@tiptap/extension-unique-id 2.24.1 → 3.0.0-beta.10

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.
@@ -8,8 +8,6 @@ export function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {
8
8
  return array.filter(item => {
9
9
  const key = by(item)
10
10
 
11
- return Object.prototype.hasOwnProperty.call(seen, key)
12
- ? false
13
- : (seen[key] = true)
11
+ return Object.prototype.hasOwnProperty.call(seen, key) ? false : (seen[key] = true)
14
12
  })
15
13
  }
package/src/unique-id.ts CHANGED
@@ -1,21 +1,17 @@
1
- import {
2
- combineTransactionSteps,
3
- Extension,
4
- findChildren,
5
- findChildrenInRange,
6
- getChangedRanges,
7
- } from '@tiptap/core'
8
- import { Fragment, Node as ProseMirrorNode, Slice } from '@tiptap/pm/model'
9
- import { Plugin, PluginKey, Transaction } from '@tiptap/pm/state'
1
+ import { combineTransactionSteps, Extension, findChildren, findChildrenInRange, getChangedRanges } from '@tiptap/core'
2
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
3
+ import { Fragment, Slice } from '@tiptap/pm/model'
4
+ import type { Transaction } from '@tiptap/pm/state'
5
+ import { Plugin, PluginKey } from '@tiptap/pm/state'
10
6
  import { v4 as uuidv4 } from 'uuid'
11
7
 
12
8
  import { findDuplicates } from './helpers/findDuplicates.js'
13
9
 
14
10
  export interface UniqueIDOptions {
15
- attributeName: string,
16
- types: string[],
17
- generateID: () => any,
18
- filterTransaction: ((transaction: Transaction) => boolean) | null,
11
+ attributeName: string
12
+ types: string[]
13
+ generateID: () => any
14
+ filterTransaction: ((transaction: Transaction) => boolean) | null
19
15
  }
20
16
 
21
17
  export const UniqueID = Extension.create<UniqueIDOptions>({
@@ -111,10 +107,10 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
111
107
  key: new PluginKey('uniqueID'),
112
108
 
113
109
  appendTransaction: (transactions, oldState, newState) => {
114
- const hasDocChanges = transactions.some(transaction => transaction.docChanged)
115
- && !oldState.doc.eq(newState.doc)
116
- const filterTransactions = this.options.filterTransaction
117
- && transactions.some(tr => !this.options.filterTransaction?.(tr))
110
+ const hasDocChanges =
111
+ transactions.some(transaction => transaction.docChanged) && !oldState.doc.eq(newState.doc)
112
+ const filterTransactions =
113
+ this.options.filterTransaction && transactions.some(tr => !this.options.filterTransaction?.(tr))
118
114
 
119
115
  const isCollabTransaction = transactions.find(tr => tr.getMeta('y-sync$'))
120
116
 
@@ -140,9 +136,7 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
140
136
  return types.includes(node.type.name)
141
137
  })
142
138
 
143
- const newIds = newNodes
144
- .map(({ node }) => node.attrs[attributeName])
145
- .filter(id => id !== null)
139
+ const newIds = newNodes.map(({ node }) => node.attrs[attributeName]).filter(id => id !== null)
146
140
 
147
141
  newNodes.forEach(({ node, pos }, i) => {
148
142
  // instead of checking `node.attrs[attributeName]` directly
@@ -198,7 +192,6 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
198
192
  })
199
193
  }
200
194
  })
201
-
202
195
  })
203
196
 
204
197
  if (!tr.steps.length) {
@@ -238,9 +231,9 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
238
231
  // or content is dragged from another editor
239
232
  drop: (view, event) => {
240
233
  if (
241
- dragSourceElement !== view.dom.parentElement
242
- || event.dataTransfer?.effectAllowed === 'copyMove'
243
- || event.dataTransfer?.effectAllowed === 'copy'
234
+ dragSourceElement !== view.dom.parentElement ||
235
+ event.dataTransfer?.effectAllowed === 'copyMove' ||
236
+ event.dataTransfer?.effectAllowed === 'copy'
244
237
  ) {
245
238
  dragSourceElement = null
246
239
  transformPasted = true
@@ -307,5 +300,4 @@ export const UniqueID = Extension.create<UniqueIDOptions>({
307
300
  }),
308
301
  ]
309
302
  },
310
-
311
303
  })
@@ -1,5 +0,0 @@
1
- /**
2
- * Returns a list of duplicated items within an array.
3
- */
4
- export declare function findDuplicates(items: any[]): any[];
5
- //# sourceMappingURL=findDuplicates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findDuplicates.d.ts","sourceRoot":"","sources":["../../src/helpers/findDuplicates.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE,CAKlD"}
@@ -1,9 +0,0 @@
1
- /**
2
- * Removes duplicated values within an array.
3
- * Supports numbers, strings and objects.
4
- */
5
- export declare function removeDuplicates<T>(array: T[], by?: {
6
- (value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string;
7
- (value: any, replacer?: (number | string)[] | null, space?: string | number): string;
8
- }): T[];
9
- //# sourceMappingURL=removeDuplicates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"removeDuplicates.d.ts","sourceRoot":"","sources":["../../src/helpers/removeDuplicates.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE;;;CAAiB,GAAG,CAAC,EAAE,CAUxE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAEzC,cAAc,gBAAgB,CAAA;AAE9B,eAAe,QAAQ,CAAA"}
package/dist/index.umd.js DELETED
@@ -1,268 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/model'), require('@tiptap/pm/state'), require('uuid')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/model', '@tiptap/pm/state', 'uuid'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-unique-id"] = {}, global.core, global.model, global.state, global.uuid));
5
- })(this, (function (exports, core, model, state, uuid) { 'use strict';
6
-
7
- /**
8
- * Removes duplicated values within an array.
9
- * Supports numbers, strings and objects.
10
- */
11
- function removeDuplicates(array, by = JSON.stringify) {
12
- const seen = {};
13
- return array.filter(item => {
14
- const key = by(item);
15
- return Object.prototype.hasOwnProperty.call(seen, key)
16
- ? false
17
- : (seen[key] = true);
18
- });
19
- }
20
-
21
- /**
22
- * Returns a list of duplicated items within an array.
23
- */
24
- function findDuplicates(items) {
25
- const filtered = items.filter((el, index) => items.indexOf(el) !== index);
26
- const duplicates = removeDuplicates(filtered);
27
- return duplicates;
28
- }
29
-
30
- const UniqueID = core.Extension.create({
31
- name: 'uniqueID',
32
- // we’ll set a very high priority to make sure this runs first
33
- // and is compatible with `appendTransaction` hooks of other extensions
34
- priority: 10000,
35
- addOptions() {
36
- return {
37
- attributeName: 'id',
38
- types: [],
39
- generateID: () => uuid.v4(),
40
- filterTransaction: null,
41
- };
42
- },
43
- addGlobalAttributes() {
44
- return [
45
- {
46
- types: this.options.types,
47
- attributes: {
48
- [this.options.attributeName]: {
49
- default: null,
50
- parseHTML: element => element.getAttribute(`data-${this.options.attributeName}`),
51
- renderHTML: attributes => {
52
- if (!attributes[this.options.attributeName]) {
53
- return {};
54
- }
55
- return {
56
- [`data-${this.options.attributeName}`]: attributes[this.options.attributeName],
57
- };
58
- },
59
- },
60
- },
61
- },
62
- ];
63
- },
64
- // check initial content for missing ids
65
- onCreate() {
66
- const collab = this.editor.extensionManager.extensions.find(ext => ext.name === 'collaboration');
67
- const provider = (collab === null || collab === void 0 ? void 0 : collab.options) ? collab.options.provider : undefined;
68
- const createIds = () => {
69
- const { view, state } = this.editor;
70
- const { tr, doc } = state;
71
- const { types, attributeName, generateID } = this.options;
72
- const nodesWithoutId = core.findChildren(doc, node => {
73
- return types.includes(node.type.name) && node.attrs[attributeName] === null;
74
- });
75
- nodesWithoutId.forEach(({ node, pos }) => {
76
- tr.setNodeMarkup(pos, undefined, {
77
- ...node.attrs,
78
- [attributeName]: generateID(),
79
- });
80
- });
81
- tr.setMeta('addToHistory', false);
82
- view.dispatch(tr);
83
- if (provider) {
84
- provider.off('synced', createIds);
85
- }
86
- };
87
- /**
88
- * We need to handle collaboration a bit different here
89
- * because we can't automatically add IDs when the provider is not yet synced
90
- * otherwise we end up with empty paragraphs
91
- */
92
- if (collab) {
93
- if (!provider) {
94
- return createIds();
95
- }
96
- provider.on('synced', createIds);
97
- }
98
- else {
99
- return createIds();
100
- }
101
- },
102
- addProseMirrorPlugins() {
103
- let dragSourceElement = null;
104
- let transformPasted = false;
105
- return [
106
- new state.Plugin({
107
- key: new state.PluginKey('uniqueID'),
108
- appendTransaction: (transactions, oldState, newState) => {
109
- const hasDocChanges = transactions.some(transaction => transaction.docChanged)
110
- && !oldState.doc.eq(newState.doc);
111
- const filterTransactions = this.options.filterTransaction
112
- && transactions.some(tr => { var _a, _b; return !((_b = (_a = this.options).filterTransaction) === null || _b === void 0 ? void 0 : _b.call(_a, tr)); });
113
- const isCollabTransaction = transactions.find(tr => tr.getMeta('y-sync$'));
114
- if (isCollabTransaction) {
115
- return;
116
- }
117
- if (!hasDocChanges || filterTransactions) {
118
- return;
119
- }
120
- const { tr } = newState;
121
- const { types, attributeName, generateID } = this.options;
122
- const transform = core.combineTransactionSteps(oldState.doc, transactions);
123
- const { mapping } = transform;
124
- // get changed ranges based on the old state
125
- const changes = core.getChangedRanges(transform);
126
- changes.forEach(({ newRange }) => {
127
- const newNodes = core.findChildrenInRange(newState.doc, newRange, node => {
128
- return types.includes(node.type.name);
129
- });
130
- const newIds = newNodes
131
- .map(({ node }) => node.attrs[attributeName])
132
- .filter(id => id !== null);
133
- newNodes.forEach(({ node, pos }, i) => {
134
- var _a;
135
- // instead of checking `node.attrs[attributeName]` directly
136
- // we look at the current state of the node within `tr.doc`.
137
- // this helps to prevent adding new ids to the same node
138
- // if the node changed multiple times within one transaction
139
- const id = (_a = tr.doc.nodeAt(pos)) === null || _a === void 0 ? void 0 : _a.attrs[attributeName];
140
- if (id === null) {
141
- tr.setNodeMarkup(pos, undefined, {
142
- ...node.attrs,
143
- [attributeName]: generateID(),
144
- });
145
- return;
146
- }
147
- const nextNode = newNodes[i + 1];
148
- if (nextNode && node.content.size === 0) {
149
- tr.setNodeMarkup(nextNode.pos, undefined, {
150
- ...nextNode.node.attrs,
151
- [attributeName]: id,
152
- });
153
- newIds[i + 1] = id;
154
- if (nextNode.node.attrs[attributeName]) {
155
- return;
156
- }
157
- const generatedId = generateID();
158
- tr.setNodeMarkup(pos, undefined, {
159
- ...node.attrs,
160
- [attributeName]: generatedId,
161
- });
162
- newIds[i] = generatedId;
163
- return tr;
164
- }
165
- const duplicatedNewIds = findDuplicates(newIds);
166
- // check if the node doesn’t exist in the old state
167
- const { deleted } = mapping.invert().mapResult(pos);
168
- const newNode = deleted && duplicatedNewIds.includes(id);
169
- if (newNode) {
170
- tr.setNodeMarkup(pos, undefined, {
171
- ...node.attrs,
172
- [attributeName]: generateID(),
173
- });
174
- }
175
- });
176
- });
177
- if (!tr.steps.length) {
178
- return;
179
- }
180
- // `tr.setNodeMarkup` resets the stored marks
181
- // so we’ll restore them if they exist
182
- tr.setStoredMarks(newState.tr.storedMarks);
183
- return tr;
184
- },
185
- // we register a global drag handler to track the current drag source element
186
- view(view) {
187
- const handleDragstart = (event) => {
188
- var _a;
189
- dragSourceElement = ((_a = view.dom.parentElement) === null || _a === void 0 ? void 0 : _a.contains(event.target))
190
- ? view.dom.parentElement
191
- : null;
192
- };
193
- window.addEventListener('dragstart', handleDragstart);
194
- return {
195
- destroy() {
196
- window.removeEventListener('dragstart', handleDragstart);
197
- },
198
- };
199
- },
200
- props: {
201
- // `handleDOMEvents` is called before `transformPasted`
202
- // so we can do some checks before
203
- handleDOMEvents: {
204
- // only create new ids for dropped content
205
- // or dropped content while holding `alt`
206
- // or content is dragged from another editor
207
- drop: (view, event) => {
208
- var _a, _b;
209
- if (dragSourceElement !== view.dom.parentElement
210
- || ((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.effectAllowed) === 'copyMove'
211
- || ((_b = event.dataTransfer) === null || _b === void 0 ? void 0 : _b.effectAllowed) === 'copy') {
212
- dragSourceElement = null;
213
- transformPasted = true;
214
- }
215
- return false;
216
- },
217
- // always create new ids on pasted content
218
- paste: () => {
219
- transformPasted = true;
220
- return false;
221
- },
222
- },
223
- // we’ll remove ids for every pasted node
224
- // so we can create a new one within `appendTransaction`
225
- transformPasted: slice => {
226
- if (!transformPasted) {
227
- return slice;
228
- }
229
- const { types, attributeName } = this.options;
230
- const removeId = (fragment) => {
231
- const list = [];
232
- fragment.forEach(node => {
233
- // don’t touch text nodes
234
- if (node.isText) {
235
- list.push(node);
236
- return;
237
- }
238
- // check for any other child nodes
239
- if (!types.includes(node.type.name)) {
240
- list.push(node.copy(removeId(node.content)));
241
- return;
242
- }
243
- // remove id
244
- const nodeWithoutId = node.type.create({
245
- ...node.attrs,
246
- [attributeName]: null,
247
- }, removeId(node.content), node.marks);
248
- list.push(nodeWithoutId);
249
- });
250
- return model.Fragment.from(list);
251
- };
252
- // reset check
253
- transformPasted = false;
254
- return new model.Slice(removeId(slice.content), slice.openStart, slice.openEnd);
255
- },
256
- },
257
- }),
258
- ];
259
- },
260
- });
261
-
262
- exports.UniqueID = UniqueID;
263
- exports.default = UniqueID;
264
-
265
- Object.defineProperty(exports, '__esModule', { value: true });
266
-
267
- }));
268
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/helpers/removeDuplicates.ts","../src/helpers/findDuplicates.ts","../src/unique-id.ts"],"sourcesContent":["/**\n * Removes duplicated values within an array.\n * Supports numbers, strings and objects.\n */\nexport function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {\n const seen: Record<any, any> = {}\n\n return array.filter(item => {\n const key = by(item)\n\n return Object.prototype.hasOwnProperty.call(seen, key)\n ? false\n : (seen[key] = true)\n })\n}\n","import { removeDuplicates } from './removeDuplicates.js'\n\n/**\n * Returns a list of duplicated items within an array.\n */\nexport function findDuplicates(items: any[]): any[] {\n const filtered = items.filter((el, index) => items.indexOf(el) !== index)\n const duplicates = removeDuplicates(filtered)\n\n return duplicates\n}\n","import {\n combineTransactionSteps,\n Extension,\n findChildren,\n findChildrenInRange,\n getChangedRanges,\n} from '@tiptap/core'\nimport { Fragment, Node as ProseMirrorNode, Slice } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, Transaction } from '@tiptap/pm/state'\nimport { v4 as uuidv4 } from 'uuid'\n\nimport { findDuplicates } from './helpers/findDuplicates.js'\n\nexport interface UniqueIDOptions {\n attributeName: string,\n types: string[],\n generateID: () => any,\n filterTransaction: ((transaction: Transaction) => boolean) | null,\n}\n\nexport const UniqueID = Extension.create<UniqueIDOptions>({\n name: 'uniqueID',\n\n // we’ll set a very high priority to make sure this runs first\n // and is compatible with `appendTransaction` hooks of other extensions\n priority: 10000,\n\n addOptions() {\n return {\n attributeName: 'id',\n types: [],\n generateID: () => uuidv4(),\n filterTransaction: null,\n }\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n [this.options.attributeName]: {\n default: null,\n parseHTML: element => element.getAttribute(`data-${this.options.attributeName}`),\n renderHTML: attributes => {\n if (!attributes[this.options.attributeName]) {\n return {}\n }\n\n return {\n [`data-${this.options.attributeName}`]: attributes[this.options.attributeName],\n }\n },\n },\n },\n },\n ]\n },\n\n // check initial content for missing ids\n onCreate() {\n const collab = this.editor.extensionManager.extensions.find(ext => ext.name === 'collaboration')\n const provider = collab?.options ? collab.options.provider : undefined\n\n const createIds = () => {\n const { view, state } = this.editor\n const { tr, doc } = state\n const { types, attributeName, generateID } = this.options\n const nodesWithoutId = findChildren(doc, node => {\n return types.includes(node.type.name) && node.attrs[attributeName] === null\n })\n\n nodesWithoutId.forEach(({ node, pos }) => {\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n [attributeName]: generateID(),\n })\n })\n\n tr.setMeta('addToHistory', false)\n\n view.dispatch(tr)\n\n if (provider) {\n provider.off('synced', createIds)\n }\n }\n\n /**\n * We need to handle collaboration a bit different here\n * because we can't automatically add IDs when the provider is not yet synced\n * otherwise we end up with empty paragraphs\n */\n if (collab) {\n if (!provider) {\n return createIds()\n }\n\n provider.on('synced', createIds)\n } else {\n return createIds()\n }\n },\n\n addProseMirrorPlugins() {\n let dragSourceElement: Element | null = null\n let transformPasted = false\n\n return [\n new Plugin({\n key: new PluginKey('uniqueID'),\n\n appendTransaction: (transactions, oldState, newState) => {\n const hasDocChanges = transactions.some(transaction => transaction.docChanged)\n && !oldState.doc.eq(newState.doc)\n const filterTransactions = this.options.filterTransaction\n && transactions.some(tr => !this.options.filterTransaction?.(tr))\n\n const isCollabTransaction = transactions.find(tr => tr.getMeta('y-sync$'))\n\n if (isCollabTransaction) {\n return\n }\n\n if (!hasDocChanges || filterTransactions) {\n return\n }\n\n const { tr } = newState\n\n const { types, attributeName, generateID } = this.options\n const transform = combineTransactionSteps(oldState.doc, transactions as Transaction[])\n const { mapping } = transform\n\n // get changed ranges based on the old state\n const changes = getChangedRanges(transform)\n\n changes.forEach(({ newRange }) => {\n const newNodes = findChildrenInRange(newState.doc, newRange, node => {\n return types.includes(node.type.name)\n })\n\n const newIds = newNodes\n .map(({ node }) => node.attrs[attributeName])\n .filter(id => id !== null)\n\n newNodes.forEach(({ node, pos }, i) => {\n // instead of checking `node.attrs[attributeName]` directly\n // we look at the current state of the node within `tr.doc`.\n // this helps to prevent adding new ids to the same node\n // if the node changed multiple times within one transaction\n const id = tr.doc.nodeAt(pos)?.attrs[attributeName]\n\n if (id === null) {\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n [attributeName]: generateID(),\n })\n\n return\n }\n\n const nextNode = newNodes[i + 1]\n\n if (nextNode && node.content.size === 0) {\n tr.setNodeMarkup(nextNode.pos, undefined, {\n ...nextNode.node.attrs,\n [attributeName]: id,\n })\n newIds[i + 1] = id\n\n if (nextNode.node.attrs[attributeName]) {\n return\n }\n\n const generatedId = generateID()\n\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n [attributeName]: generatedId,\n })\n newIds[i] = generatedId\n\n return tr\n }\n\n const duplicatedNewIds = findDuplicates(newIds)\n\n // check if the node doesn’t exist in the old state\n const { deleted } = mapping.invert().mapResult(pos)\n\n const newNode = deleted && duplicatedNewIds.includes(id)\n\n if (newNode) {\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n [attributeName]: generateID(),\n })\n }\n })\n\n })\n\n if (!tr.steps.length) {\n return\n }\n\n // `tr.setNodeMarkup` resets the stored marks\n // so we’ll restore them if they exist\n tr.setStoredMarks(newState.tr.storedMarks)\n\n return tr\n },\n\n // we register a global drag handler to track the current drag source element\n view(view) {\n const handleDragstart = (event: DragEvent) => {\n dragSourceElement = view.dom.parentElement?.contains(event.target as Element)\n ? view.dom.parentElement\n : null\n }\n\n window.addEventListener('dragstart', handleDragstart)\n\n return {\n destroy() {\n window.removeEventListener('dragstart', handleDragstart)\n },\n }\n },\n\n props: {\n // `handleDOMEvents` is called before `transformPasted`\n // so we can do some checks before\n handleDOMEvents: {\n // only create new ids for dropped content\n // or dropped content while holding `alt`\n // or content is dragged from another editor\n drop: (view, event) => {\n if (\n dragSourceElement !== view.dom.parentElement\n || event.dataTransfer?.effectAllowed === 'copyMove'\n || event.dataTransfer?.effectAllowed === 'copy'\n ) {\n dragSourceElement = null\n transformPasted = true\n }\n\n return false\n },\n // always create new ids on pasted content\n paste: () => {\n transformPasted = true\n\n return false\n },\n },\n\n // we’ll remove ids for every pasted node\n // so we can create a new one within `appendTransaction`\n transformPasted: slice => {\n if (!transformPasted) {\n return slice\n }\n\n const { types, attributeName } = this.options\n const removeId = (fragment: Fragment): Fragment => {\n const list: ProseMirrorNode[] = []\n\n fragment.forEach(node => {\n // don’t touch text nodes\n if (node.isText) {\n list.push(node)\n\n return\n }\n\n // check for any other child nodes\n if (!types.includes(node.type.name)) {\n list.push(node.copy(removeId(node.content)))\n\n return\n }\n\n // remove id\n const nodeWithoutId = node.type.create(\n {\n ...node.attrs,\n [attributeName]: null,\n },\n removeId(node.content),\n node.marks,\n )\n\n list.push(nodeWithoutId)\n })\n\n return Fragment.from(list)\n }\n\n // reset check\n transformPasted = false\n\n return new Slice(removeId(slice.content), slice.openStart, slice.openEnd)\n },\n },\n }),\n ]\n },\n\n})\n"],"names":["Extension","uuidv4","findChildren","Plugin","PluginKey","combineTransactionSteps","getChangedRanges","findChildrenInRange","Fragment","Slice"],"mappings":";;;;;;EAAA;;;EAGG;EACG,SAAU,gBAAgB,CAAI,KAAU,EAAE,EAAE,GAAG,IAAI,CAAC,SAAS,EAAA;MACjE,MAAM,IAAI,GAAqB,EAAE;EAEjC,IAAA,OAAO,KAAK,CAAC,MAAM,CAAC,IAAI,IAAG;EACzB,QAAA,MAAM,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;UAEpB,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG;EACnD,cAAE;iBACC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;EACxB,KAAC,CAAC;EACJ;;ECZA;;EAEG;EACG,SAAU,cAAc,CAAC,KAAY,EAAA;MACzC,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,KAAK,KAAK,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC;EACzE,IAAA,MAAM,UAAU,GAAG,gBAAgB,CAAC,QAAQ,CAAC;EAE7C,IAAA,OAAO,UAAU;EACnB;;ACUa,QAAA,QAAQ,GAAGA,cAAS,CAAC,MAAM,CAAkB;EACxD,IAAA,IAAI,EAAE,UAAU;;;EAIhB,IAAA,QAAQ,EAAE,KAAK;MAEf,UAAU,GAAA;UACR,OAAO;EACL,YAAA,aAAa,EAAE,IAAI;EACnB,YAAA,KAAK,EAAE,EAAE;EACT,YAAA,UAAU,EAAE,MAAMC,OAAM,EAAE;EAC1B,YAAA,iBAAiB,EAAE,IAAI;WACxB;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