@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.js
CHANGED
|
@@ -2302,8 +2302,8 @@ const syncValueCallback = ({
|
|
|
2302
2302
|
actions: {
|
|
2303
2303
|
"assign readOnly": assign({
|
|
2304
2304
|
readOnly: ({
|
|
2305
|
-
|
|
2306
|
-
}) =>
|
|
2305
|
+
event
|
|
2306
|
+
}) => (assertEvent(event, "update readOnly"), event.readOnly)
|
|
2307
2307
|
}),
|
|
2308
2308
|
"assign pending value": assign({
|
|
2309
2309
|
pendingValue: ({
|
|
@@ -2372,7 +2372,7 @@ const syncValueCallback = ({
|
|
|
2372
2372
|
isProcessingLocalChanges: !1
|
|
2373
2373
|
})
|
|
2374
2374
|
},
|
|
2375
|
-
"
|
|
2375
|
+
"update readOnly": {
|
|
2376
2376
|
actions: ["assign readOnly"]
|
|
2377
2377
|
}
|
|
2378
2378
|
},
|
|
@@ -2662,7 +2662,7 @@ function _updateBlock(slateEditor, currentBlock, oldBlock, currentBlockIndex) {
|
|
|
2662
2662
|
}
|
|
2663
2663
|
const debug$h = debugWithName("component:PortableTextEditor:Synchronizer");
|
|
2664
2664
|
function Synchronizer(props) {
|
|
2665
|
-
const $ = c(
|
|
2665
|
+
const $ = c(40), {
|
|
2666
2666
|
editorActor,
|
|
2667
2667
|
slateEditor
|
|
2668
2668
|
} = props, value = useSelector(props.editorActor, _temp), readOnly = useSelector(props.editorActor, _temp2);
|
|
@@ -2717,23 +2717,22 @@ function Synchronizer(props) {
|
|
|
2717
2717
|
subscription_0.unsubscribe();
|
|
2718
2718
|
};
|
|
2719
2719
|
}, t10 = [props.editorActor, syncActorRef], $[21] = props.editorActor, $[22] = syncActorRef, $[23] = t10, $[24] = t9) : (t10 = $[23], t9 = $[24]), useEffect(t9, t10);
|
|
2720
|
-
let t11;
|
|
2721
|
-
$[25] !== syncActorRef ? (t11 = () => {
|
|
2720
|
+
let t11, t12;
|
|
2721
|
+
$[25] !== readOnly || $[26] !== syncActorRef ? (t11 = () => {
|
|
2722
2722
|
syncActorRef.send({
|
|
2723
|
-
type: "
|
|
2723
|
+
type: "update readOnly",
|
|
2724
|
+
readOnly
|
|
2724
2725
|
});
|
|
2725
|
-
}, $[25] =
|
|
2726
|
-
let t12;
|
|
2727
|
-
$[27] !== readOnly || $[28] !== syncActorRef ? (t12 = [syncActorRef, readOnly], $[27] = readOnly, $[28] = syncActorRef, $[29] = t12) : t12 = $[29], useEffect(t11, t12);
|
|
2726
|
+
}, t12 = [syncActorRef, readOnly], $[25] = readOnly, $[26] = syncActorRef, $[27] = t11, $[28] = t12) : (t11 = $[27], t12 = $[28]), useEffect(t11, t12);
|
|
2728
2727
|
let t13, t14;
|
|
2729
|
-
$[
|
|
2728
|
+
$[29] !== syncActorRef || $[30] !== value ? (t13 = () => {
|
|
2730
2729
|
debug$h("Value from props changed, syncing new value"), syncActorRef.send({
|
|
2731
2730
|
type: "update value",
|
|
2732
2731
|
value
|
|
2733
2732
|
});
|
|
2734
|
-
}, t14 = [syncActorRef, value], $[
|
|
2733
|
+
}, t14 = [syncActorRef, value], $[29] = syncActorRef, $[30] = value, $[31] = t13, $[32] = t14) : (t13 = $[31], t14 = $[32]), useEffect(t13, t14);
|
|
2735
2734
|
let t15;
|
|
2736
|
-
$[
|
|
2735
|
+
$[33] !== editorActor || $[34] !== mutationActorRef ? (t15 = () => {
|
|
2737
2736
|
debug$h("Subscribing to patch events");
|
|
2738
2737
|
const sub = editorActor.on("patch", (event_1) => {
|
|
2739
2738
|
mutationActorRef.send(event_1);
|
|
@@ -2741,9 +2740,9 @@ function Synchronizer(props) {
|
|
|
2741
2740
|
return () => {
|
|
2742
2741
|
debug$h("Unsubscribing to patch events"), sub.unsubscribe();
|
|
2743
2742
|
};
|
|
2744
|
-
}, $[
|
|
2743
|
+
}, $[33] = editorActor, $[34] = mutationActorRef, $[35] = t15) : t15 = $[35];
|
|
2745
2744
|
let t16;
|
|
2746
|
-
return $[
|
|
2745
|
+
return $[36] !== editorActor || $[37] !== mutationActorRef || $[38] !== slateEditor ? (t16 = [editorActor, mutationActorRef, slateEditor], $[36] = editorActor, $[37] = mutationActorRef, $[38] = slateEditor, $[39] = t16) : t16 = $[39], useEffect(t15, t16), null;
|
|
2747
2746
|
}
|
|
2748
2747
|
function _temp2(s_0) {
|
|
2749
2748
|
return s_0.matches({
|
|
@@ -6199,7 +6198,10 @@ const editorMachine = setup({
|
|
|
6199
6198
|
},
|
|
6200
6199
|
"read only": {
|
|
6201
6200
|
on: {
|
|
6202
|
-
"
|
|
6201
|
+
"update readOnly": {
|
|
6202
|
+
guard: ({
|
|
6203
|
+
event
|
|
6204
|
+
}) => !event.readOnly,
|
|
6203
6205
|
target: "#editor.edit mode.editable",
|
|
6204
6206
|
actions: ["emit editable"]
|
|
6205
6207
|
}
|
|
@@ -6209,7 +6211,10 @@ const editorMachine = setup({
|
|
|
6209
6211
|
},
|
|
6210
6212
|
editable: {
|
|
6211
6213
|
on: {
|
|
6212
|
-
"
|
|
6214
|
+
"update readOnly": {
|
|
6215
|
+
guard: ({
|
|
6216
|
+
event
|
|
6217
|
+
}) => event.readOnly,
|
|
6213
6218
|
target: "#editor.edit mode.read only.read only",
|
|
6214
6219
|
actions: ["emit read only"]
|
|
6215
6220
|
},
|
|
@@ -6452,11 +6457,13 @@ class PortableTextEditor extends Component {
|
|
|
6452
6457
|
}), this.schemaTypes = this.editor._internal.editorActor.getSnapshot().context.schema, this.editable = this.editor._internal.editable;
|
|
6453
6458
|
}
|
|
6454
6459
|
componentDidUpdate(prevProps) {
|
|
6460
|
+
var _a;
|
|
6455
6461
|
!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({
|
|
6456
6462
|
type: "update schema",
|
|
6457
6463
|
schema: this.schemaTypes
|
|
6458
6464
|
})), !this.props.editor && !prevProps.editor && (this.props.readOnly !== prevProps.readOnly && this.editor._internal.editorActor.send({
|
|
6459
|
-
type: "
|
|
6465
|
+
type: "update readOnly",
|
|
6466
|
+
readOnly: (_a = this.props.readOnly) != null ? _a : !1
|
|
6460
6467
|
}), this.props.maxBlocks !== prevProps.maxBlocks && this.editor._internal.editorActor.send({
|
|
6461
6468
|
type: "update maxBlocks",
|
|
6462
6469
|
maxBlocks: this.props.maxBlocks === void 0 ? void 0 : Number.parseInt(this.props.maxBlocks.toString(), 10)
|