@portabletext/editor 1.0.12 → 1.0.13
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.esm.js +21 -17
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +21 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +21 -17
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/editor/plugins/createWithPortableTextMarkModel.ts +17 -13
- package/src/editor/plugins/index.ts +5 -1
- package/src/utils/operationToPatches.ts +0 -1
package/lib/index.js
CHANGED
|
@@ -698,7 +698,6 @@ function compileType(rawType) {
|
|
|
698
698
|
}).get(rawType.name);
|
|
699
699
|
}
|
|
700
700
|
const debug$k = debugWithName("operationToPatches");
|
|
701
|
-
debug$k.enabled = !1;
|
|
702
701
|
function createOperationToPatches(types2) {
|
|
703
702
|
const textBlockName = types2.block.name;
|
|
704
703
|
function insertTextPatch(editor, operation, beforeValue) {
|
|
@@ -2729,7 +2728,7 @@ function isPortableTextBlock(node) {
|
|
|
2729
2728
|
);
|
|
2730
2729
|
}
|
|
2731
2730
|
const debug$c = debugWithName("plugin:withPortableTextMarkModel");
|
|
2732
|
-
function createWithPortableTextMarkModel(types2, change
|
|
2731
|
+
function createWithPortableTextMarkModel(types2, change$, keyGenerator) {
|
|
2733
2732
|
return function(editor) {
|
|
2734
2733
|
const { apply: apply2, normalizeNode } = editor, decorators = types2.decorators.map((t) => t.value), forceNewSelection = () => {
|
|
2735
2734
|
editor.selection && (slate.Transforms.select(editor, { ...editor.selection }), editor.selection = { ...editor.selection });
|
|
@@ -2819,18 +2818,15 @@ function createWithPortableTextMarkModel(types2, change$) {
|
|
|
2819
2818
|
})
|
|
2820
2819
|
)[0] || [void 0];
|
|
2821
2820
|
if (slate.Text.isText(node) && node.text.length === selection.focus.offset && Array.isArray(node.marks) && node.marks.length > 0) {
|
|
2822
|
-
apply2(op), slate.Transforms.splitNodes(editor, {
|
|
2823
|
-
match: slate.Text.isText,
|
|
2824
|
-
at: { ...selection.focus, offset: selection.focus.offset }
|
|
2825
|
-
});
|
|
2826
2821
|
const marksWithoutAnnotationMarks = ({
|
|
2827
2822
|
...slate.Editor.marks(editor) || {}
|
|
2828
2823
|
}.marks || []).filter((mark) => decorators.includes(mark));
|
|
2829
|
-
slate.Transforms.
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2824
|
+
slate.Transforms.insertNodes(editor, {
|
|
2825
|
+
_type: "span",
|
|
2826
|
+
_key: keyGenerator(),
|
|
2827
|
+
text: op.text,
|
|
2828
|
+
marks: marksWithoutAnnotationMarks
|
|
2829
|
+
}), debug$c("Inserting text at end of annotation");
|
|
2834
2830
|
return;
|
|
2835
2831
|
}
|
|
2836
2832
|
}
|
|
@@ -2949,18 +2945,22 @@ function createWithPortableTextMarkModel(types2, change$) {
|
|
|
2949
2945
|
};
|
|
2950
2946
|
function mergeSpans(editor) {
|
|
2951
2947
|
const { selection } = editor;
|
|
2952
|
-
if (selection)
|
|
2953
|
-
|
|
2948
|
+
if (selection) {
|
|
2949
|
+
const textNodesInSelection = Array.from(
|
|
2954
2950
|
slate.Editor.nodes(editor, {
|
|
2955
|
-
at: slate.Editor.range(editor, [selection.anchor.path[0]], [selection.focus.path[0]])
|
|
2951
|
+
at: slate.Editor.range(editor, [selection.anchor.path[0]], [selection.focus.path[0]]),
|
|
2952
|
+
match: slate.Text.isText,
|
|
2953
|
+
reverse: !0
|
|
2956
2954
|
})
|
|
2957
|
-
)
|
|
2955
|
+
);
|
|
2956
|
+
for (const [node, path] of textNodesInSelection) {
|
|
2958
2957
|
const [parent] = path.length > 1 ? slate.Editor.node(editor, slate.Path.parent(path)) : [void 0], nextPath = [path[0], path[1] + 1];
|
|
2959
2958
|
if (editor.isTextBlock(parent)) {
|
|
2960
2959
|
const nextNode = parent.children[nextPath[1]];
|
|
2961
|
-
slate.Text.isText(
|
|
2960
|
+
slate.Text.isText(nextNode) && isEqual__default.default(nextNode.marks, node.marks) && (debug$c("Merging spans"), slate.Transforms.mergeNodes(editor, { at: nextPath, voids: !0 }), editor.onChange());
|
|
2962
2961
|
}
|
|
2963
2962
|
}
|
|
2963
|
+
}
|
|
2964
2964
|
}
|
|
2965
2965
|
}
|
|
2966
2966
|
const debug$b = debugWithName("plugin:withPortableTextSelections"), debugVerbose$2 = debug$b.enabled && !1;
|
|
@@ -3641,7 +3641,11 @@ const originalFnMap = /* @__PURE__ */ new WeakMap(), withPlugins = (editor, opti
|
|
|
3641
3641
|
readOnly,
|
|
3642
3642
|
patches$,
|
|
3643
3643
|
blockSchemaType: schemaTypes.block
|
|
3644
|
-
}), withPortableTextMarkModel = createWithPortableTextMarkModel(
|
|
3644
|
+
}), withPortableTextMarkModel = createWithPortableTextMarkModel(
|
|
3645
|
+
schemaTypes,
|
|
3646
|
+
change$,
|
|
3647
|
+
keyGenerator
|
|
3648
|
+
), withPortableTextBlockStyle = createWithPortableTextBlockStyle(schemaTypes), withPlaceholderBlock = createWithPlaceholderBlock(), withInsertBreak = createWithInsertBreak(schemaTypes), withUtils = createWithUtils({ keyGenerator, schemaTypes, portableTextEditor }), withPortableTextSelections = createWithPortableTextSelections(change$, schemaTypes);
|
|
3645
3649
|
return e.destroy = () => {
|
|
3646
3650
|
const originalFunctions = originalFnMap.get(e);
|
|
3647
3651
|
if (!originalFunctions)
|