@portabletext/editor 2.3.3 → 2.3.5
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/behavior.types.action.d.cts +14 -151
- package/lib/_chunks-dts/behavior.types.action.d.ts +14 -151
- package/lib/index.cjs +43 -279
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +5 -245
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.d.cts +3 -3
- package/lib/plugins/index.d.ts +3 -3
- package/lib/utils/index.d.cts +2 -2
- package/lib/utils/index.d.ts +2 -2
- package/package.json +6 -4
- package/src/converters/converter.portable-text.deserialize.test.ts +6 -4
- package/src/converters/converter.text-html.deserialize.test.ts +15 -15
- package/src/converters/converter.text-html.serialize.test.ts +8 -8
- package/src/converters/converter.text-plain.test.ts +8 -8
- package/src/editor/create-editor.ts +12 -10
- package/src/editor/editor-schema.ts +2 -312
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -2
- package/src/editor.ts +1 -1
- package/src/index.ts +3 -3
- package/src/internal-utils/__tests__/values.test.ts +2 -3
- package/src/internal-utils/apply-operation-to-portable-text.test.ts +2 -3
- package/src/internal-utils/build-index-maps.test.ts +2 -3
- package/src/internal-utils/create-test-snapshot.ts +2 -4
- package/src/internal-utils/drag-selection.test.ts +2 -5
- package/src/internal-utils/operation-to-patches.test.ts +5 -7
- package/src/internal-utils/parse-blocks.test.ts +21 -30
- package/src/internal-utils/selection-text.ts +2 -3
- package/src/internal-utils/terse-pt.test.ts +2 -3
- package/src/internal-utils/test-editor.tsx +1 -4
- package/src/internal-utils/to-slate-range.test.ts +2 -3
- package/src/plugins/plugin.internal.auto-close-brackets.test.tsx +1 -1
- package/src/plugins/plugin.markdown.test.tsx +1 -1
- package/src/selectors/selector.get-selection-text.test.ts +2 -3
- package/src/selectors/selector.get-trimmed-selection.test.ts +2 -3
- package/src/utils/util.block-offset.test.ts +2 -3
- package/src/utils/util.slice-blocks.test.ts +2 -3
- package/src/utils/util.slice-text-block.test.ts +2 -3
- package/src/editor/editor-schema-definition.ts +0 -105
- package/src/editor/legacy-schema.ts +0 -115
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Patch, Patch as Patch$1 } from "@portabletext/patches";
|
|
2
2
|
import * as _sanity_types5 from "@sanity/types";
|
|
3
3
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, TypedObject } from "@sanity/types";
|
|
4
|
+
import * as _portabletext_schema5 from "@portabletext/schema";
|
|
5
|
+
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
4
6
|
import * as xstate227 from "xstate";
|
|
5
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
6
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
7
|
-
import * as
|
|
9
|
+
import * as react22 from "react";
|
|
8
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
9
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
10
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -127,146 +129,7 @@ type SlateEditor = {
|
|
|
127
129
|
/**
|
|
128
130
|
* @public
|
|
129
131
|
*/
|
|
130
|
-
type
|
|
131
|
-
name: string;
|
|
132
|
-
title?: string;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
|
-
type FieldDefinition = BaseDefinition & {
|
|
138
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* @public
|
|
142
|
-
*/
|
|
143
|
-
type DecoratorDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
144
|
-
/**
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
type AnnotationDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
148
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
type BlockObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
154
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* @public
|
|
158
|
-
*/
|
|
159
|
-
type InlineObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
160
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* @public
|
|
164
|
-
*/
|
|
165
|
-
type ListDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
166
|
-
/**
|
|
167
|
-
* @public
|
|
168
|
-
*/
|
|
169
|
-
type StyleDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
170
|
-
/**
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
type SchemaDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = {
|
|
174
|
-
decorators?: ReadonlyArray<DecoratorDefinition<TBaseDefinition>>;
|
|
175
|
-
blockObjects?: ReadonlyArray<BlockObjectDefinition<TBaseDefinition>>;
|
|
176
|
-
inlineObjects?: ReadonlyArray<InlineObjectDefinition<TBaseDefinition>>;
|
|
177
|
-
annotations?: ReadonlyArray<AnnotationDefinition<TBaseDefinition>>;
|
|
178
|
-
lists?: ReadonlyArray<ListDefinition<TBaseDefinition>>;
|
|
179
|
-
styles?: ReadonlyArray<StyleDefinition<TBaseDefinition>>;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* @public
|
|
183
|
-
* A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* import { defineSchema } from '@portabletext/editor'
|
|
187
|
-
*
|
|
188
|
-
* const schemaDefinition = defineSchema({
|
|
189
|
-
* decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}],
|
|
190
|
-
* annotations: [{name: 'link'}],
|
|
191
|
-
* styles: [
|
|
192
|
-
* {name: 'normal'},
|
|
193
|
-
* {name: 'h1'},
|
|
194
|
-
* {name: 'h2'},
|
|
195
|
-
* {name: 'h3'},
|
|
196
|
-
* {name: 'blockquote'},
|
|
197
|
-
* ],
|
|
198
|
-
* lists: [],
|
|
199
|
-
* inlineObjects: [],
|
|
200
|
-
* blockObjects: [],
|
|
201
|
-
* }
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
declare function defineSchema<const TSchemaDefinition extends SchemaDefinition>(definition: TSchemaDefinition): TSchemaDefinition;
|
|
205
|
-
/**
|
|
206
|
-
* @public
|
|
207
|
-
*/
|
|
208
|
-
type EditorSchema = {
|
|
209
|
-
annotations: ReadonlyArray<AnnotationSchemaType>;
|
|
210
|
-
block: {
|
|
211
|
-
name: string;
|
|
212
|
-
};
|
|
213
|
-
blockObjects: ReadonlyArray<BlockObjectSchemaType>;
|
|
214
|
-
decorators: ReadonlyArray<DecoratorSchemaType>;
|
|
215
|
-
inlineObjects: ReadonlyArray<InlineObjectSchemaType>;
|
|
216
|
-
span: {
|
|
217
|
-
name: string;
|
|
218
|
-
};
|
|
219
|
-
styles: ReadonlyArray<StyleSchemaType>;
|
|
220
|
-
lists: ReadonlyArray<ListSchemaType>;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* @public
|
|
224
|
-
*/
|
|
225
|
-
type AnnotationSchemaType = BaseDefinition & {
|
|
226
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* @public
|
|
230
|
-
*/
|
|
231
|
-
type BlockObjectSchemaType = BaseDefinition & {
|
|
232
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* @public
|
|
236
|
-
*/
|
|
237
|
-
type DecoratorSchemaType = BaseDefinition & {
|
|
238
|
-
/**
|
|
239
|
-
* @deprecated
|
|
240
|
-
* Use `name` instead
|
|
241
|
-
*/
|
|
242
|
-
value: string;
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* @public
|
|
246
|
-
*/
|
|
247
|
-
type InlineObjectSchemaType = BaseDefinition & {
|
|
248
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* @public
|
|
252
|
-
*/
|
|
253
|
-
type ListSchemaType = BaseDefinition & {
|
|
254
|
-
/**
|
|
255
|
-
* @deprecated
|
|
256
|
-
* Use `name` instead
|
|
257
|
-
*/
|
|
258
|
-
value: string;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* @public
|
|
262
|
-
*/
|
|
263
|
-
type StyleSchemaType = BaseDefinition & {
|
|
264
|
-
/**
|
|
265
|
-
* @deprecated
|
|
266
|
-
* Use `name` instead
|
|
267
|
-
*/
|
|
268
|
-
value: string;
|
|
269
|
-
};
|
|
132
|
+
type EditorSchema = Schema;
|
|
270
133
|
type InternalEditor = Editor & {
|
|
271
134
|
_internal: {
|
|
272
135
|
editable: EditableAPI;
|
|
@@ -352,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
352
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
353
216
|
componentWillUnmount(): void;
|
|
354
217
|
setEditable: (editable: EditableAPI) => void;
|
|
355
|
-
render():
|
|
218
|
+
render(): react22.JSX.Element;
|
|
356
219
|
/**
|
|
357
220
|
* @deprecated
|
|
358
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -747,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
747
610
|
* ```
|
|
748
611
|
* @group Components
|
|
749
612
|
*/
|
|
750
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react22.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react22.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
751
614
|
type DecoratedRange = BaseRange & {
|
|
752
615
|
rangeDecoration: RangeDecoration;
|
|
753
616
|
};
|
|
@@ -1476,7 +1339,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1476
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1477
1340
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1478
1341
|
type: "blurred";
|
|
1479
|
-
event:
|
|
1342
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1480
1343
|
} | {
|
|
1481
1344
|
type: "done loading";
|
|
1482
1345
|
} | {
|
|
@@ -1488,7 +1351,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1488
1351
|
data: unknown;
|
|
1489
1352
|
} | {
|
|
1490
1353
|
type: "focused";
|
|
1491
|
-
event:
|
|
1354
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1492
1355
|
} | {
|
|
1493
1356
|
type: "invalid value";
|
|
1494
1357
|
resolution: InvalidValueResolution | null;
|
|
@@ -1912,7 +1775,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1912
1775
|
keyGenerator: () => string;
|
|
1913
1776
|
pendingEvents: never[];
|
|
1914
1777
|
pendingIncomingPatchesEvents: never[];
|
|
1915
|
-
schema:
|
|
1778
|
+
schema: _portabletext_schema5.Schema;
|
|
1916
1779
|
selection: null;
|
|
1917
1780
|
initialReadOnly: boolean;
|
|
1918
1781
|
maxBlocks: number | undefined;
|
|
@@ -2135,7 +1998,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2135
1998
|
type: "drop";
|
|
2136
1999
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2137
2000
|
type: "blurred";
|
|
2138
|
-
event:
|
|
2001
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2139
2002
|
} | {
|
|
2140
2003
|
type: "done loading";
|
|
2141
2004
|
} | {
|
|
@@ -2147,7 +2010,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2147
2010
|
data: unknown;
|
|
2148
2011
|
} | {
|
|
2149
2012
|
type: "focused";
|
|
2150
|
-
event:
|
|
2013
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2151
2014
|
} | {
|
|
2152
2015
|
type: "invalid value";
|
|
2153
2016
|
resolution: InvalidValueResolution | null;
|
|
@@ -3018,7 +2881,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
3018
2881
|
type: "drop";
|
|
3019
2882
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
3020
2883
|
type: "blurred";
|
|
3021
|
-
event:
|
|
2884
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
3022
2885
|
} | {
|
|
3023
2886
|
type: "done loading";
|
|
3024
2887
|
} | {
|
|
@@ -3030,7 +2893,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
3030
2893
|
data: unknown;
|
|
3031
2894
|
} | {
|
|
3032
2895
|
type: "focused";
|
|
3033
|
-
event:
|
|
2896
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
3034
2897
|
} | {
|
|
3035
2898
|
type: "invalid value";
|
|
3036
2899
|
resolution: InvalidValueResolution | null;
|
|
@@ -3747,4 +3610,4 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
|
|
|
3747
3610
|
event: TBehaviorEvent;
|
|
3748
3611
|
dom: EditorDom;
|
|
3749
3612
|
}, guardResponse: TGuardResponse) => Array<BehaviorAction>;
|
|
3750
|
-
export { type AddedAnnotationPaths, type AnnotationDefinition, type AnnotationPath, type AnnotationSchemaType, type BaseDefinition, Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObjectDefinition, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type BlurChange, type ChildPath, type ConnectionChange, CustomBehaviorEvent, type DecoratorDefinition, type DecoratorSchemaType, type EditableAPI, type EditableAPIDeleteOptions, type Editor, type EditorChange, type EditorChanges, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorEventListener, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type ErrorChange, type FieldDefinition, type FocusChange, type HotkeyOptions, type InlineObjectDefinition, type InlineObjectSchemaType, InsertPlacement, type InvalidValue, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type LoadingChange, type MutationChange, type MutationEvent, NativeBehaviorEvent, type OnBeforeInputFn, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type PasteData, type Patch$1 as Patch, type PatchChange, type PatchObservable, type PatchesEvent, type PortableTextBlock$1 as PortableTextBlock, type PortableTextChild$1 as PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextEditorProps, type PortableTextMemberSchemaTypes, type PortableTextObject$1 as PortableTextObject, type PortableTextSpan$1 as PortableTextSpan, type PortableTextTextBlock$1 as PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type ReadyChange, type RedoChange, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition, type ScrollSelectionIntoViewFunction, type SelectionChange, type StyleDefinition, type StyleSchemaType, SyntheticBehaviorEvent, type UndoChange, type UnsetChange, type ValueChange, defaultKeyGenerator, defineBehavior, defineSchema, effect, execute, forward, raise, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
3613
|
+
export { type AddedAnnotationPaths, type AnnotationDefinition, type AnnotationPath, type AnnotationSchemaType, type BaseDefinition, Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObjectDefinition, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type BlurChange, type ChildPath, type ConnectionChange, CustomBehaviorEvent, type DecoratorDefinition, type DecoratorSchemaType, type EditableAPI, type EditableAPIDeleteOptions, type Editor, type EditorChange, type EditorChanges, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorEventListener, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type ErrorChange, type FieldDefinition, type FocusChange, type HotkeyOptions, type InlineObjectDefinition, type InlineObjectSchemaType, InsertPlacement, type InvalidValue, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type LoadingChange, type MutationChange, type MutationEvent, NativeBehaviorEvent, type OnBeforeInputFn, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type PasteData, type Patch$1 as Patch, type PatchChange, type PatchObservable, type PatchesEvent, type PortableTextBlock$1 as PortableTextBlock, type PortableTextChild$1 as PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextEditorProps, type PortableTextMemberSchemaTypes, type PortableTextObject$1 as PortableTextObject, type PortableTextSpan$1 as PortableTextSpan, type PortableTextTextBlock$1 as PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type ReadyChange, type RedoChange, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition$1 as SchemaDefinition, type ScrollSelectionIntoViewFunction, type SelectionChange, type StyleDefinition, type StyleSchemaType, SyntheticBehaviorEvent, type UndoChange, type UnsetChange, type ValueChange, defaultKeyGenerator, defineBehavior, defineSchema, effect, execute, forward, raise, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Patch, Patch as Patch$1 } from "@portabletext/patches";
|
|
2
2
|
import * as _sanity_types5 from "@sanity/types";
|
|
3
3
|
import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType, Path, PortableTextBlock, PortableTextBlock as PortableTextBlock$1, PortableTextChild, PortableTextChild as PortableTextChild$1, PortableTextListBlock, PortableTextObject, PortableTextObject as PortableTextObject$1, PortableTextSpan, PortableTextSpan as PortableTextSpan$1, PortableTextTextBlock, PortableTextTextBlock as PortableTextTextBlock$1, TypedObject } from "@sanity/types";
|
|
4
|
+
import * as _portabletext_schema5 from "@portabletext/schema";
|
|
5
|
+
import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, defineSchema } from "@portabletext/schema";
|
|
4
6
|
import * as xstate227 from "xstate";
|
|
5
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
6
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
7
|
-
import * as
|
|
9
|
+
import * as react20 from "react";
|
|
8
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
9
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
10
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -127,146 +129,7 @@ type SlateEditor = {
|
|
|
127
129
|
/**
|
|
128
130
|
* @public
|
|
129
131
|
*/
|
|
130
|
-
type
|
|
131
|
-
name: string;
|
|
132
|
-
title?: string;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* @public
|
|
136
|
-
*/
|
|
137
|
-
type FieldDefinition = BaseDefinition & {
|
|
138
|
-
type: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* @public
|
|
142
|
-
*/
|
|
143
|
-
type DecoratorDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
144
|
-
/**
|
|
145
|
-
* @public
|
|
146
|
-
*/
|
|
147
|
-
type AnnotationDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
148
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* @public
|
|
152
|
-
*/
|
|
153
|
-
type BlockObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
154
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
155
|
-
};
|
|
156
|
-
/**
|
|
157
|
-
* @public
|
|
158
|
-
*/
|
|
159
|
-
type InlineObjectDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition & {
|
|
160
|
-
fields?: ReadonlyArray<FieldDefinition>;
|
|
161
|
-
};
|
|
162
|
-
/**
|
|
163
|
-
* @public
|
|
164
|
-
*/
|
|
165
|
-
type ListDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
166
|
-
/**
|
|
167
|
-
* @public
|
|
168
|
-
*/
|
|
169
|
-
type StyleDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = TBaseDefinition;
|
|
170
|
-
/**
|
|
171
|
-
* @public
|
|
172
|
-
*/
|
|
173
|
-
type SchemaDefinition<TBaseDefinition extends BaseDefinition = BaseDefinition> = {
|
|
174
|
-
decorators?: ReadonlyArray<DecoratorDefinition<TBaseDefinition>>;
|
|
175
|
-
blockObjects?: ReadonlyArray<BlockObjectDefinition<TBaseDefinition>>;
|
|
176
|
-
inlineObjects?: ReadonlyArray<InlineObjectDefinition<TBaseDefinition>>;
|
|
177
|
-
annotations?: ReadonlyArray<AnnotationDefinition<TBaseDefinition>>;
|
|
178
|
-
lists?: ReadonlyArray<ListDefinition<TBaseDefinition>>;
|
|
179
|
-
styles?: ReadonlyArray<StyleDefinition<TBaseDefinition>>;
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* @public
|
|
183
|
-
* A helper wrapper that adds editor support, such as autocomplete and type checking, for a schema definition.
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* import { defineSchema } from '@portabletext/editor'
|
|
187
|
-
*
|
|
188
|
-
* const schemaDefinition = defineSchema({
|
|
189
|
-
* decorators: [{name: 'strong'}, {name: 'em'}, {name: 'underline'}],
|
|
190
|
-
* annotations: [{name: 'link'}],
|
|
191
|
-
* styles: [
|
|
192
|
-
* {name: 'normal'},
|
|
193
|
-
* {name: 'h1'},
|
|
194
|
-
* {name: 'h2'},
|
|
195
|
-
* {name: 'h3'},
|
|
196
|
-
* {name: 'blockquote'},
|
|
197
|
-
* ],
|
|
198
|
-
* lists: [],
|
|
199
|
-
* inlineObjects: [],
|
|
200
|
-
* blockObjects: [],
|
|
201
|
-
* }
|
|
202
|
-
* ```
|
|
203
|
-
*/
|
|
204
|
-
declare function defineSchema<const TSchemaDefinition extends SchemaDefinition>(definition: TSchemaDefinition): TSchemaDefinition;
|
|
205
|
-
/**
|
|
206
|
-
* @public
|
|
207
|
-
*/
|
|
208
|
-
type EditorSchema = {
|
|
209
|
-
annotations: ReadonlyArray<AnnotationSchemaType>;
|
|
210
|
-
block: {
|
|
211
|
-
name: string;
|
|
212
|
-
};
|
|
213
|
-
blockObjects: ReadonlyArray<BlockObjectSchemaType>;
|
|
214
|
-
decorators: ReadonlyArray<DecoratorSchemaType>;
|
|
215
|
-
inlineObjects: ReadonlyArray<InlineObjectSchemaType>;
|
|
216
|
-
span: {
|
|
217
|
-
name: string;
|
|
218
|
-
};
|
|
219
|
-
styles: ReadonlyArray<StyleSchemaType>;
|
|
220
|
-
lists: ReadonlyArray<ListSchemaType>;
|
|
221
|
-
};
|
|
222
|
-
/**
|
|
223
|
-
* @public
|
|
224
|
-
*/
|
|
225
|
-
type AnnotationSchemaType = BaseDefinition & {
|
|
226
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
227
|
-
};
|
|
228
|
-
/**
|
|
229
|
-
* @public
|
|
230
|
-
*/
|
|
231
|
-
type BlockObjectSchemaType = BaseDefinition & {
|
|
232
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* @public
|
|
236
|
-
*/
|
|
237
|
-
type DecoratorSchemaType = BaseDefinition & {
|
|
238
|
-
/**
|
|
239
|
-
* @deprecated
|
|
240
|
-
* Use `name` instead
|
|
241
|
-
*/
|
|
242
|
-
value: string;
|
|
243
|
-
};
|
|
244
|
-
/**
|
|
245
|
-
* @public
|
|
246
|
-
*/
|
|
247
|
-
type InlineObjectSchemaType = BaseDefinition & {
|
|
248
|
-
fields: ReadonlyArray<FieldDefinition>;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* @public
|
|
252
|
-
*/
|
|
253
|
-
type ListSchemaType = BaseDefinition & {
|
|
254
|
-
/**
|
|
255
|
-
* @deprecated
|
|
256
|
-
* Use `name` instead
|
|
257
|
-
*/
|
|
258
|
-
value: string;
|
|
259
|
-
};
|
|
260
|
-
/**
|
|
261
|
-
* @public
|
|
262
|
-
*/
|
|
263
|
-
type StyleSchemaType = BaseDefinition & {
|
|
264
|
-
/**
|
|
265
|
-
* @deprecated
|
|
266
|
-
* Use `name` instead
|
|
267
|
-
*/
|
|
268
|
-
value: string;
|
|
269
|
-
};
|
|
132
|
+
type EditorSchema = Schema;
|
|
270
133
|
type InternalEditor = Editor & {
|
|
271
134
|
_internal: {
|
|
272
135
|
editable: EditableAPI;
|
|
@@ -352,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
352
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
353
216
|
componentWillUnmount(): void;
|
|
354
217
|
setEditable: (editable: EditableAPI) => void;
|
|
355
|
-
render():
|
|
218
|
+
render(): react20.JSX.Element;
|
|
356
219
|
/**
|
|
357
220
|
* @deprecated
|
|
358
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -747,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
747
610
|
* ```
|
|
748
611
|
* @group Components
|
|
749
612
|
*/
|
|
750
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react20.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react20.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
751
614
|
type DecoratedRange = BaseRange & {
|
|
752
615
|
rangeDecoration: RangeDecoration;
|
|
753
616
|
};
|
|
@@ -1476,7 +1339,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1476
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1477
1340
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1478
1341
|
type: "blurred";
|
|
1479
|
-
event:
|
|
1342
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1480
1343
|
} | {
|
|
1481
1344
|
type: "done loading";
|
|
1482
1345
|
} | {
|
|
@@ -1488,7 +1351,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1488
1351
|
data: unknown;
|
|
1489
1352
|
} | {
|
|
1490
1353
|
type: "focused";
|
|
1491
|
-
event:
|
|
1354
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1492
1355
|
} | {
|
|
1493
1356
|
type: "invalid value";
|
|
1494
1357
|
resolution: InvalidValueResolution | null;
|
|
@@ -1912,7 +1775,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1912
1775
|
keyGenerator: () => string;
|
|
1913
1776
|
pendingEvents: never[];
|
|
1914
1777
|
pendingIncomingPatchesEvents: never[];
|
|
1915
|
-
schema:
|
|
1778
|
+
schema: _portabletext_schema5.Schema;
|
|
1916
1779
|
selection: null;
|
|
1917
1780
|
initialReadOnly: boolean;
|
|
1918
1781
|
maxBlocks: number | undefined;
|
|
@@ -2135,7 +1998,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2135
1998
|
type: "drop";
|
|
2136
1999
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2137
2000
|
type: "blurred";
|
|
2138
|
-
event:
|
|
2001
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2139
2002
|
} | {
|
|
2140
2003
|
type: "done loading";
|
|
2141
2004
|
} | {
|
|
@@ -2147,7 +2010,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2147
2010
|
data: unknown;
|
|
2148
2011
|
} | {
|
|
2149
2012
|
type: "focused";
|
|
2150
|
-
event:
|
|
2013
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2151
2014
|
} | {
|
|
2152
2015
|
type: "invalid value";
|
|
2153
2016
|
resolution: InvalidValueResolution | null;
|
|
@@ -3018,7 +2881,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
3018
2881
|
type: "drop";
|
|
3019
2882
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
3020
2883
|
type: "blurred";
|
|
3021
|
-
event:
|
|
2884
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
3022
2885
|
} | {
|
|
3023
2886
|
type: "done loading";
|
|
3024
2887
|
} | {
|
|
@@ -3030,7 +2893,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
3030
2893
|
data: unknown;
|
|
3031
2894
|
} | {
|
|
3032
2895
|
type: "focused";
|
|
3033
|
-
event:
|
|
2896
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
3034
2897
|
} | {
|
|
3035
2898
|
type: "invalid value";
|
|
3036
2899
|
resolution: InvalidValueResolution | null;
|
|
@@ -3747,4 +3610,4 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
|
|
|
3747
3610
|
event: TBehaviorEvent;
|
|
3748
3611
|
dom: EditorDom;
|
|
3749
3612
|
}, guardResponse: TGuardResponse) => Array<BehaviorAction>;
|
|
3750
|
-
export { type AddedAnnotationPaths, type AnnotationDefinition, type AnnotationPath, type AnnotationSchemaType, type BaseDefinition, Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObjectDefinition, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type BlurChange, type ChildPath, type ConnectionChange, CustomBehaviorEvent, type DecoratorDefinition, type DecoratorSchemaType, type EditableAPI, type EditableAPIDeleteOptions, type Editor, type EditorChange, type EditorChanges, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorEventListener, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type ErrorChange, type FieldDefinition, type FocusChange, type HotkeyOptions, type InlineObjectDefinition, type InlineObjectSchemaType, InsertPlacement, type InvalidValue, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type LoadingChange, type MutationChange, type MutationEvent, NativeBehaviorEvent, type OnBeforeInputFn, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type PasteData, type Patch$1 as Patch, type PatchChange, type PatchObservable, type PatchesEvent, type PortableTextBlock$1 as PortableTextBlock, type PortableTextChild$1 as PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextEditorProps, type PortableTextMemberSchemaTypes, type PortableTextObject$1 as PortableTextObject, type PortableTextSpan$1 as PortableTextSpan, type PortableTextTextBlock$1 as PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type ReadyChange, type RedoChange, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition, type ScrollSelectionIntoViewFunction, type SelectionChange, type StyleDefinition, type StyleSchemaType, SyntheticBehaviorEvent, type UndoChange, type UnsetChange, type ValueChange, defaultKeyGenerator, defineBehavior, defineSchema, effect, execute, forward, raise, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|
|
3613
|
+
export { type AddedAnnotationPaths, type AnnotationDefinition, type AnnotationPath, type AnnotationSchemaType, type BaseDefinition, Behavior, BehaviorAction, BehaviorActionSet, BehaviorEvent, BehaviorGuard, type BlockAnnotationRenderProps, type BlockChildRenderProps, type BlockDecoratorRenderProps, type BlockListItemRenderProps, type BlockObjectDefinition, type BlockObjectSchemaType, type BlockOffset, type BlockPath, type BlockRenderProps, type BlockStyleRenderProps, type BlurChange, type ChildPath, type ConnectionChange, CustomBehaviorEvent, type DecoratorDefinition, type DecoratorSchemaType, type EditableAPI, type EditableAPIDeleteOptions, type Editor, type EditorChange, type EditorChanges, type EditorConfig, type EditorContext, type EditorEmittedEvent, type EditorEvent, EditorEventListener, EditorProvider, type EditorProviderProps, type EditorSchema, type EditorSelection, type EditorSelectionPoint, type EditorSelector, type EditorSnapshot, type ErrorChange, type FieldDefinition, type FocusChange, type HotkeyOptions, type InlineObjectDefinition, type InlineObjectSchemaType, InsertPlacement, type InvalidValue, type InvalidValueResolution, type ListDefinition, type ListSchemaType, type LoadingChange, type MutationChange, type MutationEvent, NativeBehaviorEvent, type OnBeforeInputFn, type OnCopyFn, type OnPasteFn, type OnPasteResult, type OnPasteResultOrPromise, type PasteData, type Patch$1 as Patch, type PatchChange, type PatchObservable, type PatchesEvent, type PortableTextBlock$1 as PortableTextBlock, type PortableTextChild$1 as PortableTextChild, PortableTextEditable, type PortableTextEditableProps, PortableTextEditor, type PortableTextEditorProps, type PortableTextMemberSchemaTypes, type PortableTextObject$1 as PortableTextObject, type PortableTextSpan$1 as PortableTextSpan, type PortableTextTextBlock$1 as PortableTextTextBlock, type RangeDecoration, type RangeDecorationOnMovedDetails, type ReadyChange, type RedoChange, type RenderAnnotationFunction, type RenderBlockFunction, type RenderChildFunction, type RenderDecoratorFunction, type RenderEditableFunction, type RenderListItemFunction, type RenderPlaceholderFunction, type RenderStyleFunction, type SchemaDefinition$1 as SchemaDefinition, type ScrollSelectionIntoViewFunction, type SelectionChange, type StyleDefinition, type StyleSchemaType, SyntheticBehaviorEvent, type UndoChange, type UnsetChange, type ValueChange, defaultKeyGenerator, defineBehavior, defineSchema, effect, execute, forward, raise, useEditor, useEditorSelector, usePortableTextEditor, usePortableTextEditorSelection };
|