tinymce-solid 0.0.1 → 0.0.3
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/.github/workflows/codeql.yml +2 -2
- package/README.md +13 -2
- package/components.json +2 -2
- package/dist/dev.js +47 -42
- package/dist/dev.jsx +40 -31
- package/dist/index.js +37 -32
- package/dist/index.jsx +30 -21
- package/package.json +14 -6
- package/src/TinyMCE.ts +1 -1
- package/src/components/SolidEditor.tsx +28 -23
- package/tsconfig.json +1 -0
- package/tsup.config.ts +0 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# TinyMCE Component for SolidJS
|
|
2
2
|
|
|
3
|
-
[<img width="100%" src="banner.svg" alt="TinyMCE Component for SolidJS">](https://thednp.github.io/tinymce-solid)
|
|
3
|
+
[<img width="100%" src="https://raw.githubusercontent.com/thednp/tinymce-solid/main/banner.svg" alt="TinyMCE Component for SolidJS">](https://thednp.github.io/tinymce-solid)
|
|
4
4
|
|
|
5
5
|
[](https://github.com/thednp/tinymce-solid/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/tinymce-solid)
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
## About
|
|
14
14
|
|
|
15
|
-
This package is a wrapper around [TinyMCE](https://github.com/tinymce/tinymce) to make it easier to use in a
|
|
15
|
+
This package is a wrapper around [TinyMCE](https://github.com/tinymce/tinymce) to make it easier to use in a SolidJS / SolidStart application.
|
|
16
16
|
|
|
17
17
|
- If you need detailed documentation on TinyMCE, see: [TinyMCE Documentation](https://www.tiny.cloud/docs/tinymce/7/).
|
|
18
18
|
- This is a community developed package forked from the TinyMCE React, see: [Official TinyMCE React](https://github.com/tinymce/tinymce-react) for more information.
|
|
@@ -118,6 +118,17 @@ export default function App() {
|
|
|
118
118
|
}
|
|
119
119
|
```
|
|
120
120
|
|
|
121
|
+
### Properties
|
|
122
|
+
|
|
123
|
+
* *skin*: **reactive** - change the skin of the editor
|
|
124
|
+
* *contentCss*: **reactive** - change the styling of the content
|
|
125
|
+
* *disabled*: **reactive** - toggles the `disabled` property of the editor
|
|
126
|
+
* *value*: **reactive** - the actual content;
|
|
127
|
+
* *initialValue*: **reactive** - the initial content value;
|
|
128
|
+
* *onEditorChange*: `(content: string, editor: Editor)` - the callback you can use to update the parent state;
|
|
129
|
+
* all other TinyMCE properties are non-reactive and should work as designed for the original TinyMCE React component.
|
|
130
|
+
|
|
131
|
+
|
|
121
132
|
### Some notes
|
|
122
133
|
|
|
123
134
|
- This package will automatically load the tinymce library and its dependencies by the use of the `tinymceScriptSrc` property
|
package/components.json
CHANGED
package/dist/dev.js
CHANGED
|
@@ -27,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// node_modules/react-is/cjs/react-is.development.js
|
|
30
|
+
// node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js
|
|
31
31
|
var require_react_is_development = __commonJS({
|
|
32
|
-
"node_modules/react-is/cjs/react-is.development.js"(exports) {
|
|
32
|
+
"node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js"(exports) {
|
|
33
33
|
{
|
|
34
34
|
(function() {
|
|
35
35
|
var hasSymbol = typeof Symbol === "function" && Symbol.for;
|
|
@@ -180,18 +180,18 @@ var require_react_is_development = __commonJS({
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
|
|
183
|
-
// node_modules/react-is/index.js
|
|
183
|
+
// node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js
|
|
184
184
|
var require_react_is = __commonJS({
|
|
185
|
-
"node_modules/react-is/index.js"(exports, module) {
|
|
185
|
+
"node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js"(exports, module) {
|
|
186
186
|
{
|
|
187
187
|
module.exports = require_react_is_development();
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
});
|
|
191
191
|
|
|
192
|
-
// node_modules/object-assign/index.js
|
|
192
|
+
// node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js
|
|
193
193
|
var require_object_assign = __commonJS({
|
|
194
|
-
"node_modules/object-assign/index.js"(exports, module) {
|
|
194
|
+
"node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js"(exports, module) {
|
|
195
195
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
196
196
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
197
197
|
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
@@ -258,24 +258,24 @@ var require_object_assign = __commonJS({
|
|
|
258
258
|
}
|
|
259
259
|
});
|
|
260
260
|
|
|
261
|
-
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
261
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
262
262
|
var require_ReactPropTypesSecret = __commonJS({
|
|
263
|
-
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
263
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
264
264
|
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
265
265
|
module.exports = ReactPropTypesSecret;
|
|
266
266
|
}
|
|
267
267
|
});
|
|
268
268
|
|
|
269
|
-
// node_modules/prop-types/lib/has.js
|
|
269
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js
|
|
270
270
|
var require_has = __commonJS({
|
|
271
|
-
"node_modules/prop-types/lib/has.js"(exports, module) {
|
|
271
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js"(exports, module) {
|
|
272
272
|
module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
273
273
|
}
|
|
274
274
|
});
|
|
275
275
|
|
|
276
|
-
// node_modules/prop-types/checkPropTypes.js
|
|
276
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js
|
|
277
277
|
var require_checkPropTypes = __commonJS({
|
|
278
|
-
"node_modules/prop-types/checkPropTypes.js"(exports, module) {
|
|
278
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js"(exports, module) {
|
|
279
279
|
var printWarning = function() {
|
|
280
280
|
};
|
|
281
281
|
{
|
|
@@ -338,9 +338,9 @@ var require_checkPropTypes = __commonJS({
|
|
|
338
338
|
}
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
// node_modules/prop-types/factoryWithTypeCheckers.js
|
|
341
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js
|
|
342
342
|
var require_factoryWithTypeCheckers = __commonJS({
|
|
343
|
-
"node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
|
|
343
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
|
|
344
344
|
var ReactIs = require_react_is();
|
|
345
345
|
var assign = require_object_assign();
|
|
346
346
|
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
@@ -780,9 +780,9 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
|
780
780
|
}
|
|
781
781
|
});
|
|
782
782
|
|
|
783
|
-
// node_modules/prop-types/index.js
|
|
783
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
|
|
784
784
|
var require_prop_types = __commonJS({
|
|
785
|
-
"node_modules/prop-types/index.js"(exports, module) {
|
|
785
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js"(exports, module) {
|
|
786
786
|
{
|
|
787
787
|
ReactIs = require_react_is();
|
|
788
788
|
throwOnDirectAccess = true;
|
|
@@ -1115,6 +1115,7 @@ var SolidEditor = (props) => {
|
|
|
1115
1115
|
const value = () => props.value || "";
|
|
1116
1116
|
const skin = () => props.skin || "oxide";
|
|
1117
1117
|
const contentCss = () => props.contentCss || "default";
|
|
1118
|
+
const disabled = () => props.disabled || false;
|
|
1118
1119
|
const [editor, setEditor] = createSignal();
|
|
1119
1120
|
const [currentContent, setCurrentContent] = createSignal(value());
|
|
1120
1121
|
const [rollbackTimer, setRollbackTimer] = createSignal();
|
|
@@ -1184,6 +1185,13 @@ var SolidEditor = (props) => {
|
|
|
1184
1185
|
}
|
|
1185
1186
|
}
|
|
1186
1187
|
};
|
|
1188
|
+
const successHandler = () => {
|
|
1189
|
+
props.onScriptsLoad?.();
|
|
1190
|
+
initialise();
|
|
1191
|
+
};
|
|
1192
|
+
const errorHandler = (err) => {
|
|
1193
|
+
props.onScriptsLoadError?.(err);
|
|
1194
|
+
};
|
|
1187
1195
|
const initialise = (attempts = 0) => {
|
|
1188
1196
|
const target = props.elementRef;
|
|
1189
1197
|
if (!target) {
|
|
@@ -1242,8 +1250,8 @@ var SolidEditor = (props) => {
|
|
|
1242
1250
|
editor2.setDirty(false);
|
|
1243
1251
|
}
|
|
1244
1252
|
setCurrentContent(newCurrentValue);
|
|
1245
|
-
const
|
|
1246
|
-
setMode(editor2,
|
|
1253
|
+
const isDisabled = disabled() ?? false;
|
|
1254
|
+
setMode(editor2, isDisabled ? "readonly" : "design");
|
|
1247
1255
|
if (props.init && isFunction(props.init.init_instance_callback)) {
|
|
1248
1256
|
props.init.init_instance_callback(editor2);
|
|
1249
1257
|
}
|
|
@@ -1261,14 +1269,8 @@ var SolidEditor = (props) => {
|
|
|
1261
1269
|
if (getTinymce(view()) !== null) {
|
|
1262
1270
|
initialise();
|
|
1263
1271
|
} else if (Array.isArray(props.tinymceScriptSrc) && props.tinymceScriptSrc.length === 0) {
|
|
1264
|
-
|
|
1272
|
+
props.onScriptsLoadError?.(new Error("No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."));
|
|
1265
1273
|
} else if (props?.elementRef?.ownerDocument) {
|
|
1266
|
-
const successHandler = () => {
|
|
1267
|
-
initialise();
|
|
1268
|
-
};
|
|
1269
|
-
const errorHandler = (err) => {
|
|
1270
|
-
throw new Error(err);
|
|
1271
|
-
};
|
|
1272
1274
|
ScriptLoader.loadList(props.elementRef.ownerDocument, getScriptSources(), props.scriptLoading?.delay ?? 0, successHandler, errorHandler);
|
|
1273
1275
|
}
|
|
1274
1276
|
};
|
|
@@ -1300,9 +1302,14 @@ var SolidEditor = (props) => {
|
|
|
1300
1302
|
}));
|
|
1301
1303
|
createEffect(on(skin, () => {
|
|
1302
1304
|
cleanUpCallback();
|
|
1303
|
-
setTimeout(
|
|
1304
|
-
|
|
1305
|
-
|
|
1305
|
+
setTimeout(mountCallback, 1);
|
|
1306
|
+
}));
|
|
1307
|
+
createEffect(on(disabled, () => {
|
|
1308
|
+
const tinyEditor = editor();
|
|
1309
|
+
if (tinyEditor?.initialized) {
|
|
1310
|
+
const isDisabled = disabled() ?? false;
|
|
1311
|
+
setMode(tinyEditor, isDisabled ? "readonly" : "design");
|
|
1312
|
+
}
|
|
1306
1313
|
}));
|
|
1307
1314
|
onMount(mountCallback);
|
|
1308
1315
|
onCleanup(cleanUpCallback);
|
|
@@ -1371,36 +1378,34 @@ var SolidEditor = (props) => {
|
|
|
1371
1378
|
var _el$ = _tmpl$();
|
|
1372
1379
|
var _ref$ = props.elementRef;
|
|
1373
1380
|
typeof _ref$ === "function" ? use(_ref$, _el$) : props.elementRef = _el$;
|
|
1381
|
+
_el$.style.setProperty("visibility", "hidden");
|
|
1374
1382
|
effect((_p$) => {
|
|
1375
|
-
var _v$ =
|
|
1376
|
-
_v$ !== _p$.e && (
|
|
1377
|
-
_v$2 !== _p$.t && setAttribute(_el$, "
|
|
1378
|
-
_v$3 !== _p$.a && setAttribute(_el$, "
|
|
1379
|
-
_v$4 !== _p$.o && setAttribute(_el$, "tabindex", _p$.o = _v$4);
|
|
1383
|
+
var _v$ = id(), _v$2 = props.testid, _v$3 = props.tabIndex;
|
|
1384
|
+
_v$ !== _p$.e && setAttribute(_el$, "id", _p$.e = _v$);
|
|
1385
|
+
_v$2 !== _p$.t && setAttribute(_el$, "data-testid", _p$.t = _v$2);
|
|
1386
|
+
_v$3 !== _p$.a && setAttribute(_el$, "tabindex", _p$.a = _v$3);
|
|
1380
1387
|
return _p$;
|
|
1381
1388
|
}, {
|
|
1382
1389
|
e: void 0,
|
|
1383
1390
|
t: void 0,
|
|
1384
|
-
a: void 0
|
|
1385
|
-
o: void 0
|
|
1391
|
+
a: void 0
|
|
1386
1392
|
});
|
|
1387
1393
|
return _el$;
|
|
1388
1394
|
})() : (() => {
|
|
1389
1395
|
var _el$2 = _tmpl$2();
|
|
1390
1396
|
var _ref$2 = props.elementRef;
|
|
1391
1397
|
typeof _ref$2 === "function" ? use(_ref$2, _el$2) : props.elementRef = _el$2;
|
|
1398
|
+
_el$2.style.setProperty("visibility", "hidden");
|
|
1392
1399
|
effect((_p$) => {
|
|
1393
|
-
var _v$
|
|
1394
|
-
_v$
|
|
1395
|
-
_v$
|
|
1396
|
-
_v$
|
|
1397
|
-
_v$8 !== _p$.o && setAttribute(_el$2, "tabindex", _p$.o = _v$8);
|
|
1400
|
+
var _v$4 = id(), _v$5 = props.testid, _v$6 = props.tabIndex;
|
|
1401
|
+
_v$4 !== _p$.e && setAttribute(_el$2, "id", _p$.e = _v$4);
|
|
1402
|
+
_v$5 !== _p$.t && setAttribute(_el$2, "data-testid", _p$.t = _v$5);
|
|
1403
|
+
_v$6 !== _p$.a && setAttribute(_el$2, "tabindex", _p$.a = _v$6);
|
|
1398
1404
|
return _p$;
|
|
1399
1405
|
}, {
|
|
1400
1406
|
e: void 0,
|
|
1401
1407
|
t: void 0,
|
|
1402
|
-
a: void 0
|
|
1403
|
-
o: void 0
|
|
1408
|
+
a: void 0
|
|
1404
1409
|
});
|
|
1405
1410
|
return _el$2;
|
|
1406
1411
|
})();
|
package/dist/dev.jsx
CHANGED
|
@@ -24,9 +24,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// node_modules/react-is/cjs/react-is.development.js
|
|
27
|
+
// node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js
|
|
28
28
|
var require_react_is_development = __commonJS({
|
|
29
|
-
"node_modules/react-is/cjs/react-is.development.js"(exports) {
|
|
29
|
+
"node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js"(exports) {
|
|
30
30
|
"use strict";
|
|
31
31
|
if (true) {
|
|
32
32
|
(function() {
|
|
@@ -179,9 +179,9 @@ var require_react_is_development = __commonJS({
|
|
|
179
179
|
}
|
|
180
180
|
});
|
|
181
181
|
|
|
182
|
-
// node_modules/react-is/index.js
|
|
182
|
+
// node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js
|
|
183
183
|
var require_react_is = __commonJS({
|
|
184
|
-
"node_modules/react-is/index.js"(exports, module) {
|
|
184
|
+
"node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js"(exports, module) {
|
|
185
185
|
"use strict";
|
|
186
186
|
if (false) {
|
|
187
187
|
module.exports = null;
|
|
@@ -191,9 +191,9 @@ var require_react_is = __commonJS({
|
|
|
191
191
|
}
|
|
192
192
|
});
|
|
193
193
|
|
|
194
|
-
// node_modules/object-assign/index.js
|
|
194
|
+
// node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js
|
|
195
195
|
var require_object_assign = __commonJS({
|
|
196
|
-
"node_modules/object-assign/index.js"(exports, module) {
|
|
196
|
+
"node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js"(exports, module) {
|
|
197
197
|
"use strict";
|
|
198
198
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
199
199
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -261,26 +261,26 @@ var require_object_assign = __commonJS({
|
|
|
261
261
|
}
|
|
262
262
|
});
|
|
263
263
|
|
|
264
|
-
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
264
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
265
265
|
var require_ReactPropTypesSecret = __commonJS({
|
|
266
|
-
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
266
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
267
267
|
"use strict";
|
|
268
268
|
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
269
269
|
module.exports = ReactPropTypesSecret;
|
|
270
270
|
}
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
-
// node_modules/prop-types/lib/has.js
|
|
273
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js
|
|
274
274
|
var require_has = __commonJS({
|
|
275
|
-
"node_modules/prop-types/lib/has.js"(exports, module) {
|
|
275
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js"(exports, module) {
|
|
276
276
|
"use strict";
|
|
277
277
|
module.exports = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
278
278
|
}
|
|
279
279
|
});
|
|
280
280
|
|
|
281
|
-
// node_modules/prop-types/checkPropTypes.js
|
|
281
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js
|
|
282
282
|
var require_checkPropTypes = __commonJS({
|
|
283
|
-
"node_modules/prop-types/checkPropTypes.js"(exports, module) {
|
|
283
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js"(exports, module) {
|
|
284
284
|
"use strict";
|
|
285
285
|
var printWarning = function() {
|
|
286
286
|
};
|
|
@@ -344,9 +344,9 @@ var require_checkPropTypes = __commonJS({
|
|
|
344
344
|
}
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
// node_modules/prop-types/factoryWithTypeCheckers.js
|
|
347
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js
|
|
348
348
|
var require_factoryWithTypeCheckers = __commonJS({
|
|
349
|
-
"node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
|
|
349
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js"(exports, module) {
|
|
350
350
|
"use strict";
|
|
351
351
|
var ReactIs = require_react_is();
|
|
352
352
|
var assign = require_object_assign();
|
|
@@ -787,9 +787,9 @@ var require_factoryWithTypeCheckers = __commonJS({
|
|
|
787
787
|
}
|
|
788
788
|
});
|
|
789
789
|
|
|
790
|
-
// node_modules/prop-types/index.js
|
|
790
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
|
|
791
791
|
var require_prop_types = __commonJS({
|
|
792
|
-
"node_modules/prop-types/index.js"(exports, module) {
|
|
792
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js"(exports, module) {
|
|
793
793
|
"use strict";
|
|
794
794
|
if (true) {
|
|
795
795
|
ReactIs = require_react_is();
|
|
@@ -1126,6 +1126,7 @@ var SolidEditor = (props) => {
|
|
|
1126
1126
|
const value = () => props.value || "";
|
|
1127
1127
|
const skin = () => props.skin || "oxide";
|
|
1128
1128
|
const contentCss = () => props.contentCss || "default";
|
|
1129
|
+
const disabled = () => props.disabled || false;
|
|
1129
1130
|
const [editor, setEditor] = createSignal();
|
|
1130
1131
|
const [currentContent, setCurrentContent] = createSignal(value());
|
|
1131
1132
|
const [rollbackTimer, setRollbackTimer] = createSignal();
|
|
@@ -1189,6 +1190,13 @@ var SolidEditor = (props) => {
|
|
|
1189
1190
|
}
|
|
1190
1191
|
}
|
|
1191
1192
|
};
|
|
1193
|
+
const successHandler = () => {
|
|
1194
|
+
props.onScriptsLoad?.();
|
|
1195
|
+
initialise();
|
|
1196
|
+
};
|
|
1197
|
+
const errorHandler = (err) => {
|
|
1198
|
+
props.onScriptsLoadError?.(err);
|
|
1199
|
+
};
|
|
1192
1200
|
const initialise = (attempts = 0) => {
|
|
1193
1201
|
const target = props.elementRef;
|
|
1194
1202
|
if (!target) {
|
|
@@ -1245,8 +1253,8 @@ var SolidEditor = (props) => {
|
|
|
1245
1253
|
editor2.setDirty(false);
|
|
1246
1254
|
}
|
|
1247
1255
|
setCurrentContent(newCurrentValue);
|
|
1248
|
-
const
|
|
1249
|
-
setMode(editor2,
|
|
1256
|
+
const isDisabled = disabled() ?? false;
|
|
1257
|
+
setMode(editor2, isDisabled ? "readonly" : "design");
|
|
1250
1258
|
if (props.init && isFunction(props.init.init_instance_callback)) {
|
|
1251
1259
|
props.init.init_instance_callback(editor2);
|
|
1252
1260
|
}
|
|
@@ -1264,16 +1272,10 @@ var SolidEditor = (props) => {
|
|
|
1264
1272
|
if (getTinymce(view()) !== null) {
|
|
1265
1273
|
initialise();
|
|
1266
1274
|
} else if (Array.isArray(props.tinymceScriptSrc) && props.tinymceScriptSrc.length === 0) {
|
|
1267
|
-
|
|
1268
|
-
"No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."
|
|
1275
|
+
props.onScriptsLoadError?.(
|
|
1276
|
+
new Error("No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.")
|
|
1269
1277
|
);
|
|
1270
1278
|
} else if (props?.elementRef?.ownerDocument) {
|
|
1271
|
-
const successHandler = () => {
|
|
1272
|
-
initialise();
|
|
1273
|
-
};
|
|
1274
|
-
const errorHandler = (err) => {
|
|
1275
|
-
throw new Error(err);
|
|
1276
|
-
};
|
|
1277
1279
|
ScriptLoader.loadList(
|
|
1278
1280
|
props.elementRef.ownerDocument,
|
|
1279
1281
|
getScriptSources(),
|
|
@@ -1311,9 +1313,16 @@ var SolidEditor = (props) => {
|
|
|
1311
1313
|
createEffect(
|
|
1312
1314
|
on(skin, () => {
|
|
1313
1315
|
cleanUpCallback();
|
|
1314
|
-
setTimeout(
|
|
1315
|
-
|
|
1316
|
-
|
|
1316
|
+
setTimeout(mountCallback, 1);
|
|
1317
|
+
})
|
|
1318
|
+
);
|
|
1319
|
+
createEffect(
|
|
1320
|
+
on(disabled, () => {
|
|
1321
|
+
const tinyEditor = editor();
|
|
1322
|
+
if (tinyEditor?.initialized) {
|
|
1323
|
+
const isDisabled = disabled() ?? false;
|
|
1324
|
+
setMode(tinyEditor, isDisabled ? "readonly" : "design");
|
|
1325
|
+
}
|
|
1317
1326
|
})
|
|
1318
1327
|
);
|
|
1319
1328
|
onMount(mountCallback);
|
|
@@ -1385,13 +1394,13 @@ var SolidEditor = (props) => {
|
|
|
1385
1394
|
}
|
|
1386
1395
|
};
|
|
1387
1396
|
return props.inline ? <div
|
|
1388
|
-
style={{
|
|
1397
|
+
style={{ visibility: "hidden" }}
|
|
1389
1398
|
ref={props.elementRef}
|
|
1390
1399
|
id={id()}
|
|
1391
1400
|
data-testid={props.testid}
|
|
1392
1401
|
tabIndex={props.tabIndex}
|
|
1393
1402
|
/> : <textarea
|
|
1394
|
-
style={{
|
|
1403
|
+
style={{ visibility: "hidden" }}
|
|
1395
1404
|
ref={props.elementRef}
|
|
1396
1405
|
id={id()}
|
|
1397
1406
|
data-testid={props.testid}
|
package/dist/index.js
CHANGED
|
@@ -27,17 +27,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
27
|
mod
|
|
28
28
|
));
|
|
29
29
|
|
|
30
|
-
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
30
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
31
31
|
var require_ReactPropTypesSecret = __commonJS({
|
|
32
|
-
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
32
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
33
33
|
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
34
34
|
module.exports = ReactPropTypesSecret;
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
// node_modules/prop-types/factoryWithThrowingShims.js
|
|
38
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js
|
|
39
39
|
var require_factoryWithThrowingShims = __commonJS({
|
|
40
|
-
"node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
|
|
40
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
|
|
41
41
|
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
42
42
|
function emptyFunction() {
|
|
43
43
|
}
|
|
@@ -88,9 +88,9 @@ var require_factoryWithThrowingShims = __commonJS({
|
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
-
// node_modules/prop-types/index.js
|
|
91
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
|
|
92
92
|
var require_prop_types = __commonJS({
|
|
93
|
-
"node_modules/prop-types/index.js"(exports, module) {
|
|
93
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js"(exports, module) {
|
|
94
94
|
{
|
|
95
95
|
module.exports = require_factoryWithThrowingShims()();
|
|
96
96
|
}
|
|
@@ -419,6 +419,7 @@ var SolidEditor = (props) => {
|
|
|
419
419
|
const value = () => props.value || "";
|
|
420
420
|
const skin = () => props.skin || "oxide";
|
|
421
421
|
const contentCss = () => props.contentCss || "default";
|
|
422
|
+
const disabled = () => props.disabled || false;
|
|
422
423
|
const [editor, setEditor] = createSignal();
|
|
423
424
|
const [currentContent, setCurrentContent] = createSignal(value());
|
|
424
425
|
const [rollbackTimer, setRollbackTimer] = createSignal();
|
|
@@ -488,6 +489,13 @@ var SolidEditor = (props) => {
|
|
|
488
489
|
}
|
|
489
490
|
}
|
|
490
491
|
};
|
|
492
|
+
const successHandler = () => {
|
|
493
|
+
props.onScriptsLoad?.();
|
|
494
|
+
initialise();
|
|
495
|
+
};
|
|
496
|
+
const errorHandler = (err) => {
|
|
497
|
+
props.onScriptsLoadError?.(err);
|
|
498
|
+
};
|
|
491
499
|
const initialise = (attempts = 0) => {
|
|
492
500
|
const target = props.elementRef;
|
|
493
501
|
if (!target) {
|
|
@@ -546,8 +554,8 @@ var SolidEditor = (props) => {
|
|
|
546
554
|
editor2.setDirty(false);
|
|
547
555
|
}
|
|
548
556
|
setCurrentContent(newCurrentValue);
|
|
549
|
-
const
|
|
550
|
-
setMode(editor2,
|
|
557
|
+
const isDisabled = disabled() ?? false;
|
|
558
|
+
setMode(editor2, isDisabled ? "readonly" : "design");
|
|
551
559
|
if (props.init && isFunction(props.init.init_instance_callback)) {
|
|
552
560
|
props.init.init_instance_callback(editor2);
|
|
553
561
|
}
|
|
@@ -565,14 +573,8 @@ var SolidEditor = (props) => {
|
|
|
565
573
|
if (getTinymce(view()) !== null) {
|
|
566
574
|
initialise();
|
|
567
575
|
} else if (Array.isArray(props.tinymceScriptSrc) && props.tinymceScriptSrc.length === 0) {
|
|
568
|
-
|
|
576
|
+
props.onScriptsLoadError?.(new Error("No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."));
|
|
569
577
|
} else if (props?.elementRef?.ownerDocument) {
|
|
570
|
-
const successHandler = () => {
|
|
571
|
-
initialise();
|
|
572
|
-
};
|
|
573
|
-
const errorHandler = (err) => {
|
|
574
|
-
throw new Error(err);
|
|
575
|
-
};
|
|
576
578
|
ScriptLoader.loadList(props.elementRef.ownerDocument, getScriptSources(), props.scriptLoading?.delay ?? 0, successHandler, errorHandler);
|
|
577
579
|
}
|
|
578
580
|
};
|
|
@@ -604,9 +606,14 @@ var SolidEditor = (props) => {
|
|
|
604
606
|
}));
|
|
605
607
|
createEffect(on(skin, () => {
|
|
606
608
|
cleanUpCallback();
|
|
607
|
-
setTimeout(
|
|
608
|
-
|
|
609
|
-
|
|
609
|
+
setTimeout(mountCallback, 1);
|
|
610
|
+
}));
|
|
611
|
+
createEffect(on(disabled, () => {
|
|
612
|
+
const tinyEditor = editor();
|
|
613
|
+
if (tinyEditor?.initialized) {
|
|
614
|
+
const isDisabled = disabled() ?? false;
|
|
615
|
+
setMode(tinyEditor, isDisabled ? "readonly" : "design");
|
|
616
|
+
}
|
|
610
617
|
}));
|
|
611
618
|
onMount(mountCallback);
|
|
612
619
|
onCleanup(cleanUpCallback);
|
|
@@ -675,36 +682,34 @@ var SolidEditor = (props) => {
|
|
|
675
682
|
var _el$ = _tmpl$();
|
|
676
683
|
var _ref$ = props.elementRef;
|
|
677
684
|
typeof _ref$ === "function" ? use(_ref$, _el$) : props.elementRef = _el$;
|
|
685
|
+
_el$.style.setProperty("visibility", "hidden");
|
|
678
686
|
effect((_p$) => {
|
|
679
|
-
var _v$ =
|
|
680
|
-
_v$ !== _p$.e && (
|
|
681
|
-
_v$2 !== _p$.t && setAttribute(_el$, "
|
|
682
|
-
_v$3 !== _p$.a && setAttribute(_el$, "
|
|
683
|
-
_v$4 !== _p$.o && setAttribute(_el$, "tabindex", _p$.o = _v$4);
|
|
687
|
+
var _v$ = id(), _v$2 = props.testid, _v$3 = props.tabIndex;
|
|
688
|
+
_v$ !== _p$.e && setAttribute(_el$, "id", _p$.e = _v$);
|
|
689
|
+
_v$2 !== _p$.t && setAttribute(_el$, "data-testid", _p$.t = _v$2);
|
|
690
|
+
_v$3 !== _p$.a && setAttribute(_el$, "tabindex", _p$.a = _v$3);
|
|
684
691
|
return _p$;
|
|
685
692
|
}, {
|
|
686
693
|
e: void 0,
|
|
687
694
|
t: void 0,
|
|
688
|
-
a: void 0
|
|
689
|
-
o: void 0
|
|
695
|
+
a: void 0
|
|
690
696
|
});
|
|
691
697
|
return _el$;
|
|
692
698
|
})() : (() => {
|
|
693
699
|
var _el$2 = _tmpl$2();
|
|
694
700
|
var _ref$2 = props.elementRef;
|
|
695
701
|
typeof _ref$2 === "function" ? use(_ref$2, _el$2) : props.elementRef = _el$2;
|
|
702
|
+
_el$2.style.setProperty("visibility", "hidden");
|
|
696
703
|
effect((_p$) => {
|
|
697
|
-
var _v$
|
|
698
|
-
_v$
|
|
699
|
-
_v$
|
|
700
|
-
_v$
|
|
701
|
-
_v$8 !== _p$.o && setAttribute(_el$2, "tabindex", _p$.o = _v$8);
|
|
704
|
+
var _v$4 = id(), _v$5 = props.testid, _v$6 = props.tabIndex;
|
|
705
|
+
_v$4 !== _p$.e && setAttribute(_el$2, "id", _p$.e = _v$4);
|
|
706
|
+
_v$5 !== _p$.t && setAttribute(_el$2, "data-testid", _p$.t = _v$5);
|
|
707
|
+
_v$6 !== _p$.a && setAttribute(_el$2, "tabindex", _p$.a = _v$6);
|
|
702
708
|
return _p$;
|
|
703
709
|
}, {
|
|
704
710
|
e: void 0,
|
|
705
711
|
t: void 0,
|
|
706
|
-
a: void 0
|
|
707
|
-
o: void 0
|
|
712
|
+
a: void 0
|
|
708
713
|
});
|
|
709
714
|
return _el$2;
|
|
710
715
|
})();
|
package/dist/index.jsx
CHANGED
|
@@ -24,18 +24,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
mod
|
|
25
25
|
));
|
|
26
26
|
|
|
27
|
-
// node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
27
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js
|
|
28
28
|
var require_ReactPropTypesSecret = __commonJS({
|
|
29
|
-
"node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
29
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js"(exports, module) {
|
|
30
30
|
"use strict";
|
|
31
31
|
var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
32
32
|
module.exports = ReactPropTypesSecret;
|
|
33
33
|
}
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
-
// node_modules/prop-types/factoryWithThrowingShims.js
|
|
36
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js
|
|
37
37
|
var require_factoryWithThrowingShims = __commonJS({
|
|
38
|
-
"node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
|
|
38
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js"(exports, module) {
|
|
39
39
|
"use strict";
|
|
40
40
|
var ReactPropTypesSecret = require_ReactPropTypesSecret();
|
|
41
41
|
function emptyFunction() {
|
|
@@ -89,9 +89,9 @@ var require_factoryWithThrowingShims = __commonJS({
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
// node_modules/prop-types/index.js
|
|
92
|
+
// node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js
|
|
93
93
|
var require_prop_types = __commonJS({
|
|
94
|
-
"node_modules/prop-types/index.js"(exports, module) {
|
|
94
|
+
"node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js"(exports, module) {
|
|
95
95
|
"use strict";
|
|
96
96
|
if (false) {
|
|
97
97
|
ReactIs = null;
|
|
@@ -428,6 +428,7 @@ var SolidEditor = (props) => {
|
|
|
428
428
|
const value = () => props.value || "";
|
|
429
429
|
const skin = () => props.skin || "oxide";
|
|
430
430
|
const contentCss = () => props.contentCss || "default";
|
|
431
|
+
const disabled = () => props.disabled || false;
|
|
431
432
|
const [editor, setEditor] = createSignal();
|
|
432
433
|
const [currentContent, setCurrentContent] = createSignal(value());
|
|
433
434
|
const [rollbackTimer, setRollbackTimer] = createSignal();
|
|
@@ -491,6 +492,13 @@ var SolidEditor = (props) => {
|
|
|
491
492
|
}
|
|
492
493
|
}
|
|
493
494
|
};
|
|
495
|
+
const successHandler = () => {
|
|
496
|
+
props.onScriptsLoad?.();
|
|
497
|
+
initialise();
|
|
498
|
+
};
|
|
499
|
+
const errorHandler = (err) => {
|
|
500
|
+
props.onScriptsLoadError?.(err);
|
|
501
|
+
};
|
|
494
502
|
const initialise = (attempts = 0) => {
|
|
495
503
|
const target = props.elementRef;
|
|
496
504
|
if (!target) {
|
|
@@ -547,8 +555,8 @@ var SolidEditor = (props) => {
|
|
|
547
555
|
editor2.setDirty(false);
|
|
548
556
|
}
|
|
549
557
|
setCurrentContent(newCurrentValue);
|
|
550
|
-
const
|
|
551
|
-
setMode(editor2,
|
|
558
|
+
const isDisabled = disabled() ?? false;
|
|
559
|
+
setMode(editor2, isDisabled ? "readonly" : "design");
|
|
552
560
|
if (props.init && isFunction(props.init.init_instance_callback)) {
|
|
553
561
|
props.init.init_instance_callback(editor2);
|
|
554
562
|
}
|
|
@@ -566,16 +574,10 @@ var SolidEditor = (props) => {
|
|
|
566
574
|
if (getTinymce(view()) !== null) {
|
|
567
575
|
initialise();
|
|
568
576
|
} else if (Array.isArray(props.tinymceScriptSrc) && props.tinymceScriptSrc.length === 0) {
|
|
569
|
-
|
|
570
|
-
"No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."
|
|
577
|
+
props.onScriptsLoadError?.(
|
|
578
|
+
new Error("No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.")
|
|
571
579
|
);
|
|
572
580
|
} else if (props?.elementRef?.ownerDocument) {
|
|
573
|
-
const successHandler = () => {
|
|
574
|
-
initialise();
|
|
575
|
-
};
|
|
576
|
-
const errorHandler = (err) => {
|
|
577
|
-
throw new Error(err);
|
|
578
|
-
};
|
|
579
581
|
ScriptLoader.loadList(
|
|
580
582
|
props.elementRef.ownerDocument,
|
|
581
583
|
getScriptSources(),
|
|
@@ -613,9 +615,16 @@ var SolidEditor = (props) => {
|
|
|
613
615
|
createEffect(
|
|
614
616
|
on(skin, () => {
|
|
615
617
|
cleanUpCallback();
|
|
616
|
-
setTimeout(
|
|
617
|
-
|
|
618
|
-
|
|
618
|
+
setTimeout(mountCallback, 1);
|
|
619
|
+
})
|
|
620
|
+
);
|
|
621
|
+
createEffect(
|
|
622
|
+
on(disabled, () => {
|
|
623
|
+
const tinyEditor = editor();
|
|
624
|
+
if (tinyEditor?.initialized) {
|
|
625
|
+
const isDisabled = disabled() ?? false;
|
|
626
|
+
setMode(tinyEditor, isDisabled ? "readonly" : "design");
|
|
627
|
+
}
|
|
619
628
|
})
|
|
620
629
|
);
|
|
621
630
|
onMount(mountCallback);
|
|
@@ -687,13 +696,13 @@ var SolidEditor = (props) => {
|
|
|
687
696
|
}
|
|
688
697
|
};
|
|
689
698
|
return props.inline ? <div
|
|
690
|
-
style={{
|
|
699
|
+
style={{ visibility: "hidden" }}
|
|
691
700
|
ref={props.elementRef}
|
|
692
701
|
id={id()}
|
|
693
702
|
data-testid={props.testid}
|
|
694
703
|
tabIndex={props.tabIndex}
|
|
695
704
|
/> : <textarea
|
|
696
|
-
style={{
|
|
705
|
+
style={{ visibility: "hidden" }}
|
|
697
706
|
ref={props.elementRef}
|
|
698
707
|
id={id()}
|
|
699
708
|
data-testid={props.testid}
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tinymce-solid",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "TinyMCE for SolidJS",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "TinyMCE Component for SolidJS",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"solidjs",
|
|
9
|
+
"tinymce",
|
|
10
|
+
"editor",
|
|
11
|
+
"wysiwyg",
|
|
12
|
+
"typescript"
|
|
13
|
+
],
|
|
6
14
|
"homepage": "https://thednp.github.io/tinymce-solid",
|
|
7
15
|
"bugs": {
|
|
8
16
|
"url": "https://github.com/thednp/tinymce-solid/issues"
|
|
@@ -13,21 +21,21 @@
|
|
|
13
21
|
},
|
|
14
22
|
"dependencies": {
|
|
15
23
|
"solid-js": "^1.8.17",
|
|
16
|
-
"tinymce": "^7.1.
|
|
24
|
+
"tinymce": "^7.1.2"
|
|
17
25
|
},
|
|
18
26
|
"devDependencies": {
|
|
19
27
|
"@kobalte/core": "^0.13.3",
|
|
20
28
|
"@kobalte/utils": "^0.9.0",
|
|
21
|
-
"@types/node": "^20.14.
|
|
29
|
+
"@types/node": "^20.14.2",
|
|
22
30
|
"@types/prop-types": "^15.7.12",
|
|
23
31
|
"autoprefixer": "^10.4.19",
|
|
24
32
|
"class-variance-authority": "^0.7.0",
|
|
25
33
|
"clsx": "^2.1.1",
|
|
26
34
|
"postcss": "^8.4.38",
|
|
27
|
-
"prettier": "^3.3.
|
|
35
|
+
"prettier": "^3.3.1",
|
|
28
36
|
"prop-types": "^15.8.1",
|
|
29
37
|
"tailwind-merge": "^2.3.0",
|
|
30
|
-
"tailwindcss": "^3.4.
|
|
38
|
+
"tailwindcss": "^3.4.4",
|
|
31
39
|
"tailwindcss-animate": "^1.0.7",
|
|
32
40
|
"tsup": "^8.1.0",
|
|
33
41
|
"tsup-preset-solid": "^2.2.0",
|
package/src/TinyMCE.ts
CHANGED
|
@@ -27,6 +27,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
27
27
|
const value = () => props.value || "";
|
|
28
28
|
const skin = () => props.skin || "oxide";
|
|
29
29
|
const contentCss = () => props.contentCss || "default";
|
|
30
|
+
const disabled = () => props.disabled || false;
|
|
30
31
|
const [editor, setEditor] = createSignal<TinyMCEEditor>();
|
|
31
32
|
const [currentContent, setCurrentContent] = createSignal<string>(value());
|
|
32
33
|
const [rollbackTimer, setRollbackTimer] = createSignal<number>();
|
|
@@ -103,6 +104,14 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
};
|
|
107
|
+
const successHandler = () => {
|
|
108
|
+
props.onScriptsLoad?.();
|
|
109
|
+
initialise();
|
|
110
|
+
};
|
|
111
|
+
const errorHandler = (err: unknown) => {
|
|
112
|
+
// console.warn(err);
|
|
113
|
+
props.onScriptsLoadError?.(err);
|
|
114
|
+
};
|
|
106
115
|
|
|
107
116
|
const initialise = (attempts = 0) => {
|
|
108
117
|
const target = props.elementRef;
|
|
@@ -178,8 +187,8 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
178
187
|
editor.setDirty(false);
|
|
179
188
|
}
|
|
180
189
|
setCurrentContent(newCurrentValue);
|
|
181
|
-
const
|
|
182
|
-
setMode(editor,
|
|
190
|
+
const isDisabled = disabled() ?? false;
|
|
191
|
+
setMode(editor, isDisabled ? "readonly" : "design");
|
|
183
192
|
// ensure existing init_instance_callback is called
|
|
184
193
|
if (props.init && isFunction(props.init.init_instance_callback)) {
|
|
185
194
|
props.init.init_instance_callback(editor);
|
|
@@ -202,24 +211,12 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
202
211
|
Array.isArray(props.tinymceScriptSrc) &&
|
|
203
212
|
props.tinymceScriptSrc.length === 0
|
|
204
213
|
) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
"No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.",
|
|
214
|
+
props.onScriptsLoadError?.(
|
|
215
|
+
new Error(
|
|
216
|
+
"No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.",
|
|
217
|
+
),
|
|
210
218
|
);
|
|
211
219
|
} else if (props?.elementRef?.ownerDocument) {
|
|
212
|
-
const successHandler = () => {
|
|
213
|
-
// console.log("loaded");
|
|
214
|
-
// props.onScriptsLoad?.();
|
|
215
|
-
initialise();
|
|
216
|
-
};
|
|
217
|
-
const errorHandler = (err: unknown) => {
|
|
218
|
-
// console.warn(err);
|
|
219
|
-
// props.onScriptsLoadError?.(err);
|
|
220
|
-
throw new Error(err as string);
|
|
221
|
-
};
|
|
222
|
-
|
|
223
220
|
ScriptLoader.loadList(
|
|
224
221
|
props.elementRef.ownerDocument,
|
|
225
222
|
getScriptSources(),
|
|
@@ -259,9 +256,17 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
259
256
|
createEffect(
|
|
260
257
|
on(skin, () => {
|
|
261
258
|
cleanUpCallback();
|
|
262
|
-
setTimeout(
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
setTimeout(mountCallback, 1);
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
createEffect(
|
|
264
|
+
on(disabled, () => {
|
|
265
|
+
const tinyEditor = editor();
|
|
266
|
+
if (tinyEditor?.initialized) {
|
|
267
|
+
const isDisabled = disabled() ?? false;
|
|
268
|
+
setMode(tinyEditor, isDisabled ? "readonly" : "design");
|
|
269
|
+
}
|
|
265
270
|
}),
|
|
266
271
|
);
|
|
267
272
|
|
|
@@ -373,7 +378,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
373
378
|
|
|
374
379
|
return props.inline ? (
|
|
375
380
|
<div
|
|
376
|
-
style={{
|
|
381
|
+
style={{ visibility: "hidden" }}
|
|
377
382
|
ref={props.elementRef as HTMLDivElement}
|
|
378
383
|
id={id()}
|
|
379
384
|
data-testid={props.testid}
|
|
@@ -381,7 +386,7 @@ export const SolidEditor = (props: Partial<IAllProps>) => {
|
|
|
381
386
|
/>
|
|
382
387
|
) : (
|
|
383
388
|
<textarea
|
|
384
|
-
style={{
|
|
389
|
+
style={{ visibility: "hidden" }}
|
|
385
390
|
ref={props.elementRef as HTMLTextAreaElement}
|
|
386
391
|
id={id()}
|
|
387
392
|
data-testid={props.testid}
|
package/tsconfig.json
CHANGED
package/tsup.config.ts
CHANGED
|
@@ -29,10 +29,8 @@ export default defineConfig(config => {
|
|
|
29
29
|
|
|
30
30
|
const parsed_options = preset.parsePresetOptions(preset_options, watching);
|
|
31
31
|
|
|
32
|
-
// DON'T OVERRIDE MY PACKAGE.JSON PLEASE!
|
|
33
32
|
if (!watching && !CI) {
|
|
34
33
|
const package_fields = preset.generatePackageExports(parsed_options)
|
|
35
|
-
// console.log(`package.json: \n\n${JSON.stringify(package_fields, null, 2)}\n\n`)
|
|
36
34
|
|
|
37
35
|
// will update ./package.json with the correct export fields
|
|
38
36
|
preset.writePackageJson(package_fields)
|