@arbidocs/blocks 0.4.107 → 0.4.109
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/{NativeDocxEditor-3VKJT43D.js → NativeDocxEditor-4PY4YZYC.js} +3 -3
- package/dist/{NativeDocxEditor-3VKJT43D.js.map → NativeDocxEditor-4PY4YZYC.js.map} +1 -1
- package/dist/{NativeDocxEditor-GNG5QV7V.cjs → NativeDocxEditor-WODZAURG.cjs} +7 -7
- package/dist/{NativeDocxEditor-GNG5QV7V.cjs.map → NativeDocxEditor-WODZAURG.cjs.map} +1 -1
- package/dist/agents/index.cjs +210 -210
- package/dist/agents/index.js +5 -5
- package/dist/chat/index.cjs +125 -125
- package/dist/chat/index.js +3 -3
- package/dist/{chunk-BHKFENKT.cjs → chunk-2NIL2ASF.cjs} +39 -295
- package/dist/chunk-2NIL2ASF.cjs.map +1 -0
- package/dist/{chunk-FZGMY6NQ.cjs → chunk-54WBIVHV.cjs} +5 -5
- package/dist/{chunk-FZGMY6NQ.cjs.map → chunk-54WBIVHV.cjs.map} +1 -1
- package/dist/{chunk-OR4CO743.cjs → chunk-5YXG342J.cjs} +3 -3
- package/dist/{chunk-OR4CO743.cjs.map → chunk-5YXG342J.cjs.map} +1 -1
- package/dist/{chunk-IXALYQT7.cjs → chunk-C2CWWEHO.cjs} +2 -2
- package/dist/chunk-C2CWWEHO.cjs.map +1 -0
- package/dist/{chunk-P5ST47VY.js → chunk-DDF5GPIJ.js} +3 -3
- package/dist/{chunk-P5ST47VY.js.map → chunk-DDF5GPIJ.js.map} +1 -1
- package/dist/{chunk-XQKGYGCJ.js → chunk-DQCYCEDR.js} +3 -3
- package/dist/{chunk-XQKGYGCJ.js.map → chunk-DQCYCEDR.js.map} +1 -1
- package/dist/{chunk-Q57MEBCK.cjs → chunk-ELDUWTRR.cjs} +4 -4
- package/dist/{chunk-Q57MEBCK.cjs.map → chunk-ELDUWTRR.cjs.map} +1 -1
- package/dist/{chunk-EB7QAZLH.js → chunk-FQX6N5G6.js} +8 -7
- package/dist/chunk-FQX6N5G6.js.map +1 -0
- package/dist/{chunk-R6APX23R.cjs → chunk-GBYY3PIC.cjs} +18 -17
- package/dist/chunk-GBYY3PIC.cjs.map +1 -0
- package/dist/{chunk-2SJTXYRM.js → chunk-GKDWQLVU.js} +14 -275
- package/dist/chunk-GKDWQLVU.js.map +1 -0
- package/dist/{chunk-RILMICOP.cjs → chunk-I4XQCE6U.cjs} +5 -5
- package/dist/{chunk-RILMICOP.cjs.map → chunk-I4XQCE6U.cjs.map} +1 -1
- package/dist/{chunk-P2KPDPFF.js → chunk-IXTQYFIF.js} +23 -15
- package/dist/chunk-IXTQYFIF.js.map +1 -0
- package/dist/{chunk-2PYENCW5.js → chunk-JB32KYAH.js} +3 -3
- package/dist/{chunk-2PYENCW5.js.map → chunk-JB32KYAH.js.map} +1 -1
- package/dist/{chunk-PBS5MFIY.cjs → chunk-JK45LSIH.cjs} +3 -3
- package/dist/{chunk-PBS5MFIY.cjs.map → chunk-JK45LSIH.cjs.map} +1 -1
- package/dist/{chunk-ZPLG7QYF.js → chunk-N5YEF3LC.js} +2 -2
- package/dist/chunk-N5YEF3LC.js.map +1 -0
- package/dist/{chunk-PFA43QNX.js → chunk-NUTLXVPX.js} +4 -3
- package/dist/chunk-NUTLXVPX.js.map +1 -0
- package/dist/{chunk-O5NDG4EA.cjs → chunk-PDRYGPZB.cjs} +4 -3
- package/dist/chunk-PDRYGPZB.cjs.map +1 -0
- package/dist/{chunk-LHBJJ2GE.js → chunk-PEHLUB52.js} +3 -3
- package/dist/{chunk-LHBJJ2GE.js.map → chunk-PEHLUB52.js.map} +1 -1
- package/dist/{chunk-HUJLKDWX.cjs → chunk-QKWQMOHN.cjs} +4 -4
- package/dist/{chunk-HUJLKDWX.cjs.map → chunk-QKWQMOHN.cjs.map} +1 -1
- package/dist/{chunk-DTBSGG36.cjs → chunk-U6MPHCEB.cjs} +24 -16
- package/dist/chunk-U6MPHCEB.cjs.map +1 -0
- package/dist/{chunk-WDD255XQ.js → chunk-UABPHZWZ.js} +3 -3
- package/dist/{chunk-WDD255XQ.js.map → chunk-UABPHZWZ.js.map} +1 -1
- package/dist/{chunk-GFYGYME3.js → chunk-W7NZRZ54.js} +3 -3
- package/dist/{chunk-GFYGYME3.js.map → chunk-W7NZRZ54.js.map} +1 -1
- package/dist/{chunk-ZV3BKLFY.cjs → chunk-Z5VUZ6YD.cjs} +3 -3
- package/dist/{chunk-ZV3BKLFY.cjs.map → chunk-Z5VUZ6YD.cjs.map} +1 -1
- package/dist/{chunk-7NLPKJV5.js → chunk-ZSV2NQQP.js} +3 -3
- package/dist/{chunk-7NLPKJV5.js.map → chunk-ZSV2NQQP.js.map} +1 -1
- package/dist/citations/index.cjs +10 -10
- package/dist/citations/index.js +1 -1
- package/dist/collaboration/index.cjs +16 -16
- package/dist/collaboration/index.js +2 -2
- package/dist/connect/docx.cjs +6 -6
- package/dist/connect/docx.js +4 -4
- package/dist/connect/index.cjs +62 -62
- package/dist/connect/index.js +10 -10
- package/dist/databases/index.cjs +2 -2
- package/dist/databases/index.js +1 -1
- package/dist/docx/definitions/fragment.d.ts +2 -6
- package/dist/docx/definitions/port.d.ts +2 -57
- package/dist/docx/index.cjs +46 -46
- package/dist/docx/index.js +3 -3
- package/dist/docx/references/commands.d.ts +3 -31
- package/dist/docx/references/numbering.d.ts +3 -47
- package/dist/docx/template/HouseTemplate.d.ts +5 -0
- package/dist/facts/index.cjs +4 -4
- package/dist/facts/index.js +3 -3
- package/dist/files/GridView.d.ts +4 -1
- package/dist/files/TagPassagePanel.d.ts +2 -0
- package/dist/files/index.cjs +86 -76
- package/dist/files/index.cjs.map +1 -1
- package/dist/files/index.js +86 -76
- package/dist/files/index.js.map +1 -1
- package/dist/home/index.cjs +17 -17
- package/dist/home/index.js +3 -3
- package/dist/index.cjs +508 -508
- package/dist/index.js +10 -10
- package/dist/retrieval/index.cjs +1 -1
- package/dist/retrieval/index.js +1 -1
- package/dist/settings/FirmPool.d.ts +45 -0
- package/dist/settings/index.cjs +132 -35
- package/dist/settings/index.cjs.map +1 -1
- package/dist/settings/index.d.ts +1 -0
- package/dist/settings/index.js +97 -3
- package/dist/settings/index.js.map +1 -1
- package/dist/shell/index.cjs +1 -1
- package/dist/shell/index.js +1 -1
- package/dist/studio/index.cjs +4 -4
- package/dist/studio/index.js +3 -3
- package/dist/workflow-canvas/index.cjs +12 -12
- package/dist/workflow-canvas/index.js +5 -5
- package/dist/workspaces/index.cjs +3 -3
- package/dist/workspaces/index.cjs.map +1 -1
- package/dist/workspaces/index.js +3 -3
- package/dist/workspaces/index.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/commands.cjs +356 -0
- package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -0
- package/node_modules/@arbidocs/coedit/dist/commands.d.cts +235 -0
- package/node_modules/@arbidocs/coedit/dist/commands.d.ts +235 -0
- package/node_modules/@arbidocs/coedit/dist/commands.js +338 -0
- package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -0
- package/node_modules/@arbidocs/coedit/package.json +6 -1
- package/package.json +4 -4
- package/dist/chunk-2SJTXYRM.js.map +0 -1
- package/dist/chunk-BHKFENKT.cjs.map +0 -1
- package/dist/chunk-DTBSGG36.cjs.map +0 -1
- package/dist/chunk-EB7QAZLH.js.map +0 -1
- package/dist/chunk-IXALYQT7.cjs.map +0 -1
- package/dist/chunk-O5NDG4EA.cjs.map +0 -1
- package/dist/chunk-P2KPDPFF.js.map +0 -1
- package/dist/chunk-PFA43QNX.js.map +0 -1
- package/dist/chunk-R6APX23R.cjs.map +0 -1
- package/dist/chunk-ZPLG7QYF.js.map +0 -1
|
@@ -17,7 +17,7 @@ var Y = require('yjs');
|
|
|
17
17
|
var coedit = require('@arbidocs/coedit');
|
|
18
18
|
var hocuspocus = require('@arbidocs/coedit/hocuspocus');
|
|
19
19
|
var template = require('@arbidocs/coedit/template');
|
|
20
|
-
var
|
|
20
|
+
var commands = require('@arbidocs/coedit/commands');
|
|
21
21
|
var editor = require('@docx-editor.dev/core/editor');
|
|
22
22
|
|
|
23
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1375,13 +1375,10 @@ function DocxMentions({
|
|
|
1375
1375
|
}
|
|
1376
1376
|
) });
|
|
1377
1377
|
}
|
|
1378
|
-
var DEFINED_TERM_STYLE = "DefinedTerm";
|
|
1379
|
-
var CROSS_REFERENCE_STYLE = "CrossReference";
|
|
1380
|
-
var BROKEN_CROSS_REFERENCE_STYLE = "CrossReferenceBroken";
|
|
1381
1378
|
var CHARACTER_STYLES = {
|
|
1382
|
-
[DEFINED_TERM_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${DEFINED_TERM_STYLE}"><w:name w:val="Defined Term"/><w:rPr><w:u w:val="dotted" w:color="7F7F7F"/></w:rPr></w:style>`,
|
|
1383
|
-
[CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference"/><w:rPr><w:color w:val="1F4E79"/><w:u w:val="dotted" w:color="8EA9C1"/></w:rPr></w:style>`,
|
|
1384
|
-
[BROKEN_CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${BROKEN_CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference Broken"/><w:basedOn w:val="${CROSS_REFERENCE_STYLE}"/><w:rPr><w:color w:val="C00000"/><w:u w:val="wave" w:color="C00000"/></w:rPr></w:style>`
|
|
1379
|
+
[commands.DEFINED_TERM_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.DEFINED_TERM_STYLE}"><w:name w:val="Defined Term"/><w:rPr><w:u w:val="dotted" w:color="7F7F7F"/></w:rPr></w:style>`,
|
|
1380
|
+
[commands.CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference"/><w:rPr><w:color w:val="1F4E79"/><w:u w:val="dotted" w:color="8EA9C1"/></w:rPr></w:style>`,
|
|
1381
|
+
[commands.BROKEN_CROSS_REFERENCE_STYLE]: `<w:style w:type="character" w:customStyle="1" w:styleId="${commands.BROKEN_CROSS_REFERENCE_STYLE}"><w:name w:val="Cross Reference Broken"/><w:basedOn w:val="${commands.CROSS_REFERENCE_STYLE}"/><w:rPr><w:color w:val="C00000"/><w:u w:val="wave" w:color="C00000"/></w:rPr></w:style>`
|
|
1385
1382
|
};
|
|
1386
1383
|
function stylesUsed(body) {
|
|
1387
1384
|
return [...new Set([...body.matchAll(/<w:rStyle w:val="([^"]+)"/g)].map((m) => m[1]))];
|
|
@@ -1407,7 +1404,7 @@ function headingParagraphXml(text, styleId) {
|
|
|
1407
1404
|
function termLinkXml(term, bookmark, tooltip) {
|
|
1408
1405
|
return `<w:p><w:hyperlink w:anchor="${chunk2A4MDHJR_cjs.esc(bookmark)}" w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}" w:history="1">${textRun(
|
|
1409
1406
|
term,
|
|
1410
|
-
`<w:rStyle w:val="${DEFINED_TERM_STYLE}"/>`
|
|
1407
|
+
`<w:rStyle w:val="${commands.DEFINED_TERM_STYLE}"/>`
|
|
1411
1408
|
)}</w:hyperlink></w:p>`;
|
|
1412
1409
|
}
|
|
1413
1410
|
function base64(bytes) {
|
|
@@ -1606,136 +1603,7 @@ function LinkHoverCard({
|
|
|
1606
1603
|
document.body
|
|
1607
1604
|
);
|
|
1608
1605
|
}
|
|
1609
|
-
|
|
1610
|
-
// src/docx/definitions/port.ts
|
|
1611
|
-
var WATCHED_STYLES = /* @__PURE__ */ new Set([BROKEN_CROSS_REFERENCE_STYLE]);
|
|
1612
1606
|
var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
|
|
1613
|
-
var FIELD_ATOM = "\uFFFC";
|
|
1614
|
-
var HEADING_STYLE = /^(heading|berschrift|titre|t[ií]tulo|titolo|kop)\s*\d/i;
|
|
1615
|
-
function readParagraphs(root) {
|
|
1616
|
-
const out = [];
|
|
1617
|
-
const body = root.children?.find((n) => n.kind === "body") ?? root;
|
|
1618
|
-
const visit = (node, topLevel, pending) => {
|
|
1619
|
-
for (const child of node.children ?? []) {
|
|
1620
|
-
if (child.kind === "paragraph") {
|
|
1621
|
-
out.push(readParagraph(child, topLevel, pending.splice(0)));
|
|
1622
|
-
} else if (child.localName === "bookmarkStart") {
|
|
1623
|
-
const name = attr(child, "name");
|
|
1624
|
-
if (name) pending.push(name);
|
|
1625
|
-
} else if (child.localName === "tbl" || child.localName === "tr" || child.localName === "tc") {
|
|
1626
|
-
visit(child, false, pending);
|
|
1627
|
-
} else if (child.localName === "sdt" || child.localName === "sdtContent") {
|
|
1628
|
-
visit(child, topLevel, pending);
|
|
1629
|
-
}
|
|
1630
|
-
}
|
|
1631
|
-
};
|
|
1632
|
-
visit(body, true, []);
|
|
1633
|
-
return out;
|
|
1634
|
-
}
|
|
1635
|
-
function readParagraph(node, topLevel, bookmarks) {
|
|
1636
|
-
let text = "";
|
|
1637
|
-
const links = [];
|
|
1638
|
-
let styleId;
|
|
1639
|
-
let outline = false;
|
|
1640
|
-
let fieldDepth = 0;
|
|
1641
|
-
const marks = [];
|
|
1642
|
-
let runStyle;
|
|
1643
|
-
const fields = [];
|
|
1644
|
-
let current = null;
|
|
1645
|
-
const field = (c) => {
|
|
1646
|
-
const type = attr(c, "fldCharType");
|
|
1647
|
-
if (type === "begin") {
|
|
1648
|
-
if (fieldDepth === 0) {
|
|
1649
|
-
current = { offset: text.length, instruction: "", result: "", inResult: false };
|
|
1650
|
-
text += FIELD_ATOM;
|
|
1651
|
-
}
|
|
1652
|
-
fieldDepth++;
|
|
1653
|
-
} else if (type === "separate" && fieldDepth === 1 && current) current.inResult = true;
|
|
1654
|
-
else if (type === "end") {
|
|
1655
|
-
fieldDepth = Math.max(0, fieldDepth - 1);
|
|
1656
|
-
if (fieldDepth === 0 && current) {
|
|
1657
|
-
const { offset, instruction, result } = current;
|
|
1658
|
-
fields.push({ offset, instruction: instruction.trim(), result });
|
|
1659
|
-
current = null;
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
};
|
|
1663
|
-
const walk = (n, link) => {
|
|
1664
|
-
for (const c of n.children ?? []) {
|
|
1665
|
-
if (c.localName === "fldChar") {
|
|
1666
|
-
field(c);
|
|
1667
|
-
continue;
|
|
1668
|
-
}
|
|
1669
|
-
if (c.localName === "fldSimple") {
|
|
1670
|
-
if (fieldDepth === 0) text += FIELD_ATOM;
|
|
1671
|
-
continue;
|
|
1672
|
-
}
|
|
1673
|
-
if (c.localName === "instrText") {
|
|
1674
|
-
if (fieldDepth === 1 && current)
|
|
1675
|
-
current.instruction += (c.children ?? []).map((t) => t.value ?? "").join("");
|
|
1676
|
-
continue;
|
|
1677
|
-
}
|
|
1678
|
-
if (c.kind === "paragraphProperties" || c.localName === "pPr") {
|
|
1679
|
-
for (const p of c.children ?? []) {
|
|
1680
|
-
if (p.localName === "pStyle") styleId = attr(p, "val");
|
|
1681
|
-
if (p.localName === "outlineLvl" && Number(attr(p, "val")) < 9) outline = true;
|
|
1682
|
-
}
|
|
1683
|
-
continue;
|
|
1684
|
-
}
|
|
1685
|
-
if (c.localName === "delText" || c.localName === "del" || c.localName === "rPr") continue;
|
|
1686
|
-
if (c.localName === "r") {
|
|
1687
|
-
const rStyle = c.children?.find((x) => x.localName === "rPr")?.children?.find((x) => x.localName === "rStyle");
|
|
1688
|
-
const watched = rStyle && attr(rStyle, "val");
|
|
1689
|
-
runStyle = watched && WATCHED_STYLES.has(watched) ? watched : void 0;
|
|
1690
|
-
walk(c, link);
|
|
1691
|
-
runStyle = void 0;
|
|
1692
|
-
continue;
|
|
1693
|
-
}
|
|
1694
|
-
if (c.localName === "bookmarkStart") {
|
|
1695
|
-
const name = attr(c, "name");
|
|
1696
|
-
if (name) bookmarks.push(name);
|
|
1697
|
-
continue;
|
|
1698
|
-
}
|
|
1699
|
-
if (c.localName === "hyperlink") {
|
|
1700
|
-
const anchor = attr(c, "anchor");
|
|
1701
|
-
const next = anchor ? { anchor, text: "" } : void 0;
|
|
1702
|
-
walk(c, next ?? link);
|
|
1703
|
-
if (next) links.push(next);
|
|
1704
|
-
continue;
|
|
1705
|
-
}
|
|
1706
|
-
if (c.kind === "textValue") {
|
|
1707
|
-
if (fieldDepth > 0) {
|
|
1708
|
-
const open = current;
|
|
1709
|
-
if (fieldDepth === 1 && open?.inResult) open.result += c.value ?? "";
|
|
1710
|
-
continue;
|
|
1711
|
-
}
|
|
1712
|
-
if (runStyle && c.value) {
|
|
1713
|
-
const last = marks[marks.length - 1];
|
|
1714
|
-
if (last && last.styleId === runStyle && last.offset + last.text.length === text.length)
|
|
1715
|
-
last.text += c.value;
|
|
1716
|
-
else marks.push({ styleId: runStyle, offset: text.length, text: c.value });
|
|
1717
|
-
}
|
|
1718
|
-
text += c.value ?? "";
|
|
1719
|
-
if (link) link.text += c.value ?? "";
|
|
1720
|
-
continue;
|
|
1721
|
-
}
|
|
1722
|
-
if (c.localName === "tab" && fieldDepth === 0) text += " ";
|
|
1723
|
-
walk(c, link);
|
|
1724
|
-
}
|
|
1725
|
-
};
|
|
1726
|
-
walk(node);
|
|
1727
|
-
return {
|
|
1728
|
-
id: node.id,
|
|
1729
|
-
text,
|
|
1730
|
-
heading: outline || !!styleId && HEADING_STYLE.test(styleId),
|
|
1731
|
-
styleId,
|
|
1732
|
-
topLevel,
|
|
1733
|
-
bookmarks,
|
|
1734
|
-
links,
|
|
1735
|
-
...fields.length ? { fields } : {},
|
|
1736
|
-
...marks.length ? { marks } : {}
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
1607
|
function documentStyleIds(root) {
|
|
1740
1608
|
const ids = /* @__PURE__ */ new Set();
|
|
1741
1609
|
for (const style of root?.children ?? [])
|
|
@@ -1752,7 +1620,7 @@ function editorPort(editor, revision) {
|
|
|
1752
1620
|
return s;
|
|
1753
1621
|
};
|
|
1754
1622
|
return {
|
|
1755
|
-
paragraphs: () => readParagraphs(surface().session.part().root),
|
|
1623
|
+
paragraphs: () => commands.readParagraphs(surface().session.part().root),
|
|
1756
1624
|
caret: () => {
|
|
1757
1625
|
const selection = surface().state().selection;
|
|
1758
1626
|
if (!selection) return null;
|
|
@@ -2642,7 +2510,7 @@ function HouseTemplateProvider({
|
|
|
2642
2510
|
[editor, editable, template$1, notify, refresh, track]
|
|
2643
2511
|
);
|
|
2644
2512
|
const setAsHouseTemplate = React4.useMemo(
|
|
2645
|
-
() => host?.setFromDocument && documentId ? async () => {
|
|
2513
|
+
() => host?.setFromDocument && documentId && (host.isEligible?.(documentId) ?? true) ? async () => {
|
|
2646
2514
|
try {
|
|
2647
2515
|
await host.setFromDocument(documentId);
|
|
2648
2516
|
setTemplate(await resolveHouseTemplate(host));
|
|
@@ -3012,88 +2880,19 @@ function runBeforeSave(editor) {
|
|
|
3012
2880
|
} catch {
|
|
3013
2881
|
}
|
|
3014
2882
|
}
|
|
3015
|
-
|
|
3016
|
-
// src/docx/references/numbering.ts
|
|
3017
|
-
var numbers = (level) => !!level && level.numFmt !== "bullet" && level.numFmt !== "none" && (level.lvlText ?? level.markerText ?? "").length > 0;
|
|
3018
|
-
function paragraphNumber(order, items, levelOf, paragraphId) {
|
|
3019
|
-
const item = items.get(paragraphId);
|
|
3020
|
-
if (!item || !numbers(item)) return null;
|
|
3021
|
-
const at = order.indexOf(paragraphId);
|
|
3022
|
-
const markerAt = (ilvl) => {
|
|
3023
|
-
if (ilvl === item.ilvl) return item.markerText;
|
|
3024
|
-
for (let i = at - 1; i >= 0; i--) {
|
|
3025
|
-
const other = items.get(order[i]);
|
|
3026
|
-
if (other && other.numId === item.numId && other.ilvl === ilvl) return other.markerText;
|
|
3027
|
-
}
|
|
3028
|
-
return null;
|
|
3029
|
-
};
|
|
3030
|
-
const chain = [];
|
|
3031
|
-
const texts = [];
|
|
3032
|
-
for (let u = item.ilvl; u >= 0; u--) {
|
|
3033
|
-
const level = levelOf(item.numId, u);
|
|
3034
|
-
if (!level || !numbers(level)) continue;
|
|
3035
|
-
if (u !== item.ilvl && texts.some((t) => t.includes(`%${u + 1}`))) continue;
|
|
3036
|
-
chain.push(u);
|
|
3037
|
-
texts.push(level.lvlText);
|
|
3038
|
-
}
|
|
3039
|
-
const value = chain.reverse().map((u) => markerAt(u) ?? "").join("");
|
|
3040
|
-
if (!value) return null;
|
|
3041
|
-
return value.length > 1 && value.endsWith(".") ? value.slice(0, -1) : value;
|
|
3042
|
-
}
|
|
3043
|
-
function listTargets(paragraphs, items, levelOf) {
|
|
3044
|
-
const order = paragraphs.map((p) => p.id);
|
|
3045
|
-
const out = [];
|
|
3046
|
-
for (const p of paragraphs) {
|
|
3047
|
-
const text = p.text.replace(//g, "").trim();
|
|
3048
|
-
if (!text) continue;
|
|
3049
|
-
const number = paragraphNumber(order, items, levelOf, p.id);
|
|
3050
|
-
const item = items.get(p.id);
|
|
3051
|
-
if (number !== null)
|
|
3052
|
-
out.push({
|
|
3053
|
-
paragraphId: p.id,
|
|
3054
|
-
kind: "numbered",
|
|
3055
|
-
number,
|
|
3056
|
-
marker: item?.markerText ?? "",
|
|
3057
|
-
text,
|
|
3058
|
-
heading: p.heading,
|
|
3059
|
-
level: item?.ilvl ?? 0
|
|
3060
|
-
});
|
|
3061
|
-
else if (p.heading)
|
|
3062
|
-
out.push({
|
|
3063
|
-
paragraphId: p.id,
|
|
3064
|
-
kind: "heading",
|
|
3065
|
-
number: null,
|
|
3066
|
-
marker: "",
|
|
3067
|
-
text,
|
|
3068
|
-
heading: true,
|
|
3069
|
-
level: 0
|
|
3070
|
-
});
|
|
3071
|
-
}
|
|
3072
|
-
return out;
|
|
3073
|
-
}
|
|
3074
|
-
function filterTargets(targets, query) {
|
|
3075
|
-
const q = query.trim().toLowerCase();
|
|
3076
|
-
if (!q) return [...targets];
|
|
3077
|
-
return targets.filter(
|
|
3078
|
-
(t) => (t.number ?? "").toLowerCase().startsWith(q) || t.text.toLowerCase().includes(q)
|
|
3079
|
-
);
|
|
3080
|
-
}
|
|
3081
|
-
|
|
3082
|
-
// src/docx/references/commands.ts
|
|
3083
|
-
var REF_BOOKMARK_PREFIX = "_Ref";
|
|
3084
2883
|
function newRefBookmark(taken, random = Math.random) {
|
|
3085
2884
|
for (; ; ) {
|
|
3086
|
-
const name = `${REF_BOOKMARK_PREFIX}${String(Math.floor(random() * 9e8) + 1e8)}`;
|
|
2885
|
+
const name = `${commands.REF_BOOKMARK_PREFIX}${String(Math.floor(random() * 9e8) + 1e8)}`;
|
|
3087
2886
|
if (!taken.has(name)) return name;
|
|
3088
2887
|
}
|
|
3089
2888
|
}
|
|
3090
2889
|
var styled = (style) => style ? `<w:rPr><w:rStyle w:val="${style}"/></w:rPr>` : "";
|
|
3091
2890
|
var run = (text, style) => `<w:r>${styled(style)}<w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(text)}</w:t></w:r>`;
|
|
3092
2891
|
function refFieldXml(instruction, cached) {
|
|
3093
|
-
const r = (inner) => `<w:r>${styled(CROSS_REFERENCE_STYLE)}${inner}</w:r>`;
|
|
2892
|
+
const r = (inner) => `<w:r>${styled(commands.CROSS_REFERENCE_STYLE)}${inner}</w:r>`;
|
|
3094
2893
|
return `${r('<w:fldChar w:fldCharType="begin"/>')}${r(
|
|
3095
2894
|
`<w:instrText xml:space="preserve"> ${chunk2A4MDHJR_cjs.esc(instruction)} </w:instrText>`
|
|
3096
|
-
)}${r('<w:fldChar w:fldCharType="separate"/>')}${run(cached, CROSS_REFERENCE_STYLE)}${r(
|
|
2895
|
+
)}${r('<w:fldChar w:fldCharType="separate"/>')}${run(cached, commands.CROSS_REFERENCE_STYLE)}${r(
|
|
3097
2896
|
'<w:fldChar w:fldCharType="end"/>'
|
|
3098
2897
|
)}`;
|
|
3099
2898
|
}
|
|
@@ -3109,7 +2908,7 @@ var allBookmarks = (port) => new Set(port.paragraphs().flatMap((p) => p.bookmark
|
|
|
3109
2908
|
function ensureTargetBookmark(port, target, mode) {
|
|
3110
2909
|
const paragraph = port.paragraphs().find((p) => p.id === target.paragraphId);
|
|
3111
2910
|
if (!paragraph) throw new Error("That clause is no longer in the document.");
|
|
3112
|
-
const existing = paragraph.bookmarks.find((b) => b.startsWith(REF_BOOKMARK_PREFIX));
|
|
2911
|
+
const existing = paragraph.bookmarks.find((b) => b.startsWith(commands.REF_BOOKMARK_PREFIX));
|
|
3113
2912
|
if (existing && mode === "number") return existing;
|
|
3114
2913
|
const name = newRefBookmark(allBookmarks(port));
|
|
3115
2914
|
const start = `<w:bookmarkStart w:id="0" w:name="${name}"/>`;
|
|
@@ -3132,7 +2931,7 @@ function ensureTargetBookmark(port, target, mode) {
|
|
|
3132
2931
|
}
|
|
3133
2932
|
function pastePoint(port, caret) {
|
|
3134
2933
|
const paragraph = port.paragraphs().find((p) => p.id === caret.paragraphId);
|
|
3135
|
-
if (paragraph?.text[caret.offset - 1] !== FIELD_ATOM) return caret;
|
|
2934
|
+
if (paragraph?.text[caret.offset - 1] !== commands.FIELD_ATOM) return caret;
|
|
3136
2935
|
port.setCaret(caret);
|
|
3137
2936
|
port.typeText(" ");
|
|
3138
2937
|
return { paragraphId: caret.paragraphId, offset: caret.offset + 1 };
|
|
@@ -3160,65 +2959,27 @@ function insertDocumentReference(port, reference, caret) {
|
|
|
3160
2959
|
const tooltip = documentReferenceTooltip(text, reference.appName).slice(0, 255);
|
|
3161
2960
|
caret = pastePoint(port, caret);
|
|
3162
2961
|
port.setCaret(caret);
|
|
3163
|
-
const link = `<w:p><w:hyperlink r:id="rIdRef1"${tooltip ? ` w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}"` : ""} w:history="1">${run(text, CROSS_REFERENCE_STYLE)}</w:hyperlink></w:p>`;
|
|
2962
|
+
const link = `<w:p><w:hyperlink r:id="rIdRef1"${tooltip ? ` w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}"` : ""} w:history="1">${run(text, commands.CROSS_REFERENCE_STYLE)}</w:hyperlink></w:p>`;
|
|
3164
2963
|
if (!port.paste(link, text, false, chunk2A4MDHJR_cjs.hyperlinkRelationship("rIdRef1", reference.url)))
|
|
3165
2964
|
throw new Error("The reference could not be inserted.");
|
|
3166
2965
|
port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + text.length });
|
|
3167
2966
|
}
|
|
3168
|
-
var REF_FIELD = /^REF\s+(\S+)((?:\s+\\[A-Za-z*]+(?:\s+MERGEFORMAT)?)*)\s*$/i;
|
|
3169
|
-
function staleCrossReferences(port) {
|
|
3170
|
-
const paragraphs = port.paragraphs();
|
|
3171
|
-
if (!paragraphs.some((p) => p.fields?.length)) return [];
|
|
3172
|
-
const items = port.listItems();
|
|
3173
|
-
const order = paragraphs.map((p) => p.id);
|
|
3174
|
-
const owner = /* @__PURE__ */ new Map();
|
|
3175
|
-
for (const p of paragraphs) for (const b of p.bookmarks) if (!owner.has(b)) owner.set(b, p.id);
|
|
3176
|
-
const out = [];
|
|
3177
|
-
for (const p of paragraphs)
|
|
3178
|
-
for (const field of p.fields ?? []) {
|
|
3179
|
-
const match = REF_FIELD.exec(field.instruction);
|
|
3180
|
-
if (!match || !match[1].startsWith(REF_BOOKMARK_PREFIX)) continue;
|
|
3181
|
-
const switches = match[2].toLowerCase();
|
|
3182
|
-
const mode = /\\[rwn]\b/.test(switches) ? "number" : "text";
|
|
3183
|
-
const target = owner.get(match[1]);
|
|
3184
|
-
const base = {
|
|
3185
|
-
paragraphId: p.id,
|
|
3186
|
-
offset: field.offset,
|
|
3187
|
-
instruction: field.instruction,
|
|
3188
|
-
cached: field.result,
|
|
3189
|
-
bookmark: match[1],
|
|
3190
|
-
mode
|
|
3191
|
-
};
|
|
3192
|
-
if (!target) {
|
|
3193
|
-
out.push({ ...base, value: null });
|
|
3194
|
-
continue;
|
|
3195
|
-
}
|
|
3196
|
-
const value = /\\[rwn]\b/.test(switches) ? switches.includes("\\r") ? paragraphNumber(order, items, port.levelOf, target) : null : (paragraphs.find((x) => x.id === target)?.text ?? "").replace(//g, "").trim();
|
|
3197
|
-
if (value && value !== field.result.trim()) out.push({ ...base, value });
|
|
3198
|
-
}
|
|
3199
|
-
return out;
|
|
3200
|
-
}
|
|
3201
|
-
function brokenCrossReferences(port) {
|
|
3202
|
-
return port.paragraphs().flatMap(
|
|
3203
|
-
(p) => (p.marks ?? []).filter((m) => m.styleId === BROKEN_CROSS_REFERENCE_STYLE).map((m) => ({ paragraphId: p.id, offset: m.offset, text: m.text }))
|
|
3204
|
-
);
|
|
3205
|
-
}
|
|
3206
2967
|
function refreshCrossReferences(port) {
|
|
3207
|
-
const stale = staleCrossReferences(port).sort(
|
|
2968
|
+
const stale = commands.staleCrossReferences(port).sort(
|
|
3208
2969
|
(a, b) => a.paragraphId === b.paragraphId ? b.offset - a.offset : 0
|
|
3209
2970
|
);
|
|
3210
2971
|
let refreshed = 0;
|
|
3211
2972
|
for (const ref of stale) {
|
|
3212
2973
|
const paragraph = port.paragraphs().find((p) => p.id === ref.paragraphId);
|
|
3213
|
-
if (!paragraph || paragraph.text[ref.offset - 1] === FIELD_ATOM) continue;
|
|
2974
|
+
if (!paragraph || paragraph.text[ref.offset - 1] === commands.FIELD_ATOM) continue;
|
|
3214
2975
|
const at = { paragraphId: ref.paragraphId, offset: ref.offset };
|
|
3215
2976
|
port.deleteRange(at, { paragraphId: ref.paragraphId, offset: ref.offset + 1 });
|
|
3216
2977
|
port.setCaret(at);
|
|
3217
2978
|
const text = ref.value ?? (ref.cached.trim() || ref.bookmark);
|
|
3218
|
-
const body = ref.value === null ? run(text, BROKEN_CROSS_REFERENCE_STYLE) : crossReferenceXml(ref.bookmark, ref.mode, ref.value);
|
|
2979
|
+
const body = ref.value === null ? run(text, commands.BROKEN_CROSS_REFERENCE_STYLE) : crossReferenceXml(ref.bookmark, ref.mode, ref.value);
|
|
3219
2980
|
if (port.paste(`<w:p>${body}</w:p>`, text, false) && ref.value !== null) refreshed++;
|
|
3220
2981
|
}
|
|
3221
|
-
return { refreshed, broken: brokenCrossReferences(port) };
|
|
2982
|
+
return { refreshed, broken: commands.brokenCrossReferences(port) };
|
|
3222
2983
|
}
|
|
3223
2984
|
|
|
3224
2985
|
// src/docx/references/passages.ts
|
|
@@ -3284,39 +3045,16 @@ function referencesPort(editor, revision) {
|
|
|
3284
3045
|
return s;
|
|
3285
3046
|
};
|
|
3286
3047
|
const root = () => session().part().root;
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
numbering = layout.withNumberingStyleLinks(layout.buildNumberingIndex(s.numberingRoot()), cascade);
|
|
3294
|
-
}
|
|
3295
|
-
return numbering;
|
|
3296
|
-
};
|
|
3048
|
+
const numbering = commands.documentNumbering({
|
|
3049
|
+
root,
|
|
3050
|
+
stylesRoot: () => session().stylesRoot(),
|
|
3051
|
+
numberingRoot: () => session().numberingRoot(),
|
|
3052
|
+
settingsRoot: () => session().settingsRoot()
|
|
3053
|
+
});
|
|
3297
3054
|
return {
|
|
3298
3055
|
...base,
|
|
3299
|
-
listItems:
|
|
3300
|
-
|
|
3301
|
-
const items = layout.resolveStoryListItems(
|
|
3302
|
-
body?.children ?? [],
|
|
3303
|
-
index(),
|
|
3304
|
-
cascade
|
|
3305
|
-
);
|
|
3306
|
-
const out = /* @__PURE__ */ new Map();
|
|
3307
|
-
for (const [id, item] of items)
|
|
3308
|
-
out.set(id, {
|
|
3309
|
-
numId: item.numId,
|
|
3310
|
-
ilvl: item.ilvl,
|
|
3311
|
-
markerText: item.markerText,
|
|
3312
|
-
numFmt: item.numFmt
|
|
3313
|
-
});
|
|
3314
|
-
return out;
|
|
3315
|
-
},
|
|
3316
|
-
levelOf: (numId, ilvl) => {
|
|
3317
|
-
const level = layout.resolveNumberingLevel(index(), numId, ilvl)?.level;
|
|
3318
|
-
return level ? { lvlText: level.lvlText, numFmt: level.numFmt } : null;
|
|
3319
|
-
},
|
|
3056
|
+
listItems: numbering.listItems,
|
|
3057
|
+
levelOf: numbering.levelOf,
|
|
3320
3058
|
runsXml: (paragraphId) => {
|
|
3321
3059
|
const node = findNode2(root(), paragraphId);
|
|
3322
3060
|
return node ? paragraphRunsXml(node) : null;
|
|
@@ -3379,7 +3117,7 @@ function CrossReferencesProvider({
|
|
|
3379
3117
|
const port = referencesPort(editor);
|
|
3380
3118
|
const caret = port.caret();
|
|
3381
3119
|
if (!caret) return notify?.("Place the cursor where the reference should go.", "error");
|
|
3382
|
-
setDialog({ caret, targets: listTargets(port.paragraphs(), port.listItems(), port.levelOf) });
|
|
3120
|
+
setDialog({ caret, targets: commands.listTargets(port.paragraphs(), port.listItems(), port.levelOf) });
|
|
3383
3121
|
} catch (error) {
|
|
3384
3122
|
notify?.(error instanceof Error ? error.message : "Could not read the document.", "error");
|
|
3385
3123
|
}
|
|
@@ -3481,7 +3219,7 @@ function CrossReferencesProvider({
|
|
|
3481
3219
|
const paragraphs = port.paragraphs();
|
|
3482
3220
|
const target = paragraphs.find((p) => p.bookmarks.includes(name));
|
|
3483
3221
|
if (!target) return { title: l.brokenCard, body: l.brokenCardBody };
|
|
3484
|
-
const number = paragraphNumber(
|
|
3222
|
+
const number = commands.paragraphNumber(
|
|
3485
3223
|
paragraphs.map((p) => p.id),
|
|
3486
3224
|
port.listItems(),
|
|
3487
3225
|
port.levelOf,
|
|
@@ -3502,7 +3240,7 @@ function CrossReferencesProvider({
|
|
|
3502
3240
|
LinkHoverCard,
|
|
3503
3241
|
{
|
|
3504
3242
|
root: viewer,
|
|
3505
|
-
matches: (href) => href.startsWith(`#${REF_BOOKMARK_PREFIX}`),
|
|
3243
|
+
matches: (href) => href.startsWith(`#${commands.REF_BOOKMARK_PREFIX}`),
|
|
3506
3244
|
resolve: resolveInternal,
|
|
3507
3245
|
testId: "docx-cross-reference-card"
|
|
3508
3246
|
}
|
|
@@ -3616,7 +3354,7 @@ function CrossReferenceDialog({
|
|
|
3616
3354
|
const [query, setQuery] = React4.useState("");
|
|
3617
3355
|
const [chosen, setChosen] = React4.useState(null);
|
|
3618
3356
|
const [mode, setMode] = React4.useState("number");
|
|
3619
|
-
const shown = React4.useMemo(() => filterTargets(targets, query), [targets, query]);
|
|
3357
|
+
const shown = React4.useMemo(() => commands.filterTargets(targets, query), [targets, query]);
|
|
3620
3358
|
const effectiveMode = chosen?.number ? mode : "text";
|
|
3621
3359
|
const [documents, setDocuments] = React4.useState(null);
|
|
3622
3360
|
const [docId, setDocId] = React4.useState(null);
|
|
@@ -5442,6 +5180,14 @@ function NativeDocxEditor({
|
|
|
5442
5180
|
);
|
|
5443
5181
|
}
|
|
5444
5182
|
|
|
5183
|
+
Object.defineProperty(exports, "listTargets", {
|
|
5184
|
+
enumerable: true,
|
|
5185
|
+
get: function () { return commands.listTargets; }
|
|
5186
|
+
});
|
|
5187
|
+
Object.defineProperty(exports, "paragraphNumber", {
|
|
5188
|
+
enumerable: true,
|
|
5189
|
+
get: function () { return commands.paragraphNumber; }
|
|
5190
|
+
});
|
|
5445
5191
|
exports.BUILTIN_TEMPLATE_NAME = BUILTIN_TEMPLATE_NAME;
|
|
5446
5192
|
exports.CrossReferenceDialog = CrossReferenceDialog;
|
|
5447
5193
|
exports.CrossReferencesProvider = CrossReferencesProvider;
|
|
@@ -5466,9 +5212,7 @@ exports.findDefinitionsSection = findDefinitionsSection;
|
|
|
5466
5212
|
exports.insertCrossReference = insertCrossReference;
|
|
5467
5213
|
exports.insertDefinedTerm = insertDefinedTerm;
|
|
5468
5214
|
exports.insertDocumentReference = insertDocumentReference;
|
|
5469
|
-
exports.listTargets = listTargets;
|
|
5470
5215
|
exports.normalizeDocxExport = normalizeDocxExport;
|
|
5471
|
-
exports.paragraphNumber = paragraphNumber;
|
|
5472
5216
|
exports.referenceText = referenceText;
|
|
5473
5217
|
exports.referencesPort = referencesPort;
|
|
5474
5218
|
exports.resolveHouseTemplate = resolveHouseTemplate;
|
|
@@ -5484,5 +5228,5 @@ exports.useReview = useReview;
|
|
|
5484
5228
|
exports.useReviewItem = useReviewItem;
|
|
5485
5229
|
exports.useTrackedOrNoted = useTrackedOrNoted;
|
|
5486
5230
|
exports.withDirectEditing = withDirectEditing;
|
|
5487
|
-
//# sourceMappingURL=chunk-
|
|
5488
|
-
//# sourceMappingURL=chunk-
|
|
5231
|
+
//# sourceMappingURL=chunk-2NIL2ASF.cjs.map
|
|
5232
|
+
//# sourceMappingURL=chunk-2NIL2ASF.cjs.map
|