@tiptap/core 3.0.0-beta.5 → 3.0.0-beta.7
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.cjs +25 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +25 -10
- package/dist/index.js.map +1 -1
- package/jsx-dev-runtime/index.cjs +1 -0
- package/jsx-dev-runtime/index.d.cts +1 -0
- package/jsx-dev-runtime/index.d.ts +1 -0
- package/jsx-dev-runtime/index.js +1 -0
- package/package.json +5 -4
- package/src/Editor.ts +1 -0
- package/src/commands/insertContentAt.ts +29 -10
- package/src/types.ts +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/jsx-runtime/jsx-runtime.cjs'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../src/jsx-runtime.ts'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from '../src/jsx-runtime.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../dist/jsx-runtime/jsx-runtime.js'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/core",
|
|
3
3
|
"description": "headless rich text editor",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.7",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -48,13 +48,14 @@
|
|
|
48
48
|
"files": [
|
|
49
49
|
"src",
|
|
50
50
|
"dist",
|
|
51
|
-
"jsx-runtime"
|
|
51
|
+
"jsx-runtime",
|
|
52
|
+
"jsx-dev-runtime"
|
|
52
53
|
],
|
|
53
54
|
"devDependencies": {
|
|
54
|
-
"@tiptap/pm": "3.0.0-beta.
|
|
55
|
+
"@tiptap/pm": "3.0.0-beta.7"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
|
-
"@tiptap/pm": "3.0.0-beta.
|
|
58
|
+
"@tiptap/pm": "3.0.0-beta.7"
|
|
58
59
|
},
|
|
59
60
|
"repository": {
|
|
60
61
|
"type": "git",
|
package/src/Editor.ts
CHANGED
|
@@ -76,18 +76,10 @@ export const insertContentAt: RawCommands['insertContentAt'] =
|
|
|
76
76
|
let content: Fragment | ProseMirrorNode
|
|
77
77
|
const { selection } = editor.state
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
content = createNodeFromContent(value, editor.schema, {
|
|
81
|
-
parseOptions: {
|
|
82
|
-
preserveWhitespace: 'full',
|
|
83
|
-
...options.parseOptions,
|
|
84
|
-
},
|
|
85
|
-
errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,
|
|
86
|
-
})
|
|
87
|
-
} catch (e) {
|
|
79
|
+
const emitContentError = (error: Error) => {
|
|
88
80
|
editor.emit('contentError', {
|
|
89
81
|
editor,
|
|
90
|
-
error
|
|
82
|
+
error,
|
|
91
83
|
disableCollaboration: () => {
|
|
92
84
|
if (
|
|
93
85
|
'collaboration' in editor.storage &&
|
|
@@ -98,6 +90,33 @@ export const insertContentAt: RawCommands['insertContentAt'] =
|
|
|
98
90
|
}
|
|
99
91
|
},
|
|
100
92
|
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const parseOptions: ParseOptions = {
|
|
96
|
+
preserveWhitespace: 'full',
|
|
97
|
+
...options.parseOptions,
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// If `emitContentError` is enabled, we want to check the content for errors
|
|
101
|
+
// but ignore them (do not remove the invalid content from the document)
|
|
102
|
+
if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {
|
|
103
|
+
try {
|
|
104
|
+
createNodeFromContent(value, editor.schema, {
|
|
105
|
+
parseOptions,
|
|
106
|
+
errorOnInvalidContent: true,
|
|
107
|
+
})
|
|
108
|
+
} catch (e) {
|
|
109
|
+
emitContentError(e as Error)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
content = createNodeFromContent(value, editor.schema, {
|
|
115
|
+
parseOptions,
|
|
116
|
+
errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,
|
|
117
|
+
})
|
|
118
|
+
} catch (e) {
|
|
119
|
+
emitContentError(e as Error)
|
|
101
120
|
return false
|
|
102
121
|
}
|
|
103
122
|
|
package/src/types.ts
CHANGED
|
@@ -354,6 +354,15 @@ export interface EditorOptions {
|
|
|
354
354
|
* @default false
|
|
355
355
|
*/
|
|
356
356
|
enableContentCheck: boolean
|
|
357
|
+
/**
|
|
358
|
+
* If `true`, the editor will emit the `contentError` event if invalid content is
|
|
359
|
+
* encountered but `enableContentCheck` is `false`. This lets you preserve the
|
|
360
|
+
* invalid editor content while still showing a warning or error message to
|
|
361
|
+
* the user.
|
|
362
|
+
*
|
|
363
|
+
* @default false
|
|
364
|
+
*/
|
|
365
|
+
emitContentError: boolean
|
|
357
366
|
/**
|
|
358
367
|
* Called before the editor is constructed.
|
|
359
368
|
*/
|