@a3s-lab/office 0.28.0 → 0.30.0

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.
Files changed (69) hide show
  1. package/README.md +126 -3
  2. package/dist/0~1403.js +1 -1
  3. package/dist/0~4980.js +1 -1
  4. package/dist/0~7048.js +1 -1
  5. package/dist/{0~7043.js → 0~7231.js} +400 -242
  6. package/dist/{0~5093.js → 0~7360.js} +293 -53
  7. package/dist/0~7614.js +1 -1
  8. package/dist/0~document-editor.js +1535 -102
  9. package/dist/0~presentation-editor.js +1 -1
  10. package/dist/0~spreadsheet-editor.js +184 -36
  11. package/dist/0~work-docx-export.js +437 -11
  12. package/dist/0~work-docx-import.js +32 -7
  13. package/dist/0~work-office-diagnostics.js +170 -7
  14. package/dist/0~work-pptx-export.js +1 -1
  15. package/dist/0~work-pptx-import.js +1 -1
  16. package/dist/0~work-presentation-charts.js +1 -1
  17. package/dist/1544.js +14 -2
  18. package/dist/4104.js +31 -8
  19. package/dist/4121.js +3448 -0
  20. package/dist/6282.js +558 -1688
  21. package/dist/8715.js +1 -1
  22. package/dist/core.js +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/internal/features/work/editors/document-command-catalog.d.ts +27 -0
  25. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +8 -2
  26. package/dist/internal/features/work/editors/document-font-dialog-run-border-model.d.ts +24 -0
  27. package/dist/internal/features/work/editors/document-font-dialog-run-border-section.d.ts +10 -0
  28. package/dist/internal/features/work/editors/document-font-dialog-run-shading-model.d.ts +23 -0
  29. package/dist/internal/features/work/editors/document-font-dialog-run-shading-section.d.ts +8 -0
  30. package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
  31. package/dist/internal/features/work/editors/document-proofing-dialog-model.d.ts +22 -0
  32. package/dist/internal/features/work/editors/document-proofing-dialog.d.ts +7 -0
  33. package/dist/internal/features/work/editors/document-table-of-contents-dialog.d.ts +10 -0
  34. package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
  35. package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +7 -1
  36. package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +2 -0
  37. package/dist/internal/features/work/work-document-character-formatting.d.ts +12 -0
  38. package/dist/internal/features/work/work-document-format-changes.d.ts +7 -0
  39. package/dist/internal/features/work/work-document-highlight.d.ts +9 -0
  40. package/dist/internal/features/work/work-document-outline.d.ts +1 -0
  41. package/dist/internal/features/work/work-document-paragraph-shading.d.ts +6 -0
  42. package/dist/internal/features/work/work-document-proofing.d.ts +19 -0
  43. package/dist/internal/features/work/work-document-run-border.d.ts +11 -0
  44. package/dist/internal/features/work/work-document-run-shading.d.ts +12 -0
  45. package/dist/internal/features/work/work-document-table-of-contents-node.d.ts +18 -0
  46. package/dist/internal/features/work/work-document-table-of-contents.d.ts +51 -0
  47. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +4 -0
  48. package/dist/internal/features/work/work-docx-field-instructions.d.ts +1 -1
  49. package/dist/internal/features/work/work-docx-import.d.ts +3 -1
  50. package/dist/internal/features/work/work-docx-proofing-diagnostics.d.ts +3 -0
  51. package/dist/internal/features/work/work-docx-proofing.d.ts +38 -0
  52. package/dist/internal/features/work/work-docx-run-border-diagnostics.d.ts +3 -0
  53. package/dist/internal/features/work/work-docx-run-border-export.d.ts +17 -0
  54. package/dist/internal/features/work/work-docx-run-border.d.ts +20 -0
  55. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +9 -0
  56. package/dist/internal/features/work/work-docx-run-shading-diagnostics.d.ts +3 -0
  57. package/dist/internal/features/work/work-docx-run-shading-export.d.ts +17 -0
  58. package/dist/internal/features/work/work-docx-run-shading.d.ts +20 -0
  59. package/dist/internal/features/work/work-docx-table-of-contents-export.d.ts +11 -0
  60. package/dist/internal/features/work/work-docx-table-of-contents-import.d.ts +15 -0
  61. package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +7 -0
  62. package/dist/internal/features/work/work-types.d.ts +9 -0
  63. package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -0
  64. package/dist/office-kernel.wasm +0 -0
  65. package/dist/styles.css +339 -1
  66. package/docs/latest/en/browser-editor-architecture.md +72 -1
  67. package/package.json +15 -2
  68. package/dist/5184.js +0 -662
  69. package/dist/9424.js +0 -16
package/dist/6282.js CHANGED
@@ -9,7 +9,6 @@ import extension_text_align from "@tiptap/extension-text-align";
9
9
  import font_size from "@tiptap/extension-text-style/font-size";
10
10
  import starter_kit from "@tiptap/starter-kit";
11
11
  import { DOMParser as model_DOMParser, Fragment, Slice } from "@tiptap/pm/model";
12
- import jszip from "jszip";
13
12
  import { closeHistory, isHistoryTransaction } from "@tiptap/pm/history";
14
13
  import extension_underline from "@tiptap/extension-underline";
15
14
  import extension_strike from "@tiptap/extension-strike";
@@ -22,8 +21,7 @@ import { CellSelection, TableMap, isInTable, selectedRect } from "@tiptap/pm/tab
22
21
  import font_family from "@tiptap/extension-text-style/font-family";
23
22
  import { TextStyle } from "@tiptap/extension-text-style";
24
23
  import extension_highlight from "@tiptap/extension-highlight";
25
- import { createOfficeId as createWorkId, parseXml, xmlNamespacePrefix } from "./5184.js";
26
- import { normalizeCssColor } from "./9424.js";
24
+ import { documentRunBorderDomAttributes, DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE, DOCUMENT_RUN_SHADING_ATTRIBUTE, serializeDocumentRunBorder, documentScriptFontSlotFromElement, documentScriptFontsForAllText, serializeDocumentScriptFonts, primeDocumentIntegrityFeatures, uniqueDocumentParagraphIdentity, documentScriptFontsDomAttributes, documentHighlightForCssColor, documentTableOfContentsValueFromElement, normalizeDocumentScriptFonts, buildDocumentTableOfContentsEntries, serializeDocumentParagraphShading, documentHasIntegrityFeature, parseDocumentRunBorder, normalizeDocumentParagraphId, DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE, documentProofingLanguagesFromElement, normalizeDocumentProofingLanguages, parseDocumentParagraphBordersElement, parseDocumentParagraphBorders, documentScriptFontsFromElement, DOCUMENT_RUN_BORDER_ATTRIBUTE, normalizeDocumentTableOfContentsValue, DOCUMENT_PARAGRAPH_ID_ATTRIBUTE, documentNoProofFromElement, normalizeDocumentRunShading, documentScriptFontSegments, documentFontNameFromCssFamily, documentRunShadingDomAttributes, parseDocumentScriptFonts, normalizeDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentParagraphBorders, parseDocxThemeReference, parseDocumentRunShading, DOCUMENT_HIGHLIGHT_ATTRIBUTE, serializeDocumentRunShading, workDocumentOutlineLevel, DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE, createDocumentParagraphIdentityRegistry, DOCUMENT_NO_PROOF_ATTRIBUTE, serializeDocxThemeReference, documentRunBorderIsVisible, normalizeDocumentTableOfContentsHtml, cssDocumentFontFamily, documentParagraphShadingDomAttributes, DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE, documentParagraphBordersDomAttributes, DOCUMENT_SCRIPT_FONTS_ATTRIBUTE, normalizeDocumentHighlight, normalizeDocumentParagraphIdentity, createOfficeId as createWorkId, DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, documentHighlightFromElement, normalizeDocumentLanguageTag, parseDocumentParagraphShading, normalizeDocumentNoProof, parseDocumentParagraphShadingElement, createDocumentParagraphIdentity, documentHighlightDomAttributes, DocumentParagraphIdentity, parseDocumentRunShadingElement, parseDocumentProofingLanguages, collectWorkDocumentOutline, documentScriptFontSlotFromHint, normalizeDocumentTableOfContentsOptions, documentBorderPresentation, documentScriptFontFamilyForRendering, parseDocumentRunBorderElement, documentProofingDomAttributes, normalizeDocumentScriptFontSlot, serializeDocumentProofingLanguages } from "./4121.js";
27
25
  import { workOfficeCollaborationJsonEqual, canonicalWorkOfficeCollaborationJson, isWorkOfficeCollaborationRecord, cloneWorkOfficeCollaborationJson } from "./4650.js";
28
26
  import { assertWorkOfficeCollaborationEditable, markWorkOfficeCollaborationInitialized, assertWorkOfficeCollaborationOrigin, initializeWorkOfficeCollaborationMetadata, assertWorkOfficeCollaborationWritable, OfficeCollaborationError as WorkOfficeCollaborationError, readOfficeCollaborationMetadata as readWorkOfficeCollaborationMetadata, registerWorkOfficeCollaborationInitializer } from "./9787.js";
29
27
  import * as __rspack_external_yjs from "yjs";
@@ -197,71 +195,6 @@ function normalizedReferenceText(value) {
197
195
  function stringAttribute(value) {
198
196
  return 'string' == typeof value ? value.trim() : '';
199
197
  }
200
- const DOCUMENT_INTEGRITY_BOOKMARK = 1;
201
- const DOCUMENT_INTEGRITY_FIELD = 2;
202
- const DOCUMENT_INTEGRITY_IMAGE = 4;
203
- const DOCUMENT_INTEGRITY_NOTE = 8;
204
- const DOCUMENT_INTEGRITY_PARAGRAPH_IDENTITY = 16;
205
- const DOCUMENT_INTEGRITY_TABLE_ROW_IDENTITY = 32;
206
- const featureCache = new WeakMap();
207
- function documentHasIntegrityFeature(document1, feature) {
208
- return (documentIntegrityFeatures(document1, true) & feature) !== 0;
209
- }
210
- function primeDocumentIntegrityFeatures(document1) {
211
- document1.forEach(primeDocumentIntegrityNode);
212
- }
213
- function primeDocumentIntegrityNode(node) {
214
- if ('documentChunk' === node.type.name) {
215
- const features = nonNegativeInteger(node.attrs.integrityFeatures);
216
- if (null !== features) featureCache.set(node, features);
217
- if (true !== node.attrs.windowContainer) return;
218
- }
219
- node.forEach(primeDocumentIntegrityNode);
220
- }
221
- function documentIntegrityFeatures(node, cacheNode) {
222
- if (cacheNode) {
223
- const cached = featureCache.get(node);
224
- if (void 0 !== cached) return cached;
225
- }
226
- let features = nodeIntegrityFeatures(node);
227
- node.forEach((child)=>{
228
- features |= documentIntegrityFeatures(child, 'documentChunk' === child.type.name);
229
- });
230
- if (cacheNode) featureCache.set(node, features);
231
- return features;
232
- }
233
- function nodeIntegrityFeatures(node) {
234
- let features = 0;
235
- switch(node.type.name){
236
- case 'documentBookmarkBoundary':
237
- features |= DOCUMENT_INTEGRITY_BOOKMARK;
238
- break;
239
- case 'documentCrossReference':
240
- if ('bookmark' === node.attrs.targetType) features |= DOCUMENT_INTEGRITY_BOOKMARK;
241
- break;
242
- case 'documentField':
243
- features |= DOCUMENT_INTEGRITY_FIELD;
244
- break;
245
- case 'image':
246
- features |= DOCUMENT_INTEGRITY_IMAGE;
247
- break;
248
- case 'documentNote':
249
- case 'documentNoteReference':
250
- features |= DOCUMENT_INTEGRITY_NOTE;
251
- break;
252
- }
253
- if (node.isText && node.marks.some((mark)=>'link' === mark.type.name && 'string' == typeof mark.attrs.href && mark.attrs.href.startsWith('#'))) features |= DOCUMENT_INTEGRITY_BOOKMARK;
254
- if (identityComponent(node.attrs.paragraphId) || identityComponent(node.attrs.textId)) features |= DOCUMENT_INTEGRITY_PARAGRAPH_IDENTITY;
255
- if (identityComponent(node.attrs.rowId) || identityComponent(node.attrs.rowTextId)) features |= DOCUMENT_INTEGRITY_TABLE_ROW_IDENTITY;
256
- return features;
257
- }
258
- function identityComponent(value) {
259
- return 'string' == typeof value && value.trim().length > 0;
260
- }
261
- function nonNegativeInteger(value) {
262
- const number = Number(value);
263
- return Number.isSafeInteger(number) && number >= 0 ? number : null;
264
- }
265
198
  const BOOKMARK_NAME_PATTERN = /^[\p{L}_][\p{L}\p{N}_]*$/u;
266
199
  const BOOKMARK_UI_NAME_PATTERN = /^[\p{L}][\p{L}\p{N}_]*$/u;
267
200
  const MAX_BOOKMARK_NAME_LENGTH = 40;
@@ -1900,7 +1833,7 @@ function createSchemaValidatedWorkDocumentModel(html, root, options = {}) {
1900
1833
  schemaValidatedDocumentModels.set(model, {
1901
1834
  html,
1902
1835
  htmlFingerprint: model.htmlFingerprint,
1903
- initialIntegrityFeatures: work_document_model_nonNegativeInteger(options.initialIntegrityFeatures),
1836
+ initialIntegrityFeatures: nonNegativeInteger(options.initialIntegrityFeatures),
1904
1837
  root
1905
1838
  });
1906
1839
  return model;
@@ -1949,7 +1882,7 @@ function nextRevision(previous) {
1949
1882
  const revision = previous?.schema === DOCUMENT_MODEL_SCHEMA && previous.version === DOCUMENT_MODEL_VERSION && Number.isSafeInteger(previous.revision) && previous.revision > 0 ? previous.revision : 0;
1950
1883
  return revision >= Number.MAX_SAFE_INTEGER ? 1 : revision + 1;
1951
1884
  }
1952
- function work_document_model_nonNegativeInteger(value) {
1885
+ function nonNegativeInteger(value) {
1953
1886
  const number = Number(value);
1954
1887
  return Number.isSafeInteger(number) && number >= 0 ? number : null;
1955
1888
  }
@@ -2210,681 +2143,6 @@ function work_document_notes_positiveInteger(value, fallback) {
2210
2143
  const number = Number(value);
2211
2144
  return Number.isSafeInteger(number) && number > 0 ? number : fallback;
2212
2145
  }
2213
- const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
2214
- class DocxThemePatchCollector {
2215
- patches = [];
2216
- nextMarker = 1;
2217
- usedColors;
2218
- constructor(sourceHtml){
2219
- this.usedColors = sourceColors(sourceHtml);
2220
- }
2221
- marker(kind, reference, currentColor) {
2222
- if (!reference || normalizeColor(currentColor) !== reference.resolved) return null;
2223
- let marker = '';
2224
- do {
2225
- marker = (0xf00000 + this.nextMarker).toString(16).padStart(6, '0').toUpperCase();
2226
- this.nextMarker += 1;
2227
- }while (this.usedColors.has(marker))
2228
- this.usedColors.add(marker);
2229
- this.patches.push({
2230
- kind,
2231
- marker,
2232
- reference
2233
- });
2234
- return marker;
2235
- }
2236
- }
2237
- function serializeDocxThemeReference(reference) {
2238
- return reference ? JSON.stringify(reference) : void 0;
2239
- }
2240
- function parseDocxThemeReference(value) {
2241
- if (!value) return null;
2242
- try {
2243
- const parsed = JSON.parse(value);
2244
- const theme = 'string' == typeof parsed.theme ? parsed.theme.trim() : '';
2245
- const resolved = normalizeColor('string' == typeof parsed.resolved ? parsed.resolved : null);
2246
- const tint = byteHex(parsed.tint);
2247
- const shade = byteHex(parsed.shade);
2248
- if (!theme || !resolved) return null;
2249
- return {
2250
- theme,
2251
- resolved,
2252
- ...tint ? {
2253
- tint
2254
- } : {},
2255
- ...shade ? {
2256
- shade
2257
- } : {}
2258
- };
2259
- } catch {
2260
- return null;
2261
- }
2262
- }
2263
- async function patchDocxThemeReferences(buffer, patches) {
2264
- if (!patches.length) return buffer;
2265
- const archive = await jszip.loadAsync(buffer);
2266
- const byMarker = new Map(patches.map((patch)=>[
2267
- patch.marker,
2268
- patch
2269
- ]));
2270
- const entries = Object.values(archive.files).filter((entry)=>!entry.dir && /^word\/(?:document|header\d+|footer\d+|footnotes|endnotes|comments)\.xml$/.test(entry.name));
2271
- for (const entry of entries){
2272
- const document1 = parseXml(await entry.async('text'), entry.name);
2273
- let changed = false;
2274
- for (const element of Array.from(document1.getElementsByTagName('*')))for (const target of themePatchTargets(element.localName)){
2275
- const marker = wordAttribute(element, target.directAttribute)?.toUpperCase();
2276
- const patch = marker ? byMarker.get(marker) : void 0;
2277
- if (patch && patch.kind === target.kind) {
2278
- setWordAttribute(document1, element, target.directAttribute, patch.reference.resolved.slice(1).toUpperCase());
2279
- setWordAttribute(document1, element, target.themeAttribute, patch.reference.theme);
2280
- setOptionalWordAttribute(document1, element, target.tintAttribute, patch.reference.tint);
2281
- setOptionalWordAttribute(document1, element, target.shadeAttribute, patch.reference.shade);
2282
- changed = true;
2283
- }
2284
- }
2285
- if (changed) archive.file(entry.name, new XMLSerializer().serializeToString(document1));
2286
- }
2287
- return archive.generateAsync({
2288
- type: 'arraybuffer'
2289
- });
2290
- }
2291
- function themePatchTargets(localName) {
2292
- if ('color' === localName) return [
2293
- {
2294
- kind: 'color',
2295
- directAttribute: 'val',
2296
- themeAttribute: 'themeColor',
2297
- tintAttribute: 'themeTint',
2298
- shadeAttribute: 'themeShade'
2299
- }
2300
- ];
2301
- if ('u' === localName) return [
2302
- {
2303
- kind: 'underline',
2304
- directAttribute: 'color',
2305
- themeAttribute: 'themeColor',
2306
- tintAttribute: 'themeTint',
2307
- shadeAttribute: 'themeShade'
2308
- }
2309
- ];
2310
- if ('shd' === localName) return [
2311
- {
2312
- kind: 'fill',
2313
- directAttribute: 'fill',
2314
- themeAttribute: 'themeFill',
2315
- tintAttribute: 'themeFillTint',
2316
- shadeAttribute: 'themeFillShade'
2317
- },
2318
- {
2319
- kind: 'shadingColor',
2320
- directAttribute: 'color',
2321
- themeAttribute: 'themeColor',
2322
- tintAttribute: 'themeTint',
2323
- shadeAttribute: 'themeShade'
2324
- }
2325
- ];
2326
- return [
2327
- 'top',
2328
- 'right',
2329
- 'bottom',
2330
- 'left',
2331
- 'start',
2332
- 'end'
2333
- ].includes(localName) ? [
2334
- {
2335
- kind: 'border',
2336
- directAttribute: 'color',
2337
- themeAttribute: 'themeColor',
2338
- tintAttribute: 'themeTint',
2339
- shadeAttribute: 'themeShade'
2340
- }
2341
- ] : [];
2342
- }
2343
- function normalizeColor(value) {
2344
- const normalized = value?.trim().toLowerCase();
2345
- if (!normalized || !/^#[0-9a-f]{6}$/.test(normalized)) return null;
2346
- return normalized;
2347
- }
2348
- function sourceColors(source) {
2349
- const colors = new Set();
2350
- for (const match of source.matchAll(/#([0-9a-f]{6})\b/gi))if (match[1]) colors.add(match[1].toUpperCase());
2351
- for (const match of source.matchAll(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/gi)){
2352
- const channels = match.slice(1, 4).map(Number);
2353
- if (!channels.some((channel)=>channel < 0 || channel > 255)) colors.add(channels.map((channel)=>channel.toString(16).padStart(2, '0')).join('').toUpperCase());
2354
- }
2355
- return colors;
2356
- }
2357
- function byteHex(value) {
2358
- if ('string' != typeof value) return;
2359
- const normalized = value.trim().toUpperCase();
2360
- return /^[0-9A-F]{2}$/.test(normalized) ? normalized : void 0;
2361
- }
2362
- function wordAttribute(element, name) {
2363
- return element.getAttributeNS(WORD_NAMESPACE, name) ?? element.getAttribute(`w:${name}`);
2364
- }
2365
- function setWordAttribute(document1, element, name, value) {
2366
- const prefix = xmlNamespacePrefix(document1.documentElement, WORD_NAMESPACE) ?? 'w';
2367
- element.setAttributeNS(WORD_NAMESPACE, `${prefix}:${name}`, value);
2368
- }
2369
- function setOptionalWordAttribute(document1, element, name, value) {
2370
- if (value) setWordAttribute(document1, element, name, value);
2371
- else element.removeAttributeNS(WORD_NAMESPACE, name);
2372
- }
2373
- const DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE = 'data-office-paragraph-borders';
2374
- const DOCUMENT_PARAGRAPH_BORDER_EDGES = [
2375
- 'top',
2376
- 'left',
2377
- 'bottom',
2378
- 'right',
2379
- 'between',
2380
- 'bar'
2381
- ];
2382
- const DOCUMENT_PARAGRAPH_BORDER_STYLES = [
2383
- 'nil',
2384
- 'none',
2385
- 'single',
2386
- 'thick',
2387
- 'double',
2388
- 'dotted',
2389
- 'dashed',
2390
- 'dotDash',
2391
- 'dotDotDash',
2392
- 'triple',
2393
- 'thinThickSmallGap',
2394
- 'thickThinSmallGap',
2395
- 'thinThickThinSmallGap',
2396
- 'thinThickMediumGap',
2397
- 'thickThinMediumGap',
2398
- 'thinThickThinMediumGap',
2399
- 'thinThickLargeGap',
2400
- 'thickThinLargeGap',
2401
- 'thinThickThinLargeGap',
2402
- 'wave',
2403
- 'doubleWave',
2404
- 'dashSmallGap',
2405
- 'dashDotStroked',
2406
- 'threeDEmboss',
2407
- 'threeDEngrave',
2408
- 'outset',
2409
- 'inset',
2410
- 'apples',
2411
- 'archedScallops',
2412
- 'babyPacifier',
2413
- 'babyRattle',
2414
- 'balloons3Colors',
2415
- 'balloonsHotAir',
2416
- 'basicBlackDashes',
2417
- 'basicBlackDots',
2418
- 'basicBlackSquares',
2419
- 'basicThinLines',
2420
- 'basicWhiteDashes',
2421
- 'basicWhiteDots',
2422
- 'basicWhiteSquares',
2423
- 'basicWideInline',
2424
- 'basicWideMidline',
2425
- 'basicWideOutline',
2426
- 'bats',
2427
- 'birds',
2428
- 'birdsFlight',
2429
- 'cabins',
2430
- 'cakeSlice',
2431
- 'candyCorn',
2432
- 'celticKnotwork',
2433
- 'certificateBanner',
2434
- 'chainLink',
2435
- 'champagneBottle',
2436
- 'checkedBarBlack',
2437
- 'checkedBarColor',
2438
- 'checkered',
2439
- 'christmasTree',
2440
- 'circlesLines',
2441
- 'circlesRectangles',
2442
- 'classicalWave',
2443
- 'clocks',
2444
- 'compass',
2445
- 'confetti',
2446
- 'confettiGrays',
2447
- 'confettiOutline',
2448
- 'confettiStreamers',
2449
- 'confettiWhite',
2450
- 'cornerTriangles',
2451
- 'couponCutoutDashes',
2452
- 'couponCutoutDots',
2453
- 'crazyMaze',
2454
- 'creaturesButterfly',
2455
- 'creaturesFish',
2456
- 'creaturesInsects',
2457
- 'creaturesLadyBug',
2458
- 'crossStitch',
2459
- 'cup',
2460
- 'decoArch',
2461
- 'decoArchColor',
2462
- 'decoBlocks',
2463
- 'diamondsGray',
2464
- 'doubleD',
2465
- 'doubleDiamonds',
2466
- 'earth1',
2467
- 'earth2',
2468
- 'eclipsingSquares1',
2469
- 'eclipsingSquares2',
2470
- 'eggsBlack',
2471
- 'fans',
2472
- 'film',
2473
- 'firecrackers',
2474
- 'flowersBlockPrint',
2475
- 'flowersDaisies',
2476
- 'flowersModern1',
2477
- 'flowersModern2',
2478
- 'flowersPansy',
2479
- 'flowersRedRose',
2480
- 'flowersRoses',
2481
- 'flowersTeacup',
2482
- 'flowersTiny',
2483
- 'gems',
2484
- 'gingerbreadMan',
2485
- 'gradient',
2486
- 'handmade1',
2487
- 'handmade2',
2488
- 'heartBalloon',
2489
- 'heartGray',
2490
- 'hearts',
2491
- 'heebieJeebies',
2492
- 'holly',
2493
- 'houseFunky',
2494
- 'hypnotic',
2495
- 'iceCreamCones',
2496
- 'lightBulb',
2497
- 'lightning1',
2498
- 'lightning2',
2499
- 'mapPins',
2500
- 'mapleLeaf',
2501
- 'mapleMuffins',
2502
- 'marquee',
2503
- 'marqueeToothed',
2504
- 'moons',
2505
- 'mosaic',
2506
- 'musicNotes',
2507
- 'northwest',
2508
- 'ovals',
2509
- 'packages',
2510
- 'palmsBlack',
2511
- 'palmsColor',
2512
- 'paperClips',
2513
- 'papyrus',
2514
- 'partyFavor',
2515
- 'partyGlass',
2516
- 'pencils',
2517
- 'people',
2518
- 'peopleWaving',
2519
- 'peopleHats',
2520
- 'poinsettias',
2521
- 'postageStamp',
2522
- 'pumpkin1',
2523
- 'pushPinNote2',
2524
- 'pushPinNote1',
2525
- 'pyramids',
2526
- 'pyramidsAbove',
2527
- 'quadrants',
2528
- 'rings',
2529
- 'safari',
2530
- 'sawtooth',
2531
- 'sawtoothGray',
2532
- 'scaredCat',
2533
- 'seattle',
2534
- 'shadowedSquares',
2535
- 'sharksTeeth',
2536
- 'shorebirdTracks',
2537
- 'skyrocket',
2538
- 'snowflakeFancy',
2539
- 'snowflakes',
2540
- 'sombrero',
2541
- 'southwest',
2542
- 'stars',
2543
- 'starsTop',
2544
- 'stars3d',
2545
- 'starsBlack',
2546
- 'starsShadowed',
2547
- 'sun',
2548
- 'swirligig',
2549
- 'tornPaper',
2550
- 'tornPaperBlack',
2551
- 'trees',
2552
- 'triangleParty',
2553
- 'triangles',
2554
- 'tribal1',
2555
- 'tribal2',
2556
- 'tribal3',
2557
- 'tribal4',
2558
- 'tribal5',
2559
- 'tribal6',
2560
- 'triangle1',
2561
- 'triangle2',
2562
- 'triangleCircle1',
2563
- 'triangleCircle2',
2564
- 'shapes1',
2565
- 'shapes2',
2566
- 'twistedLines1',
2567
- 'twistedLines2',
2568
- 'vine',
2569
- 'waveline',
2570
- 'weavingAngles',
2571
- 'weavingBraid',
2572
- 'weavingRibbon',
2573
- 'weavingStrips',
2574
- 'whiteFlowers',
2575
- 'woodwork',
2576
- 'xIllusions',
2577
- 'zanyTriangles',
2578
- 'zigZag',
2579
- 'zigZagStitch'
2580
- ];
2581
- const BORDER_STYLE_SET = new Set(DOCUMENT_PARAGRAPH_BORDER_STYLES);
2582
- const BORDER_EDGE_SET = new Set(DOCUMENT_PARAGRAPH_BORDER_EDGES);
2583
- const BORDER_PROPERTY_SET = new Set([
2584
- 'style',
2585
- 'color',
2586
- 'size',
2587
- 'space',
2588
- 'shadow',
2589
- 'frame'
2590
- ]);
2591
- const LINE_BORDER_STYLES = new Set(DOCUMENT_PARAGRAPH_BORDER_STYLES.slice(0, 27));
2592
- const DASHED_BORDER_STYLES = new Set([
2593
- 'dashed',
2594
- 'dashSmallGap',
2595
- 'dashDotStroked',
2596
- 'dotDash',
2597
- 'dotDotDash'
2598
- ]);
2599
- const DOUBLE_BORDER_STYLES = new Set([
2600
- 'double',
2601
- 'triple',
2602
- 'thinThickSmallGap',
2603
- 'thickThinSmallGap',
2604
- 'thinThickThinSmallGap',
2605
- 'thinThickMediumGap',
2606
- 'thickThinMediumGap',
2607
- 'thinThickThinMediumGap',
2608
- 'thinThickLargeGap',
2609
- 'thickThinLargeGap',
2610
- 'thinThickThinLargeGap',
2611
- 'doubleWave'
2612
- ]);
2613
- const MAX_SERIALIZED_PARAGRAPH_BORDERS = 32768;
2614
- const POINTS_TO_PIXELS = 96 / 72;
2615
- function normalizeDocumentParagraphBorders(source) {
2616
- if (!source || 'object' != typeof source || Array.isArray(source)) return null;
2617
- const record = source;
2618
- if (Object.keys(record).some((key)=>!BORDER_EDGE_SET.has(key))) return null;
2619
- const borders = {};
2620
- for (const edge of DOCUMENT_PARAGRAPH_BORDER_EDGES){
2621
- if (void 0 === record[edge]) continue;
2622
- const border = normalizeDocumentParagraphBorder(record[edge]);
2623
- if (!border) return null;
2624
- borders[edge] = border;
2625
- }
2626
- return Object.keys(borders).length ? borders : null;
2627
- }
2628
- function normalizeDocumentParagraphBorder(source) {
2629
- if (!source || 'object' != typeof source || Array.isArray(source)) return null;
2630
- const record = source;
2631
- if (Object.keys(record).some((key)=>!BORDER_PROPERTY_SET.has(key))) return null;
2632
- const style = record.style;
2633
- if ('string' != typeof style || !BORDER_STYLE_SET.has(style)) return null;
2634
- const normalizedStyle = style;
2635
- const color = normalizeBorderColor(record.color);
2636
- if (void 0 !== record.color && !color) return null;
2637
- const size = optionalInteger(record.size);
2638
- if (null === size || void 0 !== size && !validBorderSize(normalizedStyle, size)) return null;
2639
- const space = optionalInteger(record.space);
2640
- if (null === space || void 0 !== space && (space < 0 || space > 31)) return null;
2641
- const shadow = optionalBoolean(record.shadow);
2642
- const frame = optionalBoolean(record.frame);
2643
- if (null === shadow || null === frame) return null;
2644
- return {
2645
- style: normalizedStyle,
2646
- ...color ? {
2647
- color
2648
- } : {},
2649
- ...void 0 !== size ? {
2650
- size
2651
- } : {},
2652
- ...void 0 !== space ? {
2653
- space
2654
- } : {},
2655
- ...void 0 !== shadow ? {
2656
- shadow
2657
- } : {},
2658
- ...void 0 !== frame ? {
2659
- frame
2660
- } : {}
2661
- };
2662
- }
2663
- function parseDocumentParagraphBorders(source) {
2664
- if ('string' != typeof source) return normalizeDocumentParagraphBorders(source);
2665
- if (!source.trim() || source.length > MAX_SERIALIZED_PARAGRAPH_BORDERS) return null;
2666
- try {
2667
- return normalizeDocumentParagraphBorders(JSON.parse(source));
2668
- } catch {
2669
- return null;
2670
- }
2671
- }
2672
- function serializeDocumentParagraphBorders(source) {
2673
- const borders = normalizeDocumentParagraphBorders(source);
2674
- if (!borders) return;
2675
- return JSON.stringify(Object.fromEntries(DOCUMENT_PARAGRAPH_BORDER_EDGES.flatMap((edge)=>{
2676
- const border = borders[edge];
2677
- return border ? [
2678
- [
2679
- edge,
2680
- serializedBorder(border)
2681
- ]
2682
- ] : [];
2683
- })));
2684
- }
2685
- function parseDocumentParagraphBordersElement(element) {
2686
- const semantic = parseDocumentParagraphBorders(element.getAttribute(DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE));
2687
- if (!semantic) return paragraphBordersFromCss(element);
2688
- const edited = {
2689
- ...semantic
2690
- };
2691
- for (const edge of [
2692
- 'top',
2693
- 'left',
2694
- 'bottom',
2695
- 'right'
2696
- ]){
2697
- const border = semantic[edge];
2698
- const css = cssBorder(element, edge);
2699
- if (!(!css || border && sameBorderPresentation(border, css))) {
2700
- if ('none' === css.style) {
2701
- edited[edge] = {
2702
- style: 'nil'
2703
- };
2704
- continue;
2705
- }
2706
- edited[edge] = {
2707
- ...border ?? {
2708
- style: 'single'
2709
- },
2710
- style: cssStyleToBorderStyle(css.style),
2711
- color: {
2712
- value: css.color
2713
- },
2714
- size: cssWidthToEighthPoints(css.width)
2715
- };
2716
- }
2717
- }
2718
- return normalizeDocumentParagraphBorders(edited);
2719
- }
2720
- function documentParagraphBordersDomAttributes(source) {
2721
- const borders = normalizeDocumentParagraphBorders(source);
2722
- const serialized = serializeDocumentParagraphBorders(borders);
2723
- if (!borders || !serialized) return {};
2724
- const styles = [];
2725
- const shadows = [];
2726
- for (const edge of [
2727
- 'top',
2728
- 'left',
2729
- 'bottom',
2730
- 'right'
2731
- ]){
2732
- const border = borders[edge];
2733
- if (!border) continue;
2734
- const presentation = documentBorderPresentation(border);
2735
- styles.push(`border-${edge}: ${formatPixels(presentation.width)}px ${presentation.style} ${presentation.color}`);
2736
- if (border.space) styles.push(`padding-${edge}: ${formatPixels(border.space * POINTS_TO_PIXELS)}px`);
2737
- if (border.shadow && presentation.width > 0) shadows.push(`2px 2px 0 ${presentation.color}`);
2738
- }
2739
- const between = borders.between ? documentBorderPresentation(borders.between) : null;
2740
- if (between && between.width > 0) shadows.push(`inset 0 -${formatPixels(between.width)}px 0 ${between.color}`);
2741
- const bar = borders.bar ? documentBorderPresentation(borders.bar) : null;
2742
- if (bar && bar.width > 0) shadows.push(`inset ${formatPixels(bar.width)}px 0 0 ${bar.color}`);
2743
- if (shadows.length) styles.push(`box-shadow: ${shadows.join(', ')}`);
2744
- return {
2745
- [DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE]: serialized,
2746
- ...styles.length ? {
2747
- style: styles.join('; ')
2748
- } : {}
2749
- };
2750
- }
2751
- function isDocumentParagraphArtBorderStyle(style) {
2752
- return !LINE_BORDER_STYLES.has(style);
2753
- }
2754
- function normalizeBorderColor(source) {
2755
- if (!source || 'object' != typeof source || Array.isArray(source)) return null;
2756
- const record = source;
2757
- if (Object.keys(record).some((key)=>'value' !== key && 'theme' !== key)) return null;
2758
- const theme = parseDocxThemeReference('string' == typeof record.theme ? record.theme : record.theme ? JSON.stringify(record.theme) : void 0);
2759
- const direct = 'auto' === record.value ? 'auto' : 'string' == typeof record.value ? normalizeCssColor(record.value) : null;
2760
- const resolved = direct ?? theme?.resolved ?? null;
2761
- if (!resolved || 'transparent' === resolved) return null;
2762
- if (theme && resolved !== theme.resolved && !('auto' === resolved && 'none' === theme.theme && '#000000' === theme.resolved)) return null;
2763
- return {
2764
- value: resolved,
2765
- ...theme ? {
2766
- theme
2767
- } : {}
2768
- };
2769
- }
2770
- function serializedBorder(border) {
2771
- const color = border.color ? serializedBorderColor(border.color) : void 0;
2772
- return {
2773
- style: border.style,
2774
- ...color ? {
2775
- color
2776
- } : {},
2777
- ...void 0 !== border.size ? {
2778
- size: border.size
2779
- } : {},
2780
- ...void 0 !== border.space ? {
2781
- space: border.space
2782
- } : {},
2783
- ...void 0 !== border.shadow ? {
2784
- shadow: border.shadow
2785
- } : {},
2786
- ...void 0 !== border.frame ? {
2787
- frame: border.frame
2788
- } : {}
2789
- };
2790
- }
2791
- function serializedBorderColor(color) {
2792
- const theme = serializeDocxThemeReference(color.theme ?? null);
2793
- return {
2794
- value: color.value,
2795
- ...theme ? {
2796
- theme: JSON.parse(theme)
2797
- } : {}
2798
- };
2799
- }
2800
- function optionalInteger(value) {
2801
- if (void 0 === value) return;
2802
- return 'number' == typeof value && Number.isSafeInteger(value) ? value : null;
2803
- }
2804
- function optionalBoolean(value) {
2805
- if (void 0 === value) return;
2806
- return 'boolean' == typeof value ? value : null;
2807
- }
2808
- function validBorderSize(style, size) {
2809
- if ('nil' === style || 'none' === style) return size >= 0 && size <= 96;
2810
- return isDocumentParagraphArtBorderStyle(style) ? size >= 1 && size <= 31 : size >= 2 && size <= 96;
2811
- }
2812
- function documentBorderPresentation(border) {
2813
- if ('nil' === border.style || 'none' === border.style || !border.size) return {
2814
- color: 'transparent',
2815
- style: 'none',
2816
- width: 0
2817
- };
2818
- const width = Math.min(16, isDocumentParagraphArtBorderStyle(border.style) ? border.size * POINTS_TO_PIXELS : border.size / 6);
2819
- return {
2820
- color: border.color && 'auto' !== border.color.value ? border.color.value : '#000000',
2821
- style: borderStyleToCssStyle(border.style),
2822
- width
2823
- };
2824
- }
2825
- function borderStyleToCssStyle(style) {
2826
- if ('nil' === style || 'none' === style) return 'none';
2827
- if ('dotted' === style) return 'dotted';
2828
- if (DASHED_BORDER_STYLES.has(style)) return 'dashed';
2829
- if (DOUBLE_BORDER_STYLES.has(style)) return 'double';
2830
- if ('inset' === style || 'threeDEngrave' === style) return 'inset';
2831
- if ('outset' === style || 'threeDEmboss' === style) return 'outset';
2832
- return 'solid';
2833
- }
2834
- function paragraphBordersFromCss(element) {
2835
- const borders = {};
2836
- for (const edge of [
2837
- 'top',
2838
- 'left',
2839
- 'bottom',
2840
- 'right'
2841
- ]){
2842
- const css = cssBorder(element, edge);
2843
- if (css && 'none' !== css.style) borders[edge] = {
2844
- style: cssStyleToBorderStyle(css.style),
2845
- color: {
2846
- value: css.color
2847
- },
2848
- size: cssWidthToEighthPoints(css.width)
2849
- };
2850
- }
2851
- return normalizeDocumentParagraphBorders(borders);
2852
- }
2853
- function cssBorder(element, edge) {
2854
- const style = element.style.getPropertyValue(`border-${edge}-style`).trim();
2855
- const width = Number.parseFloat(element.style.getPropertyValue(`border-${edge}-width`));
2856
- const color = normalizeCssColor(element.style.getPropertyValue(`border-${edge}-color`));
2857
- if (!style) return null;
2858
- if ('none' === style || 'hidden' === style) return {
2859
- color: '#000000',
2860
- style: 'none',
2861
- width: 0
2862
- };
2863
- return color && 'transparent' !== color && Number.isFinite(width) && width > 0 ? {
2864
- color,
2865
- style,
2866
- width
2867
- } : null;
2868
- }
2869
- function sameBorderPresentation(border, css) {
2870
- const expected = documentBorderPresentation(border);
2871
- if ('none' === expected.style) return 'none' === css.style && 0 === css.width;
2872
- return expected.color === css.color && expected.style === css.style && Math.abs(expected.width - css.width) < 0.01;
2873
- }
2874
- function cssStyleToBorderStyle(style) {
2875
- if ('double' === style) return 'double';
2876
- if ('dashed' === style) return 'dashed';
2877
- if ('dotted' === style) return 'dotted';
2878
- if ('inset' === style || 'groove' === style) return 'inset';
2879
- if ('outset' === style || 'ridge' === style) return 'outset';
2880
- return 'single';
2881
- }
2882
- function cssWidthToEighthPoints(width) {
2883
- return Math.max(2, Math.min(96, Math.round(6 * width)));
2884
- }
2885
- function formatPixels(value) {
2886
- return Number(value.toFixed(3)).toString();
2887
- }
2888
2146
  const DOCUMENT_PAGE_BORDER_EDGES = [
2889
2147
  'top',
2890
2148
  'left',
@@ -2912,7 +2170,7 @@ const PAGE_BORDER_Z_ORDER_SET = new Set([
2912
2170
  'back'
2913
2171
  ]);
2914
2172
  const MAX_SERIALIZED_PAGE_BORDERS = 32768;
2915
- const work_document_page_borders_POINTS_TO_PIXELS = 96 / 72;
2173
+ const POINTS_TO_PIXELS = 96 / 72;
2916
2174
  function normalizeDocumentPageBorders(source) {
2917
2175
  if (!source || 'object' != typeof source || Array.isArray(source)) return null;
2918
2176
  const record = source;
@@ -2994,7 +2252,7 @@ function resolveDocumentPageBorders(source, margins) {
2994
2252
  const border = borders.edges[edge];
2995
2253
  const presentation = border ? documentBorderPresentation(border) : void 0;
2996
2254
  if (presentation) presentations[edge] = presentation;
2997
- const space = (border?.space ?? 0) * work_document_page_borders_POINTS_TO_PIXELS;
2255
+ const space = (border?.space ?? 0) * POINTS_TO_PIXELS;
2998
2256
  insets[edge] = 'page' === offsetFrom ? space : Math.max(0, millimetersToPixels(margins[edge]) - space - (presentation?.width ?? 0));
2999
2257
  }
3000
2258
  return {
@@ -7301,521 +6559,21 @@ function formatHexIdentifier(value) {
7301
6559
  function formatWordprocessingIdentifier(value) {
7302
6560
  return formatHexIdentifier(value & MAX_WORDPROCESSING_ID || 1);
7303
6561
  }
7304
- const DOCUMENT_PARAGRAPH_ID_ATTRIBUTE = 'data-office-paragraph-id';
7305
- const DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE = 'data-office-paragraph-text-id';
7306
- const PARAGRAPH_ID_PATTERN = /^[0-9A-F]{8}$/;
7307
- const MAX_PARAGRAPH_ID = 0x7fffffff;
7308
- let work_document_paragraph_identity_fallbackIdentitySequence = 0;
7309
- const DocumentParagraphIdentity = Extension.create({
7310
- name: 'documentParagraphIdentity',
6562
+ const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
6563
+ const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
6564
+ const DocumentTableRowIdentity = Extension.create({
6565
+ name: 'documentTableRowIdentity',
7311
6566
  addOptions () {
7312
6567
  return {
7313
- rotateTextId: ()=>true,
7314
- types: [
7315
- 'paragraph',
7316
- 'heading',
7317
- 'documentCaption'
7318
- ]
6568
+ rotateTextId: ()=>true
7319
6569
  };
7320
6570
  },
7321
6571
  addGlobalAttributes () {
7322
6572
  return [
7323
6573
  {
7324
- types: this.options.types,
7325
- attributes: {
7326
- paragraphId: {
7327
- default: null,
7328
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE)),
7329
- renderHTML: (attributes)=>{
7330
- const value = normalizeDocumentParagraphId(attributes.paragraphId);
7331
- return value ? {
7332
- [DOCUMENT_PARAGRAPH_ID_ATTRIBUTE]: value
7333
- } : {};
7334
- }
7335
- },
7336
- textId: {
7337
- default: null,
7338
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE)),
7339
- renderHTML: (attributes)=>{
7340
- const value = normalizeDocumentParagraphId(attributes.textId);
7341
- return value ? {
7342
- [DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE]: value
7343
- } : {};
7344
- }
7345
- }
7346
- }
7347
- }
7348
- ];
7349
- },
7350
- addProseMirrorPlugins () {
7351
- return [
7352
- createDocumentParagraphIdentityPlugin(this.options.types, this.options.rotateTextId)
7353
- ];
7354
- }
7355
- });
7356
- function normalizeDocumentParagraphId(value) {
7357
- if ('string' != typeof value) return null;
7358
- const normalized = value.trim().toUpperCase();
7359
- if (!PARAGRAPH_ID_PATTERN.test(normalized)) return null;
7360
- const number = Number.parseInt(normalized, 16);
7361
- return number > 0 && number <= MAX_PARAGRAPH_ID ? normalized : null;
7362
- }
7363
- function createDocumentParagraphIdentityRegistry() {
7364
- return {
7365
- paragraphIds: new Set()
7366
- };
7367
- }
7368
- function normalizeDocumentParagraphIdentity(source) {
7369
- const paragraphId = normalizeDocumentParagraphId(source.paragraphId);
7370
- const textId = normalizeDocumentParagraphId(source.textId);
7371
- return paragraphId && textId ? {
7372
- paragraphId,
7373
- textId
7374
- } : null;
7375
- }
7376
- function documentParagraphIdentityFromElement(element) {
7377
- return normalizeDocumentParagraphIdentity({
7378
- paragraphId: element.getAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE),
7379
- textId: element.getAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE)
7380
- });
7381
- }
7382
- function applyDocumentParagraphIdentityToElement(element, source) {
7383
- const identity = normalizeDocumentParagraphIdentity(source);
7384
- if (!identity) {
7385
- element.removeAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE);
7386
- element.removeAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE);
7387
- return null;
7388
- }
7389
- element.setAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE, identity.paragraphId);
7390
- element.setAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE, identity.textId);
7391
- return identity;
7392
- }
7393
- function createDocumentParagraphIdentityPlugin(types, rotateTextId) {
7394
- const trackedTypes = new Set(types);
7395
- return new Plugin({
7396
- view (view) {
7397
- const transaction = normalizeDocumentParagraphIdentities(view.state, trackedTypes, rotateTextId);
7398
- if (transaction) {
7399
- transaction.setMeta('addToHistory', false);
7400
- view.dispatch(transaction);
7401
- }
7402
- return {};
7403
- },
7404
- appendTransaction (transactions, oldState, newState) {
7405
- if (!transactions.some((transaction)=>transaction.docChanged)) return null;
7406
- return normalizeDocumentParagraphIdentities(newState, trackedTypes, rotateTextId, oldState, transactions);
7407
- }
7408
- });
7409
- }
7410
- function normalizeDocumentParagraphIdentities(state, trackedTypes, rotateTextId, oldState, transactions = []) {
7411
- if (!documentHasIntegrityFeature(state.doc, 16)) return null;
7412
- const paragraphs = documentParagraphs(state.doc, trackedTypes);
7413
- if (!paragraphs.length) return null;
7414
- const retainedPositions = oldState ? retainedDocumentParagraphPositions(oldState, state, transactions, trackedTypes) : new Set();
7415
- const editedPositions = oldState && rotateTextId() && !transactions.some(isHistoryTransaction) ? editedDocumentParagraphPositions(oldState, state, transactions, trackedTypes) : new Set();
7416
- const ordered = [
7417
- ...paragraphs.filter((item)=>retainedPositions.has(item.position)),
7418
- ...paragraphs.filter((item)=>!retainedPositions.has(item.position))
7419
- ];
7420
- const registry = createDocumentParagraphIdentityRegistry();
7421
- const updates = new Map();
7422
- for (const paragraph of ordered){
7423
- const current = paragraphIdentitySourceFromNode(paragraph.node);
7424
- const source = editedPositions.has(paragraph.position) ? {
7425
- ...current,
7426
- textId: nextDocumentParagraphTextId(current.textId)
7427
- } : current;
7428
- const identity = uniqueDocumentParagraphIdentity(source, registry);
7429
- if (!sameDocumentParagraphIdentity(current, identity)) updates.set(paragraph.position, identity);
7430
- }
7431
- if (!updates.size) return null;
7432
- const transaction = state.tr;
7433
- for (const paragraph of paragraphs){
7434
- const identity = updates.get(paragraph.position);
7435
- if (identity) transaction.setNodeMarkup(paragraph.position, void 0, {
7436
- ...paragraph.node.attrs,
7437
- ...identity
7438
- });
7439
- }
7440
- if (!transaction.docChanged) return null;
7441
- transaction.setMeta('addToHistory', false);
7442
- return transaction;
7443
- }
7444
- function hasDocumentParagraphIdentityComponent(node) {
7445
- return Boolean(normalizeDocumentParagraphId(node.attrs.paragraphId) || normalizeDocumentParagraphId(node.attrs.textId));
7446
- }
7447
- function retainedDocumentParagraphPositions(oldState, newState, transactions, trackedTypes) {
7448
- const mapping = work_document_paragraph_identity_transactionMapping(transactions);
7449
- const retained = new Set();
7450
- for (const previous of documentParagraphs(oldState.doc, trackedTypes)){
7451
- const paragraphId = normalizeDocumentParagraphId(previous.node.attrs.paragraphId);
7452
- if (!paragraphId) continue;
7453
- const mapped = mapping.mapResult(previous.position, 1);
7454
- const current = newState.doc.nodeAt(mapped.pos);
7455
- if (current && trackedTypes.has(current.type.name) && normalizeDocumentParagraphId(current.attrs.paragraphId) === paragraphId) retained.add(mapped.pos);
7456
- }
7457
- return retained;
7458
- }
7459
- function editedDocumentParagraphPositions(oldState, newState, transactions, trackedTypes) {
7460
- const mapping = work_document_paragraph_identity_transactionMapping(transactions);
7461
- const previousParagraphs = documentParagraphs(oldState.doc, trackedTypes);
7462
- const currentParagraphs = documentParagraphs(newState.doc, trackedTypes);
7463
- const previousById = paragraphsById(previousParagraphs);
7464
- const currentById = paragraphsById(currentParagraphs);
7465
- const edited = new Set();
7466
- for (const previous of previousParagraphs){
7467
- const identity = normalizeDocumentParagraphIdentity(paragraphIdentitySourceFromNode(previous.node));
7468
- if (!identity) continue;
7469
- const mapped = mapping.mapResult(previous.position, 1);
7470
- const current = newState.doc.nodeAt(mapped.pos);
7471
- if (current && trackedTypes.has(current.type.name) && normalizeDocumentParagraphId(current.attrs.paragraphId) === identity.paragraphId) {
7472
- if (paragraphTextChanged(previous.node, current, identity.textId)) edited.add(mapped.pos);
7473
- continue;
7474
- }
7475
- const previousMatches = previousById.get(identity.paragraphId) ?? [];
7476
- const currentMatches = currentById.get(identity.paragraphId) ?? [];
7477
- if (1 === previousMatches.length && 1 === currentMatches.length && paragraphTextChanged(previous.node, currentMatches[0].node, identity.textId)) edited.add(currentMatches[0].position);
7478
- }
7479
- return edited;
7480
- }
7481
- function paragraphTextChanged(previous, current, previousTextId) {
7482
- return previous.textContent !== current.textContent && normalizeDocumentParagraphId(current.attrs.textId) === previousTextId;
7483
- }
7484
- function paragraphsById(paragraphs) {
7485
- const result = new Map();
7486
- for (const paragraph of paragraphs){
7487
- const id = normalizeDocumentParagraphId(paragraph.node.attrs.paragraphId);
7488
- if (!id) continue;
7489
- const matches = result.get(id) ?? [];
7490
- matches.push(paragraph);
7491
- result.set(id, matches);
7492
- }
7493
- return result;
7494
- }
7495
- function documentParagraphs(document1, trackedTypes) {
7496
- const paragraphs = [];
7497
- document1.descendants((node, position)=>{
7498
- if (trackedTypes.has(node.type.name) && hasDocumentParagraphIdentityComponent(node)) paragraphs.push({
7499
- node,
7500
- position
7501
- });
7502
- });
7503
- return paragraphs;
7504
- }
7505
- function paragraphIdentitySourceFromNode(node) {
7506
- return {
7507
- paragraphId: node.attrs.paragraphId,
7508
- textId: node.attrs.textId
7509
- };
7510
- }
7511
- function uniqueDocumentParagraphIdentity(source, registry) {
7512
- const preferred = normalizeDocumentParagraphIdentity(source);
7513
- if (preferred && !registry.paragraphIds.has(preferred.paragraphId)) {
7514
- registry.paragraphIds.add(preferred.paragraphId);
7515
- return preferred;
7516
- }
7517
- for(let attempt = 0; attempt < 8; attempt += 1){
7518
- const identity = createDocumentParagraphIdentity();
7519
- if (!registry.paragraphIds.has(identity.paragraphId)) {
7520
- registry.paragraphIds.add(identity.paragraphId);
7521
- return identity;
7522
- }
7523
- }
7524
- return sequentialDocumentParagraphIdentity(registry);
7525
- }
7526
- function createDocumentParagraphIdentity() {
7527
- return {
7528
- paragraphId: randomDocumentParagraphId(),
7529
- textId: randomDocumentParagraphId()
7530
- };
7531
- }
7532
- function sequentialDocumentParagraphIdentity(registry) {
7533
- for(let value = 1; value <= MAX_PARAGRAPH_ID; value += 1){
7534
- const paragraphId = formatDocumentParagraphId(value);
7535
- if (!registry.paragraphIds.has(paragraphId)) {
7536
- registry.paragraphIds.add(paragraphId);
7537
- return {
7538
- paragraphId,
7539
- textId: randomDocumentParagraphId()
7540
- };
7541
- }
7542
- }
7543
- throw new Error('No unique Word paragraph identity is available.');
7544
- }
7545
- function nextDocumentParagraphTextId(value) {
7546
- const current = normalizeDocumentParagraphId(value);
7547
- if (!current) return randomDocumentParagraphId();
7548
- const number = Number.parseInt(current, 16);
7549
- return formatDocumentParagraphId(number >= MAX_PARAGRAPH_ID ? 1 : number + 1);
7550
- }
7551
- function randomDocumentParagraphId() {
7552
- let value = 0;
7553
- const cryptoApi = globalThis.crypto;
7554
- if ('function' == typeof cryptoApi?.getRandomValues) {
7555
- const values = new Uint32Array(1);
7556
- cryptoApi.getRandomValues(values);
7557
- value = values[0] ?? 0;
7558
- } else if ('function' == typeof cryptoApi?.randomUUID) value = Number.parseInt(cryptoApi.randomUUID().replaceAll('-', '').slice(0, 8), 16);
7559
- if (!value) {
7560
- work_document_paragraph_identity_fallbackIdentitySequence += 1;
7561
- value = work_document_paragraph_identity_stableIdentityHash(`${Date.now()}:${Math.random()}:${work_document_paragraph_identity_fallbackIdentitySequence}`);
7562
- }
7563
- return formatDocumentParagraphId(value || work_document_paragraph_identity_fallbackIdentitySequence || 1);
7564
- }
7565
- function work_document_paragraph_identity_stableIdentityHash(value) {
7566
- let hash = 0x811c9dc5;
7567
- for(let index = 0; index < value.length; index += 1){
7568
- hash ^= value.charCodeAt(index);
7569
- hash = Math.imul(hash, 0x01000193);
7570
- }
7571
- return hash >>> 0 || 1;
7572
- }
7573
- function formatDocumentParagraphId(value) {
7574
- return (value >>> 0 & MAX_PARAGRAPH_ID || 1).toString(16).toUpperCase().padStart(8, '0');
7575
- }
7576
- function sameDocumentParagraphIdentity(source, identity) {
7577
- return normalizeDocumentParagraphId(source.paragraphId) === identity.paragraphId && normalizeDocumentParagraphId(source.textId) === identity.textId;
7578
- }
7579
- function work_document_paragraph_identity_transactionMapping(transactions) {
7580
- const mapping = new Mapping();
7581
- for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
7582
- return mapping;
7583
- }
7584
- const DOCUMENT_PARAGRAPH_SHADING_PATTERNS = new Set([
7585
- 'nil',
7586
- 'clear',
7587
- 'solid',
7588
- 'horzStripe',
7589
- 'vertStripe',
7590
- 'reverseDiagStripe',
7591
- 'diagStripe',
7592
- 'horzCross',
7593
- 'diagCross',
7594
- 'thinHorzStripe',
7595
- 'thinVertStripe',
7596
- 'thinReverseDiagStripe',
7597
- 'thinDiagStripe',
7598
- 'thinHorzCross',
7599
- 'thinDiagCross',
7600
- 'pct5',
7601
- 'pct10',
7602
- 'pct12',
7603
- 'pct15',
7604
- 'pct20',
7605
- 'pct25',
7606
- 'pct30',
7607
- 'pct35',
7608
- 'pct37',
7609
- 'pct40',
7610
- 'pct45',
7611
- 'pct50',
7612
- 'pct55',
7613
- 'pct60',
7614
- 'pct62',
7615
- 'pct65',
7616
- 'pct70',
7617
- 'pct75',
7618
- 'pct80',
7619
- 'pct85',
7620
- 'pct87',
7621
- 'pct90',
7622
- 'pct95'
7623
- ]);
7624
- function normalizeDocumentParagraphShading(source) {
7625
- if (!source || 'object' != typeof source) return null;
7626
- const value = source;
7627
- const pattern = value.pattern;
7628
- if ('string' != typeof pattern || !DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
7629
- const color = normalizeShadingColor(value.color);
7630
- const fill = normalizeShadingColor(value.fill);
7631
- if (void 0 !== value.color && !color || void 0 !== value.fill && !fill) return null;
7632
- return {
7633
- pattern: pattern,
7634
- ...color ? {
7635
- color
7636
- } : {},
7637
- ...fill ? {
7638
- fill
7639
- } : {}
7640
- };
7641
- }
7642
- function parseDocumentParagraphShading(source) {
7643
- if ('string' != typeof source) return normalizeDocumentParagraphShading(source);
7644
- if (!source.trim()) return null;
7645
- try {
7646
- return normalizeDocumentParagraphShading(JSON.parse(source));
7647
- } catch {
7648
- return null;
7649
- }
7650
- }
7651
- function serializeDocumentParagraphShading(source) {
7652
- const shading = normalizeDocumentParagraphShading(source);
7653
- if (!shading) return;
7654
- return JSON.stringify({
7655
- pattern: shading.pattern,
7656
- ...shading.color ? {
7657
- color: serializedShadingColor(shading.color)
7658
- } : {},
7659
- ...shading.fill ? {
7660
- fill: serializedShadingColor(shading.fill)
7661
- } : {}
7662
- });
7663
- }
7664
- function parseDocumentParagraphShadingElement(element) {
7665
- const semantic = parseDocumentParagraphShading(element.dataset.officeParagraphShading);
7666
- const background = normalizeCssColor(element.style.backgroundColor);
7667
- if (semantic) {
7668
- const presentation = documentParagraphShadingPresentation(semantic);
7669
- const expected = normalizeCssColor(presentation.backgroundColor);
7670
- if (background && expected && background !== expected) {
7671
- if ('transparent' === background) return {
7672
- pattern: 'nil'
7673
- };
7674
- if (paragraphShadingBackgroundUsesForeground(semantic)) return {
7675
- ...semantic,
7676
- color: {
7677
- value: background
7678
- }
7679
- };
7680
- return {
7681
- ...semantic,
7682
- fill: {
7683
- value: background
7684
- }
7685
- };
7686
- }
7687
- return semantic;
7688
- }
7689
- return background && 'transparent' !== background ? {
7690
- pattern: 'clear',
7691
- fill: {
7692
- value: background
7693
- }
7694
- } : null;
7695
- }
7696
- function documentParagraphShadingDomAttributes(source) {
7697
- const shading = normalizeDocumentParagraphShading(source);
7698
- const serialized = serializeDocumentParagraphShading(shading);
7699
- if (!shading || !serialized) return {};
7700
- const presentation = documentParagraphShadingPresentation(shading);
7701
- const styles = [
7702
- `background-color: ${presentation.backgroundColor}`,
7703
- presentation.backgroundImage ? `background-image: ${presentation.backgroundImage}` : '',
7704
- presentation.backgroundSize ? `background-size: ${presentation.backgroundSize}` : ''
7705
- ].filter(Boolean);
7706
- return {
7707
- 'data-office-paragraph-shading': serialized,
7708
- style: styles.join('; ')
7709
- };
7710
- }
7711
- function normalizeShadingColor(source) {
7712
- if (!source || 'object' != typeof source) return null;
7713
- const value = source;
7714
- const theme = parseDocxThemeReference('string' == typeof value.theme ? value.theme : value.theme ? JSON.stringify(value.theme) : void 0);
7715
- const direct = 'auto' === value.value ? 'auto' : 'string' == typeof value.value ? normalizeCssColor(value.value) : null;
7716
- const resolved = direct ?? theme?.resolved ?? null;
7717
- if (!resolved || 'transparent' === resolved) return null;
7718
- if (theme && resolved !== theme.resolved) return null;
7719
- return {
7720
- value: resolved,
7721
- ...theme ? {
7722
- theme
7723
- } : {}
7724
- };
7725
- }
7726
- function serializedShadingColor(color) {
7727
- const theme = serializeDocxThemeReference(color.theme ?? null);
7728
- return {
7729
- value: color.value,
7730
- ...theme ? {
7731
- theme: JSON.parse(theme)
7732
- } : {}
7733
- };
7734
- }
7735
- function documentParagraphShadingPresentation(shading) {
7736
- if ('nil' === shading.pattern) return {
7737
- backgroundColor: 'transparent'
7738
- };
7739
- const foreground = shadingColor(shading.color, '#000000');
7740
- const background = shadingColor(shading.fill, 'transparent');
7741
- if ('clear' === shading.pattern) return {
7742
- backgroundColor: background
7743
- };
7744
- if ('solid' === shading.pattern) return {
7745
- backgroundColor: foreground
7746
- };
7747
- const percentage = shadingPercentage(shading.pattern);
7748
- if (null !== percentage) {
7749
- const inverted = percentage > 50;
7750
- const dotColor = inverted ? background : foreground;
7751
- const baseColor = inverted ? foreground : background;
7752
- const density = Math.min(50, inverted ? 100 - percentage : percentage);
7753
- const spacing = Math.max(2, Math.round(9 - density / 7));
7754
- return {
7755
- backgroundColor: baseColor,
7756
- backgroundImage: `radial-gradient(circle, ${dotColor} 0 1px, transparent 1.2px)`,
7757
- backgroundSize: `${spacing}px ${spacing}px`
7758
- };
7759
- }
7760
- const thin = shading.pattern.startsWith('thin');
7761
- const width = thin ? 1 : 2;
7762
- const period = thin ? 7 : 6;
7763
- const stripe = (angle)=>`repeating-linear-gradient(${angle}deg, ${foreground} 0 ${width}px, transparent ${width}px ${period}px)`;
7764
- const angles = shadingPatternAngles(shading.pattern);
7765
- return {
7766
- backgroundColor: background,
7767
- backgroundImage: angles.map(stripe).join(', ')
7768
- };
7769
- }
7770
- function shadingColor(color, fallback) {
7771
- return color && 'auto' !== color.value ? color.value : fallback;
7772
- }
7773
- function shadingPercentage(pattern) {
7774
- const match = /^pct(\d+)$/.exec(pattern);
7775
- return match?.[1] ? Number(match[1]) : null;
7776
- }
7777
- function paragraphShadingBackgroundUsesForeground(shading) {
7778
- if ('solid' === shading.pattern) return true;
7779
- const percentage = shadingPercentage(shading.pattern);
7780
- return null !== percentage && percentage > 50;
7781
- }
7782
- function shadingPatternAngles(pattern) {
7783
- if (pattern.includes('HorzCross')) return [
7784
- 0,
7785
- 90
7786
- ];
7787
- if (pattern.includes('DiagCross')) return [
7788
- 45,
7789
- -45
7790
- ];
7791
- if (pattern.includes('VertStripe')) return [
7792
- 90
7793
- ];
7794
- if (pattern.includes('ReverseDiagStripe')) return [
7795
- -45
7796
- ];
7797
- if (pattern.includes('DiagStripe')) return [
7798
- 45
7799
- ];
7800
- return [
7801
- 0
7802
- ];
7803
- }
7804
- const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
7805
- const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
7806
- const DocumentTableRowIdentity = Extension.create({
7807
- name: 'documentTableRowIdentity',
7808
- addOptions () {
7809
- return {
7810
- rotateTextId: ()=>true
7811
- };
7812
- },
7813
- addGlobalAttributes () {
7814
- return [
7815
- {
7816
- types: [
7817
- 'tableRow'
7818
- ],
6574
+ types: [
6575
+ 'tableRow'
6576
+ ],
7819
6577
  attributes: {
7820
6578
  rowId: identityAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7821
6579
  rowTextId: identityAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
@@ -7998,437 +6756,42 @@ function documentTableRows(document1) {
7998
6756
  }
7999
6757
  function tableRowIdentitySourceFromNode(node) {
8000
6758
  return {
8001
- rowId: node.attrs.rowId,
8002
- rowTextId: node.attrs.rowTextId
8003
- };
8004
- }
8005
- function sameDocumentTableRowIdentity(source, identity) {
8006
- return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
8007
- }
8008
- function work_document_table_row_identity_transactionMapping(transactions) {
8009
- const mapping = new Mapping();
8010
- for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
8011
- return mapping;
8012
- }
8013
- const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
8014
- const documentTextCaseKeyboardShortcuts = {
8015
- allCaps: 'Mod-Shift-a',
8016
- smallCaps: 'Mod-Shift-k'
8017
- };
8018
- function normalizeDocumentTextCase(value) {
8019
- return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
8020
- }
8021
- function documentTextCaseFromWordFlags(allCaps, smallCaps) {
8022
- if (void 0 === allCaps && void 0 === smallCaps) return null;
8023
- if (allCaps) return 'all-caps';
8024
- if (smallCaps) return 'small-caps';
8025
- return 'none';
8026
- }
8027
- function applyDocumentTextCaseStyle(element, textCase) {
8028
- element.dataset.officeTextCase = textCase;
8029
- element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
8030
- element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
8031
- }
8032
- function documentTextCaseCss(textCase) {
8033
- return [
8034
- `text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
8035
- `font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
8036
- ].join('; ');
8037
- }
8038
- const DOCUMENT_SCRIPT_FONTS_ATTRIBUTE = "data-office-script-fonts";
8039
- const DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE = "data-office-script-font-slot";
8040
- const MAX_FONT_NAME_LENGTH = 127;
8041
- const MAX_SERIALIZED_SCRIPT_FONTS_LENGTH = 4096;
8042
- const SCRIPT_FONT_KEYS = new Set([
8043
- 'ascii',
8044
- 'highAnsi',
8045
- 'eastAsia',
8046
- 'complexScript',
8047
- 'hint'
8048
- ]);
8049
- const SCRIPT_FONT_FACE_KEYS = new Set([
8050
- 'name',
8051
- 'theme',
8052
- 'resolved'
8053
- ]);
8054
- const SCRIPT_FONT_HINTS = new Set([
8055
- 'default',
8056
- 'eastAsia',
8057
- 'cs'
8058
- ]);
8059
- const work_document_script_fonts_THEME_FONTS = new Set([
8060
- 'majorEastAsia',
8061
- 'majorBidi',
8062
- 'majorAscii',
8063
- 'majorHAnsi',
8064
- 'minorEastAsia',
8065
- 'minorBidi',
8066
- 'minorAscii',
8067
- 'minorHAnsi'
8068
- ]);
8069
- const SLOT_FALLBACK_ORDER = {
8070
- ascii: [
8071
- 'ascii',
8072
- 'highAnsi',
8073
- 'eastAsia',
8074
- 'complexScript'
8075
- ],
8076
- highAnsi: [
8077
- 'highAnsi',
8078
- 'ascii',
8079
- 'eastAsia',
8080
- 'complexScript'
8081
- ],
8082
- eastAsia: [
8083
- 'eastAsia',
8084
- 'highAnsi',
8085
- 'ascii',
8086
- 'complexScript'
8087
- ],
8088
- complexScript: [
8089
- 'complexScript',
8090
- 'highAnsi',
8091
- 'ascii',
8092
- 'eastAsia'
8093
- ]
8094
- };
8095
- const NEUTRAL_SCRIPT_CHARACTER = /^[\p{Cc}\p{Cf}\p{M}\p{N}\p{P}\p{S}\p{Z}]$/u;
8096
- function normalizeDocumentScriptFonts(source) {
8097
- if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_KEYS)) return null;
8098
- const normalized = {};
8099
- for (const slot of scriptFontSlots){
8100
- if (void 0 === source[slot]) continue;
8101
- const face = normalizeDocumentScriptFontFace(source[slot]);
8102
- if (!face) return null;
8103
- normalized[slot] = face;
8104
- }
8105
- if (void 0 !== source.hint) {
8106
- const hint = normalizeDocumentScriptFontHint(source.hint);
8107
- if (!hint) return null;
8108
- normalized.hint = hint;
8109
- }
8110
- return Object.keys(normalized).length ? normalized : null;
8111
- }
8112
- function serializeDocumentScriptFonts(source) {
8113
- const fonts = normalizeDocumentScriptFonts(source);
8114
- return fonts ? JSON.stringify(fonts) : null;
8115
- }
8116
- function parseDocumentScriptFonts(source) {
8117
- if (!source || source.length > MAX_SERIALIZED_SCRIPT_FONTS_LENGTH) return null;
8118
- try {
8119
- return normalizeDocumentScriptFonts(JSON.parse(source));
8120
- } catch {
8121
- return null;
8122
- }
8123
- }
8124
- function documentScriptFontsFromElement(element) {
8125
- return parseDocumentScriptFonts(element.getAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE));
8126
- }
8127
- function documentScriptFontSlotFromElement(element) {
8128
- return normalizeDocumentScriptFontSlot(element.getAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE));
8129
- }
8130
- function documentScriptFontsDomAttributes(source, slot) {
8131
- const fonts = normalizeDocumentScriptFonts(source);
8132
- const normalizedSlot = normalizeDocumentScriptFontSlot(slot);
8133
- if (!fonts) return {};
8134
- const serialized = serializeDocumentScriptFonts(fonts);
8135
- if (!serialized) return {};
8136
- const family = documentScriptFontFamily(fonts, normalizedSlot ?? documentScriptFontSlotFromHint(fonts.hint));
8137
- return {
8138
- [DOCUMENT_SCRIPT_FONTS_ATTRIBUTE]: serialized,
8139
- ...normalizedSlot ? {
8140
- [DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE]: normalizedSlot
8141
- } : {},
8142
- ...family ? {
8143
- style: `font-family: ${family}`
8144
- } : {}
8145
- };
8146
- }
8147
- function documentScriptFontFamily(source, slot) {
8148
- const fonts = normalizeDocumentScriptFonts(source);
8149
- if (!fonts) return;
8150
- const families = [];
8151
- const seen = new Set();
8152
- for (const candidate of documentScriptFontFallbackSlots(slot)){
8153
- const family = documentScriptFontFaceFamily(fonts[candidate]);
8154
- const key = family?.toLocaleLowerCase();
8155
- if (!(!family || !key || seen.has(key))) {
8156
- seen.add(key);
8157
- families.push(cssFontFamily(family));
8158
- }
8159
- }
8160
- return families.length ? families.join(', ') : void 0;
8161
- }
8162
- function documentScriptFontFallbackSlots(slot) {
8163
- return SLOT_FALLBACK_ORDER[slot];
8164
- }
8165
- function documentScriptFontFamilyForRendering(source, slot, currentFontFamily) {
8166
- const projected = documentScriptFontFamily(source, slot);
8167
- const safeCurrent = safeCssFontFamilyList(currentFontFamily);
8168
- if (!safeCurrent || !projected) return projected;
8169
- const currentPrimary = documentFontNameFromCssFamily(safeCurrent);
8170
- const projectedPrimary = documentFontNameFromCssFamily(projected);
8171
- return currentPrimary && projectedPrimary && currentPrimary.toLocaleLowerCase() === projectedPrimary.toLocaleLowerCase() ? safeCurrent : projected;
8172
- }
8173
- function documentScriptFontDirectFamily(source, slot) {
8174
- const fonts = normalizeDocumentScriptFonts(source);
8175
- return fonts ? documentScriptFontFaceFamily(fonts[slot]) ?? null : null;
8176
- }
8177
- function documentScriptFontsForAllText(fontFamily) {
8178
- const name = documentFontNameFromCssFamily(fontFamily);
8179
- if (!name) return null;
8180
- const face = {
8181
- name,
8182
- resolved: name
8183
- };
8184
- return {
8185
- ascii: face,
8186
- highAnsi: face,
8187
- eastAsia: face,
8188
- complexScript: face,
8189
- hint: 'default'
8190
- };
8191
- }
8192
- function patchDocumentScriptFonts(source, patch, fallbackFontFamily) {
8193
- const current = normalizeDocumentScriptFonts(source) ?? documentScriptFontsForAllText(fallbackFontFamily) ?? {};
8194
- const next = {
8195
- ...current
8196
- };
8197
- if (void 0 !== patch.latin) {
8198
- const face = directFontFace(patch.latin);
8199
- if (face) {
8200
- next.ascii = face;
8201
- next.highAnsi = face;
8202
- } else {
8203
- delete next.ascii;
8204
- delete next.highAnsi;
8205
- }
8206
- }
8207
- if (void 0 !== patch.eastAsia) {
8208
- const face = directFontFace(patch.eastAsia);
8209
- if (face) next.eastAsia = face;
8210
- else delete next.eastAsia;
8211
- }
8212
- if (void 0 !== patch.complexScript) {
8213
- const face = directFontFace(patch.complexScript);
8214
- if (face) next.complexScript = face;
8215
- else delete next.complexScript;
8216
- }
8217
- return normalizeDocumentScriptFonts(next);
8218
- }
8219
- function documentScriptFontSegments(text, hint = 'default', forceComplexScript = false) {
8220
- if (!text) return [];
8221
- if (forceComplexScript) return [
8222
- {
8223
- from: 0,
8224
- to: text.length,
8225
- slot: 'complexScript'
8226
- }
8227
- ];
8228
- const characters = [];
8229
- let offset = 0;
8230
- for (const character of text){
8231
- const from = offset;
8232
- offset += character.length;
8233
- characters.push({
8234
- from,
8235
- to: offset,
8236
- slot: strongDocumentScriptFontSlot(character)
8237
- });
8238
- }
8239
- const fallback = documentScriptFontSlotFromHint(hint);
8240
- let previous = null;
8241
- for(let index = 0; index < characters.length; index += 1){
8242
- const entry = characters[index];
8243
- if (!entry) continue;
8244
- if (entry.slot) {
8245
- previous = entry.slot;
8246
- continue;
8247
- }
8248
- let next = previous;
8249
- if (!next) for(let cursor = index + 1; cursor < characters.length; cursor += 1){
8250
- const candidate = characters[cursor]?.slot;
8251
- if (candidate) {
8252
- next = candidate;
8253
- break;
8254
- }
8255
- }
8256
- entry.slot = next ?? fallback;
8257
- }
8258
- const segments = [];
8259
- for (const entry of characters){
8260
- const slot = entry.slot ?? fallback;
8261
- const prior = segments[segments.length - 1];
8262
- if (prior?.slot === slot && prior.to === entry.from) prior.to = entry.to;
8263
- else segments.push({
8264
- from: entry.from,
8265
- to: entry.to,
8266
- slot
8267
- });
8268
- }
8269
- return segments;
8270
- }
8271
- function normalizeDocumentScriptFontSlot(value) {
8272
- return scriptFontSlots.includes(value) ? value : null;
8273
- }
8274
- function normalizeDocumentScriptFontHint(value) {
8275
- return SCRIPT_FONT_HINTS.has(value) ? value : null;
8276
- }
8277
- function normalizeDocumentThemeFont(value) {
8278
- return work_document_script_fonts_THEME_FONTS.has(value) ? value : null;
8279
- }
8280
- function documentScriptFontSlotFromHint(hint) {
8281
- if ('eastAsia' === hint) return 'eastAsia';
8282
- if ('cs' === hint) return 'complexScript';
8283
- return 'ascii';
8284
- }
8285
- function documentFontNameFromCssFamily(value) {
8286
- if ('string' != typeof value) return null;
8287
- const source = value.trim();
8288
- if (!source) return null;
8289
- let family = '';
8290
- const quote = source[0];
8291
- if ('"' === quote || "'" === quote) {
8292
- let closed = false;
8293
- for(let index = 1; index < source.length; index += 1){
8294
- const character = source[index];
8295
- if (character === quote) {
8296
- closed = true;
8297
- break;
8298
- }
8299
- if ('\\' !== character) {
8300
- family += character;
8301
- continue;
8302
- }
8303
- const decoded = decodeCssEscape(source, index + 1);
8304
- if (!decoded) return null;
8305
- family += decoded.value;
8306
- index = decoded.end - 1;
8307
- }
8308
- if (!closed) return null;
8309
- } else family = source.split(',')[0] ?? '';
8310
- return normalizeDocumentFontName(family);
8311
- }
8312
- function cssDocumentFontFamily(value) {
8313
- const family = normalizeDocumentFontName(value);
8314
- return family ? cssFontFamily(family) : null;
8315
- }
8316
- function normalizeDocumentFontName(value) {
8317
- if ('string' != typeof value) return null;
8318
- const normalized = value.trim();
8319
- return normalized && normalized.length <= MAX_FONT_NAME_LENGTH && !/[\p{Cc}\p{Cs}]/u.test(normalized) ? normalized : null;
8320
- }
8321
- const scriptFontSlots = [
8322
- 'ascii',
8323
- 'highAnsi',
8324
- 'eastAsia',
8325
- 'complexScript'
8326
- ];
8327
- function normalizeDocumentScriptFontFace(source) {
8328
- if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_FACE_KEYS)) return null;
8329
- const name = void 0 === source.name ? void 0 : normalizeDocumentFontName(source.name);
8330
- const resolved = void 0 === source.resolved ? void 0 : normalizeDocumentFontName(source.resolved);
8331
- const theme = void 0 === source.theme ? void 0 : normalizeDocumentThemeFont(source.theme);
8332
- if (void 0 !== source.name && !name || void 0 !== source.resolved && !resolved || null === theme || !name && !theme && !resolved) return null;
8333
- return {
8334
- ...name ? {
8335
- name
8336
- } : {},
8337
- ...theme ? {
8338
- theme
8339
- } : {},
8340
- ...resolved ? {
8341
- resolved
8342
- } : {}
6759
+ rowId: node.attrs.rowId,
6760
+ rowTextId: node.attrs.rowTextId
8343
6761
  };
8344
6762
  }
8345
- function directFontFace(value) {
8346
- if (null === value) return null;
8347
- const name = documentFontNameFromCssFamily(value) ?? normalizeDocumentFontName(value);
8348
- return name ? {
8349
- name,
8350
- resolved: name
8351
- } : null;
8352
- }
8353
- function documentScriptFontFaceFamily(face) {
8354
- return face?.resolved ?? face?.name;
8355
- }
8356
- function strongDocumentScriptFontSlot(character) {
8357
- if (NEUTRAL_SCRIPT_CHARACTER.test(character)) return null;
8358
- const codePoint = character.codePointAt(0);
8359
- if (void 0 === codePoint) return null;
8360
- if (isComplexScriptCodePoint(codePoint)) return 'complexScript';
8361
- if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
8362
- return codePoint <= 0x7f ? 'ascii' : 'highAnsi';
8363
- }
8364
- function isComplexScriptCodePoint(codePoint) {
8365
- return codePoint >= 0x0590 && codePoint <= 0x08ff || codePoint >= 0x0900 && codePoint <= 0x109f || codePoint >= 0x1780 && codePoint <= 0x18af || codePoint >= 0x1900 && codePoint <= 0x1cff || codePoint >= 0xa800 && codePoint <= 0xa8ff || codePoint >= 0xa980 && codePoint <= 0xa9df || codePoint >= 0xaa00 && codePoint <= 0xaa7f || codePoint >= 0xabc0 && codePoint <= 0xabff || codePoint >= 0xfb1d && codePoint <= 0xfdff || codePoint >= 0xfe70 && codePoint <= 0xfeff || codePoint >= 0x10a00 && codePoint <= 0x10fff || codePoint >= 0x11000 && codePoint <= 0x11fff || codePoint >= 0x1e900 && codePoint <= 0x1edff || codePoint >= 0x1ee00 && codePoint <= 0x1eeff;
6763
+ function sameDocumentTableRowIdentity(source, identity) {
6764
+ return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
8366
6765
  }
8367
- function isEastAsianCodePoint(codePoint) {
8368
- return codePoint >= 0x1100 && codePoint <= 0x11ff || codePoint >= 0x2e80 && codePoint <= 0xa4cf || codePoint >= 0xac00 && codePoint <= 0xd7af || codePoint >= 0xf900 && codePoint <= 0xfaff || codePoint >= 0xfe10 && codePoint <= 0xfe6f || codePoint >= 0xff00 && codePoint <= 0xffef || codePoint >= 0x20000 && codePoint <= 0x323af;
6766
+ function work_document_table_row_identity_transactionMapping(transactions) {
6767
+ const mapping = new Mapping();
6768
+ for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
6769
+ return mapping;
8369
6770
  }
8370
- function cssFontFamily(value) {
8371
- return /^(?:-?[\p{L}_])[\p{L}\p{N}_-]*$/u.test(value) ? value : `"${Array.from(value, cssStringCharacter).join('')}"`;
6771
+ const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
6772
+ const documentTextCaseKeyboardShortcuts = {
6773
+ allCaps: 'Mod-Shift-a',
6774
+ smallCaps: 'Mod-Shift-k'
6775
+ };
6776
+ function normalizeDocumentTextCase(value) {
6777
+ return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
8372
6778
  }
8373
- function cssStringCharacter(character) {
8374
- return /[\\":;{}<>]/u.test(character) ? `\\${character.codePointAt(0)?.toString(16)} ` : character;
6779
+ function documentTextCaseFromWordFlags(allCaps, smallCaps) {
6780
+ if (void 0 === allCaps && void 0 === smallCaps) return null;
6781
+ if (allCaps) return 'all-caps';
6782
+ if (smallCaps) return 'small-caps';
6783
+ return 'none';
8375
6784
  }
8376
- function safeCssFontFamilyList(value) {
8377
- if ('string' != typeof value) return null;
8378
- const source = value.trim();
8379
- if (!source || source.length > 1024 || /[;{}]/u.test(source)) return null;
8380
- const tokens = [];
8381
- let start = 0;
8382
- let quote = '';
8383
- for(let index = 0; index < source.length; index += 1){
8384
- const character = source[index] ?? '';
8385
- if (quote) {
8386
- if ('\\' === character) {
8387
- index += 1;
8388
- if (index >= source.length) return null;
8389
- } else if (character === quote) quote = '';
8390
- continue;
8391
- }
8392
- if ('"' === character || "'" === character) {
8393
- quote = character;
8394
- continue;
8395
- }
8396
- if (',' === character) {
8397
- tokens.push(source.slice(start, index).trim());
8398
- start = index + 1;
8399
- }
8400
- }
8401
- if (quote) return null;
8402
- tokens.push(source.slice(start).trim());
8403
- return tokens.length && tokens.every(validCssFontFamilyToken) ? source : null;
8404
- }
8405
- function validCssFontFamilyToken(value) {
8406
- if (!value) return false;
8407
- if (value.startsWith('"')) return /^"(?:[^"\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*"$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
8408
- if (value.startsWith("'")) return /^'(?:[^'\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*'$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
8409
- return /[\p{L}_]/u.test(value) && /^[\p{L}_-][\p{L}\p{N}_ -]*$/u.test(value) && !/^(?:inherit|initial|revert(?:-layer)?|unset)$/iu.test(value);
8410
- }
8411
- function decodeCssEscape(source, start) {
8412
- if (start >= source.length) return null;
8413
- const hexadecimal = /^[\da-f]{1,6}/i.exec(source.slice(start))?.[0];
8414
- if (hexadecimal) {
8415
- const codePoint = Number.parseInt(hexadecimal, 16);
8416
- if (0 === codePoint || codePoint > 0x10ffff || codePoint >= 0xd800 && codePoint <= 0xdfff) return null;
8417
- let end = start + hexadecimal.length;
8418
- if (/\s/u.test(source[end] ?? '')) end += 1;
8419
- return {
8420
- value: String.fromCodePoint(codePoint),
8421
- end
8422
- };
8423
- }
8424
- const value = source[start];
8425
- return !value || /[\r\n\f]/u.test(value) ? null : {
8426
- value,
8427
- end: start + 1
8428
- };
6785
+ function applyDocumentTextCaseStyle(element, textCase) {
6786
+ element.dataset.officeTextCase = textCase;
6787
+ element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
6788
+ element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
8429
6789
  }
8430
- function work_document_script_fonts_isRecordWithKeys(value, allowed) {
8431
- return 'object' == typeof value && null !== value && !Array.isArray(value) && Object.keys(value).every((key)=>allowed.has(key));
6790
+ function documentTextCaseCss(textCase) {
6791
+ return [
6792
+ `text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
6793
+ `font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
6794
+ ].join('; ');
8432
6795
  }
8433
6796
  const workDocumentUnderlineStyles = [
8434
6797
  'none',
@@ -9027,8 +7390,17 @@ function sanitizeAttributes(element, tag) {
9027
7390
  const emphasisMark = 'span' === tag ? documentEmphasisMarkFromElement(element) : null;
9028
7391
  const emphasisAttributes = documentEmphasisMarkDomAttributes(emphasisMark);
9029
7392
  const hiddenText = 'span' === tag ? documentHiddenTextFromElement(element) : null;
7393
+ const proofingLanguages = 'span' === tag ? documentProofingLanguagesFromElement(element) : null;
7394
+ const noProof = 'span' === tag ? documentNoProofFromElement(element) : null;
7395
+ const proofingAttributes = documentProofingDomAttributes(proofingLanguages, noProof, scriptFontSlot);
9030
7396
  const legacyTextEffects = 'span' === tag ? documentLegacyTextEffectsFromElement(element) ?? {} : {};
9031
7397
  const legacyTextEffectAttributes = documentLegacyTextEffectsDomAttributes(legacyTextEffects);
7398
+ const runBorder = 'span' === tag ? parseDocumentRunBorderElement(element) : null;
7399
+ const runBorderAttributes = documentRunBorderDomAttributes(runBorder);
7400
+ const runShading = 'span' === tag ? parseDocumentRunShadingElement(element) : null;
7401
+ const runShadingAttributes = documentRunShadingDomAttributes(runShading);
7402
+ const highlight = 'span' === tag && element.hasAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE) ? documentHighlightFromElement(element) : null;
7403
+ const highlightAttributes = documentHighlightDomAttributes(highlight);
9032
7404
  const underline = 'u' === tag ? documentUnderlineFormattingFromElement(element) : null;
9033
7405
  const underlineAttributes = underline ? documentUnderlineDomAttributes(underline) : {};
9034
7406
  const strike = 's' === tag || 'strike' === tag ? documentStrikeFormattingFromElement(element) : null;
@@ -9055,6 +7427,13 @@ function sanitizeAttributes(element, tag) {
9055
7427
  element.removeAttribute(DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE);
9056
7428
  element.removeAttribute(DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE);
9057
7429
  element.removeAttribute(DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE);
7430
+ element.removeAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE);
7431
+ element.removeAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE);
7432
+ element.removeAttribute(DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE);
7433
+ element.removeAttribute(DOCUMENT_NO_PROOF_ATTRIBUTE);
7434
+ element.removeAttribute('lang');
7435
+ element.removeAttribute('spellcheck');
7436
+ element.removeAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE);
9058
7437
  element.removeAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE);
9059
7438
  element.removeAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE);
9060
7439
  const styles = [
@@ -9070,6 +7449,9 @@ function sanitizeAttributes(element, tag) {
9070
7449
  emphasisAttributes.style ?? '',
9071
7450
  underlineAttributes.style ?? '',
9072
7451
  strikeAttributes.style ?? '',
7452
+ runBorderAttributes.style ?? '',
7453
+ runShadingAttributes.style ?? '',
7454
+ highlightAttributes.style ?? '',
9073
7455
  borderAttributes.style ?? '',
9074
7456
  shadingAttributes.style ?? ''
9075
7457
  ].filter(Boolean);
@@ -9116,7 +7498,16 @@ function sanitizeAttributes(element, tag) {
9116
7498
  if ('span' === tag && null !== kerningThreshold) element.setAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE, String(kerningThreshold));
9117
7499
  if ('span' === tag && null !== emphasisMark) element.setAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE, emphasisMark);
9118
7500
  if ('span' === tag && null !== hiddenText) element.setAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE, String(hiddenText));
9119
- if ('span' === tag) for (const [name, value] of Object.entries(legacyTextEffectAttributes))element.setAttribute(name, value);
7501
+ if ('span' === tag) {
7502
+ for (const [name, value] of Object.entries(legacyTextEffectAttributes))element.setAttribute(name, value);
7503
+ const serializedRunBorder = runBorderAttributes[DOCUMENT_RUN_BORDER_ATTRIBUTE];
7504
+ if (serializedRunBorder) element.setAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE, serializedRunBorder);
7505
+ const serializedRunShading = runShadingAttributes[DOCUMENT_RUN_SHADING_ATTRIBUTE];
7506
+ if (serializedRunShading) element.setAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE, serializedRunShading);
7507
+ for (const [name, value] of Object.entries(proofingAttributes))element.setAttribute(name, value);
7508
+ const nativeHighlight = highlightAttributes[DOCUMENT_HIGHLIGHT_ATTRIBUTE];
7509
+ if (nativeHighlight) element.setAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE, nativeHighlight);
7510
+ }
9120
7511
  if ('span' === tag && scriptFonts) {
9121
7512
  for (const [name, value] of Object.entries(scriptFontAttributes))if ('style' !== name) element.setAttribute(name, value);
9122
7513
  }
@@ -9169,6 +7560,13 @@ function sanitizeAttributes(element, tag) {
9169
7560
  DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE,
9170
7561
  DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE,
9171
7562
  DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE,
7563
+ DOCUMENT_RUN_BORDER_ATTRIBUTE,
7564
+ DOCUMENT_RUN_SHADING_ATTRIBUTE,
7565
+ DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE,
7566
+ DOCUMENT_NO_PROOF_ATTRIBUTE,
7567
+ 'lang',
7568
+ 'spellcheck',
7569
+ DOCUMENT_HIGHLIGHT_ATTRIBUTE,
9172
7570
  DOCUMENT_SCRIPT_FONTS_ATTRIBUTE,
9173
7571
  DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE
9174
7572
  ] : [],
@@ -9515,7 +7913,7 @@ function documentContentLayoutProperties(layout) {
9515
7913
  };
9516
7914
  }
9517
7915
  function normalizeDocumentSemanticHtml(source, bibliography) {
9518
- return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(source))), bibliography)));
7916
+ return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentTableOfContentsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(source)))), bibliography)));
9519
7917
  }
9520
7918
  function applyDocumentSectionDomAttributes(element, layout, id) {
9521
7919
  for (const [name, value] of Object.entries(documentSectionDomAttributes(layout, id)))element.setAttribute(name, value);
@@ -10100,6 +8498,10 @@ const ALLOWED_ATTRIBUTES = {
10100
8498
  'legacyTextShadow',
10101
8499
  'legacyTextEmboss',
10102
8500
  'legacyTextImprint',
8501
+ 'runBorder',
8502
+ 'runShading',
8503
+ 'proofingLanguages',
8504
+ 'noProof',
10103
8505
  "scriptFonts",
10104
8506
  "scriptFontSlot",
10105
8507
  'themeColor',
@@ -10109,6 +8511,7 @@ const ALLOWED_ATTRIBUTES = {
10109
8511
  ]),
10110
8512
  highlight: new Set([
10111
8513
  'color',
8514
+ 'nativeHighlight',
10112
8515
  'themeFill'
10113
8516
  ])
10114
8517
  };
@@ -10195,6 +8598,10 @@ function importedDocumentCharacterFormatting(formatting) {
10195
8598
  legacyTextShadow: formatting.legacyTextShadow,
10196
8599
  legacyTextEmboss: formatting.legacyTextEmboss,
10197
8600
  legacyTextImprint: formatting.legacyTextImprint,
8601
+ runBorder: formatting.runBorder,
8602
+ runShading: formatting.runShading,
8603
+ proofingLanguages: serializeDocumentProofingLanguages(formatting.proofingLanguages) ?? void 0,
8604
+ noProof: formatting.noProof,
10198
8605
  color: formatting.color,
10199
8606
  fontFamily: formatting.fontFamily,
10200
8607
  scriptFonts: serializeDocumentScriptFonts(formatting.scriptFonts) ?? void 0,
@@ -10211,6 +8618,7 @@ function importedDocumentCharacterFormatting(formatting) {
10211
8618
  });
10212
8619
  const highlight = compactAttributes({
10213
8620
  color: formatting.backgroundColor,
8621
+ nativeHighlight: formatting.highlight,
10214
8622
  themeFill: formatting.themeFill
10215
8623
  });
10216
8624
  if (highlight) marks.push({
@@ -10288,6 +8696,36 @@ function normalizeCharacterFormatMark(value) {
10288
8696
  attrs[key] = slot;
10289
8697
  continue;
10290
8698
  }
8699
+ if ('textStyle' === type && 'runBorder' === key) {
8700
+ const border = serializeDocumentRunBorder(parseDocumentRunBorder(candidate));
8701
+ if (!border) return null;
8702
+ attrs[key] = border;
8703
+ continue;
8704
+ }
8705
+ if ('textStyle' === type && 'runShading' === key) {
8706
+ const shading = serializeDocumentRunShading(parseDocumentRunShading(candidate));
8707
+ if (!shading) return null;
8708
+ attrs[key] = shading;
8709
+ continue;
8710
+ }
8711
+ if ('textStyle' === type && 'proofingLanguages' === key) {
8712
+ const languages = serializeDocumentProofingLanguages(parseDocumentProofingLanguages(candidate));
8713
+ if (!languages) return null;
8714
+ attrs[key] = languages;
8715
+ continue;
8716
+ }
8717
+ if ('textStyle' === type && 'noProof' === key) {
8718
+ const noProof = normalizeDocumentNoProof(candidate);
8719
+ if (null === noProof) return null;
8720
+ attrs[key] = noProof;
8721
+ continue;
8722
+ }
8723
+ if ('highlight' === type && 'nativeHighlight' === key) {
8724
+ const highlight = normalizeDocumentHighlight(candidate);
8725
+ if (!highlight) return null;
8726
+ attrs[key] = highlight;
8727
+ continue;
8728
+ }
10291
8729
  if ('string' == typeof candidate) {
10292
8730
  if (!candidate.length) continue;
10293
8731
  if ('textStyle' === type && 'textCase' === key && !normalizeDocumentTextCase(candidate)) return null;
@@ -11231,7 +9669,56 @@ const DocumentCharacterFormatting = Extension.create({
11231
9669
  toggleDocumentTextCase: (textCase)=>({ commands, editor })=>{
11232
9670
  const current = normalizeDocumentTextCase(editor.getAttributes('textStyle').textCase) ?? 'none';
11233
9671
  return commands.setDocumentTextCase(current === textCase ? 'none' : textCase);
11234
- }
9672
+ },
9673
+ setDocumentRunBorder: (border)=>({ commands })=>{
9674
+ const serialized = serializeDocumentRunBorder(normalizeDocumentRunBorder(border));
9675
+ return serialized ? commands.setMark('textStyle', {
9676
+ runBorder: serialized
9677
+ }) : false;
9678
+ },
9679
+ unsetDocumentRunBorder: ()=>({ chain })=>chain().setMark('textStyle', {
9680
+ runBorder: null
9681
+ }).removeEmptyTextStyle().run(),
9682
+ toggleDocumentRunBorder: ()=>({ commands, editor })=>{
9683
+ const current = parseDocumentRunBorder(editor.getAttributes('textStyle').runBorder);
9684
+ return commands.setDocumentRunBorder(documentRunBorderIsVisible(current) ? {
9685
+ style: 'nil'
9686
+ } : {
9687
+ style: 'single',
9688
+ color: {
9689
+ value: 'auto'
9690
+ },
9691
+ size: 4,
9692
+ space: 1
9693
+ });
9694
+ },
9695
+ setDocumentRunShading: (shading)=>({ commands })=>{
9696
+ const serialized = serializeDocumentRunShading(normalizeDocumentRunShading(shading));
9697
+ return serialized ? commands.setMark('textStyle', {
9698
+ runShading: serialized
9699
+ }) : false;
9700
+ },
9701
+ unsetDocumentRunShading: ()=>({ chain })=>chain().setMark('textStyle', {
9702
+ runShading: null
9703
+ }).removeEmptyTextStyle().run(),
9704
+ setDocumentProofingLanguages: (languages)=>({ commands })=>{
9705
+ const serialized = serializeDocumentProofingLanguages(normalizeDocumentProofingLanguages(languages));
9706
+ return serialized ? commands.setMark('textStyle', {
9707
+ proofingLanguages: serialized
9708
+ }) : false;
9709
+ },
9710
+ unsetDocumentProofingLanguages: ()=>({ chain })=>chain().setMark('textStyle', {
9711
+ proofingLanguages: null
9712
+ }).removeEmptyTextStyle().run(),
9713
+ setDocumentNoProof: (noProof)=>({ commands })=>{
9714
+ const normalized = normalizeDocumentNoProof(noProof);
9715
+ return null === normalized ? false : commands.setMark('textStyle', {
9716
+ noProof: normalized
9717
+ });
9718
+ },
9719
+ unsetDocumentNoProof: ()=>({ chain })=>chain().setMark('textStyle', {
9720
+ noProof: null
9721
+ }).removeEmptyTextStyle().run()
11235
9722
  };
11236
9723
  },
11237
9724
  addKeyboardShortcuts () {
@@ -15970,7 +14457,7 @@ function documentTextParagraphStyle(style) {
15970
14457
  function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, element, paragraphRoot) {
15971
14458
  const direction = 'rtl' === style.direction ? 'rtl' : 'ltr';
15972
14459
  const whiteSpace = 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal';
15973
- if (direction !== paragraphStyle.direction || whiteSpace !== paragraphStyle.whiteSpace || !cssValueIs(style.whiteSpace, 'normal', 'break-spaces') || !cssValueIs(style.overflowWrap, 'normal', 'anywhere', 'break-word') || !cssValueIs(style.wordBreak, 'normal') || !cssValueIs(style.hyphens, 'manual', 'none') || !cssValueIs(style.wordSpacing, 'normal', '0', '0px') || !cssValueIs(style.textTransform, 'none') || !cssValueIs(style.fontVariationSettings, 'normal') || !cssValueIs(style.fontVariantCaps, 'normal') || !cssValueIs(style.fontVariantEastAsian, 'normal') || !cssValueIs(style.fontVariantNumeric, 'normal') || !cssValueIs(style.fontVariantPosition, 'normal') || !cssValueIs(style.fontStretch, 'normal', '100%') || !documentTextEmphasisAllowsKernel(style, element) || !cssValueIs(style.verticalAlign, 'baseline') || !cssValueIs(style.unicodeBidi, 'normal') && !(paragraphRoot && 'isolate' === style.unicodeBidi)) return null;
14460
+ if (direction !== paragraphStyle.direction || whiteSpace !== paragraphStyle.whiteSpace || !cssValueIs(style.whiteSpace, 'normal', 'break-spaces') || !cssValueIs(style.overflowWrap, 'normal', 'anywhere', 'break-word') || !cssValueIs(style.wordBreak, 'normal') || !cssValueIs(style.hyphens, 'manual', 'none') || !cssValueIs(style.wordSpacing, 'normal', '0', '0px') || !cssValueIs(style.textTransform, 'none') || !cssValueIs(style.fontVariationSettings, 'normal') || !cssValueIs(style.fontVariantCaps, 'normal') || !cssValueIs(style.fontVariantEastAsian, 'normal') || !cssValueIs(style.fontVariantNumeric, 'normal') || !cssValueIs(style.fontVariantPosition, 'normal') || !cssValueIs(style.fontStretch, 'normal', '100%') || !documentTextEmphasisAllowsKernel(style, element) || !documentRunBorderAllowsKernel(element) || !cssValueIs(style.verticalAlign, 'baseline') || !cssValueIs(style.unicodeBidi, 'normal') && !(paragraphRoot && 'isolate' === style.unicodeBidi)) return null;
15974
14461
  const fontStyle = style.fontStyle && 'normal' !== style.fontStyle ? 'italic' === style.fontStyle ? 'italic' : null : 'normal';
15975
14462
  if (!fontStyle) return null;
15976
14463
  const families = cssFontFamilies(style.fontFamily);
@@ -15994,6 +14481,8 @@ function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle,
15994
14481
  if (null === ligatures || null === kerning) return null;
15995
14482
  const letterSpacing = style.letterSpacing && 'normal' !== style.letterSpacing ? finitePixels(style.letterSpacing) : 0;
15996
14483
  if (letterSpacing < -100 || letterSpacing > 100) return null;
14484
+ const language = documentTextLayoutLanguage(element);
14485
+ if (null === language) return null;
15997
14486
  return {
15998
14487
  fontId: font.id,
15999
14488
  ...fallbackFonts.length ? {
@@ -16001,6 +14490,9 @@ function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle,
16001
14490
  } : {},
16002
14491
  fontSize,
16003
14492
  lineHeight,
14493
+ ...language ? {
14494
+ language
14495
+ } : {},
16004
14496
  letterSpacing,
16005
14497
  ligatures,
16006
14498
  kerning
@@ -16035,11 +14527,20 @@ function documentTextLayoutRunStyleKey(style) {
16035
14527
  (style.fallbackFontIds ?? []).join('\u0002'),
16036
14528
  style.fontSize,
16037
14529
  style.lineHeight,
14530
+ style.language ?? '',
16038
14531
  style.letterSpacing ?? 0,
16039
14532
  style.ligatures ?? true,
16040
14533
  style.kerning ?? true
16041
14534
  ].join('\u0000');
16042
14535
  }
14536
+ function documentTextLayoutLanguage(element) {
14537
+ for(let current = element; current; current = current.parentElement){
14538
+ if (!current.hasAttribute('lang')) continue;
14539
+ const source = current.getAttribute('lang') ?? '';
14540
+ if (!source) break;
14541
+ return normalizeDocumentLanguageTag(source);
14542
+ }
14543
+ }
16043
14544
  function cssValueIs(value, ...supported) {
16044
14545
  return !value || supported.includes(value);
16045
14546
  }
@@ -16056,6 +14557,10 @@ function documentTextEmphasisAllowsKernel(style, element) {
16056
14557
  const webkit = style.getPropertyValue('-webkit-text-emphasis-style').trim();
16057
14558
  return (!standard || 'none' === standard) && (!webkit || 'none' === webkit);
16058
14559
  }
14560
+ function documentRunBorderAllowsKernel(element) {
14561
+ for(let current = element; current; current = current.parentElement)if (current.hasAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE)) return !documentRunBorderIsVisible(parseDocumentRunBorder(current.getAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE)));
14562
+ return true;
14563
+ }
16059
14564
  function cssLigatures(style) {
16060
14565
  const variant = style.fontVariantLigatures;
16061
14566
  if (variant && 'normal' !== variant && 'none' !== variant) return null;
@@ -17622,7 +16127,23 @@ const DocumentTextStyle = TextStyle.extend({
17622
16127
  ].map((attribute)=>({
17623
16128
  tag: `span[${attribute}]`,
17624
16129
  consuming: false
17625
- }))
16130
+ })),
16131
+ {
16132
+ tag: `span[${DOCUMENT_RUN_BORDER_ATTRIBUTE}]`,
16133
+ consuming: false
16134
+ },
16135
+ {
16136
+ tag: `span[${DOCUMENT_RUN_SHADING_ATTRIBUTE}]`,
16137
+ consuming: false
16138
+ },
16139
+ {
16140
+ tag: `span[${DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE}]`,
16141
+ consuming: false
16142
+ },
16143
+ {
16144
+ tag: `span[${DOCUMENT_NO_PROOF_ATTRIBUTE}]`,
16145
+ consuming: false
16146
+ }
17626
16147
  ];
17627
16148
  },
17628
16149
  addCommands () {
@@ -17671,6 +16192,26 @@ const DocumentTextStyle = TextStyle.extend({
17671
16192
  legacyTextShadow: legacyTextEffectAttribute('shadow'),
17672
16193
  legacyTextEmboss: legacyTextEffectAttribute('emboss'),
17673
16194
  legacyTextImprint: legacyTextEffectAttribute('imprint'),
16195
+ runBorder: {
16196
+ default: null,
16197
+ parseHTML: (element)=>serializeDocumentRunBorder(parseDocumentRunBorderElement(element)) ?? null,
16198
+ renderHTML: (attributes)=>documentRunBorderDomAttributes(parseDocumentRunBorder(attributes.runBorder))
16199
+ },
16200
+ runShading: {
16201
+ default: null,
16202
+ parseHTML: (element)=>serializeDocumentRunShading(parseDocumentRunShadingElement(element)) ?? null,
16203
+ renderHTML: (attributes)=>documentRunShadingDomAttributes(parseDocumentRunShading(attributes.runShading))
16204
+ },
16205
+ proofingLanguages: {
16206
+ default: null,
16207
+ parseHTML: (element)=>serializeDocumentProofingLanguages(parseDocumentProofingLanguages(element.getAttribute(DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE))) ?? null,
16208
+ renderHTML: (attributes)=>documentProofingDomAttributes(parseDocumentProofingLanguages(attributes.proofingLanguages), attributes.noProof, normalizeDocumentScriptFontSlot(attributes.scriptFontSlot))
16209
+ },
16210
+ noProof: {
16211
+ default: null,
16212
+ parseHTML: (element)=>normalizeDocumentNoProof(element.getAttribute(DOCUMENT_NO_PROOF_ATTRIBUTE)),
16213
+ renderHTML: (attributes)=>documentProofingDomAttributes(parseDocumentProofingLanguages(attributes.proofingLanguages), attributes.noProof, normalizeDocumentScriptFontSlot(attributes.scriptFontSlot))
16214
+ },
17674
16215
  kerningThresholdHalfPoints: {
17675
16216
  default: null,
17676
16217
  parseHTML: (element)=>documentKerningThresholdHalfPointsFromElement(element),
@@ -17747,19 +16288,51 @@ const DocumentHighlight = extension_highlight.extend({
17747
16288
  return {};
17748
16289
  },
17749
16290
  addAttributes () {
16291
+ const parent = this.parent?.() ?? {};
17750
16292
  return {
17751
- ...this.parent?.(),
16293
+ ...parent,
16294
+ color: {
16295
+ ...parent.color ?? {},
16296
+ renderHTML: (attributes)=>{
16297
+ const color = 'string' == typeof attributes.color ? attributes.color : null;
16298
+ if (!color) return {};
16299
+ const native = normalizeDocumentHighlight(attributes.nativeHighlight) ?? documentHighlightForCssColor(color);
16300
+ return {
16301
+ 'data-color': color,
16302
+ ...native ? {
16303
+ [DOCUMENT_HIGHLIGHT_ATTRIBUTE]: native
16304
+ } : {},
16305
+ style: `background-color: ${color}; color: inherit`
16306
+ };
16307
+ }
16308
+ },
16309
+ nativeHighlight: {
16310
+ default: null,
16311
+ parseHTML: (element)=>normalizeDocumentHighlight(element.getAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE)),
16312
+ renderHTML: (attributes)=>{
16313
+ const value = normalizeDocumentHighlight(attributes.nativeHighlight);
16314
+ return value ? {
16315
+ [DOCUMENT_HIGHLIGHT_ATTRIBUTE]: value
16316
+ } : {};
16317
+ }
16318
+ },
17752
16319
  themeFill: themeReferenceAttribute('officeThemeFill')
17753
16320
  };
17754
16321
  },
17755
16322
  parseHTML () {
16323
+ const excludesRunShading = (element)=>element.hasAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE) && !element.hasAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE) ? false : null;
17756
16324
  return [
17757
16325
  ...this.parent?.() ?? [],
17758
16326
  {
17759
- tag: 'span[data-office-theme-fill]'
16327
+ tag: `span[${DOCUMENT_HIGHLIGHT_ATTRIBUTE}]`
16328
+ },
16329
+ {
16330
+ tag: 'span[data-office-theme-fill]',
16331
+ getAttrs: excludesRunShading
17760
16332
  },
17761
16333
  {
17762
- tag: 'span[style*="background-color"]'
16334
+ tag: 'span[style*="background-color"]',
16335
+ getAttrs: excludesRunShading
17763
16336
  }
17764
16337
  ];
17765
16338
  }
@@ -18101,6 +16674,302 @@ function documentTabLeaderLabel(leader) {
18101
16674
  if ('middleDot' === leader) return '居中点前导符';
18102
16675
  return '无前导符';
18103
16676
  }
16677
+ const DocumentTableOfContents = core_Node.create({
16678
+ name: 'documentTableOfContents',
16679
+ group: 'block',
16680
+ atom: true,
16681
+ selectable: true,
16682
+ draggable: false,
16683
+ addCommands () {
16684
+ return {
16685
+ insertDocumentTableOfContents: (options = DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, buildOptions)=>(props)=>insertDocumentTableOfContentsCommand(props, options, buildOptions),
16686
+ updateDocumentTableOfContents: (options, buildOptions)=>(props)=>updateDocumentTableOfContentsCommand(props, options, buildOptions),
16687
+ refreshDocumentTablesOfContents: (buildOptions)=>(props)=>refreshDocumentTablesOfContentsCommand(props, buildOptions)
16688
+ };
16689
+ },
16690
+ addAttributes () {
16691
+ return {
16692
+ id: work_document_table_of_contents_node_hiddenAttribute(''),
16693
+ minLevel: work_document_table_of_contents_node_hiddenAttribute(1),
16694
+ maxLevel: work_document_table_of_contents_node_hiddenAttribute(3),
16695
+ hyperlinks: work_document_table_of_contents_node_hiddenAttribute(true),
16696
+ showPageNumbers: work_document_table_of_contents_node_hiddenAttribute(true),
16697
+ rightAlignPageNumbers: work_document_table_of_contents_node_hiddenAttribute(true),
16698
+ leader: work_document_table_of_contents_node_hiddenAttribute('dot'),
16699
+ entries: work_document_table_of_contents_node_hiddenAttribute([]),
16700
+ truncated: work_document_table_of_contents_node_hiddenAttribute(false)
16701
+ };
16702
+ },
16703
+ parseHTML () {
16704
+ return [
16705
+ {
16706
+ tag: 'div[data-document-table-of-contents]',
16707
+ getAttrs: (node)=>{
16708
+ if (!(node instanceof HTMLElement)) return false;
16709
+ return tableOfContentsNodeAttributes(documentTableOfContentsValueFromElement(node));
16710
+ }
16711
+ }
16712
+ ];
16713
+ },
16714
+ renderHTML ({ node, HTMLAttributes }) {
16715
+ const value = normalizeDocumentTableOfContentsValue({
16716
+ id: work_document_table_of_contents_node_stringAttribute(node.attrs.id) || 'document-table-of-contents',
16717
+ options: tableOfContentsOptionsFromAttributes(node.attrs),
16718
+ entries: Array.isArray(node.attrs.entries) ? node.attrs.entries : [],
16719
+ truncated: Boolean(node.attrs.truncated)
16720
+ });
16721
+ const options = value.options;
16722
+ const rows = value.entries.length ? value.entries.map((entry)=>tableOfContentsEntrySpec(entry, options)) : [
16723
+ [
16724
+ 'li',
16725
+ {
16726
+ class: 'work-document-table-of-contents-empty'
16727
+ },
16728
+ '没有符合级别范围的标题'
16729
+ ]
16730
+ ];
16731
+ return [
16732
+ 'div',
16733
+ mergeAttributes(HTMLAttributes, {
16734
+ 'data-document-table-of-contents': 'true',
16735
+ 'data-toc-id': value.id,
16736
+ 'data-toc-min-level': String(options.minLevel),
16737
+ 'data-toc-max-level': String(options.maxLevel),
16738
+ 'data-toc-hyperlinks': String(options.hyperlinks),
16739
+ 'data-toc-show-page-numbers': String(options.showPageNumbers),
16740
+ 'data-toc-right-align-page-numbers': String(options.rightAlignPageNumbers),
16741
+ 'data-toc-leader': options.leader,
16742
+ 'data-toc-entries': JSON.stringify(value.entries),
16743
+ 'data-toc-truncated': String(value.truncated),
16744
+ class: 'work-document-table-of-contents',
16745
+ contenteditable: 'false',
16746
+ 'aria-label': '目录'
16747
+ }),
16748
+ [
16749
+ 'div',
16750
+ {
16751
+ class: 'work-document-table-of-contents-header'
16752
+ },
16753
+ [
16754
+ 'strong',
16755
+ '目录'
16756
+ ],
16757
+ [
16758
+ 'span',
16759
+ value.truncated ? '仅显示前 512 项' : `${value.entries.length} 项`
16760
+ ]
16761
+ ],
16762
+ [
16763
+ 'ol',
16764
+ {
16765
+ class: 'work-document-table-of-contents-list'
16766
+ },
16767
+ ...rows
16768
+ ]
16769
+ ];
16770
+ },
16771
+ renderText ({ node }) {
16772
+ const entries = Array.isArray(node.attrs.entries) ? node.attrs.entries : [];
16773
+ return entries.map((entry)=>entry.title).join('\n');
16774
+ },
16775
+ addProseMirrorPlugins () {
16776
+ return [
16777
+ new Plugin({
16778
+ props: {
16779
+ handleDOMEvents: {
16780
+ click: (view, event)=>{
16781
+ if (!(event.target instanceof Element)) return false;
16782
+ const table = event.target.closest('[data-document-table-of-contents][data-toc-hyperlinks="true"]');
16783
+ if (!table) return false;
16784
+ const link = event.target.closest('[data-toc-target]');
16785
+ if (!link || !table.contains(link)) return false;
16786
+ const targetId = link.dataset.tocTarget?.trim();
16787
+ if (!targetId) return false;
16788
+ const target = collectWorkDocumentOutline(view.state.doc).find((item)=>item.id === targetId);
16789
+ if (!target) return false;
16790
+ event.preventDefault();
16791
+ view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(target.from))).scrollIntoView());
16792
+ view.focus();
16793
+ return true;
16794
+ }
16795
+ }
16796
+ }
16797
+ })
16798
+ ];
16799
+ }
16800
+ });
16801
+ function selectedDocumentTableOfContentsOptions(editor) {
16802
+ const selection = editor.state.selection;
16803
+ if (!(selection instanceof NodeSelection) || 'documentTableOfContents' !== selection.node.type.name) return null;
16804
+ return tableOfContentsOptionsFromAttributes(selection.node.attrs);
16805
+ }
16806
+ function documentHasTableOfContents(editor) {
16807
+ let found = false;
16808
+ editor.state.doc.descendants((node)=>{
16809
+ if ('documentTableOfContents' === node.type.name) found = true;
16810
+ return !found;
16811
+ });
16812
+ return found;
16813
+ }
16814
+ function insertDocumentTableOfContentsCommand({ dispatch, editor, tr }, source, buildOptions = {}) {
16815
+ const nodeType = editor.schema.nodes.documentTableOfContents;
16816
+ if (!nodeType) return false;
16817
+ if (!dispatch) return true;
16818
+ const options = normalizeDocumentTableOfContentsOptions(source);
16819
+ ensureTableOfContentsHeadingIdentities(tr, [
16820
+ options
16821
+ ]);
16822
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
16823
+ tr.replaceSelectionWith(nodeType.create({
16824
+ id: createWorkId('toc'),
16825
+ ...options,
16826
+ ...built
16827
+ }), false);
16828
+ tr.scrollIntoView();
16829
+ return true;
16830
+ }
16831
+ function updateDocumentTableOfContentsCommand({ dispatch, state, tr }, source, buildOptions = {}) {
16832
+ const selection = state.selection;
16833
+ if (!(selection instanceof NodeSelection) || 'documentTableOfContents' !== selection.node.type.name) return false;
16834
+ if (!dispatch) return true;
16835
+ const options = normalizeDocumentTableOfContentsOptions(source);
16836
+ ensureTableOfContentsHeadingIdentities(tr, [
16837
+ options
16838
+ ]);
16839
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
16840
+ tr.setNodeMarkup(selection.from, void 0, {
16841
+ ...selection.node.attrs,
16842
+ ...options,
16843
+ ...built
16844
+ });
16845
+ tr.scrollIntoView();
16846
+ return tr.docChanged;
16847
+ }
16848
+ function refreshDocumentTablesOfContentsCommand({ dispatch, state, tr }, buildOptions = {}) {
16849
+ const tableOptions = [];
16850
+ state.doc.descendants((node)=>{
16851
+ if ('documentTableOfContents' === node.type.name) tableOptions.push(tableOfContentsOptionsFromAttributes(node.attrs));
16852
+ });
16853
+ if (!tableOptions.length) return false;
16854
+ ensureTableOfContentsHeadingIdentities(tr, tableOptions);
16855
+ const updates = [];
16856
+ tr.doc.descendants((node, position)=>{
16857
+ if ('documentTableOfContents' !== node.type.name) return;
16858
+ const options = tableOfContentsOptionsFromAttributes(node.attrs);
16859
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
16860
+ if (JSON.stringify(node.attrs.entries) === JSON.stringify(built.entries) && Boolean(node.attrs.truncated) === built.truncated) return;
16861
+ updates.push({
16862
+ position,
16863
+ attrs: {
16864
+ ...node.attrs,
16865
+ ...options,
16866
+ ...built
16867
+ }
16868
+ });
16869
+ });
16870
+ if (!updates.length) return false;
16871
+ if (!dispatch) return true;
16872
+ for (const update of updates)tr.setNodeMarkup(update.position, void 0, update.attrs);
16873
+ tr.scrollIntoView();
16874
+ return tr.docChanged;
16875
+ }
16876
+ function ensureTableOfContentsHeadingIdentities(transaction, tableOptions) {
16877
+ const paragraphIdCounts = new Map();
16878
+ transaction.doc.descendants((node)=>{
16879
+ const paragraphId = normalizeDocumentParagraphId(node.attrs.paragraphId);
16880
+ if (!paragraphId) return;
16881
+ paragraphIdCounts.set(paragraphId, (paragraphIdCounts.get(paragraphId) ?? 0) + 1);
16882
+ });
16883
+ const registry = createDocumentParagraphIdentityRegistry();
16884
+ for (const paragraphId of paragraphIdCounts.keys())registry.paragraphIds.add(paragraphId);
16885
+ const updates = [];
16886
+ transaction.doc.descendants((node, position)=>{
16887
+ const level = workDocumentOutlineLevel(node);
16888
+ if (null === level || !tableOptions.some((options)=>level >= options.minLevel && level <= options.maxLevel)) return;
16889
+ const paragraphId = normalizeDocumentParagraphId(node.attrs.paragraphId);
16890
+ const textId = normalizeDocumentParagraphId(node.attrs.textId);
16891
+ let identity;
16892
+ identity = paragraphId && 1 === paragraphIdCounts.get(paragraphId) ? {
16893
+ paragraphId,
16894
+ textId: textId ?? createDocumentParagraphIdentity().textId
16895
+ } : uniqueDocumentParagraphIdentity({}, registry);
16896
+ if (paragraphId === identity.paragraphId && textId === identity.textId) return;
16897
+ updates.push({
16898
+ attrs: node.attrs,
16899
+ identity,
16900
+ position
16901
+ });
16902
+ });
16903
+ for (const update of updates)transaction.setNodeMarkup(update.position, void 0, {
16904
+ ...update.attrs,
16905
+ ...update.identity
16906
+ });
16907
+ }
16908
+ function tableOfContentsOptionsFromAttributes(attrs) {
16909
+ return normalizeDocumentTableOfContentsOptions({
16910
+ minLevel: Number(attrs.minLevel),
16911
+ maxLevel: Number(attrs.maxLevel),
16912
+ hyperlinks: Boolean(attrs.hyperlinks),
16913
+ showPageNumbers: Boolean(attrs.showPageNumbers),
16914
+ rightAlignPageNumbers: Boolean(attrs.rightAlignPageNumbers),
16915
+ leader: 'string' == typeof attrs.leader ? attrs.leader : 'dot'
16916
+ });
16917
+ }
16918
+ function tableOfContentsNodeAttributes(value) {
16919
+ return {
16920
+ id: value.id,
16921
+ ...value.options,
16922
+ entries: value.entries,
16923
+ truncated: value.truncated
16924
+ };
16925
+ }
16926
+ function tableOfContentsEntrySpec(entry, options) {
16927
+ const title = options.hyperlinks ? [
16928
+ 'a',
16929
+ {
16930
+ href: `#${entry.targetId}`,
16931
+ 'data-toc-target': entry.targetId,
16932
+ tabindex: '-1'
16933
+ },
16934
+ entry.title
16935
+ ] : [
16936
+ 'span',
16937
+ entry.title
16938
+ ];
16939
+ return [
16940
+ 'li',
16941
+ {
16942
+ 'data-toc-target': entry.targetId,
16943
+ 'data-toc-level': String(entry.level),
16944
+ style: `--work-toc-level:${entry.level}`
16945
+ },
16946
+ title,
16947
+ [
16948
+ 'i',
16949
+ {
16950
+ 'aria-hidden': 'true'
16951
+ }
16952
+ ],
16953
+ ...options.showPageNumbers ? [
16954
+ [
16955
+ 'span',
16956
+ {
16957
+ class: 'work-document-table-of-contents-page'
16958
+ },
16959
+ String(entry.pageNumber)
16960
+ ]
16961
+ ] : []
16962
+ ];
16963
+ }
16964
+ function work_document_table_of_contents_node_hiddenAttribute(defaultValue) {
16965
+ return {
16966
+ default: defaultValue,
16967
+ rendered: false
16968
+ };
16969
+ }
16970
+ function work_document_table_of_contents_node_stringAttribute(value) {
16971
+ return 'string' == typeof value ? value.trim() : '';
16972
+ }
18104
16973
  const BORDER_EDGES = [
18105
16974
  'top',
18106
16975
  'right',
@@ -20007,6 +18876,7 @@ function createWorkDocumentExtensions(options = {}) {
20007
18876
  DocumentCrossReference,
20008
18877
  citationExtension,
20009
18878
  DocumentBibliography,
18879
+ DocumentTableOfContents,
20010
18880
  DocumentField,
20011
18881
  DocumentEquation,
20012
18882
  commentExtension,
@@ -21866,4 +20736,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
21866
20736
  function documentPageSurfaceGeometryForElement(element) {
21867
20737
  return documentPageSurfaceProviders.get(element)?.() ?? null;
21868
20738
  }
21869
- export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_BORDER_EDGES, DOCUMENT_PARAGRAPH_BORDER_STYLES, DOCUMENT_PARAGRAPH_SHADING_PATTERNS, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentImage, DocumentParagraphFormatting, DocumentParagraphIdentity, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, DocxThemePatchCollector, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentParagraphIdentityToElement, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createDocumentParagraphIdentityRegistry, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, cssDocumentFontFamily, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentFontNameFromCssFamily, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphBordersDomAttributes, documentParagraphDirection, documentParagraphIdentityFromElement, documentParagraphIndent, documentParagraphPagination, documentParagraphShadingDomAttributes, documentParagraphSpacing, documentParagraphTabStops, documentScriptFontDirectFamily, documentScriptFontFallbackSlots, documentScriptFontFamily, documentScriptFontFamilyForRendering, documentScriptFontSegments, documentScriptFontSlotFromElement, documentScriptFontSlotFromHint, documentScriptFontsDomAttributes, documentScriptFontsFromElement, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentParagraphArtBorderStyle, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentFontName, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphBorder, normalizeDocumentParagraphBorders, normalizeDocumentParagraphId, normalizeDocumentParagraphIdentity, normalizeDocumentParagraphIndent, normalizeDocumentScriptFontHint, normalizeDocumentScriptFontSlot, normalizeDocumentScriptFonts, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentThemeFont, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphBordersElement, parseDocumentParagraphFormatting, parseDocumentParagraphShadingElement, parseDocumentScriptFonts, parseDocxThemeReference, patchDocumentLazyHtmlProjection, patchDocumentScriptFonts, patchDocxThemeReferences, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, serializeDocumentParagraphFormatting, serializeDocumentScriptFonts, serializeDocumentTabStops, serializeDocxThemeReference, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, uniqueDocumentParagraphIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_page_margins_twipsToMillimeters, wrapsBesideImage };
20739
+ export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentHighlight, DocumentImage, DocumentParagraphFormatting, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentHasTableOfContents, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphDirection, documentParagraphIndent, documentParagraphPagination, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphIndent, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphFormatting, patchDocumentLazyHtmlProjection, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, selectedDocumentTableOfContentsOptions, serializeDocumentParagraphFormatting, serializeDocumentTabStops, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_page_margins_twipsToMillimeters, wrapsBesideImage };