ooxml-core 0.18.0 → 0.20.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/dist/automation/index.cjs +195 -193
- package/dist/automation/index.mjs +195 -193
- package/dist/diagram/index.cjs +2 -1
- package/dist/diagram/index.mjs +2 -1
- package/dist/docx/attr-units.d.ts +11 -0
- package/dist/docx/attr-units.d.ts.map +1 -0
- package/dist/docx/block-parser.d.ts.map +1 -1
- package/dist/docx/case-transform.d.ts +9 -0
- package/dist/docx/case-transform.d.ts.map +1 -0
- package/dist/docx/column-settings.d.ts +16 -0
- package/dist/docx/column-settings.d.ts.map +1 -0
- package/dist/docx/embedded.cjs +2 -1
- package/dist/docx/embedded.mjs +2 -1
- package/dist/docx/index.cjs +461 -3
- package/dist/docx/index.d.ts +8 -0
- package/dist/docx/index.d.ts.map +1 -1
- package/dist/docx/index.mjs +426 -4
- package/dist/docx/layout/adapter.d.ts.map +1 -1
- package/dist/docx/layout/table-layout.d.ts.map +1 -1
- package/dist/docx/line-spacing.d.ts +9 -0
- package/dist/docx/line-spacing.d.ts.map +1 -0
- package/dist/docx/load/index.cjs +2 -1
- package/dist/docx/load/index.mjs +2 -1
- package/dist/docx/page-setup-model.d.ts +29 -0
- package/dist/docx/page-setup-model.d.ts.map +1 -0
- package/dist/docx/page-size.d.ts +11 -0
- package/dist/docx/page-size.d.ts.map +1 -0
- package/dist/docx/parse.d.ts.map +1 -1
- package/dist/docx/section-edit.d.ts +19 -0
- package/dist/docx/section-edit.d.ts.map +1 -0
- package/dist/docx/section-layout.d.ts +14 -0
- package/dist/docx/section-layout.d.ts.map +1 -0
- package/dist/docx/tab-stops.d.ts.map +1 -1
- package/dist/docx/ui/backstage-focus.d.ts +6 -0
- package/dist/docx/ui/backstage-focus.d.ts.map +1 -0
- package/dist/docx/ui/break-note-schema.d.ts +11 -0
- package/dist/docx/ui/break-note-schema.d.ts.map +1 -0
- package/dist/docx/ui/collaboration-authority.d.ts +31 -0
- package/dist/docx/ui/collaboration-authority.d.ts.map +1 -0
- package/dist/docx/ui/collaboration-identity.d.ts +8 -0
- package/dist/docx/ui/collaboration-identity.d.ts.map +1 -0
- package/dist/docx/ui/collaboration-protocol.d.ts +25 -0
- package/dist/docx/ui/collaboration-protocol.d.ts.map +1 -0
- package/dist/docx/ui/collaboration.d.ts +30 -0
- package/dist/docx/ui/collaboration.d.ts.map +1 -0
- package/dist/docx/ui/defined.d.ts +3 -0
- package/dist/docx/ui/defined.d.ts.map +1 -0
- package/dist/docx/ui/dirty-state.d.ts +9 -0
- package/dist/docx/ui/dirty-state.d.ts.map +1 -0
- package/dist/docx/ui/field-guard.d.ts +21 -0
- package/dist/docx/ui/field-guard.d.ts.map +1 -0
- package/dist/docx/ui/header-footer-history.d.ts +15 -0
- package/dist/docx/ui/header-footer-history.d.ts.map +1 -0
- package/dist/docx/ui/index.cjs +2380 -0
- package/dist/docx/ui/index.d.ts +30 -0
- package/dist/docx/ui/index.d.ts.map +1 -0
- package/dist/docx/ui/index.mjs +2317 -0
- package/dist/docx/ui/inline-content-schema.d.ts +15 -0
- package/dist/docx/ui/inline-content-schema.d.ts.map +1 -0
- package/dist/docx/ui/ligature-style.d.ts +4 -0
- package/dist/docx/ui/ligature-style.d.ts.map +1 -0
- package/dist/docx/ui/node-numbering.d.ts +8 -0
- package/dist/docx/ui/node-numbering.d.ts.map +1 -0
- package/dist/docx/ui/review-schema.d.ts +90 -0
- package/dist/docx/ui/review-schema.d.ts.map +1 -0
- package/dist/docx/ui/ribbon-action-ids.d.ts +26 -0
- package/dist/docx/ui/ribbon-action-ids.d.ts.map +1 -0
- package/dist/docx/ui/ribbon-colors.d.ts +3 -0
- package/dist/docx/ui/ribbon-colors.d.ts.map +1 -0
- package/dist/docx/ui/ribbon-legacy-labels.d.ts +6 -0
- package/dist/docx/ui/ribbon-legacy-labels.d.ts.map +1 -0
- package/dist/docx/ui/run-compare.d.ts +5 -0
- package/dist/docx/ui/run-compare.d.ts.map +1 -0
- package/dist/docx/ui/run-extra-mark.d.ts +17 -0
- package/dist/docx/ui/run-extra-mark.d.ts.map +1 -0
- package/dist/docx/ui/schema-marks.d.ts +273 -0
- package/dist/docx/ui/schema-marks.d.ts.map +1 -0
- package/dist/docx/ui/smartart-theme.d.ts +21 -0
- package/dist/docx/ui/smartart-theme.d.ts.map +1 -0
- package/dist/docx/ui/table-render.d.ts +24 -0
- package/dist/docx/ui/table-render.d.ts.map +1 -0
- package/dist/docx/ui/table-visuals.d.ts +3 -0
- package/dist/docx/ui/table-visuals.d.ts.map +1 -0
- package/dist/docx/ui/theme/css-vars.d.ts +6 -0
- package/dist/docx/ui/theme/css-vars.d.ts.map +1 -0
- package/dist/docx/ui/theme/defaults.d.ts +12 -0
- package/dist/docx/ui/theme/defaults.d.ts.map +1 -0
- package/dist/docx/ui/theme/element.d.ts +9 -0
- package/dist/docx/ui/theme/element.d.ts.map +1 -0
- package/dist/docx/ui/theme/index.d.ts +5 -0
- package/dist/docx/ui/theme/index.d.ts.map +1 -0
- package/dist/docx/ui/theme/types.d.ts +42 -0
- package/dist/docx/ui/theme/types.d.ts.map +1 -0
- package/dist/docx/ui/word-count.d.ts +3 -0
- package/dist/docx/ui/word-count.d.ts.map +1 -0
- package/dist/docx/ui/zoom-fit.d.ts +16 -0
- package/dist/docx/ui/zoom-fit.d.ts.map +1 -0
- package/dist/docx/validate-paragraph.d.ts.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.mjs +2 -1
- package/dist/math/index.cjs +2 -1
- package/dist/math/index.mjs +2 -1
- package/dist/opc/index.cjs +2 -1
- package/dist/opc/index.mjs +2 -1
- package/dist/visio/index.cjs +2 -1
- package/dist/visio/index.mjs +2 -1
- package/dist/visio/ui/contract.d.ts +33 -0
- package/dist/visio/ui/contract.d.ts.map +1 -0
- package/dist/visio/ui/demo-document.d.ts +4 -0
- package/dist/visio/ui/demo-document.d.ts.map +1 -0
- package/dist/visio/ui/diagnostics.d.ts +10 -0
- package/dist/visio/ui/diagnostics.d.ts.map +1 -0
- package/dist/visio/ui/document-history.d.ts +43 -0
- package/dist/visio/ui/document-history.d.ts.map +1 -0
- package/dist/visio/ui/document-text-search.d.ts +45 -0
- package/dist/visio/ui/document-text-search.d.ts.map +1 -0
- package/dist/visio/ui/edit-commands.d.ts +4 -0
- package/dist/visio/ui/edit-commands.d.ts.map +1 -0
- package/dist/visio/ui/edit-error.d.ts +5 -0
- package/dist/visio/ui/edit-error.d.ts.map +1 -0
- package/dist/visio/ui/foreign-vector-budget.d.ts +25 -0
- package/dist/visio/ui/foreign-vector-budget.d.ts.map +1 -0
- package/dist/visio/ui/index.cjs +1523 -0
- package/dist/visio/ui/index.d.ts +12 -0
- package/dist/visio/ui/index.d.ts.map +1 -0
- package/dist/visio/ui/index.mjs +1498 -0
- package/dist/visio/ui/scene-details.d.ts +8 -0
- package/dist/visio/ui/scene-details.d.ts.map +1 -0
- package/dist/visio/ui/scene-validation.d.ts +5 -0
- package/dist/visio/ui/scene-validation.d.ts.map +1 -0
- package/dist/visio/ui/snapshot-scene.d.ts +9 -0
- package/dist/visio/ui/snapshot-scene.d.ts.map +1 -0
- package/dist/xlsx/index.cjs +100 -98
- package/dist/xlsx/index.mjs +100 -98
- package/dist/xlsx/load/index.cjs +68 -66
- package/dist/xlsx/load/index.mjs +68 -66
- package/dist/xlsx/ui/backstage/templates.d.ts +16 -0
- package/dist/xlsx/ui/backstage/templates.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/alignment.d.ts +4 -0
- package/dist/xlsx/ui/commands/alignment.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/cells.d.ts +3 -0
- package/dist/xlsx/ui/commands/cells.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/cf-presets.d.ts +15 -0
- package/dist/xlsx/ui/commands/cf-presets.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/clipboard.d.ts +22 -0
- package/dist/xlsx/ui/commands/clipboard.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/contextual.d.ts +13 -0
- package/dist/xlsx/ui/commands/contextual.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/data.d.ts +3 -0
- package/dist/xlsx/ui/commands/data.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/editing.d.ts +13 -0
- package/dist/xlsx/ui/commands/editing.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/font.d.ts +21 -0
- package/dist/xlsx/ui/commands/font.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/formulas.d.ts +15 -0
- package/dist/xlsx/ui/commands/formulas.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/core-features.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/core-features.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/format-cells.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/format-cells.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/index.d.ts +4 -0
- package/dist/xlsx/ui/commands/i18n/index.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/messages.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/messages.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/ribbon-home.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/ribbon-home.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/ribbon-tabs.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/ribbon-tabs.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/rules.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/rules.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/tools.d.ts +3 -0
- package/dist/xlsx/ui/commands/i18n/tools.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/i18n/types.d.ts +5 -0
- package/dist/xlsx/ui/commands/i18n/types.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/icons.d.ts +4 -0
- package/dist/xlsx/ui/commands/icons.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/number.d.ts +11 -0
- package/dist/xlsx/ui/commands/number.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/page-layout.d.ts +10 -0
- package/dist/xlsx/ui/commands/page-layout.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/select-special.d.ts +12 -0
- package/dist/xlsx/ui/commands/select-special.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/sort-filter.d.ts +3 -0
- package/dist/xlsx/ui/commands/sort-filter.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/style-presets.d.ts +21 -0
- package/dist/xlsx/ui/commands/style-presets.d.ts.map +1 -0
- package/dist/xlsx/ui/commands/util.d.ts +59 -0
- package/dist/xlsx/ui/commands/util.d.ts.map +1 -0
- package/dist/xlsx/ui/commands.d.ts +36 -0
- package/dist/xlsx/ui/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/context-menu/items.d.ts +36 -0
- package/dist/xlsx/ui/context-menu/items.d.ts.map +1 -0
- package/dist/xlsx/ui/context.d.ts +65 -0
- package/dist/xlsx/ui/context.d.ts.map +1 -0
- package/dist/xlsx/ui/dialogs/format-cells/number-categories.d.ts +28 -0
- package/dist/xlsx/ui/dialogs/format-cells/number-categories.d.ts.map +1 -0
- package/dist/xlsx/ui/dialogs/format-cells/types.d.ts +40 -0
- package/dist/xlsx/ui/dialogs/format-cells/types.d.ts.map +1 -0
- package/dist/xlsx/ui/dialogs/insert-chart-model.d.ts +9 -0
- package/dist/xlsx/ui/dialogs/insert-chart-model.d.ts.map +1 -0
- package/dist/xlsx/ui/dialogs.d.ts +9 -0
- package/dist/xlsx/ui/dialogs.d.ts.map +1 -0
- package/dist/xlsx/ui/dirty-state.d.ts +9 -0
- package/dist/xlsx/ui/dirty-state.d.ts.map +1 -0
- package/dist/xlsx/ui/formula-bar/name-resolve.d.ts +23 -0
- package/dist/xlsx/ui/formula-bar/name-resolve.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/cell-items.d.ts +42 -0
- package/dist/xlsx/ui/grid/cell-items.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/cell-paint.d.ts +26 -0
- package/dist/xlsx/ui/grid/cell-paint.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/edit-bridge.d.ts +47 -0
- package/dist/xlsx/ui/grid/edit-bridge.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/geometry.d.ts +76 -0
- package/dist/xlsx/ui/grid/geometry.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/icon-sets.d.ts +3 -0
- package/dist/xlsx/ui/grid/icon-sets.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/number-fit.d.ts +3 -0
- package/dist/xlsx/ui/grid/number-fit.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/selection-ops.d.ts +32 -0
- package/dist/xlsx/ui/grid/selection-ops.d.ts.map +1 -0
- package/dist/xlsx/ui/grid/view-cache.d.ts +15 -0
- package/dist/xlsx/ui/grid/view-cache.d.ts.map +1 -0
- package/dist/xlsx/ui/index.cjs +28484 -0
- package/dist/xlsx/ui/index.d.ts +56 -0
- package/dist/xlsx/ui/index.d.ts.map +1 -0
- package/dist/xlsx/ui/index.mjs +28290 -0
- package/dist/xlsx/ui/locales/de/commands.d.ts +2 -0
- package/dist/xlsx/ui/locales/de/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/de/grid.d.ts +2 -0
- package/dist/xlsx/ui/locales/de/grid.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/de/index.d.ts +2 -0
- package/dist/xlsx/ui/locales/de/index.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/de/shell.d.ts +2 -0
- package/dist/xlsx/ui/locales/de/shell.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/en/commands.d.ts +2 -0
- package/dist/xlsx/ui/locales/en/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/en/grid.d.ts +2 -0
- package/dist/xlsx/ui/locales/en/grid.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/en/index.d.ts +2 -0
- package/dist/xlsx/ui/locales/en/index.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/en/shell.d.ts +2 -0
- package/dist/xlsx/ui/locales/en/shell.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/es/commands.d.ts +2 -0
- package/dist/xlsx/ui/locales/es/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/es/grid.d.ts +2 -0
- package/dist/xlsx/ui/locales/es/grid.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/es/index.d.ts +2 -0
- package/dist/xlsx/ui/locales/es/index.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/es/shell.d.ts +2 -0
- package/dist/xlsx/ui/locales/es/shell.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/fr/commands.d.ts +2 -0
- package/dist/xlsx/ui/locales/fr/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/fr/grid.d.ts +2 -0
- package/dist/xlsx/ui/locales/fr/grid.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/fr/index.d.ts +2 -0
- package/dist/xlsx/ui/locales/fr/index.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/fr/shell.d.ts +2 -0
- package/dist/xlsx/ui/locales/fr/shell.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/merge.d.ts +7 -0
- package/dist/xlsx/ui/locales/merge.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/zh-CN/commands.d.ts +2 -0
- package/dist/xlsx/ui/locales/zh-CN/commands.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/zh-CN/grid.d.ts +2 -0
- package/dist/xlsx/ui/locales/zh-CN/grid.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/zh-CN/index.d.ts +2 -0
- package/dist/xlsx/ui/locales/zh-CN/index.d.ts.map +1 -0
- package/dist/xlsx/ui/locales/zh-CN/shell.d.ts +2 -0
- package/dist/xlsx/ui/locales/zh-CN/shell.d.ts.map +1 -0
- package/dist/xlsx/ui/localization.d.ts +23 -0
- package/dist/xlsx/ui/localization.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/icon-paths.d.ts +9 -0
- package/dist/xlsx/ui/ribbon/icon-paths.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/parts.d.ts +88 -0
- package/dist/xlsx/ui/ribbon/parts.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/tab-api.d.ts +21 -0
- package/dist/xlsx/ui/ribbon/tab-api.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/tabs/review-view.d.ts +5 -0
- package/dist/xlsx/ui/ribbon/tabs/review-view.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/tabs/theme-palette.d.ts +8 -0
- package/dist/xlsx/ui/ribbon/tabs/theme-palette.d.ts.map +1 -0
- package/dist/xlsx/ui/ribbon/tell-me.d.ts +16 -0
- package/dist/xlsx/ui/ribbon/tell-me.d.ts.map +1 -0
- package/dist/xlsx/ui/selection.d.ts +34 -0
- package/dist/xlsx/ui/selection.d.ts.map +1 -0
- package/dist/xlsx/ui/theme/css-vars.d.ts +6 -0
- package/dist/xlsx/ui/theme/css-vars.d.ts.map +1 -0
- package/dist/xlsx/ui/theme/defaults.d.ts +6 -0
- package/dist/xlsx/ui/theme/defaults.d.ts.map +1 -0
- package/dist/xlsx/ui/theme/element.d.ts +9 -0
- package/dist/xlsx/ui/theme/element.d.ts.map +1 -0
- package/dist/xlsx/ui/theme/types.d.ts +54 -0
- package/dist/xlsx/ui/theme/types.d.ts.map +1 -0
- package/dist/xml/index.cjs +2 -1
- package/dist/xml/index.mjs +2 -1
- package/package.json +30 -3
package/dist/diagram/index.cjs
CHANGED
|
@@ -151,7 +151,8 @@ function parseXml(xml, options = {}) {
|
|
|
151
151
|
}).parseFromString(xml, "application/xml");
|
|
152
152
|
} catch (error) {
|
|
153
153
|
throw new Error(
|
|
154
|
-
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}
|
|
154
|
+
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
155
|
+
{ cause: error }
|
|
155
156
|
);
|
|
156
157
|
}
|
|
157
158
|
if (parseError || !parsed.documentElement)
|
package/dist/diagram/index.mjs
CHANGED
|
@@ -149,7 +149,8 @@ function parseXml(xml, options = {}) {
|
|
|
149
149
|
}).parseFromString(xml, "application/xml");
|
|
150
150
|
} catch (error) {
|
|
151
151
|
throw new Error(
|
|
152
|
-
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}
|
|
152
|
+
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
153
|
+
{ cause: error }
|
|
153
154
|
);
|
|
154
155
|
}
|
|
155
156
|
if (parseError || !parsed.documentElement)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SignedTwips, type Twips } from '../units/units.js';
|
|
2
|
+
import type { Paragraph } from './model-paragraph.js';
|
|
3
|
+
/** A non-negative twip attribute as `Twips`, or undefined when absent or not a valid length. */
|
|
4
|
+
export declare function twipsAttr(value: unknown): Twips | undefined;
|
|
5
|
+
/** A possibly negative twip attribute as `SignedTwips`, or undefined when absent or not finite. */
|
|
6
|
+
export declare function signedTwipsAttr(value: unknown): SignedTwips | undefined;
|
|
7
|
+
type ParagraphTwips = Pick<Paragraph, 'spacingBeforeTwips' | 'spacingAfterTwips' | 'lineSpacingTwips' | 'indentLeftTwips' | 'indentRightTwips' | 'indentStartTwips' | 'indentEndTwips' | 'firstLineTwips' | 'hangingTwips'>;
|
|
8
|
+
/** The paragraph's direct spacing and indent attributes as model fields; absent ones are omitted. */
|
|
9
|
+
export declare function paragraphTwipsFromAttrs(attrs: Record<string, unknown>): ParagraphTwips;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=attr-units.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attr-units.d.ts","sourceRoot":"","sources":["../../src/docx/attr-units.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/F,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKtD,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAI3D;AACD,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAEvE;AAED,KAAK,cAAc,GAAG,IAAI,CACzB,SAAS,EACP,oBAAoB,GACpB,mBAAmB,GACnB,kBAAkB,GAClB,iBAAiB,GACjB,kBAAkB,GAClB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,CAChB,CAAC;AACF,qGAAqG;AACrG,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAqBtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-parser.d.ts","sourceRoot":"","sources":["../../src/docx/block-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAY,KAAK,
|
|
1
|
+
{"version":3,"file":"block-parser.d.ts","sourceRoot":"","sources":["../../src/docx/block-parser.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAY,KAAK,EAAW,MAAM,YAAY,CAAC;AAC7E,OAAO,EAMN,KAAK,UAAU,EACf,MAAM,UAAU,CAAC;AAIlB,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAsIjE,iBAAS,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,SAAS,CA0G/D;AAED,iBAAS,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,KAAK,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACvC,SAAS,EAAE,UAAU,EACrB,QAAQ,SAAK,EACb,OAAO,CAAC,EAAE,cAAc,GACtB,KAAK,EAAE,CAcT;AAYD,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type CaseMode = 'sentence' | 'lower' | 'upper' | 'title' | 'toggle';
|
|
2
|
+
/** Characters that make up a word, shared with the editor's caret-word lookup. */
|
|
3
|
+
export declare const WORD: RegExp;
|
|
4
|
+
/**
|
|
5
|
+
* Applies a Word "Change Case" mode to `text`. `atSentenceStart` says whether the text begins a
|
|
6
|
+
* sentence; it matters only for sentence case, which capitalises the first letter after `. ! ?`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function transformCase(text: string, mode: CaseMode, atSentenceStart?: boolean): string;
|
|
9
|
+
//# sourceMappingURL=case-transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"case-transform.d.ts","sourceRoot":"","sources":["../../src/docx/case-transform.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,CAAC;AAE3E,kFAAkF;AAClF,eAAO,MAAM,IAAI,QAAoB,CAAC;AAOtC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,eAAe,UAAO,GAAG,MAAM,CAsB1F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SectionColumns, SectionProperties } from './section-model.js';
|
|
2
|
+
export declare const columnTextWidth: (section: SectionProperties) => number;
|
|
3
|
+
/** Word's Left/Right presets reserve one third of the text width for the narrow column. */
|
|
4
|
+
export declare function unequalColumnPreset(section: SectionProperties, preset: 'left' | 'right'): SectionColumns;
|
|
5
|
+
export declare function columnPreset(columns: SectionColumns): string;
|
|
6
|
+
export interface ColumnDraft {
|
|
7
|
+
widths: number[];
|
|
8
|
+
gaps: number[];
|
|
9
|
+
}
|
|
10
|
+
export declare function equalColumnDraft(total: number, count: number, gap: number): ColumnDraft;
|
|
11
|
+
export declare function readColumnDraft(section: SectionProperties): ColumnDraft;
|
|
12
|
+
/** Keep the overall text width fixed by taking the difference from the adjacent column. */
|
|
13
|
+
export declare function changeColumnWidth(draft: ColumnDraft, index: number, width: number): void;
|
|
14
|
+
export declare function changeColumnGap(draft: ColumnDraft, index: number, gap: number): void;
|
|
15
|
+
export declare function validColumnDraft(draft: ColumnDraft, total: number): boolean;
|
|
16
|
+
//# sourceMappingURL=column-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"column-settings.d.ts","sourceRoot":"","sources":["../../src/docx/column-settings.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5E,eAAO,MAAM,eAAe,YAAa,iBAAiB,KAAG,MAIlC,CAAC;AAE5B,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,MAAM,GAAG,OAAO,GACtB,cAAc,CAchB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAQ5D;AAED,MAAM,WAAW,WAAW;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CACf;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,WAAW,CAQvF;AACD,wBAAgB,eAAe,CAAC,OAAO,EAAE,iBAAiB,GAAG,WAAW,CAgBvE;AACD,2FAA2F;AAC3F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAKxF;AACD,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAIpF;AACD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAM3E"}
|
package/dist/docx/embedded.cjs
CHANGED
|
@@ -37,7 +37,8 @@ function parseXml(xml, options = {}) {
|
|
|
37
37
|
}).parseFromString(xml, "application/xml");
|
|
38
38
|
} catch (error) {
|
|
39
39
|
throw new Error(
|
|
40
|
-
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}
|
|
40
|
+
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
41
|
+
{ cause: error }
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
if (parseError || !parsed.documentElement)
|
package/dist/docx/embedded.mjs
CHANGED
|
@@ -31,7 +31,8 @@ function parseXml(xml, options = {}) {
|
|
|
31
31
|
}).parseFromString(xml, "application/xml");
|
|
32
32
|
} catch (error) {
|
|
33
33
|
throw new Error(
|
|
34
|
-
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}
|
|
34
|
+
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
35
|
+
{ cause: error }
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
if (parseError || !parsed.documentElement)
|
package/dist/docx/index.cjs
CHANGED
|
@@ -37,7 +37,8 @@ function parseXml(xml, options = {}) {
|
|
|
37
37
|
}).parseFromString(xml, "application/xml");
|
|
38
38
|
} catch (error) {
|
|
39
39
|
throw new Error(
|
|
40
|
-
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}
|
|
40
|
+
`Invalid ${label} XML: ${error instanceof Error ? error.message : String(error)}`,
|
|
41
|
+
{ cause: error }
|
|
41
42
|
);
|
|
42
43
|
}
|
|
43
44
|
if (parseError || !parsed.documentElement)
|
|
@@ -515,7 +516,7 @@ var twipsFromPoints = (points) => roundTwips(points * 20);
|
|
|
515
516
|
var signedTwipsFromPoints = (points) => roundSignedTwips(points * 20);
|
|
516
517
|
var twipsFromPixels = (pixels) => roundTwips(pixels * 15);
|
|
517
518
|
var signedTwipsFromPixels = (pixels) => roundSignedTwips(pixels * 15);
|
|
518
|
-
var twipsFromInches = (
|
|
519
|
+
var twipsFromInches = (inches2) => roundTwips(inches2 * 1440);
|
|
519
520
|
var halfPointsFromPoints = (points) => roundHalfPoints(points * 2);
|
|
520
521
|
var eighthPointsFromPoints = (points) => roundEighthPoints(points * 8);
|
|
521
522
|
var emuFromPixels = (pixels) => roundEmu(pixels * 9525);
|
|
@@ -3673,7 +3674,7 @@ var add = (parent, ...items) => {
|
|
|
3673
3674
|
for (const item of items) parent.appendChild(item);
|
|
3674
3675
|
return parent;
|
|
3675
3676
|
};
|
|
3676
|
-
var emu2 = (
|
|
3677
|
+
var emu2 = (px3) => String(Math.max(1, Math.round(px3 * EMU_PER_PIXEL)));
|
|
3677
3678
|
var descendants = (root, ns, local) => Array.from(root.getElementsByTagNameNS(ns, local));
|
|
3678
3679
|
function paragraphsFor(doc, lines) {
|
|
3679
3680
|
return (lines.length ? lines : [""]).map((line) => {
|
|
@@ -9663,6 +9664,427 @@ function plainText2(model) {
|
|
|
9663
9664
|
).join("\n");
|
|
9664
9665
|
}
|
|
9665
9666
|
|
|
9667
|
+
// src/docx/column-settings.ts
|
|
9668
|
+
var columnTextWidth = (section) => section.pageWidthTwips - section.marginLeftTwips - section.marginRightTwips - (section.gutterTwips ?? 0);
|
|
9669
|
+
function unequalColumnPreset(section, preset) {
|
|
9670
|
+
const gap = 720;
|
|
9671
|
+
const available = columnTextWidth(section) - gap;
|
|
9672
|
+
const narrow = Math.round(available / 3);
|
|
9673
|
+
const wide = available - narrow;
|
|
9674
|
+
return {
|
|
9675
|
+
count: 2,
|
|
9676
|
+
equalWidth: false,
|
|
9677
|
+
spacingTwips: twips(gap),
|
|
9678
|
+
widths: [
|
|
9679
|
+
{ widthTwips: twips(preset === "left" ? narrow : wide), spacingTwips: twips(gap) },
|
|
9680
|
+
{ widthTwips: twips(preset === "left" ? wide : narrow) }
|
|
9681
|
+
]
|
|
9682
|
+
};
|
|
9683
|
+
}
|
|
9684
|
+
function columnPreset(columns) {
|
|
9685
|
+
if (columns.equalWidth) return String(columns.count);
|
|
9686
|
+
const [a, b] = columns.widths ?? [];
|
|
9687
|
+
if (columns.count === 2 && a && b) {
|
|
9688
|
+
if (Math.abs(a.widthTwips * 2 - b.widthTwips) <= 2) return "left";
|
|
9689
|
+
if (Math.abs(b.widthTwips * 2 - a.widthTwips) <= 2) return "right";
|
|
9690
|
+
}
|
|
9691
|
+
return "";
|
|
9692
|
+
}
|
|
9693
|
+
function equalColumnDraft(total, count, gap) {
|
|
9694
|
+
const width = Math.floor((total - gap * (count - 1)) / count);
|
|
9695
|
+
return {
|
|
9696
|
+
widths: Array.from(
|
|
9697
|
+
{ length: count },
|
|
9698
|
+
(_, i) => i === count - 1 ? total - gap * (count - 1) - width * (count - 1) : width
|
|
9699
|
+
),
|
|
9700
|
+
gaps: Array.from({ length: count }, (_, i) => i === count - 1 ? 0 : gap)
|
|
9701
|
+
};
|
|
9702
|
+
}
|
|
9703
|
+
function readColumnDraft(section) {
|
|
9704
|
+
const fallback = equalColumnDraft(
|
|
9705
|
+
columnTextWidth(section),
|
|
9706
|
+
section.columns.count,
|
|
9707
|
+
section.columns.spacingTwips ?? 720
|
|
9708
|
+
);
|
|
9709
|
+
return !section.columns.equalWidth && section.columns.widths?.length === section.columns.count ? {
|
|
9710
|
+
widths: section.columns.widths.map((column) => column.widthTwips),
|
|
9711
|
+
gaps: section.columns.widths.map(
|
|
9712
|
+
(column, i) => i === section.columns.count - 1 ? 0 : column.spacingTwips ?? section.columns.spacingTwips ?? 720
|
|
9713
|
+
)
|
|
9714
|
+
} : fallback;
|
|
9715
|
+
}
|
|
9716
|
+
function changeColumnWidth(draft, index, width) {
|
|
9717
|
+
const delta = width - draft.widths[index];
|
|
9718
|
+
draft.widths[index] = width;
|
|
9719
|
+
const neighbor = index < draft.widths.length - 1 ? index + 1 : index - 1;
|
|
9720
|
+
if (neighbor >= 0) draft.widths[neighbor] = draft.widths[neighbor] - delta;
|
|
9721
|
+
}
|
|
9722
|
+
function changeColumnGap(draft, index, gap) {
|
|
9723
|
+
const delta = gap - draft.gaps[index];
|
|
9724
|
+
draft.gaps[index] = gap;
|
|
9725
|
+
if (index + 1 < draft.widths.length) draft.widths[index + 1] = draft.widths[index + 1] - delta;
|
|
9726
|
+
}
|
|
9727
|
+
function validColumnDraft(draft, total) {
|
|
9728
|
+
return draft.widths.every((width) => Number.isSafeInteger(width) && width >= 720) && draft.gaps.every((gap) => Number.isSafeInteger(gap) && gap >= 0) && Math.abs(draft.widths.reduce((sum, value, i) => sum + value + draft.gaps[i], 0) - total) <= 1;
|
|
9729
|
+
}
|
|
9730
|
+
|
|
9731
|
+
// src/docx/line-spacing.ts
|
|
9732
|
+
var lineSpacingOptions = [
|
|
9733
|
+
["inherit", "Line: style default"],
|
|
9734
|
+
["auto:240", "1.0 lines"],
|
|
9735
|
+
["auto:276", "1.15 lines"],
|
|
9736
|
+
["auto:360", "1.5 lines"],
|
|
9737
|
+
["auto:480", "2.0 lines"],
|
|
9738
|
+
["auto:600", "2.5 lines"],
|
|
9739
|
+
["auto:720", "3.0 lines"]
|
|
9740
|
+
];
|
|
9741
|
+
function lineSpacingValue(attrs) {
|
|
9742
|
+
const rule = attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? attrs.lineSpacingRule : "auto";
|
|
9743
|
+
if (!Number.isSafeInteger(attrs.lineSpacingTwips))
|
|
9744
|
+
return attrs.lineSpacingRule === "exact" || attrs.lineSpacingRule === "atLeast" ? `rule-only:${attrs.lineSpacingRule}` : "inherit";
|
|
9745
|
+
return `${rule}:${Number(attrs.lineSpacingTwips)}`;
|
|
9746
|
+
}
|
|
9747
|
+
function lineSpacingLabel(value) {
|
|
9748
|
+
if (value === "inherit") return "Style default";
|
|
9749
|
+
const ruleOnly = /^rule-only:(exact|atLeast)$/.exec(value);
|
|
9750
|
+
if (ruleOnly) return `${ruleOnly[1] === "exact" ? "Exact" : "At least"} rule (no amount)`;
|
|
9751
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9752
|
+
if (!match) return "Mixed paragraphs";
|
|
9753
|
+
const [, rule, rawTwips] = match;
|
|
9754
|
+
const twips3 = Number(rawTwips);
|
|
9755
|
+
if (rule === "auto") {
|
|
9756
|
+
const ratios = {
|
|
9757
|
+
240: "1.0",
|
|
9758
|
+
276: "1.15",
|
|
9759
|
+
360: "1.5",
|
|
9760
|
+
480: "2.0",
|
|
9761
|
+
600: "2.5",
|
|
9762
|
+
720: "3.0"
|
|
9763
|
+
};
|
|
9764
|
+
return ratios[twips3] ? `${ratios[twips3]} lines` : `Automatic ${(twips3 / 240).toLocaleString(void 0, { maximumFractionDigits: 3 })} lines (${twips3}/240)`;
|
|
9765
|
+
}
|
|
9766
|
+
const points = (twips3 / 20).toLocaleString(void 0, { maximumFractionDigits: 2 });
|
|
9767
|
+
return `${rule === "exact" ? "Exact" : "At least"} ${points} pt`;
|
|
9768
|
+
}
|
|
9769
|
+
function parseLineSpacingValue(value) {
|
|
9770
|
+
const match = /^(auto|exact|atLeast):(\d+)$/.exec(value);
|
|
9771
|
+
if (!match) return null;
|
|
9772
|
+
const twips3 = Number(match[2]);
|
|
9773
|
+
return Number.isSafeInteger(twips3) && twips3 >= 0 ? { rule: match[1], twips: twips3 } : null;
|
|
9774
|
+
}
|
|
9775
|
+
|
|
9776
|
+
// src/docx/section-layout.ts
|
|
9777
|
+
function sectionLayoutJson(sections) {
|
|
9778
|
+
return JSON.stringify(
|
|
9779
|
+
sections.map(({ headers: _headers, footers: _footers, ...layout2 }) => layout2)
|
|
9780
|
+
);
|
|
9781
|
+
}
|
|
9782
|
+
function sectionsFromLayout(json, prior, blocks) {
|
|
9783
|
+
const layout2 = JSON.parse(json);
|
|
9784
|
+
const order = new Map(blocks.map((block, index) => [block.id, index]));
|
|
9785
|
+
const priorSections = prior ?? [];
|
|
9786
|
+
const endOf = (section, index, list) => index === list.length - 1 ? Number.POSITIVE_INFINITY : order.get(section.endsAtBlockId) ?? -1;
|
|
9787
|
+
const kept = layout2.filter(
|
|
9788
|
+
(section, index) => index === layout2.length - 1 || order.has(section.endsAtBlockId)
|
|
9789
|
+
);
|
|
9790
|
+
return kept.map((section, index) => {
|
|
9791
|
+
const end = endOf(section, index, kept);
|
|
9792
|
+
const source = priorSections.find((candidate) => candidate.endsAtBlockId === section.endsAtBlockId) ?? priorSections.find(
|
|
9793
|
+
(candidate, position) => endOf(candidate, position, priorSections) >= end
|
|
9794
|
+
) ?? priorSections.at(-1);
|
|
9795
|
+
return {
|
|
9796
|
+
...section,
|
|
9797
|
+
...source?.headers ? { headers: source.headers } : {},
|
|
9798
|
+
...source?.footers ? { footers: source.footers } : {}
|
|
9799
|
+
};
|
|
9800
|
+
});
|
|
9801
|
+
}
|
|
9802
|
+
function sectionsOf(model) {
|
|
9803
|
+
if (model.sections?.length) return model.sections;
|
|
9804
|
+
const { page } = model;
|
|
9805
|
+
return [
|
|
9806
|
+
{
|
|
9807
|
+
endsAtBlockId: model.blocks.at(-1)?.id ?? "",
|
|
9808
|
+
type: "nextPage",
|
|
9809
|
+
pageWidthTwips: twipsFromPixels(page.width),
|
|
9810
|
+
pageHeightTwips: twipsFromPixels(page.height),
|
|
9811
|
+
orientation: page.width > page.height ? "landscape" : "portrait",
|
|
9812
|
+
marginTopTwips: signedTwipsFromPixels(page.marginTop),
|
|
9813
|
+
marginRightTwips: twipsFromPixels(page.marginRight),
|
|
9814
|
+
marginBottomTwips: signedTwipsFromPixels(page.marginBottom),
|
|
9815
|
+
marginLeftTwips: twipsFromPixels(page.marginLeft),
|
|
9816
|
+
headerDistanceTwips: twips(720),
|
|
9817
|
+
footerDistanceTwips: twips(720),
|
|
9818
|
+
gutterTwips: twips(0),
|
|
9819
|
+
columns: { count: 1, spacingTwips: twips(720), equalWidth: true }
|
|
9820
|
+
}
|
|
9821
|
+
];
|
|
9822
|
+
}
|
|
9823
|
+
|
|
9824
|
+
// src/docx/attr-units.ts
|
|
9825
|
+
function twipsAttr(value) {
|
|
9826
|
+
return typeof value === "number" && Number.isFinite(value) && value >= 0 ? roundTwips(value) : void 0;
|
|
9827
|
+
}
|
|
9828
|
+
function signedTwipsAttr(value) {
|
|
9829
|
+
return typeof value === "number" && Number.isFinite(value) ? roundSignedTwips(value) : void 0;
|
|
9830
|
+
}
|
|
9831
|
+
function paragraphTwipsFromAttrs(attrs) {
|
|
9832
|
+
const result = {};
|
|
9833
|
+
const spacingBefore = twipsAttr(attrs.spacingBeforeTwips);
|
|
9834
|
+
const spacingAfter = twipsAttr(attrs.spacingAfterTwips);
|
|
9835
|
+
const lineSpacing = signedTwipsAttr(attrs.lineSpacingTwips);
|
|
9836
|
+
const left = signedTwipsAttr(attrs.indentLeftTwips);
|
|
9837
|
+
const right = signedTwipsAttr(attrs.indentRightTwips);
|
|
9838
|
+
const start = signedTwipsAttr(attrs.indentStartTwips);
|
|
9839
|
+
const end = signedTwipsAttr(attrs.indentEndTwips);
|
|
9840
|
+
const firstLine = twipsAttr(attrs.firstLineTwips);
|
|
9841
|
+
const hanging = twipsAttr(attrs.hangingTwips);
|
|
9842
|
+
if (spacingBefore !== void 0) result.spacingBeforeTwips = spacingBefore;
|
|
9843
|
+
if (spacingAfter !== void 0) result.spacingAfterTwips = spacingAfter;
|
|
9844
|
+
if (lineSpacing !== void 0) result.lineSpacingTwips = lineSpacing;
|
|
9845
|
+
if (left !== void 0) result.indentLeftTwips = left;
|
|
9846
|
+
if (right !== void 0) result.indentRightTwips = right;
|
|
9847
|
+
if (start !== void 0) result.indentStartTwips = start;
|
|
9848
|
+
if (end !== void 0) result.indentEndTwips = end;
|
|
9849
|
+
if (firstLine !== void 0) result.firstLineTwips = firstLine;
|
|
9850
|
+
if (hanging !== void 0) result.hangingTwips = hanging;
|
|
9851
|
+
return result;
|
|
9852
|
+
}
|
|
9853
|
+
|
|
9854
|
+
// src/docx/case-transform.ts
|
|
9855
|
+
var WORD = /[\p{L}\p{N}'’]/u;
|
|
9856
|
+
var swap = (char) => {
|
|
9857
|
+
const upper = char.toLocaleUpperCase();
|
|
9858
|
+
return char === upper ? char.toLocaleLowerCase() : upper;
|
|
9859
|
+
};
|
|
9860
|
+
function transformCase(text, mode, atSentenceStart = true) {
|
|
9861
|
+
if (mode === "lower") return text.toLocaleLowerCase();
|
|
9862
|
+
if (mode === "upper") return text.toLocaleUpperCase();
|
|
9863
|
+
if (mode === "toggle") return [...text].map(swap).join("");
|
|
9864
|
+
let start = mode === "sentence" ? atSentenceStart : true;
|
|
9865
|
+
let previousWord = false;
|
|
9866
|
+
let out = "";
|
|
9867
|
+
for (const char of text) {
|
|
9868
|
+
const isWord = WORD.test(char);
|
|
9869
|
+
if (mode === "title") {
|
|
9870
|
+
out += isWord && !previousWord ? char.toLocaleUpperCase() : char;
|
|
9871
|
+
} else if (isWord && start) {
|
|
9872
|
+
out += char.toLocaleUpperCase();
|
|
9873
|
+
start = false;
|
|
9874
|
+
} else {
|
|
9875
|
+
out += isWord ? char.toLocaleLowerCase() : char;
|
|
9876
|
+
if (/[.!?]/.test(char)) start = true;
|
|
9877
|
+
else if (isWord) start = false;
|
|
9878
|
+
}
|
|
9879
|
+
previousWord = isWord;
|
|
9880
|
+
}
|
|
9881
|
+
return out;
|
|
9882
|
+
}
|
|
9883
|
+
|
|
9884
|
+
// src/docx/section-edit.ts
|
|
9885
|
+
var px2 = twipsToPixels;
|
|
9886
|
+
function withSection(model, index, change) {
|
|
9887
|
+
const sections = sectionsOf(model).map(
|
|
9888
|
+
(section, position) => position === index ? change(structuredClone(section)) : section
|
|
9889
|
+
);
|
|
9890
|
+
const last = sections.at(-1);
|
|
9891
|
+
return {
|
|
9892
|
+
...model,
|
|
9893
|
+
sections,
|
|
9894
|
+
page: {
|
|
9895
|
+
width: px2(last.pageWidthTwips),
|
|
9896
|
+
height: px2(last.pageHeightTwips),
|
|
9897
|
+
marginTop: px2(last.marginTopTwips),
|
|
9898
|
+
marginRight: px2(last.marginRightTwips),
|
|
9899
|
+
marginBottom: px2(last.marginBottomTwips),
|
|
9900
|
+
marginLeft: px2(last.marginLeftTwips)
|
|
9901
|
+
}
|
|
9902
|
+
};
|
|
9903
|
+
}
|
|
9904
|
+
var NORMAL_MARGIN = twips(1440);
|
|
9905
|
+
var MARGINS = {
|
|
9906
|
+
normal: NORMAL_MARGIN,
|
|
9907
|
+
narrow: twips(720),
|
|
9908
|
+
wide: twips(2160)
|
|
9909
|
+
};
|
|
9910
|
+
function setMargins(model, index, preset) {
|
|
9911
|
+
if (preset === "moderate")
|
|
9912
|
+
return withSection(model, index, (section) => ({
|
|
9913
|
+
...section,
|
|
9914
|
+
marginTopTwips: NORMAL_MARGIN,
|
|
9915
|
+
marginBottomTwips: NORMAL_MARGIN,
|
|
9916
|
+
marginLeftTwips: twips(1080),
|
|
9917
|
+
marginRightTwips: twips(1080)
|
|
9918
|
+
}));
|
|
9919
|
+
const value = MARGINS[preset] ?? NORMAL_MARGIN;
|
|
9920
|
+
return withSection(model, index, (section) => ({
|
|
9921
|
+
...section,
|
|
9922
|
+
marginTopTwips: value,
|
|
9923
|
+
marginRightTwips: value,
|
|
9924
|
+
marginBottomTwips: value,
|
|
9925
|
+
marginLeftTwips: value
|
|
9926
|
+
}));
|
|
9927
|
+
}
|
|
9928
|
+
function setOrientation(model, index, orientation) {
|
|
9929
|
+
return withSection(model, index, (section) => {
|
|
9930
|
+
const { pageWidthTwips: width, pageHeightTwips: height } = section;
|
|
9931
|
+
const long = width >= height ? width : height;
|
|
9932
|
+
const short = width >= height ? height : width;
|
|
9933
|
+
return {
|
|
9934
|
+
...section,
|
|
9935
|
+
orientation,
|
|
9936
|
+
pageWidthTwips: orientation === "landscape" ? long : short,
|
|
9937
|
+
pageHeightTwips: orientation === "landscape" ? short : long
|
|
9938
|
+
};
|
|
9939
|
+
});
|
|
9940
|
+
}
|
|
9941
|
+
function setColumns(model, index, count) {
|
|
9942
|
+
return withSection(model, index, (section) => ({
|
|
9943
|
+
...section,
|
|
9944
|
+
columns: { count, spacingTwips: section.columns.spacingTwips ?? twips(720), equalWidth: true }
|
|
9945
|
+
}));
|
|
9946
|
+
}
|
|
9947
|
+
function setVerticalAlign(model, index, verticalAlign) {
|
|
9948
|
+
return withSection(model, index, (section) => {
|
|
9949
|
+
const { verticalAlign: _previous, ...rest } = section;
|
|
9950
|
+
return verticalAlign === "top" ? rest : { ...rest, verticalAlign };
|
|
9951
|
+
});
|
|
9952
|
+
}
|
|
9953
|
+
function setTitlePage(model, index, titlePage) {
|
|
9954
|
+
return withSection(model, index, (section) => ({ ...section, titlePage }));
|
|
9955
|
+
}
|
|
9956
|
+
function setPageNumbering(model, index, change) {
|
|
9957
|
+
return withSection(model, index, (section) => {
|
|
9958
|
+
const numbering = { ...section.pageNumbering };
|
|
9959
|
+
if (change.format !== void 0) numbering.format = change.format;
|
|
9960
|
+
if (change.restart === true) numbering.start = 1;
|
|
9961
|
+
if (change.restart === false) delete numbering.start;
|
|
9962
|
+
if (numbering.format === "decimal") delete numbering.format;
|
|
9963
|
+
const { pageNumbering: _previous, ...rest } = section;
|
|
9964
|
+
return Object.keys(numbering).length ? { ...rest, pageNumbering: numbering } : rest;
|
|
9965
|
+
});
|
|
9966
|
+
}
|
|
9967
|
+
function setLineNumbering(model, index, mode) {
|
|
9968
|
+
return withSection(model, index, (section) => {
|
|
9969
|
+
const { lineNumbering: _on, lineNumberSettings: previous, ...rest } = section;
|
|
9970
|
+
if (mode === "none") return rest;
|
|
9971
|
+
return {
|
|
9972
|
+
...rest,
|
|
9973
|
+
lineNumbering: true,
|
|
9974
|
+
lineNumberSettings: {
|
|
9975
|
+
countBy: previous?.countBy ?? 1,
|
|
9976
|
+
start: previous?.start ?? 1,
|
|
9977
|
+
restart: mode,
|
|
9978
|
+
...previous?.distanceTwips !== void 0 ? { distanceTwips: previous.distanceTwips } : {}
|
|
9979
|
+
}
|
|
9980
|
+
};
|
|
9981
|
+
});
|
|
9982
|
+
}
|
|
9983
|
+
|
|
9984
|
+
// src/docx/page-size.ts
|
|
9985
|
+
var PAGE_SIZES = {
|
|
9986
|
+
letter: [12240, 15840],
|
|
9987
|
+
legal: [12240, 20160],
|
|
9988
|
+
tabloid: [15840, 24480],
|
|
9989
|
+
executive: [10440, 15120],
|
|
9990
|
+
a3: [16838, 23811],
|
|
9991
|
+
a4: [11906, 16838],
|
|
9992
|
+
a5: [8391, 11906],
|
|
9993
|
+
b5: [10319, 14570]
|
|
9994
|
+
};
|
|
9995
|
+
var PAGE_SIZE_OPTIONS = [
|
|
9996
|
+
["letter", "Letter"],
|
|
9997
|
+
["legal", "Legal"],
|
|
9998
|
+
["tabloid", "Tabloid"],
|
|
9999
|
+
["executive", "Executive"],
|
|
10000
|
+
["a3", "A3"],
|
|
10001
|
+
["a4", "A4"],
|
|
10002
|
+
["a5", "A5"],
|
|
10003
|
+
["b5", "B5 (JIS)"]
|
|
10004
|
+
];
|
|
10005
|
+
function setPageSize(model, index, preset) {
|
|
10006
|
+
const size = PAGE_SIZES[preset];
|
|
10007
|
+
if (!size) return model;
|
|
10008
|
+
return withSection(model, index, (section) => {
|
|
10009
|
+
const [short, long] = size;
|
|
10010
|
+
const landscape = section.orientation === "landscape";
|
|
10011
|
+
return {
|
|
10012
|
+
...section,
|
|
10013
|
+
pageWidthTwips: twips(landscape ? long : short),
|
|
10014
|
+
pageHeightTwips: twips(landscape ? short : long)
|
|
10015
|
+
};
|
|
10016
|
+
});
|
|
10017
|
+
}
|
|
10018
|
+
function pageSizeOf(section) {
|
|
10019
|
+
const a = Math.min(section.pageWidthTwips, section.pageHeightTwips);
|
|
10020
|
+
const b = Math.max(section.pageWidthTwips, section.pageHeightTwips);
|
|
10021
|
+
for (const [key, [short, long]] of Object.entries(PAGE_SIZES))
|
|
10022
|
+
if (Math.abs(short - a) <= 2 && Math.abs(long - b) <= 2) return key;
|
|
10023
|
+
return null;
|
|
10024
|
+
}
|
|
10025
|
+
|
|
10026
|
+
// src/docx/page-setup-model.ts
|
|
10027
|
+
var TWIPS_PER_INCH2 = 1440;
|
|
10028
|
+
var MAX_PAGE_INCHES = 22;
|
|
10029
|
+
var MIN_TEXT_INCHES = 0.5;
|
|
10030
|
+
var inches = (value) => Math.round(value / TWIPS_PER_INCH2 * 1e3) / 1e3;
|
|
10031
|
+
function readPageSetup(section) {
|
|
10032
|
+
const short = Math.min(section.pageWidthTwips, section.pageHeightTwips);
|
|
10033
|
+
const long = Math.max(section.pageWidthTwips, section.pageHeightTwips);
|
|
10034
|
+
return {
|
|
10035
|
+
topIn: inches(section.marginTopTwips),
|
|
10036
|
+
bottomIn: inches(section.marginBottomTwips),
|
|
10037
|
+
leftIn: inches(section.marginLeftTwips),
|
|
10038
|
+
rightIn: inches(section.marginRightTwips),
|
|
10039
|
+
gutterIn: inches(section.gutterTwips ?? 0),
|
|
10040
|
+
headerIn: inches(section.headerDistanceTwips ?? 720),
|
|
10041
|
+
footerIn: inches(section.footerDistanceTwips ?? 720),
|
|
10042
|
+
orientation: section.orientation,
|
|
10043
|
+
widthIn: inches(short),
|
|
10044
|
+
heightIn: inches(long)
|
|
10045
|
+
};
|
|
10046
|
+
}
|
|
10047
|
+
function validatePageSetup(values) {
|
|
10048
|
+
const margins = [values.topIn, values.bottomIn, values.leftIn, values.rightIn, values.gutterIn];
|
|
10049
|
+
const measures = [...margins, values.headerIn, values.footerIn];
|
|
10050
|
+
if (measures.some((value) => !Number.isFinite(value) || value < 0 || value > MAX_PAGE_INCHES))
|
|
10051
|
+
return "range";
|
|
10052
|
+
if (![values.widthIn, values.heightIn].every((v) => v > 0 && v <= MAX_PAGE_INCHES))
|
|
10053
|
+
return "range";
|
|
10054
|
+
const short = Math.min(values.widthIn, values.heightIn);
|
|
10055
|
+
const long = Math.max(values.widthIn, values.heightIn);
|
|
10056
|
+
const [width, height] = values.orientation === "landscape" ? [long, short] : [short, long];
|
|
10057
|
+
if (width - values.leftIn - values.rightIn - values.gutterIn < MIN_TEXT_INCHES) return "width";
|
|
10058
|
+
if (height - values.topIn - values.bottomIn < MIN_TEXT_INCHES) return "height";
|
|
10059
|
+
return null;
|
|
10060
|
+
}
|
|
10061
|
+
var toTwips = (value) => Math.round(value * TWIPS_PER_INCH2);
|
|
10062
|
+
function applyPageSetup(model, index, values) {
|
|
10063
|
+
if (validatePageSetup(values)) return model;
|
|
10064
|
+
const short = Math.min(values.widthIn, values.heightIn);
|
|
10065
|
+
const long = Math.max(values.widthIn, values.heightIn);
|
|
10066
|
+
const landscape = values.orientation === "landscape";
|
|
10067
|
+
return withSection(model, index, (section) => ({
|
|
10068
|
+
...section,
|
|
10069
|
+
orientation: values.orientation,
|
|
10070
|
+
pageWidthTwips: twips(toTwips(landscape ? long : short)),
|
|
10071
|
+
pageHeightTwips: twips(toTwips(landscape ? short : long)),
|
|
10072
|
+
marginTopTwips: signedTwips(toTwips(values.topIn)),
|
|
10073
|
+
marginBottomTwips: signedTwips(toTwips(values.bottomIn)),
|
|
10074
|
+
marginLeftTwips: twips(toTwips(values.leftIn)),
|
|
10075
|
+
marginRightTwips: twips(toTwips(values.rightIn)),
|
|
10076
|
+
gutterTwips: twips(toTwips(values.gutterIn)),
|
|
10077
|
+
headerDistanceTwips: twips(toTwips(values.headerIn)),
|
|
10078
|
+
footerDistanceTwips: twips(toTwips(values.footerIn))
|
|
10079
|
+
}));
|
|
10080
|
+
}
|
|
10081
|
+
function presetOf(values) {
|
|
10082
|
+
return pageSizeOf({
|
|
10083
|
+
pageWidthTwips: twips(toTwips(values.widthIn)),
|
|
10084
|
+
pageHeightTwips: twips(toTwips(values.heightIn))
|
|
10085
|
+
});
|
|
10086
|
+
}
|
|
10087
|
+
|
|
9666
10088
|
exports.DEFAULT_STYLES_XML = DEFAULT_STYLES_XML;
|
|
9667
10089
|
exports.DEFAULT_TABLE_BORDERS = DEFAULT_TABLE_BORDERS;
|
|
9668
10090
|
exports.DEFAULT_TOC_INSTRUCTION = DEFAULT_TOC_INSTRUCTION;
|
|
@@ -9674,6 +10096,8 @@ exports.EMU_PER_INCH = EMU_PER_INCH;
|
|
|
9674
10096
|
exports.EMU_PER_PIXEL = EMU_PER_PIXEL;
|
|
9675
10097
|
exports.EMU_PER_POINT = EMU_PER_POINT;
|
|
9676
10098
|
exports.LIGATURE_VALUES = LIGATURE_VALUES;
|
|
10099
|
+
exports.PAGE_SIZES = PAGE_SIZES;
|
|
10100
|
+
exports.PAGE_SIZE_OPTIONS = PAGE_SIZE_OPTIONS;
|
|
9677
10101
|
exports.PIXELS_PER_INCH = PIXELS_PER_INCH;
|
|
9678
10102
|
exports.PROPERTY_FIELDS = PROPERTY_FIELDS;
|
|
9679
10103
|
exports.ST_AlgClass = ST_AlgClass;
|
|
@@ -9777,16 +10201,22 @@ exports.ST_YAlign = ST_YAlign;
|
|
|
9777
10201
|
exports.ST_Zoom = ST_Zoom;
|
|
9778
10202
|
exports.TWIPS_PER_INCH = TWIPS_PER_INCH;
|
|
9779
10203
|
exports.TWIPS_PER_POINT = TWIPS_PER_POINT;
|
|
10204
|
+
exports.WORD = WORD;
|
|
9780
10205
|
exports.WORD_HIGHLIGHT_TOKENS = WORD_HIGHLIGHT_TOKENS;
|
|
9781
10206
|
exports.WORD_UNDERLINE_TOKENS = WORD_UNDERLINE_TOKENS;
|
|
9782
10207
|
exports.acceptAllRevisions = acceptAllRevisions;
|
|
9783
10208
|
exports.acceptRevision = acceptRevision;
|
|
9784
10209
|
exports.alignFromJustification = alignFromJustification;
|
|
10210
|
+
exports.applyPageSetup = applyPageSetup;
|
|
9785
10211
|
exports.applyThemeShade = applyThemeShade;
|
|
9786
10212
|
exports.applyThemeTint = applyThemeTint;
|
|
9787
10213
|
exports.assertValidDocumentModel = assertValidDocumentModel;
|
|
9788
10214
|
exports.buildTableOfContents = buildTableOfContents;
|
|
9789
10215
|
exports.captionParagraphs = captionParagraphs;
|
|
10216
|
+
exports.changeColumnGap = changeColumnGap;
|
|
10217
|
+
exports.changeColumnWidth = changeColumnWidth;
|
|
10218
|
+
exports.columnPreset = columnPreset;
|
|
10219
|
+
exports.columnTextWidth = columnTextWidth;
|
|
9790
10220
|
exports.computeListLabels = computeListLabels;
|
|
9791
10221
|
exports.createDocument = createDocument;
|
|
9792
10222
|
exports.createListDefinition = createListDefinition;
|
|
@@ -9805,6 +10235,7 @@ exports.emuFromPixels = emuFromPixels;
|
|
|
9805
10235
|
exports.emuToPixels = emuToPixels;
|
|
9806
10236
|
exports.ensureListDefinition = ensureListDefinition;
|
|
9807
10237
|
exports.enumValue = enumValue;
|
|
10238
|
+
exports.equalColumnDraft = equalColumnDraft;
|
|
9808
10239
|
exports.fieldName = fieldName;
|
|
9809
10240
|
exports.findRevision = findRevision;
|
|
9810
10241
|
exports.findTableOfContents = findTableOfContents;
|
|
@@ -9922,18 +10353,24 @@ exports.isThemeColorToken = isThemeColorToken;
|
|
|
9922
10353
|
exports.isValidLanguageTag = isValidLanguageTag;
|
|
9923
10354
|
exports.isWordHighlightToken = isWordHighlightToken;
|
|
9924
10355
|
exports.isWordUnderlineStyle = isWordUnderlineStyle;
|
|
10356
|
+
exports.lineSpacingLabel = lineSpacingLabel;
|
|
10357
|
+
exports.lineSpacingOptions = lineSpacingOptions;
|
|
10358
|
+
exports.lineSpacingValue = lineSpacingValue;
|
|
9925
10359
|
exports.linkStylesToList = linkStylesToList;
|
|
9926
10360
|
exports.listRevisions = listRevisions;
|
|
9927
10361
|
exports.loadDocx = loadDocx;
|
|
9928
10362
|
exports.numberNotesInOrder = numberNotesInOrder;
|
|
9929
10363
|
exports.onOffAttribute = onOffAttribute;
|
|
9930
10364
|
exports.onOffElement = onOffElement;
|
|
10365
|
+
exports.pageSizeOf = pageSizeOf;
|
|
10366
|
+
exports.paragraphTwipsFromAttrs = paragraphTwipsFromAttrs;
|
|
9931
10367
|
exports.parseColorSchemeMapping = parseColorSchemeMapping;
|
|
9932
10368
|
exports.parseEighthPoints = parseEighthPoints;
|
|
9933
10369
|
exports.parseHalfPoints = parseHalfPoints;
|
|
9934
10370
|
exports.parseHexColor = parseHexColor;
|
|
9935
10371
|
exports.parseInteger = parseInteger;
|
|
9936
10372
|
exports.parseJustification = parseJustification;
|
|
10373
|
+
exports.parseLineSpacingValue = parseLineSpacingValue;
|
|
9937
10374
|
exports.parseNumberingCatalog = parseNumberingCatalog;
|
|
9938
10375
|
exports.parseOnOff = parseOnOff;
|
|
9939
10376
|
exports.parseParagraphStyleCatalog = parseParagraphStyleCatalog;
|
|
@@ -9948,6 +10385,9 @@ exports.parseTintShade = parseTintShade;
|
|
|
9948
10385
|
exports.parseTwips = parseTwips;
|
|
9949
10386
|
exports.parseUnsignedInteger = parseUnsignedInteger;
|
|
9950
10387
|
exports.plainText = plainText2;
|
|
10388
|
+
exports.presetOf = presetOf;
|
|
10389
|
+
exports.readColumnDraft = readColumnDraft;
|
|
10390
|
+
exports.readPageSetup = readPageSetup;
|
|
9951
10391
|
exports.rejectAllRevisions = rejectAllRevisions;
|
|
9952
10392
|
exports.rejectRevision = rejectRevision;
|
|
9953
10393
|
exports.reportParseWarning = reportParseWarning;
|
|
@@ -9967,7 +10407,19 @@ exports.roundHalfPoints = roundHalfPoints;
|
|
|
9967
10407
|
exports.roundSignedTwips = roundSignedTwips;
|
|
9968
10408
|
exports.roundTwips = roundTwips;
|
|
9969
10409
|
exports.saveDocx = saveDocx;
|
|
10410
|
+
exports.sectionLayoutJson = sectionLayoutJson;
|
|
10411
|
+
exports.sectionsFromLayout = sectionsFromLayout;
|
|
10412
|
+
exports.sectionsOf = sectionsOf;
|
|
10413
|
+
exports.setColumns = setColumns;
|
|
10414
|
+
exports.setLineNumbering = setLineNumbering;
|
|
10415
|
+
exports.setMargins = setMargins;
|
|
10416
|
+
exports.setOrientation = setOrientation;
|
|
10417
|
+
exports.setPageNumbering = setPageNumbering;
|
|
10418
|
+
exports.setPageSize = setPageSize;
|
|
10419
|
+
exports.setTitlePage = setTitlePage;
|
|
10420
|
+
exports.setVerticalAlign = setVerticalAlign;
|
|
9970
10421
|
exports.signedTwips = signedTwips;
|
|
10422
|
+
exports.signedTwipsAttr = signedTwipsAttr;
|
|
9971
10423
|
exports.signedTwipsFromPixels = signedTwipsFromPixels;
|
|
9972
10424
|
exports.signedTwipsFromPoints = signedTwipsFromPoints;
|
|
9973
10425
|
exports.tableOfFiguresInstruction = tableOfFiguresInstruction;
|
|
@@ -9976,15 +10428,21 @@ exports.tocCaptionLabel = tocCaptionLabel;
|
|
|
9976
10428
|
exports.tocEntries = tocEntries;
|
|
9977
10429
|
exports.tocHyperlinks = tocHyperlinks;
|
|
9978
10430
|
exports.tocLevels = tocLevels;
|
|
10431
|
+
exports.transformCase = transformCase;
|
|
9979
10432
|
exports.twips = twips;
|
|
10433
|
+
exports.twipsAttr = twipsAttr;
|
|
9980
10434
|
exports.twipsFromInches = twipsFromInches;
|
|
9981
10435
|
exports.twipsFromPixels = twipsFromPixels;
|
|
9982
10436
|
exports.twipsFromPoints = twipsFromPoints;
|
|
9983
10437
|
exports.twipsToInches = twipsToInches;
|
|
9984
10438
|
exports.twipsToPixels = twipsToPixels;
|
|
9985
10439
|
exports.twipsToPoints = twipsToPoints;
|
|
10440
|
+
exports.unequalColumnPreset = unequalColumnPreset;
|
|
9986
10441
|
exports.universalMeasureToTwips = universalMeasureToTwips;
|
|
9987
10442
|
exports.updateTableOfContents = updateTableOfContents;
|
|
10443
|
+
exports.validColumnDraft = validColumnDraft;
|
|
9988
10444
|
exports.validateDocumentModel = validateDocumentModel;
|
|
10445
|
+
exports.validatePageSetup = validatePageSetup;
|
|
9989
10446
|
exports.withParseWarnings = withParseWarnings;
|
|
10447
|
+
exports.withSection = withSection;
|
|
9990
10448
|
exports.withTocBookmarks = withTocBookmarks;
|