@cyberyozh/text-editor 0.1.5 → 0.1.6

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/editor.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/editor/editor.tsx
2
- import { useState as useState12 } from "react";
2
+ import { useState as useState12, useEffect as useEffect9 } from "react";
3
3
  import { NodeSelection } from "@tiptap/pm/state";
4
4
  import { Slice } from "@tiptap/pm/model";
5
5
  import { useEditor, EditorContent } from "@tiptap/react";
@@ -6030,6 +6030,12 @@ function TiptapContent({
6030
6030
  const katexHandler = createHandleKatexAdd(editor, handleCloseDialog);
6031
6031
  katexHandler(latex, katexDialogContext?.pos);
6032
6032
  };
6033
+ useEffect9(() => {
6034
+ if (!editor || editor.isDestroyed) return;
6035
+ editor.commands.setContent(safeContent, {
6036
+ emitUpdate: false
6037
+ });
6038
+ }, [content, editor]);
6033
6039
  if (!editor) return null;
6034
6040
  const shouldBubbleMenuShow = ({ state }) => {
6035
6041
  if (state.selection instanceof NodeSelection) {
@@ -6061,10 +6067,16 @@ function TiptapContent({
6061
6067
  )
6062
6068
  }
6063
6069
  ),
6064
- /* @__PURE__ */ jsxs35("div", { className: `tiptap-content-wrapper ${!!error ? "has-error" : ""} ${isDisabled ? "is-disabled" : ""}`, children: [
6065
- /* @__PURE__ */ jsx92(EditorContent, { editor }),
6066
- isEditable && !isDisabled && /* @__PURE__ */ jsx92(CharacterCount, { editor })
6067
- ] }),
6070
+ /* @__PURE__ */ jsxs35(
6071
+ "div",
6072
+ {
6073
+ className: `tiptap-content-wrapper ${!!error ? "has-error" : ""} ${isDisabled ? "is-disabled" : ""}`,
6074
+ children: [
6075
+ /* @__PURE__ */ jsx92(EditorContent, { editor }),
6076
+ isEditable && !isDisabled && /* @__PURE__ */ jsx92(CharacterCount, { editor })
6077
+ ]
6078
+ }
6079
+ ),
6068
6080
  !!error && /* @__PURE__ */ jsx92("p", { className: "tiptap-error-message", children: error }),
6069
6081
  activeDialog === "image" && isEditable && /* @__PURE__ */ jsx92(
6070
6082
  ImageDialog,