@portabletext/editor 1.16.0 → 1.16.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/index.cjs +25 -18
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +154 -87
- package/lib/index.d.ts +154 -87
- package/lib/index.js +25 -18
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/editor/PortableTextEditor.tsx +2 -1
- package/src/editor/components/Synchronizer.tsx +1 -1
- package/src/editor/create-editor.ts +4 -1
- package/src/editor/editor-machine.ts +8 -5
- package/src/editor/sync-machine.ts +7 -3
package/lib/index.cjs
CHANGED
|
@@ -2282,8 +2282,8 @@ const syncValueCallback = ({
|
|
|
2282
2282
|
actions: {
|
|
2283
2283
|
"assign readOnly": xstate.assign({
|
|
2284
2284
|
readOnly: ({
|
|
2285
|
-
|
|
2286
|
-
}) =>
|
|
2285
|
+
event
|
|
2286
|
+
}) => (xstate.assertEvent(event, "update readOnly"), event.readOnly)
|
|
2287
2287
|
}),
|
|
2288
2288
|
"assign pending value": xstate.assign({
|
|
2289
2289
|
pendingValue: ({
|
|
@@ -2352,7 +2352,7 @@ const syncValueCallback = ({
|
|
|
2352
2352
|
isProcessingLocalChanges: !1
|
|
2353
2353
|
})
|
|
2354
2354
|
},
|
|
2355
|
-
"
|
|
2355
|
+
"update readOnly": {
|
|
2356
2356
|
actions: ["assign readOnly"]
|
|
2357
2357
|
}
|
|
2358
2358
|
},
|
|
@@ -2642,7 +2642,7 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
|
|
|
2642
2642
|
}
|
|
2643
2643
|
const debug$h = debugWithName("component:PortableTextEditor:Synchronizer");
|
|
2644
2644
|
function Synchronizer(props) {
|
|
2645
|
-
const $ = reactCompilerRuntime.c(
|
|
2645
|
+
const $ = reactCompilerRuntime.c(40), {
|
|
2646
2646
|
editorActor,
|
|
2647
2647
|
slateEditor
|
|
2648
2648
|
} = props, value = react.useSelector(props.editorActor, _temp), readOnly = react.useSelector(props.editorActor, _temp2);
|
|
@@ -2697,23 +2697,22 @@ function Synchronizer(props) {
|
|
|
2697
2697
|
subscription_0.unsubscribe();
|
|
2698
2698
|
};
|
|
2699
2699
|
}, t10 = [props.editorActor, syncActorRef], $[21] = props.editorActor, $[22] = syncActorRef, $[23] = t10, $[24] = t9) : (t10 = $[23], t9 = $[24]), React.useEffect(t9, t10);
|
|
2700
|
-
let t11;
|
|
2701
|
-
$[25] !== syncActorRef ? (t11 = () => {
|
|
2700
|
+
let t11, t12;
|
|
2701
|
+
$[25] !== readOnly || $[26] !== syncActorRef ? (t11 = () => {
|
|
2702
2702
|
syncActorRef.send({
|
|
2703
|
-
type: "
|
|
2703
|
+
type: "update readOnly",
|
|
2704
|
+
readOnly
|
|
2704
2705
|
});
|
|
2705
|
-
}, $[25] =
|
|
2706
|
-
let t12;
|
|
2707
|
-
$[27] !== readOnly || $[28] !== syncActorRef ? (t12 = [syncActorRef, readOnly], $[27] = readOnly, $[28] = syncActorRef, $[29] = t12) : t12 = $[29], React.useEffect(t11, t12);
|
|
2706
|
+
}, t12 = [syncActorRef, readOnly], $[25] = readOnly, $[26] = syncActorRef, $[27] = t11, $[28] = t12) : (t11 = $[27], t12 = $[28]), React.useEffect(t11, t12);
|
|
2708
2707
|
let t13, t14;
|
|
2709
|
-
$[
|
|
2708
|
+
$[29] !== syncActorRef || $[30] !== value ? (t13 = () => {
|
|
2710
2709
|
debug$h("Value from props changed, syncing new value"), syncActorRef.send({
|
|
2711
2710
|
type: "update value",
|
|
2712
2711
|
value
|
|
2713
2712
|
});
|
|
2714
|
-
}, t14 = [syncActorRef, value], $[
|
|
2713
|
+
}, t14 = [syncActorRef, value], $[29] = syncActorRef, $[30] = value, $[31] = t13, $[32] = t14) : (t13 = $[31], t14 = $[32]), React.useEffect(t13, t14);
|
|
2715
2714
|
let t15;
|
|
2716
|
-
$[
|
|
2715
|
+
$[33] !== editorActor || $[34] !== mutationActorRef ? (t15 = () => {
|
|
2717
2716
|
debug$h("Subscribing to patch events");
|
|
2718
2717
|
const sub = editorActor.on("patch", (event_1) => {
|
|
2719
2718
|
mutationActorRef.send(event_1);
|
|
@@ -2721,9 +2720,9 @@ function Synchronizer(props) {
|
|
|
2721
2720
|
return () => {
|
|
2722
2721
|
debug$h("Unsubscribing to patch events"), sub.unsubscribe();
|
|
2723
2722
|
};
|
|
2724
|
-
}, $[
|
|
2723
|
+
}, $[33] = editorActor, $[34] = mutationActorRef, $[35] = t15) : t15 = $[35];
|
|
2725
2724
|
let t16;
|
|
2726
|
-
return $[
|
|
2725
|
+
return $[36] !== editorActor || $[37] !== mutationActorRef || $[38] !== slateEditor ? (t16 = [editorActor, mutationActorRef, slateEditor], $[36] = editorActor, $[37] = mutationActorRef, $[38] = slateEditor, $[39] = t16) : t16 = $[39], React.useEffect(t15, t16), null;
|
|
2727
2726
|
}
|
|
2728
2727
|
function _temp2(s_0) {
|
|
2729
2728
|
return s_0.matches({
|
|
@@ -6179,7 +6178,10 @@ const editorMachine = xstate.setup({
|
|
|
6179
6178
|
},
|
|
6180
6179
|
"read only": {
|
|
6181
6180
|
on: {
|
|
6182
|
-
"
|
|
6181
|
+
"update readOnly": {
|
|
6182
|
+
guard: ({
|
|
6183
|
+
event
|
|
6184
|
+
}) => !event.readOnly,
|
|
6183
6185
|
target: "#editor.edit mode.editable",
|
|
6184
6186
|
actions: ["emit editable"]
|
|
6185
6187
|
}
|
|
@@ -6189,7 +6191,10 @@ const editorMachine = xstate.setup({
|
|
|
6189
6191
|
},
|
|
6190
6192
|
editable: {
|
|
6191
6193
|
on: {
|
|
6192
|
-
"
|
|
6194
|
+
"update readOnly": {
|
|
6195
|
+
guard: ({
|
|
6196
|
+
event
|
|
6197
|
+
}) => event.readOnly,
|
|
6193
6198
|
target: "#editor.edit mode.read only.read only",
|
|
6194
6199
|
actions: ["emit read only"]
|
|
6195
6200
|
},
|
|
@@ -6432,11 +6437,13 @@ class PortableTextEditor extends React.Component {
|
|
|
6432
6437
|
}), this.schemaTypes = this.editor._internal.editorActor.getSnapshot().context.schema, this.editable = this.editor._internal.editable;
|
|
6433
6438
|
}
|
|
6434
6439
|
componentDidUpdate(prevProps) {
|
|
6440
|
+
var _a;
|
|
6435
6441
|
!this.props.editor && !prevProps.editor && this.props.schemaType !== prevProps.schemaType && (this.schemaTypes = createEditorSchema(this.props.schemaType.hasOwnProperty("jsonType") ? this.props.schemaType : compileType(this.props.schemaType)), this.editor._internal.editorActor.send({
|
|
6436
6442
|
type: "update schema",
|
|
6437
6443
|
schema: this.schemaTypes
|
|
6438
6444
|
})), !this.props.editor && !prevProps.editor && (this.props.readOnly !== prevProps.readOnly && this.editor._internal.editorActor.send({
|
|
6439
|
-
type: "
|
|
6445
|
+
type: "update readOnly",
|
|
6446
|
+
readOnly: (_a = this.props.readOnly) != null ? _a : !1
|
|
6440
6447
|
}), this.props.maxBlocks !== prevProps.maxBlocks && this.editor._internal.editorActor.send({
|
|
6441
6448
|
type: "update maxBlocks",
|
|
6442
6449
|
maxBlocks: this.props.maxBlocks === void 0 ? void 0 : Number.parseInt(this.props.maxBlocks.toString(), 10)
|