@arbidocs/blocks 0.4.111 → 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-AQKRZBIU.cjs → NativeDocxEditor-AQZSUGET.cjs} +8 -8
- package/dist/{NativeDocxEditor-AQKRZBIU.cjs.map → NativeDocxEditor-AQZSUGET.cjs.map} +1 -1
- package/dist/{NativeDocxEditor-IN2HEO5I.js → NativeDocxEditor-MBCBXYDZ.js} +4 -4
- package/dist/{NativeDocxEditor-IN2HEO5I.js.map → NativeDocxEditor-MBCBXYDZ.js.map} +1 -1
- package/dist/agents/index.cjs +208 -208
- package/dist/agents/index.js +3 -3
- package/dist/{chunk-2C7TCVQZ.js → chunk-3OT37I24.js} +30 -297
- package/dist/chunk-3OT37I24.js.map +1 -0
- package/dist/{chunk-XIGWUDOD.cjs → chunk-ETBB5KMN.cjs} +61 -316
- package/dist/chunk-ETBB5KMN.cjs.map +1 -0
- package/dist/{chunk-Q6B77ZWZ.js → chunk-GIBRZ54P.js} +3 -3
- package/dist/{chunk-Q6B77ZWZ.js.map → chunk-GIBRZ54P.js.map} +1 -1
- package/dist/{chunk-2WO5L7YT.cjs → chunk-HF4PAYBM.cjs} +5 -5
- package/dist/{chunk-2WO5L7YT.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-QXMR5YHC.js +80 -0
- package/dist/chunk-QXMR5YHC.js.map +1 -0
- package/dist/{chunk-TF47ATYS.cjs → chunk-RUFNJRLW.cjs} +4 -4
- package/dist/{chunk-TF47ATYS.cjs.map → chunk-RUFNJRLW.cjs.map} +1 -1
- package/dist/{chunk-WTM65ZNG.js → chunk-TKJSCHSX.js} +3 -3
- package/dist/{chunk-WTM65ZNG.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-FXUQZFAN.cjs → chunk-Z2NSU7D5.cjs} +4 -4
- package/dist/{chunk-FXUQZFAN.cjs.map → chunk-Z2NSU7D5.cjs.map} +1 -1
- package/dist/{chunk-6Z7DLJU2.js → chunk-ZP4IFW2E.js} +4 -4
- package/dist/{chunk-6Z7DLJU2.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 +16 -16
- package/dist/connect/index.js +9 -9
- 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 +388 -388
- package/dist/index.js +10 -10
- package/dist/settings/index.cjs +1 -1
- package/dist/settings/index.js +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 +687 -0
- package/node_modules/@arbidocs/coedit/dist/commands.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/commands.d.cts +263 -157
- package/node_modules/@arbidocs/coedit/dist/commands.d.ts +263 -157
- package/node_modules/@arbidocs/coedit/dist/commands.js +646 -2
- 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 +675 -65
- package/node_modules/@arbidocs/coedit/dist/server.cjs.map +1 -1
- package/node_modules/@arbidocs/coedit/dist/server.d.cts +15 -4
- package/node_modules/@arbidocs/coedit/dist/server.d.ts +15 -4
- package/node_modules/@arbidocs/coedit/dist/server.js +676 -67
- 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-2C7TCVQZ.js.map +0 -1
- package/dist/chunk-EPHGD4YV.js +0 -174
- package/dist/chunk-EPHGD4YV.js.map +0 -1
- package/dist/chunk-XIGWUDOD.cjs.map +0 -1
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { R as Revision, t as trackInsertion } from './track-eYC94jTp.cjs';
|
|
2
|
+
|
|
1
3
|
interface ApplyTemplateOptions {
|
|
2
4
|
/** Record the template in settings.xml (`w:attachedTemplate`), e.g. "House template.dotx". */
|
|
3
5
|
attachedTemplate?: string;
|
|
@@ -50,22 +52,6 @@ declare function buildingBlockFragment(template: Uint8Array, name: string): Uint
|
|
|
50
52
|
/** A fragment's body as clipboard HTML the editor's paste recognises as its own. */
|
|
51
53
|
declare function fragmentClipboardHtml(fragment: Uint8Array, covered?: boolean): string;
|
|
52
54
|
|
|
53
|
-
/** Who made a tracked change and when (`w:author`, `w:date`). */
|
|
54
|
-
interface Revision {
|
|
55
|
-
author: string;
|
|
56
|
-
/** ISO 8601, seconds precision, e.g. `2026-10-19T09:30:00Z`. */
|
|
57
|
-
date: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The fragment with every run wrapped in `w:ins` and every new paragraph mark marked inserted. A
|
|
61
|
-
* table row is marked inserted as a whole, its cells left as they are: the editor rejects an
|
|
62
|
-
* inserted row whose content is tracked as well only partly. A run is not descended into, so a
|
|
63
|
-
* text box goes in with its run. `covered`: the fragment's last paragraph mark is pasted too (a
|
|
64
|
-
* block before the caret's paragraph); otherwise the last paragraph runs into the text after the
|
|
65
|
-
* caret and its mark is not new.
|
|
66
|
-
*/
|
|
67
|
-
declare function trackInsertion(fragment: Uint8Array, revision: Revision, covered: boolean): Uint8Array;
|
|
68
|
-
|
|
69
55
|
interface StyleDifference {
|
|
70
56
|
styleId: string;
|
|
71
57
|
name: string;
|
|
@@ -122,4 +108,4 @@ declare class TemplateError extends Error {
|
|
|
122
108
|
constructor(message: string);
|
|
123
109
|
}
|
|
124
110
|
|
|
125
|
-
export { type ApplyTemplateOptions, type ApplyTemplateReport, type BuildingBlockInfo, LEGAL_BUILDING_BLOCKS, LEGAL_NUM, type LegalTemplateOptions, type LinkedLevel, type
|
|
111
|
+
export { type ApplyTemplateOptions, type ApplyTemplateReport, type BuildingBlockInfo, LEGAL_BUILDING_BLOCKS, LEGAL_NUM, type LegalTemplateOptions, type LinkedLevel, type StyleDifference, type StyleDivergence, TemplateError, applyTemplate, attachedTemplateOf, buildingBlockFragment, composeWithTemplate, defaultLegalTemplate, fragmentClipboardHtml, linkedLevelStyles, listBuildingBlocks, newFromTemplate, styleDivergence };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export { R as Revision, t as trackInsertion } from './track-eYC94jTp.js';
|
|
2
|
+
|
|
1
3
|
interface ApplyTemplateOptions {
|
|
2
4
|
/** Record the template in settings.xml (`w:attachedTemplate`), e.g. "House template.dotx". */
|
|
3
5
|
attachedTemplate?: string;
|
|
@@ -50,22 +52,6 @@ declare function buildingBlockFragment(template: Uint8Array, name: string): Uint
|
|
|
50
52
|
/** A fragment's body as clipboard HTML the editor's paste recognises as its own. */
|
|
51
53
|
declare function fragmentClipboardHtml(fragment: Uint8Array, covered?: boolean): string;
|
|
52
54
|
|
|
53
|
-
/** Who made a tracked change and when (`w:author`, `w:date`). */
|
|
54
|
-
interface Revision {
|
|
55
|
-
author: string;
|
|
56
|
-
/** ISO 8601, seconds precision, e.g. `2026-10-19T09:30:00Z`. */
|
|
57
|
-
date: string;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* The fragment with every run wrapped in `w:ins` and every new paragraph mark marked inserted. A
|
|
61
|
-
* table row is marked inserted as a whole, its cells left as they are: the editor rejects an
|
|
62
|
-
* inserted row whose content is tracked as well only partly. A run is not descended into, so a
|
|
63
|
-
* text box goes in with its run. `covered`: the fragment's last paragraph mark is pasted too (a
|
|
64
|
-
* block before the caret's paragraph); otherwise the last paragraph runs into the text after the
|
|
65
|
-
* caret and its mark is not new.
|
|
66
|
-
*/
|
|
67
|
-
declare function trackInsertion(fragment: Uint8Array, revision: Revision, covered: boolean): Uint8Array;
|
|
68
|
-
|
|
69
55
|
interface StyleDifference {
|
|
70
56
|
styleId: string;
|
|
71
57
|
name: string;
|
|
@@ -122,4 +108,4 @@ declare class TemplateError extends Error {
|
|
|
122
108
|
constructor(message: string);
|
|
123
109
|
}
|
|
124
110
|
|
|
125
|
-
export { type ApplyTemplateOptions, type ApplyTemplateReport, type BuildingBlockInfo, LEGAL_BUILDING_BLOCKS, LEGAL_NUM, type LegalTemplateOptions, type LinkedLevel, type
|
|
111
|
+
export { type ApplyTemplateOptions, type ApplyTemplateReport, type BuildingBlockInfo, LEGAL_BUILDING_BLOCKS, LEGAL_NUM, type LegalTemplateOptions, type LinkedLevel, type StyleDifference, type StyleDivergence, TemplateError, applyTemplate, attachedTemplateOf, buildingBlockFragment, composeWithTemplate, defaultLegalTemplate, fragmentClipboardHtml, linkedLevelStyles, listBuildingBlocks, newFromTemplate, styleDivergence };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Who made a tracked change and when (`w:author`, `w:date`). */
|
|
2
|
+
interface Revision {
|
|
3
|
+
author: string;
|
|
4
|
+
/** ISO 8601, seconds precision, e.g. `2026-10-19T09:30:00Z`. */
|
|
5
|
+
date: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The fragment with every run wrapped in `w:ins` and every new paragraph mark marked inserted. A
|
|
9
|
+
* table row is marked inserted as a whole, its cells left as they are: the editor rejects an
|
|
10
|
+
* inserted row whose content is tracked as well only partly. A run is not descended into, so a
|
|
11
|
+
* text box goes in with its run. `covered`: the fragment's last paragraph mark is pasted too (a
|
|
12
|
+
* block before the caret's paragraph); otherwise the last paragraph runs into the text after the
|
|
13
|
+
* caret and its mark is not new.
|
|
14
|
+
*/
|
|
15
|
+
declare function trackInsertion(fragment: Uint8Array, revision: Revision, covered: boolean): Uint8Array;
|
|
16
|
+
|
|
17
|
+
export { type Revision as R, trackInsertion as t };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Who made a tracked change and when (`w:author`, `w:date`). */
|
|
2
|
+
interface Revision {
|
|
3
|
+
author: string;
|
|
4
|
+
/** ISO 8601, seconds precision, e.g. `2026-10-19T09:30:00Z`. */
|
|
5
|
+
date: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The fragment with every run wrapped in `w:ins` and every new paragraph mark marked inserted. A
|
|
9
|
+
* table row is marked inserted as a whole, its cells left as they are: the editor rejects an
|
|
10
|
+
* inserted row whose content is tracked as well only partly. A run is not descended into, so a
|
|
11
|
+
* text box goes in with its run. `covered`: the fragment's last paragraph mark is pasted too (a
|
|
12
|
+
* block before the caret's paragraph); otherwise the last paragraph runs into the text after the
|
|
13
|
+
* caret and its mark is not new.
|
|
14
|
+
*/
|
|
15
|
+
declare function trackInsertion(fragment: Uint8Array, revision: Revision, covered: boolean): Uint8Array;
|
|
16
|
+
|
|
17
|
+
export { type Revision as R, trackInsertion as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/coedit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.112",
|
|
4
4
|
"description": "Real-time collaboration for the ARBI native DOCX editor: a Yjs mirror of the canonical OOXML package, session, and server runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arbidocs/blocks",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.112",
|
|
4
4
|
"description": "Composable, domain-neutral UI blocks for ARBI apps, organised by capability (retrieval, facts, agents, workspaces, citations, collaboration) plus shell, theme and site primitives, on top of @arbidocs/react.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -280,8 +280,8 @@
|
|
|
280
280
|
"example:test:e2e": "playwright test -c examples/custom-ui/playwright.config.ts"
|
|
281
281
|
},
|
|
282
282
|
"dependencies": {
|
|
283
|
-
"@arbidocs/client": "0.4.
|
|
284
|
-
"@arbidocs/coedit": "0.4.
|
|
283
|
+
"@arbidocs/client": "0.4.112",
|
|
284
|
+
"@arbidocs/coedit": "0.4.112",
|
|
285
285
|
"@dnd-kit/core": "^6.3.1",
|
|
286
286
|
"@dnd-kit/sortable": "^10.0.0",
|
|
287
287
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -323,7 +323,7 @@
|
|
|
323
323
|
"y-protocols": "^1.0.6"
|
|
324
324
|
},
|
|
325
325
|
"peerDependencies": {
|
|
326
|
-
"@arbidocs/react": "0.4.
|
|
326
|
+
"@arbidocs/react": "0.4.112",
|
|
327
327
|
"@lexical/html": "0.35.0",
|
|
328
328
|
"@lexical/link": "0.35.0",
|
|
329
329
|
"@lexical/list": "0.35.0",
|
package/dist/chunk-2A4MDHJR.cjs
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var chunkRC25WMVB_cjs = require('./chunk-RC25WMVB.cjs');
|
|
5
|
-
var fflate = require('fflate');
|
|
6
|
-
|
|
7
|
-
// src/tags/definitions.ts
|
|
8
|
-
var DEFINITIONS_LABEL = "Definitions";
|
|
9
|
-
var QUOTES = `"\u201C\u201D\u201E\u201F'\u2018\u2019\u201A\u201B\xAB\xBB`;
|
|
10
|
-
var OPEN_CLOSE = {
|
|
11
|
-
'"': '"',
|
|
12
|
-
"\u201C": "\u201D",
|
|
13
|
-
"\u201E": "\u201C",
|
|
14
|
-
"\u201F": "\u201D",
|
|
15
|
-
"'": "'",
|
|
16
|
-
"\u2018": "\u2019",
|
|
17
|
-
"\u201A": "\u2018",
|
|
18
|
-
"\u201B": "\u2019",
|
|
19
|
-
"\xAB": "\xBB"
|
|
20
|
-
};
|
|
21
|
-
var EMPHASIS = /^(\*\*|__|\*|_)/;
|
|
22
|
-
var CONNECTORS = /^(?:shall\s+(?:have\s+the\s+meaning|mean|include)s?|ha(?:s|ve)\s+the\s+meanings?|means?\s+and\s+includes?|means|mean|includes|include|[:—–]|\s-\s|-\s)/i;
|
|
23
|
-
var MAX_TERM_LENGTH = 80;
|
|
24
|
-
var MAX_TERM_WORDS = 10;
|
|
25
|
-
function plain(text) {
|
|
26
|
-
return chunkRC25WMVB_cjs.decodeWhitespaceEntities(text).replace(/\\([\\`*_{}[\]()#+\-.!"'])/g, "$1").replace(/(\*\*|__)(.+?)\1/g, "$2").replace(/\s+/g, " ").trim();
|
|
27
|
-
}
|
|
28
|
-
function termKey(term) {
|
|
29
|
-
return plain(term).replace(new RegExp(`[${QUOTES}*_]`, "g"), "").replace(/\s+/g, " ").trim().toLowerCase();
|
|
30
|
-
}
|
|
31
|
-
var validTerm = (term) => term.length > 0 && term.length <= MAX_TERM_LENGTH && term.split(/\s+/).length <= MAX_TERM_WORDS && /\p{L}/u.test(term);
|
|
32
|
-
function connectorAt(rest) {
|
|
33
|
-
const lead = rest.length - rest.trimStart().length;
|
|
34
|
-
const spaced = /^\s-\s/.exec(rest);
|
|
35
|
-
if (spaced) return spaced[0].length;
|
|
36
|
-
const match = CONNECTORS.exec(rest.slice(lead));
|
|
37
|
-
return match ? lead + match[0].length : 0;
|
|
38
|
-
}
|
|
39
|
-
function parseDefinition(text) {
|
|
40
|
-
let s = plain(text);
|
|
41
|
-
for (let i = 0; i < 3; i++) s = s.replace(EMPHASIS, "").trimStart();
|
|
42
|
-
let term;
|
|
43
|
-
let rest;
|
|
44
|
-
const open = s[0];
|
|
45
|
-
const close = open ? OPEN_CLOSE[open] : void 0;
|
|
46
|
-
if (close) {
|
|
47
|
-
const end = s.indexOf(close, 1);
|
|
48
|
-
if (end < 0) return null;
|
|
49
|
-
term = s.slice(1, end);
|
|
50
|
-
rest = s.slice(end + 1);
|
|
51
|
-
rest = rest.replace(new RegExp(`^(?:\\*\\*|__|\\*|_|[${QUOTES}])+`), "");
|
|
52
|
-
} else {
|
|
53
|
-
const match = /^(.+?)(\s+(?:shall\s+(?:have\s+the\s+meaning|mean|include)s?|ha(?:s|ve)\s+the\s+meanings?|means?\s+and\s+includes?|means|includes)\b|\s*[:—–]|\s+-\s)/i.exec(
|
|
54
|
-
s
|
|
55
|
-
);
|
|
56
|
-
if (!match) return null;
|
|
57
|
-
term = match[1];
|
|
58
|
-
rest = s.slice(match[1].length);
|
|
59
|
-
}
|
|
60
|
-
term = term.replace(/(\*\*|__|\*|_)/g, "").trim();
|
|
61
|
-
const joint = connectorAt(rest);
|
|
62
|
-
if (!joint || !validTerm(term)) return null;
|
|
63
|
-
const meaning = rest.slice(joint).trim();
|
|
64
|
-
if (!meaning) return null;
|
|
65
|
-
return { term, rest: rest.replace(/^\s+/, " ").replace(/^ (?=[:—–])/, ""), meaning };
|
|
66
|
-
}
|
|
67
|
-
function toDefinition(source) {
|
|
68
|
-
const parsed = parseDefinition(source.text);
|
|
69
|
-
return parsed ? { ...source, ...parsed, key: termKey(parsed.term) } : null;
|
|
70
|
-
}
|
|
71
|
-
var time = (iso) => iso ? Date.parse(iso) || 0 : 0;
|
|
72
|
-
function compareDefinitions(a, b) {
|
|
73
|
-
return Number(!!b.confirmed) - Number(!!a.confirmed) || time(b.updatedAt) - time(a.updatedAt) || a.id.localeCompare(b.id);
|
|
74
|
-
}
|
|
75
|
-
var compareTerms = (a, b) => a.localeCompare(b, void 0, { sensitivity: "base", numeric: true });
|
|
76
|
-
function groupDefinitions(sources, options = {}) {
|
|
77
|
-
const byKey = /* @__PURE__ */ new Map();
|
|
78
|
-
const unparsed = [];
|
|
79
|
-
for (const source of sources) {
|
|
80
|
-
if (options.labelId && !source.labels?.some((l) => l.id === options.labelId)) continue;
|
|
81
|
-
const definition = toDefinition(source);
|
|
82
|
-
if (!definition) {
|
|
83
|
-
unparsed.push(source);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
const list = byKey.get(definition.key) ?? [];
|
|
87
|
-
list.push(definition);
|
|
88
|
-
byKey.set(definition.key, list);
|
|
89
|
-
}
|
|
90
|
-
const groups = [...byKey.entries()].map(([key, list]) => {
|
|
91
|
-
const definitions = [...list].sort(compareDefinitions);
|
|
92
|
-
return { key, term: definitions[0].term, preferred: definitions[0], definitions };
|
|
93
|
-
});
|
|
94
|
-
groups.sort((a, b) => compareTerms(a.term, b.term));
|
|
95
|
-
return { groups, unparsed };
|
|
96
|
-
}
|
|
97
|
-
function definitionLabels(sources) {
|
|
98
|
-
const byId = /* @__PURE__ */ new Map();
|
|
99
|
-
for (const s of sources) for (const l of s.labels ?? []) byId.set(l.id, l);
|
|
100
|
-
return [...byId.values()].sort((a, b) => compareTerms(a.name, b.name));
|
|
101
|
-
}
|
|
102
|
-
function filterTermGroups(groups, query) {
|
|
103
|
-
const q = termKey(query);
|
|
104
|
-
if (!q) return [...groups];
|
|
105
|
-
const rank = (g) => g.key.startsWith(q) ? 0 : g.key.split(" ").some((w) => w.startsWith(q)) ? 1 : 2;
|
|
106
|
-
return groups.filter((g) => g.key.includes(q)).map((g) => ({ g, r: rank(g) })).sort((a, b) => a.r - b.r || compareTerms(a.g.term, b.g.term)).map(({ g }) => g);
|
|
107
|
-
}
|
|
108
|
-
var DEFINITION_BOOKMARK_PREFIX = "_dt_";
|
|
109
|
-
var MAX_BOOKMARK_LENGTH = 40;
|
|
110
|
-
function definitionBookmark(factId) {
|
|
111
|
-
return (DEFINITION_BOOKMARK_PREFIX + factId.replace(/[^A-Za-z0-9_]/g, "_")).slice(
|
|
112
|
-
0,
|
|
113
|
-
MAX_BOOKMARK_LENGTH
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
function definitionIdOfBookmark(name) {
|
|
117
|
-
const match = /^_dt_([a-z]{3})_([A-Za-z0-9]+)$/.exec(name);
|
|
118
|
-
return match ? `${match[1]}-${match[2]}` : null;
|
|
119
|
-
}
|
|
120
|
-
var DOCX_MIME_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
121
|
-
var W_NAMESPACES = 'xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"';
|
|
122
|
-
var INVALID_XML = /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g;
|
|
123
|
-
var esc = (text) => text.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
124
|
-
var run = ({ text, bold, italic, muted }) => {
|
|
125
|
-
const props = [bold && "<w:b/>", italic && "<w:i/>", muted && '<w:color w:val="595959"/>'].filter(Boolean).join("");
|
|
126
|
-
const body = text.split(/\r?\n/).map((line) => `<w:t xml:space="preserve">${esc(line)}</w:t>`).join("<w:br/>");
|
|
127
|
-
return `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ""}${body}</w:r>`;
|
|
128
|
-
};
|
|
129
|
-
var paragraph = (runs, style) => `<w:p>${style ? `<w:pPr><w:pStyle w:val="${style}"/></w:pPr>` : ""}${runs.map(run).join("")}</w:p>`;
|
|
130
|
-
var cell = (paragraphs, width, fill) => `<w:tc><w:tcPr><w:tcW w:w="${width}" w:type="dxa"/>${fill ? `<w:shd w:val="clear" w:color="auto" w:fill="${fill}"/>` : ""}</w:tcPr>${paragraphs.length ? paragraphs.join("") : "<w:p/>"}</w:tc>`;
|
|
131
|
-
function page(landscape) {
|
|
132
|
-
const [short, long] = [11906, 16838];
|
|
133
|
-
const margin = landscape ? 1080 : 1440;
|
|
134
|
-
const width = landscape ? long : short;
|
|
135
|
-
return {
|
|
136
|
-
margin,
|
|
137
|
-
textWidth: width - 2 * margin,
|
|
138
|
-
sectPr: `<w:sectPr><w:pgSz w:w="${landscape ? long : short}" w:h="${landscape ? short : long}"${landscape ? ' w:orient="landscape"' : ""}/><w:pgMar w:top="${margin}" w:right="${margin}" w:bottom="${margin}" w:left="${margin}" w:header="708" w:footer="708" w:gutter="0"/></w:sectPr>`
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
var minuteUtc = (at) => new Date(at).toISOString().slice(0, 16).replace("T", " ");
|
|
142
|
-
var documentXml = (body) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
143
|
-
<w:document ${W_NAMESPACES}><w:body>${body}</w:body></w:document>`;
|
|
144
|
-
var stylesXml = (defaults, styles) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
145
|
-
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">${defaults}${styles}</w:styles>`;
|
|
146
|
-
var DOC_DEFAULTS = `<w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Calibri" w:hAnsi="Calibri" w:eastAsia="Calibri" w:cs="Calibri"/><w:sz w:val="22"/><w:szCs w:val="22"/><w:lang w:val="en-GB"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after="160" w:line="259" w:lineRule="auto"/></w:pPr></w:pPrDefault></w:docDefaults>`;
|
|
147
|
-
var TABLE_DOCUMENT_STYLES = stylesXml(
|
|
148
|
-
DOC_DEFAULTS,
|
|
149
|
-
`<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="Title"><w:name w:val="Title"/><w:basedOn w:val="Normal"/><w:next w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:after="80" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="48"/><w:szCs w:val="48"/></w:rPr></w:style><w:style w:type="paragraph" w:customStyle="1" w:styleId="TagTableCell"><w:name w:val="Tag Table Cell"/><w:basedOn w:val="Normal"/><w:qFormat/><w:pPr><w:spacing w:after="40" w:line="240" w:lineRule="auto"/></w:pPr><w:rPr><w:sz w:val="18"/><w:szCs w:val="18"/></w:rPr></w:style><w:style w:type="table" w:default="1" w:styleId="TableNormal"><w:name w:val="Normal Table"/><w:tblPr><w:tblInd w:w="0" w:type="dxa"/><w:tblCellMar><w:top w:w="0" w:type="dxa"/><w:left w:w="108" w:type="dxa"/><w:bottom w:w="0" w:type="dxa"/><w:right w:w="108" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style><w:style w:type="table" w:customStyle="1" w:styleId="TagTableGrid"><w:name w:val="Tag Table"/><w:basedOn w:val="TableNormal"/><w:tblPr><w:tblBorders><w:top w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/><w:left w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/><w:bottom w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/><w:right w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/><w:insideH w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/><w:insideV w:val="single" w:sz="4" w:space="0" w:color="BFBFBF"/></w:tblBorders><w:tblCellMar><w:top w:w="60" w:type="dxa"/><w:left w:w="100" w:type="dxa"/><w:bottom w:w="60" w:type="dxa"/><w:right w:w="100" w:type="dxa"/></w:tblCellMar></w:tblPr></w:style>`
|
|
150
|
-
);
|
|
151
|
-
var CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
152
|
-
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/></Types>`;
|
|
153
|
-
var ROOT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
154
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/></Relationships>`;
|
|
155
|
-
var documentRels = (more = "") => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
156
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>${more}</Relationships>`;
|
|
157
|
-
var hyperlinkRelationship = (id, url) => `<Relationship Id="${esc(id)}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink" Target="${esc(url)}" TargetMode="External"/>`;
|
|
158
|
-
var coreXml = (title, at) => `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
159
|
-
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dc:title>${esc(
|
|
160
|
-
title
|
|
161
|
-
)}</dc:title><dcterms:created xsi:type="dcterms:W3CDTF">${at}</dcterms:created><dcterms:modified xsi:type="dcterms:W3CDTF">${at}</dcterms:modified></cp:coreProperties>`;
|
|
162
|
-
function docxPackage(parts) {
|
|
163
|
-
const at = new Date(parts.at ?? Date.now()).toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
164
|
-
return fflate.zipSync({
|
|
165
|
-
"[Content_Types].xml": fflate.strToU8(CONTENT_TYPES),
|
|
166
|
-
"_rels/.rels": fflate.strToU8(ROOT_RELS),
|
|
167
|
-
"docProps/core.xml": fflate.strToU8(coreXml(parts.title, at)),
|
|
168
|
-
"word/document.xml": fflate.strToU8(parts.document),
|
|
169
|
-
"word/styles.xml": fflate.strToU8(parts.styles),
|
|
170
|
-
"word/_rels/document.xml.rels": fflate.strToU8(documentRels(parts.relationships))
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
exports.DEFINITIONS_LABEL = DEFINITIONS_LABEL;
|
|
175
|
-
exports.DEFINITION_BOOKMARK_PREFIX = DEFINITION_BOOKMARK_PREFIX;
|
|
176
|
-
exports.DOCX_MIME_TYPE = DOCX_MIME_TYPE;
|
|
177
|
-
exports.TABLE_DOCUMENT_STYLES = TABLE_DOCUMENT_STYLES;
|
|
178
|
-
exports.cell = cell;
|
|
179
|
-
exports.compareDefinitions = compareDefinitions;
|
|
180
|
-
exports.compareTerms = compareTerms;
|
|
181
|
-
exports.definitionBookmark = definitionBookmark;
|
|
182
|
-
exports.definitionIdOfBookmark = definitionIdOfBookmark;
|
|
183
|
-
exports.definitionLabels = definitionLabels;
|
|
184
|
-
exports.documentXml = documentXml;
|
|
185
|
-
exports.docxPackage = docxPackage;
|
|
186
|
-
exports.esc = esc;
|
|
187
|
-
exports.filterTermGroups = filterTermGroups;
|
|
188
|
-
exports.groupDefinitions = groupDefinitions;
|
|
189
|
-
exports.hyperlinkRelationship = hyperlinkRelationship;
|
|
190
|
-
exports.minuteUtc = minuteUtc;
|
|
191
|
-
exports.page = page;
|
|
192
|
-
exports.paragraph = paragraph;
|
|
193
|
-
exports.parseDefinition = parseDefinition;
|
|
194
|
-
exports.stylesXml = stylesXml;
|
|
195
|
-
exports.termKey = termKey;
|
|
196
|
-
exports.toDefinition = toDefinition;
|
|
197
|
-
//# sourceMappingURL=chunk-2A4MDHJR.cjs.map
|
|
198
|
-
//# sourceMappingURL=chunk-2A4MDHJR.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tags/definitions.ts","../src/tags/ooxml.ts"],"names":["decodeWhitespaceEntities","zipSync","strToU8"],"mappings":";;;;;;AAWO,IAAM,iBAAA,GAAoB;AAkDjC,IAAM,MAAA,GAAS,CAAA,0DAAA,CAAA;AACf,IAAM,UAAA,GAAqC;AAAA,EACzC,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,GAAA,EAAK,GAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,QAAA,EAAK,QAAA;AAAA,EACL,MAAA,EAAK;AACP,CAAA;AACA,IAAM,QAAA,GAAW,iBAAA;AAEjB,IAAM,UAAA,GACJ,yJAAA;AACF,IAAM,eAAA,GAAkB,EAAA;AACxB,IAAM,cAAA,GAAiB,EAAA;AAGvB,SAAS,MAAM,IAAA,EAAsB;AACnC,EAAA,OAAOA,0CAAA,CAAyB,IAAI,CAAA,CACjC,OAAA,CAAQ,+BAA+B,IAAI,CAAA,CAC3C,OAAA,CAAQ,mBAAA,EAAqB,IAAI,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,aAAa,CAAC;AAAA,GAC1E,CAAA;AACH","file":"chunk-2A4MDHJR.cjs","sourcesContent":["/**\n * Defined terms. A definition is an ordinary fact carrying the workspace's \"Definitions\" label; its\n * TERM is read from the start of its text — `\"Shares\" means …`, `**Business Day** shall mean …`,\n * `Completion: the date …` — and facts defining the same term (one per agreement, say) are grouped,\n * a confirmed one preferred over the rest, then the most recent. Pure helpers, no React: the Word\n * editor inserts terms with them and the Tags page prints the glossary with them.\n */\n\nimport { decodeWhitespaceEntities } from '../facts/fact-text'\n\n/** The label that marks a fact as a definition. */\nexport const DEFINITIONS_LABEL = 'Definitions'\n\n/** A label on a definition other than {@link DEFINITIONS_LABEL} (e.g. the agreement it is from). */\nexport interface DefinitionLabel {\n id: string\n name: string\n}\n\n/** A definition fact, as the host reads it. */\nexport interface DefinitionSource {\n /** The fact's id (`fct-…`). */\n id: string\n /** The fact text, as written (it may be Markdown). */\n text: string\n /** A human vouched for it: preferred over unconfirmed definitions of the same term. */\n confirmed?: boolean\n /** ISO time it was last written; the most recent wins between equals. */\n updatedAt?: string\n /** Where it comes from: the cited document's name. */\n source?: string\n /** Its other labels, e.g. the agreement (\"SPA\") it defines a term of. */\n labels?: DefinitionLabel[]\n}\n\n/** A definition's text split into its term and the rest. */\nexport interface ParsedDefinition {\n /** The term as written, without quotes or emphasis (`Business Day`). */\n term: string\n /** What follows the term, its connecting word included (`means a day …`, `: the date …`). */\n rest: string\n /** Just the meaning, the connecting word dropped (`a day …`). */\n meaning: string\n}\n\n/** A parsed definition fact. */\nexport interface Definition extends DefinitionSource, ParsedDefinition {\n /** The term's matching key (case and whitespace folded). */\n key: string\n}\n\n/** Every definition of one term, the preferred one first. */\nexport interface DefinedTermGroup {\n key: string\n /** The term as the preferred definition writes it. */\n term: string\n /** The preferred definition (first of {@link DefinedTermGroup.definitions}). */\n preferred: Definition\n definitions: Definition[]\n}\n\nconst QUOTES = `\"“”„‟'‘’‚‛«»`\nconst OPEN_CLOSE: Record<string, string> = {\n '\"': '\"',\n '“': '”',\n '„': '“',\n '‟': '”',\n \"'\": \"'\",\n '‘': '’',\n '‚': '‘',\n '‛': '’',\n '«': '»',\n}\nconst EMPHASIS = /^(\\*\\*|__|\\*|_)/\n/** The words (or punctuation) joining a term to its meaning, longest first. */\nconst CONNECTORS =\n /^(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|mean|includes|include|[:—–]|\\s-\\s|-\\s)/i\nconst MAX_TERM_LENGTH = 80\nconst MAX_TERM_WORDS = 10\n\n/** Markdown emphasis and escapes dropped, entity-encoded whitespace decoded, whitespace collapsed. */\nfunction plain(text: string): string {\n return decodeWhitespaceEntities(text)\n .replace(/\\\\([\\\\`*_{}[\\]()#+\\-.!\"'])/g, '$1')\n .replace(/(\\*\\*|__)(.+?)\\1/g, '$2')\n .replace(/\\s+/g, ' ')\n .trim()\n}\n\n/** The matching key of a term: case and whitespace folded, quotes and emphasis dropped. */\nexport function termKey(term: string): string {\n return plain(term)\n .replace(new RegExp(`[${QUOTES}*_]`, 'g'), '')\n .replace(/\\s+/g, ' ')\n .trim()\n .toLowerCase()\n}\n\nconst validTerm = (term: string) =>\n term.length > 0 &&\n term.length <= MAX_TERM_LENGTH &&\n term.split(/\\s+/).length <= MAX_TERM_WORDS &&\n /\\p{L}/u.test(term)\n\n/** A connector at the start of `rest` (after optional whitespace): its length, or 0. */\nfunction connectorAt(rest: string): number {\n const lead = rest.length - rest.trimStart().length\n // A spaced hyphen needs its leading space, so try the raw text before the trimmed one.\n const spaced = /^\\s-\\s/.exec(rest)\n if (spaced) return spaced[0].length\n const match = CONNECTORS.exec(rest.slice(lead))\n return match ? lead + match[0].length : 0\n}\n\n/**\n * Read a definition's term from the start of its text, or `null` when it does not start with one.\n *\n * Optional straight or curly quotes and bold markers around the term are dropped; the term is what\n * comes before \"means\", \"shall mean\", \"includes\", \"has the meaning\", a colon, or a dash. A quoted\n * term is taken whole, so `\"Long-Stop Date\" means …` keeps its hyphen.\n */\nexport function parseDefinition(text: string): ParsedDefinition | null {\n let s = plain(text)\n // Leading emphasis markers (`**\"Shares\"** means`), any order with the opening quote.\n for (let i = 0; i < 3; i++) s = s.replace(EMPHASIS, '').trimStart()\n let term: string\n let rest: string\n const open = s[0]\n const close = open ? OPEN_CLOSE[open] : undefined\n if (close) {\n const end = s.indexOf(close, 1)\n if (end < 0) return null\n term = s.slice(1, end)\n rest = s.slice(end + 1)\n // Emphasis or a closing quote between the term and its connector (`\"Shares\"**`, `**\"X**\"`).\n rest = rest.replace(new RegExp(`^(?:\\\\*\\\\*|__|\\\\*|_|[${QUOTES}])+`), '')\n } else {\n // Unquoted: the term runs up to the first connector.\n const match =\n /^(.+?)(\\s+(?:shall\\s+(?:have\\s+the\\s+meaning|mean|include)s?|ha(?:s|ve)\\s+the\\s+meanings?|means?\\s+and\\s+includes?|means|includes)\\b|\\s*[:—–]|\\s+-\\s)/i.exec(\n s\n )\n if (!match) return null\n term = match[1]\n rest = s.slice(match[1].length)\n }\n term = term.replace(/(\\*\\*|__|\\*|_)/g, '').trim()\n const joint = connectorAt(rest)\n if (!joint || !validTerm(term)) return null\n const meaning = rest.slice(joint).trim()\n if (!meaning) return null\n return { term, rest: rest.replace(/^\\s+/, ' ').replace(/^ (?=[:—–])/, ''), meaning }\n}\n\n/** A definition parsed, or `null` when its text names no term. */\nexport function toDefinition(source: DefinitionSource): Definition | null {\n const parsed = parseDefinition(source.text)\n return parsed ? { ...source, ...parsed, key: termKey(parsed.term) } : null\n}\n\nconst time = (iso?: string) => (iso ? Date.parse(iso) || 0 : 0)\n\n/** Preferred first: confirmed, then most recently written, then by id (stable). */\nexport function compareDefinitions(a: DefinitionSource, b: DefinitionSource): number {\n return (\n Number(!!b.confirmed) - Number(!!a.confirmed) ||\n time(b.updatedAt) - time(a.updatedAt) ||\n a.id.localeCompare(b.id)\n )\n}\n\n/** Alphabetical order of terms, as a reader sorts a glossary (case and accents folded). */\nexport const compareTerms = (a: string, b: string) =>\n a.localeCompare(b, undefined, { sensitivity: 'base', numeric: true })\n\n/**\n * Definitions grouped by term, alphabetically, each group's preferred definition first. Facts whose\n * text names no term are returned apart (`unparsed`), so a host can say how many it could not read.\n * With `labelId`, only definitions carrying that label (one agreement's, say) are kept.\n */\nexport function groupDefinitions(\n sources: readonly DefinitionSource[],\n options: { labelId?: string | null } = {}\n): { groups: DefinedTermGroup[]; unparsed: DefinitionSource[] } {\n const byKey = new Map<string, Definition[]>()\n const unparsed: DefinitionSource[] = []\n for (const source of sources) {\n if (options.labelId && !source.labels?.some((l) => l.id === options.labelId)) continue\n const definition = toDefinition(source)\n if (!definition) {\n unparsed.push(source)\n continue\n }\n const list = byKey.get(definition.key) ?? []\n list.push(definition)\n byKey.set(definition.key, list)\n }\n const groups = [...byKey.entries()].map(([key, list]) => {\n const definitions = [...list].sort(compareDefinitions)\n return { key, term: definitions[0].term, preferred: definitions[0], definitions }\n })\n groups.sort((a, b) => compareTerms(a.term, b.term))\n return { groups, unparsed }\n}\n\n/** The labels (agreements) definitions carry besides the Definitions label, by name. */\nexport function definitionLabels(sources: readonly DefinitionSource[]): DefinitionLabel[] {\n const byId = new Map<string, DefinitionLabel>()\n for (const s of sources) for (const l of s.labels ?? []) byId.set(l.id, l)\n return [...byId.values()].sort((a, b) => compareTerms(a.name, b.name))\n}\n\n/** Groups whose term matches a typed query: prefix matches first, then any word, then anywhere. */\nexport function filterTermGroups(\n groups: readonly DefinedTermGroup[],\n query: string\n): DefinedTermGroup[] {\n const q = termKey(query)\n if (!q) return [...groups]\n const rank = (g: DefinedTermGroup) =>\n g.key.startsWith(q) ? 0 : g.key.split(' ').some((w) => w.startsWith(q)) ? 1 : 2\n return groups\n .filter((g) => g.key.includes(q))\n .map((g) => ({ g, r: rank(g) }))\n .sort((a, b) => a.r - b.r || compareTerms(a.g.term, b.g.term))\n .map(({ g }) => g)\n}\n\n/** Prefix of every bookmark a defined term links to: hidden in Word (leading underscore). */\nexport const DEFINITION_BOOKMARK_PREFIX = '_dt_'\nconst MAX_BOOKMARK_LENGTH = 40\n\n/**\n * The Word bookmark of a definition: `_dt_` and the fact id in valid bookmark characters\n * (`fct-AbC12345` → `_dt_fct_AbC12345`), at most 40 characters as Word requires.\n */\nexport function definitionBookmark(factId: string): string {\n return (DEFINITION_BOOKMARK_PREFIX + factId.replace(/[^A-Za-z0-9_]/g, '_')).slice(\n 0,\n MAX_BOOKMARK_LENGTH\n )\n}\n\n/** The fact id a definition bookmark names, or `null` for any other bookmark. */\nexport function definitionIdOfBookmark(name: string): string | null {\n const match = /^_dt_([a-z]{3})_([A-Za-z0-9]+)$/.exec(name)\n return match ? `${match[1]}-${match[2]}` : null\n}\n","/**\n * The small WordprocessingML vocabulary the tags exports write: escaped runs, paragraphs, table\n * cells, an A4 page, and the minimal package around a `word/document.xml`. Zipped with `fflate`, so\n * the result opens in the native Word editor and in Word without pulling the editor engine in.\n */\n\nimport { strToU8, zipSync } from 'fflate'\n\nexport const DOCX_MIME_TYPE =\n 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'\n\nexport const W_NAMESPACES =\n 'xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"'\n\n// Text that is not allowed in XML 1.0 at all (control characters) is dropped, not escaped.\n// eslint-disable-next-line no-control-regex\nconst INVALID_XML = /[\\u0000-\\u0008\\u000B\\u000C\\u000E-\\u001F]/g\n\n/** Text as XML character data or an attribute value. */\nexport const esc = (text: string) =>\n text\n .replace(INVALID_XML, '')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\"/g, '"')\n\nexport interface Run {\n text: string\n bold?: boolean\n italic?: boolean\n muted?: boolean\n}\n\nexport const run = ({ text, bold, italic, muted }: Run) => {\n const props = [bold && '<w:b/>', italic && '<w:i/>', muted && '<w:color w:val=\"595959\"/>']\n .filter(Boolean)\n .join('')\n // Line breaks inside a value become Word line breaks rather than being lost.\n const body = text\n .split(/\\r?\\n/)\n .map((line) => `<w:t xml:space=\"preserve\">${esc(line)}</w:t>`)\n .join('<w:br/>')\n return `<w:r>${props ? `<w:rPr>${props}</w:rPr>` : ''}${body}</w:r>`\n}\n\nexport const paragraph = (runs: Run[], style?: string) =>\n `<w:p>${style ? `<w:pPr><w:pStyle w:val=\"${style}\"/></w:pPr>` : ''}${runs.map(run).join('')}</w:p>`\n\n/** A table cell: its paragraphs (a cell must hold at least one), shaded when given a fill. */\nexport const cell = (paragraphs: string[], width: number, fill?: string) =>\n `<w:tc><w:tcPr><w:tcW w:w=\"${width}\" w:type=\"dxa\"/>${\n fill ? `<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"${fill}\"/>` : ''\n }</w:tcPr>${paragraphs.length ? paragraphs.join('') : '<w:p/>'}</w:tc>`\n\n/** Page geometry in twips (A4), turned for landscape. */\nexport function page(landscape: boolean) {\n const [short, long] = [11906, 16838]\n const margin = landscape ? 1080 : 1440\n const width = landscape ? long : short\n return {\n margin,\n textWidth: width - 2 * margin,\n sectPr: `<w:sectPr><w:pgSz w:w=\"${landscape ? long : short}\" w:h=\"${landscape ? short : long}\"${\n landscape ? ' w:orient=\"landscape\"' : ''\n }/><w:pgMar w:top=\"${margin}\" w:right=\"${margin}\" w:bottom=\"${margin}\" w:left=\"${margin}\" w:header=\"708\" w:footer=\"708\" w:gutter=\"0\"/></w:sectPr>`,\n }\n}\n\n/** `YYYY-MM-DD HH:MM` (UTC) of an ISO time, for a \"taken at\" line. */\nexport const minuteUtc = (at: string) => new Date(at).toISOString().slice(0, 16).replace('T', ' ')\n\n/** A `word/document.xml` around body content (paragraphs, tables, then the section). */\nexport const documentXml = (body: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:document ${W_NAMESPACES}><w:body>${body}</w:body></w:document>`\n\n/** `word/styles.xml` holding the given style definitions. */\nexport const stylesXml = (defaults: string, styles: string) =>\n `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<w:styles xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\">${defaults}${styles}</w:styles>`\n\n/** Calibri 11pt (en-GB), 8pt after each paragraph: the document defaults the exports share. */\nexport const DOC_DEFAULTS = `<w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii=\"Calibri\" w:hAnsi=\"Calibri\" w:eastAsia=\"Calibri\" w:cs=\"Calibri\"/><w:sz w:val=\"22\"/><w:szCs w:val=\"22\"/><w:lang w:val=\"en-GB\"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr><w:spacing w:after=\"160\" w:line=\"259\" w:lineRule=\"auto\"/></w:pPr></w:pPrDefault></w:docDefaults>`\n\n/**\n * Styles of a document that is a title and a table: `Title`, the compact `TagTableCell` paragraph\n * and the bordered `TagTableGrid` table.\n */\nexport const TABLE_DOCUMENT_STYLES = stylesXml(\n DOC_DEFAULTS,\n `<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=\"Title\"><w:name w:val=\"Title\"/><w:basedOn w:val=\"Normal\"/><w:next w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"80\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"48\"/><w:szCs w:val=\"48\"/></w:rPr></w:style><w:style w:type=\"paragraph\" w:customStyle=\"1\" w:styleId=\"TagTableCell\"><w:name w:val=\"Tag Table Cell\"/><w:basedOn w:val=\"Normal\"/><w:qFormat/><w:pPr><w:spacing w:after=\"40\" w:line=\"240\" w:lineRule=\"auto\"/></w:pPr><w:rPr><w:sz w:val=\"18\"/><w:szCs w:val=\"18\"/></w:rPr></w:style><w:style w:type=\"table\" w:default=\"1\" w:styleId=\"TableNormal\"><w:name w:val=\"Normal Table\"/><w:tblPr><w:tblInd w:w=\"0\" w:type=\"dxa\"/><w:tblCellMar><w:top w:w=\"0\" w:type=\"dxa\"/><w:left w:w=\"108\" w:type=\"dxa\"/><w:bottom w:w=\"0\" w:type=\"dxa\"/><w:right w:w=\"108\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style><w:style w:type=\"table\" w:customStyle=\"1\" w:styleId=\"TagTableGrid\"><w:name w:val=\"Tag Table\"/><w:basedOn w:val=\"TableNormal\"/><w:tblPr><w:tblBorders><w:top w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:left w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:bottom w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:right w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideH w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/><w:insideV w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"BFBFBF\"/></w:tblBorders><w:tblCellMar><w:top w:w=\"60\" w:type=\"dxa\"/><w:left w:w=\"100\" w:type=\"dxa\"/><w:bottom w:w=\"60\" w:type=\"dxa\"/><w:right w:w=\"100\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr></w:style>`\n)\n\nconst CONTENT_TYPES = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Override PartName=\"/word/document.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml\"/><Override PartName=\"/word/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml\"/><Override PartName=\"/docProps/core.xml\" ContentType=\"application/vnd.openxmlformats-package.core-properties+xml\"/></Types>`\n\nconst ROOT_RELS = `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument\" Target=\"word/document.xml\"/><Relationship Id=\"rId2\" Type=\"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties\" Target=\"docProps/core.xml\"/></Relationships>`\n\n/** `word/_rels/document.xml.rels`: the styles part, then any further relationships given. */\nconst documentRels = (more = '') => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\"><Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>${more}</Relationships>`\n\n/** A relationship to an external hyperlink target, for `w:hyperlink r:id`. */\nexport const hyperlinkRelationship = (id: string, url: string) =>\n `<Relationship Id=\"${esc(id)}\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink\" Target=\"${esc(url)}\" TargetMode=\"External\"/>`\n\nconst coreXml = (\n title: string,\n at: string\n) => `<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<cp:coreProperties xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:dcterms=\"http://purl.org/dc/terms/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><dc:title>${esc(\n title\n)}</dc:title><dcterms:created xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:created><dcterms:modified xsi:type=\"dcterms:W3CDTF\">${at}</dcterms:modified></cp:coreProperties>`\n\n/** The minimal `.docx` package: a document, its styles, and its title and time. */\nexport function docxPackage(parts: {\n document: string\n styles: string\n title: string\n /** ISO time; default now. */\n at?: string\n /** Further `word/document.xml` relationships (e.g. {@link hyperlinkRelationship}). */\n relationships?: string\n}): Uint8Array {\n const at = new Date(parts.at ?? Date.now()).toISOString().replace(/\\.\\d{3}Z$/, 'Z')\n return zipSync({\n '[Content_Types].xml': strToU8(CONTENT_TYPES),\n '_rels/.rels': strToU8(ROOT_RELS),\n 'docProps/core.xml': strToU8(coreXml(parts.title, at)),\n 'word/document.xml': strToU8(parts.document),\n 'word/styles.xml': strToU8(parts.styles),\n 'word/_rels/document.xml.rels': strToU8(documentRels(parts.relationships)),\n })\n}\n"]}
|