@rimori/react-client 0.4.11-next.1 → 0.4.11
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.
|
@@ -12,7 +12,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
12
12
|
import { useRimori } from '../../providers/PluginProvider';
|
|
13
13
|
import { Markdown } from 'tiptap-markdown';
|
|
14
14
|
import StarterKit from '@tiptap/starter-kit';
|
|
15
|
-
import { Paragraph } from '@tiptap/extension-paragraph';
|
|
16
15
|
import Table from '@tiptap/extension-table';
|
|
17
16
|
import TableCell from '@tiptap/extension-table-cell';
|
|
18
17
|
import TableHeader from '@tiptap/extension-table-header';
|
|
@@ -27,28 +26,6 @@ import { AiOutlineUnorderedList } from 'react-icons/ai';
|
|
|
27
26
|
import { LuClipboardPaste, LuHeading1, LuHeading2, LuHeading3, LuLink, LuUnlink } from 'react-icons/lu';
|
|
28
27
|
import { FaBold, FaCode, FaItalic, FaParagraph, FaStrikethrough } from 'react-icons/fa';
|
|
29
28
|
import { ImageUploadExtension, triggerImageUpload } from './ImageUploadExtension';
|
|
30
|
-
// Extends TipTap's Paragraph to serialize empty paragraphs as <p></p>.
|
|
31
|
-
// Standard markdown collapses consecutive blank lines, losing empty paragraph nodes.
|
|
32
|
-
// Since tiptap-markdown enables html:true by default, <p></p> survives the round-trip.
|
|
33
|
-
const ParagraphPreserveEmpty = Paragraph.extend({
|
|
34
|
-
addStorage() {
|
|
35
|
-
return {
|
|
36
|
-
markdown: {
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
serialize(state, node) {
|
|
39
|
-
if (node.childCount === 0) {
|
|
40
|
-
state.write('<p></p>');
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
state.renderInline(node);
|
|
44
|
-
}
|
|
45
|
-
state.closeBlock(node);
|
|
46
|
-
},
|
|
47
|
-
parse: {},
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
29
|
function getMarkdown(editor) {
|
|
53
30
|
return editor.storage.markdown.getMarkdown();
|
|
54
31
|
}
|
|
@@ -183,8 +160,7 @@ export const MarkdownEditor = ({ content, editable, className, onUpdate, labels,
|
|
|
183
160
|
return data.url;
|
|
184
161
|
}), [storage]);
|
|
185
162
|
const extensions = useMemo(() => [
|
|
186
|
-
StarterKit
|
|
187
|
-
ParagraphPreserveEmpty,
|
|
163
|
+
StarterKit,
|
|
188
164
|
Table.configure({ resizable: false }),
|
|
189
165
|
TableRow,
|
|
190
166
|
TableHeader,
|
|
@@ -208,8 +184,7 @@ export const MarkdownEditor = ({ content, editable, className, onUpdate, labels,
|
|
|
208
184
|
onUpdate === null || onUpdate === void 0 ? void 0 : onUpdate(markdown);
|
|
209
185
|
},
|
|
210
186
|
});
|
|
211
|
-
// Sync external content changes (e.g. AI autofill) without triggering update loop
|
|
212
|
-
// Pass false to setContent to prevent onUpdate from firing and re-normalizing the content.
|
|
187
|
+
// Sync external content changes (e.g. AI autofill) without triggering update loop
|
|
213
188
|
useEffect(() => {
|
|
214
189
|
if (!editor)
|
|
215
190
|
return;
|
|
@@ -217,7 +192,7 @@ export const MarkdownEditor = ({ content, editable, className, onUpdate, labels,
|
|
|
217
192
|
if (incoming === lastEmittedRef.current)
|
|
218
193
|
return;
|
|
219
194
|
lastEmittedRef.current = incoming;
|
|
220
|
-
editor.commands.setContent(incoming
|
|
195
|
+
editor.commands.setContent(incoming);
|
|
221
196
|
}, [editor, content]);
|
|
222
197
|
// Sync editable prop
|
|
223
198
|
useEffect(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimori/react-client",
|
|
3
|
-
"version": "0.4.11
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"format": "prettier --write ."
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@rimori/client": "2.5.19
|
|
27
|
+
"@rimori/client": "^2.5.19",
|
|
28
28
|
"react": "^18.1.0",
|
|
29
29
|
"react-dom": "^18.1.0"
|
|
30
30
|
},
|
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
"@tiptap/core": "^2.26.1",
|
|
33
33
|
"@tiptap/extension-image": "^2.26.1",
|
|
34
34
|
"@tiptap/extension-link": "^2.26.1",
|
|
35
|
-
"@tiptap/extension-paragraph": "^2.26.1",
|
|
36
35
|
"@tiptap/extension-table": "^2.26.1",
|
|
37
36
|
"@tiptap/extension-table-cell": "^2.26.1",
|
|
38
37
|
"@tiptap/extension-table-header": "^2.26.1",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
},
|
|
48
47
|
"devDependencies": {
|
|
49
48
|
"@eslint/js": "^9.37.0",
|
|
50
|
-
"@rimori/client": "2.5.19
|
|
49
|
+
"@rimori/client": "^2.5.19",
|
|
51
50
|
"@types/react": "^18.3.21",
|
|
52
51
|
"eslint-config-prettier": "^10.1.8",
|
|
53
52
|
"eslint-plugin-prettier": "^5.5.4",
|
|
@@ -2,7 +2,6 @@ import { JSX, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
|
2
2
|
import { useRimori } from '../../providers/PluginProvider';
|
|
3
3
|
import { Markdown } from 'tiptap-markdown';
|
|
4
4
|
import StarterKit from '@tiptap/starter-kit';
|
|
5
|
-
import { Paragraph } from '@tiptap/extension-paragraph';
|
|
6
5
|
import Table from '@tiptap/extension-table';
|
|
7
6
|
import TableCell from '@tiptap/extension-table-cell';
|
|
8
7
|
import TableHeader from '@tiptap/extension-table-header';
|
|
@@ -29,28 +28,6 @@ import { LuClipboardPaste, LuHeading1, LuHeading2, LuHeading3, LuLink, LuUnlink
|
|
|
29
28
|
import { FaBold, FaCode, FaItalic, FaParagraph, FaStrikethrough } from 'react-icons/fa';
|
|
30
29
|
import { ImageUploadExtension, triggerImageUpload } from './ImageUploadExtension';
|
|
31
30
|
|
|
32
|
-
// Extends TipTap's Paragraph to serialize empty paragraphs as <p></p>.
|
|
33
|
-
// Standard markdown collapses consecutive blank lines, losing empty paragraph nodes.
|
|
34
|
-
// Since tiptap-markdown enables html:true by default, <p></p> survives the round-trip.
|
|
35
|
-
const ParagraphPreserveEmpty = Paragraph.extend({
|
|
36
|
-
addStorage() {
|
|
37
|
-
return {
|
|
38
|
-
markdown: {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
serialize(state: any, node: any) {
|
|
41
|
-
if (node.childCount === 0) {
|
|
42
|
-
state.write('<p></p>');
|
|
43
|
-
} else {
|
|
44
|
-
state.renderInline(node);
|
|
45
|
-
}
|
|
46
|
-
state.closeBlock(node);
|
|
47
|
-
},
|
|
48
|
-
parse: {},
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
31
|
function getMarkdown(editor: Editor): string {
|
|
55
32
|
return (editor.storage as { markdown: { getMarkdown: () => string } }).markdown.getMarkdown();
|
|
56
33
|
}
|
|
@@ -582,8 +559,7 @@ export const MarkdownEditor = ({
|
|
|
582
559
|
|
|
583
560
|
const extensions = useMemo(
|
|
584
561
|
() => [
|
|
585
|
-
StarterKit
|
|
586
|
-
ParagraphPreserveEmpty,
|
|
562
|
+
StarterKit,
|
|
587
563
|
Table.configure({ resizable: false }),
|
|
588
564
|
TableRow,
|
|
589
565
|
TableHeader,
|
|
@@ -611,14 +587,13 @@ export const MarkdownEditor = ({
|
|
|
611
587
|
},
|
|
612
588
|
});
|
|
613
589
|
|
|
614
|
-
// Sync external content changes (e.g. AI autofill) without triggering update loop
|
|
615
|
-
// Pass false to setContent to prevent onUpdate from firing and re-normalizing the content.
|
|
590
|
+
// Sync external content changes (e.g. AI autofill) without triggering update loop
|
|
616
591
|
useEffect(() => {
|
|
617
592
|
if (!editor) return;
|
|
618
593
|
const incoming = content ?? '';
|
|
619
594
|
if (incoming === lastEmittedRef.current) return;
|
|
620
595
|
lastEmittedRef.current = incoming;
|
|
621
|
-
editor.commands.setContent(incoming
|
|
596
|
+
editor.commands.setContent(incoming);
|
|
622
597
|
}, [editor, content]);
|
|
623
598
|
|
|
624
599
|
// Sync editable prop
|