@a3s-lab/office 0.30.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.
- package/README.md +22 -5
- package/dist/{0~7231.js → 0~4808.js} +189 -2
- package/dist/0~5050.js +10 -1
- package/dist/{0~7360.js → 0~7240.js} +244 -15
- package/dist/0~document-editor.js +622 -125
- package/dist/0~work-docx-export.js +214 -26
- package/dist/0~work-docx-import.js +17 -6
- package/dist/0~work-office-diagnostics.js +25 -4
- package/dist/4104.js +1 -1
- package/dist/4121.js +412 -11
- package/dist/6282.js +431 -2
- package/dist/internal/features/work/editors/document-command-catalog.d.ts +27 -0
- package/dist/internal/features/work/editors/document-dom-selection.d.ts +7 -0
- package/dist/internal/features/work/editors/document-editor-support.d.ts +1 -0
- package/dist/internal/features/work/editors/document-index-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-index-entry-dialog.d.ts +10 -0
- package/dist/internal/features/work/editors/document-references-ribbon.d.ts +19 -0
- package/dist/internal/features/work/editors/document-toolbar.d.ts +4 -1
- package/dist/internal/features/work/editors/use-document-insert-commands.d.ts +3 -0
- package/dist/internal/features/work/work-document-index-fields.d.ts +19 -0
- package/dist/internal/features/work/work-document-index-nodes.d.ts +32 -0
- package/dist/internal/features/work/work-document-index.d.ts +63 -0
- package/dist/internal/features/work/work-docx-import.d.ts +3 -1
- package/dist/internal/features/work/work-docx-index-export.d.ts +14 -0
- package/dist/internal/features/work/work-docx-index-import.d.ts +23 -0
- package/dist/office-kernel.wasm +0 -0
- package/dist/styles.css +296 -0
- package/docs/latest/en/browser-editor-architecture.md +14 -0
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -56,18 +56,19 @@ workflows, and a separate Rust automation plane.
|
|
|
56
56
|
|
|
57
57
|
## Latest on `main`
|
|
58
58
|
|
|
59
|
-
The `0.
|
|
60
|
-
normal user-facing Playground templates, with matching implementation
|
|
61
|
-
in the
|
|
59
|
+
The `0.31.0` release plus the current `main` branch expose these capabilities
|
|
60
|
+
as normal user-facing Playground templates, with matching implementation
|
|
61
|
+
detail in the documentation:
|
|
62
62
|
|
|
63
63
|
| Editor | Latest capability | Public entry |
|
|
64
64
|
| --- | --- | --- |
|
|
65
65
|
| Writer | Insert, customize, navigate, and explicitly refresh a typed Table of Contents with heading and native outline levels 1–9, hyperlinks, page numbers, alignment, four leader styles, and native DOCX `TOC` round trips | Playground **Latest capabilities → 可更新目录** · [Document reference](docs/latest/en/components/document.mdx#native-table-of-contents) |
|
|
66
|
+
| Writer | Mark primary and secondary index terms, cross-references, and bold/italic page numbers; insert, navigate, customize, and refresh a bounded native index with editable DOCX `XE` and `INDEX` round trips | Playground **Latest capabilities → 原生索引** · [Document reference](docs/latest/en/components/document.mdx#native-document-index) |
|
|
66
67
|
| Writer | Native character shading with exact `w:shd` patterns, foreground/background color identity, explicit resets, authoring, and DOCX reopen | Playground **Latest capabilities → 字符底纹** · [Document reference](docs/latest/en/components/document.mdx#native-character-shading) |
|
|
67
68
|
| Writer | Independent Latin, East Asian, and bidi proofing languages plus explicit `w:noProof` inclusion/exclusion | Playground **Latest capabilities → 校对语言** · [Document reference](docs/latest/en/components/document.mdx#native-proofing-languages) |
|
|
68
69
|
| Spreadsheet | Complete common Data Validation input, blank/dropdown, and Stop/Warning/Information error settings with native XLSX round trips | Playground **Latest capabilities → 数据验证** · [Spreadsheet reference](docs/latest/en/components/spreadsheet.mdx#data-validation) |
|
|
69
70
|
|
|
70
|
-
The same
|
|
71
|
+
The same five entries remain available under **新建**. The highlighted strip
|
|
71
72
|
exists so a capability is discoverable from the first Playground viewport
|
|
72
73
|
instead of only through a deep documentation section or an `?e2e=` fixture.
|
|
73
74
|
|
|
@@ -131,7 +132,7 @@ baseline rather than one specific release.
|
|
|
131
132
|
| Page layout and rendering | **Partial** — sections, margins, page size, columns, headers/footers, fields, and live pagination | Desktop-grade pagination, print layout, and vector output |
|
|
132
133
|
| Tables, pictures, and equations | **Partial** — rich table geometry, floating pictures, crop/wrap, and structured OMML | Broader drawings, text boxes, charts, WordArt, and SmartArt |
|
|
133
134
|
| Comments, revisions, and collaboration | **Partial** — comments, suggestions, text/format revisions, decisions, Yjs presence, and host relay contracts | Full revision families plus integrated sharing and review services |
|
|
134
|
-
| References and document generation | **Partial** — typed Table of Contents
|
|
135
|
+
| References and document generation | **Partial** — typed Table of Contents and native index authoring/refresh, bookmarks, links, captions, cross-references, citations, notes, and common fields | Mail merge, compare/combine, tables of figures/authorities, and broader fields |
|
|
135
136
|
| Ribbon and shortcuts | **Supported** — responsive Office-style ribbon and editor-scoped daily-writing shortcuts | Complete desktop shortcut and contextual-tool surface |
|
|
136
137
|
| Very large documents | **Supported with boundaries** — bounded 100,000-block plain-document windows and measured edit/navigation budgets | Native-engine virtualization with device-dependent limits |
|
|
137
138
|
| DOCX and PDF fidelity | **Partial** — source-aware DOCX preservation and live-layout raster PDF export | Broader legacy/OOXML compatibility and searchable vector PDF output |
|
|
@@ -246,6 +247,21 @@ is requested. The complete gap inventory and exit evidence live in the
|
|
|
246
247
|
`\\u`, full-range `\\n`, and space-separator `\\p` subset while diagnosing
|
|
247
248
|
lossy custom style mappings. The Playground's **可更新目录** template exposes
|
|
248
249
|
the complete flow.
|
|
250
|
+
Writer indexes use hidden, selectable inline entry atoms and a separate
|
|
251
|
+
selectable generated block. Primary terms, secondary terms, cross-references,
|
|
252
|
+
and bold/italic page-number intent remain typed; duplicate terms on the same
|
|
253
|
+
page merge while retaining every stable marker target. The live Worker/WASM
|
|
254
|
+
field resolver remains the only page-number source. Mark, edit, insert,
|
|
255
|
+
customize, and explicit all-index refresh each commit one TipTap transaction
|
|
256
|
+
and one Undo record. At most 2,048 markers contribute to at most 512 cached
|
|
257
|
+
rows, with explicit truncation beyond either bound. DOCX export writes
|
|
258
|
+
native `XE` simple fields and a real `w:sdt`/`INDEX` content control with cached
|
|
259
|
+
`Index1`/`Index2` rows, columns, cross-references, page emphasis, alignment,
|
|
260
|
+
and dot/dash/underline/no leaders. Import accepts the lossless common `XE`
|
|
261
|
+
`\\b`, `\\i`, and `\\t` plus `INDEX` `\\c`, `\\e`, and `\\r` subset;
|
|
262
|
+
unsupported switches remain diagnosed instead of approximated. The
|
|
263
|
+
Playground's **原生索引** template exposes marking, navigation, refresh,
|
|
264
|
+
export, and reopen.
|
|
249
265
|
- **Framework choice** — React components, Vue 3 adapters, Custom Elements,
|
|
250
266
|
and a framework-neutral Core API over the same engine.
|
|
251
267
|
- **Responsive computation** — Lazy editor chunks, cancellable Workers,
|
|
@@ -1553,6 +1569,7 @@ without hard-coded return URLs.
|
|
|
1553
1569
|
|
|
1554
1570
|
- [Live Playground](https://a3s-lab.github.io/Office/)
|
|
1555
1571
|
- [Documentation center](https://a3s-lab.github.io/Office/docs/)
|
|
1572
|
+
- [A3S Office 0.31.0 documentation](https://a3s-lab.github.io/Office/docs/0.31.0/)
|
|
1556
1573
|
- [A3S Office 0.30.0 documentation](https://a3s-lab.github.io/Office/docs/0.30.0/)
|
|
1557
1574
|
- [A3S Office 0.29.0 documentation](https://a3s-lab.github.io/Office/docs/0.29.0/)
|
|
1558
1575
|
- [A3S Office 0.28.0 documentation](https://a3s-lab.github.io/Office/docs/0.28.0/)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import jszip from "jszip";
|
|
2
|
-
import { serializeUtf8Xml, directChildren, xmlNamespacePrefix, normalizeDocumentLanguageTag, parseXml, firstDescendant, decodeXmlBytes, directChild, descendants, normalizeDocumentProofingLanguages, attribute as work_ooxml_package_attribute } from "./4121.js";
|
|
2
|
+
import { normalizeDocumentIndexEntryDraft, serializeUtf8Xml, directChildren, xmlNamespacePrefix, normalizeDocumentLanguageTag, parseXml, firstDescendant, decodeXmlBytes, directChild, descendants, normalizeDocumentProofingLanguages, attribute as work_ooxml_package_attribute, normalizeDocumentIndexOptions } from "./4121.js";
|
|
3
3
|
import { normalizeDocumentEmphasisMark, normalizeDocumentCharacterScalePercent, documentCitationStyle, normalizeDocumentKerningThresholdHalfPoints, normalizeDocumentCharacterPositionHalfPoints, normalizeDocumentCharacterSpacingTwips, normalizeDocumentTabStops, createDocumentBibliography, documentCitationStyleDetails } from "./6282.js";
|
|
4
4
|
const BIBLIOGRAPHY_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/bibliography';
|
|
5
5
|
const CUSTOM_XML_NAMESPACE = 'http://schemas.openxmlformats.org/officeDocument/2006/customXml';
|
|
@@ -708,6 +708,193 @@ function isAllowedExtensionNamespace(namespace, context) {
|
|
|
708
708
|
function isNamespacePrefix(value) {
|
|
709
709
|
return /^[A-Za-z_][A-Za-z0-9_.-]*$/.test(value) && 'xml' !== value;
|
|
710
710
|
}
|
|
711
|
+
function parseDocumentIndexEntryInstruction(instruction) {
|
|
712
|
+
const command = /^\s*XE\b/i.exec(instruction);
|
|
713
|
+
if (!command) return {
|
|
714
|
+
supported: false,
|
|
715
|
+
reason: 'not-index-entry'
|
|
716
|
+
};
|
|
717
|
+
const parsed = parseLeadingFieldValue(instruction.slice(command[0].length));
|
|
718
|
+
if (!parsed) return {
|
|
719
|
+
supported: false,
|
|
720
|
+
reason: 'invalid-instruction'
|
|
721
|
+
};
|
|
722
|
+
const switches = parseFieldSwitches(parsed.rest);
|
|
723
|
+
if (!switches) return {
|
|
724
|
+
supported: false,
|
|
725
|
+
reason: 'invalid-instruction'
|
|
726
|
+
};
|
|
727
|
+
for (const name of switches.keys())if (![
|
|
728
|
+
'b',
|
|
729
|
+
'i',
|
|
730
|
+
't'
|
|
731
|
+
].includes(name)) return {
|
|
732
|
+
supported: false,
|
|
733
|
+
reason: 'unsupported-switch'
|
|
734
|
+
};
|
|
735
|
+
const boldValue = valueSwitch(switches, 'b');
|
|
736
|
+
const italicValue = valueSwitch(switches, 'i');
|
|
737
|
+
if (null != boldValue || null != italicValue) return {
|
|
738
|
+
supported: false,
|
|
739
|
+
reason: 'invalid-instruction'
|
|
740
|
+
};
|
|
741
|
+
const crossReferenceValue = valueSwitch(switches, 't');
|
|
742
|
+
if (switches.has('t') && !crossReferenceValue) return {
|
|
743
|
+
supported: false,
|
|
744
|
+
reason: 'invalid-instruction'
|
|
745
|
+
};
|
|
746
|
+
const terms = splitIndexEntryTerms(parsed.value);
|
|
747
|
+
const value = normalizeDocumentIndexEntryDraft({
|
|
748
|
+
mainEntry: terms.mainEntry,
|
|
749
|
+
subEntry: terms.subEntry,
|
|
750
|
+
crossReference: crossReferenceValue?.replace(/^see\s+/i, '') ?? '',
|
|
751
|
+
pageBold: switches.has('b'),
|
|
752
|
+
pageItalic: switches.has('i')
|
|
753
|
+
});
|
|
754
|
+
return value ? {
|
|
755
|
+
supported: true,
|
|
756
|
+
value
|
|
757
|
+
} : {
|
|
758
|
+
supported: false,
|
|
759
|
+
reason: 'invalid-entry'
|
|
760
|
+
};
|
|
761
|
+
}
|
|
762
|
+
function documentIndexEntryInstruction(source) {
|
|
763
|
+
const value = normalizeDocumentIndexEntryDraft(source);
|
|
764
|
+
if (!value) throw new Error('Document index entry is invalid.');
|
|
765
|
+
const term = value.subEntry ? `${escapeFieldValue(value.mainEntry)}:${escapeFieldValue(value.subEntry)}` : escapeFieldValue(value.mainEntry);
|
|
766
|
+
const switches = [];
|
|
767
|
+
if (value.crossReference) switches.push(`\\t "See ${escapeFieldValue(value.crossReference)}"`);
|
|
768
|
+
else {
|
|
769
|
+
if (value.pageBold) switches.push('\\b');
|
|
770
|
+
if (value.pageItalic) switches.push('\\i');
|
|
771
|
+
}
|
|
772
|
+
return `XE "${term}"${switches.length ? ` ${switches.join(' ')}` : ''}`;
|
|
773
|
+
}
|
|
774
|
+
function parseDocumentIndexInstruction(instruction) {
|
|
775
|
+
const command = /^\s*INDEX\b/i.exec(instruction);
|
|
776
|
+
if (!command) return {
|
|
777
|
+
supported: false,
|
|
778
|
+
reason: 'not-index'
|
|
779
|
+
};
|
|
780
|
+
const switches = parseFieldSwitches(instruction.slice(command[0].length));
|
|
781
|
+
if (!switches) return {
|
|
782
|
+
supported: false,
|
|
783
|
+
reason: 'invalid-instruction'
|
|
784
|
+
};
|
|
785
|
+
for (const name of switches.keys())if (![
|
|
786
|
+
'c',
|
|
787
|
+
'e',
|
|
788
|
+
'r'
|
|
789
|
+
].includes(name)) return {
|
|
790
|
+
supported: false,
|
|
791
|
+
reason: 'unsupported-switch'
|
|
792
|
+
};
|
|
793
|
+
const columnsValue = valueSwitch(switches, 'c');
|
|
794
|
+
if (switches.has('c') && !/^[1-4]$/.test(columnsValue ?? '')) return {
|
|
795
|
+
supported: false,
|
|
796
|
+
reason: 'invalid-columns'
|
|
797
|
+
};
|
|
798
|
+
const separator = valueSwitch(switches, 'e');
|
|
799
|
+
if (switches.has('e') && void 0 === separator) return {
|
|
800
|
+
supported: false,
|
|
801
|
+
reason: 'invalid-instruction'
|
|
802
|
+
};
|
|
803
|
+
if (switches.has('r') && null !== valueSwitch(switches, 'r')) return {
|
|
804
|
+
supported: false,
|
|
805
|
+
reason: 'invalid-instruction'
|
|
806
|
+
};
|
|
807
|
+
return {
|
|
808
|
+
supported: true,
|
|
809
|
+
options: normalizeDocumentIndexOptions({
|
|
810
|
+
columns: columnsValue ? Number(columnsValue) : 1,
|
|
811
|
+
format: switches.has('r') ? 'run-in' : 'indented',
|
|
812
|
+
rightAlignPageNumbers: !switches.has('e'),
|
|
813
|
+
leader: switches.has('e') ? 'none' : 'dot'
|
|
814
|
+
})
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function documentIndexInstruction(source) {
|
|
818
|
+
const options = normalizeDocumentIndexOptions(source);
|
|
819
|
+
const switches = options.columns > 1 ? [
|
|
820
|
+
`\\c "${options.columns}"`
|
|
821
|
+
] : [];
|
|
822
|
+
if ('run-in' === options.format) switches.push('\\r');
|
|
823
|
+
if (!options.rightAlignPageNumbers) switches.push('\\e ", "');
|
|
824
|
+
return `INDEX${switches.length ? ` ${switches.join(' ')}` : ''}`;
|
|
825
|
+
}
|
|
826
|
+
function splitIndexEntryTerms(source) {
|
|
827
|
+
let escaped = false;
|
|
828
|
+
for(let index = 0; index < source.length; index += 1){
|
|
829
|
+
const character = source[index];
|
|
830
|
+
if (escaped) {
|
|
831
|
+
escaped = false;
|
|
832
|
+
continue;
|
|
833
|
+
}
|
|
834
|
+
if ('\\' === character) {
|
|
835
|
+
escaped = true;
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
if (':' === character) return {
|
|
839
|
+
mainEntry: unescapeFieldValue(source.slice(0, index)),
|
|
840
|
+
subEntry: unescapeFieldValue(source.slice(index + 1))
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
return {
|
|
844
|
+
mainEntry: unescapeFieldValue(source),
|
|
845
|
+
subEntry: ''
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
function parseLeadingFieldValue(source) {
|
|
849
|
+
const trimmed = source.trimStart();
|
|
850
|
+
if (!trimmed) return null;
|
|
851
|
+
if ('"' !== trimmed[0]) {
|
|
852
|
+
const match = /^([^\s\\]+)([\s\S]*)$/.exec(trimmed);
|
|
853
|
+
return match?.[1] ? {
|
|
854
|
+
value: match[1],
|
|
855
|
+
rest: match[2] ?? ''
|
|
856
|
+
} : null;
|
|
857
|
+
}
|
|
858
|
+
let escaped = false;
|
|
859
|
+
for(let index = 1; index < trimmed.length; index += 1){
|
|
860
|
+
const character = trimmed[index];
|
|
861
|
+
if (escaped) {
|
|
862
|
+
escaped = false;
|
|
863
|
+
continue;
|
|
864
|
+
}
|
|
865
|
+
if ('\\' === character) {
|
|
866
|
+
escaped = true;
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if ('"' === character) return {
|
|
870
|
+
value: trimmed.slice(1, index),
|
|
871
|
+
rest: trimmed.slice(index + 1)
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
return null;
|
|
875
|
+
}
|
|
876
|
+
function parseFieldSwitches(source) {
|
|
877
|
+
const switches = new Map();
|
|
878
|
+
const matcher = /\\([a-z])(?:\s+("([^"\\]*(?:\\.[^"\\]*)*)"|([^\\\s]+)))?/gi;
|
|
879
|
+
let cursor = 0;
|
|
880
|
+
for(let match = matcher.exec(source); match; match = matcher.exec(source)){
|
|
881
|
+
if (source.slice(cursor, match.index).trim()) return null;
|
|
882
|
+
const name = match[1]?.toLowerCase();
|
|
883
|
+
if (!name || switches.has(name)) return null;
|
|
884
|
+
switches.set(name, unescapeFieldValue(match[3] ?? match[4] ?? '') || null);
|
|
885
|
+
cursor = matcher.lastIndex;
|
|
886
|
+
}
|
|
887
|
+
return source.slice(cursor).trim() ? null : switches;
|
|
888
|
+
}
|
|
889
|
+
function valueSwitch(switches, name) {
|
|
890
|
+
return switches.has(name) ? switches.get(name) : void 0;
|
|
891
|
+
}
|
|
892
|
+
function escapeFieldValue(value) {
|
|
893
|
+
return value.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll(':', '\\:');
|
|
894
|
+
}
|
|
895
|
+
function unescapeFieldValue(value) {
|
|
896
|
+
return value.replace(/\\([\\":])/g, '$1');
|
|
897
|
+
}
|
|
711
898
|
const STRICT_WORDPROCESSING_NAMESPACE = 'http://purl.oclc.org/ooxml/wordprocessingml/main';
|
|
712
899
|
const UNIVERSAL_TWIP_RATIOS = {
|
|
713
900
|
mm: [
|
|
@@ -1737,4 +1924,4 @@ function isParagraphPartRoot(root, path) {
|
|
|
1737
1924
|
const expected = /^word\/header\d*\.xml$/i.test(path) ? 'hdr' : /^word\/footer\d*\.xml$/i.test(path) ? 'ftr' : /^word\/footnotes\.xml$/i.test(path) ? 'footnotes' : /^word\/endnotes\.xml$/i.test(path) ? 'endnotes' : 'document';
|
|
1738
1925
|
return root.localName === expected && DOCX_WORDPROCESSING_NAMESPACES.has(root.namespaceURI ?? '');
|
|
1739
1926
|
}
|
|
1740
|
-
export { DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, DOCX_WORDPROCESSING_NAMESPACES, DocxParagraphDefaultCollapsedPatchCollector, STRICT_WORDPROCESSING_NAMESPACE, XMLNS_NAMESPACE, XML_NAMESPACE, assertXmlRoot, cloneXmlElement, createDocxThemeResolver, cssColorToHex, cssFontFamily, cssFontSize, dataBoolean, documentProofingLanguageDocxOptions, docxCharacterPositionHalfPointsFromProperties, docxCharacterPositionValue, docxCharacterScalePercentFromProperties, docxCharacterScaleValue, docxCharacterSpacingTwipsFromProperties, docxCharacterSpacingValue, docxEmphasisMarkRunOptions, docxKerningThresholdValue, docxThemeColor, docxThemeFont, domDirection, hasNonWhitespaceXmlText, inspectDocxEmphasisMark, inspectDocxKerningThresholdHalfPoints, inspectDocxNoProof, inspectDocxProofingLanguages, mergeDocxIgnorableExtensions, mergeDocxIgnorableExtensionsAtPairs, paragraphAlignment, paragraphBidirectional, paragraphDirectionOptions, paragraphIndent, paragraphPaginationOptions, paragraphSpacingOptions, paragraphTabStops, parseBoundedDocxInteger, parseDocxColorSchemeMappingElement, parseDocxParagraphDefaultCollapsed, parseDocxTwipsMeasure, patchDocxBibliography, patchDocxExplicitZeroCharacterSpacing, patchDocxExplicitZeroKerningThresholds, patchDocxParagraphDefaultCollapsed, readDocxBibliography, resolveDocxEmphasisMark, resolveDocxKerningThresholdHalfPoints, resolveDocxProofing, resolveDocxThemeResolver, xmlAttributeLocalName, xmlAttributeNamespace, xmlDeclaredPrefix, xmlNamespaceUri };
|
|
1927
|
+
export { DOCX_COLOR_SCHEME_MAPPING_ATTRIBUTES, DOCX_WORDPROCESSING_NAMESPACES, DocxParagraphDefaultCollapsedPatchCollector, STRICT_WORDPROCESSING_NAMESPACE, XMLNS_NAMESPACE, XML_NAMESPACE, assertXmlRoot, cloneXmlElement, createDocxThemeResolver, cssColorToHex, cssFontFamily, cssFontSize, dataBoolean, documentIndexEntryInstruction, documentIndexInstruction, documentProofingLanguageDocxOptions, docxCharacterPositionHalfPointsFromProperties, docxCharacterPositionValue, docxCharacterScalePercentFromProperties, docxCharacterScaleValue, docxCharacterSpacingTwipsFromProperties, docxCharacterSpacingValue, docxEmphasisMarkRunOptions, docxKerningThresholdValue, docxThemeColor, docxThemeFont, domDirection, hasNonWhitespaceXmlText, inspectDocxEmphasisMark, inspectDocxKerningThresholdHalfPoints, inspectDocxNoProof, inspectDocxProofingLanguages, mergeDocxIgnorableExtensions, mergeDocxIgnorableExtensionsAtPairs, paragraphAlignment, paragraphBidirectional, paragraphDirectionOptions, paragraphIndent, paragraphPaginationOptions, paragraphSpacingOptions, paragraphTabStops, parseBoundedDocxInteger, parseDocumentIndexEntryInstruction, parseDocumentIndexInstruction, parseDocxColorSchemeMappingElement, parseDocxParagraphDefaultCollapsed, parseDocxTwipsMeasure, patchDocxBibliography, patchDocxExplicitZeroCharacterSpacing, patchDocxExplicitZeroKerningThresholds, patchDocxParagraphDefaultCollapsed, readDocxBibliography, resolveDocxEmphasisMark, resolveDocxKerningThresholdHalfPoints, resolveDocxProofing, resolveDocxThemeResolver, xmlAttributeLocalName, xmlAttributeNamespace, xmlDeclaredPrefix, xmlNamespaceUri };
|
package/dist/0~5050.js
CHANGED
|
@@ -276,6 +276,15 @@ function documentCurrentPage(editor) {
|
|
|
276
276
|
});
|
|
277
277
|
return page;
|
|
278
278
|
}
|
|
279
|
+
function documentHasRefreshableFields(editor) {
|
|
280
|
+
let found = false;
|
|
281
|
+
editor.state.doc.descendants((node)=>{
|
|
282
|
+
if ('documentField' !== node.type.name) return !found;
|
|
283
|
+
found = true;
|
|
284
|
+
return false;
|
|
285
|
+
});
|
|
286
|
+
return found;
|
|
287
|
+
}
|
|
279
288
|
async function copyDocumentSelection(selection) {
|
|
280
289
|
try {
|
|
281
290
|
if (!navigator.clipboard?.writeText) throw new Error('Clipboard API is unavailable');
|
|
@@ -297,4 +306,4 @@ function mergeOfficeTiptapExtensions(editorName, builtInExtensions, additionalEx
|
|
|
297
306
|
...additionalExtensions
|
|
298
307
|
];
|
|
299
308
|
}
|
|
300
|
-
export { createWorkDocumentSelectionAction, createWorkDocumentSelectionSnapshot, customSelectionMenuItems, documentAgentMenuItems, documentCurrentPage, documentCustomSelectionMenuItems, documentPageCount, documentPlainTextAsHtml, mergeOfficeTiptapExtensions };
|
|
309
|
+
export { createWorkDocumentSelectionAction, createWorkDocumentSelectionSnapshot, customSelectionMenuItems, documentAgentMenuItems, documentCurrentPage, documentCustomSelectionMenuItems, documentHasRefreshableFields, documentPageCount, documentPlainTextAsHtml, mergeOfficeTiptapExtensions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { documentRunBorderDomAttributes, normalizeDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentRunBorder, serializeDocumentRunShading,
|
|
2
|
-
import { docxThemeFont, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, resolveDocxProofing, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, STRICT_WORDPROCESSING_NAMESPACE, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, docxCharacterScalePercentFromProperties, resolveDocxEmphasisMark, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver as work_docx_theme_resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, parseDocxTwipsMeasure } from "./0~
|
|
1
|
+
import { documentRunBorderDomAttributes, normalizeDocumentRunBorder, normalizeDocumentParagraphBorder, serializeDocumentRunBorder, serializeDocumentRunShading, documentIndexEntryHtml, attribute as work_ooxml_package_attribute, documentScriptFontFallbackSlots, documentScriptFontsDomAttributes, documentHighlightFromDocxValue, documentTableOfContentsHtml, directChildren as work_ooxml_package_directChildren, documentParagraphShadingDomAttributes, serializeDocxThemeReference, documentParagraphBordersDomAttributes, normalizeDocumentScriptFontHint, normalizeDocumentScriptFonts, DOCUMENT_PARAGRAPH_BORDER_STYLES, normalizeDocumentParagraphBorders as work_document_paragraph_borders_normalizeDocumentParagraphBorders, DOCUMENT_PARAGRAPH_BORDER_EDGES, documentScriptFontFamily, normalizeDocumentThemeFont, normalizeDocumentParagraphId, documentHighlightDomAttributes, descendants, documentIndexHtml, documentHighlightCssColor, xmlNamespacePrefix, normalizeDocumentFontName, documentProofingDomAttributes, work_document_paragraph_shading_DOCUMENT_PARAGRAPH_SHADING_PATTERNS, directChild, documentScriptFontSegments, childPath, parseDocumentTableOfContentsInstruction, documentRunShadingDomAttributes } from "./4121.js";
|
|
2
|
+
import { docxThemeFont, XML_NAMESPACE as work_docx_settings_xml_XML_NAMESPACE, parseDocumentIndexEntryInstruction, resolveDocxProofing, parseDocumentIndexInstruction, XMLNS_NAMESPACE as work_docx_settings_xml_XMLNS_NAMESPACE, STRICT_WORDPROCESSING_NAMESPACE, docxCharacterSpacingTwipsFromProperties, parseBoundedDocxInteger, xmlAttributeLocalName, docxCharacterScalePercentFromProperties, resolveDocxEmphasisMark, docxCharacterPositionHalfPointsFromProperties, docxThemeColor, parseDocxParagraphDefaultCollapsed, resolveDocxKerningThresholdHalfPoints, resolveDocxThemeResolver as work_docx_theme_resolveDocxThemeResolver, DOCX_WORDPROCESSING_NAMESPACES, xmlAttributeNamespace, parseDocxTwipsMeasure } from "./0~4808.js";
|
|
3
3
|
import { normalizeDocumentEmphasisMark, normalizeDocumentPageBorders, documentCharacterPositionDomAttributes, DOCUMENT_PAGE_BORDER_EDGES, normalizeDocumentTabStops, documentTextCaseFromWordFlags, documentStrikeDomAttributes, documentAutoLineHeight, documentKerningDomAttributes, normalizeDocumentUnderlineColor, documentCharacterScaleDomAttributes, serializeDocumentParagraphFormatting, normalizeDocumentPaperSource, documentEquationText, documentLegacyTextEffectsDomAttributes, documentLegacyTextEffectsConflict, documentCharacterSpacingDomAttributes, normalizeDocumentParagraphIndent, normalizeDocumentEquation, renderDocumentAutoLineHeight, documentUnderlineDomAttributes, normalizeDocumentUnderlineStyle, applyDocumentTextCaseStyle, documentHiddenTextDomAttributes, importedDocumentCharacterFormatting, DOCUMENT_LEGACY_TEXT_EFFECT_NAMES, createDocumentEquationElement, normalizeDocumentPageGeometry, serializeDocumentTabStops, documentWordLineHeightFactor, documentEmphasisMarkDomAttributes, normalizeDocumentPageMargins } from "./6282.js";
|
|
4
4
|
function docxCaptionSequenceKind(instruction) {
|
|
5
5
|
const identifier = /^\s*SEQ\s+([^\s\\]+)/i.exec(instruction)?.[1]?.toLowerCase();
|
|
@@ -4074,6 +4074,235 @@ function nextEquationMarker(state) {
|
|
|
4074
4074
|
return marker;
|
|
4075
4075
|
}
|
|
4076
4076
|
const WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4077
|
+
const work_docx_index_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4078
|
+
function markDocxIndexes(document) {
|
|
4079
|
+
const fields = docxFieldOccurrences(document);
|
|
4080
|
+
const entries = fields.flatMap((field, index)=>{
|
|
4081
|
+
const parsed = parseDocumentIndexEntryInstruction(field.instruction);
|
|
4082
|
+
if (!parsed.supported || !docxFieldOccurrenceIsInlineEditable(field)) return [];
|
|
4083
|
+
const marker = {
|
|
4084
|
+
start: `__A3S_WORK_INDEX_ENTRY_START_${index + 1}__`,
|
|
4085
|
+
end: `__A3S_WORK_INDEX_ENTRY_END_${index + 1}__`,
|
|
4086
|
+
id: `index-entry-import-${index + 1}`,
|
|
4087
|
+
value: parsed.value
|
|
4088
|
+
};
|
|
4089
|
+
insertFieldBoundaryMarkers(document, field, marker.start, marker.end);
|
|
4090
|
+
return [
|
|
4091
|
+
marker
|
|
4092
|
+
];
|
|
4093
|
+
});
|
|
4094
|
+
const indexes = [];
|
|
4095
|
+
for (const field of fields){
|
|
4096
|
+
if (!supportedDocxIndexField(field)) continue;
|
|
4097
|
+
const parsed = parseDocumentIndexInstruction(field.instruction);
|
|
4098
|
+
if (!parsed.supported) continue;
|
|
4099
|
+
const control = work_docx_index_import_closestAncestor(field.start, 'sdt');
|
|
4100
|
+
if (!control || !document.documentElement.contains(control)) continue;
|
|
4101
|
+
const index = indexes.length + 1;
|
|
4102
|
+
const marker = {
|
|
4103
|
+
marker: `__A3S_WORK_DOCUMENT_INDEX_${index}__`,
|
|
4104
|
+
id: `document-index-import-${index}`,
|
|
4105
|
+
options: {
|
|
4106
|
+
...parsed.options,
|
|
4107
|
+
leader: importedIndexLeader(control, parsed.options)
|
|
4108
|
+
},
|
|
4109
|
+
entries: importedIndexEntries(control, index)
|
|
4110
|
+
};
|
|
4111
|
+
control.replaceWith(markerParagraph(document, marker.marker));
|
|
4112
|
+
indexes.push(marker);
|
|
4113
|
+
}
|
|
4114
|
+
return {
|
|
4115
|
+
entries,
|
|
4116
|
+
indexes
|
|
4117
|
+
};
|
|
4118
|
+
}
|
|
4119
|
+
function applyImportedDocxIndexMarkers(document, markers) {
|
|
4120
|
+
for (const entry of markers.entries){
|
|
4121
|
+
const html = documentIndexEntryHtml({
|
|
4122
|
+
id: entry.id,
|
|
4123
|
+
...entry.value
|
|
4124
|
+
});
|
|
4125
|
+
const parsed = document.createRange().createContextualFragment(html);
|
|
4126
|
+
const replacement = parsed.firstElementChild;
|
|
4127
|
+
if (replacement instanceof HTMLElement) replaceMarkerRange(document.body, entry.start, entry.end, replacement);
|
|
4128
|
+
}
|
|
4129
|
+
const importedEntries = Array.from(document.body.querySelectorAll('[data-document-index-entry]'));
|
|
4130
|
+
for (const index of markers.indexes){
|
|
4131
|
+
const text = textNodes(document.body).find((node)=>node.data.includes(index.marker));
|
|
4132
|
+
if (!text) continue;
|
|
4133
|
+
const entries = index.entries.map((entry, entryIndex)=>{
|
|
4134
|
+
const targets = importedEntries.filter((candidate)=>normalizedTerm(candidate.dataset.indexMainEntry) === normalizedTerm(entry.mainEntry) && normalizedTerm(candidate.dataset.indexSubEntry) === normalizedTerm(entry.subEntry));
|
|
4135
|
+
const targetIds = targets.flatMap((candidate)=>{
|
|
4136
|
+
const id = candidate.dataset.indexEntryId?.trim();
|
|
4137
|
+
return id ? [
|
|
4138
|
+
id
|
|
4139
|
+
] : [];
|
|
4140
|
+
});
|
|
4141
|
+
return {
|
|
4142
|
+
...entry,
|
|
4143
|
+
pages: entry.pages.map((page)=>({
|
|
4144
|
+
...page,
|
|
4145
|
+
targetIds: targetIds.length ? targetIds : [
|
|
4146
|
+
`index-entry-import-${index.id}-${entryIndex + 1}`
|
|
4147
|
+
]
|
|
4148
|
+
}))
|
|
4149
|
+
};
|
|
4150
|
+
});
|
|
4151
|
+
const fragment = document.createRange().createContextualFragment(documentIndexHtml({
|
|
4152
|
+
id: index.id,
|
|
4153
|
+
options: index.options,
|
|
4154
|
+
entries
|
|
4155
|
+
}));
|
|
4156
|
+
closestHtmlBlock(text.parentElement)?.replaceWith(fragment);
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
function hasImportedDocxIndexMarkers(markers) {
|
|
4160
|
+
return markers.entries.length > 0 || markers.indexes.length > 0;
|
|
4161
|
+
}
|
|
4162
|
+
function supportedDocxIndexEntryField(field) {
|
|
4163
|
+
return parseDocumentIndexEntryInstruction(field.instruction).supported && docxFieldOccurrenceIsInlineEditable(field);
|
|
4164
|
+
}
|
|
4165
|
+
function supportedDocxIndexField(field) {
|
|
4166
|
+
return parseDocumentIndexInstruction(field.instruction).supported && field.complete && !field.nested && !field.inDeletion && Boolean(work_docx_index_import_closestAncestor(field.start, 'sdt'));
|
|
4167
|
+
}
|
|
4168
|
+
function importedIndexEntries(control, indexNumber) {
|
|
4169
|
+
const entries = [];
|
|
4170
|
+
let currentMain = '';
|
|
4171
|
+
let row = 0;
|
|
4172
|
+
for (const paragraph of descendants(control, 'p')){
|
|
4173
|
+
const style = directChild(directChild(paragraph, 'pPr') ?? paragraph, 'pStyle');
|
|
4174
|
+
const styleName = work_ooxml_package_attribute(style ?? paragraph, 'val') ?? '';
|
|
4175
|
+
const level = /^Index([12])$/i.exec(styleName)?.[1];
|
|
4176
|
+
if (!level) continue;
|
|
4177
|
+
row += 1;
|
|
4178
|
+
const parsed = importedIndexParagraph(paragraph, indexNumber, row);
|
|
4179
|
+
if (parsed) {
|
|
4180
|
+
if ('1' === level) {
|
|
4181
|
+
currentMain = parsed.term;
|
|
4182
|
+
if (!parsed.pages.length && !parsed.crossReference) continue;
|
|
4183
|
+
entries.push({
|
|
4184
|
+
mainEntry: parsed.term,
|
|
4185
|
+
subEntry: '',
|
|
4186
|
+
crossReference: parsed.crossReference,
|
|
4187
|
+
pages: parsed.pages
|
|
4188
|
+
});
|
|
4189
|
+
continue;
|
|
4190
|
+
}
|
|
4191
|
+
if (currentMain) entries.push({
|
|
4192
|
+
mainEntry: currentMain,
|
|
4193
|
+
subEntry: parsed.term,
|
|
4194
|
+
crossReference: parsed.crossReference,
|
|
4195
|
+
pages: parsed.pages
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
}
|
|
4199
|
+
return entries;
|
|
4200
|
+
}
|
|
4201
|
+
function importedIndexParagraph(paragraph, indexNumber, row) {
|
|
4202
|
+
const textElements = descendants(paragraph, 't');
|
|
4203
|
+
const values = textElements.map((element)=>element.textContent ?? '');
|
|
4204
|
+
const combined = values.join('').replace(/\s+/g, ' ').trim();
|
|
4205
|
+
if (!combined) return null;
|
|
4206
|
+
const crossReference = /^(.+?),\s*(?:see|参见)\s+(.+)$/i.exec(combined);
|
|
4207
|
+
if (crossReference?.[1] && crossReference[2]) return {
|
|
4208
|
+
term: crossReference[1].trim(),
|
|
4209
|
+
crossReference: crossReference[2].trim(),
|
|
4210
|
+
pages: []
|
|
4211
|
+
};
|
|
4212
|
+
const pageElements = textElements.filter((element)=>/^\d{1,6}$/.test((element.textContent ?? '').trim()));
|
|
4213
|
+
const pages = pageElements.map((element, pageIndex)=>{
|
|
4214
|
+
const properties = directChild(work_docx_index_import_closestAncestor(element, 'r') ?? element, 'rPr');
|
|
4215
|
+
return {
|
|
4216
|
+
pageNumber: Number((element.textContent ?? '').trim()),
|
|
4217
|
+
pageBold: Boolean(properties && directChild(properties, 'b')),
|
|
4218
|
+
pageItalic: Boolean(properties && directChild(properties, 'i')),
|
|
4219
|
+
targetIds: [
|
|
4220
|
+
`index-entry-import-${indexNumber}-${row}-${pageIndex + 1}`
|
|
4221
|
+
]
|
|
4222
|
+
};
|
|
4223
|
+
});
|
|
4224
|
+
const pageText = pageElements.map((element)=>element.textContent ?? '');
|
|
4225
|
+
let term = combined;
|
|
4226
|
+
for (const value of pageText)term = term.replace(new RegExp(`(?:,\\s*)?${escapeRegExp(value)}\\s*$`), '');
|
|
4227
|
+
term = term.replace(/[,\s]+$/, '').trim();
|
|
4228
|
+
return term ? {
|
|
4229
|
+
term,
|
|
4230
|
+
crossReference: '',
|
|
4231
|
+
pages
|
|
4232
|
+
} : null;
|
|
4233
|
+
}
|
|
4234
|
+
function importedIndexLeader(control, options) {
|
|
4235
|
+
if (!options.rightAlignPageNumbers) return 'none';
|
|
4236
|
+
const tab = descendants(control, 'tab').find((candidate)=>candidate.parentElement?.localName === 'tabs' && 'right' === work_ooxml_package_attribute(candidate, 'val'));
|
|
4237
|
+
const leader = work_ooxml_package_attribute(tab ?? control, 'leader');
|
|
4238
|
+
if ('hyphen' === leader) return 'dash';
|
|
4239
|
+
if ('underscore' === leader) return 'underline';
|
|
4240
|
+
if (!leader || 'none' === leader) return 'none';
|
|
4241
|
+
return 'dot';
|
|
4242
|
+
}
|
|
4243
|
+
function insertFieldBoundaryMarkers(document, field, start, end) {
|
|
4244
|
+
if ('fldChar' === field.start.localName && 'fldChar' === field.end.localName) {
|
|
4245
|
+
field.start.parentNode?.insertBefore(markerText(document, start), field.start);
|
|
4246
|
+
field.end.parentNode?.insertBefore(markerText(document, end), field.end.nextSibling);
|
|
4247
|
+
return;
|
|
4248
|
+
}
|
|
4249
|
+
field.start.parentNode?.insertBefore(markerRun(document, start), field.start);
|
|
4250
|
+
field.end.parentNode?.insertBefore(markerRun(document, end), field.end.nextSibling);
|
|
4251
|
+
}
|
|
4252
|
+
function markerParagraph(document, marker) {
|
|
4253
|
+
const paragraph = document.createElementNS(WORD_NAMESPACE, 'w:p');
|
|
4254
|
+
paragraph.append(markerRun(document, marker));
|
|
4255
|
+
return paragraph;
|
|
4256
|
+
}
|
|
4257
|
+
function markerRun(document, value) {
|
|
4258
|
+
const run = document.createElementNS(WORD_NAMESPACE, 'w:r');
|
|
4259
|
+
run.append(markerText(document, value));
|
|
4260
|
+
return run;
|
|
4261
|
+
}
|
|
4262
|
+
function markerText(document, value) {
|
|
4263
|
+
const text = document.createElementNS(WORD_NAMESPACE, 'w:t');
|
|
4264
|
+
text.setAttributeNS(work_docx_index_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4265
|
+
text.textContent = value;
|
|
4266
|
+
return text;
|
|
4267
|
+
}
|
|
4268
|
+
function replaceMarkerRange(root, start, end, replacement) {
|
|
4269
|
+
const nodes = textNodes(root);
|
|
4270
|
+
const startNode = nodes.find((node)=>node.data.includes(start));
|
|
4271
|
+
const endNode = nodes.find((node)=>node.data.includes(end));
|
|
4272
|
+
if (!startNode || !endNode) return;
|
|
4273
|
+
const range = root.ownerDocument.createRange();
|
|
4274
|
+
range.setStart(startNode, startNode.data.indexOf(start));
|
|
4275
|
+
range.setEnd(endNode, endNode.data.indexOf(end) + end.length);
|
|
4276
|
+
range.deleteContents();
|
|
4277
|
+
range.insertNode(replacement);
|
|
4278
|
+
}
|
|
4279
|
+
function textNodes(root) {
|
|
4280
|
+
const walker = root.ownerDocument?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4281
|
+
const nodes = [];
|
|
4282
|
+
if (!walker) return nodes;
|
|
4283
|
+
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
4284
|
+
return nodes;
|
|
4285
|
+
}
|
|
4286
|
+
function closestHtmlBlock(element) {
|
|
4287
|
+
let current = element;
|
|
4288
|
+
while(current && current.parentElement?.tagName.toLowerCase() !== 'body')current = current.parentElement;
|
|
4289
|
+
return current;
|
|
4290
|
+
}
|
|
4291
|
+
function work_docx_index_import_closestAncestor(element, localName) {
|
|
4292
|
+
let current = element;
|
|
4293
|
+
while(current){
|
|
4294
|
+
if (current.localName === localName) return current;
|
|
4295
|
+
current = current.parentElement;
|
|
4296
|
+
}
|
|
4297
|
+
return null;
|
|
4298
|
+
}
|
|
4299
|
+
function normalizedTerm(value) {
|
|
4300
|
+
return (value ?? '').normalize('NFKC').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
4301
|
+
}
|
|
4302
|
+
function escapeRegExp(value) {
|
|
4303
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
4304
|
+
}
|
|
4305
|
+
const work_docx_table_of_contents_import_WORD_NAMESPACE = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main';
|
|
4077
4306
|
const work_docx_table_of_contents_import_XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
4078
4307
|
function markDocxTablesOfContents(document) {
|
|
4079
4308
|
const tables = [];
|
|
@@ -4093,7 +4322,7 @@ function markDocxTablesOfContents(document) {
|
|
|
4093
4322
|
},
|
|
4094
4323
|
entries: importedTableOfContentsEntries(element, tableIndex)
|
|
4095
4324
|
};
|
|
4096
|
-
element.replaceWith(
|
|
4325
|
+
element.replaceWith(work_docx_table_of_contents_import_markerParagraph(document, marker.marker));
|
|
4097
4326
|
tables.push(marker);
|
|
4098
4327
|
}
|
|
4099
4328
|
return {
|
|
@@ -4104,7 +4333,7 @@ function applyImportedDocxTableOfContentsMarkers(document, markers) {
|
|
|
4104
4333
|
const headings = importedHtmlHeadings(document);
|
|
4105
4334
|
for (const table of markers.tables){
|
|
4106
4335
|
const usedHeadingIndexes = new Set();
|
|
4107
|
-
const text =
|
|
4336
|
+
const text = work_docx_table_of_contents_import_textNodes(document.body).find((node)=>node.data.includes(table.marker));
|
|
4108
4337
|
if (!text) continue;
|
|
4109
4338
|
const entries = table.entries.map((entry)=>{
|
|
4110
4339
|
const headingIndex = headings.findIndex((heading, index)=>!usedHeadingIndexes.has(index) && heading.level === entry.level && normalizedTitle(heading.title) === normalizedTitle(entry.title));
|
|
@@ -4121,7 +4350,7 @@ function applyImportedDocxTableOfContentsMarkers(document, markers) {
|
|
|
4121
4350
|
options: table.options,
|
|
4122
4351
|
entries
|
|
4123
4352
|
}));
|
|
4124
|
-
const block =
|
|
4353
|
+
const block = work_docx_table_of_contents_import_closestHtmlBlock(text.parentElement);
|
|
4125
4354
|
if (block) block.replaceWith(fragment);
|
|
4126
4355
|
}
|
|
4127
4356
|
}
|
|
@@ -4165,10 +4394,10 @@ function importedTableOfContentsLeader(element, options) {
|
|
|
4165
4394
|
if (!leader || 'none' === leader) return 'none';
|
|
4166
4395
|
return 'dot';
|
|
4167
4396
|
}
|
|
4168
|
-
function
|
|
4169
|
-
const paragraph = document.createElementNS(
|
|
4170
|
-
const run = document.createElementNS(
|
|
4171
|
-
const text = document.createElementNS(
|
|
4397
|
+
function work_docx_table_of_contents_import_markerParagraph(document, marker) {
|
|
4398
|
+
const paragraph = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:p');
|
|
4399
|
+
const run = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:r');
|
|
4400
|
+
const text = document.createElementNS(work_docx_table_of_contents_import_WORD_NAMESPACE, 'w:t');
|
|
4172
4401
|
text.setAttributeNS(work_docx_table_of_contents_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
4173
4402
|
text.textContent = marker;
|
|
4174
4403
|
run.append(text);
|
|
@@ -4191,14 +4420,14 @@ function importedHtmlHeadings(document) {
|
|
|
4191
4420
|
];
|
|
4192
4421
|
});
|
|
4193
4422
|
}
|
|
4194
|
-
function
|
|
4423
|
+
function work_docx_table_of_contents_import_textNodes(root) {
|
|
4195
4424
|
const walker = root.ownerDocument?.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
4196
4425
|
const nodes = [];
|
|
4197
4426
|
if (!walker) return nodes;
|
|
4198
4427
|
while(walker.nextNode())nodes.push(walker.currentNode);
|
|
4199
4428
|
return nodes;
|
|
4200
4429
|
}
|
|
4201
|
-
function
|
|
4430
|
+
function work_docx_table_of_contents_import_closestHtmlBlock(element) {
|
|
4202
4431
|
let current = element;
|
|
4203
4432
|
while(current && current.parentElement?.tagName.toLowerCase() !== 'body')current = current.parentElement;
|
|
4204
4433
|
return current;
|
|
@@ -7410,12 +7639,12 @@ function resolvedRunFormatting(propertySources, theme, runText, requestedFontSlo
|
|
|
7410
7639
|
};
|
|
7411
7640
|
}
|
|
7412
7641
|
function insertRunMarkers(document, run, properties, startMarker, endMarker) {
|
|
7413
|
-
const start =
|
|
7414
|
-
const end =
|
|
7642
|
+
const start = work_docx_run_formatting_import_markerText(document, startMarker);
|
|
7643
|
+
const end = work_docx_run_formatting_import_markerText(document, endMarker);
|
|
7415
7644
|
run.insertBefore(start, properties?.nextSibling ?? run.firstChild);
|
|
7416
7645
|
run.append(end);
|
|
7417
7646
|
}
|
|
7418
|
-
function
|
|
7647
|
+
function work_docx_run_formatting_import_markerText(document, marker) {
|
|
7419
7648
|
const text = document.createElementNS(work_docx_run_formatting_import_WORD_NAMESPACE, 'w:t');
|
|
7420
7649
|
text.setAttributeNS(work_docx_run_formatting_import_XML_NAMESPACE, 'xml:space', 'preserve');
|
|
7421
7650
|
text.textContent = marker;
|
|
@@ -7698,4 +7927,4 @@ function work_docx_run_formatting_import_formatNumber(value) {
|
|
|
7698
7927
|
function formatLineHeightFactor(value) {
|
|
7699
7928
|
return Number(value.toFixed(4)).toString();
|
|
7700
7929
|
}
|
|
7701
|
-
export { applyImportedDocxEquationMarkers, applyImportedDocxParagraphAlignmentMarkers, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphFormattingChangeMarkers, applyImportedDocxParagraphIndentMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphShadingMarkers, applyImportedDocxParagraphSpacingMarkers, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxRunFormattingMarkers, applyImportedDocxTableOfContentsMarkers, createDocxParagraphStyleResolver, createDocxTableStyleResolver, createImportedDocxRunFormattingMarkerState, docxCaptionBookmark, docxCaptionReferenceTarget, docxCaptionSequenceKind, docxEquationHtml, docxFieldInstructions, docxFieldOccurrenceIsInlineEditable, docxFieldOccurrences, docxFieldResultText, docxRunPropertySources, docxTableCellStyleLayers, docxTablePropertySources, docxTableRunPropertySources, hasImportedDocxParagraphAlignmentMarkers, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphIndentMarkers, hasImportedDocxParagraphPaginationMarkers, hasImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphTabStopMarkers, hasImportedDocxRunFormattingMarkers, hasImportedDocxTableOfContentsMarkers, hasInvalidDocxFieldStructure, importedDocxStrike, importedDocxUnderline, inspectDocxEquation, inspectDocxHiddenText, inspectDocxLegacyTextEffects, inspectDocxPageBorders, inspectDocxPageMarginSettings, inspectDocxPageMargins, inspectDocxPageSize, inspectDocxPaperSource, inspectDocxRunBorder, inspectDocxRunFonts, inspectDocxRunShading, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, markDocxTablesOfContents, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxRunBorder, resolveDocxRunShading, resolveDocxTableStyleResolver, supportedDocxTableOfContentsField };
|
|
7930
|
+
export { applyImportedDocxEquationMarkers, applyImportedDocxIndexMarkers, applyImportedDocxParagraphAlignmentMarkers, applyImportedDocxParagraphBorderMarkers, applyImportedDocxParagraphDirectionMarkers, applyImportedDocxParagraphFormattingChangeMarkers, applyImportedDocxParagraphIndentMarkers, applyImportedDocxParagraphPaginationMarkers, applyImportedDocxParagraphShadingMarkers, applyImportedDocxParagraphSpacingMarkers, applyImportedDocxParagraphTabStopMarkers, applyImportedDocxRunFormattingMarkers, applyImportedDocxTableOfContentsMarkers, createDocxParagraphStyleResolver, createDocxTableStyleResolver, createImportedDocxRunFormattingMarkerState, docxCaptionBookmark, docxCaptionReferenceTarget, docxCaptionSequenceKind, docxEquationHtml, docxFieldInstructions, docxFieldOccurrenceIsInlineEditable, docxFieldOccurrences, docxFieldResultText, docxRunPropertySources, docxTableCellStyleLayers, docxTablePropertySources, docxTableRunPropertySources, hasImportedDocxIndexMarkers, hasImportedDocxParagraphAlignmentMarkers, hasImportedDocxParagraphBorderMarkers, hasImportedDocxParagraphDirectionMarkers, hasImportedDocxParagraphFormattingChangeMarkers, hasImportedDocxParagraphIndentMarkers, hasImportedDocxParagraphPaginationMarkers, hasImportedDocxParagraphShadingMarkers, hasImportedDocxParagraphSpacingMarkers, hasImportedDocxParagraphTabStopMarkers, hasImportedDocxRunFormattingMarkers, hasImportedDocxTableOfContentsMarkers, hasInvalidDocxFieldStructure, importedDocxStrike, importedDocxUnderline, inspectDocxEquation, inspectDocxHiddenText, inspectDocxLegacyTextEffects, inspectDocxPageBorders, inspectDocxPageMarginSettings, inspectDocxPageMargins, inspectDocxPageSize, inspectDocxPaperSource, inspectDocxRunBorder, inspectDocxRunFonts, inspectDocxRunShading, isDocxEquationLikeRoot, isSupportedDocxEquationPlacement, isSupportedDocxParagraphFormattingChange, isSupportedDocxRunFormattingChange, markDocxIndexes, markDocxPackageEquations, markDocxParagraphAlignments, markDocxParagraphBorders, markDocxParagraphDirections, markDocxParagraphFormattingChanges, markDocxParagraphIndents, markDocxParagraphPagination, markDocxParagraphShading, markDocxParagraphSpacing, markDocxParagraphTabStops, markDocxRunFormattingIntoState, markDocxTablesOfContents, parseDirectDocxParagraphShading, parseDocxPageBorders, parseDocxPageGeometry, parseDocxPageMargins, parseDocxPaperSource, resolveDocxHiddenText, resolveDocxLegacyTextEffects, resolveDocxParagraphBordersForParagraph, resolveDocxRunBorder, resolveDocxRunShading, resolveDocxTableStyleResolver, supportedDocxIndexEntryField, supportedDocxIndexField, supportedDocxTableOfContentsField };
|