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