-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathplugin.js
More file actions
executable file
·78 lines (64 loc) · 2.2 KB
/
plugin.js
File metadata and controls
executable file
·78 lines (64 loc) · 2.2 KB
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
CKEDITOR.plugins.add('tweetabletext', {
icons: 'tweetabletext',
beforeInit: function () {
},
init: function(editor) {
editor.addCommand('tweetabletext', new CKEDITOR.dialogCommand('tweetabletextDialog'));
editor.addCommand('untweetabletext', new CKEDITOR.unlinkCommand());
editor.ui.addButton('TweetableText', {
label: 'Insert TweetableText',
command: 'tweetabletext',
toolbar: 'insert'
});
if (editor.contextMenu) {
editor.addMenuGroup('tweetabletextGroup');
editor.addMenuItems({
tweetabletextItem: {
label: 'Edit TweetableText',
icon: this.path + 'icons/tweetabletext.png',
command: 'tweetabletext',
group: 'tweetabletextGroup'
},
unTweetabletextItem: {
label: 'Remove TweetableText',
icon: this.path + 'icons/tweetabletext.png',
command: 'untweetabletext',
group: 'tweetabletextGroup'
},
});
editor.contextMenu.addListener(function(element) {
if (element.getAttribute('class') === 'tweetabletext') {
return { tweetabletextItem: CKEDITOR.TRISTATE_OFF, unTweetabletextItem: CKEDITOR.TRISTATE_OFF,};
}
});
}
CKEDITOR.dialog.add('tweetabletextDialog', this.path + 'dialogs/tweetabletext.js');
if (typeof editor.config.contentsCss === 'object') {
editor.config.contentsCss.push(CKEDITOR.getUrl(this.path + 'css/tweetabletext.css'));
}
}
});
// This part was getting from http://ckeditor.com/addon/link.
CKEDITOR.unlinkCommand = function() {};
CKEDITOR.unlinkCommand.prototype = {
exec: function(editor) {
var style = new CKEDITOR.style({
element: 'a',
type: CKEDITOR.STYLE_INLINE,
alwaysRemoveElement: 1
});
editor.removeStyle(style);
},
refresh: function(editor, path) {
var element = path.lastElement && path.lastElement.getAscendant('a', true);
if (element && element.getName() === 'a' && element.getAttribute('href') && element.getChildCount()) {
this.setState(CKEDITOR.TRISTATE_OFF);
}
else {
this.setState(CKEDITOR.TRISTATE_DISABLED);
}
},
contextSensitive: 1,
startDisabled: 1,
requiredContent: 'a[href]'
};