mirror of
https://github.com/typecho/typecho.git
synced 2025-03-20 01:49:40 +01:00
完善编辑器
This commit is contained in:
parent
d887bb44d6
commit
b9fa6ec7a2
@ -167,8 +167,8 @@ $(document).ready(function() {
|
||||
|
||||
function attachInsertEvent (el) {
|
||||
$('.insert', el).click(function () {
|
||||
var p = $(this).parents('li');
|
||||
Typecho.insertFileToEditor(p.data('url'), p.data('image'));
|
||||
var t = $(this), p = t.parents('li');
|
||||
Typecho.insertFileToEditor(t.text(), p.data('url'), p.data('image'));
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
@ -3037,6 +3037,7 @@ else
|
||||
link: "Hyperlink <a> Ctrl+L",
|
||||
linkdescription: "enter link description here",
|
||||
linkdialog: "<p><b>Insert Hyperlink</b></p><p>http://example.com/ \"optional title\"</p>",
|
||||
linkname: null,
|
||||
|
||||
quote: "Blockquote <blockquote> Ctrl+Q",
|
||||
quoteexample: "Blockquote",
|
||||
@ -3047,6 +3048,7 @@ else
|
||||
image: "Image <img> Ctrl+G",
|
||||
imagedescription: "enter image description here",
|
||||
imagedialog: "<p><b>Insert Image</b></p><p>http://example.com/images/diagram.jpg \"optional title\"<br>Need <a href='http://www.google.com/search?q=free+image+hosting' target='_blank'>free image hosting?</a></p>",
|
||||
imagename: null,
|
||||
|
||||
olist: "Numbered List <ol> Ctrl+O",
|
||||
ulist: "Bulleted List <ul> Ctrl+U",
|
||||
@ -3113,7 +3115,15 @@ else
|
||||
if (options.helpButton) {
|
||||
options.strings.help = options.strings.help || options.helpButton.title;
|
||||
}
|
||||
var getString = function (identifier) { return options.strings[identifier] || defaultsStrings[identifier]; }
|
||||
var getString = function (identifier) {
|
||||
var string = options.strings[identifier] || defaultsStrings[identifier];
|
||||
|
||||
if ('imagename' == identifier || 'linkname' == identifier) {
|
||||
options.strings[identifier] = null;
|
||||
}
|
||||
|
||||
return string;
|
||||
}
|
||||
|
||||
idPostfix = idPostfix || "";
|
||||
|
||||
@ -4795,10 +4805,10 @@ else
|
||||
|
||||
if (!chunk.selection) {
|
||||
if (isImage) {
|
||||
chunk.selection = that.getString("imagedescription");
|
||||
chunk.selection = that.getString("imagename") || that.getString("imagedescription");
|
||||
}
|
||||
else {
|
||||
chunk.selection = that.getString("linkdescription");
|
||||
chunk.selection = that.getString("linkname") || that.getString("linkdescription");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
(function (w) {
|
||||
w.Typecho = {
|
||||
insertFileToEditor : function (url, isImage) {}
|
||||
insertFileToEditor : function (file, url, isImage) {}
|
||||
};
|
||||
})(window);
|
||||
|
||||
|
@ -105,9 +105,8 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
// 原始的插入图片和文件
|
||||
Typecho.insertFileToEditor = function (url, isImage) {
|
||||
Typecho.insertFileToEditor = function (file, url, isImage) {
|
||||
var textarea = $('#text'), sel = textarea.getSelection(),
|
||||
file = url.split('/').pop(),
|
||||
html = isImage ? '<img src="' + url + '" alt="' + file + '" />'
|
||||
: '<a href="' + url + '">' + file + '</a>',
|
||||
offset = (sel ? sel.start : 0) + html.length;
|
||||
@ -250,10 +249,12 @@ $(document).ready(function () {
|
||||
var imageButton = $('#wmd-image-button'),
|
||||
linkButton = $('#wmd-image-button');
|
||||
|
||||
Typecho.insertFileToEditor = function (url, isImage) {
|
||||
Typecho.insertFileToEditor = function (file, url, isImage) {
|
||||
var button = isImage ? imageButton : linkButton;
|
||||
|
||||
options.strings[isImage ? 'imagename' : 'linkname'] = file;
|
||||
button.trigger('click');
|
||||
|
||||
var checkDialog = setInterval(function () {
|
||||
if ($('.wmd-prompt-dialog').length > 0) {
|
||||
$('.wmd-prompt-dialog input').val(url).select();
|
||||
|
Loading…
x
Reference in New Issue
Block a user