📄 insert-image.js
字号:
function InsertImage() {
}
InsertImage._pluginInfo = {
name : "InsertImage",
origin : "version: 1.0, by Jeroen Reijn, Hippo, http://www.hippo.nl",
version : "2.0",
developer : "Jeroen Reijn",
developer_url : "http://www.hippo.nl",
license : "Apache 2.0"
};
HTMLArea.prototype._insertImage = function(image) {
var editor = this; // for nested functions
var outparam = null;
if (typeof image == "undefined") {
image = this.getParentElement();
if (image && !/^img$/i.test(image.tagName))
image = null;
}
if (image) outparam = {
f_base : editor.config.baseHref,
f_url : HTMLArea.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"),
f_alt : image.alt,
f_border : image.border,
f_align : image.align,
f_vert : image.vspace,
f_horiz : image.hspace,
f_width : image.width,
f_height : image.height,
f_title : image.title
};
this._popupDialog("plugin://InsertImage/insert_image", function(param) {
if (!param) { // user must have pressed Cancel
return false;
}
var img = image;
if (!img) {
if (HTMLArea.is_ie) {
var sel = editor._getSelection();
var range = editor._createRange(sel);
editor._doc.execCommand("insertimage", false, param.f_url);
img = range.parentElement();
// wonder if this works...
if (img.tagName.toLowerCase() != "img") {
img = img.previousSibling;
}
} else {
img = document.createElement('img');
img.src = param.f_url;
editor.insertNodeAtSelection(img);
if (!img.tagName) {
// if the cursor is at the beginning of the document
img = range.startContainer.firstChild;
}
}
} else {
img.src = param.f_url;
}
for (var field in param) {
var value = param[field];
switch (field) {
case "f_alt" : img.alt = value; break;
case "f_border" : img.border = parseInt(value || "0"); break;
case "f_align" : img.align = value; break;
case "f_vert" : img.vspace = parseInt(value || "0"); break;
case "f_horiz" : img.hspace = parseInt(value || "0"); break;
case "f_width" : if(value > 0) img.width = value; break;
case "f_height" : if(value > 0) img.height = value; break;
case "f_title" : img.title = value; break;
}
}
}, outparam);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -