@portabletext/editor 7.10.8-crx.0 → 7.10.8
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.js +55 -81
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -18471,81 +18471,65 @@ async function updateValue({
|
|
|
18471
18471
|
}) {
|
|
18472
18472
|
let doneSyncing = !1, isChanged = !1, isValid = !0;
|
|
18473
18473
|
const hadSelection = !!editorEngine.snapshot.context.selection;
|
|
18474
|
-
|
|
18475
|
-
|
|
18476
|
-
|
|
18477
|
-
|
|
18478
|
-
|
|
18479
|
-
|
|
18480
|
-
|
|
18481
|
-
|
|
18482
|
-
resolve();
|
|
18483
|
-
return;
|
|
18484
|
-
}
|
|
18485
|
-
isChanged = removeExtraBlocks({
|
|
18486
|
-
editorEngine,
|
|
18487
|
-
value
|
|
18488
|
-
}), (async () => {
|
|
18489
|
-
try {
|
|
18490
|
-
for await (const [currentBlock, currentBlockIndex] of getStreamedBlocks({
|
|
18491
|
-
value
|
|
18492
|
-
})) {
|
|
18493
|
-
const {
|
|
18494
|
-
blockChanged,
|
|
18495
|
-
blockValid
|
|
18496
|
-
} = syncBlock({
|
|
18497
|
-
context,
|
|
18498
|
-
sendBack,
|
|
18499
|
-
block: currentBlock,
|
|
18500
|
-
index: currentBlockIndex,
|
|
18501
|
-
editorEngine,
|
|
18502
|
-
value
|
|
18503
|
-
});
|
|
18504
|
-
if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !isValid)
|
|
18505
|
-
break;
|
|
18506
|
-
}
|
|
18507
|
-
resolve();
|
|
18508
|
-
} catch (error) {
|
|
18509
|
-
reject(error);
|
|
18510
|
-
}
|
|
18511
|
-
})();
|
|
18512
|
-
});
|
|
18513
|
-
else {
|
|
18514
|
-
if (doneSyncing)
|
|
18474
|
+
if ((!value || value.length === 0) && (clearEditor({
|
|
18475
|
+
editorEngine,
|
|
18476
|
+
doneSyncing
|
|
18477
|
+
}), isChanged = !0), value && value.length > 0)
|
|
18478
|
+
if (streamBlocks)
|
|
18479
|
+
await new Promise((resolve) => {
|
|
18480
|
+
if (doneSyncing) {
|
|
18481
|
+
resolve();
|
|
18515
18482
|
return;
|
|
18483
|
+
}
|
|
18516
18484
|
isChanged = removeExtraBlocks({
|
|
18517
18485
|
editorEngine,
|
|
18518
18486
|
value
|
|
18519
|
-
})
|
|
18520
|
-
|
|
18521
|
-
for (const block of value) {
|
|
18522
|
-
const {
|
|
18523
|
-
blockChanged,
|
|
18524
|
-
blockValid
|
|
18525
|
-
} = syncBlock({
|
|
18526
|
-
context,
|
|
18527
|
-
sendBack,
|
|
18528
|
-
block,
|
|
18529
|
-
index,
|
|
18530
|
-
editorEngine,
|
|
18487
|
+
}), (async () => {
|
|
18488
|
+
for await (const [currentBlock, currentBlockIndex] of getStreamedBlocks({
|
|
18531
18489
|
value
|
|
18532
|
-
})
|
|
18533
|
-
|
|
18534
|
-
|
|
18535
|
-
|
|
18536
|
-
|
|
18490
|
+
})) {
|
|
18491
|
+
const {
|
|
18492
|
+
blockChanged,
|
|
18493
|
+
blockValid
|
|
18494
|
+
} = syncBlock({
|
|
18495
|
+
context,
|
|
18496
|
+
sendBack,
|
|
18497
|
+
block: currentBlock,
|
|
18498
|
+
index: currentBlockIndex,
|
|
18499
|
+
editorEngine,
|
|
18500
|
+
value
|
|
18501
|
+
});
|
|
18502
|
+
if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !isValid)
|
|
18503
|
+
break;
|
|
18504
|
+
}
|
|
18505
|
+
resolve();
|
|
18506
|
+
})();
|
|
18507
|
+
});
|
|
18508
|
+
else {
|
|
18509
|
+
if (doneSyncing)
|
|
18510
|
+
return;
|
|
18511
|
+
isChanged = removeExtraBlocks({
|
|
18512
|
+
editorEngine,
|
|
18513
|
+
value
|
|
18514
|
+
});
|
|
18515
|
+
let index = 0;
|
|
18516
|
+
for (const block of value) {
|
|
18517
|
+
const {
|
|
18518
|
+
blockChanged,
|
|
18519
|
+
blockValid
|
|
18520
|
+
} = syncBlock({
|
|
18521
|
+
context,
|
|
18522
|
+
sendBack,
|
|
18523
|
+
block,
|
|
18524
|
+
index,
|
|
18525
|
+
editorEngine,
|
|
18526
|
+
value
|
|
18527
|
+
});
|
|
18528
|
+
if (isChanged = blockChanged || isChanged, isValid = isValid && blockValid, !blockValid)
|
|
18529
|
+
break;
|
|
18530
|
+
index++;
|
|
18537
18531
|
}
|
|
18538
|
-
|
|
18539
|
-
console.error(err), sendBack({
|
|
18540
|
-
type: "invalid value",
|
|
18541
|
-
resolution: null,
|
|
18542
|
-
value
|
|
18543
|
-
}), doneSyncing = !0, sendBack({
|
|
18544
|
-
type: "done syncing",
|
|
18545
|
-
value
|
|
18546
|
-
});
|
|
18547
|
-
return;
|
|
18548
|
-
}
|
|
18532
|
+
}
|
|
18549
18533
|
if (!isValid) {
|
|
18550
18534
|
debug.syncValue("Invalid value, returning"), doneSyncing = !0, sendBack({
|
|
18551
18535
|
type: "done syncing",
|
|
@@ -18794,10 +18778,6 @@ function updateBlock({
|
|
|
18794
18778
|
const childNode = oldEngineBlock.children[childIndex];
|
|
18795
18779
|
if (!childNode)
|
|
18796
18780
|
return;
|
|
18797
|
-
if (!liveBlockHasChildKey(editorEngine, oldEngineBlock._key, childNode._key)) {
|
|
18798
|
-
debug.syncValue("Skipping superfluous-child unset; _key not present in live children", childNode._key);
|
|
18799
|
-
return;
|
|
18800
|
-
}
|
|
18801
18781
|
editorEngine.apply({
|
|
18802
18782
|
type: "unset",
|
|
18803
18783
|
path: [{
|
|
@@ -18848,14 +18828,14 @@ function updateBlock({
|
|
|
18848
18828
|
const oldChild = oldEngineBlock.children[currentBlockChildIndex];
|
|
18849
18829
|
if (!oldChild)
|
|
18850
18830
|
return;
|
|
18851
|
-
|
|
18831
|
+
editorEngine.apply({
|
|
18852
18832
|
type: "unset",
|
|
18853
18833
|
path: [{
|
|
18854
18834
|
_key: oldEngineBlock._key
|
|
18855
18835
|
}, "children", {
|
|
18856
18836
|
_key: oldChild._key
|
|
18857
18837
|
}]
|
|
18858
|
-
})
|
|
18838
|
+
});
|
|
18859
18839
|
const prevSibling = currentBlockChildIndex > 0 ? engineBlock.children[currentBlockChildIndex - 1] : void 0;
|
|
18860
18840
|
prevSibling ? editorEngine.apply({
|
|
18861
18841
|
type: "insert",
|
|
@@ -18899,12 +18879,6 @@ function updateBlock({
|
|
|
18899
18879
|
});
|
|
18900
18880
|
}
|
|
18901
18881
|
}
|
|
18902
|
-
function liveBlockHasChildKey(editorEngine, blockKey, childKey) {
|
|
18903
|
-
const liveBlock = editorEngine.snapshot.context.value.find((node) => node._key === blockKey);
|
|
18904
|
-
return !liveBlock || !isTextBlock({
|
|
18905
|
-
schema: editorEngine.snapshot.context.schema
|
|
18906
|
-
}, liveBlock) ? !1 : liveBlock.children.some((child) => child._key === childKey);
|
|
18907
|
-
}
|
|
18908
18882
|
function createInternalEditor(config) {
|
|
18909
18883
|
debug.setup("creating new editor instance");
|
|
18910
18884
|
const subscriptions = [], editorActor = createActor(editorMachine, {
|