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
package/lib/Word.js
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var FontTable = require('./openxml/word/FontTable.js');
|
|
6
7
|
var parseRelationship = require('./parse/parseRelationship.js');
|
|
7
8
|
var ContentType = require('./openxml/ContentType.js');
|
|
8
9
|
var Style = require('./openxml/Style.js');
|
|
@@ -17,20 +18,39 @@ var WDocument = require('./openxml/word/WDocument.js');
|
|
|
17
18
|
var renderRun = require('./render/renderRun.js');
|
|
18
19
|
var ZipPackageParser = require('./package/ZipPackageParser.js');
|
|
19
20
|
var xml = require('./util/xml.js');
|
|
21
|
+
var Font = require('./openxml/word/Font.js');
|
|
22
|
+
var renderFont = require('./render/renderFont.js');
|
|
23
|
+
var replaceVar = require('./util/replaceVar.js');
|
|
24
|
+
var Footnotes = require('./parse/Footnotes.js');
|
|
25
|
+
var parseEndnotes = require('./parse/parseEndnotes.js');
|
|
26
|
+
var renderNotes = require('./render/renderNotes.js');
|
|
27
|
+
var print = require('./util/print.js');
|
|
28
|
+
var Settings = require('./openxml/Settings.js');
|
|
29
|
+
var get = require('./util/get.js');
|
|
20
30
|
|
|
21
|
-
/**
|
|
22
|
-
* 总入口,它将包括所有 word 文档信息,后续渲染的时候依赖它来获取关联信息
|
|
23
|
-
*/
|
|
24
31
|
var defaultRenderOptions = {
|
|
25
|
-
imageDataURL: false,
|
|
26
32
|
classPrefix: 'docx-viewer',
|
|
27
|
-
|
|
33
|
+
page: false,
|
|
34
|
+
pageWrap: true,
|
|
28
35
|
bulletUseFont: true,
|
|
29
36
|
ignoreHeight: true,
|
|
30
|
-
ignoreWidth:
|
|
37
|
+
ignoreWidth: false,
|
|
31
38
|
minLineHeight: 1.0,
|
|
32
39
|
enableVar: false,
|
|
33
|
-
debug: false
|
|
40
|
+
debug: false,
|
|
41
|
+
pageWrapPadding: 20,
|
|
42
|
+
pageMarginBottom: 20,
|
|
43
|
+
pageShadow: true,
|
|
44
|
+
pageBackground: '#FFFFFF',
|
|
45
|
+
pageWrapBackground: '#ECECEC',
|
|
46
|
+
printWaitTime: 100,
|
|
47
|
+
zoomFitWidth: false,
|
|
48
|
+
renderHeader: true,
|
|
49
|
+
renderFooter: true,
|
|
50
|
+
data: {},
|
|
51
|
+
evalVar: function (path, data) {
|
|
52
|
+
return get.get(data, path);
|
|
53
|
+
}
|
|
34
54
|
};
|
|
35
55
|
var Word = /** @class */ (function () {
|
|
36
56
|
/**
|
|
@@ -55,11 +75,21 @@ var Word = /** @class */ (function () {
|
|
|
55
75
|
*/
|
|
56
76
|
this.styleIdNum = 0;
|
|
57
77
|
this.wrapClassName = 'docx-viewer-wrapper';
|
|
78
|
+
this.footNotes = {};
|
|
79
|
+
this.endNotes = {};
|
|
58
80
|
this.inited = false;
|
|
81
|
+
/**
|
|
82
|
+
* 分页标记,如果为 true,那么在渲染的时候会强制分页
|
|
83
|
+
*/
|
|
84
|
+
this.breakPage = false;
|
|
59
85
|
parser.load(docFile);
|
|
60
86
|
this.id = Word.globalId++;
|
|
61
87
|
this.parser = parser;
|
|
62
|
-
this.renderOptions =
|
|
88
|
+
this.renderOptions = tslib.__assign(tslib.__assign({}, defaultRenderOptions), renderOptions);
|
|
89
|
+
if (this.renderOptions.page) {
|
|
90
|
+
this.renderOptions.ignoreHeight = false;
|
|
91
|
+
this.renderOptions.ignoreWidth = false;
|
|
92
|
+
}
|
|
63
93
|
}
|
|
64
94
|
/**
|
|
65
95
|
* 初始化一些公共资源,比如
|
|
@@ -70,10 +100,14 @@ var Word = /** @class */ (function () {
|
|
|
70
100
|
}
|
|
71
101
|
// 这个必须在最前面,因为后面很多依赖它来查找文件的
|
|
72
102
|
this.initContentType();
|
|
103
|
+
// relation 需要排第二
|
|
104
|
+
this.initRelation();
|
|
105
|
+
this.initSettings();
|
|
73
106
|
this.initTheme();
|
|
107
|
+
this.initFontTable();
|
|
74
108
|
this.initStyle();
|
|
75
|
-
this.initRelation();
|
|
76
109
|
this.initNumbering();
|
|
110
|
+
this.initNotes();
|
|
77
111
|
this.inited = true;
|
|
78
112
|
};
|
|
79
113
|
/**
|
|
@@ -82,7 +116,7 @@ var Word = /** @class */ (function () {
|
|
|
82
116
|
Word.prototype.initTheme = function () {
|
|
83
117
|
var e_1, _a;
|
|
84
118
|
try {
|
|
85
|
-
for (var _b =
|
|
119
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
86
120
|
var override = _c.value;
|
|
87
121
|
if (override.partName.startsWith('/word/theme')) {
|
|
88
122
|
var theme = this.parser.getXML(override.partName);
|
|
@@ -104,7 +138,7 @@ var Word = /** @class */ (function () {
|
|
|
104
138
|
Word.prototype.initStyle = function () {
|
|
105
139
|
var e_2, _a;
|
|
106
140
|
try {
|
|
107
|
-
for (var _b =
|
|
141
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
108
142
|
var override = _c.value;
|
|
109
143
|
if (override.partName.startsWith('/word/styles.xml')) {
|
|
110
144
|
this.styles = Style.parseStyles(this, this.parser.getXML('/word/styles.xml'));
|
|
@@ -119,6 +153,48 @@ var Word = /** @class */ (function () {
|
|
|
119
153
|
finally { if (e_2) throw e_2.error; }
|
|
120
154
|
}
|
|
121
155
|
};
|
|
156
|
+
/**
|
|
157
|
+
* 解析全局配置
|
|
158
|
+
*/
|
|
159
|
+
Word.prototype.initSettings = function () {
|
|
160
|
+
var e_3, _a;
|
|
161
|
+
try {
|
|
162
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
163
|
+
var override = _c.value;
|
|
164
|
+
if (override.partName.startsWith('/word/settings.xml')) {
|
|
165
|
+
this.settings = Settings.Settings.parse(this, this.parser.getXML('/word/settings.xml'));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
170
|
+
finally {
|
|
171
|
+
try {
|
|
172
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
173
|
+
}
|
|
174
|
+
finally { if (e_3) throw e_3.error; }
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* 解析字体表
|
|
179
|
+
*/
|
|
180
|
+
Word.prototype.initFontTable = function () {
|
|
181
|
+
var e_4, _a;
|
|
182
|
+
try {
|
|
183
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
184
|
+
var override = _c.value;
|
|
185
|
+
if (override.partName.startsWith('/word/fontTable.xml')) {
|
|
186
|
+
this.fontTable = FontTable.FontTable.fromXML(this, this.parser.getXML('/word/fontTable.xml'));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
191
|
+
finally {
|
|
192
|
+
try {
|
|
193
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
194
|
+
}
|
|
195
|
+
finally { if (e_4) throw e_4.error; }
|
|
196
|
+
}
|
|
197
|
+
};
|
|
122
198
|
/**
|
|
123
199
|
* 解析关系
|
|
124
200
|
*/
|
|
@@ -127,11 +203,17 @@ var Word = /** @class */ (function () {
|
|
|
127
203
|
if (this.parser.fileExists('/_rels/.rels')) {
|
|
128
204
|
rels = parseRelationship.parseRelationships(this.parser.getXML('/_rels/.rels'), 'root');
|
|
129
205
|
}
|
|
206
|
+
this.relationships = rels;
|
|
130
207
|
var documentRels = {};
|
|
131
208
|
if (this.parser.fileExists('/word/_rels/document.xml.rels')) {
|
|
132
209
|
documentRels = parseRelationship.parseRelationships(this.parser.getXML('/word/_rels/document.xml.rels'), 'word');
|
|
133
210
|
}
|
|
134
|
-
this.
|
|
211
|
+
this.documentRels = documentRels;
|
|
212
|
+
var fontTableRels = {};
|
|
213
|
+
if (this.parser.fileExists('/word/_rels/fontTable.xml.rels')) {
|
|
214
|
+
fontTableRels = parseRelationship.parseRelationships(this.parser.getXML('/word/_rels/fontTable.xml.rels'), 'word');
|
|
215
|
+
}
|
|
216
|
+
this.fontTableRels = fontTableRels;
|
|
135
217
|
};
|
|
136
218
|
/**
|
|
137
219
|
* 解析全局配置
|
|
@@ -144,9 +226,9 @@ var Word = /** @class */ (function () {
|
|
|
144
226
|
* 解析 numbering
|
|
145
227
|
*/
|
|
146
228
|
Word.prototype.initNumbering = function () {
|
|
147
|
-
var
|
|
229
|
+
var e_5, _a;
|
|
148
230
|
try {
|
|
149
|
-
for (var _b =
|
|
231
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
150
232
|
var override = _c.value;
|
|
151
233
|
if (override.partName.startsWith('/word/numbering')) {
|
|
152
234
|
var numberingData = this.parser.getXML(override.partName);
|
|
@@ -154,32 +236,90 @@ var Word = /** @class */ (function () {
|
|
|
154
236
|
}
|
|
155
237
|
}
|
|
156
238
|
}
|
|
157
|
-
catch (
|
|
239
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
158
240
|
finally {
|
|
159
241
|
try {
|
|
160
242
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
161
243
|
}
|
|
162
|
-
finally { if (
|
|
244
|
+
finally { if (e_5) throw e_5.error; }
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
Word.prototype.initNotes = function () {
|
|
248
|
+
var e_6, _a;
|
|
249
|
+
try {
|
|
250
|
+
for (var _b = tslib.__values(this.conentTypes.overrides), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
251
|
+
var override = _c.value;
|
|
252
|
+
if (override.partName.startsWith('/word/footnotes.xml')) {
|
|
253
|
+
var notesData = this.parser.getXML(override.partName);
|
|
254
|
+
this.footNotes = Footnotes.parseFootnotes(this, notesData);
|
|
255
|
+
}
|
|
256
|
+
if (override.partName.startsWith('/word/endnotes.xml')) {
|
|
257
|
+
var notesData = this.parser.getXML(override.partName);
|
|
258
|
+
this.endNotes = parseEndnotes.parseEndnotes(this, notesData);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
263
|
+
finally {
|
|
264
|
+
try {
|
|
265
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
266
|
+
}
|
|
267
|
+
finally { if (e_6) throw e_6.error; }
|
|
163
268
|
}
|
|
164
269
|
};
|
|
165
270
|
/**
|
|
166
|
-
*
|
|
271
|
+
* 获取全局关系
|
|
167
272
|
*/
|
|
168
273
|
Word.prototype.getRelationship = function (id) {
|
|
169
|
-
if (id) {
|
|
274
|
+
if (id && this.relationships) {
|
|
170
275
|
return this.relationships[id];
|
|
171
276
|
}
|
|
172
277
|
return null;
|
|
173
278
|
};
|
|
174
279
|
/**
|
|
175
|
-
*
|
|
280
|
+
* 获取文档对应的关系
|
|
281
|
+
*/
|
|
282
|
+
Word.prototype.getDocumentRels = function (id) {
|
|
283
|
+
if (id && this.documentRels) {
|
|
284
|
+
return this.documentRels[id];
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* 获取字体对应的关系
|
|
290
|
+
*/
|
|
291
|
+
Word.prototype.getFontTableRels = function (id) {
|
|
292
|
+
if (id && this.fontTableRels) {
|
|
293
|
+
return this.fontTableRels[id];
|
|
294
|
+
}
|
|
295
|
+
return null;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* 进行单个文本替换
|
|
176
299
|
*/
|
|
177
300
|
Word.prototype.replaceText = function (text) {
|
|
178
|
-
|
|
179
|
-
|
|
301
|
+
var _this = this;
|
|
302
|
+
if (this.renderOptions.enableVar === false) {
|
|
180
303
|
return text;
|
|
181
304
|
}
|
|
182
|
-
|
|
305
|
+
var data = this.renderOptions.data;
|
|
306
|
+
if (text.indexOf('{{') !== -1) {
|
|
307
|
+
text = text.replace(/{{([^}]+)}}/g, function (all, group) {
|
|
308
|
+
var result = _this.renderOptions.evalVar(group, data);
|
|
309
|
+
if (typeof result === 'undefined') {
|
|
310
|
+
return '';
|
|
311
|
+
}
|
|
312
|
+
return String(result);
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
return text;
|
|
316
|
+
};
|
|
317
|
+
Word.prototype.loadWordRelXML = function (relation) {
|
|
318
|
+
var path = relation.target;
|
|
319
|
+
if (relation.part === 'word') {
|
|
320
|
+
path = 'word/' + path;
|
|
321
|
+
}
|
|
322
|
+
return this.getXML(path);
|
|
183
323
|
};
|
|
184
324
|
/**
|
|
185
325
|
* 加载图片
|
|
@@ -191,14 +331,22 @@ var Word = /** @class */ (function () {
|
|
|
191
331
|
}
|
|
192
332
|
var data = this.parser.getFileByType(path, 'blob');
|
|
193
333
|
if (data) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
334
|
+
return URL.createObjectURL(data);
|
|
335
|
+
}
|
|
336
|
+
return null;
|
|
337
|
+
};
|
|
338
|
+
Word.prototype.loadFont = function (rId, key) {
|
|
339
|
+
var relation = this.getFontTableRels(rId);
|
|
340
|
+
if (!relation) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
var path = relation.target;
|
|
344
|
+
if (relation.part === 'word') {
|
|
345
|
+
path = 'word/' + path;
|
|
346
|
+
}
|
|
347
|
+
var data = this.parser.getFileByType(path, 'uint8array');
|
|
348
|
+
if (data) {
|
|
349
|
+
return URL.createObjectURL(new Blob([Font.deobfuscate(data, key)]));
|
|
202
350
|
}
|
|
203
351
|
return null;
|
|
204
352
|
};
|
|
@@ -237,8 +385,9 @@ var Word = /** @class */ (function () {
|
|
|
237
385
|
* 添加新样式,主要用于表格的单元格样式
|
|
238
386
|
*/
|
|
239
387
|
Word.prototype.appendStyle = function (style) {
|
|
240
|
-
|
|
241
|
-
styleElement
|
|
388
|
+
if (style === void 0) { style = ''; }
|
|
389
|
+
var styleElement = dom.createElement('style');
|
|
390
|
+
styleElement.textContent = style;
|
|
242
391
|
this.rootElement.appendChild(styleElement);
|
|
243
392
|
};
|
|
244
393
|
/**
|
|
@@ -257,6 +406,13 @@ var Word = /** @class */ (function () {
|
|
|
257
406
|
}
|
|
258
407
|
return classNames;
|
|
259
408
|
};
|
|
409
|
+
/**
|
|
410
|
+
* 根据 id 获取样式
|
|
411
|
+
* @param styleId
|
|
412
|
+
*/
|
|
413
|
+
Word.prototype.getStyle = function (styleId) {
|
|
414
|
+
return this.styles.styleMap[styleId];
|
|
415
|
+
};
|
|
260
416
|
/**
|
|
261
417
|
* 渲染时的 css 类前缀
|
|
262
418
|
*/
|
|
@@ -264,11 +420,31 @@ var Word = /** @class */ (function () {
|
|
|
264
420
|
return "".concat(this.renderOptions.classPrefix, "-").concat(this.id);
|
|
265
421
|
};
|
|
266
422
|
/**
|
|
267
|
-
*
|
|
423
|
+
* 获取主题色
|
|
268
424
|
*/
|
|
269
425
|
Word.prototype.getThemeColor = function (name) {
|
|
270
|
-
|
|
426
|
+
var _a, _b;
|
|
427
|
+
if (this.settings.clrSchemeMapping) {
|
|
428
|
+
name = this.settings.clrSchemeMapping[name] || name;
|
|
429
|
+
}
|
|
430
|
+
if (this.themes && this.themes.length > 0) {
|
|
431
|
+
var theme = this.themes[0];
|
|
432
|
+
var colors = (_b = (_a = theme.themeElements) === null || _a === void 0 ? void 0 : _a.clrScheme) === null || _b === void 0 ? void 0 : _b.colors;
|
|
433
|
+
var color = colors === null || colors === void 0 ? void 0 : colors[name];
|
|
434
|
+
if (color) {
|
|
435
|
+
return color;
|
|
436
|
+
}
|
|
437
|
+
else {
|
|
438
|
+
// 找不到可能是从其它地方拷贝过来的,这时取 accent1
|
|
439
|
+
console.warn('unknown theme color: ' + name);
|
|
440
|
+
return (colors === null || colors === void 0 ? void 0 : colors['accent1']) || '';
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
return '';
|
|
271
444
|
};
|
|
445
|
+
/**
|
|
446
|
+
* 添加类,自动加上前缀
|
|
447
|
+
*/
|
|
272
448
|
Word.prototype.addClass = function (element, className) {
|
|
273
449
|
element.classList.add("".concat(this.getClassPrefix(), "-").concat(className));
|
|
274
450
|
};
|
|
@@ -276,9 +452,7 @@ var Word = /** @class */ (function () {
|
|
|
276
452
|
* 更新页面中的变量,这个要在 render 后运行
|
|
277
453
|
*/
|
|
278
454
|
Word.prototype.updateVariable = function () {
|
|
279
|
-
if (!this.rootElement ||
|
|
280
|
-
this.renderOptions.enableVar === false ||
|
|
281
|
-
!this.renderOptions.replaceText) {
|
|
455
|
+
if (!this.rootElement || this.renderOptions.enableVar === false) {
|
|
282
456
|
return;
|
|
283
457
|
}
|
|
284
458
|
renderRun.updateVariableText(this);
|
|
@@ -289,12 +463,13 @@ var Word = /** @class */ (function () {
|
|
|
289
463
|
Word.prototype.download = function (fileName) {
|
|
290
464
|
if (fileName === void 0) { fileName = 'document.docx'; }
|
|
291
465
|
var documentData = this.getXML('word/document.xml');
|
|
292
|
-
if (this.renderOptions.enableVar
|
|
466
|
+
if (this.renderOptions.enableVar) {
|
|
293
467
|
mergeRun.mergeRun(this, documentData);
|
|
468
|
+
replaceVar.replaceVar(this, documentData);
|
|
294
469
|
// 对文本进行替换
|
|
295
470
|
var ts = documentData.getElementsByTagName('w:t');
|
|
296
471
|
for (var i = 0; i < ts.length; i++) {
|
|
297
|
-
ts[i]
|
|
472
|
+
replaceVar.replaceT(this, ts[i], this.renderOptions.data);
|
|
298
473
|
}
|
|
299
474
|
}
|
|
300
475
|
var blob$1 = this.parser.generateZip(xml.buildXML(documentData));
|
|
@@ -304,26 +479,28 @@ var Word = /** @class */ (function () {
|
|
|
304
479
|
* 打印功能
|
|
305
480
|
*/
|
|
306
481
|
Word.prototype.print = function () {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
switch (_c.label) {
|
|
482
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
483
|
+
var iframe, printDocument;
|
|
484
|
+
return tslib.__generator(this, function (_a) {
|
|
485
|
+
switch (_a.label) {
|
|
312
486
|
case 0:
|
|
313
487
|
iframe = document.createElement('iframe');
|
|
314
488
|
iframe.style.position = 'absolute';
|
|
315
489
|
iframe.style.top = '-10000px';
|
|
316
490
|
document.body.appendChild(iframe);
|
|
317
|
-
|
|
318
|
-
|
|
491
|
+
printDocument = iframe.contentDocument;
|
|
492
|
+
if (!printDocument) {
|
|
493
|
+
console.warn('printDocument is null');
|
|
494
|
+
return [2 /*return*/, null];
|
|
495
|
+
}
|
|
496
|
+
printDocument.write("<style>\n html, body { margin:0; padding:0 }\n @page { size: auto; margin: 0mm; }\n </style>\n <div id=\"print\"></div>");
|
|
497
|
+
return [4 /*yield*/, this.render(printDocument.getElementById('print'), tslib.__assign({ page: true, pageWrap: false, pageShadow: false, pageMarginBottom: 0, pageWrapPadding: undefined, zoom: 1 }, this.renderOptions.printOptions))];
|
|
319
498
|
case 1:
|
|
320
|
-
|
|
499
|
+
_a.sent();
|
|
321
500
|
setTimeout(function () {
|
|
322
|
-
var _a, _b;
|
|
323
501
|
iframe.focus();
|
|
324
|
-
(
|
|
325
|
-
|
|
326
|
-
}, 100);
|
|
502
|
+
print.printIframe(iframe);
|
|
503
|
+
}, this.renderOptions.printWaitTime || 100); // 需要等一下图片渲染
|
|
327
504
|
window.focus();
|
|
328
505
|
return [2 /*return*/];
|
|
329
506
|
}
|
|
@@ -334,32 +511,40 @@ var Word = /** @class */ (function () {
|
|
|
334
511
|
* 渲染文档入口
|
|
335
512
|
*
|
|
336
513
|
* @param root 渲染的根节点
|
|
514
|
+
* @param renderOptionsOverride 临时覆盖某些渲选项
|
|
337
515
|
*/
|
|
338
|
-
Word.prototype.render = function (root) {
|
|
339
|
-
|
|
516
|
+
Word.prototype.render = function (root, renderOptionsOverride) {
|
|
517
|
+
if (renderOptionsOverride === void 0) { renderOptionsOverride = {}; }
|
|
518
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
340
519
|
var renderOptions, isDebug, documentData, document, documentElement;
|
|
341
|
-
return
|
|
520
|
+
return tslib.__generator(this, function (_a) {
|
|
342
521
|
this.init();
|
|
343
|
-
|
|
522
|
+
this.currentPage = 0;
|
|
523
|
+
renderOptions = tslib.__assign(tslib.__assign({}, this.renderOptions), renderOptionsOverride);
|
|
344
524
|
isDebug = renderOptions.debug;
|
|
345
525
|
isDebug && console.log('init', this);
|
|
346
526
|
this.rootElement = root;
|
|
347
527
|
root.innerHTML = '';
|
|
348
528
|
documentData = this.getXML('word/document.xml');
|
|
349
529
|
isDebug && console.log('documentData', documentData);
|
|
350
|
-
if (renderOptions.enableVar
|
|
530
|
+
if (renderOptions.enableVar) {
|
|
351
531
|
mergeRun.mergeRun(this, documentData);
|
|
532
|
+
replaceVar.replaceVar(this, documentData);
|
|
352
533
|
// 这里不进行变量替换,方便后续进行局部替换来更新变量
|
|
353
534
|
}
|
|
354
535
|
document = WDocument.WDocument.fromXML(this, documentData);
|
|
355
536
|
isDebug && console.log('document', document);
|
|
356
|
-
documentElement = renderDocument["default"](this, document);
|
|
537
|
+
documentElement = renderDocument["default"](root, this, document, renderOptions);
|
|
357
538
|
root.classList.add(this.getClassPrefix());
|
|
358
|
-
if (renderOptions.
|
|
539
|
+
if (renderOptions.page && renderOptions.pageWrap) {
|
|
359
540
|
root.classList.add(this.wrapClassName);
|
|
541
|
+
root.style.padding = "".concat(renderOptions.pageWrapPadding || 0, "pt");
|
|
542
|
+
root.style.background = renderOptions.pageWrapBackground || '#ECECEC';
|
|
360
543
|
}
|
|
361
544
|
dom.appendChild(root, renderStyle.renderStyle(this));
|
|
545
|
+
dom.appendChild(root, renderFont.renderFont(this.fontTable));
|
|
362
546
|
dom.appendChild(root, documentElement);
|
|
547
|
+
dom.appendChild(root, renderNotes.renderNotes(this));
|
|
363
548
|
return [2 /*return*/];
|
|
364
549
|
});
|
|
365
550
|
});
|
|
@@ -2,17 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* 解析 [Content_Types].xml
|
|
7
9
|
*/
|
|
8
10
|
function parseContentType(doc) {
|
|
11
|
+
var e_1, _a;
|
|
9
12
|
var types = { overrides: [] };
|
|
10
|
-
doc.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var overrides = [].slice.call(doc.getElementsByTagName('Override'));
|
|
14
|
+
try {
|
|
15
|
+
for (var overrides_1 = tslib.__values(overrides), overrides_1_1 = overrides_1.next(); !overrides_1_1.done; overrides_1_1 = overrides_1.next()) {
|
|
16
|
+
var item = overrides_1_1.value;
|
|
17
|
+
types.overrides.push({
|
|
18
|
+
partName: item.getAttribute('PartName'),
|
|
19
|
+
contentType: item.getAttribute('ContentType')
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (overrides_1_1 && !overrides_1_1.done && (_a = overrides_1.return)) _a.call(overrides_1);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e_1) throw e_1.error; }
|
|
29
|
+
}
|
|
16
30
|
return types;
|
|
17
31
|
}
|
|
18
32
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var OpenXML = require('../OpenXML.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 解析 settings.xml,只支持一小部分
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 解析颜色映射
|
|
14
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/clrSchemeMapping.html
|
|
15
|
+
*/
|
|
16
|
+
function parseClrSchemeMapping(element) {
|
|
17
|
+
var e_1, _a;
|
|
18
|
+
var clrSchemeMapping = {};
|
|
19
|
+
try {
|
|
20
|
+
for (var _b = tslib.__values(element.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
|
+
var attribute = _c.value;
|
|
22
|
+
var name_1 = attribute.name.replace('w:', '');
|
|
23
|
+
var value = attribute.value;
|
|
24
|
+
// 文档里也说了这个等于 lt1
|
|
25
|
+
if (value === 'light1') {
|
|
26
|
+
value = 'lt1';
|
|
27
|
+
}
|
|
28
|
+
else if (value === 'light2') {
|
|
29
|
+
value = 'lt2';
|
|
30
|
+
}
|
|
31
|
+
else if (value === 'dark1') {
|
|
32
|
+
value = 'dk1';
|
|
33
|
+
}
|
|
34
|
+
else if (value === 'dark2') {
|
|
35
|
+
value = 'dk2';
|
|
36
|
+
}
|
|
37
|
+
clrSchemeMapping[name_1] = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
41
|
+
finally {
|
|
42
|
+
try {
|
|
43
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
44
|
+
}
|
|
45
|
+
finally { if (e_1) throw e_1.error; }
|
|
46
|
+
}
|
|
47
|
+
if (!clrSchemeMapping.bg1) {
|
|
48
|
+
clrSchemeMapping.bg1 = 'lt1';
|
|
49
|
+
}
|
|
50
|
+
if (!clrSchemeMapping.bg2) {
|
|
51
|
+
clrSchemeMapping.bg2 = 'lt2';
|
|
52
|
+
}
|
|
53
|
+
if (!clrSchemeMapping.tx1) {
|
|
54
|
+
clrSchemeMapping.tx1 = 'dk1';
|
|
55
|
+
}
|
|
56
|
+
return clrSchemeMapping;
|
|
57
|
+
}
|
|
58
|
+
var Settings = /** @class */ (function () {
|
|
59
|
+
function Settings() {
|
|
60
|
+
this.clrSchemeMapping = {};
|
|
61
|
+
this.autoHyphenation = false;
|
|
62
|
+
}
|
|
63
|
+
Settings.parse = function (word, doc) {
|
|
64
|
+
var e_2, _a;
|
|
65
|
+
var settings = new Settings();
|
|
66
|
+
var rootElement = doc;
|
|
67
|
+
if (doc.firstElementChild &&
|
|
68
|
+
doc.firstElementChild.tagName === 'w:settings') {
|
|
69
|
+
rootElement = doc.getElementsByTagName('w:settings').item(0);
|
|
70
|
+
}
|
|
71
|
+
try {
|
|
72
|
+
for (var _b = tslib.__values(Array.from(rootElement.children)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
73
|
+
var child = _c.value;
|
|
74
|
+
var tag = child.tagName;
|
|
75
|
+
switch (tag) {
|
|
76
|
+
case 'w:clrSchemeMapping':
|
|
77
|
+
settings.clrSchemeMapping = parseClrSchemeMapping(child);
|
|
78
|
+
break;
|
|
79
|
+
case 'w:autoHyphenation':
|
|
80
|
+
settings.autoHyphenation = OpenXML.getValBoolean(child, false);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
86
|
+
finally {
|
|
87
|
+
try {
|
|
88
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
89
|
+
}
|
|
90
|
+
finally { if (e_2) throw e_2.error; }
|
|
91
|
+
}
|
|
92
|
+
return settings;
|
|
93
|
+
};
|
|
94
|
+
return Settings;
|
|
95
|
+
}());
|
|
96
|
+
|
|
97
|
+
exports.Settings = Settings;
|
package/lib/openxml/Style.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { TablePr } from './word/Table';
|
|
|
9
9
|
import { TcPr } from './word/table/Tc';
|
|
10
10
|
import { TrPr } from './word/table/Tr';
|
|
11
11
|
export interface CSSStyle {
|
|
12
|
-
[key: string]: string;
|
|
12
|
+
[key: string]: string | number;
|
|
13
13
|
}
|
|
14
14
|
export interface TblStylePrStyle {
|
|
15
15
|
rPr?: RunPr;
|