@portabletext/editor 2.21.3 → 3.0.1
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.
- package/lib/_chunks-dts/index.d.ts +49 -209
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js +103 -20
- package/lib/_chunks-es/selector.is-at-the-start-of-block.js.map +1 -1
- package/lib/_chunks-es/{util.get-text-block-text.js → util.slice-blocks.js} +73 -24
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -0
- package/lib/_chunks-es/util.slice-text-block.js +13 -2
- package/lib/_chunks-es/util.slice-text-block.js.map +1 -1
- package/lib/behaviors/index.d.ts +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +339 -341
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.ts +2 -133
- package/lib/plugins/index.js +2 -796
- package/lib/plugins/index.js.map +1 -1
- package/lib/selectors/index.d.ts +2 -24
- package/lib/selectors/index.js +28 -130
- package/lib/selectors/index.js.map +1 -1
- package/lib/utils/index.d.ts +6 -4
- package/lib/utils/index.js +98 -9
- package/lib/utils/index.js.map +1 -1
- package/package.json +1 -3
- package/src/behaviors/behavior.abstract.split.ts +1 -0
- package/src/behaviors/behavior.perform-event.ts +7 -7
- package/src/converters/converter.portable-text.ts +1 -0
- package/src/converters/converter.text-html.ts +1 -0
- package/src/converters/converter.text-plain.ts +1 -0
- package/src/editor/Editable.tsx +1 -0
- package/src/editor/PortableTextEditor.tsx +0 -19
- package/src/editor/create-editor.ts +0 -3
- package/src/editor/editor-machine.ts +0 -10
- package/src/editor/event-to-change.tsx +5 -1
- package/src/editor/plugins/create-with-event-listeners.ts +30 -6
- package/src/editor/plugins/createWithObjectKeys.ts +2 -1
- package/src/editor/plugins/createWithPatches.ts +3 -3
- package/src/editor/plugins/createWithPlaceholderBlock.ts +2 -1
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +2 -1
- package/src/editor/plugins/with-plugins.ts +10 -14
- package/src/editor/relay-machine.ts +0 -4
- package/src/editor/sync-machine.ts +2 -2
- package/src/editor.ts +0 -4
- package/src/history/behavior.operation.history.redo.ts +67 -0
- package/src/history/behavior.operation.history.undo.ts +71 -0
- package/src/history/event.history.undo.test.tsx +672 -0
- package/src/history/history.preserving-keys.test.tsx +112 -0
- package/src/history/remote-patches.ts +20 -0
- package/src/history/slate-plugin.history.ts +146 -0
- package/src/history/slate-plugin.redoing.ts +21 -0
- package/src/history/slate-plugin.undoing.ts +21 -0
- package/src/history/slate-plugin.without-history.ts +23 -0
- package/src/history/transform-operation.ts +245 -0
- package/src/history/undo-redo-collaboration.test.tsx +541 -0
- package/src/history/undo-redo.feature +125 -0
- package/src/history/undo-redo.test.tsx +195 -0
- package/src/history/undo-step.ts +148 -0
- package/src/index.ts +0 -1
- package/src/internal-utils/operation-to-patches.test.ts +23 -25
- package/src/internal-utils/operation-to-patches.ts +31 -22
- package/src/internal-utils/selection-text.test.ts +3 -0
- package/src/internal-utils/selection-text.ts +5 -2
- package/src/internal-utils/values.ts +23 -11
- package/src/operations/behavior.operation.block.set.ts +1 -0
- package/src/operations/behavior.operation.block.unset.ts +2 -0
- package/src/operations/behavior.operation.insert.block.ts +1 -0
- package/src/operations/behavior.operations.ts +2 -4
- package/src/plugins/index.ts +0 -3
- package/src/selectors/index.ts +0 -3
- package/src/test/vitest/step-definitions.tsx +57 -0
- package/src/test/vitest/test-editor.tsx +1 -1
- package/src/utils/parse-blocks.test.ts +296 -16
- package/src/utils/parse-blocks.ts +81 -22
- package/src/utils/util.merge-text-blocks.ts +5 -1
- package/src/utils/util.slice-blocks.ts +24 -10
- package/lib/_chunks-es/selector.get-selection-text.js +0 -92
- package/lib/_chunks-es/selector.get-selection-text.js.map +0 -1
- package/lib/_chunks-es/selector.get-text-before.js +0 -36
- package/lib/_chunks-es/selector.get-text-before.js.map +0 -1
- package/lib/_chunks-es/util.get-text-block-text.js.map +0 -1
- package/lib/_chunks-es/util.is-empty-text-block.js +0 -40
- package/lib/_chunks-es/util.is-empty-text-block.js.map +0 -1
- package/lib/_chunks-es/util.merge-text-blocks.js +0 -101
- package/lib/_chunks-es/util.merge-text-blocks.js.map +0 -1
- package/src/editor/plugins/createWithMaxBlocks.ts +0 -53
- package/src/editor/plugins/createWithUndoRedo.ts +0 -628
- package/src/editor/with-undo-step.ts +0 -37
- package/src/editor/withUndoRedo.ts +0 -34
- package/src/editor-event-listener.tsx +0 -28
- package/src/plugins/plugin.decorator-shortcut.ts +0 -238
- package/src/plugins/plugin.markdown.test.tsx +0 -42
- package/src/plugins/plugin.markdown.tsx +0 -131
- package/src/plugins/plugin.one-line.tsx +0 -123
- package/src/selectors/selector.get-list-state.test.ts +0 -189
- package/src/selectors/selector.get-list-state.ts +0 -96
- package/src/selectors/selector.get-selected-slice.ts +0 -13
- package/src/selectors/selector.get-trimmed-selection.test.ts +0 -657
- package/src/selectors/selector.get-trimmed-selection.ts +0 -189
package/lib/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
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 };
|