@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.js +16 -4
- package/dist/editor.js.map +1 -1
- package/dist/editor.mjs +17 -5
- package/dist/editor.mjs.map +1 -1
- package/package.json +1 -1
- package/src/editor/editor.tsx +14 -2
package/package.json
CHANGED
package/src/editor/editor.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
4
|
|
|
5
5
|
import { EditorState, NodeSelection } from "@tiptap/pm/state";
|
|
6
6
|
import { Slice } from "@tiptap/pm/model";
|
|
@@ -157,6 +157,14 @@ function TiptapContent({
|
|
|
157
157
|
katexHandler(latex, katexDialogContext?.pos);
|
|
158
158
|
};
|
|
159
159
|
|
|
160
|
+
useEffect(() => {
|
|
161
|
+
if (!editor || editor.isDestroyed) return;
|
|
162
|
+
|
|
163
|
+
editor.commands.setContent(safeContent, {
|
|
164
|
+
emitUpdate: false,
|
|
165
|
+
});
|
|
166
|
+
}, [content, editor]);
|
|
167
|
+
|
|
160
168
|
if (!editor) return null;
|
|
161
169
|
|
|
162
170
|
const shouldBubbleMenuShow = ({ state }: { state: EditorState }) => {
|
|
@@ -192,7 +200,11 @@ function TiptapContent({
|
|
|
192
200
|
</BubbleMenu>
|
|
193
201
|
)}
|
|
194
202
|
|
|
195
|
-
<div
|
|
203
|
+
<div
|
|
204
|
+
className={`tiptap-content-wrapper ${!!error ? "has-error" : ""} ${
|
|
205
|
+
isDisabled ? "is-disabled" : ""
|
|
206
|
+
}`}
|
|
207
|
+
>
|
|
196
208
|
<EditorContent editor={editor} />
|
|
197
209
|
{isEditable && !isDisabled && <CharacterCountComponent editor={editor} />}
|
|
198
210
|
</div>
|