@a3s-lab/office 0.29.0 → 0.31.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 (61) hide show
  1. package/README.md +117 -3
  2. package/dist/{0~7043.js → 0~4808.js} +347 -2
  3. package/dist/0~5050.js +10 -1
  4. package/dist/{0~5093.js → 0~7240.js} +465 -55
  5. package/dist/0~document-editor.js +1694 -187
  6. package/dist/0~spreadsheet-editor.js +183 -34
  7. package/dist/0~work-docx-export.js +507 -31
  8. package/dist/0~work-docx-import.js +41 -7
  9. package/dist/0~work-office-diagnostics.js +146 -5
  10. package/dist/1544.js +13 -1
  11. package/dist/4104.js +29 -6
  12. package/dist/4121.js +2340 -1
  13. package/dist/6282.js +1072 -1148
  14. package/dist/internal/features/work/editors/document-command-catalog.d.ts +45 -0
  15. package/dist/internal/features/work/editors/document-dom-selection.d.ts +7 -0
  16. package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -0
  17. package/dist/internal/features/work/editors/document-font-dialog-model.d.ts +5 -2
  18. package/dist/internal/features/work/editors/document-font-dialog-run-shading-model.d.ts +23 -0
  19. package/dist/internal/features/work/editors/document-font-dialog-run-shading-section.d.ts +8 -0
  20. package/dist/internal/features/work/editors/document-index-dialog.d.ts +10 -0
  21. package/dist/internal/features/work/editors/document-index-entry-dialog.d.ts +10 -0
  22. package/dist/internal/features/work/editors/document-page-chrome-ribbon.d.ts +2 -1
  23. package/dist/internal/features/work/editors/document-proofing-dialog-model.d.ts +22 -0
  24. package/dist/internal/features/work/editors/document-proofing-dialog.d.ts +7 -0
  25. package/dist/internal/features/work/editors/document-references-ribbon.d.ts +19 -0
  26. package/dist/internal/features/work/editors/document-table-of-contents-dialog.d.ts +10 -0
  27. package/dist/internal/features/work/editors/document-toolbar.d.ts +6 -1
  28. package/dist/internal/features/work/editors/spreadsheet-data-validation.d.ts +7 -1
  29. package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +5 -0
  30. package/dist/internal/features/work/work-document-character-formatting.d.ts +8 -0
  31. package/dist/internal/features/work/work-document-format-changes.d.ts +6 -0
  32. package/dist/internal/features/work/work-document-highlight.d.ts +9 -0
  33. package/dist/internal/features/work/work-document-index-fields.d.ts +19 -0
  34. package/dist/internal/features/work/work-document-index-nodes.d.ts +32 -0
  35. package/dist/internal/features/work/work-document-index.d.ts +63 -0
  36. package/dist/internal/features/work/work-document-outline.d.ts +1 -0
  37. package/dist/internal/features/work/work-document-paragraph-shading.d.ts +6 -0
  38. package/dist/internal/features/work/work-document-proofing.d.ts +19 -0
  39. package/dist/internal/features/work/work-document-run-shading.d.ts +12 -0
  40. package/dist/internal/features/work/work-document-table-of-contents-node.d.ts +18 -0
  41. package/dist/internal/features/work/work-document-table-of-contents.d.ts +51 -0
  42. package/dist/internal/features/work/work-document-word-line-metrics.d.ts +3 -0
  43. package/dist/internal/features/work/work-docx-field-instructions.d.ts +1 -1
  44. package/dist/internal/features/work/work-docx-import.d.ts +5 -1
  45. package/dist/internal/features/work/work-docx-index-export.d.ts +14 -0
  46. package/dist/internal/features/work/work-docx-index-import.d.ts +23 -0
  47. package/dist/internal/features/work/work-docx-proofing-diagnostics.d.ts +3 -0
  48. package/dist/internal/features/work/work-docx-proofing.d.ts +38 -0
  49. package/dist/internal/features/work/work-docx-run-formatting-import.d.ts +7 -0
  50. package/dist/internal/features/work/work-docx-run-shading-diagnostics.d.ts +3 -0
  51. package/dist/internal/features/work/work-docx-run-shading-export.d.ts +17 -0
  52. package/dist/internal/features/work/work-docx-run-shading.d.ts +20 -0
  53. package/dist/internal/features/work/work-docx-table-of-contents-export.d.ts +11 -0
  54. package/dist/internal/features/work/work-docx-table-of-contents-import.d.ts +15 -0
  55. package/dist/internal/features/work/work-spreadsheet-data-validation.d.ts +7 -0
  56. package/dist/internal/features/work/work-types.d.ts +9 -0
  57. package/dist/internal/kernel/office-kernel-protocol.d.ts +1 -0
  58. package/dist/office-kernel.wasm +0 -0
  59. package/dist/styles.css +607 -4
  60. package/docs/latest/en/browser-editor-architecture.md +64 -1
  61. package/package.json +15 -2
package/dist/6282.js CHANGED
@@ -21,7 +21,7 @@ import { CellSelection, TableMap, isInTable, selectedRect } from "@tiptap/pm/tab
21
21
  import font_family from "@tiptap/extension-text-style/font-family";
22
22
  import { TextStyle } from "@tiptap/extension-text-style";
23
23
  import extension_highlight from "@tiptap/extension-highlight";
24
- import { documentRunBorderDomAttributes, normalizeDocumentRunBorder, parseDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentParagraphBorders, parseDocxThemeReference, serializeDocumentRunBorder, normalizeCssColor, DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE, serializeDocxThemeReference, parseDocumentParagraphBordersElement, parseDocumentParagraphBorders, documentBorderPresentation, DOCUMENT_RUN_BORDER_ATTRIBUTE, parseDocumentRunBorderElement, documentRunBorderIsVisible, documentParagraphBordersDomAttributes, createOfficeId as createWorkId } from "./4121.js";
24
+ import { documentRunBorderDomAttributes, DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE, DOCUMENT_RUN_SHADING_ATTRIBUTE, serializeDocumentRunBorder, documentScriptFontSlotFromElement, documentScriptFontsForAllText, serializeDocumentScriptFonts, primeDocumentIntegrityFeatures, uniqueDocumentParagraphIdentity, documentScriptFontsDomAttributes, documentHighlightForCssColor, documentTableOfContentsValueFromElement, buildDocumentIndexEntries, normalizeDocumentScriptFonts, buildDocumentTableOfContentsEntries, serializeDocumentParagraphShading, documentHasIntegrityFeature, parseDocumentRunBorder, documentIndexValueFromElement, normalizeDocumentParagraphId, DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE, documentProofingLanguagesFromElement, normalizeDocumentProofingLanguages, normalizeDocumentIndexOptions, parseDocumentParagraphBordersElement, parseDocumentParagraphBorders, documentScriptFontsFromElement, DOCUMENT_RUN_BORDER_ATTRIBUTE, normalizeDocumentTableOfContentsValue, DOCUMENT_PARAGRAPH_ID_ATTRIBUTE, documentNoProofFromElement, normalizeDocumentRunShading, documentIndexEntryFromElement, documentScriptFontSegments, normalizeDocumentIndexEntry, documentFontNameFromCssFamily, documentRunShadingDomAttributes, normalizeDocumentIndexEntryDraft, parseDocumentScriptFonts, normalizeDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentParagraphBorders, parseDocxThemeReference, parseDocumentRunShading, DOCUMENT_HIGHLIGHT_ATTRIBUTE, serializeDocumentRunShading, workDocumentOutlineLevel, DOCUMENT_PARAGRAPH_BORDERS_ATTRIBUTE, createDocumentParagraphIdentityRegistry, DOCUMENT_NO_PROOF_ATTRIBUTE, serializeDocxThemeReference, documentRunBorderIsVisible, normalizeDocumentTableOfContentsHtml, cssDocumentFontFamily, documentParagraphShadingDomAttributes, normalizeDocumentIndexValue, DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE, documentParagraphBordersDomAttributes, DOCUMENT_SCRIPT_FONTS_ATTRIBUTE, normalizeDocumentHighlight, normalizeDocumentParagraphIdentity, createOfficeId as createWorkId, DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, DEFAULT_DOCUMENT_INDEX_OPTIONS, documentHighlightFromElement, normalizeDocumentLanguageTag, parseDocumentParagraphShading, normalizeDocumentNoProof, parseDocumentParagraphShadingElement, createDocumentParagraphIdentity, documentHighlightDomAttributes, DocumentParagraphIdentity, parseDocumentRunShadingElement, parseDocumentProofingLanguages, collectWorkDocumentOutline, documentScriptFontSlotFromHint, normalizeDocumentTableOfContentsOptions, documentBorderPresentation, documentScriptFontFamilyForRendering, parseDocumentRunBorderElement, documentProofingDomAttributes, normalizeDocumentScriptFontSlot, serializeDocumentProofingLanguages } from "./4121.js";
25
25
  import { workOfficeCollaborationJsonEqual, canonicalWorkOfficeCollaborationJson, isWorkOfficeCollaborationRecord, cloneWorkOfficeCollaborationJson } from "./4650.js";
26
26
  import { assertWorkOfficeCollaborationEditable, markWorkOfficeCollaborationInitialized, assertWorkOfficeCollaborationOrigin, initializeWorkOfficeCollaborationMetadata, assertWorkOfficeCollaborationWritable, OfficeCollaborationError as WorkOfficeCollaborationError, readOfficeCollaborationMetadata as readWorkOfficeCollaborationMetadata, registerWorkOfficeCollaborationInitializer } from "./9787.js";
27
27
  import * as __rspack_external_yjs from "yjs";
@@ -195,71 +195,6 @@ function normalizedReferenceText(value) {
195
195
  function stringAttribute(value) {
196
196
  return 'string' == typeof value ? value.trim() : '';
197
197
  }
198
- const DOCUMENT_INTEGRITY_BOOKMARK = 1;
199
- const DOCUMENT_INTEGRITY_FIELD = 2;
200
- const DOCUMENT_INTEGRITY_IMAGE = 4;
201
- const DOCUMENT_INTEGRITY_NOTE = 8;
202
- const DOCUMENT_INTEGRITY_PARAGRAPH_IDENTITY = 16;
203
- const DOCUMENT_INTEGRITY_TABLE_ROW_IDENTITY = 32;
204
- const featureCache = new WeakMap();
205
- function documentHasIntegrityFeature(document1, feature) {
206
- return (documentIntegrityFeatures(document1, true) & feature) !== 0;
207
- }
208
- function primeDocumentIntegrityFeatures(document1) {
209
- document1.forEach(primeDocumentIntegrityNode);
210
- }
211
- function primeDocumentIntegrityNode(node) {
212
- if ('documentChunk' === node.type.name) {
213
- const features = nonNegativeInteger(node.attrs.integrityFeatures);
214
- if (null !== features) featureCache.set(node, features);
215
- if (true !== node.attrs.windowContainer) return;
216
- }
217
- node.forEach(primeDocumentIntegrityNode);
218
- }
219
- function documentIntegrityFeatures(node, cacheNode) {
220
- if (cacheNode) {
221
- const cached = featureCache.get(node);
222
- if (void 0 !== cached) return cached;
223
- }
224
- let features = nodeIntegrityFeatures(node);
225
- node.forEach((child)=>{
226
- features |= documentIntegrityFeatures(child, 'documentChunk' === child.type.name);
227
- });
228
- if (cacheNode) featureCache.set(node, features);
229
- return features;
230
- }
231
- function nodeIntegrityFeatures(node) {
232
- let features = 0;
233
- switch(node.type.name){
234
- case 'documentBookmarkBoundary':
235
- features |= DOCUMENT_INTEGRITY_BOOKMARK;
236
- break;
237
- case 'documentCrossReference':
238
- if ('bookmark' === node.attrs.targetType) features |= DOCUMENT_INTEGRITY_BOOKMARK;
239
- break;
240
- case 'documentField':
241
- features |= DOCUMENT_INTEGRITY_FIELD;
242
- break;
243
- case 'image':
244
- features |= DOCUMENT_INTEGRITY_IMAGE;
245
- break;
246
- case 'documentNote':
247
- case 'documentNoteReference':
248
- features |= DOCUMENT_INTEGRITY_NOTE;
249
- break;
250
- }
251
- if (node.isText && node.marks.some((mark)=>'link' === mark.type.name && 'string' == typeof mark.attrs.href && mark.attrs.href.startsWith('#'))) features |= DOCUMENT_INTEGRITY_BOOKMARK;
252
- if (identityComponent(node.attrs.paragraphId) || identityComponent(node.attrs.textId)) features |= DOCUMENT_INTEGRITY_PARAGRAPH_IDENTITY;
253
- if (identityComponent(node.attrs.rowId) || identityComponent(node.attrs.rowTextId)) features |= DOCUMENT_INTEGRITY_TABLE_ROW_IDENTITY;
254
- return features;
255
- }
256
- function identityComponent(value) {
257
- return 'string' == typeof value && value.trim().length > 0;
258
- }
259
- function nonNegativeInteger(value) {
260
- const number = Number(value);
261
- return Number.isSafeInteger(number) && number >= 0 ? number : null;
262
- }
263
198
  const BOOKMARK_NAME_PATTERN = /^[\p{L}_][\p{L}\p{N}_]*$/u;
264
199
  const BOOKMARK_UI_NAME_PATTERN = /^[\p{L}][\p{L}\p{N}_]*$/u;
265
200
  const MAX_BOOKMARK_NAME_LENGTH = 40;
@@ -1898,7 +1833,7 @@ function createSchemaValidatedWorkDocumentModel(html, root, options = {}) {
1898
1833
  schemaValidatedDocumentModels.set(model, {
1899
1834
  html,
1900
1835
  htmlFingerprint: model.htmlFingerprint,
1901
- initialIntegrityFeatures: work_document_model_nonNegativeInteger(options.initialIntegrityFeatures),
1836
+ initialIntegrityFeatures: nonNegativeInteger(options.initialIntegrityFeatures),
1902
1837
  root
1903
1838
  });
1904
1839
  return model;
@@ -1947,7 +1882,7 @@ function nextRevision(previous) {
1947
1882
  const revision = previous?.schema === DOCUMENT_MODEL_SCHEMA && previous.version === DOCUMENT_MODEL_VERSION && Number.isSafeInteger(previous.revision) && previous.revision > 0 ? previous.revision : 0;
1948
1883
  return revision >= Number.MAX_SAFE_INTEGER ? 1 : revision + 1;
1949
1884
  }
1950
- function work_document_model_nonNegativeInteger(value) {
1885
+ function nonNegativeInteger(value) {
1951
1886
  const number = Number(value);
1952
1887
  return Number.isSafeInteger(number) && number >= 0 ? number : null;
1953
1888
  }
@@ -6624,100 +6559,76 @@ function formatHexIdentifier(value) {
6624
6559
  function formatWordprocessingIdentifier(value) {
6625
6560
  return formatHexIdentifier(value & MAX_WORDPROCESSING_ID || 1);
6626
6561
  }
6627
- const DOCUMENT_PARAGRAPH_ID_ATTRIBUTE = 'data-office-paragraph-id';
6628
- const DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE = 'data-office-paragraph-text-id';
6629
- const PARAGRAPH_ID_PATTERN = /^[0-9A-F]{8}$/;
6630
- const MAX_PARAGRAPH_ID = 0x7fffffff;
6631
- let work_document_paragraph_identity_fallbackIdentitySequence = 0;
6632
- const DocumentParagraphIdentity = Extension.create({
6633
- name: 'documentParagraphIdentity',
6562
+ const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
6563
+ const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
6564
+ const DocumentTableRowIdentity = Extension.create({
6565
+ name: 'documentTableRowIdentity',
6634
6566
  addOptions () {
6635
6567
  return {
6636
- rotateTextId: ()=>true,
6637
- types: [
6638
- 'paragraph',
6639
- 'heading',
6640
- 'documentCaption'
6641
- ]
6568
+ rotateTextId: ()=>true
6642
6569
  };
6643
6570
  },
6644
6571
  addGlobalAttributes () {
6645
6572
  return [
6646
6573
  {
6647
- types: this.options.types,
6574
+ types: [
6575
+ 'tableRow'
6576
+ ],
6648
6577
  attributes: {
6649
- paragraphId: {
6650
- default: null,
6651
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE)),
6652
- renderHTML: (attributes)=>{
6653
- const value = normalizeDocumentParagraphId(attributes.paragraphId);
6654
- return value ? {
6655
- [DOCUMENT_PARAGRAPH_ID_ATTRIBUTE]: value
6656
- } : {};
6657
- }
6658
- },
6659
- textId: {
6660
- default: null,
6661
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE)),
6662
- renderHTML: (attributes)=>{
6663
- const value = normalizeDocumentParagraphId(attributes.textId);
6664
- return value ? {
6665
- [DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE]: value
6666
- } : {};
6667
- }
6668
- }
6578
+ rowId: identityAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
6579
+ rowTextId: identityAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
6669
6580
  }
6670
6581
  }
6671
6582
  ];
6672
6583
  },
6673
6584
  addProseMirrorPlugins () {
6674
6585
  return [
6675
- createDocumentParagraphIdentityPlugin(this.options.types, this.options.rotateTextId)
6586
+ createDocumentTableRowIdentityPlugin(this.options.rotateTextId)
6676
6587
  ];
6677
6588
  }
6678
6589
  });
6679
- function normalizeDocumentParagraphId(value) {
6680
- if ('string' != typeof value) return null;
6681
- const normalized = value.trim().toUpperCase();
6682
- if (!PARAGRAPH_ID_PATTERN.test(normalized)) return null;
6683
- const number = Number.parseInt(normalized, 16);
6684
- return number > 0 && number <= MAX_PARAGRAPH_ID ? normalized : null;
6685
- }
6686
- function createDocumentParagraphIdentityRegistry() {
6687
- return {
6688
- paragraphIds: new Set()
6689
- };
6690
- }
6691
- function normalizeDocumentParagraphIdentity(source) {
6692
- const paragraphId = normalizeDocumentParagraphId(source.paragraphId);
6693
- const textId = normalizeDocumentParagraphId(source.textId);
6694
- return paragraphId && textId ? {
6695
- paragraphId,
6696
- textId
6590
+ function normalizeDocumentTableRowIdentity(source) {
6591
+ const rowId = normalizeDocumentParagraphId(source.rowId);
6592
+ const rowTextId = normalizeDocumentParagraphId(source.rowTextId);
6593
+ return rowId && rowTextId ? {
6594
+ rowId,
6595
+ rowTextId
6697
6596
  } : null;
6698
6597
  }
6699
- function documentParagraphIdentityFromElement(element) {
6700
- return normalizeDocumentParagraphIdentity({
6701
- paragraphId: element.getAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE),
6702
- textId: element.getAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE)
6598
+ function documentTableRowIdentityFromElement(element) {
6599
+ return normalizeDocumentTableRowIdentity({
6600
+ rowId: element.getAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
6601
+ rowTextId: element.getAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
6703
6602
  });
6704
6603
  }
6705
- function applyDocumentParagraphIdentityToElement(element, source) {
6706
- const identity = normalizeDocumentParagraphIdentity(source);
6604
+ function applyDocumentTableRowIdentityToElement(element, source) {
6605
+ const identity = normalizeDocumentTableRowIdentity(source);
6707
6606
  if (!identity) {
6708
- element.removeAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE);
6709
- element.removeAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE);
6607
+ element.removeAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE);
6608
+ element.removeAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE);
6710
6609
  return null;
6711
6610
  }
6712
- element.setAttribute(DOCUMENT_PARAGRAPH_ID_ATTRIBUTE, identity.paragraphId);
6713
- element.setAttribute(DOCUMENT_PARAGRAPH_TEXT_ID_ATTRIBUTE, identity.textId);
6611
+ element.setAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, identity.rowId);
6612
+ element.setAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, identity.rowTextId);
6714
6613
  return identity;
6715
6614
  }
6716
- function createDocumentParagraphIdentityPlugin(types, rotateTextId) {
6717
- const trackedTypes = new Set(types);
6615
+ function identityAttribute(htmlName) {
6616
+ return {
6617
+ default: null,
6618
+ parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(htmlName)),
6619
+ renderHTML: (attributes)=>{
6620
+ const modelName = htmlName === DOCUMENT_TABLE_ROW_ID_ATTRIBUTE ? 'rowId' : 'rowTextId';
6621
+ const value = normalizeDocumentParagraphId(attributes[modelName]);
6622
+ return value ? {
6623
+ [htmlName]: value
6624
+ } : {};
6625
+ }
6626
+ };
6627
+ }
6628
+ function createDocumentTableRowIdentityPlugin(rotateTextId) {
6718
6629
  return new Plugin({
6719
6630
  view (view) {
6720
- const transaction = normalizeDocumentParagraphIdentities(view.state, trackedTypes, rotateTextId);
6631
+ const transaction = normalizeDocumentTableRowIdentities(view.state, rotateTextId);
6721
6632
  if (transaction) {
6722
6633
  transaction.setMeta('addToHistory', false);
6723
6634
  view.dispatch(transaction);
@@ -6726,37 +6637,44 @@ function createDocumentParagraphIdentityPlugin(types, rotateTextId) {
6726
6637
  },
6727
6638
  appendTransaction (transactions, oldState, newState) {
6728
6639
  if (!transactions.some((transaction)=>transaction.docChanged)) return null;
6729
- return normalizeDocumentParagraphIdentities(newState, trackedTypes, rotateTextId, oldState, transactions);
6640
+ return normalizeDocumentTableRowIdentities(newState, rotateTextId, oldState, transactions);
6730
6641
  }
6731
6642
  });
6732
6643
  }
6733
- function normalizeDocumentParagraphIdentities(state, trackedTypes, rotateTextId, oldState, transactions = []) {
6734
- if (!documentHasIntegrityFeature(state.doc, 16)) return null;
6735
- const paragraphs = documentParagraphs(state.doc, trackedTypes);
6736
- if (!paragraphs.length) return null;
6737
- const retainedPositions = oldState ? retainedDocumentParagraphPositions(oldState, state, transactions, trackedTypes) : new Set();
6738
- const editedPositions = oldState && rotateTextId() && !transactions.some(isHistoryTransaction) ? editedDocumentParagraphPositions(oldState, state, transactions, trackedTypes) : new Set();
6644
+ function normalizeDocumentTableRowIdentities(state, rotateTextId, oldState, transactions = []) {
6645
+ if (!documentHasIntegrityFeature(state.doc, 32)) return null;
6646
+ const rows = documentTableRows(state.doc);
6647
+ if (!rows.length) return null;
6648
+ const retainedPositions = oldState ? retainedDocumentTableRowPositions(oldState, state, transactions) : new Set();
6649
+ const editedPositions = oldState && rotateTextId() && !transactions.some(isHistoryTransaction) ? editedDocumentTableRowPositions(oldState, state, transactions) : new Set();
6739
6650
  const ordered = [
6740
- ...paragraphs.filter((item)=>retainedPositions.has(item.position)),
6741
- ...paragraphs.filter((item)=>!retainedPositions.has(item.position))
6651
+ ...rows.filter((item)=>retainedPositions.has(item.position)),
6652
+ ...rows.filter((item)=>!retainedPositions.has(item.position))
6742
6653
  ];
6743
6654
  const registry = createDocumentParagraphIdentityRegistry();
6744
6655
  const updates = new Map();
6745
- for (const paragraph of ordered){
6746
- const current = paragraphIdentitySourceFromNode(paragraph.node);
6747
- const source = editedPositions.has(paragraph.position) ? {
6748
- ...current,
6749
- textId: nextDocumentParagraphTextId(current.textId)
6656
+ for (const row of ordered){
6657
+ const current = tableRowIdentitySourceFromNode(row.node);
6658
+ const source = editedPositions.has(row.position) ? {
6659
+ rowId: current.rowId,
6660
+ rowTextId: createDocumentParagraphIdentity().textId
6750
6661
  } : current;
6751
- const identity = uniqueDocumentParagraphIdentity(source, registry);
6752
- if (!sameDocumentParagraphIdentity(current, identity)) updates.set(paragraph.position, identity);
6662
+ const wordIdentity = uniqueDocumentParagraphIdentity({
6663
+ paragraphId: source.rowId,
6664
+ textId: source.rowTextId
6665
+ }, registry);
6666
+ const identity = {
6667
+ rowId: wordIdentity.paragraphId,
6668
+ rowTextId: wordIdentity.textId
6669
+ };
6670
+ if (!sameDocumentTableRowIdentity(current, identity)) updates.set(row.position, identity);
6753
6671
  }
6754
6672
  if (!updates.size) return null;
6755
6673
  const transaction = state.tr;
6756
- for (const paragraph of paragraphs){
6757
- const identity = updates.get(paragraph.position);
6758
- if (identity) transaction.setNodeMarkup(paragraph.position, void 0, {
6759
- ...paragraph.node.attrs,
6674
+ for (const row of rows){
6675
+ const identity = updates.get(row.position);
6676
+ if (identity) transaction.setNodeMarkup(row.position, void 0, {
6677
+ ...row.node.attrs,
6760
6678
  ...identity
6761
6679
  });
6762
6680
  }
@@ -6764,994 +6682,116 @@ function normalizeDocumentParagraphIdentities(state, trackedTypes, rotateTextId,
6764
6682
  transaction.setMeta('addToHistory', false);
6765
6683
  return transaction;
6766
6684
  }
6767
- function hasDocumentParagraphIdentityComponent(node) {
6768
- return Boolean(normalizeDocumentParagraphId(node.attrs.paragraphId) || normalizeDocumentParagraphId(node.attrs.textId));
6685
+ function hasDocumentTableRowIdentityComponent(node) {
6686
+ return Boolean(normalizeDocumentParagraphId(node.attrs.rowId) || normalizeDocumentParagraphId(node.attrs.rowTextId));
6769
6687
  }
6770
- function retainedDocumentParagraphPositions(oldState, newState, transactions, trackedTypes) {
6771
- const mapping = work_document_paragraph_identity_transactionMapping(transactions);
6688
+ function retainedDocumentTableRowPositions(oldState, newState, transactions) {
6689
+ const mapping = work_document_table_row_identity_transactionMapping(transactions);
6772
6690
  const retained = new Set();
6773
- for (const previous of documentParagraphs(oldState.doc, trackedTypes)){
6774
- const paragraphId = normalizeDocumentParagraphId(previous.node.attrs.paragraphId);
6775
- if (!paragraphId) continue;
6691
+ for (const previous of documentTableRows(oldState.doc)){
6692
+ const rowId = normalizeDocumentParagraphId(previous.node.attrs.rowId);
6693
+ if (!rowId) continue;
6776
6694
  const mapped = mapping.mapResult(previous.position, 1);
6777
6695
  const current = newState.doc.nodeAt(mapped.pos);
6778
- if (current && trackedTypes.has(current.type.name) && normalizeDocumentParagraphId(current.attrs.paragraphId) === paragraphId) retained.add(mapped.pos);
6696
+ if (current?.type.name === 'tableRow' && normalizeDocumentParagraphId(current.attrs.rowId) === rowId) retained.add(mapped.pos);
6779
6697
  }
6780
6698
  return retained;
6781
6699
  }
6782
- function editedDocumentParagraphPositions(oldState, newState, transactions, trackedTypes) {
6783
- const mapping = work_document_paragraph_identity_transactionMapping(transactions);
6784
- const previousParagraphs = documentParagraphs(oldState.doc, trackedTypes);
6785
- const currentParagraphs = documentParagraphs(newState.doc, trackedTypes);
6786
- const previousById = paragraphsById(previousParagraphs);
6787
- const currentById = paragraphsById(currentParagraphs);
6700
+ function editedDocumentTableRowPositions(oldState, newState, transactions) {
6701
+ const mapping = work_document_table_row_identity_transactionMapping(transactions);
6702
+ const previousRows = documentTableRows(oldState.doc);
6703
+ const currentRows = documentTableRows(newState.doc);
6704
+ const previousById = tableRowsById(previousRows);
6705
+ const currentById = tableRowsById(currentRows);
6788
6706
  const edited = new Set();
6789
- for (const previous of previousParagraphs){
6790
- const identity = normalizeDocumentParagraphIdentity(paragraphIdentitySourceFromNode(previous.node));
6707
+ for (const previous of previousRows){
6708
+ const identity = normalizeDocumentTableRowIdentity(tableRowIdentitySourceFromNode(previous.node));
6791
6709
  if (!identity) continue;
6792
6710
  const mapped = mapping.mapResult(previous.position, 1);
6793
6711
  const current = newState.doc.nodeAt(mapped.pos);
6794
- if (current && trackedTypes.has(current.type.name) && normalizeDocumentParagraphId(current.attrs.paragraphId) === identity.paragraphId) {
6795
- if (paragraphTextChanged(previous.node, current, identity.textId)) edited.add(mapped.pos);
6712
+ if (current?.type.name === 'tableRow' && normalizeDocumentParagraphId(current.attrs.rowId) === identity.rowId) {
6713
+ if (tableRowContentChanged(previous.node, current, identity.rowTextId)) edited.add(mapped.pos);
6796
6714
  continue;
6797
6715
  }
6798
- const previousMatches = previousById.get(identity.paragraphId) ?? [];
6799
- const currentMatches = currentById.get(identity.paragraphId) ?? [];
6800
- if (1 === previousMatches.length && 1 === currentMatches.length && paragraphTextChanged(previous.node, currentMatches[0].node, identity.textId)) edited.add(currentMatches[0].position);
6716
+ const previousMatches = previousById.get(identity.rowId) ?? [];
6717
+ const currentMatches = currentById.get(identity.rowId) ?? [];
6718
+ if (1 === previousMatches.length && 1 === currentMatches.length && tableRowContentChanged(previous.node, currentMatches[0].node, identity.rowTextId)) edited.add(currentMatches[0].position);
6801
6719
  }
6802
6720
  return edited;
6803
6721
  }
6804
- function paragraphTextChanged(previous, current, previousTextId) {
6805
- return previous.textContent !== current.textContent && normalizeDocumentParagraphId(current.attrs.textId) === previousTextId;
6722
+ function tableRowContentChanged(previous, current, previousTextId) {
6723
+ return tableRowContentSignature(previous) !== tableRowContentSignature(current) && normalizeDocumentParagraphId(current.attrs.rowTextId) === previousTextId;
6724
+ }
6725
+ function tableRowContentSignature(row) {
6726
+ const parts = [
6727
+ 'tableRow'
6728
+ ];
6729
+ row.descendants((node)=>{
6730
+ if (node.isText) return void parts.push(`text:${node.text ?? ''}`);
6731
+ if ('tableCell' === node.type.name || 'tableHeader' === node.type.name) return void parts.push(`${node.type.name}:${String(node.attrs.colspan ?? 1)}:${String(node.attrs.rowspan ?? 1)}`);
6732
+ parts.push(node.type.name);
6733
+ });
6734
+ return parts.join('\u0000');
6806
6735
  }
6807
- function paragraphsById(paragraphs) {
6736
+ function tableRowsById(rows) {
6808
6737
  const result = new Map();
6809
- for (const paragraph of paragraphs){
6810
- const id = normalizeDocumentParagraphId(paragraph.node.attrs.paragraphId);
6738
+ for (const row of rows){
6739
+ const id = normalizeDocumentParagraphId(row.node.attrs.rowId);
6811
6740
  if (!id) continue;
6812
6741
  const matches = result.get(id) ?? [];
6813
- matches.push(paragraph);
6742
+ matches.push(row);
6814
6743
  result.set(id, matches);
6815
6744
  }
6816
6745
  return result;
6817
6746
  }
6818
- function documentParagraphs(document1, trackedTypes) {
6819
- const paragraphs = [];
6747
+ function documentTableRows(document1) {
6748
+ const rows = [];
6820
6749
  document1.descendants((node, position)=>{
6821
- if (trackedTypes.has(node.type.name) && hasDocumentParagraphIdentityComponent(node)) paragraphs.push({
6750
+ if ('tableRow' === node.type.name && hasDocumentTableRowIdentityComponent(node)) rows.push({
6822
6751
  node,
6823
6752
  position
6824
6753
  });
6825
6754
  });
6826
- return paragraphs;
6827
- }
6828
- function paragraphIdentitySourceFromNode(node) {
6829
- return {
6830
- paragraphId: node.attrs.paragraphId,
6831
- textId: node.attrs.textId
6832
- };
6833
- }
6834
- function uniqueDocumentParagraphIdentity(source, registry) {
6835
- const preferred = normalizeDocumentParagraphIdentity(source);
6836
- if (preferred && !registry.paragraphIds.has(preferred.paragraphId)) {
6837
- registry.paragraphIds.add(preferred.paragraphId);
6838
- return preferred;
6839
- }
6840
- for(let attempt = 0; attempt < 8; attempt += 1){
6841
- const identity = createDocumentParagraphIdentity();
6842
- if (!registry.paragraphIds.has(identity.paragraphId)) {
6843
- registry.paragraphIds.add(identity.paragraphId);
6844
- return identity;
6845
- }
6846
- }
6847
- return sequentialDocumentParagraphIdentity(registry);
6755
+ return rows;
6848
6756
  }
6849
- function createDocumentParagraphIdentity() {
6757
+ function tableRowIdentitySourceFromNode(node) {
6850
6758
  return {
6851
- paragraphId: randomDocumentParagraphId(),
6852
- textId: randomDocumentParagraphId()
6759
+ rowId: node.attrs.rowId,
6760
+ rowTextId: node.attrs.rowTextId
6853
6761
  };
6854
6762
  }
6855
- function sequentialDocumentParagraphIdentity(registry) {
6856
- for(let value = 1; value <= MAX_PARAGRAPH_ID; value += 1){
6857
- const paragraphId = formatDocumentParagraphId(value);
6858
- if (!registry.paragraphIds.has(paragraphId)) {
6859
- registry.paragraphIds.add(paragraphId);
6860
- return {
6861
- paragraphId,
6862
- textId: randomDocumentParagraphId()
6863
- };
6864
- }
6865
- }
6866
- throw new Error('No unique Word paragraph identity is available.');
6867
- }
6868
- function nextDocumentParagraphTextId(value) {
6869
- const current = normalizeDocumentParagraphId(value);
6870
- if (!current) return randomDocumentParagraphId();
6871
- const number = Number.parseInt(current, 16);
6872
- return formatDocumentParagraphId(number >= MAX_PARAGRAPH_ID ? 1 : number + 1);
6873
- }
6874
- function randomDocumentParagraphId() {
6875
- let value = 0;
6876
- const cryptoApi = globalThis.crypto;
6877
- if ('function' == typeof cryptoApi?.getRandomValues) {
6878
- const values = new Uint32Array(1);
6879
- cryptoApi.getRandomValues(values);
6880
- value = values[0] ?? 0;
6881
- } else if ('function' == typeof cryptoApi?.randomUUID) value = Number.parseInt(cryptoApi.randomUUID().replaceAll('-', '').slice(0, 8), 16);
6882
- if (!value) {
6883
- work_document_paragraph_identity_fallbackIdentitySequence += 1;
6884
- value = work_document_paragraph_identity_stableIdentityHash(`${Date.now()}:${Math.random()}:${work_document_paragraph_identity_fallbackIdentitySequence}`);
6885
- }
6886
- return formatDocumentParagraphId(value || work_document_paragraph_identity_fallbackIdentitySequence || 1);
6887
- }
6888
- function work_document_paragraph_identity_stableIdentityHash(value) {
6889
- let hash = 0x811c9dc5;
6890
- for(let index = 0; index < value.length; index += 1){
6891
- hash ^= value.charCodeAt(index);
6892
- hash = Math.imul(hash, 0x01000193);
6893
- }
6894
- return hash >>> 0 || 1;
6895
- }
6896
- function formatDocumentParagraphId(value) {
6897
- return (value >>> 0 & MAX_PARAGRAPH_ID || 1).toString(16).toUpperCase().padStart(8, '0');
6898
- }
6899
- function sameDocumentParagraphIdentity(source, identity) {
6900
- return normalizeDocumentParagraphId(source.paragraphId) === identity.paragraphId && normalizeDocumentParagraphId(source.textId) === identity.textId;
6763
+ function sameDocumentTableRowIdentity(source, identity) {
6764
+ return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
6901
6765
  }
6902
- function work_document_paragraph_identity_transactionMapping(transactions) {
6766
+ function work_document_table_row_identity_transactionMapping(transactions) {
6903
6767
  const mapping = new Mapping();
6904
6768
  for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
6905
6769
  return mapping;
6906
6770
  }
6907
- const DOCUMENT_PARAGRAPH_SHADING_PATTERNS = new Set([
6908
- 'nil',
6909
- 'clear',
6910
- 'solid',
6911
- 'horzStripe',
6912
- 'vertStripe',
6913
- 'reverseDiagStripe',
6914
- 'diagStripe',
6915
- 'horzCross',
6916
- 'diagCross',
6917
- 'thinHorzStripe',
6918
- 'thinVertStripe',
6919
- 'thinReverseDiagStripe',
6920
- 'thinDiagStripe',
6921
- 'thinHorzCross',
6922
- 'thinDiagCross',
6923
- 'pct5',
6924
- 'pct10',
6925
- 'pct12',
6926
- 'pct15',
6927
- 'pct20',
6928
- 'pct25',
6929
- 'pct30',
6930
- 'pct35',
6931
- 'pct37',
6932
- 'pct40',
6933
- 'pct45',
6934
- 'pct50',
6935
- 'pct55',
6936
- 'pct60',
6937
- 'pct62',
6938
- 'pct65',
6939
- 'pct70',
6940
- 'pct75',
6941
- 'pct80',
6942
- 'pct85',
6943
- 'pct87',
6944
- 'pct90',
6945
- 'pct95'
6946
- ]);
6947
- function normalizeDocumentParagraphShading(source) {
6948
- if (!source || 'object' != typeof source) return null;
6949
- const value = source;
6950
- const pattern = value.pattern;
6951
- if ('string' != typeof pattern || !DOCUMENT_PARAGRAPH_SHADING_PATTERNS.has(pattern)) return null;
6952
- const color = normalizeShadingColor(value.color);
6953
- const fill = normalizeShadingColor(value.fill);
6954
- if (void 0 !== value.color && !color || void 0 !== value.fill && !fill) return null;
6955
- return {
6956
- pattern: pattern,
6957
- ...color ? {
6958
- color
6959
- } : {},
6960
- ...fill ? {
6961
- fill
6962
- } : {}
6963
- };
6964
- }
6965
- function parseDocumentParagraphShading(source) {
6966
- if ('string' != typeof source) return normalizeDocumentParagraphShading(source);
6967
- if (!source.trim()) return null;
6968
- try {
6969
- return normalizeDocumentParagraphShading(JSON.parse(source));
6970
- } catch {
6971
- return null;
6972
- }
6771
+ const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
6772
+ const documentTextCaseKeyboardShortcuts = {
6773
+ allCaps: 'Mod-Shift-a',
6774
+ smallCaps: 'Mod-Shift-k'
6775
+ };
6776
+ function normalizeDocumentTextCase(value) {
6777
+ return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
6973
6778
  }
6974
- function serializeDocumentParagraphShading(source) {
6975
- const shading = normalizeDocumentParagraphShading(source);
6976
- if (!shading) return;
6977
- return JSON.stringify({
6978
- pattern: shading.pattern,
6979
- ...shading.color ? {
6980
- color: serializedShadingColor(shading.color)
6981
- } : {},
6982
- ...shading.fill ? {
6983
- fill: serializedShadingColor(shading.fill)
6984
- } : {}
6985
- });
6986
- }
6987
- function parseDocumentParagraphShadingElement(element) {
6988
- const semantic = parseDocumentParagraphShading(element.dataset.officeParagraphShading);
6989
- const background = normalizeCssColor(element.style.backgroundColor);
6990
- if (semantic) {
6991
- const presentation = documentParagraphShadingPresentation(semantic);
6992
- const expected = normalizeCssColor(presentation.backgroundColor);
6993
- if (background && expected && background !== expected) {
6994
- if ('transparent' === background) return {
6995
- pattern: 'nil'
6996
- };
6997
- if (paragraphShadingBackgroundUsesForeground(semantic)) return {
6998
- ...semantic,
6999
- color: {
7000
- value: background
7001
- }
7002
- };
7003
- return {
7004
- ...semantic,
7005
- fill: {
7006
- value: background
7007
- }
7008
- };
7009
- }
7010
- return semantic;
7011
- }
7012
- return background && 'transparent' !== background ? {
7013
- pattern: 'clear',
7014
- fill: {
7015
- value: background
7016
- }
7017
- } : null;
7018
- }
7019
- function documentParagraphShadingDomAttributes(source) {
7020
- const shading = normalizeDocumentParagraphShading(source);
7021
- const serialized = serializeDocumentParagraphShading(shading);
7022
- if (!shading || !serialized) return {};
7023
- const presentation = documentParagraphShadingPresentation(shading);
7024
- const styles = [
7025
- `background-color: ${presentation.backgroundColor}`,
7026
- presentation.backgroundImage ? `background-image: ${presentation.backgroundImage}` : '',
7027
- presentation.backgroundSize ? `background-size: ${presentation.backgroundSize}` : ''
7028
- ].filter(Boolean);
7029
- return {
7030
- 'data-office-paragraph-shading': serialized,
7031
- style: styles.join('; ')
7032
- };
7033
- }
7034
- function normalizeShadingColor(source) {
7035
- if (!source || 'object' != typeof source) return null;
7036
- const value = source;
7037
- const theme = parseDocxThemeReference('string' == typeof value.theme ? value.theme : value.theme ? JSON.stringify(value.theme) : void 0);
7038
- const direct = 'auto' === value.value ? 'auto' : 'string' == typeof value.value ? normalizeCssColor(value.value) : null;
7039
- const resolved = direct ?? theme?.resolved ?? null;
7040
- if (!resolved || 'transparent' === resolved) return null;
7041
- if (theme && resolved !== theme.resolved) return null;
7042
- return {
7043
- value: resolved,
7044
- ...theme ? {
7045
- theme
7046
- } : {}
7047
- };
7048
- }
7049
- function serializedShadingColor(color) {
7050
- const theme = serializeDocxThemeReference(color.theme ?? null);
7051
- return {
7052
- value: color.value,
7053
- ...theme ? {
7054
- theme: JSON.parse(theme)
7055
- } : {}
7056
- };
7057
- }
7058
- function documentParagraphShadingPresentation(shading) {
7059
- if ('nil' === shading.pattern) return {
7060
- backgroundColor: 'transparent'
7061
- };
7062
- const foreground = shadingColor(shading.color, '#000000');
7063
- const background = shadingColor(shading.fill, 'transparent');
7064
- if ('clear' === shading.pattern) return {
7065
- backgroundColor: background
7066
- };
7067
- if ('solid' === shading.pattern) return {
7068
- backgroundColor: foreground
7069
- };
7070
- const percentage = shadingPercentage(shading.pattern);
7071
- if (null !== percentage) {
7072
- const inverted = percentage > 50;
7073
- const dotColor = inverted ? background : foreground;
7074
- const baseColor = inverted ? foreground : background;
7075
- const density = Math.min(50, inverted ? 100 - percentage : percentage);
7076
- const spacing = Math.max(2, Math.round(9 - density / 7));
7077
- return {
7078
- backgroundColor: baseColor,
7079
- backgroundImage: `radial-gradient(circle, ${dotColor} 0 1px, transparent 1.2px)`,
7080
- backgroundSize: `${spacing}px ${spacing}px`
7081
- };
7082
- }
7083
- const thin = shading.pattern.startsWith('thin');
7084
- const width = thin ? 1 : 2;
7085
- const period = thin ? 7 : 6;
7086
- const stripe = (angle)=>`repeating-linear-gradient(${angle}deg, ${foreground} 0 ${width}px, transparent ${width}px ${period}px)`;
7087
- const angles = shadingPatternAngles(shading.pattern);
7088
- return {
7089
- backgroundColor: background,
7090
- backgroundImage: angles.map(stripe).join(', ')
7091
- };
7092
- }
7093
- function shadingColor(color, fallback) {
7094
- return color && 'auto' !== color.value ? color.value : fallback;
7095
- }
7096
- function shadingPercentage(pattern) {
7097
- const match = /^pct(\d+)$/.exec(pattern);
7098
- return match?.[1] ? Number(match[1]) : null;
7099
- }
7100
- function paragraphShadingBackgroundUsesForeground(shading) {
7101
- if ('solid' === shading.pattern) return true;
7102
- const percentage = shadingPercentage(shading.pattern);
7103
- return null !== percentage && percentage > 50;
7104
- }
7105
- function shadingPatternAngles(pattern) {
7106
- if (pattern.includes('HorzCross')) return [
7107
- 0,
7108
- 90
7109
- ];
7110
- if (pattern.includes('DiagCross')) return [
7111
- 45,
7112
- -45
7113
- ];
7114
- if (pattern.includes('VertStripe')) return [
7115
- 90
7116
- ];
7117
- if (pattern.includes('ReverseDiagStripe')) return [
7118
- -45
7119
- ];
7120
- if (pattern.includes('DiagStripe')) return [
7121
- 45
7122
- ];
7123
- return [
7124
- 0
7125
- ];
7126
- }
7127
- const DOCUMENT_TABLE_ROW_ID_ATTRIBUTE = 'data-office-row-id';
7128
- const DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE = 'data-office-row-text-id';
7129
- const DocumentTableRowIdentity = Extension.create({
7130
- name: 'documentTableRowIdentity',
7131
- addOptions () {
7132
- return {
7133
- rotateTextId: ()=>true
7134
- };
7135
- },
7136
- addGlobalAttributes () {
7137
- return [
7138
- {
7139
- types: [
7140
- 'tableRow'
7141
- ],
7142
- attributes: {
7143
- rowId: identityAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7144
- rowTextId: identityAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7145
- }
7146
- }
7147
- ];
7148
- },
7149
- addProseMirrorPlugins () {
7150
- return [
7151
- createDocumentTableRowIdentityPlugin(this.options.rotateTextId)
7152
- ];
7153
- }
7154
- });
7155
- function normalizeDocumentTableRowIdentity(source) {
7156
- const rowId = normalizeDocumentParagraphId(source.rowId);
7157
- const rowTextId = normalizeDocumentParagraphId(source.rowTextId);
7158
- return rowId && rowTextId ? {
7159
- rowId,
7160
- rowTextId
7161
- } : null;
7162
- }
7163
- function documentTableRowIdentityFromElement(element) {
7164
- return normalizeDocumentTableRowIdentity({
7165
- rowId: element.getAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE),
7166
- rowTextId: element.getAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE)
7167
- });
7168
- }
7169
- function applyDocumentTableRowIdentityToElement(element, source) {
7170
- const identity = normalizeDocumentTableRowIdentity(source);
7171
- if (!identity) {
7172
- element.removeAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE);
7173
- element.removeAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE);
7174
- return null;
7175
- }
7176
- element.setAttribute(DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, identity.rowId);
7177
- element.setAttribute(DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, identity.rowTextId);
7178
- return identity;
7179
- }
7180
- function identityAttribute(htmlName) {
7181
- return {
7182
- default: null,
7183
- parseHTML: (element)=>normalizeDocumentParagraphId(element.getAttribute(htmlName)),
7184
- renderHTML: (attributes)=>{
7185
- const modelName = htmlName === DOCUMENT_TABLE_ROW_ID_ATTRIBUTE ? 'rowId' : 'rowTextId';
7186
- const value = normalizeDocumentParagraphId(attributes[modelName]);
7187
- return value ? {
7188
- [htmlName]: value
7189
- } : {};
7190
- }
7191
- };
7192
- }
7193
- function createDocumentTableRowIdentityPlugin(rotateTextId) {
7194
- return new Plugin({
7195
- view (view) {
7196
- const transaction = normalizeDocumentTableRowIdentities(view.state, rotateTextId);
7197
- if (transaction) {
7198
- transaction.setMeta('addToHistory', false);
7199
- view.dispatch(transaction);
7200
- }
7201
- return {};
7202
- },
7203
- appendTransaction (transactions, oldState, newState) {
7204
- if (!transactions.some((transaction)=>transaction.docChanged)) return null;
7205
- return normalizeDocumentTableRowIdentities(newState, rotateTextId, oldState, transactions);
7206
- }
7207
- });
7208
- }
7209
- function normalizeDocumentTableRowIdentities(state, rotateTextId, oldState, transactions = []) {
7210
- if (!documentHasIntegrityFeature(state.doc, 32)) return null;
7211
- const rows = documentTableRows(state.doc);
7212
- if (!rows.length) return null;
7213
- const retainedPositions = oldState ? retainedDocumentTableRowPositions(oldState, state, transactions) : new Set();
7214
- const editedPositions = oldState && rotateTextId() && !transactions.some(isHistoryTransaction) ? editedDocumentTableRowPositions(oldState, state, transactions) : new Set();
7215
- const ordered = [
7216
- ...rows.filter((item)=>retainedPositions.has(item.position)),
7217
- ...rows.filter((item)=>!retainedPositions.has(item.position))
7218
- ];
7219
- const registry = createDocumentParagraphIdentityRegistry();
7220
- const updates = new Map();
7221
- for (const row of ordered){
7222
- const current = tableRowIdentitySourceFromNode(row.node);
7223
- const source = editedPositions.has(row.position) ? {
7224
- rowId: current.rowId,
7225
- rowTextId: createDocumentParagraphIdentity().textId
7226
- } : current;
7227
- const wordIdentity = uniqueDocumentParagraphIdentity({
7228
- paragraphId: source.rowId,
7229
- textId: source.rowTextId
7230
- }, registry);
7231
- const identity = {
7232
- rowId: wordIdentity.paragraphId,
7233
- rowTextId: wordIdentity.textId
7234
- };
7235
- if (!sameDocumentTableRowIdentity(current, identity)) updates.set(row.position, identity);
7236
- }
7237
- if (!updates.size) return null;
7238
- const transaction = state.tr;
7239
- for (const row of rows){
7240
- const identity = updates.get(row.position);
7241
- if (identity) transaction.setNodeMarkup(row.position, void 0, {
7242
- ...row.node.attrs,
7243
- ...identity
7244
- });
7245
- }
7246
- if (!transaction.docChanged) return null;
7247
- transaction.setMeta('addToHistory', false);
7248
- return transaction;
7249
- }
7250
- function hasDocumentTableRowIdentityComponent(node) {
7251
- return Boolean(normalizeDocumentParagraphId(node.attrs.rowId) || normalizeDocumentParagraphId(node.attrs.rowTextId));
7252
- }
7253
- function retainedDocumentTableRowPositions(oldState, newState, transactions) {
7254
- const mapping = work_document_table_row_identity_transactionMapping(transactions);
7255
- const retained = new Set();
7256
- for (const previous of documentTableRows(oldState.doc)){
7257
- const rowId = normalizeDocumentParagraphId(previous.node.attrs.rowId);
7258
- if (!rowId) continue;
7259
- const mapped = mapping.mapResult(previous.position, 1);
7260
- const current = newState.doc.nodeAt(mapped.pos);
7261
- if (current?.type.name === 'tableRow' && normalizeDocumentParagraphId(current.attrs.rowId) === rowId) retained.add(mapped.pos);
7262
- }
7263
- return retained;
7264
- }
7265
- function editedDocumentTableRowPositions(oldState, newState, transactions) {
7266
- const mapping = work_document_table_row_identity_transactionMapping(transactions);
7267
- const previousRows = documentTableRows(oldState.doc);
7268
- const currentRows = documentTableRows(newState.doc);
7269
- const previousById = tableRowsById(previousRows);
7270
- const currentById = tableRowsById(currentRows);
7271
- const edited = new Set();
7272
- for (const previous of previousRows){
7273
- const identity = normalizeDocumentTableRowIdentity(tableRowIdentitySourceFromNode(previous.node));
7274
- if (!identity) continue;
7275
- const mapped = mapping.mapResult(previous.position, 1);
7276
- const current = newState.doc.nodeAt(mapped.pos);
7277
- if (current?.type.name === 'tableRow' && normalizeDocumentParagraphId(current.attrs.rowId) === identity.rowId) {
7278
- if (tableRowContentChanged(previous.node, current, identity.rowTextId)) edited.add(mapped.pos);
7279
- continue;
7280
- }
7281
- const previousMatches = previousById.get(identity.rowId) ?? [];
7282
- const currentMatches = currentById.get(identity.rowId) ?? [];
7283
- if (1 === previousMatches.length && 1 === currentMatches.length && tableRowContentChanged(previous.node, currentMatches[0].node, identity.rowTextId)) edited.add(currentMatches[0].position);
7284
- }
7285
- return edited;
7286
- }
7287
- function tableRowContentChanged(previous, current, previousTextId) {
7288
- return tableRowContentSignature(previous) !== tableRowContentSignature(current) && normalizeDocumentParagraphId(current.attrs.rowTextId) === previousTextId;
7289
- }
7290
- function tableRowContentSignature(row) {
7291
- const parts = [
7292
- 'tableRow'
7293
- ];
7294
- row.descendants((node)=>{
7295
- if (node.isText) return void parts.push(`text:${node.text ?? ''}`);
7296
- if ('tableCell' === node.type.name || 'tableHeader' === node.type.name) return void parts.push(`${node.type.name}:${String(node.attrs.colspan ?? 1)}:${String(node.attrs.rowspan ?? 1)}`);
7297
- parts.push(node.type.name);
7298
- });
7299
- return parts.join('\u0000');
7300
- }
7301
- function tableRowsById(rows) {
7302
- const result = new Map();
7303
- for (const row of rows){
7304
- const id = normalizeDocumentParagraphId(row.node.attrs.rowId);
7305
- if (!id) continue;
7306
- const matches = result.get(id) ?? [];
7307
- matches.push(row);
7308
- result.set(id, matches);
7309
- }
7310
- return result;
7311
- }
7312
- function documentTableRows(document1) {
7313
- const rows = [];
7314
- document1.descendants((node, position)=>{
7315
- if ('tableRow' === node.type.name && hasDocumentTableRowIdentityComponent(node)) rows.push({
7316
- node,
7317
- position
7318
- });
7319
- });
7320
- return rows;
7321
- }
7322
- function tableRowIdentitySourceFromNode(node) {
7323
- return {
7324
- rowId: node.attrs.rowId,
7325
- rowTextId: node.attrs.rowTextId
7326
- };
7327
- }
7328
- function sameDocumentTableRowIdentity(source, identity) {
7329
- return normalizeDocumentParagraphId(source.rowId) === identity.rowId && normalizeDocumentParagraphId(source.rowTextId) === identity.rowTextId;
7330
- }
7331
- function work_document_table_row_identity_transactionMapping(transactions) {
7332
- const mapping = new Mapping();
7333
- for (const transaction of transactions)mapping.appendMapping(transaction.mapping);
7334
- return mapping;
7335
- }
7336
- const DOCUMENT_TEXT_CASE_ATTRIBUTE = 'data-office-text-case';
7337
- const documentTextCaseKeyboardShortcuts = {
7338
- allCaps: 'Mod-Shift-a',
7339
- smallCaps: 'Mod-Shift-k'
7340
- };
7341
- function normalizeDocumentTextCase(value) {
7342
- return 'none' === value || 'all-caps' === value || 'small-caps' === value ? value : null;
7343
- }
7344
- function documentTextCaseFromWordFlags(allCaps, smallCaps) {
7345
- if (void 0 === allCaps && void 0 === smallCaps) return null;
7346
- if (allCaps) return 'all-caps';
7347
- if (smallCaps) return 'small-caps';
7348
- return 'none';
7349
- }
7350
- function applyDocumentTextCaseStyle(element, textCase) {
7351
- element.dataset.officeTextCase = textCase;
7352
- element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
7353
- element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
7354
- }
7355
- function documentTextCaseCss(textCase) {
7356
- return [
7357
- `text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
7358
- `font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
7359
- ].join('; ');
7360
- }
7361
- const DOCUMENT_SCRIPT_FONTS_ATTRIBUTE = "data-office-script-fonts";
7362
- const DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE = "data-office-script-font-slot";
7363
- const MAX_FONT_NAME_LENGTH = 127;
7364
- const MAX_SERIALIZED_SCRIPT_FONTS_LENGTH = 4096;
7365
- const SCRIPT_FONT_KEYS = new Set([
7366
- 'ascii',
7367
- 'highAnsi',
7368
- 'eastAsia',
7369
- 'complexScript',
7370
- 'hint'
7371
- ]);
7372
- const SCRIPT_FONT_FACE_KEYS = new Set([
7373
- 'name',
7374
- 'theme',
7375
- 'resolved'
7376
- ]);
7377
- const SCRIPT_FONT_HINTS = new Set([
7378
- 'default',
7379
- 'eastAsia',
7380
- 'cs'
7381
- ]);
7382
- const work_document_script_fonts_THEME_FONTS = new Set([
7383
- 'majorEastAsia',
7384
- 'majorBidi',
7385
- 'majorAscii',
7386
- 'majorHAnsi',
7387
- 'minorEastAsia',
7388
- 'minorBidi',
7389
- 'minorAscii',
7390
- 'minorHAnsi'
7391
- ]);
7392
- const SLOT_FALLBACK_ORDER = {
7393
- ascii: [
7394
- 'ascii',
7395
- 'highAnsi',
7396
- 'eastAsia',
7397
- 'complexScript'
7398
- ],
7399
- highAnsi: [
7400
- 'highAnsi',
7401
- 'ascii',
7402
- 'eastAsia',
7403
- 'complexScript'
7404
- ],
7405
- eastAsia: [
7406
- 'eastAsia',
7407
- 'highAnsi',
7408
- 'ascii',
7409
- 'complexScript'
7410
- ],
7411
- complexScript: [
7412
- 'complexScript',
7413
- 'highAnsi',
7414
- 'ascii',
7415
- 'eastAsia'
7416
- ]
7417
- };
7418
- const NEUTRAL_SCRIPT_CHARACTER = /^[\p{Cc}\p{Cf}\p{M}\p{N}\p{P}\p{S}\p{Z}]$/u;
7419
- function normalizeDocumentScriptFonts(source) {
7420
- if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_KEYS)) return null;
7421
- const normalized = {};
7422
- for (const slot of scriptFontSlots){
7423
- if (void 0 === source[slot]) continue;
7424
- const face = normalizeDocumentScriptFontFace(source[slot]);
7425
- if (!face) return null;
7426
- normalized[slot] = face;
7427
- }
7428
- if (void 0 !== source.hint) {
7429
- const hint = normalizeDocumentScriptFontHint(source.hint);
7430
- if (!hint) return null;
7431
- normalized.hint = hint;
7432
- }
7433
- return Object.keys(normalized).length ? normalized : null;
7434
- }
7435
- function serializeDocumentScriptFonts(source) {
7436
- const fonts = normalizeDocumentScriptFonts(source);
7437
- return fonts ? JSON.stringify(fonts) : null;
7438
- }
7439
- function parseDocumentScriptFonts(source) {
7440
- if (!source || source.length > MAX_SERIALIZED_SCRIPT_FONTS_LENGTH) return null;
7441
- try {
7442
- return normalizeDocumentScriptFonts(JSON.parse(source));
7443
- } catch {
7444
- return null;
7445
- }
7446
- }
7447
- function documentScriptFontsFromElement(element) {
7448
- return parseDocumentScriptFonts(element.getAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE));
7449
- }
7450
- function documentScriptFontSlotFromElement(element) {
7451
- return normalizeDocumentScriptFontSlot(element.getAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE));
7452
- }
7453
- function documentScriptFontsDomAttributes(source, slot) {
7454
- const fonts = normalizeDocumentScriptFonts(source);
7455
- const normalizedSlot = normalizeDocumentScriptFontSlot(slot);
7456
- if (!fonts) return {};
7457
- const serialized = serializeDocumentScriptFonts(fonts);
7458
- if (!serialized) return {};
7459
- const family = documentScriptFontFamily(fonts, normalizedSlot ?? documentScriptFontSlotFromHint(fonts.hint));
7460
- return {
7461
- [DOCUMENT_SCRIPT_FONTS_ATTRIBUTE]: serialized,
7462
- ...normalizedSlot ? {
7463
- [DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE]: normalizedSlot
7464
- } : {},
7465
- ...family ? {
7466
- style: `font-family: ${family}`
7467
- } : {}
7468
- };
7469
- }
7470
- function documentScriptFontFamily(source, slot) {
7471
- const fonts = normalizeDocumentScriptFonts(source);
7472
- if (!fonts) return;
7473
- const families = [];
7474
- const seen = new Set();
7475
- for (const candidate of documentScriptFontFallbackSlots(slot)){
7476
- const family = documentScriptFontFaceFamily(fonts[candidate]);
7477
- const key = family?.toLocaleLowerCase();
7478
- if (!(!family || !key || seen.has(key))) {
7479
- seen.add(key);
7480
- families.push(cssFontFamily(family));
7481
- }
7482
- }
7483
- return families.length ? families.join(', ') : void 0;
7484
- }
7485
- function documentScriptFontFallbackSlots(slot) {
7486
- return SLOT_FALLBACK_ORDER[slot];
7487
- }
7488
- function documentScriptFontFamilyForRendering(source, slot, currentFontFamily) {
7489
- const projected = documentScriptFontFamily(source, slot);
7490
- const safeCurrent = safeCssFontFamilyList(currentFontFamily);
7491
- if (!safeCurrent || !projected) return projected;
7492
- const currentPrimary = documentFontNameFromCssFamily(safeCurrent);
7493
- const projectedPrimary = documentFontNameFromCssFamily(projected);
7494
- return currentPrimary && projectedPrimary && currentPrimary.toLocaleLowerCase() === projectedPrimary.toLocaleLowerCase() ? safeCurrent : projected;
7495
- }
7496
- function documentScriptFontDirectFamily(source, slot) {
7497
- const fonts = normalizeDocumentScriptFonts(source);
7498
- return fonts ? documentScriptFontFaceFamily(fonts[slot]) ?? null : null;
7499
- }
7500
- function documentScriptFontsForAllText(fontFamily) {
7501
- const name = documentFontNameFromCssFamily(fontFamily);
7502
- if (!name) return null;
7503
- const face = {
7504
- name,
7505
- resolved: name
7506
- };
7507
- return {
7508
- ascii: face,
7509
- highAnsi: face,
7510
- eastAsia: face,
7511
- complexScript: face,
7512
- hint: 'default'
7513
- };
7514
- }
7515
- function patchDocumentScriptFonts(source, patch, fallbackFontFamily) {
7516
- const current = normalizeDocumentScriptFonts(source) ?? documentScriptFontsForAllText(fallbackFontFamily) ?? {};
7517
- const next = {
7518
- ...current
7519
- };
7520
- if (void 0 !== patch.latin) {
7521
- const face = directFontFace(patch.latin);
7522
- if (face) {
7523
- next.ascii = face;
7524
- next.highAnsi = face;
7525
- } else {
7526
- delete next.ascii;
7527
- delete next.highAnsi;
7528
- }
7529
- }
7530
- if (void 0 !== patch.eastAsia) {
7531
- const face = directFontFace(patch.eastAsia);
7532
- if (face) next.eastAsia = face;
7533
- else delete next.eastAsia;
7534
- }
7535
- if (void 0 !== patch.complexScript) {
7536
- const face = directFontFace(patch.complexScript);
7537
- if (face) next.complexScript = face;
7538
- else delete next.complexScript;
7539
- }
7540
- return normalizeDocumentScriptFonts(next);
7541
- }
7542
- function documentScriptFontSegments(text, hint = 'default', forceComplexScript = false) {
7543
- if (!text) return [];
7544
- if (forceComplexScript) return [
7545
- {
7546
- from: 0,
7547
- to: text.length,
7548
- slot: 'complexScript'
7549
- }
7550
- ];
7551
- const characters = [];
7552
- let offset = 0;
7553
- for (const character of text){
7554
- const from = offset;
7555
- offset += character.length;
7556
- characters.push({
7557
- from,
7558
- to: offset,
7559
- slot: strongDocumentScriptFontSlot(character)
7560
- });
7561
- }
7562
- const fallback = documentScriptFontSlotFromHint(hint);
7563
- let previous = null;
7564
- for(let index = 0; index < characters.length; index += 1){
7565
- const entry = characters[index];
7566
- if (!entry) continue;
7567
- if (entry.slot) {
7568
- previous = entry.slot;
7569
- continue;
7570
- }
7571
- let next = previous;
7572
- if (!next) for(let cursor = index + 1; cursor < characters.length; cursor += 1){
7573
- const candidate = characters[cursor]?.slot;
7574
- if (candidate) {
7575
- next = candidate;
7576
- break;
7577
- }
7578
- }
7579
- entry.slot = next ?? fallback;
7580
- }
7581
- const segments = [];
7582
- for (const entry of characters){
7583
- const slot = entry.slot ?? fallback;
7584
- const prior = segments[segments.length - 1];
7585
- if (prior?.slot === slot && prior.to === entry.from) prior.to = entry.to;
7586
- else segments.push({
7587
- from: entry.from,
7588
- to: entry.to,
7589
- slot
7590
- });
7591
- }
7592
- return segments;
7593
- }
7594
- function normalizeDocumentScriptFontSlot(value) {
7595
- return scriptFontSlots.includes(value) ? value : null;
7596
- }
7597
- function normalizeDocumentScriptFontHint(value) {
7598
- return SCRIPT_FONT_HINTS.has(value) ? value : null;
7599
- }
7600
- function normalizeDocumentThemeFont(value) {
7601
- return work_document_script_fonts_THEME_FONTS.has(value) ? value : null;
7602
- }
7603
- function documentScriptFontSlotFromHint(hint) {
7604
- if ('eastAsia' === hint) return 'eastAsia';
7605
- if ('cs' === hint) return 'complexScript';
7606
- return 'ascii';
7607
- }
7608
- function documentFontNameFromCssFamily(value) {
7609
- if ('string' != typeof value) return null;
7610
- const source = value.trim();
7611
- if (!source) return null;
7612
- let family = '';
7613
- const quote = source[0];
7614
- if ('"' === quote || "'" === quote) {
7615
- let closed = false;
7616
- for(let index = 1; index < source.length; index += 1){
7617
- const character = source[index];
7618
- if (character === quote) {
7619
- closed = true;
7620
- break;
7621
- }
7622
- if ('\\' !== character) {
7623
- family += character;
7624
- continue;
7625
- }
7626
- const decoded = decodeCssEscape(source, index + 1);
7627
- if (!decoded) return null;
7628
- family += decoded.value;
7629
- index = decoded.end - 1;
7630
- }
7631
- if (!closed) return null;
7632
- } else family = source.split(',')[0] ?? '';
7633
- return normalizeDocumentFontName(family);
7634
- }
7635
- function cssDocumentFontFamily(value) {
7636
- const family = normalizeDocumentFontName(value);
7637
- return family ? cssFontFamily(family) : null;
7638
- }
7639
- function normalizeDocumentFontName(value) {
7640
- if ('string' != typeof value) return null;
7641
- const normalized = value.trim();
7642
- return normalized && normalized.length <= MAX_FONT_NAME_LENGTH && !/[\p{Cc}\p{Cs}]/u.test(normalized) ? normalized : null;
7643
- }
7644
- const scriptFontSlots = [
7645
- 'ascii',
7646
- 'highAnsi',
7647
- 'eastAsia',
7648
- 'complexScript'
7649
- ];
7650
- function normalizeDocumentScriptFontFace(source) {
7651
- if (!work_document_script_fonts_isRecordWithKeys(source, SCRIPT_FONT_FACE_KEYS)) return null;
7652
- const name = void 0 === source.name ? void 0 : normalizeDocumentFontName(source.name);
7653
- const resolved = void 0 === source.resolved ? void 0 : normalizeDocumentFontName(source.resolved);
7654
- const theme = void 0 === source.theme ? void 0 : normalizeDocumentThemeFont(source.theme);
7655
- if (void 0 !== source.name && !name || void 0 !== source.resolved && !resolved || null === theme || !name && !theme && !resolved) return null;
7656
- return {
7657
- ...name ? {
7658
- name
7659
- } : {},
7660
- ...theme ? {
7661
- theme
7662
- } : {},
7663
- ...resolved ? {
7664
- resolved
7665
- } : {}
7666
- };
7667
- }
7668
- function directFontFace(value) {
7669
- if (null === value) return null;
7670
- const name = documentFontNameFromCssFamily(value) ?? normalizeDocumentFontName(value);
7671
- return name ? {
7672
- name,
7673
- resolved: name
7674
- } : null;
7675
- }
7676
- function documentScriptFontFaceFamily(face) {
7677
- return face?.resolved ?? face?.name;
7678
- }
7679
- function strongDocumentScriptFontSlot(character) {
7680
- if (NEUTRAL_SCRIPT_CHARACTER.test(character)) return null;
7681
- const codePoint = character.codePointAt(0);
7682
- if (void 0 === codePoint) return null;
7683
- if (isComplexScriptCodePoint(codePoint)) return 'complexScript';
7684
- if (isEastAsianCodePoint(codePoint)) return 'eastAsia';
7685
- return codePoint <= 0x7f ? 'ascii' : 'highAnsi';
7686
- }
7687
- function isComplexScriptCodePoint(codePoint) {
7688
- 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;
7689
- }
7690
- function isEastAsianCodePoint(codePoint) {
7691
- 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;
7692
- }
7693
- function cssFontFamily(value) {
7694
- return /^(?:-?[\p{L}_])[\p{L}\p{N}_-]*$/u.test(value) ? value : `"${Array.from(value, cssStringCharacter).join('')}"`;
7695
- }
7696
- function cssStringCharacter(character) {
7697
- return /[\\":;{}<>]/u.test(character) ? `\\${character.codePointAt(0)?.toString(16)} ` : character;
6779
+ function documentTextCaseFromWordFlags(allCaps, smallCaps) {
6780
+ if (void 0 === allCaps && void 0 === smallCaps) return null;
6781
+ if (allCaps) return 'all-caps';
6782
+ if (smallCaps) return 'small-caps';
6783
+ return 'none';
7698
6784
  }
7699
- function safeCssFontFamilyList(value) {
7700
- if ('string' != typeof value) return null;
7701
- const source = value.trim();
7702
- if (!source || source.length > 1024 || /[;{}]/u.test(source)) return null;
7703
- const tokens = [];
7704
- let start = 0;
7705
- let quote = '';
7706
- for(let index = 0; index < source.length; index += 1){
7707
- const character = source[index] ?? '';
7708
- if (quote) {
7709
- if ('\\' === character) {
7710
- index += 1;
7711
- if (index >= source.length) return null;
7712
- } else if (character === quote) quote = '';
7713
- continue;
7714
- }
7715
- if ('"' === character || "'" === character) {
7716
- quote = character;
7717
- continue;
7718
- }
7719
- if (',' === character) {
7720
- tokens.push(source.slice(start, index).trim());
7721
- start = index + 1;
7722
- }
7723
- }
7724
- if (quote) return null;
7725
- tokens.push(source.slice(start).trim());
7726
- return tokens.length && tokens.every(validCssFontFamilyToken) ? source : null;
7727
- }
7728
- function validCssFontFamilyToken(value) {
7729
- if (!value) return false;
7730
- if (value.startsWith('"')) return /^"(?:[^"\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*"$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
7731
- if (value.startsWith("'")) return /^'(?:[^'\\\r\n\f]|\\(?:[\da-f]{1,6}\s?|[^\r\n\f]))*'$/iu.test(value) && null !== documentFontNameFromCssFamily(value);
7732
- return /[\p{L}_]/u.test(value) && /^[\p{L}_-][\p{L}\p{N}_ -]*$/u.test(value) && !/^(?:inherit|initial|revert(?:-layer)?|unset)$/iu.test(value);
7733
- }
7734
- function decodeCssEscape(source, start) {
7735
- if (start >= source.length) return null;
7736
- const hexadecimal = /^[\da-f]{1,6}/i.exec(source.slice(start))?.[0];
7737
- if (hexadecimal) {
7738
- const codePoint = Number.parseInt(hexadecimal, 16);
7739
- if (0 === codePoint || codePoint > 0x10ffff || codePoint >= 0xd800 && codePoint <= 0xdfff) return null;
7740
- let end = start + hexadecimal.length;
7741
- if (/\s/u.test(source[end] ?? '')) end += 1;
7742
- return {
7743
- value: String.fromCodePoint(codePoint),
7744
- end
7745
- };
7746
- }
7747
- const value = source[start];
7748
- return !value || /[\r\n\f]/u.test(value) ? null : {
7749
- value,
7750
- end: start + 1
7751
- };
6785
+ function applyDocumentTextCaseStyle(element, textCase) {
6786
+ element.dataset.officeTextCase = textCase;
6787
+ element.style.textTransform = 'all-caps' === textCase ? 'uppercase' : 'none';
6788
+ element.style.fontVariantCaps = 'small-caps' === textCase ? 'small-caps' : 'normal';
7752
6789
  }
7753
- function work_document_script_fonts_isRecordWithKeys(value, allowed) {
7754
- return 'object' == typeof value && null !== value && !Array.isArray(value) && Object.keys(value).every((key)=>allowed.has(key));
6790
+ function documentTextCaseCss(textCase) {
6791
+ return [
6792
+ `text-transform: ${'all-caps' === textCase ? 'uppercase' : 'none'}`,
6793
+ `font-variant-caps: ${'small-caps' === textCase ? 'small-caps' : 'normal'}`
6794
+ ].join('; ');
7755
6795
  }
7756
6796
  const workDocumentUnderlineStyles = [
7757
6797
  'none',
@@ -8350,10 +7390,17 @@ function sanitizeAttributes(element, tag) {
8350
7390
  const emphasisMark = 'span' === tag ? documentEmphasisMarkFromElement(element) : null;
8351
7391
  const emphasisAttributes = documentEmphasisMarkDomAttributes(emphasisMark);
8352
7392
  const hiddenText = 'span' === tag ? documentHiddenTextFromElement(element) : null;
7393
+ const proofingLanguages = 'span' === tag ? documentProofingLanguagesFromElement(element) : null;
7394
+ const noProof = 'span' === tag ? documentNoProofFromElement(element) : null;
7395
+ const proofingAttributes = documentProofingDomAttributes(proofingLanguages, noProof, scriptFontSlot);
8353
7396
  const legacyTextEffects = 'span' === tag ? documentLegacyTextEffectsFromElement(element) ?? {} : {};
8354
7397
  const legacyTextEffectAttributes = documentLegacyTextEffectsDomAttributes(legacyTextEffects);
8355
7398
  const runBorder = 'span' === tag ? parseDocumentRunBorderElement(element) : null;
8356
7399
  const runBorderAttributes = documentRunBorderDomAttributes(runBorder);
7400
+ const runShading = 'span' === tag ? parseDocumentRunShadingElement(element) : null;
7401
+ const runShadingAttributes = documentRunShadingDomAttributes(runShading);
7402
+ const highlight = 'span' === tag && element.hasAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE) ? documentHighlightFromElement(element) : null;
7403
+ const highlightAttributes = documentHighlightDomAttributes(highlight);
8357
7404
  const underline = 'u' === tag ? documentUnderlineFormattingFromElement(element) : null;
8358
7405
  const underlineAttributes = underline ? documentUnderlineDomAttributes(underline) : {};
8359
7406
  const strike = 's' === tag || 'strike' === tag ? documentStrikeFormattingFromElement(element) : null;
@@ -8381,6 +7428,12 @@ function sanitizeAttributes(element, tag) {
8381
7428
  element.removeAttribute(DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE);
8382
7429
  element.removeAttribute(DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE);
8383
7430
  element.removeAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE);
7431
+ element.removeAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE);
7432
+ element.removeAttribute(DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE);
7433
+ element.removeAttribute(DOCUMENT_NO_PROOF_ATTRIBUTE);
7434
+ element.removeAttribute('lang');
7435
+ element.removeAttribute('spellcheck');
7436
+ element.removeAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE);
8384
7437
  element.removeAttribute(DOCUMENT_SCRIPT_FONTS_ATTRIBUTE);
8385
7438
  element.removeAttribute(DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE);
8386
7439
  const styles = [
@@ -8397,6 +7450,8 @@ function sanitizeAttributes(element, tag) {
8397
7450
  underlineAttributes.style ?? '',
8398
7451
  strikeAttributes.style ?? '',
8399
7452
  runBorderAttributes.style ?? '',
7453
+ runShadingAttributes.style ?? '',
7454
+ highlightAttributes.style ?? '',
8400
7455
  borderAttributes.style ?? '',
8401
7456
  shadingAttributes.style ?? ''
8402
7457
  ].filter(Boolean);
@@ -8447,6 +7502,11 @@ function sanitizeAttributes(element, tag) {
8447
7502
  for (const [name, value] of Object.entries(legacyTextEffectAttributes))element.setAttribute(name, value);
8448
7503
  const serializedRunBorder = runBorderAttributes[DOCUMENT_RUN_BORDER_ATTRIBUTE];
8449
7504
  if (serializedRunBorder) element.setAttribute(DOCUMENT_RUN_BORDER_ATTRIBUTE, serializedRunBorder);
7505
+ const serializedRunShading = runShadingAttributes[DOCUMENT_RUN_SHADING_ATTRIBUTE];
7506
+ if (serializedRunShading) element.setAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE, serializedRunShading);
7507
+ for (const [name, value] of Object.entries(proofingAttributes))element.setAttribute(name, value);
7508
+ const nativeHighlight = highlightAttributes[DOCUMENT_HIGHLIGHT_ATTRIBUTE];
7509
+ if (nativeHighlight) element.setAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE, nativeHighlight);
8450
7510
  }
8451
7511
  if ('span' === tag && scriptFonts) {
8452
7512
  for (const [name, value] of Object.entries(scriptFontAttributes))if ('style' !== name) element.setAttribute(name, value);
@@ -8501,6 +7561,12 @@ function sanitizeAttributes(element, tag) {
8501
7561
  DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE,
8502
7562
  DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE,
8503
7563
  DOCUMENT_RUN_BORDER_ATTRIBUTE,
7564
+ DOCUMENT_RUN_SHADING_ATTRIBUTE,
7565
+ DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE,
7566
+ DOCUMENT_NO_PROOF_ATTRIBUTE,
7567
+ 'lang',
7568
+ 'spellcheck',
7569
+ DOCUMENT_HIGHLIGHT_ATTRIBUTE,
8504
7570
  DOCUMENT_SCRIPT_FONTS_ATTRIBUTE,
8505
7571
  DOCUMENT_SCRIPT_FONT_SLOT_ATTRIBUTE
8506
7572
  ] : [],
@@ -8847,7 +7913,7 @@ function documentContentLayoutProperties(layout) {
8847
7913
  };
8848
7914
  }
8849
7915
  function normalizeDocumentSemanticHtml(source, bibliography) {
8850
- return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(source))), bibliography)));
7916
+ return normalizeDocumentBookmarkReferencesHtml(normalizeDocumentBookmarksHtml(normalizeDocumentCitationsHtml(normalizeDocumentTableOfContentsHtml(normalizeDocumentFieldsHtml(normalizeDocumentCaptionsHtml(normalizeDocumentNotesHtml(source)))), bibliography)));
8851
7917
  }
8852
7918
  function applyDocumentSectionDomAttributes(element, layout, id) {
8853
7919
  for (const [name, value] of Object.entries(documentSectionDomAttributes(layout, id)))element.setAttribute(name, value);
@@ -9433,6 +8499,9 @@ const ALLOWED_ATTRIBUTES = {
9433
8499
  'legacyTextEmboss',
9434
8500
  'legacyTextImprint',
9435
8501
  'runBorder',
8502
+ 'runShading',
8503
+ 'proofingLanguages',
8504
+ 'noProof',
9436
8505
  "scriptFonts",
9437
8506
  "scriptFontSlot",
9438
8507
  'themeColor',
@@ -9442,6 +8511,7 @@ const ALLOWED_ATTRIBUTES = {
9442
8511
  ]),
9443
8512
  highlight: new Set([
9444
8513
  'color',
8514
+ 'nativeHighlight',
9445
8515
  'themeFill'
9446
8516
  ])
9447
8517
  };
@@ -9529,6 +8599,9 @@ function importedDocumentCharacterFormatting(formatting) {
9529
8599
  legacyTextEmboss: formatting.legacyTextEmboss,
9530
8600
  legacyTextImprint: formatting.legacyTextImprint,
9531
8601
  runBorder: formatting.runBorder,
8602
+ runShading: formatting.runShading,
8603
+ proofingLanguages: serializeDocumentProofingLanguages(formatting.proofingLanguages) ?? void 0,
8604
+ noProof: formatting.noProof,
9532
8605
  color: formatting.color,
9533
8606
  fontFamily: formatting.fontFamily,
9534
8607
  scriptFonts: serializeDocumentScriptFonts(formatting.scriptFonts) ?? void 0,
@@ -9545,6 +8618,7 @@ function importedDocumentCharacterFormatting(formatting) {
9545
8618
  });
9546
8619
  const highlight = compactAttributes({
9547
8620
  color: formatting.backgroundColor,
8621
+ nativeHighlight: formatting.highlight,
9548
8622
  themeFill: formatting.themeFill
9549
8623
  });
9550
8624
  if (highlight) marks.push({
@@ -9628,6 +8702,30 @@ function normalizeCharacterFormatMark(value) {
9628
8702
  attrs[key] = border;
9629
8703
  continue;
9630
8704
  }
8705
+ if ('textStyle' === type && 'runShading' === key) {
8706
+ const shading = serializeDocumentRunShading(parseDocumentRunShading(candidate));
8707
+ if (!shading) return null;
8708
+ attrs[key] = shading;
8709
+ continue;
8710
+ }
8711
+ if ('textStyle' === type && 'proofingLanguages' === key) {
8712
+ const languages = serializeDocumentProofingLanguages(parseDocumentProofingLanguages(candidate));
8713
+ if (!languages) return null;
8714
+ attrs[key] = languages;
8715
+ continue;
8716
+ }
8717
+ if ('textStyle' === type && 'noProof' === key) {
8718
+ const noProof = normalizeDocumentNoProof(candidate);
8719
+ if (null === noProof) return null;
8720
+ attrs[key] = noProof;
8721
+ continue;
8722
+ }
8723
+ if ('highlight' === type && 'nativeHighlight' === key) {
8724
+ const highlight = normalizeDocumentHighlight(candidate);
8725
+ if (!highlight) return null;
8726
+ attrs[key] = highlight;
8727
+ continue;
8728
+ }
9631
8729
  if ('string' == typeof candidate) {
9632
8730
  if (!candidate.length) continue;
9633
8731
  if ('textStyle' === type && 'textCase' === key && !normalizeDocumentTextCase(candidate)) return null;
@@ -10593,7 +9691,34 @@ const DocumentCharacterFormatting = Extension.create({
10593
9691
  size: 4,
10594
9692
  space: 1
10595
9693
  });
10596
- }
9694
+ },
9695
+ setDocumentRunShading: (shading)=>({ commands })=>{
9696
+ const serialized = serializeDocumentRunShading(normalizeDocumentRunShading(shading));
9697
+ return serialized ? commands.setMark('textStyle', {
9698
+ runShading: serialized
9699
+ }) : false;
9700
+ },
9701
+ unsetDocumentRunShading: ()=>({ chain })=>chain().setMark('textStyle', {
9702
+ runShading: null
9703
+ }).removeEmptyTextStyle().run(),
9704
+ setDocumentProofingLanguages: (languages)=>({ commands })=>{
9705
+ const serialized = serializeDocumentProofingLanguages(normalizeDocumentProofingLanguages(languages));
9706
+ return serialized ? commands.setMark('textStyle', {
9707
+ proofingLanguages: serialized
9708
+ }) : false;
9709
+ },
9710
+ unsetDocumentProofingLanguages: ()=>({ chain })=>chain().setMark('textStyle', {
9711
+ proofingLanguages: null
9712
+ }).removeEmptyTextStyle().run(),
9713
+ setDocumentNoProof: (noProof)=>({ commands })=>{
9714
+ const normalized = normalizeDocumentNoProof(noProof);
9715
+ return null === normalized ? false : commands.setMark('textStyle', {
9716
+ noProof: normalized
9717
+ });
9718
+ },
9719
+ unsetDocumentNoProof: ()=>({ chain })=>chain().setMark('textStyle', {
9720
+ noProof: null
9721
+ }).removeEmptyTextStyle().run()
10597
9722
  };
10598
9723
  },
10599
9724
  addKeyboardShortcuts () {
@@ -13405,58 +12530,485 @@ function applyDocumentImageLayerToElement(element, layer) {
13405
12530
  element.dataset.officeImageLockAnchor = String(normalized.lockAnchor);
13406
12531
  element.style.setProperty('--work-document-image-z-index', String(documentImageLayerCssZIndex(normalized)));
13407
12532
  }
13408
- function normalizeDocumentImageLayerBoolean(value, fallback) {
13409
- if (true === value || 1 === value || '1' === value || 'true' === value) return true;
13410
- if (false === value || 0 === value || '0' === value || 'false' === value) return false;
13411
- return fallback;
12533
+ function normalizeDocumentImageLayerBoolean(value, fallback) {
12534
+ if (true === value || 1 === value || '1' === value || 'true' === value) return true;
12535
+ if (false === value || 0 === value || '0' === value || 'false' === value) return false;
12536
+ return fallback;
12537
+ }
12538
+ function documentImageCropStyle(crop) {
12539
+ return documentImageCropStyleEntries(crop).map(([name, value])=>`${name}:${value}`).join(';');
12540
+ }
12541
+ function documentImageCropStyleEntries(crop) {
12542
+ const visibleWidth = 100 - crop.left - crop.right;
12543
+ const visibleHeight = 100 - crop.top - crop.bottom;
12544
+ return [
12545
+ ...[
12546
+ 'top',
12547
+ 'right',
12548
+ 'bottom',
12549
+ 'left'
12550
+ ].map((edge)=>[
12551
+ `--work-document-image-crop-${edge}`,
12552
+ `${formatImageLayoutNumber(crop[edge])}%`
12553
+ ]),
12554
+ [
12555
+ '--work-document-image-crop-scale-x',
12556
+ formatImageLayoutNumber(100 / visibleWidth)
12557
+ ],
12558
+ [
12559
+ '--work-document-image-crop-scale-y',
12560
+ formatImageLayoutNumber(100 / visibleHeight)
12561
+ ],
12562
+ [
12563
+ '--work-document-image-crop-translate-x',
12564
+ `${formatImageLayoutNumber(100 * -crop.left / visibleWidth)}%`
12565
+ ],
12566
+ [
12567
+ '--work-document-image-crop-translate-y',
12568
+ `${formatImageLayoutNumber(100 * -crop.top / visibleHeight)}%`
12569
+ ]
12570
+ ];
12571
+ }
12572
+ function setOptionalImageAttribute(element, name, value) {
12573
+ if ('string' == typeof value && value) element.setAttribute(name, value);
12574
+ else element.removeAttribute(name);
12575
+ }
12576
+ function syncImageDimension(element, dimension, value) {
12577
+ const pixels = 'number' == typeof value ? value : Number(value);
12578
+ if (Number.isFinite(pixels) && pixels > 0) {
12579
+ element.style[dimension] = `${pixels}px`;
12580
+ element.setAttribute(dimension, String(Math.round(pixels)));
12581
+ return;
12582
+ }
12583
+ element.style.removeProperty(dimension);
12584
+ element.removeAttribute(dimension);
12585
+ }
12586
+ const DocumentIndexEntry = core_Node.create({
12587
+ name: 'documentIndexEntry',
12588
+ group: 'inline',
12589
+ inline: true,
12590
+ atom: true,
12591
+ selectable: true,
12592
+ draggable: false,
12593
+ addAttributes () {
12594
+ return {
12595
+ id: work_document_index_nodes_hiddenAttribute(''),
12596
+ mainEntry: work_document_index_nodes_hiddenAttribute(''),
12597
+ subEntry: work_document_index_nodes_hiddenAttribute(''),
12598
+ crossReference: work_document_index_nodes_hiddenAttribute(''),
12599
+ pageBold: work_document_index_nodes_hiddenAttribute(false),
12600
+ pageItalic: work_document_index_nodes_hiddenAttribute(false)
12601
+ };
12602
+ },
12603
+ addCommands () {
12604
+ return {
12605
+ markDocumentIndexEntry: (value)=>(props)=>markDocumentIndexEntryCommand(props, value),
12606
+ updateDocumentIndexEntry: (value)=>(props)=>updateDocumentIndexEntryCommand(props, value)
12607
+ };
12608
+ },
12609
+ parseHTML () {
12610
+ return [
12611
+ {
12612
+ tag: 'span[data-document-index-entry]',
12613
+ getAttrs: (node)=>{
12614
+ if (!(node instanceof HTMLElement)) return false;
12615
+ const value = documentIndexEntryFromElement(node);
12616
+ return value ? indexEntryNodeAttributes(value) : false;
12617
+ }
12618
+ }
12619
+ ];
12620
+ },
12621
+ renderHTML ({ node, HTMLAttributes }) {
12622
+ const value = normalizeDocumentIndexEntry(node.attrs);
12623
+ if (!value) return [
12624
+ 'span',
12625
+ {
12626
+ hidden: 'true'
12627
+ }
12628
+ ];
12629
+ const detail = indexEntryLabel(value);
12630
+ return [
12631
+ 'span',
12632
+ mergeAttributes(HTMLAttributes, {
12633
+ 'data-document-index-entry': 'true',
12634
+ 'data-index-entry-id': value.id,
12635
+ 'data-index-main-entry': value.mainEntry,
12636
+ 'data-index-sub-entry': value.subEntry,
12637
+ 'data-index-cross-reference': value.crossReference,
12638
+ 'data-index-page-bold': String(value.pageBold),
12639
+ 'data-index-page-italic': String(value.pageItalic),
12640
+ class: 'work-document-index-entry',
12641
+ contenteditable: 'false',
12642
+ 'aria-label': `索引项:${detail}`
12643
+ }),
12644
+ [
12645
+ 'span',
12646
+ {
12647
+ 'aria-hidden': 'true'
12648
+ },
12649
+ '索引项'
12650
+ ],
12651
+ [
12652
+ 'strong',
12653
+ detail
12654
+ ]
12655
+ ];
12656
+ },
12657
+ renderText () {
12658
+ return '';
12659
+ }
12660
+ });
12661
+ const DocumentIndex = core_Node.create({
12662
+ name: 'documentIndex',
12663
+ group: 'block',
12664
+ atom: true,
12665
+ selectable: true,
12666
+ draggable: false,
12667
+ addAttributes () {
12668
+ return {
12669
+ id: work_document_index_nodes_hiddenAttribute(''),
12670
+ columns: work_document_index_nodes_hiddenAttribute(1),
12671
+ format: work_document_index_nodes_hiddenAttribute('indented'),
12672
+ rightAlignPageNumbers: work_document_index_nodes_hiddenAttribute(true),
12673
+ leader: work_document_index_nodes_hiddenAttribute('dot'),
12674
+ entries: work_document_index_nodes_hiddenAttribute([]),
12675
+ truncated: work_document_index_nodes_hiddenAttribute(false)
12676
+ };
12677
+ },
12678
+ addCommands () {
12679
+ return {
12680
+ insertDocumentIndex: (options = DEFAULT_DOCUMENT_INDEX_OPTIONS, buildOptions)=>(props)=>insertDocumentIndexCommand(props, options, buildOptions),
12681
+ updateDocumentIndex: (options, buildOptions)=>(props)=>updateDocumentIndexCommand(props, options, buildOptions),
12682
+ refreshDocumentIndexes: (buildOptions)=>(props)=>refreshDocumentIndexesCommand(props, buildOptions)
12683
+ };
12684
+ },
12685
+ parseHTML () {
12686
+ return [
12687
+ {
12688
+ tag: 'div[data-document-index]',
12689
+ getAttrs: (node)=>{
12690
+ if (!(node instanceof HTMLElement)) return false;
12691
+ return indexNodeAttributes(documentIndexValueFromElement(node));
12692
+ }
12693
+ }
12694
+ ];
12695
+ },
12696
+ renderHTML ({ node, HTMLAttributes }) {
12697
+ const value = normalizeDocumentIndexValue({
12698
+ id: work_document_index_nodes_stringAttribute(node.attrs.id) || 'document-index',
12699
+ options: indexOptionsFromAttributes(node.attrs),
12700
+ entries: Array.isArray(node.attrs.entries) ? node.attrs.entries : [],
12701
+ truncated: Boolean(node.attrs.truncated)
12702
+ });
12703
+ const rows = value.entries.length ? value.entries.map((entry)=>indexEntrySpec(entry)) : [
12704
+ [
12705
+ 'li',
12706
+ {
12707
+ class: 'work-document-index-empty'
12708
+ },
12709
+ '没有已标记的索引项'
12710
+ ]
12711
+ ];
12712
+ return [
12713
+ 'div',
12714
+ mergeAttributes(HTMLAttributes, {
12715
+ 'data-document-index': 'true',
12716
+ 'data-index-id': value.id,
12717
+ 'data-index-columns': String(value.options.columns),
12718
+ 'data-index-format': value.options.format,
12719
+ 'data-index-right-align-page-numbers': String(value.options.rightAlignPageNumbers),
12720
+ 'data-index-leader': value.options.leader,
12721
+ 'data-index-entries': JSON.stringify(value.entries),
12722
+ 'data-index-truncated': String(value.truncated),
12723
+ class: 'work-document-index',
12724
+ contenteditable: 'false',
12725
+ 'aria-label': '索引'
12726
+ }),
12727
+ [
12728
+ 'div',
12729
+ {
12730
+ class: 'work-document-index-header'
12731
+ },
12732
+ [
12733
+ 'strong',
12734
+ '索引'
12735
+ ],
12736
+ [
12737
+ 'span',
12738
+ value.truncated ? "仅显示前 512 项" : `${value.entries.length} 项`
12739
+ ]
12740
+ ],
12741
+ [
12742
+ 'ol',
12743
+ {
12744
+ class: 'work-document-index-list'
12745
+ },
12746
+ ...rows
12747
+ ]
12748
+ ];
12749
+ },
12750
+ renderText ({ node }) {
12751
+ const entries = Array.isArray(node.attrs.entries) ? node.attrs.entries : [];
12752
+ return entries.map((entry)=>[
12753
+ entry.mainEntry,
12754
+ entry.subEntry,
12755
+ entry.crossReference
12756
+ ].filter(Boolean).join(' ')).join('\n');
12757
+ },
12758
+ addProseMirrorPlugins () {
12759
+ return [
12760
+ new Plugin({
12761
+ props: {
12762
+ handleDOMEvents: {
12763
+ click: (view, event)=>{
12764
+ if (!(event.target instanceof Element)) return false;
12765
+ const link = event.target.closest('[data-document-index] [data-index-target]');
12766
+ const targetId = link?.dataset.indexTarget?.trim();
12767
+ if (!link || !targetId) return false;
12768
+ let targetPosition = null;
12769
+ view.state.doc.descendants((node, position)=>{
12770
+ if (null !== targetPosition) return false;
12771
+ if ('documentIndexEntry' === node.type.name && node.attrs.id === targetId) {
12772
+ targetPosition = position;
12773
+ return false;
12774
+ }
12775
+ return true;
12776
+ });
12777
+ if (null === targetPosition) return false;
12778
+ event.preventDefault();
12779
+ view.dispatch(view.state.tr.setSelection(NodeSelection.create(view.state.doc, targetPosition)).scrollIntoView());
12780
+ view.focus();
12781
+ return true;
12782
+ }
12783
+ }
12784
+ }
12785
+ })
12786
+ ];
12787
+ }
12788
+ });
12789
+ function selectedDocumentIndexEntry(editor) {
12790
+ const selection = editor.state.selection;
12791
+ if (!(selection instanceof NodeSelection) || 'documentIndexEntry' !== selection.node.type.name) return null;
12792
+ return normalizeDocumentIndexEntry(selection.node.attrs);
12793
+ }
12794
+ function selectedDocumentIndexOptions(editor) {
12795
+ const selection = editor.state.selection;
12796
+ if (!(selection instanceof NodeSelection) || 'documentIndex' !== selection.node.type.name) return null;
12797
+ return indexOptionsFromAttributes(selection.node.attrs);
12798
+ }
12799
+ function selectedDocumentIndexDraft(editor) {
12800
+ const selected = selectedDocumentIndexEntry(editor);
12801
+ if (selected) return {
12802
+ mainEntry: selected.mainEntry,
12803
+ subEntry: selected.subEntry,
12804
+ crossReference: selected.crossReference,
12805
+ pageBold: selected.pageBold,
12806
+ pageItalic: selected.pageItalic
12807
+ };
12808
+ const { from, to } = editor.state.selection;
12809
+ const mainEntry = editor.state.doc.textBetween(from, to, ' ').replace(/\s+/g, ' ').trim();
12810
+ return normalizeDocumentIndexEntryDraft({
12811
+ mainEntry
12812
+ });
12813
+ }
12814
+ function documentHasIndex(editor) {
12815
+ return documentHasNode(editor, 'documentIndex');
12816
+ }
12817
+ function markDocumentIndexEntryCommand({ dispatch, editor, state, tr }, source) {
12818
+ const value = normalizeDocumentIndexEntryDraft(source);
12819
+ const nodeType = editor.schema.nodes.documentIndexEntry;
12820
+ if (!value || !nodeType) return false;
12821
+ const selection = state.selection;
12822
+ if (selection instanceof NodeSelection && 'documentIndexEntry' === selection.node.type.name) return updateDocumentIndexEntryCommand({
12823
+ dispatch,
12824
+ editor,
12825
+ state,
12826
+ tr
12827
+ }, value);
12828
+ if (!dispatch) return true;
12829
+ const position = selection.to;
12830
+ const node = nodeType.create({
12831
+ id: createWorkId('index-entry'),
12832
+ ...value
12833
+ });
12834
+ tr.insert(position, node);
12835
+ tr.setSelection(TextSelection.near(tr.doc.resolve(position + node.nodeSize)));
12836
+ tr.scrollIntoView();
12837
+ return tr.docChanged;
12838
+ }
12839
+ function updateDocumentIndexEntryCommand({ dispatch, state, tr }, source) {
12840
+ const selection = state.selection;
12841
+ const value = normalizeDocumentIndexEntryDraft(source);
12842
+ if (!value || !(selection instanceof NodeSelection) || 'documentIndexEntry' !== selection.node.type.name) return false;
12843
+ if (!dispatch) return true;
12844
+ tr.setNodeMarkup(selection.from, void 0, {
12845
+ ...selection.node.attrs,
12846
+ ...value
12847
+ });
12848
+ tr.scrollIntoView();
12849
+ return tr.docChanged;
12850
+ }
12851
+ function insertDocumentIndexCommand({ dispatch, editor, tr }, source, buildOptions = {}) {
12852
+ const nodeType = editor.schema.nodes.documentIndex;
12853
+ if (!nodeType) return false;
12854
+ if (!dispatch) return true;
12855
+ const options = normalizeDocumentIndexOptions(source);
12856
+ const built = buildDocumentIndexEntries(tr.doc, buildOptions);
12857
+ tr.replaceSelectionWith(nodeType.create({
12858
+ id: createWorkId('index'),
12859
+ ...options,
12860
+ ...built
12861
+ }), false);
12862
+ tr.scrollIntoView();
12863
+ return true;
12864
+ }
12865
+ function updateDocumentIndexCommand({ dispatch, state, tr }, source, buildOptions = {}) {
12866
+ const selection = state.selection;
12867
+ if (!(selection instanceof NodeSelection) || 'documentIndex' !== selection.node.type.name) return false;
12868
+ if (!dispatch) return true;
12869
+ const options = normalizeDocumentIndexOptions(source);
12870
+ const built = buildDocumentIndexEntries(tr.doc, buildOptions);
12871
+ tr.setNodeMarkup(selection.from, void 0, {
12872
+ ...selection.node.attrs,
12873
+ ...options,
12874
+ ...built
12875
+ });
12876
+ tr.scrollIntoView();
12877
+ return tr.docChanged;
12878
+ }
12879
+ function refreshDocumentIndexesCommand({ dispatch, state, tr }, buildOptions = {}) {
12880
+ const updates = [];
12881
+ const built = buildDocumentIndexEntries(state.doc, buildOptions);
12882
+ state.doc.descendants((node, position)=>{
12883
+ if ('documentIndex' !== node.type.name) return;
12884
+ if (JSON.stringify(node.attrs.entries) === JSON.stringify(built.entries) && Boolean(node.attrs.truncated) === built.truncated) return;
12885
+ updates.push({
12886
+ position,
12887
+ attrs: {
12888
+ ...node.attrs,
12889
+ ...built
12890
+ }
12891
+ });
12892
+ });
12893
+ if (!updates.length) return false;
12894
+ if (!dispatch) return true;
12895
+ for (const update of updates)tr.setNodeMarkup(update.position, void 0, update.attrs);
12896
+ tr.scrollIntoView();
12897
+ return tr.docChanged;
12898
+ }
12899
+ function indexEntryNodeAttributes(value) {
12900
+ return {
12901
+ ...value
12902
+ };
13412
12903
  }
13413
- function documentImageCropStyle(crop) {
13414
- return documentImageCropStyleEntries(crop).map(([name, value])=>`${name}:${value}`).join(';');
12904
+ function indexNodeAttributes(value) {
12905
+ return {
12906
+ id: value.id,
12907
+ ...value.options,
12908
+ entries: value.entries,
12909
+ truncated: value.truncated
12910
+ };
12911
+ }
12912
+ function indexOptionsFromAttributes(attrs) {
12913
+ return normalizeDocumentIndexOptions({
12914
+ columns: Number(attrs.columns),
12915
+ format: 'run-in' === attrs.format ? 'run-in' : 'indented',
12916
+ rightAlignPageNumbers: Boolean(attrs.rightAlignPageNumbers),
12917
+ leader: 'string' == typeof attrs.leader ? attrs.leader : 'dot'
12918
+ });
13415
12919
  }
13416
- function documentImageCropStyleEntries(crop) {
13417
- const visibleWidth = 100 - crop.left - crop.right;
13418
- const visibleHeight = 100 - crop.top - crop.bottom;
13419
- return [
13420
- ...[
13421
- 'top',
13422
- 'right',
13423
- 'bottom',
13424
- 'left'
13425
- ].map((edge)=>[
13426
- `--work-document-image-crop-${edge}`,
13427
- `${formatImageLayoutNumber(crop[edge])}%`
13428
- ]),
12920
+ function indexEntrySpec(entry) {
12921
+ const term = [
13429
12922
  [
13430
- '--work-document-image-crop-scale-x',
13431
- formatImageLayoutNumber(100 / visibleWidth)
13432
- ],
12923
+ 'span',
12924
+ {
12925
+ class: 'work-document-index-main'
12926
+ },
12927
+ entry.mainEntry
12928
+ ]
12929
+ ];
12930
+ if (entry.subEntry) term.push([
12931
+ 'span',
12932
+ {
12933
+ class: 'work-document-index-sub'
12934
+ },
12935
+ entry.subEntry
12936
+ ]);
12937
+ const pages = entry.crossReference ? [
13433
12938
  [
13434
- '--work-document-image-crop-scale-y',
13435
- formatImageLayoutNumber(100 / visibleHeight)
13436
- ],
12939
+ 'span',
12940
+ {
12941
+ class: 'work-document-index-cross-reference'
12942
+ },
12943
+ `参见 ${entry.crossReference}`
12944
+ ]
12945
+ ] : entry.pages.flatMap((page, index)=>{
12946
+ const targetId = page.targetIds[0] ?? '';
12947
+ const result = [];
12948
+ if (index > 0) result.push([
12949
+ 'span',
12950
+ {
12951
+ 'aria-hidden': 'true'
12952
+ },
12953
+ ', '
12954
+ ]);
12955
+ result.push([
12956
+ 'a',
12957
+ {
12958
+ href: `#${targetId}`,
12959
+ 'data-index-target': targetId,
12960
+ tabindex: '-1',
12961
+ class: [
12962
+ page.pageBold ? 'bold' : '',
12963
+ page.pageItalic ? 'italic' : ''
12964
+ ].filter(Boolean).join(' ') || void 0
12965
+ },
12966
+ String(page.pageNumber)
12967
+ ]);
12968
+ return result;
12969
+ });
12970
+ return [
12971
+ 'li',
12972
+ {
12973
+ 'data-index-main-entry': entry.mainEntry,
12974
+ 'data-index-sub-entry': entry.subEntry
12975
+ },
12976
+ ...term,
13437
12977
  [
13438
- '--work-document-image-crop-translate-x',
13439
- `${formatImageLayoutNumber(100 * -crop.left / visibleWidth)}%`
12978
+ 'i',
12979
+ {
12980
+ 'aria-hidden': 'true'
12981
+ }
13440
12982
  ],
13441
12983
  [
13442
- '--work-document-image-crop-translate-y',
13443
- `${formatImageLayoutNumber(100 * -crop.top / visibleHeight)}%`
12984
+ 'span',
12985
+ {
12986
+ class: 'work-document-index-pages'
12987
+ },
12988
+ ...pages
13444
12989
  ]
13445
12990
  ];
13446
12991
  }
13447
- function setOptionalImageAttribute(element, name, value) {
13448
- if ('string' == typeof value && value) element.setAttribute(name, value);
13449
- else element.removeAttribute(name);
12992
+ function indexEntryLabel(value) {
12993
+ const term = value.subEntry ? `${value.mainEntry} ${value.subEntry}` : value.mainEntry;
12994
+ return value.crossReference ? `${term} · 参见 ${value.crossReference}` : term;
13450
12995
  }
13451
- function syncImageDimension(element, dimension, value) {
13452
- const pixels = 'number' == typeof value ? value : Number(value);
13453
- if (Number.isFinite(pixels) && pixels > 0) {
13454
- element.style[dimension] = `${pixels}px`;
13455
- element.setAttribute(dimension, String(Math.round(pixels)));
13456
- return;
13457
- }
13458
- element.style.removeProperty(dimension);
13459
- element.removeAttribute(dimension);
12996
+ function documentHasNode(editor, typeName) {
12997
+ let found = false;
12998
+ editor.state.doc.descendants((node)=>{
12999
+ if (node.type.name === typeName) found = true;
13000
+ return !found;
13001
+ });
13002
+ return found;
13003
+ }
13004
+ function work_document_index_nodes_hiddenAttribute(defaultValue) {
13005
+ return {
13006
+ default: defaultValue,
13007
+ rendered: false
13008
+ };
13009
+ }
13010
+ function work_document_index_nodes_stringAttribute(value) {
13011
+ return 'string' == typeof value ? value.trim() : '';
13460
13012
  }
13461
13013
  const DocumentLazyBlock = core_Node.create({
13462
13014
  name: DOCUMENT_LAZY_BLOCK_NODE,
@@ -15356,6 +14908,8 @@ function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle,
15356
14908
  if (null === ligatures || null === kerning) return null;
15357
14909
  const letterSpacing = style.letterSpacing && 'normal' !== style.letterSpacing ? finitePixels(style.letterSpacing) : 0;
15358
14910
  if (letterSpacing < -100 || letterSpacing > 100) return null;
14911
+ const language = documentTextLayoutLanguage(element);
14912
+ if (null === language) return null;
15359
14913
  return {
15360
14914
  fontId: font.id,
15361
14915
  ...fallbackFonts.length ? {
@@ -15363,6 +14917,9 @@ function documentTextLayoutRunStyle(style, fonts, loadedFontIds, paragraphStyle,
15363
14917
  } : {},
15364
14918
  fontSize,
15365
14919
  lineHeight,
14920
+ ...language ? {
14921
+ language
14922
+ } : {},
15366
14923
  letterSpacing,
15367
14924
  ligatures,
15368
14925
  kerning
@@ -15397,11 +14954,20 @@ function documentTextLayoutRunStyleKey(style) {
15397
14954
  (style.fallbackFontIds ?? []).join('\u0002'),
15398
14955
  style.fontSize,
15399
14956
  style.lineHeight,
14957
+ style.language ?? '',
15400
14958
  style.letterSpacing ?? 0,
15401
14959
  style.ligatures ?? true,
15402
14960
  style.kerning ?? true
15403
14961
  ].join('\u0000');
15404
14962
  }
14963
+ function documentTextLayoutLanguage(element) {
14964
+ for(let current = element; current; current = current.parentElement){
14965
+ if (!current.hasAttribute('lang')) continue;
14966
+ const source = current.getAttribute('lang') ?? '';
14967
+ if (!source) break;
14968
+ return normalizeDocumentLanguageTag(source);
14969
+ }
14970
+ }
15405
14971
  function cssValueIs(value, ...supported) {
15406
14972
  return !value || supported.includes(value);
15407
14973
  }
@@ -16992,6 +16558,18 @@ const DocumentTextStyle = TextStyle.extend({
16992
16558
  {
16993
16559
  tag: `span[${DOCUMENT_RUN_BORDER_ATTRIBUTE}]`,
16994
16560
  consuming: false
16561
+ },
16562
+ {
16563
+ tag: `span[${DOCUMENT_RUN_SHADING_ATTRIBUTE}]`,
16564
+ consuming: false
16565
+ },
16566
+ {
16567
+ tag: `span[${DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE}]`,
16568
+ consuming: false
16569
+ },
16570
+ {
16571
+ tag: `span[${DOCUMENT_NO_PROOF_ATTRIBUTE}]`,
16572
+ consuming: false
16995
16573
  }
16996
16574
  ];
16997
16575
  },
@@ -17046,6 +16624,21 @@ const DocumentTextStyle = TextStyle.extend({
17046
16624
  parseHTML: (element)=>serializeDocumentRunBorder(parseDocumentRunBorderElement(element)) ?? null,
17047
16625
  renderHTML: (attributes)=>documentRunBorderDomAttributes(parseDocumentRunBorder(attributes.runBorder))
17048
16626
  },
16627
+ runShading: {
16628
+ default: null,
16629
+ parseHTML: (element)=>serializeDocumentRunShading(parseDocumentRunShadingElement(element)) ?? null,
16630
+ renderHTML: (attributes)=>documentRunShadingDomAttributes(parseDocumentRunShading(attributes.runShading))
16631
+ },
16632
+ proofingLanguages: {
16633
+ default: null,
16634
+ parseHTML: (element)=>serializeDocumentProofingLanguages(parseDocumentProofingLanguages(element.getAttribute(DOCUMENT_PROOFING_LANGUAGES_ATTRIBUTE))) ?? null,
16635
+ renderHTML: (attributes)=>documentProofingDomAttributes(parseDocumentProofingLanguages(attributes.proofingLanguages), attributes.noProof, normalizeDocumentScriptFontSlot(attributes.scriptFontSlot))
16636
+ },
16637
+ noProof: {
16638
+ default: null,
16639
+ parseHTML: (element)=>normalizeDocumentNoProof(element.getAttribute(DOCUMENT_NO_PROOF_ATTRIBUTE)),
16640
+ renderHTML: (attributes)=>documentProofingDomAttributes(parseDocumentProofingLanguages(attributes.proofingLanguages), attributes.noProof, normalizeDocumentScriptFontSlot(attributes.scriptFontSlot))
16641
+ },
17049
16642
  kerningThresholdHalfPoints: {
17050
16643
  default: null,
17051
16644
  parseHTML: (element)=>documentKerningThresholdHalfPointsFromElement(element),
@@ -17122,19 +16715,51 @@ const DocumentHighlight = extension_highlight.extend({
17122
16715
  return {};
17123
16716
  },
17124
16717
  addAttributes () {
16718
+ const parent = this.parent?.() ?? {};
17125
16719
  return {
17126
- ...this.parent?.(),
16720
+ ...parent,
16721
+ color: {
16722
+ ...parent.color ?? {},
16723
+ renderHTML: (attributes)=>{
16724
+ const color = 'string' == typeof attributes.color ? attributes.color : null;
16725
+ if (!color) return {};
16726
+ const native = normalizeDocumentHighlight(attributes.nativeHighlight) ?? documentHighlightForCssColor(color);
16727
+ return {
16728
+ 'data-color': color,
16729
+ ...native ? {
16730
+ [DOCUMENT_HIGHLIGHT_ATTRIBUTE]: native
16731
+ } : {},
16732
+ style: `background-color: ${color}; color: inherit`
16733
+ };
16734
+ }
16735
+ },
16736
+ nativeHighlight: {
16737
+ default: null,
16738
+ parseHTML: (element)=>normalizeDocumentHighlight(element.getAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE)),
16739
+ renderHTML: (attributes)=>{
16740
+ const value = normalizeDocumentHighlight(attributes.nativeHighlight);
16741
+ return value ? {
16742
+ [DOCUMENT_HIGHLIGHT_ATTRIBUTE]: value
16743
+ } : {};
16744
+ }
16745
+ },
17127
16746
  themeFill: themeReferenceAttribute('officeThemeFill')
17128
16747
  };
17129
16748
  },
17130
16749
  parseHTML () {
16750
+ const excludesRunShading = (element)=>element.hasAttribute(DOCUMENT_RUN_SHADING_ATTRIBUTE) && !element.hasAttribute(DOCUMENT_HIGHLIGHT_ATTRIBUTE) ? false : null;
17131
16751
  return [
17132
16752
  ...this.parent?.() ?? [],
17133
16753
  {
17134
- tag: 'span[data-office-theme-fill]'
16754
+ tag: `span[${DOCUMENT_HIGHLIGHT_ATTRIBUTE}]`
16755
+ },
16756
+ {
16757
+ tag: 'span[data-office-theme-fill]',
16758
+ getAttrs: excludesRunShading
17135
16759
  },
17136
16760
  {
17137
- tag: 'span[style*="background-color"]'
16761
+ tag: 'span[style*="background-color"]',
16762
+ getAttrs: excludesRunShading
17138
16763
  }
17139
16764
  ];
17140
16765
  }
@@ -17476,6 +17101,302 @@ function documentTabLeaderLabel(leader) {
17476
17101
  if ('middleDot' === leader) return '居中点前导符';
17477
17102
  return '无前导符';
17478
17103
  }
17104
+ const DocumentTableOfContents = core_Node.create({
17105
+ name: 'documentTableOfContents',
17106
+ group: 'block',
17107
+ atom: true,
17108
+ selectable: true,
17109
+ draggable: false,
17110
+ addCommands () {
17111
+ return {
17112
+ insertDocumentTableOfContents: (options = DEFAULT_DOCUMENT_TABLE_OF_CONTENTS_OPTIONS, buildOptions)=>(props)=>insertDocumentTableOfContentsCommand(props, options, buildOptions),
17113
+ updateDocumentTableOfContents: (options, buildOptions)=>(props)=>updateDocumentTableOfContentsCommand(props, options, buildOptions),
17114
+ refreshDocumentTablesOfContents: (buildOptions)=>(props)=>refreshDocumentTablesOfContentsCommand(props, buildOptions)
17115
+ };
17116
+ },
17117
+ addAttributes () {
17118
+ return {
17119
+ id: work_document_table_of_contents_node_hiddenAttribute(''),
17120
+ minLevel: work_document_table_of_contents_node_hiddenAttribute(1),
17121
+ maxLevel: work_document_table_of_contents_node_hiddenAttribute(3),
17122
+ hyperlinks: work_document_table_of_contents_node_hiddenAttribute(true),
17123
+ showPageNumbers: work_document_table_of_contents_node_hiddenAttribute(true),
17124
+ rightAlignPageNumbers: work_document_table_of_contents_node_hiddenAttribute(true),
17125
+ leader: work_document_table_of_contents_node_hiddenAttribute('dot'),
17126
+ entries: work_document_table_of_contents_node_hiddenAttribute([]),
17127
+ truncated: work_document_table_of_contents_node_hiddenAttribute(false)
17128
+ };
17129
+ },
17130
+ parseHTML () {
17131
+ return [
17132
+ {
17133
+ tag: 'div[data-document-table-of-contents]',
17134
+ getAttrs: (node)=>{
17135
+ if (!(node instanceof HTMLElement)) return false;
17136
+ return tableOfContentsNodeAttributes(documentTableOfContentsValueFromElement(node));
17137
+ }
17138
+ }
17139
+ ];
17140
+ },
17141
+ renderHTML ({ node, HTMLAttributes }) {
17142
+ const value = normalizeDocumentTableOfContentsValue({
17143
+ id: work_document_table_of_contents_node_stringAttribute(node.attrs.id) || 'document-table-of-contents',
17144
+ options: tableOfContentsOptionsFromAttributes(node.attrs),
17145
+ entries: Array.isArray(node.attrs.entries) ? node.attrs.entries : [],
17146
+ truncated: Boolean(node.attrs.truncated)
17147
+ });
17148
+ const options = value.options;
17149
+ const rows = value.entries.length ? value.entries.map((entry)=>tableOfContentsEntrySpec(entry, options)) : [
17150
+ [
17151
+ 'li',
17152
+ {
17153
+ class: 'work-document-table-of-contents-empty'
17154
+ },
17155
+ '没有符合级别范围的标题'
17156
+ ]
17157
+ ];
17158
+ return [
17159
+ 'div',
17160
+ mergeAttributes(HTMLAttributes, {
17161
+ 'data-document-table-of-contents': 'true',
17162
+ 'data-toc-id': value.id,
17163
+ 'data-toc-min-level': String(options.minLevel),
17164
+ 'data-toc-max-level': String(options.maxLevel),
17165
+ 'data-toc-hyperlinks': String(options.hyperlinks),
17166
+ 'data-toc-show-page-numbers': String(options.showPageNumbers),
17167
+ 'data-toc-right-align-page-numbers': String(options.rightAlignPageNumbers),
17168
+ 'data-toc-leader': options.leader,
17169
+ 'data-toc-entries': JSON.stringify(value.entries),
17170
+ 'data-toc-truncated': String(value.truncated),
17171
+ class: 'work-document-table-of-contents',
17172
+ contenteditable: 'false',
17173
+ 'aria-label': '目录'
17174
+ }),
17175
+ [
17176
+ 'div',
17177
+ {
17178
+ class: 'work-document-table-of-contents-header'
17179
+ },
17180
+ [
17181
+ 'strong',
17182
+ '目录'
17183
+ ],
17184
+ [
17185
+ 'span',
17186
+ value.truncated ? '仅显示前 512 项' : `${value.entries.length} 项`
17187
+ ]
17188
+ ],
17189
+ [
17190
+ 'ol',
17191
+ {
17192
+ class: 'work-document-table-of-contents-list'
17193
+ },
17194
+ ...rows
17195
+ ]
17196
+ ];
17197
+ },
17198
+ renderText ({ node }) {
17199
+ const entries = Array.isArray(node.attrs.entries) ? node.attrs.entries : [];
17200
+ return entries.map((entry)=>entry.title).join('\n');
17201
+ },
17202
+ addProseMirrorPlugins () {
17203
+ return [
17204
+ new Plugin({
17205
+ props: {
17206
+ handleDOMEvents: {
17207
+ click: (view, event)=>{
17208
+ if (!(event.target instanceof Element)) return false;
17209
+ const table = event.target.closest('[data-document-table-of-contents][data-toc-hyperlinks="true"]');
17210
+ if (!table) return false;
17211
+ const link = event.target.closest('[data-toc-target]');
17212
+ if (!link || !table.contains(link)) return false;
17213
+ const targetId = link.dataset.tocTarget?.trim();
17214
+ if (!targetId) return false;
17215
+ const target = collectWorkDocumentOutline(view.state.doc).find((item)=>item.id === targetId);
17216
+ if (!target) return false;
17217
+ event.preventDefault();
17218
+ view.dispatch(view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(target.from))).scrollIntoView());
17219
+ view.focus();
17220
+ return true;
17221
+ }
17222
+ }
17223
+ }
17224
+ })
17225
+ ];
17226
+ }
17227
+ });
17228
+ function selectedDocumentTableOfContentsOptions(editor) {
17229
+ const selection = editor.state.selection;
17230
+ if (!(selection instanceof NodeSelection) || 'documentTableOfContents' !== selection.node.type.name) return null;
17231
+ return tableOfContentsOptionsFromAttributes(selection.node.attrs);
17232
+ }
17233
+ function documentHasTableOfContents(editor) {
17234
+ let found = false;
17235
+ editor.state.doc.descendants((node)=>{
17236
+ if ('documentTableOfContents' === node.type.name) found = true;
17237
+ return !found;
17238
+ });
17239
+ return found;
17240
+ }
17241
+ function insertDocumentTableOfContentsCommand({ dispatch, editor, tr }, source, buildOptions = {}) {
17242
+ const nodeType = editor.schema.nodes.documentTableOfContents;
17243
+ if (!nodeType) return false;
17244
+ if (!dispatch) return true;
17245
+ const options = normalizeDocumentTableOfContentsOptions(source);
17246
+ ensureTableOfContentsHeadingIdentities(tr, [
17247
+ options
17248
+ ]);
17249
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
17250
+ tr.replaceSelectionWith(nodeType.create({
17251
+ id: createWorkId('toc'),
17252
+ ...options,
17253
+ ...built
17254
+ }), false);
17255
+ tr.scrollIntoView();
17256
+ return true;
17257
+ }
17258
+ function updateDocumentTableOfContentsCommand({ dispatch, state, tr }, source, buildOptions = {}) {
17259
+ const selection = state.selection;
17260
+ if (!(selection instanceof NodeSelection) || 'documentTableOfContents' !== selection.node.type.name) return false;
17261
+ if (!dispatch) return true;
17262
+ const options = normalizeDocumentTableOfContentsOptions(source);
17263
+ ensureTableOfContentsHeadingIdentities(tr, [
17264
+ options
17265
+ ]);
17266
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
17267
+ tr.setNodeMarkup(selection.from, void 0, {
17268
+ ...selection.node.attrs,
17269
+ ...options,
17270
+ ...built
17271
+ });
17272
+ tr.scrollIntoView();
17273
+ return tr.docChanged;
17274
+ }
17275
+ function refreshDocumentTablesOfContentsCommand({ dispatch, state, tr }, buildOptions = {}) {
17276
+ const tableOptions = [];
17277
+ state.doc.descendants((node)=>{
17278
+ if ('documentTableOfContents' === node.type.name) tableOptions.push(tableOfContentsOptionsFromAttributes(node.attrs));
17279
+ });
17280
+ if (!tableOptions.length) return false;
17281
+ ensureTableOfContentsHeadingIdentities(tr, tableOptions);
17282
+ const updates = [];
17283
+ tr.doc.descendants((node, position)=>{
17284
+ if ('documentTableOfContents' !== node.type.name) return;
17285
+ const options = tableOfContentsOptionsFromAttributes(node.attrs);
17286
+ const built = buildDocumentTableOfContentsEntries(tr.doc, options, buildOptions);
17287
+ if (JSON.stringify(node.attrs.entries) === JSON.stringify(built.entries) && Boolean(node.attrs.truncated) === built.truncated) return;
17288
+ updates.push({
17289
+ position,
17290
+ attrs: {
17291
+ ...node.attrs,
17292
+ ...options,
17293
+ ...built
17294
+ }
17295
+ });
17296
+ });
17297
+ if (!updates.length) return false;
17298
+ if (!dispatch) return true;
17299
+ for (const update of updates)tr.setNodeMarkup(update.position, void 0, update.attrs);
17300
+ tr.scrollIntoView();
17301
+ return tr.docChanged;
17302
+ }
17303
+ function ensureTableOfContentsHeadingIdentities(transaction, tableOptions) {
17304
+ const paragraphIdCounts = new Map();
17305
+ transaction.doc.descendants((node)=>{
17306
+ const paragraphId = normalizeDocumentParagraphId(node.attrs.paragraphId);
17307
+ if (!paragraphId) return;
17308
+ paragraphIdCounts.set(paragraphId, (paragraphIdCounts.get(paragraphId) ?? 0) + 1);
17309
+ });
17310
+ const registry = createDocumentParagraphIdentityRegistry();
17311
+ for (const paragraphId of paragraphIdCounts.keys())registry.paragraphIds.add(paragraphId);
17312
+ const updates = [];
17313
+ transaction.doc.descendants((node, position)=>{
17314
+ const level = workDocumentOutlineLevel(node);
17315
+ if (null === level || !tableOptions.some((options)=>level >= options.minLevel && level <= options.maxLevel)) return;
17316
+ const paragraphId = normalizeDocumentParagraphId(node.attrs.paragraphId);
17317
+ const textId = normalizeDocumentParagraphId(node.attrs.textId);
17318
+ let identity;
17319
+ identity = paragraphId && 1 === paragraphIdCounts.get(paragraphId) ? {
17320
+ paragraphId,
17321
+ textId: textId ?? createDocumentParagraphIdentity().textId
17322
+ } : uniqueDocumentParagraphIdentity({}, registry);
17323
+ if (paragraphId === identity.paragraphId && textId === identity.textId) return;
17324
+ updates.push({
17325
+ attrs: node.attrs,
17326
+ identity,
17327
+ position
17328
+ });
17329
+ });
17330
+ for (const update of updates)transaction.setNodeMarkup(update.position, void 0, {
17331
+ ...update.attrs,
17332
+ ...update.identity
17333
+ });
17334
+ }
17335
+ function tableOfContentsOptionsFromAttributes(attrs) {
17336
+ return normalizeDocumentTableOfContentsOptions({
17337
+ minLevel: Number(attrs.minLevel),
17338
+ maxLevel: Number(attrs.maxLevel),
17339
+ hyperlinks: Boolean(attrs.hyperlinks),
17340
+ showPageNumbers: Boolean(attrs.showPageNumbers),
17341
+ rightAlignPageNumbers: Boolean(attrs.rightAlignPageNumbers),
17342
+ leader: 'string' == typeof attrs.leader ? attrs.leader : 'dot'
17343
+ });
17344
+ }
17345
+ function tableOfContentsNodeAttributes(value) {
17346
+ return {
17347
+ id: value.id,
17348
+ ...value.options,
17349
+ entries: value.entries,
17350
+ truncated: value.truncated
17351
+ };
17352
+ }
17353
+ function tableOfContentsEntrySpec(entry, options) {
17354
+ const title = options.hyperlinks ? [
17355
+ 'a',
17356
+ {
17357
+ href: `#${entry.targetId}`,
17358
+ 'data-toc-target': entry.targetId,
17359
+ tabindex: '-1'
17360
+ },
17361
+ entry.title
17362
+ ] : [
17363
+ 'span',
17364
+ entry.title
17365
+ ];
17366
+ return [
17367
+ 'li',
17368
+ {
17369
+ 'data-toc-target': entry.targetId,
17370
+ 'data-toc-level': String(entry.level),
17371
+ style: `--work-toc-level:${entry.level}`
17372
+ },
17373
+ title,
17374
+ [
17375
+ 'i',
17376
+ {
17377
+ 'aria-hidden': 'true'
17378
+ }
17379
+ ],
17380
+ ...options.showPageNumbers ? [
17381
+ [
17382
+ 'span',
17383
+ {
17384
+ class: 'work-document-table-of-contents-page'
17385
+ },
17386
+ String(entry.pageNumber)
17387
+ ]
17388
+ ] : []
17389
+ ];
17390
+ }
17391
+ function work_document_table_of_contents_node_hiddenAttribute(defaultValue) {
17392
+ return {
17393
+ default: defaultValue,
17394
+ rendered: false
17395
+ };
17396
+ }
17397
+ function work_document_table_of_contents_node_stringAttribute(value) {
17398
+ return 'string' == typeof value ? value.trim() : '';
17399
+ }
17479
17400
  const BORDER_EDGES = [
17480
17401
  'top',
17481
17402
  'right',
@@ -19382,6 +19303,9 @@ function createWorkDocumentExtensions(options = {}) {
19382
19303
  DocumentCrossReference,
19383
19304
  citationExtension,
19384
19305
  DocumentBibliography,
19306
+ DocumentTableOfContents,
19307
+ DocumentIndexEntry,
19308
+ DocumentIndex,
19385
19309
  DocumentField,
19386
19310
  DocumentEquation,
19387
19311
  commentExtension,
@@ -21241,4 +21165,4 @@ function registerDocumentPageSurfaceGeometry(element, provider) {
21241
21165
  function documentPageSurfaceGeometryForElement(element) {
21242
21166
  return documentPageSurfaceProviders.get(element)?.() ?? null;
21243
21167
  }
21244
- export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_PARAGRAPH_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, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentParagraphIdentityToElement, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createDocumentParagraphIdentityRegistry, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, cssDocumentFontFamily, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentFontNameFromCssFamily, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, 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, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentFontName, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphId, normalizeDocumentParagraphIdentity, normalizeDocumentParagraphIndent, normalizeDocumentScriptFontHint, normalizeDocumentScriptFontSlot, normalizeDocumentScriptFonts, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentThemeFont, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphFormatting, parseDocumentParagraphShadingElement, parseDocumentScriptFonts, patchDocumentLazyHtmlProjection, patchDocumentScriptFonts, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, serializeDocumentParagraphFormatting, serializeDocumentScriptFonts, serializeDocumentTabStops, 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 };
21168
+ export { DEFAULT_DOCUMENT_TABLE_CELL_FORMAT, DEFAULT_DOCUMENT_TABLE_CELL_MARGINS, DEFAULT_DOCUMENT_TABLE_GEOMETRY, DOCUMENT_BOOKMARK_DUPLICATE_MESSAGE, DOCUMENT_CHUNK_HYDRATION_META, DOCUMENT_CHUNK_PAGINATION_META, DOCUMENT_CHUNK_VISIBLE_IDS_META, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, DOCUMENT_LEGACY_TEXT_EMBOSS_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_IMPRINT_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_OUTLINE_ATTRIBUTE, DOCUMENT_LEGACY_TEXT_SHADOW_ATTRIBUTE, DOCUMENT_PAGE_BORDER_EDGES, DOCUMENT_PAGE_MARGIN_KEYS, DOCUMENT_STRIKE_STYLE_ATTRIBUTE, DOCUMENT_TABLE_ROW_ID_ATTRIBUTE, DOCUMENT_TABLE_ROW_TEXT_ID_ATTRIBUTE, DOCUMENT_TABLE_STYLE_OPTIONS, DOCUMENT_UNDERLINE_STYLE_ATTRIBUTE, DocumentCharacterFormatting, DocumentEquation, DocumentFontFamily, DocumentHighlight, DocumentImage, DocumentParagraphFormatting, DocumentScriptFontFormatting, DocumentStrike, DocumentSubscript, DocumentSuperscript, DocumentTableRowIdentity, DocumentTextStyle, DocumentUnderline, MAX_DOCUMENT_IMAGE_RELATIVE_HEIGHT, MAX_DOCUMENT_NUMBERING_START, activeDocumentBookmark, activeDocumentSection, activeDocumentTableStyle, applyDocumentImageCropToElement, applyDocumentImageIdentityToElement, applyDocumentImageLayerToElement, applyDocumentImageWrapContourToElement, applyDocumentPageGeometry, applyDocumentTableGeometryToElement, applyDocumentTableRowIdentityToElement, applyDocumentTextCaseStyle, canChangeDocumentIndent, canInsertDocumentComment, canSetDocumentTableRowRepeatHeader, clampDocumentMargin, collectDocumentChanges, collectDocumentCommentAnchors, collectDocumentNotes, collectDocumentTextLayoutParagraphs, createDocumentBibliography, createDocumentEquationElement, createDocumentImageIdentityRegistry, createDocumentNoteElement, createSchemaDerivedWorkDocumentModel, createSchemaValidatedWorkDocumentModel, createWorkDocumentExtensions, createWorkDocumentModel, createWorkDocumentModelFromContent, createWorkOfficeDocumentCollaborationBinding as createOfficeDocumentCollaborationBinding, defaultDocumentImageWrapContour, documentAutoLineHeight, documentBookmarkNameExists, documentBookmarkReferenceInstruction, documentBulletListStyle, documentCaptionKind, documentCaptionLabel, documentCharacterPositionDomAttributes, documentCharacterPositionHalfPointsFromElement, documentCharacterPositionPoints, documentCharacterScaleDomAttributes, documentCharacterScalePercentFromElement, documentCharacterSpacingDomAttributes, documentCharacterSpacingPoints, documentCharacterSpacingTwipsFromElement, documentChunkMountedIds, documentCitationCount, documentCitationInstruction, documentCitationStyle, documentCitationStyleDetails, documentCitationTags, documentCitationTagsFromInstruction, documentCommentDraftRange, documentCommentViews, documentContentLayoutProperties, documentEmphasisMarkDomAttributes, documentEmphasisMarkFromElement, documentEquationFromElement, documentEquationText, documentHasIndex, documentHasTableOfContents, documentHiddenTextDomAttributes, documentHiddenTextFromElement, documentHiddenTextKeyboardShortcut, documentImageCropFromElement, documentImageIdentityFromElement, documentImageLayerFromElement, documentImageLayoutFromElement, documentImageLayoutOptions, documentImagePositionFromElement, documentImageProperties, documentImageWrapContourFromElement, documentInitialSectionLayout, documentKerningDomAttributes, documentKerningIsEffective, documentKerningThresholdHalfPointsFromElement, documentKerningThresholdPoints, documentLazyHtmlChunkFragment, documentLazyHtmlProjection, documentLazyHtmlProjectionFingerprint, documentLegacyTextEffectsConflict, documentLegacyTextEffectsCss, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsFromElement, documentLegacyTextEffectsFromTextStyleAttributes, documentModelForContent, documentModelForHtml, documentModelHasTrustedInitialIntegrityFeatures, documentModelUsesWindowing, documentNoteKey, documentNoteKind, documentOrderedListState, documentPageBordersVisible, documentPageChromeLegacyFields, documentPageGeometryForLayout, documentPageHorizontalMarginTwips, documentPageMarginBody, documentPageMarginsForLayout, documentPageMetrics, documentPageSurfaceGeometryForElement, documentPaperSizeForGeometry, documentParagraphDirection, documentParagraphIndent, documentParagraphPagination, documentParagraphSpacing, documentParagraphTabStops, documentSectionById, documentSectionDomAttributes, documentSections, documentStrikeDomAttributes, documentStrikeFormattingFromElement, documentStrikeStyle, documentTabLeaderLabel, documentTableBordersFromElement, documentTableCellFormat, documentTableCellMarginOverridesFromElement, documentTableColumnPercentagesFromElement, documentTableGeometryFromElement, documentTableHorizontalAlignment, documentTableRowIdentityFromElement, documentTableRowOptions, documentTableSizing, documentTextCaseFromWordFlags, documentTextCaseKeyboardShortcuts, documentTextLayoutBatches, documentTextStatistics, documentTransactionsOnlyHydrateChunks, documentUnderlineColor, documentUnderlineDomAttributes, documentUnderlineFormattingFromElement, documentUnderlineKeyboardShortcuts, documentUnderlineStyle, documentWordLineHeightFactor, docxBookmarkReferenceTarget, docxDocumentFieldKind, editorDocumentBookmarkReferenceTargets, editorDocumentCaptionTargets, importedDocumentCharacterFormatting, initializeWorkOfficeDocumentCollaboration as initializeOfficeDocumentCollaboration, invalidateDocumentLazyHtmlProjection, isContourImageLayout, isValidDocumentCitationTag, materializeLazyDocumentEditorRoot, materializeWorkDocumentContent, measureDocumentLayoutBlocksIncrementally, millimetersToPixels, mountWorkLiveDocumentCapture, nextDocumentTabAlignment, normalizeDocumentBookmarkName, normalizeDocumentBookmarkNativeId, normalizeDocumentBookmarkReferencesHtml, normalizeDocumentBookmarksHtml, normalizeDocumentCaptionsHtml, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterScalePercent, normalizeDocumentCharacterSpacingTwips, normalizeDocumentCitationsHtml, normalizeDocumentColumns, normalizeDocumentEmphasisMark, normalizeDocumentEquation, normalizeDocumentFieldsHtml, normalizeDocumentHiddenText, normalizeDocumentHtml, normalizeDocumentImageAlignment, normalizeDocumentImageCrop, normalizeDocumentImageIdentity, normalizeDocumentImageLayer, normalizeDocumentImageLayoutOptions, normalizeDocumentImagePosition, normalizeDocumentImageWrapContour, normalizeDocumentImageWrapSide, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentLegacyTextEffect, normalizeDocumentLegacyTextEffects, normalizeDocumentNotesHtml, normalizeDocumentPageBorders, normalizeDocumentPageChrome, normalizeDocumentPageGeometry, normalizeDocumentPageMargins, normalizeDocumentPaperSource, normalizeDocumentParagraphIndent, normalizeDocumentStrikeStyle, normalizeDocumentTabStops, normalizeDocumentTableBorderStyle, normalizeDocumentTableBorderWidth, normalizeDocumentTableRowHeightRule, normalizeDocumentTableRowIdentity, normalizeDocumentTableVerticalAlign, normalizeDocumentTextCase, normalizeDocumentUnderlineColor, normalizeDocumentUnderlineStyle, normalizeTableColor, normalizedTabPosition, pageTwipsToMillimeters, parseDocumentCharacterFormatting, parseDocumentParagraphFormatting, patchDocumentLazyHtmlProjection, positionWorkLiveDocumentCapture, readWorkOfficeDocumentCollaboration as readOfficeDocumentCollaboration, registerDocumentPageSurfaceGeometry, renderDocumentAutoLineHeight, renderDocumentTableBorders, renderDocumentTableCellMarginOverrides, resolveDocumentPageBorders, resolveDocumentPageChrome, resolveDocumentPageMargins, resolveDocumentPageSize, resolveWorkDocumentEditorInput, retainAnchoredDocumentComments, sanitizeDocumentPageChromeHtml, selectedDocumentChunkId, selectedDocumentIndexDraft, selectedDocumentIndexEntry, selectedDocumentIndexOptions, selectedDocumentTableOfContentsOptions, serializeDocumentParagraphFormatting, serializeDocumentTabStops, serializeWorkDocumentNode, setCustomDocumentColumns, supportedDocxBookmarkReferenceInstruction, syncDocumentContentFromHtml, transferChangedDocumentTextStatistics, uniqueDocumentImageIdentity, updateDocumentColumnWidth, updateDocumentCustomPageMillimeters, updateDocumentGutterPosition, updateDocumentMirrorMargins, updateDocumentPageChromeVariant, updateDocumentPageMarginMillimeters, updateDocumentPageMarginMode, updateDocumentPageOrientation, updateDocumentPaperSizePreset, validateDocumentBookmarkName, windowDocumentModel, workDocumentSchema, workOfficeDocumentCollaborationFragment as officeDocumentCollaborationFragment, work_document_page_margins_twipsToMillimeters, wrapsBesideImage };