@portabletext/editor 1.50.2 → 1.50.4

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 (33) hide show
  1. package/lib/behaviors/index.d.cts +1 -0
  2. package/lib/behaviors/index.d.ts +1 -0
  3. package/lib/index.cjs +577 -286
  4. package/lib/index.cjs.map +1 -1
  5. package/lib/index.d.cts +15 -2
  6. package/lib/index.d.ts +15 -2
  7. package/lib/index.js +584 -292
  8. package/lib/index.js.map +1 -1
  9. package/lib/plugins/index.d.cts +7 -0
  10. package/lib/plugins/index.d.ts +7 -0
  11. package/lib/selectors/index.d.cts +1 -0
  12. package/lib/selectors/index.d.ts +1 -0
  13. package/lib/utils/index.d.cts +1 -0
  14. package/lib/utils/index.d.ts +1 -0
  15. package/package.json +14 -13
  16. package/src/editor/PortableTextEditor.tsx +22 -22
  17. package/src/editor/create-slate-editor.tsx +9 -1
  18. package/src/editor/editor-selector.ts +1 -5
  19. package/src/editor/editor-snapshot.ts +1 -3
  20. package/src/editor/plugins/createWithPatches.ts +37 -75
  21. package/src/editor/plugins/slate-plugin.update-value.ts +30 -0
  22. package/src/editor/plugins/with-plugins.ts +8 -4
  23. package/src/editor/relay-machine.ts +9 -0
  24. package/src/internal-utils/apply-operation-to-portable-text.test.ts +175 -0
  25. package/src/internal-utils/apply-operation-to-portable-text.ts +435 -0
  26. package/src/internal-utils/create-placeholder-block.ts +20 -0
  27. package/src/internal-utils/{__tests__/operationToPatches.test.ts → operation-to-patches.test.ts} +44 -39
  28. package/src/internal-utils/operation-to-patches.ts +467 -0
  29. package/src/internal-utils/portable-text-node.ts +209 -0
  30. package/src/types/editor.ts +8 -2
  31. package/src/internal-utils/__tests__/patchToOperations.test.ts +0 -312
  32. package/src/internal-utils/operationToPatches.ts +0 -489
  33. package/src/internal-utils/slate-children-to-blocks.ts +0 -49
package/lib/index.d.cts CHANGED
@@ -824,6 +824,9 @@ export declare type EditorEmittedEvent =
824
824
  event: FocusEvent_2<HTMLDivElement, Element>
825
825
  }
826
826
  | {
827
+ /**
828
+ * @deprecated
829
+ */
827
830
  type: 'done loading'
828
831
  }
829
832
  | {
@@ -840,6 +843,9 @@ export declare type EditorEmittedEvent =
840
843
  value: Array<PortableTextBlock> | undefined
841
844
  }
842
845
  | {
846
+ /**
847
+ * @deprecated
848
+ */
843
849
  type: 'loading'
844
850
  }
845
851
  | MutationEvent
@@ -2977,7 +2983,9 @@ export declare const keyGenerator: () => string
2977
2983
  /**
2978
2984
  * The editor is currently loading something
2979
2985
  * Could be used to show a spinner etc.
2980
- * @beta */
2986
+ * @beta
2987
+ * @deprecated
2988
+ */
2981
2989
  export declare type LoadingChange = {
2982
2990
  type: 'loading'
2983
2991
  isLoading: boolean
@@ -3225,6 +3233,7 @@ export declare class PortableTextEditor extends Component<
3225
3233
  private editor
3226
3234
  private editable
3227
3235
  private actors?
3236
+ private subscriptions
3228
3237
  private unsubscribers
3229
3238
  constructor(props: PortableTextEditorProps)
3230
3239
  componentDidMount(): void
@@ -3733,6 +3742,7 @@ declare interface PortableTextSlateEditor extends ReactEditor {
3733
3742
  isTextBlock: (value: unknown) => value is PortableTextTextBlock
3734
3743
  isTextSpan: (value: unknown) => value is PortableTextSpan
3735
3744
  isListBlock: (value: unknown) => value is PortableTextListBlock
3745
+ value: Array<PortableTextBlock>
3736
3746
  /**
3737
3747
  * Use hotkeys
3738
3748
  */
@@ -4100,7 +4110,10 @@ export declare type UndoChange = {
4100
4110
  timestamp: Date
4101
4111
  }
4102
4112
 
4103
- /** @beta */
4113
+ /**
4114
+ * @beta
4115
+ * @deprecated Use `'patch'` changes instead
4116
+ */
4104
4117
  export declare type UnsetChange = {
4105
4118
  type: 'unset'
4106
4119
  previousValue: PortableTextBlock[]
package/lib/index.d.ts CHANGED
@@ -824,6 +824,9 @@ export declare type EditorEmittedEvent =
824
824
  event: FocusEvent_2<HTMLDivElement, Element>
825
825
  }
826
826
  | {
827
+ /**
828
+ * @deprecated
829
+ */
827
830
  type: 'done loading'
828
831
  }
829
832
  | {
@@ -840,6 +843,9 @@ export declare type EditorEmittedEvent =
840
843
  value: Array<PortableTextBlock> | undefined
841
844
  }
842
845
  | {
846
+ /**
847
+ * @deprecated
848
+ */
843
849
  type: 'loading'
844
850
  }
845
851
  | MutationEvent
@@ -2977,7 +2983,9 @@ export declare const keyGenerator: () => string
2977
2983
  /**
2978
2984
  * The editor is currently loading something
2979
2985
  * Could be used to show a spinner etc.
2980
- * @beta */
2986
+ * @beta
2987
+ * @deprecated
2988
+ */
2981
2989
  export declare type LoadingChange = {
2982
2990
  type: 'loading'
2983
2991
  isLoading: boolean
@@ -3225,6 +3233,7 @@ export declare class PortableTextEditor extends Component<
3225
3233
  private editor
3226
3234
  private editable
3227
3235
  private actors?
3236
+ private subscriptions
3228
3237
  private unsubscribers
3229
3238
  constructor(props: PortableTextEditorProps)
3230
3239
  componentDidMount(): void
@@ -3733,6 +3742,7 @@ declare interface PortableTextSlateEditor extends ReactEditor {
3733
3742
  isTextBlock: (value: unknown) => value is PortableTextTextBlock
3734
3743
  isTextSpan: (value: unknown) => value is PortableTextSpan
3735
3744
  isListBlock: (value: unknown) => value is PortableTextListBlock
3745
+ value: Array<PortableTextBlock>
3736
3746
  /**
3737
3747
  * Use hotkeys
3738
3748
  */
@@ -4100,7 +4110,10 @@ export declare type UndoChange = {
4100
4110
  timestamp: Date
4101
4111
  }
4102
4112
 
4103
- /** @beta */
4113
+ /**
4114
+ * @beta
4115
+ * @deprecated Use `'patch'` changes instead
4116
+ */
4104
4117
  export declare type UnsetChange = {
4105
4118
  type: 'unset'
4106
4119
  previousValue: PortableTextBlock[]