office-viewer 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/esm/OpenXML.d.ts +19 -0
- package/esm/OpenXML.js +43 -2
- package/esm/Word.d.ts +132 -15
- package/esm/Word.js +239 -54
- package/esm/openxml/ContentType.js +20 -6
- package/esm/openxml/Settings.d.ts +10 -0
- package/esm/openxml/Settings.js +93 -0
- package/esm/openxml/Style.d.ts +1 -1
- package/esm/openxml/Style.js +12 -12
- package/esm/openxml/Theme.js +30 -6
- package/esm/openxml/Types.d.ts +179 -2472
- package/esm/openxml/drawing/Blip.d.ts +7 -0
- package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
- package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
- package/esm/openxml/drawing/CustomGeom.js +17 -0
- package/esm/openxml/drawing/Drawing.d.ts +37 -0
- package/esm/openxml/drawing/Drawing.js +173 -0
- package/esm/openxml/drawing/Geom.d.ts +11 -0
- package/esm/openxml/drawing/Geom.js +34 -0
- package/esm/openxml/drawing/Path.d.ts +37 -0
- package/esm/openxml/drawing/Pic.d.ts +16 -0
- package/esm/openxml/drawing/Pic.js +26 -0
- package/esm/openxml/drawing/Shape.d.ts +20 -0
- package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/esm/openxml/drawing/ShapeProperties.js +119 -0
- package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +4 -1
- package/esm/openxml/drawing/Transform.js +63 -0
- package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/esm/openxml/drawing/diagram/Diagram.js +24 -0
- package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/esm/openxml/drawing/presetShape.d.ts +3 -0
- package/esm/openxml/drawing/presetShape.js +38785 -0
- package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/esm/openxml/drawing/svg/arcToA.js +88 -0
- package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
- package/esm/openxml/drawing/svg/formulas.js +103 -0
- package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/esm/openxml/drawing/svg/generateDefines.js +144 -0
- package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/esm/openxml/drawing/svg/presetVal.js +53 -0
- package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
- package/esm/openxml/math/OMath.d.ts +5 -0
- package/esm/openxml/math/OMath.js +12 -0
- package/esm/openxml/math/convertOOML.d.ts +4 -0
- package/esm/openxml/math/convertOOML.js +13 -0
- package/esm/openxml/math/xsl.d.ts +4 -0
- package/esm/openxml/math/xsl.js +8 -0
- package/esm/openxml/word/Body.js +11 -7
- package/esm/openxml/word/Break.js +1 -3
- package/esm/openxml/word/Font.d.ts +16 -0
- package/esm/openxml/word/Font.js +78 -0
- package/esm/openxml/word/FontTable.d.ts +9 -0
- package/esm/openxml/word/FontTable.js +34 -0
- package/esm/openxml/word/Header.d.ts +11 -0
- package/esm/openxml/word/Header.js +54 -0
- package/esm/openxml/word/Hyperlink.d.ts +1 -0
- package/esm/openxml/word/Hyperlink.js +7 -3
- package/esm/openxml/word/InlineText.js +1 -1
- package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/esm/openxml/word/NoBreakHyphen.js +7 -0
- package/esm/openxml/word/Note.d.ts +12 -0
- package/esm/openxml/word/Note.js +48 -0
- package/esm/openxml/word/Paragraph.d.ts +2 -2
- package/esm/openxml/word/Paragraph.js +10 -9
- package/esm/openxml/word/Pict.d.ts +1 -2
- package/esm/openxml/word/Pict.js +5 -3
- package/esm/openxml/word/Ruby.js +1 -1
- package/esm/openxml/word/Run.d.ts +7 -3
- package/esm/openxml/word/Run.js +28 -4
- package/esm/openxml/word/Section.d.ts +18 -5
- package/esm/openxml/word/Section.js +46 -2
- package/esm/openxml/word/Separator.d.ts +5 -0
- package/esm/openxml/word/Separator.js +10 -0
- package/esm/openxml/word/SoftHyphen.d.ts +5 -0
- package/esm/openxml/word/SoftHyphen.js +10 -0
- package/esm/openxml/word/Tab.d.ts +1 -1
- package/esm/openxml/word/Table.d.ts +4 -9
- package/esm/openxml/word/Table.js +0 -235
- package/esm/openxml/word/WDocument.d.ts +1 -2
- package/esm/openxml/word/WDocument.js +53 -7
- package/esm/openxml/word/numbering/AbstractNum.js +4 -2
- package/esm/openxml/word/numbering/Lvl.js +10 -4
- package/esm/openxml/word/numbering/Num.js +12 -4
- package/esm/openxml/word/numbering/NumberProperties.js +2 -2
- package/esm/openxml/word/numbering/Numbering.js +1 -1
- package/esm/openxml/word/table/Tc.d.ts +1 -22
- package/esm/openxml/word/table/Tc.js +1 -221
- package/esm/openxml/word/table/Tr.d.ts +0 -5
- package/esm/openxml/word/table/Tr.js +0 -97
- package/esm/openxml/word/wps/WPG.d.ts +14 -0
- package/esm/openxml/word/wps/WPG.js +56 -0
- package/esm/openxml/word/wps/WPS.d.ts +18 -0
- package/esm/openxml/word/wps/WPS.js +148 -0
- package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/esm/openxml/word/wps/WPSStyle.js +42 -0
- package/esm/package/PackageParser.d.ts +1 -1
- package/esm/package/XMLPackageParser.d.ts +3 -3
- package/esm/package/ZipPackageParser.d.ts +1 -1
- package/esm/package/ZipPackageParser.js +7 -8
- package/esm/parse/Footnotes.d.ts +3 -0
- package/esm/parse/Footnotes.js +25 -0
- package/esm/parse/colorNameMap.d.ts +6 -0
- package/esm/parse/colorNameMap.js +201 -0
- package/esm/parse/jcToTextAlign.js +1 -0
- package/esm/parse/mergeSdt.d.ts +4 -0
- package/esm/parse/mergeSdt.js +57 -0
- package/esm/parse/modifyColor.d.ts +1 -0
- package/esm/parse/modifyColor.js +106 -0
- package/esm/parse/parseBorder.js +2 -21
- package/esm/parse/parseCellMargin.d.ts +2 -0
- package/esm/parse/parseCellMargin.js +38 -0
- package/esm/parse/parseChildColor.d.ts +5 -0
- package/esm/parse/parseChildColor.js +66 -0
- package/esm/parse/parseColor.d.ts +4 -0
- package/esm/parse/parseColor.js +41 -46
- package/esm/parse/parseEndnotes.d.ts +3 -0
- package/esm/parse/parseEndnotes.js +25 -0
- package/esm/parse/parseFont.js +1 -1
- package/esm/parse/parseInsideBorders.d.ts +9 -0
- package/esm/parse/parseInsideBorders.js +24 -0
- package/esm/parse/parsePr.d.ts +3 -0
- package/esm/parse/parsePr.js +108 -11
- package/esm/parse/parseRelationship.js +1 -1
- package/esm/parse/parseSdt.d.ts +5 -0
- package/esm/parse/parseShape.d.ts +10 -0
- package/esm/parse/parseShape.js +239 -0
- package/esm/parse/parseSize.d.ts +2 -1
- package/esm/parse/parseSize.js +7 -1
- package/esm/parse/parseSpacing.js +1 -1
- package/esm/parse/parseTable.d.ts +3 -0
- package/esm/parse/parseTable.js +62 -0
- package/esm/parse/parseTablePr.d.ts +3 -0
- package/esm/parse/parseTablePr.js +185 -0
- package/esm/parse/parseTblWidth.d.ts +4 -0
- package/esm/parse/parseTblWidth.js +23 -0
- package/esm/parse/parseTc.d.ts +10 -0
- package/esm/parse/parseTc.js +64 -0
- package/esm/parse/parseTcPr.d.ts +5 -0
- package/esm/parse/parseTcPr.js +99 -0
- package/esm/parse/parseTextDirection.js +4 -6
- package/esm/parse/parseTr.d.ts +6 -0
- package/esm/parse/parseTr.js +49 -0
- package/esm/parse/parseTrPr.d.ts +3 -0
- package/esm/parse/parseTrPr.js +59 -0
- package/esm/render/fixAbsolutePosition.d.ts +8 -0
- package/esm/render/renderBody.d.ts +6 -2
- package/esm/render/renderBody.js +184 -30
- package/esm/render/renderBr.d.ts +2 -1
- package/esm/render/renderBr.js +4 -1
- package/esm/render/renderCustGeom.d.ts +4 -0
- package/esm/render/renderCustGeom.js +10 -0
- package/esm/render/renderDocument.d.ts +2 -2
- package/esm/render/renderDocument.js +2 -2
- package/esm/render/renderDrawing.d.ts +3 -2
- package/esm/render/renderDrawing.js +238 -21
- package/esm/render/renderFont.d.ts +5 -0
- package/esm/render/renderFont.js +39 -0
- package/esm/render/renderGeom.d.ts +4 -0
- package/esm/render/renderGeom.js +14 -0
- package/esm/render/renderHeader.d.ts +6 -0
- package/esm/render/renderHeader.js +40 -0
- package/esm/render/renderHyperLink.js +4 -1
- package/esm/render/renderInlineText.js +1 -1
- package/esm/render/renderInstrText.js +1 -1
- package/esm/render/renderMath.d.ts +3 -0
- package/esm/render/renderMath.js +7 -0
- package/esm/render/renderNoBreakHyphen.d.ts +1 -0
- package/esm/render/renderNoBreakHyphen.js +9 -0
- package/esm/render/renderNotes.d.ts +5 -0
- package/esm/render/renderNotes.js +77 -0
- package/esm/render/renderNumbering.js +8 -10
- package/esm/render/renderParagraph.d.ts +1 -1
- package/esm/render/renderParagraph.js +58 -18
- package/esm/render/renderPict.js +5 -10
- package/esm/render/renderRuby.js +1 -1
- package/esm/render/renderRun.d.ts +4 -2
- package/esm/render/renderRun.js +42 -12
- package/esm/render/renderSection.d.ts +3 -2
- package/esm/render/renderSection.js +79 -5
- package/esm/render/renderSeparator.d.ts +1 -0
- package/esm/render/renderSeparator.js +9 -0
- package/esm/render/renderSoftHyphen.d.ts +1 -0
- package/esm/render/renderSoftHyphen.js +9 -0
- package/esm/render/renderStyle.js +36 -35
- package/esm/render/renderTab.d.ts +2 -1
- package/esm/render/renderTab.js +10 -6
- package/esm/render/renderTable.js +23 -20
- package/esm/render/setElementStyle.js +7 -2
- package/esm/render/zindex.d.ts +1 -0
- package/esm/util/blob.js +1 -10
- package/esm/util/color.d.ts +48 -0
- package/esm/util/color.js +211 -0
- package/esm/util/createObject.d.ts +10 -0
- package/esm/util/createObject.js +48 -0
- package/esm/util/dom.d.ts +8 -4
- package/esm/util/dom.js +21 -4
- package/esm/util/get.d.ts +4 -0
- package/esm/util/get.js +18 -0
- package/esm/util/mergeRun.js +1 -1
- package/esm/util/parseSides.d.ts +11 -0
- package/esm/util/print.d.ts +5 -0
- package/esm/util/print.js +54 -0
- package/esm/util/replaceVar.d.ts +10 -0
- package/esm/util/replaceVar.js +215 -0
- package/esm/util/xml.js +4 -1
- package/lib/OpenXML.d.ts +19 -0
- package/lib/OpenXML.js +44 -1
- package/lib/Word.d.ts +132 -15
- package/lib/Word.js +244 -59
- package/lib/openxml/ContentType.js +20 -6
- package/lib/openxml/Settings.d.ts +10 -0
- package/lib/openxml/Settings.js +97 -0
- package/lib/openxml/Style.d.ts +1 -1
- package/lib/openxml/Style.js +15 -15
- package/lib/openxml/Theme.js +31 -7
- package/lib/openxml/Types.d.ts +179 -2472
- package/lib/openxml/drawing/Blip.d.ts +7 -0
- package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
- package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
- package/lib/openxml/drawing/CustomGeom.js +21 -0
- package/lib/openxml/drawing/Drawing.d.ts +37 -0
- package/lib/openxml/drawing/Drawing.js +177 -0
- package/lib/openxml/drawing/Geom.d.ts +11 -0
- package/lib/openxml/drawing/Geom.js +38 -0
- package/lib/openxml/drawing/Path.d.ts +37 -0
- package/lib/openxml/drawing/Pic.d.ts +16 -0
- package/lib/openxml/drawing/Pic.js +30 -0
- package/lib/openxml/drawing/Shape.d.ts +20 -0
- package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/lib/openxml/drawing/ShapeProperties.js +123 -0
- package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +4 -1
- package/lib/openxml/drawing/Transform.js +67 -0
- package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/lib/openxml/drawing/diagram/Diagram.js +28 -0
- package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/lib/openxml/drawing/presetShape.d.ts +3 -0
- package/lib/openxml/drawing/presetShape.js +38789 -0
- package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/lib/openxml/drawing/svg/arcToA.js +92 -0
- package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
- package/lib/openxml/drawing/svg/formulas.js +108 -0
- package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/lib/openxml/drawing/svg/generateDefines.js +148 -0
- package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/lib/openxml/drawing/svg/presetVal.js +57 -0
- package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
- package/lib/openxml/math/OMath.d.ts +5 -0
- package/lib/openxml/math/OMath.js +16 -0
- package/lib/openxml/math/convertOOML.d.ts +4 -0
- package/lib/openxml/math/convertOOML.js +17 -0
- package/lib/openxml/math/xsl.d.ts +4 -0
- package/lib/openxml/math/xsl.js +12 -0
- package/lib/openxml/word/Body.js +11 -7
- package/lib/openxml/word/Break.js +1 -3
- package/lib/openxml/word/Font.d.ts +16 -0
- package/lib/openxml/word/Font.js +83 -0
- package/lib/openxml/word/FontTable.d.ts +9 -0
- package/lib/openxml/word/FontTable.js +38 -0
- package/lib/openxml/word/Header.d.ts +11 -0
- package/lib/openxml/word/Header.js +58 -0
- package/lib/openxml/word/Hyperlink.d.ts +1 -0
- package/lib/openxml/word/Hyperlink.js +8 -4
- package/lib/openxml/word/InlineText.js +2 -2
- package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/lib/openxml/word/NoBreakHyphen.js +11 -0
- package/lib/openxml/word/Note.d.ts +12 -0
- package/lib/openxml/word/Note.js +52 -0
- package/lib/openxml/word/Paragraph.d.ts +2 -2
- package/lib/openxml/word/Paragraph.js +11 -10
- package/lib/openxml/word/Pict.d.ts +1 -2
- package/lib/openxml/word/Pict.js +5 -3
- package/lib/openxml/word/Ruby.js +4 -4
- package/lib/openxml/word/Run.d.ts +7 -3
- package/lib/openxml/word/Run.js +29 -5
- package/lib/openxml/word/Section.d.ts +18 -5
- package/lib/openxml/word/Section.js +47 -3
- package/lib/openxml/word/Separator.d.ts +5 -0
- package/lib/openxml/word/Separator.js +14 -0
- package/lib/openxml/word/SoftHyphen.d.ts +5 -0
- package/lib/openxml/word/SoftHyphen.js +14 -0
- package/lib/openxml/word/Tab.d.ts +1 -1
- package/lib/openxml/word/Table.d.ts +4 -9
- package/lib/openxml/word/Table.js +0 -235
- package/lib/openxml/word/WDocument.d.ts +1 -2
- package/lib/openxml/word/WDocument.js +53 -7
- package/lib/openxml/word/numbering/AbstractNum.js +5 -3
- package/lib/openxml/word/numbering/Lvl.js +11 -5
- package/lib/openxml/word/numbering/Num.js +12 -4
- package/lib/openxml/word/numbering/NumberProperties.js +2 -2
- package/lib/openxml/word/numbering/Numbering.js +3 -3
- package/lib/openxml/word/table/Tc.d.ts +1 -22
- package/lib/openxml/word/table/Tc.js +0 -224
- package/lib/openxml/word/table/Tr.d.ts +0 -5
- package/lib/openxml/word/table/Tr.js +0 -97
- package/lib/openxml/word/wps/WPG.d.ts +14 -0
- package/lib/openxml/word/wps/WPG.js +60 -0
- package/lib/openxml/word/wps/WPS.d.ts +18 -0
- package/lib/openxml/word/wps/WPS.js +152 -0
- package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/lib/openxml/word/wps/WPSStyle.js +46 -0
- package/lib/package/PackageParser.d.ts +1 -1
- package/lib/package/XMLPackageParser.d.ts +3 -3
- package/lib/package/ZipPackageParser.d.ts +1 -1
- package/lib/package/ZipPackageParser.js +7 -8
- package/lib/parse/Footnotes.d.ts +3 -0
- package/lib/parse/Footnotes.js +29 -0
- package/lib/parse/colorNameMap.d.ts +6 -0
- package/lib/parse/colorNameMap.js +205 -0
- package/lib/parse/jcToTextAlign.js +1 -0
- package/lib/parse/mergeSdt.d.ts +4 -0
- package/lib/parse/mergeSdt.js +61 -0
- package/lib/parse/modifyColor.d.ts +1 -0
- package/lib/parse/modifyColor.js +110 -0
- package/lib/parse/parseBorder.js +3 -22
- package/lib/parse/parseCellMargin.d.ts +2 -0
- package/lib/parse/parseCellMargin.js +42 -0
- package/lib/parse/parseChildColor.d.ts +5 -0
- package/lib/parse/parseChildColor.js +70 -0
- package/lib/parse/parseColor.d.ts +4 -0
- package/lib/parse/parseColor.js +41 -45
- package/lib/parse/parseEndnotes.d.ts +3 -0
- package/lib/parse/parseEndnotes.js +29 -0
- package/lib/parse/parseFont.js +2 -2
- package/lib/parse/parseInsideBorders.d.ts +9 -0
- package/lib/parse/parseInsideBorders.js +28 -0
- package/lib/parse/parsePr.d.ts +3 -0
- package/lib/parse/parsePr.js +109 -12
- package/lib/parse/parseRelationship.js +2 -2
- package/lib/parse/parseSdt.d.ts +5 -0
- package/lib/parse/parseShape.d.ts +10 -0
- package/lib/parse/parseShape.js +247 -0
- package/lib/parse/parseSize.d.ts +2 -1
- package/lib/parse/parseSize.js +7 -0
- package/lib/parse/parseSpacing.js +1 -1
- package/lib/parse/parseTable.d.ts +3 -0
- package/lib/parse/parseTable.js +66 -0
- package/lib/parse/parseTablePr.d.ts +3 -0
- package/lib/parse/parseTablePr.js +189 -0
- package/lib/parse/parseTblWidth.d.ts +4 -0
- package/lib/parse/parseTblWidth.js +27 -0
- package/lib/parse/parseTc.d.ts +10 -0
- package/lib/parse/parseTc.js +68 -0
- package/lib/parse/parseTcPr.d.ts +5 -0
- package/lib/parse/parseTcPr.js +104 -0
- package/lib/parse/parseTextDirection.js +4 -6
- package/lib/parse/parseTr.d.ts +6 -0
- package/lib/parse/parseTr.js +53 -0
- package/lib/parse/parseTrPr.d.ts +3 -0
- package/lib/parse/parseTrPr.js +63 -0
- package/lib/render/fixAbsolutePosition.d.ts +8 -0
- package/lib/render/renderBody.d.ts +6 -2
- package/lib/render/renderBody.js +183 -29
- package/lib/render/renderBr.d.ts +2 -1
- package/lib/render/renderBr.js +4 -1
- package/lib/render/renderCustGeom.d.ts +4 -0
- package/lib/render/renderCustGeom.js +14 -0
- package/lib/render/renderDocument.d.ts +2 -2
- package/lib/render/renderDocument.js +2 -2
- package/lib/render/renderDrawing.d.ts +3 -2
- package/lib/render/renderDrawing.js +238 -21
- package/lib/render/renderFont.d.ts +5 -0
- package/lib/render/renderFont.js +43 -0
- package/lib/render/renderGeom.d.ts +4 -0
- package/lib/render/renderGeom.js +18 -0
- package/lib/render/renderHeader.d.ts +6 -0
- package/lib/render/renderHeader.js +44 -0
- package/lib/render/renderHyperLink.js +5 -2
- package/lib/render/renderInlineText.js +2 -2
- package/lib/render/renderInstrText.js +2 -2
- package/lib/render/renderMath.d.ts +3 -0
- package/lib/render/renderMath.js +11 -0
- package/lib/render/renderNoBreakHyphen.d.ts +1 -0
- package/lib/render/renderNoBreakHyphen.js +13 -0
- package/lib/render/renderNotes.d.ts +5 -0
- package/lib/render/renderNotes.js +81 -0
- package/lib/render/renderNumbering.js +9 -11
- package/lib/render/renderParagraph.d.ts +1 -1
- package/lib/render/renderParagraph.js +58 -18
- package/lib/render/renderPict.js +5 -10
- package/lib/render/renderRuby.js +3 -3
- package/lib/render/renderRun.d.ts +4 -2
- package/lib/render/renderRun.js +41 -11
- package/lib/render/renderSection.d.ts +3 -2
- package/lib/render/renderSection.js +79 -5
- package/lib/render/renderSeparator.d.ts +1 -0
- package/lib/render/renderSeparator.js +13 -0
- package/lib/render/renderSoftHyphen.d.ts +1 -0
- package/lib/render/renderSoftHyphen.js +13 -0
- package/lib/render/renderStyle.js +37 -36
- package/lib/render/renderTab.d.ts +2 -1
- package/lib/render/renderTab.js +10 -6
- package/lib/render/renderTable.js +25 -22
- package/lib/render/setElementStyle.js +6 -1
- package/lib/render/zindex.d.ts +1 -0
- package/lib/util/blob.js +0 -10
- package/lib/util/color.d.ts +48 -0
- package/lib/util/color.js +215 -0
- package/lib/util/createObject.d.ts +10 -0
- package/lib/util/createObject.js +54 -0
- package/lib/util/dom.d.ts +8 -4
- package/lib/util/dom.js +24 -5
- package/lib/util/get.d.ts +4 -0
- package/lib/util/get.js +22 -0
- package/lib/util/mergeRun.js +5 -5
- package/lib/util/parseSides.d.ts +11 -0
- package/lib/util/print.d.ts +5 -0
- package/lib/util/print.js +58 -0
- package/lib/util/replaceVar.d.ts +10 -0
- package/lib/util/replaceVar.js +220 -0
- package/lib/util/xml.js +4 -0
- package/package.json +17 -7
- package/esm/node_modules/tslib/tslib.es6.js +0 -120
- package/esm/openxml/Types.js +0 -1003
- package/esm/openxml/word/CustomXml.d.ts +0 -8
- package/esm/openxml/word/SmartTag.d.ts +0 -8
- package/esm/openxml/word/SmartTag.js +0 -18
- package/esm/openxml/word/drawing/Blip.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.js +0 -15
- package/esm/openxml/word/drawing/Pic.d.ts +0 -8
- package/esm/openxml/word/drawing/Pic.js +0 -16
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
- package/esm/openxml/word/drawing/Transform.js +0 -30
- package/lib/node_modules/tslib/tslib.es6.js +0 -129
- package/lib/openxml/Types.js +0 -1005
- package/lib/openxml/word/CustomXml.d.ts +0 -8
- package/lib/openxml/word/SmartTag.d.ts +0 -8
- package/lib/openxml/word/SmartTag.js +0 -22
- package/lib/openxml/word/drawing/Blip.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.js +0 -19
- package/lib/openxml/word/drawing/Pic.d.ts +0 -8
- package/lib/openxml/word/drawing/Pic.js +0 -20
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
- package/lib/openxml/word/drawing/Transform.js +0 -34
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var parseCellMargin = require('./parseCellMargin.js');
|
|
7
|
+
var parseColor = require('./parseColor.js');
|
|
8
|
+
var OpenXML = require('../OpenXML.js');
|
|
9
|
+
var parseBorder = require('./parseBorder.js');
|
|
10
|
+
var parseTextDirection = require('./parseTextDirection.js');
|
|
11
|
+
var parseTblWidth = require('./parseTblWidth.js');
|
|
12
|
+
var parseInsideBorders = require('./parseInsideBorders.js');
|
|
13
|
+
|
|
14
|
+
function parseVAlign(element, style) {
|
|
15
|
+
var vAlign = OpenXML.getVal(element);
|
|
16
|
+
switch (vAlign) {
|
|
17
|
+
case 'bottom':
|
|
18
|
+
style['vertical-align'] = 'bottom';
|
|
19
|
+
break;
|
|
20
|
+
case 'center':
|
|
21
|
+
style['vertical-align'] = 'middle';
|
|
22
|
+
break;
|
|
23
|
+
case 'top':
|
|
24
|
+
style['vertical-align'] = 'top';
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function parseTblCellSpacing(element, style) {
|
|
29
|
+
var width = parseTblWidth.parseTblWidth(element);
|
|
30
|
+
if (width) {
|
|
31
|
+
style['cell-spacing'] = width;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function parseTcW(element, style) {
|
|
35
|
+
var width = parseTblWidth.parseTblWidth(element);
|
|
36
|
+
if (width) {
|
|
37
|
+
style.width = width;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function parseTcPr(word, element) {
|
|
41
|
+
var e_1, _a;
|
|
42
|
+
var properties = {};
|
|
43
|
+
var style = {};
|
|
44
|
+
properties.cssStyle = style;
|
|
45
|
+
try {
|
|
46
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
47
|
+
var child = _c.value;
|
|
48
|
+
var tagName = child.tagName;
|
|
49
|
+
switch (tagName) {
|
|
50
|
+
case 'w:tcMar':
|
|
51
|
+
parseCellMargin.parseCellMargin(child, style);
|
|
52
|
+
break;
|
|
53
|
+
case 'w:shd':
|
|
54
|
+
style['background-color'] = parseColor.parseShdColor(word, child);
|
|
55
|
+
break;
|
|
56
|
+
case 'w:tcW':
|
|
57
|
+
parseTcW(child, style);
|
|
58
|
+
break;
|
|
59
|
+
case 'w:noWrap':
|
|
60
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/noWrap.html
|
|
61
|
+
var noWrap = OpenXML.getValBoolean(child);
|
|
62
|
+
if (noWrap) {
|
|
63
|
+
style['white-space'] = 'nowrap';
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'w:vAlign':
|
|
67
|
+
parseVAlign(child, style);
|
|
68
|
+
break;
|
|
69
|
+
case 'w:tcBorders':
|
|
70
|
+
parseBorder.parseBorders(word, child, style);
|
|
71
|
+
properties.insideBorder = parseInsideBorders.parseInsideBorders(word, child);
|
|
72
|
+
break;
|
|
73
|
+
case 'w:gridSpan':
|
|
74
|
+
properties.gridSpan = OpenXML.getValNumber(child);
|
|
75
|
+
break;
|
|
76
|
+
case 'w:vMerge':
|
|
77
|
+
properties.vMerge = OpenXML.getVal(child) || 'continue';
|
|
78
|
+
break;
|
|
79
|
+
case 'w:textDirection':
|
|
80
|
+
parseTextDirection.parseTextDirection(child, style);
|
|
81
|
+
break;
|
|
82
|
+
case 'w:cnfStyle':
|
|
83
|
+
// 目前是自动计算的,所以不需要这个了
|
|
84
|
+
break;
|
|
85
|
+
case 'w:hideMark':
|
|
86
|
+
properties.hideMark = OpenXML.getValBoolean(child, true);
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
console.warn('parseTcPr: ignore', tagName, child);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
94
|
+
finally {
|
|
95
|
+
try {
|
|
96
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
97
|
+
}
|
|
98
|
+
finally { if (e_1) throw e_1.error; }
|
|
99
|
+
}
|
|
100
|
+
return properties;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
exports.parseTblCellSpacing = parseTblCellSpacing;
|
|
104
|
+
exports.parseTcPr = parseTcPr;
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Types = require('../openxml/Types.js');
|
|
6
|
-
|
|
7
5
|
function parseTextDirection(element, style) {
|
|
8
6
|
var val = element.getAttribute('w:val');
|
|
9
7
|
// 目前值支持 ltr 或 rtl
|
|
10
8
|
// 奇怪这里的类型定义不完整,可能是脚本的问题
|
|
11
9
|
switch (val) {
|
|
12
|
-
case
|
|
13
|
-
case
|
|
10
|
+
case 'lr':
|
|
11
|
+
case 'lrV':
|
|
14
12
|
case 'btLr':
|
|
15
13
|
case 'lrTb':
|
|
16
14
|
case 'lrTbV':
|
|
17
15
|
case 'tbLrV':
|
|
18
16
|
style['direction'] = 'ltr';
|
|
19
17
|
break;
|
|
20
|
-
case
|
|
21
|
-
case
|
|
18
|
+
case 'rl':
|
|
19
|
+
case 'rlV':
|
|
22
20
|
case 'tbRl':
|
|
23
21
|
case 'tbRlV':
|
|
24
22
|
style['direction'] = 'rtl';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Tr = require('../openxml/word/table/Tr.js');
|
|
7
|
+
var parseTc = require('./parseTc.js');
|
|
8
|
+
var parseTablePr = require('./parseTablePr.js');
|
|
9
|
+
var parseTrPr = require('./parseTrPr.js');
|
|
10
|
+
var mergeSdt = require('./mergeSdt.js');
|
|
11
|
+
|
|
12
|
+
function parseTr(word, element, rowSpanMap) {
|
|
13
|
+
var e_1, _a;
|
|
14
|
+
var tr = new Tr.Tr();
|
|
15
|
+
// 做成对象是为了传递引用来修改
|
|
16
|
+
var currentCol = {
|
|
17
|
+
index: 0
|
|
18
|
+
};
|
|
19
|
+
try {
|
|
20
|
+
for (var _b = tslib.__values(mergeSdt.mergeSdt(element)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
|
+
var child = _c.value;
|
|
22
|
+
var tagName = child.tagName;
|
|
23
|
+
switch (tagName) {
|
|
24
|
+
case 'w:tc':
|
|
25
|
+
var tc = parseTc.parseTc(word, child, currentCol, rowSpanMap);
|
|
26
|
+
if (tc) {
|
|
27
|
+
tr.tcs.push(tc);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
case 'w:trPr':
|
|
31
|
+
tr.properties = parseTrPr.parseTrPr(word, child);
|
|
32
|
+
break;
|
|
33
|
+
case 'w:tblPrEx':
|
|
34
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
35
|
+
var tablePr = parseTablePr.parseTablePr(word, child);
|
|
36
|
+
Object.assign(tr.properties.cssStyle || {}, tablePr.cssStyle);
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
console.warn("Tr: Unknown tag ", tagName, child);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
44
|
+
finally {
|
|
45
|
+
try {
|
|
46
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
47
|
+
}
|
|
48
|
+
finally { if (e_1) throw e_1.error; }
|
|
49
|
+
}
|
|
50
|
+
return tr;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
exports.parseTr = parseTr;
|
|
@@ -0,0 +1,63 @@
|
|
|
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 jcToTextAlign = require('./jcToTextAlign.js');
|
|
8
|
+
var parseTablePr = require('./parseTablePr.js');
|
|
9
|
+
var parseTcPr = require('./parseTcPr.js');
|
|
10
|
+
var parseTrHeight = require('./parseTrHeight.js');
|
|
11
|
+
|
|
12
|
+
function parseTrPr(word, element) {
|
|
13
|
+
var e_1, _a;
|
|
14
|
+
var cssStyle = {};
|
|
15
|
+
var tcStyle = {};
|
|
16
|
+
try {
|
|
17
|
+
for (var _b = tslib.__values(element.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
18
|
+
var child = _c.value;
|
|
19
|
+
var tagName = child.tagName;
|
|
20
|
+
switch (tagName) {
|
|
21
|
+
case 'w:hidden':
|
|
22
|
+
if (OpenXML.getValBoolean(child)) {
|
|
23
|
+
cssStyle.display = 'none';
|
|
24
|
+
}
|
|
25
|
+
break;
|
|
26
|
+
case 'w:trHeight':
|
|
27
|
+
parseTrHeight.parseTrHeight(child, cssStyle);
|
|
28
|
+
break;
|
|
29
|
+
case 'w:jc':
|
|
30
|
+
cssStyle['text-align'] = jcToTextAlign.jcToTextAlign(OpenXML.getVal(child));
|
|
31
|
+
break;
|
|
32
|
+
case 'w:cantSplit':
|
|
33
|
+
// 目前也不支持分页
|
|
34
|
+
break;
|
|
35
|
+
case 'w:tblPrEx':
|
|
36
|
+
// http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/tblPrEx_1.html
|
|
37
|
+
var tablePr = parseTablePr.parseTablePr(word, child);
|
|
38
|
+
Object.assign(cssStyle, tablePr.cssStyle);
|
|
39
|
+
break;
|
|
40
|
+
case 'w:tblCellSpacing':
|
|
41
|
+
parseTcPr.parseTblCellSpacing(child, tcStyle);
|
|
42
|
+
break;
|
|
43
|
+
case 'w:cnfStyle':
|
|
44
|
+
// 目前是自动计算的,所以不需要这个了
|
|
45
|
+
break;
|
|
46
|
+
default:
|
|
47
|
+
console.warn("Tr: Unknown tag ", tagName, child);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
52
|
+
finally {
|
|
53
|
+
try {
|
|
54
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
55
|
+
}
|
|
56
|
+
finally { if (e_1) throw e_1.error; }
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
cssStyle: cssStyle
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.parseTrPr = parseTrPr;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CSSStyle } from '../openxml/Style';
|
|
2
|
+
import Word from '../Word';
|
|
3
|
+
/**
|
|
4
|
+
* 修复绝对定位的位置,主要是加上 padding,因为 html 中的定位是不考虑 padding 的
|
|
5
|
+
* @param word
|
|
6
|
+
* @param style
|
|
7
|
+
*/
|
|
8
|
+
export declare function fixAbsolutePosition(word: Word, style: CSSStyle, inHeader?: boolean): void;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 渲染 body 节点
|
|
3
3
|
*/
|
|
4
|
-
import Word from '../Word';
|
|
4
|
+
import Word, { WordRenderOptions } from '../Word';
|
|
5
5
|
import { Body } from '../openxml/word/Body';
|
|
6
|
-
|
|
6
|
+
import { WDocument } from '../openxml/word/WDocument';
|
|
7
|
+
/**
|
|
8
|
+
* 渲染文档主体
|
|
9
|
+
*/
|
|
10
|
+
export default function renderBody(root: HTMLElement, word: Word, bodyEl: HTMLElement, wDocument: WDocument, body: Body, renderOptions: WordRenderOptions): void;
|
package/lib/render/renderBody.js
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
7
|
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
8
8
|
var Table = require('../openxml/word/Table.js');
|
|
9
|
-
var Hyperlink = require('../openxml/word/Hyperlink.js');
|
|
10
9
|
var renderParagraph = require('./renderParagraph.js');
|
|
11
10
|
var renderSection = require('./renderSection.js');
|
|
12
11
|
var renderTable = require('./renderTable.js');
|
|
@@ -14,44 +13,199 @@ var renderTable = require('./renderTable.js');
|
|
|
14
13
|
/**
|
|
15
14
|
* 渲染 body 节点
|
|
16
15
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
/**
|
|
17
|
+
* 判断是否需要创建一个新 section,包括强制分页和超出了 section 的高宽或宽度
|
|
18
|
+
*/
|
|
19
|
+
function createNewSection(word, sectionEnd, child) {
|
|
20
|
+
// 支持插入分页符
|
|
21
|
+
if (word.breakPage) {
|
|
22
|
+
word.breakPage = false;
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
var childBound = child.getBoundingClientRect();
|
|
26
|
+
return (childBound.top + childBound.height > sectionEnd.bottom ||
|
|
27
|
+
// 注意这里没有 + childBound.width,因为 width 一般都是 100% 导致容易超出
|
|
28
|
+
childBound.left > sectionEnd.right);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 添加到 section 里,如果超出了就创建一个新的 section
|
|
32
|
+
*/
|
|
33
|
+
function appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, child) {
|
|
34
|
+
// 如果是第一个节点,即便超长也得写入,不然就会出现一个空 section
|
|
35
|
+
var isFirst = sectionEl.children.length === 0;
|
|
36
|
+
// 首先尝试写入
|
|
37
|
+
dom.appendChild(sectionEl, child);
|
|
38
|
+
// 如果超出了就新建一个 section
|
|
39
|
+
if (!isFirst && createNewSection(word, sectionEnd, child)) {
|
|
40
|
+
var newChild = child.cloneNode(true);
|
|
41
|
+
dom.removeChild(sectionEl, child);
|
|
42
|
+
var newSectionEl = renderSection.renderSection(word, wDocument, section, renderOptions);
|
|
43
|
+
dom.appendChild(bodyEl, newSectionEl);
|
|
44
|
+
dom.appendChild(newSectionEl, newChild);
|
|
45
|
+
sectionEnd = getSectionEnd(section, newSectionEl);
|
|
46
|
+
return { sectionEl: newSectionEl, sectionEnd: sectionEnd };
|
|
47
|
+
}
|
|
48
|
+
return { sectionEl: sectionEl, sectionEnd: sectionEnd };
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 获取 section 结束的位置,也就是最后能放下子元素的位置
|
|
52
|
+
*/
|
|
53
|
+
function getSectionEnd(section, sectionEl) {
|
|
54
|
+
var sectionBound = sectionEl.getBoundingClientRect();
|
|
55
|
+
var pageMargin = section.properties.pageMargin;
|
|
56
|
+
var bottom = sectionBound.top + sectionBound.height;
|
|
57
|
+
if (pageMargin === null || pageMargin === void 0 ? void 0 : pageMargin.bottom) {
|
|
58
|
+
bottom = bottom - parseInt(pageMargin.bottom.replace('px', ''), 10);
|
|
59
|
+
}
|
|
60
|
+
var right = sectionBound.left + sectionBound.width;
|
|
61
|
+
if (pageMargin === null || pageMargin === void 0 ? void 0 : pageMargin.right) {
|
|
62
|
+
right = right - parseInt(pageMargin.right.replace('px', ''), 10);
|
|
63
|
+
}
|
|
64
|
+
return { bottom: bottom, right: right };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* 获取缩放比例
|
|
68
|
+
*/
|
|
69
|
+
function getTransform(rootWidth, section, renderOptions) {
|
|
70
|
+
var props = section.properties;
|
|
71
|
+
var pageSize = props.pageSize;
|
|
72
|
+
if (renderOptions.zoomFitWidth && !renderOptions.ignoreWidth) {
|
|
73
|
+
var pageWidth = pageSize === null || pageSize === void 0 ? void 0 : pageSize.width;
|
|
74
|
+
if (rootWidth && pageWidth) {
|
|
75
|
+
var pageWidthNum = parseInt(pageWidth.replace('px', ''), 10);
|
|
76
|
+
if (props.pageMargin) {
|
|
77
|
+
var pageMargin = props.pageMargin;
|
|
78
|
+
pageWidthNum += pageMargin.left
|
|
79
|
+
? parseInt(pageMargin.left.replace('px', ''), 10)
|
|
80
|
+
: 0;
|
|
81
|
+
pageWidthNum += pageMargin.right
|
|
82
|
+
? parseInt(pageMargin.right.replace('px', ''), 10)
|
|
83
|
+
: 0;
|
|
84
|
+
}
|
|
85
|
+
var zoomWidth = rootWidth / pageWidthNum;
|
|
86
|
+
return zoomWidth;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 分页渲染
|
|
93
|
+
* @param isLastSection 是否是最后一节
|
|
94
|
+
*/
|
|
95
|
+
function renderSectionInPage(word, wDocument, bodyEl, renderOptions, sectionEl, section, isLastSection) {
|
|
96
|
+
// 如果不 setTimeout 取到的位置信息不对
|
|
97
|
+
setTimeout(function () {
|
|
98
|
+
var e_1, _a;
|
|
99
|
+
var sectionEnd = getSectionEnd(section, sectionEl);
|
|
100
|
+
try {
|
|
101
|
+
for (var _b = tslib.__values(section.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
102
|
+
var child = _c.value;
|
|
103
|
+
if (child instanceof Paragraph.Paragraph) {
|
|
104
|
+
var p = renderParagraph["default"](word, child);
|
|
105
|
+
var appendResult = appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, p);
|
|
106
|
+
sectionEl = appendResult.sectionEl;
|
|
107
|
+
sectionEnd = appendResult.sectionEnd;
|
|
108
|
+
}
|
|
109
|
+
else if (child instanceof Table.Table) {
|
|
110
|
+
var table = renderTable["default"](word, child);
|
|
111
|
+
var appendResult = appendToSection(word, wDocument, renderOptions, bodyEl, sectionEl, sectionEnd, section, table);
|
|
112
|
+
sectionEl = appendResult.sectionEl;
|
|
113
|
+
sectionEnd = appendResult.sectionEnd;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
console.warn('unknown child', child);
|
|
36
117
|
}
|
|
37
118
|
}
|
|
38
|
-
|
|
39
|
-
|
|
119
|
+
}
|
|
120
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
121
|
+
finally {
|
|
122
|
+
try {
|
|
123
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
124
|
+
}
|
|
125
|
+
finally { if (e_1) throw e_1.error; }
|
|
126
|
+
}
|
|
127
|
+
if (isLastSection) {
|
|
128
|
+
sectionEl.style.marginBottom = '0';
|
|
129
|
+
}
|
|
130
|
+
}, 0);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* 渲染文档主体
|
|
134
|
+
*/
|
|
135
|
+
function renderBody(root, word, bodyEl, wDocument, body, renderOptions) {
|
|
136
|
+
var e_2, _a, e_3, _b;
|
|
137
|
+
var page = renderOptions.page || false;
|
|
138
|
+
var rootWidth = root.getBoundingClientRect().width -
|
|
139
|
+
(renderOptions.pageWrapPadding || 0) * 2;
|
|
140
|
+
var zooms = [];
|
|
141
|
+
var index = 0;
|
|
142
|
+
var sections = body.sections;
|
|
143
|
+
var sectionLength = sections.length;
|
|
144
|
+
// 用于最后一个 section 不加 margin-bottom
|
|
145
|
+
var isLastSection = false;
|
|
146
|
+
try {
|
|
147
|
+
for (var sections_1 = tslib.__values(sections), sections_1_1 = sections_1.next(); !sections_1_1.done; sections_1_1 = sections_1.next()) {
|
|
148
|
+
var section = sections_1_1.value;
|
|
149
|
+
zooms.push(getTransform(rootWidth, section, renderOptions));
|
|
150
|
+
word.currentSection = section;
|
|
151
|
+
var sectionEl = renderSection.renderSection(word, wDocument, section, renderOptions);
|
|
152
|
+
dom.appendChild(bodyEl, sectionEl);
|
|
153
|
+
index = index + 1;
|
|
154
|
+
if (index === sectionLength) {
|
|
155
|
+
isLastSection = true;
|
|
156
|
+
}
|
|
157
|
+
if (page) {
|
|
158
|
+
renderSectionInPage(word, wDocument, bodyEl, renderOptions, sectionEl, section, isLastSection);
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
40
161
|
try {
|
|
41
|
-
|
|
162
|
+
for (var _c = (e_3 = void 0, tslib.__values(section.children)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
163
|
+
var child = _d.value;
|
|
164
|
+
if (child instanceof Paragraph.Paragraph) {
|
|
165
|
+
var p = renderParagraph["default"](word, child);
|
|
166
|
+
dom.appendChild(sectionEl, p);
|
|
167
|
+
}
|
|
168
|
+
else if (child instanceof Table.Table) {
|
|
169
|
+
var table = renderTable["default"](word, child);
|
|
170
|
+
dom.appendChild(sectionEl, table);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
console.warn('unknown child', child);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
178
|
+
finally {
|
|
179
|
+
try {
|
|
180
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
181
|
+
}
|
|
182
|
+
finally { if (e_3) throw e_3.error; }
|
|
42
183
|
}
|
|
43
|
-
finally { if (e_2) throw e_2.error; }
|
|
44
184
|
}
|
|
45
|
-
dom.appendChild(parent, sectionEl);
|
|
46
185
|
}
|
|
47
186
|
}
|
|
48
|
-
catch (
|
|
187
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
49
188
|
finally {
|
|
50
189
|
try {
|
|
51
|
-
if (
|
|
190
|
+
if (sections_1_1 && !sections_1_1.done && (_a = sections_1.return)) _a.call(sections_1);
|
|
52
191
|
}
|
|
53
|
-
finally { if (
|
|
192
|
+
finally { if (e_2) throw e_2.error; }
|
|
54
193
|
}
|
|
194
|
+
setTimeout(function () {
|
|
195
|
+
if (renderOptions.zoom) {
|
|
196
|
+
// 固定缩放
|
|
197
|
+
bodyEl.style.transformOrigin = '0 0';
|
|
198
|
+
bodyEl.style.transform = "scale(".concat(renderOptions.zoom, ")");
|
|
199
|
+
}
|
|
200
|
+
else if (renderOptions.page &&
|
|
201
|
+
renderOptions.zoomFitWidth &&
|
|
202
|
+
!renderOptions.ignoreWidth) {
|
|
203
|
+
// 自适应宽度的缩放
|
|
204
|
+
var minZoom = Math.min.apply(Math, tslib.__spreadArray([], tslib.__read(zooms), false));
|
|
205
|
+
bodyEl.style.transformOrigin = '0 0';
|
|
206
|
+
bodyEl.style.transform = "scale(".concat(minZoom, ")");
|
|
207
|
+
}
|
|
208
|
+
}, 0);
|
|
55
209
|
}
|
|
56
210
|
|
|
57
211
|
exports["default"] = renderBody;
|
package/lib/render/renderBr.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import Word from '../Word';
|
|
1
2
|
import { Break } from '../openxml/word/Break';
|
|
2
3
|
/**
|
|
3
4
|
* 解析 br http://officeopenxml.com/WPtextSpecialContent-break.php
|
|
4
5
|
* 其实还有 column 和 page,但目前还没实现分页渲染,所以目前先简单处理,后续再看看如何处理
|
|
5
6
|
* @returns 生成的 dom 结构
|
|
6
7
|
*/
|
|
7
|
-
export declare function renderBr(brak: Break): HTMLElement;
|
|
8
|
+
export declare function renderBr(word: Word, brak: Break): HTMLElement;
|
package/lib/render/renderBr.js
CHANGED
|
@@ -9,7 +9,10 @@ var dom = require('../util/dom.js');
|
|
|
9
9
|
* 其实还有 column 和 page,但目前还没实现分页渲染,所以目前先简单处理,后续再看看如何处理
|
|
10
10
|
* @returns 生成的 dom 结构
|
|
11
11
|
*/
|
|
12
|
-
function renderBr(brak) {
|
|
12
|
+
function renderBr(word, brak) {
|
|
13
|
+
if (brak.type === 'page') {
|
|
14
|
+
word.breakPage = true;
|
|
15
|
+
}
|
|
13
16
|
var br = dom.createElement('br');
|
|
14
17
|
return br;
|
|
15
18
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ShapePr } from '../openxml/drawing/ShapeProperties';
|
|
2
|
+
import { WPSStyle } from '../openxml/word/wps/WPSStyle';
|
|
3
|
+
import { CustomGeom } from '../openxml/drawing/CustomGeom';
|
|
4
|
+
export declare function renderCustGeom(geom: CustomGeom, shapePr: ShapePr, width: number, height: number, wpsStyle?: WPSStyle): SVGElement | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var shapeToSVG = require('../openxml/drawing/svg/shapeToSVG.js');
|
|
6
|
+
|
|
7
|
+
function renderCustGeom(geom, shapePr, width, height, wpsStyle) {
|
|
8
|
+
if (geom.shape) {
|
|
9
|
+
return shapeToSVG.shapeToSVG(geom.shape, [], shapePr, width, height, wpsStyle);
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
exports.renderCustGeom = renderCustGeom;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import Word from '../Word';
|
|
1
|
+
import Word, { WordRenderOptions } from '../Word';
|
|
2
2
|
import { WDocument } from '../openxml/word/WDocument';
|
|
3
3
|
/**
|
|
4
4
|
* 渲染 document 主要入口
|
|
5
5
|
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
|
|
6
6
|
*/
|
|
7
|
-
export default function renderDocument(word: Word,
|
|
7
|
+
export default function renderDocument(root: HTMLElement, word: Word, wDocument: WDocument, renderOptions: WordRenderOptions): HTMLElement;
|
|
@@ -9,9 +9,9 @@ var renderBody = require('./renderBody.js');
|
|
|
9
9
|
* 渲染 document 主要入口
|
|
10
10
|
* http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/document.html
|
|
11
11
|
*/
|
|
12
|
-
function renderDocument(word,
|
|
12
|
+
function renderDocument(root, word, wDocument, renderOptions) {
|
|
13
13
|
var doc = dom.createElement('article');
|
|
14
|
-
renderBody["default"](word, doc,
|
|
14
|
+
renderBody["default"](root, word, doc, wDocument, wDocument.body, renderOptions);
|
|
15
15
|
return doc;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Word from '../Word';
|
|
2
|
-
import { Drawing } from '../openxml/
|
|
2
|
+
import { Drawing } from '../openxml/drawing/Drawing';
|
|
3
3
|
/**
|
|
4
4
|
* 渲染图片,目前只支持 picture
|
|
5
5
|
* http://officeopenxml.com/drwOverview.php
|
|
6
|
+
* @param inHeader,如果在 header 中,位置计算要特殊处理
|
|
6
7
|
*
|
|
7
8
|
*/
|
|
8
|
-
export declare function renderDrawing(word: Word, drawing: Drawing): HTMLElement | null;
|
|
9
|
+
export declare function renderDrawing(word: Word, drawing: Drawing, inHeader?: boolean): HTMLElement | null;
|