office-viewer 0.1.0 → 0.1.3
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 +7 -2
- package/esm/OpenXML.d.ts +19 -0
- package/esm/OpenXML.js +43 -2
- package/esm/Word.d.ts +132 -15
- package/esm/Word.js +233 -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 +35 -0
- package/esm/openxml/drawing/Drawing.js +169 -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 +2 -1
- package/esm/openxml/{word/drawing → drawing}/Transform.js +7 -3
- 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/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 +5 -0
- package/esm/openxml/word/wps/WPS.d.ts +18 -0
- package/esm/openxml/word/wps/WPS.js +147 -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 +129 -24
- 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 +26 -29
- 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 +35 -10
- 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 +1 -0
- package/esm/render/renderTab.js +4 -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/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 +214 -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 +238 -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 +35 -0
- package/lib/openxml/drawing/Drawing.js +173 -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 +2 -1
- package/lib/openxml/{word/drawing → drawing}/Transform.js +7 -3
- 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/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 +5 -0
- package/lib/openxml/word/wps/WPS.d.ts +18 -0
- package/lib/openxml/word/wps/WPS.js +151 -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 +129 -24
- 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 +26 -29
- 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 +34 -9
- 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 +1 -0
- package/lib/render/renderTab.js +4 -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/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 +219 -0
- package/lib/util/xml.js +4 -0
- package/package.json +17 -6
- 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/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
|
@@ -2,114 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
|
|
6
|
-
var OpenXML = require('../../../OpenXML.js');
|
|
7
|
-
var Paragraph = require('../Paragraph.js');
|
|
8
|
-
var Table = require('../Table.js');
|
|
9
|
-
var parseSize = require('../../../parse/parseSize.js');
|
|
10
|
-
var parseColor = require('../../../parse/parseColor.js');
|
|
11
|
-
var parseBorder = require('../../../parse/parseBorder.js');
|
|
12
|
-
var parseTextDirection = require('../../../parse/parseTextDirection.js');
|
|
13
|
-
var Types = require('../../Types.js');
|
|
14
|
-
|
|
15
|
-
// http://officeopenxml.com/WPtableCellProperties-Margins.php
|
|
16
|
-
function parseCellMargin(element, style) {
|
|
17
|
-
var e_1, _a;
|
|
18
|
-
try {
|
|
19
|
-
for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
20
|
-
var child = _c.value;
|
|
21
|
-
var tagName = child.tagName;
|
|
22
|
-
switch (tagName) {
|
|
23
|
-
case 'w:left':
|
|
24
|
-
case 'w:start':
|
|
25
|
-
style['padding-left'] = parseSize.parseSize(child, 'w:w');
|
|
26
|
-
break;
|
|
27
|
-
case 'w:right':
|
|
28
|
-
case 'w:end':
|
|
29
|
-
style['padding-right'] = parseSize.parseSize(child, 'w:w');
|
|
30
|
-
break;
|
|
31
|
-
case 'w:top':
|
|
32
|
-
style['padding-top'] = parseSize.parseSize(child, 'w:w');
|
|
33
|
-
break;
|
|
34
|
-
case 'w:bottom':
|
|
35
|
-
style['padding-bottom'] = parseSize.parseSize(child, 'w:w');
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
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
|
-
}
|
|
48
|
-
function parseVAlign(element, style) {
|
|
49
|
-
var vAlign = OpenXML.getVal(element);
|
|
50
|
-
switch (vAlign) {
|
|
51
|
-
case Types.ST_VerticalJc.bottom:
|
|
52
|
-
style['vertical-align'] = 'bottom';
|
|
53
|
-
break;
|
|
54
|
-
case Types.ST_VerticalJc.center:
|
|
55
|
-
style['vertical-align'] = 'middle';
|
|
56
|
-
break;
|
|
57
|
-
case Types.ST_VerticalJc.top:
|
|
58
|
-
style['vertical-align'] = 'top';
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function parseTblCellSpacing(element, style) {
|
|
63
|
-
var width = parseTblWidth(element);
|
|
64
|
-
if (width) {
|
|
65
|
-
style['cell-spacing'] = width;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* parseBorders 不支持 insideH 和 insideV,所以单独支持一下
|
|
70
|
-
* 实际显示时需要过滤掉第一列
|
|
71
|
-
*/
|
|
72
|
-
function parseInsideBorders(word, element) {
|
|
73
|
-
var H;
|
|
74
|
-
var insideH = element.querySelector('insideH');
|
|
75
|
-
if (insideH) {
|
|
76
|
-
H = parseBorder.parseBorder(word, insideH);
|
|
77
|
-
}
|
|
78
|
-
var V;
|
|
79
|
-
var insideV = element.querySelector('insideV');
|
|
80
|
-
if (insideV) {
|
|
81
|
-
V = parseBorder.parseBorder(word, insideV);
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
H: H,
|
|
85
|
-
V: V
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* http://officeopenxml.com/WPtableWidth.php
|
|
90
|
-
*/
|
|
91
|
-
function parseTblWidth(element) {
|
|
92
|
-
var type = element.getAttribute('w:type');
|
|
93
|
-
if (!type || type === Types.ST_TblWidth.dxa) {
|
|
94
|
-
return parseSize.parseSize(element, 'w:w');
|
|
95
|
-
}
|
|
96
|
-
else if (type === Types.ST_TblWidth.pct) {
|
|
97
|
-
return parseSize.parseSize(element, 'w:w', parseSize.LengthUsage.Percent);
|
|
98
|
-
}
|
|
99
|
-
else if (type === Types.ST_TblWidth.auto) {
|
|
100
|
-
return 'auto';
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
console.warn('parseTblWidth: ignore type', type, element);
|
|
104
|
-
}
|
|
105
|
-
return '';
|
|
106
|
-
}
|
|
107
|
-
function parseTcW(element, style) {
|
|
108
|
-
var width = parseTblWidth(element);
|
|
109
|
-
if (width) {
|
|
110
|
-
style.width = width;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
5
|
var Tc = /** @class */ (function () {
|
|
114
6
|
function Tc() {
|
|
115
7
|
this.properties = {};
|
|
@@ -120,123 +12,7 @@ var Tc = /** @class */ (function () {
|
|
|
120
12
|
this.children.push(child);
|
|
121
13
|
}
|
|
122
14
|
};
|
|
123
|
-
Tc.parseTcPr = function (word, element) {
|
|
124
|
-
var e_2, _a;
|
|
125
|
-
var properties = {};
|
|
126
|
-
var style = {};
|
|
127
|
-
properties.cssStyle = style;
|
|
128
|
-
try {
|
|
129
|
-
for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
130
|
-
var child = _c.value;
|
|
131
|
-
var tagName = child.tagName;
|
|
132
|
-
switch (tagName) {
|
|
133
|
-
case 'w:tcMar':
|
|
134
|
-
parseCellMargin(child, style);
|
|
135
|
-
break;
|
|
136
|
-
case 'w:shd':
|
|
137
|
-
style['background-color'] = parseColor.parseShdColor(word, child);
|
|
138
|
-
break;
|
|
139
|
-
case 'w:tcW':
|
|
140
|
-
parseTcW(child, style);
|
|
141
|
-
break;
|
|
142
|
-
case 'w:noWrap':
|
|
143
|
-
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noWrap.html
|
|
144
|
-
var noWrap = OpenXML.getValBoolean(child);
|
|
145
|
-
if (noWrap) {
|
|
146
|
-
style['white-space'] = 'nowrap';
|
|
147
|
-
}
|
|
148
|
-
break;
|
|
149
|
-
case 'w:vAlign':
|
|
150
|
-
parseVAlign(child, style);
|
|
151
|
-
break;
|
|
152
|
-
case 'w:tcBorders':
|
|
153
|
-
parseBorder.parseBorders(word, child, style);
|
|
154
|
-
properties.insideBorder = parseInsideBorders(word, child);
|
|
155
|
-
break;
|
|
156
|
-
case 'w:gridSpan':
|
|
157
|
-
properties.gridSpan = OpenXML.getValNumber(child);
|
|
158
|
-
break;
|
|
159
|
-
case 'w:vMerge':
|
|
160
|
-
properties.vMerge = OpenXML.getVal(child) || Types.ST_Merge.continue;
|
|
161
|
-
break;
|
|
162
|
-
case 'w:textDirection':
|
|
163
|
-
parseTextDirection.parseTextDirection(child, style);
|
|
164
|
-
break;
|
|
165
|
-
case 'w:cnfStyle':
|
|
166
|
-
// 目前是自动计算的,所以不需要这个了
|
|
167
|
-
break;
|
|
168
|
-
default:
|
|
169
|
-
console.warn('parseTcPr: ignore', tagName, child);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
174
|
-
finally {
|
|
175
|
-
try {
|
|
176
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
177
|
-
}
|
|
178
|
-
finally { if (e_2) throw e_2.error; }
|
|
179
|
-
}
|
|
180
|
-
return properties;
|
|
181
|
-
};
|
|
182
|
-
Tc.fromXML = function (word, element, currentCol, rowSpanMap) {
|
|
183
|
-
var e_3, _a;
|
|
184
|
-
var tc = new Tc();
|
|
185
|
-
try {
|
|
186
|
-
for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
187
|
-
var child = _c.value;
|
|
188
|
-
var tagName = child.tagName;
|
|
189
|
-
switch (tagName) {
|
|
190
|
-
case 'w:tcPr':
|
|
191
|
-
tc.properties = Tc.parseTcPr(word, child);
|
|
192
|
-
break;
|
|
193
|
-
case 'w:p':
|
|
194
|
-
tc.add(Paragraph.Paragraph.fromXML(word, child));
|
|
195
|
-
break;
|
|
196
|
-
case 'w:tbl':
|
|
197
|
-
tc.add(Table.Table.fromXML(word, child));
|
|
198
|
-
break;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
203
|
-
finally {
|
|
204
|
-
try {
|
|
205
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
206
|
-
}
|
|
207
|
-
finally { if (e_3) throw e_3.error; }
|
|
208
|
-
}
|
|
209
|
-
var lastCol = rowSpanMap[currentCol.index];
|
|
210
|
-
// 如果是 continue 意味着这个被合并了
|
|
211
|
-
if (tc.properties.vMerge) {
|
|
212
|
-
if (tc.properties.vMerge === Types.ST_Merge.restart) {
|
|
213
|
-
tc.properties.rowSpan = 1;
|
|
214
|
-
rowSpanMap[currentCol.index] = tc;
|
|
215
|
-
}
|
|
216
|
-
else if (lastCol) {
|
|
217
|
-
if (lastCol.properties && lastCol.properties.rowSpan) {
|
|
218
|
-
lastCol.properties.rowSpan = lastCol.properties.rowSpan + 1;
|
|
219
|
-
var colSpan_1 = tc.properties.gridSpan || 1;
|
|
220
|
-
currentCol.index += colSpan_1;
|
|
221
|
-
return null;
|
|
222
|
-
}
|
|
223
|
-
else {
|
|
224
|
-
console.warn('Tc.fromXML: continue but not found lastCol', currentCol.index, tc, rowSpanMap);
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
delete rowSpanMap[currentCol.index];
|
|
230
|
-
}
|
|
231
|
-
var colSpan = tc.properties.gridSpan || 1;
|
|
232
|
-
currentCol.index += colSpan;
|
|
233
|
-
return tc;
|
|
234
|
-
};
|
|
235
15
|
return Tc;
|
|
236
16
|
}());
|
|
237
17
|
|
|
238
18
|
exports.Tc = Tc;
|
|
239
|
-
exports.parseCellMargin = parseCellMargin;
|
|
240
|
-
exports.parseInsideBorders = parseInsideBorders;
|
|
241
|
-
exports.parseTblCellSpacing = parseTblCellSpacing;
|
|
242
|
-
exports.parseTblWidth = parseTblWidth;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { CSSStyle } from '../../Style';
|
|
2
2
|
import { Tc } from './Tc';
|
|
3
|
-
import Word from '../../../Word';
|
|
4
3
|
export interface TrPr {
|
|
5
4
|
cssStyle?: CSSStyle;
|
|
6
5
|
/**
|
|
@@ -11,8 +10,4 @@ export interface TrPr {
|
|
|
11
10
|
export declare class Tr {
|
|
12
11
|
properties: TrPr;
|
|
13
12
|
tcs: Tc[];
|
|
14
|
-
static parseTrPr(word: Word, element: Element): TrPr;
|
|
15
|
-
static fromXML(word: Word, element: Element, rowSpanMap: {
|
|
16
|
-
[key: string]: Tc;
|
|
17
|
-
}): Tr;
|
|
18
13
|
}
|
|
@@ -2,108 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../../../node_modules/tslib/tslib.es6.js');
|
|
6
|
-
var OpenXML = require('../../../OpenXML.js');
|
|
7
|
-
var Tc = require('./Tc.js');
|
|
8
|
-
var parseTrHeight = require('../../../parse/parseTrHeight.js');
|
|
9
|
-
var jcToTextAlign = require('../../../parse/jcToTextAlign.js');
|
|
10
|
-
var Table = require('../Table.js');
|
|
11
|
-
|
|
12
5
|
var Tr = /** @class */ (function () {
|
|
13
6
|
function Tr() {
|
|
14
7
|
this.properties = {};
|
|
15
8
|
this.tcs = [];
|
|
16
9
|
}
|
|
17
|
-
Tr.parseTrPr = function (word, element) {
|
|
18
|
-
var e_1, _a;
|
|
19
|
-
var cssStyle = {};
|
|
20
|
-
var tcStyle = {};
|
|
21
|
-
try {
|
|
22
|
-
for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
23
|
-
var child = _c.value;
|
|
24
|
-
var tagName = child.tagName;
|
|
25
|
-
switch (tagName) {
|
|
26
|
-
case 'w:hidden':
|
|
27
|
-
if (OpenXML.getValBoolean(child)) {
|
|
28
|
-
cssStyle.display = 'none';
|
|
29
|
-
}
|
|
30
|
-
break;
|
|
31
|
-
case 'w:trHeight':
|
|
32
|
-
parseTrHeight.parseTrHeight(child, cssStyle);
|
|
33
|
-
break;
|
|
34
|
-
case 'w:jc':
|
|
35
|
-
cssStyle['text-align'] = jcToTextAlign.jcToTextAlign(OpenXML.getVal(child));
|
|
36
|
-
break;
|
|
37
|
-
case 'w:cantSplit':
|
|
38
|
-
// 目前也不支持分页
|
|
39
|
-
break;
|
|
40
|
-
case 'w:tblPrEx':
|
|
41
|
-
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
42
|
-
var tablePr = Table.Table.parseTablePr(word, child);
|
|
43
|
-
Object.assign(cssStyle, tablePr.cssStyle);
|
|
44
|
-
break;
|
|
45
|
-
case 'w:tblCellSpacing':
|
|
46
|
-
Tc.parseTblCellSpacing(child, tcStyle);
|
|
47
|
-
break;
|
|
48
|
-
case 'w:cnfStyle':
|
|
49
|
-
// 目前是自动计算的,所以不需要这个了
|
|
50
|
-
break;
|
|
51
|
-
default:
|
|
52
|
-
console.warn("Tr: Unknown tag ", tagName, child);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e_1) throw e_1.error; }
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
cssStyle: cssStyle
|
|
65
|
-
};
|
|
66
|
-
};
|
|
67
|
-
Tr.fromXML = function (word, element, rowSpanMap) {
|
|
68
|
-
var e_2, _a;
|
|
69
|
-
var tr = new Tr();
|
|
70
|
-
// 做成对象是为了传递引用来修改
|
|
71
|
-
var currentCol = {
|
|
72
|
-
index: 0
|
|
73
|
-
};
|
|
74
|
-
try {
|
|
75
|
-
for (var _b = tslib_es6.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
76
|
-
var child = _c.value;
|
|
77
|
-
var tagName = child.tagName;
|
|
78
|
-
switch (tagName) {
|
|
79
|
-
case 'w:tc':
|
|
80
|
-
var tc = Tc.Tc.fromXML(word, child, currentCol, rowSpanMap);
|
|
81
|
-
if (tc) {
|
|
82
|
-
tr.tcs.push(tc);
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
case 'w:trPr':
|
|
86
|
-
tr.properties = Tr.parseTrPr(word, child);
|
|
87
|
-
break;
|
|
88
|
-
case 'w:tblPrEx':
|
|
89
|
-
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
90
|
-
var tablePr = Table.Table.parseTablePr(word, child);
|
|
91
|
-
Object.assign(tr.properties.cssStyle || {}, tablePr.cssStyle);
|
|
92
|
-
break;
|
|
93
|
-
default:
|
|
94
|
-
console.warn("Tr: Unknown tag ", tagName, child);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
99
|
-
finally {
|
|
100
|
-
try {
|
|
101
|
-
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
102
|
-
}
|
|
103
|
-
finally { if (e_2) throw e_2.error; }
|
|
104
|
-
}
|
|
105
|
-
return tr;
|
|
106
|
-
};
|
|
107
10
|
return Tr;
|
|
108
11
|
}());
|
|
109
12
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Paragraph } from '../Paragraph';
|
|
2
|
+
import { ShapePr } from '../../drawing/ShapeProperties';
|
|
3
|
+
/**
|
|
4
|
+
* wps 指的是 wordprocessingShape,在 drawing 里 word 相关的 shape 定义
|
|
5
|
+
* 目前主要是支持 textbox,
|
|
6
|
+
*/
|
|
7
|
+
import Word from '../../../Word';
|
|
8
|
+
import { Table } from '../Table';
|
|
9
|
+
import { CSSStyle } from '../../../openxml/Style';
|
|
10
|
+
import { WPSStyle } from './WPSStyle';
|
|
11
|
+
export type TxbxContentChild = Paragraph | Table;
|
|
12
|
+
export declare class WPS {
|
|
13
|
+
spPr?: ShapePr;
|
|
14
|
+
wpsStyle?: WPSStyle;
|
|
15
|
+
txbxContent: TxbxContentChild[];
|
|
16
|
+
style: CSSStyle;
|
|
17
|
+
static fromXML(word: Word, element: Element): WPS;
|
|
18
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Paragraph = require('../Paragraph.js');
|
|
7
|
+
var ShapeProperties = require('../../drawing/ShapeProperties.js');
|
|
8
|
+
var parseTable = require('../../../parse/parseTable.js');
|
|
9
|
+
var parseSize = require('../../../parse/parseSize.js');
|
|
10
|
+
var WPSStyle = require('./WPSStyle.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 文档 20.4.2.22,不过大部分属性不支持
|
|
14
|
+
*/
|
|
15
|
+
function parseBodyPr(element, style) {
|
|
16
|
+
var e_1, _a;
|
|
17
|
+
try {
|
|
18
|
+
for (var _b = tslib.__values(element.attributes), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19
|
+
var attribute = _c.value;
|
|
20
|
+
var name_1 = attribute.name;
|
|
21
|
+
var value = attribute.value;
|
|
22
|
+
switch (name_1) {
|
|
23
|
+
case 'numCol':
|
|
24
|
+
if (value !== '1') {
|
|
25
|
+
style['column-count'] = value;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
case 'vert':
|
|
29
|
+
var val = value;
|
|
30
|
+
switch (val) {
|
|
31
|
+
case 'vert':
|
|
32
|
+
style['writing-mode'] = 'vertical-rl';
|
|
33
|
+
style['text-orientation'] = 'sideways';
|
|
34
|
+
break;
|
|
35
|
+
case 'vert270':
|
|
36
|
+
case 'eaVert':
|
|
37
|
+
// 不太准确,但 css 也只能做到这样
|
|
38
|
+
style['writing-mode'] = 'vertical-rl';
|
|
39
|
+
style['text-orientation'] = 'mixed';
|
|
40
|
+
break;
|
|
41
|
+
default:
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
case 'anchor':
|
|
46
|
+
var anchor = value;
|
|
47
|
+
switch (anchor) {
|
|
48
|
+
case 'b':
|
|
49
|
+
style['vertical-align'] = 'bottom';
|
|
50
|
+
break;
|
|
51
|
+
case 't':
|
|
52
|
+
style['vertical-align'] = 'top';
|
|
53
|
+
break;
|
|
54
|
+
case 'ctr':
|
|
55
|
+
style['vertical-align'] = 'middle';
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'rot':
|
|
60
|
+
var rot = parseSize.convertAngle(value);
|
|
61
|
+
if (rot) {
|
|
62
|
+
style['transform'] = "rotate(".concat(rot, "deg)");
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
|
+
finally {
|
|
70
|
+
try {
|
|
71
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
72
|
+
}
|
|
73
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
var WPS = /** @class */ (function () {
|
|
77
|
+
function WPS() {
|
|
78
|
+
// 外层容器样式
|
|
79
|
+
this.style = {};
|
|
80
|
+
}
|
|
81
|
+
WPS.fromXML = function (word, element) {
|
|
82
|
+
var e_2, _a, e_3, _b;
|
|
83
|
+
var wps = new WPS();
|
|
84
|
+
wps.txbxContent = [];
|
|
85
|
+
try {
|
|
86
|
+
for (var _c = tslib.__values(element.children), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
87
|
+
var child = _d.value;
|
|
88
|
+
var tagName = child.tagName;
|
|
89
|
+
switch (tagName) {
|
|
90
|
+
case 'wps:cNvSpPr':
|
|
91
|
+
// 和展现无关
|
|
92
|
+
break;
|
|
93
|
+
case 'wps:spPr':
|
|
94
|
+
wps.spPr = ShapeProperties.ShapePr.fromXML(word, child);
|
|
95
|
+
break;
|
|
96
|
+
case 'wps:txbx':
|
|
97
|
+
// 文本框内容
|
|
98
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/txbxContent.html
|
|
99
|
+
var txbxContent = child.firstElementChild;
|
|
100
|
+
if (txbxContent) {
|
|
101
|
+
try {
|
|
102
|
+
for (var _e = (e_3 = void 0, tslib.__values(txbxContent.children)), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
103
|
+
var txbxContentChild = _f.value;
|
|
104
|
+
var txbxContentTagName = txbxContentChild.tagName;
|
|
105
|
+
switch (txbxContentTagName) {
|
|
106
|
+
case 'w:p':
|
|
107
|
+
wps.txbxContent.push(Paragraph.Paragraph.fromXML(word, txbxContentChild));
|
|
108
|
+
break;
|
|
109
|
+
case 'w:tbl':
|
|
110
|
+
wps.txbxContent.push(parseTable.parseTable(word, txbxContentChild));
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
116
|
+
finally {
|
|
117
|
+
try {
|
|
118
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
119
|
+
}
|
|
120
|
+
finally { if (e_3) throw e_3.error; }
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
console.warn('unknown wps:txbx', child);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
case 'wps:style':
|
|
128
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/style_1.html
|
|
129
|
+
wps.wpsStyle = WPSStyle.WPSStyle.fromXML(word, child);
|
|
130
|
+
break;
|
|
131
|
+
case 'wps:bodyPr':
|
|
132
|
+
parseBodyPr(child, wps.style);
|
|
133
|
+
break;
|
|
134
|
+
default:
|
|
135
|
+
console.warn('WPS: Unknown tag ', tagName, child);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
140
|
+
finally {
|
|
141
|
+
try {
|
|
142
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
143
|
+
}
|
|
144
|
+
finally { if (e_2) throw e_2.error; }
|
|
145
|
+
}
|
|
146
|
+
return wps;
|
|
147
|
+
};
|
|
148
|
+
return WPS;
|
|
149
|
+
}());
|
|
150
|
+
|
|
151
|
+
exports.WPS = WPS;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var parseChildColor = require('../../../parse/parseChildColor.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 没去不太清楚这个是什么,目前主要用于形状的颜色
|
|
10
|
+
*/
|
|
11
|
+
var WPSStyle = /** @class */ (function () {
|
|
12
|
+
function WPSStyle() {
|
|
13
|
+
}
|
|
14
|
+
WPSStyle.fromXML = function (word, element) {
|
|
15
|
+
var e_1, _a;
|
|
16
|
+
var wpsStyle = new WPSStyle();
|
|
17
|
+
try {
|
|
18
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
19
|
+
var child = _c.value;
|
|
20
|
+
var tagName = child.tagName;
|
|
21
|
+
switch (tagName) {
|
|
22
|
+
case 'a:fillRef':
|
|
23
|
+
wpsStyle.fillColor = parseChildColor.parseChildColor(word, child);
|
|
24
|
+
break;
|
|
25
|
+
case 'a:lnRef':
|
|
26
|
+
wpsStyle.lineColor = parseChildColor.parseChildColor(word, child);
|
|
27
|
+
break;
|
|
28
|
+
case 'a:fontRef':
|
|
29
|
+
wpsStyle.fontColor = parseChildColor.parseChildColor(word, child);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e_1) throw e_1.error; }
|
|
40
|
+
}
|
|
41
|
+
return wpsStyle;
|
|
42
|
+
};
|
|
43
|
+
return WPSStyle;
|
|
44
|
+
}());
|
|
45
|
+
|
|
46
|
+
exports.WPSStyle = WPSStyle;
|
|
@@ -12,7 +12,7 @@ export interface PackageParser {
|
|
|
12
12
|
/**
|
|
13
13
|
* 根据类型读取文件
|
|
14
14
|
*/
|
|
15
|
-
getFileByType(filePath: string, type: 'string' | 'blob'): string | Blob;
|
|
15
|
+
getFileByType(filePath: string, type: 'string' | 'blob' | 'uint8array'): string | Blob | Uint8Array | null;
|
|
16
16
|
/**
|
|
17
17
|
* 文件是否存在
|
|
18
18
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* openxml 默认是 zip
|
|
2
|
+
* openxml 默认是 zip 格式构造起来比较麻烦,这个格式可以方便文本编辑,word 也能直接打开
|
|
3
3
|
*/
|
|
4
4
|
import { PackageParser } from './PackageParser';
|
|
5
5
|
export default class XMLPackageParser implements PackageParser {
|
|
@@ -9,7 +9,7 @@ export default class XMLPackageParser implements PackageParser {
|
|
|
9
9
|
/**
|
|
10
10
|
* 加载 zip 文件
|
|
11
11
|
*/
|
|
12
|
-
load(fileContent: ArrayBuffer | string): void;
|
|
12
|
+
load(fileContent: ArrayBuffer | string | Uint8Array): void;
|
|
13
13
|
/**
|
|
14
14
|
* 读取 xml 文件,转成 json 对象
|
|
15
15
|
* @param filePath 文件路径
|
|
@@ -19,7 +19,7 @@ export default class XMLPackageParser implements PackageParser {
|
|
|
19
19
|
/**
|
|
20
20
|
* 在 xml 下基本不用这个
|
|
21
21
|
*/
|
|
22
|
-
getFileByType(filePath: string, type: 'string' | 'blob'): string;
|
|
22
|
+
getFileByType(filePath: string, type: 'string' | 'blob'): string | Uint8Array | Blob | null;
|
|
23
23
|
/**
|
|
24
24
|
* 判断文件是否存在
|
|
25
25
|
*/
|
|
@@ -17,7 +17,7 @@ export default class ZipPackageParser implements PackageParser {
|
|
|
17
17
|
/**
|
|
18
18
|
* 根据类型读取文件
|
|
19
19
|
*/
|
|
20
|
-
getFileByType(filePath: string, type: 'string' | 'blob'): string | Blob;
|
|
20
|
+
getFileByType(filePath: string, type: 'string' | 'blob' | 'uint8array'): string | Uint8Array | Blob | null;
|
|
21
21
|
/**
|
|
22
22
|
* 判断文件是否存在
|
|
23
23
|
*/
|
|
@@ -14,12 +14,7 @@ var ZipPackageParser = /** @class */ (function () {
|
|
|
14
14
|
* 加载 zip 文件
|
|
15
15
|
*/
|
|
16
16
|
ZipPackageParser.prototype.load = function (docxFile) {
|
|
17
|
-
this.zip = fflate.unzipSync(new Uint8Array(docxFile)
|
|
18
|
-
filter: function (file) {
|
|
19
|
-
// 不解析大于 10 MiB 的文件
|
|
20
|
-
return file.originalSize <= 10000000;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
17
|
+
this.zip = fflate.unzipSync(new Uint8Array(docxFile));
|
|
23
18
|
};
|
|
24
19
|
/**
|
|
25
20
|
* 读取 xml 文件,转成 json 对象
|
|
@@ -29,7 +24,7 @@ var ZipPackageParser = /** @class */ (function () {
|
|
|
29
24
|
ZipPackageParser.prototype.getXML = function (filePath) {
|
|
30
25
|
var fileContent = this.getFileByType(filePath, 'string');
|
|
31
26
|
var doc = new DOMParser().parseFromString(fileContent, 'application/xml');
|
|
32
|
-
var errorNode = doc.
|
|
27
|
+
var errorNode = doc.getElementsByTagName('parsererror').item(0);
|
|
33
28
|
if (errorNode) {
|
|
34
29
|
throw new Error(errorNode.textContent || "can't parse xml");
|
|
35
30
|
}
|
|
@@ -50,8 +45,12 @@ var ZipPackageParser = /** @class */ (function () {
|
|
|
50
45
|
else if (type === 'blob') {
|
|
51
46
|
return new Blob([file]);
|
|
52
47
|
}
|
|
48
|
+
else if (type === 'uint8array') {
|
|
49
|
+
return file;
|
|
50
|
+
}
|
|
53
51
|
}
|
|
54
|
-
|
|
52
|
+
console.warn('getFileByType', filePath, 'not found');
|
|
53
|
+
return null;
|
|
55
54
|
};
|
|
56
55
|
/**
|
|
57
56
|
* 判断文件是否存在
|