tinymce-rails 4.4.1 → 4.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/source/tinymce/tinymce.js +406 -197
  3. data/lib/tinymce/rails/version.rb +2 -2
  4. data/vendor/assets/javascripts/tinymce/plugins/codesample/plugin.js +1 -1
  5. data/vendor/assets/javascripts/tinymce/plugins/contextmenu/plugin.js +1 -1
  6. data/vendor/assets/javascripts/tinymce/plugins/fullscreen/plugin.js +1 -1
  7. data/vendor/assets/javascripts/tinymce/plugins/importcss/plugin.js +1 -1
  8. data/vendor/assets/javascripts/tinymce/plugins/lists/plugin.js +1 -1
  9. data/vendor/assets/javascripts/tinymce/plugins/paste/plugin.js +1 -1
  10. data/vendor/assets/javascripts/tinymce/plugins/spellchecker/plugin.js +1 -1
  11. data/vendor/assets/javascripts/tinymce/plugins/table/plugin.js +2 -2
  12. data/vendor/assets/javascripts/tinymce/plugins/template/plugin.js +1 -1
  13. data/vendor/assets/javascripts/tinymce/themes/inlite/theme.js +1 -1
  14. data/vendor/assets/javascripts/tinymce/tinymce.js +14 -13
  15. metadata +2 -55
  16. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/atomic.js +0 -5
  17. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-atomic.js +0 -1491
  18. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-browser.js +0 -1491
  19. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-demo.js +0 -1491
  20. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/bootstrap-prod.js +0 -1491
  21. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/browser.js +0 -10
  22. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/demo.js +0 -8
  23. data/vendor/assets/javascripts/tinymce/themes/inlite/config/bolt/prod.js +0 -5
  24. data/vendor/assets/javascripts/tinymce/themes/inlite/config/dent/depend.js +0 -21
  25. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/bootstrap.js +0 -1526
  26. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/compile/theme.js +0 -1594
  27. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.js +0 -1679
  28. data/vendor/assets/javascripts/tinymce/themes/inlite/scratch/inline/theme.raw.js +0 -1679
  29. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/css/demo.css +0 -25
  30. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/html/demo.html +0 -69
  31. data/vendor/assets/javascripts/tinymce/themes/inlite/src/demo/js/tinymce/inlite/Demo.js +0 -28
  32. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/Theme.js +0 -150
  33. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Arr.js +0 -22
  34. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Bookmark.js +0 -130
  35. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Unlink.js +0 -84
  36. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/alien/Uuid.js +0 -34
  37. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Actions.js +0 -106
  38. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Convert.js +0 -37
  39. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/ElementMatcher.js +0 -47
  40. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Layout.js +0 -95
  41. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Matcher.js +0 -39
  42. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/Measure.js +0 -61
  43. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/PredicateId.js +0 -32
  44. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SelectionMatcher.js +0 -55
  45. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/SkinLoader.js +0 -45
  46. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/core/UrlType.js +0 -27
  47. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Conversions.js +0 -31
  48. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/file/Picker.js +0 -40
  49. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Buttons.js +0 -80
  50. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Forms.js +0 -102
  51. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Panel.js +0 -218
  52. data/vendor/assets/javascripts/tinymce/themes/inlite/src/main/js/tinymce/inlite/ui/Toolbar.js +0 -126
  53. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/ArrTest.js +0 -9
  54. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/alien/UuidTest.js +0 -10
  55. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/ConvertTest.js +0 -12
  56. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/MatcherTest.js +0 -51
  57. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/atomic/core/UrlTypeTest.js +0 -33
  58. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/ThemeTest.js +0 -202
  59. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/BookmarkTest.js +0 -65
  60. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/alien/UnlinkTest.js +0 -38
  61. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ActionsTest.js +0 -177
  62. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/ElementMatcher.js +0 -69
  63. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/LayoutTest.js +0 -118
  64. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/MeasureTest.js +0 -62
  65. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/PredicateIdTest.js +0 -26
  66. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/core/SelectionMatcherTest.js +0 -76
  67. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/ConversionsTest.js +0 -41
  68. data/vendor/assets/javascripts/tinymce/themes/inlite/src/test/js/browser/file/SelectionMatcher.js +0 -55
@@ -1,1594 +0,0 @@
1
- /*jsc
2
- ["tinymce/inlite/Theme","global!tinymce.ThemeManager","global!tinymce.util.Delay","tinymce/inlite/ui/Panel","tinymce/inlite/ui/Buttons","tinymce/inlite/core/SkinLoader","tinymce/inlite/core/SelectionMatcher","tinymce/inlite/core/ElementMatcher","tinymce/inlite/core/Matcher","tinymce/inlite/alien/Arr","tinymce/inlite/core/PredicateId","global!tinymce.util.Tools","global!tinymce.ui.Factory","global!tinymce.DOM","tinymce/inlite/ui/Toolbar","tinymce/inlite/ui/Forms","tinymce/inlite/core/Measure","tinymce/inlite/core/Layout","tinymce/inlite/file/Conversions","tinymce/inlite/file/Picker","tinymce/inlite/core/Actions","global!tinymce.EditorManager","global!tinymce.util.Promise","tinymce/inlite/alien/Uuid","tinymce/inlite/alien/Unlink","tinymce/inlite/core/UrlType","global!tinymce.geom.Rect","tinymce/inlite/core/Convert","tinymce/inlite/alien/Bookmark","global!tinymce.dom.TreeWalker","global!tinymce.dom.RangeUtils"]
3
- jsc*/
4
- defineGlobal("global!tinymce.ThemeManager", tinymce.ThemeManager);
5
- defineGlobal("global!tinymce.util.Delay", tinymce.util.Delay);
6
- defineGlobal("global!tinymce.util.Tools", tinymce.util.Tools);
7
- defineGlobal("global!tinymce.ui.Factory", tinymce.ui.Factory);
8
- defineGlobal("global!tinymce.DOM", tinymce.DOM);
9
- /**
10
- * Toolbar.js
11
- *
12
- * Released under LGPL License.
13
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
14
- *
15
- * License: http://www.tinymce.com/license
16
- * Contributing: http://www.tinymce.com/contributing
17
- */
18
-
19
- define('tinymce/inlite/ui/Toolbar', [
20
- 'global!tinymce.util.Tools',
21
- 'global!tinymce.ui.Factory'
22
- ], function (Tools, Factory) {
23
- var setActiveItem = function (item, name) {
24
- return function(state, args) {
25
- var nodeName, i = args.parents.length;
26
-
27
- while (i--) {
28
- nodeName = args.parents[i].nodeName;
29
- if (nodeName == 'OL' || nodeName == 'UL') {
30
- break;
31
- }
32
- }
33
-
34
- item.active(state && nodeName == name);
35
- };
36
- };
37
-
38
- var getSelectorStateResult = function (itemName, item) {
39
- var result = function (selector, handler) {
40
- return {
41
- selector: selector,
42
- handler: handler
43
- };
44
- };
45
-
46
- var activeHandler = function(state) {
47
- item.active(state);
48
- };
49
-
50
- var disabledHandler = function (state) {
51
- item.disabled(state);
52
- };
53
-
54
- if (itemName == 'bullist') {
55
- return result('ul > li', setActiveItem(item, 'UL'));
56
- }
57
-
58
- if (itemName == 'numlist') {
59
- return result('ol > li', setActiveItem(item, 'OL'));
60
- }
61
-
62
- if (item.settings.stateSelector) {
63
- return result(item.settings.stateSelector, activeHandler);
64
- }
65
-
66
- if (item.settings.disabledStateSelector) {
67
- return result(item.settings.disabledStateSelector, disabledHandler);
68
- }
69
-
70
- return null;
71
- };
72
-
73
- var bindSelectorChanged = function (editor, itemName, item) {
74
- return function () {
75
- var result = getSelectorStateResult(itemName, item);
76
- if (result !== null) {
77
- editor.selection.selectorChanged(result.selector, result.handler);
78
- }
79
- };
80
- };
81
-
82
- var create = function (editor, name, items) {
83
- var toolbarItems = [], buttonGroup;
84
-
85
- if (!items) {
86
- return;
87
- }
88
-
89
- Tools.each(items.split(/[ ,]/), function(item) {
90
- var itemName;
91
-
92
- if (item == '|') {
93
- buttonGroup = null;
94
- } else {
95
- if (Factory.has(item)) {
96
- item = {type: item};
97
- toolbarItems.push(item);
98
- buttonGroup = null;
99
- } else {
100
- if (!buttonGroup) {
101
- buttonGroup = {type: 'buttongroup', items: []};
102
- toolbarItems.push(buttonGroup);
103
- }
104
-
105
- if (editor.buttons[item]) {
106
- itemName = item;
107
- item = editor.buttons[itemName];
108
-
109
- if (typeof item == 'function') {
110
- item = item();
111
- }
112
-
113
- item.type = item.type || 'button';
114
-
115
- item = Factory.create(item);
116
- item.on('postRender', bindSelectorChanged(editor, itemName, item));
117
- buttonGroup.items.push(item);
118
- }
119
- }
120
- }
121
- });
122
-
123
- return Factory.create({
124
- type: 'toolbar',
125
- layout: 'flow',
126
- name: name,
127
- items: toolbarItems
128
- });
129
- };
130
-
131
- return {
132
- create: create
133
- };
134
- });
135
-
136
- defineGlobal("global!tinymce.util.Promise", tinymce.util.Promise);
137
- /**
138
- * Uuid.js
139
- *
140
- * Released under LGPL License.
141
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
142
- *
143
- * License: http://www.tinymce.com/license
144
- * Contributing: http://www.tinymce.com/contributing
145
- */
146
-
147
- /**
148
- * Generates unique ids this is the same as in core but since
149
- * it's not exposed as a global we can't access it.
150
- */
151
- define("tinymce/inlite/alien/Uuid", [
152
- ], function() {
153
- var count = 0;
154
-
155
- var seed = function () {
156
- var rnd = function () {
157
- return Math.round(Math.random() * 0xFFFFFFFF).toString(36);
158
- };
159
-
160
- return 's' + Date.now().toString(36) + rnd() + rnd() + rnd();
161
- };
162
-
163
- var uuid = function (prefix) {
164
- return prefix + (count++) + seed();
165
- };
166
-
167
- return {
168
- uuid: uuid
169
- };
170
- });
171
-
172
- /**
173
- * Bookmark.js
174
- *
175
- * Released under LGPL License.
176
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
177
- *
178
- * License: http://www.tinymce.com/license
179
- * Contributing: http://www.tinymce.com/contributing
180
- */
181
-
182
- define('tinymce/inlite/alien/Bookmark', [
183
- ], function () {
184
- /**
185
- * Returns a range bookmark. This will convert indexed bookmarks into temporary span elements with
186
- * index 0 so that they can be restored properly after the DOM has been modified. Text bookmarks will not have spans
187
- * added to them since they can be restored after a dom operation.
188
- *
189
- * So this: <p><b>|</b><b>|</b></p>
190
- * becomes: <p><b><span data-mce-type="bookmark">|</span></b><b data-mce-type="bookmark">|</span></b></p>
191
- *
192
- * @param {DOMRange} rng DOM Range to get bookmark on.
193
- * @return {Object} Bookmark object.
194
- */
195
- var create = function (dom, rng) {
196
- var bookmark = {};
197
-
198
- function setupEndPoint(start) {
199
- var offsetNode, container, offset;
200
-
201
- container = rng[start ? 'startContainer' : 'endContainer'];
202
- offset = rng[start ? 'startOffset' : 'endOffset'];
203
-
204
- if (container.nodeType == 1) {
205
- offsetNode = dom.create('span', {'data-mce-type': 'bookmark'});
206
-
207
- if (container.hasChildNodes()) {
208
- offset = Math.min(offset, container.childNodes.length - 1);
209
-
210
- if (start) {
211
- container.insertBefore(offsetNode, container.childNodes[offset]);
212
- } else {
213
- dom.insertAfter(offsetNode, container.childNodes[offset]);
214
- }
215
- } else {
216
- container.appendChild(offsetNode);
217
- }
218
-
219
- container = offsetNode;
220
- offset = 0;
221
- }
222
-
223
- bookmark[start ? 'startContainer' : 'endContainer'] = container;
224
- bookmark[start ? 'startOffset' : 'endOffset'] = offset;
225
- }
226
-
227
- setupEndPoint(true);
228
-
229
- if (!rng.collapsed) {
230
- setupEndPoint();
231
- }
232
-
233
- return bookmark;
234
- };
235
-
236
- /**
237
- * Moves the selection to the current bookmark and removes any selection container wrappers.
238
- *
239
- * @param {Object} bookmark Bookmark object to move selection to.
240
- */
241
- var resolve = function (dom, bookmark) {
242
- function restoreEndPoint(start) {
243
- var container, offset, node;
244
-
245
- function nodeIndex(container) {
246
- var node = container.parentNode.firstChild, idx = 0;
247
-
248
- while (node) {
249
- if (node == container) {
250
- return idx;
251
- }
252
-
253
- // Skip data-mce-type=bookmark nodes
254
- if (node.nodeType != 1 || node.getAttribute('data-mce-type') != 'bookmark') {
255
- idx++;
256
- }
257
-
258
- node = node.nextSibling;
259
- }
260
-
261
- return -1;
262
- }
263
-
264
- container = node = bookmark[start ? 'startContainer' : 'endContainer'];
265
- offset = bookmark[start ? 'startOffset' : 'endOffset'];
266
-
267
- if (!container) {
268
- return;
269
- }
270
-
271
- if (container.nodeType == 1) {
272
- offset = nodeIndex(container);
273
- container = container.parentNode;
274
- dom.remove(node);
275
- }
276
-
277
- bookmark[start ? 'startContainer' : 'endContainer'] = container;
278
- bookmark[start ? 'startOffset' : 'endOffset'] = offset;
279
- }
280
-
281
- restoreEndPoint(true);
282
- restoreEndPoint();
283
-
284
- var rng = dom.createRng();
285
-
286
- rng.setStart(bookmark.startContainer, bookmark.startOffset);
287
-
288
- if (bookmark.endContainer) {
289
- rng.setEnd(bookmark.endContainer, bookmark.endOffset);
290
- }
291
-
292
- return rng;
293
- };
294
-
295
- return {
296
- create: create,
297
- resolve: resolve
298
- };
299
- });
300
-
301
-
302
-
303
- defineGlobal("global!tinymce.dom.TreeWalker", tinymce.dom.TreeWalker);
304
- defineGlobal("global!tinymce.dom.RangeUtils", tinymce.dom.RangeUtils);
305
- /**
306
- * Unlink.js
307
- *
308
- * Released under LGPL License.
309
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
310
- *
311
- * License: http://www.tinymce.com/license
312
- * Contributing: http://www.tinymce.com/contributing
313
- */
314
-
315
- /**
316
- * Unlink implementation that doesn't leave partial links for example it would produce:
317
- * a[b<a href="x">c]d</a>e -> a[bc]de
318
- * instead of:
319
- * a[b<a href="x">c]d</a>e -> a[bc]<a href="x">d</a>e
320
- */
321
- define("tinymce/inlite/alien/Unlink", [
322
- 'tinymce/inlite/alien/Bookmark',
323
- 'global!tinymce.util.Tools',
324
- 'global!tinymce.dom.TreeWalker',
325
- 'global!tinymce.dom.RangeUtils'
326
- ], function (Bookmark, Tools, TreeWalker, RangeUtils) {
327
- var getSelectedElements = function (rootElm, startNode, endNode) {
328
- var walker, node, elms = [];
329
-
330
- walker = new TreeWalker(startNode, rootElm);
331
- for (node = startNode; node; node = walker.next()) {
332
- if (node.nodeType === 1) {
333
- elms.push(node);
334
- }
335
-
336
- if (node === endNode) {
337
- break;
338
- }
339
- }
340
-
341
- return elms;
342
- };
343
-
344
- var unwrapElements = function (editor, elms) {
345
- var bookmark, dom, selection;
346
-
347
- dom = editor.dom;
348
- selection = editor.selection;
349
- bookmark = Bookmark.create(dom, selection.getRng());
350
-
351
- Tools.each(elms, function (elm) {
352
- editor.dom.remove(elm, true);
353
- });
354
-
355
- selection.setRng(Bookmark.resolve(dom, bookmark));
356
- };
357
-
358
- var isLink = function (elm) {
359
- return elm.nodeName === 'A' && elm.hasAttribute('href');
360
- };
361
-
362
- var getParentAnchorOrSelf = function (dom, elm) {
363
- var anchorElm = dom.getParent(elm, isLink);
364
- return anchorElm ? anchorElm : elm;
365
- };
366
-
367
- var getSelectedAnchors = function (editor) {
368
- var startElm, endElm, rootElm, anchorElms, selection, dom, rng;
369
-
370
- selection = editor.selection;
371
- dom = editor.dom;
372
- rng = selection.getRng();
373
- startElm = getParentAnchorOrSelf(dom, RangeUtils.getNode(rng.startContainer, rng.startOffset));
374
- endElm = RangeUtils.getNode(rng.endContainer, rng.endOffset);
375
- rootElm = editor.getBody();
376
- anchorElms = Tools.grep(getSelectedElements(rootElm, startElm, endElm), isLink);
377
-
378
- return anchorElms;
379
- };
380
-
381
- var unlinkSelection = function (editor) {
382
- unwrapElements(editor, getSelectedAnchors(editor));
383
- };
384
-
385
- return {
386
- unlinkSelection: unlinkSelection
387
- };
388
- });
389
-
390
- /**
391
- * Actions.js
392
- *
393
- * Released under LGPL License.
394
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
395
- *
396
- * License: http://www.tinymce.com/license
397
- * Contributing: http://www.tinymce.com/contributing
398
- */
399
-
400
- define('tinymce/inlite/core/Actions', [
401
- 'tinymce/inlite/alien/Uuid',
402
- 'tinymce/inlite/alien/Unlink'
403
- ], function (Uuid, Unlink) {
404
- var createTableHtml = function (cols, rows) {
405
- var x, y, html;
406
-
407
- html = '<table data-mce-id="mce" style="width: 100%">';
408
- html += '<tbody>';
409
-
410
- for (y = 0; y < rows; y++) {
411
- html += '<tr>';
412
-
413
- for (x = 0; x < cols; x++) {
414
- html += '<td><br></td>';
415
- }
416
-
417
- html += '</tr>';
418
- }
419
-
420
- html += '</tbody>';
421
- html += '</table>';
422
-
423
- return html;
424
- };
425
-
426
- var getInsertedElement = function (editor) {
427
- var elms = editor.dom.select('*[data-mce-id]');
428
- return elms[0];
429
- };
430
-
431
- var insertTable = function (editor, cols, rows) {
432
- editor.undoManager.transact(function () {
433
- var tableElm, cellElm;
434
-
435
- editor.insertContent(createTableHtml(cols, rows));
436
-
437
- tableElm = getInsertedElement(editor);
438
- tableElm.removeAttribute('data-mce-id');
439
- cellElm = editor.dom.select('td,th', tableElm);
440
- editor.selection.setCursorLocation(cellElm[0], 0);
441
- });
442
- };
443
-
444
- var formatBlock = function (editor, formatName) {
445
- editor.execCommand('FormatBlock', false, formatName);
446
- };
447
-
448
- var insertBlob = function (editor, base64, blob) {
449
- var blobCache, blobInfo;
450
-
451
- blobCache = editor.editorUpload.blobCache;
452
- blobInfo = blobCache.create(Uuid.uuid('mceu'), blob, base64);
453
- blobCache.add(blobInfo);
454
-
455
- editor.insertContent(editor.dom.createHTML('img', {src: blobInfo.blobUri()}));
456
- };
457
-
458
- var collapseSelectionToEnd = function (editor) {
459
- editor.selection.collapse(false);
460
- };
461
-
462
- var unlink = function (editor) {
463
- editor.focus();
464
- Unlink.unlinkSelection(editor);
465
- collapseSelectionToEnd(editor);
466
- };
467
-
468
- var changeHref = function (editor, elm, url) {
469
- editor.focus();
470
- editor.dom.setAttrib(elm, 'href', url);
471
- collapseSelectionToEnd(editor);
472
- };
473
-
474
- var insertLink = function (editor, url) {
475
- editor.execCommand('mceInsertLink', false, {href: url});
476
- collapseSelectionToEnd(editor);
477
- };
478
-
479
- var updateOrInsertLink = function (editor, url) {
480
- var elm = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
481
- elm ? changeHref(editor, elm, url) : insertLink(editor, url);
482
- };
483
-
484
- var createLink = function (editor, url) {
485
- url.trim().length === 0 ? unlink(editor) : updateOrInsertLink(editor, url);
486
- };
487
-
488
- return {
489
- insertTable: insertTable,
490
- formatBlock: formatBlock,
491
- insertBlob: insertBlob,
492
- createLink: createLink,
493
- unlink: unlink
494
- };
495
- });
496
-
497
- /**
498
- * UrlType.js
499
- *
500
- * Released under LGPL License.
501
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
502
- *
503
- * License: http://www.tinymce.com/license
504
- * Contributing: http://www.tinymce.com/contributing
505
- */
506
-
507
- define('tinymce/inlite/core/UrlType', [
508
- ], function () {
509
- var isDomainLike = function (href) {
510
- return /^www\.|\.(com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil)$/i.test(href.trim());
511
- };
512
-
513
- var isAbsolute = function (href) {
514
- return /^https?:\/\//.test(href.trim());
515
- };
516
-
517
- return {
518
- isDomainLike: isDomainLike,
519
- isAbsolute: isAbsolute
520
- };
521
- });
522
-
523
-
524
-
525
- /**
526
- * Forms.js
527
- *
528
- * Released under LGPL License.
529
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
530
- *
531
- * License: http://www.tinymce.com/license
532
- * Contributing: http://www.tinymce.com/contributing
533
- */
534
-
535
- define('tinymce/inlite/ui/Forms', [
536
- 'global!tinymce.util.Tools',
537
- 'global!tinymce.ui.Factory',
538
- 'global!tinymce.util.Promise',
539
- 'tinymce/inlite/core/Actions',
540
- 'tinymce/inlite/core/UrlType'
541
- ], function (Tools, Factory, Promise, Actions, UrlType) {
542
- var focusFirstTextBox = function (form) {
543
- form.find('textbox').eq(0).each(function (ctrl) {
544
- ctrl.focus();
545
- });
546
- };
547
-
548
- var createForm = function (name, spec) {
549
- var form = Factory.create(
550
- Tools.extend({
551
- type: 'form',
552
- layout: 'flex',
553
- direction: 'row',
554
- padding: 5,
555
- name: name,
556
- spacing: 3
557
- }, spec)
558
- );
559
-
560
- form.on('show', function () {
561
- focusFirstTextBox(form);
562
- });
563
-
564
- return form;
565
- };
566
-
567
- var toggleVisibility = function (ctrl, state) {
568
- return state ? ctrl.show() : ctrl.hide();
569
- };
570
-
571
- var askAboutPrefix = function (editor, href) {
572
- return new Promise(function (resolve) {
573
- editor.windowManager.confirm(
574
- 'The URL you entered seems to be an external link. Do you want to add the required http:// prefix?',
575
- function (result) {
576
- var output = result === true ? 'http://' + href : href;
577
- resolve(output);
578
- }
579
- );
580
- });
581
- };
582
-
583
- var convertLinkToAbsolute = function (editor, href) {
584
- return !UrlType.isAbsolute(href) && UrlType.isDomainLike(href) ? askAboutPrefix(editor, href) : Promise.resolve(href);
585
- };
586
-
587
- var createQuickLinkForm = function (editor, hide) {
588
- var unlink = function () {
589
- editor.focus();
590
- Actions.unlink(editor);
591
- hide();
592
- };
593
-
594
- return createForm('quicklink', {
595
- items: [
596
- {type: 'button', name: 'unlink', icon: 'unlink', onclick: unlink, tooltip: 'Remove link'},
597
- {type: 'textbox', name: 'linkurl', placeholder: 'Paste or type a link'},
598
- {type: 'button', icon: 'checkmark', subtype: 'primary', tooltip: 'Ok', onclick: 'submit'}
599
- ],
600
- onshow: function () {
601
- var elm, linkurl = '';
602
-
603
- elm = editor.dom.getParent(editor.selection.getStart(), 'a[href]');
604
- if (elm) {
605
- linkurl = editor.dom.getAttrib(elm, 'href');
606
- }
607
-
608
- this.fromJSON({
609
- linkurl: linkurl
610
- });
611
-
612
- toggleVisibility(this.find('#unlink'), elm);
613
- },
614
- onsubmit: function (e) {
615
- convertLinkToAbsolute(editor, e.data.linkurl).then(function (url) {
616
- Actions.createLink(editor, url);
617
- hide();
618
- });
619
- }
620
- });
621
- };
622
-
623
- return {
624
- createQuickLinkForm: createQuickLinkForm
625
- };
626
- });
627
-
628
- defineGlobal("global!tinymce.geom.Rect", tinymce.geom.Rect);
629
- /**
630
- * Convert.js
631
- *
632
- * Released under LGPL License.
633
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
634
- *
635
- * License: http://www.tinymce.com/license
636
- * Contributing: http://www.tinymce.com/contributing
637
- */
638
-
639
- define('tinymce/inlite/core/Convert', [
640
- ], function () {
641
- var fromClientRect = function (clientRect) {
642
- return {
643
- x: clientRect.left,
644
- y: clientRect.top,
645
- w: clientRect.width,
646
- h: clientRect.height
647
- };
648
- };
649
-
650
- var toClientRect = function (geomRect) {
651
- return {
652
- left: geomRect.x,
653
- top: geomRect.y,
654
- width: geomRect.w,
655
- height: geomRect.h,
656
- right: geomRect.x + geomRect.w,
657
- bottom: geomRect.y + geomRect.h
658
- };
659
- };
660
-
661
- return {
662
- fromClientRect: fromClientRect,
663
- toClientRect: toClientRect
664
- };
665
- });
666
-
667
- /**
668
- * Measure.js
669
- *
670
- * Released under LGPL License.
671
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
672
- *
673
- * License: http://www.tinymce.com/license
674
- * Contributing: http://www.tinymce.com/contributing
675
- */
676
-
677
- define('tinymce/inlite/core/Measure', [
678
- 'global!tinymce.DOM',
679
- 'global!tinymce.geom.Rect',
680
- 'tinymce/inlite/core/Convert'
681
- ], function (DOM, Rect, Convert) {
682
- var toAbsolute = function (rect) {
683
- var vp = DOM.getViewPort();
684
-
685
- return {
686
- x: rect.x + vp.x,
687
- y: rect.y + vp.y,
688
- w: rect.w,
689
- h: rect.h
690
- };
691
- };
692
-
693
- var measureElement = function (elm) {
694
- var clientRect = elm.getBoundingClientRect();
695
-
696
- return toAbsolute({
697
- x: clientRect.left,
698
- y: clientRect.top,
699
- w: Math.max(elm.clientWidth, elm.offsetWidth),
700
- h: Math.max(elm.clientHeight, elm.offsetHeight)
701
- });
702
- };
703
-
704
- var getElementRect = function (editor, elm) {
705
- return measureElement(elm);
706
- };
707
-
708
- var getPageAreaRect = function (editor) {
709
- return measureElement(editor.getElement().ownerDocument.body);
710
- };
711
-
712
- var getContentAreaRect = function (editor) {
713
- return measureElement(editor.getContentAreaContainer() || editor.getBody());
714
- };
715
-
716
- var getSelectionRect = function (editor) {
717
- var clientRect = editor.selection.getBoundingClientRect();
718
- return clientRect ? toAbsolute(Convert.fromClientRect(clientRect)) : null;
719
- };
720
-
721
- return {
722
- getElementRect: getElementRect,
723
- getPageAreaRect: getPageAreaRect,
724
- getContentAreaRect: getContentAreaRect,
725
- getSelectionRect: getSelectionRect
726
- };
727
- });
728
-
729
- /**
730
- * Layout.js
731
- *
732
- * Released under LGPL License.
733
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
734
- *
735
- * License: http://www.tinymce.com/license
736
- * Contributing: http://www.tinymce.com/contributing
737
- */
738
-
739
- define('tinymce/inlite/core/Layout', [
740
- 'global!tinymce.geom.Rect',
741
- 'tinymce/inlite/core/Convert'
742
- ], function (Rect, Convert) {
743
- var result = function (rect, position) {
744
- return {
745
- rect: rect,
746
- position: position
747
- };
748
- };
749
-
750
- var moveTo = function (rect, toRect) {
751
- return {x: toRect.x, y: toRect.y, w: rect.w, h: rect.h};
752
- };
753
-
754
- var calcByPositions = function (testPositions1, testPositions2, targetRect, contentAreaRect, panelRect) {
755
- var relPos, relRect, outputPanelRect;
756
-
757
- relPos = Rect.findBestRelativePosition(panelRect, targetRect, contentAreaRect, testPositions1);
758
- targetRect = Rect.clamp(targetRect, contentAreaRect);
759
-
760
- if (relPos) {
761
- relRect = Rect.relativePosition(panelRect, targetRect, relPos);
762
- outputPanelRect = moveTo(panelRect, relRect);
763
- return result(outputPanelRect, relPos);
764
- }
765
-
766
- targetRect = Rect.intersect(contentAreaRect, targetRect);
767
- if (targetRect) {
768
- relPos = Rect.findBestRelativePosition(panelRect, targetRect, contentAreaRect, testPositions2);
769
- if (relPos) {
770
- relRect = Rect.relativePosition(panelRect, targetRect, relPos);
771
- outputPanelRect = moveTo(panelRect, relRect);
772
- return result(outputPanelRect, relPos);
773
- }
774
-
775
- outputPanelRect = moveTo(panelRect, targetRect);
776
- return result(outputPanelRect, relPos);
777
- }
778
-
779
- return null;
780
- };
781
-
782
- var calcInsert = function (targetRect, contentAreaRect, panelRect) {
783
- return calcByPositions(
784
- ['cr-cl', 'cl-cr'],
785
- ['bc-tc', 'bl-tl', 'br-tr'],
786
- targetRect,
787
- contentAreaRect,
788
- panelRect
789
- );
790
- };
791
-
792
- var calc = function (targetRect, contentAreaRect, panelRect) {
793
- return calcByPositions(
794
- ['tc-bc', 'bc-tc', 'tl-bl', 'bl-tl', 'tr-br', 'br-tr'],
795
- ['bc-tc', 'bl-tl', 'br-tr'],
796
- targetRect,
797
- contentAreaRect,
798
- panelRect
799
- );
800
- };
801
-
802
- var userConstrain = function (handler, targetRect, contentAreaRect, panelRect) {
803
- var userConstrainedPanelRect;
804
-
805
- if (typeof handler === 'function') {
806
- userConstrainedPanelRect = handler({
807
- elementRect: Convert.toClientRect(targetRect),
808
- contentAreaRect: Convert.toClientRect(contentAreaRect),
809
- panelRect: Convert.toClientRect(panelRect)
810
- });
811
-
812
- return Convert.fromClientRect(userConstrainedPanelRect);
813
- }
814
-
815
- return panelRect;
816
- };
817
-
818
- return {
819
- calcInsert: calcInsert,
820
- calc: calc,
821
- userConstrain: userConstrain
822
- };
823
- });
824
-
825
- /**
826
- * Panel.js
827
- *
828
- * Released under LGPL License.
829
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
830
- *
831
- * License: http://www.tinymce.com/license
832
- * Contributing: http://www.tinymce.com/contributing
833
- */
834
-
835
- define('tinymce/inlite/ui/Panel', [
836
- 'global!tinymce.util.Tools',
837
- 'global!tinymce.ui.Factory',
838
- 'global!tinymce.DOM',
839
- 'tinymce/inlite/ui/Toolbar',
840
- 'tinymce/inlite/ui/Forms',
841
- 'tinymce/inlite/core/Measure',
842
- 'tinymce/inlite/core/Layout'
843
- ], function (Tools, Factory, DOM, Toolbar, Forms, Measure, Layout) {
844
- return function () {
845
- var DEFAULT_TEXT_SELECTION_ITEMS = 'bold italic | quicklink h2 h3 blockquote';
846
- var DEFAULT_INSERT_TOOLBAR_ITEMS = 'quickimage quicktable';
847
- var panel, currentRect;
848
-
849
- var createToolbars = function (editor, toolbars) {
850
- return Tools.map(toolbars, function (toolbar) {
851
- return Toolbar.create(editor, toolbar.id, toolbar.items);
852
- });
853
- };
854
-
855
- var getTextSelectionToolbarItems = function (settings) {
856
- var value = settings.selection_toolbar;
857
- return value ? value : DEFAULT_TEXT_SELECTION_ITEMS;
858
- };
859
-
860
- var getInsertToolbarItems = function (settings) {
861
- var value = settings.insert_toolbar;
862
- return value ? value : DEFAULT_INSERT_TOOLBAR_ITEMS;
863
- };
864
-
865
- var create = function (editor, toolbars) {
866
- var items, settings = editor.settings;
867
-
868
- items = createToolbars(editor, toolbars);
869
- items = items.concat([
870
- Toolbar.create(editor, 'text', getTextSelectionToolbarItems(settings)),
871
- Toolbar.create(editor, 'insert', getInsertToolbarItems(settings)),
872
- Forms.createQuickLinkForm(editor, hide)
873
- ]);
874
-
875
- return Factory.create({
876
- type: 'floatpanel',
877
- role: 'dialog',
878
- classes: 'tinymce tinymce-inline arrow',
879
- ariaLabel: 'Inline toolbar',
880
- layout: 'flex',
881
- direction: 'column',
882
- align: 'stretch',
883
- autohide: false,
884
- autofix: true,
885
- fixed: true,
886
- border: 1,
887
- items: items,
888
- oncancel: function() {
889
- editor.focus();
890
- }
891
- });
892
- };
893
-
894
- var showPanel = function (panel) {
895
- if (panel) {
896
- panel.show();
897
- }
898
- };
899
-
900
- var movePanelTo = function (panel, pos) {
901
- panel.moveTo(pos.x, pos.y);
902
- };
903
-
904
- var togglePositionClass = function (panel, relPos) {
905
- relPos = relPos ? relPos.substr(0, 2) : '';
906
-
907
- Tools.each({
908
- t: 'down',
909
- b: 'up',
910
- c: 'center'
911
- }, function(cls, pos) {
912
- panel.classes.toggle('arrow-' + cls, pos === relPos.substr(0, 1));
913
- });
914
-
915
- if (relPos === 'cr') {
916
- panel.classes.toggle('arrow-left', true);
917
- panel.classes.toggle('arrow-right', false);
918
- } else if (relPos === 'cl') {
919
- panel.classes.toggle('arrow-left', true);
920
- panel.classes.toggle('arrow-right', true);
921
- } else {
922
- Tools.each({
923
- l: 'left',
924
- r: 'right'
925
- }, function(cls, pos) {
926
- panel.classes.toggle('arrow-' + cls, pos === relPos.substr(1, 1));
927
- });
928
- }
929
- };
930
-
931
- var showToolbar = function (panel, id) {
932
- var toolbars = panel.items().filter('#' + id);
933
-
934
- if (toolbars.length > 0) {
935
- toolbars[0].show();
936
- panel.reflow();
937
- }
938
- };
939
-
940
- var showPanelAt = function (panel, id, editor, targetRect) {
941
- var contentAreaRect, panelRect, result, userConstainHandler;
942
-
943
- showPanel(panel);
944
- panel.items().hide();
945
- showToolbar(panel, id);
946
-
947
- userConstainHandler = editor.settings.inline_toolbar_position_handler;
948
- contentAreaRect = Measure.getContentAreaRect(editor);
949
- panelRect = DOM.getRect(panel.getEl());
950
-
951
- if (id === 'insert') {
952
- result = Layout.calcInsert(targetRect, contentAreaRect, panelRect);
953
- } else {
954
- result = Layout.calc(targetRect, contentAreaRect, panelRect);
955
- }
956
-
957
- if (result) {
958
- panelRect = result.rect;
959
- currentRect = targetRect;
960
- movePanelTo(panel, Layout.userConstrain(userConstainHandler, targetRect, contentAreaRect, panelRect));
961
-
962
- togglePositionClass(panel, result.position);
963
- } else {
964
- hide(panel);
965
- }
966
- };
967
-
968
- var hasFormVisible = function () {
969
- return panel.items().filter('form:visible').length > 0;
970
- };
971
-
972
- var showForm = function (editor, id) {
973
- if (panel) {
974
- panel.items().hide();
975
- showToolbar(panel, id);
976
-
977
- var contentAreaRect, panelRect, result, userConstainHandler;
978
-
979
- showPanel(panel);
980
- panel.items().hide();
981
- showToolbar(panel, id);
982
-
983
- userConstainHandler = editor.settings.inline_toolbar_position_handler;
984
- contentAreaRect = Measure.getContentAreaRect(editor);
985
- panelRect = DOM.getRect(panel.getEl());
986
-
987
- result = Layout.calc(currentRect, contentAreaRect, panelRect);
988
-
989
- if (result) {
990
- panelRect = result.rect;
991
- movePanelTo(panel, Layout.userConstrain(userConstainHandler, currentRect, contentAreaRect, panelRect));
992
-
993
- togglePositionClass(panel, result.position);
994
- }
995
- }
996
- };
997
-
998
- var show = function (editor, id, targetRect, toolbars) {
999
- if (!panel) {
1000
- panel = create(editor, toolbars);
1001
- panel.renderTo(document.body).reflow().moveTo(targetRect.x, targetRect.y);
1002
- editor.nodeChanged();
1003
- }
1004
-
1005
- showPanelAt(panel, id, editor, targetRect);
1006
- };
1007
-
1008
- var hide = function () {
1009
- if (panel) {
1010
- panel.hide();
1011
- }
1012
- };
1013
-
1014
- var focus = function () {
1015
- if (panel) {
1016
- panel.find('toolbar:visible').eq(0).each(function (item) {
1017
- item.focus(true);
1018
- });
1019
- }
1020
- };
1021
-
1022
- var remove = function () {
1023
- if (panel) {
1024
- panel.remove();
1025
- panel = null;
1026
- }
1027
- };
1028
-
1029
- var inForm = function () {
1030
- return panel && panel.visible() && hasFormVisible();
1031
- };
1032
-
1033
- return {
1034
- show: show,
1035
- showForm: showForm,
1036
- inForm: inForm,
1037
- hide: hide,
1038
- focus: focus,
1039
- remove: remove
1040
- };
1041
- };
1042
- });
1043
-
1044
- /**
1045
- * Conversions.js
1046
- *
1047
- * Released under LGPL License.
1048
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1049
- *
1050
- * License: http://www.tinymce.com/license
1051
- * Contributing: http://www.tinymce.com/contributing
1052
- */
1053
-
1054
- define('tinymce/inlite/file/Conversions', [
1055
- 'global!tinymce.util.Promise'
1056
- ], function (Promise) {
1057
- var blobToBase64 = function (blob) {
1058
- return new Promise(function(resolve) {
1059
- var reader = new FileReader();
1060
-
1061
- reader.onloadend = function() {
1062
- resolve(reader.result.split(',')[1]);
1063
- };
1064
-
1065
- reader.readAsDataURL(blob);
1066
- });
1067
- };
1068
-
1069
- return {
1070
- blobToBase64: blobToBase64
1071
- };
1072
- });
1073
-
1074
-
1075
-
1076
- /**
1077
- * Picker.js
1078
- *
1079
- * Released under LGPL License.
1080
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1081
- *
1082
- * License: http://www.tinymce.com/license
1083
- * Contributing: http://www.tinymce.com/contributing
1084
- */
1085
-
1086
- define('tinymce/inlite/file/Picker', [
1087
- 'global!tinymce.util.Promise'
1088
- ], function (Promise) {
1089
- var pickFile = function () {
1090
- return new Promise(function (resolve) {
1091
- var fileInput;
1092
-
1093
- fileInput = document.createElement("input");
1094
- fileInput.type = "file";
1095
- fileInput.style.position = 'fixed';
1096
- fileInput.style.left = 0;
1097
- fileInput.style.top = 0;
1098
- fileInput.style.opacity = 0.001;
1099
- document.body.appendChild(fileInput);
1100
-
1101
- fileInput.onchange = function(e) {
1102
- resolve(Array.prototype.slice.call(e.target.files));
1103
- };
1104
-
1105
- fileInput.click();
1106
- fileInput.parentNode.removeChild(fileInput);
1107
- });
1108
- };
1109
-
1110
- return {
1111
- pickFile: pickFile
1112
- };
1113
- });
1114
-
1115
-
1116
-
1117
- /**
1118
- * Buttons.js
1119
- *
1120
- * Released under LGPL License.
1121
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1122
- *
1123
- * License: http://www.tinymce.com/license
1124
- * Contributing: http://www.tinymce.com/contributing
1125
- */
1126
-
1127
- define('tinymce/inlite/ui/Buttons', [
1128
- 'tinymce/inlite/ui/Panel',
1129
- 'tinymce/inlite/file/Conversions',
1130
- 'tinymce/inlite/file/Picker',
1131
- 'tinymce/inlite/core/Actions'
1132
- ], function (Panel, Conversions, Picker, Actions) {
1133
- var addHeaderButtons = function (editor) {
1134
- var formatBlock = function (name) {
1135
- return function () {
1136
- Actions.formatBlock(editor, name);
1137
- };
1138
- };
1139
-
1140
- for (var i = 1; i < 6; i++) {
1141
- var name = 'h' + i;
1142
-
1143
- editor.addButton(name, {
1144
- text: name.toUpperCase(),
1145
- tooltip: 'Heading ' + i,
1146
- stateSelector: name,
1147
- onclick: formatBlock(name),
1148
- onPostRender: function () {
1149
- // TODO: Remove this hack that produces bold H1-H6 when we have proper icons
1150
- var span = this.getEl().firstChild.firstChild;
1151
- span.style.fontWeight = 'bold';
1152
- }
1153
- });
1154
- }
1155
- };
1156
-
1157
- var addToEditor = function (editor, panel) {
1158
- editor.addButton('quicklink', {
1159
- icon: 'link',
1160
- tooltip: 'Insert/Edit link',
1161
- stateSelector: 'a[href]',
1162
- onclick: function () {
1163
- panel.showForm(editor, 'quicklink');
1164
- }
1165
- });
1166
-
1167
- editor.addButton('quickimage', {
1168
- icon: 'image',
1169
- tooltip: 'Insert image',
1170
- onclick: function () {
1171
- Picker.pickFile().then(function (files) {
1172
- var blob = files[0];
1173
-
1174
- Conversions.blobToBase64(blob).then(function (base64) {
1175
- Actions.insertBlob(editor, base64, blob);
1176
- });
1177
- });
1178
- }
1179
- });
1180
-
1181
- editor.addButton('quicktable', {
1182
- icon: 'table',
1183
- tooltip: 'Insert table',
1184
- onclick: function () {
1185
- panel.hide();
1186
- Actions.insertTable(editor, 2, 2);
1187
- }
1188
- });
1189
-
1190
- addHeaderButtons(editor);
1191
- };
1192
-
1193
- return {
1194
- addToEditor: addToEditor
1195
- };
1196
- });
1197
-
1198
- defineGlobal("global!tinymce.EditorManager", tinymce.EditorManager);
1199
- /**
1200
- * SkinLoader.js
1201
- *
1202
- * Released under LGPL License.
1203
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1204
- *
1205
- * License: http://www.tinymce.com/license
1206
- * Contributing: http://www.tinymce.com/contributing
1207
- */
1208
-
1209
- define('tinymce/inlite/core/SkinLoader', [
1210
- 'global!tinymce.EditorManager',
1211
- 'global!tinymce.DOM'
1212
- ], function (EditorManager, DOM) {
1213
- var fireSkinLoaded = function (editor, callback) {
1214
- var done = function () {
1215
- editor.fire('SkinLoaded');
1216
- callback();
1217
- };
1218
-
1219
- if (editor.initialized) {
1220
- done();
1221
- } else {
1222
- editor.on('init', done);
1223
- }
1224
- };
1225
-
1226
- var load = function (editor, skin, callback) {
1227
- var baseUrl = EditorManager.baseURL;
1228
- var skinUrl = baseUrl + '/skins/' + skin;
1229
-
1230
- var done = function () {
1231
- fireSkinLoaded(editor, callback);
1232
- };
1233
-
1234
- DOM.styleSheetLoader.load(skinUrl + '/skin.min.css', done);
1235
- editor.contentCSS.push(skinUrl + '/content.inline.min.css');
1236
- };
1237
-
1238
- return {
1239
- load: load
1240
- };
1241
- });
1242
-
1243
-
1244
-
1245
- /**
1246
- * Matcher.js
1247
- *
1248
- * Released under LGPL License.
1249
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1250
- *
1251
- * License: http://www.tinymce.com/license
1252
- * Contributing: http://www.tinymce.com/contributing
1253
- */
1254
-
1255
- define('tinymce/inlite/core/Matcher', [
1256
- ], function () {
1257
- // result :: String, Rect -> Matcher.result
1258
- var result = function (id, rect) {
1259
- return {
1260
- id: id,
1261
- rect: rect
1262
- };
1263
- };
1264
-
1265
- // match :: Editor, [(Editor -> Matcher.result | Null)] -> Matcher.result | Null
1266
- var match = function (editor, matchers) {
1267
- for (var i = 0; i < matchers.length; i++) {
1268
- var f = matchers[i];
1269
- var result = f(editor);
1270
-
1271
- if (result) {
1272
- return result;
1273
- }
1274
- }
1275
-
1276
- return null;
1277
- };
1278
-
1279
- return {
1280
- match: match,
1281
- result: result
1282
- };
1283
- });
1284
-
1285
- /**
1286
- * SelectionMatcher.js
1287
- *
1288
- * Released under LGPL License.
1289
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1290
- *
1291
- * License: http://www.tinymce.com/license
1292
- * Contributing: http://www.tinymce.com/contributing
1293
- */
1294
-
1295
- define('tinymce/inlite/core/SelectionMatcher', [
1296
- 'tinymce/inlite/core/Matcher',
1297
- 'tinymce/inlite/core/Measure'
1298
- ], function (Matcher, Measure) {
1299
- // textSelection :: String -> (Editor -> Matcher.result | Null)
1300
- var textSelection = function (id) {
1301
- return function (editor) {
1302
- if (!editor.selection.isCollapsed()) {
1303
- return Matcher.result(id, Measure.getSelectionRect(editor));
1304
- }
1305
-
1306
- return null;
1307
- };
1308
- };
1309
-
1310
- // emptyTextBlock :: [Elements], String -> (Editor -> Matcher.result | Null)
1311
- var emptyTextBlock = function (elements, id) {
1312
- return function (editor) {
1313
- var i, textBlockElementsMap = editor.schema.getTextBlockElements();
1314
-
1315
- for (i = 0; i < elements.length; i++) {
1316
- if (elements[i].nodeName === 'TABLE') {
1317
- return null;
1318
- }
1319
- }
1320
-
1321
- for (i = 0; i < elements.length; i++) {
1322
- if (elements[i].nodeName in textBlockElementsMap) {
1323
- if (editor.dom.isEmpty(elements[i])) {
1324
- return Matcher.result(id, Measure.getSelectionRect(editor));
1325
- }
1326
-
1327
- return null;
1328
- }
1329
- }
1330
-
1331
- return null;
1332
- };
1333
- };
1334
-
1335
- return {
1336
- textSelection: textSelection,
1337
- emptyTextBlock: emptyTextBlock
1338
- };
1339
- });
1340
-
1341
- /**
1342
- * ElementMatcher.js
1343
- *
1344
- * Released under LGPL License.
1345
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1346
- *
1347
- * License: http://www.tinymce.com/license
1348
- * Contributing: http://www.tinymce.com/contributing
1349
- */
1350
-
1351
- define('tinymce/inlite/core/ElementMatcher', [
1352
- 'tinymce/inlite/core/Matcher',
1353
- 'tinymce/inlite/core/Measure'
1354
- ], function (Matcher, Measure) {
1355
- // element :: Element, [PredicateId] -> (Editor -> Matcher.result | Null)
1356
- var element = function (element, predicateIds) {
1357
- return function (editor) {
1358
- for (var i = 0; i < predicateIds.length; i++) {
1359
- if (predicateIds[i].predicate(element)) {
1360
- return Matcher.result(predicateIds[i].id, Measure.getElementRect(editor, element));
1361
- }
1362
- }
1363
-
1364
- return null;
1365
- };
1366
- };
1367
-
1368
- // parent :: [Elements], [PredicateId] -> (Editor -> Matcher.result | Null)
1369
- var parent = function (elements, predicateIds) {
1370
- return function (editor) {
1371
- for (var i = 0; i < elements.length; i++) {
1372
- for (var x = 0; x < predicateIds.length; x++) {
1373
- if (predicateIds[x].predicate(elements[i])) {
1374
- return Matcher.result(predicateIds[x].id, Measure.getElementRect(editor, elements[i]));
1375
- }
1376
- }
1377
- }
1378
-
1379
- return null;
1380
- };
1381
- };
1382
-
1383
- return {
1384
- element: element,
1385
- parent: parent
1386
- };
1387
- });
1388
-
1389
- /**
1390
- * Arr.js
1391
- *
1392
- * Released under LGPL License.
1393
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1394
- *
1395
- * License: http://www.tinymce.com/license
1396
- * Contributing: http://www.tinymce.com/contributing
1397
- */
1398
-
1399
- define('tinymce/inlite/alien/Arr', [
1400
- ], function () {
1401
- var flatten = function (arr) {
1402
- return arr.reduce(function (results, item) {
1403
- return Array.isArray(item) ? results.concat(flatten(item)) : results.concat(item);
1404
- }, []);
1405
- };
1406
-
1407
- return {
1408
- flatten: flatten
1409
- };
1410
- });
1411
-
1412
- /**
1413
- * PredicateId.js
1414
- *
1415
- * Released under LGPL License.
1416
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1417
- *
1418
- * License: http://www.tinymce.com/license
1419
- * Contributing: http://www.tinymce.com/contributing
1420
- */
1421
-
1422
- define('tinymce/inlite/core/PredicateId', [
1423
- 'global!tinymce.util.Tools'
1424
- ], function (Tools) {
1425
- var create = function (id, predicate) {
1426
- return {
1427
- id: id,
1428
- predicate: predicate
1429
- };
1430
- };
1431
-
1432
- // fromContextToolbars :: [ContextToolbar] -> [PredicateId]
1433
- var fromContextToolbars = function (toolbars) {
1434
- return Tools.map(toolbars, function (toolbar) {
1435
- return create(toolbar.id, toolbar.predicate);
1436
- });
1437
- };
1438
-
1439
- return {
1440
- create: create,
1441
- fromContextToolbars: fromContextToolbars
1442
- };
1443
- });
1444
-
1445
- /**
1446
- * Theme.js
1447
- *
1448
- * Released under LGPL License.
1449
- * Copyright (c) 1999-2016 Ephox Corp. All rights reserved
1450
- *
1451
- * License: http://www.tinymce.com/license
1452
- * Contributing: http://www.tinymce.com/contributing
1453
- */
1454
-
1455
- define('tinymce/inlite/Theme', [
1456
- 'global!tinymce.ThemeManager',
1457
- 'global!tinymce.util.Delay',
1458
- 'tinymce/inlite/ui/Panel',
1459
- 'tinymce/inlite/ui/Buttons',
1460
- 'tinymce/inlite/core/SkinLoader',
1461
- 'tinymce/inlite/core/SelectionMatcher',
1462
- 'tinymce/inlite/core/ElementMatcher',
1463
- 'tinymce/inlite/core/Matcher',
1464
- 'tinymce/inlite/alien/Arr',
1465
- 'tinymce/inlite/core/PredicateId'
1466
- ], function(ThemeManager, Delay, Panel, Buttons, SkinLoader, SelectionMatcher, ElementMatcher, Matcher, Arr, PredicateId) {
1467
- var getSelectionElements = function (editor) {
1468
- var node = editor.selection.getNode();
1469
- var elms = editor.dom.getParents(node);
1470
- return elms;
1471
- };
1472
-
1473
- var createToolbar = function (editor, selector, id, items) {
1474
- var selectorPredicate = function (elm) {
1475
- return editor.dom.is(elm, selector);
1476
- };
1477
-
1478
- return {
1479
- predicate: selectorPredicate,
1480
- id: id,
1481
- items: items
1482
- };
1483
- };
1484
-
1485
- var getToolbars = function (editor) {
1486
- var contextToolbars = editor.contextToolbars;
1487
-
1488
- return Arr.flatten([
1489
- contextToolbars ? contextToolbars : [],
1490
- createToolbar(editor, 'img', 'image', 'alignleft aligncenter alignright')
1491
- ]);
1492
- };
1493
-
1494
- var findMatchResult = function (editor, toolbars) {
1495
- var result, elements, contextToolbarsPredicateIds;
1496
-
1497
- elements = getSelectionElements(editor);
1498
- contextToolbarsPredicateIds = PredicateId.fromContextToolbars(toolbars);
1499
-
1500
- result = Matcher.match(editor, [
1501
- ElementMatcher.element(elements[0], contextToolbarsPredicateIds),
1502
- SelectionMatcher.textSelection('text'),
1503
- SelectionMatcher.emptyTextBlock(elements, 'insert'),
1504
- ElementMatcher.parent(elements, contextToolbarsPredicateIds)
1505
- ]);
1506
-
1507
- return result && result.rect ? result : null;
1508
- };
1509
-
1510
- var togglePanel = function (editor, panel) {
1511
- var toggle = function () {
1512
- var toolbars = getToolbars(editor);
1513
- var result = findMatchResult(editor, toolbars);
1514
-
1515
- if (result) {
1516
- panel.show(editor, result.id, result.rect, toolbars);
1517
- } else {
1518
- panel.hide();
1519
- }
1520
- };
1521
-
1522
- return function () {
1523
- if (!editor.removed) {
1524
- toggle();
1525
- }
1526
- };
1527
- };
1528
-
1529
- var ignoreWhenFormIsVisible = function (panel, f) {
1530
- return function () {
1531
- if (!panel.inForm()) {
1532
- f();
1533
- }
1534
- };
1535
- };
1536
-
1537
- var bindContextualToolbarsEvents = function (editor, panel) {
1538
- var throttledTogglePanel = Delay.throttle(togglePanel(editor, panel), 0);
1539
- var throttledTogglePanelWhenNotInForm = Delay.throttle(ignoreWhenFormIsVisible(panel, togglePanel(editor, panel)), 0);
1540
-
1541
- editor.on('blur hide ObjectResizeStart', panel.hide);
1542
- editor.on('click', throttledTogglePanel);
1543
- editor.on('nodeChange mouseup', throttledTogglePanelWhenNotInForm);
1544
- editor.on('ResizeEditor ResizeWindow keyup', throttledTogglePanel);
1545
- editor.on('remove', panel.remove);
1546
-
1547
- editor.shortcuts.add('Alt+F10', '', panel.focus);
1548
- };
1549
-
1550
- var overrideLinkShortcut = function (editor, panel) {
1551
- editor.shortcuts.remove('meta+k');
1552
- editor.shortcuts.add('meta+k', '', function () {
1553
- var toolbars = getToolbars(editor);
1554
- var result = result = Matcher.match(editor, [
1555
- SelectionMatcher.textSelection('quicklink')
1556
- ]);
1557
-
1558
- if (result) {
1559
- panel.show(editor, result.id, result.rect, toolbars);
1560
- }
1561
- });
1562
- };
1563
-
1564
- var renderInlineUI = function (editor, panel) {
1565
- var skinName = editor.settings.skin || 'lightgray';
1566
-
1567
- SkinLoader.load(editor, skinName, function () {
1568
- bindContextualToolbarsEvents(editor, panel);
1569
- overrideLinkShortcut(editor, panel);
1570
- });
1571
-
1572
- return {};
1573
- };
1574
-
1575
- var fail = function (message) {
1576
- throw new Error(message);
1577
- };
1578
-
1579
- ThemeManager.add('inlite', function (editor) {
1580
- var panel = new Panel();
1581
-
1582
- Buttons.addToEditor(editor, panel);
1583
-
1584
- var renderUI = function () {
1585
- return editor.inline ? renderInlineUI(editor, panel) : fail('inlite theme only supports inline mode.');
1586
- };
1587
-
1588
- return {
1589
- renderUI: renderUI
1590
- };
1591
- });
1592
-
1593
- return function() {};
1594
- });