@portabletext/editor 5.1.1 → 6.0.0-canary.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.
@@ -1,12 +1,10 @@
1
1
  import * as _portabletext_schema6 from "@portabletext/schema";
2
- import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, DecoratorDefinition, DecoratorSchemaType, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, ListDefinition, ListSchemaType, 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, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, TypedObject, defineSchema } from "@portabletext/schema";
2
+ import { AnnotationDefinition, AnnotationSchemaType, AnnotationSchemaType as AnnotationSchemaType$1, BaseDefinition, BlockObjectDefinition, BlockObjectSchemaType, BlockObjectSchemaType as BlockObjectSchemaType$1, DecoratorDefinition, DecoratorSchemaType, DecoratorSchemaType as DecoratorSchemaType$1, FieldDefinition, InlineObjectDefinition, InlineObjectSchemaType, InlineObjectSchemaType as InlineObjectSchemaType$1, ListDefinition, ListSchemaType, ListSchemaType as ListSchemaType$1, 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, Schema, SchemaDefinition, SchemaDefinition as SchemaDefinition$1, StyleDefinition, StyleSchemaType, StyleSchemaType as StyleSchemaType$1, TypedObject, defineSchema } from "@portabletext/schema";
3
3
  import * as xstate73 from "xstate";
4
4
  import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
5
- import * as react10 from "react";
5
+ import * as react11 from "react";
6
6
  import React$1, { BaseSyntheticEvent, ClipboardEvent as ClipboardEvent$1, FocusEvent, JSX, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
7
7
  import { Patch, Patch as Patch$1 } from "@portabletext/patches";
8
- import { Observable, Subject } from "rxjs";
9
- import { ArrayDefinition, ArraySchemaType, BlockDecoratorDefinition, BlockListDefinition, BlockStyleDefinition, ObjectSchemaType } from "@sanity/types";
10
8
  type MIMEType = `${string}/${string}`;
11
9
  /**
12
10
  * @internal
@@ -1915,14 +1913,10 @@ type InternalEditor = Editor & {
1915
1913
  * ```
1916
1914
  */
1917
1915
  declare class PortableTextEditor {
1918
- /**
1919
- * An observable of all the editor changes.
1920
- */
1921
- change$: EditorChanges;
1922
1916
  /**
1923
1917
  * A lookup table for all the relevant schema types for this portable text type.
1924
1918
  */
1925
- schemaTypes: PortableTextMemberSchemaTypes;
1919
+ schemaTypes: Schema;
1926
1920
  /**
1927
1921
  * The editor instance
1928
1922
  */
@@ -2340,7 +2334,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
2340
2334
  * ```
2341
2335
  * @group Components
2342
2336
  */
2343
- declare const PortableTextEditable: react10.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react10.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
2337
+ declare const PortableTextEditable: react11.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react11.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
2344
2338
  /** @beta */
2345
2339
  interface EditableAPIDeleteOptions {
2346
2340
  mode?: 'blocks' | 'children' | 'selected';
@@ -2421,85 +2415,6 @@ type EditorSelection = {
2421
2415
  focus: EditorSelectionPoint;
2422
2416
  backward?: boolean;
2423
2417
  } | null;
2424
- /**
2425
- * The editor has mutated it's content.
2426
- * @beta */
2427
- type MutationChange = {
2428
- type: 'mutation';
2429
- patches: Patch[];
2430
- snapshot: PortableTextBlock[] | undefined;
2431
- };
2432
- /**
2433
- * The editor has produced a patch
2434
- * @beta */
2435
- type PatchChange = {
2436
- type: 'patch';
2437
- patch: Patch;
2438
- };
2439
- /**
2440
- * The editor has received a new (props) value
2441
- * @beta */
2442
- type ValueChange = {
2443
- type: 'value';
2444
- value: PortableTextBlock[] | undefined;
2445
- };
2446
- /**
2447
- * The editor has a new selection
2448
- * @beta */
2449
- type SelectionChange = {
2450
- type: 'selection';
2451
- selection: EditorSelection;
2452
- };
2453
- /**
2454
- * The editor received focus
2455
- * @beta */
2456
- type FocusChange = {
2457
- type: 'focus';
2458
- event: FocusEvent<HTMLDivElement, Element>;
2459
- };
2460
- /**
2461
- * @beta
2462
- * @deprecated Use `'patch'` changes instead
2463
- */
2464
- type UnsetChange = {
2465
- type: 'unset';
2466
- previousValue: PortableTextBlock[];
2467
- };
2468
- /**
2469
- * The editor blurred
2470
- * @beta */
2471
- type BlurChange = {
2472
- type: 'blur';
2473
- event: FocusEvent<HTMLDivElement, Element>;
2474
- };
2475
- /**
2476
- * The editor is currently loading something
2477
- * Could be used to show a spinner etc.
2478
- * @beta
2479
- * @deprecated Will be removed in the next major version
2480
- */
2481
- type LoadingChange = {
2482
- type: 'loading';
2483
- isLoading: boolean;
2484
- };
2485
- /**
2486
- * The editor content is ready to be edited by the user
2487
- * @beta */
2488
- type ReadyChange = {
2489
- type: 'ready';
2490
- };
2491
- /**
2492
- * The editor produced an error
2493
- * @beta
2494
- * @deprecated The change is no longer emitted
2495
- * */
2496
- type ErrorChange = {
2497
- type: 'error';
2498
- name: string;
2499
- level: 'warning' | 'error';
2500
- description: string;
2501
- data?: unknown;
2502
- };
2503
2418
  /**
2504
2419
  * The editor has invalid data in the value that can be resolved by the user
2505
2420
  * @beta */
@@ -2522,52 +2437,6 @@ type InvalidValueResolution = {
2522
2437
  values?: Record<string, string | number | string[]>;
2523
2438
  };
2524
2439
  };
2525
- /**
2526
- * The editor has an invalid value
2527
- * @beta */
2528
- type InvalidValue = {
2529
- type: 'invalidValue';
2530
- resolution: InvalidValueResolution | null;
2531
- value: PortableTextBlock[] | undefined;
2532
- };
2533
- /**
2534
- * The editor performed a undo history step
2535
- * @beta
2536
- * @deprecated The change is no longer emitted
2537
- * */
2538
- type UndoChange = {
2539
- type: 'undo';
2540
- patches: Patch[];
2541
- timestamp: Date;
2542
- };
2543
- /**
2544
- * The editor performed redo history step
2545
- * @beta
2546
- * @deprecated The change is no longer emitted
2547
- * */
2548
- type RedoChange = {
2549
- type: 'redo';
2550
- patches: Patch[];
2551
- timestamp: Date;
2552
- };
2553
- /**
2554
- * The editor was either connected or disconnected to the network
2555
- * To show out of sync warnings etc when in collaborative mode.
2556
- * @beta
2557
- * @deprecated The change is no longer emitted
2558
- * */
2559
- type ConnectionChange = {
2560
- type: 'connection';
2561
- value: 'online' | 'offline';
2562
- };
2563
- /**
2564
- * When the editor changes, it will emit a change item describing the change
2565
- * @beta */
2566
- type EditorChange = BlurChange | ConnectionChange | ErrorChange | FocusChange | InvalidValue | LoadingChange | MutationChange | PatchChange | ReadyChange | RedoChange | SelectionChange | UndoChange | UnsetChange | ValueChange;
2567
- /**
2568
- * @beta
2569
- */
2570
- type EditorChanges = Subject<EditorChange>;
2571
2440
  /** @beta */
2572
2441
  type OnPasteResult = {
2573
2442
  insert?: TypedObject[];
@@ -2581,7 +2450,7 @@ type OnPasteResultOrPromise = OnPasteResult | Promise<OnPasteResult>;
2581
2450
  interface PasteData {
2582
2451
  event: ClipboardEvent$1;
2583
2452
  path: Path;
2584
- schemaTypes: PortableTextMemberSchemaTypes;
2453
+ schemaTypes: EditorSchema;
2585
2454
  value: PortableTextBlock[] | undefined;
2586
2455
  }
2587
2456
  /**
@@ -2596,11 +2465,6 @@ type OnBeforeInputFn = (event: InputEvent) => void;
2596
2465
  /** @beta */
2597
2466
  type OnCopyFn = (event: ClipboardEvent$1<HTMLDivElement | HTMLSpanElement>) => undefined | unknown;
2598
2467
  /** @beta */
2599
- type PatchObservable = Observable<{
2600
- patches: Patch[];
2601
- snapshot: PortableTextBlock[] | undefined;
2602
- }>;
2603
- /** @beta */
2604
2468
  interface BlockRenderProps {
2605
2469
  children: ReactElement<any>;
2606
2470
  editorElementRef: RefObject<HTMLElement | null>;
@@ -2610,9 +2474,7 @@ interface BlockRenderProps {
2610
2474
  path: BlockPath;
2611
2475
  selected: boolean;
2612
2476
  style?: string;
2613
- schemaType: ObjectSchemaType;
2614
- /** @deprecated Use `schemaType` instead */
2615
- type: ObjectSchemaType;
2477
+ schemaType: BlockObjectSchemaType;
2616
2478
  value: PortableTextBlock;
2617
2479
  }
2618
2480
  /** @beta */
@@ -2623,9 +2485,7 @@ interface BlockChildRenderProps {
2623
2485
  focused: boolean;
2624
2486
  path: Path;
2625
2487
  selected: boolean;
2626
- schemaType: ObjectSchemaType;
2627
- /** @deprecated Use `schemaType` instead */
2628
- type: ObjectSchemaType;
2488
+ schemaType: InlineObjectSchemaType;
2629
2489
  value: PortableTextChild;
2630
2490
  }
2631
2491
  /** @beta */
@@ -2635,10 +2495,8 @@ interface BlockAnnotationRenderProps {
2635
2495
  editorElementRef: RefObject<HTMLElement | null>;
2636
2496
  focused: boolean;
2637
2497
  path: Path;
2638
- schemaType: ObjectSchemaType;
2498
+ schemaType: AnnotationSchemaType;
2639
2499
  selected: boolean;
2640
- /** @deprecated Use `schemaType` instead */
2641
- type: ObjectSchemaType;
2642
2500
  value: PortableTextObject;
2643
2501
  }
2644
2502
  /** @beta */
@@ -2647,10 +2505,8 @@ interface BlockDecoratorRenderProps {
2647
2505
  editorElementRef: RefObject<HTMLElement | null>;
2648
2506
  focused: boolean;
2649
2507
  path: Path;
2650
- schemaType: BlockDecoratorDefinition;
2508
+ schemaType: DecoratorSchemaType;
2651
2509
  selected: boolean;
2652
- /** @deprecated Use `schemaType` instead */
2653
- type: BlockDecoratorDefinition;
2654
2510
  value: string;
2655
2511
  }
2656
2512
  /** @beta */
@@ -2661,7 +2517,7 @@ interface BlockListItemRenderProps {
2661
2517
  focused: boolean;
2662
2518
  level: number;
2663
2519
  path: Path;
2664
- schemaType: BlockListDefinition;
2520
+ schemaType: ListSchemaType;
2665
2521
  selected: boolean;
2666
2522
  value: string;
2667
2523
  }
@@ -2685,7 +2541,7 @@ interface BlockStyleRenderProps {
2685
2541
  focused: boolean;
2686
2542
  path: Path;
2687
2543
  selected: boolean;
2688
- schemaType: BlockStyleDefinition;
2544
+ schemaType: StyleSchemaType;
2689
2545
  value: string;
2690
2546
  }
2691
2547
  /** @beta */
@@ -2735,20 +2591,6 @@ interface RangeDecoration {
2735
2591
  */
2736
2592
  payload?: Record<string, unknown>;
2737
2593
  }
2738
- /** @beta */
2739
- type PortableTextMemberSchemaTypes = {
2740
- annotations: (ObjectSchemaType & {
2741
- i18nTitleKey?: string;
2742
- })[];
2743
- block: ObjectSchemaType;
2744
- blockObjects: ObjectSchemaType[];
2745
- decorators: BlockDecoratorDefinition[];
2746
- inlineObjects: ObjectSchemaType[];
2747
- portableText: ArraySchemaType<PortableTextBlock>;
2748
- span: ObjectSchemaType;
2749
- styles: BlockStyleDefinition[];
2750
- lists: BlockListDefinition[];
2751
- };
2752
2594
  /**
2753
2595
  * @public
2754
2596
  */
@@ -2825,13 +2667,8 @@ type EditorConfig = {
2825
2667
  keyGenerator?: () => string;
2826
2668
  readOnly?: boolean;
2827
2669
  initialValue?: Array<PortableTextBlock>;
2828
- } & ({
2829
2670
  schemaDefinition: SchemaDefinition;
2830
- schema?: undefined;
2831
- } | {
2832
- schemaDefinition?: undefined;
2833
- schema: ArraySchemaType<PortableTextBlock> | ArrayDefinition;
2834
- });
2671
+ };
2835
2672
  /**
2836
2673
  * @public
2837
2674
  */
@@ -2990,7 +2827,6 @@ declare const editorMachine: xstate73.StateMachine<{
2990
2827
  behaviors: Set<BehaviorConfig>;
2991
2828
  behaviorsSorted: boolean;
2992
2829
  converters: Set<Converter>;
2993
- getLegacySchema: () => PortableTextMemberSchemaTypes;
2994
2830
  keyGenerator: () => string;
2995
2831
  pendingEvents: Array<InternalPatchEvent | MutationEvent>;
2996
2832
  pendingIncomingPatchesEvents: Array<PatchesEvent>;
@@ -3130,14 +2966,13 @@ declare const editorMachine: xstate73.StateMachine<{
3130
2966
  };
3131
2967
  }, "dragging internally", {
3132
2968
  converters?: Array<Converter>;
3133
- getLegacySchema: () => PortableTextMemberSchemaTypes;
3134
2969
  keyGenerator: () => string;
3135
2970
  readOnly?: boolean;
3136
2971
  schema: EditorSchema;
3137
2972
  initialValue?: Array<PortableTextBlock>;
3138
2973
  }, xstate73.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
3139
2974
  type: "blurred";
3140
- event: react10.FocusEvent<HTMLDivElement, Element>;
2975
+ event: react11.FocusEvent<HTMLDivElement, Element>;
3141
2976
  } | {
3142
2977
  type: "done loading";
3143
2978
  } | {
@@ -3149,7 +2984,7 @@ declare const editorMachine: xstate73.StateMachine<{
3149
2984
  data: unknown;
3150
2985
  } | {
3151
2986
  type: "focused";
3152
- event: react10.FocusEvent<HTMLDivElement, Element>;
2987
+ event: react11.FocusEvent<HTMLDivElement, Element>;
3153
2988
  } | {
3154
2989
  type: "invalid value";
3155
2990
  resolution: InvalidValueResolution | null;
@@ -3815,5 +3650,5 @@ type BehaviorActionSet<TBehaviorEvent, TGuardResponse> = (payload: {
3815
3650
  event: TBehaviorEvent;
3816
3651
  dom: EditorDom;
3817
3652
  }, guardResponse: TGuardResponse) => Array<BehaviorAction>;
3818
- export { BlockAnnotationRenderProps as $, BlockPath as $t, PortableTextTextBlock$1 as A, ReadyChange as At, EditorSelector as B, ScrollSelectionIntoViewFunction as Bt, ListDefinition as C, OnPasteResultOrPromise as Ct, PortableTextChild$1 as D, PortableTextMemberSchemaTypes as Dt, PortableTextBlock$1 as E, PatchObservable as Et, BlockOffset as F, RenderDecoratorFunction as Ft, EditorConfig as G, PortableTextEditable as Gt, EditorProvider as H, UndoChange as Ht, useEditor as I, RenderEditableFunction as It, defineBehavior as J, PortableTextEditor as Jt, EditorEvent as K, PortableTextEditableProps as Kt, defaultKeyGenerator as L, RenderListItemFunction as Lt, StyleDefinition as M, RenderAnnotationFunction as Mt, StyleSchemaType as N, RenderBlockFunction as Nt, PortableTextObject$1 as O, RangeDecoration as Ot, defineSchema as P, RenderChildFunction as Pt, AddedAnnotationPaths as Q, AnnotationPath as Qt, usePortableTextEditorSelection as R, RenderPlaceholderFunction as Rt, InlineObjectSchemaType as S, OnPasteResult as St, Patch$1 as T, PatchChange as Tt, EditorProviderProps as U, UnsetChange as Ut, useEditorSelector as V, SelectionChange as Vt, Editor as W, ValueChange as Wt, EditorContext as X, MutationEvent as Xt, BehaviorGuard as Y, EditorEmittedEvent as Yt, EditorSnapshot as Z, EditorSchema as Zt, BlockObjectSchemaType as _, LoadingChange as _t, forward as a, BlurChange as at, FieldDefinition as b, OnCopyFn as bt, CustomBehaviorEvent as c, EditableAPIDeleteOptions as ct, SyntheticBehaviorEvent as d, EditorSelection as dt, ChildPath as en, BlockChildRenderProps as et, PatchesEvent as f, EditorSelectionPoint as ft, BlockObjectDefinition as g, InvalidValueResolution as gt, BaseDefinition as h, InvalidValue as ht, execute as i, BlockStyleRenderProps as it, SchemaDefinition$1 as j, RedoChange as jt, PortableTextSpan$1 as k, RangeDecorationOnMovedDetails as kt, InsertPlacement as l, EditorChange as lt, AnnotationSchemaType as m, FocusChange as mt, BehaviorActionSet as n, Path as nn, BlockListItemRenderProps as nt, raise as o, ConnectionChange as ot, AnnotationDefinition as p, ErrorChange as pt, Behavior as q, HotkeyOptions as qt, effect as r, BlockRenderProps as rt, BehaviorEvent as s, EditableAPI as st, BehaviorAction as t, KeyedSegment as tn, BlockDecoratorRenderProps as tt, NativeBehaviorEvent as u, EditorChanges as ut, DecoratorDefinition as v, MutationChange as vt, ListSchemaType as w, PasteData as wt, InlineObjectDefinition as x, OnPasteFn as xt, DecoratorSchemaType as y, OnBeforeInputFn as yt, usePortableTextEditor as z, RenderStyleFunction as zt };
3653
+ export { BlockAnnotationRenderProps as $, PortableTextTextBlock$1 as A, PortableTextEditor as At, EditorSelector as B, ListDefinition as C, RenderListItemFunction as Ct, PortableTextChild$1 as D, PortableTextEditable as Dt, PortableTextBlock$1 as E, ScrollSelectionIntoViewFunction as Et, BlockOffset as F, BlockPath as Ft, EditorConfig as G, EditorProvider as H, useEditor as I, ChildPath as It, defineBehavior as J, EditorEvent as K, defaultKeyGenerator as L, KeyedSegment as Lt, StyleDefinition as M, MutationEvent as Mt, StyleSchemaType$1 as N, EditorSchema as Nt, PortableTextObject$1 as O, PortableTextEditableProps as Ot, defineSchema as P, AnnotationPath as Pt, AddedAnnotationPaths as Q, usePortableTextEditorSelection as R, Path as Rt, InlineObjectSchemaType$1 as S, RenderEditableFunction as St, Patch$1 as T, RenderStyleFunction as Tt, EditorProviderProps as U, useEditorSelector as V, Editor as W, EditorContext as X, BehaviorGuard as Y, EditorSnapshot as Z, BlockObjectSchemaType$1 as _, RangeDecorationOnMovedDetails as _t, forward as a, EditableAPI as at, FieldDefinition as b, RenderChildFunction as bt, CustomBehaviorEvent as c, EditorSelectionPoint as ct, SyntheticBehaviorEvent as d, OnCopyFn as dt, BlockChildRenderProps as et, PatchesEvent as f, OnPasteFn as ft, BlockObjectDefinition as g, RangeDecoration as gt, BaseDefinition as h, PasteData as ht, execute as i, BlockStyleRenderProps as it, SchemaDefinition$1 as j, EditorEmittedEvent as jt, PortableTextSpan$1 as k, HotkeyOptions as kt, InsertPlacement as l, InvalidValueResolution as lt, AnnotationSchemaType$1 as m, OnPasteResultOrPromise as mt, BehaviorActionSet as n, BlockListItemRenderProps as nt, raise as o, EditableAPIDeleteOptions as ot, AnnotationDefinition as p, OnPasteResult as pt, Behavior as q, effect as r, BlockRenderProps as rt, BehaviorEvent as s, EditorSelection as st, BehaviorAction as t, BlockDecoratorRenderProps as tt, NativeBehaviorEvent as u, OnBeforeInputFn as ut, DecoratorDefinition as v, RenderAnnotationFunction as vt, ListSchemaType$1 as w, RenderPlaceholderFunction as wt, InlineObjectDefinition as x, RenderDecoratorFunction as xt, DecoratorSchemaType$1 as y, RenderBlockFunction as yt, usePortableTextEditor as z };
3819
3654
  //# sourceMappingURL=behavior.types.action.d.ts.map