tinymce-solid 0.0.1

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/dist/index.jsx ADDED
@@ -0,0 +1,709 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/prop-types/lib/ReactPropTypesSecret.js
28
+ var require_ReactPropTypesSecret = __commonJS({
29
+ "node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
30
+ "use strict";
31
+ var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
32
+ module.exports = ReactPropTypesSecret;
33
+ }
34
+ });
35
+
36
+ // node_modules/prop-types/factoryWithThrowingShims.js
37
+ var require_factoryWithThrowingShims = __commonJS({
38
+ "node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
39
+ "use strict";
40
+ var ReactPropTypesSecret = require_ReactPropTypesSecret();
41
+ function emptyFunction() {
42
+ }
43
+ function emptyFunctionWithReset() {
44
+ }
45
+ emptyFunctionWithReset.resetWarningCache = emptyFunction;
46
+ module.exports = function() {
47
+ function shim(props, propName, componentName, location, propFullName, secret) {
48
+ if (secret === ReactPropTypesSecret) {
49
+ return;
50
+ }
51
+ var err = new Error(
52
+ "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
53
+ );
54
+ err.name = "Invariant Violation";
55
+ throw err;
56
+ }
57
+ ;
58
+ shim.isRequired = shim;
59
+ function getShim() {
60
+ return shim;
61
+ }
62
+ ;
63
+ var ReactPropTypes = {
64
+ array: shim,
65
+ bigint: shim,
66
+ bool: shim,
67
+ func: shim,
68
+ number: shim,
69
+ object: shim,
70
+ string: shim,
71
+ symbol: shim,
72
+ any: shim,
73
+ arrayOf: getShim,
74
+ element: shim,
75
+ elementType: shim,
76
+ instanceOf: getShim,
77
+ node: shim,
78
+ objectOf: getShim,
79
+ oneOf: getShim,
80
+ oneOfType: getShim,
81
+ shape: getShim,
82
+ exact: getShim,
83
+ checkPropTypes: emptyFunctionWithReset,
84
+ resetWarningCache: emptyFunction
85
+ };
86
+ ReactPropTypes.PropTypes = ReactPropTypes;
87
+ return ReactPropTypes;
88
+ };
89
+ }
90
+ });
91
+
92
+ // node_modules/prop-types/index.js
93
+ var require_prop_types = __commonJS({
94
+ "node_modules/prop-types/index.js"(exports, module) {
95
+ "use strict";
96
+ if (false) {
97
+ ReactIs = null;
98
+ throwOnDirectAccess = true;
99
+ module.exports = null(ReactIs.isElement, throwOnDirectAccess);
100
+ } else {
101
+ module.exports = require_factoryWithThrowingShims()();
102
+ }
103
+ var ReactIs;
104
+ var throwOnDirectAccess;
105
+ }
106
+ });
107
+
108
+ // src/components/SolidEditor.tsx
109
+ import { createEffect, createSignal, on, onCleanup, onMount } from "solid-js";
110
+
111
+ // src/components/EditorPropTypes.ts
112
+ var PropTypes = __toESM(require_prop_types(), 1);
113
+ var eventPropTypes = {
114
+ onActivate: PropTypes.func,
115
+ onAddUndo: PropTypes.func,
116
+ onBeforeAddUndo: PropTypes.func,
117
+ onBeforeExecCommand: PropTypes.func,
118
+ onBeforeGetContent: PropTypes.func,
119
+ onBeforeRenderUI: PropTypes.func,
120
+ onBeforeSetContent: PropTypes.func,
121
+ onBeforePaste: PropTypes.func,
122
+ onBlur: PropTypes.func,
123
+ onChange: PropTypes.func,
124
+ onClearUndos: PropTypes.func,
125
+ onClick: PropTypes.func,
126
+ onContextMenu: PropTypes.func,
127
+ onCommentChange: PropTypes.func,
128
+ onCompositionEnd: PropTypes.func,
129
+ onCompositionStart: PropTypes.func,
130
+ onCompositionUpdate: PropTypes.func,
131
+ onCopy: PropTypes.func,
132
+ onCut: PropTypes.func,
133
+ onDblclick: PropTypes.func,
134
+ onDeactivate: PropTypes.func,
135
+ onDirty: PropTypes.func,
136
+ onDrag: PropTypes.func,
137
+ onDragDrop: PropTypes.func,
138
+ onDragEnd: PropTypes.func,
139
+ onDragGesture: PropTypes.func,
140
+ onDragOver: PropTypes.func,
141
+ onDrop: PropTypes.func,
142
+ onExecCommand: PropTypes.func,
143
+ onFocus: PropTypes.func,
144
+ onFocusIn: PropTypes.func,
145
+ onFocusOut: PropTypes.func,
146
+ onGetContent: PropTypes.func,
147
+ onHide: PropTypes.func,
148
+ onInit: PropTypes.func,
149
+ onInput: PropTypes.func,
150
+ onKeyDown: PropTypes.func,
151
+ onKeyPress: PropTypes.func,
152
+ onKeyUp: PropTypes.func,
153
+ onLoadContent: PropTypes.func,
154
+ onMouseDown: PropTypes.func,
155
+ onMouseEnter: PropTypes.func,
156
+ onMouseLeave: PropTypes.func,
157
+ onMouseMove: PropTypes.func,
158
+ onMouseOut: PropTypes.func,
159
+ onMouseOver: PropTypes.func,
160
+ onMouseUp: PropTypes.func,
161
+ onNodeChange: PropTypes.func,
162
+ onObjectResizeStart: PropTypes.func,
163
+ onObjectResized: PropTypes.func,
164
+ onObjectSelected: PropTypes.func,
165
+ onPaste: PropTypes.func,
166
+ onPostProcess: PropTypes.func,
167
+ onPostRender: PropTypes.func,
168
+ onPreProcess: PropTypes.func,
169
+ onProgressState: PropTypes.func,
170
+ onRedo: PropTypes.func,
171
+ onRemove: PropTypes.func,
172
+ onReset: PropTypes.func,
173
+ onSaveContent: PropTypes.func,
174
+ onSelectionChange: PropTypes.func,
175
+ onSetAttrib: PropTypes.func,
176
+ onSetContent: PropTypes.func,
177
+ onShow: PropTypes.func,
178
+ onSubmit: PropTypes.func,
179
+ onUndo: PropTypes.func,
180
+ onVisualAid: PropTypes.func,
181
+ onSkinLoadError: PropTypes.func,
182
+ onThemeLoadError: PropTypes.func,
183
+ onModelLoadError: PropTypes.func,
184
+ onPluginLoadError: PropTypes.func,
185
+ onIconsLoadError: PropTypes.func,
186
+ onLanguageLoadError: PropTypes.func,
187
+ onScriptsLoad: PropTypes.func,
188
+ onScriptsLoadError: PropTypes.func
189
+ };
190
+ var EditorPropTypes = {
191
+ apiKey: PropTypes.string,
192
+ licenseKey: PropTypes.string,
193
+ id: PropTypes.string,
194
+ inline: PropTypes.bool,
195
+ init: PropTypes.object,
196
+ initialValue: PropTypes.string,
197
+ onEditorChange: PropTypes.func,
198
+ value: PropTypes.string,
199
+ tagName: PropTypes.string,
200
+ tabIndex: PropTypes.number,
201
+ cloudChannel: PropTypes.string,
202
+ plugins: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
203
+ toolbar: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
204
+ disabled: PropTypes.bool,
205
+ textareaName: PropTypes.string,
206
+ tinymceScriptSrc: PropTypes.oneOfType([
207
+ PropTypes.string,
208
+ PropTypes.arrayOf(PropTypes.string),
209
+ PropTypes.arrayOf(
210
+ PropTypes.shape({
211
+ src: PropTypes.string,
212
+ async: PropTypes.bool,
213
+ defer: PropTypes.bool
214
+ })
215
+ )
216
+ ]),
217
+ rollback: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf([false])]),
218
+ scriptLoading: PropTypes.shape({
219
+ async: PropTypes.bool,
220
+ defer: PropTypes.bool,
221
+ delay: PropTypes.number
222
+ }),
223
+ ...eventPropTypes
224
+ };
225
+
226
+ // src/Utils.ts
227
+ var isFunction = (x) => typeof x === "function";
228
+ var isEventProp = (name) => name in eventPropTypes;
229
+ var eventAttrToEventName = (attrName) => attrName.substr(2);
230
+ var configHandlers2 = (handlerLookup, on2, off, adapter, prevProps, props, boundHandlers) => {
231
+ const prevEventKeys = Object.keys(prevProps).filter(isEventProp);
232
+ const currEventKeys = Object.keys(props).filter(isEventProp);
233
+ const removedKeys = prevEventKeys.filter((key) => props[key] === void 0);
234
+ const addedKeys = currEventKeys.filter((key) => prevProps[key] === void 0);
235
+ removedKeys.forEach((key) => {
236
+ const eventName = eventAttrToEventName(key);
237
+ const wrappedHandler = boundHandlers[eventName];
238
+ off(eventName, wrappedHandler);
239
+ delete boundHandlers[eventName];
240
+ });
241
+ addedKeys.forEach((key) => {
242
+ const wrappedHandler = adapter(handlerLookup, key);
243
+ const eventName = eventAttrToEventName(key);
244
+ boundHandlers[eventName] = wrappedHandler;
245
+ on2(eventName, wrappedHandler);
246
+ });
247
+ };
248
+ var configHandlers = (editor, prevProps, props, boundHandlers, lookup) => configHandlers2(
249
+ lookup,
250
+ editor.on.bind(editor),
251
+ editor.off.bind(editor),
252
+ // @ts-expect-error: typescript cannot infer the type of the lookup function
253
+ (handlerLookup, key) => (e) => handlerLookup(key)?.(e, editor),
254
+ prevProps,
255
+ props,
256
+ boundHandlers
257
+ );
258
+ var unique = 0;
259
+ var uuid = (prefix) => {
260
+ const time = Date.now();
261
+ const random = Math.floor(Math.random() * 1e9);
262
+ unique++;
263
+ return prefix + "_" + random + unique + String(time);
264
+ };
265
+ var isTextareaOrInput = (element) => element !== null && (element.tagName.toLowerCase() === "textarea" || element.tagName.toLowerCase() === "input");
266
+ var normalizePluginArray = (plugins) => {
267
+ if (typeof plugins === "undefined" || plugins === "") {
268
+ return [];
269
+ }
270
+ return Array.isArray(plugins) ? plugins : plugins.split(" ");
271
+ };
272
+ var mergePlugins = (initPlugins, inputPlugins) => normalizePluginArray(initPlugins).concat(normalizePluginArray(inputPlugins));
273
+ var isBeforeInputEventAvailable = () => window.InputEvent && typeof InputEvent.prototype.getTargetRanges === "function";
274
+ var isInDoc = (elem) => {
275
+ if (!("isConnected" in Node.prototype)) {
276
+ let current = elem;
277
+ let parent = elem.parentNode;
278
+ while (parent != null) {
279
+ current = parent;
280
+ parent = current.parentNode;
281
+ }
282
+ return current === elem.ownerDocument;
283
+ }
284
+ return elem.isConnected;
285
+ };
286
+ var setMode = (editor, mode) => {
287
+ if (editor !== void 0) {
288
+ if (editor.mode != null && typeof editor.mode === "object" && typeof editor.mode.set === "function") {
289
+ editor.mode.set(mode);
290
+ } else {
291
+ editor.setMode(mode);
292
+ }
293
+ }
294
+ };
295
+
296
+ // src/ScriptLoader2.ts
297
+ var injectScriptTag = (doc, item, handler) => {
298
+ const scriptTag = doc.createElement("script");
299
+ scriptTag.referrerPolicy = "origin";
300
+ scriptTag.type = "application/javascript";
301
+ scriptTag.id = item.id;
302
+ scriptTag.src = item.src;
303
+ scriptTag.async = item.async ?? false;
304
+ scriptTag.defer = item.defer ?? false;
305
+ const loadHandler = () => {
306
+ scriptTag.removeEventListener("load", loadHandler);
307
+ scriptTag.removeEventListener("error", errorHandler);
308
+ handler(item.src);
309
+ };
310
+ const errorHandler = (err) => {
311
+ scriptTag.removeEventListener("load", loadHandler);
312
+ scriptTag.removeEventListener("error", errorHandler);
313
+ handler(item.src, err);
314
+ };
315
+ scriptTag.addEventListener("load", loadHandler);
316
+ scriptTag.addEventListener("error", errorHandler);
317
+ if (doc.head) {
318
+ doc.head.appendChild(scriptTag);
319
+ }
320
+ };
321
+ var createDocumentScriptLoader = (doc) => {
322
+ let lookup = {};
323
+ const scriptLoadOrErrorHandler = (src, err) => {
324
+ const item = lookup[src];
325
+ item.done = true;
326
+ item.error = err;
327
+ for (const h of item.handlers) {
328
+ h(src, err);
329
+ }
330
+ item.handlers = [];
331
+ };
332
+ const loadScripts = (items, success, failure) => {
333
+ const failureOrLog = (err) => failure !== void 0 ? failure(err) : void 0;
334
+ if (items.length === 0) {
335
+ failureOrLog(new Error("At least one script must be provided"));
336
+ return;
337
+ }
338
+ let successCount = 0;
339
+ let failed = false;
340
+ const loaded = (_src, err) => {
341
+ if (failed) {
342
+ return;
343
+ }
344
+ if (err) {
345
+ failed = true;
346
+ failureOrLog(err);
347
+ } else if (++successCount === items.length) {
348
+ success();
349
+ }
350
+ };
351
+ for (const item of items) {
352
+ const existing = lookup[item.src];
353
+ if (existing) {
354
+ if (existing.done) {
355
+ loaded(item.src, existing.error);
356
+ } else {
357
+ existing.handlers.push(loaded);
358
+ }
359
+ } else {
360
+ const id = uuid("tiny-");
361
+ lookup[item.src] = {
362
+ id,
363
+ src: item.src,
364
+ done: false,
365
+ error: null,
366
+ handlers: [loaded]
367
+ };
368
+ injectScriptTag(doc, { id, ...item }, scriptLoadOrErrorHandler);
369
+ }
370
+ }
371
+ };
372
+ const deleteScripts = () => {
373
+ for (const item of Object.values(lookup)) {
374
+ const scriptTag = doc.getElementById(item.id);
375
+ if (scriptTag != null && scriptTag.tagName === "SCRIPT") {
376
+ scriptTag.parentNode?.removeChild(scriptTag);
377
+ }
378
+ }
379
+ lookup = {};
380
+ };
381
+ const getDocument = () => doc;
382
+ return {
383
+ loadScripts,
384
+ deleteScripts,
385
+ getDocument
386
+ };
387
+ };
388
+ var createScriptLoader = () => {
389
+ const cache = [];
390
+ const getDocumentScriptLoader = (doc) => {
391
+ let loader = cache.find((l) => l.getDocument() === doc);
392
+ if (loader === void 0) {
393
+ loader = createDocumentScriptLoader(doc);
394
+ cache.push(loader);
395
+ }
396
+ return loader;
397
+ };
398
+ const loadList = (doc, items, delay, success, failure) => {
399
+ const doLoad = () => getDocumentScriptLoader(doc).loadScripts(items, success, failure);
400
+ if (delay > 0) {
401
+ setTimeout(doLoad, delay);
402
+ } else {
403
+ doLoad();
404
+ }
405
+ };
406
+ const reinitialize = () => {
407
+ for (let loader = cache.pop(); loader != null; loader = cache.pop()) {
408
+ loader.deleteScripts();
409
+ }
410
+ };
411
+ return {
412
+ loadList,
413
+ reinitialize
414
+ };
415
+ };
416
+ var ScriptLoader = createScriptLoader();
417
+
418
+ // src/TinyMCE.ts
419
+ var getTinymce = (view) => {
420
+ const global = view;
421
+ return global && global.tinymce ? global.tinymce : null;
422
+ };
423
+
424
+ // src/components/SolidEditor.tsx
425
+ var SolidEditor = (props) => {
426
+ const [id] = createSignal(props.id || uuid("solid-tinymce-editor"));
427
+ const initialValue = () => props.initialValue;
428
+ const value = () => props.value || "";
429
+ const skin = () => props.skin || "oxide";
430
+ const contentCss = () => props.contentCss || "default";
431
+ const [editor, setEditor] = createSignal();
432
+ const [currentContent, setCurrentContent] = createSignal(value());
433
+ const [rollbackTimer, setRollbackTimer] = createSignal();
434
+ const [valueCursor, setValueCursor] = createSignal();
435
+ const [boundHandlers, setBoundHandlers] = createSignal({});
436
+ const view = () => props?.elementRef?.ownerDocument.defaultView ?? window;
437
+ const getInitialValue = () => {
438
+ if (typeof initialValue() === "string") {
439
+ return initialValue();
440
+ } else if (typeof value() === "string") {
441
+ return value();
442
+ } else {
443
+ return "";
444
+ }
445
+ };
446
+ const getScriptSources = () => {
447
+ const async = props.scriptLoading?.async;
448
+ const defer = props.scriptLoading?.defer;
449
+ if (props.tinymceScriptSrc !== void 0) {
450
+ if (typeof props.tinymceScriptSrc === "string") {
451
+ return [{ src: props.tinymceScriptSrc, async, defer }];
452
+ }
453
+ return props.tinymceScriptSrc.map((item) => {
454
+ if (typeof item === "string") {
455
+ return { src: item, async, defer };
456
+ } else {
457
+ return item;
458
+ }
459
+ });
460
+ }
461
+ const channel = props.cloudChannel || "7";
462
+ const apiKey = props.apiKey ? props.apiKey : "no-api-key";
463
+ const cloudTinyJs = `https://cdn.tiny.cloud/1/${apiKey}/tinymce/${channel}/tinymce.min.js`;
464
+ return [{ src: cloudTinyJs, async, defer }];
465
+ };
466
+ const bindHandlers = (prevProps) => {
467
+ if (editor() !== void 0) {
468
+ const tinyEditor = editor();
469
+ configHandlers(
470
+ tinyEditor,
471
+ prevProps,
472
+ props,
473
+ boundHandlers(),
474
+ (key) => props[key]
475
+ );
476
+ const isValueControlled = (p) => p.onEditorChange !== void 0 || p.value !== void 0;
477
+ const wasControlled = isValueControlled(prevProps);
478
+ const nowControlled = isValueControlled(props);
479
+ if (!wasControlled && nowControlled) {
480
+ tinyEditor.on(changeEvents(), handleEditorChange);
481
+ tinyEditor.on(beforeInputEvent(), handleBeforeInput);
482
+ tinyEditor.on("keydown", handleBeforeInputSpecial);
483
+ tinyEditor.on("keyup", handleEditorChangeSpecial);
484
+ tinyEditor.on("NewBlock", handleEditorChange);
485
+ } else if (wasControlled && !nowControlled) {
486
+ tinyEditor.off(changeEvents(), handleEditorChange);
487
+ tinyEditor.off(beforeInputEvent(), handleBeforeInput);
488
+ tinyEditor.off("keydown", handleBeforeInputSpecial);
489
+ tinyEditor.off("keyup", handleEditorChangeSpecial);
490
+ tinyEditor.off("NewBlock", handleEditorChange);
491
+ }
492
+ }
493
+ };
494
+ const initialise = (attempts = 0) => {
495
+ const target = props.elementRef;
496
+ if (!target) {
497
+ return;
498
+ }
499
+ if (!isInDoc(target)) {
500
+ if (attempts === 0) {
501
+ setTimeout(() => initialise(1), 1);
502
+ } else if (attempts < 100) {
503
+ setTimeout(() => initialise(attempts + 1), 100);
504
+ } else {
505
+ throw new Error("tinymce can only be initialised when in a document");
506
+ }
507
+ return;
508
+ }
509
+ const tinymce = getTinymce(view());
510
+ if (!tinymce) {
511
+ throw new Error("tinymce should have been loaded into global scope");
512
+ }
513
+ const finalInit = {
514
+ ...props.init,
515
+ selector: void 0,
516
+ target,
517
+ skin: skin(),
518
+ content_css: contentCss(),
519
+ readonly: props.disabled,
520
+ inline: props.inline,
521
+ plugins: mergePlugins(props.init?.plugins, props.plugins),
522
+ toolbar: props.toolbar ?? props.init?.toolbar,
523
+ ...props.licenseKey ? { license_key: props.licenseKey } : {},
524
+ setup: (editor2) => {
525
+ setEditor(editor2);
526
+ bindHandlers({});
527
+ if (props.inline && !isTextareaOrInput(target)) {
528
+ editor2.once("PostRender", (_evt) => {
529
+ editor2.setContent(getInitialValue(), {
530
+ no_events: true,
531
+ event_name: _evt.type
532
+ });
533
+ });
534
+ }
535
+ if (props.init && isFunction(props.init.setup)) {
536
+ props.init.setup(editor2);
537
+ }
538
+ },
539
+ init_instance_callback: (editor2) => {
540
+ const initialValue2 = getInitialValue();
541
+ let newCurrentValue = currentContent() ?? editor2.getContent();
542
+ if (newCurrentValue !== initialValue2) {
543
+ newCurrentValue = initialValue2;
544
+ editor2.setContent(initialValue2);
545
+ editor2.undoManager.clear();
546
+ editor2.undoManager.add();
547
+ editor2.setDirty(false);
548
+ }
549
+ setCurrentContent(newCurrentValue);
550
+ const disabled = props.disabled ?? false;
551
+ setMode(editor2, disabled ? "readonly" : "design");
552
+ if (props.init && isFunction(props.init.init_instance_callback)) {
553
+ props.init.init_instance_callback(editor2);
554
+ }
555
+ }
556
+ };
557
+ if (!props.inline) {
558
+ target.style.visibility = "";
559
+ }
560
+ if (isTextareaOrInput(target)) {
561
+ target.value = getInitialValue();
562
+ }
563
+ tinymce.init(finalInit);
564
+ };
565
+ const mountCallback = () => {
566
+ if (getTinymce(view()) !== null) {
567
+ initialise();
568
+ } else if (Array.isArray(props.tinymceScriptSrc) && props.tinymceScriptSrc.length === 0) {
569
+ throw new Error(
570
+ "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."
571
+ );
572
+ } else if (props?.elementRef?.ownerDocument) {
573
+ const successHandler = () => {
574
+ initialise();
575
+ };
576
+ const errorHandler = (err) => {
577
+ throw new Error(err);
578
+ };
579
+ ScriptLoader.loadList(
580
+ props.elementRef.ownerDocument,
581
+ getScriptSources(),
582
+ props.scriptLoading?.delay ?? 0,
583
+ successHandler,
584
+ errorHandler
585
+ );
586
+ }
587
+ };
588
+ const cleanUpCallback = () => {
589
+ const tinyEditor = editor();
590
+ if (typeof tinyEditor !== "undefined") {
591
+ tinyEditor.off(changeEvents(), handleEditorChange);
592
+ tinyEditor.off(beforeInputEvent(), handleBeforeInput);
593
+ tinyEditor.off("keypress", handleEditorChangeSpecial);
594
+ tinyEditor.off("keydown", handleBeforeInputSpecial);
595
+ tinyEditor.off("NewBlock", handleEditorChange);
596
+ Object.keys(boundHandlers()).forEach((eventName) => {
597
+ tinyEditor.off(eventName, boundHandlers()[eventName]);
598
+ });
599
+ setBoundHandlers({});
600
+ tinyEditor.destroy();
601
+ tinyEditor.remove();
602
+ setEditor();
603
+ }
604
+ };
605
+ createEffect(
606
+ on(value, () => {
607
+ if (value() !== currentContent()) {
608
+ setCurrentContent(value());
609
+ editor()?.setContent(value(), { no_events: true, event_name: "input" });
610
+ }
611
+ })
612
+ );
613
+ createEffect(
614
+ on(skin, () => {
615
+ cleanUpCallback();
616
+ setTimeout(() => {
617
+ mountCallback();
618
+ }, 34);
619
+ })
620
+ );
621
+ onMount(mountCallback);
622
+ onCleanup(cleanUpCallback);
623
+ const changeEvents = () => {
624
+ const isIE = getTinymce(view())?.Env?.browser?.isIE();
625
+ return isIE ? "change keyup compositionend setcontent CommentChange" : "change input compositionend setcontent CommentChange";
626
+ };
627
+ const beforeInputEvent = () => {
628
+ return isBeforeInputEventAvailable() ? "beforeinput SelectionChange" : "SelectionChange";
629
+ };
630
+ const handleEditorChange = (event) => {
631
+ const tinyEditor = editor();
632
+ if (tinyEditor && tinyEditor.initialized && !event.isDefaultPrevented()) {
633
+ const newContent = tinyEditor.getContent();
634
+ if (props.value !== void 0 && props.value !== newContent && props.rollback !== false) {
635
+ if (!rollbackTimer()) {
636
+ setRollbackTimer(
637
+ window.setTimeout(
638
+ rollbackChange,
639
+ typeof props.rollback === "number" ? props.rollback : 200
640
+ )
641
+ );
642
+ }
643
+ }
644
+ if (newContent !== currentContent()) {
645
+ setCurrentContent(newContent);
646
+ if (isFunction(props.onEditorChange)) {
647
+ props.onEditorChange(newContent, tinyEditor);
648
+ }
649
+ }
650
+ }
651
+ };
652
+ const rollbackChange = () => {
653
+ const tinyEditor = editor();
654
+ const value2 = props.value;
655
+ if (tinyEditor && value2 && value2 !== currentContent()) {
656
+ tinyEditor.undoManager.ignore(() => {
657
+ tinyEditor.setContent(value2);
658
+ if (valueCursor() && (!props.inline || tinyEditor.hasFocus())) {
659
+ try {
660
+ tinyEditor.selection.moveToBookmark(valueCursor());
661
+ } catch (e) {
662
+ }
663
+ }
664
+ });
665
+ }
666
+ setRollbackTimer(void 0);
667
+ };
668
+ const handleBeforeInput = (event) => {
669
+ const tinyEditor = editor();
670
+ if (props.value !== void 0 && props.value === currentContent() && tinyEditor && !event.isDefaultPrevented()) {
671
+ if (!props.inline || tinyEditor.hasFocus()) {
672
+ try {
673
+ setValueCursor(tinyEditor.selection.getBookmark(3));
674
+ } catch (e) {
675
+ }
676
+ }
677
+ }
678
+ };
679
+ const handleEditorChangeSpecial = (evt) => {
680
+ if (evt.key === "Enter" || evt.key === "Backspace" || evt.key === "Delete") {
681
+ handleBeforeInput(evt);
682
+ }
683
+ };
684
+ const handleBeforeInputSpecial = (evt) => {
685
+ if (evt.key === "Enter" || evt.key === "Backspace" || evt.key === "Delete") {
686
+ handleBeforeInput(evt);
687
+ }
688
+ };
689
+ return props.inline ? <div
690
+ style={{ display: editor() ? "" : "none" }}
691
+ ref={props.elementRef}
692
+ id={id()}
693
+ data-testid={props.testid}
694
+ tabIndex={props.tabIndex}
695
+ /> : <textarea
696
+ style={{ display: editor() ? "" : "none" }}
697
+ ref={props.elementRef}
698
+ id={id()}
699
+ data-testid={props.testid}
700
+ tabIndex={props.tabIndex}
701
+ />;
702
+ };
703
+
704
+ // src/index.tsx
705
+ var src_default = SolidEditor;
706
+ export {
707
+ EditorPropTypes,
708
+ src_default as default
709
+ };
@@ -0,0 +1,5 @@
1
+ // @ts-check
2
+
3
+ import tseslint from "typescript-eslint";
4
+
5
+ export default tseslint.config(...tseslint.configs.recommended);