@portabletext/editor 2.7.0 → 2.7.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/behavior.types.action.d.cts +9 -9
- package/lib/_chunks-dts/behavior.types.action.d.ts +9 -9
- package/lib/_chunks-es/selector.is-selection-expanded.js +1 -1
- package/lib/_chunks-es/util.slice-text-block.js +1 -1
- package/lib/index.cjs +10714 -10667
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +10677 -10630
- 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.ts +2 -2
- package/package.json +1 -1
- package/src/editor/components/render-block-object.tsx +11 -10
- package/src/editor/components/render-inline-object.tsx +12 -11
- package/src/editor/components/render-span.tsx +109 -149
- package/src/editor/components/render-text-block.tsx +45 -36
|
@@ -6,7 +6,7 @@ import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObject
|
|
|
6
6
|
import * as xstate227 from "xstate";
|
|
7
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
8
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react22 from "react";
|
|
10
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
11
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
12
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -215,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
215
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
216
216
|
componentWillUnmount(): void;
|
|
217
217
|
setEditable: (editable: EditableAPI) => void;
|
|
218
|
-
render():
|
|
218
|
+
render(): react22.JSX.Element;
|
|
219
219
|
/**
|
|
220
220
|
* @deprecated
|
|
221
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -610,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
610
610
|
* ```
|
|
611
611
|
* @group Components
|
|
612
612
|
*/
|
|
613
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react22.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react22.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
614
614
|
type DecoratedRange = BaseRange & {
|
|
615
615
|
rangeDecoration: RangeDecoration;
|
|
616
616
|
};
|
|
@@ -1339,7 +1339,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1339
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1340
1340
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1341
1341
|
type: "blurred";
|
|
1342
|
-
event:
|
|
1342
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1343
1343
|
} | {
|
|
1344
1344
|
type: "done loading";
|
|
1345
1345
|
} | {
|
|
@@ -1351,7 +1351,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1351
1351
|
data: unknown;
|
|
1352
1352
|
} | {
|
|
1353
1353
|
type: "focused";
|
|
1354
|
-
event:
|
|
1354
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
1355
1355
|
} | {
|
|
1356
1356
|
type: "invalid value";
|
|
1357
1357
|
resolution: InvalidValueResolution | null;
|
|
@@ -2007,7 +2007,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2007
2007
|
type: "drop";
|
|
2008
2008
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2009
2009
|
type: "blurred";
|
|
2010
|
-
event:
|
|
2010
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2011
2011
|
} | {
|
|
2012
2012
|
type: "done loading";
|
|
2013
2013
|
} | {
|
|
@@ -2019,7 +2019,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2019
2019
|
data: unknown;
|
|
2020
2020
|
} | {
|
|
2021
2021
|
type: "focused";
|
|
2022
|
-
event:
|
|
2022
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2023
2023
|
} | {
|
|
2024
2024
|
type: "invalid value";
|
|
2025
2025
|
resolution: InvalidValueResolution | null;
|
|
@@ -2890,7 +2890,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2890
2890
|
type: "drop";
|
|
2891
2891
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2892
2892
|
type: "blurred";
|
|
2893
|
-
event:
|
|
2893
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2894
2894
|
} | {
|
|
2895
2895
|
type: "done loading";
|
|
2896
2896
|
} | {
|
|
@@ -2902,7 +2902,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2902
2902
|
data: unknown;
|
|
2903
2903
|
} | {
|
|
2904
2904
|
type: "focused";
|
|
2905
|
-
event:
|
|
2905
|
+
event: react22.FocusEvent<HTMLDivElement, Element>;
|
|
2906
2906
|
} | {
|
|
2907
2907
|
type: "invalid value";
|
|
2908
2908
|
resolution: InvalidValueResolution | null;
|
|
@@ -6,7 +6,7 @@ import { AnnotationDefinition, AnnotationSchemaType, BaseDefinition, BlockObject
|
|
|
6
6
|
import * as xstate227 from "xstate";
|
|
7
7
|
import { ActorRef, ActorRefFrom, EventObject, Snapshot } from "xstate";
|
|
8
8
|
import { BaseRange, Descendant, Operation } from "slate";
|
|
9
|
-
import * as
|
|
9
|
+
import * as react20 from "react";
|
|
10
10
|
import React$1, { BaseSyntheticEvent, ClipboardEvent, Component, FocusEvent, JSX, KeyboardEvent as KeyboardEvent$1, MutableRefObject, PropsWithChildren, ReactElement, RefObject, TextareaHTMLAttributes } from "react";
|
|
11
11
|
import * as xstate_guards12 from "xstate/guards";
|
|
12
12
|
import { Observable, Subject } from "rxjs";
|
|
@@ -215,7 +215,7 @@ declare class PortableTextEditor extends Component<PortableTextEditorProps<Inter
|
|
|
215
215
|
componentDidUpdate(prevProps: PortableTextEditorProps): void;
|
|
216
216
|
componentWillUnmount(): void;
|
|
217
217
|
setEditable: (editable: EditableAPI) => void;
|
|
218
|
-
render():
|
|
218
|
+
render(): react20.JSX.Element;
|
|
219
219
|
/**
|
|
220
220
|
* @deprecated
|
|
221
221
|
* Use built-in selectors or write your own: https://www.portabletext.org/reference/selectors/
|
|
@@ -610,7 +610,7 @@ type PortableTextEditableProps = Omit<TextareaHTMLAttributes<HTMLDivElement>, 'o
|
|
|
610
610
|
* ```
|
|
611
611
|
* @group Components
|
|
612
612
|
*/
|
|
613
|
-
declare const PortableTextEditable:
|
|
613
|
+
declare const PortableTextEditable: react20.ForwardRefExoticComponent<Omit<PortableTextEditableProps, "ref"> & react20.RefAttributes<Omit<HTMLDivElement, "as" | "onPaste" | "onBeforeInput">>>;
|
|
614
614
|
type DecoratedRange = BaseRange & {
|
|
615
615
|
rangeDecoration: RangeDecoration;
|
|
616
616
|
};
|
|
@@ -1339,7 +1339,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1339
1339
|
initialValue?: Array<PortableTextBlock>;
|
|
1340
1340
|
}, xstate227.NonReducibleUnknown, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
1341
1341
|
type: "blurred";
|
|
1342
|
-
event:
|
|
1342
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1343
1343
|
} | {
|
|
1344
1344
|
type: "done loading";
|
|
1345
1345
|
} | {
|
|
@@ -1351,7 +1351,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
1351
1351
|
data: unknown;
|
|
1352
1352
|
} | {
|
|
1353
1353
|
type: "focused";
|
|
1354
|
-
event:
|
|
1354
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
1355
1355
|
} | {
|
|
1356
1356
|
type: "invalid value";
|
|
1357
1357
|
resolution: InvalidValueResolution | null;
|
|
@@ -2007,7 +2007,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2007
2007
|
type: "drop";
|
|
2008
2008
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2009
2009
|
type: "blurred";
|
|
2010
|
-
event:
|
|
2010
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2011
2011
|
} | {
|
|
2012
2012
|
type: "done loading";
|
|
2013
2013
|
} | {
|
|
@@ -2019,7 +2019,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2019
2019
|
data: unknown;
|
|
2020
2020
|
} | {
|
|
2021
2021
|
type: "focused";
|
|
2022
|
-
event:
|
|
2022
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2023
2023
|
} | {
|
|
2024
2024
|
type: "invalid value";
|
|
2025
2025
|
resolution: InvalidValueResolution | null;
|
|
@@ -2890,7 +2890,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2890
2890
|
type: "drop";
|
|
2891
2891
|
}, undefined, never, never, never, never, InternalPatchEvent | MutationEvent | PatchesEvent | {
|
|
2892
2892
|
type: "blurred";
|
|
2893
|
-
event:
|
|
2893
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2894
2894
|
} | {
|
|
2895
2895
|
type: "done loading";
|
|
2896
2896
|
} | {
|
|
@@ -2902,7 +2902,7 @@ declare const editorMachine: xstate227.StateMachine<{
|
|
|
2902
2902
|
data: unknown;
|
|
2903
2903
|
} | {
|
|
2904
2904
|
type: "focused";
|
|
2905
|
-
event:
|
|
2905
|
+
event: react20.FocusEvent<HTMLDivElement, Element>;
|
|
2906
2906
|
} | {
|
|
2907
2907
|
type: "invalid value";
|
|
2908
2908
|
resolution: InvalidValueResolution | null;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isTextBlock, isSpan } from "@portabletext/schema";
|
|
2
|
-
import { getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint,
|
|
2
|
+
import { getBlockKeyFromSelectionPoint, getChildKeyFromSelectionPoint, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint, sliceBlocks } from "./util.slice-blocks.js";
|
|
3
3
|
import { isKeySegment } from "@sanity/types";
|
|
4
4
|
const getFocusBlock = (snapshot) => {
|
|
5
5
|
if (!snapshot.context.selection)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getBlockKeyFromSelectionPoint,
|
|
1
|
+
import { getBlockKeyFromSelectionPoint, getSelectionStartPoint, getSelectionEndPoint, getChildKeyFromSelectionPoint } from "./util.slice-blocks.js";
|
|
2
2
|
import { childSelectionPointToBlockOffset } from "./util.child-selection-point-to-block-offset.js";
|
|
3
3
|
import { isSpan } from "@portabletext/schema";
|
|
4
4
|
function selectionPointToBlockOffset({
|