@portabletext/editor 2.21.2 → 3.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.
Files changed (79) hide show
  1. package/lib/_chunks-dts/index.d.ts +50 -210
  2. package/lib/_chunks-es/selector.is-at-the-start-of-block.js +103 -20
  3. package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
  4. package/lib/_chunks-es/{util.get-text-block-text.js → util.slice-blocks.js} +29 -5
  5. package/lib/_chunks-es/util.slice-blocks.js.map +1 -0
  6. package/lib/_chunks-es/util.slice-text-block.js +13 -2
  7. package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
  8. package/lib/behaviors/index.d.ts +1 -1
  9. package/lib/index.d.ts +2 -2
  10. package/lib/index.js +323 -320
  11. package/lib/index.js.map +1 -1
  12. package/lib/plugins/index.d.ts +2 -133
  13. package/lib/plugins/index.js +2 -796
  14. package/lib/plugins/index.js.map +1 -1
  15. package/lib/selectors/index.d.ts +2 -24
  16. package/lib/selectors/index.js +28 -130
  17. package/lib/selectors/index.js.map +1 -1
  18. package/lib/utils/index.d.ts +3 -3
  19. package/lib/utils/index.js +97 -9
  20. package/lib/utils/index.js.map +1 -1
  21. package/package.json +7 -9
  22. package/src/behaviors/behavior.perform-event.ts +7 -7
  23. package/src/editor/PortableTextEditor.tsx +0 -19
  24. package/src/editor/create-editor.ts +0 -3
  25. package/src/editor/editor-machine.ts +0 -10
  26. package/src/editor/event-to-change.tsx +5 -1
  27. package/src/editor/plugins/create-with-event-listeners.ts +0 -4
  28. package/src/editor/plugins/createWithObjectKeys.ts +2 -1
  29. package/src/editor/plugins/createWithPatches.ts +3 -3
  30. package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -1
  31. package/src/editor/plugins/createWithPortableTextMarkModel.ts +2 -1
  32. package/src/editor/plugins/with-plugins.ts +10 -14
  33. package/src/editor/relay-machine.ts +0 -4
  34. package/src/editor/sync-machine.ts +2 -2
  35. package/src/editor.ts +0 -4
  36. package/src/history/behavior.operation.history.redo.ts +67 -0
  37. package/src/history/behavior.operation.history.undo.ts +71 -0
  38. package/src/history/event.history.undo.test.tsx +672 -0
  39. package/src/history/history.preserving-keys.test.tsx +112 -0
  40. package/src/history/remote-patches.ts +20 -0
  41. package/src/history/slate-plugin.history.ts +146 -0
  42. package/src/history/slate-plugin.redoing.ts +21 -0
  43. package/src/history/slate-plugin.undoing.ts +21 -0
  44. package/src/history/slate-plugin.without-history.ts +23 -0
  45. package/src/history/transform-operation.ts +245 -0
  46. package/src/history/undo-redo-collaboration.test.tsx +541 -0
  47. package/src/history/undo-redo.feature +125 -0
  48. package/src/history/undo-redo.test.tsx +195 -0
  49. package/src/history/undo-step.ts +148 -0
  50. package/src/index.ts +0 -1
  51. package/src/internal-utils/applyPatch.ts +46 -1
  52. package/src/operations/behavior.operations.ts +2 -4
  53. package/src/plugins/index.ts +0 -3
  54. package/src/selectors/index.ts +0 -3
  55. package/src/test/vitest/step-definitions.tsx +88 -8
  56. package/src/test/vitest/test-editor.tsx +1 -1
  57. package/lib/_chunks-es/selector.get-selection-text.js +0 -92
  58. package/lib/_chunks-es/selector.get-selection-text.js.map +0 -1
  59. package/lib/_chunks-es/selector.get-text-before.js +0 -36
  60. package/lib/_chunks-es/selector.get-text-before.js.map +0 -1
  61. package/lib/_chunks-es/util.get-text-block-text.js.map +0 -1
  62. package/lib/_chunks-es/util.is-empty-text-block.js +0 -40
  63. package/lib/_chunks-es/util.is-empty-text-block.js.map +0 -1
  64. package/lib/_chunks-es/util.merge-text-blocks.js +0 -101
  65. package/lib/_chunks-es/util.merge-text-blocks.js.map +0 -1
  66. package/src/editor/plugins/createWithMaxBlocks.ts +0 -53
  67. package/src/editor/plugins/createWithUndoRedo.ts +0 -628
  68. package/src/editor/with-undo-step.ts +0 -37
  69. package/src/editor/withUndoRedo.ts +0 -34
  70. package/src/editor-event-listener.tsx +0 -28
  71. package/src/plugins/plugin.decorator-shortcut.ts +0 -238
  72. package/src/plugins/plugin.markdown.test.tsx +0 -42
  73. package/src/plugins/plugin.markdown.tsx +0 -131
  74. package/src/plugins/plugin.one-line.tsx +0 -123
  75. package/src/selectors/selector.get-list-state.test.ts +0 -189
  76. package/src/selectors/selector.get-list-state.ts +0 -96
  77. package/src/selectors/selector.get-selected-slice.ts +0 -13
  78. package/src/selectors/selector.get-trimmed-selection.test.ts +0 -657
  79. package/src/selectors/selector.get-trimmed-selection.ts +0 -189
@@ -1,5 +1,4 @@
1
- import { G as Editor, J as Behavior, en as EditorSchema, tn as EditorEmittedEvent } from "../_chunks-dts/index.js";
2
- import * as react22 from "react";
1
+ import { W as Editor, en as EditorEmittedEvent, q as Behavior } from "../_chunks-dts/index.js";
3
2
  import React from "react";
4
3
  /**
5
4
  * @beta
@@ -7,21 +6,6 @@ import React from "react";
7
6
  declare function BehaviorPlugin(props: {
8
7
  behaviors: Array<Behavior>;
9
8
  }): null;
10
- /**
11
- * @beta
12
- * @deprecated Install the plugin from `@portabletext/plugin-character-pair-decorator`
13
- */
14
- declare function DecoratorShortcutPlugin(config: {
15
- decorator: ({
16
- schema
17
- }: {
18
- schema: EditorSchema;
19
- }) => string | undefined;
20
- pair: {
21
- char: string;
22
- amount: number;
23
- };
24
- }): null;
25
9
  /**
26
10
  * @beta
27
11
  */
@@ -78,119 +62,4 @@ declare const EditorRefPlugin: React.ForwardRefExoticComponent<React.RefAttribut
78
62
  declare function EventListenerPlugin(props: {
79
63
  on: (event: EditorEmittedEvent) => void;
80
64
  }): null;
81
- type MarkdownBehaviorsConfig = {
82
- horizontalRuleObject?: (context: {
83
- schema: EditorSchema;
84
- }) => {
85
- name: string;
86
- value?: {
87
- [prop: string]: unknown;
88
- };
89
- } | undefined;
90
- defaultStyle?: (context: {
91
- schema: EditorSchema;
92
- }) => string | undefined;
93
- headingStyle?: (context: {
94
- schema: EditorSchema;
95
- level: number;
96
- }) => string | undefined;
97
- blockquoteStyle?: (context: {
98
- schema: EditorSchema;
99
- }) => string | undefined;
100
- unorderedListStyle?: (context: {
101
- schema: EditorSchema;
102
- }) => string | undefined;
103
- orderedListStyle?: (context: {
104
- schema: EditorSchema;
105
- }) => string | undefined;
106
- };
107
- /**
108
- * @beta
109
- */
110
- type MarkdownPluginConfig = MarkdownBehaviorsConfig & {
111
- boldDecorator?: ({
112
- schema
113
- }: {
114
- schema: EditorSchema;
115
- }) => string | undefined;
116
- codeDecorator?: ({
117
- schema
118
- }: {
119
- schema: EditorSchema;
120
- }) => string | undefined;
121
- italicDecorator?: ({
122
- schema
123
- }: {
124
- schema: EditorSchema;
125
- }) => string | undefined;
126
- strikeThroughDecorator?: ({
127
- schema
128
- }: {
129
- schema: EditorSchema;
130
- }) => string | undefined;
131
- };
132
- /**
133
- * @beta
134
- * Add markdown behaviors for common markdown actions such as converting ### to headings, --- to HRs, and more.
135
- *
136
- * @example
137
- * Configure the bundled markdown behaviors
138
- * ```ts
139
- * import {EditorProvider} from '@portabletext/editor'
140
- * import {MarkdownPlugin} from '@portabletext/editor/plugins'
141
- *
142
- * function App() {
143
- * return (
144
- * <EditorProvider>
145
- * <MarkdownPlugin
146
- * config={{
147
- * boldDecorator: ({schema}) =>
148
- * schema.decorators.find((decorator) => decorator.value === 'strong')?.value,
149
- * codeDecorator: ({schema}) =>
150
- * schema.decorators.find((decorator) => decorator.value === 'code')?.value,
151
- * italicDecorator: ({schema}) =>
152
- * schema.decorators.find((decorator) => decorator.value === 'em')?.value,
153
- * strikeThroughDecorator: ({schema}) =>
154
- * schema.decorators.find((decorator) => decorator.value === 'strike-through')?.value,
155
- * horizontalRuleObject: ({schema}) => {
156
- * const name = schema.blockObjects.find(
157
- * (object) => object.name === 'break',
158
- * )?.name
159
- * return name ? {name} : undefined
160
- * },
161
- * defaultStyle: ({schema}) => schema.styles[0].value,
162
- * headingStyle: ({schema, level}) =>
163
- * schema.styles.find((style) => style.value === `h${level}`)
164
- * ?.value,
165
- * blockquoteStyle: ({schema}) =>
166
- * schema.styles.find((style) => style.value === 'blockquote')
167
- * ?.value,
168
- * unorderedListStyle: ({schema}) =>
169
- * schema.lists.find((list) => list.value === 'bullet')?.value,
170
- * orderedListStyle: ({schema}) =>
171
- * schema.lists.find((list) => list.value === 'number')?.value,
172
- * }}
173
- * />
174
- * {...}
175
- * </EditorProvider>
176
- * )
177
- * }
178
- * ```
179
- *
180
- * @deprecated Install the plugin from `@portabletext/plugin-markdown-shortcuts`
181
- */
182
- declare function MarkdownPlugin(props: {
183
- config: MarkdownPluginConfig;
184
- }): react22.JSX.Element;
185
- /**
186
- * @beta
187
- * Restrict the editor to one line. The plugin takes care of blocking
188
- * `insert.break` events and smart handling of other `insert.*` events.
189
- *
190
- * Place it with as high priority as possible to make sure other plugins don't
191
- * overwrite `insert.*` events before this plugin gets a chance to do so.
192
- *
193
- * @deprecated Install the plugin from `@portabletext/plugin-one-line`
194
- */
195
- declare function OneLinePlugin(): react22.JSX.Element;
196
- export { BehaviorPlugin, DecoratorShortcutPlugin, EditorRefPlugin, EventListenerPlugin, MarkdownPlugin, type MarkdownPluginConfig, OneLinePlugin };
65
+ export { BehaviorPlugin, EditorRefPlugin, EventListenerPlugin };