📄 emoticon.js
字号:
// Emoticon Plugin for HTMLArea-3.0
function Emoticon(editor) {
this.editor = editor;
var cfg = editor.config;
var tt = Emoticon.I18N;
var bl = Emoticon.btnList;
var self = this;
// register the toolbar buttons provided by this plugin
var toolbar = [];
for (var i in bl) {
var btn = bl[i];
if (!btn) {
toolbar.push("separator");
} else {
var id = "EM-" + btn[0];
cfg.registerButton(id, tt[id], editor.imgURL("emoticon.gif", "Emoticon"), false,
function(editor, id) {
// dispatch button press event
self.buttonPress(editor, id);
}, null);
toolbar.push(id);
}
}
for (var i in toolbar) {
cfg.toolbar[0].push(toolbar[i]);
}
};
Emoticon._pluginInfo = {
name : "Emoticon",
version : "1.0",
developer : "Bruce Ritchie",
developer_url : "http://www.jivesoftware.com/",
c_owner : "Jive Software",
sponsor : "Jive Software",
sponsor_url : "http://www.jivesoftware.com/",
license : "htmlArea"
};
Emoticon.btnList = [
["emoticon"]
];
Emoticon.prototype.buttonPress = function(editor, id) {
switch (id) {
case "EM-emoticon":
Emoticon.editor = editor;
Emoticon.init = true;
this._createEmoticon();
}
};
Emoticon.prototype._createEmoticon = function(emoticon) {
var outparam = null;
var editor = this.editor;
if (typeof emoticon == "undefined") {
emoticon = editor.getParentElement();
if (emoticon && !/^img$/i.test(emoticon.tagName))
emoticon = null;
}
if (emoticon) outparam = {
f_url : emoticon.getAttribute("src")
};
var uiurl = _editor_url + "plugins/Emoticon/emoticon-ui.jsp";
Dialog(uiurl, function(param) {
// user must have pressed Cancel
if (!param) {
return false;
}
var img = emoticon;
if (!img) {
var html = "<img class='emoticon' src='" + param.f_url + "' alt='' />";
editor.focusEditor();
var sel = editor._getSelection();
var range = editor._createRange(sel);
if (HTMLArea.is_ie) {
range.pasteHTML(html);
}
else {
// construct a new document fragment with the given HTML
var fragment = editor._doc.createDocumentFragment();
var div = editor._doc.createElement("div");
div.innerHTML = html;
while (div.firstChild) {
// the following call also removes the node from div
fragment.appendChild(div.firstChild);
}
// this also removes the selection
var node = editor.insertNodeAtSelection(fragment);
}
}
else {
img.src = param.f_url;
img.className = 'emoticon';
}
}, outparam);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -