@37signals/lexxy 0.1.12-beta → 0.1.13-beta
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/dist/lexxy.esm.js +52 -26
- package/package.json +1 -1
package/dist/lexxy.esm.js
CHANGED
|
@@ -514,7 +514,7 @@ class ActionTextAttachmentNode extends DecoratorNode {
|
|
|
514
514
|
this.altText = altText || "";
|
|
515
515
|
this.caption = caption || "";
|
|
516
516
|
this.contentType = contentType || "";
|
|
517
|
-
this.fileName = fileName;
|
|
517
|
+
this.fileName = fileName || "";
|
|
518
518
|
this.fileSize = fileSize;
|
|
519
519
|
this.width = width;
|
|
520
520
|
this.height = height;
|
|
@@ -2033,38 +2033,25 @@ class Contents {
|
|
|
2033
2033
|
}, { tag: HISTORY_MERGE_TAG });
|
|
2034
2034
|
}
|
|
2035
2035
|
|
|
2036
|
-
deleteSelectedNodes() {
|
|
2036
|
+
async deleteSelectedNodes() {
|
|
2037
|
+
let focusNode = null;
|
|
2038
|
+
|
|
2037
2039
|
this.editor.update(() => {
|
|
2038
2040
|
if ($isNodeSelection(this.#selection.current)) {
|
|
2039
2041
|
const nodesToRemove = this.#selection.current.getNodes();
|
|
2040
2042
|
if (nodesToRemove.length === 0) return
|
|
2041
2043
|
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
const parent = node.getParent();
|
|
2047
|
-
if (!$isElementNode(parent)) return
|
|
2048
|
-
|
|
2049
|
-
const children = parent.getChildren();
|
|
2050
|
-
const index = children.indexOf(node);
|
|
2051
|
-
|
|
2052
|
-
if (index >= 0) {
|
|
2053
|
-
parent.splice(index, 1, []);
|
|
2054
|
-
}
|
|
2055
|
-
});
|
|
2056
|
-
|
|
2057
|
-
// Check if root is empty after all removals
|
|
2058
|
-
const root = $getRoot();
|
|
2059
|
-
if (root.getChildrenSize() === 0) {
|
|
2060
|
-
root.append($createParagraphNode());
|
|
2061
|
-
}
|
|
2044
|
+
focusNode = this.#findAdjacentNodeTo(nodesToRemove);
|
|
2045
|
+
this.#deleteNodes(nodesToRemove);
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2062
2048
|
|
|
2063
|
-
|
|
2064
|
-
this.editor.focus();
|
|
2049
|
+
await nextFrame();
|
|
2065
2050
|
|
|
2066
|
-
|
|
2067
|
-
|
|
2051
|
+
this.editor.update(() => {
|
|
2052
|
+
this.#selectAfterDeletion(focusNode);
|
|
2053
|
+
this.#selection.clear();
|
|
2054
|
+
this.editor.focus();
|
|
2068
2055
|
});
|
|
2069
2056
|
}
|
|
2070
2057
|
|
|
@@ -2199,6 +2186,45 @@ class Contents {
|
|
|
2199
2186
|
nodesToDelete.forEach((node) => node.remove());
|
|
2200
2187
|
}
|
|
2201
2188
|
|
|
2189
|
+
#deleteNodes(nodes) {
|
|
2190
|
+
// Use splice() instead of node.remove() for proper removal and
|
|
2191
|
+
// reconciliation. Would have issues with removing unintended decorator nodes
|
|
2192
|
+
// with node.remove()
|
|
2193
|
+
nodes.forEach((node) => {
|
|
2194
|
+
const parent = node.getParent();
|
|
2195
|
+
if (!$isElementNode(parent)) return
|
|
2196
|
+
|
|
2197
|
+
const children = parent.getChildren();
|
|
2198
|
+
const index = children.indexOf(node);
|
|
2199
|
+
|
|
2200
|
+
if (index >= 0) {
|
|
2201
|
+
parent.splice(index, 1, []);
|
|
2202
|
+
}
|
|
2203
|
+
});
|
|
2204
|
+
}
|
|
2205
|
+
|
|
2206
|
+
#findAdjacentNodeTo(nodes) {
|
|
2207
|
+
const firstNode = nodes[0];
|
|
2208
|
+
const lastNode = nodes[nodes.length - 1];
|
|
2209
|
+
|
|
2210
|
+
return firstNode?.getPreviousSibling() || lastNode?.getNextSibling()
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
#selectAfterDeletion(focusNode) {
|
|
2214
|
+
const root = $getRoot();
|
|
2215
|
+
if (root.getChildrenSize() === 0) {
|
|
2216
|
+
const newParagraph = $createParagraphNode();
|
|
2217
|
+
root.append(newParagraph);
|
|
2218
|
+
newParagraph.selectStart();
|
|
2219
|
+
} else if (focusNode) {
|
|
2220
|
+
if ($isTextNode(focusNode) || $isParagraphNode(focusNode)) {
|
|
2221
|
+
focusNode.selectEnd();
|
|
2222
|
+
} else {
|
|
2223
|
+
focusNode.selectNext(0, 0);
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2202
2228
|
#collectSelectedListItems(selection) {
|
|
2203
2229
|
const nodes = selection.getNodes();
|
|
2204
2230
|
const listItems = new Set();
|