@tinymce/tinymce-jquery 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Change log
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ### Added
9
+ - Initial release of the TinyMCE jQuery integration as a separate node module.
10
+
11
+ ### Changed
12
+ - The `$(e).tinymce({...})` now returns a `Promise` of all initialized editors instead of the `this` object.
13
+ - The `$(e).tinymce()` now returns `undefined` when no editor is present instead of `null`.
14
+
15
+ ### Removed
16
+ - Removed the patch on `replaceAll` as it was inconsistent with other functions. Due to this change calling `replaceAll` will not automatically destroy any moved or overwritten TinyMCE instances though they will likely be left in a non-functional state.
17
+ - Removed the patch on `replaceWith` as it was inconsistent with other functions. Due to this change calling `replaceWith` will not automatically destroy any moved or overwritten TinyMCE instances though they will likely be left in a non-functional state.
18
+
19
+ ### Fixed
20
+ - Removing an element with `$(e).remove()` destroys all contained editors.
21
+ - Removing child elements with `$(e).empty()` destroys all contained editors.
22
+ - Overwriting an element with `$(e).text(value)` or `$(e).html(value)` destroys all contained editors
package/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Ephox Corporation DBA Tiny Technologies, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Official TinyMCE jQuery integration
2
+
3
+ ## About
4
+
5
+ This package is a thin wrapper around [TinyMCE](https://github.com/tinymce/tinymce)
6
+ to make it easier to use in jQuery.
7
+
8
+ The jQuery integration used to be included with the default TinyMCE bundle,
9
+ starting with TinyMCE 6 it has been removed from the TinyMCE bundle and will
10
+ instead be distributed as an independent npm package.
11
+
12
+ * If you need detailed documentation on TinyMCE, see:
13
+ [TinyMCE Documentation](https://www.tiny.cloud/docs/).
14
+ * For the TinyMCE jQuery Quick Start, see:
15
+ [TinyMCE Documentation - jQuery Integration](https://www.tiny.cloud/docs/integrations/jquery/).
16
+ * For our quick demos, check out the TinyMCE jQuery
17
+ [Storybook](https://tinymce.github.io/tinymce-jquery/).
18
+
19
+
20
+ ### Issues
21
+
22
+ Have you found an issue with tinymce-jquery or do you have a feature request?
23
+ Open up an [issue](https://github.com/tinymce/tinymce-jquery/issues) and let us
24
+ know or submit a [pull request](https://github.com/tinymce/tinymce-jquery/pulls).
25
+ *Note: For issues concerning TinyMCE please visit the
26
+ [TinyMCE repository](https://github.com/tinymce/tinymce).*
@@ -0,0 +1,528 @@
1
+ (function () {
2
+ 'use strict';
3
+
4
+ var __assign = function () {
5
+ __assign = Object.assign || function __assign(t) {
6
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
7
+ s = arguments[i];
8
+ for (var p in s)
9
+ if (Object.prototype.hasOwnProperty.call(s, p))
10
+ t[p] = s[p];
11
+ }
12
+ return t;
13
+ };
14
+ return __assign.apply(this, arguments);
15
+ };
16
+
17
+ var Global$1 = typeof window !== 'undefined' ? window : Function('return this;')();
18
+
19
+ var jquery = function () {
20
+ var _a;
21
+ return (_a = Global$1 && Global$1.jQuery) !== null && _a !== void 0 ? _a : null;
22
+ };
23
+ var getJquery = function () {
24
+ var jq = jquery();
25
+ if (jq != null) {
26
+ return jq;
27
+ }
28
+ throw new Error('Expected global jQuery');
29
+ };
30
+
31
+ const hasProto = (v, constructor, predicate) => {
32
+ var _a;
33
+ if (predicate(v, constructor.prototype)) {
34
+ return true;
35
+ } else {
36
+ return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
37
+ }
38
+ };
39
+ const typeOf = x => {
40
+ const t = typeof x;
41
+ if (x === null) {
42
+ return 'null';
43
+ } else if (t === 'object' && Array.isArray(x)) {
44
+ return 'array';
45
+ } else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
46
+ return 'string';
47
+ } else {
48
+ return t;
49
+ }
50
+ };
51
+ const isType = type => value => typeOf(value) === type;
52
+ const isSimpleType = type => value => typeof value === type;
53
+ const isString = isType('string');
54
+ const isObject = isType('object');
55
+ const isArray = isType('array');
56
+ const isFunction = isSimpleType('function');
57
+
58
+ const keys = Object.keys;
59
+ const hasOwnProperty = Object.hasOwnProperty;
60
+ const has = (obj, key) => hasOwnProperty.call(obj, key);
61
+
62
+ const cached = f => {
63
+ let called = false;
64
+ let r;
65
+ return (...args) => {
66
+ if (!called) {
67
+ called = true;
68
+ r = f.apply(null, args);
69
+ }
70
+ return r;
71
+ };
72
+ };
73
+
74
+ const Global = typeof window !== 'undefined' ? window : Function('return this;')();
75
+
76
+ const path = (parts, scope) => {
77
+ let o = scope !== undefined && scope !== null ? scope : Global;
78
+ for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
79
+ o = o[parts[i]];
80
+ }
81
+ return o;
82
+ };
83
+ const resolve = (p, scope) => {
84
+ const parts = p.split('.');
85
+ return path(parts, scope);
86
+ };
87
+
88
+ const unsafe = (name, scope) => {
89
+ return resolve(name, scope);
90
+ };
91
+ const getOrDie = (name, scope) => {
92
+ const actual = unsafe(name, scope);
93
+ if (actual === undefined || actual === null) {
94
+ throw new Error(name + ' not available on this browser');
95
+ }
96
+ return actual;
97
+ };
98
+
99
+ const getPrototypeOf = Object.getPrototypeOf;
100
+ const sandHTMLElement = scope => {
101
+ return getOrDie('HTMLElement', scope);
102
+ };
103
+ const isPrototypeOf = x => {
104
+ const scope = resolve('ownerDocument.defaultView', x);
105
+ return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf(x).constructor.name));
106
+ };
107
+
108
+ var tinymce = function () {
109
+ var _a;
110
+ return (_a = Global$1.tinymce) !== null && _a !== void 0 ? _a : null;
111
+ };
112
+ var hasTinymce = function () {
113
+ return !!tinymce();
114
+ };
115
+ var getTinymce = function () {
116
+ var tiny = tinymce();
117
+ if (tiny != null) {
118
+ return tiny;
119
+ }
120
+ throw new Error('Expected global tinymce');
121
+ };
122
+ var getTinymceInstance = function (element) {
123
+ var ed = null;
124
+ if (element && element.id && hasTinymce()) {
125
+ ed = getTinymce().get(element.id);
126
+ }
127
+ return ed;
128
+ };
129
+ var withTinymceInstance = function (node, ifPresent, ifMissing) {
130
+ var ed = getTinymceInstance(node);
131
+ if (ed) {
132
+ return ifPresent(ed);
133
+ } else if (ifMissing) {
134
+ return ifMissing(node);
135
+ }
136
+ };
137
+ var LoadStatus;
138
+ (function (LoadStatus) {
139
+ LoadStatus[LoadStatus['NOT_LOADING'] = 0] = 'NOT_LOADING';
140
+ LoadStatus[LoadStatus['LOADING_STARTED'] = 1] = 'LOADING_STARTED';
141
+ LoadStatus[LoadStatus['LOADING_FINISHED'] = 2] = 'LOADING_FINISHED';
142
+ }(LoadStatus || (LoadStatus = {})));
143
+ var lazyLoading = LoadStatus.NOT_LOADING;
144
+ var callbacks = [];
145
+ var loadTinymce = function (url, callback) {
146
+ if (!hasTinymce() && lazyLoading === LoadStatus.NOT_LOADING) {
147
+ lazyLoading = LoadStatus.LOADING_STARTED;
148
+ var script = document.createElement('script');
149
+ script.type = 'text/javascript';
150
+ script.onload = function (e) {
151
+ if (lazyLoading !== LoadStatus.LOADING_FINISHED && e.type === 'load') {
152
+ lazyLoading = LoadStatus.LOADING_FINISHED;
153
+ var tiny = getTinymce();
154
+ callback(tiny, true);
155
+ for (var i = 0; i < callbacks.length; i++) {
156
+ callbacks[i](tiny, false);
157
+ }
158
+ }
159
+ };
160
+ script.src = url;
161
+ document.body.appendChild(script);
162
+ } else {
163
+ if (lazyLoading === LoadStatus.LOADING_STARTED) {
164
+ callbacks.push(callback);
165
+ } else {
166
+ callback(getTinymce(), false);
167
+ }
168
+ }
169
+ };
170
+
171
+ var withEachContainedEditor = function (subject, callback) {
172
+ subject.each(function (i, elem) {
173
+ for (var _a = 0, _b = getTinymce().get(); _a < _b.length; _a++) {
174
+ var editor = _b[_a];
175
+ if ($.contains(elem, editor.getContentAreaContainer())) {
176
+ if (callback(editor, elem, subject) === false) {
177
+ return false;
178
+ }
179
+ }
180
+ }
181
+ return;
182
+ });
183
+ };
184
+ var withEachLinkedEditor = function (subject, callback) {
185
+ subject.each(function (_i, elm) {
186
+ return withTinymceInstance(elm, function (ed) {
187
+ return callback(ed, elm, subject);
188
+ });
189
+ });
190
+ };
191
+ var removeTargetElementEditor = function (subject) {
192
+ return withEachLinkedEditor(subject, function (ed) {
193
+ return ed.remove();
194
+ });
195
+ };
196
+ var removeChildEditors = function (subject) {
197
+ return withEachContainedEditor(subject, function (ed) {
198
+ return ed.remove();
199
+ });
200
+ };
201
+ var removeEditors = function (subject) {
202
+ removeTargetElementEditor(subject);
203
+ removeChildEditors(subject);
204
+ };
205
+ var patchJqAttr = function (origAttrFn) {
206
+ return function () {
207
+ var _this = this;
208
+ var args = [];
209
+ for (var _a = 0; _a < arguments.length; _a++) {
210
+ args[_a] = arguments[_a];
211
+ }
212
+ var setValue = function (valueOrProducer) {
213
+ if (valueOrProducer === undefined) {
214
+ return;
215
+ }
216
+ removeChildEditors(_this);
217
+ _this.each(function (i, elm) {
218
+ return withTinymceInstance(elm, function (ed) {
219
+ var value = isFunction(valueOrProducer) ? valueOrProducer.call(elm, i, ed.getContent()) : valueOrProducer;
220
+ if (value !== undefined) {
221
+ ed.setContent(value === null ? '' : ''.concat(value));
222
+ }
223
+ }, function (el) {
224
+ if (isFunction(valueOrProducer)) {
225
+ var origValue = origAttrFn.call($(el), 'value');
226
+ var newValue = valueOrProducer.call(el, i, origValue);
227
+ origAttrFn.call($(el), 'value', newValue);
228
+ } else {
229
+ origAttrFn.call($(el), 'value', valueOrProducer);
230
+ }
231
+ });
232
+ });
233
+ };
234
+ var nameOrBatch = args[0];
235
+ if (isString(nameOrBatch)) {
236
+ var name_1 = nameOrBatch;
237
+ if (name_1 !== 'value') {
238
+ return origAttrFn.apply(this, args);
239
+ }
240
+ var value = args[1];
241
+ if (value !== undefined) {
242
+ setValue(value);
243
+ return this;
244
+ } else {
245
+ if (this.length >= 1) {
246
+ return withTinymceInstance(this[0], function (ed) {
247
+ return ed.getContent();
248
+ }, function (_elm) {
249
+ return origAttrFn.call(_this, 'value');
250
+ });
251
+ }
252
+ return undefined;
253
+ }
254
+ } else {
255
+ var batch = __assign({}, nameOrBatch);
256
+ if (has(batch, 'value')) {
257
+ setValue(batch.value);
258
+ delete batch.value;
259
+ }
260
+ return keys(batch).length > 0 ? origAttrFn.call(this, batch) : this;
261
+ }
262
+ };
263
+ };
264
+ var patchJqRemove = function (origFn) {
265
+ return function (selector) {
266
+ removeEditors(selector !== undefined ? this.filter(selector) : this);
267
+ return origFn.call(this, selector);
268
+ };
269
+ };
270
+ var patchJqEmpty = function (origFn) {
271
+ return function () {
272
+ removeChildEditors(this);
273
+ withEachLinkedEditor(this, function (ed) {
274
+ return void ed.setContent('');
275
+ });
276
+ return origFn.call(this);
277
+ };
278
+ };
279
+ var stringifyContent = function (origFn, content) {
280
+ var dummy = document.createElement('div');
281
+ origFn.apply($(dummy), content);
282
+ return dummy.innerHTML;
283
+ };
284
+ var patchJqPend = function (origFn, position) {
285
+ return function () {
286
+ var args = [];
287
+ for (var _a = 0; _a < arguments.length; _a++) {
288
+ args[_a] = arguments[_a];
289
+ }
290
+ var prepend = position === 'prepend';
291
+ var contentStr;
292
+ if (args.length === 1 && isFunction(args[0])) {
293
+ var contentFn_1 = args[0];
294
+ contentStr = function (el, origContent) {
295
+ return stringifyContent(origFn, [contentFn_1.call(el, 0, origContent)]);
296
+ };
297
+ } else {
298
+ var content_1 = args;
299
+ contentStr = cached(function (_el, _origContent) {
300
+ return stringifyContent(origFn, content_1);
301
+ });
302
+ }
303
+ this.each(function (_i2, elm) {
304
+ return withTinymceInstance(elm, function (ed) {
305
+ var oldContent = ed.getContent();
306
+ var addition = contentStr(elm, oldContent);
307
+ ed.setContent(prepend ? addition + oldContent : oldContent + addition);
308
+ }, function (el) {
309
+ return void origFn.apply($(el), args);
310
+ });
311
+ });
312
+ return this;
313
+ };
314
+ };
315
+ var patchJqHtml = function (origFn) {
316
+ return function (htmlOrNodeOrProducer) {
317
+ if (htmlOrNodeOrProducer === undefined) {
318
+ if (this.length >= 1) {
319
+ return withTinymceInstance(this[0], function (ed) {
320
+ return ed.getContent();
321
+ }, function (el) {
322
+ return origFn.call($(el));
323
+ });
324
+ }
325
+ return undefined;
326
+ } else {
327
+ removeChildEditors(this);
328
+ this.each(function (i, el) {
329
+ withTinymceInstance(el, function (ed) {
330
+ var htmlOrNode = isFunction(htmlOrNodeOrProducer) ? htmlOrNodeOrProducer.call(el, i, ed.getContent()) : htmlOrNodeOrProducer;
331
+ var html = isString(htmlOrNode) ? htmlOrNode : function () {
332
+ if (isPrototypeOf(htmlOrNode)) {
333
+ removeEditors($(htmlOrNode));
334
+ }
335
+ var elem = document.createElement('div');
336
+ origFn.call($(elem), htmlOrNode);
337
+ return elem.innerHTML;
338
+ }();
339
+ ed.setContent(html);
340
+ }, function (elm) {
341
+ if (isFunction(htmlOrNodeOrProducer)) {
342
+ var origValue = origFn.call($(el));
343
+ var newValue = htmlOrNodeOrProducer.call(el, i, origValue);
344
+ origFn.call($(el), newValue);
345
+ } else {
346
+ origFn.call($(elm), htmlOrNodeOrProducer);
347
+ }
348
+ });
349
+ });
350
+ return this;
351
+ }
352
+ };
353
+ };
354
+ var patchJqText = function (origFn) {
355
+ return function (valueOrProducer) {
356
+ if (valueOrProducer === undefined) {
357
+ var out_1 = '';
358
+ this.each(function (_i, el) {
359
+ out_1 += withTinymceInstance(el, function (ed) {
360
+ return ed.getContent({ format: 'text' });
361
+ }, function (elm) {
362
+ return origFn.call($(elm));
363
+ });
364
+ });
365
+ return out_1;
366
+ } else {
367
+ removeChildEditors(this);
368
+ this.each(function (i, el) {
369
+ withTinymceInstance(el, function (ed) {
370
+ var val = isFunction(valueOrProducer) ? valueOrProducer.call(el, i, ed.getContent({ format: 'text' })) : valueOrProducer;
371
+ var dummy = document.createElement('div');
372
+ dummy.innerText = ''.concat(val);
373
+ ed.setContent(dummy.innerHTML);
374
+ }, function (elm) {
375
+ if (isFunction(valueOrProducer)) {
376
+ var origValue = origFn.call($(el));
377
+ var newValue = valueOrProducer.call(el, i, origValue);
378
+ origFn.call($(el), newValue);
379
+ } else {
380
+ origFn.call($(elm), valueOrProducer);
381
+ }
382
+ });
383
+ });
384
+ return this;
385
+ }
386
+ };
387
+ };
388
+ var patchJqVal = function (origFn) {
389
+ return function (valueOrProducer) {
390
+ if (valueOrProducer === undefined) {
391
+ if (this.length >= 1) {
392
+ return withTinymceInstance(this[0], function (ed) {
393
+ return ed.getContent();
394
+ }, function (elm) {
395
+ return origFn.call($(elm));
396
+ });
397
+ }
398
+ return undefined;
399
+ } else {
400
+ this.each(function (i, el) {
401
+ withTinymceInstance(el, function (ed) {
402
+ var val = isFunction(valueOrProducer) ? valueOrProducer.call(el, i, ed.getContent()) : valueOrProducer;
403
+ var html = isArray(val) ? val.join('') : ''.concat(val);
404
+ ed.setContent(html);
405
+ }, function (elm) {
406
+ if (isFunction(valueOrProducer)) {
407
+ var origValue = origFn.call($(el));
408
+ var newValue = valueOrProducer.call(el, i, origValue !== null && origValue !== void 0 ? origValue : '');
409
+ origFn.call($(el), newValue);
410
+ } else {
411
+ origFn.call($(elm), valueOrProducer);
412
+ }
413
+ });
414
+ });
415
+ }
416
+ return this;
417
+ };
418
+ };
419
+ var patchJQueryFunctions = function (jq) {
420
+ jq.fn.html = patchJqHtml(jq.fn.html);
421
+ jq.fn.text = patchJqText(jq.fn.text);
422
+ jq.fn.val = patchJqVal(jq.fn.val);
423
+ jq.fn.append = patchJqPend(jq.fn.append, 'append');
424
+ jq.fn.prepend = patchJqPend(jq.fn.prepend, 'prepend');
425
+ jq.fn.remove = patchJqRemove(jq.fn.remove);
426
+ jq.fn.empty = patchJqEmpty(jq.fn.empty);
427
+ jq.fn.attr = patchJqAttr(jq.fn.attr);
428
+ };
429
+
430
+ var getScriptSrc = function (settings) {
431
+ if (typeof settings.script_url === 'string') {
432
+ return settings.script_url;
433
+ } else {
434
+ var channel = typeof settings.channel === 'string' ? settings.channel : '5-stable';
435
+ var apiKey = typeof settings.api_key === 'string' ? settings.api_key : 'no-api-key';
436
+ return 'https://cdn.tiny.cloud/1/'.concat(apiKey, '/tinymce/').concat(channel, '/tinymce.min.js');
437
+ }
438
+ };
439
+ var getEditors = function (tinymce, self) {
440
+ var out = [];
441
+ self.each(function (i, ele) {
442
+ out.push(tinymce.get(ele.id));
443
+ });
444
+ return out;
445
+ };
446
+ var resolveFunction = function (tiny, fnOrStr) {
447
+ if (typeof fnOrStr === 'string') {
448
+ var func = tiny.resolve(fnOrStr);
449
+ if (typeof func === 'function') {
450
+ var scope = fnOrStr.indexOf('.') === -1 ? tiny : tiny.resolve(fnOrStr.replace(/\.\w+$/, ''));
451
+ return func.bind(scope);
452
+ }
453
+ } else if (typeof fnOrStr === 'function') {
454
+ return fnOrStr.bind(tiny);
455
+ }
456
+ return null;
457
+ };
458
+ var patchApplied = false;
459
+ var tinymceFn = function (settings) {
460
+ var _this = this;
461
+ var _a;
462
+ if (!this.length) {
463
+ return !settings ? undefined : Promise.resolve([]);
464
+ }
465
+ if (!settings) {
466
+ return (_a = getTinymceInstance(this[0])) !== null && _a !== void 0 ? _a : undefined;
467
+ }
468
+ this.css('visibility', 'hidden');
469
+ return new Promise(function (resolve) {
470
+ loadTinymce(getScriptSrc(settings), function (tinymce, loadedFromProvidedUrl) {
471
+ if (loadedFromProvidedUrl && settings.script_loaded) {
472
+ settings.script_loaded();
473
+ }
474
+ if (!patchApplied) {
475
+ patchApplied = true;
476
+ patchJQueryFunctions(getJquery());
477
+ }
478
+ var initCount = 0;
479
+ var allInitCallback = resolveFunction(tinymce, settings.oninit);
480
+ var allInitialized = function () {
481
+ var editors = getEditors(tinymce, _this);
482
+ if (allInitCallback) {
483
+ allInitCallback(editors);
484
+ }
485
+ resolve(editors);
486
+ };
487
+ _this.each(function (_i, elm) {
488
+ if (!elm.id) {
489
+ elm.id = tinymce.DOM.uniqueId();
490
+ }
491
+ if (tinymce.get(elm.id)) {
492
+ initCount++;
493
+ return;
494
+ }
495
+ var initInstanceCallback = function (editor) {
496
+ _this.css('visibility', '');
497
+ initCount++;
498
+ var origFn = settings.init_instance_callback;
499
+ if (typeof origFn === 'function') {
500
+ origFn.call(editor, editor);
501
+ }
502
+ if (initCount === _this.length) {
503
+ allInitialized();
504
+ }
505
+ };
506
+ tinymce.init(__assign(__assign({}, settings), {
507
+ selector: undefined,
508
+ target: elm,
509
+ init_instance_callback: initInstanceCallback
510
+ }));
511
+ });
512
+ if (initCount === _this.length) {
513
+ allInitialized();
514
+ }
515
+ });
516
+ });
517
+ };
518
+ var setupIntegration = function () {
519
+ var jq = getJquery();
520
+ jq.expr.pseudos.tinymce = function (e) {
521
+ return !!getTinymceInstance(e);
522
+ };
523
+ jq.fn.tinymce = tinymceFn;
524
+ };
525
+
526
+ setupIntegration();
527
+
528
+ })();
@@ -0,0 +1 @@
1
+ !function(){"use strict";var l=function(){return(l=Object.assign||function(n){for(var t,e=1,r=arguments.length;e<r;e++)for(var i in t=arguments[e])Object.prototype.hasOwnProperty.call(t,i)&&(n[i]=t[i]);return n}).apply(this,arguments)},t="undefined"!=typeof window?window:Function("return this;")(),e=function(){var n;return null!=(n=t&&t.jQuery)?n:null},a=function(){var n=e();if(null!=n)return n;throw new Error("Expected global jQuery")};const r=(n,t,e)=>{return!!e(n,t.prototype)||(null==(e=n.constructor)?void 0:e.name)===t.name};var i,n=t=>n=>(n=>{var t=typeof n;return null===n?"null":"object"==t&&Array.isArray(n)?"array":"object"==t&&r(n,String,(n,t)=>t.isPrototypeOf(n))?"string":t})(n)===t;const f=n("string"),o=n("object"),u=n("array"),s=(i="function",n=>typeof n===i),v=Object.keys,h=Object.hasOwnProperty,c="undefined"!=typeof window?window:Function("return this;")(),p=(n,e)=>{n=n.split(".");{var r=n;let t=null!=(n=e)?n:c;for(let n=0;n<r.length&&void 0!==t&&null!==t;++n)t=t[r[n]];return t}},d=(n,t)=>{e=n,t=t;var e=p(e,t);if(null==e)throw new Error(n+" not available on this browser");return e},y=Object.getPrototypeOf,g=n=>{var t=p("ownerDocument.defaultView",n);return o(n)&&(t=t,d("HTMLElement",t).prototype.isPrototypeOf(n)||/^HTML\w*Element$/.test(y(n).constructor.name))};function m(){var n;return null!=(n=t.tinymce)?n:null}function O(n,t,e){var r=j(n);return r?t(r):e?e(n):void 0}function w(e,r){e.each(function(n,t){return O(t,function(n){return r(n,t,e)})})}function D(n){var o,c;c=function(n){return n.remove()},(o=n).each(function(n,t){for(var e=0,r=L().get();e<r.length;e++){var i=r[e];if($.contains(t,i.getContentAreaContainer())&&!1===c(i,t,o))return!1}})}function _(n){w(n,function(n){return n.remove()}),D(n)}function I(u){return function(){for(var t=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];function r(i){void 0!==i&&(D(t),t.each(function(e,r){return O(r,function(n){var t=s(i)?i.call(r,e,n.getContent()):i;void 0!==t&&n.setContent(null===t?"":"".concat(t))},function(n){var t;s(i)?(t=u.call($(n),"value"),t=i.call(n,e,t),u.call($(n),"value",t)):u.call($(n),"value",i)})}))}var i,o=n[0];if(f(o)){if("value"!==o)return u.apply(this,n);var c=n[1];return void 0!==c?(r(c),this):1<=this.length?O(this[0],function(n){return n.getContent()},function(n){return u.call(t,"value")}):void 0}return c=l({},o),o=c,i="value",h.call(o,i)&&(r(c.value),delete c.value),0<v(c).length?u.call(this,c):this}}function b(n,t){var e=document.createElement("div");return n.apply($(e),t),e.innerHTML}function N(c,u){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e,i,r,o="prepend"===u;return i=1===t.length&&s(t[0])?(e=t[0],function(n,t){return b(c,[e.call(n,0,t)])}):(r=t,(t=>{let e=!1,r;return(...n)=>(e||(e=!0,r=t.apply(null,n)),r)})(function(n,t){return b(c,r)})),this.each(function(n,r){return O(r,function(n){var t=n.getContent(),e=i(r,t);n.setContent(o?e+t:t+e)},function(n){c.apply($(n),t)})}),this}}function A(c){return function(o){return void 0!==o?(D(this),this.each(function(r,i){O(i,function(n){var t,e=s(o)?o.call(i,r,n.getContent()):o,e=f(e)?e:(g(e)&&_($(e)),t=document.createElement("div"),c.call($(t),e),t.innerHTML);n.setContent(e)},function(n){var t;s(o)?(t=c.call($(i)),t=o.call(i,r,t),c.call($(i),t)):c.call($(n),o)})}),this):1<=this.length?O(this[0],function(n){return n.getContent()},function(n){return c.call($(n))}):void 0}}function E(c){var n,u=this;return this.length?c?(this.css("visibility","hidden"),new Promise(function(o){H(k(c),function(e,n){n&&c.script_loaded&&c.script_loaded(),S||(S=!0,P(a()));function r(){var n=F(e,u);t&&t(n),o(n)}var i=0,t=M(e,c.oninit);u.each(function(n,t){t.id||(t.id=e.DOM.uniqueId()),e.get(t.id)?i++:e.init(l(l({},c),{selector:void 0,target:t,init_instance_callback:function(n){u.css("visibility",""),i++;var t=c.init_instance_callback;"function"==typeof t&&t.call(n,n),i===u.length&&r()}}))}),i===u.length&&r()})})):null!=(n=j(this[0]))?n:void 0:c?Promise.resolve([]):void 0}var C,T=function(){return!!m()},L=function(){var n=m();if(null!=n)return n;throw new Error("Expected global tinymce")},j=function(n){var t=null;return t=n&&n.id&&T()?L().get(n.id):t},G=((n=C=C||{})[n.NOT_LOADING=0]="NOT_LOADING",n[n.LOADING_STARTED=1]="LOADING_STARTED",n[n.LOADING_FINISHED=2]="LOADING_FINISHED",C.NOT_LOADING),x=[],H=function(n,r){var t;T()||G!==C.NOT_LOADING?G===C.LOADING_STARTED?x.push(r):r(L(),!1):(G=C.LOADING_STARTED,(t=document.createElement("script")).type="text/javascript",t.onload=function(n){if(G!==C.LOADING_FINISHED&&"load"===n.type){G=C.LOADING_FINISHED;var t=L();r(t,!0);for(var e=0;e<x.length;e++)x[e](t,!1)}},t.src=n,document.body.appendChild(t))},P=function(n){var c,o,t,e;n.fn.html=A(n.fn.html),n.fn.text=(c=n.fn.text,function(o){var e;return void 0===o?(e="",this.each(function(n,t){e+=O(t,function(n){return n.getContent({format:"text"})},function(n){return c.call($(n))})}),e):(D(this),this.each(function(r,i){O(i,function(n){var t=s(o)?o.call(i,r,n.getContent({format:"text"})):o,e=document.createElement("div");e.innerText="".concat(t),n.setContent(e.innerHTML)},function(n){var t;s(o)?(t=c.call($(i)),t=o.call(i,r,t),c.call($(i),t)):c.call($(n),o)})}),this)}),n.fn.val=(o=n.fn.val,function(i){return void 0===i?1<=this.length?O(this[0],function(n){return n.getContent()},function(n){return o.call($(n))}):void 0:(this.each(function(e,r){O(r,function(n){var t=s(i)?i.call(r,e,n.getContent()):i,t=u(t)?t.join(""):"".concat(t);n.setContent(t)},function(n){var t;s(i)?(t=o.call($(r)),t=i.call(r,e,null!=t?t:""),o.call($(r),t)):o.call($(n),i)})}),this)}),n.fn.append=N(n.fn.append,"append"),n.fn.prepend=N(n.fn.prepend,"prepend"),n.fn.remove=(t=n.fn.remove,function(n){return _(void 0!==n?this.filter(n):this),t.call(this,n)}),n.fn.empty=(e=n.fn.empty,function(){return D(this),w(this,function(n){n.setContent("")}),e.call(this)}),n.fn.attr=I(n.fn.attr)},k=function(n){var t;return"string"==typeof n.script_url?n.script_url:(t="string"==typeof n.channel?n.channel:"5-stable",n="string"==typeof n.api_key?n.api_key:"no-api-key","https://cdn.tiny.cloud/1/".concat(n,"/tinymce/").concat(t,"/tinymce.min.js"))},F=function(e,n){var r=[];return n.each(function(n,t){r.push(e.get(t.id))}),r},M=function(n,t){if("string"==typeof t){var e,r=n.resolve(t);if("function"==typeof r)return e=-1===t.indexOf(".")?n:n.resolve(t.replace(/\.\w+$/,"")),r.bind(e)}else if("function"==typeof t)return t.bind(n);return null},S=!1;(n=a()).expr.pseudos.tinymce=function(n){return!!j(n)},n.fn.tinymce=E}();
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@tinymce/tinymce-jquery",
3
+ "version": "1.0.0",
4
+ "description": "Official TinyMCE integration for jQuery",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist",
8
+ "README.md",
9
+ "CHANGELOG.md",
10
+ "LICENSE.txt"
11
+ ],
12
+ "publishConfig": {
13
+ "access": "public",
14
+ "registry": "https://registry.npmjs.org/"
15
+ },
16
+ "scripts": {
17
+ "clean": "rimraf lib list",
18
+ "test": "bedrock-auto -b chrome-headless -d src/test/ts",
19
+ "test-manual": "bedrock -d src/test/ts",
20
+ "build": "yarn run clean && tsc -p ./tsconfig.json && rollup -c rollup.config.js",
21
+ "lint": "eslint src",
22
+ "storybook": "start-storybook -p 6006",
23
+ "build-storybook": "build-storybook",
24
+ "deploy-storybook": "yarn storybook-to-ghpages --source-branch=main"
25
+ },
26
+ "repository": "https://github.com/tinymce/tinymce-jquery",
27
+ "author": "Tiny Technologies",
28
+ "license": "MIT",
29
+ "devDependencies": {
30
+ "@babel/core": "^7.17.5",
31
+ "@ephox/agar": "^7.0.1",
32
+ "@ephox/bedrock-client": "^13.0.0",
33
+ "@ephox/bedrock-server": "^13.1.0",
34
+ "@ephox/katamari": "^9.0.1",
35
+ "@ephox/mcagar": "^8.0.1",
36
+ "@ephox/sand": "^6.0.1",
37
+ "@ephox/sugar": "^9.0.1",
38
+ "@ephox/swag": "^4.5.0",
39
+ "@storybook/addon-actions": "^6.4.19",
40
+ "@storybook/addon-essentials": "^6.4.19",
41
+ "@storybook/addon-links": "^6.4.19",
42
+ "@storybook/html": "^6.4.19",
43
+ "@storybook/storybook-deployer": "^2.8.10",
44
+ "@tinymce/beehive-flow": "^0.17.0",
45
+ "@tinymce/eslint-plugin": "^2.0.1",
46
+ "@types/express": "^4.17.13",
47
+ "@types/jquery": "^3.5.13",
48
+ "babel-loader": "^8.2.3",
49
+ "react": "^17.0.0",
50
+ "react-dom": "^17.0.0",
51
+ "rimraf": "^3.0.2",
52
+ "rollup": "^2.68.0",
53
+ "rollup-plugin-uglify": "^6.0.4",
54
+ "tinymce": "^6.0.0",
55
+ "ts-loader": "^9.2.6",
56
+ "tslib": "^2.3.1",
57
+ "typescript": "^4.5.5",
58
+ "webpack": "^5.69.1"
59
+ },
60
+ "dependencies": {}
61
+ }