v1.0
只读模式 group, 分享 评论更多问题 博客标签总是存在一个
This commit is contained in:
76
public/tinymce/plugins/compat3x/plugin.js
Normal file → Executable file
76
public/tinymce/plugins/compat3x/plugin.js
Normal file → Executable file
@ -9,6 +9,7 @@
|
||||
*/
|
||||
|
||||
/*global tinymce:true, console:true */
|
||||
/*eslint no-console:0, new-cap:0 */
|
||||
|
||||
/**
|
||||
* This plugin adds missing events form the 4.x API back. Not every event is
|
||||
@ -21,6 +22,9 @@
|
||||
(function(tinymce) {
|
||||
var reported;
|
||||
|
||||
function noop() {
|
||||
}
|
||||
|
||||
function log(apiCall) {
|
||||
if (!reported && window && window.console) {
|
||||
reported = true;
|
||||
@ -31,7 +35,12 @@
|
||||
function Dispatcher(target, newEventName, argsMap, defaultScope) {
|
||||
target = target || this;
|
||||
|
||||
this.add = function(callback, scope) {
|
||||
if (!newEventName) {
|
||||
this.add = this.addToTop = this.remove = this.dispatch = noop;
|
||||
return;
|
||||
}
|
||||
|
||||
this.add = function(callback, scope, prepend) {
|
||||
log('<target>.on' + newEventName + ".add(..)");
|
||||
|
||||
// Convert callback({arg1:x, arg2:x}) -> callback(arg1, arg2)
|
||||
@ -66,13 +75,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
target.on(newEventName, patchedEventCallback);
|
||||
target.on(newEventName, patchedEventCallback, prepend);
|
||||
|
||||
return patchedEventCallback;
|
||||
};
|
||||
|
||||
// Not supported to just use add
|
||||
this.addToTop = this.add;
|
||||
this.addToTop = function(callback, scope) {
|
||||
this.add(callback, scope, true);
|
||||
};
|
||||
|
||||
this.remove = function(callback) {
|
||||
return target.off(newEventName, callback);
|
||||
@ -85,10 +95,15 @@
|
||||
};
|
||||
}
|
||||
|
||||
tinymce.util.Dispatcher = Dispatcher;
|
||||
tinymce.onBeforeUnload = new Dispatcher(tinymce, "BeforeUnload");
|
||||
tinymce.onAddEditor = new Dispatcher(tinymce, "AddEditor", "editor");
|
||||
tinymce.onRemoveEditor = new Dispatcher(tinymce, "RemoveEditor", "editor");
|
||||
|
||||
tinymce.util.Cookie = {
|
||||
get: noop, getHash: noop, remove: noop, set: noop, setHash: noop
|
||||
};
|
||||
|
||||
function patchEditor(editor) {
|
||||
function patchEditorEvents(oldEventNames, argsMap) {
|
||||
tinymce.each(oldEventNames.split(" "), function(oldName) {
|
||||
@ -115,6 +130,25 @@
|
||||
return;
|
||||
}
|
||||
|
||||
function cmNoop() {
|
||||
var obj = {}, methods = 'add addMenu addSeparator collapse createMenu destroy displayColor expand focus ' +
|
||||
'getLength hasMenus hideMenu isActive isCollapsed isDisabled isRendered isSelected mark ' +
|
||||
'postRender remove removeAll renderHTML renderMenu renderNode renderTo select selectByIndex ' +
|
||||
'setActive setAriaProperty setColor setDisabled setSelected setState showMenu update';
|
||||
|
||||
log('editor.controlManager.*');
|
||||
|
||||
function _noop() {
|
||||
return cmNoop();
|
||||
}
|
||||
|
||||
tinymce.each(methods.split(' '), function(method) {
|
||||
obj[method] = _noop;
|
||||
});
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
editor.controlManager = {
|
||||
buttons: {},
|
||||
|
||||
@ -133,6 +167,26 @@
|
||||
this.buttons[name].active(state);
|
||||
}
|
||||
},
|
||||
|
||||
onAdd: new Dispatcher(),
|
||||
onPostRender: new Dispatcher(),
|
||||
|
||||
add: function(obj) {
|
||||
return obj;
|
||||
},
|
||||
createButton: cmNoop,
|
||||
createColorSplitButton: cmNoop,
|
||||
createControl: cmNoop,
|
||||
createDropMenu: cmNoop,
|
||||
createListBox: cmNoop,
|
||||
createMenuButton: cmNoop,
|
||||
createSeparator: cmNoop,
|
||||
createSplitButton: cmNoop,
|
||||
createToolbar: cmNoop,
|
||||
createToolbarGroup: cmNoop,
|
||||
destroy: noop,
|
||||
get: noop,
|
||||
setControlType: cmNoop
|
||||
};
|
||||
|
||||
patchEditorEvents("PreInit BeforeRenderUI PostRender Load Init Remove Activate Deactivate", "editor");
|
||||
@ -176,7 +230,9 @@
|
||||
settings.onPostRender = patchedPostRender;
|
||||
}
|
||||
|
||||
settings.title = tinymce.i18n.translate((editor.settings.language || "en") + "." + settings.title);
|
||||
if (settings.title) {
|
||||
settings.title = tinymce.i18n.translate((editor.settings.language || "en") + "." + settings.title);
|
||||
}
|
||||
|
||||
return originalAddButton.call(this, name, settings);
|
||||
};
|
||||
@ -193,8 +249,14 @@
|
||||
selection.onGetContent = new Dispatcher(editor, "GetContent", filterSelectionEvents(true), selection);
|
||||
selection.onBeforeSetContent = new Dispatcher(editor, "BeforeSetContent", filterSelectionEvents(true), selection);
|
||||
selection.onSetContent = new Dispatcher(editor, "SetContent", filterSelectionEvents(true), selection);
|
||||
});
|
||||
|
||||
editor.windowManager.createInstance = function(className, a, b, c, d, e) {
|
||||
editor.on('BeforeRenderUI', function() {
|
||||
var windowManager = editor.windowManager;
|
||||
|
||||
windowManager.onOpen = new Dispatcher();
|
||||
windowManager.onClose = new Dispatcher();
|
||||
windowManager.createInstance = function(className, a, b, c, d, e) {
|
||||
log("windowManager.createInstance(..)");
|
||||
|
||||
var constr = tinymce.resolve(className);
|
||||
@ -209,7 +271,7 @@
|
||||
tinymce.addI18n = function(prefix, o) {
|
||||
var I18n = tinymce.util.I18n, each = tinymce.each;
|
||||
|
||||
if (typeof(prefix) == "string" && prefix.indexOf('.') === -1) {
|
||||
if (typeof prefix == "string" && prefix.indexOf('.') === -1) {
|
||||
I18n.add(prefix, o);
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user