@portabletext/editor 1.14.2 → 1.15.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.
- package/lib/index.cjs +30 -21
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +15 -15
- package/lib/index.d.ts +15 -15
- package/lib/index.js +30 -21
- package/lib/index.js.map +1 -1
- package/package.json +7 -7
- package/src/editor/__tests__/PortableTextEditor.test.tsx +6 -6
- package/src/editor/__tests__/RangeDecorations.test.tsx +1 -1
- package/src/editor/__tests__/handleClick.test.tsx +4 -4
- package/src/editor/__tests__/insert-block.test.tsx +3 -3
- package/src/editor/__tests__/pteWarningsSelfSolving.test.tsx +6 -6
- package/src/editor/__tests__/self-solving.test.tsx +1 -1
- package/src/editor/components/DraggableBlock.tsx +1 -1
- package/src/editor/components/Element.tsx +8 -2
- package/src/editor/components/Leaf.tsx +1 -1
- package/src/editor/create-editor.ts +18 -29
- package/src/editor/hooks/useSyncValue.test.tsx +2 -2
- package/src/editor/hooks/useSyncValue.ts +2 -2
- package/src/editor/nodes/DefaultObject.tsx +1 -0
- package/src/editor/plugins/__tests__/withEditableAPIDelete.test.tsx +4 -4
- package/src/editor/plugins/__tests__/withEditableAPIGetFragment.test.tsx +2 -2
- package/src/editor/plugins/__tests__/withEditableAPIInsert.test.tsx +7 -7
- package/src/editor/plugins/__tests__/withEditableAPISelectionsOverlapping.test.tsx +4 -4
- package/src/editor/plugins/__tests__/withPortableTextLists.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withPortableTextMarkModel.test.tsx +9 -9
- package/src/editor/plugins/__tests__/withPortableTextSelections.test.tsx +1 -1
- package/src/editor/plugins/__tests__/withUndoRedo.test.tsx +2 -2
- package/src/types/editor.ts +14 -13
- package/src/utils/__tests__/valueNormalization.test.tsx +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
import {
|
|
30
30
|
Component,
|
|
31
31
|
ForwardRefExoticComponent,
|
|
32
|
-
JSX
|
|
32
|
+
JSX,
|
|
33
33
|
MutableRefObject,
|
|
34
34
|
PropsWithChildren,
|
|
35
35
|
default as React_2,
|
|
@@ -239,8 +239,8 @@ export declare type BehaviorGuard<
|
|
|
239
239
|
/** @beta */
|
|
240
240
|
export declare interface BlockAnnotationRenderProps {
|
|
241
241
|
block: PortableTextBlock
|
|
242
|
-
children: ReactElement
|
|
243
|
-
editorElementRef: RefObject<HTMLElement>
|
|
242
|
+
children: ReactElement<any>
|
|
243
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
244
244
|
focused: boolean
|
|
245
245
|
path: Path
|
|
246
246
|
schemaType: ObjectSchemaType
|
|
@@ -253,8 +253,8 @@ export declare interface BlockAnnotationRenderProps {
|
|
|
253
253
|
/** @beta */
|
|
254
254
|
export declare interface BlockChildRenderProps {
|
|
255
255
|
annotations: PortableTextObject[]
|
|
256
|
-
children: ReactElement
|
|
257
|
-
editorElementRef: RefObject<HTMLElement>
|
|
256
|
+
children: ReactElement<any>
|
|
257
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
258
258
|
focused: boolean
|
|
259
259
|
path: Path
|
|
260
260
|
selected: boolean
|
|
@@ -266,8 +266,8 @@ export declare interface BlockChildRenderProps {
|
|
|
266
266
|
|
|
267
267
|
/** @beta */
|
|
268
268
|
export declare interface BlockDecoratorRenderProps {
|
|
269
|
-
children: ReactElement
|
|
270
|
-
editorElementRef: RefObject<HTMLElement>
|
|
269
|
+
children: ReactElement<any>
|
|
270
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
271
271
|
focused: boolean
|
|
272
272
|
path: Path
|
|
273
273
|
schemaType: BlockDecoratorDefinition
|
|
@@ -280,8 +280,8 @@ export declare interface BlockDecoratorRenderProps {
|
|
|
280
280
|
/** @beta */
|
|
281
281
|
export declare interface BlockListItemRenderProps {
|
|
282
282
|
block: PortableTextTextBlock
|
|
283
|
-
children: ReactElement
|
|
284
|
-
editorElementRef: RefObject<HTMLElement>
|
|
283
|
+
children: ReactElement<any>
|
|
284
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
285
285
|
focused: boolean
|
|
286
286
|
level: number
|
|
287
287
|
path: Path
|
|
@@ -300,8 +300,8 @@ export declare type BlockOffset = {
|
|
|
300
300
|
|
|
301
301
|
/** @beta */
|
|
302
302
|
export declare interface BlockRenderProps {
|
|
303
|
-
children: ReactElement
|
|
304
|
-
editorElementRef: RefObject<HTMLElement>
|
|
303
|
+
children: ReactElement<any>
|
|
304
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
305
305
|
focused: boolean
|
|
306
306
|
level?: number
|
|
307
307
|
listItem?: string
|
|
@@ -317,8 +317,8 @@ export declare interface BlockRenderProps {
|
|
|
317
317
|
/** @beta */
|
|
318
318
|
export declare interface BlockStyleRenderProps {
|
|
319
319
|
block: PortableTextTextBlock
|
|
320
|
-
children: ReactElement
|
|
321
|
-
editorElementRef: RefObject<HTMLElement>
|
|
320
|
+
children: ReactElement<any>
|
|
321
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
322
322
|
focused: boolean
|
|
323
323
|
path: Path
|
|
324
324
|
selected: boolean
|
|
@@ -9804,7 +9804,7 @@ export declare class PortableTextEditor extends Component<
|
|
|
9804
9804
|
constructor(props: PortableTextEditorProps)
|
|
9805
9805
|
componentDidUpdate(prevProps: PortableTextEditorProps): void
|
|
9806
9806
|
setEditable: (editable: EditableAPI) => void
|
|
9807
|
-
render():
|
|
9807
|
+
render(): JSX.Element
|
|
9808
9808
|
static activeAnnotations: (editor: PortableTextEditor) => PortableTextObject[]
|
|
9809
9809
|
static isAnnotationActive: (
|
|
9810
9810
|
editor: PortableTextEditor,
|
|
@@ -10052,7 +10052,7 @@ export declare interface RangeDecoration {
|
|
|
10052
10052
|
* )
|
|
10053
10053
|
* ```
|
|
10054
10054
|
*/
|
|
10055
|
-
component: (props: PropsWithChildren) => ReactElement
|
|
10055
|
+
component: (props: PropsWithChildren) => ReactElement<any>
|
|
10056
10056
|
/**
|
|
10057
10057
|
* The editor content selection range
|
|
10058
10058
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ import type {
|
|
|
29
29
|
import {
|
|
30
30
|
Component,
|
|
31
31
|
ForwardRefExoticComponent,
|
|
32
|
-
JSX
|
|
32
|
+
JSX,
|
|
33
33
|
MutableRefObject,
|
|
34
34
|
PropsWithChildren,
|
|
35
35
|
default as React_2,
|
|
@@ -239,8 +239,8 @@ export declare type BehaviorGuard<
|
|
|
239
239
|
/** @beta */
|
|
240
240
|
export declare interface BlockAnnotationRenderProps {
|
|
241
241
|
block: PortableTextBlock
|
|
242
|
-
children: ReactElement
|
|
243
|
-
editorElementRef: RefObject<HTMLElement>
|
|
242
|
+
children: ReactElement<any>
|
|
243
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
244
244
|
focused: boolean
|
|
245
245
|
path: Path
|
|
246
246
|
schemaType: ObjectSchemaType
|
|
@@ -253,8 +253,8 @@ export declare interface BlockAnnotationRenderProps {
|
|
|
253
253
|
/** @beta */
|
|
254
254
|
export declare interface BlockChildRenderProps {
|
|
255
255
|
annotations: PortableTextObject[]
|
|
256
|
-
children: ReactElement
|
|
257
|
-
editorElementRef: RefObject<HTMLElement>
|
|
256
|
+
children: ReactElement<any>
|
|
257
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
258
258
|
focused: boolean
|
|
259
259
|
path: Path
|
|
260
260
|
selected: boolean
|
|
@@ -266,8 +266,8 @@ export declare interface BlockChildRenderProps {
|
|
|
266
266
|
|
|
267
267
|
/** @beta */
|
|
268
268
|
export declare interface BlockDecoratorRenderProps {
|
|
269
|
-
children: ReactElement
|
|
270
|
-
editorElementRef: RefObject<HTMLElement>
|
|
269
|
+
children: ReactElement<any>
|
|
270
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
271
271
|
focused: boolean
|
|
272
272
|
path: Path
|
|
273
273
|
schemaType: BlockDecoratorDefinition
|
|
@@ -280,8 +280,8 @@ export declare interface BlockDecoratorRenderProps {
|
|
|
280
280
|
/** @beta */
|
|
281
281
|
export declare interface BlockListItemRenderProps {
|
|
282
282
|
block: PortableTextTextBlock
|
|
283
|
-
children: ReactElement
|
|
284
|
-
editorElementRef: RefObject<HTMLElement>
|
|
283
|
+
children: ReactElement<any>
|
|
284
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
285
285
|
focused: boolean
|
|
286
286
|
level: number
|
|
287
287
|
path: Path
|
|
@@ -300,8 +300,8 @@ export declare type BlockOffset = {
|
|
|
300
300
|
|
|
301
301
|
/** @beta */
|
|
302
302
|
export declare interface BlockRenderProps {
|
|
303
|
-
children: ReactElement
|
|
304
|
-
editorElementRef: RefObject<HTMLElement>
|
|
303
|
+
children: ReactElement<any>
|
|
304
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
305
305
|
focused: boolean
|
|
306
306
|
level?: number
|
|
307
307
|
listItem?: string
|
|
@@ -317,8 +317,8 @@ export declare interface BlockRenderProps {
|
|
|
317
317
|
/** @beta */
|
|
318
318
|
export declare interface BlockStyleRenderProps {
|
|
319
319
|
block: PortableTextTextBlock
|
|
320
|
-
children: ReactElement
|
|
321
|
-
editorElementRef: RefObject<HTMLElement>
|
|
320
|
+
children: ReactElement<any>
|
|
321
|
+
editorElementRef: RefObject<HTMLElement | null>
|
|
322
322
|
focused: boolean
|
|
323
323
|
path: Path
|
|
324
324
|
selected: boolean
|
|
@@ -9804,7 +9804,7 @@ export declare class PortableTextEditor extends Component<
|
|
|
9804
9804
|
constructor(props: PortableTextEditorProps)
|
|
9805
9805
|
componentDidUpdate(prevProps: PortableTextEditorProps): void
|
|
9806
9806
|
setEditable: (editable: EditableAPI) => void
|
|
9807
|
-
render():
|
|
9807
|
+
render(): JSX.Element
|
|
9808
9808
|
static activeAnnotations: (editor: PortableTextEditor) => PortableTextObject[]
|
|
9809
9809
|
static isAnnotationActive: (
|
|
9810
9810
|
editor: PortableTextEditor,
|
|
@@ -10052,7 +10052,7 @@ export declare interface RangeDecoration {
|
|
|
10052
10052
|
* )
|
|
10053
10053
|
* ```
|
|
10054
10054
|
*/
|
|
10055
|
-
component: (props: PropsWithChildren) => ReactElement
|
|
10055
|
+
component: (props: PropsWithChildren) => ReactElement<any>
|
|
10056
10056
|
/**
|
|
10057
10057
|
* The editor content selection range
|
|
10058
10058
|
*/
|
package/lib/index.js
CHANGED
|
@@ -1483,7 +1483,7 @@ const debug$k = debugWithName("components:DraggableBlock"), DraggableBlock = (t0
|
|
|
1483
1483
|
element,
|
|
1484
1484
|
readOnly,
|
|
1485
1485
|
blockRef
|
|
1486
|
-
} = t0, editor = useSlateStatic(), dragGhostRef = useRef(), [isDragOver, setIsDragOver] = useState(!1);
|
|
1486
|
+
} = t0, editor = useSlateStatic(), dragGhostRef = useRef(void 0), [isDragOver, setIsDragOver] = useState(!1);
|
|
1487
1487
|
let t1, t2;
|
|
1488
1488
|
$[0] !== editor || $[1] !== element ? (t2 = Editor.isVoid(editor, element), $[0] = editor, $[1] = element, $[2] = t2) : t2 = $[2], t1 = t2;
|
|
1489
1489
|
const isVoid = t1;
|
|
@@ -3099,7 +3099,7 @@ function useSyncValue(props) {
|
|
|
3099
3099
|
portableTextEditor,
|
|
3100
3100
|
readOnly,
|
|
3101
3101
|
slateEditor
|
|
3102
|
-
} = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = useRef(), updateValueFunctionRef = useRef(), updateFromCurrentValue = useCallback(() => {
|
|
3102
|
+
} = props, schemaTypes = editorActor.getSnapshot().context.schema, previousValue = useRef(void 0), updateValueFunctionRef = useRef(void 0), updateFromCurrentValue = useCallback(() => {
|
|
3103
3103
|
const currentValue = CURRENT_VALUE.get(portableTextEditor);
|
|
3104
3104
|
if (previousValue.current === currentValue) {
|
|
3105
3105
|
debug$i("Value is the same object as previous, not need to sync");
|
|
@@ -6776,7 +6776,7 @@ function createEditor(config) {
|
|
|
6776
6776
|
},
|
|
6777
6777
|
on: (event, listener) => editorActor.on(
|
|
6778
6778
|
event,
|
|
6779
|
-
// @ts-
|
|
6779
|
+
// @ts-expect-error
|
|
6780
6780
|
listener
|
|
6781
6781
|
),
|
|
6782
6782
|
_internal: {
|
|
@@ -6787,26 +6787,35 @@ function createEditor(config) {
|
|
|
6787
6787
|
};
|
|
6788
6788
|
}
|
|
6789
6789
|
function useCreateEditor(config) {
|
|
6790
|
-
const
|
|
6791
|
-
|
|
6792
|
-
|
|
6790
|
+
const $ = c(18);
|
|
6791
|
+
let t0;
|
|
6792
|
+
$[0] !== config ? (t0 = editorConfigToMachineInput(config), $[0] = config, $[1] = t0) : t0 = $[1];
|
|
6793
|
+
let t1;
|
|
6794
|
+
$[2] !== t0 ? (t1 = {
|
|
6795
|
+
input: t0
|
|
6796
|
+
}, $[2] = t0, $[3] = t1) : t1 = $[3];
|
|
6797
|
+
const editorActor = useActorRef(editorMachine, t1);
|
|
6798
|
+
let t2, slateEditor, t3;
|
|
6799
|
+
$[4] !== editorActor ? (slateEditor = createSlateEditor({
|
|
6793
6800
|
editorActor
|
|
6794
|
-
}),
|
|
6801
|
+
}), t3 = createEditableAPI(slateEditor.instance, editorActor), $[4] = editorActor, $[5] = slateEditor, $[6] = t3) : (slateEditor = $[5], t3 = $[6]);
|
|
6802
|
+
const editable = t3;
|
|
6803
|
+
let t4, t5;
|
|
6804
|
+
$[7] !== editorActor ? (t4 = (event) => {
|
|
6795
6805
|
editorActor.send(event);
|
|
6796
|
-
},
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
}), [send, on, editable, editorActor, slateEditor]);
|
|
6806
|
+
}, t5 = (event_0, listener) => editorActor.on(event_0, listener), $[7] = editorActor, $[8] = t4, $[9] = t5) : (t4 = $[8], t5 = $[9]);
|
|
6807
|
+
let t6;
|
|
6808
|
+
$[10] !== editable || $[11] !== editorActor || $[12] !== slateEditor ? (t6 = {
|
|
6809
|
+
editable,
|
|
6810
|
+
editorActor,
|
|
6811
|
+
slateEditor
|
|
6812
|
+
}, $[10] = editable, $[11] = editorActor, $[12] = slateEditor, $[13] = t6) : t6 = $[13];
|
|
6813
|
+
let t7;
|
|
6814
|
+
return $[14] !== t4 || $[15] !== t5 || $[16] !== t6 ? (t7 = {
|
|
6815
|
+
send: t4,
|
|
6816
|
+
on: t5,
|
|
6817
|
+
_internal: t6
|
|
6818
|
+
}, $[14] = t4, $[15] = t5, $[16] = t6, $[17] = t7) : t7 = $[17], t2 = t7, t2;
|
|
6810
6819
|
}
|
|
6811
6820
|
function editorConfigToMachineInput(config) {
|
|
6812
6821
|
return {
|