@portabletext/editor 3.3.5 → 3.3.7
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/_chunks-dts/index.d.ts +9 -9
- package/lib/_chunks-es/util.slice-blocks.js +3 -3
- package/lib/_chunks-es/util.slice-blocks.js.map +1 -1
- package/lib/index.js +279 -58
- package/lib/index.js.map +1 -1
- package/lib/plugins/index.js +1 -1
- package/lib/plugins/index.js.map +1 -1
- package/package.json +9 -13
package/lib/index.js
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { c } from "react-compiler-runtime";
|
|
3
3
|
import { useSelector, useActorRef } from "@xstate/react";
|
|
4
|
-
import noop from "lodash/noop.js";
|
|
5
4
|
import { createContext, useContext, useEffect, useState, useRef, forwardRef, Component, startTransition } from "react";
|
|
6
5
|
import { Element as Element$1, Text, Range, Editor, Node, Point, Path, Transforms, Operation, deleteText, createEditor } from "slate";
|
|
7
6
|
import { useSelected, useSlateSelector, useSlateStatic, ReactEditor, useSlate, Editable, withReact, Slate } from "slate-react";
|
|
8
7
|
import debug$h from "debug";
|
|
9
8
|
import { DOMEditor, isDOMNode, EDITOR_TO_PENDING_SELECTION, IS_FOCUSED, IS_READ_ONLY } from "slate-dom";
|
|
10
|
-
import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject,
|
|
11
|
-
import isEqual from "lodash/isEqual.js";
|
|
9
|
+
import { getBlockEndPoint, getBlockStartPoint, getBlockKeyFromSelectionPoint, isSelectionCollapsed, isKeyedSegment, isEqualSelectionPoints, getChildKeyFromSelectionPoint, blockOffsetToSpanSelectionPoint, defaultKeyGenerator, parseBlocks, parseBlock, parseAnnotation, parseMarkDefs, parseSpan, parseInlineObject, isListBlock, isTypedObject, getSelectionStartPoint, getSelectionEndPoint } from "./_chunks-es/util.slice-blocks.js";
|
|
12
10
|
import { isTextBlock, isSpan, compileSchema } from "@portabletext/schema";
|
|
13
11
|
import { defineSchema } from "@portabletext/schema";
|
|
14
12
|
import { isEmptyTextBlock, sliceTextBlock, getTextBlockText } from "./_chunks-es/util.slice-text-block.js";
|
|
15
13
|
import { getFocusInlineObject, isSelectionCollapsed as isSelectionCollapsed$1, getFocusTextBlock, getFocusSpan as getFocusSpan$1, getSelectedBlocks, isSelectionExpanded, getSelectionStartBlock, getSelectionEndBlock, isOverlappingSelection, getFocusBlock as getFocusBlock$1, isSelectingEntireBlocks, getSelectedValue, getActiveDecorators, isActiveAnnotation, getCaretWordSelection, getFocusBlockObject, getPreviousBlock, getNextBlock, getMarkState, getActiveAnnotationsMarks, isAtTheEndOfBlock, isAtTheStartOfBlock, getFirstBlock as getFirstBlock$1, getLastBlock as getLastBlock$1, getFocusListBlock, getSelectionStartPoint as getSelectionStartPoint$1, getSelectionEndPoint as getSelectionEndPoint$1, isActiveDecorator, getFocusChild as getFocusChild$1, getActiveAnnotations, getSelectedTextBlocks, isActiveListItem, isActiveStyle } from "./_chunks-es/selector.is-at-the-start-of-block.js";
|
|
16
14
|
import { defineBehavior, forward, raise, effect } from "./behaviors/index.js";
|
|
17
|
-
import uniq from "lodash/uniq.js";
|
|
18
15
|
import { setup, fromCallback, assign, and, enqueueActions, emit, assertEvent, raise as raise$1, not, createActor } from "xstate";
|
|
19
16
|
import { compileSchemaDefinitionToPortableTextMemberSchemaTypes, createPortableTextMemberSchemaTypes, portableTextMemberSchemaTypesToSchema } from "@portabletext/sanity-bridge";
|
|
20
17
|
import { htmlToBlocks } from "@portabletext/block-tools";
|
|
21
18
|
import { toHTML } from "@portabletext/to-html";
|
|
22
19
|
import { markdownToPortableText, portableTextToMarkdown } from "@portabletext/markdown";
|
|
23
20
|
import { Schema } from "@sanity/schema";
|
|
24
|
-
import flatten from "lodash/flatten.js";
|
|
25
21
|
import { set, applyAll, unset, insert, setIfMissing, diffMatchPatch as diffMatchPatch$1 } from "@portabletext/patches";
|
|
26
22
|
import { createKeyboardShortcut, code, underline, italic, bold, undo, redo } from "@portabletext/keyboard-shortcuts";
|
|
27
|
-
import isPlainObject from "lodash/isPlainObject.js";
|
|
28
23
|
import { EditorContext } from "./_chunks-es/use-editor.js";
|
|
29
24
|
import { useEditor } from "./_chunks-es/use-editor.js";
|
|
30
25
|
import { Subject } from "rxjs";
|
|
@@ -34,10 +29,144 @@ function debugWithName(name) {
|
|
|
34
29
|
const namespace = `${rootName}${name}`;
|
|
35
30
|
return debug$h && debug$h.enabled(namespace) ? debug$h(namespace) : debug$h(rootName);
|
|
36
31
|
}
|
|
32
|
+
function isEqualValues(context, a, b) {
|
|
33
|
+
if (!a || !b)
|
|
34
|
+
return a === b;
|
|
35
|
+
if (a.length !== b.length)
|
|
36
|
+
return !1;
|
|
37
|
+
for (let index = 0; index < a.length; index++) {
|
|
38
|
+
const blockA = a.at(index), blockB = b.at(index);
|
|
39
|
+
if (!blockA || !blockB || !isEqualBlocks(context, blockA, blockB))
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
return !0;
|
|
43
|
+
}
|
|
44
|
+
function isEqualBlocks(context, a, b) {
|
|
45
|
+
return a._type !== b._type ? !1 : a._type === context.schema.block.name && b._type === context.schema.block.name ? isEqualTextBlocks(context, a, b) : isEqualPortableTextObjects(a, b);
|
|
46
|
+
}
|
|
47
|
+
function isEqualTextBlocks(context, a, b) {
|
|
48
|
+
return !isTextBlock(context, a) || !isTextBlock(context, b) || a._key !== b._key || a.style !== b.style || a.listItem !== b.listItem || a.level !== b.level || "markDefs" in a && "markDefs" in b && (!Array.isArray(a.markDefs) || !Array.isArray(b.markDefs) || !isEqualMarkDefs(a.markDefs, b.markDefs)) || !isEqualChildren(a.children, b.children) ? !1 : isEqualProps(a, b, ["_key", "_type", "style", "listItem", "level", "markDefs", "children"]);
|
|
49
|
+
}
|
|
50
|
+
function isEqualProps(a, b, excludeKeys) {
|
|
51
|
+
const keysA = Object.keys(a).filter((key) => !excludeKeys.includes(key)), keysB = Object.keys(b).filter((key) => !excludeKeys.includes(key));
|
|
52
|
+
if (keysA.length !== keysB.length)
|
|
53
|
+
return !1;
|
|
54
|
+
for (const key of keysA) {
|
|
55
|
+
if (!(key in a) || !(key in b))
|
|
56
|
+
return !1;
|
|
57
|
+
const valueA = a[key], valueB = b[key];
|
|
58
|
+
if (valueA !== valueB && !isDeepEqual(valueA, valueB))
|
|
59
|
+
return !1;
|
|
60
|
+
}
|
|
61
|
+
return !0;
|
|
62
|
+
}
|
|
63
|
+
function isEqualInlineObjects(a, b) {
|
|
64
|
+
return a._key !== b._key || a._type !== b._type ? !1 : isEqualProps(a, b, ["_key", "_type"]);
|
|
65
|
+
}
|
|
66
|
+
function isEqualMarks(a, b) {
|
|
67
|
+
if (!a || !b)
|
|
68
|
+
return a === b;
|
|
69
|
+
if (a.length !== b.length)
|
|
70
|
+
return !1;
|
|
71
|
+
for (let index = 0; index < a.length; index++)
|
|
72
|
+
if (a.at(index) !== b.at(index))
|
|
73
|
+
return !1;
|
|
74
|
+
return !0;
|
|
75
|
+
}
|
|
76
|
+
function isEqualSpans(a, b) {
|
|
77
|
+
return a._key !== b._key || a._type !== b._type || a.text !== b.text || !isEqualMarks(a.marks, b.marks) ? !1 : isEqualProps(a, b, ["_key", "_type", "text", "marks"]);
|
|
78
|
+
}
|
|
79
|
+
function isEqualMarkDefs(a, b) {
|
|
80
|
+
if (a.length !== b.length)
|
|
81
|
+
return !1;
|
|
82
|
+
for (let index = 0; index < a.length; index++) {
|
|
83
|
+
const markDefA = a.at(index), markDefB = b.at(index);
|
|
84
|
+
if (!markDefA || !markDefB || !isDeepEqual(markDefA, markDefB))
|
|
85
|
+
return !1;
|
|
86
|
+
}
|
|
87
|
+
return !0;
|
|
88
|
+
}
|
|
89
|
+
function isEqualChildren(a, b) {
|
|
90
|
+
if (a.length !== b.length)
|
|
91
|
+
return !1;
|
|
92
|
+
for (let index = 0; index < a.length; index++) {
|
|
93
|
+
const childA = a.at(index), childB = b.at(index);
|
|
94
|
+
if (!childA || !childB || !isEqualChild(childA, childB))
|
|
95
|
+
return !1;
|
|
96
|
+
}
|
|
97
|
+
return !0;
|
|
98
|
+
}
|
|
99
|
+
function isEqualChild(a, b) {
|
|
100
|
+
return a._type === "span" && b._type === "span" ? isEqualSpans(a, b) : isEqualInlineObjects(a, b);
|
|
101
|
+
}
|
|
102
|
+
function isEqualPortableTextObjects(a, b) {
|
|
103
|
+
return a._key !== b._key || a._type !== b._type ? !1 : isEqualProps(a, b, ["_key", "_type"]);
|
|
104
|
+
}
|
|
105
|
+
function isDeepEqual(data, other) {
|
|
106
|
+
return isDeepEqualImplementation(data, other);
|
|
107
|
+
}
|
|
108
|
+
function isDeepEqualImplementation(data, other) {
|
|
109
|
+
if (data === other || Object.is(data, other))
|
|
110
|
+
return !0;
|
|
111
|
+
if (typeof data != "object" || typeof other != "object" || data === null || other === null || Object.getPrototypeOf(data) !== Object.getPrototypeOf(other))
|
|
112
|
+
return !1;
|
|
113
|
+
if (Array.isArray(data))
|
|
114
|
+
return isDeepEqualArrays(data, other);
|
|
115
|
+
if (data instanceof Map)
|
|
116
|
+
return isDeepEqualMaps(data, other);
|
|
117
|
+
if (data instanceof Set)
|
|
118
|
+
return isDeepEqualSets(data, other);
|
|
119
|
+
if (data instanceof Date)
|
|
120
|
+
return data.getTime() === other.getTime();
|
|
121
|
+
if (data instanceof RegExp)
|
|
122
|
+
return data.toString() === other.toString();
|
|
123
|
+
if (Object.keys(data).length !== Object.keys(other).length)
|
|
124
|
+
return !1;
|
|
125
|
+
for (const [key, value] of Object.entries(data))
|
|
126
|
+
if (!(key in other) || !isDeepEqualImplementation(
|
|
127
|
+
value,
|
|
128
|
+
// @ts-expect-error [ts7053] - We already checked that `other` has `key`
|
|
129
|
+
other[key]
|
|
130
|
+
))
|
|
131
|
+
return !1;
|
|
132
|
+
return !0;
|
|
133
|
+
}
|
|
134
|
+
function isDeepEqualArrays(data, other) {
|
|
135
|
+
if (data.length !== other.length)
|
|
136
|
+
return !1;
|
|
137
|
+
for (const [index, item] of data.entries())
|
|
138
|
+
if (!isDeepEqualImplementation(item, other[index]))
|
|
139
|
+
return !1;
|
|
140
|
+
return !0;
|
|
141
|
+
}
|
|
142
|
+
function isDeepEqualMaps(data, other) {
|
|
143
|
+
if (data.size !== other.size)
|
|
144
|
+
return !1;
|
|
145
|
+
for (const [key, value] of data.entries())
|
|
146
|
+
if (!other.has(key) || !isDeepEqualImplementation(value, other.get(key)))
|
|
147
|
+
return !1;
|
|
148
|
+
return !0;
|
|
149
|
+
}
|
|
150
|
+
function isDeepEqualSets(data, other) {
|
|
151
|
+
if (data.size !== other.size)
|
|
152
|
+
return !1;
|
|
153
|
+
const otherCopy = [...other];
|
|
154
|
+
for (const dataItem of data) {
|
|
155
|
+
let isFound = !1;
|
|
156
|
+
for (const [index, otherItem] of otherCopy.entries())
|
|
157
|
+
if (isDeepEqualImplementation(dataItem, otherItem)) {
|
|
158
|
+
isFound = !0, otherCopy.splice(index, 1);
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
if (!isFound)
|
|
162
|
+
return !1;
|
|
163
|
+
}
|
|
164
|
+
return !0;
|
|
165
|
+
}
|
|
37
166
|
const VOID_CHILD_KEY = "void-child";
|
|
38
|
-
function keepObjectEquality(object, keyMap) {
|
|
167
|
+
function keepObjectEquality(context, object, keyMap) {
|
|
39
168
|
const value = keyMap[object._key];
|
|
40
|
-
return value &&
|
|
169
|
+
return value && isEqualBlocks(context, object, value) ? value : (keyMap[object._key] = object, object);
|
|
41
170
|
}
|
|
42
171
|
function toSlateBlock(block, {
|
|
43
172
|
schemaTypes
|
|
@@ -61,6 +190,8 @@ function toSlateBlock(block, {
|
|
|
61
190
|
_type: schemaTypes.span.name,
|
|
62
191
|
text: childProps.text
|
|
63
192
|
} : childType !== schemaTypes.span.name ? (hasInlines = !0, keepObjectEquality({
|
|
193
|
+
schema: schemaTypes
|
|
194
|
+
}, {
|
|
64
195
|
_type: childType,
|
|
65
196
|
_key: childKey,
|
|
66
197
|
children: [{
|
|
@@ -74,6 +205,8 @@ function toSlateBlock(block, {
|
|
|
74
205
|
}, keyMap)) : child;
|
|
75
206
|
});
|
|
76
207
|
return !hasMissingMarkDefs && !hasMissingChildren && !hasInlines && Element$1.isElement(block) ? block : keepObjectEquality({
|
|
208
|
+
schema: schemaTypes
|
|
209
|
+
}, {
|
|
77
210
|
_type,
|
|
78
211
|
_key,
|
|
79
212
|
...rest,
|
|
@@ -81,6 +214,8 @@ function toSlateBlock(block, {
|
|
|
81
214
|
}, keyMap);
|
|
82
215
|
}
|
|
83
216
|
return keepObjectEquality({
|
|
217
|
+
schema: schemaTypes
|
|
218
|
+
}, {
|
|
84
219
|
_type,
|
|
85
220
|
_key,
|
|
86
221
|
children: [{
|
|
@@ -92,7 +227,7 @@ function toSlateBlock(block, {
|
|
|
92
227
|
value: rest
|
|
93
228
|
}, keyMap);
|
|
94
229
|
}
|
|
95
|
-
function fromSlateBlock(block, textBlockType, keyMap = {}) {
|
|
230
|
+
function fromSlateBlock(context, block, textBlockType, keyMap = {}) {
|
|
96
231
|
const {
|
|
97
232
|
_key,
|
|
98
233
|
_type
|
|
@@ -115,7 +250,7 @@ function fromSlateBlock(block, textBlockType, keyMap = {}) {
|
|
|
115
250
|
children: _c,
|
|
116
251
|
...rest
|
|
117
252
|
} = child;
|
|
118
|
-
return keepObjectEquality({
|
|
253
|
+
return keepObjectEquality(context, {
|
|
119
254
|
...rest,
|
|
120
255
|
...v,
|
|
121
256
|
_key: k,
|
|
@@ -124,7 +259,7 @@ function fromSlateBlock(block, textBlockType, keyMap = {}) {
|
|
|
124
259
|
}
|
|
125
260
|
return child;
|
|
126
261
|
});
|
|
127
|
-
return hasInlines ? keepObjectEquality({
|
|
262
|
+
return hasInlines ? keepObjectEquality(context, {
|
|
128
263
|
...block,
|
|
129
264
|
children,
|
|
130
265
|
_key,
|
|
@@ -132,7 +267,7 @@ function fromSlateBlock(block, textBlockType, keyMap = {}) {
|
|
|
132
267
|
}, keyMap) : block;
|
|
133
268
|
}
|
|
134
269
|
const blockValue = "value" in block && block.value;
|
|
135
|
-
return keepObjectEquality({
|
|
270
|
+
return keepObjectEquality(context, {
|
|
136
271
|
_key,
|
|
137
272
|
_type,
|
|
138
273
|
...typeof blockValue == "object" ? blockValue : {}
|
|
@@ -147,7 +282,9 @@ function isEqualToEmptyEditor(initialValue, blocks, schemaTypes) {
|
|
|
147
282
|
if (!Element$1.isElement(firstBlock) || firstBlock._type !== schemaTypes.block.name || "listItem" in firstBlock || !("style" in firstBlock) || firstBlock.style !== schemaTypes.styles.at(0)?.name || !Array.isArray(firstBlock.children) || firstBlock.children.length !== 1)
|
|
148
283
|
return !1;
|
|
149
284
|
const firstChild = firstBlock.children.at(0);
|
|
150
|
-
return !(!firstChild || !Text.isText(firstChild) || !("_type" in firstChild) || firstChild._type !== schemaTypes.span.name || firstChild.text !== "" || firstChild.marks?.join("") || Object.keys(firstBlock).some((key) => key !== "_type" && key !== "_key" && key !== "children" && key !== "markDefs" && key !== "style") ||
|
|
285
|
+
return !(!firstChild || !Text.isText(firstChild) || !("_type" in firstChild) || firstChild._type !== schemaTypes.span.name || firstChild.text !== "" || firstChild.marks?.join("") || Object.keys(firstBlock).some((key) => key !== "_type" && key !== "_key" && key !== "children" && key !== "markDefs" && key !== "style") || isEqualValues({
|
|
286
|
+
schema: schemaTypes
|
|
287
|
+
}, initialValue, [firstBlock]));
|
|
151
288
|
}
|
|
152
289
|
function getFocusBlock({
|
|
153
290
|
editor
|
|
@@ -280,7 +417,9 @@ function elementToBlock({
|
|
|
280
417
|
schema,
|
|
281
418
|
element
|
|
282
419
|
}) {
|
|
283
|
-
return fromSlateBlock(
|
|
420
|
+
return fromSlateBlock({
|
|
421
|
+
schema
|
|
422
|
+
}, element, schema.block.name);
|
|
284
423
|
}
|
|
285
424
|
function isBlockElement({
|
|
286
425
|
editor,
|
|
@@ -353,6 +492,35 @@ function slateRangeToSelection({
|
|
|
353
492
|
_key: focusChild._key
|
|
354
493
|
})), selection;
|
|
355
494
|
}
|
|
495
|
+
function slatePointToSelectionPoint({
|
|
496
|
+
schema,
|
|
497
|
+
editor,
|
|
498
|
+
point
|
|
499
|
+
}) {
|
|
500
|
+
const [block] = getPointBlock({
|
|
501
|
+
editor,
|
|
502
|
+
point
|
|
503
|
+
});
|
|
504
|
+
if (!block)
|
|
505
|
+
return;
|
|
506
|
+
const [child] = block._type === schema.block.name ? getPointChild({
|
|
507
|
+
editor,
|
|
508
|
+
point
|
|
509
|
+
}) : [void 0, void 0];
|
|
510
|
+
return child ? {
|
|
511
|
+
path: [{
|
|
512
|
+
_key: block._key
|
|
513
|
+
}, "children", {
|
|
514
|
+
_key: child._key
|
|
515
|
+
}],
|
|
516
|
+
offset: point.offset
|
|
517
|
+
} : {
|
|
518
|
+
path: [{
|
|
519
|
+
_key: block._key
|
|
520
|
+
}],
|
|
521
|
+
offset: point.offset
|
|
522
|
+
};
|
|
523
|
+
}
|
|
356
524
|
function getEventPosition({
|
|
357
525
|
editorActor,
|
|
358
526
|
slateEditor,
|
|
@@ -580,11 +748,7 @@ function normalizeSelection(selection, value) {
|
|
|
580
748
|
anchor,
|
|
581
749
|
focus
|
|
582
750
|
} = selection;
|
|
583
|
-
return anchor && value.find((blk) =>
|
|
584
|
-
_key: blk._key
|
|
585
|
-
}, anchor.path[0])) && (newAnchor = normalizePoint(anchor, value)), focus && value.find((blk) => isEqual({
|
|
586
|
-
_key: blk._key
|
|
587
|
-
}, focus.path[0])) && (newFocus = normalizePoint(focus, value)), newAnchor && newFocus ? {
|
|
751
|
+
return anchor && value.find((blk) => isKeyedSegment(anchor.path[0]) && blk._key === anchor.path[0]._key) && (newAnchor = normalizePoint(anchor, value)), focus && value.find((blk) => isKeyedSegment(focus.path[0]) && blk._key === focus.path[0]._key) && (newFocus = normalizePoint(focus, value)), newAnchor && newFocus ? {
|
|
588
752
|
anchor: newAnchor,
|
|
589
753
|
focus: newFocus,
|
|
590
754
|
backward: selection.backward
|
|
@@ -660,7 +824,7 @@ const EditorActorContext = createContext({});
|
|
|
660
824
|
function DropIndicator() {
|
|
661
825
|
const $ = c(1);
|
|
662
826
|
let t0;
|
|
663
|
-
return $[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("div", { contentEditable: !1, className: "pt-drop-indicator", style: {
|
|
827
|
+
return $[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = /* @__PURE__ */ jsx("div", { contentEditable: !1, className: "pt-drop-indicator", style: {
|
|
664
828
|
position: "absolute",
|
|
665
829
|
width: "100%",
|
|
666
830
|
height: 1,
|
|
@@ -671,7 +835,7 @@ function DropIndicator() {
|
|
|
671
835
|
function RenderDefaultBlockObject(props) {
|
|
672
836
|
const $ = c(4);
|
|
673
837
|
let t0;
|
|
674
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
838
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
675
839
|
userSelect: "none"
|
|
676
840
|
}, $[0] = t0) : t0 = $[0];
|
|
677
841
|
let t1;
|
|
@@ -686,7 +850,7 @@ function RenderDefaultBlockObject(props) {
|
|
|
686
850
|
function RenderDefaultInlineObject(props) {
|
|
687
851
|
const $ = c(4);
|
|
688
852
|
let t0;
|
|
689
|
-
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
853
|
+
$[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t0 = {
|
|
690
854
|
userSelect: "none"
|
|
691
855
|
}, $[0] = t0) : t0 = $[0];
|
|
692
856
|
let t1;
|
|
@@ -983,7 +1147,7 @@ function RenderInlineObject(props) {
|
|
|
983
1147
|
}, $[12] = props.element._key, $[13] = props.element._type, $[14] = t3, $[15] = t4) : t4 = $[15];
|
|
984
1148
|
const inlineObject_0 = t4, t5 = !props.readOnly;
|
|
985
1149
|
let t6;
|
|
986
|
-
$[16] === Symbol.for("react.memo_cache_sentinel") ? (t6 = {
|
|
1150
|
+
$[16] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel") ? (t6 = {
|
|
987
1151
|
display: "inline-block"
|
|
988
1152
|
}, $[16] = t6) : t6 = $[16];
|
|
989
1153
|
let t7;
|
|
@@ -1301,7 +1465,7 @@ function RenderSpan(props) {
|
|
|
1301
1465
|
const path = t2;
|
|
1302
1466
|
let annotationMarkDefs, children;
|
|
1303
1467
|
if ($[11] !== block_0 || $[12] !== editorActor || $[13] !== focused || $[14] !== legacySchema || $[15] !== path || $[16] !== props.children || $[17] !== props.leaf.marks || $[18] !== props.renderAnnotation || $[19] !== props.renderDecorator || $[20] !== selected) {
|
|
1304
|
-
const decoratorSchemaTypes = editorActor.getSnapshot().context.schema.decorators.map(_temp2$1), decorators =
|
|
1468
|
+
const decoratorSchemaTypes = editorActor.getSnapshot().context.schema.decorators.map(_temp2$1), decorators = [...new Set((props.leaf.marks ?? []).filter((mark) => decoratorSchemaTypes.includes(mark)))];
|
|
1305
1469
|
annotationMarkDefs = (props.leaf.marks ?? []).flatMap((mark_0) => {
|
|
1306
1470
|
if (decoratorSchemaTypes.includes(mark_0))
|
|
1307
1471
|
return [];
|
|
@@ -1794,7 +1958,7 @@ const slateOperationCallback = ({
|
|
|
1794
1958
|
focus: rangeDecoration.selection?.focus,
|
|
1795
1959
|
payload: rangeDecoration.payload
|
|
1796
1960
|
}));
|
|
1797
|
-
return !
|
|
1961
|
+
return !isDeepEqual(existingRangeDecorations, newRangeDecorations);
|
|
1798
1962
|
},
|
|
1799
1963
|
"not read only": ({
|
|
1800
1964
|
context
|
|
@@ -2569,6 +2733,8 @@ const debug$e = debugWithName("component:Editable"), PortableTextEditable = forw
|
|
|
2569
2733
|
return $[151] !== callbackRef || $[152] !== decorate || $[153] !== handleClick || $[154] !== handleCopy || $[155] !== handleCut || $[156] !== handleDrag || $[157] !== handleDragEnd || $[158] !== handleDragEnter || $[159] !== handleDragLeave || $[160] !== handleDragOver || $[161] !== handleDragStart || $[162] !== handleDrop || $[163] !== handleKeyDown || $[164] !== handleKeyUp || $[165] !== handleOnBeforeInput || $[166] !== handleOnBlur || $[167] !== handleOnFocus || $[168] !== handlePaste || $[169] !== hasInvalidValue || $[170] !== readOnly || $[171] !== renderElement || $[172] !== renderLeaf || $[173] !== restProps || $[174] !== scrollSelectionIntoViewToSlate ? (t39 = hasInvalidValue ? null : /* @__PURE__ */ jsx(Editable, { ...restProps, ref: callbackRef, "data-read-only": readOnly, autoFocus: !1, className: restProps.className || "pt-editable", decorate, onBlur: handleOnBlur, onCopy: handleCopy, onCut: handleCut, onClick: handleClick, onDOMBeforeInput: handleOnBeforeInput, onDragStart: handleDragStart, onDrag: handleDrag, onDragEnd: handleDragEnd, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onDrop: handleDrop, onDragLeave: handleDragLeave, onFocus: handleOnFocus, onKeyDown: handleKeyDown, onKeyUp: handleKeyUp, onPaste: handlePaste, readOnly, renderPlaceholder: void 0, renderElement, renderLeaf, renderText, scrollSelectionIntoView: scrollSelectionIntoViewToSlate }), $[151] = callbackRef, $[152] = decorate, $[153] = handleClick, $[154] = handleCopy, $[155] = handleCut, $[156] = handleDrag, $[157] = handleDragEnd, $[158] = handleDragEnter, $[159] = handleDragLeave, $[160] = handleDragOver, $[161] = handleDragStart, $[162] = handleDrop, $[163] = handleKeyDown, $[164] = handleKeyUp, $[165] = handleOnBeforeInput, $[166] = handleOnBlur, $[167] = handleOnFocus, $[168] = handlePaste, $[169] = hasInvalidValue, $[170] = readOnly, $[171] = renderElement, $[172] = renderLeaf, $[173] = restProps, $[174] = scrollSelectionIntoViewToSlate, $[175] = t39) : t39 = $[175], t39;
|
|
2570
2734
|
});
|
|
2571
2735
|
PortableTextEditable.displayName = "ForwardRef(PortableTextEditable)";
|
|
2736
|
+
function noop() {
|
|
2737
|
+
}
|
|
2572
2738
|
function _temp(s) {
|
|
2573
2739
|
return s.matches({
|
|
2574
2740
|
"edit mode": "read only"
|
|
@@ -3292,7 +3458,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
3292
3458
|
}
|
|
3293
3459
|
if (editor.isTextBlock(node) && !editor.operations.some((op) => op.type === "merge_node" && "markDefs" in op.properties && op.path.length === 1)) {
|
|
3294
3460
|
const newMarkDefs = (node.markDefs || []).filter((def) => node.children.find((child) => Text.isText(child) && Array.isArray(child.marks) && child.marks.includes(def._key)));
|
|
3295
|
-
if (node.markDefs && !
|
|
3461
|
+
if (node.markDefs && !isEqualMarkDefs(newMarkDefs, node.markDefs)) {
|
|
3296
3462
|
debug$c("Removing markDef not in use"), withNormalizeNode(editor, () => {
|
|
3297
3463
|
Transforms.setNodes(editor, {
|
|
3298
3464
|
markDefs: newMarkDefs
|
|
@@ -3386,7 +3552,7 @@ function createWithPortableTextMarkModel(editorActor) {
|
|
|
3386
3552
|
if (op.type === "merge_node" && op.path.length === 1 && "markDefs" in op.properties && op.properties._type === editorActor.getSnapshot().context.schema.block.name && Array.isArray(op.properties.markDefs) && op.properties.markDefs.length > 0 && op.path[0] - 1 >= 0) {
|
|
3387
3553
|
const [targetBlock, targetPath] = Editor.node(editor, [op.path[0] - 1]);
|
|
3388
3554
|
if (editor.isTextBlock(targetBlock)) {
|
|
3389
|
-
const oldDefs = Array.isArray(targetBlock.markDefs) && targetBlock.markDefs || [], newMarkDefs =
|
|
3555
|
+
const oldDefs = Array.isArray(targetBlock.markDefs) && targetBlock.markDefs || [], newMarkDefs = [...new Map([...oldDefs, ...op.properties.markDefs].map((def) => [def._key, def])).values()];
|
|
3390
3556
|
debug$c("Copying markDefs over to merged block", op), Transforms.setNodes(editor, {
|
|
3391
3557
|
markDefs: newMarkDefs
|
|
3392
3558
|
}, {
|
|
@@ -4089,24 +4255,18 @@ function transformOperation(editor, patch, operation, snapshot, previousSnapshot
|
|
|
4089
4255
|
...operation
|
|
4090
4256
|
};
|
|
4091
4257
|
if (patch.type === "insert" && patch.path.length === 1) {
|
|
4092
|
-
const insertBlockIndex = (snapshot || []).findIndex((blk) =>
|
|
4093
|
-
_key: blk._key
|
|
4094
|
-
}, patch.path[0]));
|
|
4258
|
+
const pathSegment = patch.path[0], insertBlockIndex = (snapshot || []).findIndex((blk) => isKeyedSegment(pathSegment) && blk._key === pathSegment._key);
|
|
4095
4259
|
return debug$b(`Adjusting block path (+${patch.items.length}) for '${transformedOperation.type}' operation and patch '${patch.type}'`), [adjustBlockPath(transformedOperation, patch.items.length, insertBlockIndex)];
|
|
4096
4260
|
}
|
|
4097
4261
|
if (patch.type === "unset" && patch.path.length === 1) {
|
|
4098
|
-
const unsetBlockIndex = (previousSnapshot || []).findIndex((blk) =>
|
|
4099
|
-
_key: blk._key
|
|
4100
|
-
}, patch.path[0]));
|
|
4262
|
+
const pathSegment = patch.path[0], unsetBlockIndex = (previousSnapshot || []).findIndex((blk) => isKeyedSegment(pathSegment) && blk._key === pathSegment._key);
|
|
4101
4263
|
return "path" in transformedOperation && Array.isArray(transformedOperation.path) && transformedOperation.path[0] === unsetBlockIndex ? (debug$b("Skipping transformation that targeted removed block"), []) : [adjustBlockPath(transformedOperation, -1, unsetBlockIndex)];
|
|
4102
4264
|
}
|
|
4103
4265
|
if (patch.type === "unset" && patch.path.length === 0)
|
|
4104
4266
|
return debug$b(`Adjusting selection for unset everything patch and ${operation.type} operation`), [];
|
|
4105
4267
|
if (patch.type === "diffMatchPatch") {
|
|
4106
|
-
const operationTargetBlock = findOperationTargetBlock(editor, transformedOperation);
|
|
4107
|
-
return !operationTargetBlock || !
|
|
4108
|
-
_key: operationTargetBlock._key
|
|
4109
|
-
}, patch.path[0]) ? [transformedOperation] : (parse(patch.value).forEach((diffPatch) => {
|
|
4268
|
+
const operationTargetBlock = findOperationTargetBlock(editor, transformedOperation), pathSegment = patch.path[0];
|
|
4269
|
+
return !operationTargetBlock || !isKeyedSegment(pathSegment) || operationTargetBlock._key !== pathSegment._key ? [transformedOperation] : (parse(patch.value).forEach((diffPatch) => {
|
|
4110
4270
|
let adjustOffsetBy = 0, changedOffset = diffPatch.utf8Start1;
|
|
4111
4271
|
const {
|
|
4112
4272
|
diffs
|
|
@@ -4184,7 +4344,7 @@ const debug$a = debugWithName("behavior.operation.history.redo"), historyRedoOpe
|
|
|
4184
4344
|
const otherPatches = remotePatches.filter((item) => item.time >= step.timestamp);
|
|
4185
4345
|
let transformedOperations = step.operations;
|
|
4186
4346
|
otherPatches.forEach((item) => {
|
|
4187
|
-
transformedOperations =
|
|
4347
|
+
transformedOperations = transformedOperations.flatMap((op) => transformOperation(editor, item.patch, op, item.snapshot, item.previousSnapshot));
|
|
4188
4348
|
});
|
|
4189
4349
|
try {
|
|
4190
4350
|
Editor.withoutNormalizing(editor, () => {
|
|
@@ -4218,7 +4378,7 @@ const debug$a = debugWithName("behavior.operation.history.redo"), historyRedoOpe
|
|
|
4218
4378
|
const otherPatches = remotePatches.filter((item) => item.time >= step.timestamp);
|
|
4219
4379
|
let transformedOperations = step.operations;
|
|
4220
4380
|
otherPatches.forEach((item) => {
|
|
4221
|
-
transformedOperations =
|
|
4381
|
+
transformedOperations = transformedOperations.flatMap((op) => transformOperation(editor, item.patch, op, item.snapshot, item.previousSnapshot));
|
|
4222
4382
|
});
|
|
4223
4383
|
const reversedOperations = transformedOperations.map(Operation.inverse).reverse();
|
|
4224
4384
|
try {
|
|
@@ -4966,7 +5126,7 @@ function insertBlock(options) {
|
|
|
4966
5126
|
}), adjustedChildren = block.children.map((child) => {
|
|
4967
5127
|
if (isSpan(context, child)) {
|
|
4968
5128
|
const marks = child.marks?.map((mark) => markDefKeyMap.get(mark) || mark) ?? [];
|
|
4969
|
-
if (!
|
|
5129
|
+
if (!isEqualMarks(child.marks, marks))
|
|
4970
5130
|
return {
|
|
4971
5131
|
...child,
|
|
4972
5132
|
_key: endBlockChildKeys.includes(child._key) ? context.keyGenerator() : child._key,
|
|
@@ -4983,7 +5143,7 @@ function insertBlock(options) {
|
|
|
4983
5143
|
}, {
|
|
4984
5144
|
at: endBlockPath
|
|
4985
5145
|
});
|
|
4986
|
-
const adjustedBlock =
|
|
5146
|
+
const adjustedBlock = isEqualChildren(block.children, adjustedChildren) ? block : {
|
|
4987
5147
|
...block,
|
|
4988
5148
|
children: adjustedChildren
|
|
4989
5149
|
};
|
|
@@ -5364,7 +5524,8 @@ function createWithEventListeners(editorActor) {
|
|
|
5364
5524
|
const {
|
|
5365
5525
|
delete: editorDelete,
|
|
5366
5526
|
insertNodes,
|
|
5367
|
-
select
|
|
5527
|
+
select,
|
|
5528
|
+
setSelection
|
|
5368
5529
|
} = editor;
|
|
5369
5530
|
return editor.delete = (options) => {
|
|
5370
5531
|
if (isPerformingBehaviorOperation(editor)) {
|
|
@@ -5529,6 +5690,10 @@ function createWithEventListeners(editorActor) {
|
|
|
5529
5690
|
select(location);
|
|
5530
5691
|
return;
|
|
5531
5692
|
}
|
|
5693
|
+
if (editor.selection) {
|
|
5694
|
+
select(location);
|
|
5695
|
+
return;
|
|
5696
|
+
}
|
|
5532
5697
|
const range = Editor.range(editor, location);
|
|
5533
5698
|
editorActor.send({
|
|
5534
5699
|
type: "behavior event",
|
|
@@ -5542,6 +5707,49 @@ function createWithEventListeners(editorActor) {
|
|
|
5542
5707
|
},
|
|
5543
5708
|
editor
|
|
5544
5709
|
});
|
|
5710
|
+
}, editor.setSelection = (partialRange) => {
|
|
5711
|
+
if (isPerformingBehaviorOperation(editor)) {
|
|
5712
|
+
setSelection(partialRange);
|
|
5713
|
+
return;
|
|
5714
|
+
}
|
|
5715
|
+
const anchor = partialRange.anchor ? slatePointToSelectionPoint({
|
|
5716
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
5717
|
+
editor,
|
|
5718
|
+
point: partialRange.anchor
|
|
5719
|
+
}) : void 0, focus = partialRange.focus ? slatePointToSelectionPoint({
|
|
5720
|
+
schema: editorActor.getSnapshot().context.schema,
|
|
5721
|
+
editor,
|
|
5722
|
+
point: partialRange.focus
|
|
5723
|
+
}) : void 0, backward = editor.selection ? Range.isBackward({
|
|
5724
|
+
anchor: partialRange.anchor ?? editor.selection.anchor,
|
|
5725
|
+
focus: partialRange.focus ?? editor.selection.focus
|
|
5726
|
+
}) : partialRange.anchor && partialRange.focus ? Range.isBackward({
|
|
5727
|
+
anchor: partialRange.anchor,
|
|
5728
|
+
focus: partialRange.focus
|
|
5729
|
+
}) : void 0;
|
|
5730
|
+
if (editor.selection) {
|
|
5731
|
+
const newAnchor = partialRange.anchor ?? editor.selection.anchor, newFocus = partialRange.focus ?? editor.selection.focus;
|
|
5732
|
+
if (Point.equals(newAnchor, editor.selection.anchor) && Point.equals(newFocus, editor.selection.focus)) {
|
|
5733
|
+
setSelection(partialRange);
|
|
5734
|
+
return;
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
if (!anchor || !focus) {
|
|
5738
|
+
setSelection(partialRange);
|
|
5739
|
+
return;
|
|
5740
|
+
}
|
|
5741
|
+
editorActor.send({
|
|
5742
|
+
type: "behavior event",
|
|
5743
|
+
behaviorEvent: {
|
|
5744
|
+
type: "select",
|
|
5745
|
+
at: {
|
|
5746
|
+
anchor,
|
|
5747
|
+
focus,
|
|
5748
|
+
backward
|
|
5749
|
+
}
|
|
5750
|
+
},
|
|
5751
|
+
editor
|
|
5752
|
+
});
|
|
5545
5753
|
}, editor.setFragmentData = () => {
|
|
5546
5754
|
console.error("Unexpected call to .setFragmentData(...)");
|
|
5547
5755
|
}, editor.undo = () => {
|
|
@@ -5634,7 +5842,7 @@ function createWithObjectKeys(editorActor) {
|
|
|
5634
5842
|
for (const child of block.children) {
|
|
5635
5843
|
if (isSpan(editorActor.getSnapshot().context, child)) {
|
|
5636
5844
|
const marks = child.marks?.map((mark) => markDefKeyMap.get(mark) || mark) ?? [];
|
|
5637
|
-
|
|
5845
|
+
isEqualMarks(child.marks, marks) || Transforms.setNodes(editor, {
|
|
5638
5846
|
marks
|
|
5639
5847
|
}, {
|
|
5640
5848
|
at: [index, childIndex]
|
|
@@ -6208,9 +6416,13 @@ function insertNodePatch(schema, children, operation, beforeValue) {
|
|
|
6208
6416
|
const block = beforeValue[operation.path[0]];
|
|
6209
6417
|
if (operation.path.length === 1) {
|
|
6210
6418
|
const position = operation.path[0] === 0 ? "before" : "after", beforeBlock = beforeValue[operation.path[0] - 1], targetKey = operation.path[0] === 0 ? block?._key : beforeBlock?._key;
|
|
6211
|
-
return targetKey ? [insert([fromSlateBlock(
|
|
6419
|
+
return targetKey ? [insert([fromSlateBlock({
|
|
6420
|
+
schema
|
|
6421
|
+
}, operation.node, schema.block.name)], position, [{
|
|
6212
6422
|
_key: targetKey
|
|
6213
|
-
}])] : [setIfMissing(beforeValue, []), insert([fromSlateBlock(
|
|
6423
|
+
}])] : [setIfMissing(beforeValue, []), insert([fromSlateBlock({
|
|
6424
|
+
schema
|
|
6425
|
+
}, operation.node, schema.block.name)], "before", [operation.path[0]])];
|
|
6214
6426
|
} else if (isTextBlock({
|
|
6215
6427
|
schema
|
|
6216
6428
|
}, block) && operation.path.length === 2 && children[operation.path[0]]) {
|
|
@@ -6243,7 +6455,9 @@ function splitNodePatch(schema, children, operation, beforeValue) {
|
|
|
6243
6455
|
if (isTextBlock({
|
|
6244
6456
|
schema
|
|
6245
6457
|
}, oldBlock)) {
|
|
6246
|
-
const targetValue = fromSlateBlock(
|
|
6458
|
+
const targetValue = fromSlateBlock({
|
|
6459
|
+
schema
|
|
6460
|
+
}, children[operation.path[0] + 1], schema.block.name);
|
|
6247
6461
|
targetValue && (patches.push(insert([targetValue], "after", [{
|
|
6248
6462
|
_key: splitBlock._key
|
|
6249
6463
|
}])), oldBlock.children.slice(operation.position).forEach((span) => {
|
|
@@ -6263,6 +6477,8 @@ function splitNodePatch(schema, children, operation, beforeValue) {
|
|
|
6263
6477
|
schema
|
|
6264
6478
|
}, splitSpan)) {
|
|
6265
6479
|
const targetSpans = fromSlateBlock({
|
|
6480
|
+
schema
|
|
6481
|
+
}, {
|
|
6266
6482
|
...splitBlock,
|
|
6267
6483
|
children: splitBlock.children.slice(operation.path[1] + 1, operation.path[1] + 2)
|
|
6268
6484
|
}, schema.block.name).children;
|
|
@@ -6304,7 +6520,9 @@ function mergeNodePatch(schema, children, operation, beforeValue) {
|
|
|
6304
6520
|
const patches = [], block = beforeValue[operation.path[0]], updatedBlock = children[operation.path[0]];
|
|
6305
6521
|
if (operation.path.length === 1)
|
|
6306
6522
|
if (block?._key) {
|
|
6307
|
-
const newBlock = fromSlateBlock(
|
|
6523
|
+
const newBlock = fromSlateBlock({
|
|
6524
|
+
schema
|
|
6525
|
+
}, children[operation.path[0] - 1], schema.block.name);
|
|
6308
6526
|
patches.push(set(newBlock, [{
|
|
6309
6527
|
_key: newBlock._key
|
|
6310
6528
|
}])), patches.push(unset([{
|
|
@@ -10366,13 +10584,14 @@ const editorMachine = setup({
|
|
|
10366
10584
|
"handle focus": ({
|
|
10367
10585
|
context
|
|
10368
10586
|
}) => {
|
|
10369
|
-
|
|
10587
|
+
const slateEditor = context.slateEditor;
|
|
10588
|
+
if (!slateEditor) {
|
|
10370
10589
|
console.error("No Slate editor found to focus");
|
|
10371
10590
|
return;
|
|
10372
10591
|
}
|
|
10373
10592
|
try {
|
|
10374
|
-
const currentSelection =
|
|
10375
|
-
ReactEditor.focus(
|
|
10593
|
+
const currentSelection = slateEditor.selection;
|
|
10594
|
+
ReactEditor.focus(slateEditor), currentSelection && (Transforms.select(slateEditor, currentSelection), EDITOR_TO_PENDING_SELECTION.set(slateEditor, slateEditor.selection), slateEditor.onChange());
|
|
10376
10595
|
} catch (error) {
|
|
10377
10596
|
console.error(new Error(`Failed to focus editor: ${error.message}`));
|
|
10378
10597
|
}
|
|
@@ -11408,7 +11627,7 @@ function validateValue(value, types, keyGenerator) {
|
|
|
11408
11627
|
},
|
|
11409
11628
|
value
|
|
11410
11629
|
} : (value.some((blk, index) => {
|
|
11411
|
-
if (
|
|
11630
|
+
if (typeof blk != "object" || blk === null)
|
|
11412
11631
|
return resolution = {
|
|
11413
11632
|
patches: [unset([index])],
|
|
11414
11633
|
description: `Block must be an object, got ${String(blk)}`,
|
|
@@ -11562,11 +11781,11 @@ function validateValue(value, types, keyGenerator) {
|
|
|
11562
11781
|
}
|
|
11563
11782
|
}, !0;
|
|
11564
11783
|
}
|
|
11565
|
-
const allUsedMarks =
|
|
11784
|
+
const allUsedMarks = [...new Set(textBlock.children.filter((child) => isSpan({
|
|
11566
11785
|
schema: types
|
|
11567
|
-
}, child)).
|
|
11786
|
+
}, child)).flatMap((cld) => cld.marks || []))];
|
|
11568
11787
|
if (Array.isArray(blk.markDefs) && blk.markDefs.length > 0) {
|
|
11569
|
-
const unusedMarkDefs =
|
|
11788
|
+
const unusedMarkDefs = [...new Set(blk.markDefs.map((def) => def._key).filter((key) => !allUsedMarks.includes(key)))];
|
|
11570
11789
|
if (unusedMarkDefs.length > 0)
|
|
11571
11790
|
return resolution = {
|
|
11572
11791
|
autoResolve: !0,
|
|
@@ -11615,7 +11834,7 @@ function validateValue(value, types, keyGenerator) {
|
|
|
11615
11834
|
}
|
|
11616
11835
|
}
|
|
11617
11836
|
textBlock.children.some((child, cIndex) => {
|
|
11618
|
-
if (
|
|
11837
|
+
if (typeof child != "object" || child === null)
|
|
11619
11838
|
return resolution = {
|
|
11620
11839
|
patches: [unset([{
|
|
11621
11840
|
_key: blk._key
|
|
@@ -11797,7 +12016,9 @@ const debug$2 = debugWithName("sync machine"), syncValueCallback = ({
|
|
|
11797
12016
|
}) => (assertEvent(event, "done syncing"), context.pendingValue !== event.value),
|
|
11798
12017
|
"pending value equals previous value": ({
|
|
11799
12018
|
context
|
|
11800
|
-
}) =>
|
|
12019
|
+
}) => isEqualValues({
|
|
12020
|
+
schema: context.schema
|
|
12021
|
+
}, context.pendingValue, context.previousValue)
|
|
11801
12022
|
},
|
|
11802
12023
|
actors: {
|
|
11803
12024
|
"sync value": syncValueLogic
|
|
@@ -12155,7 +12376,7 @@ function syncBlock({
|
|
|
12155
12376
|
blockValid: !1
|
|
12156
12377
|
};
|
|
12157
12378
|
}
|
|
12158
|
-
if (
|
|
12379
|
+
if (isEqualBlocks(context, block, oldBlock))
|
|
12159
12380
|
return {
|
|
12160
12381
|
blockChanged: !1,
|
|
12161
12382
|
blockValid: !0
|
|
@@ -12236,7 +12457,7 @@ function updateBlock({
|
|
|
12236
12457
|
at: [index2, childIndex]
|
|
12237
12458
|
}));
|
|
12238
12459
|
}), slateBlock.children.forEach((currentBlockChild, currentBlockChildIndex) => {
|
|
12239
|
-
const oldBlockChild = oldBlock.children
|
|
12460
|
+
const oldBlockChild = oldBlock.children.at(currentBlockChildIndex), isChildChanged = oldBlockChild && !isEqualChild(currentBlockChild, oldBlockChild), isTextChanged = oldBlockChild && Text.isText(oldBlockChild) && currentBlockChild.text !== oldBlockChild.text, path = [index, currentBlockChildIndex];
|
|
12240
12461
|
if (isChildChanged)
|
|
12241
12462
|
if (currentBlockChild._key === oldBlockChild?._key) {
|
|
12242
12463
|
debug$2("Updating changed child", currentBlockChild, oldBlockChild), Transforms.setNodes(slateEditor, currentBlockChild, {
|