@portone/docx-editor 0.1.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/CHANGELOG.md +7 -0
- package/CONTRIBUTING.md +63 -0
- package/LICENSE +203 -0
- package/README.md +48 -0
- package/assets/editor.png +0 -0
- package/dist/DocxEditor.d.ts +123 -0
- package/dist/DocxEditor.js +348 -0
- package/dist/core.d.ts +36 -0
- package/dist/core.js +38 -0
- package/dist/docx/comments/constants.d.ts +8 -0
- package/dist/docx/comments/constants.js +20 -0
- package/dist/docx/comments/model.d.ts +37 -0
- package/dist/docx/comments/model.js +104 -0
- package/dist/docx/comments/reading.d.ts +36 -0
- package/dist/docx/comments/reading.js +149 -0
- package/dist/docx/comments/writing.d.ts +11 -0
- package/dist/docx/comments/writing.js +327 -0
- package/dist/docx/comments.d.ts +3 -0
- package/dist/docx/comments.js +4 -0
- package/dist/docx/container.d.ts +12 -0
- package/dist/docx/container.js +130 -0
- package/dist/docx/documentSettings.d.ts +4 -0
- package/dist/docx/documentSettings.js +14 -0
- package/dist/docx/exportDocx.d.ts +15 -0
- package/dist/docx/exportDocx.js +163 -0
- package/dist/docx/exportRefs.d.ts +16 -0
- package/dist/docx/exportRefs.js +10 -0
- package/dist/docx/formatting/direct.d.ts +30 -0
- package/dist/docx/formatting/direct.js +201 -0
- package/dist/docx/formatting/effectiveParagraph.d.ts +15 -0
- package/dist/docx/formatting/effectiveParagraph.js +81 -0
- package/dist/docx/formatting/styles.d.ts +67 -0
- package/dist/docx/formatting/styles.js +165 -0
- package/dist/docx/formatting/tabStops.d.ts +8 -0
- package/dist/docx/formatting/tabStops.js +65 -0
- package/dist/docx/formatting.d.ts +4 -0
- package/dist/docx/formatting.js +4 -0
- package/dist/docx/headersFooters.d.ts +36 -0
- package/dist/docx/headersFooters.js +218 -0
- package/dist/docx/hyperlink.d.ts +75 -0
- package/dist/docx/hyperlink.js +71 -0
- package/dist/docx/importDocx.d.ts +21 -0
- package/dist/docx/importDocx.js +263 -0
- package/dist/docx/importParagraph.d.ts +32 -0
- package/dist/docx/importParagraph.js +308 -0
- package/dist/docx/importTable.d.ts +9 -0
- package/dist/docx/importTable.js +275 -0
- package/dist/docx/media.d.ts +60 -0
- package/dist/docx/media.js +213 -0
- package/dist/docx/notes.d.ts +22 -0
- package/dist/docx/notes.js +71 -0
- package/dist/docx/pageGeometry.d.ts +75 -0
- package/dist/docx/pageGeometry.js +88 -0
- package/dist/docx/paraProps.d.ts +74 -0
- package/dist/docx/paraProps.js +167 -0
- package/dist/docx/propsXml.d.ts +49 -0
- package/dist/docx/propsXml.js +302 -0
- package/dist/docx/relationships.d.ts +42 -0
- package/dist/docx/relationships.js +94 -0
- package/dist/docx/runProps.d.ts +51 -0
- package/dist/docx/runProps.js +207 -0
- package/dist/docx/scan.d.ts +20 -0
- package/dist/docx/scan.js +110 -0
- package/dist/docx/sdt.d.ts +56 -0
- package/dist/docx/sdt.js +104 -0
- package/dist/docx/sdtProps.d.ts +18 -0
- package/dist/docx/sdtProps.js +11 -0
- package/dist/docx/serializeBlock.d.ts +4 -0
- package/dist/docx/serializeBlock.js +30 -0
- package/dist/docx/serializeParagraph.d.ts +15 -0
- package/dist/docx/serializeParagraph.js +208 -0
- package/dist/docx/serializeTable.d.ts +12 -0
- package/dist/docx/serializeTable.js +134 -0
- package/dist/docx/session.d.ts +81 -0
- package/dist/docx/session.js +79 -0
- package/dist/docx/tableFormatting/editing.d.ts +64 -0
- package/dist/docx/tableFormatting/editing.js +318 -0
- package/dist/docx/tableFormatting/reading.d.ts +96 -0
- package/dist/docx/tableFormatting/reading.js +221 -0
- package/dist/docx/tableFormatting.d.ts +2 -0
- package/dist/docx/tableFormatting.js +3 -0
- package/dist/docx/tableTemplate.d.ts +22 -0
- package/dist/docx/tableTemplate.js +111 -0
- package/dist/docx/theme.d.ts +40 -0
- package/dist/docx/theme.js +61 -0
- package/dist/docx/uniqueControls.d.ts +14 -0
- package/dist/docx/uniqueControls.js +62 -0
- package/dist/download.d.ts +57 -0
- package/dist/download.js +44 -0
- package/dist/editor/clipboard/images.d.ts +14 -0
- package/dist/editor/clipboard/images.js +158 -0
- package/dist/editor/clipboard/inlineFormatting.d.ts +21 -0
- package/dist/editor/clipboard/inlineFormatting.js +232 -0
- package/dist/editor/commands/breakCommands.d.ts +8 -0
- package/dist/editor/commands/breakCommands.js +19 -0
- package/dist/editor/commands/canRunCommand.d.ts +6 -0
- package/dist/editor/commands/canRunCommand.js +10 -0
- package/dist/editor/commands/commentCommands.d.ts +3 -0
- package/dist/editor/commands/commentCommands.js +4 -0
- package/dist/editor/commands/comments/editing.d.ts +21 -0
- package/dist/editor/commands/comments/editing.js +305 -0
- package/dist/editor/commands/comments/model.d.ts +31 -0
- package/dist/editor/commands/comments/model.js +0 -0
- package/dist/editor/commands/comments/reading.d.ts +8 -0
- package/dist/editor/commands/comments/reading.js +58 -0
- package/dist/editor/commands/formatting/editing.d.ts +32 -0
- package/dist/editor/commands/formatting/editing.js +138 -0
- package/dist/editor/commands/formatting/reading.d.ts +57 -0
- package/dist/editor/commands/formatting/reading.js +82 -0
- package/dist/editor/commands/formatting/shared.d.ts +32 -0
- package/dist/editor/commands/formatting/shared.js +53 -0
- package/dist/editor/commands/formattingCommands.d.ts +2 -0
- package/dist/editor/commands/formattingCommands.js +3 -0
- package/dist/editor/commands/historyCommands.d.ts +11 -0
- package/dist/editor/commands/historyCommands.js +16 -0
- package/dist/editor/commands/indentCommands.d.ts +15 -0
- package/dist/editor/commands/indentCommands.js +44 -0
- package/dist/editor/commands/index.d.ts +82 -0
- package/dist/editor/commands/index.js +171 -0
- package/dist/editor/commands/linkCommands.d.ts +56 -0
- package/dist/editor/commands/linkCommands.js +146 -0
- package/dist/editor/commands/listCommands.d.ts +58 -0
- package/dist/editor/commands/listCommands.js +140 -0
- package/dist/editor/commands/lockCommands.d.ts +47 -0
- package/dist/editor/commands/lockCommands.js +198 -0
- package/dist/editor/commands/noteQueries.d.ts +12 -0
- package/dist/editor/commands/noteQueries.js +29 -0
- package/dist/editor/commands/paragraphCommands.d.ts +59 -0
- package/dist/editor/commands/paragraphCommands.js +113 -0
- package/dist/editor/commands/spacingCommands.d.ts +23 -0
- package/dist/editor/commands/spacingCommands.js +48 -0
- package/dist/editor/commands/tabCommands.d.ts +5 -0
- package/dist/editor/commands/tabCommands.js +65 -0
- package/dist/editor/createEditor.d.ts +59 -0
- package/dist/editor/createEditor.js +160 -0
- package/dist/editor/documentStyles.d.ts +60 -0
- package/dist/editor/documentStyles.js +80 -0
- package/dist/editor/externalClipboard.d.ts +11 -0
- package/dist/editor/externalClipboard.js +323 -0
- package/dist/editor/imageFiles.d.ts +74 -0
- package/dist/editor/imageFiles.js +173 -0
- package/dist/editor/insertImage.d.ts +31 -0
- package/dist/editor/insertImage.js +35 -0
- package/dist/editor/insertTable.d.ts +18 -0
- package/dist/editor/insertTable.js +44 -0
- package/dist/editor/paragraphEdits.d.ts +42 -0
- package/dist/editor/paragraphEdits.js +59 -0
- package/dist/editor/plainText.d.ts +3 -0
- package/dist/editor/plainText.js +50 -0
- package/dist/editor/plugins/bookmarkProtection.d.ts +3 -0
- package/dist/editor/plugins/bookmarkProtection.js +28 -0
- package/dist/editor/plugins/columnResize.d.ts +27 -0
- package/dist/editor/plugins/columnResize.js +192 -0
- package/dist/editor/plugins/commentDecorations.d.ts +3 -0
- package/dist/editor/plugins/commentDecorations.js +23 -0
- package/dist/editor/plugins/commentReservations.d.ts +5 -0
- package/dist/editor/plugins/commentReservations.js +26 -0
- package/dist/editor/plugins/dropCaret.d.ts +10 -0
- package/dist/editor/plugins/dropCaret.js +11 -0
- package/dist/editor/plugins/imagePaste.d.ts +8 -0
- package/dist/editor/plugins/imagePaste.js +265 -0
- package/dist/editor/plugins/keymap.d.ts +5 -0
- package/dist/editor/plugins/keymap.js +94 -0
- package/dist/editor/plugins/linkPanel.d.ts +23 -0
- package/dist/editor/plugins/linkPanel.js +39 -0
- package/dist/editor/plugins/listInputRules.d.ts +14 -0
- package/dist/editor/plugins/listInputRules.js +36 -0
- package/dist/editor/plugins/lockedContent.d.ts +6 -0
- package/dist/editor/plugins/lockedContent.js +41 -0
- package/dist/editor/plugins/noteProtection.d.ts +3 -0
- package/dist/editor/plugins/noteProtection.js +25 -0
- package/dist/editor/plugins/numberingDecorations.d.ts +42 -0
- package/dist/editor/plugins/numberingDecorations.js +110 -0
- package/dist/editor/plugins/rowResize.d.ts +15 -0
- package/dist/editor/plugins/rowResize.js +196 -0
- package/dist/editor/plugins/styledParagraphs.d.ts +15 -0
- package/dist/editor/plugins/styledParagraphs.js +65 -0
- package/dist/editor/plugins/tabCaret.d.ts +3 -0
- package/dist/editor/plugins/tabCaret.js +126 -0
- package/dist/editor/plugins/tabDecorations.d.ts +11 -0
- package/dist/editor/plugins/tabDecorations.js +87 -0
- package/dist/editor/plugins/tabLayout.d.ts +16 -0
- package/dist/editor/plugins/tabLayout.js +328 -0
- package/dist/editor/plugins/tabPointer.d.ts +7 -0
- package/dist/editor/plugins/tabPointer.js +95 -0
- package/dist/editor/plugins/tableContextMenu.d.ts +21 -0
- package/dist/editor/plugins/tableContextMenu.js +88 -0
- package/dist/editor/plugins/textContextMenu.d.ts +15 -0
- package/dist/editor/plugins/textContextMenu.js +90 -0
- package/dist/editor/views/imageResize.d.ts +53 -0
- package/dist/editor/views/imageResize.js +167 -0
- package/dist/editor/views/runMarkView.d.ts +15 -0
- package/dist/editor/views/runMarkView.js +9 -0
- package/dist/editor/views/tableView.d.ts +24 -0
- package/dist/editor/views/tableView.js +32 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +38 -0
- package/dist/model/format.d.ts +240 -0
- package/dist/model/format.js +305 -0
- package/dist/model/tabStops.d.ts +17 -0
- package/dist/model/tabStops.js +22 -0
- package/dist/numbering/listTemplate.d.ts +29 -0
- package/dist/numbering/listTemplate.js +83 -0
- package/dist/numbering/markers.d.ts +24 -0
- package/dist/numbering/markers.js +93 -0
- package/dist/numbering/parseNumbering.d.ts +65 -0
- package/dist/numbering/parseNumbering.js +116 -0
- package/dist/numbering/writeNumbering.d.ts +13 -0
- package/dist/numbering/writeNumbering.js +49 -0
- package/dist/ooxml/errors.d.ts +39 -0
- package/dist/ooxml/errors.js +21 -0
- package/dist/ooxml/image.d.ts +88 -0
- package/dist/ooxml/image.js +106 -0
- package/dist/ooxml/tabStops.d.ts +3 -0
- package/dist/ooxml/tabStops.js +51 -0
- package/dist/ooxml/units.d.ts +37 -0
- package/dist/ooxml/units.js +116 -0
- package/dist/ooxml/xml.d.ts +36 -0
- package/dist/ooxml/xml.js +89 -0
- package/dist/page/PageGuides.d.ts +16 -0
- package/dist/page/PageGuides.js +114 -0
- package/dist/page/measureBlocks.d.ts +25 -0
- package/dist/page/measureBlocks.js +80 -0
- package/dist/page/pageDecorations.d.ts +36 -0
- package/dist/page/pageDecorations.js +211 -0
- package/dist/page/pageLayout.d.ts +176 -0
- package/dist/page/pageLayout.js +157 -0
- package/dist/page/tableMeasurements.d.ts +10 -0
- package/dist/page/tableMeasurements.js +115 -0
- package/dist/page/usePageLayout.d.ts +57 -0
- package/dist/page/usePageLayout.js +141 -0
- package/dist/schema/docxSchema.d.ts +9 -0
- package/dist/schema/docxSchema.js +863 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/locks.d.ts +112 -0
- package/dist/schema/locks.js +211 -0
- package/dist/schema/rendering.d.ts +6 -0
- package/dist/schema/rendering.js +46 -0
- package/dist/styles/classNames.d.ts +214 -0
- package/dist/styles/classNames.js +208 -0
- package/dist/styles/colors.d.ts +11 -0
- package/dist/styles/colors.js +14 -0
- package/dist/styles/fontSizes.d.ts +6 -0
- package/dist/styles/fontSizes.js +20 -0
- package/dist/styles/fontStack.d.ts +55 -0
- package/dist/styles/fontStack.js +262 -0
- package/dist/styles/fonts.d.ts +6 -0
- package/dist/styles/fonts.js +11 -0
- package/dist/styles/inlineStyle.d.ts +67 -0
- package/dist/styles/inlineStyle.js +212 -0
- package/dist/styles/lineSpacings.d.ts +11 -0
- package/dist/styles/lineSpacings.js +10 -0
- package/dist/styles.css +1650 -0
- package/dist/table/cellBorders.d.ts +12 -0
- package/dist/table/cellBorders.js +9 -0
- package/dist/table/cellFormatting.d.ts +57 -0
- package/dist/table/cellFormatting.js +173 -0
- package/dist/table/columns.d.ts +25 -0
- package/dist/table/columns.js +155 -0
- package/dist/table/commands.d.ts +19 -0
- package/dist/table/commands.js +63 -0
- package/dist/table/format.d.ts +35 -0
- package/dist/table/format.js +26 -0
- package/dist/table/gridBorders.d.ts +42 -0
- package/dist/table/gridBorders.js +192 -0
- package/dist/table/index.d.ts +16 -0
- package/dist/table/index.js +52 -0
- package/dist/table/merge.d.ts +36 -0
- package/dist/table/merge.js +125 -0
- package/dist/table/resize.d.ts +55 -0
- package/dist/table/resize.js +66 -0
- package/dist/table/rowResize.d.ts +14 -0
- package/dist/table/rowResize.js +44 -0
- package/dist/table/rows.d.ts +32 -0
- package/dist/table/rows.js +89 -0
- package/dist/table/widths.d.ts +69 -0
- package/dist/table/widths.js +97 -0
- package/dist/ui/AlignMenu.d.ts +15 -0
- package/dist/ui/AlignMenu.js +64 -0
- package/dist/ui/CellStyleGroup.d.ts +15 -0
- package/dist/ui/CellStyleGroup.js +232 -0
- package/dist/ui/ColorPicker.d.ts +13 -0
- package/dist/ui/ColorPicker.js +165 -0
- package/dist/ui/CommentsPanel.d.ts +15 -0
- package/dist/ui/CommentsPanel.js +348 -0
- package/dist/ui/FontFamilySelect.d.ts +14 -0
- package/dist/ui/FontFamilySelect.js +59 -0
- package/dist/ui/FontSizeSelect.d.ts +11 -0
- package/dist/ui/FontSizeSelect.js +49 -0
- package/dist/ui/InsertImageButton.d.ts +9 -0
- package/dist/ui/InsertImageButton.js +47 -0
- package/dist/ui/LinkCard.d.ts +12 -0
- package/dist/ui/LinkCard.js +127 -0
- package/dist/ui/LinkPanel.d.ts +9 -0
- package/dist/ui/LinkPanel.js +121 -0
- package/dist/ui/MenuChoice.d.ts +11 -0
- package/dist/ui/MenuChoice.js +32 -0
- package/dist/ui/NotesPanel.d.ts +6 -0
- package/dist/ui/NotesPanel.js +33 -0
- package/dist/ui/ParagraphStyleSelect.d.ts +11 -0
- package/dist/ui/ParagraphStyleSelect.js +62 -0
- package/dist/ui/Popover.d.ts +22 -0
- package/dist/ui/Popover.js +74 -0
- package/dist/ui/SpacingMenu.d.ts +12 -0
- package/dist/ui/SpacingMenu.js +54 -0
- package/dist/ui/TableMenu.d.ts +12 -0
- package/dist/ui/TableMenu.js +112 -0
- package/dist/ui/TableSizePicker.d.ts +9 -0
- package/dist/ui/TableSizePicker.js +53 -0
- package/dist/ui/TextMenu.d.ts +15 -0
- package/dist/ui/TextMenu.js +194 -0
- package/dist/ui/Toolbar.d.ts +19 -0
- package/dist/ui/Toolbar.js +448 -0
- package/dist/ui/ToolbarButton.d.ts +23 -0
- package/dist/ui/ToolbarButton.js +56 -0
- package/dist/ui/Tooltip.d.ts +19 -0
- package/dist/ui/Tooltip.js +47 -0
- package/dist/ui/ZoomSelect.d.ts +7 -0
- package/dist/ui/ZoomSelect.js +44 -0
- package/dist/ui/comments/CommentComposer.d.ts +17 -0
- package/dist/ui/comments/CommentComposer.js +59 -0
- package/dist/ui/comments/useCommentRailLayout.d.ts +18 -0
- package/dist/ui/comments/useCommentRailLayout.js +183 -0
- package/dist/ui/keyboardWalk.d.ts +22 -0
- package/dist/ui/keyboardWalk.js +70 -0
- package/dist/ui/openAddress.d.ts +11 -0
- package/dist/ui/openAddress.js +16 -0
- package/dist/ui/panelPlacement.d.ts +51 -0
- package/dist/ui/panelPlacement.js +71 -0
- package/dist/ui/presets.d.ts +11 -0
- package/dist/ui/presets.js +0 -0
- package/dist/ui/rovingFocus.d.ts +20 -0
- package/dist/ui/rovingFocus.js +61 -0
- package/dist/ui/runCommand.d.ts +5 -0
- package/dist/ui/runCommand.js +13 -0
- package/dist/ui/useDismiss.d.ts +6 -0
- package/dist/ui/useDismiss.js +31 -0
- package/dist/ui/useFitWidthZoom.d.ts +2 -0
- package/dist/ui/useFitWidthZoom.js +26 -0
- package/dist/ui/useGridKeyboard.d.ts +12 -0
- package/dist/ui/useGridKeyboard.js +90 -0
- package/dist/ui/useMenuKeyboard.d.ts +12 -0
- package/dist/ui/useMenuKeyboard.js +56 -0
- package/dist/ui/zoom.d.ts +4 -0
- package/dist/ui/zoom.js +21 -0
- package/package.json +120 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The paper a document is written on: its size and its margins.
|
|
3
|
+
*
|
|
4
|
+
* A document says so in the `w:sectPr` at the end of its body. The values are read for the screen
|
|
5
|
+
* only: the `w:sectPr` itself rides out with the rest of the preserved tail, so what a document
|
|
6
|
+
* declares is never rewritten from these numbers.
|
|
7
|
+
*
|
|
8
|
+
* Everything here is in twips (1/1440 inch), the unit `w:pgSz` and `w:pgMar` are written in.
|
|
9
|
+
* The one derived value the rest of the editor asks for in two units is the body width, which
|
|
10
|
+
* a table writes down in twips and the sheet draws in pixels, so `bodyWidth` hands out both
|
|
11
|
+
* views of the one number rather than letting each caller convert for itself.
|
|
12
|
+
*/
|
|
13
|
+
/** The paper and the margins a section lays down, in twips */
|
|
14
|
+
export interface PageGeometry {
|
|
15
|
+
/** The paper width. §17.6.13 `w:pgSz/@w:w` */
|
|
16
|
+
widthTwips: number;
|
|
17
|
+
/** The paper height. §17.6.13 `w:pgSz/@w:h` */
|
|
18
|
+
heightTwips: number;
|
|
19
|
+
marginLeftTwips: number;
|
|
20
|
+
marginRightTwips: number;
|
|
21
|
+
marginTopTwips: number;
|
|
22
|
+
marginBottomTwips: number;
|
|
23
|
+
}
|
|
24
|
+
export declare function twipsToPx(twips: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* The paper a document that says nothing is drawn on: A4 portrait with the margins this
|
|
27
|
+
* editor has always used.
|
|
28
|
+
*
|
|
29
|
+
* A document with no `w:sectPr`, or one whose `w:pgSz` cannot be read, is drawn on this, which
|
|
30
|
+
* is what every document was drawn on before the geometry was read at all.
|
|
31
|
+
*/
|
|
32
|
+
export declare const A4_PORTRAIT: PageGeometry;
|
|
33
|
+
/**
|
|
34
|
+
* The geometry a `w:sectPr` element lays down, with anything it leaves unsaid taken from A4.
|
|
35
|
+
*
|
|
36
|
+
* `w:orient` is not applied on top of the size: Word writes the width and the height already
|
|
37
|
+
* swapped for a landscape section, so honouring both would turn the paper back upright.
|
|
38
|
+
*/
|
|
39
|
+
export declare function readPageGeometry(sectPr: Element | null): PageGeometry;
|
|
40
|
+
/** The width one line of body text occupies: the paper less the side margins */
|
|
41
|
+
export declare function bodyWidthTwips(geometry: PageGeometry): number;
|
|
42
|
+
/** The height the body occupies on one page: the paper less the top and bottom margins */
|
|
43
|
+
export declare function bodyHeightTwips(geometry: PageGeometry): number;
|
|
44
|
+
/**
|
|
45
|
+
* The width of one line of body text, in both units the editor fits things to.
|
|
46
|
+
*
|
|
47
|
+
* A table writes its width down in twips (`w:tblW`, `w:tcW`) and the sheet draws an image in
|
|
48
|
+
* pixels, so the width a new table is divided into, the width a column drag stops at and the
|
|
49
|
+
* width an oversized image is shrunk to are all one number in two views.
|
|
50
|
+
*/
|
|
51
|
+
export interface BodyWidth {
|
|
52
|
+
/** dxa, the unit a table width is written in */
|
|
53
|
+
twips: number;
|
|
54
|
+
/** CSS pixels, the unit the sheet is drawn in */
|
|
55
|
+
px: number;
|
|
56
|
+
}
|
|
57
|
+
export declare function bodyWidth(geometry: PageGeometry): BodyWidth;
|
|
58
|
+
/**
|
|
59
|
+
* The body width of the paper a document that names none is drawn on.
|
|
60
|
+
*
|
|
61
|
+
* It is what a caller with no document to ask still gets: 11906 - 1247 * 2 = 9412 dxa.
|
|
62
|
+
*/
|
|
63
|
+
export declare const A4_BODY_WIDTH: BodyWidth;
|
|
64
|
+
/**
|
|
65
|
+
* The geometry of the first section of an already parsed body.
|
|
66
|
+
*
|
|
67
|
+
* A document may hold a `w:sectPr` per section, each with a paper of its own. The screen draws
|
|
68
|
+
* one paper for the whole document, so the first section decides it; the rest ride out
|
|
69
|
+
* untouched in their preserved blocks and are drawn on the first section's paper.
|
|
70
|
+
* `site/content/docs/features.mdx` records that limit.
|
|
71
|
+
*
|
|
72
|
+
* The reading is deliberately forgiving: this runs against a document already opened, and a
|
|
73
|
+
* `w:sectPr` we cannot read is a reason to draw A4, never a reason to refuse the file.
|
|
74
|
+
*/
|
|
75
|
+
export declare function readBodyGeometry(body: Element): PageGeometry;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// src/docx/pageGeometry.ts
|
|
2
|
+
import { toNumber, wAttr } from "../ooxml/units.js";
|
|
3
|
+
import { childByLocalName } from "../ooxml/xml.js";
|
|
4
|
+
var TWIPS_PER_CM = 1440 / 2.54;
|
|
5
|
+
var PX_PER_TWIP = 96 / 1440;
|
|
6
|
+
function cm(value) {
|
|
7
|
+
return Math.round(value * TWIPS_PER_CM);
|
|
8
|
+
}
|
|
9
|
+
function twipsToPx(twips) {
|
|
10
|
+
return twips * PX_PER_TWIP;
|
|
11
|
+
}
|
|
12
|
+
var A4_PORTRAIT = {
|
|
13
|
+
widthTwips: cm(21),
|
|
14
|
+
heightTwips: cm(29.7),
|
|
15
|
+
marginLeftTwips: cm(2.2),
|
|
16
|
+
marginRightTwips: cm(2.2),
|
|
17
|
+
marginTopTwips: cm(2),
|
|
18
|
+
marginBottomTwips: cm(2)
|
|
19
|
+
};
|
|
20
|
+
var MIN_PAGE_TWIPS = cm(1);
|
|
21
|
+
var MAX_PAGE_TWIPS = cm(600);
|
|
22
|
+
function readSize(value) {
|
|
23
|
+
if (value === null) return null;
|
|
24
|
+
if (!Number.isFinite(value)) return null;
|
|
25
|
+
if (value < MIN_PAGE_TWIPS || value > MAX_PAGE_TWIPS) return null;
|
|
26
|
+
return Math.round(value);
|
|
27
|
+
}
|
|
28
|
+
function readMargin(value, fallback) {
|
|
29
|
+
if (value === null || !Number.isFinite(value)) return fallback;
|
|
30
|
+
if (value < 0) return 0;
|
|
31
|
+
return Math.min(Math.round(value), MAX_PAGE_TWIPS);
|
|
32
|
+
}
|
|
33
|
+
function readPageGeometry(sectPr) {
|
|
34
|
+
if (!sectPr) return A4_PORTRAIT;
|
|
35
|
+
const pgSz = childByLocalName(sectPr, "pgSz");
|
|
36
|
+
const pgMar = childByLocalName(sectPr, "pgMar");
|
|
37
|
+
const width = pgSz ? readSize(toNumber(wAttr(pgSz, "w"))) : null;
|
|
38
|
+
const height = pgSz ? readSize(toNumber(wAttr(pgSz, "h"))) : null;
|
|
39
|
+
const readable = width !== null && height !== null;
|
|
40
|
+
const marginLeft = pgMar ? toNumber(wAttr(pgMar, "left")) : null;
|
|
41
|
+
const marginRight = pgMar ? toNumber(wAttr(pgMar, "right")) : null;
|
|
42
|
+
const marginTop = pgMar ? toNumber(wAttr(pgMar, "top")) : null;
|
|
43
|
+
const marginBottom = pgMar ? toNumber(wAttr(pgMar, "bottom")) : null;
|
|
44
|
+
const geometry = {
|
|
45
|
+
widthTwips: readable ? width : A4_PORTRAIT.widthTwips,
|
|
46
|
+
heightTwips: readable ? height : A4_PORTRAIT.heightTwips,
|
|
47
|
+
marginLeftTwips: readMargin(marginLeft, A4_PORTRAIT.marginLeftTwips),
|
|
48
|
+
marginRightTwips: readMargin(marginRight, A4_PORTRAIT.marginRightTwips),
|
|
49
|
+
marginTopTwips: readMargin(marginTop, A4_PORTRAIT.marginTopTwips),
|
|
50
|
+
marginBottomTwips: readMargin(marginBottom, A4_PORTRAIT.marginBottomTwips)
|
|
51
|
+
};
|
|
52
|
+
return hasBody(geometry) ? geometry : A4_PORTRAIT;
|
|
53
|
+
}
|
|
54
|
+
function hasBody(geometry) {
|
|
55
|
+
return bodyWidthTwips(geometry) > 0 && bodyHeightTwips(geometry) > 0;
|
|
56
|
+
}
|
|
57
|
+
function bodyWidthTwips(geometry) {
|
|
58
|
+
return geometry.widthTwips - geometry.marginLeftTwips - geometry.marginRightTwips;
|
|
59
|
+
}
|
|
60
|
+
function bodyHeightTwips(geometry) {
|
|
61
|
+
return geometry.heightTwips - geometry.marginTopTwips - geometry.marginBottomTwips;
|
|
62
|
+
}
|
|
63
|
+
function bodyWidth(geometry) {
|
|
64
|
+
const twips = bodyWidthTwips(geometry);
|
|
65
|
+
return { twips, px: twipsToPx(twips) };
|
|
66
|
+
}
|
|
67
|
+
var A4_BODY_WIDTH = bodyWidth(A4_PORTRAIT);
|
|
68
|
+
function readBodyGeometry(body) {
|
|
69
|
+
return readPageGeometry(firstSectPrIn(body));
|
|
70
|
+
}
|
|
71
|
+
function firstSectPrIn(root) {
|
|
72
|
+
const found = root.getElementsByTagName("w:sectPr").item(0);
|
|
73
|
+
if (found) return found;
|
|
74
|
+
for (const el of root.getElementsByTagName("*")) {
|
|
75
|
+
if (el.localName === "sectPr") return el;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
A4_BODY_WIDTH,
|
|
81
|
+
A4_PORTRAIT,
|
|
82
|
+
bodyHeightTwips,
|
|
83
|
+
bodyWidth,
|
|
84
|
+
bodyWidthTwips,
|
|
85
|
+
readBodyGeometry,
|
|
86
|
+
readPageGeometry,
|
|
87
|
+
twipsToPx
|
|
88
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Swaps out only the style name, the list slot, the indents, the spacing, and the alignment in a
|
|
3
|
+
* paragraph formatting fragment (`<w:pPr>`).
|
|
4
|
+
*
|
|
5
|
+
* When one paragraph is changed, the formatting we do not touch, such as tab stops and borders,
|
|
6
|
+
* must stay as the original text wrote it. So we never rebuild the fragment; we change it one child
|
|
7
|
+
* at a time, and within a child one attribute at a time.
|
|
8
|
+
* The fragment we operated on is read back with the parser used when opening the document to build
|
|
9
|
+
* the display values, and the style the paragraph points at is layered in the same order as it was
|
|
10
|
+
* then. That way a changed paragraph's display values are the same as they would be after saving
|
|
11
|
+
* and reopening.
|
|
12
|
+
*/
|
|
13
|
+
import type { LineSpacing, NumberingRef, ParagraphAlign, ParagraphFormat, RunFormat } from "../model/format";
|
|
14
|
+
import type { LevelIndent } from "../numbering/parseNumbering";
|
|
15
|
+
import { type StyleTable } from "./formatting";
|
|
16
|
+
/** What to do with the indents */
|
|
17
|
+
export type IndentChange =
|
|
18
|
+
/** Leaves the indents the paragraph wrote down as they are */
|
|
19
|
+
{
|
|
20
|
+
kind: "keep";
|
|
21
|
+
}
|
|
22
|
+
/** Changes them to the indents the list level lays down */
|
|
23
|
+
| {
|
|
24
|
+
kind: "level";
|
|
25
|
+
indent: LevelIndent;
|
|
26
|
+
}
|
|
27
|
+
/** Removes only the hanging indent the marker used to sit in (when leaving a list) */
|
|
28
|
+
| {
|
|
29
|
+
kind: "clearHanging";
|
|
30
|
+
};
|
|
31
|
+
export interface ListChange {
|
|
32
|
+
/** The list slot this paragraph will belong to. null takes it out of the list */
|
|
33
|
+
numbering: NumberingRef | null;
|
|
34
|
+
indent: IndentChange;
|
|
35
|
+
}
|
|
36
|
+
/** The paragraph formatting we operated on, and the display values read back out of it */
|
|
37
|
+
export interface ParagraphProps {
|
|
38
|
+
pPr: string | null;
|
|
39
|
+
format: ParagraphFormat | null;
|
|
40
|
+
/** The character formatting the style the paragraph now wears lays down (`styleRun` in `schema`) */
|
|
41
|
+
styleRun: RunFormat | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Reads the fragment we operated on back along the same path used when opening the document.
|
|
45
|
+
*
|
|
46
|
+
* The values of the style the paragraph wears are laid down underneath (the same order as import),
|
|
47
|
+
* which for a paragraph pointing at no style of its own is the document's default paragraph style.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readParagraphProps(pPr: string | null, styles?: StyleTable, defaultStyleId?: string | null): ParagraphFormat | null;
|
|
50
|
+
export declare function withListNumbering(pPr: string | null, change: ListChange, styles?: StyleTable, defaultStyleId?: string | null): ParagraphProps | null;
|
|
51
|
+
/**
|
|
52
|
+
* The result of moving the paragraph's own left indent to `leftTwips`.
|
|
53
|
+
* Everything else the indent recorded - the hanging or first-line indent, the right indent -
|
|
54
|
+
* stays as it was.
|
|
55
|
+
*/
|
|
56
|
+
export declare function withLeftIndent(pPr: string | null, leftTwips: number, styles?: StyleTable, defaultStyleId?: string | null): ParagraphProps | null;
|
|
57
|
+
/**
|
|
58
|
+
* The result of changing the line spacing. The space above and below the paragraph is left as it was.
|
|
59
|
+
* `auto` states the multiple in 240ths of a line; the other rules pin the height down in twips.
|
|
60
|
+
*/
|
|
61
|
+
export declare function withLineSpacing(pPr: string | null, spacing: LineSpacing, styles?: StyleTable, defaultStyleId?: string | null): ParagraphProps | null;
|
|
62
|
+
/**
|
|
63
|
+
* The result of pointing the paragraph at a named style.
|
|
64
|
+
* A null id takes the pStyle away, which is how the default style is worn.
|
|
65
|
+
*
|
|
66
|
+
* Nothing else in the fragment moves: as in Word, a style is applied by naming it and not by
|
|
67
|
+
* copying its values into the paragraph, so the direct formatting written here keeps beating it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function withParagraphStyle(pPr: string | null, styleId: string | null, styles?: StyleTable, defaultStyleId?: string | null): ParagraphProps | null;
|
|
70
|
+
/**
|
|
71
|
+
* The result of changing the paragraph alignment.
|
|
72
|
+
* One alignment is always on, so we provide no way to withdraw the setting (the same as Word).
|
|
73
|
+
*/
|
|
74
|
+
export declare function withParagraphAlign(pPr: string | null, align: ParagraphAlign, styles?: StyleTable, defaultStyleId?: string | null): ParagraphProps | null;
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
// src/docx/paraProps.ts
|
|
2
|
+
import { childByLocalName, escapeXml, localPart } from "../ooxml/xml.js";
|
|
3
|
+
import {
|
|
4
|
+
layerParagraphFormat,
|
|
5
|
+
layerRunFormat,
|
|
6
|
+
NO_STYLES,
|
|
7
|
+
paragraphStyleFormat,
|
|
8
|
+
readParagraphFormat
|
|
9
|
+
} from "./formatting.js";
|
|
10
|
+
import {
|
|
11
|
+
P_PR_ORDER,
|
|
12
|
+
parseProps,
|
|
13
|
+
parsePropsXml,
|
|
14
|
+
renderProps,
|
|
15
|
+
setPropsChild
|
|
16
|
+
} from "./propsXml.js";
|
|
17
|
+
var LEFT_IND_ATTRS = ["left", "start", "leftChars", "startChars"];
|
|
18
|
+
var LEFT_TWIPS_IND_ATTRS = ["left", "start"];
|
|
19
|
+
var HANGING_IND_ATTRS = ["hanging", "hangingChars"];
|
|
20
|
+
var FIRST_LINE_IND_ATTRS = [
|
|
21
|
+
...HANGING_IND_ATTRS,
|
|
22
|
+
"firstLine",
|
|
23
|
+
"firstLineChars"
|
|
24
|
+
];
|
|
25
|
+
function readParagraphProps(pPr, styles = NO_STYLES, defaultStyleId = null) {
|
|
26
|
+
const direct = pPr === null ? null : readParagraphFormat(parsePropsXml(pPr));
|
|
27
|
+
const style = paragraphStyleFormat(pPr, styles, defaultStyleId);
|
|
28
|
+
return layerParagraphFormat(style?.paragraph ?? {}, direct);
|
|
29
|
+
}
|
|
30
|
+
function readParagraphStyleRun(pPr, styles = NO_STYLES, defaultStyleId = null) {
|
|
31
|
+
const style = paragraphStyleFormat(pPr, styles, defaultStyleId);
|
|
32
|
+
return layerRunFormat(style?.run ?? {}, null);
|
|
33
|
+
}
|
|
34
|
+
function numPrXml(ref) {
|
|
35
|
+
if (!ref) return null;
|
|
36
|
+
return `<w:numPr><w:ilvl w:val="${ref.ilvl}"/><w:numId w:val="${ref.numId}"/></w:numPr>`;
|
|
37
|
+
}
|
|
38
|
+
function keptIndAttrs(ind, dropped) {
|
|
39
|
+
if (!ind) return [];
|
|
40
|
+
return Array.from(ind.attributes).filter((attr) => !dropped.includes(localPart(attr.name))).map((attr) => [attr.name, attr.value]);
|
|
41
|
+
}
|
|
42
|
+
function levelIndAttrs(indent) {
|
|
43
|
+
const attrs = [];
|
|
44
|
+
if (indent.startTwips !== null)
|
|
45
|
+
attrs.push(["w:left", `${indent.startTwips}`]);
|
|
46
|
+
if (indent.hangingTwips !== null) {
|
|
47
|
+
attrs.push(["w:hanging", `${indent.hangingTwips}`]);
|
|
48
|
+
} else if (indent.firstLineTwips !== null) {
|
|
49
|
+
attrs.push(["w:firstLine", `${indent.firstLineTwips}`]);
|
|
50
|
+
}
|
|
51
|
+
return attrs;
|
|
52
|
+
}
|
|
53
|
+
function attrsXml(tag, attrs) {
|
|
54
|
+
if (attrs.length === 0) return null;
|
|
55
|
+
const text = attrs.map(([name, value]) => `${name}="${escapeXml(value)}"`).join(" ");
|
|
56
|
+
return `<${tag} ${text}/>`;
|
|
57
|
+
}
|
|
58
|
+
function indXml(attrs) {
|
|
59
|
+
return attrsXml("w:ind", attrs);
|
|
60
|
+
}
|
|
61
|
+
function nextIndXml(ind, change) {
|
|
62
|
+
if (change.kind === "keep") return void 0;
|
|
63
|
+
if (change.kind === "clearHanging") {
|
|
64
|
+
return indXml(keptIndAttrs(ind, HANGING_IND_ATTRS));
|
|
65
|
+
}
|
|
66
|
+
const dropped = [...LEFT_IND_ATTRS, ...FIRST_LINE_IND_ATTRS];
|
|
67
|
+
return indXml([
|
|
68
|
+
...levelIndAttrs(change.indent),
|
|
69
|
+
...keptIndAttrs(ind, dropped)
|
|
70
|
+
]);
|
|
71
|
+
}
|
|
72
|
+
function leftIndAttrs(ind, leftTwips) {
|
|
73
|
+
const original = ind ? Array.from(ind.attributes) : [];
|
|
74
|
+
const slot = original.find(
|
|
75
|
+
(attr) => LEFT_TWIPS_IND_ATTRS.includes(localPart(attr.name))
|
|
76
|
+
)?.name;
|
|
77
|
+
const moved = original.flatMap((attr) => {
|
|
78
|
+
if (!LEFT_IND_ATTRS.includes(localPart(attr.name))) {
|
|
79
|
+
return [[attr.name, attr.value]];
|
|
80
|
+
}
|
|
81
|
+
return attr.name === slot && leftTwips > 0 ? [[attr.name, `${leftTwips}`]] : [];
|
|
82
|
+
});
|
|
83
|
+
return slot === void 0 && leftTwips > 0 ? [["w:left", `${leftTwips}`], ...moved] : moved;
|
|
84
|
+
}
|
|
85
|
+
var EMPTY_P_PR = { tag: "w:pPr", attrs: null, children: [] };
|
|
86
|
+
function editParagraphProps(pPr, styles, defaultStyleId, plan) {
|
|
87
|
+
const props = pPr === null ? EMPTY_P_PR : parseProps(pPr);
|
|
88
|
+
const element = pPr === null ? null : parsePropsXml(pPr);
|
|
89
|
+
if (!props || pPr !== null && !element) return null;
|
|
90
|
+
const children = plan(element).reduce(
|
|
91
|
+
(kept, [name, xml]) => setPropsChild(kept, name, xml, P_PR_ORDER),
|
|
92
|
+
props.children
|
|
93
|
+
);
|
|
94
|
+
const rendered = renderProps({ ...props, children });
|
|
95
|
+
const next = rendered === "" ? null : rendered;
|
|
96
|
+
return {
|
|
97
|
+
pPr: next,
|
|
98
|
+
format: readParagraphProps(next, styles, defaultStyleId),
|
|
99
|
+
styleRun: readParagraphStyleRun(next, styles, defaultStyleId)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function withListNumbering(pPr, change, styles = NO_STYLES, defaultStyleId = null) {
|
|
103
|
+
return editParagraphProps(pPr, styles, defaultStyleId, (element) => {
|
|
104
|
+
const ind = nextIndXml(
|
|
105
|
+
element ? childByLocalName(element, "ind") : null,
|
|
106
|
+
change.indent
|
|
107
|
+
);
|
|
108
|
+
const numPr = ["numPr", numPrXml(change.numbering)];
|
|
109
|
+
return ind === void 0 ? [numPr] : [numPr, ["ind", ind]];
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function withLeftIndent(pPr, leftTwips, styles = NO_STYLES, defaultStyleId = null) {
|
|
113
|
+
return editParagraphProps(pPr, styles, defaultStyleId, (element) => {
|
|
114
|
+
const ind = element ? childByLocalName(element, "ind") : null;
|
|
115
|
+
return [["ind", indXml(leftIndAttrs(ind, leftTwips))]];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function spacingAttrs(spacing, edits) {
|
|
119
|
+
const original = spacing ? Array.from(spacing.attributes) : [];
|
|
120
|
+
const editOf = (name) => edits.find(([edited]) => edited === localPart(name));
|
|
121
|
+
const changed = original.map((attr) => [
|
|
122
|
+
attr.name,
|
|
123
|
+
editOf(attr.name)?.[1] ?? attr.value
|
|
124
|
+
]);
|
|
125
|
+
const added = edits.filter(
|
|
126
|
+
([name]) => !original.some((attr) => localPart(attr.name) === name)
|
|
127
|
+
);
|
|
128
|
+
return [
|
|
129
|
+
...changed,
|
|
130
|
+
...added.map(([name, value]) => [`w:${name}`, value])
|
|
131
|
+
];
|
|
132
|
+
}
|
|
133
|
+
function withLineSpacing(pPr, spacing, styles = NO_STYLES, defaultStyleId = null) {
|
|
134
|
+
const line = spacing.rule === "auto" ? Math.round(spacing.lines * 240) : Math.round(spacing.pt * 20);
|
|
135
|
+
return editParagraphProps(pPr, styles, defaultStyleId, (element) => {
|
|
136
|
+
const current = element ? childByLocalName(element, "spacing") : null;
|
|
137
|
+
const attrs = spacingAttrs(current, [
|
|
138
|
+
["line", `${line}`],
|
|
139
|
+
["lineRule", spacing.rule]
|
|
140
|
+
]);
|
|
141
|
+
return [["spacing", attrsXml("w:spacing", attrs)]];
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function withParagraphStyle(pPr, styleId, styles = NO_STYLES, defaultStyleId = null) {
|
|
145
|
+
const pStyle = styleId === null ? null : `<w:pStyle w:val="${escapeXml(styleId)}"/>`;
|
|
146
|
+
return editParagraphProps(pPr, styles, defaultStyleId, () => [
|
|
147
|
+
["pStyle", pStyle]
|
|
148
|
+
]);
|
|
149
|
+
}
|
|
150
|
+
var JC_BY_ALIGN = {
|
|
151
|
+
left: "left",
|
|
152
|
+
center: "center",
|
|
153
|
+
right: "right",
|
|
154
|
+
justify: "both"
|
|
155
|
+
};
|
|
156
|
+
function withParagraphAlign(pPr, align, styles = NO_STYLES, defaultStyleId = null) {
|
|
157
|
+
const jc = `<w:jc w:val="${JC_BY_ALIGN[align]}"/>`;
|
|
158
|
+
return editParagraphProps(pPr, styles, defaultStyleId, () => [["jc", jc]]);
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
readParagraphProps,
|
|
162
|
+
withLeftIndent,
|
|
163
|
+
withLineSpacing,
|
|
164
|
+
withListNumbering,
|
|
165
|
+
withParagraphAlign,
|
|
166
|
+
withParagraphStyle
|
|
167
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handles the XML fragments that carry formatting, such as `<w:rPr>`, `<w:pPr>`, and `<w:tcPr>`.
|
|
3
|
+
*
|
|
4
|
+
* A fragment is never rebuilt: only the one child a job names is sliced out and swapped, so the
|
|
5
|
+
* rest (borders, shading, margins) stays as the original text wrote it. OOXML lays down the order
|
|
6
|
+
* of the children, so the spot to insert a child that was not there is found by that same order.
|
|
7
|
+
*/
|
|
8
|
+
export interface PropsChild {
|
|
9
|
+
/** The name with its namespace prefix stripped off (e.g. `gridSpan`) */
|
|
10
|
+
name: string;
|
|
11
|
+
/** This child's original XML fragment exactly as it was */
|
|
12
|
+
xml: string;
|
|
13
|
+
}
|
|
14
|
+
export interface Props {
|
|
15
|
+
/** The opening tag name exactly as written (e.g. `w:tcPr`) */
|
|
16
|
+
tag: string;
|
|
17
|
+
attrs: string | null;
|
|
18
|
+
children: PropsChild[];
|
|
19
|
+
}
|
|
20
|
+
/** The order the children are laid out in under `w:rPr` (CT_RPr) */
|
|
21
|
+
export declare const RUN_PR_ORDER: readonly string[];
|
|
22
|
+
/** The order the children are laid out in under `w:pPr` (CT_PPr) */
|
|
23
|
+
export declare const P_PR_ORDER: readonly string[];
|
|
24
|
+
/** The order the children are laid out in under `w:tcPr` (CT_TcPr) */
|
|
25
|
+
export declare const TC_PR_ORDER: readonly string[];
|
|
26
|
+
/** The conventional order of children under `w:trPr` (CT_TrPr). */
|
|
27
|
+
export declare const TR_PR_ORDER: readonly string[];
|
|
28
|
+
/** The order the children are laid out in under `w:tblPr` (CT_TblPr) */
|
|
29
|
+
export declare const TBL_PR_ORDER: readonly string[];
|
|
30
|
+
/**
|
|
31
|
+
* Splits a formatting fragment into its opening tag and its list of children.
|
|
32
|
+
* null if its shape cannot be made out (in which case leaving the original untouched is the safe move).
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseProps(xml: string): Props | null;
|
|
35
|
+
/** With no children at all, the formatting fragment itself is not written */
|
|
36
|
+
export declare function renderProps(props: Props): string;
|
|
37
|
+
/**
|
|
38
|
+
* Replaces a single child with new XML.
|
|
39
|
+
* A null `xml` removes that child. A child that was not there goes into the spot the order calls for.
|
|
40
|
+
*/
|
|
41
|
+
export declare function setPropsChild(children: PropsChild[], name: string, xml: string | null, order: readonly string[]): PropsChild[];
|
|
42
|
+
export declare function propsChild(children: PropsChild[], name: string): PropsChild | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Reads a single formatting fragment into an element.
|
|
45
|
+
*
|
|
46
|
+
* A fragment carries no namespace declarations, so they are put back on as it is wrapped.
|
|
47
|
+
* null if its shape cannot be made out, in which case the caller leaves the display values alone.
|
|
48
|
+
*/
|
|
49
|
+
export declare function parsePropsXml(xml: string): Element | null;
|