office-viewer 0.1.0 → 0.1.4
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 +6 -1
- package/esm/OpenXML.d.ts +19 -0
- package/esm/OpenXML.js +43 -2
- package/esm/Word.d.ts +132 -15
- package/esm/Word.js +239 -54
- package/esm/openxml/ContentType.js +20 -6
- package/esm/openxml/Settings.d.ts +10 -0
- package/esm/openxml/Settings.js +93 -0
- package/esm/openxml/Style.d.ts +1 -1
- package/esm/openxml/Style.js +12 -12
- package/esm/openxml/Theme.js +30 -6
- package/esm/openxml/Types.d.ts +179 -2472
- package/esm/openxml/drawing/Blip.d.ts +7 -0
- package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
- package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
- package/esm/openxml/drawing/CustomGeom.js +17 -0
- package/esm/openxml/drawing/Drawing.d.ts +37 -0
- package/esm/openxml/drawing/Drawing.js +173 -0
- package/esm/openxml/drawing/Geom.d.ts +11 -0
- package/esm/openxml/drawing/Geom.js +34 -0
- package/esm/openxml/drawing/Path.d.ts +37 -0
- package/esm/openxml/drawing/Pic.d.ts +16 -0
- package/esm/openxml/drawing/Pic.js +26 -0
- package/esm/openxml/drawing/Shape.d.ts +20 -0
- package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/esm/openxml/drawing/ShapeProperties.js +119 -0
- package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +4 -1
- package/esm/openxml/drawing/Transform.js +63 -0
- package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/esm/openxml/drawing/diagram/Diagram.js +24 -0
- package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/esm/openxml/drawing/presetShape.d.ts +3 -0
- package/esm/openxml/drawing/presetShape.js +38785 -0
- package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/esm/openxml/drawing/svg/arcToA.js +88 -0
- package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
- package/esm/openxml/drawing/svg/formulas.js +103 -0
- package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/esm/openxml/drawing/svg/generateDefines.js +144 -0
- package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/esm/openxml/drawing/svg/presetVal.js +53 -0
- package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
- package/esm/openxml/math/OMath.d.ts +5 -0
- package/esm/openxml/math/OMath.js +12 -0
- package/esm/openxml/math/convertOOML.d.ts +4 -0
- package/esm/openxml/math/convertOOML.js +13 -0
- package/esm/openxml/math/xsl.d.ts +4 -0
- package/esm/openxml/math/xsl.js +8 -0
- package/esm/openxml/word/Body.js +11 -7
- package/esm/openxml/word/Break.js +1 -3
- package/esm/openxml/word/Font.d.ts +16 -0
- package/esm/openxml/word/Font.js +78 -0
- package/esm/openxml/word/FontTable.d.ts +9 -0
- package/esm/openxml/word/FontTable.js +34 -0
- package/esm/openxml/word/Header.d.ts +11 -0
- package/esm/openxml/word/Header.js +54 -0
- package/esm/openxml/word/Hyperlink.d.ts +1 -0
- package/esm/openxml/word/Hyperlink.js +7 -3
- package/esm/openxml/word/InlineText.js +1 -1
- package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/esm/openxml/word/NoBreakHyphen.js +7 -0
- package/esm/openxml/word/Note.d.ts +12 -0
- package/esm/openxml/word/Note.js +48 -0
- package/esm/openxml/word/Paragraph.d.ts +2 -2
- package/esm/openxml/word/Paragraph.js +10 -9
- package/esm/openxml/word/Pict.d.ts +1 -2
- package/esm/openxml/word/Pict.js +5 -3
- package/esm/openxml/word/Ruby.js +1 -1
- package/esm/openxml/word/Run.d.ts +7 -3
- package/esm/openxml/word/Run.js +28 -4
- package/esm/openxml/word/Section.d.ts +18 -5
- package/esm/openxml/word/Section.js +46 -2
- package/esm/openxml/word/Separator.d.ts +5 -0
- package/esm/openxml/word/Separator.js +10 -0
- package/esm/openxml/word/SoftHyphen.d.ts +5 -0
- package/esm/openxml/word/SoftHyphen.js +10 -0
- package/esm/openxml/word/Tab.d.ts +1 -1
- package/esm/openxml/word/Table.d.ts +4 -9
- package/esm/openxml/word/Table.js +0 -235
- package/esm/openxml/word/WDocument.d.ts +1 -2
- package/esm/openxml/word/WDocument.js +53 -7
- package/esm/openxml/word/numbering/AbstractNum.js +4 -2
- package/esm/openxml/word/numbering/Lvl.js +10 -4
- package/esm/openxml/word/numbering/Num.js +12 -4
- package/esm/openxml/word/numbering/NumberProperties.js +2 -2
- package/esm/openxml/word/numbering/Numbering.js +1 -1
- package/esm/openxml/word/table/Tc.d.ts +1 -22
- package/esm/openxml/word/table/Tc.js +1 -221
- package/esm/openxml/word/table/Tr.d.ts +0 -5
- package/esm/openxml/word/table/Tr.js +0 -97
- package/esm/openxml/word/wps/WPG.d.ts +14 -0
- package/esm/openxml/word/wps/WPG.js +56 -0
- package/esm/openxml/word/wps/WPS.d.ts +18 -0
- package/esm/openxml/word/wps/WPS.js +148 -0
- package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/esm/openxml/word/wps/WPSStyle.js +42 -0
- package/esm/package/PackageParser.d.ts +1 -1
- package/esm/package/XMLPackageParser.d.ts +3 -3
- package/esm/package/ZipPackageParser.d.ts +1 -1
- package/esm/package/ZipPackageParser.js +7 -8
- package/esm/parse/Footnotes.d.ts +3 -0
- package/esm/parse/Footnotes.js +25 -0
- package/esm/parse/colorNameMap.d.ts +6 -0
- package/esm/parse/colorNameMap.js +201 -0
- package/esm/parse/jcToTextAlign.js +1 -0
- package/esm/parse/mergeSdt.d.ts +4 -0
- package/esm/parse/mergeSdt.js +57 -0
- package/esm/parse/modifyColor.d.ts +1 -0
- package/esm/parse/modifyColor.js +106 -0
- package/esm/parse/parseBorder.js +2 -21
- package/esm/parse/parseCellMargin.d.ts +2 -0
- package/esm/parse/parseCellMargin.js +38 -0
- package/esm/parse/parseChildColor.d.ts +5 -0
- package/esm/parse/parseChildColor.js +66 -0
- package/esm/parse/parseColor.d.ts +4 -0
- package/esm/parse/parseColor.js +41 -46
- package/esm/parse/parseEndnotes.d.ts +3 -0
- package/esm/parse/parseEndnotes.js +25 -0
- package/esm/parse/parseFont.js +1 -1
- package/esm/parse/parseInsideBorders.d.ts +9 -0
- package/esm/parse/parseInsideBorders.js +24 -0
- package/esm/parse/parsePr.d.ts +3 -0
- package/esm/parse/parsePr.js +108 -11
- package/esm/parse/parseRelationship.js +1 -1
- package/esm/parse/parseSdt.d.ts +5 -0
- package/esm/parse/parseShape.d.ts +10 -0
- package/esm/parse/parseShape.js +239 -0
- package/esm/parse/parseSize.d.ts +2 -1
- package/esm/parse/parseSize.js +7 -1
- package/esm/parse/parseSpacing.js +1 -1
- package/esm/parse/parseTable.d.ts +3 -0
- package/esm/parse/parseTable.js +62 -0
- package/esm/parse/parseTablePr.d.ts +3 -0
- package/esm/parse/parseTablePr.js +185 -0
- package/esm/parse/parseTblWidth.d.ts +4 -0
- package/esm/parse/parseTblWidth.js +23 -0
- package/esm/parse/parseTc.d.ts +10 -0
- package/esm/parse/parseTc.js +64 -0
- package/esm/parse/parseTcPr.d.ts +5 -0
- package/esm/parse/parseTcPr.js +99 -0
- package/esm/parse/parseTextDirection.js +4 -6
- package/esm/parse/parseTr.d.ts +6 -0
- package/esm/parse/parseTr.js +49 -0
- package/esm/parse/parseTrPr.d.ts +3 -0
- package/esm/parse/parseTrPr.js +59 -0
- package/esm/render/fixAbsolutePosition.d.ts +8 -0
- package/esm/render/renderBody.d.ts +6 -2
- package/esm/render/renderBody.js +184 -30
- package/esm/render/renderBr.d.ts +2 -1
- package/esm/render/renderBr.js +4 -1
- package/esm/render/renderCustGeom.d.ts +4 -0
- package/esm/render/renderCustGeom.js +10 -0
- package/esm/render/renderDocument.d.ts +2 -2
- package/esm/render/renderDocument.js +2 -2
- package/esm/render/renderDrawing.d.ts +3 -2
- package/esm/render/renderDrawing.js +238 -21
- package/esm/render/renderFont.d.ts +5 -0
- package/esm/render/renderFont.js +39 -0
- package/esm/render/renderGeom.d.ts +4 -0
- package/esm/render/renderGeom.js +14 -0
- package/esm/render/renderHeader.d.ts +6 -0
- package/esm/render/renderHeader.js +40 -0
- package/esm/render/renderHyperLink.js +4 -1
- package/esm/render/renderInlineText.js +1 -1
- package/esm/render/renderInstrText.js +1 -1
- package/esm/render/renderMath.d.ts +3 -0
- package/esm/render/renderMath.js +7 -0
- package/esm/render/renderNoBreakHyphen.d.ts +1 -0
- package/esm/render/renderNoBreakHyphen.js +9 -0
- package/esm/render/renderNotes.d.ts +5 -0
- package/esm/render/renderNotes.js +77 -0
- package/esm/render/renderNumbering.js +8 -10
- package/esm/render/renderParagraph.d.ts +1 -1
- package/esm/render/renderParagraph.js +58 -18
- package/esm/render/renderPict.js +5 -10
- package/esm/render/renderRuby.js +1 -1
- package/esm/render/renderRun.d.ts +4 -2
- package/esm/render/renderRun.js +42 -12
- package/esm/render/renderSection.d.ts +3 -2
- package/esm/render/renderSection.js +79 -5
- package/esm/render/renderSeparator.d.ts +1 -0
- package/esm/render/renderSeparator.js +9 -0
- package/esm/render/renderSoftHyphen.d.ts +1 -0
- package/esm/render/renderSoftHyphen.js +9 -0
- package/esm/render/renderStyle.js +36 -35
- package/esm/render/renderTab.d.ts +2 -1
- package/esm/render/renderTab.js +10 -6
- package/esm/render/renderTable.js +23 -20
- package/esm/render/setElementStyle.js +7 -2
- package/esm/render/zindex.d.ts +1 -0
- package/esm/util/blob.js +1 -10
- package/esm/util/color.d.ts +48 -0
- package/esm/util/color.js +211 -0
- package/esm/util/createObject.d.ts +10 -0
- package/esm/util/createObject.js +48 -0
- package/esm/util/dom.d.ts +8 -4
- package/esm/util/dom.js +21 -4
- package/esm/util/get.d.ts +4 -0
- package/esm/util/get.js +18 -0
- package/esm/util/mergeRun.js +1 -1
- package/esm/util/parseSides.d.ts +11 -0
- package/esm/util/print.d.ts +5 -0
- package/esm/util/print.js +54 -0
- package/esm/util/replaceVar.d.ts +10 -0
- package/esm/util/replaceVar.js +215 -0
- package/esm/util/xml.js +4 -1
- package/lib/OpenXML.d.ts +19 -0
- package/lib/OpenXML.js +44 -1
- package/lib/Word.d.ts +132 -15
- package/lib/Word.js +244 -59
- package/lib/openxml/ContentType.js +20 -6
- package/lib/openxml/Settings.d.ts +10 -0
- package/lib/openxml/Settings.js +97 -0
- package/lib/openxml/Style.d.ts +1 -1
- package/lib/openxml/Style.js +15 -15
- package/lib/openxml/Theme.js +31 -7
- package/lib/openxml/Types.d.ts +179 -2472
- package/lib/openxml/drawing/Blip.d.ts +7 -0
- package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
- package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
- package/lib/openxml/drawing/CustomGeom.js +21 -0
- package/lib/openxml/drawing/Drawing.d.ts +37 -0
- package/lib/openxml/drawing/Drawing.js +177 -0
- package/lib/openxml/drawing/Geom.d.ts +11 -0
- package/lib/openxml/drawing/Geom.js +38 -0
- package/lib/openxml/drawing/Path.d.ts +37 -0
- package/lib/openxml/drawing/Pic.d.ts +16 -0
- package/lib/openxml/drawing/Pic.js +30 -0
- package/lib/openxml/drawing/Shape.d.ts +20 -0
- package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/lib/openxml/drawing/ShapeProperties.js +123 -0
- package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +4 -1
- package/lib/openxml/drawing/Transform.js +67 -0
- package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/lib/openxml/drawing/diagram/Diagram.js +28 -0
- package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/lib/openxml/drawing/presetShape.d.ts +3 -0
- package/lib/openxml/drawing/presetShape.js +38789 -0
- package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/lib/openxml/drawing/svg/arcToA.js +92 -0
- package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
- package/lib/openxml/drawing/svg/formulas.js +108 -0
- package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/lib/openxml/drawing/svg/generateDefines.js +148 -0
- package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/lib/openxml/drawing/svg/presetVal.js +57 -0
- package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
- package/lib/openxml/math/OMath.d.ts +5 -0
- package/lib/openxml/math/OMath.js +16 -0
- package/lib/openxml/math/convertOOML.d.ts +4 -0
- package/lib/openxml/math/convertOOML.js +17 -0
- package/lib/openxml/math/xsl.d.ts +4 -0
- package/lib/openxml/math/xsl.js +12 -0
- package/lib/openxml/word/Body.js +11 -7
- package/lib/openxml/word/Break.js +1 -3
- package/lib/openxml/word/Font.d.ts +16 -0
- package/lib/openxml/word/Font.js +83 -0
- package/lib/openxml/word/FontTable.d.ts +9 -0
- package/lib/openxml/word/FontTable.js +38 -0
- package/lib/openxml/word/Header.d.ts +11 -0
- package/lib/openxml/word/Header.js +58 -0
- package/lib/openxml/word/Hyperlink.d.ts +1 -0
- package/lib/openxml/word/Hyperlink.js +8 -4
- package/lib/openxml/word/InlineText.js +2 -2
- package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/lib/openxml/word/NoBreakHyphen.js +11 -0
- package/lib/openxml/word/Note.d.ts +12 -0
- package/lib/openxml/word/Note.js +52 -0
- package/lib/openxml/word/Paragraph.d.ts +2 -2
- package/lib/openxml/word/Paragraph.js +11 -10
- package/lib/openxml/word/Pict.d.ts +1 -2
- package/lib/openxml/word/Pict.js +5 -3
- package/lib/openxml/word/Ruby.js +4 -4
- package/lib/openxml/word/Run.d.ts +7 -3
- package/lib/openxml/word/Run.js +29 -5
- package/lib/openxml/word/Section.d.ts +18 -5
- package/lib/openxml/word/Section.js +47 -3
- package/lib/openxml/word/Separator.d.ts +5 -0
- package/lib/openxml/word/Separator.js +14 -0
- package/lib/openxml/word/SoftHyphen.d.ts +5 -0
- package/lib/openxml/word/SoftHyphen.js +14 -0
- package/lib/openxml/word/Tab.d.ts +1 -1
- package/lib/openxml/word/Table.d.ts +4 -9
- package/lib/openxml/word/Table.js +0 -235
- package/lib/openxml/word/WDocument.d.ts +1 -2
- package/lib/openxml/word/WDocument.js +53 -7
- package/lib/openxml/word/numbering/AbstractNum.js +5 -3
- package/lib/openxml/word/numbering/Lvl.js +11 -5
- package/lib/openxml/word/numbering/Num.js +12 -4
- package/lib/openxml/word/numbering/NumberProperties.js +2 -2
- package/lib/openxml/word/numbering/Numbering.js +3 -3
- package/lib/openxml/word/table/Tc.d.ts +1 -22
- package/lib/openxml/word/table/Tc.js +0 -224
- package/lib/openxml/word/table/Tr.d.ts +0 -5
- package/lib/openxml/word/table/Tr.js +0 -97
- package/lib/openxml/word/wps/WPG.d.ts +14 -0
- package/lib/openxml/word/wps/WPG.js +60 -0
- package/lib/openxml/word/wps/WPS.d.ts +18 -0
- package/lib/openxml/word/wps/WPS.js +152 -0
- package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/lib/openxml/word/wps/WPSStyle.js +46 -0
- package/lib/package/PackageParser.d.ts +1 -1
- package/lib/package/XMLPackageParser.d.ts +3 -3
- package/lib/package/ZipPackageParser.d.ts +1 -1
- package/lib/package/ZipPackageParser.js +7 -8
- package/lib/parse/Footnotes.d.ts +3 -0
- package/lib/parse/Footnotes.js +29 -0
- package/lib/parse/colorNameMap.d.ts +6 -0
- package/lib/parse/colorNameMap.js +205 -0
- package/lib/parse/jcToTextAlign.js +1 -0
- package/lib/parse/mergeSdt.d.ts +4 -0
- package/lib/parse/mergeSdt.js +61 -0
- package/lib/parse/modifyColor.d.ts +1 -0
- package/lib/parse/modifyColor.js +110 -0
- package/lib/parse/parseBorder.js +3 -22
- package/lib/parse/parseCellMargin.d.ts +2 -0
- package/lib/parse/parseCellMargin.js +42 -0
- package/lib/parse/parseChildColor.d.ts +5 -0
- package/lib/parse/parseChildColor.js +70 -0
- package/lib/parse/parseColor.d.ts +4 -0
- package/lib/parse/parseColor.js +41 -45
- package/lib/parse/parseEndnotes.d.ts +3 -0
- package/lib/parse/parseEndnotes.js +29 -0
- package/lib/parse/parseFont.js +2 -2
- package/lib/parse/parseInsideBorders.d.ts +9 -0
- package/lib/parse/parseInsideBorders.js +28 -0
- package/lib/parse/parsePr.d.ts +3 -0
- package/lib/parse/parsePr.js +109 -12
- package/lib/parse/parseRelationship.js +2 -2
- package/lib/parse/parseSdt.d.ts +5 -0
- package/lib/parse/parseShape.d.ts +10 -0
- package/lib/parse/parseShape.js +247 -0
- package/lib/parse/parseSize.d.ts +2 -1
- package/lib/parse/parseSize.js +7 -0
- package/lib/parse/parseSpacing.js +1 -1
- package/lib/parse/parseTable.d.ts +3 -0
- package/lib/parse/parseTable.js +66 -0
- package/lib/parse/parseTablePr.d.ts +3 -0
- package/lib/parse/parseTablePr.js +189 -0
- package/lib/parse/parseTblWidth.d.ts +4 -0
- package/lib/parse/parseTblWidth.js +27 -0
- package/lib/parse/parseTc.d.ts +10 -0
- package/lib/parse/parseTc.js +68 -0
- package/lib/parse/parseTcPr.d.ts +5 -0
- package/lib/parse/parseTcPr.js +104 -0
- package/lib/parse/parseTextDirection.js +4 -6
- package/lib/parse/parseTr.d.ts +6 -0
- package/lib/parse/parseTr.js +53 -0
- package/lib/parse/parseTrPr.d.ts +3 -0
- package/lib/parse/parseTrPr.js +63 -0
- package/lib/render/fixAbsolutePosition.d.ts +8 -0
- package/lib/render/renderBody.d.ts +6 -2
- package/lib/render/renderBody.js +183 -29
- package/lib/render/renderBr.d.ts +2 -1
- package/lib/render/renderBr.js +4 -1
- package/lib/render/renderCustGeom.d.ts +4 -0
- package/lib/render/renderCustGeom.js +14 -0
- package/lib/render/renderDocument.d.ts +2 -2
- package/lib/render/renderDocument.js +2 -2
- package/lib/render/renderDrawing.d.ts +3 -2
- package/lib/render/renderDrawing.js +238 -21
- package/lib/render/renderFont.d.ts +5 -0
- package/lib/render/renderFont.js +43 -0
- package/lib/render/renderGeom.d.ts +4 -0
- package/lib/render/renderGeom.js +18 -0
- package/lib/render/renderHeader.d.ts +6 -0
- package/lib/render/renderHeader.js +44 -0
- package/lib/render/renderHyperLink.js +5 -2
- package/lib/render/renderInlineText.js +2 -2
- package/lib/render/renderInstrText.js +2 -2
- package/lib/render/renderMath.d.ts +3 -0
- package/lib/render/renderMath.js +11 -0
- package/lib/render/renderNoBreakHyphen.d.ts +1 -0
- package/lib/render/renderNoBreakHyphen.js +13 -0
- package/lib/render/renderNotes.d.ts +5 -0
- package/lib/render/renderNotes.js +81 -0
- package/lib/render/renderNumbering.js +9 -11
- package/lib/render/renderParagraph.d.ts +1 -1
- package/lib/render/renderParagraph.js +58 -18
- package/lib/render/renderPict.js +5 -10
- package/lib/render/renderRuby.js +3 -3
- package/lib/render/renderRun.d.ts +4 -2
- package/lib/render/renderRun.js +41 -11
- package/lib/render/renderSection.d.ts +3 -2
- package/lib/render/renderSection.js +79 -5
- package/lib/render/renderSeparator.d.ts +1 -0
- package/lib/render/renderSeparator.js +13 -0
- package/lib/render/renderSoftHyphen.d.ts +1 -0
- package/lib/render/renderSoftHyphen.js +13 -0
- package/lib/render/renderStyle.js +37 -36
- package/lib/render/renderTab.d.ts +2 -1
- package/lib/render/renderTab.js +10 -6
- package/lib/render/renderTable.js +25 -22
- package/lib/render/setElementStyle.js +6 -1
- package/lib/render/zindex.d.ts +1 -0
- package/lib/util/blob.js +0 -10
- package/lib/util/color.d.ts +48 -0
- package/lib/util/color.js +215 -0
- package/lib/util/createObject.d.ts +10 -0
- package/lib/util/createObject.js +54 -0
- package/lib/util/dom.d.ts +8 -4
- package/lib/util/dom.js +24 -5
- package/lib/util/get.d.ts +4 -0
- package/lib/util/get.js +22 -0
- package/lib/util/mergeRun.js +5 -5
- package/lib/util/parseSides.d.ts +11 -0
- package/lib/util/print.d.ts +5 -0
- package/lib/util/print.js +58 -0
- package/lib/util/replaceVar.d.ts +10 -0
- package/lib/util/replaceVar.js +220 -0
- package/lib/util/xml.js +4 -0
- package/package.json +17 -7
- package/esm/node_modules/tslib/tslib.es6.js +0 -120
- package/esm/openxml/Types.js +0 -1003
- package/esm/openxml/word/CustomXml.d.ts +0 -8
- package/esm/openxml/word/SmartTag.d.ts +0 -8
- package/esm/openxml/word/SmartTag.js +0 -18
- package/esm/openxml/word/drawing/Blip.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.js +0 -15
- package/esm/openxml/word/drawing/Pic.d.ts +0 -8
- package/esm/openxml/word/drawing/Pic.js +0 -16
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
- package/esm/openxml/word/drawing/Transform.js +0 -30
- package/lib/node_modules/tslib/tslib.es6.js +0 -129
- package/lib/openxml/Types.js +0 -1005
- package/lib/openxml/word/CustomXml.d.ts +0 -8
- package/lib/openxml/word/SmartTag.d.ts +0 -8
- package/lib/openxml/word/SmartTag.js +0 -22
- package/lib/openxml/word/drawing/Blip.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.js +0 -19
- package/lib/openxml/word/drawing/Pic.d.ts +0 -8
- package/lib/openxml/word/drawing/Pic.js +0 -20
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
- package/lib/openxml/word/drawing/Transform.js +0 -34
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { __values } from 'tslib';
|
|
2
|
+
import { createObject } from './createObject.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 执行变量替换,和普通变量不同,这个支持数组,但因为是提前执行好的,没法再动态生效了
|
|
6
|
+
* 为了避免 word 里不必要的标签要先执行 mergeRun
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* 替换单个文本变量
|
|
10
|
+
*/
|
|
11
|
+
function replaceT(word, t, data) {
|
|
12
|
+
var text = t.textContent || '';
|
|
13
|
+
t.textContent = replaceText(word, text, data);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 替换变量文本
|
|
17
|
+
*/
|
|
18
|
+
function replaceText(word, text, data) {
|
|
19
|
+
var evalVar = word.renderOptions.evalVar;
|
|
20
|
+
if (text.startsWith('{{')) {
|
|
21
|
+
text = text.replace(/^{{/g, '').replace(/}}$/g, '');
|
|
22
|
+
var result = evalVar(text, data);
|
|
23
|
+
if (result !== undefined && result !== null) {
|
|
24
|
+
return String(result);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
console.warn('var error: [', text, '] not found in data');
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
function replaceAlt(word, cNvPr, data) {
|
|
34
|
+
var alt = cNvPr.getAttribute('descr') || '';
|
|
35
|
+
cNvPr.setAttribute('descrVar', replaceText(word, alt, data));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* 替换表格行
|
|
39
|
+
*/
|
|
40
|
+
function replaceTableRow(word, tr) {
|
|
41
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
42
|
+
var evalVar = word.renderOptions.evalVar;
|
|
43
|
+
var data = word.renderOptions.data;
|
|
44
|
+
var table = tr.parentNode;
|
|
45
|
+
var tcs = tr.getElementsByTagName('w:tc');
|
|
46
|
+
var hasLoop = false;
|
|
47
|
+
var loopArray = [];
|
|
48
|
+
try {
|
|
49
|
+
// 查找对应的循环
|
|
50
|
+
for (var tcs_1 = __values(tcs), tcs_1_1 = tcs_1.next(); !tcs_1_1.done; tcs_1_1 = tcs_1.next()) {
|
|
51
|
+
var tc = tcs_1_1.value;
|
|
52
|
+
var ts = tc.getElementsByTagName('w:t');
|
|
53
|
+
try {
|
|
54
|
+
for (var ts_1 = (e_2 = void 0, __values(ts)), ts_1_1 = ts_1.next(); !ts_1_1.done; ts_1_1 = ts_1.next()) {
|
|
55
|
+
var t = ts_1_1.value;
|
|
56
|
+
var text = t.textContent || '';
|
|
57
|
+
if (text.startsWith('{{#')) {
|
|
58
|
+
var arrayNameMatch = /{{#([^\}]+)}}/;
|
|
59
|
+
var arrayMatchResult = arrayNameMatch.exec(text);
|
|
60
|
+
if (arrayMatchResult && arrayMatchResult.length > 0) {
|
|
61
|
+
hasLoop = true;
|
|
62
|
+
var arrayName = arrayMatchResult[1];
|
|
63
|
+
var array = evalVar(arrayName, data);
|
|
64
|
+
if (Array.isArray(array)) {
|
|
65
|
+
loopArray = array;
|
|
66
|
+
}
|
|
67
|
+
// 去掉这个循环变量
|
|
68
|
+
t.textContent = t.textContent.replace("{{#".concat(arrayName, "}}"), '');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (text.indexOf('{{/}}')) {
|
|
72
|
+
// 去掉结束变量
|
|
73
|
+
t.textContent = t.textContent.replace('{{/}}', '');
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
78
|
+
finally {
|
|
79
|
+
try {
|
|
80
|
+
if (ts_1_1 && !ts_1_1.done && (_b = ts_1.return)) _b.call(ts_1);
|
|
81
|
+
}
|
|
82
|
+
finally { if (e_2) throw e_2.error; }
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
87
|
+
finally {
|
|
88
|
+
try {
|
|
89
|
+
if (tcs_1_1 && !tcs_1_1.done && (_a = tcs_1.return)) _a.call(tcs_1);
|
|
90
|
+
}
|
|
91
|
+
finally { if (e_1) throw e_1.error; }
|
|
92
|
+
}
|
|
93
|
+
if (hasLoop) {
|
|
94
|
+
try {
|
|
95
|
+
// 有循环,复制多行
|
|
96
|
+
for (var loopArray_1 = __values(loopArray), loopArray_1_1 = loopArray_1.next(); !loopArray_1_1.done; loopArray_1_1 = loopArray_1.next()) {
|
|
97
|
+
var item = loopArray_1_1.value;
|
|
98
|
+
var newTr = cloneTr(tr);
|
|
99
|
+
var ts = newTr.getElementsByTagName('w:t');
|
|
100
|
+
// 将 item 加入上下文
|
|
101
|
+
var rowData = createObject(data, item);
|
|
102
|
+
try {
|
|
103
|
+
for (var ts_2 = (e_4 = void 0, __values(ts)), ts_2_1 = ts_2.next(); !ts_2_1.done; ts_2_1 = ts_2.next()) {
|
|
104
|
+
var t = ts_2_1.value;
|
|
105
|
+
replaceT(word, t, rowData);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
109
|
+
finally {
|
|
110
|
+
try {
|
|
111
|
+
if (ts_2_1 && !ts_2_1.done && (_d = ts_2.return)) _d.call(ts_2);
|
|
112
|
+
}
|
|
113
|
+
finally { if (e_4) throw e_4.error; }
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
// 替换图片里的变量
|
|
117
|
+
for (var _f = (e_5 = void 0, __values(newTr.getElementsByTagName('pic:cNvPr'))), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
118
|
+
var cNvPr = _g.value;
|
|
119
|
+
replaceAlt(word, cNvPr, rowData);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
123
|
+
finally {
|
|
124
|
+
try {
|
|
125
|
+
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
126
|
+
}
|
|
127
|
+
finally { if (e_5) throw e_5.error; }
|
|
128
|
+
}
|
|
129
|
+
table.insertBefore(newTr, tr);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
133
|
+
finally {
|
|
134
|
+
try {
|
|
135
|
+
if (loopArray_1_1 && !loopArray_1_1.done && (_c = loopArray_1.return)) _c.call(loopArray_1);
|
|
136
|
+
}
|
|
137
|
+
finally { if (e_3) throw e_3.error; }
|
|
138
|
+
}
|
|
139
|
+
// 删除原来的行
|
|
140
|
+
table.removeChild(tr);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* 克隆行,并进行一些清理
|
|
145
|
+
*/
|
|
146
|
+
function cloneTr(tr) {
|
|
147
|
+
var e_6, _a, e_7, _b;
|
|
148
|
+
var _c;
|
|
149
|
+
var newTr = tr.cloneNode(true);
|
|
150
|
+
// 去掉 tr 里的属性,感觉可能会有问题
|
|
151
|
+
removeAllAttr(newTr);
|
|
152
|
+
var ps = [].slice.call(newTr.getElementsByTagName('w:p'));
|
|
153
|
+
try {
|
|
154
|
+
for (var ps_1 = __values(ps), ps_1_1 = ps_1.next(); !ps_1_1.done; ps_1_1 = ps_1.next()) {
|
|
155
|
+
var p = ps_1_1.value;
|
|
156
|
+
removeAllAttr(p);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (ps_1_1 && !ps_1_1.done && (_a = ps_1.return)) _a.call(ps_1);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_6) throw e_6.error; }
|
|
165
|
+
}
|
|
166
|
+
// cnfStyles 基本上都是错的所以删了
|
|
167
|
+
var cnfStyles = [].slice.call(newTr.getElementsByTagName('w:cnfStyle'));
|
|
168
|
+
try {
|
|
169
|
+
for (var cnfStyles_1 = __values(cnfStyles), cnfStyles_1_1 = cnfStyles_1.next(); !cnfStyles_1_1.done; cnfStyles_1_1 = cnfStyles_1.next()) {
|
|
170
|
+
var cnfStyle = cnfStyles_1_1.value;
|
|
171
|
+
(_c = cnfStyle.parentElement) === null || _c === void 0 ? void 0 : _c.removeChild(cnfStyle);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
175
|
+
finally {
|
|
176
|
+
try {
|
|
177
|
+
if (cnfStyles_1_1 && !cnfStyles_1_1.done && (_b = cnfStyles_1.return)) _b.call(cnfStyles_1);
|
|
178
|
+
}
|
|
179
|
+
finally { if (e_7) throw e_7.error; }
|
|
180
|
+
}
|
|
181
|
+
return newTr;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* 删掉所有属性,虽然不知道为啥有些不生效
|
|
185
|
+
*/
|
|
186
|
+
function removeAllAttr(node) {
|
|
187
|
+
while (node.attributes.length > 0) {
|
|
188
|
+
node.removeAttributeNode(node.attributes[0]);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* 替换表格,目前只支持行
|
|
193
|
+
*/
|
|
194
|
+
function replaceTable(word, documentData) {
|
|
195
|
+
var e_8, _a;
|
|
196
|
+
var trs = [].slice.call(documentData.getElementsByTagName('w:tr'));
|
|
197
|
+
try {
|
|
198
|
+
for (var trs_1 = __values(trs), trs_1_1 = trs_1.next(); !trs_1_1.done; trs_1_1 = trs_1.next()) {
|
|
199
|
+
var tr = trs_1_1.value;
|
|
200
|
+
replaceTableRow(word, tr);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
204
|
+
finally {
|
|
205
|
+
try {
|
|
206
|
+
if (trs_1_1 && !trs_1_1.done && (_a = trs_1.return)) _a.call(trs_1);
|
|
207
|
+
}
|
|
208
|
+
finally { if (e_8) throw e_8.error; }
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function replaceVar(word, documentData) {
|
|
212
|
+
replaceTable(word, documentData);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export { replaceT, replaceVar };
|
package/esm/util/xml.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 解析 xml
|
|
3
3
|
*/
|
|
4
|
+
function parseXML(content) {
|
|
5
|
+
return new DOMParser().parseFromString(content, 'application/xml');
|
|
6
|
+
}
|
|
4
7
|
/**
|
|
5
8
|
* 构建 xml 文本
|
|
6
9
|
*/
|
|
@@ -9,4 +12,4 @@ function buildXML(doc) {
|
|
|
9
12
|
return serializer.serializeToString(doc);
|
|
10
13
|
}
|
|
11
14
|
|
|
12
|
-
export { buildXML };
|
|
15
|
+
export { buildXML, parseXML };
|
package/lib/OpenXML.d.ts
CHANGED
|
@@ -18,4 +18,23 @@ export declare function getValNumber(element: Element): number;
|
|
|
18
18
|
export declare function normalizeBoolean(value: string | boolean | null, defaultValue?: boolean): boolean;
|
|
19
19
|
export declare function getValBoolean(element: Element, defaultValue?: boolean): boolean;
|
|
20
20
|
export declare function getAttrBoolean(element: Element, attr: string, defaultValue?: boolean): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* 获取属性值,转成数字
|
|
23
|
+
*
|
|
24
|
+
* @param attr 属性名
|
|
25
|
+
* @param defaultValue 默认值
|
|
26
|
+
* @returns 解析后的数字
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAttrNumber(element: Element, attr: string, defaultValue?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* 获取百分比值,没测过
|
|
31
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/ST_Percentage.html
|
|
32
|
+
* https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_Percentage_topic_ID0EY3XNB.html#topic_ID0EY3XNB
|
|
33
|
+
*
|
|
34
|
+
* @returns 0-1 之间的小数
|
|
35
|
+
*/
|
|
36
|
+
export declare function getAttrPercent(element: Element, attr: string): number;
|
|
37
|
+
/**
|
|
38
|
+
* 获取属性的 hex 值
|
|
39
|
+
*/
|
|
21
40
|
export declare function getValHex(element: Element): number;
|
package/lib/OpenXML.js
CHANGED
|
@@ -9,7 +9,10 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
9
9
|
* 获取 w:val 的值
|
|
10
10
|
*/
|
|
11
11
|
function getVal(element) {
|
|
12
|
-
return element.getAttribute('w:val') ||
|
|
12
|
+
return (element.getAttribute('w:val') ||
|
|
13
|
+
element.getAttribute('w14:val') ||
|
|
14
|
+
element.getAttribute('val') ||
|
|
15
|
+
'');
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* 获取 w:val 的值,转成 number 类型
|
|
@@ -57,11 +60,51 @@ function getAttrBoolean(element, attr, defaultValue) {
|
|
|
57
60
|
if (defaultValue === void 0) { defaultValue = true; }
|
|
58
61
|
return normalizeBoolean(element.getAttribute(attr), defaultValue);
|
|
59
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* 获取属性值,转成数字
|
|
65
|
+
*
|
|
66
|
+
* @param attr 属性名
|
|
67
|
+
* @param defaultValue 默认值
|
|
68
|
+
* @returns 解析后的数字
|
|
69
|
+
*/
|
|
70
|
+
function getAttrNumber(element, attr, defaultValue) {
|
|
71
|
+
if (defaultValue === void 0) { defaultValue = 0; }
|
|
72
|
+
var value = element.getAttribute(attr);
|
|
73
|
+
if (value) {
|
|
74
|
+
return parseInt(value, 10);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return defaultValue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 获取百分比值,没测过
|
|
82
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/ST_Percentage.html
|
|
83
|
+
* https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_ST_Percentage_topic_ID0EY3XNB.html#topic_ID0EY3XNB
|
|
84
|
+
*
|
|
85
|
+
* @returns 0-1 之间的小数
|
|
86
|
+
*/
|
|
87
|
+
function getAttrPercent(element, attr) {
|
|
88
|
+
var value = element.getAttribute(attr);
|
|
89
|
+
if (value) {
|
|
90
|
+
if (value.endsWith('%')) {
|
|
91
|
+
return parseInt(value, 10) / 100;
|
|
92
|
+
}
|
|
93
|
+
var num = parseInt(value, 10);
|
|
94
|
+
return num / 100000;
|
|
95
|
+
}
|
|
96
|
+
return 1;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 获取属性的 hex 值
|
|
100
|
+
*/
|
|
60
101
|
function getValHex(element) {
|
|
61
102
|
return parseInt(getVal(element) || '0', 16);
|
|
62
103
|
}
|
|
63
104
|
|
|
64
105
|
exports.getAttrBoolean = getAttrBoolean;
|
|
106
|
+
exports.getAttrNumber = getAttrNumber;
|
|
107
|
+
exports.getAttrPercent = getAttrPercent;
|
|
65
108
|
exports.getVal = getVal;
|
|
66
109
|
exports.getValBoolean = getValBoolean;
|
|
67
110
|
exports.getValHex = getValHex;
|
package/lib/Word.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FontTable } from './openxml/word/FontTable';
|
|
1
2
|
/**
|
|
2
3
|
* 总入口,它将包括所有 word 文档信息,后续渲染的时候依赖它来获取关联信息
|
|
3
4
|
*/
|
|
@@ -8,6 +9,9 @@ import { Theme } from './openxml/Theme';
|
|
|
8
9
|
import { Numbering } from './openxml/word/numbering/Numbering';
|
|
9
10
|
import { PackageParser } from './package/PackageParser';
|
|
10
11
|
import { Paragraph } from './openxml/word/Paragraph';
|
|
12
|
+
import { Note } from './openxml/word/Note';
|
|
13
|
+
import { Section } from './openxml/word/Section';
|
|
14
|
+
import { Settings } from './openxml/Settings';
|
|
11
15
|
/**
|
|
12
16
|
* 渲染配置
|
|
13
17
|
*/
|
|
@@ -16,16 +20,10 @@ export interface WordRenderOptions {
|
|
|
16
20
|
* css 类前缀
|
|
17
21
|
*/
|
|
18
22
|
classPrefix: string;
|
|
19
|
-
/** 图片是否使用 data url */
|
|
20
|
-
imageDataURL: boolean;
|
|
21
23
|
/**
|
|
22
24
|
* 列表使用字体渲染,需要自行引入 Windings 字体
|
|
23
25
|
*/
|
|
24
26
|
bulletUseFont: boolean;
|
|
25
|
-
/**
|
|
26
|
-
* 是否包裹出页面效果
|
|
27
|
-
*/
|
|
28
|
-
inWrap: boolean;
|
|
29
27
|
/**
|
|
30
28
|
* 是否忽略文档宽度设置
|
|
31
29
|
*/
|
|
@@ -47,9 +45,13 @@ export interface WordRenderOptions {
|
|
|
47
45
|
*/
|
|
48
46
|
enableVar?: boolean;
|
|
49
47
|
/**
|
|
50
|
-
*
|
|
48
|
+
* 上下文数据,用于替换变量
|
|
49
|
+
*/
|
|
50
|
+
data?: any;
|
|
51
|
+
/**
|
|
52
|
+
* 进行表达式计算的函数,第一个参数是文本变量,第二个参数是上下文数据
|
|
51
53
|
*/
|
|
52
|
-
|
|
54
|
+
evalVar: (text: string, data?: Object) => Object | string | number | boolean | null | undefined;
|
|
53
55
|
/**
|
|
54
56
|
* 是否开启调试模式
|
|
55
57
|
*/
|
|
@@ -62,6 +64,59 @@ export interface WordRenderOptions {
|
|
|
62
64
|
* 强制行高,设置之后所有文本都使用这个行高,可以优化排版效果
|
|
63
65
|
*/
|
|
64
66
|
forceLineHeight?: string;
|
|
67
|
+
/**
|
|
68
|
+
* 打印等待时间,单位毫秒,可能有的文档有很多图片,如果等待时间太短图片还没加载完,所以加这个配置项可控
|
|
69
|
+
*/
|
|
70
|
+
printWaitTime?: number;
|
|
71
|
+
/**
|
|
72
|
+
* 是否使用分页的方式来渲染内容,使用这种方式还原度更高,但不支持打印功能
|
|
73
|
+
* 设置后会自动将 ignoreHeight 和 ignoreWidth 设置为 false
|
|
74
|
+
*/
|
|
75
|
+
page?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* 每页之间的间距
|
|
78
|
+
*/
|
|
79
|
+
pageMarginBottom?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 页面背景色
|
|
82
|
+
*/
|
|
83
|
+
pageBackground?: string;
|
|
84
|
+
/**
|
|
85
|
+
* 是否显示页面阴影,只有在 page 为 true 的时候才生效
|
|
86
|
+
*/
|
|
87
|
+
pageShadow?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* 显示页面包裹效果,只有在 page 为 true 的时候才生效
|
|
90
|
+
*/
|
|
91
|
+
pageWrap?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* 页面包裹宽度
|
|
94
|
+
*/
|
|
95
|
+
pageWrapPadding?: number;
|
|
96
|
+
/**
|
|
97
|
+
* 页面包裹背景色
|
|
98
|
+
*/
|
|
99
|
+
pageWrapBackground?: string;
|
|
100
|
+
/**
|
|
101
|
+
* 缩放比例,取值 0-1 之间
|
|
102
|
+
*/
|
|
103
|
+
zoom?: number;
|
|
104
|
+
/**
|
|
105
|
+
* 自适应宽度,如果设置了 zoom,那么 zoom 优先级更高,这个设置只在 ignoreWidth 为 false 的时候生效
|
|
106
|
+
*/
|
|
107
|
+
zoomFitWidth?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* 打印可以覆盖其它配置
|
|
110
|
+
*/
|
|
111
|
+
printOptions?: WordRenderOptions;
|
|
112
|
+
/**
|
|
113
|
+
* 是否渲染 header
|
|
114
|
+
*/
|
|
115
|
+
renderHeader?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* 是否渲染 footer
|
|
118
|
+
*/
|
|
119
|
+
renderFooter?: boolean;
|
|
65
120
|
}
|
|
66
121
|
export default class Word {
|
|
67
122
|
/**
|
|
@@ -88,12 +143,28 @@ export default class Word {
|
|
|
88
143
|
* 解析 numbering.xml 里的数据
|
|
89
144
|
*/
|
|
90
145
|
numbering: Numbering;
|
|
146
|
+
settings: Settings;
|
|
91
147
|
/**
|
|
92
148
|
* 解析 styles.xml 里的数据
|
|
93
149
|
*/
|
|
94
150
|
styles: Styles;
|
|
95
151
|
renderOptions: WordRenderOptions;
|
|
152
|
+
/**
|
|
153
|
+
* 全局关系表
|
|
154
|
+
*/
|
|
96
155
|
relationships: Record<string, Relationship>;
|
|
156
|
+
/**
|
|
157
|
+
* 文档关系表
|
|
158
|
+
*/
|
|
159
|
+
documentRels: Record<string, Relationship>;
|
|
160
|
+
/**
|
|
161
|
+
* 当前文档使用的关系表,比如 headers.xml 里的图片是
|
|
162
|
+
*/
|
|
163
|
+
currentDocumentRels: Record<string, Relationship>;
|
|
164
|
+
/**
|
|
165
|
+
* 字体关系表
|
|
166
|
+
*/
|
|
167
|
+
fontTableRels: Record<string, Relationship>;
|
|
97
168
|
/**
|
|
98
169
|
* 样式名映射,因为自定义样式名有可能不符合 css 命名规范,因此实际使用这个名字
|
|
99
170
|
*/
|
|
@@ -102,6 +173,10 @@ export default class Word {
|
|
|
102
173
|
* 用于自动生成样式名时的计数,保证每次都是唯一的
|
|
103
174
|
*/
|
|
104
175
|
styleIdNum: number;
|
|
176
|
+
/**
|
|
177
|
+
* 内置字体标
|
|
178
|
+
*/
|
|
179
|
+
fontTable?: FontTable;
|
|
105
180
|
/**
|
|
106
181
|
* 渲染根节点
|
|
107
182
|
*/
|
|
@@ -111,6 +186,12 @@ export default class Word {
|
|
|
111
186
|
* 当前渲染的段落,主要用于获取 fldSimple
|
|
112
187
|
*/
|
|
113
188
|
currentParagraph: Paragraph;
|
|
189
|
+
footNotes: Record<string, Note>;
|
|
190
|
+
endNotes: Record<string, Note>;
|
|
191
|
+
/**
|
|
192
|
+
* 当前页码
|
|
193
|
+
*/
|
|
194
|
+
currentPage: 0;
|
|
114
195
|
/**
|
|
115
196
|
* 构建 word
|
|
116
197
|
*
|
|
@@ -120,6 +201,14 @@ export default class Word {
|
|
|
120
201
|
*/
|
|
121
202
|
constructor(docFile: ArrayBuffer | string, renderOptions?: Partial<WordRenderOptions>, parser?: PackageParser);
|
|
122
203
|
inited: boolean;
|
|
204
|
+
/**
|
|
205
|
+
* 分页标记,如果为 true,那么在渲染的时候会强制分页
|
|
206
|
+
*/
|
|
207
|
+
breakPage: boolean;
|
|
208
|
+
/**
|
|
209
|
+
* 当前渲染的段,因为很多渲染需要,所以为了避免大量传参,这里直接挂在这里
|
|
210
|
+
*/
|
|
211
|
+
currentSection: Section;
|
|
123
212
|
/**
|
|
124
213
|
* 初始化一些公共资源,比如
|
|
125
214
|
*/
|
|
@@ -132,6 +221,14 @@ export default class Word {
|
|
|
132
221
|
* 解析全局样式
|
|
133
222
|
*/
|
|
134
223
|
initStyle(): void;
|
|
224
|
+
/**
|
|
225
|
+
* 解析全局配置
|
|
226
|
+
*/
|
|
227
|
+
initSettings(): void;
|
|
228
|
+
/**
|
|
229
|
+
* 解析字体表
|
|
230
|
+
*/
|
|
231
|
+
initFontTable(): void;
|
|
135
232
|
/**
|
|
136
233
|
* 解析关系
|
|
137
234
|
*/
|
|
@@ -144,18 +241,29 @@ export default class Word {
|
|
|
144
241
|
* 解析 numbering
|
|
145
242
|
*/
|
|
146
243
|
initNumbering(): void;
|
|
244
|
+
initNotes(): void;
|
|
147
245
|
/**
|
|
148
|
-
*
|
|
246
|
+
* 获取全局关系
|
|
149
247
|
*/
|
|
150
248
|
getRelationship(id?: string): Relationship | null;
|
|
151
249
|
/**
|
|
152
|
-
*
|
|
250
|
+
* 获取文档对应的关系
|
|
251
|
+
*/
|
|
252
|
+
getDocumentRels(id?: string): Relationship | null;
|
|
253
|
+
/**
|
|
254
|
+
* 获取字体对应的关系
|
|
255
|
+
*/
|
|
256
|
+
getFontTableRels(id?: string): Relationship | null;
|
|
257
|
+
/**
|
|
258
|
+
* 进行单个文本替换
|
|
153
259
|
*/
|
|
154
260
|
replaceText(text: string): string;
|
|
261
|
+
loadWordRelXML(relation: Relationship): Document;
|
|
155
262
|
/**
|
|
156
263
|
* 加载图片
|
|
157
264
|
*/
|
|
158
|
-
loadImage(relation: Relationship):
|
|
265
|
+
loadImage(relation: Relationship): string | null;
|
|
266
|
+
loadFont(rId: string, key: string): string | null;
|
|
159
267
|
/**
|
|
160
268
|
* 解析 html
|
|
161
269
|
*/
|
|
@@ -171,21 +279,29 @@ export default class Word {
|
|
|
171
279
|
/**
|
|
172
280
|
* 添加新样式,主要用于表格的单元格样式
|
|
173
281
|
*/
|
|
174
|
-
appendStyle(style
|
|
282
|
+
appendStyle(style?: string): void;
|
|
175
283
|
/**
|
|
176
284
|
* 返回样式表名及它的父级样式表名
|
|
177
285
|
* @param styleId 样式表里的 style 名称
|
|
178
286
|
* @returns 返回 className 数组
|
|
179
287
|
*/
|
|
180
288
|
getStyleClassName(stylId: string): string[];
|
|
289
|
+
/**
|
|
290
|
+
* 根据 id 获取样式
|
|
291
|
+
* @param styleId
|
|
292
|
+
*/
|
|
293
|
+
getStyle(styleId: string): import("./openxml/Style").Style;
|
|
181
294
|
/**
|
|
182
295
|
* 渲染时的 css 类前缀
|
|
183
296
|
*/
|
|
184
297
|
getClassPrefix(): string;
|
|
185
298
|
/**
|
|
186
|
-
*
|
|
299
|
+
* 获取主题色
|
|
187
300
|
*/
|
|
188
301
|
getThemeColor(name: string): string;
|
|
302
|
+
/**
|
|
303
|
+
* 添加类,自动加上前缀
|
|
304
|
+
*/
|
|
189
305
|
addClass(element: HTMLElement, className: string): void;
|
|
190
306
|
/**
|
|
191
307
|
* 更新页面中的变量,这个要在 render 后运行
|
|
@@ -198,11 +314,12 @@ export default class Word {
|
|
|
198
314
|
/**
|
|
199
315
|
* 打印功能
|
|
200
316
|
*/
|
|
201
|
-
print(): Promise<
|
|
317
|
+
print(): Promise<any>;
|
|
202
318
|
/**
|
|
203
319
|
* 渲染文档入口
|
|
204
320
|
*
|
|
205
321
|
* @param root 渲染的根节点
|
|
322
|
+
* @param renderOptionsOverride 临时覆盖某些渲选项
|
|
206
323
|
*/
|
|
207
|
-
render(root: HTMLElement): Promise<void>;
|
|
324
|
+
render(root: HTMLElement, renderOptionsOverride?: Partial<WordRenderOptions>): Promise<void>;
|
|
208
325
|
}
|