-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplugin.js
104 lines (94 loc) · 2.82 KB
/
plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
CKEDITOR.plugins.add('smethods', {
init: function(){
CKEDITOR.tools.extend(CKEDITOR.dom.element.prototype, {
matchClass: function(regexp){
return this.hasAttribute('class') && this.getAttribute('class').match(regexp);
},
rmClass: function(remove){
remove = remove instanceof RegExp ? this.matchClass(remove) : remove;
if (remove)
for (var i in remove)
this.removeClass(remove[i]);
return this;
},
toggleClass: function(name, remove){
if (remove && !this.hasClass(name))
this.rmClass(remove);
if (name)
this.hasClass(name) ? this.removeClass(name) : this.addClass(name);
return this;
},
toggleAttribute: function(name, value){
if (value)
this.getAttribute(name) == value ? this.removeAttribute(name) : this.setAttribute(name, value);
else
this.hasAttribute(name) ? this.removeAttribute(name) : this.setAttribute(name, '');
return this;
},
matchAttribute: function(regexp){
return CKEDITOR.tools.objectKeys(this.getAttributes()).join().match(regexp);
},
realName: function(){
return this.data('cke-real-element-type') || this.getName();
},
isReal: function(){
for (var i in arguments)
if (arguments[i] == this.realName())
return true;
return false;
},
findParent: function(selector){
return this.getParents(true).find(function(node){
if (node.$.matches(selector))
return node;
});
}
});
CKEDITOR.tools.extend(CKEDITOR.dialog.prototype, {
getCurrentPageId: function(){
return this._.currentTabId;
}
});
CKEDITOR.tools.extend(CKEDITOR.ui.dialog.uiElement.prototype, {
getValues: function(){
var values = [];
if (this.items)
for (var i in this.items){
var value = this.items[i];
value = value[1] ? value[1] : CKEDITOR.tools.isArray(value[0]) ? value[0][0] : value[0];
if (value)
values.push(value);
}
return values;
},
hasFocus: function(){
return this.getDialog()._.currentFocusIndex == this.focusIndex;
},
toggleState: function(){
this.isEnabled() ? this.disable() : this.enable();
},
isOnCurrentPage: function(){
var dialog = this.getDialog();
return !!dialog.getContentElement(dialog.getCurrentPageId(), this.id);
}
});
CKEDITOR.tools.extend(CKEDITOR.tools.array, {
without: function(array, ...values){
return CKEDITOR.tools.array.filter(array, function(value){
return !CKEDITOR.tools.search(values, value) && value;
});
}
});
}
});
CKEDITOR.tools.extend(CKEDITOR.editor.prototype, {
addCommands: function(definitions){
for (var commandName in definitions)
this.addCommand(commandName, definitions[commandName]);
}
});
CKEDITOR.tools.extend(CKEDITOR.ui.prototype, {
addMenuButton: function(name, definition){
this.add(name, CKEDITOR.UI_MENUBUTTON, definition);
}
});