@portabletext/editor 1.55.13 → 1.55.15

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.
Files changed (89) hide show
  1. package/lib/_chunks-cjs/{selector.is-selection-expanded.cjs → selector.get-focus-span.cjs} +27 -27
  2. package/lib/_chunks-cjs/selector.get-focus-span.cjs.map +1 -0
  3. package/lib/_chunks-cjs/selector.get-text-before.cjs +3 -3
  4. package/lib/_chunks-cjs/selector.get-text-before.cjs.map +1 -1
  5. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs +291 -168
  6. package/lib/_chunks-cjs/selector.is-selecting-entire-blocks.cjs.map +1 -1
  7. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs +1 -1
  8. package/lib/_chunks-cjs/util.child-selection-point-to-block-offset.cjs.map +1 -1
  9. package/lib/_chunks-cjs/{util.is-equal-selection-points.cjs → util.is-selection-collapsed.cjs} +7 -3
  10. package/lib/_chunks-cjs/util.is-selection-collapsed.cjs.map +1 -0
  11. package/lib/_chunks-cjs/util.slice-blocks.cjs +2 -2
  12. package/lib/_chunks-cjs/util.slice-text-block.cjs +2 -6
  13. package/lib/_chunks-cjs/util.slice-text-block.cjs.map +1 -1
  14. package/lib/_chunks-es/{selector.is-selection-expanded.js → selector.get-focus-span.js} +27 -27
  15. package/lib/_chunks-es/selector.get-focus-span.js.map +1 -0
  16. package/lib/_chunks-es/selector.get-text-before.js +1 -1
  17. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js +266 -143
  18. package/lib/_chunks-es/selector.is-selecting-entire-blocks.js.map +1 -1
  19. package/lib/_chunks-es/util.child-selection-point-to-block-offset.js +1 -1
  20. package/lib/_chunks-es/{util.is-equal-selection-points.js → util.is-selection-collapsed.js} +7 -3
  21. package/lib/_chunks-es/util.is-selection-collapsed.js.map +1 -0
  22. package/lib/_chunks-es/util.slice-blocks.js +2 -2
  23. package/lib/_chunks-es/util.slice-text-block.js +1 -5
  24. package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
  25. package/lib/behaviors/index.d.cts +3 -6
  26. package/lib/behaviors/index.d.ts +3 -6
  27. package/lib/index.cjs +357 -322
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +11 -20
  30. package/lib/index.d.ts +11 -20
  31. package/lib/index.js +296 -261
  32. package/lib/index.js.map +1 -1
  33. package/lib/plugins/index.cjs +16 -16
  34. package/lib/plugins/index.cjs.map +1 -1
  35. package/lib/plugins/index.d.cts +3 -6
  36. package/lib/plugins/index.d.ts +3 -6
  37. package/lib/plugins/index.js +1 -1
  38. package/lib/selectors/index.cjs +14 -14
  39. package/lib/selectors/index.cjs.map +1 -1
  40. package/lib/selectors/index.d.cts +3 -6
  41. package/lib/selectors/index.d.ts +3 -6
  42. package/lib/selectors/index.js +2 -2
  43. package/lib/utils/index.cjs +9 -9
  44. package/lib/utils/index.cjs.map +1 -1
  45. package/lib/utils/index.d.cts +3 -6
  46. package/lib/utils/index.d.ts +3 -6
  47. package/lib/utils/index.js +5 -5
  48. package/package.json +3 -3
  49. package/src/behaviors/behavior.abstract.ts +2 -1
  50. package/src/behaviors/behavior.core.dnd.ts +4 -4
  51. package/src/editor/Editable.tsx +8 -1
  52. package/src/editor/create-slate-editor.tsx +0 -1
  53. package/src/editor/editor-dom.ts +3 -3
  54. package/src/editor/editor-selector.ts +1 -13
  55. package/src/editor/editor-snapshot.ts +4 -19
  56. package/src/editor/plugins/createWithEditableAPI.ts +52 -13
  57. package/src/editor/plugins/createWithPortableTextMarkModel.ts +13 -4
  58. package/src/editor/plugins/with-plugins.ts +4 -8
  59. package/src/editor/range-decorations-machine.ts +24 -12
  60. package/src/internal-utils/create-test-snapshot.ts +2 -5
  61. package/src/internal-utils/paths.ts +65 -17
  62. package/src/internal-utils/ranges.test.ts +179 -0
  63. package/src/internal-utils/ranges.ts +39 -22
  64. package/src/internal-utils/test-editor.tsx +16 -1
  65. package/src/operations/behavior.operation.block.set.ts +10 -6
  66. package/src/operations/behavior.operation.block.unset.ts +10 -6
  67. package/src/operations/behavior.operation.child.set.ts +10 -6
  68. package/src/operations/behavior.operation.child.unset.ts +10 -6
  69. package/src/operations/behavior.operation.decorator.add.ts +17 -6
  70. package/src/operations/behavior.operation.delete.ts +8 -1
  71. package/src/operations/behavior.operation.insert.text.ts +34 -20
  72. package/src/operations/behavior.operation.move.block.ts +25 -3
  73. package/src/operations/behavior.operation.select.ts +9 -2
  74. package/src/selectors/selector.get-active-annotation-marks.ts +12 -0
  75. package/src/selectors/selector.get-active-annotations.ts +8 -20
  76. package/src/{editor/get-active-decorators.ts → selectors/selector.get-active-decorators.ts} +6 -11
  77. package/src/{internal-utils/mark-state.ts → selectors/selector.get-mark-state.ts} +41 -67
  78. package/src/selectors/selector.get-next-span.ts +56 -0
  79. package/src/selectors/selector.get-previous-span.ts +53 -0
  80. package/src/selectors/selector.is-active-annotation.ts +3 -1
  81. package/src/selectors/selector.is-active-decorator.ts +4 -1
  82. package/src/types/editor.ts +0 -2
  83. package/src/utils/util.is-selection-expanded.ts +13 -0
  84. package/lib/_chunks-cjs/selector.is-selection-expanded.cjs.map +0 -1
  85. package/lib/_chunks-cjs/util.is-equal-selection-points.cjs.map +0 -1
  86. package/lib/_chunks-es/selector.is-selection-expanded.js.map +0 -1
  87. package/lib/_chunks-es/util.is-equal-selection-points.js.map +0 -1
  88. package/src/editor/get-active-annotations.ts +0 -15
  89. package/src/editor/plugins/slate-plugin.update-mark-state.ts +0 -21
package/lib/index.d.cts CHANGED
@@ -1215,10 +1215,10 @@ declare const editorMachine: StateMachine<
1215
1215
  'edit mode':
1216
1216
  | {
1217
1217
  editable:
1218
- | 'dragging internally'
1219
1218
  | 'idle'
1219
+ | 'dragging internally'
1220
1220
  | {
1221
- focusing: 'checking if busy' | 'busy'
1221
+ focusing: 'busy' | 'checking if busy'
1222
1222
  }
1223
1223
  }
1224
1224
  | {
@@ -1228,11 +1228,11 @@ declare const editorMachine: StateMachine<
1228
1228
  | 'setting up'
1229
1229
  | {
1230
1230
  'set up': {
1231
- 'value sync': 'syncing value' | 'idle'
1231
+ 'value sync': 'idle' | 'syncing value'
1232
1232
  'writing':
1233
1233
  | 'dirty'
1234
1234
  | {
1235
- pristine: 'normalizing' | 'idle'
1235
+ pristine: 'idle' | 'normalizing'
1236
1236
  }
1237
1237
  }
1238
1238
  }
@@ -1557,6 +1557,7 @@ declare const editorMachine: StateMachine<
1557
1557
  | 'keyboard.keyup'
1558
1558
  | 'mouse.click'
1559
1559
  | '*'
1560
+ | `custom.${string}`
1560
1561
  | 'deserialize.*'
1561
1562
  | 'serialize.*'
1562
1563
  | 'split.*'
@@ -1564,20 +1565,19 @@ declare const editorMachine: StateMachine<
1564
1565
  | 'select.*'
1565
1566
  | 'style.*'
1566
1567
  | 'block.*'
1568
+ | 'history.*'
1569
+ | 'insert.*'
1567
1570
  | 'annotation.*'
1568
1571
  | 'decorator.*'
1569
1572
  | 'child.*'
1570
1573
  | 'deserialization.*'
1571
- | 'insert.*'
1572
1574
  | 'list item.*'
1573
1575
  | 'move.*'
1574
1576
  | 'serialization.*'
1575
- | 'history.*'
1576
1577
  | 'clipboard.*'
1577
1578
  | 'drag.*'
1578
1579
  | 'keyboard.*'
1579
- | 'mouse.*'
1580
- | `custom.${string}`,
1580
+ | 'mouse.*',
1581
1581
  true,
1582
1582
  | {
1583
1583
  type: StrictExtract_2<
@@ -6156,15 +6156,12 @@ export declare type EditorSelector<TSelected> = (
6156
6156
  */
6157
6157
  export declare type EditorSnapshot = {
6158
6158
  context: EditorContext
6159
+ blockIndexMap: Map<string, number>
6159
6160
  /**
6160
6161
  * @beta
6161
- * Do not rely on this externally
6162
+ * Subject to change
6162
6163
  */
6163
- beta: {
6164
- activeAnnotations: Array<string>
6165
- activeDecorators: Array<string>
6166
- }
6167
- blockIndexMap: Map<string, number>
6164
+ decoratorState: Record<string, boolean | undefined>
6168
6165
  }
6169
6166
 
6170
6167
  /**
@@ -6417,11 +6414,6 @@ export declare type LoadingChange = {
6417
6414
  isLoading: boolean
6418
6415
  }
6419
6416
 
6420
- declare type MarkState = {
6421
- state: 'changed' | 'unchanged'
6422
- marks: Array<string>
6423
- }
6424
-
6425
6417
  declare type MIMEType = `${string}/${string}`
6426
6418
 
6427
6419
  declare type MouseBehaviorEvent = {
@@ -7178,7 +7170,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7178
7170
  value: Array<PortableTextBlock>
7179
7171
  decoratedRanges: Array<DecoratedRange>
7180
7172
  decoratorState: Record<string, boolean | undefined>
7181
- markState: MarkState | undefined
7182
7173
  blockIndexMap: Map<string, number>
7183
7174
  listIndexMap: Map<string, number>
7184
7175
  /**
package/lib/index.d.ts CHANGED
@@ -1215,10 +1215,10 @@ declare const editorMachine: StateMachine<
1215
1215
  'edit mode':
1216
1216
  | {
1217
1217
  editable:
1218
- | 'dragging internally'
1219
1218
  | 'idle'
1219
+ | 'dragging internally'
1220
1220
  | {
1221
- focusing: 'checking if busy' | 'busy'
1221
+ focusing: 'busy' | 'checking if busy'
1222
1222
  }
1223
1223
  }
1224
1224
  | {
@@ -1228,11 +1228,11 @@ declare const editorMachine: StateMachine<
1228
1228
  | 'setting up'
1229
1229
  | {
1230
1230
  'set up': {
1231
- 'value sync': 'syncing value' | 'idle'
1231
+ 'value sync': 'idle' | 'syncing value'
1232
1232
  'writing':
1233
1233
  | 'dirty'
1234
1234
  | {
1235
- pristine: 'normalizing' | 'idle'
1235
+ pristine: 'idle' | 'normalizing'
1236
1236
  }
1237
1237
  }
1238
1238
  }
@@ -1557,6 +1557,7 @@ declare const editorMachine: StateMachine<
1557
1557
  | 'keyboard.keyup'
1558
1558
  | 'mouse.click'
1559
1559
  | '*'
1560
+ | `custom.${string}`
1560
1561
  | 'deserialize.*'
1561
1562
  | 'serialize.*'
1562
1563
  | 'split.*'
@@ -1564,20 +1565,19 @@ declare const editorMachine: StateMachine<
1564
1565
  | 'select.*'
1565
1566
  | 'style.*'
1566
1567
  | 'block.*'
1568
+ | 'history.*'
1569
+ | 'insert.*'
1567
1570
  | 'annotation.*'
1568
1571
  | 'decorator.*'
1569
1572
  | 'child.*'
1570
1573
  | 'deserialization.*'
1571
- | 'insert.*'
1572
1574
  | 'list item.*'
1573
1575
  | 'move.*'
1574
1576
  | 'serialization.*'
1575
- | 'history.*'
1576
1577
  | 'clipboard.*'
1577
1578
  | 'drag.*'
1578
1579
  | 'keyboard.*'
1579
- | 'mouse.*'
1580
- | `custom.${string}`,
1580
+ | 'mouse.*',
1581
1581
  true,
1582
1582
  | {
1583
1583
  type: StrictExtract_2<
@@ -6156,15 +6156,12 @@ export declare type EditorSelector<TSelected> = (
6156
6156
  */
6157
6157
  export declare type EditorSnapshot = {
6158
6158
  context: EditorContext
6159
+ blockIndexMap: Map<string, number>
6159
6160
  /**
6160
6161
  * @beta
6161
- * Do not rely on this externally
6162
+ * Subject to change
6162
6163
  */
6163
- beta: {
6164
- activeAnnotations: Array<string>
6165
- activeDecorators: Array<string>
6166
- }
6167
- blockIndexMap: Map<string, number>
6164
+ decoratorState: Record<string, boolean | undefined>
6168
6165
  }
6169
6166
 
6170
6167
  /**
@@ -6417,11 +6414,6 @@ export declare type LoadingChange = {
6417
6414
  isLoading: boolean
6418
6415
  }
6419
6416
 
6420
- declare type MarkState = {
6421
- state: 'changed' | 'unchanged'
6422
- marks: Array<string>
6423
- }
6424
-
6425
6417
  declare type MIMEType = `${string}/${string}`
6426
6418
 
6427
6419
  declare type MouseBehaviorEvent = {
@@ -7178,7 +7170,6 @@ declare interface PortableTextSlateEditor extends ReactEditor {
7178
7170
  value: Array<PortableTextBlock>
7179
7171
  decoratedRanges: Array<DecoratedRange>
7180
7172
  decoratorState: Record<string, boolean | undefined>
7181
- markState: MarkState | undefined
7182
7173
  blockIndexMap: Map<string, number>
7183
7174
  listIndexMap: Map<string, number>
7184
7175
  /**