@burger-editor/client 4.0.0-alpha.75 → 4.0.0-alpha.76
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/client.js +178 -160
- package/dist/client.js.map +1 -1
- package/dist/{editable-area-view-DssYcTqQ.js → editable-area-view-S2Uz7pl8.js} +2 -2
- package/dist/{editable-area-view-DssYcTqQ.js.map → editable-area-view-S2Uz7pl8.js.map} +1 -1
- package/dist/{engine-context-gX6mWHke.js → engine-context-D0zt6fhJ.js} +48 -1
- package/dist/engine-context-D0zt6fhJ.js.map +1 -0
- package/dist/file-browser/store.d.ts +5 -0
- package/dist/file-browser/store.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/ui.js +12 -2
- package/dist/ui.js.map +1 -1
- package/package.json +6 -6
- package/dist/engine-context-gX6mWHke.js.map +0 -1
package/dist/client.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as BurgerEditorEngine, n as useEngine, t as EngineProvider } from "./engine-context-
|
|
2
|
-
import { d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, l as reactMount, m as EditorDialog, p as ItemEditorHost, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher } from "./editable-area-view-
|
|
1
|
+
import { i as BurgerEditorEngine, n as useEngine, t as EngineProvider } from "./engine-context-D0zt6fhJ.js";
|
|
2
|
+
import { d as registerEngineCommands, f as useUIState, g as BlockCatalog, h as BlockOptions, l as reactMount, m as EditorDialog, p as ItemEditorHost, s as RootErrorBoundary, t as EditableAreaView, u as DraftSwitcher } from "./editable-area-view-S2Uz7pl8.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { createRoot } from "react-dom/client";
|
|
@@ -760,9 +760,7 @@ var Mark$1 = class Mark$1 {
|
|
|
760
760
|
if (!json) throw new RangeError("Invalid input for Mark.fromJSON");
|
|
761
761
|
let type = schema.marks[json.type];
|
|
762
762
|
if (!type) throw new RangeError(`There is no mark type ${json.type} in this schema`);
|
|
763
|
-
|
|
764
|
-
type.checkAttrs(mark.attrs);
|
|
765
|
-
return mark;
|
|
763
|
+
return type.create(json.attrs);
|
|
766
764
|
}
|
|
767
765
|
/**
|
|
768
766
|
Test whether two sets of marks are identical.
|
|
@@ -1659,11 +1657,11 @@ var Node$2 = class Node$2 {
|
|
|
1659
1657
|
*/
|
|
1660
1658
|
check() {
|
|
1661
1659
|
this.type.checkContent(this.content);
|
|
1662
|
-
this.type.
|
|
1660
|
+
checkAttrs(this.type.attrs, this.attrs, "node", this.type.name);
|
|
1663
1661
|
let copy = Mark$1.none;
|
|
1664
1662
|
for (let i = 0; i < this.marks.length; i++) {
|
|
1665
1663
|
let mark = this.marks[i];
|
|
1666
|
-
mark.type.
|
|
1664
|
+
checkAttrs(mark.type.attrs, mark.attrs, "mark", mark.type.name);
|
|
1667
1665
|
copy = mark.addToSet(copy);
|
|
1668
1666
|
}
|
|
1669
1667
|
if (!Mark$1.sameSet(copy, this.marks)) throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m) => m.type.name)}`);
|
|
@@ -1697,9 +1695,7 @@ var Node$2 = class Node$2 {
|
|
|
1697
1695
|
return schema.text(json.text, marks);
|
|
1698
1696
|
}
|
|
1699
1697
|
let content = Fragment$1.fromJSON(schema, json.content);
|
|
1700
|
-
|
|
1701
|
-
node.type.checkAttrs(node.attrs);
|
|
1702
|
-
return node;
|
|
1698
|
+
return schema.nodeType(json.type).create(json.attrs, content, marks);
|
|
1703
1699
|
}
|
|
1704
1700
|
};
|
|
1705
1701
|
Node$2.prototype.text = void 0;
|
|
@@ -1749,6 +1745,10 @@ function wrapMarks(marks, str) {
|
|
|
1749
1745
|
for (let i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + "(" + str + ")";
|
|
1750
1746
|
return str;
|
|
1751
1747
|
}
|
|
1748
|
+
function checkAttrs(attrs, values, type, name) {
|
|
1749
|
+
for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
1750
|
+
for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
|
|
1751
|
+
}
|
|
1752
1752
|
/**
|
|
1753
1753
|
Instances of this class represent a match state of a node type's
|
|
1754
1754
|
[content expression](https://prosemirror.net/docs/ref/#model.NodeSpec.content), and can be used to
|
|
@@ -2159,20 +2159,16 @@ function defaultAttrs(attrs) {
|
|
|
2159
2159
|
function computeAttrs(attrs, value) {
|
|
2160
2160
|
let built = Object.create(null);
|
|
2161
2161
|
for (let name in attrs) {
|
|
2162
|
+
let attr = attrs[name];
|
|
2162
2163
|
let given = value && value[name];
|
|
2163
2164
|
if (given === void 0) {
|
|
2164
|
-
let attr = attrs[name];
|
|
2165
2165
|
if (attr.hasDefault) given = attr.default;
|
|
2166
2166
|
else throw new RangeError("No value supplied for attribute " + name);
|
|
2167
|
-
}
|
|
2167
|
+
} else if (attr.validate) attr.validate(given);
|
|
2168
2168
|
built[name] = given;
|
|
2169
2169
|
}
|
|
2170
2170
|
return built;
|
|
2171
2171
|
}
|
|
2172
|
-
function checkAttrs(attrs, values, type, name) {
|
|
2173
|
-
for (let attr in values) if (!(attr in attrs)) throw new RangeError(`Unsupported attribute ${attr} for ${type} of type ${name}`);
|
|
2174
|
-
for (let attr in attrs) if (attrs[attr].validate) attrs[attr].validate(values[attr]);
|
|
2175
|
-
}
|
|
2176
2172
|
function initAttrs(typeName, attrs) {
|
|
2177
2173
|
let result = Object.create(null);
|
|
2178
2174
|
if (attrs) for (let name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);
|
|
@@ -2327,11 +2323,9 @@ var NodeType$1 = class NodeType$1 {
|
|
|
2327
2323
|
if (!this.validContent(content)) throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
|
|
2328
2324
|
}
|
|
2329
2325
|
/**
|
|
2330
|
-
@internal
|
|
2326
|
+
@internal no longer useful, but called by old prosemirror-view versions
|
|
2331
2327
|
*/
|
|
2332
|
-
checkAttrs(attrs) {
|
|
2333
|
-
checkAttrs(this.attrs, attrs, "node", this.name);
|
|
2334
|
-
}
|
|
2328
|
+
checkAttrs(attrs) {}
|
|
2335
2329
|
/**
|
|
2336
2330
|
Check whether the given mark type is allowed in this node.
|
|
2337
2331
|
*/
|
|
@@ -2442,12 +2436,6 @@ var MarkType = class MarkType {
|
|
|
2442
2436
|
for (let i = 0; i < set.length; i++) if (set[i].type == this) return set[i];
|
|
2443
2437
|
}
|
|
2444
2438
|
/**
|
|
2445
|
-
@internal
|
|
2446
|
-
*/
|
|
2447
|
-
checkAttrs(attrs) {
|
|
2448
|
-
checkAttrs(this.attrs, attrs, "mark", this.name);
|
|
2449
|
-
}
|
|
2450
|
-
/**
|
|
2451
2439
|
Queries whether a given mark type is
|
|
2452
2440
|
[excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
|
|
2453
2441
|
*/
|
|
@@ -3412,8 +3400,11 @@ var StepMap = class StepMap {
|
|
|
3412
3400
|
let result = start + diff + (side < 0 ? 0 : newSize);
|
|
3413
3401
|
if (simple) return result;
|
|
3414
3402
|
let recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);
|
|
3415
|
-
let del =
|
|
3416
|
-
if (
|
|
3403
|
+
let del = 0;
|
|
3404
|
+
if (oldSize) {
|
|
3405
|
+
del |= pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;
|
|
3406
|
+
if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;
|
|
3407
|
+
}
|
|
3417
3408
|
return new MapResult(result, del, recover);
|
|
3418
3409
|
}
|
|
3419
3410
|
diff += newSize - oldSize;
|
|
@@ -6838,12 +6829,12 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
6838
6829
|
if (node == targetNode && off == targetOff) return true;
|
|
6839
6830
|
if (off == (dir < 0 ? 0 : nodeSize(node))) {
|
|
6840
6831
|
let parent = node.parentNode;
|
|
6841
|
-
if (!parent || parent
|
|
6832
|
+
if (!parent || !isElt(parent) || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == "false") return false;
|
|
6842
6833
|
off = domIndex(node) + (dir < 0 ? 0 : 1);
|
|
6843
6834
|
node = parent;
|
|
6844
|
-
} else if (node
|
|
6835
|
+
} else if (isElt(node)) {
|
|
6845
6836
|
let child = node.childNodes[off + (dir < 0 ? -1 : 0)];
|
|
6846
|
-
if (child
|
|
6837
|
+
if (isElt(child) && child.contentEditable == "false") {
|
|
6847
6838
|
if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;
|
|
6848
6839
|
else return false;
|
|
6849
6840
|
} else {
|
|
@@ -6856,10 +6847,19 @@ function scanFor(node, off, targetNode, targetOff, dir) {
|
|
|
6856
6847
|
function nodeSize(node) {
|
|
6857
6848
|
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
6858
6849
|
}
|
|
6850
|
+
function isElt(node) {
|
|
6851
|
+
return node.nodeType == 1;
|
|
6852
|
+
}
|
|
6853
|
+
function isText(node) {
|
|
6854
|
+
return node.nodeType == 3;
|
|
6855
|
+
}
|
|
6856
|
+
function contains(parent, child) {
|
|
6857
|
+
return child ? parent.contains(isElt(child) ? child : child.parentNode) : false;
|
|
6858
|
+
}
|
|
6859
6859
|
function textNodeBefore$1(node, offset) {
|
|
6860
6860
|
for (;;) {
|
|
6861
|
-
if (node
|
|
6862
|
-
if (node
|
|
6861
|
+
if (isText(node) && offset) return node;
|
|
6862
|
+
if (isElt(node) && offset > 0) {
|
|
6863
6863
|
if (node.contentEditable == "false") return null;
|
|
6864
6864
|
node = node.childNodes[offset - 1];
|
|
6865
6865
|
offset = nodeSize(node);
|
|
@@ -6871,8 +6871,8 @@ function textNodeBefore$1(node, offset) {
|
|
|
6871
6871
|
}
|
|
6872
6872
|
function textNodeAfter$1(node, offset) {
|
|
6873
6873
|
for (;;) {
|
|
6874
|
-
if (node
|
|
6875
|
-
if (node
|
|
6874
|
+
if (isText(node) && offset < node.nodeValue.length) return node;
|
|
6875
|
+
if (isElt(node) && offset < node.childNodes.length) {
|
|
6876
6876
|
if (node.contentEditable == "false") return null;
|
|
6877
6877
|
node = node.childNodes[offset];
|
|
6878
6878
|
offset = 0;
|
|
@@ -6983,13 +6983,12 @@ function scrollRectIntoView(view, rect, startDOM) {
|
|
|
6983
6983
|
let doc = view.dom.ownerDocument;
|
|
6984
6984
|
for (let parent = startDOM || view.dom;;) {
|
|
6985
6985
|
if (!parent) break;
|
|
6986
|
-
if (parent
|
|
6986
|
+
if (!isElt(parent)) {
|
|
6987
6987
|
parent = parentNode(parent);
|
|
6988
6988
|
continue;
|
|
6989
6989
|
}
|
|
6990
|
-
let
|
|
6991
|
-
let
|
|
6992
|
-
let bounding = atTop ? windowRect(doc) : clientRect(elt);
|
|
6990
|
+
let atTop = parent == doc.body;
|
|
6991
|
+
let bounding = atTop ? windowRect(doc) : clientRect(parent);
|
|
6993
6992
|
let moveX = 0, moveY = 0;
|
|
6994
6993
|
if (rect.top < bounding.top + getSide(scrollThreshold, "top")) moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top"));
|
|
6995
6994
|
else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom")) moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, "top") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom");
|
|
@@ -6998,10 +6997,10 @@ function scrollRectIntoView(view, rect, startDOM) {
|
|
|
6998
6997
|
if (moveX || moveY) {
|
|
6999
6998
|
if (atTop) doc.defaultView.scrollBy(moveX, moveY);
|
|
7000
6999
|
else {
|
|
7001
|
-
let startX =
|
|
7002
|
-
if (moveY)
|
|
7003
|
-
if (moveX)
|
|
7004
|
-
let dX =
|
|
7000
|
+
let startX = parent.scrollLeft, startY = parent.scrollTop;
|
|
7001
|
+
if (moveY) parent.scrollTop += moveY;
|
|
7002
|
+
if (moveX) parent.scrollLeft += moveX;
|
|
7003
|
+
let dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
|
7005
7004
|
rect = {
|
|
7006
7005
|
left: rect.left - dX,
|
|
7007
7006
|
top: rect.top - dY,
|
|
@@ -7072,13 +7071,14 @@ function focusPreventScroll(dom) {
|
|
|
7072
7071
|
}
|
|
7073
7072
|
}
|
|
7074
7073
|
function findOffsetInNode(node, coords) {
|
|
7075
|
-
let closest
|
|
7074
|
+
let closest;
|
|
7075
|
+
let dxClosest = 2e8, coordsClosest, offset = 0;
|
|
7076
7076
|
let rowBot = coords.top, rowTop = coords.top;
|
|
7077
7077
|
let firstBelow, coordsBelow;
|
|
7078
7078
|
for (let child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {
|
|
7079
7079
|
let rects;
|
|
7080
|
-
if (child
|
|
7081
|
-
else if (child
|
|
7080
|
+
if (isElt(child)) rects = child.getClientRects();
|
|
7081
|
+
else if (isText(child)) rects = textRange(child).getClientRects();
|
|
7082
7082
|
else continue;
|
|
7083
7083
|
for (let i = 0; i < rects.length; i++) {
|
|
7084
7084
|
let rect = rects[i];
|
|
@@ -7089,11 +7089,11 @@ function findOffsetInNode(node, coords) {
|
|
|
7089
7089
|
if (dx < dxClosest) {
|
|
7090
7090
|
closest = child;
|
|
7091
7091
|
dxClosest = dx;
|
|
7092
|
-
coordsClosest = dx && closest
|
|
7092
|
+
coordsClosest = dx && isText(closest) ? {
|
|
7093
7093
|
left: rect.right < coords.left ? rect.right : rect.left,
|
|
7094
7094
|
top: coords.top
|
|
7095
7095
|
} : coords;
|
|
7096
|
-
if (child
|
|
7096
|
+
if (isElt(child) && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);
|
|
7097
7097
|
continue;
|
|
7098
7098
|
}
|
|
7099
7099
|
} else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {
|
|
@@ -7111,8 +7111,8 @@ function findOffsetInNode(node, coords) {
|
|
|
7111
7111
|
coordsClosest = coordsBelow;
|
|
7112
7112
|
dxClosest = 0;
|
|
7113
7113
|
}
|
|
7114
|
-
if (closest && closest
|
|
7115
|
-
if (!closest || dxClosest
|
|
7114
|
+
if (closest && isText(closest)) return findOffsetInText(closest, coordsClosest);
|
|
7115
|
+
if (!closest || dxClosest) return {
|
|
7116
7116
|
node,
|
|
7117
7117
|
offset
|
|
7118
7118
|
};
|
|
@@ -7150,7 +7150,7 @@ function targetKludge(dom, coords) {
|
|
|
7150
7150
|
}
|
|
7151
7151
|
function posFromElement(view, elt, coords) {
|
|
7152
7152
|
let { node, offset } = findOffsetInNode(elt, coords), bias = -1;
|
|
7153
|
-
if (node
|
|
7153
|
+
if (isElt(node) && !node.firstChild) {
|
|
7154
7154
|
let rect = node.getBoundingClientRect();
|
|
7155
7155
|
bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;
|
|
7156
7156
|
}
|
|
@@ -7162,7 +7162,7 @@ function posFromCaret(view, node, offset, coords) {
|
|
|
7162
7162
|
if (cur == view.dom) break;
|
|
7163
7163
|
let desc = view.docView.nearestDesc(cur, true), rect;
|
|
7164
7164
|
if (!desc) return null;
|
|
7165
|
-
if (desc.dom
|
|
7165
|
+
if (isElt(desc.dom) && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {
|
|
7166
7166
|
if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {
|
|
7167
7167
|
if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore;
|
|
7168
7168
|
else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top) outsideBlock = desc.posAfter;
|
|
@@ -7178,7 +7178,7 @@ function elementFromPoint(element, coords, box) {
|
|
|
7178
7178
|
let len = element.childNodes.length;
|
|
7179
7179
|
if (len && box.top < box.bottom) for (let startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {
|
|
7180
7180
|
let child = element.childNodes[i];
|
|
7181
|
-
if (child
|
|
7181
|
+
if (isElt(child)) {
|
|
7182
7182
|
let rects = child.getClientRects();
|
|
7183
7183
|
for (let j = 0; j < rects.length; j++) {
|
|
7184
7184
|
let rect = rects[j];
|
|
@@ -7195,7 +7195,7 @@ function posAtCoords(view, coords) {
|
|
|
7195
7195
|
if (caret) ({node, offset} = caret);
|
|
7196
7196
|
let elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top);
|
|
7197
7197
|
let pos;
|
|
7198
|
-
if (!elt || !view.dom.contains(elt
|
|
7198
|
+
if (!elt || !view.dom.contains(elt)) {
|
|
7199
7199
|
let box = view.dom.getBoundingClientRect();
|
|
7200
7200
|
if (!inRect(coords, box)) return null;
|
|
7201
7201
|
elt = elementFromPoint(view.dom, coords, box);
|
|
@@ -7206,7 +7206,7 @@ function posAtCoords(view, coords) {
|
|
|
7206
7206
|
}
|
|
7207
7207
|
elt = targetKludge(elt, coords);
|
|
7208
7208
|
if (node) {
|
|
7209
|
-
if (gecko && node
|
|
7209
|
+
if (gecko && isElt(node)) {
|
|
7210
7210
|
offset = Math.min(offset, node.childNodes.length);
|
|
7211
7211
|
if (offset < node.childNodes.length) {
|
|
7212
7212
|
let next = node.childNodes[offset], box;
|
|
@@ -7214,9 +7214,9 @@ function posAtCoords(view, coords) {
|
|
|
7214
7214
|
}
|
|
7215
7215
|
}
|
|
7216
7216
|
let prev;
|
|
7217
|
-
if (webkit && offset && node
|
|
7218
|
-
if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild
|
|
7219
|
-
else if (offset == 0 || node
|
|
7217
|
+
if (webkit && offset && isElt(node) && isElt(prev = node.childNodes[offset - 1]) && prev.contentEditable == "false" && prev.getBoundingClientRect().top >= coords.top) offset--;
|
|
7218
|
+
if (node == view.dom && offset == node.childNodes.length - 1 && isElt(node.lastChild) && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;
|
|
7219
|
+
else if (offset == 0 || !isElt(node) || node.childNodes[offset - 1].nodeName != "BR") pos = posFromCaret(view, node, offset, coords);
|
|
7220
7220
|
}
|
|
7221
7221
|
if (pos == null) pos = posFromElement(view, elt, coords);
|
|
7222
7222
|
let desc = view.docView.nearestDesc(elt, true);
|
|
@@ -7240,7 +7240,7 @@ var BIDI = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
|
|
|
7240
7240
|
function coordsAtPos(view, pos, side) {
|
|
7241
7241
|
let { node, offset, atom } = view.docView.domFromPos(pos, side < 0 ? -1 : 1);
|
|
7242
7242
|
let supportEmptyRange = webkit || gecko;
|
|
7243
|
-
if (node
|
|
7243
|
+
if (isText(node)) {
|
|
7244
7244
|
if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {
|
|
7245
7245
|
let rect = singleRect(textRange(node, offset, offset), side);
|
|
7246
7246
|
if (gecko && offset && /\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {
|
|
@@ -7267,26 +7267,26 @@ function coordsAtPos(view, pos, side) {
|
|
|
7267
7267
|
if (!view.state.doc.resolve(pos - (atom || 0)).parent.inlineContent) {
|
|
7268
7268
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
7269
7269
|
let before = node.childNodes[offset - 1];
|
|
7270
|
-
if (before
|
|
7270
|
+
if (isElt(before)) return flattenH(before.getBoundingClientRect(), false);
|
|
7271
7271
|
}
|
|
7272
7272
|
if (atom == null && offset < nodeSize(node)) {
|
|
7273
7273
|
let after = node.childNodes[offset];
|
|
7274
|
-
if (after
|
|
7274
|
+
if (isElt(after)) return flattenH(after.getBoundingClientRect(), true);
|
|
7275
7275
|
}
|
|
7276
7276
|
return flattenH(node.getBoundingClientRect(), side >= 0);
|
|
7277
7277
|
}
|
|
7278
7278
|
if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {
|
|
7279
7279
|
let before = node.childNodes[offset - 1];
|
|
7280
|
-
let target = before
|
|
7280
|
+
let target = isText(before) ? textRange(before, nodeSize(before) - (supportEmptyRange ? 0 : 1)) : isElt(before) && (before.nodeName != "BR" || !before.nextSibling) ? before : null;
|
|
7281
7281
|
if (target) return flattenV(singleRect(target, 1), false);
|
|
7282
7282
|
}
|
|
7283
7283
|
if (atom == null && offset < nodeSize(node)) {
|
|
7284
7284
|
let after = node.childNodes[offset];
|
|
7285
7285
|
while (after.pmViewDesc && after.pmViewDesc.ignoreForCoords) after = after.nextSibling;
|
|
7286
|
-
let target = !after ? null : after
|
|
7286
|
+
let target = !after ? null : isText(after) ? textRange(after, 0, supportEmptyRange ? 0 : 1) : isElt(after) ? after : null;
|
|
7287
7287
|
if (target) return flattenV(singleRect(target, -1), true);
|
|
7288
7288
|
}
|
|
7289
|
-
return flattenV(singleRect(node
|
|
7289
|
+
return flattenV(singleRect(isText(node) ? textRange(node) : node, -side), side >= 0);
|
|
7290
7290
|
}
|
|
7291
7291
|
function flattenV(rect, left) {
|
|
7292
7292
|
if (rect.width == 0) return rect;
|
|
@@ -7336,8 +7336,8 @@ function endOfTextblockVertical(view, state, dir) {
|
|
|
7336
7336
|
let coords = coordsAtPos(view, $pos.pos, 1);
|
|
7337
7337
|
for (let child = dom.firstChild; child; child = child.nextSibling) {
|
|
7338
7338
|
let boxes;
|
|
7339
|
-
if (child
|
|
7340
|
-
else if (child
|
|
7339
|
+
if (isElt(child)) boxes = child.getClientRects();
|
|
7340
|
+
else if (isText(child)) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();
|
|
7341
7341
|
else continue;
|
|
7342
7342
|
for (let i = 0; i < boxes.length; i++) {
|
|
7343
7343
|
let box = boxes[i];
|
|
@@ -7361,7 +7361,7 @@ function endOfTextblockHorizontal(view, state, dir) {
|
|
|
7361
7361
|
sel.modify("move", dir, "character");
|
|
7362
7362
|
let parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;
|
|
7363
7363
|
let { focusNode: newNode, focusOffset: newOff } = view.domSelectionRange();
|
|
7364
|
-
let result = newNode && !
|
|
7364
|
+
let result = newNode && !contains(parentDOM, newNode) || oldNode == newNode && oldOff == newOff;
|
|
7365
7365
|
try {
|
|
7366
7366
|
sel.collapse(anchorNode, anchorOffset);
|
|
7367
7367
|
if (oldNode && (oldNode != anchorNode || oldOff != anchorOffset) && sel.extend) sel.extend(oldNode, oldOff);
|
|
@@ -7443,7 +7443,7 @@ var ViewDesc = class {
|
|
|
7443
7443
|
return this.posAtStart + this.size - 2 * this.border;
|
|
7444
7444
|
}
|
|
7445
7445
|
localPosFromDOM(dom, offset, bias) {
|
|
7446
|
-
if (this.contentDOM && this.contentDOM
|
|
7446
|
+
if (this.contentDOM && contains(this.contentDOM, dom)) {
|
|
7447
7447
|
if (bias < 0) {
|
|
7448
7448
|
let domBefore, desc;
|
|
7449
7449
|
if (dom == this.contentDOM) domBefore = dom.childNodes[offset - 1];
|
|
@@ -7466,7 +7466,7 @@ var ViewDesc = class {
|
|
|
7466
7466
|
}
|
|
7467
7467
|
let atEnd;
|
|
7468
7468
|
if (dom == this.dom && this.contentDOM) atEnd = offset > domIndex(this.contentDOM);
|
|
7469
|
-
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = dom.compareDocumentPosition(this.contentDOM) &
|
|
7469
|
+
else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) atEnd = !!(dom.compareDocumentPosition(this.contentDOM) & 4);
|
|
7470
7470
|
else if (this.dom.firstChild) {
|
|
7471
7471
|
if (offset == 0) for (let search = dom;; search = search.parentNode) {
|
|
7472
7472
|
if (search == this.dom) {
|
|
@@ -7489,7 +7489,7 @@ var ViewDesc = class {
|
|
|
7489
7489
|
for (let first = true, cur = dom; cur; cur = cur.parentNode) {
|
|
7490
7490
|
let desc = this.getDesc(cur), nodeDOM;
|
|
7491
7491
|
if (desc && (!onlyNodes || desc.node)) {
|
|
7492
|
-
if (first && (nodeDOM = desc.nodeDOM) && !(nodeDOM
|
|
7492
|
+
if (first && (nodeDOM = desc.nodeDOM) && !(isElt(nodeDOM) ? contains(nodeDOM, dom) : nodeDOM == dom)) first = false;
|
|
7493
7493
|
else return desc;
|
|
7494
7494
|
}
|
|
7495
7495
|
}
|
|
@@ -7531,14 +7531,17 @@ var ViewDesc = class {
|
|
|
7531
7531
|
let i = 0, offset = 0;
|
|
7532
7532
|
for (let curPos = 0; i < this.children.length; i++) {
|
|
7533
7533
|
let child = this.children[i], end = curPos + child.size;
|
|
7534
|
-
if (end > pos
|
|
7534
|
+
if (end > pos) {
|
|
7535
7535
|
offset = pos - curPos;
|
|
7536
7536
|
break;
|
|
7537
7537
|
}
|
|
7538
7538
|
curPos = end;
|
|
7539
7539
|
}
|
|
7540
7540
|
if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side);
|
|
7541
|
-
for (
|
|
7541
|
+
for (; i > 0; i--) {
|
|
7542
|
+
let prev = this.children[i - 1];
|
|
7543
|
+
if (prev.size || !(prev instanceof BufferHackViewDesc || prev instanceof WidgetViewDesc && prev.side >= 0)) break;
|
|
7544
|
+
}
|
|
7542
7545
|
if (side <= 0) {
|
|
7543
7546
|
let prev, enter = true;
|
|
7544
7547
|
for (;; i--, enter = false) {
|
|
@@ -7618,7 +7621,7 @@ var ViewDesc = class {
|
|
|
7618
7621
|
}
|
|
7619
7622
|
domAfterPos(pos) {
|
|
7620
7623
|
let { node, offset } = this.domFromPos(pos, 0);
|
|
7621
|
-
if (node
|
|
7624
|
+
if (!isElt(node) || offset == node.childNodes.length) throw new RangeError("No node after pos " + pos);
|
|
7622
7625
|
return node.childNodes[offset];
|
|
7623
7626
|
}
|
|
7624
7627
|
setSelection(anchor, head, view, force = false) {
|
|
@@ -7635,7 +7638,7 @@ var ViewDesc = class {
|
|
|
7635
7638
|
let brKludge = false;
|
|
7636
7639
|
if ((gecko || safari) && anchor == head) {
|
|
7637
7640
|
let { node, offset } = anchorDOM;
|
|
7638
|
-
if (node
|
|
7641
|
+
if (isText(node)) {
|
|
7639
7642
|
brKludge = !!(offset && node.nodeValue[offset - 1] == "\n");
|
|
7640
7643
|
if (brKludge && offset == node.nodeValue.length) for (let scan = node, after; scan; scan = scan.parentNode) {
|
|
7641
7644
|
if (after = scan.nextSibling) {
|
|
@@ -7653,7 +7656,7 @@ var ViewDesc = class {
|
|
|
7653
7656
|
brKludge = prev && (prev.nodeName == "BR" || prev.contentEditable == "false");
|
|
7654
7657
|
}
|
|
7655
7658
|
}
|
|
7656
|
-
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode
|
|
7659
|
+
if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && isElt(selRange.focusNode)) {
|
|
7657
7660
|
let after = selRange.focusNode.childNodes[selRange.focusOffset];
|
|
7658
7661
|
if (after && after.contentEditable == "false") force = true;
|
|
7659
7662
|
}
|
|
@@ -7729,13 +7732,10 @@ var WidgetViewDesc = class extends ViewDesc {
|
|
|
7729
7732
|
if (self.parent) return self.parent.posBeforeChild(self);
|
|
7730
7733
|
});
|
|
7731
7734
|
if (!widget.type.spec.raw) {
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
}
|
|
7737
|
-
if (!dom.hasAttribute("contenteditable")) dom.contentEditable = "false";
|
|
7738
|
-
dom.classList.add("ProseMirror-widget");
|
|
7735
|
+
let elt = isElt(dom) ? dom : document.createElement("span");
|
|
7736
|
+
if (elt != dom) elt.appendChild(dom);
|
|
7737
|
+
if (!elt.hasAttribute("contenteditable")) elt.contentEditable = "false";
|
|
7738
|
+
elt.classList.add("ProseMirror-widget");
|
|
7739
7739
|
}
|
|
7740
7740
|
super(parent, [], dom, null);
|
|
7741
7741
|
this.widget = widget;
|
|
@@ -7858,7 +7858,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
7858
7858
|
let dom = spec && spec.dom, contentDOM = spec && spec.contentDOM;
|
|
7859
7859
|
if (node.isText) {
|
|
7860
7860
|
if (!dom) dom = document.createTextNode(node.text);
|
|
7861
|
-
else if (dom
|
|
7861
|
+
else if (!isText(dom)) throw new RangeError("Text must be rendered as a DOM text node");
|
|
7862
7862
|
} else if (!dom) {
|
|
7863
7863
|
let spec = DOMSerializer.renderSpec(document, node.type.spec.toDOM(node), null, node.attrs);
|
|
7864
7864
|
({dom, contentDOM} = spec);
|
|
@@ -7891,7 +7891,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
7891
7891
|
}
|
|
7892
7892
|
}
|
|
7893
7893
|
if (!rule.contentElement) {
|
|
7894
|
-
let found = addedNodes && addedNodes.find((n) => n
|
|
7894
|
+
let found = addedNodes && addedNodes.find((n) => isElt(n) && addedNodes.indexOf(n.parentNode) < 0 && this.dom.contains(n));
|
|
7895
7895
|
if (found) rule.contentElement = found;
|
|
7896
7896
|
else rule.getContent = () => Fragment$1.empty;
|
|
7897
7897
|
}
|
|
@@ -7913,18 +7913,21 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
7913
7913
|
let localComposition = composition && composition.pos > -1 ? composition : null;
|
|
7914
7914
|
let compositionInChild = composition && composition.pos < 0;
|
|
7915
7915
|
let updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);
|
|
7916
|
+
let addBuffers = this.node.inlineContent, atBufferPos = addBuffers && this.node.isBlock;
|
|
7916
7917
|
iterDeco(this.node, this.innerDeco, (widget, i, insideNode) => {
|
|
7917
7918
|
if (widget.spec.marks) updater.syncToMarks(widget.spec.marks, inline, view, i);
|
|
7918
7919
|
else if (widget.type.side >= 0 && !insideNode) updater.syncToMarks(i == this.node.childCount ? Mark$1.none : this.node.child(i).marks, inline, view, i);
|
|
7919
7920
|
updater.placeWidget(widget, view, off);
|
|
7920
7921
|
}, (child, outerDeco, innerDeco, i) => {
|
|
7921
7922
|
updater.syncToMarks(child.marks, inline, view, i);
|
|
7923
|
+
if (atBufferPos && child.isAtom && !child.isText) updater.addHackNode("IMG", updater.top);
|
|
7922
7924
|
let compIndex;
|
|
7923
7925
|
if (updater.findNodeMatch(child, outerDeco, innerDeco, i));
|
|
7924
7926
|
else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view));
|
|
7925
7927
|
else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i, off));
|
|
7926
7928
|
else updater.addNode(child, outerDeco, innerDeco, view, off);
|
|
7927
7929
|
off += child.nodeSize;
|
|
7930
|
+
if (addBuffers) atBufferPos = child.isAtom && !child.isText;
|
|
7928
7931
|
});
|
|
7929
7932
|
updater.syncToMarks([], inline, view, 0);
|
|
7930
7933
|
if (this.node.isTextblock) updater.addTextblockHacks();
|
|
@@ -7981,7 +7984,7 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
7981
7984
|
}
|
|
7982
7985
|
updateOuterDeco(outerDeco) {
|
|
7983
7986
|
if (sameOuterDeco(outerDeco, this.outerDeco)) return;
|
|
7984
|
-
let needsWrap = this.nodeDOM
|
|
7987
|
+
let needsWrap = !isElt(this.nodeDOM);
|
|
7985
7988
|
let oldDOM = this.dom;
|
|
7986
7989
|
this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));
|
|
7987
7990
|
if (this.dom != oldDOM) {
|
|
@@ -7991,13 +7994,13 @@ var NodeViewDesc = class NodeViewDesc extends ViewDesc {
|
|
|
7991
7994
|
this.outerDeco = outerDeco;
|
|
7992
7995
|
}
|
|
7993
7996
|
selectNode() {
|
|
7994
|
-
if (this.nodeDOM
|
|
7997
|
+
if (isElt(this.nodeDOM)) {
|
|
7995
7998
|
this.nodeDOM.classList.add("ProseMirror-selectednode");
|
|
7996
7999
|
if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.draggable = true;
|
|
7997
8000
|
}
|
|
7998
8001
|
}
|
|
7999
8002
|
deselectNode() {
|
|
8000
|
-
if (this.nodeDOM
|
|
8003
|
+
if (isElt(this.nodeDOM)) {
|
|
8001
8004
|
this.nodeDOM.classList.remove("ProseMirror-selectednode");
|
|
8002
8005
|
if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.removeAttribute("draggable");
|
|
8003
8006
|
}
|
|
@@ -8065,7 +8068,7 @@ var TextViewDesc = class TextViewDesc extends NodeViewDesc {
|
|
|
8065
8068
|
return this.node.text == text;
|
|
8066
8069
|
}
|
|
8067
8070
|
};
|
|
8068
|
-
var
|
|
8071
|
+
var BufferHackViewDesc = class extends ViewDesc {
|
|
8069
8072
|
parseRule() {
|
|
8070
8073
|
return { ignore: true };
|
|
8071
8074
|
}
|
|
@@ -8201,7 +8204,7 @@ function patchAttributes(dom, prev, cur) {
|
|
|
8201
8204
|
}
|
|
8202
8205
|
}
|
|
8203
8206
|
function applyOuterDeco(dom, deco, node) {
|
|
8204
|
-
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom
|
|
8207
|
+
return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, !isElt(dom)));
|
|
8205
8208
|
}
|
|
8206
8209
|
function sameOuterDeco(a, b) {
|
|
8207
8210
|
if (a.length != b.length) return false;
|
|
@@ -8391,14 +8394,14 @@ var ViewTreeUpdater = class {
|
|
|
8391
8394
|
dom.alt = "";
|
|
8392
8395
|
}
|
|
8393
8396
|
if (nodeName == "BR") dom.className = "ProseMirror-trailingBreak";
|
|
8394
|
-
let hack = new
|
|
8397
|
+
let hack = new BufferHackViewDesc(this.top, [], dom, null);
|
|
8395
8398
|
if (parent != this.top) parent.children.push(hack);
|
|
8396
8399
|
else parent.children.splice(this.index++, 0, hack);
|
|
8397
8400
|
this.changed = true;
|
|
8398
8401
|
}
|
|
8399
8402
|
}
|
|
8400
8403
|
isLocked(node) {
|
|
8401
|
-
return this.lock && (node == this.lock || node
|
|
8404
|
+
return this.lock && (node == this.lock || isElt(node) && node.contains(this.lock.parentNode));
|
|
8402
8405
|
}
|
|
8403
8406
|
};
|
|
8404
8407
|
function preMatch(frag, parentDesc) {
|
|
@@ -8546,10 +8549,15 @@ function selectionFromDOM(view, origin = null) {
|
|
|
8546
8549
|
if (selectionCollapsed(domSel)) {
|
|
8547
8550
|
anchor = head;
|
|
8548
8551
|
while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent;
|
|
8549
|
-
|
|
8550
|
-
if (nearestDesc && nearestDescNode.isAtom && NodeSelection.isSelectable(nearestDescNode) && nearestDesc.parent && !(nearestDescNode.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
8552
|
+
if (nearestDesc && nearestDesc.node.isAtom && NodeSelection.isSelectable(nearestDesc.node) && nearestDesc.parent && !(nearestDesc.node.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {
|
|
8551
8553
|
let pos = nearestDesc.posBefore;
|
|
8552
8554
|
selection = new NodeSelection(head == pos ? $head : doc.resolve(pos));
|
|
8555
|
+
} else if (gecko && origin == "key" && head > view.state.selection.to && isElt(domSel.focusNode) && domSel.focusOffset == domSel.focusNode.childNodes.length && nearestDesc && nearestDesc.posAtStart > view.state.selection.to) for (let scan = domSel.focusNode;; scan = scan.parentNode) {
|
|
8556
|
+
if (getComputedStyle(scan).overflow != "visible") {
|
|
8557
|
+
selection = Selection$1.findFrom(doc.resolve(nearestDesc.posAtStart), 1);
|
|
8558
|
+
break;
|
|
8559
|
+
}
|
|
8560
|
+
if (scan == nearestDesc.dom || scan.nextSibling || !scan.parentNode || !isElt(scan.parentNode)) break;
|
|
8553
8561
|
}
|
|
8554
8562
|
} else {
|
|
8555
8563
|
if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {
|
|
@@ -8687,7 +8695,7 @@ function hasSelection(view) {
|
|
|
8687
8695
|
let sel = view.domSelectionRange();
|
|
8688
8696
|
if (!sel.anchorNode) return false;
|
|
8689
8697
|
try {
|
|
8690
|
-
return view.dom
|
|
8698
|
+
return contains(view.dom, sel.anchorNode) && (view.editable || contains(view.dom, sel.focusNode));
|
|
8691
8699
|
} catch (_) {
|
|
8692
8700
|
return false;
|
|
8693
8701
|
}
|
|
@@ -8726,8 +8734,7 @@ function selectHorizontally(view, dir, mods) {
|
|
|
8726
8734
|
let nodePos = dir < 0 ? $head.pos - node.nodeSize : $head.pos;
|
|
8727
8735
|
if (!(node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;
|
|
8728
8736
|
if (NodeSelection.isSelectable(node)) return apply(view, new NodeSelection(dir < 0 ? view.state.doc.resolve($head.pos - node.nodeSize) : $head));
|
|
8729
|
-
else
|
|
8730
|
-
else return false;
|
|
8737
|
+
else return apply(view, new TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + node.nodeSize)));
|
|
8731
8738
|
}
|
|
8732
8739
|
} else if (sel instanceof NodeSelection && sel.node.isInline) return apply(view, new TextSelection(dir > 0 ? sel.$to : sel.$from));
|
|
8733
8740
|
else {
|
|
@@ -8736,12 +8743,9 @@ function selectHorizontally(view, dir, mods) {
|
|
|
8736
8743
|
return false;
|
|
8737
8744
|
}
|
|
8738
8745
|
}
|
|
8739
|
-
function nodeLen(node) {
|
|
8740
|
-
return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
|
|
8741
|
-
}
|
|
8742
8746
|
function isIgnorable(dom, dir) {
|
|
8743
8747
|
let desc = dom.pmViewDesc;
|
|
8744
|
-
return desc
|
|
8748
|
+
return desc ? desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != "BR") : isElt(dom) && dom.contentEditable == "false";
|
|
8745
8749
|
}
|
|
8746
8750
|
function skipIgnoredNodes(view, dir) {
|
|
8747
8751
|
return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);
|
|
@@ -8751,19 +8755,17 @@ function skipIgnoredNodesBefore(view) {
|
|
|
8751
8755
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
8752
8756
|
if (!node) return;
|
|
8753
8757
|
let moveNode, moveOffset, force = false;
|
|
8754
|
-
if (gecko && node
|
|
8758
|
+
if (gecko && isElt(node) && offset < nodeSize(node) && isIgnorable(node.childNodes[offset], -1)) force = true;
|
|
8755
8759
|
for (;;) if (offset > 0) {
|
|
8756
|
-
if (node
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
} else break;
|
|
8766
|
-
}
|
|
8760
|
+
if (!isElt(node)) break;
|
|
8761
|
+
let before = node.childNodes[offset - 1];
|
|
8762
|
+
if (isIgnorable(before, -1)) {
|
|
8763
|
+
moveNode = node;
|
|
8764
|
+
moveOffset = --offset;
|
|
8765
|
+
} else if (isText(before)) {
|
|
8766
|
+
node = before;
|
|
8767
|
+
offset = node.nodeValue.length;
|
|
8768
|
+
} else break;
|
|
8767
8769
|
} else if (isBlockNode(node)) break;
|
|
8768
8770
|
else {
|
|
8769
8771
|
let prev = node.previousSibling;
|
|
@@ -8778,7 +8780,7 @@ function skipIgnoredNodesBefore(view) {
|
|
|
8778
8780
|
offset = 0;
|
|
8779
8781
|
} else {
|
|
8780
8782
|
node = prev;
|
|
8781
|
-
offset =
|
|
8783
|
+
offset = nodeSize(node);
|
|
8782
8784
|
}
|
|
8783
8785
|
}
|
|
8784
8786
|
if (force) setSelFocus(view, node, offset);
|
|
@@ -8788,10 +8790,10 @@ function skipIgnoredNodesAfter(view) {
|
|
|
8788
8790
|
let sel = view.domSelectionRange();
|
|
8789
8791
|
let node = sel.focusNode, offset = sel.focusOffset;
|
|
8790
8792
|
if (!node) return;
|
|
8791
|
-
let len =
|
|
8793
|
+
let len = nodeSize(node);
|
|
8792
8794
|
let moveNode, moveOffset;
|
|
8793
8795
|
for (;;) if (offset < len) {
|
|
8794
|
-
if (node
|
|
8796
|
+
if (!isElt(node)) break;
|
|
8795
8797
|
let after = node.childNodes[offset];
|
|
8796
8798
|
if (isIgnorable(after, 1)) {
|
|
8797
8799
|
moveNode = node;
|
|
@@ -8812,7 +8814,7 @@ function skipIgnoredNodesAfter(view) {
|
|
|
8812
8814
|
} else {
|
|
8813
8815
|
node = next;
|
|
8814
8816
|
offset = 0;
|
|
8815
|
-
len =
|
|
8817
|
+
len = nodeSize(node);
|
|
8816
8818
|
}
|
|
8817
8819
|
}
|
|
8818
8820
|
if (moveNode) setSelFocus(view, moveNode, moveOffset);
|
|
@@ -8828,8 +8830,8 @@ function textNodeAfter(node, offset) {
|
|
|
8828
8830
|
}
|
|
8829
8831
|
while (node && offset < node.childNodes.length) {
|
|
8830
8832
|
let next = node.childNodes[offset];
|
|
8831
|
-
if (next
|
|
8832
|
-
if (next
|
|
8833
|
+
if (isText(next)) return next;
|
|
8834
|
+
if (isElt(next) && next.contentEditable == "false") break;
|
|
8833
8835
|
node = next;
|
|
8834
8836
|
offset = 0;
|
|
8835
8837
|
}
|
|
@@ -8841,14 +8843,14 @@ function textNodeBefore(node, offset) {
|
|
|
8841
8843
|
}
|
|
8842
8844
|
while (node && offset) {
|
|
8843
8845
|
let next = node.childNodes[offset - 1];
|
|
8844
|
-
if (next
|
|
8845
|
-
if (next
|
|
8846
|
+
if (isText(next)) return next;
|
|
8847
|
+
if (isElt(next) && next.contentEditable == "false") break;
|
|
8846
8848
|
node = next;
|
|
8847
8849
|
offset = node.childNodes.length;
|
|
8848
8850
|
}
|
|
8849
8851
|
}
|
|
8850
8852
|
function setSelFocus(view, node, offset) {
|
|
8851
|
-
if (node
|
|
8853
|
+
if (!isText(node)) {
|
|
8852
8854
|
let before, after;
|
|
8853
8855
|
if (after = textNodeAfter(node, offset)) {
|
|
8854
8856
|
node = after;
|
|
@@ -8930,7 +8932,7 @@ function switchEditable(view, node, state) {
|
|
|
8930
8932
|
function safariDownArrowBug(view) {
|
|
8931
8933
|
if (!safari || view.state.selection.$head.parentOffset > 0) return false;
|
|
8932
8934
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
8933
|
-
if (focusNode && focusNode
|
|
8935
|
+
if (focusNode && isElt(focusNode) && focusOffset == 0 && focusNode.firstChild && isElt(focusNode.firstChild) && focusNode.firstChild.contentEditable == "false") {
|
|
8934
8936
|
let child = focusNode.firstChild;
|
|
8935
8937
|
switchEditable(view, child, "true");
|
|
8936
8938
|
setTimeout(() => switchEditable(view, child, "false"), 20);
|
|
@@ -8977,7 +8979,7 @@ function serializeForClipboard(view, slice) {
|
|
|
8977
8979
|
let doc = detachedDoc(), wrap = doc.createElement("div");
|
|
8978
8980
|
wrap.appendChild(serializer.serializeFragment(content, { document: doc }));
|
|
8979
8981
|
let firstChild = wrap.firstChild, needsWrap, wrappers = 0;
|
|
8980
|
-
while (firstChild && firstChild
|
|
8982
|
+
while (firstChild && isElt(firstChild) && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {
|
|
8981
8983
|
for (let i = needsWrap.length - 1; i >= 0; i--) {
|
|
8982
8984
|
let wrapper = doc.createElement(needsWrap[i]);
|
|
8983
8985
|
while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);
|
|
@@ -8986,7 +8988,7 @@ function serializeForClipboard(view, slice) {
|
|
|
8986
8988
|
}
|
|
8987
8989
|
firstChild = wrap.firstChild;
|
|
8988
8990
|
}
|
|
8989
|
-
if (firstChild && firstChild
|
|
8991
|
+
if (firstChild && isElt(firstChild)) firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
|
|
8990
8992
|
return {
|
|
8991
8993
|
dom: wrap,
|
|
8992
8994
|
text: view.someProp("clipboardTextSerializer", (f) => f(slice, view)) || slice.content.textBetween(0, slice.content.size, "\n\n"),
|
|
@@ -9031,7 +9033,7 @@ function parseFromClipboard(view, text, html, plainText, $context) {
|
|
|
9031
9033
|
let sliceData = contextNode && /^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(contextNode.getAttribute("data-pm-slice") || "");
|
|
9032
9034
|
if (sliceData && sliceData[3]) for (let i = +sliceData[3]; i > 0; i--) {
|
|
9033
9035
|
let child = dom.firstChild;
|
|
9034
|
-
while (child && child
|
|
9036
|
+
while (child && !isElt(child)) child = child.nextSibling;
|
|
9035
9037
|
if (!child) break;
|
|
9036
9038
|
dom = child;
|
|
9037
9039
|
}
|
|
@@ -9184,11 +9186,10 @@ function addContext(slice, context) {
|
|
|
9184
9186
|
let type = schema.nodes[array[i]];
|
|
9185
9187
|
if (!type || type.hasRequiredAttrs()) break;
|
|
9186
9188
|
try {
|
|
9187
|
-
type.
|
|
9189
|
+
content = Fragment$1.from(type.create(array[i + 1], content));
|
|
9188
9190
|
} catch (e) {
|
|
9189
9191
|
break;
|
|
9190
9192
|
}
|
|
9191
|
-
content = Fragment$1.from(type.create(array[i + 1], content));
|
|
9192
9193
|
openStart++;
|
|
9193
9194
|
openEnd++;
|
|
9194
9195
|
}
|
|
@@ -9332,14 +9333,14 @@ function updateSelection(view, selection, origin) {
|
|
|
9332
9333
|
if (!view.focused) view.focus();
|
|
9333
9334
|
if (view.state.selection.eq(selection)) return;
|
|
9334
9335
|
let tr = view.state.tr.setSelection(selection);
|
|
9335
|
-
|
|
9336
|
+
tr.setMeta("pointer", true);
|
|
9336
9337
|
view.dispatch(tr);
|
|
9337
9338
|
}
|
|
9338
9339
|
function selectClickedLeaf(view, inside) {
|
|
9339
9340
|
if (inside == -1) return false;
|
|
9340
9341
|
let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
|
|
9341
9342
|
if (node && node.isAtom && NodeSelection.isSelectable(node)) {
|
|
9342
|
-
updateSelection(view, new NodeSelection($pos)
|
|
9343
|
+
updateSelection(view, new NodeSelection($pos));
|
|
9343
9344
|
return true;
|
|
9344
9345
|
}
|
|
9345
9346
|
return false;
|
|
@@ -9358,7 +9359,7 @@ function selectClickedNode(view, inside) {
|
|
|
9358
9359
|
}
|
|
9359
9360
|
}
|
|
9360
9361
|
if (selectAt != null) {
|
|
9361
|
-
updateSelection(view, NodeSelection.create(view.state.doc, selectAt)
|
|
9362
|
+
updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
|
|
9362
9363
|
return true;
|
|
9363
9364
|
} else return false;
|
|
9364
9365
|
}
|
|
@@ -9375,7 +9376,7 @@ function defaultTripleClick(view, inside, event) {
|
|
|
9375
9376
|
if (event.button != 0) return false;
|
|
9376
9377
|
let selection = selectionForTripleClick(view, inside, true), doc = view.state.doc;
|
|
9377
9378
|
if (!selection) return false;
|
|
9378
|
-
updateSelection(view, selection
|
|
9379
|
+
updateSelection(view, selection);
|
|
9379
9380
|
if (selection instanceof TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);
|
|
9380
9381
|
return true;
|
|
9381
9382
|
}
|
|
@@ -9461,7 +9462,7 @@ var LeftMouseDown = class extends MouseDown {
|
|
|
9461
9462
|
}
|
|
9462
9463
|
const target = flushed ? null : event.target;
|
|
9463
9464
|
const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
|
|
9464
|
-
this.target = targetDesc && targetDesc.nodeDOM
|
|
9465
|
+
this.target = targetDesc && isElt(targetDesc.nodeDOM) ? targetDesc.nodeDOM : null;
|
|
9465
9466
|
let { selection } = view.state;
|
|
9466
9467
|
if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)) this.mightDrag = {
|
|
9467
9468
|
node: targetNode,
|
|
@@ -9500,7 +9501,7 @@ var LeftMouseDown = class extends MouseDown {
|
|
|
9500
9501
|
if (this.allowDefault || !pos) setSelectionOrigin(this.view, "pointer");
|
|
9501
9502
|
else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) event.preventDefault();
|
|
9502
9503
|
else if (event.button == 0 && (this.flushed || safari && this.mightDrag && !this.mightDrag.node.isAtom || chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
|
|
9503
|
-
updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos))
|
|
9504
|
+
updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
|
|
9504
9505
|
event.preventDefault();
|
|
9505
9506
|
} else setSelectionOrigin(this.view, "pointer");
|
|
9506
9507
|
}
|
|
@@ -9536,7 +9537,7 @@ var TripleClickDrag = class extends MouseDown {
|
|
|
9536
9537
|
if (!target) return;
|
|
9537
9538
|
let { doc } = this.view.state, start = this.startSelection;
|
|
9538
9539
|
let [anchor, head] = target.from < start.from ? [start.to, target.from] : [start.from, target.to];
|
|
9539
|
-
updateSelection(this.view, TextSelection.create(doc, anchor, head)
|
|
9540
|
+
updateSelection(this.view, TextSelection.create(doc, anchor, head));
|
|
9540
9541
|
}
|
|
9541
9542
|
};
|
|
9542
9543
|
handlers.touchstart = (view) => {
|
|
@@ -9562,7 +9563,7 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
9562
9563
|
if (!view.composing) {
|
|
9563
9564
|
view.domObserver.flush();
|
|
9564
9565
|
let { state } = view, $pos = state.selection.$to;
|
|
9565
|
-
if (state.selection instanceof TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
|
|
9566
|
+
if (state.selection instanceof TextSelection && state.selection.empty && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some((m) => m.type.spec.inclusive === false) || chrome && windows$1 && selectionBeforeUneditable(view))) {
|
|
9566
9567
|
view.markCursor = view.state.storedMarks || $pos.marks();
|
|
9567
9568
|
endComposition(view, true);
|
|
9568
9569
|
view.markCursor = null;
|
|
@@ -9570,10 +9571,10 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
9570
9571
|
endComposition(view, !state.selection.empty);
|
|
9571
9572
|
if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {
|
|
9572
9573
|
let sel = view.domSelectionRange();
|
|
9573
|
-
for (let node = sel.focusNode, offset = sel.focusOffset; node && node
|
|
9574
|
+
for (let node = sel.focusNode, offset = sel.focusOffset; node && isElt(node) && offset != 0;) {
|
|
9574
9575
|
let before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];
|
|
9575
9576
|
if (!before) break;
|
|
9576
|
-
if (before
|
|
9577
|
+
if (isText(before)) {
|
|
9577
9578
|
let sel = view.domSelection();
|
|
9578
9579
|
if (sel) sel.collapse(before, before.nodeValue.length);
|
|
9579
9580
|
break;
|
|
@@ -9590,9 +9591,9 @@ editHandlers.compositionstart = editHandlers.compositionupdate = (view) => {
|
|
|
9590
9591
|
};
|
|
9591
9592
|
function selectionBeforeUneditable(view) {
|
|
9592
9593
|
let { focusNode, focusOffset } = view.domSelectionRange();
|
|
9593
|
-
if (!focusNode || focusNode
|
|
9594
|
+
if (!focusNode || !isElt(focusNode) || focusOffset >= focusNode.childNodes.length) return false;
|
|
9594
9595
|
let next = focusNode.childNodes[focusOffset];
|
|
9595
|
-
return next
|
|
9596
|
+
return isElt(next) && next.contentEditable == "false";
|
|
9596
9597
|
}
|
|
9597
9598
|
editHandlers.compositionend = (view, event) => {
|
|
9598
9599
|
if (view.composing) {
|
|
@@ -9745,7 +9746,7 @@ handlers.dragstart = (view, _event) => {
|
|
|
9745
9746
|
let node;
|
|
9746
9747
|
if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof NodeSelection ? sel.to - 1 : sel.to));
|
|
9747
9748
|
else if (mouseDown && mouseDown.mightDrag) node = NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);
|
|
9748
|
-
else if (event.target && event.target
|
|
9749
|
+
else if (event.target && isElt(event.target)) {
|
|
9749
9750
|
let desc = view.docView.nearestDesc(event.target, true);
|
|
9750
9751
|
if (desc && desc.node.type.spec.draggable && desc != view.docView) node = NodeSelection.create(view.state.doc, desc.posBefore);
|
|
9751
9752
|
}
|
|
@@ -10518,7 +10519,7 @@ var DOMObserver = class {
|
|
|
10518
10519
|
let desc = container && this.view.docView.nearestDesc(container);
|
|
10519
10520
|
if (desc && desc.ignoreMutation({
|
|
10520
10521
|
type: "selection",
|
|
10521
|
-
target: container
|
|
10522
|
+
target: isText(container) ? container.parentNode : container
|
|
10522
10523
|
})) {
|
|
10523
10524
|
this.setCurSelection();
|
|
10524
10525
|
return true;
|
|
@@ -10547,7 +10548,7 @@ var DOMObserver = class {
|
|
|
10547
10548
|
if (added.some((n) => n.nodeName == "BR") && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some((m) => m.type == "childList" && m.removedNodes.length))) {
|
|
10548
10549
|
for (let node of added) if (node.nodeName == "BR" && node.parentNode) {
|
|
10549
10550
|
let after = node.nextSibling;
|
|
10550
|
-
while (after && after
|
|
10551
|
+
while (after && isElt(after)) {
|
|
10551
10552
|
if (after.contentEditable == "false") {
|
|
10552
10553
|
node.parentNode.removeChild(node);
|
|
10553
10554
|
break;
|
|
@@ -10599,7 +10600,7 @@ var DOMObserver = class {
|
|
|
10599
10600
|
for (let i = 0; i < mut.addedNodes.length; i++) {
|
|
10600
10601
|
let node = mut.addedNodes[i];
|
|
10601
10602
|
added.push(node);
|
|
10602
|
-
if (node
|
|
10603
|
+
if (isText(node)) this.lastChangedTextNode = node;
|
|
10603
10604
|
}
|
|
10604
10605
|
if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {
|
|
10605
10606
|
from: desc.posBefore,
|
|
@@ -10698,7 +10699,7 @@ function fixUpBadSafariComposition(view, addedNodes) {
|
|
|
10698
10699
|
let parent = nextCell;
|
|
10699
10700
|
for (;;) {
|
|
10700
10701
|
let first = parent.firstChild;
|
|
10701
|
-
if (!first || first
|
|
10702
|
+
if (!first || !isElt(first) || first.contentEditable == "false" || /^(BR|IMG)$/.test(first.nodeName)) break;
|
|
10702
10703
|
parent = first;
|
|
10703
10704
|
}
|
|
10704
10705
|
parent.insertBefore(node, parent.firstChild);
|
|
@@ -10711,7 +10712,7 @@ function parseBetween(view, from_, to_, addedNodes) {
|
|
|
10711
10712
|
let domSel = view.domSelectionRange();
|
|
10712
10713
|
let find;
|
|
10713
10714
|
let anchor = domSel.anchorNode;
|
|
10714
|
-
if (anchor && view.dom
|
|
10715
|
+
if (anchor && contains(view.dom, anchor)) {
|
|
10715
10716
|
find = [{
|
|
10716
10717
|
node: anchor,
|
|
10717
10718
|
offset: domSel.anchorOffset
|
|
@@ -10805,7 +10806,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
10805
10806
|
view.input.lastKeyCode = null;
|
|
10806
10807
|
let change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);
|
|
10807
10808
|
if (change) view.input.domChangeCount++;
|
|
10808
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => n
|
|
10809
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some((n) => isElt(n) && !isInline.test(n.nodeName)) && (!change || change.endA >= change.endB) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
10809
10810
|
view.input.lastIOSEnter = 0;
|
|
10810
10811
|
return;
|
|
10811
10812
|
}
|
|
@@ -10843,7 +10844,7 @@ function readDOMChange(view, from, to, typeOver, addedNodes) {
|
|
|
10843
10844
|
let $to = parse.doc.resolveNoCache(change.endB - parse.from);
|
|
10844
10845
|
let $fromA = doc.resolve(change.start);
|
|
10845
10846
|
let inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;
|
|
10846
|
-
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange &&
|
|
10847
|
+
if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some((n) => n.nodeName == "DIV" || n.nodeName == "P")) || !inlineChange && looksLikeEnter(parse.doc, $from.pos, $to.pos)) && view.someProp("handleKeyDown", (f) => f(view, keyEvent(13, "Enter")))) {
|
|
10847
10848
|
view.input.lastIOSEnter = 0;
|
|
10848
10849
|
return;
|
|
10849
10850
|
}
|
|
@@ -10931,6 +10932,14 @@ function looksLikeBackspace(old, start, end, $newStart, $newEnd) {
|
|
|
10931
10932
|
if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;
|
|
10932
10933
|
return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);
|
|
10933
10934
|
}
|
|
10935
|
+
function looksLikeEnter(content, from, to) {
|
|
10936
|
+
let newTextlines = 0, newLeaves = 0;
|
|
10937
|
+
content.nodesBetween(from, to, (node, pos) => {
|
|
10938
|
+
if (node.isTextblock && pos >= from && pos < to) newTextlines++;
|
|
10939
|
+
else if (node.isText ? /\S/.test(node.text.slice(Math.max(0, from - pos), Math.min(node.nodeSize, to - pos))) : node.isLeaf) newLeaves++;
|
|
10940
|
+
});
|
|
10941
|
+
return newLeaves == 0 && newTextlines == 1;
|
|
10942
|
+
}
|
|
10934
10943
|
function skipClosingAndOpening($pos, fromEnd, mayOpen) {
|
|
10935
10944
|
let depth = $pos.depth, end = fromEnd ? $pos.end() : $pos.pos;
|
|
10936
10945
|
while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {
|
|
@@ -11155,11 +11164,11 @@ var EditorView = class {
|
|
|
11155
11164
|
*/
|
|
11156
11165
|
scrollToSelection() {
|
|
11157
11166
|
let startDOM = this.domSelectionRange().focusNode;
|
|
11158
|
-
if (!startDOM || !this.dom
|
|
11167
|
+
if (!startDOM || !contains(this.dom, startDOM));
|
|
11159
11168
|
else if (this.someProp("handleScrollToSelection", (f) => f(this)));
|
|
11160
11169
|
else if (this.state.selection instanceof NodeSelection) {
|
|
11161
11170
|
let target = this.docView.domAfterPos(this.state.selection.from);
|
|
11162
|
-
if (target
|
|
11171
|
+
if (isElt(target)) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);
|
|
11163
11172
|
} else scrollRectIntoView(this, this.coordsAtPos(this.state.selection.head, 1), startDOM);
|
|
11164
11173
|
}
|
|
11165
11174
|
destroyPluginViews() {
|
|
@@ -11388,7 +11397,7 @@ var EditorView = class {
|
|
|
11388
11397
|
@internal
|
|
11389
11398
|
*/
|
|
11390
11399
|
domSelectionRange() {
|
|
11391
|
-
let sel = this.domSelection();
|
|
11400
|
+
let sel = this.dom.isConnected !== false && this.domSelection();
|
|
11392
11401
|
if (!sel) return {
|
|
11393
11402
|
focusNode: null,
|
|
11394
11403
|
focusOffset: 0,
|
|
@@ -26935,15 +26944,19 @@ var controlUIStyles = `
|
|
|
26935
26944
|
outline-offset: 2px;
|
|
26936
26945
|
}
|
|
26937
26946
|
|
|
26938
|
-
[
|
|
26947
|
+
[data-bge-structure-change-message] {
|
|
26939
26948
|
margin-block-start: 0.5rem;
|
|
26940
26949
|
padding: 0.5rem;
|
|
26941
|
-
background-color: var(--bge-
|
|
26942
|
-
border: 1px solid var(--bge-
|
|
26950
|
+
background-color: var(--bge-notice-background-color, #f4f5f7);
|
|
26951
|
+
border: 1px solid var(--bge-notice-border-color, var(--bge-border-color, #d6d8de));
|
|
26943
26952
|
border-radius: var(--border-radius);
|
|
26944
|
-
color: var(--bge-
|
|
26953
|
+
color: var(--bge-notice-text-color, #4a4f5c);
|
|
26945
26954
|
font-size: 0.875rem;
|
|
26946
26955
|
}
|
|
26956
|
+
|
|
26957
|
+
[data-bge-structure-change-message]:empty {
|
|
26958
|
+
display: none;
|
|
26959
|
+
}
|
|
26947
26960
|
`;
|
|
26948
26961
|
var editorContentStyles = (css) => `
|
|
26949
26962
|
:where(html, body) {
|
|
@@ -27096,6 +27109,7 @@ var TextOnlyModeController = class {
|
|
|
27096
27109
|
for (const el of editableElements) el.setAttribute("contenteditable", "plaintext-only");
|
|
27097
27110
|
}
|
|
27098
27111
|
};
|
|
27112
|
+
var STRUCTURE_CHANGE_MESSAGE = "デザインモードで表示できないHTML構造が含まれているため、デザインモードに切り替えはできません。";
|
|
27099
27113
|
function defineBgeWysiwygElement(options, global = window) {
|
|
27100
27114
|
if (options?.extensions) BgeWysiwygElement.extensions = options.extensions;
|
|
27101
27115
|
if (options?.wrapperElement) BgeWysiwygElement.wrapperElement = options.wrapperElement;
|
|
@@ -27311,8 +27325,7 @@ var BgeWysiwygElement = class BgeWysiwygElement extends HTMLElement {
|
|
|
27311
27325
|
const label = this.getAttribute("label") ?? "内容";
|
|
27312
27326
|
const itemName = this.getAttribute("item-name");
|
|
27313
27327
|
const messageId = `bge-structure-change-message-${Math.random().toString(36).slice(2, 11)}`;
|
|
27314
|
-
|
|
27315
|
-
this.shadowRoot.innerHTML = `<div data-bge-mode="wysiwyg"><iframe></iframe><textarea aria-label="${label} HTML" aria-describedby="${messageId}"></textarea><div id="${messageId}" role="alert" aria-live="polite" style="display: none;">${structureChangeMessage}</div></div>`;
|
|
27328
|
+
this.shadowRoot.innerHTML = `<div data-bge-mode="wysiwyg"><iframe></iframe><textarea aria-label="${label} HTML"></textarea><div id="${messageId}" role="status" data-bge-structure-change-message></div></div>`;
|
|
27316
27329
|
const preview = this.shadowRoot.querySelector("iframe");
|
|
27317
27330
|
if (!preview || !preview.contentWindow || !preview.contentDocument) throw new Error("Not supported iframe in shadow DOM");
|
|
27318
27331
|
this.#editorRoot = preview.contentDocument.createElement("div");
|
|
@@ -27336,7 +27349,7 @@ var BgeWysiwygElement = class BgeWysiwygElement extends HTMLElement {
|
|
|
27336
27349
|
}
|
|
27337
27350
|
if (!textarea) throw new Error("Not supported textarea in shadow DOM");
|
|
27338
27351
|
this.#textarea = textarea;
|
|
27339
|
-
this.#structureChangeMessage = this.shadowRoot.querySelector(
|
|
27352
|
+
this.#structureChangeMessage = this.shadowRoot.querySelector("[data-bge-structure-change-message]");
|
|
27340
27353
|
const extensions = [src_default$2.configure({ link: { HTMLAttributes: {
|
|
27341
27354
|
target: null,
|
|
27342
27355
|
rel: null
|
|
@@ -27423,8 +27436,13 @@ var BgeWysiwygElement = class BgeWysiwygElement extends HTMLElement {
|
|
|
27423
27436
|
}
|
|
27424
27437
|
#updateStructureChangeMessage() {
|
|
27425
27438
|
if (!this.#structureChangeMessage) return;
|
|
27426
|
-
if (this.mode === "html" && this.#hasStructureChange)
|
|
27427
|
-
|
|
27439
|
+
if (this.mode === "html" && this.#hasStructureChange) {
|
|
27440
|
+
this.#structureChangeMessage.textContent = STRUCTURE_CHANGE_MESSAGE;
|
|
27441
|
+
this.#textarea?.setAttribute("aria-describedby", this.#structureChangeMessage.id);
|
|
27442
|
+
} else {
|
|
27443
|
+
this.#structureChangeMessage.textContent = "";
|
|
27444
|
+
this.#textarea?.removeAttribute("aria-describedby");
|
|
27445
|
+
}
|
|
27428
27446
|
}
|
|
27429
27447
|
static extensions = null;
|
|
27430
27448
|
static wrapperElement = null;
|
|
@@ -28069,7 +28087,7 @@ function parseConfig(config) {
|
|
|
28069
28087
|
}
|
|
28070
28088
|
//#endregion
|
|
28071
28089
|
//#region src/index.tsx
|
|
28072
|
-
var version = "4.0.0-alpha.
|
|
28090
|
+
var version = "4.0.0-alpha.76";
|
|
28073
28091
|
/**
|
|
28074
28092
|
* 本稿⇄下書き切替UIをビューエリアの直前にマウントする
|
|
28075
28093
|
*
|