@37signals/lexxy 0.1.11-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 +56 -26
- package/package.json +1 -1
package/dist/lexxy.esm.js
CHANGED
|
@@ -493,6 +493,7 @@ class ActionTextAttachmentNode extends DecoratorNode {
|
|
|
493
493
|
conversion: () => ({
|
|
494
494
|
node: new ActionTextAttachmentNode({
|
|
495
495
|
src: img.getAttribute("src"),
|
|
496
|
+
caption: img.getAttribute("alt") || "",
|
|
496
497
|
contentType: "image/*",
|
|
497
498
|
width: img.getAttribute("width"),
|
|
498
499
|
height: img.getAttribute("height")
|
|
@@ -513,7 +514,7 @@ class ActionTextAttachmentNode extends DecoratorNode {
|
|
|
513
514
|
this.altText = altText || "";
|
|
514
515
|
this.caption = caption || "";
|
|
515
516
|
this.contentType = contentType || "";
|
|
516
|
-
this.fileName = fileName;
|
|
517
|
+
this.fileName = fileName || "";
|
|
517
518
|
this.fileSize = fileSize;
|
|
518
519
|
this.width = width;
|
|
519
520
|
this.height = height;
|
|
@@ -2032,38 +2033,25 @@ class Contents {
|
|
|
2032
2033
|
}, { tag: HISTORY_MERGE_TAG });
|
|
2033
2034
|
}
|
|
2034
2035
|
|
|
2035
|
-
deleteSelectedNodes() {
|
|
2036
|
+
async deleteSelectedNodes() {
|
|
2037
|
+
let focusNode = null;
|
|
2038
|
+
|
|
2036
2039
|
this.editor.update(() => {
|
|
2037
2040
|
if ($isNodeSelection(this.#selection.current)) {
|
|
2038
2041
|
const nodesToRemove = this.#selection.current.getNodes();
|
|
2039
2042
|
if (nodesToRemove.length === 0) return
|
|
2040
2043
|
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
const parent = node.getParent();
|
|
2046
|
-
if (!$isElementNode(parent)) return
|
|
2047
|
-
|
|
2048
|
-
const children = parent.getChildren();
|
|
2049
|
-
const index = children.indexOf(node);
|
|
2050
|
-
|
|
2051
|
-
if (index >= 0) {
|
|
2052
|
-
parent.splice(index, 1, []);
|
|
2053
|
-
}
|
|
2054
|
-
});
|
|
2055
|
-
|
|
2056
|
-
// Check if root is empty after all removals
|
|
2057
|
-
const root = $getRoot();
|
|
2058
|
-
if (root.getChildrenSize() === 0) {
|
|
2059
|
-
root.append($createParagraphNode());
|
|
2060
|
-
}
|
|
2044
|
+
focusNode = this.#findAdjacentNodeTo(nodesToRemove);
|
|
2045
|
+
this.#deleteNodes(nodesToRemove);
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2061
2048
|
|
|
2062
|
-
|
|
2063
|
-
this.editor.focus();
|
|
2049
|
+
await nextFrame();
|
|
2064
2050
|
|
|
2065
|
-
|
|
2066
|
-
|
|
2051
|
+
this.editor.update(() => {
|
|
2052
|
+
this.#selectAfterDeletion(focusNode);
|
|
2053
|
+
this.#selection.clear();
|
|
2054
|
+
this.editor.focus();
|
|
2067
2055
|
});
|
|
2068
2056
|
}
|
|
2069
2057
|
|
|
@@ -2198,6 +2186,45 @@ class Contents {
|
|
|
2198
2186
|
nodesToDelete.forEach((node) => node.remove());
|
|
2199
2187
|
}
|
|
2200
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
|
+
|
|
2201
2228
|
#collectSelectedListItems(selection) {
|
|
2202
2229
|
const nodes = selection.getNodes();
|
|
2203
2230
|
const listItems = new Set();
|
|
@@ -2449,6 +2476,9 @@ class Clipboard {
|
|
|
2449
2476
|
#handlePastedFiles(clipboardData) {
|
|
2450
2477
|
if (!this.editorElement.supportsAttachments) return
|
|
2451
2478
|
|
|
2479
|
+
const html = clipboardData.getData('text/html');
|
|
2480
|
+
if (html) return // Ignore if image copied from browser since we will load it as a remote image
|
|
2481
|
+
|
|
2452
2482
|
this.#preservingScrollPosition(() => {
|
|
2453
2483
|
for (const item of clipboardData.items) {
|
|
2454
2484
|
const file = item.getAsFile();
|