tinymce-solid 0.0.2 → 0.0.4

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 CHANGED
@@ -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 disabled = props.disabled ?? false;
551
- setMode(editor2, disabled ? "readonly" : "design");
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,12 @@ 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
- throw new Error(
570
- "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."
577
+ props.onScriptsLoadError?.(
578
+ new Error(
579
+ "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array."
580
+ )
571
581
  );
572
582
  } else if (props?.elementRef?.ownerDocument) {
573
- const successHandler = () => {
574
- initialise();
575
- };
576
- const errorHandler = (err) => {
577
- throw new Error(err);
578
- };
579
583
  ScriptLoader.loadList(
580
584
  props.elementRef.ownerDocument,
581
585
  getScriptSources(),
@@ -613,9 +617,16 @@ var SolidEditor = (props) => {
613
617
  createEffect(
614
618
  on(skin, () => {
615
619
  cleanUpCallback();
616
- setTimeout(() => {
617
- mountCallback();
618
- }, 34);
620
+ setTimeout(mountCallback, 1);
621
+ })
622
+ );
623
+ createEffect(
624
+ on(disabled, () => {
625
+ const tinyEditor = editor();
626
+ if (tinyEditor?.initialized) {
627
+ const isDisabled = disabled() ?? false;
628
+ setMode(tinyEditor, isDisabled ? "readonly" : "design");
629
+ }
619
630
  })
620
631
  );
621
632
  onMount(mountCallback);
@@ -687,13 +698,13 @@ var SolidEditor = (props) => {
687
698
  }
688
699
  };
689
700
  return props.inline ? <div
690
- style={{ display: editor() ? "" : "none" }}
701
+ style={{ visibility: "hidden" }}
691
702
  ref={props.elementRef}
692
703
  id={id()}
693
704
  data-testid={props.testid}
694
705
  tabIndex={props.tabIndex}
695
706
  /> : <textarea
696
- style={{ display: editor() ? "" : "none" }}
707
+ style={{ visibility: "hidden" }}
697
708
  ref={props.elementRef}
698
709
  id={id()}
699
710
  data-testid={props.testid}