biso24-editor 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CKEditor4/.eslintrc.json +4 -0
- package/CKEditor4/CHANGES.md +2182 -0
- package/CKEditor4/LICENSE.md +1436 -0
- package/CKEditor4/README.md +39 -0
- package/CKEditor4/SECURITY.md +10 -0
- package/CKEditor4/adapters/jquery.js +158 -0
- package/CKEditor4/bender-runner.config.json +16 -0
- package/CKEditor4/build-config.js +100 -0
- package/CKEditor4/ckeditor.js +30065 -0
- package/CKEditor4/config.js +39 -0
- package/CKEditor4/contents.css +161 -0
- package/CKEditor4/lang/vi.js +475 -0
- package/CKEditor4/plugins/a11yhelp/dialogs/a11yhelp.js +143 -0
- package/CKEditor4/plugins/a11yhelp/dialogs/lang/vi.js +122 -0
- package/CKEditor4/plugins/ajax/plugin.js +241 -0
- package/CKEditor4/plugins/autocomplete/plugin.js +1655 -0
- package/CKEditor4/plugins/autocomplete/skins/default.css +38 -0
- package/CKEditor4/plugins/custompaste/plugin.js +57 -0
- package/CKEditor4/plugins/dialog/dialogDefinition.js +4 -0
- package/CKEditor4/plugins/dialog/styles/dialog.css +18 -0
- package/CKEditor4/plugins/font/lang/vi.js +14 -0
- package/CKEditor4/plugins/font/plugin.js +535 -0
- package/CKEditor4/plugins/icons.png +0 -0
- package/CKEditor4/plugins/icons_hidpi.png +0 -0
- package/CKEditor4/plugins/image2/dialogs/image2.js +558 -0
- package/CKEditor4/plugins/image2/icons/hidpi/image.png +0 -0
- package/CKEditor4/plugins/image2/icons/image.png +0 -0
- package/CKEditor4/plugins/image2/lang/vi.js +21 -0
- package/CKEditor4/plugins/image2/plugin.js +1708 -0
- package/CKEditor4/plugins/justify/icons/hidpi/justifyblock.png +0 -0
- package/CKEditor4/plugins/justify/icons/hidpi/justifycenter.png +0 -0
- package/CKEditor4/plugins/justify/icons/hidpi/justifyleft.png +0 -0
- package/CKEditor4/plugins/justify/icons/hidpi/justifyright.png +0 -0
- package/CKEditor4/plugins/justify/icons/justifyblock.png +0 -0
- package/CKEditor4/plugins/justify/icons/justifycenter.png +0 -0
- package/CKEditor4/plugins/justify/icons/justifyleft.png +0 -0
- package/CKEditor4/plugins/justify/icons/justifyright.png +0 -0
- package/CKEditor4/plugins/justify/plugin.js +266 -0
- package/CKEditor4/plugins/justify_group/icons/hidpi/justifycenter.png +0 -0
- package/CKEditor4/plugins/justify_group/icons/justifycenter.png +0 -0
- package/CKEditor4/plugins/justify_group/plugin.js +64 -0
- package/CKEditor4/plugins/lineheight/LICENSE +22 -0
- package/CKEditor4/plugins/lineheight/README.md +2 -0
- package/CKEditor4/plugins/lineheight/lang/vi.js +3 -0
- package/CKEditor4/plugins/lineheight/plugin.js +99 -0
- package/CKEditor4/plugins/lineheight/readme.txt +30 -0
- package/CKEditor4/plugins/link/dialogs/anchor.js +82 -0
- package/CKEditor4/plugins/link/dialogs/link.js +777 -0
- package/CKEditor4/plugins/link/images/anchor.png +0 -0
- package/CKEditor4/plugins/link/images/hidpi/anchor.png +0 -0
- package/CKEditor4/plugins/magicline/images/hidpi/icon-rtl.png +0 -0
- package/CKEditor4/plugins/magicline/images/hidpi/icon.png +0 -0
- package/CKEditor4/plugins/magicline/images/icon-rtl.png +0 -0
- package/CKEditor4/plugins/magicline/images/icon.png +0 -0
- package/CKEditor4/plugins/mentions/plugin.js +471 -0
- package/CKEditor4/plugins/menubutton/plugin.js +99 -0
- package/CKEditor4/plugins/pastefromword/filter/default.js +849 -0
- package/CKEditor4/plugins/pastetools/filter/common.js +445 -0
- package/CKEditor4/plugins/pastetools/filter/image.js +163 -0
- package/CKEditor4/plugins/pdffile/icons/exporttopdf.png +0 -0
- package/CKEditor4/plugins/pdffile/icons/hidpi/exporttopdf.png +0 -0
- package/CKEditor4/plugins/pdffile/plugin.js +36 -0
- package/CKEditor4/plugins/placeholder_button/plugin.js +31 -0
- package/CKEditor4/plugins/sourcedialog/dialogs/sourcedialog.js +88 -0
- package/CKEditor4/plugins/sourcedialog/icons/hidpi/sourcedialog-rtl.png +0 -0
- package/CKEditor4/plugins/sourcedialog/icons/hidpi/sourcedialog.png +0 -0
- package/CKEditor4/plugins/sourcedialog/icons/sourcedialog-rtl.png +0 -0
- package/CKEditor4/plugins/sourcedialog/icons/sourcedialog.png +0 -0
- package/CKEditor4/plugins/sourcedialog/lang/vi.js +9 -0
- package/CKEditor4/plugins/sourcedialog/plugin.js +30 -0
- package/CKEditor4/plugins/textmatch/plugin.js +331 -0
- package/CKEditor4/plugins/textwatcher/plugin.js +295 -0
- package/CKEditor4/plugins/widget/images/handle.png +0 -0
- package/CKEditor4/plugins/wordfile/icons/exporttoword.png +0 -0
- package/CKEditor4/plugins/wordfile/icons/hidpi/exporttoword.png +0 -0
- package/CKEditor4/plugins/wordfile/icons/hidpi/importfromword.png +0 -0
- package/CKEditor4/plugins/wordfile/icons/importfromword.png +0 -0
- package/CKEditor4/plugins/wordfile/plugin.js +161 -0
- package/CKEditor4/skins/moono-lisa/dialog.css +685 -0
- package/CKEditor4/skins/moono-lisa/dialog_ie.css +721 -0
- package/CKEditor4/skins/moono-lisa/dialog_ie8.css +746 -0
- package/CKEditor4/skins/moono-lisa/dialog_iequirks.css +724 -0
- package/CKEditor4/skins/moono-lisa/editor.css +1551 -0
- package/CKEditor4/skins/moono-lisa/editor_gecko.css +1556 -0
- package/CKEditor4/skins/moono-lisa/editor_ie.css +1588 -0
- package/CKEditor4/skins/moono-lisa/editor_ie8.css +1639 -0
- package/CKEditor4/skins/moono-lisa/editor_iequirks.css +1632 -0
- package/CKEditor4/skins/moono-lisa/icons.png +0 -0
- package/CKEditor4/skins/moono-lisa/icons_hidpi.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/arrow.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/close.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/hidpi/close.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/hidpi/lock-open.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/hidpi/lock.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/hidpi/refresh.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/lock-open.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/lock.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/refresh.png +0 -0
- package/CKEditor4/skins/moono-lisa/images/spinner.gif +0 -0
- package/CKEditor4/skins/moono-lisa/readme.md +46 -0
- package/CKEditor4/styles.js +136 -0
- package/CKEditor4/vendor/promise.js +385 -0
- package/README.md +3 -0
- package/package.json +9 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* CKEditor 4 LTS ("Long Term Support") is available under the terms of the Extended Support Model.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
(function () {
|
|
9
|
+
CKEDITOR._.mentions = {
|
|
10
|
+
cache: {},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var MARKER = '@',
|
|
14
|
+
MIN_CHARS = 2,
|
|
15
|
+
cache = CKEDITOR._.mentions.cache;
|
|
16
|
+
|
|
17
|
+
CKEDITOR.plugins.add('mentions', {
|
|
18
|
+
requires: 'autocomplete,textmatch,ajax',
|
|
19
|
+
instances: [],
|
|
20
|
+
init: function (editor) {
|
|
21
|
+
var self = this;
|
|
22
|
+
|
|
23
|
+
editor.on('instanceReady', function () {
|
|
24
|
+
CKEDITOR.tools.array.forEach(editor.config.mentions || [], function (config) {
|
|
25
|
+
self.instances.push(new Mentions(editor, config));
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
},
|
|
29
|
+
isSupportedEnvironment: function (editor) {
|
|
30
|
+
return editor.plugins.autocomplete.isSupportedEnvironment(editor);
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The [Mentions](https://ckeditor.com/cke4/addon/mentions) plugin allows you to type a marker character and get suggested values for the
|
|
36
|
+
* text matches so that you do not have to write it on your own.
|
|
37
|
+
*
|
|
38
|
+
* The recommended way to add the mentions feature to an editor is by setting the {@link CKEDITOR.config#mentions config.mentions} option:
|
|
39
|
+
*
|
|
40
|
+
* ```javascript
|
|
41
|
+
* // Passing mentions configuration when creating the editor.
|
|
42
|
+
* CKEDITOR.replace( 'editor', {
|
|
43
|
+
* mentions: [ { feed: ['Anna', 'Thomas', 'John'], minChars: 0 } ]
|
|
44
|
+
* } );
|
|
45
|
+
*
|
|
46
|
+
* // Simple usage with the CKEDITOR.config.mentions property.
|
|
47
|
+
* CKEDITOR.config.mentions = [ { feed: ['Anna', 'Thomas', 'John'], minChars: 0 } ];
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* @class CKEDITOR.plugins.mentions
|
|
51
|
+
* @since 4.10.0
|
|
52
|
+
* @constructor Creates a new instance of mentions and attaches it to the editor.
|
|
53
|
+
* @param {CKEDITOR.editor} editor The editor to watch.
|
|
54
|
+
* @param {CKEDITOR.plugins.mentions.configDefinition} config Configuration object keeping information about how to instantiate the mentions plugin.
|
|
55
|
+
*/
|
|
56
|
+
function Mentions(editor, config) {
|
|
57
|
+
var feed = config.feed;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Indicates that a mentions instance is case-sensitive for simple items feed, i.e. an array feed.
|
|
61
|
+
*
|
|
62
|
+
* **Note:** This will take no effect on feeds using a callback or URLs, as in this case the results are expected to
|
|
63
|
+
* be already filtered.
|
|
64
|
+
*
|
|
65
|
+
* @property {Boolean} [caseSensitive=false]
|
|
66
|
+
* @readonly
|
|
67
|
+
*/
|
|
68
|
+
this.caseSensitive = config.caseSensitive;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The character that should trigger autocompletion.
|
|
72
|
+
*
|
|
73
|
+
* @property {String} [marker='@']
|
|
74
|
+
* @readonly
|
|
75
|
+
*/
|
|
76
|
+
this.marker = config.hasOwnProperty('marker') ? config.marker : MARKER;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The number of characters that should follow the marker character in order to trigger the mentions feature.
|
|
80
|
+
*
|
|
81
|
+
* @property {Number} [minChars=2]
|
|
82
|
+
* @readonly
|
|
83
|
+
*/
|
|
84
|
+
this.minChars = config.minChars !== null && config.minChars !== undefined ? config.minChars : MIN_CHARS;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* The pattern used to match queries.
|
|
88
|
+
*
|
|
89
|
+
* The default pattern matches words with the query including the {@link #marker config.marker} and {@link #minChars config.minChars} properties.
|
|
90
|
+
*
|
|
91
|
+
* ```javascript
|
|
92
|
+
* // Match only words starting with "a".
|
|
93
|
+
* var pattern = /^a+\w*$/;
|
|
94
|
+
* ```
|
|
95
|
+
*
|
|
96
|
+
* @property {RegExp} pattern
|
|
97
|
+
* @readonly
|
|
98
|
+
*/
|
|
99
|
+
this.pattern = config.pattern || createPattern(this.marker, this.minChars);
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Indicates if the URL feed responses will be cached.
|
|
103
|
+
*
|
|
104
|
+
* The cache is based on the URL request and is shared between all mentions instances (including different editors).
|
|
105
|
+
*
|
|
106
|
+
* @property {Boolean} [cache=true]
|
|
107
|
+
* @readonly
|
|
108
|
+
*/
|
|
109
|
+
this.cache = config.cache !== undefined ? config.cache : true;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete#followingSpace
|
|
113
|
+
* @property {Boolean} [followingSpace]
|
|
114
|
+
* @readonly
|
|
115
|
+
* @since 4.20.0
|
|
116
|
+
*/
|
|
117
|
+
this.followingSpace = config.followingSpace;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @inheritdoc CKEDITOR.plugins.mentions.configDefinition#throttle
|
|
121
|
+
* @property {Number} [throttle=200]
|
|
122
|
+
* @readonly
|
|
123
|
+
*/
|
|
124
|
+
this.throttle = config.throttle !== undefined ? config.throttle : 200;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* {@link CKEDITOR.plugins.autocomplete Autocomplete} instance used by the mentions feature to implement autocompletion logic.
|
|
128
|
+
*
|
|
129
|
+
* @property {CKEDITOR.plugins.autocomplete}
|
|
130
|
+
* @private
|
|
131
|
+
*/
|
|
132
|
+
this._autocomplete = new CKEDITOR.plugins.autocomplete(editor, {
|
|
133
|
+
textTestCallback: getTextTestCallback(this.marker, this.minChars, this.pattern),
|
|
134
|
+
dataCallback: getDataCallback(feed, this),
|
|
135
|
+
itemTemplate: config.itemTemplate,
|
|
136
|
+
outputTemplate: config.outputTemplate,
|
|
137
|
+
throttle: this.throttle,
|
|
138
|
+
itemsLimit: config.itemsLimit,
|
|
139
|
+
followingSpace: this.followingSpace,
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
Mentions.prototype = {
|
|
144
|
+
/**
|
|
145
|
+
* Destroys the mentions instance.
|
|
146
|
+
*
|
|
147
|
+
* The view element and event listeners will be removed from the DOM.
|
|
148
|
+
*/
|
|
149
|
+
destroy: function () {
|
|
150
|
+
this._autocomplete.destroy();
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
function createPattern(marker, minChars) {
|
|
155
|
+
// Match also diacritic characters (#2491).
|
|
156
|
+
var pattern = '\\' + marker + '[_a-zA-Z0-9À-ž]';
|
|
157
|
+
|
|
158
|
+
if (minChars) {
|
|
159
|
+
pattern += '{' + minChars + ',}';
|
|
160
|
+
} else {
|
|
161
|
+
pattern += '*';
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
pattern += '$';
|
|
165
|
+
|
|
166
|
+
return new RegExp(pattern);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function getTextTestCallback(marker, minChars, pattern) {
|
|
170
|
+
return function (range) {
|
|
171
|
+
if (!range.collapsed) {
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return CKEDITOR.plugins.textMatch.match(range, matchCallback);
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
function matchCallback(text, offset) {
|
|
179
|
+
var match = text.slice(0, offset).match(pattern);
|
|
180
|
+
|
|
181
|
+
if (!match) {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Do not proceed if a query is a part of word.
|
|
186
|
+
var prevChar = text[match.index - 1];
|
|
187
|
+
if (prevChar !== undefined && !prevChar.match(/\s+/)) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
start: match.index,
|
|
193
|
+
end: offset,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function getDataCallback(feed, mentions) {
|
|
199
|
+
return function (matchInfo, callback) {
|
|
200
|
+
var query = matchInfo.query;
|
|
201
|
+
|
|
202
|
+
// We are removing marker here to give clean query result for the endpoint callback.
|
|
203
|
+
if (mentions.marker) {
|
|
204
|
+
query = query.substring(mentions.marker.length);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (CKEDITOR.tools.array.isArray(feed)) {
|
|
208
|
+
createArrayFeed();
|
|
209
|
+
} else if (typeof feed === 'string') {
|
|
210
|
+
createUrlFeed();
|
|
211
|
+
} else {
|
|
212
|
+
feed(
|
|
213
|
+
{
|
|
214
|
+
query: query,
|
|
215
|
+
marker: mentions.marker,
|
|
216
|
+
},
|
|
217
|
+
resolveCallbackData,
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function createArrayFeed() {
|
|
222
|
+
var data = indexArrayFeed(feed).filter(function (item) {
|
|
223
|
+
var itemName = item.name;
|
|
224
|
+
|
|
225
|
+
if (!mentions.caseSensitive) {
|
|
226
|
+
itemName = itemName.toLowerCase();
|
|
227
|
+
query = query.toLowerCase();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
return itemName.indexOf(query) === 0;
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
resolveCallbackData(data);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function indexArrayFeed(feed) {
|
|
237
|
+
var index = 1;
|
|
238
|
+
return CKEDITOR.tools.array.reduce(
|
|
239
|
+
feed,
|
|
240
|
+
function (current, name) {
|
|
241
|
+
current.push({ name: name, id: index++ });
|
|
242
|
+
return current;
|
|
243
|
+
},
|
|
244
|
+
[],
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function createUrlFeed() {
|
|
249
|
+
var encodedUrl = new CKEDITOR.template(feed).output({ encodedQuery: encodeURIComponent(query) });
|
|
250
|
+
|
|
251
|
+
if (mentions.cache && cache[encodedUrl]) {
|
|
252
|
+
return resolveCallbackData(cache[encodedUrl]);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
CKEDITOR.ajax.load(encodedUrl, function (data) {
|
|
256
|
+
var items = JSON.parse(data);
|
|
257
|
+
|
|
258
|
+
// Cache URL responses for performance improvement (#1969).
|
|
259
|
+
if (mentions.cache && items !== null) {
|
|
260
|
+
cache[encodedUrl] = items;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
resolveCallbackData(items);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
function resolveCallbackData(data) {
|
|
268
|
+
if (!data) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// We don't want to change item data, so lets create new one.
|
|
273
|
+
var newData = CKEDITOR.tools.array.map(data, function (item) {
|
|
274
|
+
var name = mentions.marker + item.name;
|
|
275
|
+
return CKEDITOR.tools.object.merge(item, { name: name });
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
callback(newData);
|
|
279
|
+
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
CKEDITOR.plugins.mentions = Mentions;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* A list of mentions configuration objects.
|
|
287
|
+
*
|
|
288
|
+
* For each configuration object a new {@link CKEDITOR.plugins.mentions mentions} plugin instance will be created and attached to the editor.
|
|
289
|
+
*
|
|
290
|
+
* ```javascript
|
|
291
|
+
* config.mentions = [
|
|
292
|
+
* { feed: [ 'Anna', 'Thomas', 'Jack' ], minChars: 0 },
|
|
293
|
+
* { feed: backendApiFunction, marker: '#' },
|
|
294
|
+
* { feed: '/users?query={encodedQuery}', marker: '$' }
|
|
295
|
+
* ];
|
|
296
|
+
*
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @cfg {CKEDITOR.plugins.mentions.configDefinition[]} [mentions]
|
|
300
|
+
* @since 4.10.0
|
|
301
|
+
* @member CKEDITOR.config
|
|
302
|
+
*/
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Abstract class describing the definition of a {@link CKEDITOR.plugins.mentions mentions} plugin configuration.
|
|
306
|
+
*
|
|
307
|
+
* This virtual class illustrates the properties that the developers can use to define and create
|
|
308
|
+
* a mentions configuration definition.
|
|
309
|
+
* The mentions definition object represents an object as a set of properties defining a mentions
|
|
310
|
+
* data feed and its optional parameters.
|
|
311
|
+
*
|
|
312
|
+
* Simple usage:
|
|
313
|
+
*
|
|
314
|
+
* ```javascript
|
|
315
|
+
* var definition = { feed: ['Anna', 'Thomas', 'John'], minChars: 0 };
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* @class CKEDITOR.plugins.mentions.configDefinition
|
|
319
|
+
* @abstract
|
|
320
|
+
* @since 4.10.0
|
|
321
|
+
*/
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* The feed of items to be displayed in the mentions plugin.
|
|
325
|
+
*
|
|
326
|
+
* Essential option which should be configured to create a correct mentions configuration definition.
|
|
327
|
+
* There are three different ways to create a data feed:
|
|
328
|
+
*
|
|
329
|
+
* * A simple array of text matches as a synchronous data feed.
|
|
330
|
+
* * A backend URL string responding with a list of items in the JSON format. This method utilizes an asynchronous data feed.
|
|
331
|
+
* * A function allowing to use an asynchronous callback to customize the data source.
|
|
332
|
+
* Gives the freedom to use any data source depending on your implementation.
|
|
333
|
+
*
|
|
334
|
+
* # An array of text matches
|
|
335
|
+
* The easiest way to configure the data feed is to provide an array of text matches.
|
|
336
|
+
* The mentions plugin will use a synchronous data feed and create item IDs by itself.
|
|
337
|
+
* The biggest advantage of this method is its simplicity, although it is limited to a synchronous data feed.
|
|
338
|
+
* Please see two other methods if you require more complex techniques to fetch the text matches.
|
|
339
|
+
*
|
|
340
|
+
*```javascript
|
|
341
|
+
* var definition = { feed: ['Anna', 'Thomas', 'John'], minChars: 0 };
|
|
342
|
+
* ```
|
|
343
|
+
*
|
|
344
|
+
* By default query matching for an array feed is case insensitive.
|
|
345
|
+
* You can change this behavior by setting the {@link #caseSensitive caseSensitive} property to `true`.
|
|
346
|
+
*
|
|
347
|
+
* # A backend URL string
|
|
348
|
+
* You can provide a backend URL string which will be used to fetch text matches from a custom endpoint service.
|
|
349
|
+
* Each time the user types matching text into an editor, your backend service will be queried for text matches.
|
|
350
|
+
* An Ajax URL request should response with an array of matches in the JSON format. A URL response will appear in the mentions dropdown.
|
|
351
|
+
*
|
|
352
|
+
* A backend URL string features the special `encodedQuery` variable replaced with a mentions query.
|
|
353
|
+
* The `encodedQuery` variable allows you to create a customized URL which can be both RESTful API compliant or any other
|
|
354
|
+
* URL which suits your needs. E.g. for the query `@anna` and the given URL `/users?name={encodedQuery}` your endpoint
|
|
355
|
+
* service will be queried with `/users?name=anna`.
|
|
356
|
+
*
|
|
357
|
+
* ```javascript
|
|
358
|
+
* var definition = { feed: '/users?query={encodedQuery}' };
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* To avoid multiple HTTP requests to your endpoint service, each HTTP response is cached by default and shared globally.
|
|
362
|
+
* See the {@link #cache cache} property for more details.
|
|
363
|
+
*
|
|
364
|
+
* # Function feed
|
|
365
|
+
* This method is recommended for advanced users who would like to take full control of the data feed.
|
|
366
|
+
* It allows you to provide the data feed as a function that accepts two parameters: `options` and `callback`.
|
|
367
|
+
* The provided function will be called every time the user types matching text into an editor.
|
|
368
|
+
*
|
|
369
|
+
* The `options` object contains information about the current query and a {@link #marker marker}.
|
|
370
|
+
*
|
|
371
|
+
* ```javascript
|
|
372
|
+
* { query: 'anna', marker: '@' }
|
|
373
|
+
* ```
|
|
374
|
+
*
|
|
375
|
+
* The `callback` argument should be used to pass an array of text match items into the mentions instance.
|
|
376
|
+
*
|
|
377
|
+
* ```javascript
|
|
378
|
+
* callback( [ { id: 1, name: 'anna' }, { id: 2, name: 'annabelle' } ] );
|
|
379
|
+
* ```
|
|
380
|
+
*
|
|
381
|
+
* Depending on your use case, you can use this code as an example boilerplate to create your own function feed:
|
|
382
|
+
*
|
|
383
|
+
* ```javascript
|
|
384
|
+
* var definition = {
|
|
385
|
+
* feed: function( opts, callback ) {
|
|
386
|
+
* var xhr = new XMLHttpRequest();
|
|
387
|
+
*
|
|
388
|
+
* xhr.onreadystatechange = function() {
|
|
389
|
+
* if ( xhr.readyState == 4 ) {
|
|
390
|
+
* if ( xhr.status == 200 ) {
|
|
391
|
+
* callback( JSON.parse( this.responseText ) );
|
|
392
|
+
* } else {
|
|
393
|
+
* callback( [] );
|
|
394
|
+
* }
|
|
395
|
+
* }
|
|
396
|
+
* }
|
|
397
|
+
*
|
|
398
|
+
* xhr.open( 'GET', '/users?name=' + opts.query );
|
|
399
|
+
* xhr.send();
|
|
400
|
+
* }
|
|
401
|
+
* };
|
|
402
|
+
* ```
|
|
403
|
+
*
|
|
404
|
+
* **Other details**
|
|
405
|
+
*
|
|
406
|
+
* When using the asynchronous method, i.e. a backend URL string or a function,
|
|
407
|
+
* you should provide correct object structure containing a unique item ID and a name.
|
|
408
|
+
*
|
|
409
|
+
* ```javascript
|
|
410
|
+
* // Example of expected results from the backend API.
|
|
411
|
+
* // The `firstName` and `lastName` properties are optional.
|
|
412
|
+
* [
|
|
413
|
+
* { id: 1, name: 'anna87', firstName: 'Anna', lastName: 'Doe' },
|
|
414
|
+
* { id: 2, name: 'tho-mass', firstName: 'Thomas', lastName: 'Doe' },
|
|
415
|
+
* { id: 3, name: 'ozzy', firstName: 'John', lastName: 'Doe' }
|
|
416
|
+
* ]
|
|
417
|
+
* ```
|
|
418
|
+
*
|
|
419
|
+
* @property {String/String[]/Function} feed
|
|
420
|
+
*/
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete.configDefinition#itemTemplate
|
|
424
|
+
* @property {String} [itemTemplate]
|
|
425
|
+
*/
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete.configDefinition#outputTemplate
|
|
429
|
+
* @property {String} [outputTemplate]
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete.configDefinition#throttle
|
|
434
|
+
* @property {Number} [throttle=200]
|
|
435
|
+
*/
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* @inheritdoc CKEDITOR.plugins.mentions#marker
|
|
439
|
+
* @property {String} [marker='@']
|
|
440
|
+
*/
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* @inheritdoc CKEDITOR.plugins.mentions#minChars
|
|
444
|
+
* @property {Number} [minChars=2]
|
|
445
|
+
*/
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* @inheritdoc CKEDITOR.plugins.mentions#caseSensitive
|
|
449
|
+
* @property {Boolean} [caseSensitive=false]
|
|
450
|
+
*/
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* @inheritdoc CKEDITOR.plugins.mentions#cache
|
|
454
|
+
* @property {Boolean} [cache=true]
|
|
455
|
+
*/
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* @inheritdoc CKEDITOR.plugins.mentions#pattern
|
|
459
|
+
* @property {RegExp} pattern
|
|
460
|
+
*/
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete.configDefinition#itemsLimit
|
|
464
|
+
* @property {Number} [itemsLimit]
|
|
465
|
+
*/
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* @inheritdoc CKEDITOR.plugins.autocomplete#followingSpace
|
|
469
|
+
* @property {Boolean} [followingSpace]
|
|
470
|
+
*/
|
|
471
|
+
})();
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license Copyright (c) 2003-2022, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
CKEDITOR.plugins.add('menubutton', {
|
|
7
|
+
requires: 'button,menu',
|
|
8
|
+
onLoad: function () {
|
|
9
|
+
var clickFn = function (editor) {
|
|
10
|
+
var _ = this._,
|
|
11
|
+
menu = _.menu;
|
|
12
|
+
|
|
13
|
+
// Do nothing if this button is disabled.
|
|
14
|
+
if (_.state === CKEDITOR.TRISTATE_DISABLED) return;
|
|
15
|
+
|
|
16
|
+
if (_.on && menu) {
|
|
17
|
+
menu.hide();
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
_.previousState = _.state;
|
|
22
|
+
|
|
23
|
+
// Check if we already have a menu for it, otherwise just create it.
|
|
24
|
+
if (!menu) {
|
|
25
|
+
menu = _.menu = new CKEDITOR.menu(editor, {
|
|
26
|
+
panel: {
|
|
27
|
+
className: 'cke_menu_panel',
|
|
28
|
+
attributes: { 'aria-label': editor.lang.common.options },
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
menu.onHide = CKEDITOR.tools.bind(function () {
|
|
33
|
+
var modes = this.command ? editor.getCommand(this.command).modes : this.modes;
|
|
34
|
+
this.setState(!modes || modes[editor.mode] ? _.previousState : CKEDITOR.TRISTATE_DISABLED);
|
|
35
|
+
_.on = 0;
|
|
36
|
+
}, this);
|
|
37
|
+
|
|
38
|
+
// Initialize the menu items at this point.
|
|
39
|
+
if (this.onMenu) menu.addListener(this.onMenu);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
this.setState(CKEDITOR.TRISTATE_ON);
|
|
43
|
+
_.on = 1;
|
|
44
|
+
|
|
45
|
+
// This timeout is needed to give time for the panel get focus
|
|
46
|
+
// when JAWS is running. (https://dev.ckeditor.com/ticket/9842)
|
|
47
|
+
setTimeout(function () {
|
|
48
|
+
menu.show(CKEDITOR.document.getById(_.id), 4);
|
|
49
|
+
}, 0);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @class
|
|
54
|
+
* @extends CKEDITOR.ui.button
|
|
55
|
+
* @todo
|
|
56
|
+
*/
|
|
57
|
+
CKEDITOR.ui.menuButton = CKEDITOR.tools.createClass({
|
|
58
|
+
base: CKEDITOR.ui.button,
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Creates a menuButton class instance.
|
|
62
|
+
*
|
|
63
|
+
* @constructor
|
|
64
|
+
* @param Object definition
|
|
65
|
+
* @todo
|
|
66
|
+
*/
|
|
67
|
+
$: function (definition) {
|
|
68
|
+
// We don't want the panel definition in this object.
|
|
69
|
+
delete definition.panel;
|
|
70
|
+
|
|
71
|
+
this.base(definition);
|
|
72
|
+
|
|
73
|
+
this.hasArrow = 'menu';
|
|
74
|
+
|
|
75
|
+
this.click = clickFn;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
statics: {
|
|
79
|
+
handler: {
|
|
80
|
+
create: function (definition) {
|
|
81
|
+
return new CKEDITOR.ui.menuButton(definition);
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
beforeInit: function (editor) {
|
|
88
|
+
editor.ui.addHandler(CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Button UI element.
|
|
94
|
+
*
|
|
95
|
+
* @readonly
|
|
96
|
+
* @property {String} [='menubutton']
|
|
97
|
+
* @member CKEDITOR
|
|
98
|
+
*/
|
|
99
|
+
CKEDITOR.UI_MENUBUTTON = 'menubutton';
|