@vertesia/rich-text 1.5.0-dev.20260807.073259Z → 1.5.0-dev.20260901.005903Z
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/lib/MarkdownEditors.d.ts +2 -0
- package/lib/MarkdownEditors.d.ts.map +1 -1
- package/lib/MarkdownEditors.js +3 -1
- package/lib/MarkdownEditors.js.map +1 -1
- package/lib/MarkdownRichTextEditor.d.ts.map +1 -1
- package/lib/MarkdownRichTextEditor.js +8 -2
- package/lib/MarkdownRichTextEditor.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/markdown.d.ts.map +1 -1
- package/lib/markdown.js +2 -1
- package/lib/markdown.js.map +1 -1
- package/lib/vertesia-rich-text.js +129 -65
- package/lib/vertesia-rich-text.js.map +1 -1
- package/package.json +13 -13
- package/src/MarkdownEditors.tsx +4 -1
- package/src/MarkdownRichTextEditor.tsx +7 -2
- package/src/index.ts +1 -0
- package/src/markdown.tsx +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vertesia/rich-text",
|
|
3
|
-
"version": "1.5.0-dev.
|
|
3
|
+
"version": "1.5.0-dev.20260901.005903Z",
|
|
4
4
|
"description": "Markdown-first rich-text editing primitives for Vertesia",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -18,16 +18,16 @@
|
|
|
18
18
|
"tiptap"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@tiptap/core": "^3.
|
|
22
|
-
"@tiptap/extension-code-block": "^3.
|
|
23
|
-
"@tiptap/extension-image": "^3.
|
|
24
|
-
"@tiptap/extension-link": "^3.
|
|
25
|
-
"@tiptap/extension-table": "^3.
|
|
26
|
-
"@tiptap/markdown": "^3.
|
|
27
|
-
"@tiptap/pm": "^3.
|
|
28
|
-
"@tiptap/react": "^3.
|
|
29
|
-
"@tiptap/starter-kit": "^3.
|
|
30
|
-
"marked": "^
|
|
21
|
+
"@tiptap/core": "^3.30.0",
|
|
22
|
+
"@tiptap/extension-code-block": "^3.30.0",
|
|
23
|
+
"@tiptap/extension-image": "^3.30.0",
|
|
24
|
+
"@tiptap/extension-link": "^3.30.0",
|
|
25
|
+
"@tiptap/extension-table": "^3.30.0",
|
|
26
|
+
"@tiptap/markdown": "^3.30.0",
|
|
27
|
+
"@tiptap/pm": "^3.30.0",
|
|
28
|
+
"@tiptap/react": "^3.30.0",
|
|
29
|
+
"@tiptap/starter-kit": "^3.30.0",
|
|
30
|
+
"marked": "^18.0.9",
|
|
31
31
|
"react": "19.2.7",
|
|
32
32
|
"react-dom": "19.2.7"
|
|
33
33
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/node": "^24.13.3",
|
|
36
36
|
"@types/react": "19.2.17",
|
|
37
37
|
"@types/react-dom": "19.2.3",
|
|
38
|
-
"rolldown": "1.2.
|
|
38
|
+
"rolldown": "1.2.4",
|
|
39
39
|
"typescript": "7.0.2",
|
|
40
40
|
"vitest": "^4.1.9",
|
|
41
41
|
"@vertesia/tsconfig": "0.1.0"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"url": "https://github.com/vertesia/composableai.git",
|
|
52
52
|
"directory": "packages/rich-text"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "73de8716696201bda20b5ec0d0134bafd597387e",
|
|
55
55
|
"scripts": {
|
|
56
56
|
"clean:lib": "rimraf ./lib ./tsconfig.tsbuildinfo",
|
|
57
57
|
"clean": "rimraf ./node_modules ./lib ./tsconfig.tsbuildinfo",
|
package/src/MarkdownEditors.tsx
CHANGED
|
@@ -9,6 +9,9 @@ export interface MarkdownComponentEditorProps extends MarkdownEditorShellProps {
|
|
|
9
9
|
|
|
10
10
|
export interface MarkdownDocumentEditorProps extends MarkdownEditorShellProps {}
|
|
11
11
|
|
|
12
|
+
/** Default delay before a full-document edit is serialized back to Markdown. */
|
|
13
|
+
export const DOCUMENT_EDITOR_CHANGE_DEBOUNCE_MS = 150;
|
|
14
|
+
|
|
12
15
|
function mergeClasses(...values: Array<string | undefined>): string {
|
|
13
16
|
return values.filter(Boolean).join(' ');
|
|
14
17
|
}
|
|
@@ -33,7 +36,7 @@ export function MarkdownComponentEditor({
|
|
|
33
36
|
export function MarkdownDocumentEditor({
|
|
34
37
|
className,
|
|
35
38
|
contentClassName,
|
|
36
|
-
onChangeDebounceMs =
|
|
39
|
+
onChangeDebounceMs = DOCUMENT_EDITOR_CHANGE_DEBOUNCE_MS,
|
|
37
40
|
...props
|
|
38
41
|
}: MarkdownDocumentEditorProps) {
|
|
39
42
|
return (
|
|
@@ -116,7 +116,10 @@ export function MarkdownRichTextEditor({
|
|
|
116
116
|
...(ariaLabel ? { 'aria-label': ariaLabel } : {}),
|
|
117
117
|
},
|
|
118
118
|
},
|
|
119
|
-
onUpdate: ({ editor: updatedEditor }) => {
|
|
119
|
+
onUpdate: ({ editor: updatedEditor, transaction }) => {
|
|
120
|
+
// Tiptap emits `update` for state changes that leave the document untouched, so
|
|
121
|
+
// serializing here would report an edit the user never made.
|
|
122
|
+
if (!transaction.docChanged) return;
|
|
120
123
|
if (changeTimeoutRef.current !== undefined) clearTimeout(changeTimeoutRef.current);
|
|
121
124
|
|
|
122
125
|
const emitMarkdown = () => {
|
|
@@ -151,7 +154,9 @@ export function MarkdownRichTextEditor({
|
|
|
151
154
|
);
|
|
152
155
|
|
|
153
156
|
useEffect(() => {
|
|
154
|
-
|
|
157
|
+
// `setEditable` emits an `update` with an empty transaction unless told not to; that
|
|
158
|
+
// phantom update would re-serialize the document on mount and on every editable toggle.
|
|
159
|
+
editor?.setEditable(editable, false);
|
|
155
160
|
}, [editable, editor]);
|
|
156
161
|
|
|
157
162
|
useEffect(() => {
|
package/src/index.ts
CHANGED
package/src/markdown.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { CodeBlock, type CodeBlockOptions } from '@tiptap/extension-code-block';
|
|
|
3
3
|
import { Image, type ImageOptions } from '@tiptap/extension-image';
|
|
4
4
|
import { Link, type LinkOptions } from '@tiptap/extension-link';
|
|
5
5
|
import { TableKit } from '@tiptap/extension-table';
|
|
6
|
-
import { Markdown } from '@tiptap/markdown';
|
|
6
|
+
import { Markdown, type MarkdownExtensionOptions } from '@tiptap/markdown';
|
|
7
7
|
import {
|
|
8
8
|
MarkViewContent,
|
|
9
9
|
type MarkViewProps,
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
ReactNodeViewRenderer,
|
|
15
15
|
} from '@tiptap/react';
|
|
16
16
|
import StarterKit from '@tiptap/starter-kit';
|
|
17
|
-
import { Marked
|
|
17
|
+
import { Marked } from 'marked';
|
|
18
18
|
import type { OpaqueMarkdownKind, RichTextRenderers } from './types.js';
|
|
19
19
|
|
|
20
20
|
export const VERTESIA_WIDGET_LANGUAGES = new Set(['chart', 'vega-lite', 'vegalite', 'mermaid', 'mockup', 'svg']);
|
|
@@ -69,11 +69,12 @@ function markdownLabel(value: string): string {
|
|
|
69
69
|
return value.replaceAll('\\', '\\\\').replaceAll('[', '\\[').replaceAll(']', '\\]');
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
function createIsolatedMarked():
|
|
72
|
+
function createIsolatedMarked(): NonNullable<MarkdownExtensionOptions['marked']> {
|
|
73
73
|
// Tiptap types this option as the callable singleton even though MarkdownManager only
|
|
74
74
|
// consumes the instance methods shared by Marked. A fresh instance prevents one editor's
|
|
75
|
-
// custom tokenizers from accumulating globally across tests, remounts, and workspaces.
|
|
76
|
-
|
|
75
|
+
// custom tokenizers from accumulating globally across tests, remounts, and workspaces. Type
|
|
76
|
+
// the adapter against Tiptap's bundled marked contract so direct major upgrades stay isolated.
|
|
77
|
+
return new Marked() as unknown as NonNullable<MarkdownExtensionOptions['marked']>;
|
|
77
78
|
}
|
|
78
79
|
|
|
79
80
|
function trimConsumedNewline(raw: string): string {
|