documents.js 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/blr-types-CYYC3yYU.d.cts +35 -0
- package/dist/blr-types-CYYC3yYU.d.ts +35 -0
- package/dist/cell-CNHPsDEk.d.cts +17 -0
- package/dist/cell-CNHPsDEk.d.ts +17 -0
- package/dist/color-71eoF1Up.d.cts +2 -0
- package/dist/color-Bo228AY2.d.ts +2 -0
- package/dist/convert/codec.cjs +51 -0
- package/dist/convert/codec.d.cts +13 -0
- package/dist/convert/codec.d.ts +13 -0
- package/dist/convert/codec.js +42 -0
- package/dist/convert/convert.cjs +443 -0
- package/dist/convert/convert.d.cts +55 -0
- package/dist/convert/convert.d.ts +55 -0
- package/dist/convert/convert.js +419 -0
- package/dist/convert/local.cjs +393 -0
- package/dist/convert/local.d.cts +5 -0
- package/dist/convert/local.d.ts +5 -0
- package/dist/convert/local.js +392 -0
- package/dist/convert/port.cjs +0 -0
- package/dist/convert/port.d.cts +34 -0
- package/dist/convert/port.d.ts +34 -0
- package/dist/convert/port.js +0 -0
- package/dist/edit/docx/content.cjs +71 -0
- package/dist/edit/docx/content.d.cts +6 -0
- package/dist/edit/docx/content.d.ts +6 -0
- package/dist/edit/docx/content.js +70 -0
- package/dist/edit/docx/editor.cjs +116 -0
- package/dist/edit/docx/editor.d.cts +23 -0
- package/dist/edit/docx/editor.d.ts +23 -0
- package/dist/edit/docx/editor.js +113 -0
- package/dist/edit/docx/image.cjs +74 -0
- package/dist/edit/docx/image.d.cts +2 -0
- package/dist/edit/docx/image.d.ts +2 -0
- package/dist/edit/docx/image.js +72 -0
- package/dist/edit/docx/paragraph.cjs +132 -0
- package/dist/edit/docx/paragraph.d.cts +40 -0
- package/dist/edit/docx/paragraph.d.ts +40 -0
- package/dist/edit/docx/paragraph.js +130 -0
- package/dist/edit/docx/props.cjs +132 -0
- package/dist/edit/docx/props.d.cts +20 -0
- package/dist/edit/docx/props.d.ts +20 -0
- package/dist/edit/docx/props.js +117 -0
- package/dist/edit/docx/run.cjs +143 -0
- package/dist/edit/docx/run.d.cts +2 -0
- package/dist/edit/docx/run.d.ts +2 -0
- package/dist/edit/docx/run.js +141 -0
- package/dist/edit/docx/scaffold.cjs +97 -0
- package/dist/edit/docx/scaffold.d.cts +5 -0
- package/dist/edit/docx/scaffold.d.ts +5 -0
- package/dist/edit/docx/scaffold.js +96 -0
- package/dist/edit/docx/table.cjs +99 -0
- package/dist/edit/docx/table.d.cts +34 -0
- package/dist/edit/docx/table.d.ts +34 -0
- package/dist/edit/docx/table.js +95 -0
- package/dist/edit/odg/content.cjs +65 -0
- package/dist/edit/odg/content.d.cts +6 -0
- package/dist/edit/odg/content.d.ts +6 -0
- package/dist/edit/odg/content.js +64 -0
- package/dist/edit/odg/editor.cjs +96 -0
- package/dist/edit/odg/editor.d.cts +19 -0
- package/dist/edit/odg/editor.d.ts +19 -0
- package/dist/edit/odg/editor.js +93 -0
- package/dist/edit/odg/page.cjs +70 -0
- package/dist/edit/odg/page.d.cts +34 -0
- package/dist/edit/odg/page.d.ts +34 -0
- package/dist/edit/odg/page.js +69 -0
- package/dist/edit/odg/scaffold.cjs +106 -0
- package/dist/edit/odg/scaffold.d.cts +7 -0
- package/dist/edit/odg/scaffold.d.ts +7 -0
- package/dist/edit/odg/scaffold.js +103 -0
- package/dist/edit/odg/style.cjs +83 -0
- package/dist/edit/odg/style.d.cts +14 -0
- package/dist/edit/odg/style.d.ts +14 -0
- package/dist/edit/odg/style.js +78 -0
- package/dist/edit/odg/svg-path.cjs +30 -0
- package/dist/edit/odg/svg-path.d.cts +7 -0
- package/dist/edit/odg/svg-path.d.ts +7 -0
- package/dist/edit/odg/svg-path.js +27 -0
- package/dist/edit/odg/vector.cjs +208 -0
- package/dist/edit/odg/vector.d.cts +2 -0
- package/dist/edit/odg/vector.d.ts +2 -0
- package/dist/edit/odg/vector.js +201 -0
- package/dist/edit/odp/content.cjs +42 -0
- package/dist/edit/odp/content.d.cts +6 -0
- package/dist/edit/odp/content.d.ts +6 -0
- package/dist/edit/odp/content.js +41 -0
- package/dist/edit/odp/editor.cjs +113 -0
- package/dist/edit/odp/editor.d.cts +20 -0
- package/dist/edit/odp/editor.d.ts +20 -0
- package/dist/edit/odp/editor.js +110 -0
- package/dist/edit/odp/image.cjs +10 -0
- package/dist/edit/odp/image.d.cts +2 -0
- package/dist/edit/odp/image.d.ts +2 -0
- package/dist/edit/odp/image.js +9 -0
- package/dist/edit/odp/scaffold.cjs +108 -0
- package/dist/edit/odp/scaffold.d.cts +7 -0
- package/dist/edit/odp/scaffold.d.ts +7 -0
- package/dist/edit/odp/scaffold.js +105 -0
- package/dist/edit/odp/shape.cjs +133 -0
- package/dist/edit/odp/shape.d.cts +2 -0
- package/dist/edit/odp/shape.d.ts +2 -0
- package/dist/edit/odp/shape.js +130 -0
- package/dist/edit/odp/slide.cjs +80 -0
- package/dist/edit/odp/slide.d.cts +31 -0
- package/dist/edit/odp/slide.d.ts +31 -0
- package/dist/edit/odp/slide.js +79 -0
- package/dist/edit/ods/address.cjs +108 -0
- package/dist/edit/ods/address.d.cts +15 -0
- package/dist/edit/ods/address.d.ts +15 -0
- package/dist/edit/ods/address.js +97 -0
- package/dist/edit/ods/cell.cjs +177 -0
- package/dist/edit/ods/cell.d.cts +2 -0
- package/dist/edit/ods/cell.d.ts +2 -0
- package/dist/edit/ods/cell.js +176 -0
- package/dist/edit/ods/content.cjs +26 -0
- package/dist/edit/ods/content.d.cts +6 -0
- package/dist/edit/ods/content.d.ts +6 -0
- package/dist/edit/ods/content.js +25 -0
- package/dist/edit/ods/editor.cjs +84 -0
- package/dist/edit/ods/editor.d.cts +17 -0
- package/dist/edit/ods/editor.d.ts +17 -0
- package/dist/edit/ods/editor.js +81 -0
- package/dist/edit/ods/print-settings.cjs +90 -0
- package/dist/edit/ods/print-settings.d.cts +7 -0
- package/dist/edit/ods/print-settings.d.ts +7 -0
- package/dist/edit/ods/print-settings.js +88 -0
- package/dist/edit/ods/scaffold.cjs +129 -0
- package/dist/edit/ods/scaffold.d.cts +9 -0
- package/dist/edit/ods/scaffold.d.ts +9 -0
- package/dist/edit/ods/scaffold.js +124 -0
- package/dist/edit/ods/sheet.cjs +70 -0
- package/dist/edit/ods/sheet.d.cts +22 -0
- package/dist/edit/ods/sheet.d.ts +22 -0
- package/dist/edit/ods/sheet.js +69 -0
- package/dist/edit/odt/automatic-styles.cjs +49 -0
- package/dist/edit/odt/automatic-styles.d.cts +8 -0
- package/dist/edit/odt/automatic-styles.d.ts +8 -0
- package/dist/edit/odt/automatic-styles.js +45 -0
- package/dist/edit/odt/content.cjs +110 -0
- package/dist/edit/odt/content.d.cts +9 -0
- package/dist/edit/odt/content.d.ts +9 -0
- package/dist/edit/odt/content.js +108 -0
- package/dist/edit/odt/editor.cjs +98 -0
- package/dist/edit/odt/editor.d.cts +25 -0
- package/dist/edit/odt/editor.d.ts +25 -0
- package/dist/edit/odt/editor.js +95 -0
- package/dist/edit/odt/list.cjs +82 -0
- package/dist/edit/odt/list.d.cts +2 -0
- package/dist/edit/odt/list.d.ts +2 -0
- package/dist/edit/odt/list.js +79 -0
- package/dist/edit/odt/paragraph.cjs +84 -0
- package/dist/edit/odt/paragraph.d.cts +2 -0
- package/dist/edit/odt/paragraph.d.ts +2 -0
- package/dist/edit/odt/paragraph.js +82 -0
- package/dist/edit/odt/props.cjs +26 -0
- package/dist/edit/odt/props.d.cts +7 -0
- package/dist/edit/odt/props.d.ts +7 -0
- package/dist/edit/odt/props.js +23 -0
- package/dist/edit/odt/run.cjs +82 -0
- package/dist/edit/odt/run.d.cts +2 -0
- package/dist/edit/odt/run.d.ts +2 -0
- package/dist/edit/odt/run.js +80 -0
- package/dist/edit/odt/scaffold.cjs +109 -0
- package/dist/edit/odt/scaffold.d.cts +5 -0
- package/dist/edit/odt/scaffold.d.ts +5 -0
- package/dist/edit/odt/scaffold.js +108 -0
- package/dist/edit/odt/table.cjs +123 -0
- package/dist/edit/odt/table.d.cts +37 -0
- package/dist/edit/odt/table.d.ts +37 -0
- package/dist/edit/odt/table.js +119 -0
- package/dist/edit/pptx/content.cjs +49 -0
- package/dist/edit/pptx/content.d.cts +6 -0
- package/dist/edit/pptx/content.d.ts +6 -0
- package/dist/edit/pptx/content.js +48 -0
- package/dist/edit/pptx/editor.cjs +187 -0
- package/dist/edit/pptx/editor.d.cts +20 -0
- package/dist/edit/pptx/editor.d.ts +20 -0
- package/dist/edit/pptx/editor.js +184 -0
- package/dist/edit/pptx/image.cjs +27 -0
- package/dist/edit/pptx/image.d.cts +2 -0
- package/dist/edit/pptx/image.d.ts +2 -0
- package/dist/edit/pptx/image.js +26 -0
- package/dist/edit/pptx/scaffold.cjs +292 -0
- package/dist/edit/pptx/scaffold.d.cts +13 -0
- package/dist/edit/pptx/scaffold.d.ts +13 -0
- package/dist/edit/pptx/scaffold.js +283 -0
- package/dist/edit/pptx/shape.cjs +182 -0
- package/dist/edit/pptx/shape.d.cts +2 -0
- package/dist/edit/pptx/shape.d.ts +2 -0
- package/dist/edit/pptx/shape.js +179 -0
- package/dist/edit/pptx/slide.cjs +146 -0
- package/dist/edit/pptx/slide.d.cts +33 -0
- package/dist/edit/pptx/slide.d.ts +33 -0
- package/dist/edit/pptx/slide.js +145 -0
- package/dist/firebird/backup.cjs +150 -0
- package/dist/firebird/backup.d.cts +21 -0
- package/dist/firebird/backup.d.ts +21 -0
- package/dist/firebird/backup.js +145 -0
- package/dist/firebird/blr-types.cjs +118 -0
- package/dist/firebird/blr-types.d.cts +2 -0
- package/dist/firebird/blr-types.d.ts +2 -0
- package/dist/firebird/blr-types.js +90 -0
- package/dist/firebird/data.cjs +231 -0
- package/dist/firebird/data.d.cts +17 -0
- package/dist/firebird/data.d.ts +17 -0
- package/dist/firebird/data.js +228 -0
- package/dist/firebird/date.cjs +63 -0
- package/dist/firebird/date.d.cts +17 -0
- package/dist/firebird/date.d.ts +17 -0
- package/dist/firebird/date.js +58 -0
- package/dist/firebird/reader.cjs +157 -0
- package/dist/firebird/reader.d.cts +2 -0
- package/dist/firebird/reader.d.ts +2 -0
- package/dist/firebird/reader.js +154 -0
- package/dist/firebird/schema.cjs +91 -0
- package/dist/firebird/schema.d.cts +2 -0
- package/dist/firebird/schema.d.ts +2 -0
- package/dist/firebird/schema.js +89 -0
- package/dist/geometry-DvwdrIij.d.cts +5 -0
- package/dist/geometry-DvwdrIij.d.ts +5 -0
- package/dist/hsqldb/cache.cjs +88 -0
- package/dist/hsqldb/cache.d.cts +13 -0
- package/dist/hsqldb/cache.d.ts +13 -0
- package/dist/hsqldb/cache.js +84 -0
- package/dist/hsqldb/rowformat.cjs +222 -0
- package/dist/hsqldb/rowformat.d.cts +21 -0
- package/dist/hsqldb/rowformat.d.ts +21 -0
- package/dist/hsqldb/rowformat.js +218 -0
- package/dist/hsqldb/script.cjs +450 -0
- package/dist/hsqldb/script.d.cts +19 -0
- package/dist/hsqldb/script.d.ts +19 -0
- package/dist/hsqldb/script.js +447 -0
- package/dist/image-B-xQWYYS.d.ts +16 -0
- package/dist/image-BZDy72Jb.d.cts +16 -0
- package/dist/image-BfRLAD9B.d.cts +18 -0
- package/dist/image-BfRLAD9B.d.ts +18 -0
- package/dist/image-CeqwL-Qs.d.ts +14 -0
- package/dist/image-DWX6cNOD.d.cts +14 -0
- package/dist/index.cjs +201 -10863
- package/dist/index.d.cts +71 -1406
- package/dist/index.d.ts +71 -1406
- package/dist/index.js +67 -10727
- package/dist/layout/drawing.cjs +117 -0
- package/dist/layout/drawing.d.cts +13 -0
- package/dist/layout/drawing.d.ts +13 -0
- package/dist/layout/drawing.js +116 -0
- package/dist/layout/engine.cjs +216 -0
- package/dist/layout/engine.d.cts +19 -0
- package/dist/layout/engine.d.ts +19 -0
- package/dist/layout/engine.js +215 -0
- package/dist/layout/reconstruct.cjs +809 -0
- package/dist/layout/reconstruct.d.cts +12 -0
- package/dist/layout/reconstruct.d.ts +12 -0
- package/dist/layout/reconstruct.js +805 -0
- package/dist/layout/shared.cjs +104 -0
- package/dist/layout/shared.d.cts +15 -0
- package/dist/layout/shared.d.ts +15 -0
- package/dist/layout/shared.js +96 -0
- package/dist/layout/sheets.cjs +413 -0
- package/dist/layout/sheets.d.cts +14 -0
- package/dist/layout/sheets.d.ts +14 -0
- package/dist/layout/sheets.js +414 -0
- package/dist/layout/slides.cjs +194 -0
- package/dist/layout/slides.d.cts +25 -0
- package/dist/layout/slides.d.ts +25 -0
- package/dist/layout/slides.js +192 -0
- package/dist/list-BuBM9rwQ.d.cts +24 -0
- package/dist/list-CvKxhy3y.d.ts +24 -0
- package/dist/mathml/compose.cjs +53 -0
- package/dist/mathml/compose.d.cts +8 -0
- package/dist/mathml/compose.d.ts +8 -0
- package/dist/mathml/compose.js +49 -0
- package/dist/mathml/layout-types.cjs +0 -0
- package/dist/mathml/layout-types.d.cts +50 -0
- package/dist/mathml/layout-types.d.ts +50 -0
- package/dist/mathml/layout-types.js +0 -0
- package/dist/mathml/layout.cjs +373 -0
- package/dist/mathml/layout.d.cts +24 -0
- package/dist/mathml/layout.d.ts +24 -0
- package/dist/mathml/layout.js +371 -0
- package/dist/mathml/length.cjs +41 -0
- package/dist/mathml/length.d.cts +4 -0
- package/dist/mathml/length.d.ts +4 -0
- package/dist/mathml/length.js +40 -0
- package/dist/mathml/metrics.cjs +0 -0
- package/dist/mathml/metrics.d.cts +44 -0
- package/dist/mathml/metrics.d.ts +44 -0
- package/dist/mathml/metrics.js +0 -0
- package/dist/mathml/nodes.cjs +39 -0
- package/dist/mathml/nodes.d.cts +2 -0
- package/dist/mathml/nodes.d.ts +2 -0
- package/dist/mathml/nodes.js +32 -0
- package/dist/mathml/operators.cjs +189 -0
- package/dist/mathml/operators.d.cts +13 -0
- package/dist/mathml/operators.d.ts +13 -0
- package/dist/mathml/operators.js +188 -0
- package/dist/mathml/radical.cjs +46 -0
- package/dist/mathml/radical.d.cts +10 -0
- package/dist/mathml/radical.d.ts +10 -0
- package/dist/mathml/radical.js +45 -0
- package/dist/mathml/variant.cjs +1160 -0
- package/dist/mathml/variant.d.cts +7 -0
- package/dist/mathml/variant.d.ts +7 -0
- package/dist/mathml/variant.js +1157 -0
- package/dist/model/bytes.cjs +88 -0
- package/dist/model/bytes.d.cts +12 -0
- package/dist/model/bytes.d.ts +12 -0
- package/dist/model/bytes.js +80 -0
- package/dist/model/color.cjs +26 -0
- package/dist/model/color.d.cts +2 -0
- package/dist/model/color.d.ts +2 -0
- package/dist/model/color.js +2 -0
- package/dist/model/content.cjs +34 -0
- package/dist/model/content.d.cts +362 -0
- package/dist/model/content.d.ts +362 -0
- package/dist/model/content.js +32 -0
- package/dist/model/formula.cjs +0 -0
- package/dist/model/formula.d.cts +8 -0
- package/dist/model/formula.d.ts +8 -0
- package/dist/model/formula.js +0 -0
- package/dist/model/geometry.cjs +55 -0
- package/dist/model/geometry.d.cts +2 -0
- package/dist/model/geometry.d.ts +2 -0
- package/dist/model/geometry.js +12 -0
- package/dist/model/style.cjs +20 -0
- package/dist/model/style.d.cts +2 -0
- package/dist/model/style.d.ts +2 -0
- package/dist/model/style.js +2 -0
- package/dist/model/units.cjs +55 -0
- package/dist/model/units.d.cts +20 -0
- package/dist/model/units.d.ts +20 -0
- package/dist/model/units.js +38 -0
- package/dist/nodes-pArN9ilm.d.cts +27 -0
- package/dist/nodes-pArN9ilm.d.ts +27 -0
- package/dist/odb/csv.cjs +48 -0
- package/dist/odb/csv.d.cts +14 -0
- package/dist/odb/csv.d.ts +14 -0
- package/dist/odb/csv.js +45 -0
- package/dist/odb/read.cjs +87 -0
- package/dist/odb/read.d.cts +15 -0
- package/dist/odb/read.d.ts +15 -0
- package/dist/odb/read.js +85 -0
- package/dist/odb/spreadsheet.cjs +68 -0
- package/dist/odb/spreadsheet.d.cts +6 -0
- package/dist/odb/spreadsheet.d.ts +6 -0
- package/dist/odb/spreadsheet.js +67 -0
- package/dist/odf/formula/detect.cjs +29 -0
- package/dist/odf/formula/detect.d.cts +12 -0
- package/dist/odf/formula/detect.d.ts +12 -0
- package/dist/odf/formula/detect.js +28 -0
- package/dist/odf/formula/placeholder.cjs +37 -0
- package/dist/odf/formula/placeholder.d.cts +14 -0
- package/dist/odf/formula/placeholder.d.ts +14 -0
- package/dist/odf/formula/placeholder.js +36 -0
- package/dist/odf/formula/read.cjs +32 -0
- package/dist/odf/formula/read.d.cts +11 -0
- package/dist/odf/formula/read.d.ts +11 -0
- package/dist/odf/formula/read.js +30 -0
- package/dist/odf/odg/read.cjs +15 -0
- package/dist/odf/odg/read.d.cts +6 -0
- package/dist/odf/odg/read.d.ts +6 -0
- package/dist/odf/odg/read.js +14 -0
- package/dist/odf/odp/read.cjs +45 -0
- package/dist/odf/odp/read.d.cts +11 -0
- package/dist/odf/odp/read.d.ts +11 -0
- package/dist/odf/odp/read.js +44 -0
- package/dist/odf/ods/read.cjs +15 -0
- package/dist/odf/ods/read.d.cts +6 -0
- package/dist/odf/ods/read.d.ts +6 -0
- package/dist/odf/ods/read.js +14 -0
- package/dist/odf/odt/read.cjs +43 -0
- package/dist/odf/odt/read.d.cts +11 -0
- package/dist/odf/odt/read.d.ts +11 -0
- package/dist/odf/odt/read.js +42 -0
- package/dist/odf-package/manifest.cjs +62 -0
- package/dist/odf-package/manifest.d.cts +2 -0
- package/dist/odf-package/manifest.d.ts +2 -0
- package/dist/odf-package/manifest.js +2 -0
- package/dist/odf-package/media.cjs +34 -0
- package/dist/odf-package/media.d.cts +8 -0
- package/dist/odf-package/media.d.ts +8 -0
- package/dist/odf-package/media.js +34 -0
- package/dist/ooxml/docx/read.cjs +15 -0
- package/dist/ooxml/docx/read.d.cts +6 -0
- package/dist/ooxml/docx/read.d.ts +6 -0
- package/dist/ooxml/docx/read.js +14 -0
- package/dist/ooxml/pptx/read.cjs +15 -0
- package/dist/ooxml/pptx/read.d.cts +6 -0
- package/dist/ooxml/pptx/read.d.ts +6 -0
- package/dist/ooxml/pptx/read.js +14 -0
- package/dist/opc/content-types.cjs +47 -0
- package/dist/opc/content-types.d.cts +7 -0
- package/dist/opc/content-types.d.ts +7 -0
- package/dist/opc/content-types.js +44 -0
- package/dist/opc/media.cjs +45 -0
- package/dist/opc/media.d.cts +10 -0
- package/dist/opc/media.d.ts +10 -0
- package/dist/opc/media.js +44 -0
- package/dist/opc/paths.cjs +28 -0
- package/dist/opc/paths.d.cts +5 -0
- package/dist/opc/paths.d.ts +5 -0
- package/dist/opc/paths.js +26 -0
- package/dist/opc/rels.cjs +47 -0
- package/dist/opc/rels.d.cts +10 -0
- package/dist/opc/rels.d.ts +10 -0
- package/dist/opc/rels.js +46 -0
- package/dist/paragraph-BXbXKPy3.d.cts +30 -0
- package/dist/paragraph-CoUi_88j.d.ts +30 -0
- package/dist/ports/abort.cjs +7 -0
- package/dist/ports/abort.d.cts +4 -0
- package/dist/ports/abort.d.ts +4 -0
- package/dist/ports/abort.js +6 -0
- package/dist/ports/clock.cjs +9 -0
- package/dist/ports/clock.d.cts +8 -0
- package/dist/ports/clock.d.ts +8 -0
- package/dist/ports/clock.js +7 -0
- package/dist/reader-DP0Mbaj4.d.cts +41 -0
- package/dist/reader-DP0Mbaj4.d.ts +41 -0
- package/dist/run-B3GNScJH.d.cts +38 -0
- package/dist/run-CJfh8rv3.d.ts +38 -0
- package/dist/run-D2rTWHbt.d.ts +38 -0
- package/dist/run-F8JN7Vy4.d.cts +38 -0
- package/dist/schema-Acco3Ezi.d.cts +22 -0
- package/dist/schema-VkAA6pF5.d.ts +22 -0
- package/dist/shape-BUfjw5eZ.d.cts +35 -0
- package/dist/shape-BfN3m52m.d.ts +30 -0
- package/dist/shape-CN2ycxOo.d.cts +30 -0
- package/dist/shape-CTkl6kt8.d.ts +35 -0
- package/dist/style-DkamR3aY.d.cts +2 -0
- package/dist/style-DkamR3aY.d.ts +2 -0
- package/dist/vector-ClohqsOe.d.cts +76 -0
- package/dist/vector-ClohqsOe.d.ts +76 -0
- package/dist/xml/edit.cjs +65 -0
- package/dist/xml/edit.d.cts +12 -0
- package/dist/xml/edit.d.ts +12 -0
- package/dist/xml/edit.js +57 -0
- package/dist/xml/entities.cjs +12 -0
- package/dist/xml/entities.d.cts +5 -0
- package/dist/xml/entities.d.ts +5 -0
- package/dist/xml/entities.js +10 -0
- package/dist/xml/fragment.cjs +22 -0
- package/dist/xml/fragment.d.cts +6 -0
- package/dist/xml/fragment.d.ts +6 -0
- package/dist/xml/fragment.js +20 -0
- package/dist/xml/odf-text.cjs +53 -0
- package/dist/xml/odf-text.d.cts +6 -0
- package/dist/xml/odf-text.d.ts +6 -0
- package/dist/xml/odf-text.js +51 -0
- package/dist/xml/query.cjs +33 -0
- package/dist/xml/query.d.cts +12 -0
- package/dist/xml/query.d.ts +12 -0
- package/dist/xml/query.js +29 -0
- package/package.json +9 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { getOrCreateChildElement, removeChild } from "../../xml/edit.js";
|
|
3
|
+
import { insertImageMedia } from "./image.js";
|
|
4
|
+
import { PPR_ORDER, ensureFirstChild, getAlignment, getStyleId, setAlignment, setStyleId } from "./props.js";
|
|
5
|
+
import { DocxRun, buildRun } from "./run.js";
|
|
6
|
+
import { attr, textContent } from "ooxml.js";
|
|
7
|
+
//#region src/edit/docx/paragraph.ts
|
|
8
|
+
function directChild(parent, tag) {
|
|
9
|
+
for (const child of parent.children) if (child.type === "element" && child.tag === tag) return child;
|
|
10
|
+
}
|
|
11
|
+
var DocxParagraph = class {
|
|
12
|
+
container;
|
|
13
|
+
node;
|
|
14
|
+
imageContext;
|
|
15
|
+
removed = false;
|
|
16
|
+
constructor(container, node, imageContext) {
|
|
17
|
+
this.container = container;
|
|
18
|
+
this.node = node;
|
|
19
|
+
this.imageContext = imageContext;
|
|
20
|
+
}
|
|
21
|
+
live() {
|
|
22
|
+
if (this.removed) throw new Error("this DocxParagraph has been removed from its body and can no longer be used");
|
|
23
|
+
return this.node;
|
|
24
|
+
}
|
|
25
|
+
pPr(create) {
|
|
26
|
+
const node = this.live();
|
|
27
|
+
return create ? ensureFirstChild(node, "w:pPr") : directChild(node, "w:pPr");
|
|
28
|
+
}
|
|
29
|
+
get text() {
|
|
30
|
+
return textContent(this.live());
|
|
31
|
+
}
|
|
32
|
+
runs() {
|
|
33
|
+
const node = this.live();
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const child of node.children) if (child.type === "element" && child.tag === "w:r") out.push(new DocxRun(node.children, child));
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
appendRun(init) {
|
|
39
|
+
const node = this.live();
|
|
40
|
+
const runElement = buildRun(init);
|
|
41
|
+
node.children.push(runElement);
|
|
42
|
+
return new DocxRun(node.children, runElement);
|
|
43
|
+
}
|
|
44
|
+
appendTab() {
|
|
45
|
+
this.live().children.push(el("w:r", {}, [el("w:tab")]));
|
|
46
|
+
}
|
|
47
|
+
insertRunAt(index, init) {
|
|
48
|
+
const node = this.live();
|
|
49
|
+
const runElement = buildRun(init);
|
|
50
|
+
const runIndices = [];
|
|
51
|
+
node.children.forEach((child, i) => {
|
|
52
|
+
if (child.type === "element" && child.tag === "w:r") runIndices.push(i);
|
|
53
|
+
});
|
|
54
|
+
const insertAt = index < runIndices.length ? runIndices[index] ?? node.children.length : node.children.length;
|
|
55
|
+
node.children.splice(insertAt, 0, runElement);
|
|
56
|
+
return new DocxRun(node.children, runElement);
|
|
57
|
+
}
|
|
58
|
+
get styleId() {
|
|
59
|
+
return getStyleId(this.pPr(false), "w:pStyle");
|
|
60
|
+
}
|
|
61
|
+
set styleId(value) {
|
|
62
|
+
if (value === void 0) {
|
|
63
|
+
const pPr = this.pPr(false);
|
|
64
|
+
const existing = pPr === void 0 ? void 0 : directChild(pPr, "w:pStyle");
|
|
65
|
+
if (existing !== void 0 && pPr !== void 0) removeChild(pPr.children, existing);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
setStyleId(this.pPr(true), "w:pStyle", value, PPR_ORDER);
|
|
69
|
+
}
|
|
70
|
+
get alignment() {
|
|
71
|
+
return getAlignment(this.pPr(false));
|
|
72
|
+
}
|
|
73
|
+
set alignment(value) {
|
|
74
|
+
if (value === void 0) {
|
|
75
|
+
const pPr = this.pPr(false);
|
|
76
|
+
const existing = pPr === void 0 ? void 0 : directChild(pPr, "w:jc");
|
|
77
|
+
if (existing !== void 0 && pPr !== void 0) removeChild(pPr.children, existing);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
setAlignment(this.pPr(true), value);
|
|
81
|
+
}
|
|
82
|
+
get list() {
|
|
83
|
+
const pPr = this.pPr(false);
|
|
84
|
+
const numPr = pPr === void 0 ? void 0 : directChild(pPr, "w:numPr");
|
|
85
|
+
if (numPr === void 0) return;
|
|
86
|
+
const numIdElement = directChild(numPr, "w:numId");
|
|
87
|
+
const numId = numIdElement === void 0 ? void 0 : attr(numIdElement, "w:val");
|
|
88
|
+
if (numId === void 0) return;
|
|
89
|
+
const ilvlElement = directChild(numPr, "w:ilvl");
|
|
90
|
+
const ilvl = ilvlElement === void 0 ? void 0 : attr(ilvlElement, "w:val");
|
|
91
|
+
return {
|
|
92
|
+
numId,
|
|
93
|
+
level: ilvl === void 0 ? 0 : Number.parseInt(ilvl, 10)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
set list(value) {
|
|
97
|
+
const pPr = this.pPr(true);
|
|
98
|
+
if (value === void 0) {
|
|
99
|
+
const existing = directChild(pPr, "w:numPr");
|
|
100
|
+
if (existing !== void 0) removeChild(pPr.children, existing);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const numPr = getOrCreateChildElement(pPr, "w:numPr", PPR_ORDER, () => el("w:numPr"));
|
|
104
|
+
numPr.children = [el("w:ilvl", { "w:val": String(value.level) }), el("w:numId", { "w:val": value.numId })];
|
|
105
|
+
}
|
|
106
|
+
insertImageAfter(image) {
|
|
107
|
+
const node = this.live();
|
|
108
|
+
if (this.imageContext === void 0) throw new Error("insertImageAfter requires a paragraph opened through a DocxEditor");
|
|
109
|
+
const drawing = insertImageMedia(this.imageContext.media, this.imageContext.documentRoot, image);
|
|
110
|
+
const run = el("w:r", {}, [drawing]);
|
|
111
|
+
node.children.push(run);
|
|
112
|
+
}
|
|
113
|
+
remove() {
|
|
114
|
+
removeChild(this.container, this.live());
|
|
115
|
+
this.removed = true;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
function buildParagraph(init = {}) {
|
|
119
|
+
const paragraph = el("w:p");
|
|
120
|
+
if (init.styleId !== void 0 || init.alignment !== void 0) {
|
|
121
|
+
const pPr = el("w:pPr");
|
|
122
|
+
if (init.styleId !== void 0) pPr.children.push(el("w:pStyle", { "w:val": init.styleId }));
|
|
123
|
+
if (init.alignment !== void 0) pPr.children.push(el("w:jc", { "w:val": init.alignment === "justify" ? "both" : init.alignment }));
|
|
124
|
+
paragraph.children.push(pPr);
|
|
125
|
+
}
|
|
126
|
+
if (init.text !== void 0) paragraph.children.push(buildRun({ text: init.text }));
|
|
127
|
+
return paragraph;
|
|
128
|
+
}
|
|
129
|
+
//#endregion
|
|
130
|
+
export { DocxParagraph, buildParagraph };
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
|
+
const require_model_units = require("../../model/units.cjs");
|
|
5
|
+
let ooxml_js = require("ooxml.js");
|
|
6
|
+
let document_schema_js = require("document-schema.js");
|
|
7
|
+
//#region src/edit/docx/props.ts
|
|
8
|
+
const RPR_ORDER = [
|
|
9
|
+
"w:rStyle",
|
|
10
|
+
"w:rFonts",
|
|
11
|
+
"w:b",
|
|
12
|
+
"w:bCs",
|
|
13
|
+
"w:i",
|
|
14
|
+
"w:iCs",
|
|
15
|
+
"w:strike",
|
|
16
|
+
"w:color",
|
|
17
|
+
"w:sz",
|
|
18
|
+
"w:szCs",
|
|
19
|
+
"w:u"
|
|
20
|
+
];
|
|
21
|
+
const PPR_ORDER = [
|
|
22
|
+
"w:pStyle",
|
|
23
|
+
"w:numPr",
|
|
24
|
+
"w:spacing",
|
|
25
|
+
"w:ind",
|
|
26
|
+
"w:jc",
|
|
27
|
+
"w:rPr"
|
|
28
|
+
];
|
|
29
|
+
function ensureFirstChild(parent, tag) {
|
|
30
|
+
const existing = require_xml_edit.directChildElement(parent, tag);
|
|
31
|
+
if (existing !== void 0) return existing;
|
|
32
|
+
const created = require_xml_fragment.el(tag);
|
|
33
|
+
parent.children.unshift(created);
|
|
34
|
+
return created;
|
|
35
|
+
}
|
|
36
|
+
const TOGGLE_OFF_VALUES = /* @__PURE__ */ new Set([
|
|
37
|
+
"0",
|
|
38
|
+
"false",
|
|
39
|
+
"off"
|
|
40
|
+
]);
|
|
41
|
+
function getToggle(propsElement, tag) {
|
|
42
|
+
if (propsElement === void 0) return false;
|
|
43
|
+
const element = require_xml_edit.directChildElement(propsElement, tag);
|
|
44
|
+
if (element === void 0) return false;
|
|
45
|
+
const val = (0, ooxml_js.attr)(element, "w:val");
|
|
46
|
+
return val === void 0 || !TOGGLE_OFF_VALUES.has(val.toLowerCase());
|
|
47
|
+
}
|
|
48
|
+
function setToggle(propsElement, tag, value, order) {
|
|
49
|
+
const existing = require_xml_edit.directChildElement(propsElement, tag);
|
|
50
|
+
if (existing === void 0) {
|
|
51
|
+
const created = require_xml_fragment.el(tag, value ? {} : { "w:val": "0" });
|
|
52
|
+
require_xml_edit.insertInSchemaOrder(propsElement, created, order);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (value) require_xml_edit.removeAttr(existing, "w:val");
|
|
56
|
+
else require_xml_edit.setAttr(existing, "w:val", "0");
|
|
57
|
+
}
|
|
58
|
+
function getFontFamily(rPr) {
|
|
59
|
+
if (rPr === void 0) return;
|
|
60
|
+
const rFonts = require_xml_edit.directChildElement(rPr, "w:rFonts");
|
|
61
|
+
return rFonts === void 0 ? void 0 : (0, ooxml_js.attr)(rFonts, "w:ascii");
|
|
62
|
+
}
|
|
63
|
+
function setFontFamily(rPr, family) {
|
|
64
|
+
const rFonts = require_xml_edit.getOrCreateChildElement(rPr, "w:rFonts", RPR_ORDER, () => require_xml_fragment.el("w:rFonts"));
|
|
65
|
+
require_xml_edit.setAttr(rFonts, "w:ascii", family);
|
|
66
|
+
require_xml_edit.setAttr(rFonts, "w:hAnsi", family);
|
|
67
|
+
}
|
|
68
|
+
function getSizePt(rPr) {
|
|
69
|
+
if (rPr === void 0) return;
|
|
70
|
+
const sz = require_xml_edit.directChildElement(rPr, "w:sz");
|
|
71
|
+
if (sz === void 0) return;
|
|
72
|
+
const val = (0, ooxml_js.attr)(sz, "w:val");
|
|
73
|
+
return val === void 0 ? void 0 : require_model_units.halfPointsToPt(Number.parseInt(val, 10));
|
|
74
|
+
}
|
|
75
|
+
function setSizePt(rPr, sizePt) {
|
|
76
|
+
const halfPoints = String(require_model_units.ptToHalfPoints(sizePt));
|
|
77
|
+
const sz = require_xml_edit.getOrCreateChildElement(rPr, "w:sz", RPR_ORDER, () => require_xml_fragment.el("w:sz"));
|
|
78
|
+
require_xml_edit.setAttr(sz, "w:val", halfPoints);
|
|
79
|
+
const szCs = require_xml_edit.getOrCreateChildElement(rPr, "w:szCs", RPR_ORDER, () => require_xml_fragment.el("w:szCs"));
|
|
80
|
+
require_xml_edit.setAttr(szCs, "w:val", halfPoints);
|
|
81
|
+
}
|
|
82
|
+
function getColor(rPr) {
|
|
83
|
+
if (rPr === void 0) return;
|
|
84
|
+
const color = require_xml_edit.directChildElement(rPr, "w:color");
|
|
85
|
+
if (color === void 0) return;
|
|
86
|
+
const val = (0, ooxml_js.attr)(color, "w:val");
|
|
87
|
+
if (val === void 0 || val.toLowerCase() === "auto") return;
|
|
88
|
+
return (0, document_schema_js.rgbHexToColor)(val);
|
|
89
|
+
}
|
|
90
|
+
function setColor(rPr, color) {
|
|
91
|
+
const element = require_xml_edit.getOrCreateChildElement(rPr, "w:color", RPR_ORDER, () => require_xml_fragment.el("w:color"));
|
|
92
|
+
require_xml_edit.setAttr(element, "w:val", (0, document_schema_js.colorToRgbHex)(color));
|
|
93
|
+
}
|
|
94
|
+
function getStyleId(propsElement, tag) {
|
|
95
|
+
if (propsElement === void 0) return;
|
|
96
|
+
const element = require_xml_edit.directChildElement(propsElement, tag);
|
|
97
|
+
return element === void 0 ? void 0 : (0, ooxml_js.attr)(element, "w:val");
|
|
98
|
+
}
|
|
99
|
+
function setStyleId(propsElement, tag, styleId, order) {
|
|
100
|
+
const element = require_xml_edit.getOrCreateChildElement(propsElement, tag, order, () => require_xml_fragment.el(tag));
|
|
101
|
+
require_xml_edit.setAttr(element, "w:val", styleId);
|
|
102
|
+
}
|
|
103
|
+
function getAlignment(pPr) {
|
|
104
|
+
if (pPr === void 0) return;
|
|
105
|
+
const jc = require_xml_edit.directChildElement(pPr, "w:jc");
|
|
106
|
+
if (jc === void 0) return;
|
|
107
|
+
const val = (0, ooxml_js.attr)(jc, "w:val");
|
|
108
|
+
if (val === "left") return "left";
|
|
109
|
+
if (val === "center") return "center";
|
|
110
|
+
if (val === "right") return "right";
|
|
111
|
+
if (val === "both") return "justify";
|
|
112
|
+
}
|
|
113
|
+
function setAlignment(pPr, alignment) {
|
|
114
|
+
const jc = require_xml_edit.getOrCreateChildElement(pPr, "w:jc", PPR_ORDER, () => require_xml_fragment.el("w:jc"));
|
|
115
|
+
require_xml_edit.setAttr(jc, "w:val", alignment === "justify" ? "both" : alignment);
|
|
116
|
+
}
|
|
117
|
+
//#endregion
|
|
118
|
+
exports.PPR_ORDER = PPR_ORDER;
|
|
119
|
+
exports.RPR_ORDER = RPR_ORDER;
|
|
120
|
+
exports.ensureFirstChild = ensureFirstChild;
|
|
121
|
+
exports.getAlignment = getAlignment;
|
|
122
|
+
exports.getColor = getColor;
|
|
123
|
+
exports.getFontFamily = getFontFamily;
|
|
124
|
+
exports.getSizePt = getSizePt;
|
|
125
|
+
exports.getStyleId = getStyleId;
|
|
126
|
+
exports.getToggle = getToggle;
|
|
127
|
+
exports.setAlignment = setAlignment;
|
|
128
|
+
exports.setColor = setColor;
|
|
129
|
+
exports.setFontFamily = setFontFamily;
|
|
130
|
+
exports.setSizePt = setSizePt;
|
|
131
|
+
exports.setStyleId = setStyleId;
|
|
132
|
+
exports.setToggle = setToggle;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { n as LayoutColor } from "../../color-71eoF1Up.cjs";
|
|
2
|
+
import { XmlElement } from "ooxml.js";
|
|
3
|
+
//#region src/edit/docx/props.d.ts
|
|
4
|
+
declare const RPR_ORDER: readonly string[];
|
|
5
|
+
declare const PPR_ORDER: readonly string[];
|
|
6
|
+
declare function ensureFirstChild(parent: XmlElement, tag: string): XmlElement;
|
|
7
|
+
declare function getToggle(propsElement: XmlElement | undefined, tag: string): boolean;
|
|
8
|
+
declare function setToggle(propsElement: XmlElement, tag: string, value: boolean, order: readonly string[]): void;
|
|
9
|
+
declare function getFontFamily(rPr: XmlElement | undefined): string | undefined;
|
|
10
|
+
declare function setFontFamily(rPr: XmlElement, family: string): void;
|
|
11
|
+
declare function getSizePt(rPr: XmlElement | undefined): number | undefined;
|
|
12
|
+
declare function setSizePt(rPr: XmlElement, sizePt: number): void;
|
|
13
|
+
declare function getColor(rPr: XmlElement | undefined): LayoutColor | undefined;
|
|
14
|
+
declare function setColor(rPr: XmlElement, color: LayoutColor): void;
|
|
15
|
+
declare function getStyleId(propsElement: XmlElement | undefined, tag: 'w:pStyle' | 'w:rStyle'): string | undefined;
|
|
16
|
+
declare function setStyleId(propsElement: XmlElement, tag: 'w:pStyle' | 'w:rStyle', styleId: string, order: readonly string[]): void;
|
|
17
|
+
declare function getAlignment(pPr: XmlElement | undefined): 'left' | 'center' | 'right' | 'justify' | undefined;
|
|
18
|
+
declare function setAlignment(pPr: XmlElement, alignment: 'left' | 'center' | 'right' | 'justify'): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { PPR_ORDER, RPR_ORDER, ensureFirstChild, getAlignment, getColor, getFontFamily, getSizePt, getStyleId, getToggle, setAlignment, setColor, setFontFamily, setSizePt, setStyleId, setToggle };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { n as LayoutColor } from "../../color-Bo228AY2.js";
|
|
2
|
+
import { XmlElement } from "ooxml.js";
|
|
3
|
+
//#region src/edit/docx/props.d.ts
|
|
4
|
+
declare const RPR_ORDER: readonly string[];
|
|
5
|
+
declare const PPR_ORDER: readonly string[];
|
|
6
|
+
declare function ensureFirstChild(parent: XmlElement, tag: string): XmlElement;
|
|
7
|
+
declare function getToggle(propsElement: XmlElement | undefined, tag: string): boolean;
|
|
8
|
+
declare function setToggle(propsElement: XmlElement, tag: string, value: boolean, order: readonly string[]): void;
|
|
9
|
+
declare function getFontFamily(rPr: XmlElement | undefined): string | undefined;
|
|
10
|
+
declare function setFontFamily(rPr: XmlElement, family: string): void;
|
|
11
|
+
declare function getSizePt(rPr: XmlElement | undefined): number | undefined;
|
|
12
|
+
declare function setSizePt(rPr: XmlElement, sizePt: number): void;
|
|
13
|
+
declare function getColor(rPr: XmlElement | undefined): LayoutColor | undefined;
|
|
14
|
+
declare function setColor(rPr: XmlElement, color: LayoutColor): void;
|
|
15
|
+
declare function getStyleId(propsElement: XmlElement | undefined, tag: 'w:pStyle' | 'w:rStyle'): string | undefined;
|
|
16
|
+
declare function setStyleId(propsElement: XmlElement, tag: 'w:pStyle' | 'w:rStyle', styleId: string, order: readonly string[]): void;
|
|
17
|
+
declare function getAlignment(pPr: XmlElement | undefined): 'left' | 'center' | 'right' | 'justify' | undefined;
|
|
18
|
+
declare function setAlignment(pPr: XmlElement, alignment: 'left' | 'center' | 'right' | 'justify'): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { PPR_ORDER, RPR_ORDER, ensureFirstChild, getAlignment, getColor, getFontFamily, getSizePt, getStyleId, getToggle, setAlignment, setColor, setFontFamily, setSizePt, setStyleId, setToggle };
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { colorToRgbHex, rgbHexToColor } from "../../model/color.js";
|
|
2
|
+
import { el } from "../../xml/fragment.js";
|
|
3
|
+
import { directChildElement, getOrCreateChildElement, insertInSchemaOrder, removeAttr, setAttr } from "../../xml/edit.js";
|
|
4
|
+
import { halfPointsToPt, ptToHalfPoints } from "../../model/units.js";
|
|
5
|
+
import { attr } from "ooxml.js";
|
|
6
|
+
//#region src/edit/docx/props.ts
|
|
7
|
+
const RPR_ORDER = [
|
|
8
|
+
"w:rStyle",
|
|
9
|
+
"w:rFonts",
|
|
10
|
+
"w:b",
|
|
11
|
+
"w:bCs",
|
|
12
|
+
"w:i",
|
|
13
|
+
"w:iCs",
|
|
14
|
+
"w:strike",
|
|
15
|
+
"w:color",
|
|
16
|
+
"w:sz",
|
|
17
|
+
"w:szCs",
|
|
18
|
+
"w:u"
|
|
19
|
+
];
|
|
20
|
+
const PPR_ORDER = [
|
|
21
|
+
"w:pStyle",
|
|
22
|
+
"w:numPr",
|
|
23
|
+
"w:spacing",
|
|
24
|
+
"w:ind",
|
|
25
|
+
"w:jc",
|
|
26
|
+
"w:rPr"
|
|
27
|
+
];
|
|
28
|
+
function ensureFirstChild(parent, tag) {
|
|
29
|
+
const existing = directChildElement(parent, tag);
|
|
30
|
+
if (existing !== void 0) return existing;
|
|
31
|
+
const created = el(tag);
|
|
32
|
+
parent.children.unshift(created);
|
|
33
|
+
return created;
|
|
34
|
+
}
|
|
35
|
+
const TOGGLE_OFF_VALUES = /* @__PURE__ */ new Set([
|
|
36
|
+
"0",
|
|
37
|
+
"false",
|
|
38
|
+
"off"
|
|
39
|
+
]);
|
|
40
|
+
function getToggle(propsElement, tag) {
|
|
41
|
+
if (propsElement === void 0) return false;
|
|
42
|
+
const element = directChildElement(propsElement, tag);
|
|
43
|
+
if (element === void 0) return false;
|
|
44
|
+
const val = attr(element, "w:val");
|
|
45
|
+
return val === void 0 || !TOGGLE_OFF_VALUES.has(val.toLowerCase());
|
|
46
|
+
}
|
|
47
|
+
function setToggle(propsElement, tag, value, order) {
|
|
48
|
+
const existing = directChildElement(propsElement, tag);
|
|
49
|
+
if (existing === void 0) {
|
|
50
|
+
const created = el(tag, value ? {} : { "w:val": "0" });
|
|
51
|
+
insertInSchemaOrder(propsElement, created, order);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (value) removeAttr(existing, "w:val");
|
|
55
|
+
else setAttr(existing, "w:val", "0");
|
|
56
|
+
}
|
|
57
|
+
function getFontFamily(rPr) {
|
|
58
|
+
if (rPr === void 0) return;
|
|
59
|
+
const rFonts = directChildElement(rPr, "w:rFonts");
|
|
60
|
+
return rFonts === void 0 ? void 0 : attr(rFonts, "w:ascii");
|
|
61
|
+
}
|
|
62
|
+
function setFontFamily(rPr, family) {
|
|
63
|
+
const rFonts = getOrCreateChildElement(rPr, "w:rFonts", RPR_ORDER, () => el("w:rFonts"));
|
|
64
|
+
setAttr(rFonts, "w:ascii", family);
|
|
65
|
+
setAttr(rFonts, "w:hAnsi", family);
|
|
66
|
+
}
|
|
67
|
+
function getSizePt(rPr) {
|
|
68
|
+
if (rPr === void 0) return;
|
|
69
|
+
const sz = directChildElement(rPr, "w:sz");
|
|
70
|
+
if (sz === void 0) return;
|
|
71
|
+
const val = attr(sz, "w:val");
|
|
72
|
+
return val === void 0 ? void 0 : halfPointsToPt(Number.parseInt(val, 10));
|
|
73
|
+
}
|
|
74
|
+
function setSizePt(rPr, sizePt) {
|
|
75
|
+
const halfPoints = String(ptToHalfPoints(sizePt));
|
|
76
|
+
const sz = getOrCreateChildElement(rPr, "w:sz", RPR_ORDER, () => el("w:sz"));
|
|
77
|
+
setAttr(sz, "w:val", halfPoints);
|
|
78
|
+
const szCs = getOrCreateChildElement(rPr, "w:szCs", RPR_ORDER, () => el("w:szCs"));
|
|
79
|
+
setAttr(szCs, "w:val", halfPoints);
|
|
80
|
+
}
|
|
81
|
+
function getColor(rPr) {
|
|
82
|
+
if (rPr === void 0) return;
|
|
83
|
+
const color = directChildElement(rPr, "w:color");
|
|
84
|
+
if (color === void 0) return;
|
|
85
|
+
const val = attr(color, "w:val");
|
|
86
|
+
if (val === void 0 || val.toLowerCase() === "auto") return;
|
|
87
|
+
return rgbHexToColor(val);
|
|
88
|
+
}
|
|
89
|
+
function setColor(rPr, color) {
|
|
90
|
+
const element = getOrCreateChildElement(rPr, "w:color", RPR_ORDER, () => el("w:color"));
|
|
91
|
+
setAttr(element, "w:val", colorToRgbHex(color));
|
|
92
|
+
}
|
|
93
|
+
function getStyleId(propsElement, tag) {
|
|
94
|
+
if (propsElement === void 0) return;
|
|
95
|
+
const element = directChildElement(propsElement, tag);
|
|
96
|
+
return element === void 0 ? void 0 : attr(element, "w:val");
|
|
97
|
+
}
|
|
98
|
+
function setStyleId(propsElement, tag, styleId, order) {
|
|
99
|
+
const element = getOrCreateChildElement(propsElement, tag, order, () => el(tag));
|
|
100
|
+
setAttr(element, "w:val", styleId);
|
|
101
|
+
}
|
|
102
|
+
function getAlignment(pPr) {
|
|
103
|
+
if (pPr === void 0) return;
|
|
104
|
+
const jc = directChildElement(pPr, "w:jc");
|
|
105
|
+
if (jc === void 0) return;
|
|
106
|
+
const val = attr(jc, "w:val");
|
|
107
|
+
if (val === "left") return "left";
|
|
108
|
+
if (val === "center") return "center";
|
|
109
|
+
if (val === "right") return "right";
|
|
110
|
+
if (val === "both") return "justify";
|
|
111
|
+
}
|
|
112
|
+
function setAlignment(pPr, alignment) {
|
|
113
|
+
const jc = getOrCreateChildElement(pPr, "w:jc", PPR_ORDER, () => el("w:jc"));
|
|
114
|
+
setAttr(jc, "w:val", alignment === "justify" ? "both" : alignment);
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { PPR_ORDER, RPR_ORDER, ensureFirstChild, getAlignment, getColor, getFontFamily, getSizePt, getStyleId, getToggle, setAlignment, setColor, setFontFamily, setSizePt, setStyleId, setToggle };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
|
+
const require_edit_docx_props = require("./props.cjs");
|
|
5
|
+
const require_xml_entities = require("../../xml/entities.cjs");
|
|
6
|
+
let ooxml_js = require("ooxml.js");
|
|
7
|
+
let document_schema_js = require("document-schema.js");
|
|
8
|
+
//#region src/edit/docx/run.ts
|
|
9
|
+
function directChild(parent, tag) {
|
|
10
|
+
for (const child of parent.children) if (child.type === "element" && child.tag === tag) return child;
|
|
11
|
+
}
|
|
12
|
+
function appendUElement(rPr, value) {
|
|
13
|
+
const created = require_xml_fragment.el("w:u", { "w:val": value ? "single" : "none" });
|
|
14
|
+
rPr.children.push(created);
|
|
15
|
+
return created;
|
|
16
|
+
}
|
|
17
|
+
function findOrCreateT(run) {
|
|
18
|
+
const existing = directChild(run, "w:t");
|
|
19
|
+
if (existing !== void 0) return existing;
|
|
20
|
+
const created = require_xml_fragment.el("w:t");
|
|
21
|
+
run.children.push(created);
|
|
22
|
+
return created;
|
|
23
|
+
}
|
|
24
|
+
var DocxRun = class {
|
|
25
|
+
container;
|
|
26
|
+
node;
|
|
27
|
+
removed = false;
|
|
28
|
+
constructor(container, node) {
|
|
29
|
+
this.container = container;
|
|
30
|
+
this.node = node;
|
|
31
|
+
}
|
|
32
|
+
live() {
|
|
33
|
+
if (this.removed) throw new Error("this DocxRun has been removed from its paragraph and can no longer be used");
|
|
34
|
+
return this.node;
|
|
35
|
+
}
|
|
36
|
+
rPr(create) {
|
|
37
|
+
const node = this.live();
|
|
38
|
+
return create ? require_edit_docx_props.ensureFirstChild(node, "w:rPr") : directChild(node, "w:rPr");
|
|
39
|
+
}
|
|
40
|
+
get text() {
|
|
41
|
+
return (0, ooxml_js.textContent)(this.live());
|
|
42
|
+
}
|
|
43
|
+
set text(value) {
|
|
44
|
+
const tNode = findOrCreateT(this.live());
|
|
45
|
+
if (require_xml_entities.needsSpacePreserve(value)) require_xml_edit.setAttr(tNode, "xml:space", "preserve");
|
|
46
|
+
tNode.children = [require_xml_fragment.txt(require_xml_entities.encodeXmlText(value))];
|
|
47
|
+
}
|
|
48
|
+
get bold() {
|
|
49
|
+
return require_edit_docx_props.getToggle(this.rPr(false), "w:b");
|
|
50
|
+
}
|
|
51
|
+
set bold(value) {
|
|
52
|
+
require_edit_docx_props.setToggle(this.rPr(true), "w:b", value, require_edit_docx_props.RPR_ORDER);
|
|
53
|
+
}
|
|
54
|
+
get italic() {
|
|
55
|
+
return require_edit_docx_props.getToggle(this.rPr(false), "w:i");
|
|
56
|
+
}
|
|
57
|
+
set italic(value) {
|
|
58
|
+
require_edit_docx_props.setToggle(this.rPr(true), "w:i", value, require_edit_docx_props.RPR_ORDER);
|
|
59
|
+
}
|
|
60
|
+
get underline() {
|
|
61
|
+
const rPr = this.rPr(false);
|
|
62
|
+
const uElement = rPr === void 0 ? void 0 : directChild(rPr, "w:u");
|
|
63
|
+
if (uElement === void 0) return false;
|
|
64
|
+
for (const a of uElement.attributes) if (a.name === "w:val") return a.value !== "none";
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
set underline(value) {
|
|
68
|
+
const rPr = this.rPr(true);
|
|
69
|
+
const existing = directChild(rPr, "w:u");
|
|
70
|
+
if (existing === void 0) {
|
|
71
|
+
appendUElement(rPr, value);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
require_xml_edit.setAttr(existing, "w:val", value ? "single" : "none");
|
|
75
|
+
}
|
|
76
|
+
get fontFamily() {
|
|
77
|
+
return require_edit_docx_props.getFontFamily(this.rPr(false));
|
|
78
|
+
}
|
|
79
|
+
set fontFamily(value) {
|
|
80
|
+
require_edit_docx_props.setFontFamily(this.rPr(true), value);
|
|
81
|
+
}
|
|
82
|
+
get sizePt() {
|
|
83
|
+
return require_edit_docx_props.getSizePt(this.rPr(false));
|
|
84
|
+
}
|
|
85
|
+
set sizePt(value) {
|
|
86
|
+
require_edit_docx_props.setSizePt(this.rPr(true), value);
|
|
87
|
+
}
|
|
88
|
+
get color() {
|
|
89
|
+
return require_edit_docx_props.getColor(this.rPr(false));
|
|
90
|
+
}
|
|
91
|
+
set color(value) {
|
|
92
|
+
require_edit_docx_props.setColor(this.rPr(true), value);
|
|
93
|
+
}
|
|
94
|
+
remove() {
|
|
95
|
+
require_xml_edit.removeChild(this.container, this.live());
|
|
96
|
+
this.removed = true;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
function insertRPrChildInOrder(rPr, child) {
|
|
100
|
+
const rank = require_edit_docx_props.RPR_ORDER.indexOf(child.tag);
|
|
101
|
+
if (rank === -1) {
|
|
102
|
+
rPr.children.push(child);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
for (let i = 0; i < rPr.children.length; i++) {
|
|
106
|
+
const sibling = rPr.children[i];
|
|
107
|
+
if (sibling?.type !== "element") continue;
|
|
108
|
+
const siblingRank = require_edit_docx_props.RPR_ORDER.indexOf(sibling.tag);
|
|
109
|
+
if (siblingRank !== -1 && siblingRank > rank) {
|
|
110
|
+
rPr.children.splice(i, 0, child);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
rPr.children.push(child);
|
|
115
|
+
}
|
|
116
|
+
function buildRun(init = {}) {
|
|
117
|
+
const rPrChildren = [];
|
|
118
|
+
if (init.bold === true) rPrChildren.push(require_xml_fragment.el("w:b"));
|
|
119
|
+
if (init.italic === true) rPrChildren.push(require_xml_fragment.el("w:i"));
|
|
120
|
+
if (init.fontFamily !== void 0) rPrChildren.push(require_xml_fragment.el("w:rFonts", {
|
|
121
|
+
"w:ascii": init.fontFamily,
|
|
122
|
+
"w:hAnsi": init.fontFamily
|
|
123
|
+
}));
|
|
124
|
+
if (init.sizePt !== void 0) {
|
|
125
|
+
const half = String(Math.round(init.sizePt * 2));
|
|
126
|
+
rPrChildren.push(require_xml_fragment.el("w:sz", { "w:val": half }), require_xml_fragment.el("w:szCs", { "w:val": half }));
|
|
127
|
+
}
|
|
128
|
+
if (init.color !== void 0) rPrChildren.push(require_xml_fragment.el("w:color", { "w:val": (0, document_schema_js.colorToRgbHex)(init.color) }));
|
|
129
|
+
const run = require_xml_fragment.el("w:r");
|
|
130
|
+
if (rPrChildren.length > 0 || init.underline === true) {
|
|
131
|
+
const rPr = require_xml_fragment.el("w:rPr");
|
|
132
|
+
for (const child of rPrChildren) insertRPrChildInOrder(rPr, child);
|
|
133
|
+
if (init.underline === true) appendUElement(rPr, true);
|
|
134
|
+
run.children.push(rPr);
|
|
135
|
+
}
|
|
136
|
+
const text = init.text ?? "";
|
|
137
|
+
const tAttrs = require_xml_entities.needsSpacePreserve(text) ? { "xml:space": "preserve" } : {};
|
|
138
|
+
run.children.push(require_xml_fragment.el("w:t", tAttrs, [require_xml_fragment.txt(require_xml_entities.encodeXmlText(text))]));
|
|
139
|
+
return run;
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
exports.DocxRun = DocxRun;
|
|
143
|
+
exports.buildRun = buildRun;
|