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
|
@@ -0,0 +1,247 @@
|
|
|
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
|
+
* 解析 shape
|
|
10
|
+
*/
|
|
11
|
+
function parsePts(element) {
|
|
12
|
+
var e_1, _a;
|
|
13
|
+
var pts = [];
|
|
14
|
+
try {
|
|
15
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
16
|
+
var child = _c.value;
|
|
17
|
+
var tagName = child.tagName;
|
|
18
|
+
if (tagName === 'a:pt' || tagName === 'pt') {
|
|
19
|
+
var x = child.getAttribute('x');
|
|
20
|
+
var y = child.getAttribute('y');
|
|
21
|
+
if (x && y) {
|
|
22
|
+
pts.push({ x: x, y: y });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
console.warn('unknown pt', tagName, child);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
31
|
+
finally {
|
|
32
|
+
try {
|
|
33
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
34
|
+
}
|
|
35
|
+
finally { if (e_1) throw e_1.error; }
|
|
36
|
+
}
|
|
37
|
+
return pts;
|
|
38
|
+
}
|
|
39
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/DrawingML/path_2.html
|
|
40
|
+
function parsePath(element) {
|
|
41
|
+
var e_2, _a;
|
|
42
|
+
var pathChild = [];
|
|
43
|
+
try {
|
|
44
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
45
|
+
var child = _c.value;
|
|
46
|
+
var tagName = child.tagName;
|
|
47
|
+
switch (tagName) {
|
|
48
|
+
case 'a:moveTo':
|
|
49
|
+
case 'moveTo':
|
|
50
|
+
var moveToPt = parsePts(child);
|
|
51
|
+
if (moveToPt.length) {
|
|
52
|
+
var moveTo_1 = {
|
|
53
|
+
type: 'moveTo',
|
|
54
|
+
pt: moveToPt[0]
|
|
55
|
+
};
|
|
56
|
+
pathChild.push(moveTo_1);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'a:lnTo':
|
|
60
|
+
case 'lnTo':
|
|
61
|
+
var lnToPt = parsePts(child);
|
|
62
|
+
if (lnToPt.length) {
|
|
63
|
+
var lnTo = {
|
|
64
|
+
type: 'lnTo',
|
|
65
|
+
pt: lnToPt[0]
|
|
66
|
+
};
|
|
67
|
+
pathChild.push(lnTo);
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case 'a:quadBezTo':
|
|
71
|
+
case 'quadBezTo':
|
|
72
|
+
var quadBezToPt = parsePts(child);
|
|
73
|
+
if (quadBezToPt.length) {
|
|
74
|
+
var quadBezTo = {
|
|
75
|
+
type: 'quadBezTo',
|
|
76
|
+
pts: quadBezToPt
|
|
77
|
+
};
|
|
78
|
+
pathChild.push(quadBezTo);
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
case 'a:cubicBezTo':
|
|
82
|
+
case 'cubicBezTo':
|
|
83
|
+
var cubicBezToPt = parsePts(child);
|
|
84
|
+
if (cubicBezToPt.length) {
|
|
85
|
+
var cubicBezTo = {
|
|
86
|
+
type: 'cubicBezTo',
|
|
87
|
+
pts: cubicBezToPt
|
|
88
|
+
};
|
|
89
|
+
pathChild.push(cubicBezTo);
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case 'a:arcTo':
|
|
93
|
+
case 'arcTo':
|
|
94
|
+
var wR = child.getAttribute('wR');
|
|
95
|
+
var hR = child.getAttribute('hR');
|
|
96
|
+
var stAng = child.getAttribute('stAng');
|
|
97
|
+
var swAng = child.getAttribute('swAng');
|
|
98
|
+
if (wR && hR && stAng && swAng) {
|
|
99
|
+
var arcTo = {
|
|
100
|
+
type: 'arcTo',
|
|
101
|
+
wR: wR,
|
|
102
|
+
hR: hR,
|
|
103
|
+
stAng: stAng,
|
|
104
|
+
swAng: swAng
|
|
105
|
+
};
|
|
106
|
+
pathChild.push(arcTo);
|
|
107
|
+
}
|
|
108
|
+
break;
|
|
109
|
+
case 'a:close':
|
|
110
|
+
case 'close':
|
|
111
|
+
pathChild.push({
|
|
112
|
+
type: 'close'
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
default:
|
|
116
|
+
console.warn('parsePath: unknown tag', tagName, child);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
121
|
+
finally {
|
|
122
|
+
try {
|
|
123
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
124
|
+
}
|
|
125
|
+
finally { if (e_2) throw e_2.error; }
|
|
126
|
+
}
|
|
127
|
+
var path = { defines: pathChild };
|
|
128
|
+
var fill = element.getAttribute('fill');
|
|
129
|
+
if (fill) {
|
|
130
|
+
path.fill = fill;
|
|
131
|
+
}
|
|
132
|
+
path.extrusionOk = OpenXML.getAttrBoolean(element, 'extrusionOk', false);
|
|
133
|
+
path.stroke = OpenXML.getAttrBoolean(element, 'stroke', true);
|
|
134
|
+
var w = element.getAttribute('w');
|
|
135
|
+
if (w) {
|
|
136
|
+
path.w = parseInt(w, 10);
|
|
137
|
+
}
|
|
138
|
+
var h = element.getAttribute('h');
|
|
139
|
+
if (h) {
|
|
140
|
+
path.h = parseInt(h, 10);
|
|
141
|
+
}
|
|
142
|
+
return path;
|
|
143
|
+
}
|
|
144
|
+
function parsePathLst(element) {
|
|
145
|
+
var e_3, _a;
|
|
146
|
+
var pathLst = [];
|
|
147
|
+
try {
|
|
148
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
149
|
+
var child = _c.value;
|
|
150
|
+
var tagName = child.tagName;
|
|
151
|
+
switch (tagName) {
|
|
152
|
+
case 'a:path':
|
|
153
|
+
case 'path':
|
|
154
|
+
pathLst.push(parsePath(child));
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
160
|
+
finally {
|
|
161
|
+
try {
|
|
162
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
163
|
+
}
|
|
164
|
+
finally { if (e_3) throw e_3.error; }
|
|
165
|
+
}
|
|
166
|
+
return pathLst;
|
|
167
|
+
}
|
|
168
|
+
function parseShapeGuide(element) {
|
|
169
|
+
var e_4, _a;
|
|
170
|
+
var gds = [];
|
|
171
|
+
try {
|
|
172
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
173
|
+
var child = _c.value;
|
|
174
|
+
var tagName = child.tagName;
|
|
175
|
+
switch (tagName) {
|
|
176
|
+
case 'a:gd':
|
|
177
|
+
case 'gd':
|
|
178
|
+
var name_1 = child.getAttribute('name');
|
|
179
|
+
var fmla = child.getAttribute('fmla');
|
|
180
|
+
if (name_1 && fmla) {
|
|
181
|
+
var gd = {
|
|
182
|
+
n: name_1,
|
|
183
|
+
f: fmla
|
|
184
|
+
};
|
|
185
|
+
gds.push(gd);
|
|
186
|
+
}
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
192
|
+
finally {
|
|
193
|
+
try {
|
|
194
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
195
|
+
}
|
|
196
|
+
finally { if (e_4) throw e_4.error; }
|
|
197
|
+
}
|
|
198
|
+
return gds;
|
|
199
|
+
}
|
|
200
|
+
function parseShape(element) {
|
|
201
|
+
var e_5, _a;
|
|
202
|
+
var shape = {};
|
|
203
|
+
try {
|
|
204
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
205
|
+
var child = _c.value;
|
|
206
|
+
var tagName = child.tagName;
|
|
207
|
+
switch (tagName) {
|
|
208
|
+
case 'a:avLst':
|
|
209
|
+
case 'avLst':
|
|
210
|
+
shape.avLst = parseShapeGuide(child);
|
|
211
|
+
break;
|
|
212
|
+
case 'a:gdLst':
|
|
213
|
+
case 'gdLst':
|
|
214
|
+
shape.gdLst = parseShapeGuide(child);
|
|
215
|
+
break;
|
|
216
|
+
case 'a:rect':
|
|
217
|
+
case 'react':
|
|
218
|
+
var rect = {
|
|
219
|
+
b: child.getAttribute('b') || '',
|
|
220
|
+
l: child.getAttribute('l') || '',
|
|
221
|
+
r: child.getAttribute('r') || '',
|
|
222
|
+
t: child.getAttribute('t') || ''
|
|
223
|
+
};
|
|
224
|
+
shape.rect = rect;
|
|
225
|
+
break;
|
|
226
|
+
case 'a:pathLst':
|
|
227
|
+
case 'pathLst':
|
|
228
|
+
shape.pathLst = parsePathLst(child);
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
234
|
+
finally {
|
|
235
|
+
try {
|
|
236
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
237
|
+
}
|
|
238
|
+
finally { if (e_5) throw e_5.error; }
|
|
239
|
+
}
|
|
240
|
+
return shape;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
exports.parsePath = parsePath;
|
|
244
|
+
exports.parsePathLst = parsePathLst;
|
|
245
|
+
exports.parsePts = parsePts;
|
|
246
|
+
exports.parseShape = parseShape;
|
|
247
|
+
exports.parseShapeGuide = parseShapeGuide;
|
package/lib/parse/parseSize.d.ts
CHANGED
|
@@ -12,7 +12,8 @@ export declare function convertLength(val: string, usage?: LengthUsageType): str
|
|
|
12
12
|
* 转换布尔值
|
|
13
13
|
*/
|
|
14
14
|
export declare function convertBoolean(v: string, defaultValue?: boolean): boolean;
|
|
15
|
-
export declare function convertPercentage(val: string): number;
|
|
15
|
+
export declare function convertPercentage(val: string | null): number;
|
|
16
|
+
export declare function convertAngle(val: string | null): number;
|
|
16
17
|
/**
|
|
17
18
|
* 解析尺寸,返回 css 值
|
|
18
19
|
*
|
package/lib/parse/parseSize.js
CHANGED
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
/**
|
|
6
6
|
* 单位相关的解析,参考了 docxjs 里的实现
|
|
7
7
|
*/
|
|
8
|
+
/**
|
|
9
|
+
* 单位转成 px,这样才能和 svg 里的一致
|
|
10
|
+
*/
|
|
8
11
|
var ptToPx = 1.3333;
|
|
9
12
|
var LengthUsage = {
|
|
10
13
|
Dxa: { mul: ptToPx * 0.05, unit: 'px' },
|
|
@@ -23,6 +26,9 @@ function convertLength(val, usage) {
|
|
|
23
26
|
}
|
|
24
27
|
return "".concat((parseInt(val) * usage.mul).toFixed(2)).concat(usage.unit);
|
|
25
28
|
}
|
|
29
|
+
function convertAngle(val) {
|
|
30
|
+
return val ? parseInt(val) / 60000 : 0;
|
|
31
|
+
}
|
|
26
32
|
/**
|
|
27
33
|
* 解析尺寸,返回 css 值
|
|
28
34
|
*
|
|
@@ -40,5 +46,6 @@ function parseSize(element, attrName, usage) {
|
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
exports.LengthUsage = LengthUsage;
|
|
49
|
+
exports.convertAngle = convertAngle;
|
|
43
50
|
exports.convertLength = convertLength;
|
|
44
51
|
exports.parseSize = parseSize;
|
|
@@ -38,7 +38,7 @@ function parseSpacing(word, element, style) {
|
|
|
38
38
|
break;
|
|
39
39
|
default:
|
|
40
40
|
var lineHeightMin = Math.max(minLineHeight, lineNum / 20);
|
|
41
|
-
style['line-height'] =
|
|
41
|
+
style['line-height'] = "".concat(lineHeightMin, "pt");
|
|
42
42
|
break;
|
|
43
43
|
}
|
|
44
44
|
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Table = require('../openxml/word/Table.js');
|
|
7
|
+
var parseTr = require('./parseTr.js');
|
|
8
|
+
var parseTablePr = require('./parseTablePr.js');
|
|
9
|
+
var parseSize = require('./parseSize.js');
|
|
10
|
+
var mergeSdt = require('./mergeSdt.js');
|
|
11
|
+
|
|
12
|
+
function parseTblGrid(element) {
|
|
13
|
+
var e_1, _a;
|
|
14
|
+
var gridCol = [];
|
|
15
|
+
var gridColElements = element.getElementsByTagName('w:gridCol');
|
|
16
|
+
try {
|
|
17
|
+
for (var gridColElements_1 = tslib.__values(gridColElements), gridColElements_1_1 = gridColElements_1.next(); !gridColElements_1_1.done; gridColElements_1_1 = gridColElements_1.next()) {
|
|
18
|
+
var gridColElement = gridColElements_1_1.value;
|
|
19
|
+
var w = parseSize.parseSize(gridColElement, 'w:w');
|
|
20
|
+
gridCol.push({ w: w });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
24
|
+
finally {
|
|
25
|
+
try {
|
|
26
|
+
if (gridColElements_1_1 && !gridColElements_1_1.done && (_a = gridColElements_1.return)) _a.call(gridColElements_1);
|
|
27
|
+
}
|
|
28
|
+
finally { if (e_1) throw e_1.error; }
|
|
29
|
+
}
|
|
30
|
+
return gridCol;
|
|
31
|
+
}
|
|
32
|
+
function parseTable(word, element) {
|
|
33
|
+
var e_2, _a;
|
|
34
|
+
var table = new Table.Table();
|
|
35
|
+
// 用于计算列的跨行,这里记下前面的跨行情况
|
|
36
|
+
var rowSpanMap = {};
|
|
37
|
+
try {
|
|
38
|
+
for (var _b = tslib.__values(mergeSdt.mergeSdt(element)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
39
|
+
var child = _c.value;
|
|
40
|
+
var tagName = child.tagName;
|
|
41
|
+
switch (tagName) {
|
|
42
|
+
case 'w:tblPr':
|
|
43
|
+
table.properties = parseTablePr.parseTablePr(word, child);
|
|
44
|
+
break;
|
|
45
|
+
case 'w:tr':
|
|
46
|
+
table.trs.push(parseTr.parseTr(word, child, rowSpanMap));
|
|
47
|
+
break;
|
|
48
|
+
case 'w:tblGrid':
|
|
49
|
+
table.tblGrid = parseTblGrid(child);
|
|
50
|
+
break;
|
|
51
|
+
default:
|
|
52
|
+
console.warn('Table.fromXML unknown tag', tagName, child);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e_2) throw e_2.error; }
|
|
62
|
+
}
|
|
63
|
+
return table;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.parseTable = parseTable;
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var OpenXML = require('../OpenXML.js');
|
|
7
|
+
var parseBorder = require('./parseBorder.js');
|
|
8
|
+
var parseInsideBorders = require('./parseInsideBorders.js');
|
|
9
|
+
var parseTblWidth = require('./parseTblWidth.js');
|
|
10
|
+
var parseColor = require('./parseColor.js');
|
|
11
|
+
var parseSize = require('./parseSize.js');
|
|
12
|
+
var parseTcPr = require('./parseTcPr.js');
|
|
13
|
+
var parseCellMargin = require('./parseCellMargin.js');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 表格的 jc 需要使用 float 来实现
|
|
17
|
+
* http://officeopenxml.com/WPtableAlignment.php
|
|
18
|
+
*/
|
|
19
|
+
function parseTblJc(element, cssStyle) {
|
|
20
|
+
var val = OpenXML.getVal(element);
|
|
21
|
+
switch (val) {
|
|
22
|
+
case 'left':
|
|
23
|
+
case 'start':
|
|
24
|
+
// TODO: 会导致前面的文字掉下去,感觉还是不能支持这个功能
|
|
25
|
+
// cssStyle['float'] = 'left';
|
|
26
|
+
break;
|
|
27
|
+
case 'right':
|
|
28
|
+
case 'end':
|
|
29
|
+
cssStyle['float'] = 'right';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 这个其实分左右,但目前只支持左,右可能是阿拉伯语?
|
|
34
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblInd_2.html
|
|
35
|
+
*/
|
|
36
|
+
function parseTblInd(element, style) {
|
|
37
|
+
var width = parseTblWidth.parseTblWidth(element);
|
|
38
|
+
if (width) {
|
|
39
|
+
style['margin-left'] = width;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function parseTblW(element, style) {
|
|
43
|
+
var width = parseTblWidth.parseTblWidth(element);
|
|
44
|
+
if (width) {
|
|
45
|
+
style['width'] = width;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/ST_TblStyleOverrideType.html
|
|
49
|
+
// val 是旧的格式
|
|
50
|
+
function parseTblLook(child) {
|
|
51
|
+
var tblLook = {};
|
|
52
|
+
var tblLookVal = OpenXML.getValHex(child);
|
|
53
|
+
if (OpenXML.getAttrBoolean(child, 'firstRow', false) || tblLookVal & 0x0020) {
|
|
54
|
+
tblLook['firstRow'] = true;
|
|
55
|
+
}
|
|
56
|
+
if (OpenXML.getAttrBoolean(child, 'lastRow', false) || tblLookVal & 0x0040) {
|
|
57
|
+
tblLook['lastRow'] = true;
|
|
58
|
+
}
|
|
59
|
+
if (OpenXML.getAttrBoolean(child, 'firstColumn', false) || tblLookVal & 0x0080) {
|
|
60
|
+
tblLook['firstColumn'] = true;
|
|
61
|
+
}
|
|
62
|
+
if (OpenXML.getAttrBoolean(child, 'lastColumn', false) || tblLookVal & 0x0100) {
|
|
63
|
+
tblLook['lastColumn'] = true;
|
|
64
|
+
}
|
|
65
|
+
if (OpenXML.getAttrBoolean(child, 'noHBand', false) || tblLookVal & 0x0200) {
|
|
66
|
+
tblLook['noHBand'] = true;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
tblLook['noHBand'] = false;
|
|
70
|
+
}
|
|
71
|
+
if (OpenXML.getAttrBoolean(child, 'noVBand', false) || tblLookVal & 0x0400) {
|
|
72
|
+
tblLook['noVBand'] = true;
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
tblLook['noVBand'] = false;
|
|
76
|
+
}
|
|
77
|
+
return tblLook;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblpPr.html
|
|
81
|
+
* 只支持部分
|
|
82
|
+
*/
|
|
83
|
+
function parseTblpPr(word, child, style) {
|
|
84
|
+
// 如果设置 padding 会导致绝对定位不准确,所以一旦设置就不支持
|
|
85
|
+
if (typeof word.renderOptions.padding === 'undefined') {
|
|
86
|
+
var tplpX = parseSize.parseSize(child, 'w:tblpX');
|
|
87
|
+
var tplpY = parseSize.parseSize(child, 'w:tblpY');
|
|
88
|
+
// style.position = 'absolute';
|
|
89
|
+
style.top = tplpY;
|
|
90
|
+
style.left = tplpX;
|
|
91
|
+
}
|
|
92
|
+
// 之前想用 float 来实现,但是会导致文字掉下去
|
|
93
|
+
// const topFromText = parseSize(child, 'w:topFromText');
|
|
94
|
+
// const bottomFromText = parseSize(child, 'w:bottomFromText');
|
|
95
|
+
// const rightFromText = parseSize(child, 'w:rightFromText');
|
|
96
|
+
// const leftFromText = parseSize(child, 'w:leftFromText');
|
|
97
|
+
// style['float'] = 'left';
|
|
98
|
+
// style['margin-bottom'] = addSize(style['margin-bottom'], bottomFromText);
|
|
99
|
+
// style['margin-left'] = addSize(style['margin-left'], leftFromText);
|
|
100
|
+
// style['margin-right'] = addSize(style['margin-right'], rightFromText);
|
|
101
|
+
// style['margin-top'] = addSize(style['margin-top'], topFromText);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* http://officeopenxml.com/WPtableLayout.php
|
|
105
|
+
*/
|
|
106
|
+
function parseTblLayout(element, style) {
|
|
107
|
+
var type = element.getAttribute('w:type');
|
|
108
|
+
if (type === 'fixed') {
|
|
109
|
+
style['table-layout'] = 'fixed';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function parseTablePr(word, element) {
|
|
113
|
+
var e_1, _a;
|
|
114
|
+
var properties = {};
|
|
115
|
+
var tableStyle = {};
|
|
116
|
+
var tcStyle = {};
|
|
117
|
+
properties.tblLook = {};
|
|
118
|
+
properties.cssStyle = tableStyle;
|
|
119
|
+
properties.tcCSSStyle = tcStyle;
|
|
120
|
+
try {
|
|
121
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
122
|
+
var child = _c.value;
|
|
123
|
+
var tagName = child.tagName;
|
|
124
|
+
switch (tagName) {
|
|
125
|
+
case 'w:tblBorders':
|
|
126
|
+
parseBorder.parseBorders(word, child, tableStyle);
|
|
127
|
+
properties.insideBorder = parseInsideBorders.parseInsideBorders(word, child);
|
|
128
|
+
break;
|
|
129
|
+
case 'w:tcBorders':
|
|
130
|
+
parseBorder.parseBorders(word, child, tableStyle);
|
|
131
|
+
break;
|
|
132
|
+
case 'w:tblInd':
|
|
133
|
+
parseTblInd(child, tableStyle);
|
|
134
|
+
break;
|
|
135
|
+
case 'w:jc':
|
|
136
|
+
parseTblJc(child, tableStyle);
|
|
137
|
+
break;
|
|
138
|
+
case 'w:tblCellMar':
|
|
139
|
+
case 'w:tcMar':
|
|
140
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblCellMar_1.html
|
|
141
|
+
parseCellMargin.parseCellMargin(child, tcStyle);
|
|
142
|
+
break;
|
|
143
|
+
case 'w:tblStyle':
|
|
144
|
+
properties.pStyle = OpenXML.getVal(child);
|
|
145
|
+
break;
|
|
146
|
+
case 'w:tblW':
|
|
147
|
+
parseTblW(child, tableStyle);
|
|
148
|
+
break;
|
|
149
|
+
case 'w:shd':
|
|
150
|
+
// http://officeopenxml.com/WPtableShading.php
|
|
151
|
+
tableStyle['background-color'] = parseColor.parseShdColor(word, child);
|
|
152
|
+
break;
|
|
153
|
+
case 'w:tblCaption':
|
|
154
|
+
properties.tblCaption = OpenXML.getVal(child);
|
|
155
|
+
break;
|
|
156
|
+
case 'w:tblCellSpacing':
|
|
157
|
+
parseTcPr.parseTblCellSpacing(child, tableStyle);
|
|
158
|
+
break;
|
|
159
|
+
case 'w:tblLayout':
|
|
160
|
+
parseTblLayout(child, tableStyle);
|
|
161
|
+
break;
|
|
162
|
+
case 'w:tblLook':
|
|
163
|
+
properties.tblLook = parseTblLook(child);
|
|
164
|
+
break;
|
|
165
|
+
case 'w:tblStyleRowBandSize':
|
|
166
|
+
properties.rowBandSize = OpenXML.getValNumber(child);
|
|
167
|
+
break;
|
|
168
|
+
case 'w:tblStyleColBandSize':
|
|
169
|
+
properties.colBandSize = OpenXML.getValNumber(child);
|
|
170
|
+
break;
|
|
171
|
+
case 'w:tblpPr':
|
|
172
|
+
parseTblpPr(word, child, tableStyle);
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
console.warn('parseTableProperties unknown tag', tagName, child);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
180
|
+
finally {
|
|
181
|
+
try {
|
|
182
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
183
|
+
}
|
|
184
|
+
finally { if (e_1) throw e_1.error; }
|
|
185
|
+
}
|
|
186
|
+
return properties;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
exports.parseTablePr = parseTablePr;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var parseSize = require('./parseSize.js');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* http://officeopenxml.com/WPtableWidth.php
|
|
9
|
+
*/
|
|
10
|
+
function parseTblWidth(element) {
|
|
11
|
+
var type = element.getAttribute('w:type');
|
|
12
|
+
if (!type || type === 'dxa') {
|
|
13
|
+
return parseSize.parseSize(element, 'w:w');
|
|
14
|
+
}
|
|
15
|
+
else if (type === 'pct') {
|
|
16
|
+
return parseSize.parseSize(element, 'w:w', parseSize.LengthUsage.Percent);
|
|
17
|
+
}
|
|
18
|
+
else if (type === 'auto') {
|
|
19
|
+
return 'auto';
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
console.warn('parseTblWidth: ignore type', type, element);
|
|
23
|
+
}
|
|
24
|
+
return '';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
exports.parseTblWidth = parseTblWidth;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Tc = require('../openxml/word/table/Tc.js');
|
|
7
|
+
var parseTcPr = require('./parseTcPr.js');
|
|
8
|
+
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
9
|
+
var parseTable = require('./parseTable.js');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 拆分出来主要是为了避免循环引用
|
|
13
|
+
*/
|
|
14
|
+
function parseTc(word, element, currentCol, rowSpanMap) {
|
|
15
|
+
var e_1, _a;
|
|
16
|
+
var tc = new Tc.Tc();
|
|
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 'w:tcPr':
|
|
23
|
+
tc.properties = parseTcPr.parseTcPr(word, child);
|
|
24
|
+
break;
|
|
25
|
+
case 'w:p':
|
|
26
|
+
tc.add(Paragraph.Paragraph.fromXML(word, child));
|
|
27
|
+
break;
|
|
28
|
+
case 'w:tbl':
|
|
29
|
+
tc.add(parseTable.parseTable(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
|
+
var lastCol = rowSpanMap[currentCol.index];
|
|
42
|
+
// 如果是 continue 意味着这个被合并了
|
|
43
|
+
if (tc.properties.vMerge) {
|
|
44
|
+
if (tc.properties.vMerge === 'restart') {
|
|
45
|
+
tc.properties.rowSpan = 1;
|
|
46
|
+
rowSpanMap[currentCol.index] = tc;
|
|
47
|
+
}
|
|
48
|
+
else if (lastCol) {
|
|
49
|
+
if (lastCol.properties && lastCol.properties.rowSpan) {
|
|
50
|
+
lastCol.properties.rowSpan = lastCol.properties.rowSpan + 1;
|
|
51
|
+
var colSpan_1 = tc.properties.gridSpan || 1;
|
|
52
|
+
currentCol.index += colSpan_1;
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
console.warn('Tc.fromXML: continue but not found lastCol', currentCol.index, tc, rowSpanMap);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
delete rowSpanMap[currentCol.index];
|
|
62
|
+
}
|
|
63
|
+
var colSpan = tc.properties.gridSpan || 1;
|
|
64
|
+
currentCol.index += colSpan;
|
|
65
|
+
return tc;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
exports.parseTc = parseTc;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CSSStyle } from '../openxml/Style';
|
|
2
|
+
import { TcPr } from '../openxml/word/table/Tc';
|
|
3
|
+
import Word from '../Word';
|
|
4
|
+
export declare function parseTblCellSpacing(element: Element, style: CSSStyle): void;
|
|
5
|
+
export declare function parseTcPr(word: Word, element: Element): TcPr;
|