@stll/folio-core 0.8.0 → 0.9.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 +39 -0
- package/dist/ai-edits/apply.js +18 -4
- package/dist/ai-edits/headless.d.ts +31 -4
- package/dist/ai-edits/headless.js +148 -35
- package/dist/ai-edits/index.d.ts +3 -3
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/snapshot.js +40 -3
- package/dist/ai-edits/types.d.ts +2 -1
- package/dist/compat/eigenpal.d.ts +6 -4
- package/dist/compat/eigenpal.js +5 -3
- package/dist/controller/latestRequestGate.d.ts +13 -0
- package/dist/controller/latestRequestGate.js +16 -0
- package/dist/controller/layoutPipeline.js +12 -1
- package/dist/document-operations.d.ts +10 -3
- package/dist/document-operations.js +29 -14
- package/dist/docx/blockContentParser.js +2 -2
- package/dist/docx/commentParser.js +1 -1
- package/dist/docx/compatibility.d.ts +3 -7
- package/dist/docx/compatibility.js +0 -11
- package/dist/docx/encryption/agileDecryption.js +1 -1
- package/dist/docx/encryption/encryptionInfo.js +1 -1
- package/dist/docx/encryption/openEncryptedDocx.js +1 -1
- package/dist/docx/fontTableParser.d.ts +6 -0
- package/dist/docx/fontTableParser.js +72 -0
- package/dist/docx/groupDrawingParser.js +7 -2
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/normalizeBaseDirection.js +1 -1
- package/dist/docx/numberingParser.js +1 -0
- package/dist/docx/paragraphParser.js +12 -1
- package/dist/docx/parser.d.ts +1 -1
- package/dist/docx/parser.js +12 -9
- package/dist/docx/rezip.js +70 -5
- package/dist/docx/runConsolidator.js +4 -0
- package/dist/docx/runParser.js +19 -1
- package/dist/docx/selectiveSave.js +3 -3
- package/dist/docx/serializer/fontTableSerializer.d.ts +6 -0
- package/dist/docx/serializer/fontTableSerializer.js +26 -0
- package/dist/docx/serializer/headerFooterSerializer.js +1 -1
- package/dist/docx/serializer/paragraphSerializer.js +4 -0
- package/dist/docx/serializer/runSerializer.js +7 -0
- package/dist/docx/serializer/settingsSerializer.d.ts +6 -0
- package/dist/docx/serializer/settingsSerializer.js +16 -0
- package/dist/docx/serializer/stylesSerializer.d.ts +6 -0
- package/dist/docx/serializer/stylesSerializer.js +56 -0
- package/dist/docx/serializer/tableSerializer.js +25 -26
- package/dist/docx/serializer/themeSerializer.d.ts +6 -0
- package/dist/docx/serializer/themeSerializer.js +36 -0
- package/dist/docx/settingsParser.js +46 -0
- package/dist/docx/styleParser.js +26 -1
- package/dist/docx/tableParser.js +11 -1
- package/dist/docx/vmlImageParser.js +1 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +5916 -5916
- package/dist/i18n/messages/catalogs.gen.js +5910 -5910
- package/dist/index.d.ts +6 -4
- package/dist/index.js +5 -3
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +3 -1
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +3 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +6 -1
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +14 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +51 -14
- package/dist/layout-bridge/engine/measuring/index.d.ts +2 -1
- package/dist/layout-bridge/engine/measuring/index.js +2 -1
- package/dist/layout-engine/index.js +36 -28
- package/dist/layout-engine/measure/cache.js +11 -3
- package/dist/layout-engine/measure/font-metrics.worker.js +1 -0
- package/dist/layout-engine/measure/index.d.ts +2 -1
- package/dist/layout-engine/measure/index.js +2 -1
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +33 -0
- package/dist/layout-engine/measure/lineBreakProvider.js +252 -0
- package/dist/layout-engine/measure/lineBreaks.d.ts +7 -2
- package/dist/layout-engine/measure/lineBreaks.js +11 -18
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +1 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +12 -6
- package/dist/layout-engine/measure/measureBlocks.d.ts +1 -2
- package/dist/layout-engine/measure/measureBlocks.js +6 -36
- package/dist/layout-engine/measure/measureContainer.js +32 -9
- package/dist/layout-engine/measure/measureHelpers.js +5 -2
- package/dist/layout-engine/measure/measureParagraph.js +335 -72
- package/dist/layout-engine/measure/measureTypes.d.ts +2 -1
- package/dist/layout-engine/measure/measureWorker.d.ts +2 -2
- package/dist/layout-engine/measure/measureWorker.js +8 -19
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +3 -14
- package/dist/layout-engine/measure/tableCellFloating.d.ts +10 -3
- package/dist/layout-engine/measure/tableCellFloating.js +37 -29
- package/dist/layout-engine/measure/tableCellFlow.d.ts +27 -0
- package/dist/layout-engine/measure/tableCellFlow.js +73 -0
- package/dist/layout-engine/measure/tableCellGrid.js +1 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +18 -0
- package/dist/layout-engine/measure/textMeasurementPolicy.js +24 -0
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +6 -1
- package/dist/layout-engine/renderedBreakReconciliation.js +34 -11
- package/dist/layout-engine/tableRowBreak.d.ts +5 -2
- package/dist/layout-engine/tableRowBreak.js +62 -29
- package/dist/layout-engine/types.d.ts +40 -7
- package/dist/layout-painter/anchoredImagePosition.d.ts +23 -0
- package/dist/layout-painter/anchoredImagePosition.js +95 -0
- package/dist/layout-painter/borderStroke.d.ts +23 -0
- package/dist/layout-painter/borderStroke.js +39 -0
- package/dist/layout-painter/renderImage.d.ts +5 -4
- package/dist/layout-painter/renderImage.js +18 -4
- package/dist/layout-painter/renderPage.d.ts +2 -27
- package/dist/layout-painter/renderPage.js +13 -99
- package/dist/layout-painter/renderParagraph.js +41 -23
- package/dist/layout-painter/renderTable.d.ts +2 -0
- package/dist/layout-painter/renderTable.js +223 -43
- package/dist/managers/DocumentLoaderManager.d.ts +1 -1
- package/dist/managers/DocumentLoaderManager.js +2 -2
- package/dist/prosemirror/attrs/index.d.ts +4 -2
- package/dist/prosemirror/attrs/index.js +21 -2
- package/dist/prosemirror/commands/propertyChangeScope.js +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +33 -18
- package/dist/prosemirror/conversion/toProseDoc.js +50 -18
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +7 -2
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +1 -1
- package/dist/prosemirror/extensions/features/ListExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +7 -0
- package/dist/prosemirror/extensions/marks/LanguageExtension.js +30 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +1 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +1 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +12 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +4 -2
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/marks.d.ts +6 -1
- package/dist/prosemirror/schema/nodes.d.ts +13 -11
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +1 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +3 -1
- package/dist/prosemirror/utils/tabCalculator.js +12 -10
- package/dist/prosemirror/validation.js +4 -1
- package/dist/redline.js +13 -3
- package/dist/server.d.ts +6 -3
- package/dist/server.js +5 -2
- package/dist/style-sets/extract.d.ts +35 -0
- package/dist/style-sets/extract.js +123 -0
- package/dist/style-sets/stellaStyle.d.ts +13 -0
- package/dist/style-sets/stellaStyle.js +516 -0
- package/dist/style-sets/types.d.ts +31 -0
- package/dist/style-sets/types.js +5 -0
- package/dist/utils/createDocument.d.ts +12 -2
- package/dist/utils/createDocument.js +42 -31
- package/dist/utils/fontResolver.js +6 -6
- package/dist/utils/formatToStyle.js +1 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -3
- package/dist/utils/paragraphFormattingMerge.js +14 -4
- package/package.json +5 -1
- package/dist/docx/capabilities.d.ts +0 -41
- package/dist/docx/capabilities.js +0 -322
package/dist/compat/eigenpal.js
CHANGED
|
@@ -3,16 +3,18 @@ import { createFolioAIEditSnapshot, hashFolioAIBlockText, normalizeFolioAIBlockT
|
|
|
3
3
|
import { diffWordSegments } from "../ai-edits/word-diff.js";
|
|
4
4
|
import { applyFolioAIEditOperations } from "../ai-edits/apply.js";
|
|
5
5
|
import { FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch } from "../document-operations.js";
|
|
6
|
+
import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "../style-sets/types.js";
|
|
6
7
|
import { createEmptyDocument } from "../utils/createDocument.js";
|
|
8
|
+
import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "../style-sets/extract.js";
|
|
9
|
+
import { STELLA_STYLE_SET_NAME, createStellaStyleDocumentPreset, createStellaStyleSet } from "../style-sets/stellaStyle.js";
|
|
7
10
|
import { createDocx } from "../docx/rezip.js";
|
|
8
|
-
import { FOLIO_DOCX_CAPABILITY_HOSTS, FOLIO_DOCX_CAPABILITY_IDS, FOLIO_DOCX_CAPABILITY_MANIFEST, FOLIO_DOCX_CAPABILITY_MANIFEST_VERSION, FOLIO_DOCX_CAPABILITY_OPERATIONS, FOLIO_DOCX_COMPATIBILITY_HOSTS, FOLIO_DOCX_COMPATIBILITY_PROFILES, FOLIO_DOCX_PROFILES, FOLIO_DOCX_SUPPORT_STATES, InvalidFolioDocxCapabilityIdError, getFolioDocxCapability, isFolioDocxCapabilityId } from "../docx/capabilities.js";
|
|
9
11
|
import { inspectDocxCompatibility } from "../docx/compatibility.js";
|
|
10
12
|
import { DEFAULT_AI_SUGGESTION_PRESETS } from "../ai-suggestions/types.js";
|
|
11
13
|
import { buildPositionalText } from "../ai-suggestions/text-positions.js";
|
|
12
14
|
import { isSuggestionStale, resolveSuggestionAnchor } from "../ai-suggestions/conflict.js";
|
|
13
15
|
import { applySuggestions } from "../ai-suggestions/apply.js";
|
|
14
|
-
import { setAISuggestionsMeta, setFocusedSuggestionMeta } from "../prosemirror/plugins/aiSuggestionDecorations.js";
|
|
15
16
|
import { getGoogleFontsEnabled, setGoogleFontsEnabled } from "../utils/fontResolver.js";
|
|
17
|
+
import { setAISuggestionsMeta, setFocusedSuggestionMeta } from "../prosemirror/plugins/aiSuggestionDecorations.js";
|
|
16
18
|
import { scrollFolioPositionIntoView } from "../paged-layout/scrollToPmPosition.js";
|
|
17
19
|
import { getFolioCaretViewportRect, getFolioSelectionViewportRect } from "../paged-layout/selectionViewportRect.js";
|
|
18
20
|
import { createAICitationDecorationsPlugin, setAICitationsMeta, setActiveCitationMeta } from "../prosemirror/plugins/aiCitationDecorations.js";
|
|
@@ -25,4 +27,4 @@ import { fromMarkdown } from "../markdown/fromMarkdown.js";
|
|
|
25
27
|
import { toMarkdown, toMarkdownResult } from "../markdown/index.js";
|
|
26
28
|
import { extractEmbeddedFonts, getEmbeddedFontFaces } from "../fonts/embeddedFonts.js";
|
|
27
29
|
import { DOCX_CONFORMANCE_CLASSES } from "../index.js";
|
|
28
|
-
export { DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCX_CONFORMANCE_CLASSES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES,
|
|
30
|
+
export { DEFAULT_AI_SUGGESTION_PRESETS, DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DOCX_CONFORMANCE_CLASSES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, InvalidFolioDocumentOperationBatchError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, acceptAutocompleteSuggestion, acceptAutocompleteWord, anonymizationDecorationsKey, appendAutocompleteToken, applyFolioAIEditOperations, applyFolioDocumentOperations, applySuggestions, assertSupportedFolioDocumentOperationVersion, autocompleteSuggestionKey, autocompleteSuggestionPlugin, buildPositionalText, clearAutocompleteSuggestion, clearTemplateSlashMenu, consumeTemplateSlashQuery, createAICitationDecorationsPlugin, createDocx, createEmptyDocument, createFolioAIEditSnapshot, createStellaStyleDocumentPreset, createStellaStyleSet, deriveBlockId, diffWordSegments, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractEmbeddedFonts, finishAutocompleteSuggestion, fromMarkdown, getAnonymizationMatches, getAutocompleteSuggestion, getEmbeddedFontFaces, getFolioCaretViewportRect, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioParaIdFromBlockId, getFolioSelectionViewportRect, getGoogleFontsEnabled, getTemplateDirectives, getTemplateSlashMenu, hashFolioAIBlockText, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxCompatibility, isFolioBlockId, isFolioDocumentOperationModeSupported, isSequentialFolioBlockId, isSuggestionStale, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, parseFolioDocumentOperationBatch, resetTemplateSlashQuery, resolveSuggestionAnchor, scanDirectives, scrollFolioPositionIntoView, setAICitationsMeta, setAISuggestionsMeta, setActiveCitationMeta, setAnonymizationTermsMeta, setFocusedSuggestionMeta, setGoogleFontsEnabled, setTemplatePreviewValues, shouldTriggerAutocomplete, startAutocompleteSuggestion, templateSlashMenuKey, toMarkdown, toMarkdownResult };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/controller/latestRequestGate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Coordinates async work where only the most recently started request may
|
|
4
|
+
* commit a result. Each guard closes over an opaque identity, so callers
|
|
5
|
+
* cannot accidentally make an older request current again.
|
|
6
|
+
*/
|
|
7
|
+
type LatestRequestGate = {
|
|
8
|
+
/** Start a request and return a guard that remains true while it is latest. */begin: () => () => boolean; /** Supersede the current request without starting another one. */
|
|
9
|
+
invalidate: () => void;
|
|
10
|
+
};
|
|
11
|
+
declare const createLatestRequestGate: () => LatestRequestGate;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { LatestRequestGate, createLatestRequestGate };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/controller/latestRequestGate.ts
|
|
2
|
+
const createLatestRequestGate = () => {
|
|
3
|
+
let current = Symbol();
|
|
4
|
+
return {
|
|
5
|
+
begin: () => {
|
|
6
|
+
const request = Symbol();
|
|
7
|
+
current = request;
|
|
8
|
+
return () => current === request;
|
|
9
|
+
},
|
|
10
|
+
invalidate: () => {
|
|
11
|
+
current = Symbol();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { createLatestRequestGate };
|
|
@@ -73,6 +73,13 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
73
73
|
const flowOpts = { pageContentHeight: pageSize.h - margins.top - margins.bottom };
|
|
74
74
|
if (_theme !== void 0) flowOpts.theme = _theme;
|
|
75
75
|
if (defaultTabStop !== void 0) flowOpts.defaultTabStopTwips = defaultTabStop;
|
|
76
|
+
if (document?.package.settings?.lineBreakRules) flowOpts.lineBreakRules = document.package.settings.lineBreakRules;
|
|
77
|
+
const documentSettings = document?.package.settings;
|
|
78
|
+
if (documentSettings?.autoHyphenation === true) flowOpts.automaticHyphenation = {
|
|
79
|
+
enabled: true,
|
|
80
|
+
...documentSettings.doNotHyphenateCaps !== void 0 ? { doNotHyphenateCaps: documentSettings.doNotHyphenateCaps } : {},
|
|
81
|
+
...documentSettings.consecutiveHyphenLimit !== void 0 ? { consecutiveLineLimit: documentSettings.consecutiveHyphenLimit } : {}
|
|
82
|
+
};
|
|
76
83
|
let newBlocks = toFlowBlocks(state.doc, flowOpts);
|
|
77
84
|
const previewState = templatePreviewValuesKey.getState(state);
|
|
78
85
|
const previewEntries = previewState?.entries ?? EMPTY_TEMPLATE_PREVIEW_ENTRIES;
|
|
@@ -117,7 +124,9 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
117
124
|
...styles ? { styles } : {},
|
|
118
125
|
..._theme !== void 0 ? { theme: _theme } : {},
|
|
119
126
|
measureBlocks: hfMeasureBlocks,
|
|
120
|
-
...defaultTabStop !== void 0 ? { defaultTabStopTwips: defaultTabStop } : {}
|
|
127
|
+
...defaultTabStop !== void 0 ? { defaultTabStopTwips: defaultTabStop } : {},
|
|
128
|
+
...flowOpts.lineBreakRules ? { lineBreakRules: flowOpts.lineBreakRules } : {},
|
|
129
|
+
...flowOpts.automaticHyphenation ? { automaticHyphenation: flowOpts.automaticHyphenation } : {}
|
|
121
130
|
};
|
|
122
131
|
};
|
|
123
132
|
const hfOptions = buildHfOptions(hfPageCountEstimate);
|
|
@@ -245,6 +254,8 @@ function runLayoutPipeline(deps, state, options = {}) {
|
|
|
245
254
|
if (styles) footnoteOptions.styles = styles;
|
|
246
255
|
if (_theme !== void 0) footnoteOptions.theme = _theme;
|
|
247
256
|
if (defaultTabStop !== void 0) footnoteOptions.defaultTabStopTwips = defaultTabStop;
|
|
257
|
+
if (flowOpts.lineBreakRules) footnoteOptions.lineBreakRules = flowOpts.lineBreakRules;
|
|
258
|
+
if (flowOpts.automaticHyphenation) footnoteOptions.automaticHyphenation = flowOpts.automaticHyphenation;
|
|
248
259
|
return footnoteOptions;
|
|
249
260
|
})());
|
|
250
261
|
const footnoteHeightById = /* @__PURE__ */ new Map();
|
|
@@ -67,19 +67,24 @@ type FolioDocumentOperationIssue = {
|
|
|
67
67
|
retryable: boolean;
|
|
68
68
|
recovery: FolioDocumentOperationRecovery;
|
|
69
69
|
};
|
|
70
|
+
type FolioDocumentOperationStory = "main" | {
|
|
71
|
+
type: "header" | "footer";
|
|
72
|
+
relationshipId: string;
|
|
73
|
+
};
|
|
70
74
|
/** One typed target affected by a successfully applied document operation. */
|
|
71
75
|
type FolioDocumentOperationAffectedTarget = {
|
|
72
76
|
type: "block";
|
|
73
|
-
story:
|
|
77
|
+
story: FolioDocumentOperationStory;
|
|
74
78
|
blockId: string;
|
|
75
79
|
effect: "updated" | "deleted" | "commented";
|
|
76
80
|
} | {
|
|
77
81
|
type: "textRange";
|
|
78
82
|
range: FolioAITextRangeHandle;
|
|
79
83
|
effect: "formatted" | "commented";
|
|
84
|
+
story?: Exclude<FolioDocumentOperationStory, "main">;
|
|
80
85
|
} | {
|
|
81
86
|
type: "insertion";
|
|
82
|
-
story:
|
|
87
|
+
story: FolioDocumentOperationStory;
|
|
83
88
|
anchorBlockId: string;
|
|
84
89
|
position: "before" | "after";
|
|
85
90
|
content: "block" | "signatureTable";
|
|
@@ -123,6 +128,7 @@ type ApplyFolioDocumentOperationsOptions = {
|
|
|
123
128
|
view: FolioAIEditView;
|
|
124
129
|
snapshot: FolioAIEditSnapshot;
|
|
125
130
|
batch: FolioDocumentOperationBatch;
|
|
131
|
+
story?: FolioDocumentOperationStory;
|
|
126
132
|
author?: string;
|
|
127
133
|
createCommentId?: (text: string) => number;
|
|
128
134
|
createUndoHandle?: () => FolioDocumentOperationUndoHandle;
|
|
@@ -131,9 +137,10 @@ declare const applyFolioDocumentOperations: ({
|
|
|
131
137
|
view,
|
|
132
138
|
snapshot,
|
|
133
139
|
batch,
|
|
140
|
+
story,
|
|
134
141
|
author,
|
|
135
142
|
createCommentId,
|
|
136
143
|
createUndoHandle
|
|
137
144
|
}: ApplyFolioDocumentOperationsOptions) => FolioDocumentOperationResult;
|
|
138
145
|
//#endregion
|
|
139
|
-
export { ApplyFolioDocumentOperationsOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationStatus, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch };
|
|
146
|
+
export { ApplyFolioDocumentOperationsOptions, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FolioDocumentOperation, FolioDocumentOperationAffectedTarget, FolioDocumentOperationBatch, FolioDocumentOperationCapabilities, FolioDocumentOperationIssue, FolioDocumentOperationMode, FolioDocumentOperationPrecondition, FolioDocumentOperationReceipt, FolioDocumentOperationRecovery, FolioDocumentOperationResult, FolioDocumentOperationStatus, FolioDocumentOperationStory, FolioDocumentOperationType, FolioDocumentOperationUndoFailureReason, FolioDocumentOperationUndoHandle, FolioDocumentOperationUndoResult, InvalidFolioDocumentOperationBatchError, UnsupportedFolioDocumentOperationVersionError, applyFolioDocumentOperations, assertSupportedFolioDocumentOperationVersion, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, isFolioDocumentOperationModeSupported, isSupportedFolioDocumentOperationVersion, parseFolioDocumentOperationBatch };
|
|
@@ -438,54 +438,56 @@ const getFolioDocumentOperationIssues = (operations, skipped) => {
|
|
|
438
438
|
};
|
|
439
439
|
});
|
|
440
440
|
};
|
|
441
|
-
const getPrimaryAffectedTarget = (operation) => {
|
|
441
|
+
const getPrimaryAffectedTarget = (operation, story) => {
|
|
442
442
|
switch (operation.type) {
|
|
443
443
|
case "replaceInBlock":
|
|
444
444
|
case "replaceBlock": return {
|
|
445
445
|
type: "block",
|
|
446
|
-
story
|
|
446
|
+
story,
|
|
447
447
|
blockId: operation.blockId,
|
|
448
448
|
effect: "updated"
|
|
449
449
|
};
|
|
450
450
|
case "replaceRange": return {
|
|
451
451
|
type: "block",
|
|
452
|
-
story
|
|
452
|
+
story,
|
|
453
453
|
blockId: operation.range.blockId,
|
|
454
454
|
effect: "updated"
|
|
455
455
|
};
|
|
456
456
|
case "commentOnRange": return {
|
|
457
457
|
type: "textRange",
|
|
458
458
|
range: operation.range,
|
|
459
|
-
effect: "commented"
|
|
459
|
+
effect: "commented",
|
|
460
|
+
...story !== "main" && { story }
|
|
460
461
|
};
|
|
461
462
|
case "formatRange": return {
|
|
462
463
|
type: "textRange",
|
|
463
464
|
range: operation.range,
|
|
464
|
-
effect: "formatted"
|
|
465
|
+
effect: "formatted",
|
|
466
|
+
...story !== "main" && { story }
|
|
465
467
|
};
|
|
466
468
|
case "insertAfterBlock":
|
|
467
469
|
case "insertBeforeBlock": return {
|
|
468
470
|
type: "insertion",
|
|
469
|
-
story
|
|
471
|
+
story,
|
|
470
472
|
anchorBlockId: operation.blockId,
|
|
471
473
|
position: operation.type === "insertBeforeBlock" ? "before" : "after",
|
|
472
474
|
content: "block"
|
|
473
475
|
};
|
|
474
476
|
case "deleteBlock": return {
|
|
475
477
|
type: "block",
|
|
476
|
-
story
|
|
478
|
+
story,
|
|
477
479
|
blockId: operation.blockId,
|
|
478
480
|
effect: "deleted"
|
|
479
481
|
};
|
|
480
482
|
case "commentOnBlock": return {
|
|
481
483
|
type: "block",
|
|
482
|
-
story
|
|
484
|
+
story,
|
|
483
485
|
blockId: operation.blockId,
|
|
484
486
|
effect: "commented"
|
|
485
487
|
};
|
|
486
488
|
case "insertSignatureTable": return {
|
|
487
489
|
type: "insertion",
|
|
488
|
-
story
|
|
490
|
+
story,
|
|
489
491
|
anchorBlockId: operation.blockId,
|
|
490
492
|
position: operation.position ?? "after",
|
|
491
493
|
content: "signatureTable"
|
|
@@ -493,7 +495,12 @@ const getPrimaryAffectedTarget = (operation) => {
|
|
|
493
495
|
}
|
|
494
496
|
};
|
|
495
497
|
/** Build deterministic affected-target receipts from operations and their applied entries. */
|
|
496
|
-
const getFolioDocumentOperationReceipts = (operations, applied) => {
|
|
498
|
+
const getFolioDocumentOperationReceipts = (operations, applied) => getFolioDocumentOperationReceiptsForStory({
|
|
499
|
+
operations,
|
|
500
|
+
applied,
|
|
501
|
+
story: "main"
|
|
502
|
+
});
|
|
503
|
+
const getFolioDocumentOperationReceiptsForStory = ({ operations, applied, story }) => {
|
|
497
504
|
const appliedById = /* @__PURE__ */ new Map();
|
|
498
505
|
applied.forEach((operation) => {
|
|
499
506
|
appliedById.set(operation.id, operation);
|
|
@@ -502,7 +509,7 @@ const getFolioDocumentOperationReceipts = (operations, applied) => {
|
|
|
502
509
|
operations.forEach((operation, operationIndex) => {
|
|
503
510
|
const appliedOperation = appliedById.get(operation.id);
|
|
504
511
|
if (!appliedOperation) return;
|
|
505
|
-
const affected = [getPrimaryAffectedTarget(operation)];
|
|
512
|
+
const affected = [getPrimaryAffectedTarget(operation, story)];
|
|
506
513
|
if (appliedOperation.commentId !== void 0) affected.push({
|
|
507
514
|
type: "comment",
|
|
508
515
|
commentId: appliedOperation.commentId
|
|
@@ -515,7 +522,7 @@ const getFolioDocumentOperationReceipts = (operations, applied) => {
|
|
|
515
522
|
});
|
|
516
523
|
return receipts;
|
|
517
524
|
};
|
|
518
|
-
const applyFolioDocumentOperations = ({ view, snapshot, batch, author, createCommentId, createUndoHandle }) => {
|
|
525
|
+
const applyFolioDocumentOperations = ({ view, snapshot, batch, story = "main", author, createCommentId, createUndoHandle }) => {
|
|
519
526
|
const parsedBatch = parseFolioDocumentOperationBatch(batch);
|
|
520
527
|
const apply = ({ targetView, targetCreateCommentId = createCommentId, preview = false }) => {
|
|
521
528
|
return (preview ? previewFolioAIEditOperations : applyFolioAIEditOperations)({
|
|
@@ -556,7 +563,11 @@ const applyFolioDocumentOperations = ({ view, snapshot, batch, author, createCom
|
|
|
556
563
|
applied: previewResult.applied.map(({ id }) => ({ id })),
|
|
557
564
|
skipped: previewResult.skipped,
|
|
558
565
|
issues: getFolioDocumentOperationIssues(parsedBatch.operations, previewResult.skipped),
|
|
559
|
-
receipts:
|
|
566
|
+
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
567
|
+
operations: parsedBatch.operations,
|
|
568
|
+
applied: previewResult.applied,
|
|
569
|
+
story
|
|
570
|
+
}),
|
|
560
571
|
undoHandle: null
|
|
561
572
|
};
|
|
562
573
|
}
|
|
@@ -570,7 +581,11 @@ const applyFolioDocumentOperations = ({ view, snapshot, batch, author, createCom
|
|
|
570
581
|
status: "committed",
|
|
571
582
|
...result,
|
|
572
583
|
issues: getFolioDocumentOperationIssues(parsedBatch.operations, result.skipped),
|
|
573
|
-
receipts:
|
|
584
|
+
receipts: getFolioDocumentOperationReceiptsForStory({
|
|
585
|
+
operations: parsedBatch.operations,
|
|
586
|
+
applied: result.applied,
|
|
587
|
+
story
|
|
588
|
+
}),
|
|
574
589
|
undoHandle: result.applied.length > 0 && createUndoHandle !== void 0 ? createUndoHandle() : null
|
|
575
590
|
};
|
|
576
591
|
};
|
|
@@ -3,10 +3,10 @@ import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
|
3
3
|
import { parseSdtProperties } from "./sdtProperties.js";
|
|
4
4
|
import { parseParagraph } from "./paragraphParser.js";
|
|
5
5
|
import { appendBookmarkMarkerToLastParagraphInBlocks, prependBookmarkMarkersToFirstParagraphInBlocks } from "./bookmarkPlacement.js";
|
|
6
|
+
import { convertBulletToUnicode } from "./bulletMarkers.js";
|
|
7
|
+
import { padDecimal } from "./numberingParser.js";
|
|
6
8
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
7
9
|
import { parseTable } from "./tableParser.js";
|
|
8
|
-
import { padDecimal } from "./numberingParser.js";
|
|
9
|
-
import { convertBulletToUnicode } from "./bulletMarkers.js";
|
|
10
10
|
//#region src/docx/blockContentParser.ts
|
|
11
11
|
const toRoman = (numParam) => {
|
|
12
12
|
let num = numParam;
|
|
@@ -75,7 +75,7 @@ function parseComments(commentsXml, styles, theme, rels, media, commentsExtensib
|
|
|
75
75
|
for (const child of children) {
|
|
76
76
|
if ((child.name?.replace(/^.*:/u, "") ?? "") !== "comment") continue;
|
|
77
77
|
const id = Number.parseInt(getAttribute(child, "w", "id") ?? "0", 10);
|
|
78
|
-
const author = getAttribute(child, "w", "author")
|
|
78
|
+
const author = getAttribute(child, "w", "author")?.trim() || "Unknown";
|
|
79
79
|
const rawInitials = getAttribute(child, "w", "initials");
|
|
80
80
|
const initials = rawInitials !== null ? String(rawInitials) : void 0;
|
|
81
81
|
const rawDate = getAttribute(child, "w", "date");
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
import { FolioDocxCompatibilityHost, FolioDocxCompatibilityProfile, FolioDocxFeatureCapability } from "./capabilities.js";
|
|
3
2
|
|
|
4
3
|
//#region src/docx/compatibility.d.ts
|
|
5
4
|
type DocxCompatibilityReason = "opaqueDrawing";
|
|
5
|
+
type FolioDocxCompatibilityHost = "browser" | "server" | "unknown";
|
|
6
|
+
type FolioDocxCompatibilityProfile = document_d_exports.DocxConformanceClass;
|
|
6
7
|
type DocxCompatibilityContext = {
|
|
7
8
|
host: FolioDocxCompatibilityHost;
|
|
8
9
|
profile: FolioDocxCompatibilityProfile;
|
|
@@ -24,11 +25,6 @@ type DocxCompatibilityLocation = {
|
|
|
24
25
|
};
|
|
25
26
|
type DocxCompatibilityIssue = {
|
|
26
27
|
code: DocxCompatibilityReason;
|
|
27
|
-
capability: FolioDocxFeatureCapability;
|
|
28
|
-
coverage: {
|
|
29
|
-
host: "covered" | "unknown" | "unverified";
|
|
30
|
-
profile: "covered" | "unknown" | "unverified";
|
|
31
|
-
};
|
|
32
28
|
location: DocxCompatibilityLocation;
|
|
33
29
|
};
|
|
34
30
|
type DocxCompatibility = {
|
|
@@ -41,4 +37,4 @@ type DocxCompatibility = {
|
|
|
41
37
|
};
|
|
42
38
|
declare const inspectDocxCompatibility: (doc: document_d_exports.Document, options?: InspectDocxCompatibilityOptions) => DocxCompatibility;
|
|
43
39
|
//#endregion
|
|
44
|
-
export { DocxCompatibility, DocxCompatibilityContext, DocxCompatibilityIssue, DocxCompatibilityLocation, DocxCompatibilityPart, DocxCompatibilityReason, InspectDocxCompatibilityOptions, inspectDocxCompatibility };
|
|
40
|
+
export { DocxCompatibility, DocxCompatibilityContext, DocxCompatibilityIssue, DocxCompatibilityLocation, DocxCompatibilityPart, DocxCompatibilityReason, FolioDocxCompatibilityHost, FolioDocxCompatibilityProfile, InspectDocxCompatibilityOptions, inspectDocxCompatibility };
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import { getFolioDocxCapability } from "./capabilities.js";
|
|
2
1
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
3
2
|
//#region src/docx/compatibility.ts
|
|
4
3
|
const resolveCompatibilityContext = (doc, options) => ({
|
|
5
4
|
host: options.host ?? "unknown",
|
|
6
5
|
profile: options.profile ?? doc.package.conformanceClass ?? DOCX_CONFORMANCE_CLASSES.UNKNOWN
|
|
7
6
|
});
|
|
8
|
-
const getCoverageState = (value, coveredValues) => {
|
|
9
|
-
if (value === "unknown") return "unknown";
|
|
10
|
-
return coveredValues.includes(value) ? "covered" : "unverified";
|
|
11
|
-
};
|
|
12
7
|
const inspectDocxCompatibility = (doc, options = {}) => {
|
|
13
8
|
const context = resolveCompatibilityContext(doc, options);
|
|
14
9
|
const reasons = /* @__PURE__ */ new Set();
|
|
15
10
|
const issues = [];
|
|
16
11
|
const record = (location) => {
|
|
17
12
|
const code = "opaqueDrawing";
|
|
18
|
-
const capability = getFolioDocxCapability(code);
|
|
19
13
|
reasons.add(code);
|
|
20
14
|
issues.push({
|
|
21
15
|
code,
|
|
22
|
-
capability,
|
|
23
|
-
coverage: {
|
|
24
|
-
host: getCoverageState(context.host, capability.hosts),
|
|
25
|
-
profile: getCoverageState(context.profile, capability.profiles)
|
|
26
|
-
},
|
|
27
16
|
location
|
|
28
17
|
});
|
|
29
18
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bytesEqual, joinBytes, padToBlock, passwordToUtf16Le, toArrayBuffer, writeUint32Le } from "./cryptoBytes.js";
|
|
2
1
|
import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
|
|
2
|
+
import { bytesEqual, joinBytes, padToBlock, passwordToUtf16Le, toArrayBuffer, writeUint32Le } from "./cryptoBytes.js";
|
|
3
3
|
//#region src/docx/encryption/agileDecryption.ts
|
|
4
4
|
/**
|
|
5
5
|
* Agile Encryption decryption (Office 2010+) using Web Crypto.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { decodeBase64 } from "./cryptoBytes.js";
|
|
2
1
|
import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
|
|
2
|
+
import { decodeBase64 } from "./cryptoBytes.js";
|
|
3
3
|
//#region src/docx/encryption/encryptionInfo.ts
|
|
4
4
|
/**
|
|
5
5
|
* Parse the EncryptionInfo stream for Agile Encryption (Office 2010+).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toArrayBuffer } from "./cryptoBytes.js";
|
|
2
1
|
import { DOCX_ENCRYPTION_ERROR_CODES, DocxEncryptionError } from "./errors.js";
|
|
2
|
+
import { toArrayBuffer } from "./cryptoBytes.js";
|
|
3
3
|
import { decryptAgileEncryptedPackage } from "./agileDecryption.js";
|
|
4
4
|
import { readEncryptedPackageStreams } from "./compoundFile.js";
|
|
5
5
|
import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "./containerFormat.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { findChild, findChildren, getAttribute, parseXmlDocument } from "./xmlParser.js";
|
|
2
|
+
//#region src/docx/fontTableParser.ts
|
|
3
|
+
const FONT_FAMILIES = [
|
|
4
|
+
"decorative",
|
|
5
|
+
"modern",
|
|
6
|
+
"roman",
|
|
7
|
+
"script",
|
|
8
|
+
"swiss",
|
|
9
|
+
"auto"
|
|
10
|
+
];
|
|
11
|
+
const FONT_PITCHES = [
|
|
12
|
+
"default",
|
|
13
|
+
"fixed",
|
|
14
|
+
"variable"
|
|
15
|
+
];
|
|
16
|
+
const parseFontTable = (xml) => {
|
|
17
|
+
if (!xml) return;
|
|
18
|
+
const root = parseXmlDocument(xml);
|
|
19
|
+
if (!root) return;
|
|
20
|
+
const fonts = [];
|
|
21
|
+
for (const element of findChildren(root, "w", "font")) {
|
|
22
|
+
const font = parseFont(element);
|
|
23
|
+
if (font) fonts.push(font);
|
|
24
|
+
}
|
|
25
|
+
return fonts.length > 0 ? { fonts } : void 0;
|
|
26
|
+
};
|
|
27
|
+
const parseFont = (element) => {
|
|
28
|
+
const name = getAttribute(element, "w", "name");
|
|
29
|
+
if (!name) return;
|
|
30
|
+
const font = { name };
|
|
31
|
+
assignValue(font, "altName", childValue(element, "altName"));
|
|
32
|
+
assignValue(font, "panose1", childValue(element, "panose1"));
|
|
33
|
+
assignValue(font, "charset", childValue(element, "charset"));
|
|
34
|
+
const family = childValue(element, "family");
|
|
35
|
+
if (family && isFontFamily(family)) font.family = family;
|
|
36
|
+
const pitch = childValue(element, "pitch");
|
|
37
|
+
if (pitch && isFontPitch(pitch)) font.pitch = pitch;
|
|
38
|
+
const sig = findChild(element, "w", "sig");
|
|
39
|
+
if (sig) {
|
|
40
|
+
const parsed = {};
|
|
41
|
+
assignSignatureValue(parsed, "usb0", getAttribute(sig, "w", "usb0") ?? void 0);
|
|
42
|
+
assignSignatureValue(parsed, "usb1", getAttribute(sig, "w", "usb1") ?? void 0);
|
|
43
|
+
assignSignatureValue(parsed, "usb2", getAttribute(sig, "w", "usb2") ?? void 0);
|
|
44
|
+
assignSignatureValue(parsed, "usb3", getAttribute(sig, "w", "usb3") ?? void 0);
|
|
45
|
+
assignSignatureValue(parsed, "csb0", getAttribute(sig, "w", "csb0") ?? void 0);
|
|
46
|
+
assignSignatureValue(parsed, "csb1", getAttribute(sig, "w", "csb1") ?? void 0);
|
|
47
|
+
if (Object.values(parsed).some((value) => value !== void 0)) font.sig = parsed;
|
|
48
|
+
}
|
|
49
|
+
assignValue(font, "embedRegular", relationshipId(element, "embedRegular"));
|
|
50
|
+
assignValue(font, "embedBold", relationshipId(element, "embedBold"));
|
|
51
|
+
assignValue(font, "embedItalic", relationshipId(element, "embedItalic"));
|
|
52
|
+
assignValue(font, "embedBoldItalic", relationshipId(element, "embedBoldItalic"));
|
|
53
|
+
return font;
|
|
54
|
+
};
|
|
55
|
+
const childValue = (element, name) => {
|
|
56
|
+
const child = findChild(element, "w", name);
|
|
57
|
+
return child ? getAttribute(child, "w", "val") ?? void 0 : void 0;
|
|
58
|
+
};
|
|
59
|
+
const relationshipId = (element, name) => {
|
|
60
|
+
const child = findChild(element, "w", name);
|
|
61
|
+
return child ? getAttribute(child, "r", "id") ?? void 0 : void 0;
|
|
62
|
+
};
|
|
63
|
+
const assignValue = (font, key, value) => {
|
|
64
|
+
if (value !== void 0) font[key] = value;
|
|
65
|
+
};
|
|
66
|
+
const assignSignatureValue = (signature, key, value) => {
|
|
67
|
+
if (value !== void 0) signature[key] = value;
|
|
68
|
+
};
|
|
69
|
+
const isFontFamily = (value) => FONT_FAMILIES.some((family) => family === value);
|
|
70
|
+
const isFontPitch = (value) => FONT_PITCHES.some((pitch) => pitch === value);
|
|
71
|
+
//#endregion
|
|
72
|
+
export { parseFontTable };
|
|
@@ -37,7 +37,10 @@ const colorFrom = (parent, fallback) => {
|
|
|
37
37
|
const value = getAttribute(parent, "w", "val");
|
|
38
38
|
if (value && HEX_COLOR.test(value)) return value.toUpperCase();
|
|
39
39
|
}
|
|
40
|
-
|
|
40
|
+
if (findChildByLocalName(parent, "noFill")) return "none";
|
|
41
|
+
const srgb = findChildByLocalName(findChildByLocalName(parent, "solidFill"), "srgbClr");
|
|
42
|
+
const referencedSrgb = findChildByLocalName(parent, "srgbClr");
|
|
43
|
+
const value = getAttribute(srgb ?? referencedSrgb, null, "val");
|
|
41
44
|
if (value && HEX_COLOR.test(value)) return value.toUpperCase();
|
|
42
45
|
return fallback;
|
|
43
46
|
};
|
|
@@ -80,9 +83,11 @@ const renderGeometry = (wsp) => {
|
|
|
80
83
|
const { x, y, width, height } = childTransform(wsp);
|
|
81
84
|
if (width <= 0 || height <= 0) return "";
|
|
82
85
|
const spPr = findChildByLocalName(wsp, "spPr");
|
|
86
|
+
const style = findChildByLocalName(wsp, "style");
|
|
87
|
+
const styleStroke = colorFrom(findChildByLocalName(style, "lnRef"), "none");
|
|
83
88
|
const fill = colorFrom(spPr, "none");
|
|
84
89
|
const line = findChildByLocalName(spPr, "ln");
|
|
85
|
-
const stroke = colorFrom(line,
|
|
90
|
+
const stroke = colorFrom(line, styleStroke);
|
|
86
91
|
const strokeWidth = line ? parseNumericAttribute(line, null, "w") ?? DEFAULT_LINE_WIDTH_EMU : 0;
|
|
87
92
|
const paths = findAllDeep(findChildByLocalName(spPr, "custGeom"), "a", "path");
|
|
88
93
|
if (paths.length === 0) return `<rect x="${x}" y="${y}" width="${width}" height="${height}" fill="${fill === "none" ? "none" : `#${fill}`}" stroke="${stroke === "none" ? "none" : `#${stroke}`}" stroke-width="${strokeWidth}"/>`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { collectXmlnsDeclarations, parseXml } from "./xmlParser.js";
|
|
2
2
|
import { parseWatermark } from "./watermarkParser.js";
|
|
3
3
|
import { parseFooterReference, parseFooterReferences, parseHeaderReference, parseHeaderReferences } from "./headerFooterRefParser.js";
|
|
4
|
-
import { assignHeaderFooterVerbatimXml } from "./headerFooterVerbatim.js";
|
|
5
4
|
import { parseBlockContent } from "./blockContentParser.js";
|
|
5
|
+
import { assignHeaderFooterVerbatimXml } from "./headerFooterVerbatim.js";
|
|
6
6
|
//#region src/docx/headerFooterParser.ts
|
|
7
7
|
/**
|
|
8
8
|
* Parse a header XML file (word/header*.xml)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { detectBaseDirection } from "../utils/baseDirection.js";
|
|
2
1
|
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
2
|
+
import { detectBaseDirection } from "../utils/baseDirection.js";
|
|
3
3
|
//#region src/docx/normalizeBaseDirection.ts
|
|
4
4
|
const runText = (run) => {
|
|
5
5
|
let text = "";
|
|
@@ -603,6 +603,7 @@ function computeListRendering(numPr, numbering) {
|
|
|
603
603
|
const markerFont = level.rPr?.fontFamily?.ascii || level.rPr?.fontFamily?.hAnsi;
|
|
604
604
|
if (markerFont) rendering.markerFontFamily = markerFont;
|
|
605
605
|
if (level.rPr?.fontSize) rendering.markerFontSize = level.rPr.fontSize / 2;
|
|
606
|
+
if (level.rPr?.bold !== void 0) rendering.markerBold = level.rPr.bold;
|
|
606
607
|
if (level.rPr?.allCaps) rendering.markerAllCaps = true;
|
|
607
608
|
if (level.lvlJc) rendering.markerAlignment = level.lvlJc;
|
|
608
609
|
if (level.suffix) rendering.markerSuffix = level.suffix;
|
|
@@ -164,12 +164,18 @@ function collectFirstParagraphPropertyChildren(pPr) {
|
|
|
164
164
|
case "keepNext":
|
|
165
165
|
children.keepNext ??= child;
|
|
166
166
|
break;
|
|
167
|
+
case "kinsoku":
|
|
168
|
+
children.kinsoku ??= child;
|
|
169
|
+
break;
|
|
167
170
|
case "numPr":
|
|
168
171
|
children.numPr ??= child;
|
|
169
172
|
break;
|
|
170
173
|
case "outlineLvl":
|
|
171
174
|
children.outlineLvl ??= child;
|
|
172
175
|
break;
|
|
176
|
+
case "overflowPunct":
|
|
177
|
+
children.overflowPunct ??= child;
|
|
178
|
+
break;
|
|
173
179
|
case "pageBreakBefore":
|
|
174
180
|
children.pageBreakBefore ??= child;
|
|
175
181
|
break;
|
|
@@ -226,6 +232,10 @@ function parseParagraphProperties(pPr, theme, styles) {
|
|
|
226
232
|
if (!pPr) return;
|
|
227
233
|
const formatting = {};
|
|
228
234
|
const propertyChildren = collectFirstParagraphPropertyChildren(pPr);
|
|
235
|
+
const kinsoku = propertyChildren.kinsoku;
|
|
236
|
+
if (kinsoku) formatting.kinsoku = parseBooleanElement(kinsoku);
|
|
237
|
+
const overflowPunct = propertyChildren.overflowPunct;
|
|
238
|
+
if (overflowPunct) formatting.overflowPunctuation = parseBooleanElement(overflowPunct);
|
|
229
239
|
const jc = propertyChildren.jc;
|
|
230
240
|
if (jc) {
|
|
231
241
|
const val = narrowEnum(getAttribute(jc, "w", "val"), ParagraphAlignmentSchema);
|
|
@@ -525,7 +535,7 @@ function isTrackedChangeWrapperChild(content) {
|
|
|
525
535
|
return content.type === "run" || content.type === "hyperlink";
|
|
526
536
|
}
|
|
527
537
|
function isInlineSdtContent(content) {
|
|
528
|
-
return content.type === "run" || content.type === "hyperlink" || content.type === "simpleField" || content.type === "complexField" || content.type === "inlineSdt" || content.type === "mathEquation";
|
|
538
|
+
return content.type === "run" || content.type === "hyperlink" || content.type === "simpleField" || content.type === "complexField" || content.type === "inlineSdt" || content.type === "insertion" || content.type === "deletion" || content.type === "mathEquation";
|
|
529
539
|
}
|
|
530
540
|
function pushTrackedChangeWrapper({ contents, type, info, content, preserveEmpty = false }) {
|
|
531
541
|
if (content.length === 0 && !preserveEmpty) return;
|
|
@@ -981,6 +991,7 @@ function parseParagraph(node, styles, theme, numbering, rels = null, media = nul
|
|
|
981
991
|
const markerFont = level.rPr?.fontFamily?.ascii || level.rPr?.fontFamily?.hAnsi;
|
|
982
992
|
if (markerFont) listRendering.markerFontFamily = markerFont;
|
|
983
993
|
if (level.rPr?.fontSize) listRendering.markerFontSize = level.rPr.fontSize / 2;
|
|
994
|
+
if (level.rPr?.bold !== void 0) listRendering.markerBold = level.rPr.bold;
|
|
984
995
|
if (level.rPr?.allCaps) listRendering.markerAllCaps = true;
|
|
985
996
|
if (level.lvlJc) listRendering.markerAlignment = level.lvlJc;
|
|
986
997
|
if (level.suffix) listRendering.markerSuffix = level.suffix;
|
package/dist/docx/parser.d.ts
CHANGED
package/dist/docx/parser.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
2
|
-
import { applyThemeFontLang, parseTheme } from "./themeParser.js";
|
|
3
|
-
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
4
|
-
import { DocxModelValidationError, formatDocumentModelIssues, validateFolioDocumentModel } from "./modelValidation.js";
|
|
5
|
-
import { parseNumbering } from "./numberingParser.js";
|
|
6
|
-
import { DocxEncryptionError } from "./encryption/errors.js";
|
|
7
|
-
import { getMediaMimeType, mediaToDataUrl, unzipDocx } from "./unzip.js";
|
|
8
|
-
import { parseComments } from "./commentParser.js";
|
|
9
|
-
import { parseFooter, parseHeader } from "./headerFooterParser.js";
|
|
10
1
|
import { toArrayBuffer } from "../utils/docxInput.js";
|
|
11
2
|
import { loadFontsWithMapping } from "../utils/fontLoader.js";
|
|
12
3
|
import { convertTiffToPngDataUrl, isTiffMimeType } from "../utils/tiffConverter.js";
|
|
4
|
+
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
5
|
+
import { applyThemeFontLang, parseTheme } from "./themeParser.js";
|
|
6
|
+
import { parseComments } from "./commentParser.js";
|
|
13
7
|
import { normalizeCommentReferences } from "./commentReferenceNormalization.js";
|
|
14
8
|
import { detectDocxConformanceClass } from "./conformance.js";
|
|
9
|
+
import { parseNumbering } from "./numberingParser.js";
|
|
15
10
|
import { extractAllTemplateVariables, parseDocumentBody } from "./documentParser.js";
|
|
11
|
+
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
12
|
+
import { parseFooter, parseHeader } from "./headerFooterParser.js";
|
|
16
13
|
import { normalizeHeaderFooterReferences } from "./headerFooterReferenceNormalization.js";
|
|
14
|
+
import { DocxModelValidationError, formatDocumentModelIssues, validateFolioDocumentModel } from "./modelValidation.js";
|
|
17
15
|
import { extractMetafileRaster, isMetafileMimeType } from "./metafileRaster.js";
|
|
16
|
+
import { parseFontTable } from "./fontTableParser.js";
|
|
18
17
|
import { normalizeNumberingReferences } from "./numberingReferenceNormalization.js";
|
|
19
18
|
import { parseSettings } from "./settingsParser.js";
|
|
20
19
|
import { parseStylesPackage } from "./styleParser.js";
|
|
21
20
|
import { normalizeTrackedMoveRanges } from "./trackedMoveRangeNormalization.js";
|
|
21
|
+
import { DocxEncryptionError } from "./encryption/errors.js";
|
|
22
|
+
import { getMediaMimeType, mediaToDataUrl, unzipDocx } from "./unzip.js";
|
|
22
23
|
import { TaggedError } from "better-result";
|
|
23
24
|
//#region src/docx/parser.ts
|
|
24
25
|
/**
|
|
@@ -84,6 +85,7 @@ async function parseDocx(input, options = {}) {
|
|
|
84
85
|
onProgress("Parsed styles", 30);
|
|
85
86
|
onProgress("Parsing numbering...", 30);
|
|
86
87
|
const numbering = timeStage("numbering", () => parseNumbering(raw.numberingXml));
|
|
88
|
+
const fontTable = timeStage("fontTable", () => parseFontTable(raw.fontTableXml));
|
|
87
89
|
onProgress("Parsed numbering", 35);
|
|
88
90
|
onProgress("Processing media files...", 35);
|
|
89
91
|
const media = await timeStageAsync("media", () => buildMediaMap(raw, rels));
|
|
@@ -174,6 +176,7 @@ async function parseDocx(input, options = {}) {
|
|
|
174
176
|
...styleDefinitions !== void 0 ? { styles: styleDefinitions } : {},
|
|
175
177
|
theme,
|
|
176
178
|
numbering: numbering.definitions,
|
|
179
|
+
...fontTable ? { fontTable } : {},
|
|
177
180
|
...headers !== void 0 ? { headers } : {},
|
|
178
181
|
...footers !== void 0 ? { footers } : {},
|
|
179
182
|
...footnotes !== void 0 ? { footnotes } : {},
|