@tiptap/core 2.0.0-rc.2 → 2.0.0

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.
@@ -235,6 +235,7 @@ declare module '@tiptap/core' {
235
235
  options: Options;
236
236
  storage: Storage;
237
237
  parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive'];
238
+ editor?: Editor;
238
239
  }) => MarkSpec['inclusive']);
239
240
  /**
240
241
  * Excludes
@@ -244,6 +245,7 @@ declare module '@tiptap/core' {
244
245
  options: Options;
245
246
  storage: Storage;
246
247
  parent: ParentConfig<MarkConfig<Options, Storage>>['excludes'];
248
+ editor?: Editor;
247
249
  }) => MarkSpec['excludes']);
248
250
  /**
249
251
  * Marks this Mark as exitable
@@ -257,6 +259,7 @@ declare module '@tiptap/core' {
257
259
  options: Options;
258
260
  storage: Storage;
259
261
  parent: ParentConfig<MarkConfig<Options, Storage>>['group'];
262
+ editor?: Editor;
260
263
  }) => MarkSpec['group']);
261
264
  /**
262
265
  * Spanning
@@ -266,6 +269,7 @@ declare module '@tiptap/core' {
266
269
  options: Options;
267
270
  storage: Storage;
268
271
  parent: ParentConfig<MarkConfig<Options, Storage>>['spanning'];
272
+ editor?: Editor;
269
273
  }) => MarkSpec['spanning']);
270
274
  /**
271
275
  * Code
@@ -275,6 +279,7 @@ declare module '@tiptap/core' {
275
279
  options: Options;
276
280
  storage: Storage;
277
281
  parent: ParentConfig<MarkConfig<Options, Storage>>['code'];
282
+ editor?: Editor;
278
283
  }) => boolean);
279
284
  /**
280
285
  * Parse HTML
@@ -284,6 +289,7 @@ declare module '@tiptap/core' {
284
289
  options: Options;
285
290
  storage: Storage;
286
291
  parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML'];
292
+ editor?: Editor;
287
293
  }) => MarkSpec['parseDOM'];
288
294
  /**
289
295
  * Render HTML
@@ -293,6 +299,7 @@ declare module '@tiptap/core' {
293
299
  options: Options;
294
300
  storage: Storage;
295
301
  parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML'];
302
+ editor?: Editor;
296
303
  }, props: {
297
304
  mark: ProseMirrorMark;
298
305
  HTMLAttributes: Record<string, any>;
@@ -305,6 +312,7 @@ declare module '@tiptap/core' {
305
312
  options: Options;
306
313
  storage: Storage;
307
314
  parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes'];
315
+ editor?: Editor;
308
316
  }) => Attributes | {};
309
317
  }
310
318
  }
@@ -127,6 +127,7 @@ declare module '@tiptap/core' {
127
127
  options: Options;
128
128
  storage: Storage;
129
129
  parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema'];
130
+ editor?: Editor;
130
131
  }, extension: Node) => Record<string, any>) | null;
131
132
  /**
132
133
  * The editor is not ready yet.
@@ -245,6 +246,7 @@ declare module '@tiptap/core' {
245
246
  options: Options;
246
247
  storage: Storage;
247
248
  parent: ParentConfig<NodeConfig<Options, Storage>>['content'];
249
+ editor?: Editor;
248
250
  }) => NodeSpec['content']);
249
251
  /**
250
252
  * Marks
@@ -254,6 +256,7 @@ declare module '@tiptap/core' {
254
256
  options: Options;
255
257
  storage: Storage;
256
258
  parent: ParentConfig<NodeConfig<Options, Storage>>['marks'];
259
+ editor?: Editor;
257
260
  }) => NodeSpec['marks']);
258
261
  /**
259
262
  * Group
@@ -263,6 +266,7 @@ declare module '@tiptap/core' {
263
266
  options: Options;
264
267
  storage: Storage;
265
268
  parent: ParentConfig<NodeConfig<Options, Storage>>['group'];
269
+ editor?: Editor;
266
270
  }) => NodeSpec['group']);
267
271
  /**
268
272
  * Inline
@@ -272,6 +276,7 @@ declare module '@tiptap/core' {
272
276
  options: Options;
273
277
  storage: Storage;
274
278
  parent: ParentConfig<NodeConfig<Options, Storage>>['inline'];
279
+ editor?: Editor;
275
280
  }) => NodeSpec['inline']);
276
281
  /**
277
282
  * Atom
@@ -281,6 +286,7 @@ declare module '@tiptap/core' {
281
286
  options: Options;
282
287
  storage: Storage;
283
288
  parent: ParentConfig<NodeConfig<Options, Storage>>['atom'];
289
+ editor?: Editor;
284
290
  }) => NodeSpec['atom']);
285
291
  /**
286
292
  * Selectable
@@ -290,6 +296,7 @@ declare module '@tiptap/core' {
290
296
  options: Options;
291
297
  storage: Storage;
292
298
  parent: ParentConfig<NodeConfig<Options, Storage>>['selectable'];
299
+ editor?: Editor;
293
300
  }) => NodeSpec['selectable']);
294
301
  /**
295
302
  * Draggable
@@ -299,6 +306,7 @@ declare module '@tiptap/core' {
299
306
  options: Options;
300
307
  storage: Storage;
301
308
  parent: ParentConfig<NodeConfig<Options, Storage>>['draggable'];
309
+ editor?: Editor;
302
310
  }) => NodeSpec['draggable']);
303
311
  /**
304
312
  * Code
@@ -308,6 +316,7 @@ declare module '@tiptap/core' {
308
316
  options: Options;
309
317
  storage: Storage;
310
318
  parent: ParentConfig<NodeConfig<Options, Storage>>['code'];
319
+ editor?: Editor;
311
320
  }) => NodeSpec['code']);
312
321
  /**
313
322
  * Whitespace
@@ -317,6 +326,7 @@ declare module '@tiptap/core' {
317
326
  options: Options;
318
327
  storage: Storage;
319
328
  parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace'];
329
+ editor?: Editor;
320
330
  }) => NodeSpec['whitespace']);
321
331
  /**
322
332
  * Defining
@@ -326,6 +336,7 @@ declare module '@tiptap/core' {
326
336
  options: Options;
327
337
  storage: Storage;
328
338
  parent: ParentConfig<NodeConfig<Options, Storage>>['defining'];
339
+ editor?: Editor;
329
340
  }) => NodeSpec['defining']);
330
341
  /**
331
342
  * Isolating
@@ -335,6 +346,7 @@ declare module '@tiptap/core' {
335
346
  options: Options;
336
347
  storage: Storage;
337
348
  parent: ParentConfig<NodeConfig<Options, Storage>>['isolating'];
349
+ editor?: Editor;
338
350
  }) => NodeSpec['isolating']);
339
351
  /**
340
352
  * Parse HTML
@@ -344,6 +356,7 @@ declare module '@tiptap/core' {
344
356
  options: Options;
345
357
  storage: Storage;
346
358
  parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML'];
359
+ editor?: Editor;
347
360
  }) => NodeSpec['parseDOM'];
348
361
  /**
349
362
  * Render HTML
@@ -353,6 +366,7 @@ declare module '@tiptap/core' {
353
366
  options: Options;
354
367
  storage: Storage;
355
368
  parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML'];
369
+ editor?: Editor;
356
370
  }, props: {
357
371
  node: ProseMirrorNode;
358
372
  HTMLAttributes: Record<string, any>;
@@ -365,6 +379,7 @@ declare module '@tiptap/core' {
365
379
  options: Options;
366
380
  storage: Storage;
367
381
  parent: ParentConfig<NodeConfig<Options, Storage>>['renderText'];
382
+ editor?: Editor;
368
383
  }, props: {
369
384
  node: ProseMirrorNode;
370
385
  pos: number;
@@ -379,6 +394,7 @@ declare module '@tiptap/core' {
379
394
  options: Options;
380
395
  storage: Storage;
381
396
  parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes'];
397
+ editor?: Editor;
382
398
  }) => Attributes | {};
383
399
  }
384
400
  }
@@ -1,3 +1,4 @@
1
1
  import { Schema } from '@tiptap/pm/model';
2
+ import { Editor } from '../Editor';
2
3
  import { Extensions } from '../types';
3
- export declare function getSchema(extensions: Extensions): Schema;
4
+ export declare function getSchema(extensions: Extensions, editor?: Editor): Schema;
@@ -1,3 +1,4 @@
1
1
  import { Schema } from '@tiptap/pm/model';
2
+ import { Editor } from '..';
2
3
  import { Extensions } from '../types';
3
- export declare function getSchemaByResolvedExtensions(extensions: Extensions): Schema;
4
+ export declare function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/core",
3
3
  "description": "headless rich text editor",
4
- "version": "2.0.0-rc.2",
4
+ "version": "2.0.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -32,10 +32,10 @@
32
32
  "dist"
33
33
  ],
34
34
  "peerDependencies": {
35
- "@tiptap/pm": "^2.0.0-rc.1"
35
+ "@tiptap/pm": "^2.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@tiptap/pm": "^2.0.0-rc.1"
38
+ "@tiptap/pm": "^2.0.0"
39
39
  },
40
40
  "repository": {
41
41
  "type": "git",
@@ -31,7 +31,7 @@ export class ExtensionManager {
31
31
  constructor(extensions: Extensions, editor: Editor) {
32
32
  this.editor = editor
33
33
  this.extensions = ExtensionManager.resolve(extensions)
34
- this.schema = getSchemaByResolvedExtensions(this.extensions)
34
+ this.schema = getSchemaByResolvedExtensions(this.extensions, editor)
35
35
 
36
36
  this.extensions.forEach(extension => {
37
37
  // store extension storage in editor
package/src/Mark.ts CHANGED
@@ -311,6 +311,7 @@ declare module '@tiptap/core' {
311
311
  options: Options
312
312
  storage: Storage
313
313
  parent: ParentConfig<MarkConfig<Options, Storage>>['inclusive']
314
+ editor?: Editor
314
315
  }) => MarkSpec['inclusive'])
315
316
 
316
317
  /**
@@ -323,6 +324,7 @@ declare module '@tiptap/core' {
323
324
  options: Options
324
325
  storage: Storage
325
326
  parent: ParentConfig<MarkConfig<Options, Storage>>['excludes']
327
+ editor?: Editor
326
328
  }) => MarkSpec['excludes'])
327
329
 
328
330
  /**
@@ -340,6 +342,7 @@ declare module '@tiptap/core' {
340
342
  options: Options
341
343
  storage: Storage
342
344
  parent: ParentConfig<MarkConfig<Options, Storage>>['group']
345
+ editor?: Editor
343
346
  }) => MarkSpec['group'])
344
347
 
345
348
  /**
@@ -352,6 +355,7 @@ declare module '@tiptap/core' {
352
355
  options: Options
353
356
  storage: Storage
354
357
  parent: ParentConfig<MarkConfig<Options, Storage>>['spanning']
358
+ editor?: Editor
355
359
  }) => MarkSpec['spanning'])
356
360
 
357
361
  /**
@@ -364,6 +368,7 @@ declare module '@tiptap/core' {
364
368
  options: Options
365
369
  storage: Storage
366
370
  parent: ParentConfig<MarkConfig<Options, Storage>>['code']
371
+ editor?: Editor
367
372
  }) => boolean)
368
373
 
369
374
  /**
@@ -374,6 +379,7 @@ declare module '@tiptap/core' {
374
379
  options: Options
375
380
  storage: Storage
376
381
  parent: ParentConfig<MarkConfig<Options, Storage>>['parseHTML']
382
+ editor?: Editor
377
383
  }) => MarkSpec['parseDOM']
378
384
 
379
385
  /**
@@ -386,6 +392,7 @@ declare module '@tiptap/core' {
386
392
  options: Options
387
393
  storage: Storage
388
394
  parent: ParentConfig<MarkConfig<Options, Storage>>['renderHTML']
395
+ editor?: Editor
389
396
  },
390
397
  props: {
391
398
  mark: ProseMirrorMark
@@ -402,6 +409,7 @@ declare module '@tiptap/core' {
402
409
  options: Options
403
410
  storage: Storage
404
411
  parent: ParentConfig<MarkConfig<Options, Storage>>['addAttributes']
412
+ editor?: Editor
405
413
  }) => Attributes | {}
406
414
  }
407
415
  }
package/src/Node.ts CHANGED
@@ -164,6 +164,7 @@ declare module '@tiptap/core' {
164
164
  options: Options
165
165
  storage: Storage
166
166
  parent: ParentConfig<NodeConfig<Options, Storage>>['extendMarkSchema']
167
+ editor?: Editor
167
168
  },
168
169
  extension: Node,
169
170
  ) => Record<string, any>)
@@ -325,6 +326,7 @@ declare module '@tiptap/core' {
325
326
  options: Options
326
327
  storage: Storage
327
328
  parent: ParentConfig<NodeConfig<Options, Storage>>['content']
329
+ editor?: Editor
328
330
  }) => NodeSpec['content'])
329
331
 
330
332
  /**
@@ -337,6 +339,7 @@ declare module '@tiptap/core' {
337
339
  options: Options
338
340
  storage: Storage
339
341
  parent: ParentConfig<NodeConfig<Options, Storage>>['marks']
342
+ editor?: Editor
340
343
  }) => NodeSpec['marks'])
341
344
 
342
345
  /**
@@ -349,6 +352,7 @@ declare module '@tiptap/core' {
349
352
  options: Options
350
353
  storage: Storage
351
354
  parent: ParentConfig<NodeConfig<Options, Storage>>['group']
355
+ editor?: Editor
352
356
  }) => NodeSpec['group'])
353
357
 
354
358
  /**
@@ -361,6 +365,7 @@ declare module '@tiptap/core' {
361
365
  options: Options
362
366
  storage: Storage
363
367
  parent: ParentConfig<NodeConfig<Options, Storage>>['inline']
368
+ editor?: Editor
364
369
  }) => NodeSpec['inline'])
365
370
 
366
371
  /**
@@ -373,6 +378,7 @@ declare module '@tiptap/core' {
373
378
  options: Options
374
379
  storage: Storage
375
380
  parent: ParentConfig<NodeConfig<Options, Storage>>['atom']
381
+ editor?: Editor
376
382
  }) => NodeSpec['atom'])
377
383
 
378
384
  /**
@@ -385,6 +391,7 @@ declare module '@tiptap/core' {
385
391
  options: Options
386
392
  storage: Storage
387
393
  parent: ParentConfig<NodeConfig<Options, Storage>>['selectable']
394
+ editor?: Editor
388
395
  }) => NodeSpec['selectable'])
389
396
 
390
397
  /**
@@ -397,6 +404,7 @@ declare module '@tiptap/core' {
397
404
  options: Options
398
405
  storage: Storage
399
406
  parent: ParentConfig<NodeConfig<Options, Storage>>['draggable']
407
+ editor?: Editor
400
408
  }) => NodeSpec['draggable'])
401
409
 
402
410
  /**
@@ -409,6 +417,7 @@ declare module '@tiptap/core' {
409
417
  options: Options
410
418
  storage: Storage
411
419
  parent: ParentConfig<NodeConfig<Options, Storage>>['code']
420
+ editor?: Editor
412
421
  }) => NodeSpec['code'])
413
422
 
414
423
  /**
@@ -421,6 +430,7 @@ declare module '@tiptap/core' {
421
430
  options: Options
422
431
  storage: Storage
423
432
  parent: ParentConfig<NodeConfig<Options, Storage>>['whitespace']
433
+ editor?: Editor
424
434
  }) => NodeSpec['whitespace'])
425
435
 
426
436
  /**
@@ -433,6 +443,7 @@ declare module '@tiptap/core' {
433
443
  options: Options
434
444
  storage: Storage
435
445
  parent: ParentConfig<NodeConfig<Options, Storage>>['defining']
446
+ editor?: Editor
436
447
  }) => NodeSpec['defining'])
437
448
 
438
449
  /**
@@ -445,6 +456,7 @@ declare module '@tiptap/core' {
445
456
  options: Options
446
457
  storage: Storage
447
458
  parent: ParentConfig<NodeConfig<Options, Storage>>['isolating']
459
+ editor?: Editor
448
460
  }) => NodeSpec['isolating'])
449
461
 
450
462
  /**
@@ -455,6 +467,7 @@ declare module '@tiptap/core' {
455
467
  options: Options
456
468
  storage: Storage
457
469
  parent: ParentConfig<NodeConfig<Options, Storage>>['parseHTML']
470
+ editor?: Editor
458
471
  }) => NodeSpec['parseDOM']
459
472
 
460
473
  /**
@@ -467,6 +480,7 @@ declare module '@tiptap/core' {
467
480
  options: Options
468
481
  storage: Storage
469
482
  parent: ParentConfig<NodeConfig<Options, Storage>>['renderHTML']
483
+ editor?: Editor
470
484
  },
471
485
  props: {
472
486
  node: ProseMirrorNode
@@ -485,6 +499,7 @@ declare module '@tiptap/core' {
485
499
  options: Options
486
500
  storage: Storage
487
501
  parent: ParentConfig<NodeConfig<Options, Storage>>['renderText']
502
+ editor?: Editor
488
503
  },
489
504
  props: {
490
505
  node: ProseMirrorNode
@@ -503,6 +518,7 @@ declare module '@tiptap/core' {
503
518
  options: Options
504
519
  storage: Storage
505
520
  parent: ParentConfig<NodeConfig<Options, Storage>>['addAttributes']
521
+ editor?: Editor
506
522
  }) => Attributes | {}
507
523
  }
508
524
  }
@@ -1,11 +1,12 @@
1
1
  import { Schema } from '@tiptap/pm/model'
2
2
 
3
+ import { Editor } from '../Editor'
3
4
  import { ExtensionManager } from '../ExtensionManager'
4
5
  import { Extensions } from '../types'
5
6
  import { getSchemaByResolvedExtensions } from './getSchemaByResolvedExtensions'
6
7
 
7
- export function getSchema(extensions: Extensions): Schema {
8
+ export function getSchema(extensions: Extensions, editor?: Editor): Schema {
8
9
  const resolvedExtensions = ExtensionManager.resolve(extensions)
9
10
 
10
- return getSchemaByResolvedExtensions(resolvedExtensions)
11
+ return getSchemaByResolvedExtensions(resolvedExtensions, editor)
11
12
  }
@@ -1,6 +1,6 @@
1
1
  import { MarkSpec, NodeSpec, Schema } from '@tiptap/pm/model'
2
2
 
3
- import { MarkConfig, NodeConfig } from '..'
3
+ import { Editor, MarkConfig, NodeConfig } from '..'
4
4
  import { AnyConfig, Extensions } from '../types'
5
5
  import { callOrReturn } from '../utilities/callOrReturn'
6
6
  import { isEmptyObject } from '../utilities/isEmptyObject'
@@ -12,8 +12,9 @@ import { splitExtensions } from './splitExtensions'
12
12
 
13
13
  function cleanUpSchemaItem<T>(data: T) {
14
14
  return Object.fromEntries(
15
+ // @ts-ignore
15
16
  Object.entries(data).filter(([key, value]) => {
16
- if (key === 'attrs' && isEmptyObject(value)) {
17
+ if (key === 'attrs' && isEmptyObject(value as {} | undefined)) {
17
18
  return false
18
19
  }
19
20
 
@@ -22,7 +23,7 @@ function cleanUpSchemaItem<T>(data: T) {
22
23
  ) as T
23
24
  }
24
25
 
25
- export function getSchemaByResolvedExtensions(extensions: Extensions): Schema {
26
+ export function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema {
26
27
  const allAttributes = getAttributesFromExtensions(extensions)
27
28
  const { nodeExtensions, markExtensions } = splitExtensions(extensions)
28
29
  const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name
@@ -36,6 +37,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions): Schema {
36
37
  name: extension.name,
37
38
  options: extension.options,
38
39
  storage: extension.storage,
40
+ editor,
39
41
  }
40
42
 
41
43
  const extraNodeFields = extensions.reduce((fields, e) => {
@@ -124,6 +126,7 @@ export function getSchemaByResolvedExtensions(extensions: Extensions): Schema {
124
126
  name: extension.name,
125
127
  options: extension.options,
126
128
  storage: extension.storage,
129
+ editor,
127
130
  }
128
131
 
129
132
  const extraMarkFields = extensions.reduce((fields, e) => {