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,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 拷贝自 amis 里的方法,避免依赖
|
|
9
|
+
*/
|
|
10
|
+
function createObject(superProps, props, properties) {
|
|
11
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
12
|
+
superProps = cloneObject(superProps);
|
|
13
|
+
}
|
|
14
|
+
var obj = superProps
|
|
15
|
+
? Object.create(superProps, tslib.__assign(tslib.__assign({}, properties), { __super: {
|
|
16
|
+
value: superProps,
|
|
17
|
+
writable: false,
|
|
18
|
+
enumerable: false
|
|
19
|
+
} }))
|
|
20
|
+
: Object.create(Object.prototype, properties);
|
|
21
|
+
props &&
|
|
22
|
+
isObject(props) &&
|
|
23
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
24
|
+
return obj;
|
|
25
|
+
}
|
|
26
|
+
function cloneObject(target, persistOwnProps) {
|
|
27
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
28
|
+
var obj = target && target.__super
|
|
29
|
+
? Object.create(target.__super, {
|
|
30
|
+
__super: {
|
|
31
|
+
value: target.__super,
|
|
32
|
+
writable: false,
|
|
33
|
+
enumerable: false
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
: Object.create(Object.prototype);
|
|
37
|
+
persistOwnProps &&
|
|
38
|
+
target &&
|
|
39
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
40
|
+
return obj;
|
|
41
|
+
}
|
|
42
|
+
function isObject(obj) {
|
|
43
|
+
var typename = typeof obj;
|
|
44
|
+
return (obj &&
|
|
45
|
+
typename !== 'string' &&
|
|
46
|
+
typename !== 'number' &&
|
|
47
|
+
typename !== 'boolean' &&
|
|
48
|
+
typename !== 'function' &&
|
|
49
|
+
!Array.isArray(obj));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.cloneObject = cloneObject;
|
|
53
|
+
exports.createObject = createObject;
|
|
54
|
+
exports.isObject = isObject;
|
package/lib/util/dom.d.ts
CHANGED
|
@@ -9,19 +9,23 @@ export declare function styleToText(style?: CSSStyle): string;
|
|
|
9
9
|
/**
|
|
10
10
|
* 设置元素样式
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function applyStyle(el: HTMLElement, style?: CSSStyle): void;
|
|
13
13
|
/**
|
|
14
14
|
* 创建元素
|
|
15
15
|
*/
|
|
16
16
|
export declare function createElement(tagName: string): HTMLElement;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* 创建 SVG 元素
|
|
19
19
|
*/
|
|
20
|
-
export declare function
|
|
20
|
+
export declare function createSVGElement(tagName: string): SVGElement;
|
|
21
21
|
/**
|
|
22
22
|
* 添加子节点,会做一些判断避免报错
|
|
23
23
|
*/
|
|
24
|
-
export declare function appendChild(parent: HTMLElement, child
|
|
24
|
+
export declare function appendChild(parent: HTMLElement, child?: Node | null): void;
|
|
25
|
+
/**
|
|
26
|
+
* 删除子节点,会做一些判断避免报错
|
|
27
|
+
*/
|
|
28
|
+
export declare function removeChild(parent: HTMLElement, child?: Node | null): void;
|
|
25
29
|
/**
|
|
26
30
|
* 添加注释节点
|
|
27
31
|
*/
|
package/lib/util/dom.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* dom 相关的操作
|
|
@@ -24,11 +24,14 @@ function styleToText(style) {
|
|
|
24
24
|
/**
|
|
25
25
|
* 设置元素样式
|
|
26
26
|
*/
|
|
27
|
-
function
|
|
27
|
+
function applyStyle(el, style) {
|
|
28
|
+
if (!style) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
28
31
|
for (var key in style) {
|
|
29
32
|
var value = style[key];
|
|
30
33
|
if (value != null && value !== '') {
|
|
31
|
-
el.style.setProperty(key,
|
|
34
|
+
el.style.setProperty(key, String(value));
|
|
32
35
|
}
|
|
33
36
|
}
|
|
34
37
|
}
|
|
@@ -38,6 +41,12 @@ function setStyle(el, style) {
|
|
|
38
41
|
function createElement(tagName) {
|
|
39
42
|
return document.createElement(tagName);
|
|
40
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* 创建 SVG 元素
|
|
46
|
+
*/
|
|
47
|
+
function createSVGElement(tagName) {
|
|
48
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
49
|
+
}
|
|
41
50
|
/**
|
|
42
51
|
* 添加子节点,会做一些判断避免报错
|
|
43
52
|
*/
|
|
@@ -46,6 +55,14 @@ function appendChild(parent, child) {
|
|
|
46
55
|
parent.appendChild(child);
|
|
47
56
|
}
|
|
48
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* 删除子节点,会做一些判断避免报错
|
|
60
|
+
*/
|
|
61
|
+
function removeChild(parent, child) {
|
|
62
|
+
if (parent && child) {
|
|
63
|
+
parent.removeChild(child);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
49
66
|
/**
|
|
50
67
|
* 添加 css 类
|
|
51
68
|
*/
|
|
@@ -60,13 +77,15 @@ function addClassName(el, className) {
|
|
|
60
77
|
function addClassNames(el, classNames) {
|
|
61
78
|
var _a;
|
|
62
79
|
if (el && classNames) {
|
|
63
|
-
(_a = el.classList).add.apply(_a,
|
|
80
|
+
(_a = el.classList).add.apply(_a, tslib.__spreadArray([], tslib.__read(classNames), false));
|
|
64
81
|
}
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
exports.addClassName = addClassName;
|
|
68
85
|
exports.addClassNames = addClassNames;
|
|
69
86
|
exports.appendChild = appendChild;
|
|
87
|
+
exports.applyStyle = applyStyle;
|
|
70
88
|
exports.createElement = createElement;
|
|
71
|
-
exports.
|
|
89
|
+
exports.createSVGElement = createSVGElement;
|
|
90
|
+
exports.removeChild = removeChild;
|
|
72
91
|
exports.styleToText = styleToText;
|
package/lib/util/get.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
|
|
7
|
+
*/
|
|
8
|
+
var get = function (obj, path, defaultValue) {
|
|
9
|
+
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
10
|
+
var travel = function (regexp) {
|
|
11
|
+
return String.prototype.split
|
|
12
|
+
.call(path, regexp)
|
|
13
|
+
.filter(Boolean)
|
|
14
|
+
.reduce(function (res, key) {
|
|
15
|
+
return res !== null && res !== undefined ? res[key] : res;
|
|
16
|
+
}, obj);
|
|
17
|
+
};
|
|
18
|
+
var result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
|
|
19
|
+
return result === undefined || result === obj ? defaultValue : result;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.get = get;
|
package/lib/util/mergeRun.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var parsePr = require('../parse/parsePr.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -34,7 +34,7 @@ function canMerge(element) {
|
|
|
34
34
|
var hasText = false;
|
|
35
35
|
var textHasSpace = false;
|
|
36
36
|
try {
|
|
37
|
-
for (var childChildren_1 =
|
|
37
|
+
for (var childChildren_1 = tslib.__values(childChildren), childChildren_1_1 = childChildren_1.next(); !childChildren_1_1.done; childChildren_1_1 = childChildren_1.next()) {
|
|
38
38
|
var childChild = childChildren_1_1.value;
|
|
39
39
|
if (childChild.tagName === 'w:t') {
|
|
40
40
|
hasText = true;
|
|
@@ -60,7 +60,7 @@ function mergeRunInP(word, p) {
|
|
|
60
60
|
var newElements = [];
|
|
61
61
|
var lastRun = null;
|
|
62
62
|
try {
|
|
63
|
-
for (var _c =
|
|
63
|
+
for (var _c = tslib.__values(p.children), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
64
64
|
var child = _d.value;
|
|
65
65
|
var tagName = child.tagName;
|
|
66
66
|
// 避免图片和空格被合并了
|
|
@@ -100,7 +100,7 @@ function mergeRunInP(word, p) {
|
|
|
100
100
|
}
|
|
101
101
|
p.innerHTML = '';
|
|
102
102
|
try {
|
|
103
|
-
for (var newElements_1 =
|
|
103
|
+
for (var newElements_1 = tslib.__values(newElements), newElements_1_1 = newElements_1.next(); !newElements_1_1.done; newElements_1_1 = newElements_1.next()) {
|
|
104
104
|
var newElement = newElements_1_1.value;
|
|
105
105
|
p.appendChild(newElement);
|
|
106
106
|
}
|
|
@@ -121,7 +121,7 @@ function mergeRun(word, doc) {
|
|
|
121
121
|
var e_4, _a;
|
|
122
122
|
var ps = doc.getElementsByTagName('w:p');
|
|
123
123
|
try {
|
|
124
|
-
for (var ps_1 =
|
|
124
|
+
for (var ps_1 = tslib.__values(ps), ps_1_1 = ps_1.next(); !ps_1_1.done; ps_1_1 = ps_1.next()) {
|
|
125
125
|
var p = ps_1_1.value;
|
|
126
126
|
mergeRunInP(word, p);
|
|
127
127
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 来自 https://github.com/jednano/parse-css-sides/blob/master/src/index.ts
|
|
3
|
+
*/
|
|
4
|
+
export interface ISides {
|
|
5
|
+
top: string;
|
|
6
|
+
right: string;
|
|
7
|
+
bottom: string;
|
|
8
|
+
left: string;
|
|
9
|
+
important?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export default function parseSides(value: string): ISides;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
|
|
7
|
+
function loadIframeImages(images) {
|
|
8
|
+
var _this = this;
|
|
9
|
+
var promises = images.map(function (image) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
10
|
+
return tslib.__generator(this, function (_a) {
|
|
11
|
+
switch (_a.label) {
|
|
12
|
+
case 0:
|
|
13
|
+
if (!(image.src && image.src !== window.location.href)) return [3 /*break*/, 2];
|
|
14
|
+
return [4 /*yield*/, loadIframeImage(image)];
|
|
15
|
+
case 1:
|
|
16
|
+
_a.sent();
|
|
17
|
+
_a.label = 2;
|
|
18
|
+
case 2: return [2 /*return*/];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}); });
|
|
22
|
+
return Promise.all(promises);
|
|
23
|
+
}
|
|
24
|
+
function loadIframeImage(image) {
|
|
25
|
+
return new Promise(function (resolve) {
|
|
26
|
+
var pollImage = function () {
|
|
27
|
+
!image ||
|
|
28
|
+
typeof image.naturalWidth === 'undefined' ||
|
|
29
|
+
image.naturalWidth === 0 ||
|
|
30
|
+
!image.complete
|
|
31
|
+
? setTimeout(pollImage, 500)
|
|
32
|
+
: resolve();
|
|
33
|
+
};
|
|
34
|
+
pollImage();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function performPrint(iframe) {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.print();
|
|
40
|
+
(_b = iframe.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(iframe);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* 打印 iframe,参考了 print.js 里的部分实现
|
|
44
|
+
* @param iframe
|
|
45
|
+
*/
|
|
46
|
+
function printIframe(iframe) {
|
|
47
|
+
var printDocument = iframe.contentDocument;
|
|
48
|
+
// If printing images, wait for them to load inside the iframe
|
|
49
|
+
var images = printDocument.getElementsByTagName('img');
|
|
50
|
+
if (images.length > 0) {
|
|
51
|
+
loadIframeImages(Array.from(images)).then(function () { return performPrint(iframe); });
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
performPrint(iframe);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.printIframe = printIframe;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 执行变量替换,和普通变量不同,这个支持数组,但因为是提前执行好的,没法再动态生效了
|
|
3
|
+
* 为了避免 word 里不必要的标签要先执行 mergeRun
|
|
4
|
+
*/
|
|
5
|
+
import Word from '../Word';
|
|
6
|
+
/**
|
|
7
|
+
* 替换单个文本变量
|
|
8
|
+
*/
|
|
9
|
+
export declare function replaceT(word: Word, t: Element, data: any): void;
|
|
10
|
+
export declare function replaceVar(word: Word, documentData: Document): void;
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var createObject = require('./createObject.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 执行变量替换,和普通变量不同,这个支持数组,但因为是提前执行好的,没法再动态生效了
|
|
10
|
+
* 为了避免 word 里不必要的标签要先执行 mergeRun
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* 替换单个文本变量
|
|
14
|
+
*/
|
|
15
|
+
function replaceT(word, t, data) {
|
|
16
|
+
var text = t.textContent || '';
|
|
17
|
+
t.textContent = replaceText(word, text, data);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 替换变量文本
|
|
21
|
+
*/
|
|
22
|
+
function replaceText(word, text, data) {
|
|
23
|
+
var evalVar = word.renderOptions.evalVar;
|
|
24
|
+
if (text.startsWith('{{')) {
|
|
25
|
+
text = text.replace(/^{{/g, '').replace(/}}$/g, '');
|
|
26
|
+
var result = evalVar(text, data);
|
|
27
|
+
if (result !== undefined && result !== null) {
|
|
28
|
+
return String(result);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
console.warn('var error: [', text, '] not found in data');
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
function replaceAlt(word, cNvPr, data) {
|
|
38
|
+
var alt = cNvPr.getAttribute('descr') || '';
|
|
39
|
+
cNvPr.setAttribute('descrVar', replaceText(word, alt, data));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 替换表格行
|
|
43
|
+
*/
|
|
44
|
+
function replaceTableRow(word, tr) {
|
|
45
|
+
var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e;
|
|
46
|
+
var evalVar = word.renderOptions.evalVar;
|
|
47
|
+
var data = word.renderOptions.data;
|
|
48
|
+
var table = tr.parentNode;
|
|
49
|
+
var tcs = tr.getElementsByTagName('w:tc');
|
|
50
|
+
var hasLoop = false;
|
|
51
|
+
var loopArray = [];
|
|
52
|
+
try {
|
|
53
|
+
// 查找对应的循环
|
|
54
|
+
for (var tcs_1 = tslib.__values(tcs), tcs_1_1 = tcs_1.next(); !tcs_1_1.done; tcs_1_1 = tcs_1.next()) {
|
|
55
|
+
var tc = tcs_1_1.value;
|
|
56
|
+
var ts = tc.getElementsByTagName('w:t');
|
|
57
|
+
try {
|
|
58
|
+
for (var ts_1 = (e_2 = void 0, tslib.__values(ts)), ts_1_1 = ts_1.next(); !ts_1_1.done; ts_1_1 = ts_1.next()) {
|
|
59
|
+
var t = ts_1_1.value;
|
|
60
|
+
var text = t.textContent || '';
|
|
61
|
+
if (text.startsWith('{{#')) {
|
|
62
|
+
var arrayNameMatch = /{{#([^\}]+)}}/;
|
|
63
|
+
var arrayMatchResult = arrayNameMatch.exec(text);
|
|
64
|
+
if (arrayMatchResult && arrayMatchResult.length > 0) {
|
|
65
|
+
hasLoop = true;
|
|
66
|
+
var arrayName = arrayMatchResult[1];
|
|
67
|
+
var array = evalVar(arrayName, data);
|
|
68
|
+
if (Array.isArray(array)) {
|
|
69
|
+
loopArray = array;
|
|
70
|
+
}
|
|
71
|
+
// 去掉这个循环变量
|
|
72
|
+
t.textContent = t.textContent.replace("{{#".concat(arrayName, "}}"), '');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (text.indexOf('{{/}}')) {
|
|
76
|
+
// 去掉结束变量
|
|
77
|
+
t.textContent = t.textContent.replace('{{/}}', '');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
82
|
+
finally {
|
|
83
|
+
try {
|
|
84
|
+
if (ts_1_1 && !ts_1_1.done && (_b = ts_1.return)) _b.call(ts_1);
|
|
85
|
+
}
|
|
86
|
+
finally { if (e_2) throw e_2.error; }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (tcs_1_1 && !tcs_1_1.done && (_a = tcs_1.return)) _a.call(tcs_1);
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
if (hasLoop) {
|
|
98
|
+
try {
|
|
99
|
+
// 有循环,复制多行
|
|
100
|
+
for (var loopArray_1 = tslib.__values(loopArray), loopArray_1_1 = loopArray_1.next(); !loopArray_1_1.done; loopArray_1_1 = loopArray_1.next()) {
|
|
101
|
+
var item = loopArray_1_1.value;
|
|
102
|
+
var newTr = cloneTr(tr);
|
|
103
|
+
var ts = newTr.getElementsByTagName('w:t');
|
|
104
|
+
// 将 item 加入上下文
|
|
105
|
+
var rowData = createObject.createObject(data, item);
|
|
106
|
+
try {
|
|
107
|
+
for (var ts_2 = (e_4 = void 0, tslib.__values(ts)), ts_2_1 = ts_2.next(); !ts_2_1.done; ts_2_1 = ts_2.next()) {
|
|
108
|
+
var t = ts_2_1.value;
|
|
109
|
+
replaceT(word, t, rowData);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
113
|
+
finally {
|
|
114
|
+
try {
|
|
115
|
+
if (ts_2_1 && !ts_2_1.done && (_d = ts_2.return)) _d.call(ts_2);
|
|
116
|
+
}
|
|
117
|
+
finally { if (e_4) throw e_4.error; }
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
// 替换图片里的变量
|
|
121
|
+
for (var _f = (e_5 = void 0, tslib.__values(newTr.getElementsByTagName('pic:cNvPr'))), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
122
|
+
var cNvPr = _g.value;
|
|
123
|
+
replaceAlt(word, cNvPr, rowData);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
127
|
+
finally {
|
|
128
|
+
try {
|
|
129
|
+
if (_g && !_g.done && (_e = _f.return)) _e.call(_f);
|
|
130
|
+
}
|
|
131
|
+
finally { if (e_5) throw e_5.error; }
|
|
132
|
+
}
|
|
133
|
+
table.insertBefore(newTr, tr);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
137
|
+
finally {
|
|
138
|
+
try {
|
|
139
|
+
if (loopArray_1_1 && !loopArray_1_1.done && (_c = loopArray_1.return)) _c.call(loopArray_1);
|
|
140
|
+
}
|
|
141
|
+
finally { if (e_3) throw e_3.error; }
|
|
142
|
+
}
|
|
143
|
+
// 删除原来的行
|
|
144
|
+
table.removeChild(tr);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* 克隆行,并进行一些清理
|
|
149
|
+
*/
|
|
150
|
+
function cloneTr(tr) {
|
|
151
|
+
var e_6, _a, e_7, _b;
|
|
152
|
+
var _c;
|
|
153
|
+
var newTr = tr.cloneNode(true);
|
|
154
|
+
// 去掉 tr 里的属性,感觉可能会有问题
|
|
155
|
+
removeAllAttr(newTr);
|
|
156
|
+
var ps = [].slice.call(newTr.getElementsByTagName('w:p'));
|
|
157
|
+
try {
|
|
158
|
+
for (var ps_1 = tslib.__values(ps), ps_1_1 = ps_1.next(); !ps_1_1.done; ps_1_1 = ps_1.next()) {
|
|
159
|
+
var p = ps_1_1.value;
|
|
160
|
+
removeAllAttr(p);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
164
|
+
finally {
|
|
165
|
+
try {
|
|
166
|
+
if (ps_1_1 && !ps_1_1.done && (_a = ps_1.return)) _a.call(ps_1);
|
|
167
|
+
}
|
|
168
|
+
finally { if (e_6) throw e_6.error; }
|
|
169
|
+
}
|
|
170
|
+
// cnfStyles 基本上都是错的所以删了
|
|
171
|
+
var cnfStyles = [].slice.call(newTr.getElementsByTagName('w:cnfStyle'));
|
|
172
|
+
try {
|
|
173
|
+
for (var cnfStyles_1 = tslib.__values(cnfStyles), cnfStyles_1_1 = cnfStyles_1.next(); !cnfStyles_1_1.done; cnfStyles_1_1 = cnfStyles_1.next()) {
|
|
174
|
+
var cnfStyle = cnfStyles_1_1.value;
|
|
175
|
+
(_c = cnfStyle.parentElement) === null || _c === void 0 ? void 0 : _c.removeChild(cnfStyle);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
179
|
+
finally {
|
|
180
|
+
try {
|
|
181
|
+
if (cnfStyles_1_1 && !cnfStyles_1_1.done && (_b = cnfStyles_1.return)) _b.call(cnfStyles_1);
|
|
182
|
+
}
|
|
183
|
+
finally { if (e_7) throw e_7.error; }
|
|
184
|
+
}
|
|
185
|
+
return newTr;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* 删掉所有属性,虽然不知道为啥有些不生效
|
|
189
|
+
*/
|
|
190
|
+
function removeAllAttr(node) {
|
|
191
|
+
while (node.attributes.length > 0) {
|
|
192
|
+
node.removeAttributeNode(node.attributes[0]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 替换表格,目前只支持行
|
|
197
|
+
*/
|
|
198
|
+
function replaceTable(word, documentData) {
|
|
199
|
+
var e_8, _a;
|
|
200
|
+
var trs = [].slice.call(documentData.getElementsByTagName('w:tr'));
|
|
201
|
+
try {
|
|
202
|
+
for (var trs_1 = tslib.__values(trs), trs_1_1 = trs_1.next(); !trs_1_1.done; trs_1_1 = trs_1.next()) {
|
|
203
|
+
var tr = trs_1_1.value;
|
|
204
|
+
replaceTableRow(word, tr);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
208
|
+
finally {
|
|
209
|
+
try {
|
|
210
|
+
if (trs_1_1 && !trs_1_1.done && (_a = trs_1.return)) _a.call(trs_1);
|
|
211
|
+
}
|
|
212
|
+
finally { if (e_8) throw e_8.error; }
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
function replaceVar(word, documentData) {
|
|
216
|
+
replaceTable(word, documentData);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
exports.replaceT = replaceT;
|
|
220
|
+
exports.replaceVar = replaceVar;
|
package/lib/util/xml.js
CHANGED
|
@@ -5,6 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
/**
|
|
6
6
|
* 解析 xml
|
|
7
7
|
*/
|
|
8
|
+
function parseXML(content) {
|
|
9
|
+
return new DOMParser().parseFromString(content, 'application/xml');
|
|
10
|
+
}
|
|
8
11
|
/**
|
|
9
12
|
* 构建 xml 文本
|
|
10
13
|
*/
|
|
@@ -14,3 +17,4 @@ function buildXML(doc) {
|
|
|
14
17
|
}
|
|
15
18
|
|
|
16
19
|
exports.buildXML = buildXML;
|
|
20
|
+
exports.parseXML = parseXML;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "office-viewer",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "office 文档在线预览",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
"build": "npm run clean-dist && cross-env NODE_ENV=production rollup -c ",
|
|
11
11
|
"test": "jest",
|
|
12
12
|
"lib": "npm run clean-dist && cross-env NODE_ENV=production IS_LIB=1 rollup -c",
|
|
13
|
+
"update-snapshot": "jest --updateSnapshot",
|
|
13
14
|
"coverage": "jest --coverage",
|
|
14
15
|
"declaration": "tsc --project tsconfig-for-declaration.json --allowJs --declaration --emitDeclarationOnly --declarationDir ./lib --rootDir ./src",
|
|
15
16
|
"clean-dist": "rimraf lib/** esm/**",
|
|
16
|
-
"xsd2ts": "cd tools && ts-node --transpileOnly xsd2ts.ts"
|
|
17
|
+
"xsd2ts": "cd tools && ts-node --transpileOnly xsd2ts.ts",
|
|
18
|
+
"conver-preset": "cd tools && ts-node --transpileOnly converDrawingML.ts"
|
|
17
19
|
},
|
|
18
20
|
"exports": {
|
|
19
21
|
".": {
|
|
@@ -39,7 +41,8 @@
|
|
|
39
41
|
},
|
|
40
42
|
"homepage": "https://github.com/baidu/amis#readme",
|
|
41
43
|
"dependencies": {
|
|
42
|
-
"fflate": "^0.7.4"
|
|
44
|
+
"fflate": "^0.7.4",
|
|
45
|
+
"tslib": "^2.3.1"
|
|
43
46
|
},
|
|
44
47
|
"devDependencies": {
|
|
45
48
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
@@ -47,18 +50,25 @@
|
|
|
47
50
|
"@rollup/plugin-node-resolve": "^14.1.0",
|
|
48
51
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
49
52
|
"@types/jest": "^28.1.0",
|
|
53
|
+
"@testing-library/jest-dom": "^5.16.4",
|
|
50
54
|
"amis-formula": "^2.7.2",
|
|
55
|
+
"fast-xml-parser": "4.1.3",
|
|
51
56
|
"jest": "^29.0.3",
|
|
57
|
+
"jest-environment-jsdom": "^29.0.3",
|
|
58
|
+
"rollup": "^2.60.2",
|
|
59
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
52
60
|
"ts-jest": "^29.0.2",
|
|
53
61
|
"ts-loader": "^9.2.3",
|
|
54
62
|
"ts-node": "^10.4.0",
|
|
55
63
|
"typescript": "^4.3.5",
|
|
56
|
-
"
|
|
57
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
58
|
-
"vite": "^3.2.2"
|
|
64
|
+
"xml-formatter": "^3.3.2"
|
|
59
65
|
},
|
|
60
66
|
"jest": {
|
|
61
67
|
"testEnvironment": "jsdom",
|
|
68
|
+
"coverageReporters": [
|
|
69
|
+
"text",
|
|
70
|
+
"cobertura"
|
|
71
|
+
],
|
|
62
72
|
"collectCoverageFrom": [
|
|
63
73
|
"src/**/*"
|
|
64
74
|
],
|
|
@@ -88,4 +98,4 @@
|
|
|
88
98
|
"printBasicPrototype": false
|
|
89
99
|
}
|
|
90
100
|
}
|
|
91
|
-
}
|
|
101
|
+
}
|