@a3s-lab/office 0.25.0 → 0.27.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 (93) hide show
  1. package/README.md +76 -2
  2. package/dist/0~4595.js +16 -2
  3. package/dist/0~5093.js +463 -201
  4. package/dist/0~6090.js +77 -77
  5. package/dist/{0~2805.js → 0~7043.js} +305 -2
  6. package/dist/0~document-editor.js +2451 -985
  7. package/dist/0~spreadsheet-editor.js +22113 -20117
  8. package/dist/0~work-docx-export.js +492 -10
  9. package/dist/0~work-docx-import.js +171 -98
  10. package/dist/0~work-office-diagnostics.js +198 -4
  11. package/dist/{164.js → 1544.js} +1412 -1055
  12. package/dist/4104.js +145 -29
  13. package/dist/6282.js +1920 -544
  14. package/dist/9424.js +16 -0
  15. package/dist/core.js +1 -1
  16. package/dist/index.js +1 -1
  17. package/dist/internal/features/work/editors/document-command-catalog.d.ts +102 -0
  18. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +83 -0
  19. package/dist/internal/features/work/editors/document-font-dialog-script-font-model.d.ts +18 -0
  20. package/dist/internal/features/work/editors/document-font-dialog.d.ts +9 -0
  21. package/dist/internal/features/work/editors/document-home-ribbon.d.ts +2 -1
  22. package/dist/internal/features/work/editors/document-page-chrome-editor.d.ts +6 -0
  23. package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
  24. package/dist/internal/features/work/editors/document-strike-ribbon.d.ts +7 -0
  25. package/dist/internal/features/work/editors/document-text-case-ribbon.d.ts +4 -0
  26. package/dist/internal/features/work/editors/document-toolbar.d.ts +3 -1
  27. package/dist/internal/features/work/editors/document-underline-ribbon.d.ts +9 -0
  28. package/dist/internal/features/work/editors/document-wps-shortcuts.d.ts +1 -0
  29. package/dist/internal/features/work/editors/spreadsheet-cell-fill-format.d.ts +11 -0
  30. package/dist/internal/features/work/editors/spreadsheet-cell-format.d.ts +2 -1
  31. package/dist/internal/features/work/editors/spreadsheet-command-controller.d.ts +18 -9
  32. package/dist/internal/features/work/editors/spreadsheet-format-cells-dialog-model.d.ts +13 -2
  33. package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-panel.d.ts +13 -0
  34. package/dist/internal/features/work/editors/spreadsheet-format-cells-fill-preview.d.ts +6 -0
  35. package/dist/internal/features/work/editors/spreadsheet-format-painter.d.ts +1 -1
  36. package/dist/internal/features/work/editors/spreadsheet-operation-projection.d.ts +6 -0
  37. package/dist/internal/features/work/editors/spreadsheet-rich-text-dom-selection.d.ts +11 -0
  38. package/dist/internal/features/work/editors/spreadsheet-rich-text-paste.d.ts +22 -0
  39. package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-controller.d.ts +38 -0
  40. package/dist/internal/features/work/editors/spreadsheet-rich-text-selection-format.d.ts +26 -0
  41. package/dist/internal/features/work/editors/work-office-chrome.d.ts +9 -1
  42. package/dist/internal/features/work/work-css-color.d.ts +1 -0
  43. package/dist/internal/features/work/work-document-character-formatting.d.ts +16 -1
  44. package/dist/internal/features/work/work-document-character-position.d.ts +9 -0
  45. package/dist/internal/features/work/work-document-character-scale.d.ts +8 -0
  46. package/dist/internal/features/work/work-document-character-spacing.d.ts +8 -0
  47. package/dist/internal/features/work/work-document-emphasis.d.ts +7 -0
  48. package/dist/internal/features/work/work-document-equations.d.ts +2 -1
  49. package/dist/internal/features/work/work-document-format-changes.d.ts +16 -2
  50. package/dist/internal/features/work/work-document-hidden-text.d.ts +5 -0
  51. package/dist/internal/features/work/work-document-kerning.d.ts +10 -0
  52. package/dist/internal/features/work/work-document-paragraph-shading.d.ts +1 -1
  53. package/dist/internal/features/work/work-document-script-font-extension.d.ts +2 -0
  54. package/dist/internal/features/work/work-document-script-fonts.d.ts +51 -0
  55. package/dist/internal/features/work/work-document-strike.d.ts +21 -0
  56. package/dist/internal/features/work/work-document-text-case.d.ts +10 -0
  57. package/dist/internal/features/work/work-document-underline.d.ts +37 -0
  58. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +12 -0
  59. package/dist/internal/features/work/work-docx-character-position.d.ts +2 -0
  60. package/dist/internal/features/work/work-docx-character-scale.d.ts +2 -0
  61. package/dist/internal/features/work/work-docx-character-spacing.d.ts +4 -0
  62. package/dist/internal/features/work/work-docx-emphasis-diagnostics.d.ts +3 -0
  63. package/dist/internal/features/work/work-docx-emphasis.d.ts +14 -0
  64. package/dist/internal/features/work/work-docx-hidden-text-diagnostics.d.ts +3 -0
  65. package/dist/internal/features/work/work-docx-hidden-text-export.d.ts +16 -0
  66. package/dist/internal/features/work/work-docx-hidden-text.d.ts +11 -0
  67. package/dist/internal/features/work/work-docx-kerning-diagnostics.d.ts +3 -0
  68. package/dist/internal/features/work/work-docx-kerning.d.ts +14 -0
  69. package/dist/internal/features/work/work-docx-run-fonts-diagnostics.d.ts +3 -0
  70. package/dist/internal/features/work/work-docx-run-fonts-export.d.ts +14 -0
  71. package/dist/internal/features/work/work-docx-run-fonts.d.ts +13 -0
  72. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +23 -2
  73. package/dist/internal/features/work/work-docx-run-script-font-import.d.ts +9 -0
  74. package/dist/internal/features/work/work-docx-strike.d.ts +8 -0
  75. package/dist/internal/features/work/work-docx-theme-reference.d.ts +1 -1
  76. package/dist/internal/features/work/work-docx-twips.d.ts +6 -0
  77. package/dist/internal/features/work/work-docx-underline.d.ts +3 -0
  78. package/dist/internal/features/work/work-spreadsheet-gradient-fill-canvas.d.ts +10 -0
  79. package/dist/internal/features/work/work-spreadsheet-native-fill-canvas.d.ts +8 -0
  80. package/dist/internal/features/work/work-spreadsheet-pattern-fill-canvas.d.ts +8 -0
  81. package/dist/internal/features/work/work-xlsx-cell-style-origin.d.ts +2 -1
  82. package/dist/internal/features/work/work-xlsx-cell-style-writer.d.ts +3 -0
  83. package/dist/internal/features/work/work-xlsx-cell-styles.d.ts +4 -0
  84. package/dist/internal/features/work/work-xlsx-gradient-fill.d.ts +31 -0
  85. package/dist/internal/features/work/work-xlsx-native-fill.d.ts +17 -0
  86. package/dist/internal/features/work/work-xlsx-pattern-fill.d.ts +21 -0
  87. package/dist/internal/features/work/work-xlsx-rich-text-edit.d.ts +28 -0
  88. package/dist/internal/features/work/work-xlsx-rich-text-model.d.ts +40 -0
  89. package/dist/internal/features/work/work-xlsx-rich-text.d.ts +4 -18
  90. package/dist/office-kernel.wasm +0 -0
  91. package/dist/styles.css +770 -80
  92. package/docs/latest/en/browser-editor-architecture.md +37 -0
  93. package/package.json +32 -1
package/dist/6282.js CHANGED
@@ -7,11 +7,12 @@ import extension_color from "@tiptap/extension-color";
7
7
  import { Table, TableCell, TableHeader, TableKit, TableRow, TableView, createTable } from "@tiptap/extension-table";
8
8
  import extension_text_align from "@tiptap/extension-text-align";
9
9
  import font_size from "@tiptap/extension-text-style/font-size";
10
- import extension_underline from "@tiptap/extension-underline";
11
10
  import starter_kit from "@tiptap/starter-kit";
12
11
  import { DOMParser as model_DOMParser, Fragment, Slice } from "@tiptap/pm/model";
13
12
  import jszip from "jszip";
14
13
  import { closeHistory, isHistoryTransaction } from "@tiptap/pm/history";
14
+ import extension_underline from "@tiptap/extension-underline";
15
+ import extension_strike from "@tiptap/extension-strike";
15
16
  import extension_subscript from "@tiptap/extension-subscript";
16
17
  import extension_superscript from "@tiptap/extension-superscript";
17
18
  import { Decoration, DecorationSet } from "@tiptap/pm/view";
@@ -22,6 +23,7 @@ import font_family from "@tiptap/extension-text-style/font-family";
22
23
  import { TextStyle } from "@tiptap/extension-text-style";
23
24
  import extension_highlight from "@tiptap/extension-highlight";
24
25
  import { createOfficeId as createWorkId, parseXml, xmlNamespacePrefix } from "./5184.js";
26
+ import { normalizeCssColor } from "./9424.js";
25
27
  import { workOfficeCollaborationJsonEqual, canonicalWorkOfficeCollaborationJson, isWorkOfficeCollaborationRecord, cloneWorkOfficeCollaborationJson } from "./4650.js";
26
28
  import { assertWorkOfficeCollaborationEditable, markWorkOfficeCollaborationInitialized, assertWorkOfficeCollaborationOrigin, initializeWorkOfficeCollaborationMetadata, assertWorkOfficeCollaborationWritable, OfficeCollaborationError as WorkOfficeCollaborationError, readOfficeCollaborationMetadata as readWorkOfficeCollaborationMetadata, registerWorkOfficeCollaborationInitializer } from "./9787.js";
27
29
  import * as __rspack_external_yjs from "yjs";
@@ -2296,6 +2298,15 @@ function themePatchTargets(localName) {
2296
2298
  shadeAttribute: 'themeShade'
2297
2299
  }
2298
2300
  ];
2301
+ if ('u' === localName) return [
2302
+ {
2303
+ kind: 'underline',
2304
+ directAttribute: 'color',
2305
+ themeAttribute: 'themeColor',
2306
+ tintAttribute: 'themeTint',
2307
+ shadeAttribute: 'themeShade'
2308
+ }
2309
+ ];
2299
2310
  if ('shd' === localName) return [
2300
2311
  {
2301
2312
  kind: 'fill',
@@ -2359,241 +2370,6 @@ function setOptionalWordAttribute(document1, element, name, value) {
2359
2370
  if (value) setWordAttribute(document1, element, name, value);
2360
2371
  else element.removeAttributeNS(WORD_NAMESPACE, name);
2361
2372
  }
2362
- const DOCUMENT_PARAGRAPH_SHADING_PATTERNS = new Set([
2363
- 'nil',
2364
- 'clear',
2365
- 'solid',
2366
- 'horzStripe',
2367
- 'vertStripe',
2368
- 'reverseDiagStripe',
2369
- 'diagStripe',
2370
- 'horzCross',
2371
- 'diagCross',
2372
- 'thinHorzStripe',
2373
- 'thinVertStripe',
2374
- 'thinReverseDiagStripe',
2375
- 'thinDiagStripe',
2376
- 'thinHorzCross',
2377
- 'thinDiagCross',
2378
- 'pct5',
2379
- 'pct10',
2380
- 'pct12',
2381
- 'pct15',
2382
- 'pct20',
2383
- 'pct25',
2384
- 'pct30',
2385
- 'pct35',
2386
- 'pct37',
2387
- 'pct40',
2388
- 'pct45',
2389
- 'pct50',
2390
- 'pct55',
2391
- 'pct60',
2392
- 'pct62',
2393
- 'pct65',
2394
- 'pct70',
2395
- 'pct75',
2396
- 'pct80',
2397
- 'pct85',
2398
- 'pct87',
2399
- 'pct90',
2400
- 'pct95'
2401
- ]);
2402
- function normalizeDocumentParagraphShading(source) {
2403
- if (!source || 'object' != typeof source) return null;
2404
- const value = source;
2405
- const pattern = value.pattern;
2406
- if ('string' != typeof pattern || !DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
2407
- const color = normalizeShadingColor(value.color);
2408
- const fill = normalizeShadingColor(value.fill);
2409
- if (void 0 !== value.color && !color || void 0 !== value.fill && !fill) return null;
2410
- return {
2411
- pattern: pattern,
2412
- ...color ? {
2413
- color
2414
- } : {},
2415
- ...fill ? {
2416
- fill
2417
- } : {}
2418
- };
2419
- }
2420
- function parseDocumentParagraphShading(source) {
2421
- if ('string' != typeof source) return normalizeDocumentParagraphShading(source);
2422
- if (!source.trim()) return null;
2423
- try {
2424
- return normalizeDocumentParagraphShading(JSON.parse(source));
2425
- } catch {
2426
- return null;
2427
- }
2428
- }
2429
- function serializeDocumentParagraphShading(source) {
2430
- const shading = normalizeDocumentParagraphShading(source);
2431
- if (!shading) return;
2432
- return JSON.stringify({
2433
- pattern: shading.pattern,
2434
- ...shading.color ? {
2435
- color: serializedShadingColor(shading.color)
2436
- } : {},
2437
- ...shading.fill ? {
2438
- fill: serializedShadingColor(shading.fill)
2439
- } : {}
2440
- });
2441
- }
2442
- function parseDocumentParagraphShadingElement(element) {
2443
- const semantic = parseDocumentParagraphShading(element.dataset.officeParagraphShading);
2444
- const background = normalizeCssColor(element.style.backgroundColor);
2445
- if (semantic) {
2446
- const presentation = documentParagraphShadingPresentation(semantic);
2447
- const expected = normalizeCssColor(presentation.backgroundColor);
2448
- if (background && expected && background !== expected) {
2449
- if ('transparent' === background) return {
2450
- pattern: 'nil'
2451
- };
2452
- if (paragraphShadingBackgroundUsesForeground(semantic)) return {
2453
- ...semantic,
2454
- color: {
2455
- value: background
2456
- }
2457
- };
2458
- return {
2459
- ...semantic,
2460
- fill: {
2461
- value: background
2462
- }
2463
- };
2464
- }
2465
- return semantic;
2466
- }
2467
- return background && 'transparent' !== background ? {
2468
- pattern: 'clear',
2469
- fill: {
2470
- value: background
2471
- }
2472
- } : null;
2473
- }
2474
- function documentParagraphShadingDomAttributes(source) {
2475
- const shading = normalizeDocumentParagraphShading(source);
2476
- const serialized = serializeDocumentParagraphShading(shading);
2477
- if (!shading || !serialized) return {};
2478
- const presentation = documentParagraphShadingPresentation(shading);
2479
- const styles = [
2480
- `background-color: ${presentation.backgroundColor}`,
2481
- presentation.backgroundImage ? `background-image: ${presentation.backgroundImage}` : '',
2482
- presentation.backgroundSize ? `background-size: ${presentation.backgroundSize}` : ''
2483
- ].filter(Boolean);
2484
- return {
2485
- 'data-office-paragraph-shading': serialized,
2486
- style: styles.join('; ')
2487
- };
2488
- }
2489
- function normalizeCssColor(source) {
2490
- const value = source?.trim().toLowerCase();
2491
- if (!value) return null;
2492
- if ('transparent' === value) return 'transparent';
2493
- const shortHex = /^#([0-9a-f]{3})$/i.exec(value);
2494
- if (shortHex?.[1]) return `#${Array.from(shortHex[1]).map((channel)=>`${channel}${channel}`).join('')}`;
2495
- if (/^#[0-9a-f]{6}$/i.test(value)) return value;
2496
- const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*([\d.]+))?\s*\)$/i.exec(value);
2497
- if (!rgb) return null;
2498
- const channels = rgb.slice(1, 4).map(Number);
2499
- if (channels.some((channel)=>channel < 0 || channel > 255)) return null;
2500
- if (void 0 !== rgb[4] && 0 === Number(rgb[4])) return 'transparent';
2501
- if (void 0 !== rgb[4] && 1 !== Number(rgb[4])) return null;
2502
- return `#${channels.map((channel)=>channel.toString(16).padStart(2, '0')).join('')}`;
2503
- }
2504
- function normalizeShadingColor(source) {
2505
- if (!source || 'object' != typeof source) return null;
2506
- const value = source;
2507
- const theme = parseDocxThemeReference('string' == typeof value.theme ? value.theme : value.theme ? JSON.stringify(value.theme) : void 0);
2508
- const direct = 'auto' === value.value ? 'auto' : 'string' == typeof value.value ? normalizeCssColor(value.value) : null;
2509
- const resolved = direct ?? theme?.resolved ?? null;
2510
- if (!resolved || 'transparent' === resolved) return null;
2511
- if (theme && resolved !== theme.resolved) return null;
2512
- return {
2513
- value: resolved,
2514
- ...theme ? {
2515
- theme
2516
- } : {}
2517
- };
2518
- }
2519
- function serializedShadingColor(color) {
2520
- const theme = serializeDocxThemeReference(color.theme ?? null);
2521
- return {
2522
- value: color.value,
2523
- ...theme ? {
2524
- theme: JSON.parse(theme)
2525
- } : {}
2526
- };
2527
- }
2528
- function documentParagraphShadingPresentation(shading) {
2529
- if ('nil' === shading.pattern) return {
2530
- backgroundColor: 'transparent'
2531
- };
2532
- const foreground = shadingColor(shading.color, '#000000');
2533
- const background = shadingColor(shading.fill, 'transparent');
2534
- if ('clear' === shading.pattern) return {
2535
- backgroundColor: background
2536
- };
2537
- if ('solid' === shading.pattern) return {
2538
- backgroundColor: foreground
2539
- };
2540
- const percentage = shadingPercentage(shading.pattern);
2541
- if (null !== percentage) {
2542
- const inverted = percentage > 50;
2543
- const dotColor = inverted ? background : foreground;
2544
- const baseColor = inverted ? foreground : background;
2545
- const density = Math.min(50, inverted ? 100 - percentage : percentage);
2546
- const spacing = Math.max(2, Math.round(9 - density / 7));
2547
- return {
2548
- backgroundColor: baseColor,
2549
- backgroundImage: `radial-gradient(circle, ${dotColor} 0 1px, transparent 1.2px)`,
2550
- backgroundSize: `${spacing}px ${spacing}px`
2551
- };
2552
- }
2553
- const thin = shading.pattern.startsWith('thin');
2554
- const width = thin ? 1 : 2;
2555
- const period = thin ? 7 : 6;
2556
- const stripe = (angle)=>`repeating-linear-gradient(${angle}deg, ${foreground} 0 ${width}px, transparent ${width}px ${period}px)`;
2557
- const angles = shadingPatternAngles(shading.pattern);
2558
- return {
2559
- backgroundColor: background,
2560
- backgroundImage: angles.map(stripe).join(', ')
2561
- };
2562
- }
2563
- function shadingColor(color, fallback) {
2564
- return color && 'auto' !== color.value ? color.value : fallback;
2565
- }
2566
- function shadingPercentage(pattern) {
2567
- const match = /^pct(\d+)$/.exec(pattern);
2568
- return match?.[1] ? Number(match[1]) : null;
2569
- }
2570
- function paragraphShadingBackgroundUsesForeground(shading) {
2571
- if ('solid' === shading.pattern) return true;
2572
- const percentage = shadingPercentage(shading.pattern);
2573
- return null !== percentage && percentage > 50;
2574
- }
2575
- function shadingPatternAngles(pattern) {
2576
- if (pattern.includes('HorzCross')) return [
2577
- 0,
2578
- 90
2579
- ];
2580
- if (pattern.includes('DiagCross')) return [
2581
- 45,
2582
- -45
2583
- ];
2584
- if (pattern.includes('VertStripe')) return [
2585
- 90
2586
- ];
2587
- if (pattern.includes('ReverseDiagStripe')) return [
2588
- -45
2589
- ];
2590
- if (pattern.includes('DiagStripe')) return [
2591
- 45
2592
- ];
2593
- return [
2594
- 0
2595
- ];
2596
- }
2597
2373
  const DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE = 'data-office-paragraph-borders';
2598
2374
  const DOCUMENT_PARAGRAPH_BORDER_EDGES = [
2599
2375
  'top',
@@ -3815,27 +3591,125 @@ function work_document_page_margins_roundFour(value) {
3815
3591
  function normalizeNegativeZero(value) {
3816
3592
  return Object.is(value, -0) ? 0 : value;
3817
3593
  }
3818
- const EQUATION_SELECTOR = 'span[data-document-equation]';
3819
- const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
3820
- const MAX_EQUATION_DEPTH = 32;
3821
- const MAX_EQUATION_NODES = 4096;
3822
- const MAX_EQUATION_TEXT_LENGTH = 65536;
3823
- const MAX_EQUATION_MODEL_LENGTH = 262144;
3824
- const MAX_DELIMITER_ARGUMENTS = 32;
3825
- const MAX_MATRIX_ROWS = 64;
3826
- const MAX_MATRIX_COLUMNS = 64;
3827
- const MAX_MATRIX_CELLS = 1024;
3828
- const MAX_MATRIX_SPACING = 65535;
3829
- const MAX_MATRIX_MINIMUM_COLUMN_WIDTH = 31680;
3830
- const MAX_EQUATION_ARRAY_ROWS = 64;
3831
- const MAX_EQUATION_ARRAY_ALIGNMENT_MARKERS = 4096;
3832
- const NARY_OPERATORS = new Set([
3833
- '∑',
3834
- '∏',
3835
- '∐',
3836
- '∫',
3837
- '∬',
3838
- '∭',
3594
+ const DOCUMENT_CHARACTER_SCALE_ATTRIBUTE = 'data-office-character-scale-percent';
3595
+ const DOCUMENT_CHARACTER_SCALE_MIN_PERCENT = 1;
3596
+ const DOCUMENT_CHARACTER_SCALE_MAX_PERCENT = 600;
3597
+ function normalizeDocumentCharacterScalePercent(value) {
3598
+ if (null == value || '' === value) return null;
3599
+ const scale = Number(value);
3600
+ return Number.isSafeInteger(scale) && scale >= DOCUMENT_CHARACTER_SCALE_MIN_PERCENT && scale <= DOCUMENT_CHARACTER_SCALE_MAX_PERCENT ? scale : null;
3601
+ }
3602
+ function documentCharacterScaleDomAttributes(value) {
3603
+ const scale = normalizeDocumentCharacterScalePercent(value);
3604
+ if (null === scale) return {};
3605
+ return {
3606
+ [DOCUMENT_CHARACTER_SCALE_ATTRIBUTE]: String(scale),
3607
+ style: `font-stretch: ${scale}%`
3608
+ };
3609
+ }
3610
+ function documentCharacterScalePercentFromElement(element) {
3611
+ if (element.hasAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE)) return normalizeDocumentCharacterScalePercent(element.getAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE));
3612
+ return documentCharacterScalePercentFromCss(element.style.fontStretch);
3613
+ }
3614
+ function documentCharacterScalePercentFromCss(value) {
3615
+ if ('string' != typeof value) return null;
3616
+ const source = value.trim().toLowerCase();
3617
+ if (!source || 'normal' === source) return null;
3618
+ const match = /^(\d+(?:\.\d*)?|\.\d+)%$/u.exec(source);
3619
+ if (!match) return null;
3620
+ return normalizeDocumentCharacterScalePercent(Number(match[1]));
3621
+ }
3622
+ const DOCUMENT_EMPHASIS_MARK_ATTRIBUTE = 'data-office-emphasis-mark';
3623
+ const DOCUMENT_EMPHASIS_MARKS = [
3624
+ 'none',
3625
+ 'dot',
3626
+ 'comma',
3627
+ 'circle',
3628
+ 'underDot'
3629
+ ];
3630
+ const DOCUMENT_EMPHASIS_MARK_SET = new Set(DOCUMENT_EMPHASIS_MARKS);
3631
+ function normalizeDocumentEmphasisMark(value) {
3632
+ return 'string' == typeof value && DOCUMENT_EMPHASIS_MARK_SET.has(value) ? value : null;
3633
+ }
3634
+ function documentEmphasisMarkCss(value) {
3635
+ const emphasisMark = normalizeDocumentEmphasisMark(value);
3636
+ if (!emphasisMark) return '';
3637
+ if ('none' === emphasisMark) return 'text-emphasis-style:none;-webkit-text-emphasis-style:none';
3638
+ const style = 'comma' === emphasisMark ? '","' : 'circle' === emphasisMark ? 'open circle' : 'filled dot';
3639
+ const position = 'underDot' === emphasisMark ? 'under right' : 'over right';
3640
+ return `text-emphasis-style:${style};text-emphasis-position:${position};-webkit-text-emphasis-style:${style};-webkit-text-emphasis-position:${position}`;
3641
+ }
3642
+ function documentEmphasisMarkDomAttributes(value) {
3643
+ const emphasisMark = normalizeDocumentEmphasisMark(value);
3644
+ if (!emphasisMark) return {};
3645
+ return {
3646
+ [DOCUMENT_EMPHASIS_MARK_ATTRIBUTE]: emphasisMark,
3647
+ style: documentEmphasisMarkCss(emphasisMark)
3648
+ };
3649
+ }
3650
+ function documentEmphasisMarkFromElement(element) {
3651
+ return element.hasAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE) ? normalizeDocumentEmphasisMark(element.getAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE)) : null;
3652
+ }
3653
+ const DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE = 'data-office-kerning-threshold-half-points';
3654
+ const DOCUMENT_KERNING_THRESHOLD_MIN_HALF_POINTS = 0;
3655
+ const DOCUMENT_KERNING_THRESHOLD_MAX_HALF_POINTS = 3277;
3656
+ const DOCUMENT_DEFAULT_FONT_SIZE_POINTS = 10.5;
3657
+ function normalizeDocumentKerningThresholdHalfPoints(value) {
3658
+ const threshold = 'number' == typeof value ? value : 'string' == typeof value && /^\+?\d+$/u.test(value.trim()) ? Number(value.trim()) : NaN;
3659
+ if (!Number.isSafeInteger(threshold) || threshold < DOCUMENT_KERNING_THRESHOLD_MIN_HALF_POINTS || threshold > DOCUMENT_KERNING_THRESHOLD_MAX_HALF_POINTS) return null;
3660
+ return Object.is(threshold, -0) ? 0 : threshold;
3661
+ }
3662
+ function documentKerningThresholdPoints(value) {
3663
+ const threshold = normalizeDocumentKerningThresholdHalfPoints(value);
3664
+ return null === threshold ? null : threshold / 2;
3665
+ }
3666
+ function documentKerningIsEffective(thresholdValue, fontSizeValue) {
3667
+ const threshold = normalizeDocumentKerningThresholdHalfPoints(thresholdValue);
3668
+ if (null === threshold) return false;
3669
+ if (0 === threshold) return true;
3670
+ return 2 * documentKerningFontSizePoints(fontSizeValue) >= threshold;
3671
+ }
3672
+ function documentKerningDomAttributes(thresholdValue, fontSizeValue) {
3673
+ const threshold = normalizeDocumentKerningThresholdHalfPoints(thresholdValue);
3674
+ if (null === threshold) return {};
3675
+ return {
3676
+ [DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE]: String(threshold),
3677
+ style: `font-kerning: ${documentKerningIsEffective(threshold, fontSizeValue) ? 'normal' : 'none'}`
3678
+ };
3679
+ }
3680
+ function documentKerningThresholdHalfPointsFromElement(element) {
3681
+ return element.hasAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE) ? normalizeDocumentKerningThresholdHalfPoints(element.getAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE)) : null;
3682
+ }
3683
+ function documentKerningFontSizePoints(value) {
3684
+ if ('number' == typeof value) return Number.isFinite(value) && value > 0 ? value : DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
3685
+ if ('string' != typeof value) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
3686
+ const match = /^(\d+(?:\.\d*)?|\.\d+)(pt|px)?$/iu.exec(value.trim());
3687
+ if (!match) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
3688
+ const amount = Number(match[1]);
3689
+ if (!Number.isFinite(amount) || amount <= 0) return DOCUMENT_DEFAULT_FONT_SIZE_POINTS;
3690
+ return match[2]?.toLowerCase() === 'px' ? 0.75 * amount : amount;
3691
+ }
3692
+ const EQUATION_SELECTOR = 'span[data-document-equation]';
3693
+ const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';
3694
+ const MAX_EQUATION_DEPTH = 32;
3695
+ const MAX_EQUATION_NODES = 4096;
3696
+ const MAX_EQUATION_TEXT_LENGTH = 65536;
3697
+ const MAX_EQUATION_MODEL_LENGTH = 262144;
3698
+ const MAX_DELIMITER_ARGUMENTS = 32;
3699
+ const MAX_MATRIX_ROWS = 64;
3700
+ const MAX_MATRIX_COLUMNS = 64;
3701
+ const MAX_MATRIX_CELLS = 1024;
3702
+ const MAX_MATRIX_SPACING = 65535;
3703
+ const MAX_MATRIX_MINIMUM_COLUMN_WIDTH = 31680;
3704
+ const MAX_EQUATION_ARRAY_ROWS = 64;
3705
+ const MAX_EQUATION_ARRAY_ALIGNMENT_MARKERS = 4096;
3706
+ const NARY_OPERATORS = new Set([
3707
+ '∑',
3708
+ '∏',
3709
+ '∐',
3710
+ '∫',
3711
+ '∬',
3712
+ '∭',
3839
3713
  '∮',
3840
3714
  '∯',
3841
3715
  '∰',
@@ -4067,13 +3941,6 @@ const WORD_VERTICAL_ALIGNMENTS = new Set([
4067
3941
  "superscript",
4068
3942
  "subscript"
4069
3943
  ]);
4070
- const WORD_EMPHASIS_MARKS = new Set([
4071
- 'none',
4072
- 'dot',
4073
- 'comma',
4074
- 'circle',
4075
- 'underDot'
4076
- ]);
4077
3944
  const WORD_COMBINE_BRACKETS = new Set([
4078
3945
  'none',
4079
3946
  'round',
@@ -4085,8 +3952,6 @@ const MAX_EQUATION_WORD_FONT_LENGTH = 127;
4085
3952
  const MAX_EQUATION_LANGUAGE_LENGTH = 85;
4086
3953
  const MAX_EQUATION_FONT_SIZE = 512;
4087
3954
  const MAX_EQUATION_CHARACTER_SPACING_TWIPS = 31680;
4088
- const MAX_EQUATION_CHARACTER_SCALE_PERCENT = 600;
4089
- const MAX_EQUATION_KERNING_THRESHOLD_HALF_POINTS = 3277;
4090
3955
  const MIN_EQUATION_WORD_LINE_BORDER_EIGHTH_POINTS = 2;
4091
3956
  const MAX_EQUATION_WORD_LINE_BORDER_EIGHTH_POINTS = 96;
4092
3957
  const MAX_EQUATION_WORD_BORDER_SPACING_POINTS = 31;
@@ -5901,7 +5766,7 @@ function normalizeEquationWordRunProperties(source) {
5901
5766
  const shading = void 0 === source.shading ? void 0 : normalizeEquationWordShading(source.shading);
5902
5767
  const fitText = void 0 === source.fitText ? void 0 : normalizeEquationWordFitText(source.fitText);
5903
5768
  const verticalAlignment = void 0 === source.verticalAlignment ? void 0 : WORD_VERTICAL_ALIGNMENTS.has(source.verticalAlignment) ? source.verticalAlignment : null;
5904
- const emphasisMark = void 0 === source.emphasisMark ? void 0 : WORD_EMPHASIS_MARKS.has(source.emphasisMark) ? source.emphasisMark : null;
5769
+ const emphasisMark = void 0 === source.emphasisMark ? void 0 : normalizeDocumentEmphasisMark(source.emphasisMark);
5905
5770
  const languages = void 0 === source.languages ? void 0 : normalizeEquationWordLanguages(source.languages);
5906
5771
  const eastAsianLayout = void 0 === source.eastAsianLayout ? void 0 : normalizeEquationWordEastAsianLayout(source.eastAsianLayout);
5907
5772
  const glow = void 0 === source.glow ? void 0 : normalizeEquationWordGlow(source.glow);
@@ -5916,8 +5781,8 @@ function normalizeEquationWordRunProperties(source) {
5916
5781
  const numberSpacing = void 0 === source.numberSpacing ? void 0 : WORD_NUMBER_SPACINGS.has(source.numberSpacing) ? source.numberSpacing : null;
5917
5782
  const stylisticSets = void 0 === source.stylisticSets ? void 0 : normalizeEquationWordStylisticSets(source.stylisticSets);
5918
5783
  const characterSpacingTwips = void 0 === source.characterSpacingTwips ? void 0 : normalizeEquationInteger(source.characterSpacingTwips, -MAX_EQUATION_CHARACTER_SPACING_TWIPS, MAX_EQUATION_CHARACTER_SPACING_TWIPS);
5919
- const characterScalePercent = void 0 === source.characterScalePercent ? void 0 : normalizeEquationInteger(source.characterScalePercent, 1, MAX_EQUATION_CHARACTER_SCALE_PERCENT);
5920
- const kerningThresholdHalfPoints = void 0 === source.kerningThresholdHalfPoints ? void 0 : normalizeEquationInteger(source.kerningThresholdHalfPoints, 0, MAX_EQUATION_KERNING_THRESHOLD_HALF_POINTS);
5784
+ const characterScalePercent = void 0 === source.characterScalePercent ? void 0 : 'number' == typeof source.characterScalePercent ? normalizeDocumentCharacterScalePercent(source.characterScalePercent) : null;
5785
+ const kerningThresholdHalfPoints = void 0 === source.kerningThresholdHalfPoints ? void 0 : 'number' == typeof source.kerningThresholdHalfPoints ? normalizeDocumentKerningThresholdHalfPoints(source.kerningThresholdHalfPoints) : null;
5921
5786
  const positionHalfPoints = void 0 === source.positionHalfPoints ? void 0 : normalizeEquationInteger(source.positionHalfPoints, MIN_EQUATION_POSITION_HALF_POINTS, MAX_EQUATION_POSITION_HALF_POINTS);
5922
5787
  const fontSize = void 0 === source.fontSize ? void 0 : normalizeEquationFontSize(source.fontSize);
5923
5788
  const fontSizeComplexScript = void 0 === source.fontSizeComplexScript ? void 0 : normalizeEquationFontSize(source.fontSizeComplexScript);
@@ -6826,11 +6691,7 @@ function wordRunVerticalAlignmentStyles(alignment) {
6826
6691
  return `vertical-align:${"superscript" === alignment ? 'super' : 'sub'};font-size:smaller`;
6827
6692
  }
6828
6693
  function wordRunEmphasisMarkStyles(emphasisMark) {
6829
- if (!emphasisMark) return '';
6830
- if ('none' === emphasisMark) return 'text-emphasis-style:none';
6831
- const style = 'comma' === emphasisMark ? cssString(',') : 'circle' === emphasisMark ? 'open circle' : 'filled dot';
6832
- const position = 'underDot' === emphasisMark ? 'under right' : 'over right';
6833
- return `text-emphasis-style:${style};text-emphasis-position:${position}`;
6694
+ return documentEmphasisMarkCss(emphasisMark);
6834
6695
  }
6835
6696
  function wordRunCaseStyles(properties) {
6836
6697
  return [
@@ -6939,6 +6800,105 @@ function validXmlText(source) {
6939
6800
  function work_document_equations_isRecord(source) {
6940
6801
  return Boolean(source) && 'object' == typeof source && !Array.isArray(source);
6941
6802
  }
6803
+ const DOCUMENT_CHARACTER_POSITION_ATTRIBUTE = 'data-office-character-position-half-points';
6804
+ const DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY = '--work-document-character-position';
6805
+ const DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS = 3168;
6806
+ const DOCUMENT_CHARACTER_POSITION_MIN_HALF_POINTS = -DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS;
6807
+ function normalizeDocumentCharacterPositionHalfPoints(value) {
6808
+ if (null == value || '' === value) return null;
6809
+ const position = Number(value);
6810
+ if (!Number.isSafeInteger(position) || position < DOCUMENT_CHARACTER_POSITION_MIN_HALF_POINTS || position > DOCUMENT_CHARACTER_POSITION_MAX_HALF_POINTS) return null;
6811
+ return Object.is(position, -0) ? 0 : position;
6812
+ }
6813
+ function documentCharacterPositionDomAttributes(value) {
6814
+ const position = normalizeDocumentCharacterPositionHalfPoints(value);
6815
+ if (null === position) return {};
6816
+ return {
6817
+ [DOCUMENT_CHARACTER_POSITION_ATTRIBUTE]: String(position),
6818
+ style: `${DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY}: ${formatCharacterPositionPoints(position)}pt`
6819
+ };
6820
+ }
6821
+ function documentCharacterPositionHalfPointsFromElement(element) {
6822
+ if (element.hasAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE)) return normalizeDocumentCharacterPositionHalfPoints(element.getAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE));
6823
+ return documentCharacterPositionHalfPointsFromCss(element.style.getPropertyValue(DOCUMENT_CHARACTER_POSITION_CSS_PROPERTY)) ?? documentCharacterPositionHalfPointsFromCss(element.style.verticalAlign);
6824
+ }
6825
+ function documentCharacterPositionHalfPointsFromCss(value) {
6826
+ if ('string' != typeof value) return null;
6827
+ const source = value.trim().toLowerCase();
6828
+ if (!source || 'baseline' === source) return null;
6829
+ const match = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(pt|px)?$/.exec(source);
6830
+ if (!match) return null;
6831
+ const amount = Number(match[1]);
6832
+ if (!Number.isFinite(amount)) return null;
6833
+ const unit = match[2];
6834
+ if (!unit && 0 !== amount) return null;
6835
+ const halfPoints = Math.round(amount * ('px' === unit ? 1.5 : 2));
6836
+ return normalizeDocumentCharacterPositionHalfPoints(halfPoints);
6837
+ }
6838
+ function documentCharacterPositionPoints(value) {
6839
+ const position = normalizeDocumentCharacterPositionHalfPoints(value);
6840
+ return null === position ? null : position / 2;
6841
+ }
6842
+ function formatCharacterPositionPoints(value) {
6843
+ return String(value / 2);
6844
+ }
6845
+ const DOCUMENT_CHARACTER_SPACING_ATTRIBUTE = 'data-office-character-spacing-twips';
6846
+ const DOCUMENT_CHARACTER_SPACING_MAX_TWIPS = 31680;
6847
+ const DOCUMENT_CHARACTER_SPACING_MIN_TWIPS = -DOCUMENT_CHARACTER_SPACING_MAX_TWIPS;
6848
+ function normalizeDocumentCharacterSpacingTwips(value) {
6849
+ if (null == value || '' === value) return null;
6850
+ const spacing = Number(value);
6851
+ if (!Number.isSafeInteger(spacing) || spacing < DOCUMENT_CHARACTER_SPACING_MIN_TWIPS || spacing > DOCUMENT_CHARACTER_SPACING_MAX_TWIPS) return null;
6852
+ return Object.is(spacing, -0) ? 0 : spacing;
6853
+ }
6854
+ function documentCharacterSpacingDomAttributes(value) {
6855
+ const spacing = normalizeDocumentCharacterSpacingTwips(value);
6856
+ if (null === spacing) return {};
6857
+ return {
6858
+ [DOCUMENT_CHARACTER_SPACING_ATTRIBUTE]: String(spacing),
6859
+ style: `letter-spacing: ${formatCharacterSpacingPoints(spacing)}pt`
6860
+ };
6861
+ }
6862
+ function documentCharacterSpacingTwipsFromElement(element) {
6863
+ if (element.hasAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE)) return normalizeDocumentCharacterSpacingTwips(element.getAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE));
6864
+ return documentCharacterSpacingTwipsFromCss(element.style.letterSpacing);
6865
+ }
6866
+ function documentCharacterSpacingTwipsFromCss(value) {
6867
+ if ('string' != typeof value) return null;
6868
+ const source = value.trim().toLowerCase();
6869
+ if (!source || 'normal' === source) return null;
6870
+ const match = /^([+-]?(?:\d+(?:\.\d*)?|\.\d+))(pt|px)?$/.exec(source);
6871
+ if (!match) return null;
6872
+ const amount = Number(match[1]);
6873
+ if (!Number.isFinite(amount)) return null;
6874
+ const unit = match[2];
6875
+ if (!unit && 0 !== amount) return null;
6876
+ const twips = Math.round(amount * ('px' === unit ? 15 : 20));
6877
+ return normalizeDocumentCharacterSpacingTwips(twips);
6878
+ }
6879
+ function documentCharacterSpacingPoints(value) {
6880
+ const spacing = normalizeDocumentCharacterSpacingTwips(value);
6881
+ return null === spacing ? null : spacing / 20;
6882
+ }
6883
+ function formatCharacterSpacingPoints(value) {
6884
+ return String(value / 20);
6885
+ }
6886
+ const DOCUMENT_HIDDEN_TEXT_ATTRIBUTE = 'data-office-hidden-text';
6887
+ const documentHiddenTextKeyboardShortcut = 'Mod-Shift-h';
6888
+ function normalizeDocumentHiddenText(value) {
6889
+ if (true === value || 'true' === value || '1' === value) return true;
6890
+ if (false === value || 'false' === value || '0' === value) return false;
6891
+ return null;
6892
+ }
6893
+ function documentHiddenTextFromElement(element) {
6894
+ return normalizeDocumentHiddenText(element.getAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE));
6895
+ }
6896
+ function documentHiddenTextDomAttributes(value) {
6897
+ const hiddenText = normalizeDocumentHiddenText(value);
6898
+ return null === hiddenText ? {} : {
6899
+ [DOCUMENT_HIDDEN_TEXT_ATTRIBUTE]: String(hiddenText)
6900
+ };
6901
+ }
6942
6902
  const IMAGE_OBJECT_ID_PATTERN = /^[0-9A-F]{8}$/;
6943
6903
  const MAX_DOC_PROPERTIES_ID = 0xffffffff;
6944
6904
  const MAX_WORDPROCESSING_ID = 0x7fffffff;
@@ -7519,79 +7479,299 @@ function work_document_paragraph_identity_transactionMapping(transactions) {
7519
7479
  for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
7520
7480
  return mapping;
7521
7481
  }
7522
- const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
7523
- const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
7524
- const DocumentTableRowIdentity = Extension.create({
7525
- name: 'documentTableRowIdentity',
7526
- addOptions () {
7527
- return {
7528
- rotateTextId: ()=>true
7529
- };
7530
- },
7531
- addGlobalAttributes () {
7532
- return [
7533
- {
7534
- types: [
7535
- 'tableRow'
7536
- ],
7537
- attributes: {
7538
- rowId: identityAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7539
- rowTextId: identityAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7540
- }
7541
- }
7542
- ];
7543
- },
7544
- addProseMirrorPlugins () {
7545
- return [
7546
- createDocumentTableRowIdentityPlugin(this.options.rotateTextId)
7547
- ];
7482
+ const DOCUMENT_PARAGRAPH_SHADING_PATTERNS = new Set([
7483
+ 'nil',
7484
+ 'clear',
7485
+ 'solid',
7486
+ 'horzStripe',
7487
+ 'vertStripe',
7488
+ 'reverseDiagStripe',
7489
+ 'diagStripe',
7490
+ 'horzCross',
7491
+ 'diagCross',
7492
+ 'thinHorzStripe',
7493
+ 'thinVertStripe',
7494
+ 'thinReverseDiagStripe',
7495
+ 'thinDiagStripe',
7496
+ 'thinHorzCross',
7497
+ 'thinDiagCross',
7498
+ 'pct5',
7499
+ 'pct10',
7500
+ 'pct12',
7501
+ 'pct15',
7502
+ 'pct20',
7503
+ 'pct25',
7504
+ 'pct30',
7505
+ 'pct35',
7506
+ 'pct37',
7507
+ 'pct40',
7508
+ 'pct45',
7509
+ 'pct50',
7510
+ 'pct55',
7511
+ 'pct60',
7512
+ 'pct62',
7513
+ 'pct65',
7514
+ 'pct70',
7515
+ 'pct75',
7516
+ 'pct80',
7517
+ 'pct85',
7518
+ 'pct87',
7519
+ 'pct90',
7520
+ 'pct95'
7521
+ ]);
7522
+ function normalizeDocumentParagraphShading(source) {
7523
+ if (!source || 'object' != typeof source) return null;
7524
+ const value = source;
7525
+ const pattern = value.pattern;
7526
+ if ('string' != typeof pattern || !DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
7527
+ const color = normalizeShadingColor(value.color);
7528
+ const fill = normalizeShadingColor(value.fill);
7529
+ if (void 0 !== value.color && !color || void 0 !== value.fill && !fill) return null;
7530
+ return {
7531
+ pattern: pattern,
7532
+ ...color ? {
7533
+ color
7534
+ } : {},
7535
+ ...fill ? {
7536
+ fill
7537
+ } : {}
7538
+ };
7539
+ }
7540
+ function parseDocumentParagraphShading(source) {
7541
+ if ('string' != typeof source) return normalizeDocumentParagraphShading(source);
7542
+ if (!source.trim()) return null;
7543
+ try {
7544
+ return normalizeDocumentParagraphShading(JSON.parse(source));
7545
+ } catch {
7546
+ return null;
7548
7547
  }
7549
- });
7550
- function normalizeDocumentTableRowIdentity(source) {
7551
- const rowId = normalizeDocumentParagraphId(source.rowId);
7552
- const rowTextId = normalizeDocumentParagraphId(source.rowTextId);
7553
- return rowId && rowTextId ? {
7554
- rowId,
7555
- rowTextId
7556
- } : null;
7557
7548
  }
7558
- function documentTableRowIdentityFromElement(element) {
7559
- return normalizeDocumentTableRowIdentity({
7560
- rowId: element.getAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7561
- rowTextId: element.getAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7549
+ function serializeDocumentParagraphShading(source) {
7550
+ const shading = normalizeDocumentParagraphShading(source);
7551
+ if (!shading) return;
7552
+ return JSON.stringify({
7553
+ pattern: shading.pattern,
7554
+ ...shading.color ? {
7555
+ color: serializedShadingColor(shading.color)
7556
+ } : {},
7557
+ ...shading.fill ? {
7558
+ fill: serializedShadingColor(shading.fill)
7559
+ } : {}
7562
7560
  });
7563
7561
  }
7564
- function applyDocumentTableRowIdentityToElement(element, source) {
7565
- const identity = normalizeDocumentTableRowIdentity(source);
7566
- if (!identity) {
7567
- element.removeAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE);
7568
- element.removeAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE);
7569
- return null;
7562
+ function parseDocumentParagraphShadingElement(element) {
7563
+ const semantic = parseDocumentParagraphShading(element.dataset.officeParagraphShading);
7564
+ const background = normalizeCssColor(element.style.backgroundColor);
7565
+ if (semantic) {
7566
+ const presentation = documentParagraphShadingPresentation(semantic);
7567
+ const expected = normalizeCssColor(presentation.backgroundColor);
7568
+ if (background && expected && background !== expected) {
7569
+ if ('transparent' === background) return {
7570
+ pattern: 'nil'
7571
+ };
7572
+ if (paragraphShadingBackgroundUsesForeground(semantic)) return {
7573
+ ...semantic,
7574
+ color: {
7575
+ value: background
7576
+ }
7577
+ };
7578
+ return {
7579
+ ...semantic,
7580
+ fill: {
7581
+ value: background
7582
+ }
7583
+ };
7584
+ }
7585
+ return semantic;
7570
7586
  }
7571
- element.setAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, identity.rowId);
7572
- element.setAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, identity.rowTextId);
7573
- return identity;
7574
- }
7575
- function identityAttribute(htmlName) {
7576
- return {
7577
- default: null,
7578
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(htmlName)),
7579
- renderHTML: (attributes)=>{
7580
- const modelName = htmlName === DOCUMENT_TABLE_ROW_ID_ATTRIBUTE ? 'rowId' : 'rowTextId';
7581
- const value = normalizeDocumentParagraphId(attributes[modelName]);
7582
- return value ? {
7583
- [htmlName]: value
7584
- } : {};
7587
+ return background && 'transparent' !== background ? {
7588
+ pattern: 'clear',
7589
+ fill: {
7590
+ value: background
7585
7591
  }
7586
- };
7592
+ } : null;
7587
7593
  }
7588
- function createDocumentTableRowIdentityPlugin(rotateTextId) {
7589
- return new Plugin({
7590
- view (view) {
7591
- const transaction = normalizeDocumentTableRowIdentities(view.state, rotateTextId);
7592
- if (transaction) {
7593
- transaction.setMeta('addToHistory', false);
7594
- view.dispatch(transaction);
7594
+ function documentParagraphShadingDomAttributes(source) {
7595
+ const shading = normalizeDocumentParagraphShading(source);
7596
+ const serialized = serializeDocumentParagraphShading(shading);
7597
+ if (!shading || !serialized) return {};
7598
+ const presentation = documentParagraphShadingPresentation(shading);
7599
+ const styles = [
7600
+ `background-color: ${presentation.backgroundColor}`,
7601
+ presentation.backgroundImage ? `background-image: ${presentation.backgroundImage}` : '',
7602
+ presentation.backgroundSize ? `background-size: ${presentation.backgroundSize}` : ''
7603
+ ].filter(Boolean);
7604
+ return {
7605
+ 'data-office-paragraph-shading': serialized,
7606
+ style: styles.join('; ')
7607
+ };
7608
+ }
7609
+ function normalizeShadingColor(source) {
7610
+ if (!source || 'object' != typeof source) return null;
7611
+ const value = source;
7612
+ const theme = parseDocxThemeReference('string' == typeof value.theme ? value.theme : value.theme ? JSON.stringify(value.theme) : void 0);
7613
+ const direct = 'auto' === value.value ? 'auto' : 'string' == typeof value.value ? normalizeCssColor(value.value) : null;
7614
+ const resolved = direct ?? theme?.resolved ?? null;
7615
+ if (!resolved || 'transparent' === resolved) return null;
7616
+ if (theme && resolved !== theme.resolved) return null;
7617
+ return {
7618
+ value: resolved,
7619
+ ...theme ? {
7620
+ theme
7621
+ } : {}
7622
+ };
7623
+ }
7624
+ function serializedShadingColor(color) {
7625
+ const theme = serializeDocxThemeReference(color.theme ?? null);
7626
+ return {
7627
+ value: color.value,
7628
+ ...theme ? {
7629
+ theme: JSON.parse(theme)
7630
+ } : {}
7631
+ };
7632
+ }
7633
+ function documentParagraphShadingPresentation(shading) {
7634
+ if ('nil' === shading.pattern) return {
7635
+ backgroundColor: 'transparent'
7636
+ };
7637
+ const foreground = shadingColor(shading.color, '#000000');
7638
+ const background = shadingColor(shading.fill, 'transparent');
7639
+ if ('clear' === shading.pattern) return {
7640
+ backgroundColor: background
7641
+ };
7642
+ if ('solid' === shading.pattern) return {
7643
+ backgroundColor: foreground
7644
+ };
7645
+ const percentage = shadingPercentage(shading.pattern);
7646
+ if (null !== percentage) {
7647
+ const inverted = percentage > 50;
7648
+ const dotColor = inverted ? background : foreground;
7649
+ const baseColor = inverted ? foreground : background;
7650
+ const density = Math.min(50, inverted ? 100 - percentage : percentage);
7651
+ const spacing = Math.max(2, Math.round(9 - density / 7));
7652
+ return {
7653
+ backgroundColor: baseColor,
7654
+ backgroundImage: `radial-gradient(circle, ${dotColor} 0 1px, transparent 1.2px)`,
7655
+ backgroundSize: `${spacing}px ${spacing}px`
7656
+ };
7657
+ }
7658
+ const thin = shading.pattern.startsWith('thin');
7659
+ const width = thin ? 1 : 2;
7660
+ const period = thin ? 7 : 6;
7661
+ const stripe = (angle)=>`repeating-linear-gradient(${angle}deg, ${foreground} 0 ${width}px, transparent ${width}px ${period}px)`;
7662
+ const angles = shadingPatternAngles(shading.pattern);
7663
+ return {
7664
+ backgroundColor: background,
7665
+ backgroundImage: angles.map(stripe).join(', ')
7666
+ };
7667
+ }
7668
+ function shadingColor(color, fallback) {
7669
+ return color && 'auto' !== color.value ? color.value : fallback;
7670
+ }
7671
+ function shadingPercentage(pattern) {
7672
+ const match = /^pct(\d+)$/.exec(pattern);
7673
+ return match?.[1] ? Number(match[1]) : null;
7674
+ }
7675
+ function paragraphShadingBackgroundUsesForeground(shading) {
7676
+ if ('solid' === shading.pattern) return true;
7677
+ const percentage = shadingPercentage(shading.pattern);
7678
+ return null !== percentage && percentage > 50;
7679
+ }
7680
+ function shadingPatternAngles(pattern) {
7681
+ if (pattern.includes('HorzCross')) return [
7682
+ 0,
7683
+ 90
7684
+ ];
7685
+ if (pattern.includes('DiagCross')) return [
7686
+ 45,
7687
+ -45
7688
+ ];
7689
+ if (pattern.includes('VertStripe')) return [
7690
+ 90
7691
+ ];
7692
+ if (pattern.includes('ReverseDiagStripe')) return [
7693
+ -45
7694
+ ];
7695
+ if (pattern.includes('DiagStripe')) return [
7696
+ 45
7697
+ ];
7698
+ return [
7699
+ 0
7700
+ ];
7701
+ }
7702
+ const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
7703
+ const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
7704
+ const DocumentTableRowIdentity = Extension.create({
7705
+ name: 'documentTableRowIdentity',
7706
+ addOptions () {
7707
+ return {
7708
+ rotateTextId: ()=>true
7709
+ };
7710
+ },
7711
+ addGlobalAttributes () {
7712
+ return [
7713
+ {
7714
+ types: [
7715
+ 'tableRow'
7716
+ ],
7717
+ attributes: {
7718
+ rowId: identityAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7719
+ rowTextId: identityAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7720
+ }
7721
+ }
7722
+ ];
7723
+ },
7724
+ addProseMirrorPlugins () {
7725
+ return [
7726
+ createDocumentTableRowIdentityPlugin(this.options.rotateTextId)
7727
+ ];
7728
+ }
7729
+ });
7730
+ function normalizeDocumentTableRowIdentity(source) {
7731
+ const rowId = normalizeDocumentParagraphId(source.rowId);
7732
+ const rowTextId = normalizeDocumentParagraphId(source.rowTextId);
7733
+ return rowId && rowTextId ? {
7734
+ rowId,
7735
+ rowTextId
7736
+ } : null;
7737
+ }
7738
+ function documentTableRowIdentityFromElement(element) {
7739
+ return normalizeDocumentTableRowIdentity({
7740
+ rowId: element.getAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7741
+ rowTextId: element.getAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7742
+ });
7743
+ }
7744
+ function applyDocumentTableRowIdentityToElement(element, source) {
7745
+ const identity = normalizeDocumentTableRowIdentity(source);
7746
+ if (!identity) {
7747
+ element.removeAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE);
7748
+ element.removeAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE);
7749
+ return null;
7750
+ }
7751
+ element.setAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, identity.rowId);
7752
+ element.setAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, identity.rowTextId);
7753
+ return identity;
7754
+ }
7755
+ function identityAttribute(htmlName) {
7756
+ return {
7757
+ default: null,
7758
+ parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(htmlName)),
7759
+ renderHTML: (attributes)=>{
7760
+ const modelName = htmlName === DOCUMENT_TABLE_ROW_ID_ATTRIBUTE ? 'rowId' : 'rowTextId';
7761
+ const value = normalizeDocumentParagraphId(attributes[modelName]);
7762
+ return value ? {
7763
+ [htmlName]: value
7764
+ } : {};
7765
+ }
7766
+ };
7767
+ }
7768
+ function createDocumentTableRowIdentityPlugin(rotateTextId) {
7769
+ return new Plugin({
7770
+ view (view) {
7771
+ const transaction = normalizeDocumentTableRowIdentities(view.state, rotateTextId);
7772
+ if (transaction) {
7773
+ transaction.setMeta('addToHistory', false);
7774
+ view.dispatch(transaction);
7595
7775
  }
7596
7776
  return {};
7597
7777
  },
@@ -7702,31 +7882,774 @@ function tableRowsById(rows) {
7702
7882
  matches.push(row);
7703
7883
  result.set(id, matches);
7704
7884
  }
7705
- return result;
7706
- }
7707
- function documentTableRows(document1) {
7708
- const rows = [];
7709
- document1.descendants((node, position)=>{
7710
- if ('tableRow' === node.type.name && hasDocumentTableRowIdentityComponent(node)) rows.push({
7711
- node,
7712
- position
7713
- });
7714
- });
7715
- return rows;
7885
+ return result;
7886
+ }
7887
+ function documentTableRows(document1) {
7888
+ const rows = [];
7889
+ document1.descendants((node, position)=>{
7890
+ if ('tableRow' === node.type.name && hasDocumentTableRowIdentityComponent(node)) rows.push({
7891
+ node,
7892
+ position
7893
+ });
7894
+ });
7895
+ return rows;
7896
+ }
7897
+ function tableRowIdentitySourceFromNode(node) {
7898
+ return {
7899
+ rowId: node.attrs.rowId,
7900
+ rowTextId: node.attrs.rowTextId
7901
+ };
7902
+ }
7903
+ function sameDocumentTableRowIdentity(source, identity) {
7904
+ return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
7905
+ }
7906
+ function work_document_table_row_identity_transactionMapping(transactions) {
7907
+ const mapping = new Mapping();
7908
+ for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
7909
+ return mapping;
7910
+ }
7911
+ const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
7912
+ const documentTextCaseKeyboardShortcuts = {
7913
+ allCaps: 'Mod-Shift-a',
7914
+ smallCaps: 'Mod-Shift-k'
7915
+ };
7916
+ function normalizeDocumentTextCase(value) {
7917
+ return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
7918
+ }
7919
+ function documentTextCaseFromWordFlags(allCaps, smallCaps) {
7920
+ if (void 0 === allCaps && void 0 === smallCaps) return null;
7921
+ if (allCaps) return 'all-caps';
7922
+ if (smallCaps) return 'small-caps';
7923
+ return 'none';
7924
+ }
7925
+ function applyDocumentTextCaseStyle(element, textCase) {
7926
+ element.dataset.officeTextCase = textCase;
7927
+ element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
7928
+ element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
7929
+ }
7930
+ function documentTextCaseCss(textCase) {
7931
+ return [
7932
+ `text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
7933
+ `font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
7934
+ ].join('; ');
7935
+ }
7936
+ const DOCUMENT_SCRIPT_FONTS_ATTRIBUTE = "data-office-script-fonts";
7937
+ const DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE = "data-office-script-font-slot";
7938
+ const MAX_FONT_NAME_LENGTH = 127;
7939
+ const MAX_SERIALIZED_SCRIPT_FONTS_LENGTH = 4096;
7940
+ const SCRIPT_FONT_KEYS = new Set([
7941
+ 'ascii',
7942
+ 'highAnsi',
7943
+ 'eastAsia',
7944
+ 'complexScript',
7945
+ 'hint'
7946
+ ]);
7947
+ const SCRIPT_FONT_FACE_KEYS = new Set([
7948
+ 'name',
7949
+ 'theme',
7950
+ 'resolved'
7951
+ ]);
7952
+ const SCRIPT_FONT_HINTS = new Set([
7953
+ 'default',
7954
+ 'eastAsia',
7955
+ 'cs'
7956
+ ]);
7957
+ const work_document_script_fonts_THEME_FONTS = new Set([
7958
+ 'majorEastAsia',
7959
+ 'majorBidi',
7960
+ 'majorAscii',
7961
+ 'majorHAnsi',
7962
+ 'minorEastAsia',
7963
+ 'minorBidi',
7964
+ 'minorAscii',
7965
+ 'minorHAnsi'
7966
+ ]);
7967
+ const SLOT_FALLBACK_ORDER = {
7968
+ ascii: [
7969
+ 'ascii',
7970
+ 'highAnsi',
7971
+ 'eastAsia',
7972
+ 'complexScript'
7973
+ ],
7974
+ highAnsi: [
7975
+ 'highAnsi',
7976
+ 'ascii',
7977
+ 'eastAsia',
7978
+ 'complexScript'
7979
+ ],
7980
+ eastAsia: [
7981
+ 'eastAsia',
7982
+ 'highAnsi',
7983
+ 'ascii',
7984
+ 'complexScript'
7985
+ ],
7986
+ complexScript: [
7987
+ 'complexScript',
7988
+ 'highAnsi',
7989
+ 'ascii',
7990
+ 'eastAsia'
7991
+ ]
7992
+ };
7993
+ const NEUTRAL_SCRIPT_CHARACTER = /^[\p{Cc}\p{Cf}\p{M}\p{N}\p{P}\p{S}\p{Z}]$/u;
7994
+ function normalizeDocumentScriptFonts(source) {
7995
+ if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_KEYS)) return null;
7996
+ const normalized = {};
7997
+ for (const slot of scriptFontSlots){
7998
+ if (void 0 === source[slot]) continue;
7999
+ const face = normalizeDocumentScriptFontFace(source[slot]);
8000
+ if (!face) return null;
8001
+ normalized[slot] = face;
8002
+ }
8003
+ if (void 0 !== source.hint) {
8004
+ const hint = normalizeDocumentScriptFontHint(source.hint);
8005
+ if (!hint) return null;
8006
+ normalized.hint = hint;
8007
+ }
8008
+ return Object.keys(normalized).length ? normalized : null;
8009
+ }
8010
+ function serializeDocumentScriptFonts(source) {
8011
+ const fonts = normalizeDocumentScriptFonts(source);
8012
+ return fonts ? JSON.stringify(fonts) : null;
8013
+ }
8014
+ function parseDocumentScriptFonts(source) {
8015
+ if (!source || source.length > MAX_SERIALIZED_SCRIPT_FONTS_LENGTH) return null;
8016
+ try {
8017
+ return normalizeDocumentScriptFonts(JSON.parse(source));
8018
+ } catch {
8019
+ return null;
8020
+ }
8021
+ }
8022
+ function documentScriptFontsFromElement(element) {
8023
+ return parseDocumentScriptFonts(element.getAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE));
8024
+ }
8025
+ function documentScriptFontSlotFromElement(element) {
8026
+ return normalizeDocumentScriptFontSlot(element.getAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE));
8027
+ }
8028
+ function documentScriptFontsDomAttributes(source, slot) {
8029
+ const fonts = normalizeDocumentScriptFonts(source);
8030
+ const normalizedSlot = normalizeDocumentScriptFontSlot(slot);
8031
+ if (!fonts) return {};
8032
+ const serialized = serializeDocumentScriptFonts(fonts);
8033
+ if (!serialized) return {};
8034
+ const family = documentScriptFontFamily(fonts, normalizedSlot ?? documentScriptFontSlotFromHint(fonts.hint));
8035
+ return {
8036
+ [DOCUMENT_SCRIPT_FONTS_ATTRIBUTE]: serialized,
8037
+ ...normalizedSlot ? {
8038
+ [DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE]: normalizedSlot
8039
+ } : {},
8040
+ ...family ? {
8041
+ style: `font-family: ${family}`
8042
+ } : {}
8043
+ };
8044
+ }
8045
+ function documentScriptFontFamily(source, slot) {
8046
+ const fonts = normalizeDocumentScriptFonts(source);
8047
+ if (!fonts) return;
8048
+ const families = [];
8049
+ const seen = new Set();
8050
+ for (const candidate of documentScriptFontFallbackSlots(slot)){
8051
+ const family = documentScriptFontFaceFamily(fonts[candidate]);
8052
+ const key = family?.toLocaleLowerCase();
8053
+ if (!(!family || !key || seen.has(key))) {
8054
+ seen.add(key);
8055
+ families.push(cssFontFamily(family));
8056
+ }
8057
+ }
8058
+ return families.length ? families.join(', ') : void 0;
8059
+ }
8060
+ function documentScriptFontFallbackSlots(slot) {
8061
+ return SLOT_FALLBACK_ORDER[slot];
8062
+ }
8063
+ function documentScriptFontFamilyForRendering(source, slot, currentFontFamily) {
8064
+ const projected = documentScriptFontFamily(source, slot);
8065
+ const safeCurrent = safeCssFontFamilyList(currentFontFamily);
8066
+ if (!safeCurrent || !projected) return projected;
8067
+ const currentPrimary = documentFontNameFromCssFamily(safeCurrent);
8068
+ const projectedPrimary = documentFontNameFromCssFamily(projected);
8069
+ return currentPrimary && projectedPrimary && currentPrimary.toLocaleLowerCase() === projectedPrimary.toLocaleLowerCase() ? safeCurrent : projected;
8070
+ }
8071
+ function documentScriptFontDirectFamily(source, slot) {
8072
+ const fonts = normalizeDocumentScriptFonts(source);
8073
+ return fonts ? documentScriptFontFaceFamily(fonts[slot]) ?? null : null;
8074
+ }
8075
+ function documentScriptFontsForAllText(fontFamily) {
8076
+ const name = documentFontNameFromCssFamily(fontFamily);
8077
+ if (!name) return null;
8078
+ const face = {
8079
+ name,
8080
+ resolved: name
8081
+ };
8082
+ return {
8083
+ ascii: face,
8084
+ highAnsi: face,
8085
+ eastAsia: face,
8086
+ complexScript: face,
8087
+ hint: 'default'
8088
+ };
8089
+ }
8090
+ function patchDocumentScriptFonts(source, patch, fallbackFontFamily) {
8091
+ const current = normalizeDocumentScriptFonts(source) ?? documentScriptFontsForAllText(fallbackFontFamily) ?? {};
8092
+ const next = {
8093
+ ...current
8094
+ };
8095
+ if (void 0 !== patch.latin) {
8096
+ const face = directFontFace(patch.latin);
8097
+ if (face) {
8098
+ next.ascii = face;
8099
+ next.highAnsi = face;
8100
+ } else {
8101
+ delete next.ascii;
8102
+ delete next.highAnsi;
8103
+ }
8104
+ }
8105
+ if (void 0 !== patch.eastAsia) {
8106
+ const face = directFontFace(patch.eastAsia);
8107
+ if (face) next.eastAsia = face;
8108
+ else delete next.eastAsia;
8109
+ }
8110
+ if (void 0 !== patch.complexScript) {
8111
+ const face = directFontFace(patch.complexScript);
8112
+ if (face) next.complexScript = face;
8113
+ else delete next.complexScript;
8114
+ }
8115
+ return normalizeDocumentScriptFonts(next);
8116
+ }
8117
+ function documentScriptFontSegments(text, hint = 'default', forceComplexScript = false) {
8118
+ if (!text) return [];
8119
+ if (forceComplexScript) return [
8120
+ {
8121
+ from: 0,
8122
+ to: text.length,
8123
+ slot: 'complexScript'
8124
+ }
8125
+ ];
8126
+ const characters = [];
8127
+ let offset = 0;
8128
+ for (const character of text){
8129
+ const from = offset;
8130
+ offset += character.length;
8131
+ characters.push({
8132
+ from,
8133
+ to: offset,
8134
+ slot: strongDocumentScriptFontSlot(character)
8135
+ });
8136
+ }
8137
+ const fallback = documentScriptFontSlotFromHint(hint);
8138
+ let previous = null;
8139
+ for(let index = 0; index < characters.length; index += 1){
8140
+ const entry = characters[index];
8141
+ if (!entry) continue;
8142
+ if (entry.slot) {
8143
+ previous = entry.slot;
8144
+ continue;
8145
+ }
8146
+ let next = previous;
8147
+ if (!next) for(let cursor = index + 1; cursor < characters.length; cursor += 1){
8148
+ const candidate = characters[cursor]?.slot;
8149
+ if (candidate) {
8150
+ next = candidate;
8151
+ break;
8152
+ }
8153
+ }
8154
+ entry.slot = next ?? fallback;
8155
+ }
8156
+ const segments = [];
8157
+ for (const entry of characters){
8158
+ const slot = entry.slot ?? fallback;
8159
+ const prior = segments[segments.length - 1];
8160
+ if (prior?.slot === slot && prior.to === entry.from) prior.to = entry.to;
8161
+ else segments.push({
8162
+ from: entry.from,
8163
+ to: entry.to,
8164
+ slot
8165
+ });
8166
+ }
8167
+ return segments;
8168
+ }
8169
+ function normalizeDocumentScriptFontSlot(value) {
8170
+ return scriptFontSlots.includes(value) ? value : null;
8171
+ }
8172
+ function normalizeDocumentScriptFontHint(value) {
8173
+ return SCRIPT_FONT_HINTS.has(value) ? value : null;
8174
+ }
8175
+ function normalizeDocumentThemeFont(value) {
8176
+ return work_document_script_fonts_THEME_FONTS.has(value) ? value : null;
8177
+ }
8178
+ function documentScriptFontSlotFromHint(hint) {
8179
+ if ('eastAsia' === hint) return 'eastAsia';
8180
+ if ('cs' === hint) return 'complexScript';
8181
+ return 'ascii';
8182
+ }
8183
+ function documentFontNameFromCssFamily(value) {
8184
+ if ('string' != typeof value) return null;
8185
+ const source = value.trim();
8186
+ if (!source) return null;
8187
+ let family = '';
8188
+ const quote = source[0];
8189
+ if ('"' === quote || "'" === quote) {
8190
+ let closed = false;
8191
+ for(let index = 1; index < source.length; index += 1){
8192
+ const character = source[index];
8193
+ if (character === quote) {
8194
+ closed = true;
8195
+ break;
8196
+ }
8197
+ if ('\\' !== character) {
8198
+ family += character;
8199
+ continue;
8200
+ }
8201
+ const decoded = decodeCssEscape(source, index + 1);
8202
+ if (!decoded) return null;
8203
+ family += decoded.value;
8204
+ index = decoded.end - 1;
8205
+ }
8206
+ if (!closed) return null;
8207
+ } else family = source.split(',')[0] ?? '';
8208
+ return normalizeDocumentFontName(family);
8209
+ }
8210
+ function cssDocumentFontFamily(value) {
8211
+ const family = normalizeDocumentFontName(value);
8212
+ return family ? cssFontFamily(family) : null;
8213
+ }
8214
+ function normalizeDocumentFontName(value) {
8215
+ if ('string' != typeof value) return null;
8216
+ const normalized = value.trim();
8217
+ return normalized && normalized.length <= MAX_FONT_NAME_LENGTH && !/[\p{Cc}\p{Cs}]/u.test(normalized) ? normalized : null;
8218
+ }
8219
+ const scriptFontSlots = [
8220
+ 'ascii',
8221
+ 'highAnsi',
8222
+ 'eastAsia',
8223
+ 'complexScript'
8224
+ ];
8225
+ function normalizeDocumentScriptFontFace(source) {
8226
+ if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_FACE_KEYS)) return null;
8227
+ const name = void 0 === source.name ? void 0 : normalizeDocumentFontName(source.name);
8228
+ const resolved = void 0 === source.resolved ? void 0 : normalizeDocumentFontName(source.resolved);
8229
+ const theme = void 0 === source.theme ? void 0 : normalizeDocumentThemeFont(source.theme);
8230
+ if (void 0 !== source.name && !name || void 0 !== source.resolved && !resolved || null === theme || !name && !theme && !resolved) return null;
8231
+ return {
8232
+ ...name ? {
8233
+ name
8234
+ } : {},
8235
+ ...theme ? {
8236
+ theme
8237
+ } : {},
8238
+ ...resolved ? {
8239
+ resolved
8240
+ } : {}
8241
+ };
8242
+ }
8243
+ function directFontFace(value) {
8244
+ if (null === value) return null;
8245
+ const name = documentFontNameFromCssFamily(value) ?? normalizeDocumentFontName(value);
8246
+ return name ? {
8247
+ name,
8248
+ resolved: name
8249
+ } : null;
8250
+ }
8251
+ function documentScriptFontFaceFamily(face) {
8252
+ return face?.resolved ?? face?.name;
8253
+ }
8254
+ function strongDocumentScriptFontSlot(character) {
8255
+ if (NEUTRAL_SCRIPT_CHARACTER.test(character)) return null;
8256
+ const codePoint = character.codePointAt(0);
8257
+ if (void 0 === codePoint) return null;
8258
+ if (isComplexScriptCodePoint(codePoint)) return 'complexScript';
8259
+ if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
8260
+ return codePoint <= 0x7f ? 'ascii' : 'highAnsi';
8261
+ }
8262
+ function isComplexScriptCodePoint(codePoint) {
8263
+ 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;
8264
+ }
8265
+ function isEastAsianCodePoint(codePoint) {
8266
+ 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;
8267
+ }
8268
+ function cssFontFamily(value) {
8269
+ return /^(?:-?[\p{L}_])[\p{L}\p{N}_-]*$/u.test(value) ? value : `"${Array.from(value, cssStringCharacter).join('')}"`;
8270
+ }
8271
+ function cssStringCharacter(character) {
8272
+ return /[\\":;{}<>]/u.test(character) ? `\\${character.codePointAt(0)?.toString(16)} ` : character;
8273
+ }
8274
+ function safeCssFontFamilyList(value) {
8275
+ if ('string' != typeof value) return null;
8276
+ const source = value.trim();
8277
+ if (!source || source.length > 1024 || /[;{}]/u.test(source)) return null;
8278
+ const tokens = [];
8279
+ let start = 0;
8280
+ let quote = '';
8281
+ for(let index = 0; index < source.length; index += 1){
8282
+ const character = source[index] ?? '';
8283
+ if (quote) {
8284
+ if ('\\' === character) {
8285
+ index += 1;
8286
+ if (index >= source.length) return null;
8287
+ } else if (character === quote) quote = '';
8288
+ continue;
8289
+ }
8290
+ if ('"' === character || "'" === character) {
8291
+ quote = character;
8292
+ continue;
8293
+ }
8294
+ if (',' === character) {
8295
+ tokens.push(source.slice(start, index).trim());
8296
+ start = index + 1;
8297
+ }
8298
+ }
8299
+ if (quote) return null;
8300
+ tokens.push(source.slice(start).trim());
8301
+ return tokens.length && tokens.every(validCssFontFamilyToken) ? source : null;
8302
+ }
8303
+ function validCssFontFamilyToken(value) {
8304
+ if (!value) return false;
8305
+ if (value.startsWith('"')) return /^"(?:[^"\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*"$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
8306
+ if (value.startsWith("'")) return /^'(?:[^'\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*'$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
8307
+ return /[\p{L}_]/u.test(value) && /^[\p{L}_-][\p{L}\p{N}_ -]*$/u.test(value) && !/^(?:inherit|initial|revert(?:-layer)?|unset)$/iu.test(value);
8308
+ }
8309
+ function decodeCssEscape(source, start) {
8310
+ if (start >= source.length) return null;
8311
+ const hexadecimal = /^[\da-f]{1,6}/i.exec(source.slice(start))?.[0];
8312
+ if (hexadecimal) {
8313
+ const codePoint = Number.parseInt(hexadecimal, 16);
8314
+ if (0 === codePoint || codePoint > 0x10ffff || codePoint >= 0xd800 && codePoint <= 0xdfff) return null;
8315
+ let end = start + hexadecimal.length;
8316
+ if (/\s/u.test(source[end] ?? '')) end += 1;
8317
+ return {
8318
+ value: String.fromCodePoint(codePoint),
8319
+ end
8320
+ };
8321
+ }
8322
+ const value = source[start];
8323
+ return !value || /[\r\n\f]/u.test(value) ? null : {
8324
+ value,
8325
+ end: start + 1
8326
+ };
8327
+ }
8328
+ function work_document_script_fonts_isRecordWithKeys(value, allowed) {
8329
+ return 'object' == typeof value && null !== value && !Array.isArray(value) && Object.keys(value).every((key)=>allowed.has(key));
8330
+ }
8331
+ const workDocumentUnderlineStyles = [
8332
+ 'none',
8333
+ 'single',
8334
+ 'words',
8335
+ 'double',
8336
+ 'thick',
8337
+ 'dotted',
8338
+ 'dottedHeavy',
8339
+ 'dash',
8340
+ 'dashedHeavy',
8341
+ 'dashLong',
8342
+ 'dashLongHeavy',
8343
+ 'dotDash',
8344
+ 'dashDotHeavy',
8345
+ 'dotDotDash',
8346
+ 'dashDotDotHeavy',
8347
+ 'wave',
8348
+ 'wavyHeavy',
8349
+ 'wavyDouble'
8350
+ ];
8351
+ const DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE = 'data-office-underline-style';
8352
+ const DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE = 'data-office-underline-color';
8353
+ const DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE = 'data-office-underline-theme-color';
8354
+ const documentUnderlineKeyboardShortcuts = {
8355
+ double: 'Mod-Shift-d',
8356
+ words: 'Mod-Shift-w'
8357
+ };
8358
+ const UNDERLINE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentUnderlineStyles.map((style)=>[
8359
+ style.toLowerCase(),
8360
+ style
8361
+ ]));
8362
+ const HEAVY_UNDERLINE_STYLES = new Set([
8363
+ 'thick',
8364
+ 'dottedHeavy',
8365
+ 'dashedHeavy',
8366
+ 'dashLongHeavy',
8367
+ 'dashDotHeavy',
8368
+ 'dashDotDotHeavy',
8369
+ 'wavyHeavy'
8370
+ ]);
8371
+ const DocumentUnderline = extension_underline.extend({
8372
+ addAttributes () {
8373
+ return {
8374
+ underlineStyle: {
8375
+ default: 'single',
8376
+ parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.style ?? 'single',
8377
+ renderHTML: ()=>({})
8378
+ },
8379
+ underlineColor: {
8380
+ default: null,
8381
+ parseHTML: (element)=>documentUnderlineFormattingFromElement(element)?.color ?? null,
8382
+ renderHTML: ()=>({})
8383
+ },
8384
+ underlineThemeColor: {
8385
+ default: null,
8386
+ parseHTML: (element)=>serializeDocxThemeReference(documentUnderlineFormattingFromElement(element)?.themeColor ?? null) ?? null,
8387
+ renderHTML: ()=>({})
8388
+ }
8389
+ };
8390
+ },
8391
+ renderHTML ({ mark, HTMLAttributes }) {
8392
+ const attributes = documentUnderlineDomAttributes(documentUnderlineFormattingFromMarkAttributes(mark.attrs));
8393
+ return [
8394
+ 'u',
8395
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, attributes),
8396
+ 0
8397
+ ];
8398
+ },
8399
+ addCommands () {
8400
+ return {
8401
+ setUnderline: ()=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'single')),
8402
+ toggleUnderline: ()=>({ commands, editor })=>{
8403
+ const style = 'none' === documentUnderlineStyle(editor) ? 'single' : 'none';
8404
+ return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style));
8405
+ },
8406
+ unsetUnderline: ()=>({ commands })=>commands.unsetMark(this.name),
8407
+ setDocumentUnderline: (style, options = {})=>({ commands, editor })=>commands.setMark(this.name, documentUnderlineMarkAttributes(editor, style, options)),
8408
+ setDocumentUnderlineColor: (color, themeColor = null)=>({ commands, editor })=>{
8409
+ const normalizedColor = normalizeDocumentUnderlineColor(color);
8410
+ if (null !== color && !normalizedColor) return false;
8411
+ const style = documentUnderlineStyle(editor);
8412
+ return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, 'none' === style ? 'single' : style, {
8413
+ color: normalizedColor,
8414
+ themeColor
8415
+ }));
8416
+ },
8417
+ toggleDocumentUnderlineStyle: (style)=>({ commands, editor })=>{
8418
+ const next = documentUnderlineStyle(editor) === style ? 'none' : style;
8419
+ return commands.setMark(this.name, documentUnderlineMarkAttributes(editor, next));
8420
+ }
8421
+ };
8422
+ },
8423
+ addKeyboardShortcuts () {
8424
+ return {
8425
+ 'Mod-u': ()=>this.editor.commands.toggleUnderline(),
8426
+ 'Mod-U': ()=>this.editor.commands.toggleUnderline(),
8427
+ [documentUnderlineKeyboardShortcuts.double]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('double'),
8428
+ [documentUnderlineKeyboardShortcuts.words]: ()=>this.editor.commands.toggleDocumentUnderlineStyle('words')
8429
+ };
8430
+ }
8431
+ });
8432
+ function normalizeDocumentUnderlineStyle(value) {
8433
+ if ('string' != typeof value) return null;
8434
+ const normalized = value.trim().toLowerCase();
8435
+ if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
8436
+ return UNDERLINE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
8437
+ }
8438
+ function normalizeDocumentUnderlineColor(value) {
8439
+ if ('string' != typeof value) return null;
8440
+ const source = value.trim();
8441
+ const hex = /^#?([\da-f]{6})$/i.exec(source)?.[1];
8442
+ if (hex) return `#${hex.toLowerCase()}`;
8443
+ const shortHex = /^#([\da-f]{3})$/i.exec(source)?.[1];
8444
+ if (shortHex) return `#${[
8445
+ ...shortHex
8446
+ ].map((channel)=>`${channel}${channel}`).join('').toLowerCase()}`;
8447
+ const rgb = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})(?:\s*,\s*(?:1(?:\.0+)?|0?\.\d+))?\s*\)$/i.exec(source);
8448
+ if (!rgb) return null;
8449
+ const channels = rgb.slice(1, 4).map(Number);
8450
+ if (channels.some((channel)=>channel < 0 || channel > 255)) return null;
8451
+ return `#${channels.map((channel)=>channel.toString(16).padStart(2, '0')).join('')}`;
8452
+ }
8453
+ function documentUnderlineStyle(editor) {
8454
+ return documentUnderlineFormatting(editor)?.style ?? 'none';
8455
+ }
8456
+ function documentUnderlineColor(editor) {
8457
+ return documentUnderlineFormatting(editor)?.color ?? null;
8458
+ }
8459
+ function documentUnderlineFormatting(editor) {
8460
+ if (editor.isDestroyed || !editor.isActive('underline')) return null;
8461
+ return documentUnderlineFormattingFromMarkAttributes(editor.getAttributes('underline'));
8462
+ }
8463
+ function documentUnderlineFormattingFromElement(element) {
8464
+ const declaredStyle = normalizeDocumentUnderlineStyle(element.getAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE));
8465
+ const cssLine = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
8466
+ const style = declaredStyle ?? documentUnderlineStyleFromCss(element) ?? ('u' === element.tagName.toLowerCase() ? 'single' : cssLine.includes('none') ? 'none' : null);
8467
+ if (!style) return null;
8468
+ const themeColor = parseDocxThemeReference(element.getAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE));
8469
+ const color = normalizeDocumentUnderlineColor(element.getAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE)) ?? normalizeDocumentUnderlineColor(element.style.textDecorationColor) ?? themeColor?.resolved;
8470
+ return {
8471
+ style,
8472
+ ...color ? {
8473
+ color
8474
+ } : {},
8475
+ ...themeColor ? {
8476
+ themeColor
8477
+ } : {}
8478
+ };
8479
+ }
8480
+ function documentUnderlineDomAttributes(formatting) {
8481
+ const style = normalizeDocumentUnderlineStyle(formatting.style) ?? 'single';
8482
+ const color = normalizeDocumentUnderlineColor(formatting.color);
8483
+ const themeColor = serializeDocxThemeReference(formatting.themeColor ?? null);
8484
+ const declarations = documentUnderlineCssDeclarations({
8485
+ style,
8486
+ ...color ? {
8487
+ color
8488
+ } : {}
8489
+ });
8490
+ return {
8491
+ [DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE]: style,
8492
+ ...color ? {
8493
+ [DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE]: color
8494
+ } : {},
8495
+ ...themeColor ? {
8496
+ [DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE]: themeColor
8497
+ } : {},
8498
+ style: declarations.join('; ')
8499
+ };
8500
+ }
8501
+ function documentUnderlineMarkAttributes(editor, style, options = {}) {
8502
+ const current = documentUnderlineFormatting(editor);
8503
+ const color = void 0 === options.color ? current?.color ?? null : normalizeDocumentUnderlineColor(options.color);
8504
+ const requestedTheme = void 0 === options.themeColor ? current?.themeColor ?? null : documentUnderlineThemeReference(options.themeColor);
8505
+ const themeColor = requestedTheme && color === requestedTheme.resolved ? serializeDocxThemeReference(requestedTheme) ?? null : null;
8506
+ return {
8507
+ underlineStyle: style,
8508
+ underlineColor: color,
8509
+ underlineThemeColor: themeColor
8510
+ };
8511
+ }
8512
+ function documentUnderlineFormattingFromMarkAttributes(attributes) {
8513
+ const style = normalizeDocumentUnderlineStyle(attributes.underlineStyle) ?? 'single';
8514
+ const themeColor = 'string' == typeof attributes.underlineThemeColor ? parseDocxThemeReference(attributes.underlineThemeColor) : null;
8515
+ const color = normalizeDocumentUnderlineColor(attributes.underlineColor) ?? themeColor?.resolved;
8516
+ return {
8517
+ style,
8518
+ ...color ? {
8519
+ color
8520
+ } : {},
8521
+ ...themeColor ? {
8522
+ themeColor
8523
+ } : {}
8524
+ };
8525
+ }
8526
+ function documentUnderlineThemeReference(value) {
8527
+ if ('string' == typeof value) return parseDocxThemeReference(value);
8528
+ return value ? parseDocxThemeReference(serializeDocxThemeReference(value)) : null;
8529
+ }
8530
+ function documentUnderlineStyleFromCss(element) {
8531
+ const line = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
8532
+ if (line.includes('none')) return 'none';
8533
+ if (!line.includes('underline')) return null;
8534
+ switch(element.style.textDecorationStyle.trim().toLowerCase()){
8535
+ case 'double':
8536
+ return 'double';
8537
+ case 'dotted':
8538
+ return 'dotted';
8539
+ case 'dashed':
8540
+ return 'dash';
8541
+ case 'wavy':
8542
+ return 'wave';
8543
+ default:
8544
+ return 'single';
8545
+ }
8546
+ }
8547
+ function documentUnderlineCssDeclarations(formatting) {
8548
+ const { style, color } = formatting;
8549
+ if ('none' === style) return [
8550
+ 'text-decoration-line: none'
8551
+ ];
8552
+ const declarations = [
8553
+ 'text-decoration-line: underline',
8554
+ `text-decoration-style: ${documentUnderlineCssStyle(style)}`,
8555
+ 'text-underline-offset: 0.12em',
8556
+ 'text-decoration-skip-ink: auto'
8557
+ ];
8558
+ if (color) declarations.push(`text-decoration-color: ${color}`);
8559
+ if (HEAVY_UNDERLINE_STYLES.has(style)) declarations.push('text-decoration-thickness: 0.14em');
8560
+ return declarations;
8561
+ }
8562
+ function documentUnderlineCssStyle(style) {
8563
+ if ('double' === style) return 'double';
8564
+ if ('dotted' === style || 'dottedHeavy' === style) return 'dotted';
8565
+ if ('dash' === style || 'dashedHeavy' === style || 'dashLong' === style || 'dashLongHeavy' === style || 'dotDash' === style || 'dashDotHeavy' === style || 'dotDotDash' === style || 'dashDotDotHeavy' === style) return 'dashed';
8566
+ if ('wave' === style || 'wavyHeavy' === style || 'wavyDouble' === style) return 'wavy';
8567
+ return 'solid';
8568
+ }
8569
+ const workDocumentStrikeStyles = [
8570
+ 'none',
8571
+ 'single',
8572
+ 'double'
8573
+ ];
8574
+ const DOCUMENT_STRIKE_STYLE_ATTRIBUTE = 'data-office-strike-style';
8575
+ const STRIKE_STYLE_BY_NORMALIZED_VALUE = new Map(workDocumentStrikeStyles.map((style)=>[
8576
+ style,
8577
+ style
8578
+ ]));
8579
+ const DocumentStrike = extension_strike.extend({
8580
+ addAttributes () {
8581
+ return {
8582
+ strikeStyle: {
8583
+ default: 'single',
8584
+ parseHTML: (element)=>documentStrikeFormattingFromElement(element)?.style ?? 'single',
8585
+ renderHTML: ()=>({})
8586
+ }
8587
+ };
8588
+ },
8589
+ renderHTML ({ mark, HTMLAttributes }) {
8590
+ return [
8591
+ 's',
8592
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, documentStrikeDomAttributes(documentStrikeFormattingFromMarkAttributes(mark.attrs))),
8593
+ 0
8594
+ ];
8595
+ },
8596
+ addCommands () {
8597
+ return {
8598
+ setStrike: ()=>({ commands })=>commands.setMark(this.name, {
8599
+ strikeStyle: 'single'
8600
+ }),
8601
+ toggleStrike: ()=>({ commands, editor })=>commands.setMark(this.name, {
8602
+ strikeStyle: 'none' === documentStrikeStyle(editor) ? 'single' : 'none'
8603
+ }),
8604
+ unsetStrike: ()=>({ commands })=>commands.unsetMark(this.name),
8605
+ setDocumentStrike: (style)=>({ commands })=>commands.setMark(this.name, {
8606
+ strikeStyle: style
8607
+ }),
8608
+ toggleDocumentStrikeStyle: (style)=>({ commands, editor })=>commands.setMark(this.name, {
8609
+ strikeStyle: documentStrikeStyle(editor) === style ? 'none' : style
8610
+ })
8611
+ };
8612
+ },
8613
+ addKeyboardShortcuts () {
8614
+ return {};
8615
+ }
8616
+ });
8617
+ function normalizeDocumentStrikeStyle(value) {
8618
+ if ('string' != typeof value) return null;
8619
+ const normalized = value.trim().toLowerCase();
8620
+ if ('0' === normalized || 'false' === normalized || 'off' === normalized) return 'none';
8621
+ return STRIKE_STYLE_BY_NORMALIZED_VALUE.get(normalized) ?? null;
8622
+ }
8623
+ function documentStrikeStyle(editor) {
8624
+ return documentStrikeFormatting(editor)?.style ?? 'none';
8625
+ }
8626
+ function documentStrikeFormatting(editor) {
8627
+ if (editor.isDestroyed || !editor.isActive('strike')) return null;
8628
+ return documentStrikeFormattingFromMarkAttributes(editor.getAttributes('strike'));
8629
+ }
8630
+ function documentStrikeFormattingFromElement(element) {
8631
+ const declared = normalizeDocumentStrikeStyle(element.getAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE));
8632
+ const lines = element.style.textDecorationLine.trim().toLowerCase().split(/\s+/);
8633
+ const style = declared ?? (lines.includes('none') ? 'none' : lines.includes('line-through') ? 'double' === element.style.textDecorationStyle.trim().toLowerCase() ? 'double' : 'single' : [
8634
+ 'del',
8635
+ 's',
8636
+ 'strike'
8637
+ ].includes(element.tagName.toLowerCase()) ? 'single' : null);
8638
+ return style ? {
8639
+ style
8640
+ } : null;
7716
8641
  }
7717
- function tableRowIdentitySourceFromNode(node) {
8642
+ function documentStrikeDomAttributes(formatting) {
8643
+ const style = normalizeDocumentStrikeStyle(formatting.style) ?? 'single';
7718
8644
  return {
7719
- rowId: node.attrs.rowId,
7720
- rowTextId: node.attrs.rowTextId
8645
+ [DOCUMENT_STRIKE_STYLE_ATTRIBUTE]: style,
8646
+ style: 'none' === style ? 'text-decoration-line: none' : `text-decoration-line: line-through; text-decoration-style: ${'double' === style ? 'double' : 'solid'}; text-decoration-skip-ink: none`
7721
8647
  };
7722
8648
  }
7723
- function sameDocumentTableRowIdentity(source, identity) {
7724
- return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
7725
- }
7726
- function work_document_table_row_identity_transactionMapping(transactions) {
7727
- const mapping = new Mapping();
7728
- for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
7729
- return mapping;
8649
+ function documentStrikeFormattingFromMarkAttributes(attributes) {
8650
+ return {
8651
+ style: normalizeDocumentStrikeStyle(attributes.strikeStyle) ?? 'single'
8652
+ };
7730
8653
  }
7731
8654
  const EMPTY_CONTENT = {
7732
8655
  headerHtml: '',
@@ -7985,6 +8908,27 @@ function sanitizeAttributes(element, tag) {
7985
8908
  'justify'
7986
8909
  ].includes(element.style.textAlign) ? element.style.textAlign : '';
7987
8910
  const color = element.style.color;
8911
+ const scriptFonts = 'span' === tag ? documentScriptFontsFromElement(element) : null;
8912
+ const scriptFontSlot = 'span' === tag ? documentScriptFontSlotFromElement(element) : null;
8913
+ const scriptFontAttributes = scriptFonts ? documentScriptFontsDomAttributes(scriptFonts, scriptFontSlot) : {};
8914
+ const fontFamily = (scriptFonts ? documentScriptFontFamilyForRendering(scriptFonts, scriptFontSlot ?? documentScriptFontSlotFromHint(scriptFonts.hint), element.style.fontFamily) : null) ?? cssDocumentFontFamily(documentFontNameFromCssFamily(element.style.fontFamily));
8915
+ const fontSize = 'span' === tag ? normalizedPageChromeFontSize(element.style.fontSize) : null;
8916
+ const textCase = 'span' === tag ? normalizeDocumentTextCase(element.getAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE)) : null;
8917
+ const characterSpacing = 'span' === tag ? documentCharacterSpacingTwipsFromElement(element) : null;
8918
+ const characterScale = 'span' === tag ? documentCharacterScalePercentFromElement(element) : null;
8919
+ const characterScaleAttributes = documentCharacterScaleDomAttributes(characterScale);
8920
+ const characterPosition = 'span' === tag ? documentCharacterPositionHalfPointsFromElement(element) : null;
8921
+ const characterPositionAttributes = documentCharacterPositionDomAttributes(characterPosition);
8922
+ const characterSpacingAttributes = documentCharacterSpacingDomAttributes(characterSpacing);
8923
+ const kerningThreshold = 'span' === tag ? documentKerningThresholdHalfPointsFromElement(element) : null;
8924
+ const kerningAttributes = documentKerningDomAttributes(kerningThreshold, fontSize);
8925
+ const emphasisMark = 'span' === tag ? documentEmphasisMarkFromElement(element) : null;
8926
+ const emphasisAttributes = documentEmphasisMarkDomAttributes(emphasisMark);
8927
+ const hiddenText = 'span' === tag ? documentHiddenTextFromElement(element) : null;
8928
+ const underline = 'u' === tag ? documentUnderlineFormattingFromElement(element) : null;
8929
+ const underlineAttributes = underline ? documentUnderlineDomAttributes(underline) : {};
8930
+ const strike = 's' === tag || 'strike' === tag ? documentStrikeFormattingFromElement(element) : null;
8931
+ const strikeAttributes = strike ? documentStrikeDomAttributes(strike) : {};
7988
8932
  const paragraphShading = 'p' === tag ? parseDocumentParagraphShadingElement(element) : null;
7989
8933
  const shadingAttributes = documentParagraphShadingDomAttributes(paragraphShading);
7990
8934
  const paragraphBorders = 'p' === tag ? parseDocumentParagraphBordersElement(element) : null;
@@ -7993,9 +8937,31 @@ function sanitizeAttributes(element, tag) {
7993
8937
  element.removeAttribute('style');
7994
8938
  element.removeAttribute(PARAGRAPH_BORDERS_ATTRIBUTE);
7995
8939
  element.removeAttribute(PARAGRAPH_SHADING_ATTRIBUTE);
8940
+ element.removeAttribute(DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE);
8941
+ element.removeAttribute(DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE);
8942
+ element.removeAttribute(DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE);
8943
+ element.removeAttribute(DOCUMENT_STRIKE_STYLE_ATTRIBUTE);
8944
+ element.removeAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE);
8945
+ element.removeAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE);
8946
+ element.removeAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE);
8947
+ element.removeAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE);
8948
+ element.removeAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE);
8949
+ element.removeAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE);
8950
+ element.removeAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE);
8951
+ element.removeAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE);
7996
8952
  const styles = [
7997
8953
  textAlign ? `text-align: ${textAlign}` : '',
7998
8954
  color ? `color: ${color}` : '',
8955
+ fontFamily ? `font-family: ${fontFamily}` : '',
8956
+ fontSize ? `font-size: ${fontSize}` : '',
8957
+ textCase ? documentTextCaseCss(textCase) : '',
8958
+ characterScaleAttributes.style ?? '',
8959
+ characterPositionAttributes.style ?? '',
8960
+ characterSpacingAttributes.style ?? '',
8961
+ kerningAttributes.style ?? '',
8962
+ emphasisAttributes.style ?? '',
8963
+ underlineAttributes.style ?? '',
8964
+ strikeAttributes.style ?? '',
7999
8965
  borderAttributes.style ?? '',
8000
8966
  shadingAttributes.style ?? ''
8001
8967
  ].filter(Boolean);
@@ -8028,6 +8994,23 @@ function sanitizeAttributes(element, tag) {
8028
8994
  normalizeParagraphDefaultCollapsedAttribute(element);
8029
8995
  }
8030
8996
  if ('tr' === tag) normalizeTableRowIdentityAttributes(element);
8997
+ if ('u' === tag) {
8998
+ for (const [name, value] of Object.entries(underlineAttributes))if ('style' !== name) element.setAttribute(name, value);
8999
+ }
9000
+ if ('s' === tag || 'strike' === tag) {
9001
+ for (const [name, value] of Object.entries(strikeAttributes))if ('style' !== name) element.setAttribute(name, value);
9002
+ }
9003
+ if ('span' === tag && textCase) element.setAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE, textCase);
9004
+ else element.removeAttribute(DOCUMENT_TEXT_CASE_ATTRIBUTE);
9005
+ if ('span' === tag && null !== characterSpacing) element.setAttribute(DOCUMENT_CHARACTER_SPACING_ATTRIBUTE, String(characterSpacing));
9006
+ if ('span' === tag && null !== characterScale) element.setAttribute(DOCUMENT_CHARACTER_SCALE_ATTRIBUTE, String(characterScale));
9007
+ if ('span' === tag && null !== characterPosition) element.setAttribute(DOCUMENT_CHARACTER_POSITION_ATTRIBUTE, String(characterPosition));
9008
+ if ('span' === tag && null !== kerningThreshold) element.setAttribute(DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE, String(kerningThreshold));
9009
+ if ('span' === tag && null !== emphasisMark) element.setAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE, emphasisMark);
9010
+ if ('span' === tag && null !== hiddenText) element.setAttribute(DOCUMENT_HIDDEN_TEXT_ATTRIBUTE, String(hiddenText));
9011
+ if ('span' === tag && scriptFonts) {
9012
+ for (const [name, value] of Object.entries(scriptFontAttributes))if ('style' !== name) element.setAttribute(name, value);
9013
+ }
8031
9014
  if ('ltr' === direction || 'rtl' === direction) element.setAttribute('dir', direction);
8032
9015
  else element.removeAttribute('dir');
8033
9016
  const allowed = 'span' === tag && 'true' === element.dataset.documentEquation ? new Set(EQUATION_ATTRIBUTES) : 'a' === tag ? new Set([
@@ -8064,10 +9047,37 @@ function sanitizeAttributes(element, tag) {
8064
9047
  'colspan',
8065
9048
  'dir',
8066
9049
  'rowspan',
8067
- 'style'
9050
+ 'style',
9051
+ ...'span' === tag ? [
9052
+ DOCUMENT_TEXT_CASE_ATTRIBUTE,
9053
+ DOCUMENT_CHARACTER_SCALE_ATTRIBUTE,
9054
+ DOCUMENT_CHARACTER_POSITION_ATTRIBUTE,
9055
+ DOCUMENT_CHARACTER_SPACING_ATTRIBUTE,
9056
+ DOCUMENT_KERNING_THRESHOLD_ATTRIBUTE,
9057
+ DOCUMENT_EMPHASIS_MARK_ATTRIBUTE,
9058
+ DOCUMENT_HIDDEN_TEXT_ATTRIBUTE,
9059
+ DOCUMENT_SCRIPT_FONTS_ATTRIBUTE,
9060
+ DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE
9061
+ ] : [],
9062
+ ...'u' === tag ? [
9063
+ DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE,
9064
+ DOCUMENT_UNDERLINE_COLOR_ATTRIBUTE,
9065
+ DOCUMENT_UNDERLINE_THEME_COLOR_ATTRIBUTE
9066
+ ] : [],
9067
+ ...'s' === tag || 'strike' === tag ? [
9068
+ DOCUMENT_STRIKE_STYLE_ATTRIBUTE
9069
+ ] : []
8068
9070
  ]);
8069
9071
  for (const attribute of Array.from(element.attributes))if (!allowed.has(attribute.name.toLowerCase())) element.removeAttribute(attribute.name);
8070
9072
  }
9073
+ function normalizedPageChromeFontSize(value) {
9074
+ const match = /^(\d+(?:\.\d*)?|\.\d+)(pt|px)$/iu.exec(value.trim());
9075
+ if (!match) return null;
9076
+ const amount = Number(match[1]);
9077
+ const points = match[2]?.toLowerCase() === 'px' ? 0.75 * amount : amount;
9078
+ if (!Number.isFinite(points) || points <= 0 || points > 512 || !Number.isSafeInteger(2 * points)) return null;
9079
+ return `${Number(points.toFixed(1))}pt`;
9080
+ }
8071
9081
  function normalizeTableRowIdentityAttributes(element) {
8072
9082
  const identity = normalizeDocumentTableRowIdentity({
8073
9083
  rowId: element.getAttribute(TABLE_ROW_IDENTITY_ATTRIBUTES[0]),
@@ -8948,20 +9958,35 @@ const CHARACTER_FORMAT_MARK_ORDER = new Map(DOCUMENT_CHARACTER_FORMAT_MARKS.map(
8948
9958
  name,
8949
9959
  index
8950
9960
  ]));
8951
- const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES = 4096;
9961
+ const MAX_CHARACTER_FORMAT_SNAPSHOT_BYTES = 8192;
8952
9962
  const MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH = 512;
8953
9963
  const ALLOWED_ATTRIBUTES = {
8954
9964
  bold: new Set(),
8955
9965
  italic: new Set(),
8956
- underline: new Set(),
8957
- strike: new Set(),
9966
+ underline: new Set([
9967
+ 'underlineColor',
9968
+ 'underlineStyle',
9969
+ 'underlineThemeColor'
9970
+ ]),
9971
+ strike: new Set([
9972
+ 'strikeStyle'
9973
+ ]),
8958
9974
  subscript: new Set(),
8959
9975
  superscript: new Set(),
8960
9976
  textStyle: new Set([
9977
+ 'characterScalePercent',
9978
+ 'characterPositionHalfPoints',
9979
+ 'characterSpacingTwips',
8961
9980
  'color',
8962
9981
  'fontFamily',
8963
9982
  'fontSize',
9983
+ 'emphasisMark',
9984
+ 'kerningThresholdHalfPoints',
9985
+ 'hiddenText',
9986
+ "scriptFonts",
9987
+ "scriptFontSlot",
8964
9988
  'themeColor',
9989
+ 'textCase',
8965
9990
  'wordLineHeightFactor',
8966
9991
  'wordSnapToGrid'
8967
9992
  ]),
@@ -9023,18 +10048,39 @@ function importedDocumentCharacterFormatting(formatting) {
9023
10048
  for (const name of [
9024
10049
  'bold',
9025
10050
  'italic',
9026
- 'underline',
9027
- 'strike',
9028
10051
  "subscript",
9029
10052
  "superscript"
9030
10053
  ])if (formatting[name]) marks.push({
9031
10054
  type: name
9032
10055
  });
10056
+ if (formatting.strike) marks.push({
10057
+ type: 'strike',
10058
+ attrs: {
10059
+ strikeStyle: formatting.strike.style
10060
+ }
10061
+ });
10062
+ if (formatting.underline) marks.push({
10063
+ type: 'underline',
10064
+ attrs: compactAttributes({
10065
+ underlineColor: formatting.underline.color,
10066
+ underlineStyle: formatting.underline.style,
10067
+ underlineThemeColor: serializeDocxThemeReference(formatting.underline.themeColor ?? null)
10068
+ })
10069
+ });
9033
10070
  const textStyle = compactAttributes({
10071
+ characterScalePercent: formatting.characterScalePercent,
10072
+ characterPositionHalfPoints: formatting.characterPositionHalfPoints,
10073
+ characterSpacingTwips: formatting.characterSpacingTwips,
10074
+ kerningThresholdHalfPoints: formatting.kerningThresholdHalfPoints,
10075
+ emphasisMark: formatting.emphasisMark,
10076
+ hiddenText: formatting.hiddenText,
9034
10077
  color: formatting.color,
9035
10078
  fontFamily: formatting.fontFamily,
10079
+ scriptFonts: serializeDocumentScriptFonts(formatting.scriptFonts) ?? void 0,
10080
+ scriptFontSlot: formatting.scriptFontSlot,
9036
10081
  fontSize: void 0 === formatting.fontSize ? void 0 : `${formatting.fontSize}pt`,
9037
10082
  themeColor: formatting.themeColor,
10083
+ textCase: formatting.textCase,
9038
10084
  wordLineHeightFactor: formatting.wordLineHeightFactor,
9039
10085
  wordSnapToGrid: formatting.wordSnapToGrid
9040
10086
  });
@@ -9062,9 +10108,61 @@ function normalizeCharacterFormatMark(value) {
9062
10108
  if (void 0 !== source && !work_document_format_changes_isRecord(source)) return null;
9063
10109
  const attrs = {};
9064
10110
  for (const [key, candidate] of Object.entries(source ?? {}))if (allowed.has(key) && null != candidate) {
10111
+ if ('textStyle' === type && 'characterSpacingTwips' === key) {
10112
+ const spacing = normalizeDocumentCharacterSpacingTwips(candidate);
10113
+ if (null === spacing) return null;
10114
+ attrs[key] = spacing;
10115
+ continue;
10116
+ }
10117
+ if ('textStyle' === type && 'characterPositionHalfPoints' === key) {
10118
+ const position = normalizeDocumentCharacterPositionHalfPoints(candidate);
10119
+ if (null === position) return null;
10120
+ attrs[key] = position;
10121
+ continue;
10122
+ }
10123
+ if ('textStyle' === type && 'characterScalePercent' === key) {
10124
+ const scale = normalizeDocumentCharacterScalePercent(candidate);
10125
+ if (null === scale) return null;
10126
+ attrs[key] = scale;
10127
+ continue;
10128
+ }
10129
+ if ('textStyle' === type && 'kerningThresholdHalfPoints' === key) {
10130
+ const threshold = normalizeDocumentKerningThresholdHalfPoints(candidate);
10131
+ if (null === threshold) return null;
10132
+ attrs[key] = threshold;
10133
+ continue;
10134
+ }
10135
+ if ('textStyle' === type && 'emphasisMark' === key) {
10136
+ const emphasisMark = normalizeDocumentEmphasisMark(candidate);
10137
+ if (null === emphasisMark) return null;
10138
+ attrs[key] = emphasisMark;
10139
+ continue;
10140
+ }
10141
+ if ('textStyle' === type && 'hiddenText' === key) {
10142
+ const hiddenText = normalizeDocumentHiddenText(candidate);
10143
+ if (null === hiddenText) return null;
10144
+ attrs[key] = hiddenText;
10145
+ continue;
10146
+ }
10147
+ if ('textStyle' === type && "scriptFonts" === key) {
10148
+ const fonts = 'string' == typeof candidate ? serializeDocumentScriptFonts(parseDocumentScriptFonts(candidate)) : serializeDocumentScriptFonts(normalizeDocumentScriptFonts(candidate));
10149
+ if (!fonts) return null;
10150
+ attrs[key] = fonts;
10151
+ continue;
10152
+ }
10153
+ if ('textStyle' === type && "scriptFontSlot" === key) {
10154
+ const slot = normalizeDocumentScriptFontSlot(candidate);
10155
+ if (!slot) return null;
10156
+ attrs[key] = slot;
10157
+ continue;
10158
+ }
9065
10159
  if ('string' == typeof candidate) {
9066
- if (!candidate.length || candidate.length > MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH) return null;
9067
- attrs[key] = candidate;
10160
+ if (!candidate.length) continue;
10161
+ if ('textStyle' === type && 'textCase' === key && !normalizeDocumentTextCase(candidate)) return null;
10162
+ if (candidate.length > MAX_CHARACTER_FORMAT_ATTRIBUTE_LENGTH) return null;
10163
+ const normalized = normalizeCharacterFormatStringAttribute(type, key, candidate);
10164
+ if (!normalized) return null;
10165
+ attrs[key] = normalized;
9068
10166
  continue;
9069
10167
  }
9070
10168
  if ('boolean' == typeof candidate) {
@@ -9089,6 +10187,14 @@ function normalizeCharacterFormatMark(value) {
9089
10187
  } : {}
9090
10188
  };
9091
10189
  }
10190
+ function normalizeCharacterFormatStringAttribute(type, key, value) {
10191
+ if ('strike' === type) return 'strikeStyle' === key ? normalizeDocumentStrikeStyle(value) : null;
10192
+ if ('underline' !== type) return value;
10193
+ if ('underlineStyle' === key) return normalizeDocumentUnderlineStyle(value);
10194
+ if ('underlineColor' === key) return normalizeDocumentUnderlineColor(value);
10195
+ if ('underlineThemeColor' === key) return serializeDocxThemeReference(parseDocxThemeReference(value)) ?? null;
10196
+ return null;
10197
+ }
9092
10198
  function compareCharacterFormatMarks(left, right) {
9093
10199
  return (CHARACTER_FORMAT_MARK_ORDER.get(left.type) ?? Number.MAX_SAFE_INTEGER) - (CHARACTER_FORMAT_MARK_ORDER.get(right.type) ?? Number.MAX_SAFE_INTEGER);
9094
10200
  }
@@ -9097,6 +10203,7 @@ function createCharacterFormatMark(type, value) {
9097
10203
  }
9098
10204
  function compactAttributes(value) {
9099
10205
  const entries = Object.entries(value).filter((entry)=>void 0 !== entry[1]);
10206
+ entries.sort(([left], [right])=>left < right ? -1 : left > right ? 1 : 0);
9100
10207
  return entries.length ? Object.fromEntries(entries) : void 0;
9101
10208
  }
9102
10209
  function work_document_format_changes_isRecord(value) {
@@ -9933,6 +11040,70 @@ function createDocumentChangeId() {
9933
11040
  const random = "u" > typeof crypto && 'function' == typeof crypto.randomUUID ? crypto.randomUUID() : `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
9934
11041
  return `change-${random}`;
9935
11042
  }
11043
+ const DocumentCharacterFormatting = Extension.create({
11044
+ name: 'documentCharacterFormatting',
11045
+ addCommands () {
11046
+ return {
11047
+ setDocumentCharacterScale: (characterScalePercent)=>({ commands })=>{
11048
+ const scale = normalizeDocumentCharacterScalePercent(characterScalePercent);
11049
+ return null === scale ? false : commands.setMark('textStyle', {
11050
+ characterScalePercent: scale
11051
+ });
11052
+ },
11053
+ setDocumentCharacterPosition: (characterPositionHalfPoints)=>({ commands })=>{
11054
+ const position = normalizeDocumentCharacterPositionHalfPoints(characterPositionHalfPoints);
11055
+ return null === position ? false : commands.setMark('textStyle', {
11056
+ characterPositionHalfPoints: position
11057
+ });
11058
+ },
11059
+ setDocumentCharacterSpacing: (characterSpacingTwips)=>({ commands })=>{
11060
+ const spacing = normalizeDocumentCharacterSpacingTwips(characterSpacingTwips);
11061
+ return null === spacing ? false : commands.setMark('textStyle', {
11062
+ characterSpacingTwips: spacing
11063
+ });
11064
+ },
11065
+ setDocumentKerningThreshold: (kerningThresholdHalfPoints)=>({ commands })=>{
11066
+ const threshold = normalizeDocumentKerningThresholdHalfPoints(kerningThresholdHalfPoints);
11067
+ return null === threshold ? false : commands.setMark('textStyle', {
11068
+ kerningThresholdHalfPoints: threshold
11069
+ });
11070
+ },
11071
+ unsetDocumentKerningThreshold: ()=>({ chain })=>chain().setMark('textStyle', {
11072
+ kerningThresholdHalfPoints: null
11073
+ }).removeEmptyTextStyle().run(),
11074
+ setDocumentEmphasisMark: (emphasisMark)=>({ commands })=>{
11075
+ const mark = normalizeDocumentEmphasisMark(emphasisMark);
11076
+ return null === mark ? false : commands.setMark('textStyle', {
11077
+ emphasisMark: mark
11078
+ });
11079
+ },
11080
+ unsetDocumentEmphasisMark: ()=>({ chain })=>chain().setMark('textStyle', {
11081
+ emphasisMark: null
11082
+ }).removeEmptyTextStyle().run(),
11083
+ setDocumentHiddenText: (hiddenText)=>({ commands })=>'boolean' == typeof hiddenText ? commands.setMark('textStyle', {
11084
+ hiddenText
11085
+ }) : false,
11086
+ unsetDocumentHiddenText: ()=>({ chain })=>chain().setMark('textStyle', {
11087
+ hiddenText: null
11088
+ }).removeEmptyTextStyle().run(),
11089
+ toggleDocumentHiddenText: ()=>({ commands, editor })=>commands.setDocumentHiddenText(!(normalizeDocumentHiddenText(editor.getAttributes('textStyle').hiddenText) ?? false)),
11090
+ setDocumentTextCase: (textCase)=>({ chain })=>chain().focus().setMark('textStyle', {
11091
+ textCase
11092
+ }).run(),
11093
+ toggleDocumentTextCase: (textCase)=>({ commands, editor })=>{
11094
+ const current = normalizeDocumentTextCase(editor.getAttributes('textStyle').textCase) ?? 'none';
11095
+ return commands.setDocumentTextCase(current === textCase ? 'none' : textCase);
11096
+ }
11097
+ };
11098
+ },
11099
+ addKeyboardShortcuts () {
11100
+ return {
11101
+ [documentTextCaseKeyboardShortcuts.allCaps]: ()=>this.editor.commands.toggleDocumentTextCase('all-caps'),
11102
+ [documentTextCaseKeyboardShortcuts.smallCaps]: ()=>this.editor.commands.toggleDocumentTextCase('small-caps'),
11103
+ [documentHiddenTextKeyboardShortcut]: ()=>this.editor.commands.toggleDocumentHiddenText()
11104
+ };
11105
+ }
11106
+ });
9936
11107
  const DocumentSubscript = extension_subscript.extend({
9937
11108
  excludes: "superscript",
9938
11109
  addCommands () {
@@ -14598,6 +15769,7 @@ function documentTextLayoutContent(node) {
14598
15769
  return supported ? content.join('') : null;
14599
15770
  }
14600
15771
  function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontIds, paragraphStyle = documentTextParagraphStyle(getComputedStyle(element))) {
15772
+ if (element.matches(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`) || element.querySelector(`[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}="true"]`)) return null;
14601
15773
  if (!paragraphStyle) return null;
14602
15774
  const tokens = documentTextLayoutDomTokens(element);
14603
15775
  if (!tokens) return null;
@@ -14605,7 +15777,7 @@ function collectDocumentTextLayoutRuns(element, expectedText, fonts, loadedFontI
14605
15777
  const runs = [];
14606
15778
  let utf16Offset = 0;
14607
15779
  for (const token of tokens){
14608
- const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement === element);
15780
+ const runStyle = documentTextLayoutRunStyle(getComputedStyle(token.styleElement), fonts, loadedFontIds, paragraphStyle, token.styleElement, token.styleElement === element);
14609
15781
  if (!runStyle) return null;
14610
15782
  const startUtf16 = utf16Offset;
14611
15783
  utf16Offset += token.text.length;
@@ -14657,10 +15829,10 @@ function documentTextParagraphStyle(style) {
14657
15829
  whiteSpace: 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal'
14658
15830
  };
14659
15831
  }
14660
- function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, paragraphRoot) {
15832
+ function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle, element, paragraphRoot) {
14661
15833
  const direction = 'rtl' === style.direction ? 'rtl' : 'ltr';
14662
15834
  const whiteSpace = 'break-spaces' === style.whiteSpace ? 'breakSpaces' : 'normal';
14663
- 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%') || !cssValueIs(style.verticalAlign, 'baseline') || !cssValueIs(style.unicodeBidi, 'normal') && !(paragraphRoot && 'isolate' === style.unicodeBidi)) return null;
15835
+ 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;
14664
15836
  const fontStyle = style.fontStyle && 'normal' !== style.fontStyle ? 'italic' === style.fontStyle ? 'italic' : null : 'normal';
14665
15837
  if (!fontStyle) return null;
14666
15838
  const families = cssFontFamilies(style.fontFamily);
@@ -14733,6 +15905,19 @@ function documentTextLayoutRunStyleKey(style) {
14733
15905
  function cssValueIs(value, ...supported) {
14734
15906
  return !value || supported.includes(value);
14735
15907
  }
15908
+ function documentTextEmphasisAllowsKernel(style, element) {
15909
+ for(let current = element; current; current = current.parentElement){
15910
+ if (!current.hasAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE)) continue;
15911
+ const emphasisMark = normalizeDocumentEmphasisMark(current.getAttribute(DOCUMENT_EMPHASIS_MARK_ATTRIBUTE));
15912
+ if (null !== emphasisMark) {
15913
+ if ('none' !== emphasisMark) return false;
15914
+ break;
15915
+ }
15916
+ }
15917
+ const standard = style.getPropertyValue('text-emphasis-style').trim();
15918
+ const webkit = style.getPropertyValue('-webkit-text-emphasis-style').trim();
15919
+ return (!standard || 'none' === standard) && (!webkit || 'none' === webkit);
15920
+ }
14736
15921
  function cssLigatures(style) {
14737
15922
  const variant = style.fontVariantLigatures;
14738
15923
  if (variant && 'normal' !== variant && 'none' !== variant) return null;
@@ -16196,34 +17381,371 @@ const DocumentSection = core_Node.create({
16196
17381
  ] : []
16197
17382
  ].join(';');
16198
17383
  return [
16199
- 'section',
16200
- mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
16201
- class: 'work-document-section',
16202
- style
16203
- }),
16204
- 0
17384
+ 'section',
17385
+ mergeAttributes(HTMLAttributes, documentSectionDomAttributes(layout, id), {
17386
+ class: 'work-document-section',
17387
+ style
17388
+ }),
17389
+ 0
17390
+ ];
17391
+ }
17392
+ });
17393
+ function work_document_section_node_hiddenAttribute(defaultValue) {
17394
+ return {
17395
+ default: defaultValue,
17396
+ rendered: false
17397
+ };
17398
+ }
17399
+ function numberAttribute(element, name, fallback) {
17400
+ const value = Number(element.dataset[name]);
17401
+ return Number.isFinite(value) ? value : fallback;
17402
+ }
17403
+ function nullableNumberAttribute(element, name) {
17404
+ const source = element.dataset[name];
17405
+ if (!source?.trim()) return null;
17406
+ const value = Number(source);
17407
+ return Number.isFinite(value) ? value : null;
17408
+ }
17409
+ function sectionBreakAttribute(value) {
17410
+ if ('continuous' === value || 'evenPage' === value || 'oddPage' === value || 'nextColumn' === value) return value;
17411
+ return 'nextPage';
17412
+ }
17413
+ const DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT = 1.15;
17414
+ const DOCUMENT_WORD_LINE_HEIGHT_FACTORS = new Map([
17415
+ [
17416
+ 'arial',
17417
+ 1.15
17418
+ ],
17419
+ [
17420
+ 'times new roman',
17421
+ 1.15
17422
+ ],
17423
+ [
17424
+ 'calibri',
17425
+ 1.2207
17426
+ ],
17427
+ [
17428
+ 'segoe ui',
17429
+ 1.3301
17430
+ ],
17431
+ [
17432
+ 'microsoft yahei',
17433
+ 1.7143
17434
+ ],
17435
+ [
17436
+ 'microsoft yahei ui',
17437
+ 1.7143
17438
+ ],
17439
+ [
17440
+ 'simsun',
17441
+ 1.2976
17442
+ ],
17443
+ [
17444
+ 'simhei',
17445
+ 1.2976
17446
+ ],
17447
+ [
17448
+ 'fangsong',
17449
+ 1.2976
17450
+ ],
17451
+ [
17452
+ 'kaiti',
17453
+ 1.2976
17454
+ ],
17455
+ [
17456
+ 'dengxian',
17457
+ 1.3548
17458
+ ]
17459
+ ]);
17460
+ function documentWordLineHeightFactor(fontFamily) {
17461
+ if ('string' != typeof fontFamily) return DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
17462
+ const family = firstCssFontFamily(fontFamily).toLocaleLowerCase();
17463
+ return DOCUMENT_WORD_LINE_HEIGHT_FACTORS.get(family) ?? DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
17464
+ }
17465
+ function normalizedDocumentWordLineHeightFactor(value) {
17466
+ if (null == value || '' === value) return null;
17467
+ const factor = Number(value);
17468
+ if (!Number.isFinite(factor) || factor < 0.5 || factor > 4) return null;
17469
+ return Number(factor.toFixed(4));
17470
+ }
17471
+ const DocumentTextStyle = TextStyle.extend({
17472
+ parseHTML () {
17473
+ return [
17474
+ ...this.parent?.() ?? [],
17475
+ {
17476
+ tag: `span[${DOCUMENT_HIDDEN_TEXT_ATTRIBUTE}]`,
17477
+ consuming: false
17478
+ }
17479
+ ];
17480
+ },
17481
+ addCommands () {
17482
+ return {
17483
+ ...this.parent?.() ?? {},
17484
+ removeEmptyTextStyle: ()=>({ tr })=>{
17485
+ const { from, to } = tr.selection;
17486
+ tr.doc.nodesBetween(from, to, (node, position)=>{
17487
+ if (!node.isText) return true;
17488
+ const mark = node.marks.find((candidate)=>candidate.type === this.type && documentTextStyleAttributesAreEmpty(candidate.attrs));
17489
+ if (mark) tr.removeMark(Math.max(position, from), Math.min(position + node.nodeSize, to), mark);
17490
+ return false;
17491
+ });
17492
+ return true;
17493
+ }
17494
+ };
17495
+ },
17496
+ addAttributes () {
17497
+ return {
17498
+ characterScalePercent: {
17499
+ default: null,
17500
+ parseHTML: (element)=>documentCharacterScalePercentFromElement(element),
17501
+ renderHTML: (attributes)=>documentCharacterScaleDomAttributes(normalizeDocumentCharacterScalePercent(attributes.characterScalePercent))
17502
+ },
17503
+ characterPositionHalfPoints: {
17504
+ default: null,
17505
+ parseHTML: (element)=>documentCharacterPositionHalfPointsFromElement(element),
17506
+ renderHTML: (attributes)=>documentCharacterPositionDomAttributes(normalizeDocumentCharacterPositionHalfPoints(attributes.characterPositionHalfPoints))
17507
+ },
17508
+ characterSpacingTwips: {
17509
+ default: null,
17510
+ parseHTML: (element)=>documentCharacterSpacingTwipsFromElement(element),
17511
+ renderHTML: (attributes)=>documentCharacterSpacingDomAttributes(normalizeDocumentCharacterSpacingTwips(attributes.characterSpacingTwips))
17512
+ },
17513
+ emphasisMark: {
17514
+ default: null,
17515
+ parseHTML: (element)=>documentEmphasisMarkFromElement(element),
17516
+ renderHTML: (attributes)=>documentEmphasisMarkDomAttributes(normalizeDocumentEmphasisMark(attributes.emphasisMark))
17517
+ },
17518
+ hiddenText: {
17519
+ default: null,
17520
+ parseHTML: (element)=>documentHiddenTextFromElement(element),
17521
+ renderHTML: (attributes)=>documentHiddenTextDomAttributes(attributes.hiddenText)
17522
+ },
17523
+ kerningThresholdHalfPoints: {
17524
+ default: null,
17525
+ parseHTML: (element)=>documentKerningThresholdHalfPointsFromElement(element),
17526
+ renderHTML: (attributes)=>documentKerningDomAttributes(normalizeDocumentKerningThresholdHalfPoints(attributes.kerningThresholdHalfPoints), attributes.fontSize)
17527
+ },
17528
+ scriptFonts: {
17529
+ default: null,
17530
+ parseHTML: (element)=>serializeDocumentScriptFonts(parseDocumentScriptFonts(element.dataset.officeScriptFonts)),
17531
+ renderHTML: (attributes)=>{
17532
+ const domAttributes = documentScriptFontsDomAttributes('string' == typeof attributes.scriptFonts ? parseDocumentScriptFonts(attributes.scriptFonts) : attributes.scriptFonts, attributes.scriptFontSlot);
17533
+ delete domAttributes.style;
17534
+ return domAttributes;
17535
+ }
17536
+ },
17537
+ scriptFontSlot: {
17538
+ default: null,
17539
+ parseHTML: (element)=>normalizeDocumentScriptFontSlot(element.dataset.officeScriptFontSlot),
17540
+ renderHTML: ()=>({})
17541
+ },
17542
+ wordLineHeightFactor: {
17543
+ default: null,
17544
+ parseHTML: (element)=>normalizedDocumentWordLineHeightFactor(element.dataset.officeWordLineHeightFactor ?? element.style.getPropertyValue('--work-document-word-line-height-factor')),
17545
+ renderHTML: (attributes)=>{
17546
+ const factor = normalizedDocumentWordLineHeightFactor(attributes.wordLineHeightFactor);
17547
+ if (null === factor) return {};
17548
+ return {
17549
+ 'data-office-word-line-height-factor': String(factor),
17550
+ style: `--work-document-word-line-height-factor: ${factor}`
17551
+ };
17552
+ }
17553
+ },
17554
+ wordSnapToGrid: {
17555
+ default: null,
17556
+ parseHTML: (element)=>normalizedBoolean(element.dataset.officeWordSnapToGrid),
17557
+ renderHTML: (attributes)=>{
17558
+ const value = normalizedBoolean(attributes.wordSnapToGrid);
17559
+ return null === value ? {} : {
17560
+ 'data-office-word-snap-to-grid': String(value)
17561
+ };
17562
+ }
17563
+ },
17564
+ themeColor: themeReferenceAttribute('officeThemeColor'),
17565
+ textCase: {
17566
+ default: null,
17567
+ parseHTML: (element)=>normalizeDocumentTextCase(element.dataset.officeTextCase),
17568
+ renderHTML: (attributes)=>{
17569
+ const textCase = normalizeDocumentTextCase(attributes.textCase);
17570
+ return textCase ? {
17571
+ [DOCUMENT_TEXT_CASE_ATTRIBUTE]: textCase,
17572
+ style: documentTextCaseCss(textCase)
17573
+ } : {};
17574
+ }
17575
+ }
17576
+ };
17577
+ }
17578
+ });
17579
+ function documentTextStyleAttributesAreEmpty(attributes) {
17580
+ return Object.values(attributes).every((value)=>null == value || '' === value);
17581
+ }
17582
+ const DocumentHighlight = extension_highlight.extend({
17583
+ addKeyboardShortcuts () {
17584
+ return {};
17585
+ },
17586
+ addAttributes () {
17587
+ return {
17588
+ ...this.parent?.(),
17589
+ themeFill: themeReferenceAttribute('officeThemeFill')
17590
+ };
17591
+ },
17592
+ parseHTML () {
17593
+ return [
17594
+ ...this.parent?.() ?? [],
17595
+ {
17596
+ tag: 'span[data-office-theme-fill]'
17597
+ },
17598
+ {
17599
+ tag: 'span[style*="background-color"]'
17600
+ }
16205
17601
  ];
16206
17602
  }
16207
17603
  });
16208
- function work_document_section_node_hiddenAttribute(defaultValue) {
17604
+ const DocumentFontFamily = font_family.extend({
17605
+ addCommands () {
17606
+ return {
17607
+ setFontFamily: (fontFamily)=>({ chain })=>{
17608
+ const scriptFonts = serializeDocumentScriptFonts(documentScriptFontsForAllText(fontFamily));
17609
+ return chain().setMark('textStyle', {
17610
+ fontFamily,
17611
+ scriptFonts,
17612
+ scriptFontSlot: null,
17613
+ wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
17614
+ }).run();
17615
+ },
17616
+ unsetFontFamily: ()=>({ chain })=>chain().setMark('textStyle', {
17617
+ fontFamily: null,
17618
+ scriptFonts: null,
17619
+ scriptFontSlot: null,
17620
+ wordLineHeightFactor: null
17621
+ }).removeEmptyTextStyle().run()
17622
+ };
17623
+ }
17624
+ });
17625
+ function firstCssFontFamily(value) {
17626
+ const source = value.trim();
17627
+ if (!source) return '';
17628
+ const quote = source[0];
17629
+ if ('"' === quote || "'" === quote) {
17630
+ const end = source.indexOf(quote, 1);
17631
+ if (end > 0) return source.slice(1, end).trim();
17632
+ }
17633
+ return (source.split(',')[0] ?? source).trim().replace(/^(['"])(.*)\1$/, '$2');
17634
+ }
17635
+ function normalizedBoolean(value) {
17636
+ if (true === value || 'true' === value || '1' === value) return true;
17637
+ if (false === value || 'false' === value || '0' === value) return false;
17638
+ return null;
17639
+ }
17640
+ function themeReferenceAttribute(datasetKey) {
16209
17641
  return {
16210
- default: defaultValue,
16211
- rendered: false
17642
+ default: null,
17643
+ parseHTML: (element)=>serializeDocxThemeReference(parseDocxThemeReference(element.dataset[datasetKey])) ?? null,
17644
+ renderHTML: (attributes)=>{
17645
+ const value = serializeDocxThemeReference(parseDocxThemeReference('string' == typeof attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill'] ? String(attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill']) : null));
17646
+ return value ? {
17647
+ [`data-${toKebabCase(datasetKey)}`]: value
17648
+ } : {};
17649
+ }
16212
17650
  };
16213
17651
  }
16214
- function numberAttribute(element, name, fallback) {
16215
- const value = Number(element.dataset[name]);
16216
- return Number.isFinite(value) ? value : fallback;
17652
+ function toKebabCase(value) {
17653
+ return value.replace(/[A-Z]/g, (character)=>`-${character.toLowerCase()}`);
16217
17654
  }
16218
- function nullableNumberAttribute(element, name) {
16219
- const source = element.dataset[name];
16220
- if (!source?.trim()) return null;
16221
- const value = Number(source);
16222
- return Number.isFinite(value) ? value : null;
17655
+ const SCRIPT_FONT_NORMALIZATION_META = 'documentScriptFontNormalization';
17656
+ const documentScriptFontPluginKey = new PluginKey('documentScriptFontNormalization');
17657
+ const DocumentScriptFontFormatting = Extension.create({
17658
+ name: 'documentScriptFontFormatting',
17659
+ addProseMirrorPlugins () {
17660
+ return [
17661
+ new Plugin({
17662
+ key: documentScriptFontPluginKey,
17663
+ view (view) {
17664
+ const transaction = normalizeDocumentScriptFontMarks(view.state);
17665
+ if (transaction) view.dispatch(transaction);
17666
+ return {};
17667
+ },
17668
+ appendTransaction (transactions, _oldState, newState) {
17669
+ if (!transactions.some((transaction)=>transaction.docChanged) || transactions.some((transaction)=>transaction.getMeta(SCRIPT_FONT_NORMALIZATION_META))) return null;
17670
+ return normalizeDocumentScriptFontMarks(newState, changedDocumentRanges(transactions, newState), true);
17671
+ }
17672
+ })
17673
+ ];
17674
+ }
17675
+ });
17676
+ function normalizeDocumentScriptFontMarks(state, ranges, includeInHistory = false) {
17677
+ const textStyle = state.schema.marks.textStyle;
17678
+ if (!textStyle) return null;
17679
+ const updates = [];
17680
+ const visited = new Set();
17681
+ const visit = (node, position)=>{
17682
+ if (!node.isText || !node.text || visited.has(position)) return;
17683
+ visited.add(position);
17684
+ const current = node.marks.find((mark)=>mark.type === textStyle);
17685
+ const fonts = parseDocumentScriptFonts(current?.attrs.scriptFonts);
17686
+ if (!current || !fonts) return;
17687
+ const serialized = serializeDocumentScriptFonts(fonts);
17688
+ if (!serialized) return;
17689
+ for (const segment of documentScriptFontSegments(node.text, fonts.hint)){
17690
+ const family = documentScriptFontFamilyForRendering(fonts, segment.slot, current.attrs.fontFamily);
17691
+ const attributes = {
17692
+ ...current.attrs,
17693
+ scriptFonts: serialized,
17694
+ scriptFontSlot: segment.slot,
17695
+ ...family ? {
17696
+ fontFamily: family,
17697
+ wordLineHeightFactor: documentWordLineHeightFactor(family)
17698
+ } : {}
17699
+ };
17700
+ const next = textStyle.create(attributes);
17701
+ if (!current.eq(next)) updates.push({
17702
+ from: position + segment.from,
17703
+ to: position + segment.to,
17704
+ current,
17705
+ next
17706
+ });
17707
+ }
17708
+ };
17709
+ if (ranges?.length) for (const range of ranges)state.doc.nodesBetween(range.from, range.to, visit);
17710
+ else state.doc.descendants(visit);
17711
+ if (!updates.length) return null;
17712
+ const transaction = state.tr;
17713
+ for (const update of updates){
17714
+ transaction.removeMark(update.from, update.to, update.current);
17715
+ transaction.addMark(update.from, update.to, update.next);
17716
+ }
17717
+ transaction.setMeta(SCRIPT_FONT_NORMALIZATION_META, true);
17718
+ if (!includeInHistory) transaction.setMeta('addToHistory', false);
17719
+ return transaction;
16223
17720
  }
16224
- function sectionBreakAttribute(value) {
16225
- if ('continuous' === value || 'evenPage' === value || 'oddPage' === value || 'nextColumn' === value) return value;
16226
- return 'nextPage';
17721
+ function changedDocumentRanges(transactions, state) {
17722
+ const maximum = state.doc.content.size;
17723
+ const ranges = [];
17724
+ for (const transaction of transactions)for (const map of transaction.mapping.maps)map.forEach((_oldFrom, _oldTo, newFrom, newTo)=>{
17725
+ ranges.push(expandedRange(newFrom, newTo, maximum));
17726
+ });
17727
+ ranges.push(expandedRange(state.selection.from, state.selection.to, maximum));
17728
+ return mergeRanges(ranges);
17729
+ }
17730
+ function expandedRange(from, to, maximum) {
17731
+ return {
17732
+ from: Math.max(0, Math.min(maximum, Math.min(from, to) - 2)),
17733
+ to: Math.max(0, Math.min(maximum, Math.max(from, to) + 2))
17734
+ };
17735
+ }
17736
+ function mergeRanges(ranges) {
17737
+ const ordered = [
17738
+ ...ranges
17739
+ ].filter((range)=>range.to >= range.from).sort((left, right)=>left.from - right.from || left.to - right.to);
17740
+ const merged = [];
17741
+ for (const range of ordered){
17742
+ const previous = merged[merged.length - 1];
17743
+ if (previous && range.from <= previous.to) previous.to = Math.max(previous.to, range.to);
17744
+ else merged.push({
17745
+ ...range
17746
+ });
17747
+ }
17748
+ return merged;
16227
17749
  }
16228
17750
  const DOCUMENT_TAB_SELECTOR = 'span[data-document-tab]';
16229
17751
  const DOCUMENT_TAB_BLOCK_SELECTOR = 'p, h1, h2, h3, h4, h5, h6';
@@ -18258,156 +19780,6 @@ function commonNullableValue(values) {
18258
19780
  if (!values.length || values.some((value)=>null === value)) return null;
18259
19781
  return values.every((value)=>value === values[0]) ? values[0] : null;
18260
19782
  }
18261
- const DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT = 1.15;
18262
- const DOCUMENT_WORD_LINE_HEIGHT_FACTORS = new Map([
18263
- [
18264
- 'arial',
18265
- 1.15
18266
- ],
18267
- [
18268
- 'times new roman',
18269
- 1.15
18270
- ],
18271
- [
18272
- 'calibri',
18273
- 1.2207
18274
- ],
18275
- [
18276
- 'segoe ui',
18277
- 1.3301
18278
- ],
18279
- [
18280
- 'microsoft yahei',
18281
- 1.7143
18282
- ],
18283
- [
18284
- 'microsoft yahei ui',
18285
- 1.7143
18286
- ],
18287
- [
18288
- 'simsun',
18289
- 1.2976
18290
- ],
18291
- [
18292
- 'simhei',
18293
- 1.2976
18294
- ],
18295
- [
18296
- 'fangsong',
18297
- 1.2976
18298
- ],
18299
- [
18300
- 'kaiti',
18301
- 1.2976
18302
- ],
18303
- [
18304
- 'dengxian',
18305
- 1.3548
18306
- ]
18307
- ]);
18308
- function documentWordLineHeightFactor(fontFamily) {
18309
- if ('string' != typeof fontFamily) return DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
18310
- const family = firstCssFontFamily(fontFamily).toLocaleLowerCase();
18311
- return DOCUMENT_WORD_LINE_HEIGHT_FACTORS.get(family) ?? DOCUMENT_WORD_DEFAULT_SINGLE_LINE_HEIGHT;
18312
- }
18313
- function normalizedDocumentWordLineHeightFactor(value) {
18314
- if (null == value || '' === value) return null;
18315
- const factor = Number(value);
18316
- if (!Number.isFinite(factor) || factor < 0.5 || factor > 4) return null;
18317
- return Number(factor.toFixed(4));
18318
- }
18319
- const DocumentTextStyle = TextStyle.extend({
18320
- addAttributes () {
18321
- return {
18322
- wordLineHeightFactor: {
18323
- default: null,
18324
- parseHTML: (element)=>normalizedDocumentWordLineHeightFactor(element.dataset.officeWordLineHeightFactor ?? element.style.getPropertyValue('--work-document-word-line-height-factor')),
18325
- renderHTML: (attributes)=>{
18326
- const factor = normalizedDocumentWordLineHeightFactor(attributes.wordLineHeightFactor);
18327
- if (null === factor) return {};
18328
- return {
18329
- 'data-office-word-line-height-factor': String(factor),
18330
- style: `--work-document-word-line-height-factor: ${factor}`
18331
- };
18332
- }
18333
- },
18334
- wordSnapToGrid: {
18335
- default: null,
18336
- parseHTML: (element)=>normalizedBoolean(element.dataset.officeWordSnapToGrid),
18337
- renderHTML: (attributes)=>{
18338
- const value = normalizedBoolean(attributes.wordSnapToGrid);
18339
- return null === value ? {} : {
18340
- 'data-office-word-snap-to-grid': String(value)
18341
- };
18342
- }
18343
- },
18344
- themeColor: themeReferenceAttribute('officeThemeColor')
18345
- };
18346
- }
18347
- });
18348
- const DocumentHighlight = extension_highlight.extend({
18349
- addAttributes () {
18350
- return {
18351
- ...this.parent?.(),
18352
- themeFill: themeReferenceAttribute('officeThemeFill')
18353
- };
18354
- },
18355
- parseHTML () {
18356
- return [
18357
- ...this.parent?.() ?? [],
18358
- {
18359
- tag: 'span[data-office-theme-fill]'
18360
- },
18361
- {
18362
- tag: 'span[style*="background-color"]'
18363
- }
18364
- ];
18365
- }
18366
- });
18367
- const DocumentFontFamily = font_family.extend({
18368
- addCommands () {
18369
- return {
18370
- setFontFamily: (fontFamily)=>({ chain })=>chain().setMark('textStyle', {
18371
- fontFamily,
18372
- wordLineHeightFactor: documentWordLineHeightFactor(fontFamily)
18373
- }).run(),
18374
- unsetFontFamily: ()=>({ chain })=>chain().setMark('textStyle', {
18375
- fontFamily: null,
18376
- wordLineHeightFactor: null
18377
- }).removeEmptyTextStyle().run()
18378
- };
18379
- }
18380
- });
18381
- function firstCssFontFamily(value) {
18382
- const source = value.trim();
18383
- if (!source) return '';
18384
- const quote = source[0];
18385
- if ('"' === quote || "'" === quote) {
18386
- const end = source.indexOf(quote, 1);
18387
- if (end > 0) return source.slice(1, end).trim();
18388
- }
18389
- return (source.split(',')[0] ?? source).trim().replace(/^(['"])(.*)\1$/, '$2');
18390
- }
18391
- function normalizedBoolean(value) {
18392
- if (true === value || 'true' === value || '1' === value) return true;
18393
- if (false === value || 'false' === value || '0' === value) return false;
18394
- return null;
18395
- }
18396
- function themeReferenceAttribute(datasetKey) {
18397
- return {
18398
- default: null,
18399
- parseHTML: (element)=>serializeDocxThemeReference(parseDocxThemeReference(element.dataset[datasetKey])) ?? null,
18400
- renderHTML: (attributes)=>{
18401
- const value = serializeDocxThemeReference(parseDocxThemeReference('string' == typeof attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill'] ? String(attributes['officeThemeColor' === datasetKey ? 'themeColor' : 'themeFill']) : null));
18402
- return value ? {
18403
- [`data-${toKebabCase(datasetKey)}`]: value
18404
- } : {};
18405
- }
18406
- };
18407
- }
18408
- function toKebabCase(value) {
18409
- return value.replace(/[A-Z]/g, (character)=>`-${character.toLowerCase()}`);
18410
- }
18411
19783
  function createWorkDocumentExtensions(options = {}) {
18412
19784
  const changeExtension = DocumentChange.configure({
18413
19785
  ...options.isTracking ? {
@@ -18444,6 +19816,7 @@ function createWorkDocumentExtensions(options = {}) {
18444
19816
  openOnClick: false
18445
19817
  },
18446
19818
  underline: false,
19819
+ strike: false,
18447
19820
  bulletList: false,
18448
19821
  orderedList: false,
18449
19822
  trailingNode: {
@@ -18476,7 +19849,9 @@ function createWorkDocumentExtensions(options = {}) {
18476
19849
  commentExtension,
18477
19850
  DocumentNoteReference,
18478
19851
  DocumentNote,
18479
- extension_underline,
19852
+ DocumentUnderline,
19853
+ DocumentStrike,
19854
+ DocumentCharacterFormatting,
18480
19855
  DocumentSubscript,
18481
19856
  DocumentSuperscript,
18482
19857
  DocumentImage.configure({
@@ -18505,6 +19880,7 @@ function createWorkDocumentExtensions(options = {}) {
18505
19880
  DocumentTableFormatting,
18506
19881
  DocumentTableSizing,
18507
19882
  DocumentTextStyle,
19883
+ DocumentScriptFontFormatting,
18508
19884
  DocumentFontFamily,
18509
19885
  font_size,
18510
19886
  extension_color,
@@ -20327,4 +21703,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
20327
21703
  function documentPageSurfaceGeometryForElement(element) {
20328
21704
  return documentPageSurfaceProviders.get(element)?.() ?? null;
20329
21705
  }
20330
- 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_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_BORDER_EDGES, DOCUMENT_PARAGRAPH_BORDER_STYLES, DOCUMENT_PARAGRAPH_SHADING_PATTERNS, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DocumentEquation, DocumentImage, DocumentParagraphFormatting, DocumentParagraphIdentity, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocxThemePatchCollector, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentParagraphIdentityToElement, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createDocumentParagraphIdentityRegistry, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEquationFromElement, documentEquationText, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphBordersDomAttributes, documentParagraphDirection, documentParagraphIdentityFromElement, documentParagraphIndent, documentParagraphPagination, documentParagraphShadingDomAttributes, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isDocumentParagraphArtBorderStyle, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphBorder, normalizeDocumentParagraphBorders, normalizeDocumentParagraphId, normalizeDocumentParagraphIdentity, normalizeDocumentParagraphIndent, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphBordersElement, parseDocumentParagraphFormatting, parseDocumentParagraphShadingElement, parseDocxThemeReference, patchDocumentLazyHtmlProjection, patchDocxThemeReferences, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, serializeDocumentParagraphFormatting, 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 };
21706
+ 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_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, 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, 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 };