quoin-editor 1.1.0 → 1.1.2
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/CHANGELOG.md +20 -0
- package/dist/ai.cjs +80 -79
- package/dist/ai.cjs.map +1 -1
- package/dist/ai.js +8 -7
- package/dist/ai.js.map +1 -1
- package/dist/catalogue.cjs +26 -25
- package/dist/catalogue.cjs.map +1 -1
- package/dist/catalogue.js +17 -16
- package/dist/catalogue.js.map +1 -1
- package/dist/{chunk-RHQPAW4W.js → chunk-36OSSZDK.js} +6 -6
- package/dist/{chunk-RHQPAW4W.js.map → chunk-36OSSZDK.js.map} +1 -1
- package/dist/{chunk-3BXUGX5F.js → chunk-3G4ZWUUY.js} +4 -16
- package/dist/chunk-3G4ZWUUY.js.map +1 -0
- package/dist/{chunk-DTQFYHDJ.cjs → chunk-5DEPLPDS.cjs} +28 -28
- package/dist/{chunk-DTQFYHDJ.cjs.map → chunk-5DEPLPDS.cjs.map} +1 -1
- package/dist/{chunk-2EQ6FKSK.js → chunk-5LWJDRWD.js} +3 -3
- package/dist/{chunk-2EQ6FKSK.js.map → chunk-5LWJDRWD.js.map} +1 -1
- package/dist/{chunk-ITXCE6KL.js → chunk-5QNNF5ZJ.js} +5 -5
- package/dist/{chunk-ITXCE6KL.js.map → chunk-5QNNF5ZJ.js.map} +1 -1
- package/dist/{chunk-AIS37SL2.cjs → chunk-6H76FAI3.cjs} +79 -7
- package/dist/chunk-6H76FAI3.cjs.map +1 -0
- package/dist/{chunk-SKZC4K5S.cjs → chunk-6QLA3JOU.cjs} +90 -90
- package/dist/{chunk-SKZC4K5S.cjs.map → chunk-6QLA3JOU.cjs.map} +1 -1
- package/dist/{chunk-QEMGOL5L.cjs → chunk-ABVSP2XR.cjs} +325 -295
- package/dist/chunk-ABVSP2XR.cjs.map +1 -0
- package/dist/{chunk-KSF2HILJ.js → chunk-AQNVYFEU.js} +6 -6
- package/dist/{chunk-KSF2HILJ.js.map → chunk-AQNVYFEU.js.map} +1 -1
- package/dist/{chunk-ZTLYHRZT.cjs → chunk-BMEEEI43.cjs} +13 -13
- package/dist/{chunk-ZTLYHRZT.cjs.map → chunk-BMEEEI43.cjs.map} +1 -1
- package/dist/{chunk-RIIXJWBR.cjs → chunk-E52VO5JT.cjs} +4 -4
- package/dist/{chunk-RIIXJWBR.cjs.map → chunk-E52VO5JT.cjs.map} +1 -1
- package/dist/{chunk-WDO6DBYU.cjs → chunk-EABO523V.cjs} +31 -31
- package/dist/{chunk-WDO6DBYU.cjs.map → chunk-EABO523V.cjs.map} +1 -1
- package/dist/{chunk-TBCHYHNU.js → chunk-EDKQQKQR.js} +6 -6
- package/dist/{chunk-TBCHYHNU.js.map → chunk-EDKQQKQR.js.map} +1 -1
- package/dist/{chunk-IXVGHH7F.cjs → chunk-ES2QYHXL.cjs} +45 -45
- package/dist/{chunk-IXVGHH7F.cjs.map → chunk-ES2QYHXL.cjs.map} +1 -1
- package/dist/{chunk-QC35D2AU.js → chunk-G7HK4OHE.js} +24 -14
- package/dist/chunk-G7HK4OHE.js.map +1 -0
- package/dist/{chunk-L4D23LM2.js → chunk-IVWFPFUG.js} +4 -4
- package/dist/{chunk-L4D23LM2.js.map → chunk-IVWFPFUG.js.map} +1 -1
- package/dist/{chunk-SAEQMDAU.js → chunk-J37ORWSG.js} +7 -7
- package/dist/{chunk-SAEQMDAU.js.map → chunk-J37ORWSG.js.map} +1 -1
- package/dist/{chunk-XJDPQFPU.js → chunk-JEFQNZO4.js} +40 -10
- package/dist/chunk-JEFQNZO4.js.map +1 -0
- package/dist/{chunk-TNN6Z52D.js → chunk-JHA23OOK.js} +6 -6
- package/dist/{chunk-TNN6Z52D.js.map → chunk-JHA23OOK.js.map} +1 -1
- package/dist/{chunk-7FAVFJAS.js → chunk-JYO2T4MC.js} +3 -3
- package/dist/{chunk-7FAVFJAS.js.map → chunk-JYO2T4MC.js.map} +1 -1
- package/dist/{chunk-HQ43EIYO.cjs → chunk-K5HWMBWH.cjs} +9 -9
- package/dist/{chunk-HQ43EIYO.cjs.map → chunk-K5HWMBWH.cjs.map} +1 -1
- package/dist/{chunk-OM7E43ZN.cjs → chunk-KFIE4OJE.cjs} +15 -15
- package/dist/{chunk-OM7E43ZN.cjs.map → chunk-KFIE4OJE.cjs.map} +1 -1
- package/dist/{chunk-ZWB7SZVI.cjs → chunk-KKRQDVBJ.cjs} +24 -24
- package/dist/{chunk-ZWB7SZVI.cjs.map → chunk-KKRQDVBJ.cjs.map} +1 -1
- package/dist/{chunk-VFSVN5IQ.cjs → chunk-M5FREXRQ.cjs} +218 -218
- package/dist/{chunk-VFSVN5IQ.cjs.map → chunk-M5FREXRQ.cjs.map} +1 -1
- package/dist/{chunk-7SVKLWDT.cjs → chunk-OAAYF2EI.cjs} +13 -26
- package/dist/chunk-OAAYF2EI.cjs.map +1 -0
- package/dist/{chunk-HTLWPSMU.js → chunk-OIQAO7QU.js} +4 -4
- package/dist/{chunk-HTLWPSMU.js.map → chunk-OIQAO7QU.js.map} +1 -1
- package/dist/{chunk-3QRVAI53.cjs → chunk-P3T5XBYW.cjs} +6 -6
- package/dist/{chunk-3QRVAI53.cjs.map → chunk-P3T5XBYW.cjs.map} +1 -1
- package/dist/{chunk-NO3KTZDY.cjs → chunk-PNMBRBAT.cjs} +4 -4
- package/dist/{chunk-NO3KTZDY.cjs.map → chunk-PNMBRBAT.cjs.map} +1 -1
- package/dist/{chunk-MGMA5PEL.js → chunk-PRXIYHSX.js} +6 -6
- package/dist/{chunk-MGMA5PEL.js.map → chunk-PRXIYHSX.js.map} +1 -1
- package/dist/{chunk-QWS7KH3K.cjs → chunk-QAI3CM7V.cjs} +55 -55
- package/dist/{chunk-QWS7KH3K.cjs.map → chunk-QAI3CM7V.cjs.map} +1 -1
- package/dist/{chunk-L6OW2FL3.js → chunk-QLDXQOHQ.js} +79 -8
- package/dist/chunk-QLDXQOHQ.js.map +1 -0
- package/dist/{chunk-TYZSB7JT.js → chunk-RUC5OZXO.js} +3 -3
- package/dist/{chunk-TYZSB7JT.js.map → chunk-RUC5OZXO.js.map} +1 -1
- package/dist/{chunk-WHV5ZSIO.cjs → chunk-UGAOEZ3O.cjs} +15 -15
- package/dist/{chunk-WHV5ZSIO.cjs.map → chunk-UGAOEZ3O.cjs.map} +1 -1
- package/dist/{chunk-PJCHSHM3.js → chunk-V2ZBA5VC.js} +8 -8
- package/dist/{chunk-PJCHSHM3.js.map → chunk-V2ZBA5VC.js.map} +1 -1
- package/dist/{chunk-ACSEYJJF.cjs → chunk-VSUGJZ7G.cjs} +135 -125
- package/dist/chunk-VSUGJZ7G.cjs.map +1 -0
- package/dist/{chunk-LY2D45F2.cjs → chunk-XJ32XESJ.cjs} +98 -98
- package/dist/{chunk-LY2D45F2.cjs.map → chunk-XJ32XESJ.cjs.map} +1 -1
- package/dist/{chunk-JZJIWRF3.js → chunk-ZEQXMRJW.js} +3 -3
- package/dist/{chunk-JZJIWRF3.js.map → chunk-ZEQXMRJW.js.map} +1 -1
- package/dist/{chunk-HWEK7EX5.js → chunk-ZPGA5UIY.js} +7 -7
- package/dist/{chunk-HWEK7EX5.js.map → chunk-ZPGA5UIY.js.map} +1 -1
- package/dist/comments.cjs +60 -59
- package/dist/comments.cjs.map +1 -1
- package/dist/comments.js +8 -7
- package/dist/comments.js.map +1 -1
- package/dist/diff.cjs +27 -27
- package/dist/diff.js +3 -3
- package/dist/docx.cjs +30 -30
- package/dist/docx.js +3 -3
- package/dist/embed.cjs +11 -10
- package/dist/embed.cjs.map +1 -1
- package/dist/embed.js +8 -7
- package/dist/embed.js.map +1 -1
- package/dist/emoji.cjs +11 -10
- package/dist/emoji.cjs.map +1 -1
- package/dist/emoji.js +7 -6
- package/dist/emoji.js.map +1 -1
- package/dist/engine.cjs +58 -58
- package/dist/engine.js +3 -3
- package/dist/find.cjs +12 -11
- package/dist/find.cjs.map +1 -1
- package/dist/find.js +7 -6
- package/dist/find.js.map +1 -1
- package/dist/headless.cjs +76 -75
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.js +5 -4
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +88 -87
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/math.cjs +12 -11
- package/dist/math.cjs.map +1 -1
- package/dist/math.js +9 -8
- package/dist/math.js.map +1 -1
- package/dist/mention.cjs +12 -11
- package/dist/mention.cjs.map +1 -1
- package/dist/mention.js +9 -8
- package/dist/mention.js.map +1 -1
- package/dist/presence.cjs +40 -39
- package/dist/presence.cjs.map +1 -1
- package/dist/presence.js +9 -8
- package/dist/presence.js.map +1 -1
- package/dist/stats.cjs +12 -11
- package/dist/stats.cjs.map +1 -1
- package/dist/stats.js +8 -7
- package/dist/stats.js.map +1 -1
- package/dist/table.cjs +27 -26
- package/dist/table.cjs.map +1 -1
- package/dist/table.js +7 -6
- package/dist/table.js.map +1 -1
- package/dist/toc.cjs +11 -10
- package/dist/toc.cjs.map +1 -1
- package/dist/toc.js +7 -6
- package/dist/toc.js.map +1 -1
- package/dist/view.cjs +4 -4
- package/dist/view.js +2 -2
- package/dist/yjs.cjs +119 -119
- package/dist/yjs.js +5 -5
- package/package.json +2 -1
- package/dist/chunk-3BXUGX5F.js.map +0 -1
- package/dist/chunk-7SVKLWDT.cjs.map +0 -1
- package/dist/chunk-ACSEYJJF.cjs.map +0 -1
- package/dist/chunk-AIS37SL2.cjs.map +0 -1
- package/dist/chunk-L6OW2FL3.js.map +0 -1
- package/dist/chunk-QC35D2AU.js.map +0 -1
- package/dist/chunk-QEMGOL5L.cjs.map +0 -1
- package/dist/chunk-XJDPQFPU.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkM5FREXRQ_cjs = require('./chunk-M5FREXRQ.cjs');
|
|
4
|
+
var chunk6H76FAI3_cjs = require('./chunk-6H76FAI3.cjs');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var reactDom = require('react-dom');
|
|
7
7
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -34,7 +34,7 @@ function isCrossSelection(selection) {
|
|
|
34
34
|
}
|
|
35
35
|
function selectionDecorations(state, mode) {
|
|
36
36
|
if (mode !== "decorations" || !isCrossSelection(state.selection)) return [];
|
|
37
|
-
return
|
|
37
|
+
return chunkM5FREXRQ_cjs.markRanges(state).map(({ block, region, from, to }) => ({
|
|
38
38
|
kind: "inline",
|
|
39
39
|
block,
|
|
40
40
|
region,
|
|
@@ -45,9 +45,9 @@ function selectionDecorations(state, mode) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// src/view/dom/attributes.ts
|
|
48
|
-
var sortedEntries = (attrs) =>
|
|
48
|
+
var sortedEntries = (attrs) => chunk6H76FAI3_cjs.dataAttributes(attrs, "");
|
|
49
49
|
function setAttributes(element, attrs, prefix = "") {
|
|
50
|
-
for (const [name, value] of
|
|
50
|
+
for (const [name, value] of chunk6H76FAI3_cjs.writtenAttrs(chunk6H76FAI3_cjs.dataAttributes(attrs, prefix))) element.setAttribute(name, value);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// src/view/dom/segments.ts
|
|
@@ -62,7 +62,7 @@ function decorationRanges(decorations, length) {
|
|
|
62
62
|
return ranges;
|
|
63
63
|
}
|
|
64
64
|
function toSegments(inline, decorations) {
|
|
65
|
-
const length =
|
|
65
|
+
const length = chunk6H76FAI3_cjs.inlineLength(inline);
|
|
66
66
|
const ranges = decorationRanges(decorations, length);
|
|
67
67
|
const widgets = decorations.filter((decoration) => decoration.kind === "widget").map((decoration) => ({ decoration, at: Math.min(Math.max(decoration.offset, 0), length) })).sort((a, b) => a.at - b.at || (a.decoration.side ?? 1) - (b.decoration.side ?? 1));
|
|
68
68
|
const edges = [...ranges.flatMap((range) => [range.from, range.to]), ...widgets.map((widget) => widget.at)];
|
|
@@ -78,7 +78,7 @@ function toSegments(inline, decorations) {
|
|
|
78
78
|
};
|
|
79
79
|
let start = 0;
|
|
80
80
|
for (const node of inline) {
|
|
81
|
-
const end = start +
|
|
81
|
+
const end = start + chunk6H76FAI3_cjs.nodeLength(node);
|
|
82
82
|
if (node.kind === "atom") {
|
|
83
83
|
placeWidgets(start);
|
|
84
84
|
segments.push({ kind: "atom", node, decorations: covering(start, end), from: start });
|
|
@@ -121,6 +121,11 @@ function segmentSignature(segment) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
// src/view/dom/decoration-attrs.ts
|
|
125
|
+
function withoutEventHandlers(attrs) {
|
|
126
|
+
return Object.fromEntries(Object.entries(attrs).filter(([name]) => !/^on/i.test(name)));
|
|
127
|
+
}
|
|
128
|
+
|
|
124
129
|
// src/view/dom/mark-elements.ts
|
|
125
130
|
function create(doc, tag, attributes) {
|
|
126
131
|
const element = doc.createElement(tag);
|
|
@@ -128,7 +133,7 @@ function create(doc, tag, attributes) {
|
|
|
128
133
|
return element;
|
|
129
134
|
}
|
|
130
135
|
function linkElement({ href = "", title } = {}, doc) {
|
|
131
|
-
const safe =
|
|
136
|
+
const safe = chunk6H76FAI3_cjs.sanitizeHref(href);
|
|
132
137
|
if (safe === null) return create(doc, "span", [["data-quoin-link", ""]]);
|
|
133
138
|
const anchor = create(doc, "a", [["href", safe], ["data-quoin-link", ""]]);
|
|
134
139
|
if (title) anchor.title = title;
|
|
@@ -136,8 +141,8 @@ function linkElement({ href = "", title } = {}, doc) {
|
|
|
136
141
|
}
|
|
137
142
|
function markElement2(mark2, doc) {
|
|
138
143
|
if (mark2.type === "link") return linkElement(mark2.attrs, doc);
|
|
139
|
-
const { tag, attrs } =
|
|
140
|
-
return create(doc, tag,
|
|
144
|
+
const { tag, attrs } = chunk6H76FAI3_cjs.markElement(mark2);
|
|
145
|
+
return create(doc, tag, chunk6H76FAI3_cjs.writtenAttrs(attrs));
|
|
141
146
|
}
|
|
142
147
|
|
|
143
148
|
// src/view/dom/wrappers.ts
|
|
@@ -145,7 +150,7 @@ var created = /* @__PURE__ */ new WeakSet();
|
|
|
145
150
|
function decorationElement(attrs, doc) {
|
|
146
151
|
const element = doc.createElement("span");
|
|
147
152
|
element.setAttribute("data-quoin-deco", "");
|
|
148
|
-
setAttributes(element, attrs);
|
|
153
|
+
setAttributes(element, withoutEventHandlers(attrs));
|
|
149
154
|
return element;
|
|
150
155
|
}
|
|
151
156
|
function wrapperDepth(marks, decorations) {
|
|
@@ -334,8 +339,8 @@ function reconcileChildren(parent, specs) {
|
|
|
334
339
|
// src/view/dom/text-diff.ts
|
|
335
340
|
function textDiff(before, after, caretHint) {
|
|
336
341
|
if (before === after) return null;
|
|
337
|
-
const prefix =
|
|
338
|
-
const suffix =
|
|
342
|
+
const prefix = chunkM5FREXRQ_cjs.commonPrefix(before, after);
|
|
343
|
+
const suffix = chunkM5FREXRQ_cjs.commonSuffix(before, after);
|
|
339
344
|
const shared = Math.min(suffix, Math.min(before.length, after.length) - prefix);
|
|
340
345
|
const removed = before.length - prefix - shared;
|
|
341
346
|
const inserted = after.length - prefix - shared;
|
|
@@ -440,12 +445,12 @@ function specsFor(segment, options, doc) {
|
|
|
440
445
|
}
|
|
441
446
|
}
|
|
442
447
|
function needsFiller(inline) {
|
|
443
|
-
const content =
|
|
448
|
+
const content = chunk6H76FAI3_cjs.inlineText(inline);
|
|
444
449
|
return content === "" || content.endsWith("\n");
|
|
445
450
|
}
|
|
446
451
|
function renderInline(host, inline, decorations, options = {}) {
|
|
447
452
|
const doc = host.ownerDocument;
|
|
448
|
-
const length =
|
|
453
|
+
const length = chunk6H76FAI3_cjs.inlineLength(inline);
|
|
449
454
|
const specs = toSegments(inline, decorations).flatMap((segment) => specsFor(segment, options, doc));
|
|
450
455
|
if (needsFiller(inline)) specs.push(fillerSpec(doc, length));
|
|
451
456
|
reconcileChildren(host, specs);
|
|
@@ -523,10 +528,10 @@ function readSelection(registry, domSelection, blockAt2 = () => void 0) {
|
|
|
523
528
|
if (!domSelection || !anchorNode || !focusNode) return null;
|
|
524
529
|
const anchor = domToPos(registry, anchorNode, domSelection.anchorOffset);
|
|
525
530
|
const head = domToPos(registry, focusNode, domSelection.focusOffset);
|
|
526
|
-
if (anchor && head) return
|
|
531
|
+
if (anchor && head) return chunkM5FREXRQ_cjs.textSelection(anchor, head);
|
|
527
532
|
if (anchor || head || registry.locate(anchorNode) || registry.locate(focusNode)) return null;
|
|
528
533
|
const block = blockAt2(anchorNode);
|
|
529
|
-
return block !== void 0 && block === blockAt2(focusNode) ?
|
|
534
|
+
return block !== void 0 && block === blockAt2(focusNode) ? chunkM5FREXRQ_cjs.nodeSelection(block) : null;
|
|
530
535
|
}
|
|
531
536
|
function selectBlock(domSelection, element) {
|
|
532
537
|
if (!element) return false;
|
|
@@ -543,7 +548,7 @@ function writeSelection(registry, selection, domSelection, blockElement) {
|
|
|
543
548
|
if (selection.kind !== "text") return false;
|
|
544
549
|
const { anchor, head } = selection;
|
|
545
550
|
if (anchor.block !== head.block || anchor.region !== head.region) return false;
|
|
546
|
-
if (
|
|
551
|
+
if (chunkM5FREXRQ_cjs.sameSelection(readSelection(registry, domSelection), selection)) return true;
|
|
547
552
|
const base = posToDom(registry, anchor, anchor.offset < head.offset ? 1 : -1);
|
|
548
553
|
const extent = posToDom(registry, head, head.offset < anchor.offset ? 1 : -1);
|
|
549
554
|
if (!base || !extent) return false;
|
|
@@ -605,8 +610,8 @@ var known = /* @__PURE__ */ new WeakMap();
|
|
|
605
610
|
function hidersOf(doc) {
|
|
606
611
|
let hiders = known.get(doc);
|
|
607
612
|
if (hiders === void 0) {
|
|
608
|
-
const first = doc.blocks.findIndex(
|
|
609
|
-
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null :
|
|
613
|
+
const first = doc.blocks.findIndex(chunkM5FREXRQ_cjs.isClosedToggle);
|
|
614
|
+
hiders = doc.blocks.map((_, index) => first < 0 || index <= first ? null : chunkM5FREXRQ_cjs.hidingToggle(doc, index + 1));
|
|
610
615
|
known.set(doc, hiders);
|
|
611
616
|
}
|
|
612
617
|
return hiders;
|
|
@@ -615,7 +620,7 @@ var hidingToggleAt = (doc, index) => hidersOf(doc)[index] ?? null;
|
|
|
615
620
|
function isHiddenAt(doc, index, choices) {
|
|
616
621
|
if (choices.size === 0) return hidingToggleAt(doc, index) !== null;
|
|
617
622
|
const closed = (block) => block.type === "TOGGLE" && !shownOpen(block, choices);
|
|
618
|
-
return
|
|
623
|
+
return chunkM5FREXRQ_cjs.hidingToggle(doc, index + 1, closed) !== null;
|
|
619
624
|
}
|
|
620
625
|
var visibleBlockIndexes = (doc) => hidersOf(doc).flatMap((hider, index) => hider === null ? [index] : []);
|
|
621
626
|
function drawnBlockCount(doc, start = 0, end = doc.blocks.length) {
|
|
@@ -640,18 +645,18 @@ function neighbourBlock(doc, from, direction, accept = anyBlock) {
|
|
|
640
645
|
}
|
|
641
646
|
function entryEdge(controller, block, direction) {
|
|
642
647
|
const { doc, schema } = controller.editor.state;
|
|
643
|
-
const edge = direction < 0 ?
|
|
648
|
+
const edge = direction < 0 ? chunkM5FREXRQ_cjs.endOf(doc, schema, block) : chunkM5FREXRQ_cjs.startOf(doc, schema, block);
|
|
644
649
|
if (edge.kind !== "text") return edge;
|
|
645
650
|
const drawn = controller.registry.get(edge.head.block, edge.head.region) !== void 0;
|
|
646
|
-
return drawn && !entersAsNode(controller, block) ? edge :
|
|
651
|
+
return drawn && !entersAsNode(controller, block) ? edge : chunkM5FREXRQ_cjs.nodeSelection(block);
|
|
647
652
|
}
|
|
648
|
-
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ?
|
|
653
|
+
var ownNode = (controller, block, direction) => direction < 0 && entersAsNode(controller, block) ? chunkM5FREXRQ_cjs.nodeSelection(block) : null;
|
|
649
654
|
var canBeEntered = (controller) => (block) => {
|
|
650
655
|
const { schema } = controller.editor.state;
|
|
651
|
-
const region =
|
|
656
|
+
const region = chunkM5FREXRQ_cjs.isTextFlow(schema, block) ? chunkM5FREXRQ_cjs.primaryRegion(schema, block) : null;
|
|
652
657
|
return region === null || controller.registry.get(block.id, region) !== void 0 || entersAsNode(controller, block.id);
|
|
653
658
|
};
|
|
654
|
-
var holdsTextHead = (controller) => (block) =>
|
|
659
|
+
var holdsTextHead = (controller) => (block) => chunkM5FREXRQ_cjs.isTextFlow(controller.editor.state.schema, block) && entryEdge(controller, block.id, 1).kind === "text";
|
|
655
660
|
function neighbourHead(controller, from, direction) {
|
|
656
661
|
const target = neighbourBlock(controller.editor.state.doc, from, direction, holdsTextHead(controller));
|
|
657
662
|
const edge = target && entryEdge(controller, target.id, direction);
|
|
@@ -790,7 +795,7 @@ function createCrossBlockPointer(controller) {
|
|
|
790
795
|
let preventMouseDown = false;
|
|
791
796
|
const scroll = createAutoScroll(root, () => follow(last.x, last.y));
|
|
792
797
|
function select(selection) {
|
|
793
|
-
if (
|
|
798
|
+
if (chunkM5FREXRQ_cjs.sameSelection(selection, controller.editor.state.selection)) return;
|
|
794
799
|
dispatchSelection(controller, selection);
|
|
795
800
|
}
|
|
796
801
|
function startDragging() {
|
|
@@ -806,14 +811,14 @@ function createCrossBlockPointer(controller) {
|
|
|
806
811
|
if (current.anchor === null) return;
|
|
807
812
|
startDragging();
|
|
808
813
|
}
|
|
809
|
-
select(
|
|
814
|
+
select(chunkM5FREXRQ_cjs.textSelection(current.anchor, caretPosAt(controller, target, x, y)));
|
|
810
815
|
}
|
|
811
816
|
function followBlocks(current, x, y) {
|
|
812
817
|
if (!controller.dragging && Math.hypot(x - current.x, y - current.y) < DRAG_DISTANCE) return;
|
|
813
818
|
const block = blockAt(controller, x, y);
|
|
814
819
|
if (block === null) return;
|
|
815
820
|
startDragging();
|
|
816
|
-
select(
|
|
821
|
+
select(chunkM5FREXRQ_cjs.blockRangeSelection(current.start, block));
|
|
817
822
|
}
|
|
818
823
|
function follow(x, y) {
|
|
819
824
|
if (press?.kind === "text") followText(press, x, y);
|
|
@@ -846,6 +851,13 @@ function createCrossBlockPointer(controller) {
|
|
|
846
851
|
startDragging();
|
|
847
852
|
follow(x, y);
|
|
848
853
|
}
|
|
854
|
+
function pressWhole(block) {
|
|
855
|
+
if (entryEdge(controller, block, 1).kind !== "node") return;
|
|
856
|
+
const pressed = chunk6H76FAI3_cjs.blockById(controller.editor.state.doc, block);
|
|
857
|
+
if (pressed !== void 0 && !canBeEntered(controller)(pressed)) return select(chunkM5FREXRQ_cjs.blockRangeSelection(block));
|
|
858
|
+
controller.nodeReveal.pressed(block);
|
|
859
|
+
select(chunkM5FREXRQ_cjs.nodeSelection(block));
|
|
860
|
+
}
|
|
849
861
|
function onPointerDown(event) {
|
|
850
862
|
end();
|
|
851
863
|
preventMouseDown = false;
|
|
@@ -859,10 +871,7 @@ function createCrossBlockPointer(controller) {
|
|
|
859
871
|
if (event.shiftKey) extendFrom(host, event.clientX, event.clientY);
|
|
860
872
|
} else if (block !== void 0 && !(control && root.contains(control))) {
|
|
861
873
|
press = { kind: "blocks", start: block, x: event.clientX, y: event.clientY };
|
|
862
|
-
if (!event.shiftKey
|
|
863
|
-
controller.nodeReveal.pressed(block);
|
|
864
|
-
select(chunkVFSVN5IQ_cjs.nodeSelection(block));
|
|
865
|
-
}
|
|
874
|
+
if (!event.shiftKey) pressWhole(block);
|
|
866
875
|
} else {
|
|
867
876
|
return;
|
|
868
877
|
}
|
|
@@ -889,7 +898,7 @@ function createCrossBlockPointer(controller) {
|
|
|
889
898
|
// src/view/selection/paint-selection.ts
|
|
890
899
|
var NAME = "quoin-selection";
|
|
891
900
|
function coveredRanges(controller) {
|
|
892
|
-
return
|
|
901
|
+
return chunkM5FREXRQ_cjs.markRanges(controller.editor.state).flatMap(({ block, region, from, to }) => {
|
|
893
902
|
const host = controller.registry.get(block, region);
|
|
894
903
|
const map = host && domMapOf(host);
|
|
895
904
|
if (!host || !map) return [];
|
|
@@ -960,7 +969,7 @@ function heldBySink(selection) {
|
|
|
960
969
|
}
|
|
961
970
|
var NO_TEXT = "\xA0";
|
|
962
971
|
function selectionText(state) {
|
|
963
|
-
const text =
|
|
972
|
+
const text = chunkM5FREXRQ_cjs.markRanges(state).map((range) => chunk6H76FAI3_cjs.inlinePlainText(chunkM5FREXRQ_cjs.rangeContent(state, range), state.schema)).join("\n");
|
|
964
973
|
return text === "" ? NO_TEXT : text;
|
|
965
974
|
}
|
|
966
975
|
var focusInPlace = (sink) => inPlace(sink, () => sink.focus({ preventScroll: true }));
|
|
@@ -983,7 +992,7 @@ function focusSink(controller) {
|
|
|
983
992
|
sink.ownerDocument.getSelection()?.selectAllChildren(sink);
|
|
984
993
|
}
|
|
985
994
|
function selectedBlockName({ doc, schema, selection }, blockLabel) {
|
|
986
|
-
const block = selection?.kind === "node" ?
|
|
995
|
+
const block = selection?.kind === "node" ? chunk6H76FAI3_cjs.blockById(doc, selection.block) : void 0;
|
|
987
996
|
return block === void 0 ? null : blockLabel?.(block, schema) ?? "";
|
|
988
997
|
}
|
|
989
998
|
function clearSink(controller) {
|
|
@@ -1120,7 +1129,7 @@ function createElementSlot(changed) {
|
|
|
1120
1129
|
|
|
1121
1130
|
// src/view/controller/selection-element.ts
|
|
1122
1131
|
function elementFor({ doc }, selection, rendered) {
|
|
1123
|
-
const id =
|
|
1132
|
+
const id = chunkM5FREXRQ_cjs.headBlockId(selection);
|
|
1124
1133
|
const index = id === null ? void 0 : doc.index.get(id);
|
|
1125
1134
|
if (id === null || index === void 0) return void 0;
|
|
1126
1135
|
const hiding = hidingToggleAt(doc, index);
|
|
@@ -1133,7 +1142,7 @@ function selectionElement(state, rendered) {
|
|
|
1133
1142
|
if (doc.blocks.length === 0) return rendered.empty?.() ?? void 0;
|
|
1134
1143
|
const sink = heldBySink(selection) ? rendered.sink?.() : null;
|
|
1135
1144
|
if (sink) return sink;
|
|
1136
|
-
return elementFor(state, selection, rendered) ?? elementFor(state,
|
|
1145
|
+
return elementFor(state, selection, rendered) ?? elementFor(state, chunkM5FREXRQ_cjs.startOf(doc, schema, doc.blocks[0].id), rendered);
|
|
1137
1146
|
}
|
|
1138
1147
|
|
|
1139
1148
|
// src/view/controller/tab-stop.ts
|
|
@@ -1200,9 +1209,9 @@ function ownsFocus(controller, doc) {
|
|
|
1200
1209
|
function focusTarget(state, target) {
|
|
1201
1210
|
const { doc, schema, selection } = state;
|
|
1202
1211
|
if (doc.blocks.length === 0) return null;
|
|
1203
|
-
if (target === "end") return
|
|
1204
|
-
if (target === "start" || target === void 0 && selection === null) return
|
|
1205
|
-
return target === void 0 ? selection :
|
|
1212
|
+
if (target === "end") return chunkM5FREXRQ_cjs.endOf(doc, schema, doc.blocks[doc.blocks.length - 1].id);
|
|
1213
|
+
if (target === "start" || target === void 0 && selection === null) return chunkM5FREXRQ_cjs.startOf(doc, schema, doc.blocks[0].id);
|
|
1214
|
+
return target === void 0 ? selection : chunkM5FREXRQ_cjs.textSelection(target);
|
|
1206
1215
|
}
|
|
1207
1216
|
|
|
1208
1217
|
// src/view/controller/host-decorations.ts
|
|
@@ -1218,7 +1227,7 @@ function decorationsByHost(decorations) {
|
|
|
1218
1227
|
return byHost;
|
|
1219
1228
|
}
|
|
1220
1229
|
function sameDecoration(a, b) {
|
|
1221
|
-
if (a.kind !== b.kind || a.block !== b.block || !
|
|
1230
|
+
if (a.kind !== b.kind || a.block !== b.block || !chunk6H76FAI3_cjs.sameAttrs(a.attrs, b.attrs)) return false;
|
|
1222
1231
|
if (a.kind === "inline" && b.kind === "inline") {
|
|
1223
1232
|
return a.region === b.region && a.from === b.from && a.to === b.to;
|
|
1224
1233
|
}
|
|
@@ -1229,7 +1238,7 @@ function sameDecoration(a, b) {
|
|
|
1229
1238
|
return true;
|
|
1230
1239
|
}
|
|
1231
1240
|
function sameDecorations(a, b) {
|
|
1232
|
-
return a === b ||
|
|
1241
|
+
return a === b || chunk6H76FAI3_cjs.sameItems(a, b, sameDecoration);
|
|
1233
1242
|
}
|
|
1234
1243
|
var byMode = { highlight: /* @__PURE__ */ new WeakMap(), decorations: /* @__PURE__ */ new WeakMap() };
|
|
1235
1244
|
function hostDecorations(editor, block, region, mode = "highlight") {
|
|
@@ -1245,7 +1254,7 @@ function hostDecorations(editor, block, region, mode = "highlight") {
|
|
|
1245
1254
|
|
|
1246
1255
|
// src/view/controller/region-inline.ts
|
|
1247
1256
|
function regionInline(state, block, region) {
|
|
1248
|
-
const regions =
|
|
1257
|
+
const regions = chunk6H76FAI3_cjs.blockById(state.doc, block)?.regions;
|
|
1249
1258
|
return regions && Object.hasOwn(regions, region) ? regions[region] : void 0;
|
|
1250
1259
|
}
|
|
1251
1260
|
|
|
@@ -1295,7 +1304,7 @@ function createOutsideChanges(editorHasFocus, movedFrom) {
|
|
|
1295
1304
|
}
|
|
1296
1305
|
const from = moved ?? (outside && !settled ? movedFrom(tr.before.selection) : null);
|
|
1297
1306
|
settled ||= outside;
|
|
1298
|
-
moved = from &&
|
|
1307
|
+
moved = from && chunkM5FREXRQ_cjs.mapSelection(from, (pos, assoc) => tr.mapPos(pos, assoc), tr.before.doc);
|
|
1299
1308
|
},
|
|
1300
1309
|
takeFocused() {
|
|
1301
1310
|
const value = focused;
|
|
@@ -1388,7 +1397,7 @@ function handleCopy(controller, event, cut) {
|
|
|
1388
1397
|
clipboardData.setData("text/plain", copied.text);
|
|
1389
1398
|
clipboardData.setData("text/html", wrapSliceHTML(copied.html, copied.json));
|
|
1390
1399
|
clipboardData.setData(QUOIN_SLICE_TYPE, copied.json);
|
|
1391
|
-
if (cut) controller.run(
|
|
1400
|
+
if (cut) controller.run(chunkM5FREXRQ_cjs.deleteSelection);
|
|
1392
1401
|
}
|
|
1393
1402
|
function handlePaste(controller, event) {
|
|
1394
1403
|
if (!event.clipboardData) return;
|
|
@@ -1420,7 +1429,7 @@ function handleDrop(controller, event) {
|
|
|
1420
1429
|
return;
|
|
1421
1430
|
}
|
|
1422
1431
|
const pos = dropPos(controller, event.clientX, event.clientY);
|
|
1423
|
-
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(
|
|
1432
|
+
if (pos) controller.dispatch(controller.editor.createTransaction().setSelection(chunkM5FREXRQ_cjs.textSelection(pos)).setOrigin("drop"));
|
|
1424
1433
|
pasteTransfer(controller, dataTransfer);
|
|
1425
1434
|
}
|
|
1426
1435
|
function handleDragOver(event) {
|
|
@@ -1548,29 +1557,29 @@ function createSinkComposition(controller) {
|
|
|
1548
1557
|
var LINE_BREAK = "\n";
|
|
1549
1558
|
var transposeChars = (state, dispatch) => {
|
|
1550
1559
|
const { selection } = state;
|
|
1551
|
-
if (selection?.kind !== "text" || !
|
|
1560
|
+
if (selection?.kind !== "text" || !chunkM5FREXRQ_cjs.isCollapsed(selection)) return false;
|
|
1552
1561
|
const { head } = selection;
|
|
1553
|
-
const inline =
|
|
1562
|
+
const inline = chunk6H76FAI3_cjs.blockById(state.doc, head.block)?.regions[head.region];
|
|
1554
1563
|
if (inline === void 0) return false;
|
|
1555
|
-
const value =
|
|
1564
|
+
const value = chunk6H76FAI3_cjs.inlineText(inline);
|
|
1556
1565
|
const atLineEnd = head.offset === value.length || value[head.offset] === LINE_BREAK;
|
|
1557
|
-
const end = atLineEnd ? head.offset :
|
|
1558
|
-
const middle =
|
|
1559
|
-
const start =
|
|
1566
|
+
const end = atLineEnd ? head.offset : chunkM5FREXRQ_cjs.nextGraphemeOffset(value, head.offset);
|
|
1567
|
+
const middle = chunkM5FREXRQ_cjs.prevGraphemeOffset(value, end);
|
|
1568
|
+
const start = chunkM5FREXRQ_cjs.prevGraphemeOffset(value, middle);
|
|
1560
1569
|
if (start === middle || value.slice(start, end).includes(LINE_BREAK)) return false;
|
|
1561
|
-
const swapped = [...
|
|
1562
|
-
const tr = new
|
|
1563
|
-
tr.step(
|
|
1564
|
-
dispatch?.(tr.setSelection(
|
|
1570
|
+
const swapped = [...chunk6H76FAI3_cjs.sliceInline(inline, middle, end), ...chunk6H76FAI3_cjs.sliceInline(inline, start, middle)];
|
|
1571
|
+
const tr = new chunkM5FREXRQ_cjs.Transaction(state).setOrigin("input");
|
|
1572
|
+
tr.step(chunkM5FREXRQ_cjs.replaceInlineStep(head.block, head.region, start, end, swapped));
|
|
1573
|
+
dispatch?.(tr.setSelection(chunkM5FREXRQ_cjs.textSelection({ ...head, offset: end })));
|
|
1565
1574
|
return true;
|
|
1566
1575
|
};
|
|
1567
1576
|
|
|
1568
1577
|
// src/view/input/replace-range.ts
|
|
1569
1578
|
function replaceRange(editor, range, text, withRules) {
|
|
1570
1579
|
const dispatch = (tr) => editor.dispatch(tr);
|
|
1571
|
-
dispatch(editor.createTransaction().setSelection(
|
|
1572
|
-
if (text === "") return
|
|
1573
|
-
return withRules ? editor.insertText(text) :
|
|
1580
|
+
dispatch(editor.createTransaction().setSelection(chunkM5FREXRQ_cjs.textSelection(range.from, range.to)).setOrigin("input"));
|
|
1581
|
+
if (text === "") return chunkM5FREXRQ_cjs.deleteSelection(editor.state, (tr) => dispatch(tr.setOrigin("input")));
|
|
1582
|
+
return withRules ? editor.insertText(text) : chunkM5FREXRQ_cjs.insertText(text, { origin: "input" })(editor.state, dispatch);
|
|
1574
1583
|
}
|
|
1575
1584
|
|
|
1576
1585
|
// src/view/input/target-range.ts
|
|
@@ -1581,13 +1590,13 @@ function targetRangeToModel(controller, event) {
|
|
|
1581
1590
|
const to = domToPos(controller.registry, range.endContainer, range.endOffset);
|
|
1582
1591
|
return from && to && { from, to };
|
|
1583
1592
|
}
|
|
1584
|
-
var isEmpty = ({ from, to }) =>
|
|
1593
|
+
var isEmpty = ({ from, to }) => chunkM5FREXRQ_cjs.sameSelection(chunkM5FREXRQ_cjs.textSelection(from), chunkM5FREXRQ_cjs.textSelection(to));
|
|
1585
1594
|
function targetBeyondSelection(controller, event) {
|
|
1586
1595
|
const range = targetRangeToModel(controller, event);
|
|
1587
1596
|
if (range === null || isEmpty(range)) return null;
|
|
1588
1597
|
const { doc, selection } = controller.editor.state;
|
|
1589
|
-
const selected =
|
|
1590
|
-
const same = selected !== null &&
|
|
1598
|
+
const selected = chunkM5FREXRQ_cjs.selectionRange(doc, selection);
|
|
1599
|
+
const same = selected !== null && chunkM5FREXRQ_cjs.sameSelection(chunkM5FREXRQ_cjs.textSelection(selected.from, selected.to), chunkM5FREXRQ_cjs.textSelection(range.from, range.to));
|
|
1591
1600
|
return same ? null : range;
|
|
1592
1601
|
}
|
|
1593
1602
|
|
|
@@ -1609,34 +1618,34 @@ function insertTypedText(controller, event) {
|
|
|
1609
1618
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1610
1619
|
}
|
|
1611
1620
|
function deleteContentBackward(controller, event) {
|
|
1612
|
-
if (!controller.run(
|
|
1621
|
+
if (!controller.run(chunkM5FREXRQ_cjs.undoInputRule)) targetOr(chunkM5FREXRQ_cjs.deleteBackward)(controller, event);
|
|
1613
1622
|
}
|
|
1614
1623
|
function insertReplacementText(controller, event) {
|
|
1615
1624
|
const text = event.dataTransfer?.getData("text/plain") || event.data;
|
|
1616
1625
|
if (!text) return;
|
|
1617
1626
|
const range = targetRangeToModel(controller, event);
|
|
1618
|
-
if (range === null) controller.run(
|
|
1627
|
+
if (range === null) controller.run(chunkM5FREXRQ_cjs.insertText(text, { origin: "input" }));
|
|
1619
1628
|
else controller.edit(() => replaceRange(controller.editor, range, text, false));
|
|
1620
1629
|
}
|
|
1621
1630
|
var actions = {
|
|
1622
1631
|
insertText: insertTypedText,
|
|
1623
1632
|
insertReplacementText,
|
|
1624
1633
|
insertParagraph: (controller) => void controller.edit(() => controller.editor.handleKey(ENTER)),
|
|
1625
|
-
insertLineBreak: run(
|
|
1634
|
+
insertLineBreak: run(chunkM5FREXRQ_cjs.insertHardBreak),
|
|
1626
1635
|
deleteContentBackward,
|
|
1627
|
-
deleteContentForward: targetOr(
|
|
1628
|
-
deleteWordBackward: targetOr(
|
|
1629
|
-
deleteWordForward: targetOr(
|
|
1630
|
-
deleteSoftLineBackward: targetOr(
|
|
1631
|
-
deleteHardLineBackward: targetOr(
|
|
1632
|
-
deleteSoftLineForward: targetOr(
|
|
1633
|
-
deleteHardLineForward: targetOr(
|
|
1634
|
-
formatBold: run(
|
|
1635
|
-
formatItalic: run(
|
|
1636
|
-
formatUnderline: run(
|
|
1637
|
-
formatStrikeThrough: run(
|
|
1638
|
-
historyUndo: run(
|
|
1639
|
-
historyRedo: run(
|
|
1636
|
+
deleteContentForward: targetOr(chunkM5FREXRQ_cjs.deleteForward),
|
|
1637
|
+
deleteWordBackward: targetOr(chunkM5FREXRQ_cjs.deleteWordBackward),
|
|
1638
|
+
deleteWordForward: targetOr(chunkM5FREXRQ_cjs.deleteWordForward),
|
|
1639
|
+
deleteSoftLineBackward: targetOr(chunkM5FREXRQ_cjs.deleteToLineStart),
|
|
1640
|
+
deleteHardLineBackward: targetOr(chunkM5FREXRQ_cjs.deleteToLineStart),
|
|
1641
|
+
deleteSoftLineForward: targetOr(chunkM5FREXRQ_cjs.deleteToLineEnd),
|
|
1642
|
+
deleteHardLineForward: targetOr(chunkM5FREXRQ_cjs.deleteToLineEnd),
|
|
1643
|
+
formatBold: run(chunkM5FREXRQ_cjs.toggleMark("bold")),
|
|
1644
|
+
formatItalic: run(chunkM5FREXRQ_cjs.toggleMark("italic")),
|
|
1645
|
+
formatUnderline: run(chunkM5FREXRQ_cjs.toggleMark("underline")),
|
|
1646
|
+
formatStrikeThrough: run(chunkM5FREXRQ_cjs.toggleMark("strike")),
|
|
1647
|
+
historyUndo: run(chunkM5FREXRQ_cjs.undo),
|
|
1648
|
+
historyRedo: run(chunkM5FREXRQ_cjs.redo),
|
|
1640
1649
|
insertTranspose: run(transposeChars),
|
|
1641
1650
|
insertFromPaste: leaveToHandlers,
|
|
1642
1651
|
insertFromDrop: leaveToHandlers,
|
|
@@ -1737,7 +1746,7 @@ function snapshotComposition(controller, block, region) {
|
|
|
1737
1746
|
const element = controller.registry.get(block, region);
|
|
1738
1747
|
const inline = regionInline(editor.state, block, region);
|
|
1739
1748
|
if (element === void 0 || inline === void 0) return null;
|
|
1740
|
-
const text =
|
|
1749
|
+
const text = chunk6H76FAI3_cjs.inlineText(inline);
|
|
1741
1750
|
const end = composedEnd(controller, block, region);
|
|
1742
1751
|
const since = [];
|
|
1743
1752
|
const release = editor.subscribe((_, tr) => void (tr && since.push(tr)));
|
|
@@ -1849,7 +1858,7 @@ function reconcileHost(controller, block, region, caretHint) {
|
|
|
1849
1858
|
const element = controller.registry.get(block, region);
|
|
1850
1859
|
const inline = regionInline(controller.editor.state, block, region);
|
|
1851
1860
|
if (element === void 0 || inline === void 0) return false;
|
|
1852
|
-
const before =
|
|
1861
|
+
const before = chunk6H76FAI3_cjs.inlineText(inline);
|
|
1853
1862
|
const after = readDomText(element);
|
|
1854
1863
|
const edit = before === after ? null : textDiff(before, after, domCaretOffset(element));
|
|
1855
1864
|
if (edit === null) return false;
|
|
@@ -1914,33 +1923,33 @@ function createDomInputFallback(controller) {
|
|
|
1914
1923
|
|
|
1915
1924
|
// src/view/navigation/cross-moves.ts
|
|
1916
1925
|
function moveHead(controller, { anchor }, head) {
|
|
1917
|
-
dispatchSelection(controller,
|
|
1926
|
+
dispatchSelection(controller, chunkM5FREXRQ_cjs.textSelection(anchor, head));
|
|
1918
1927
|
return true;
|
|
1919
1928
|
}
|
|
1920
1929
|
function blockOf(controller, { block }) {
|
|
1921
1930
|
const { doc } = controller.editor.state;
|
|
1922
|
-
return doc.blocks[
|
|
1931
|
+
return doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, block)];
|
|
1923
1932
|
}
|
|
1924
1933
|
function collapseCross(controller, selection, direction) {
|
|
1925
|
-
const { from, to } =
|
|
1926
|
-
dispatchSelection(controller,
|
|
1934
|
+
const { from, to } = chunkM5FREXRQ_cjs.selectionRange(controller.editor.state.doc, selection);
|
|
1935
|
+
dispatchSelection(controller, chunkM5FREXRQ_cjs.textSelection(direction < 0 ? from : to));
|
|
1927
1936
|
return true;
|
|
1928
1937
|
}
|
|
1929
1938
|
function crossHeadVertically(controller, selection, direction) {
|
|
1930
1939
|
const { head } = selection;
|
|
1931
1940
|
const edge = neighbourHead(controller, head.block, direction);
|
|
1932
1941
|
if (edge !== null) {
|
|
1933
|
-
const end2 =
|
|
1942
|
+
const end2 = chunkM5FREXRQ_cjs.regionLength(blockOf(controller, edge), edge.region);
|
|
1934
1943
|
return moveHead(controller, selection, { ...edge, offset: Math.min(head.offset, end2) });
|
|
1935
1944
|
}
|
|
1936
|
-
const end =
|
|
1945
|
+
const end = chunkM5FREXRQ_cjs.regionLength(blockOf(controller, head), head.region);
|
|
1937
1946
|
return moveHead(controller, selection, { ...head, offset: direction < 0 ? 0 : end });
|
|
1938
1947
|
}
|
|
1939
1948
|
function crossHeadHorizontally(controller, selection, direction) {
|
|
1940
1949
|
const { head } = selection;
|
|
1941
|
-
const text =
|
|
1950
|
+
const text = chunk6H76FAI3_cjs.inlineText(blockOf(controller, head).regions[head.region] ?? []);
|
|
1942
1951
|
if (direction < 0 ? head.offset > 0 : head.offset < text.length) {
|
|
1943
|
-
const offset = direction < 0 ?
|
|
1952
|
+
const offset = direction < 0 ? chunkM5FREXRQ_cjs.prevGraphemeOffset(text, head.offset) : chunkM5FREXRQ_cjs.nextGraphemeOffset(text, head.offset);
|
|
1944
1953
|
return moveHead(controller, selection, { ...head, offset });
|
|
1945
1954
|
}
|
|
1946
1955
|
const edge = neighbourHead(controller, head.block, direction);
|
|
@@ -1959,9 +1968,9 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
1959
1968
|
const move = extend ? crossHeadHorizontally : collapseCross;
|
|
1960
1969
|
return move(controller, selection, direction);
|
|
1961
1970
|
}
|
|
1962
|
-
if (!extend && !
|
|
1971
|
+
if (!extend && !chunkM5FREXRQ_cjs.isCollapsed(selection)) return false;
|
|
1963
1972
|
const { head } = selection;
|
|
1964
|
-
const length =
|
|
1973
|
+
const length = chunkM5FREXRQ_cjs.regionLength(doc.blocks[chunk6H76FAI3_cjs.requireBlockIndex(doc, head.block)], head.region);
|
|
1965
1974
|
if (direction < 0 ? head.offset > 0 : head.offset < length) return false;
|
|
1966
1975
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
1967
1976
|
if (own2 !== null) {
|
|
@@ -1971,7 +1980,7 @@ function moveHorizontally(controller, direction, extend) {
|
|
|
1971
1980
|
if (!extend) return moveToNeighbour(controller, head.block, direction);
|
|
1972
1981
|
const edge = neighbourHead(controller, head.block, direction);
|
|
1973
1982
|
if (edge === null) return false;
|
|
1974
|
-
dispatchSelection(controller,
|
|
1983
|
+
dispatchSelection(controller, chunkM5FREXRQ_cjs.textSelection(selection.anchor, edge));
|
|
1975
1984
|
return true;
|
|
1976
1985
|
}
|
|
1977
1986
|
|
|
@@ -2069,12 +2078,12 @@ function caretAtGoal(controller, host, at, y) {
|
|
|
2069
2078
|
}
|
|
2070
2079
|
function landAtGoal(controller, block, direction) {
|
|
2071
2080
|
const { schema } = controller.editor.state;
|
|
2072
|
-
const region =
|
|
2081
|
+
const region = chunkM5FREXRQ_cjs.isTextFlow(schema, block) ? chunkM5FREXRQ_cjs.primaryRegion(schema, block) : null;
|
|
2073
2082
|
const host = region === null ? void 0 : controller.registry.get(block.id, region);
|
|
2074
2083
|
if (!host || region === null || controller.goalX === null) return null;
|
|
2075
2084
|
const line = lineInView(host, direction < 0);
|
|
2076
2085
|
const pos = line && caretAtGoal(controller, host, { block: block.id, region }, line.top + line.height / 2);
|
|
2077
|
-
return pos ?
|
|
2086
|
+
return pos ? chunkM5FREXRQ_cjs.textSelection(pos) : null;
|
|
2078
2087
|
}
|
|
2079
2088
|
function moveInHost(controller, host, head, caret, direction) {
|
|
2080
2089
|
const { goalX } = controller;
|
|
@@ -2092,7 +2101,7 @@ function landing(controller, { head }, direction, extend) {
|
|
|
2092
2101
|
controller.goalX ??= caret?.left ?? null;
|
|
2093
2102
|
if (!(direction < 0 ? isOnFirstLine(host, point) : isOnLastLine(host, point))) {
|
|
2094
2103
|
const pos = moveInHost(controller, host, head, caret, direction);
|
|
2095
|
-
return pos &&
|
|
2104
|
+
return pos && chunkM5FREXRQ_cjs.textSelection(pos);
|
|
2096
2105
|
}
|
|
2097
2106
|
const own2 = extend ? null : ownNode(controller, head.block, direction);
|
|
2098
2107
|
if (own2 !== null) return own2;
|
|
@@ -2106,14 +2115,14 @@ function moveText(controller, selection, direction, extend) {
|
|
|
2106
2115
|
controller.nativeVerticalMove = true;
|
|
2107
2116
|
return false;
|
|
2108
2117
|
}
|
|
2109
|
-
const moved = extend && next.kind === "text" ?
|
|
2118
|
+
const moved = extend && next.kind === "text" ? chunkM5FREXRQ_cjs.textSelection(selection.anchor, next.head) : next;
|
|
2110
2119
|
dispatchSelection(controller, moved);
|
|
2111
2120
|
return true;
|
|
2112
2121
|
}
|
|
2113
2122
|
function extendBlocks(controller, { anchor, head }, direction) {
|
|
2114
2123
|
const next = neighbourBlock(controller.editor.state.doc, head, direction);
|
|
2115
2124
|
if (next === null) return false;
|
|
2116
|
-
dispatchSelection(controller,
|
|
2125
|
+
dispatchSelection(controller, chunkM5FREXRQ_cjs.blockRangeSelection(anchor, next.id));
|
|
2117
2126
|
return true;
|
|
2118
2127
|
}
|
|
2119
2128
|
function moveVertically(controller, direction, extend) {
|
|
@@ -2129,8 +2138,8 @@ function moveVertically(controller, direction, extend) {
|
|
|
2129
2138
|
// src/view/input/flip-block.ts
|
|
2130
2139
|
var isTask = ({ type, attrs }) => type === "MARKDOWN" && attrs.kind === "task";
|
|
2131
2140
|
function flipCommand(block) {
|
|
2132
|
-
if (isTask(block)) return
|
|
2133
|
-
return block.type === "TOGGLE" ?
|
|
2141
|
+
if (isTask(block)) return chunkM5FREXRQ_cjs.toggleTask;
|
|
2142
|
+
return block.type === "TOGGLE" ? chunkM5FREXRQ_cjs.setAttrs({ open: block.attrs.open !== true }) : null;
|
|
2134
2143
|
}
|
|
2135
2144
|
var toggleState = (open) => open ? "expanded" : "collapsed";
|
|
2136
2145
|
function stateName(block) {
|
|
@@ -2139,7 +2148,7 @@ function stateName(block) {
|
|
|
2139
2148
|
}
|
|
2140
2149
|
function blockHoldingCaret({ doc, selection }) {
|
|
2141
2150
|
if (selection?.kind !== "text" || selection.anchor.block !== selection.head.block) return null;
|
|
2142
|
-
return
|
|
2151
|
+
return chunk6H76FAI3_cjs.blockById(doc, selection.head.block) ?? null;
|
|
2143
2152
|
}
|
|
2144
2153
|
function flipForReader(controller, block) {
|
|
2145
2154
|
if (block?.type !== "TOGGLE") return false;
|
|
@@ -2154,7 +2163,7 @@ function flipSelectedBlock(controller) {
|
|
|
2154
2163
|
if (controller.readOnly) return flipForReader(controller, block);
|
|
2155
2164
|
const command = block && flipCommand(block);
|
|
2156
2165
|
if (!block || !command || !controller.run(command)) return false;
|
|
2157
|
-
const after =
|
|
2166
|
+
const after = chunk6H76FAI3_cjs.blockById(editor.state.doc, block.id);
|
|
2158
2167
|
if (after) controller.announce(stateName(after));
|
|
2159
2168
|
return true;
|
|
2160
2169
|
}
|
|
@@ -2365,7 +2374,7 @@ function bindRoot(controller, root, cross, committed) {
|
|
|
2365
2374
|
function movedSelection(controller, doc, model) {
|
|
2366
2375
|
if (controller.composingKey !== null || controller.dragging || !doc || !ownsFocus(controller, doc)) return null;
|
|
2367
2376
|
const selection = readSelection(controller.registry, doc.getSelection(), (node) => controller.blockAt(node));
|
|
2368
|
-
return selection === null ||
|
|
2377
|
+
return selection === null || chunkM5FREXRQ_cjs.sameSelection(selection, model) ? null : selection;
|
|
2369
2378
|
}
|
|
2370
2379
|
function writeModelSelection(controller, doc, moved, local) {
|
|
2371
2380
|
const domSelection = doc?.getSelection();
|
|
@@ -2423,7 +2432,7 @@ var ViewController = class {
|
|
|
2423
2432
|
});
|
|
2424
2433
|
this.#flush = options.flush ?? runNow;
|
|
2425
2434
|
this.onFiles = options.onFiles;
|
|
2426
|
-
this.isMac = options.isMac ??
|
|
2435
|
+
this.isMac = options.isMac ?? chunkM5FREXRQ_cjs.detectMac();
|
|
2427
2436
|
const decorationsOf = (block, region) => this.decorationsFor(block, region);
|
|
2428
2437
|
const drain = (element) => this.#binding?.input.drain(element);
|
|
2429
2438
|
this.#hosts = createHostRenderer(options.editor, options.render, decorationsOf, drain);
|
|
@@ -2576,7 +2585,7 @@ var ViewController = class {
|
|
|
2576
2585
|
focus(target) {
|
|
2577
2586
|
const { editor } = this;
|
|
2578
2587
|
const selection = focusTarget(editor.state, target);
|
|
2579
|
-
if (selection !== null && !
|
|
2588
|
+
if (selection !== null && !chunkM5FREXRQ_cjs.sameSelection(selection, editor.state.selection)) dispatchSelection(this, selection);
|
|
2580
2589
|
this.#takeFocus();
|
|
2581
2590
|
this.syncSelectionToDom();
|
|
2582
2591
|
}
|
|
@@ -2624,7 +2633,7 @@ function useQuoinEditor(options) {
|
|
|
2624
2633
|
const { blocks, readOnly = false } = options;
|
|
2625
2634
|
const callbacks = react.useRef(options);
|
|
2626
2635
|
const [controller] = react.useState(() => {
|
|
2627
|
-
const editor =
|
|
2636
|
+
const editor = chunkM5FREXRQ_cjs.createEditor({
|
|
2628
2637
|
blocks,
|
|
2629
2638
|
extensions: options.extensions,
|
|
2630
2639
|
onChange: (next) => callbacks.current.onChange(next),
|
|
@@ -2687,11 +2696,11 @@ function SelectionSink({ label = "Selected content", blockLabel }) {
|
|
|
2687
2696
|
}
|
|
2688
2697
|
);
|
|
2689
2698
|
}
|
|
2690
|
-
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${
|
|
2699
|
+
var headingPlaceholder = (_state, { type, attrs }) => type === "MARKDOWN" && attrs.kind === "heading" ? `Heading ${chunk6H76FAI3_cjs.headingLevel(attrs.level)}` : void 0;
|
|
2691
2700
|
var BlockPlaceholderContext = react.createContext(headingPlaceholder);
|
|
2692
2701
|
function regionPlaceholder(state, blockId, region, placeholderOf) {
|
|
2693
|
-
const block =
|
|
2694
|
-
return block !== void 0 &&
|
|
2702
|
+
const block = chunk6H76FAI3_cjs.blockById(state.doc, blockId);
|
|
2703
|
+
return block !== void 0 && chunkM5FREXRQ_cjs.primaryRegion(state.schema, block) === region ? placeholderOf(state, block) : void 0;
|
|
2695
2704
|
}
|
|
2696
2705
|
var samePainted = (a, b) => a.inline === b.inline && a.placeholder === b.placeholder && sameDecorations(a.decorations, b.decorations);
|
|
2697
2706
|
function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
@@ -2702,7 +2711,7 @@ function EditableRegion({ block, region, label, id, placeholder, className }) {
|
|
|
2702
2711
|
const select = react.useCallback(
|
|
2703
2712
|
(state) => {
|
|
2704
2713
|
const inline2 = regionInline(state, block, region);
|
|
2705
|
-
const empty = inline2 === void 0 ||
|
|
2714
|
+
const empty = inline2 === void 0 || chunk6H76FAI3_cjs.inlineLength(inline2) === 0;
|
|
2706
2715
|
return {
|
|
2707
2716
|
inline: inline2,
|
|
2708
2717
|
decorations: controller.decorationsFor(block, region),
|
|
@@ -2747,7 +2756,7 @@ var CalloutBlock = ({ block }) => {
|
|
|
2747
2756
|
// src/view/react/block-command.ts
|
|
2748
2757
|
function onBlock(id, command) {
|
|
2749
2758
|
return (state, dispatch) => {
|
|
2750
|
-
const { ok, tr } =
|
|
2759
|
+
const { ok, tr } = chunkM5FREXRQ_cjs.runCommands(state, [chunkM5FREXRQ_cjs.setSelection(chunkM5FREXRQ_cjs.blockRangeSelection(id)), command]);
|
|
2751
2760
|
if (!ok || tr === null) return false;
|
|
2752
2761
|
dispatch?.(tr.setSelection(state.selection));
|
|
2753
2762
|
return true;
|
|
@@ -2767,7 +2776,7 @@ function TaskCheckbox({ block, controller, label, labelledBy }) {
|
|
|
2767
2776
|
role: "checkbox",
|
|
2768
2777
|
"aria-checked": checked,
|
|
2769
2778
|
"aria-readonly": readOnly ? "true" : void 0,
|
|
2770
|
-
"aria-label":
|
|
2779
|
+
"aria-label": chunk6H76FAI3_cjs.firstNamed(label, "Task"),
|
|
2771
2780
|
"aria-labelledby": labelledBy,
|
|
2772
2781
|
className: "quoin-task-box",
|
|
2773
2782
|
contentEditable: false,
|
|
@@ -2798,7 +2807,7 @@ function numberDoc(doc) {
|
|
|
2798
2807
|
numbers[index] = run2.next++;
|
|
2799
2808
|
return;
|
|
2800
2809
|
}
|
|
2801
|
-
const start =
|
|
2810
|
+
const start = chunk6H76FAI3_cjs.orderedStart(block.attrs.start);
|
|
2802
2811
|
numbers[index] = start;
|
|
2803
2812
|
runs.push({ indent: block.indent, next: start + 1 });
|
|
2804
2813
|
});
|
|
@@ -2836,7 +2845,7 @@ var MarkdownBlock = (props) => {
|
|
|
2836
2845
|
const { block } = props;
|
|
2837
2846
|
switch (block.attrs.kind) {
|
|
2838
2847
|
case "heading": {
|
|
2839
|
-
const level =
|
|
2848
|
+
const level = chunk6H76FAI3_cjs.headingLevel(block.attrs.level);
|
|
2840
2849
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "heading", "aria-level": level, className: "quoin-heading", children: /* @__PURE__ */ jsxRuntime.jsx(TextRegion, { block, label: `Heading ${level}` }) });
|
|
2841
2850
|
}
|
|
2842
2851
|
case "bullet":
|
|
@@ -2909,12 +2918,13 @@ var VoidBlockFallback = ({ block }) => {
|
|
|
2909
2918
|
var BLOCK_ERROR = "Block could not be drawn";
|
|
2910
2919
|
var BlockErrorContext = react.createContext({ label: BLOCK_ERROR });
|
|
2911
2920
|
var Boundary = class extends react.Component {
|
|
2912
|
-
state = { block: this.props.block, failed: false };
|
|
2921
|
+
state = { block: this.props.block, renderer: this.props.renderer, failed: false };
|
|
2913
2922
|
static getDerivedStateFromError() {
|
|
2914
2923
|
return { failed: true };
|
|
2915
2924
|
}
|
|
2916
2925
|
static getDerivedStateFromProps(props, state) {
|
|
2917
|
-
|
|
2926
|
+
const same = props.block === state.block && props.renderer === state.renderer;
|
|
2927
|
+
return same ? null : { block: props.block, renderer: props.renderer, failed: false };
|
|
2918
2928
|
}
|
|
2919
2929
|
componentDidCatch(error) {
|
|
2920
2930
|
this.props.report?.(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -2925,9 +2935,9 @@ var Boundary = class extends react.Component {
|
|
|
2925
2935
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "quoin-void", contentEditable: false, role: "group", "aria-label": label, children: label });
|
|
2926
2936
|
}
|
|
2927
2937
|
};
|
|
2928
|
-
function BlockErrorBoundary({ block, children }) {
|
|
2938
|
+
function BlockErrorBoundary({ block, renderer, children }) {
|
|
2929
2939
|
const { label, report } = react.useContext(BlockErrorContext);
|
|
2930
|
-
return /* @__PURE__ */ jsxRuntime.jsx(Boundary, { block, label, report, children });
|
|
2940
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Boundary, { block, renderer, label, report, children });
|
|
2931
2941
|
}
|
|
2932
2942
|
var BlockDomIdScope = react.createContext("quoin");
|
|
2933
2943
|
function useBlockDomId() {
|
|
@@ -2949,7 +2959,7 @@ function covers(state, id, index) {
|
|
|
2949
2959
|
if (selection === null) return false;
|
|
2950
2960
|
if (selection.kind === "node") return selection.block === id;
|
|
2951
2961
|
if (selection.kind === "blocks") return within(state, index, [selection.anchor, selection.head]);
|
|
2952
|
-
if (!isCrossSelection(selection) ||
|
|
2962
|
+
if (!isCrossSelection(selection) || chunkM5FREXRQ_cjs.isTextFlow(schema, doc.blocks[index])) return false;
|
|
2953
2963
|
return within(state, index, [selection.anchor.block, selection.head.block]);
|
|
2954
2964
|
}
|
|
2955
2965
|
function blockStatus(state, id, choices = NO_CHOICES) {
|
|
@@ -2991,15 +3001,15 @@ var BlockShell = react.memo(function BlockShell2({ block, renderers }) {
|
|
|
2991
3001
|
"data-quoin-block": "",
|
|
2992
3002
|
"data-block-id": block.id,
|
|
2993
3003
|
"data-type": block.type,
|
|
2994
|
-
"data-kind":
|
|
3004
|
+
"data-kind": chunk6H76FAI3_cjs.optionalString(kind),
|
|
2995
3005
|
"data-indent": block.indent,
|
|
2996
|
-
"data-color":
|
|
2997
|
-
"data-bg":
|
|
2998
|
-
"data-align":
|
|
3006
|
+
"data-color": chunk6H76FAI3_cjs.paletteOrUndefined(color),
|
|
3007
|
+
"data-bg": chunk6H76FAI3_cjs.paletteOrUndefined(background),
|
|
3008
|
+
"data-align": chunk6H76FAI3_cjs.alignOrUndefined(align),
|
|
2999
3009
|
style: { "--quoin-indent": block.indent },
|
|
3000
3010
|
tabIndex: -1,
|
|
3001
3011
|
"data-selected": status === "selected" ? "true" : void 0,
|
|
3002
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(BlockErrorBoundary, { block, children: /* @__PURE__ */ jsxRuntime.jsx(Renderer, { block, controller }) })
|
|
3012
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(BlockErrorBoundary, { block, renderer: Renderer, children: /* @__PURE__ */ jsxRuntime.jsx(Renderer, { block, controller }) })
|
|
3003
3013
|
}
|
|
3004
3014
|
);
|
|
3005
3015
|
});
|
|
@@ -3192,5 +3202,5 @@ exports.useToggleOpen = useToggleOpen;
|
|
|
3192
3202
|
exports.useViewController = useViewController;
|
|
3193
3203
|
exports.visibleBlockIndexes = visibleBlockIndexes;
|
|
3194
3204
|
exports.wholeState = wholeState;
|
|
3195
|
-
//# sourceMappingURL=chunk-
|
|
3196
|
-
//# sourceMappingURL=chunk-
|
|
3205
|
+
//# sourceMappingURL=chunk-VSUGJZ7G.cjs.map
|
|
3206
|
+
//# sourceMappingURL=chunk-VSUGJZ7G.cjs.map
|