@arbidocs/blocks 0.4.110 → 0.4.112
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-WODZAURG.cjs → NativeDocxEditor-AQZSUGET.cjs} +8 -8
- package/dist/{NativeDocxEditor-WODZAURG.cjs.map → NativeDocxEditor-AQZSUGET.cjs.map} +1 -1
- package/dist/{NativeDocxEditor-4PY4YZYC.js → NativeDocxEditor-MBCBXYDZ.js} +4 -4
- package/dist/{NativeDocxEditor-4PY4YZYC.js.map → NativeDocxEditor-MBCBXYDZ.js.map} +1 -1
- package/dist/agents/index.cjs +208 -208
- package/dist/agents/index.js +3 -3
- package/dist/calendar/EventEditor.d.ts +1 -1
- package/dist/calendar/draft.d.ts +7 -1
- package/dist/calendar/index.cjs +58 -10
- package/dist/calendar/index.cjs.map +1 -1
- package/dist/calendar/index.d.ts +1 -1
- package/dist/calendar/index.js +56 -11
- package/dist/calendar/index.js.map +1 -1
- package/dist/calendar/types.d.ts +20 -0
- package/dist/calls/CallSidePanel.d.ts +16 -1
- package/dist/calls/ControlBar.d.ts +25 -3
- package/dist/calls/PreJoin.d.ts +6 -2
- package/dist/calls/cards.d.ts +6 -2
- package/dist/calls/index.cjs +1078 -47
- package/dist/calls/index.cjs.map +1 -1
- package/dist/calls/index.d.ts +4 -3
- package/dist/calls/index.js +1067 -51
- package/dist/calls/index.js.map +1 -1
- package/dist/calls/panels.d.ts +11 -0
- package/dist/calls/webinar/ChatPermissionSetting.d.ts +18 -0
- package/dist/calls/webinar/OnStageCheck.d.ts +23 -0
- package/dist/calls/webinar/QAPanel.d.ts +56 -0
- package/dist/calls/webinar/RaiseHandButton.d.ts +14 -0
- package/dist/calls/webinar/WebinarAudiencePanel.d.ts +23 -0
- package/dist/calls/webinar/WebinarViewer.d.ts +39 -0
- package/dist/calls/webinar/WebinarWaiting.d.ts +19 -0
- package/dist/calls/webinar/hooks.d.ts +13 -0
- package/dist/calls/webinar/index.d.ts +14 -0
- package/dist/calls/webinar/live.d.ts +43 -0
- package/dist/calls/webinar/types.d.ts +49 -0
- package/dist/{chunk-GKDWQLVU.js → chunk-3OT37I24.js} +165 -381
- package/dist/chunk-3OT37I24.js.map +1 -0
- package/dist/{chunk-2NIL2ASF.cjs → chunk-ETBB5KMN.cjs} +196 -400
- package/dist/chunk-ETBB5KMN.cjs.map +1 -0
- package/dist/{chunk-SQNAJPNR.js → chunk-GFYGYME3.js} +3 -3
- package/dist/{chunk-SQNAJPNR.js.map → chunk-GFYGYME3.js.map} +1 -1
- package/dist/{chunk-PEHLUB52.js → chunk-GIBRZ54P.js} +3 -3
- package/dist/{chunk-PEHLUB52.js.map → chunk-GIBRZ54P.js.map} +1 -1
- package/dist/chunk-GICUGQNN.cjs +76 -0
- package/dist/chunk-GICUGQNN.cjs.map +1 -0
- package/dist/{chunk-54WBIVHV.cjs → chunk-HF4PAYBM.cjs} +5 -5
- package/dist/{chunk-54WBIVHV.cjs.map → chunk-HF4PAYBM.cjs.map} +1 -1
- package/dist/chunk-I2QSDQQV.cjs +126 -0
- package/dist/chunk-I2QSDQQV.cjs.map +1 -0
- package/dist/chunk-JJLMCV3T.js +73 -0
- package/dist/chunk-JJLMCV3T.js.map +1 -0
- package/dist/{chunk-W7ZDBPJ3.cjs → chunk-OR4CO743.cjs} +3 -3
- package/dist/{chunk-W7ZDBPJ3.cjs.map → chunk-OR4CO743.cjs.map} +1 -1
- package/dist/chunk-QXMR5YHC.js +80 -0
- package/dist/chunk-QXMR5YHC.js.map +1 -0
- package/dist/{chunk-ELDUWTRR.cjs → chunk-RUFNJRLW.cjs} +4 -4
- package/dist/{chunk-ELDUWTRR.cjs.map → chunk-RUFNJRLW.cjs.map} +1 -1
- package/dist/{chunk-JB32KYAH.js → chunk-TKJSCHSX.js} +3 -3
- package/dist/{chunk-JB32KYAH.js.map → chunk-TKJSCHSX.js.map} +1 -1
- package/dist/{chunk-WPVIOGDG.cjs → chunk-US5ASM4G.cjs} +22 -22
- package/dist/{chunk-WPVIOGDG.cjs.map → chunk-US5ASM4G.cjs.map} +1 -1
- package/dist/{chunk-CECWAIHL.js → chunk-XFZ7HNPG.js} +3 -3
- package/dist/{chunk-CECWAIHL.js.map → chunk-XFZ7HNPG.js.map} +1 -1
- package/dist/{chunk-VZKBI2KJ.cjs → chunk-Z2NSU7D5.cjs} +4 -4
- package/dist/{chunk-VZKBI2KJ.cjs.map → chunk-Z2NSU7D5.cjs.map} +1 -1
- package/dist/{chunk-A35KT2II.js → chunk-ZP4IFW2E.js} +4 -4
- package/dist/{chunk-A35KT2II.js.map → chunk-ZP4IFW2E.js.map} +1 -1
- package/dist/collaboration/index.cjs +1 -1
- package/dist/collaboration/index.js +1 -1
- package/dist/connect/docx.cjs +7 -7
- package/dist/connect/docx.js +5 -5
- package/dist/connect/index.cjs +38 -38
- package/dist/connect/index.js +8 -8
- package/dist/docx/AgentUndo.d.ts +4 -0
- package/dist/docx/definitions/commands.d.ts +3 -52
- package/dist/docx/definitions/fragment.d.ts +5 -31
- package/dist/docx/definitions/port.d.ts +2 -22
- package/dist/docx/index.cjs +47 -47
- package/dist/docx/index.js +4 -4
- package/dist/docx/references/commands.d.ts +3 -89
- package/dist/docx/references/port.d.ts +2 -11
- package/dist/facts/index.cjs +1 -1
- package/dist/facts/index.js +1 -1
- package/dist/files/index.cjs +1 -1
- package/dist/files/index.js +1 -1
- package/dist/index.cjs +278 -278
- package/dist/index.js +8 -8
- package/dist/settings/index.cjs +47 -101
- package/dist/settings/index.cjs.map +1 -1
- package/dist/settings/index.js +9 -69
- package/dist/settings/index.js.map +1 -1
- package/dist/shell/index.cjs +9 -9
- package/dist/shell/index.js +1 -1
- package/dist/tags/definitions.d.ts +4 -25
- package/dist/tags/ooxml.d.ts +1 -19
- package/dist/workflow-canvas/index.cjs +10 -10
- package/dist/workflow-canvas/index.js +3 -3
- package/node_modules/@arbidocs/coedit/dist/commands.cjs +866 -9
- package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/commands.d.cts +342 -156
- package/node_modules/@arbidocs/coedit/dist/commands.d.ts +342 -156
- package/node_modules/@arbidocs/coedit/dist/commands.js +817 -11
- package/node_modules/@arbidocs/coedit/dist/commands.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.cts +188 -0
- package/node_modules/@arbidocs/coedit/dist/port-ip7WByvH.d.ts +188 -0
- package/node_modules/@arbidocs/coedit/dist/server.cjs +731 -65
- package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.d.cts +40 -1
- package/node_modules/@arbidocs/coedit/dist/server.d.ts +40 -1
- package/node_modules/@arbidocs/coedit/dist/server.js +730 -66
- package/node_modules/@arbidocs/coedit/dist/server.js.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/template.d.cts +3 -17
- package/node_modules/@arbidocs/coedit/dist/template.d.ts +3 -17
- package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.cts +17 -0
- package/node_modules/@arbidocs/coedit/dist/track-eYC94jTp.d.ts +17 -0
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +4 -4
- package/dist/chunk-2A4MDHJR.cjs +0 -198
- package/dist/chunk-2A4MDHJR.cjs.map +0 -1
- package/dist/chunk-2NIL2ASF.cjs.map +0 -1
- package/dist/chunk-EPHGD4YV.js +0 -174
- package/dist/chunk-EPHGD4YV.js.map +0 -1
- package/dist/chunk-GKDWQLVU.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var chunk5FYU7ZIU_cjs = require('./chunk-5FYU7ZIU.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkI2QSDQQV_cjs = require('./chunk-I2QSDQQV.cjs');
|
|
6
6
|
var chunk7UTB4PHM_cjs = require('./chunk-7UTB4PHM.cjs');
|
|
7
7
|
var fflate = require('fflate');
|
|
8
8
|
var server = require('react-dom/server');
|
|
@@ -16,8 +16,8 @@ var lucideReact = require('lucide-react');
|
|
|
16
16
|
var Y = require('yjs');
|
|
17
17
|
var coedit = require('@arbidocs/coedit');
|
|
18
18
|
var hocuspocus = require('@arbidocs/coedit/hocuspocus');
|
|
19
|
-
var template = require('@arbidocs/coedit/template');
|
|
20
19
|
var commands = require('@arbidocs/coedit/commands');
|
|
20
|
+
var template = require('@arbidocs/coedit/template');
|
|
21
21
|
var editor = require('@docx-editor.dev/core/editor');
|
|
22
22
|
|
|
23
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -1010,7 +1010,7 @@ function DocxCommentActivity() {
|
|
|
1010
1010
|
const thread = review.items.filter(
|
|
1011
1011
|
(entry) => entry.kind === "comment" && (entry.item.id === commentId || entry.parentId === commentId)
|
|
1012
1012
|
);
|
|
1013
|
-
const statuses = Object.entries(activity).filter(([,
|
|
1013
|
+
const statuses = Object.entries(activity).filter(([, run]) => run.commentId === commentId);
|
|
1014
1014
|
const labels = {
|
|
1015
1015
|
delivering: "Delivering mention\u2026",
|
|
1016
1016
|
queued: "Queued\u2026",
|
|
@@ -1022,18 +1022,18 @@ function DocxCommentActivity() {
|
|
|
1022
1022
|
unknown: "Status unavailable"
|
|
1023
1023
|
};
|
|
1024
1024
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-comment-extra", "data-review-selectable": "", children: [
|
|
1025
|
-
statuses.map(([id,
|
|
1025
|
+
statuses.map(([id, run]) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1026
1026
|
"div",
|
|
1027
1027
|
{
|
|
1028
1028
|
role: "status",
|
|
1029
1029
|
"data-testid": "docx-comment-agent-status",
|
|
1030
|
-
"data-status":
|
|
1030
|
+
"data-status": run.status,
|
|
1031
1031
|
className: "native-docx-comment-activity",
|
|
1032
1032
|
children: [
|
|
1033
|
-
["delivering", "queued", "in_progress"].includes(
|
|
1034
|
-
|
|
1033
|
+
["delivering", "queued", "in_progress"].includes(run.status) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "native-docx-agent-spinner", "aria-hidden": "true" }),
|
|
1034
|
+
run.label,
|
|
1035
1035
|
": ",
|
|
1036
|
-
labels[
|
|
1036
|
+
labels[run.status]
|
|
1037
1037
|
]
|
|
1038
1038
|
},
|
|
1039
1039
|
id
|
|
@@ -1061,10 +1061,10 @@ function DocxCommentActivity() {
|
|
|
1061
1061
|
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium", children: entry.author || "Reviewer" }),
|
|
1062
1062
|
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "docx-full-comment-text", children: /* @__PURE__ */ jsxRuntime.jsx(ui.AiMarkdown, { allowHtml: false, children: commentText(entry) }) })
|
|
1063
1063
|
] }, entry.key)),
|
|
1064
|
-
statuses.map(([id,
|
|
1065
|
-
|
|
1064
|
+
statuses.map(([id, run]) => /* @__PURE__ */ jsxRuntime.jsxs("p", { role: "status", className: "text-sm", children: [
|
|
1065
|
+
run.label,
|
|
1066
1066
|
": ",
|
|
1067
|
-
labels[
|
|
1067
|
+
labels[run.status]
|
|
1068
1068
|
] }, id))
|
|
1069
1069
|
]
|
|
1070
1070
|
}
|
|
@@ -1375,243 +1375,14 @@ function DocxMentions({
|
|
|
1375
1375
|
}
|
|
1376
1376
|
) });
|
|
1377
1377
|
}
|
|
1378
|
-
var CHARACTER_STYLES = {
|
|
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>`
|
|
1382
|
-
};
|
|
1383
|
-
function stylesUsed(body) {
|
|
1384
|
-
return [...new Set([...body.matchAll(/<w:rStyle w:val="([^"]+)"/g)].map((m) => m[1]))];
|
|
1385
|
-
}
|
|
1386
|
-
var fragmentStyles = (ids) => chunk2A4MDHJR_cjs.stylesXml(
|
|
1387
|
-
"",
|
|
1388
|
-
`<w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style>${ids.map((id) => CHARACTER_STYLES[id] ?? "").join("")}`
|
|
1389
|
-
);
|
|
1390
|
-
var textRun = (text, props = "") => `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ""}<w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(text)}</w:t></w:r>`;
|
|
1391
|
-
function definitionTooltip(definition) {
|
|
1392
|
-
const line = `\u201C${definition.term}\u201D${definition.rest}`.replace(/\s+/g, " ").trim();
|
|
1393
|
-
return line.length > 255 ? `${line.slice(0, 254)}\u2026` : line;
|
|
1394
|
-
}
|
|
1395
|
-
function definitionParagraphXml(definition, bookmark, id = 0) {
|
|
1396
|
-
return `<w:p><w:bookmarkStart w:id="${id}" w:name="${chunk2A4MDHJR_cjs.esc(bookmark)}"/>${textRun("\u201C")}${textRun(
|
|
1397
|
-
definition.term,
|
|
1398
|
-
"<w:b/>"
|
|
1399
|
-
)}${textRun("\u201D")}<w:bookmarkEnd w:id="${id}"/>${textRun(definition.rest)}</w:p>`;
|
|
1400
|
-
}
|
|
1401
|
-
function headingParagraphXml(text, styleId) {
|
|
1402
|
-
return styleId ? `<w:p><w:pPr><w:pStyle w:val="${chunk2A4MDHJR_cjs.esc(styleId)}"/></w:pPr>${textRun(text)}</w:p>` : `<w:p><w:pPr><w:keepNext/></w:pPr>${textRun(text, "<w:b/>")}</w:p>`;
|
|
1403
|
-
}
|
|
1404
|
-
function termLinkXml(term, bookmark, tooltip) {
|
|
1405
|
-
return `<w:p><w:hyperlink w:anchor="${chunk2A4MDHJR_cjs.esc(bookmark)}" w:tooltip="${chunk2A4MDHJR_cjs.esc(tooltip)}" w:history="1">${textRun(
|
|
1406
|
-
term,
|
|
1407
|
-
`<w:rStyle w:val="${commands.DEFINED_TERM_STYLE}"/>`
|
|
1408
|
-
)}</w:hyperlink></w:p>`;
|
|
1409
|
-
}
|
|
1410
1378
|
function base64(bytes) {
|
|
1411
1379
|
let binary = "";
|
|
1412
1380
|
for (let i = 0; i < bytes.length; i += 32768)
|
|
1413
1381
|
binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
|
|
1414
1382
|
return btoa(binary);
|
|
1415
1383
|
}
|
|
1416
|
-
function fragmentHtml(body, covered2, {
|
|
1417
|
-
|
|
1418
|
-
relationships,
|
|
1419
|
-
styles = stylesUsed(body)
|
|
1420
|
-
} = {}) {
|
|
1421
|
-
const untracked = chunk2A4MDHJR_cjs.docxPackage({
|
|
1422
|
-
document: chunk2A4MDHJR_cjs.documentXml(body),
|
|
1423
|
-
styles: fragmentStyles(styles),
|
|
1424
|
-
title: "Defined terms",
|
|
1425
|
-
relationships
|
|
1426
|
-
});
|
|
1427
|
-
const bytes = revision ? template.trackInsertion(untracked, revision, covered2) : untracked;
|
|
1428
|
-
return `<div data-docx-fragment="${base64(bytes)}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
|
|
1429
|
-
}
|
|
1430
|
-
|
|
1431
|
-
// src/docx/definitions/commands.ts
|
|
1432
|
-
var DEFINITIONS_HEADING = "Definitions";
|
|
1433
|
-
var SECTION_TITLE = /^(definitions?(\s*(and|&)\s*interpretations?)?|interpretations?(\s*(and|&)\s*definitions?)?|defined\s+terms|glossary)$/i;
|
|
1434
|
-
var NUMBERING = /^(?:(?:clause|section|article|schedule|part)\s+)?(?:[0-9]+(?:\.[0-9]+)*|[A-Z]|[ivxlc]+)[.):]?\s+(?:[-–—]\s*)?/i;
|
|
1435
|
-
function isDefinitionsTitle(paragraph) {
|
|
1436
|
-
if (!paragraph.topLevel) return false;
|
|
1437
|
-
const title = paragraph.text.trim().replace(NUMBERING, "").replace(/[.:]+$/, "").trim();
|
|
1438
|
-
return SECTION_TITLE.test(title) && (paragraph.heading || title.length <= 40);
|
|
1439
|
-
}
|
|
1440
|
-
function findDefinitionsSection(paragraphs) {
|
|
1441
|
-
const title = paragraphs.findIndex(isDefinitionsTitle);
|
|
1442
|
-
if (title < 0) return null;
|
|
1443
|
-
let end = title + 1;
|
|
1444
|
-
while (end < paragraphs.length && paragraphs[end].topLevel && !paragraphs[end].heading) end++;
|
|
1445
|
-
return { title, start: title + 1, end };
|
|
1446
|
-
}
|
|
1447
|
-
var termOf = (paragraph) => chunk2A4MDHJR_cjs.parseDefinition(paragraph.text)?.term ?? null;
|
|
1448
|
-
function insertionIndex(paragraphs, section, term, skip = /* @__PURE__ */ new Set()) {
|
|
1449
|
-
let afterLast = section.start;
|
|
1450
|
-
for (let i = section.start; i < section.end; i++) {
|
|
1451
|
-
if (skip.has(paragraphs[i].id)) continue;
|
|
1452
|
-
const other = termOf(paragraphs[i]);
|
|
1453
|
-
if (other === null) continue;
|
|
1454
|
-
if (chunk2A4MDHJR_cjs.compareTerms(other, term) > 0) return i;
|
|
1455
|
-
afterLast = i + 1;
|
|
1456
|
-
}
|
|
1457
|
-
return afterLast;
|
|
1458
|
-
}
|
|
1459
|
-
var headingStyle = (paragraphs) => paragraphs.find((p) => p.topLevel && p.heading && p.styleId)?.styleId;
|
|
1460
|
-
function insertParagraphs(port, index, body, count, keep) {
|
|
1461
|
-
const before = port.paragraphs();
|
|
1462
|
-
const kept = keep ? before.findIndex((p) => p.id === keep.paragraphId) : -1;
|
|
1463
|
-
if (index < before.length) {
|
|
1464
|
-
port.setCaret({ paragraphId: before[index].id, offset: 0 });
|
|
1465
|
-
} else {
|
|
1466
|
-
const last = before[before.length - 1];
|
|
1467
|
-
port.setCaret({ paragraphId: last.id, offset: last.text.length });
|
|
1468
|
-
port.splitParagraph();
|
|
1469
|
-
const opened = port.paragraphs();
|
|
1470
|
-
port.setCaret({ paragraphId: opened[opened.length - 1].id, offset: 0 });
|
|
1471
|
-
}
|
|
1472
|
-
if (!port.paste(body, "", true)) throw new Error("The definition could not be added.");
|
|
1473
|
-
if (!keep || kept < 0) return keep;
|
|
1474
|
-
const after = port.paragraphs();
|
|
1475
|
-
const moved = index <= kept ? kept + count : kept;
|
|
1476
|
-
return { paragraphId: after[moved]?.id ?? keep.paragraphId, offset: keep.offset };
|
|
1477
|
-
}
|
|
1478
|
-
function addDefinition(port, definition, keep) {
|
|
1479
|
-
const paragraphs = port.paragraphs();
|
|
1480
|
-
const section = findDefinitionsSection(paragraphs);
|
|
1481
|
-
const paragraph = definitionParagraphXml(definition, chunk2A4MDHJR_cjs.definitionBookmark(definition.id));
|
|
1482
|
-
if (section)
|
|
1483
|
-
return insertParagraphs(
|
|
1484
|
-
port,
|
|
1485
|
-
insertionIndex(paragraphs, section, definition.term),
|
|
1486
|
-
paragraph,
|
|
1487
|
-
1,
|
|
1488
|
-
keep
|
|
1489
|
-
);
|
|
1490
|
-
return insertParagraphs(
|
|
1491
|
-
port,
|
|
1492
|
-
paragraphs.length,
|
|
1493
|
-
headingParagraphXml(DEFINITIONS_HEADING, headingStyle(paragraphs)) + paragraph,
|
|
1494
|
-
2,
|
|
1495
|
-
keep
|
|
1496
|
-
);
|
|
1497
|
-
}
|
|
1498
|
-
var hasBookmark = (paragraphs, name) => paragraphs.some((p) => p.bookmarks.includes(name));
|
|
1499
|
-
function insertDefinedTerm(port, definition, options = {}) {
|
|
1500
|
-
const start = port.caret();
|
|
1501
|
-
if (!start) throw new Error("Place the cursor where the term should go.");
|
|
1502
|
-
let caret = start;
|
|
1503
|
-
if (options.replace) {
|
|
1504
|
-
caret = { paragraphId: start.paragraphId, offset: Math.max(0, start.offset - options.replace) };
|
|
1505
|
-
port.deleteRange(caret, start);
|
|
1506
|
-
}
|
|
1507
|
-
const bookmark = chunk2A4MDHJR_cjs.definitionBookmark(definition.id);
|
|
1508
|
-
const addedDefinition = !hasBookmark(port.paragraphs(), bookmark);
|
|
1509
|
-
if (addedDefinition) caret = addDefinition(port, definition, caret) ?? caret;
|
|
1510
|
-
port.setCaret(caret);
|
|
1511
|
-
if (!port.paste(
|
|
1512
|
-
termLinkXml(definition.term, bookmark, definitionTooltip(definition)),
|
|
1513
|
-
definition.term,
|
|
1514
|
-
false
|
|
1515
|
-
))
|
|
1516
|
-
throw new Error("The term could not be inserted.");
|
|
1517
|
-
port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + definition.term.length });
|
|
1518
|
-
return { addedDefinition };
|
|
1519
|
-
}
|
|
1520
|
-
function definitionOfAnchor(anchor, definitions) {
|
|
1521
|
-
const id = chunk2A4MDHJR_cjs.definitionIdOfBookmark(anchor.replace(/^#/, ""));
|
|
1522
|
-
return id ? definitions.get(id) : void 0;
|
|
1523
|
-
}
|
|
1524
|
-
function LinkHoverCard({
|
|
1525
|
-
root,
|
|
1526
|
-
matches,
|
|
1527
|
-
resolve,
|
|
1528
|
-
onFirstHover,
|
|
1529
|
-
testId
|
|
1530
|
-
}) {
|
|
1531
|
-
const [card, setCard] = React4.useState(null);
|
|
1532
|
-
const hovered = React4.useRef(false);
|
|
1533
|
-
const latest = React4.useRef({ matches, onFirstHover });
|
|
1534
|
-
latest.current = { matches, onFirstHover };
|
|
1535
|
-
React4.useEffect(() => {
|
|
1536
|
-
if (!root) return;
|
|
1537
|
-
const over = (event) => {
|
|
1538
|
-
const link = event.target?.closest?.(
|
|
1539
|
-
"a.docx-hyperlink"
|
|
1540
|
-
);
|
|
1541
|
-
const href = link?.getAttribute("href") ?? "";
|
|
1542
|
-
if (!link || !href || !latest.current.matches(href, link)) return;
|
|
1543
|
-
if (!hovered.current) {
|
|
1544
|
-
hovered.current = true;
|
|
1545
|
-
latest.current.onFirstHover?.();
|
|
1546
|
-
}
|
|
1547
|
-
const title = link.getAttribute("title");
|
|
1548
|
-
if (title) {
|
|
1549
|
-
link.dataset.hoverTitle = title;
|
|
1550
|
-
link.removeAttribute("title");
|
|
1551
|
-
}
|
|
1552
|
-
const rect = link.getBoundingClientRect();
|
|
1553
|
-
setCard({
|
|
1554
|
-
left: rect.left,
|
|
1555
|
-
top: rect.bottom + 6,
|
|
1556
|
-
href,
|
|
1557
|
-
fallback: link.dataset.hoverTitle ?? ""
|
|
1558
|
-
});
|
|
1559
|
-
};
|
|
1560
|
-
const out = (event) => {
|
|
1561
|
-
const link = event.target?.closest?.("a.docx-hyperlink");
|
|
1562
|
-
if (link && !link.contains(event.relatedTarget)) setCard(null);
|
|
1563
|
-
};
|
|
1564
|
-
const hide = () => setCard(null);
|
|
1565
|
-
root.addEventListener("mouseover", over);
|
|
1566
|
-
root.addEventListener("mouseout", out);
|
|
1567
|
-
window.addEventListener("keydown", hide, true);
|
|
1568
|
-
window.addEventListener("pointerdown", hide, true);
|
|
1569
|
-
window.addEventListener("scroll", hide, true);
|
|
1570
|
-
return () => {
|
|
1571
|
-
root.removeEventListener("mouseover", over);
|
|
1572
|
-
root.removeEventListener("mouseout", out);
|
|
1573
|
-
window.removeEventListener("keydown", hide, true);
|
|
1574
|
-
window.removeEventListener("pointerdown", hide, true);
|
|
1575
|
-
window.removeEventListener("scroll", hide, true);
|
|
1576
|
-
};
|
|
1577
|
-
}, [root]);
|
|
1578
|
-
if (!card) return null;
|
|
1579
|
-
const content = resolve(card.href);
|
|
1580
|
-
if (!content && !card.fallback) return null;
|
|
1581
|
-
return reactDom.createPortal(
|
|
1582
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1583
|
-
"div",
|
|
1584
|
-
{
|
|
1585
|
-
role: "tooltip",
|
|
1586
|
-
className: "native-docx-link-card rounded-md border border-border bg-popover p-3 text-sm text-popover-foreground shadow-lg",
|
|
1587
|
-
style: {
|
|
1588
|
-
position: "fixed",
|
|
1589
|
-
left: Math.max(8, Math.min(card.left, window.innerWidth - 348)),
|
|
1590
|
-
top: card.top,
|
|
1591
|
-
width: 340,
|
|
1592
|
-
zIndex: 1e3,
|
|
1593
|
-
pointerEvents: "none"
|
|
1594
|
-
},
|
|
1595
|
-
"data-testid": testId,
|
|
1596
|
-
children: content ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1597
|
-
content.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: content.title }),
|
|
1598
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: content.title ? "mt-1 text-muted-foreground" : void 0, children: content.body }),
|
|
1599
|
-
content.footer && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: content.footer })
|
|
1600
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { children: card.fallback })
|
|
1601
|
-
}
|
|
1602
|
-
),
|
|
1603
|
-
document.body
|
|
1604
|
-
);
|
|
1605
|
-
}
|
|
1606
|
-
var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
|
|
1607
|
-
function documentStyleIds(root) {
|
|
1608
|
-
const ids = /* @__PURE__ */ new Set();
|
|
1609
|
-
for (const style of root?.children ?? [])
|
|
1610
|
-
if (style.localName === "style") {
|
|
1611
|
-
const id = attr(style, "styleId");
|
|
1612
|
-
if (id) ids.add(id);
|
|
1613
|
-
}
|
|
1614
|
-
return ids;
|
|
1384
|
+
function fragmentHtml(body, covered2, options = {}) {
|
|
1385
|
+
return `<div data-docx-fragment="${base64(commands.fragmentPackage(body, covered2, options))}" data-docx-fragment-end="${covered2 ? "covered" : "open"}"></div>`;
|
|
1615
1386
|
}
|
|
1616
1387
|
function editorPort(editor, revision) {
|
|
1617
1388
|
const surface = () => {
|
|
@@ -1633,8 +1404,8 @@ function editorPort(editor, revision) {
|
|
|
1633
1404
|
surface().deleteSelection();
|
|
1634
1405
|
},
|
|
1635
1406
|
paste: (body, text, covered2, relationships) => {
|
|
1636
|
-
const defined = documentStyleIds(surface().session.stylesRoot());
|
|
1637
|
-
const styles = stylesUsed(body).filter((id) => !defined.has(id));
|
|
1407
|
+
const defined = commands.documentStyleIds(surface().session.stylesRoot());
|
|
1408
|
+
const styles = commands.stylesUsed(body).filter((id) => !defined.has(id));
|
|
1638
1409
|
return editor.exec({
|
|
1639
1410
|
type: "paste",
|
|
1640
1411
|
text,
|
|
@@ -1718,6 +1489,136 @@ function preservingCaret(editor, fn) {
|
|
|
1718
1489
|
}
|
|
1719
1490
|
return result;
|
|
1720
1491
|
}
|
|
1492
|
+
var AgentUndoRoom = React4.createContext(null);
|
|
1493
|
+
function AgentUndo() {
|
|
1494
|
+
const item = useReviewItem();
|
|
1495
|
+
const review = useReview();
|
|
1496
|
+
const editor = react.useDocxEditor();
|
|
1497
|
+
const room = React4.useContext(AgentUndoRoom);
|
|
1498
|
+
const records = room?.getMap(commands.AGENT_UNDO_MAP);
|
|
1499
|
+
const [, changed] = React4.useReducer((n) => n + 1, 0);
|
|
1500
|
+
const [error, setError] = React4.useState("");
|
|
1501
|
+
React4.useEffect(() => {
|
|
1502
|
+
if (!records) return;
|
|
1503
|
+
records.observe(changed);
|
|
1504
|
+
return () => records.unobserve(changed);
|
|
1505
|
+
}, [records]);
|
|
1506
|
+
if (!item || item.kind !== "comment" || item.parentId || !records) return null;
|
|
1507
|
+
const id = item.item.id;
|
|
1508
|
+
const record = records.get(id);
|
|
1509
|
+
if (!record) return null;
|
|
1510
|
+
const undo = () => {
|
|
1511
|
+
const surface = editor?.surface;
|
|
1512
|
+
if (!editor || !surface) return;
|
|
1513
|
+
const ops = commands.undoOps(surface.session.part().root, record);
|
|
1514
|
+
if (!ops) return setError("What this changed is no longer in the document.");
|
|
1515
|
+
let applied = false;
|
|
1516
|
+
try {
|
|
1517
|
+
applied = withDirectEditing(editor, () => surface.applyAutomationOps(() => ops)).committed;
|
|
1518
|
+
} catch {
|
|
1519
|
+
}
|
|
1520
|
+
if (!applied) return setError("This change could not be undone.");
|
|
1521
|
+
records.delete(id);
|
|
1522
|
+
review.resolve(item, true);
|
|
1523
|
+
};
|
|
1524
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "native-docx-comment-extra", "data-review-selectable": "", children: [
|
|
1525
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1526
|
+
"button",
|
|
1527
|
+
{
|
|
1528
|
+
type: "button",
|
|
1529
|
+
"data-testid": "docx-agent-undo",
|
|
1530
|
+
onClick: (event) => {
|
|
1531
|
+
event.stopPropagation();
|
|
1532
|
+
undo();
|
|
1533
|
+
},
|
|
1534
|
+
children: "Undo"
|
|
1535
|
+
}
|
|
1536
|
+
),
|
|
1537
|
+
error && /* @__PURE__ */ jsxRuntime.jsx("p", { role: "status", className: "native-docx-comment-activity", children: error })
|
|
1538
|
+
] });
|
|
1539
|
+
}
|
|
1540
|
+
function LinkHoverCard({
|
|
1541
|
+
root,
|
|
1542
|
+
matches,
|
|
1543
|
+
resolve,
|
|
1544
|
+
onFirstHover,
|
|
1545
|
+
testId
|
|
1546
|
+
}) {
|
|
1547
|
+
const [card, setCard] = React4.useState(null);
|
|
1548
|
+
const hovered = React4.useRef(false);
|
|
1549
|
+
const latest = React4.useRef({ matches, onFirstHover });
|
|
1550
|
+
latest.current = { matches, onFirstHover };
|
|
1551
|
+
React4.useEffect(() => {
|
|
1552
|
+
if (!root) return;
|
|
1553
|
+
const over = (event) => {
|
|
1554
|
+
const link = event.target?.closest?.(
|
|
1555
|
+
"a.docx-hyperlink"
|
|
1556
|
+
);
|
|
1557
|
+
const href = link?.getAttribute("href") ?? "";
|
|
1558
|
+
if (!link || !href || !latest.current.matches(href, link)) return;
|
|
1559
|
+
if (!hovered.current) {
|
|
1560
|
+
hovered.current = true;
|
|
1561
|
+
latest.current.onFirstHover?.();
|
|
1562
|
+
}
|
|
1563
|
+
const title = link.getAttribute("title");
|
|
1564
|
+
if (title) {
|
|
1565
|
+
link.dataset.hoverTitle = title;
|
|
1566
|
+
link.removeAttribute("title");
|
|
1567
|
+
}
|
|
1568
|
+
const rect = link.getBoundingClientRect();
|
|
1569
|
+
setCard({
|
|
1570
|
+
left: rect.left,
|
|
1571
|
+
top: rect.bottom + 6,
|
|
1572
|
+
href,
|
|
1573
|
+
fallback: link.dataset.hoverTitle ?? ""
|
|
1574
|
+
});
|
|
1575
|
+
};
|
|
1576
|
+
const out = (event) => {
|
|
1577
|
+
const link = event.target?.closest?.("a.docx-hyperlink");
|
|
1578
|
+
if (link && !link.contains(event.relatedTarget)) setCard(null);
|
|
1579
|
+
};
|
|
1580
|
+
const hide = () => setCard(null);
|
|
1581
|
+
root.addEventListener("mouseover", over);
|
|
1582
|
+
root.addEventListener("mouseout", out);
|
|
1583
|
+
window.addEventListener("keydown", hide, true);
|
|
1584
|
+
window.addEventListener("pointerdown", hide, true);
|
|
1585
|
+
window.addEventListener("scroll", hide, true);
|
|
1586
|
+
return () => {
|
|
1587
|
+
root.removeEventListener("mouseover", over);
|
|
1588
|
+
root.removeEventListener("mouseout", out);
|
|
1589
|
+
window.removeEventListener("keydown", hide, true);
|
|
1590
|
+
window.removeEventListener("pointerdown", hide, true);
|
|
1591
|
+
window.removeEventListener("scroll", hide, true);
|
|
1592
|
+
};
|
|
1593
|
+
}, [root]);
|
|
1594
|
+
if (!card) return null;
|
|
1595
|
+
const content = resolve(card.href);
|
|
1596
|
+
if (!content && !card.fallback) return null;
|
|
1597
|
+
return reactDom.createPortal(
|
|
1598
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1599
|
+
"div",
|
|
1600
|
+
{
|
|
1601
|
+
role: "tooltip",
|
|
1602
|
+
className: "native-docx-link-card rounded-md border border-border bg-popover p-3 text-sm text-popover-foreground shadow-lg",
|
|
1603
|
+
style: {
|
|
1604
|
+
position: "fixed",
|
|
1605
|
+
left: Math.max(8, Math.min(card.left, window.innerWidth - 348)),
|
|
1606
|
+
top: card.top,
|
|
1607
|
+
width: 340,
|
|
1608
|
+
zIndex: 1e3,
|
|
1609
|
+
pointerEvents: "none"
|
|
1610
|
+
},
|
|
1611
|
+
"data-testid": testId,
|
|
1612
|
+
children: content ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1613
|
+
content.title && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: content.title }),
|
|
1614
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: content.title ? "mt-1 text-muted-foreground" : void 0, children: content.body }),
|
|
1615
|
+
content.footer && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: content.footer })
|
|
1616
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("p", { children: card.fallback })
|
|
1617
|
+
}
|
|
1618
|
+
),
|
|
1619
|
+
document.body
|
|
1620
|
+
);
|
|
1621
|
+
}
|
|
1721
1622
|
|
|
1722
1623
|
// src/docx/structural/trackedOrNoted.ts
|
|
1723
1624
|
var revisionDate = (at = /* @__PURE__ */ new Date()) => at.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
@@ -1741,7 +1642,7 @@ function trackedOrNoted(port, { label, author, insert, inserted = Boolean }) {
|
|
|
1741
1642
|
if (before && after && port.comment(before, after, label)) return { result, how: "noted" };
|
|
1742
1643
|
return { result, how: "direct" };
|
|
1743
1644
|
}
|
|
1744
|
-
var
|
|
1645
|
+
var attr = (node, name) => node.attributes?.find((a) => a.localName === name)?.value;
|
|
1745
1646
|
function structuralPort(editor) {
|
|
1746
1647
|
return {
|
|
1747
1648
|
mode: () => editor.getEditingMode(),
|
|
@@ -1756,7 +1657,7 @@ function structuralPort(editor) {
|
|
|
1756
1657
|
const root = editor.surface?.session.part().root;
|
|
1757
1658
|
let count = 0;
|
|
1758
1659
|
const visit = (node) => {
|
|
1759
|
-
if (node.localName === "ins" &&
|
|
1660
|
+
if (node.localName === "ins" && attr(node, "author") === author && attr(node, "date") === date)
|
|
1760
1661
|
count++;
|
|
1761
1662
|
node.children?.forEach(visit);
|
|
1762
1663
|
};
|
|
@@ -1849,14 +1750,14 @@ function DefinedTermsProvider({
|
|
|
1849
1750
|
},
|
|
1850
1751
|
[load, sources, notify]
|
|
1851
1752
|
);
|
|
1852
|
-
const all = React4.useMemo(() =>
|
|
1753
|
+
const all = React4.useMemo(() => chunkI2QSDQQV_cjs.groupDefinitions(sources ?? []).groups, [sources]);
|
|
1853
1754
|
const byId = React4.useMemo(
|
|
1854
1755
|
() => new Map(all.flatMap((g) => g.definitions).map((d) => [d.id, d])),
|
|
1855
1756
|
[all]
|
|
1856
1757
|
);
|
|
1857
|
-
const agreements = React4.useMemo(() =>
|
|
1758
|
+
const agreements = React4.useMemo(() => chunkI2QSDQQV_cjs.definitionLabels(sources ?? []), [sources]);
|
|
1858
1759
|
const groups = React4.useMemo(
|
|
1859
|
-
() => picker ?
|
|
1760
|
+
() => picker ? chunkI2QSDQQV_cjs.filterTermGroups(chunkI2QSDQQV_cjs.groupDefinitions(sources ?? [], { labelId }).groups, picker.query).slice(
|
|
1860
1761
|
0,
|
|
1861
1762
|
MAX_GROUPS
|
|
1862
1763
|
) : [],
|
|
@@ -1882,7 +1783,7 @@ function DefinedTermsProvider({
|
|
|
1882
1783
|
},
|
|
1883
1784
|
[notify]
|
|
1884
1785
|
);
|
|
1885
|
-
const
|
|
1786
|
+
const run = React4.useCallback(
|
|
1886
1787
|
(fn) => editor ? attempt(() => withDirectEditing(editor, fn)) : void 0,
|
|
1887
1788
|
[editor, attempt]
|
|
1888
1789
|
);
|
|
@@ -1897,7 +1798,7 @@ function DefinedTermsProvider({
|
|
|
1897
1798
|
(row) => {
|
|
1898
1799
|
if (!editor || !picker || !row) return;
|
|
1899
1800
|
const port = editorPort(editor);
|
|
1900
|
-
const placed =
|
|
1801
|
+
const placed = run(() => {
|
|
1901
1802
|
if (picker.mode === "search" && picker.caret) port.setCaret(picker.caret);
|
|
1902
1803
|
const caret = port.caret();
|
|
1903
1804
|
if (!caret) throw new Error("Place the cursor where the term should go.");
|
|
@@ -1908,7 +1809,7 @@ function DefinedTermsProvider({
|
|
|
1908
1809
|
const result = placed ? attempt(
|
|
1909
1810
|
() => track({
|
|
1910
1811
|
label: `Inserted defined term: ${row.definition.term}`,
|
|
1911
|
-
insert: (revision) => insertDefinedTerm(editorPort(editor, revision), row.definition)
|
|
1812
|
+
insert: (revision) => commands.insertDefinedTerm(editorPort(editor, revision), row.definition)
|
|
1912
1813
|
})?.result
|
|
1913
1814
|
) : void 0;
|
|
1914
1815
|
setPicker(null);
|
|
@@ -1917,7 +1818,7 @@ function DefinedTermsProvider({
|
|
|
1917
1818
|
if (result?.addedDefinition)
|
|
1918
1819
|
notify?.(`\u201C${row.definition.term}\u201D added to the Definitions section.`, "success");
|
|
1919
1820
|
},
|
|
1920
|
-
[editor, picker,
|
|
1821
|
+
[editor, picker, run, attempt, track, notify]
|
|
1921
1822
|
);
|
|
1922
1823
|
const openPicker = React4.useCallback(
|
|
1923
1824
|
(anchor) => {
|
|
@@ -2001,7 +1902,7 @@ function DefinedTermsProvider({
|
|
|
2001
1902
|
root: viewer,
|
|
2002
1903
|
matches: (href) => href.startsWith("#_dt_"),
|
|
2003
1904
|
resolve: (href) => {
|
|
2004
|
-
const definition = definitionOfAnchor(href, byId);
|
|
1905
|
+
const definition = commands.definitionOfAnchor(href, byId);
|
|
2005
1906
|
return definition ? { title: definition.term, body: definition.meaning, footer: sourceOf(definition) } : null;
|
|
2006
1907
|
},
|
|
2007
1908
|
onFirstHover: firstHover,
|
|
@@ -2880,107 +2781,6 @@ function runBeforeSave(editor) {
|
|
|
2880
2781
|
} catch {
|
|
2881
2782
|
}
|
|
2882
2783
|
}
|
|
2883
|
-
function newRefBookmark(taken, random = Math.random) {
|
|
2884
|
-
for (; ; ) {
|
|
2885
|
-
const name = `${commands.REF_BOOKMARK_PREFIX}${String(Math.floor(random() * 9e8) + 1e8)}`;
|
|
2886
|
-
if (!taken.has(name)) return name;
|
|
2887
|
-
}
|
|
2888
|
-
}
|
|
2889
|
-
var styled = (style) => style ? `<w:rPr><w:rStyle w:val="${style}"/></w:rPr>` : "";
|
|
2890
|
-
var run = (text, style) => `<w:r>${styled(style)}<w:t xml:space="preserve">${chunk2A4MDHJR_cjs.esc(text)}</w:t></w:r>`;
|
|
2891
|
-
function refFieldXml(instruction, cached) {
|
|
2892
|
-
const r = (inner) => `<w:r>${styled(commands.CROSS_REFERENCE_STYLE)}${inner}</w:r>`;
|
|
2893
|
-
return `${r('<w:fldChar w:fldCharType="begin"/>')}${r(
|
|
2894
|
-
`<w:instrText xml:space="preserve"> ${chunk2A4MDHJR_cjs.esc(instruction)} </w:instrText>`
|
|
2895
|
-
)}${r('<w:fldChar w:fldCharType="separate"/>')}${run(cached, commands.CROSS_REFERENCE_STYLE)}${r(
|
|
2896
|
-
'<w:fldChar w:fldCharType="end"/>'
|
|
2897
|
-
)}`;
|
|
2898
|
-
}
|
|
2899
|
-
var refTooltip = (value, mode) => mode === "number" ? `Cross-reference to clause ${value}` : `Cross-reference to \u201C${value}\u201D`;
|
|
2900
|
-
function crossReferenceXml(bookmark, mode, value) {
|
|
2901
|
-
return `<w:hyperlink w:anchor="${chunk2A4MDHJR_cjs.esc(bookmark)}" w:tooltip="${chunk2A4MDHJR_cjs.esc(
|
|
2902
|
-
refTooltip(value, mode)
|
|
2903
|
-
)}" w:history="1">${refFieldXml(refInstruction(bookmark, mode), value)}</w:hyperlink>`;
|
|
2904
|
-
}
|
|
2905
|
-
var refInstruction = (bookmark, mode) => mode === "number" ? `REF ${bookmark} \\r \\h` : `REF ${bookmark} \\h`;
|
|
2906
|
-
var refResult = (target, mode) => mode === "number" && target.number ? target.number : target.text;
|
|
2907
|
-
var allBookmarks = (port) => new Set(port.paragraphs().flatMap((p) => p.bookmarks));
|
|
2908
|
-
function ensureTargetBookmark(port, target, mode) {
|
|
2909
|
-
const paragraph = port.paragraphs().find((p) => p.id === target.paragraphId);
|
|
2910
|
-
if (!paragraph) throw new Error("That clause is no longer in the document.");
|
|
2911
|
-
const existing = paragraph.bookmarks.find((b) => b.startsWith(commands.REF_BOOKMARK_PREFIX));
|
|
2912
|
-
if (existing && mode === "number") return existing;
|
|
2913
|
-
const name = newRefBookmark(allBookmarks(port));
|
|
2914
|
-
const start = `<w:bookmarkStart w:id="0" w:name="${name}"/>`;
|
|
2915
|
-
const end = '<w:bookmarkEnd w:id="0"/>';
|
|
2916
|
-
if (mode === "number") {
|
|
2917
|
-
port.setCaret({ paragraphId: paragraph.id, offset: 0 });
|
|
2918
|
-
if (!port.paste(`<w:p>${start}${end}</w:p>`, "", false))
|
|
2919
|
-
throw new Error("The cross-reference target could not be marked.");
|
|
2920
|
-
return name;
|
|
2921
|
-
}
|
|
2922
|
-
const runs = port.runsXml(paragraph.id);
|
|
2923
|
-
if (!runs) throw new Error("This heading cannot be referred to by its text; use its number.");
|
|
2924
|
-
port.deleteRange(
|
|
2925
|
-
{ paragraphId: paragraph.id, offset: 0 },
|
|
2926
|
-
{ paragraphId: paragraph.id, offset: paragraph.text.length }
|
|
2927
|
-
);
|
|
2928
|
-
if (!port.paste(`<w:p>${start}${runs}${end}</w:p>`, paragraph.text, false))
|
|
2929
|
-
throw new Error("The cross-reference target could not be marked.");
|
|
2930
|
-
return name;
|
|
2931
|
-
}
|
|
2932
|
-
function pastePoint(port, caret) {
|
|
2933
|
-
const paragraph = port.paragraphs().find((p) => p.id === caret.paragraphId);
|
|
2934
|
-
if (paragraph?.text[caret.offset - 1] !== commands.FIELD_ATOM) return caret;
|
|
2935
|
-
port.setCaret(caret);
|
|
2936
|
-
port.typeText(" ");
|
|
2937
|
-
return { paragraphId: caret.paragraphId, offset: caret.offset + 1 };
|
|
2938
|
-
}
|
|
2939
|
-
function markCrossReferenceTarget(port, target, mode) {
|
|
2940
|
-
if (mode === "number" && !target.number) mode = "text";
|
|
2941
|
-
const bookmark = ensureTargetBookmark(port, target, mode);
|
|
2942
|
-
return { bookmark, mode, value: refResult(target, mode) };
|
|
2943
|
-
}
|
|
2944
|
-
function insertCrossReferenceField(port, { bookmark, mode, value }, caret) {
|
|
2945
|
-
caret = pastePoint(port, caret);
|
|
2946
|
-
port.setCaret(caret);
|
|
2947
|
-
if (!port.paste(`<w:p>${crossReferenceXml(bookmark, mode, value)}</w:p>`, value, false))
|
|
2948
|
-
throw new Error("The cross-reference could not be inserted.");
|
|
2949
|
-
port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + 1 });
|
|
2950
|
-
return { bookmark };
|
|
2951
|
-
}
|
|
2952
|
-
function insertCrossReference(port, target, mode, caret) {
|
|
2953
|
-
return insertCrossReferenceField(port, markCrossReferenceTarget(port, target, mode), caret);
|
|
2954
|
-
}
|
|
2955
|
-
var documentReferenceTooltip = (text, appName = "ARBI") => `Cross-reference: ${text} \u2014 opens in ${appName}`;
|
|
2956
|
-
function insertDocumentReference(port, reference, caret) {
|
|
2957
|
-
const text = reference.text.trim();
|
|
2958
|
-
if (!text) throw new Error("Enter the reference text.");
|
|
2959
|
-
const tooltip = documentReferenceTooltip(text, reference.appName).slice(0, 255);
|
|
2960
|
-
caret = pastePoint(port, caret);
|
|
2961
|
-
port.setCaret(caret);
|
|
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>`;
|
|
2963
|
-
if (!port.paste(link, text, false, chunk2A4MDHJR_cjs.hyperlinkRelationship("rIdRef1", reference.url)))
|
|
2964
|
-
throw new Error("The reference could not be inserted.");
|
|
2965
|
-
port.setCaret({ paragraphId: caret.paragraphId, offset: caret.offset + text.length });
|
|
2966
|
-
}
|
|
2967
|
-
function refreshCrossReferences(port) {
|
|
2968
|
-
const stale = commands.staleCrossReferences(port).sort(
|
|
2969
|
-
(a, b) => a.paragraphId === b.paragraphId ? b.offset - a.offset : 0
|
|
2970
|
-
);
|
|
2971
|
-
let refreshed = 0;
|
|
2972
|
-
for (const ref of stale) {
|
|
2973
|
-
const paragraph = port.paragraphs().find((p) => p.id === ref.paragraphId);
|
|
2974
|
-
if (!paragraph || paragraph.text[ref.offset - 1] === commands.FIELD_ATOM) continue;
|
|
2975
|
-
const at = { paragraphId: ref.paragraphId, offset: ref.offset };
|
|
2976
|
-
port.deleteRange(at, { paragraphId: ref.paragraphId, offset: ref.offset + 1 });
|
|
2977
|
-
port.setCaret(at);
|
|
2978
|
-
const text = ref.value ?? (ref.cached.trim() || ref.bookmark);
|
|
2979
|
-
const body = ref.value === null ? run(text, commands.BROKEN_CROSS_REFERENCE_STYLE) : crossReferenceXml(ref.bookmark, ref.mode, ref.value);
|
|
2980
|
-
if (port.paste(`<w:p>${body}</w:p>`, text, false) && ref.value !== null) refreshed++;
|
|
2981
|
-
}
|
|
2982
|
-
return { refreshed, broken: commands.brokenCrossReferences(port) };
|
|
2983
|
-
}
|
|
2984
2784
|
|
|
2985
2785
|
// src/docx/references/passages.ts
|
|
2986
2786
|
function shortTitle(title) {
|
|
@@ -3010,25 +2810,6 @@ function filterPassages(passages, query) {
|
|
|
3010
2810
|
const q = query.trim().toLowerCase();
|
|
3011
2811
|
return q ? passages.filter((p) => p.text.toLowerCase().includes(q)) : [...passages];
|
|
3012
2812
|
}
|
|
3013
|
-
var RUN_PARTS = /* @__PURE__ */ new Set(["rPr", "t", "tab", "br", "lastRenderedPageBreak"]);
|
|
3014
|
-
var SKIPPED = /* @__PURE__ */ new Set(["pPr", "bookmarkStart", "bookmarkEnd", "proofErr", "permStart", "permEnd"]);
|
|
3015
|
-
function serialize(node) {
|
|
3016
|
-
if (node.kind === "textValue") return chunk2A4MDHJR_cjs.esc(node.value ?? "");
|
|
3017
|
-
const name = `${node.prefix ?? "w"}:${node.localName}`;
|
|
3018
|
-
const attrs = (node.attributes ?? []).map((a) => ` ${a.prefix ? `${a.prefix}:` : ""}${a.localName}="${chunk2A4MDHJR_cjs.esc(a.value)}"`).join("");
|
|
3019
|
-
const children = (node.children ?? []).map((c) => serialize(c)).join("");
|
|
3020
|
-
return children ? `<${name}${attrs}>${children}</${name}>` : `<${name}${attrs}/>`;
|
|
3021
|
-
}
|
|
3022
|
-
function paragraphRunsXml(paragraph) {
|
|
3023
|
-
const runs = [];
|
|
3024
|
-
for (const child of paragraph.children ?? []) {
|
|
3025
|
-
if (child.localName && SKIPPED.has(child.localName)) continue;
|
|
3026
|
-
if (child.localName !== "r") return null;
|
|
3027
|
-
if ((child.children ?? []).some((c) => !c.localName || !RUN_PARTS.has(c.localName))) return null;
|
|
3028
|
-
runs.push(serialize(child));
|
|
3029
|
-
}
|
|
3030
|
-
return runs.length ? runs.join("") : null;
|
|
3031
|
-
}
|
|
3032
2813
|
function findNode2(node, id) {
|
|
3033
2814
|
if (node.id === id) return node;
|
|
3034
2815
|
for (const child of node.children ?? []) {
|
|
@@ -3057,7 +2838,7 @@ function referencesPort(editor, revision) {
|
|
|
3057
2838
|
levelOf: numbering.levelOf,
|
|
3058
2839
|
runsXml: (paragraphId) => {
|
|
3059
2840
|
const node = findNode2(root(), paragraphId);
|
|
3060
|
-
return node ? paragraphRunsXml(node) : null;
|
|
2841
|
+
return node ? commands.paragraphRunsXml(node) : null;
|
|
3061
2842
|
}
|
|
3062
2843
|
};
|
|
3063
2844
|
}
|
|
@@ -3122,7 +2903,7 @@ function CrossReferencesProvider({
|
|
|
3122
2903
|
notify?.(error instanceof Error ? error.message : "Could not read the document.", "error");
|
|
3123
2904
|
}
|
|
3124
2905
|
}, [editor, editable, notify]);
|
|
3125
|
-
const
|
|
2906
|
+
const run = React4.useCallback(
|
|
3126
2907
|
(label, prepare, insert) => {
|
|
3127
2908
|
if (!editor) return;
|
|
3128
2909
|
try {
|
|
@@ -3147,7 +2928,7 @@ function CrossReferencesProvider({
|
|
|
3147
2928
|
try {
|
|
3148
2929
|
const port = referencesPort(editor);
|
|
3149
2930
|
if (!port.paragraphs().some((p) => p.fields?.length)) return;
|
|
3150
|
-
preservingCaret(editor, () => withDirectEditing(editor, () => refreshCrossReferences(port)));
|
|
2931
|
+
preservingCaret(editor, () => withDirectEditing(editor, () => commands.refreshCrossReferences(port)));
|
|
3151
2932
|
} catch {
|
|
3152
2933
|
}
|
|
3153
2934
|
};
|
|
@@ -3164,7 +2945,7 @@ function CrossReferencesProvider({
|
|
|
3164
2945
|
try {
|
|
3165
2946
|
const result = preservingCaret(
|
|
3166
2947
|
editor,
|
|
3167
|
-
() => withDirectEditing(editor, () => refreshCrossReferences(referencesPort(editor)))
|
|
2948
|
+
() => withDirectEditing(editor, () => commands.refreshCrossReferences(referencesPort(editor)))
|
|
3168
2949
|
);
|
|
3169
2950
|
setReport(result);
|
|
3170
2951
|
} catch (error) {
|
|
@@ -3275,15 +3056,15 @@ function CrossReferencesProvider({
|
|
|
3275
3056
|
labels: l,
|
|
3276
3057
|
onCancel: () => setDialog(null),
|
|
3277
3058
|
onClosed: () => editor?.surface?.focus(),
|
|
3278
|
-
onInsertTarget: (target, mode) =>
|
|
3279
|
-
`Inserted cross-reference: ${refResult(target, mode)}`,
|
|
3280
|
-
() => markCrossReferenceTarget(referencesPort(editor), target, mode),
|
|
3281
|
-
(marked, revision) => insertCrossReferenceField(referencesPort(editor, revision), marked, dialog.caret)
|
|
3059
|
+
onInsertTarget: (target, mode) => run(
|
|
3060
|
+
`Inserted cross-reference: ${commands.refResult(target, mode)}`,
|
|
3061
|
+
() => commands.markCrossReferenceTarget(referencesPort(editor), target, mode),
|
|
3062
|
+
(marked, revision) => commands.insertCrossReferenceField(referencesPort(editor, revision), marked, dialog.caret)
|
|
3282
3063
|
),
|
|
3283
|
-
onInsertPassage: (target, text) =>
|
|
3064
|
+
onInsertPassage: (target, text) => run(
|
|
3284
3065
|
`Inserted cross-reference: ${text}`,
|
|
3285
3066
|
() => void 0,
|
|
3286
|
-
(_, revision) => insertDocumentReference(
|
|
3067
|
+
(_, revision) => commands.insertDocumentReference(
|
|
3287
3068
|
referencesPort(editor, revision),
|
|
3288
3069
|
{ text, url: references.linkFor(target), appName: references.appName },
|
|
3289
3070
|
dialog.caret
|
|
@@ -3477,7 +3258,7 @@ function CrossReferenceDialog({
|
|
|
3477
3258
|
{
|
|
3478
3259
|
className: "ml-auto rounded bg-muted px-2 py-0.5",
|
|
3479
3260
|
"data-testid": "docx-cross-reference-preview",
|
|
3480
|
-
children: refResult(chosen, effectiveMode)
|
|
3261
|
+
children: commands.refResult(chosen, effectiveMode)
|
|
3481
3262
|
}
|
|
3482
3263
|
)
|
|
3483
3264
|
] })
|
|
@@ -4017,7 +3798,7 @@ function TableButtons() {
|
|
|
4017
3798
|
] });
|
|
4018
3799
|
}
|
|
4019
3800
|
var CAPTION_LABELS = ["Figure", "Table", "Equation"];
|
|
4020
|
-
var CAPTION_STYLES =
|
|
3801
|
+
var CAPTION_STYLES = chunkI2QSDQQV_cjs.stylesXml(
|
|
4021
3802
|
"",
|
|
4022
3803
|
'<w:style w:type="paragraph" w:default="1" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/></w:style><w:style w:type="paragraph" w:styleId="Caption"><w:name w:val="caption"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:uiPriority w:val="35"/><w:unhideWhenUsed/><w:qFormat/><w:pPr><w:spacing w:after="200" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:i/><w:iCs/><w:color w:val="44546A"/><w:sz w:val="18"/><w:szCs w:val="18"/></w:rPr></w:style>'
|
|
4023
3804
|
);
|
|
@@ -4045,9 +3826,9 @@ function countSeqFields(root, label, throughId) {
|
|
|
4045
3826
|
return count;
|
|
4046
3827
|
}
|
|
4047
3828
|
function captionParagraphXml(label, number, text) {
|
|
4048
|
-
const
|
|
3829
|
+
const run = (value) => `<w:r><w:t xml:space="preserve">${chunkI2QSDQQV_cjs.esc(value)}</w:t></w:r>`;
|
|
4049
3830
|
const rest = text.trim() ? `: ${text.trim()}` : "";
|
|
4050
|
-
return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${
|
|
3831
|
+
return `<w:p><w:pPr><w:pStyle w:val="Caption"/></w:pPr>${run(`${label} `)}<w:fldSimple w:instr=" SEQ ${chunkI2QSDQQV_cjs.esc(label)} \\* ARABIC "><w:r><w:t>${number}</w:t></w:r></w:fldSimple>${rest ? run(rest) : ""}</w:p>`;
|
|
4051
3832
|
}
|
|
4052
3833
|
function base642(bytes) {
|
|
4053
3834
|
let binary = "";
|
|
@@ -4056,8 +3837,8 @@ function base642(bytes) {
|
|
|
4056
3837
|
return btoa(binary);
|
|
4057
3838
|
}
|
|
4058
3839
|
function captionFragmentHtml(label, number, text, revision) {
|
|
4059
|
-
const untracked =
|
|
4060
|
-
document:
|
|
3840
|
+
const untracked = chunkI2QSDQQV_cjs.docxPackage({
|
|
3841
|
+
document: chunkI2QSDQQV_cjs.documentXml(captionParagraphXml(label, number, text)),
|
|
4061
3842
|
styles: CAPTION_STYLES,
|
|
4062
3843
|
title: "Caption"
|
|
4063
3844
|
});
|
|
@@ -4297,7 +4078,7 @@ function GenerateImageButton({ generation }) {
|
|
|
4297
4078
|
});
|
|
4298
4079
|
const editable = react.useEditorState((snapshot) => snapshot.editable);
|
|
4299
4080
|
const generating = React4.useSyncExternalStore(subscribe, () => running > 0);
|
|
4300
|
-
async function
|
|
4081
|
+
async function run() {
|
|
4301
4082
|
if (!editor || !prompt.trim() || busy) return;
|
|
4302
4083
|
const caret = rememberCaret(editor);
|
|
4303
4084
|
const controller = new AbortController();
|
|
@@ -4343,7 +4124,7 @@ function GenerateImageButton({ generation }) {
|
|
|
4343
4124
|
className: "native-docx-form native-docx-generate-image",
|
|
4344
4125
|
onSubmit: (event) => {
|
|
4345
4126
|
event.preventDefault();
|
|
4346
|
-
void
|
|
4127
|
+
void run();
|
|
4347
4128
|
},
|
|
4348
4129
|
children: [
|
|
4349
4130
|
/* @__PURE__ */ jsxRuntime.jsxs("label", { children: [
|
|
@@ -4359,7 +4140,7 @@ function GenerateImageButton({ generation }) {
|
|
|
4359
4140
|
"data-testid": "docx-generate-image-prompt",
|
|
4360
4141
|
onChange: (event) => setPrompt(event.target.value),
|
|
4361
4142
|
onKeyDown: (event) => {
|
|
4362
|
-
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void
|
|
4143
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) void run();
|
|
4363
4144
|
}
|
|
4364
4145
|
}
|
|
4365
4146
|
)
|
|
@@ -5121,7 +4902,10 @@ function NativeDocxEditor({
|
|
|
5121
4902
|
notify: adapter.notify,
|
|
5122
4903
|
getAgentStatus: adapter.getAgentStatus,
|
|
5123
4904
|
requestAgent: adapter.requestAgent ? (request) => adapter.requestAgent(documentId, request) : void 0,
|
|
5124
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
4905
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(AgentUndoRoom.Provider, { value: ready.room?.ydoc ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(DocxEditorReview, { children: () => /* @__PURE__ */ jsxRuntime.jsxs(DocxEditorReview.Card, { children: [
|
|
4906
|
+
/* @__PURE__ */ jsxRuntime.jsx(DocxCommentActivity, {}),
|
|
4907
|
+
/* @__PURE__ */ jsxRuntime.jsx(AgentUndo, {})
|
|
4908
|
+
] }) }) })
|
|
5125
4909
|
}
|
|
5126
4910
|
),
|
|
5127
4911
|
!compact && /* @__PURE__ */ jsxRuntime.jsx(react.DocxEditor.HeaderFooterChrome, {}),
|
|
@@ -5180,6 +4964,22 @@ function NativeDocxEditor({
|
|
|
5180
4964
|
);
|
|
5181
4965
|
}
|
|
5182
4966
|
|
|
4967
|
+
Object.defineProperty(exports, "findDefinitionsSection", {
|
|
4968
|
+
enumerable: true,
|
|
4969
|
+
get: function () { return commands.findDefinitionsSection; }
|
|
4970
|
+
});
|
|
4971
|
+
Object.defineProperty(exports, "insertCrossReference", {
|
|
4972
|
+
enumerable: true,
|
|
4973
|
+
get: function () { return commands.insertCrossReference; }
|
|
4974
|
+
});
|
|
4975
|
+
Object.defineProperty(exports, "insertDefinedTerm", {
|
|
4976
|
+
enumerable: true,
|
|
4977
|
+
get: function () { return commands.insertDefinedTerm; }
|
|
4978
|
+
});
|
|
4979
|
+
Object.defineProperty(exports, "insertDocumentReference", {
|
|
4980
|
+
enumerable: true,
|
|
4981
|
+
get: function () { return commands.insertDocumentReference; }
|
|
4982
|
+
});
|
|
5183
4983
|
Object.defineProperty(exports, "listTargets", {
|
|
5184
4984
|
enumerable: true,
|
|
5185
4985
|
get: function () { return commands.listTargets; }
|
|
@@ -5208,10 +5008,6 @@ exports.NativeDocxEditor = NativeDocxEditor;
|
|
|
5208
5008
|
exports.builtinHouseTemplate = builtinHouseTemplate;
|
|
5209
5009
|
exports.contentPath = contentPath;
|
|
5210
5010
|
exports.editorPort = editorPort;
|
|
5211
|
-
exports.findDefinitionsSection = findDefinitionsSection;
|
|
5212
|
-
exports.insertCrossReference = insertCrossReference;
|
|
5213
|
-
exports.insertDefinedTerm = insertDefinedTerm;
|
|
5214
|
-
exports.insertDocumentReference = insertDocumentReference;
|
|
5215
5011
|
exports.normalizeDocxExport = normalizeDocxExport;
|
|
5216
5012
|
exports.referenceText = referenceText;
|
|
5217
5013
|
exports.referencesPort = referencesPort;
|
|
@@ -5228,5 +5024,5 @@ exports.useReview = useReview;
|
|
|
5228
5024
|
exports.useReviewItem = useReviewItem;
|
|
5229
5025
|
exports.useTrackedOrNoted = useTrackedOrNoted;
|
|
5230
5026
|
exports.withDirectEditing = withDirectEditing;
|
|
5231
|
-
//# sourceMappingURL=chunk-
|
|
5232
|
-
//# sourceMappingURL=chunk-
|
|
5027
|
+
//# sourceMappingURL=chunk-ETBB5KMN.cjs.map
|
|
5028
|
+
//# sourceMappingURL=chunk-ETBB5KMN.cjs.map
|