File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
packages/extension-unique-id/src Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' @tiptap/extension-unique-id ' : minor
3+ ---
4+
5+ Add ` updateDocument ` option to disable document updates caused by the Unique ID extension.
Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ export interface UniqueIDOptions {
3535 * @default null
3636 */
3737 filterTransaction : ( ( transaction : Transaction ) => boolean ) | null
38+ /**
39+ * Whether to update the document by adding unique IDs to the nodes. Set this
40+ * property to `false` if the document is in `readonly` mode, is immutable, or
41+ * you don't want it to be modified.
42+ *
43+ * @default true
44+ */
45+ updateDocument : boolean
3846}
3947
4048export const UniqueID = Extension . create < UniqueIDOptions > ( {
@@ -50,6 +58,7 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
5058 types : [ ] ,
5159 generateID : ( ) => uuidv4 ( ) ,
5260 filterTransaction : null ,
61+ updateDocument : true ,
5362 }
5463 } ,
5564
@@ -78,6 +87,10 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
7887
7988 // check initial content for missing ids
8089 onCreate ( ) {
90+ if ( ! this . options . updateDocument ) {
91+ return
92+ }
93+
8194 const collaboration = this . editor . extensionManager . extensions . find ( ext => ext . name === 'collaboration' )
8295 const collaborationCaret = this . editor . extensionManager . extensions . find ( ext => ext . name === 'collaborationCaret' )
8396
@@ -126,6 +139,10 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
126139 } ,
127140
128141 addProseMirrorPlugins ( ) {
142+ if ( ! this . options . updateDocument ) {
143+ return [ ]
144+ }
145+
129146 let dragSourceElement : Element | null = null
130147 let transformPasted = false
131148
You can’t perform that action at this time.
0 commit comments