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
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { __values } from '
|
|
2
|
-
import { ST_TblStyleOverrideType } from '../openxml/Types.js';
|
|
1
|
+
import { __values } from 'tslib';
|
|
3
2
|
import { Paragraph } from '../openxml/word/Paragraph.js';
|
|
4
3
|
import { Table } from '../openxml/word/Table.js';
|
|
5
|
-
import { addClassName,
|
|
4
|
+
import { addClassName, applyStyle, appendChild } from '../util/dom.js';
|
|
6
5
|
import renderParagraph from './renderParagraph.js';
|
|
7
6
|
import { generateTableStyle } from './renderStyle.js';
|
|
8
7
|
import { setElementStyle } from './setElementStyle.js';
|
|
@@ -14,51 +13,51 @@ import { setElementStyle } from './setElementStyle.js';
|
|
|
14
13
|
function setTdClassName(rowIndex, colIndex, rowLength, colLength, element, rowBandSize, colBandSize) {
|
|
15
14
|
// 左上角
|
|
16
15
|
if (rowIndex === 0 && colIndex === 0) {
|
|
17
|
-
element.classList.add(
|
|
16
|
+
element.classList.add('nwCell');
|
|
18
17
|
}
|
|
19
18
|
// 右上角
|
|
20
19
|
if (rowIndex === 0 && colIndex === colLength - 1) {
|
|
21
|
-
element.classList.add(
|
|
20
|
+
element.classList.add('neCell');
|
|
22
21
|
}
|
|
23
22
|
// 左下角
|
|
24
23
|
if (rowIndex === rowLength - 1 && colIndex === 0) {
|
|
25
|
-
element.classList.add(
|
|
24
|
+
element.classList.add('swCell');
|
|
26
25
|
}
|
|
27
26
|
// 右下角
|
|
28
27
|
if (rowIndex === rowLength - 1 && colIndex === colLength - 1) {
|
|
29
|
-
element.classList.add(
|
|
28
|
+
element.classList.add('seCell');
|
|
30
29
|
}
|
|
31
30
|
// 第一行
|
|
32
31
|
if (rowIndex === 0) {
|
|
33
|
-
element.classList.add(
|
|
32
|
+
element.classList.add('firstRow');
|
|
34
33
|
}
|
|
35
34
|
// 最后一行
|
|
36
35
|
if (rowIndex === rowLength - 1) {
|
|
37
|
-
element.classList.add(
|
|
36
|
+
element.classList.add('lastRow');
|
|
38
37
|
}
|
|
39
38
|
// 第一列
|
|
40
39
|
if (colIndex === 0) {
|
|
41
|
-
element.classList.add(
|
|
40
|
+
element.classList.add('firstCol');
|
|
42
41
|
}
|
|
43
42
|
// 最后一列
|
|
44
43
|
if (colIndex === colLength - 1) {
|
|
45
|
-
element.classList.add(
|
|
44
|
+
element.classList.add('lastCol');
|
|
46
45
|
}
|
|
47
46
|
// 奇数行
|
|
48
47
|
if (isOdd(rowIndex + 1)) {
|
|
49
|
-
element.classList.add(
|
|
48
|
+
element.classList.add('band1Horz');
|
|
50
49
|
}
|
|
51
50
|
// 偶数行
|
|
52
51
|
if (!isOdd(rowIndex + 1)) {
|
|
53
|
-
element.classList.add(
|
|
52
|
+
element.classList.add('band2Horz');
|
|
54
53
|
}
|
|
55
54
|
// 奇数列
|
|
56
55
|
if (isOdd(colIndex + 1)) {
|
|
57
|
-
element.classList.add(
|
|
56
|
+
element.classList.add('band1Vert');
|
|
58
57
|
}
|
|
59
58
|
// 偶数列
|
|
60
59
|
if (!isOdd(colIndex + 1)) {
|
|
61
|
-
element.classList.add(
|
|
60
|
+
element.classList.add('band2Vert');
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
/**
|
|
@@ -120,7 +119,7 @@ function renderTable(word, table) {
|
|
|
120
119
|
setTdClassName(rowIndex, colIndex, table.trs.length, tr.tcs.length, tdEl, properties.rowBandSize, properties.colBandSize);
|
|
121
120
|
// tr 也能设置 tc style,所以先应用这个
|
|
122
121
|
if (tr.properties.tcStyle) {
|
|
123
|
-
|
|
122
|
+
applyStyle(tdEl, tr.properties.tcStyle);
|
|
124
123
|
}
|
|
125
124
|
var tcPr = tc.properties;
|
|
126
125
|
setElementStyle(word, tdEl, tcPr);
|
|
@@ -130,17 +129,21 @@ function renderTable(word, table) {
|
|
|
130
129
|
if (tcPr.rowSpan) {
|
|
131
130
|
tdEl.rowSpan = tcPr.rowSpan;
|
|
132
131
|
}
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
var renderSpace = true;
|
|
133
|
+
// 如果有 tcPr.hideMark 就不渲染空格
|
|
134
|
+
if (tcPr.hideMark) {
|
|
135
|
+
renderSpace = false;
|
|
136
|
+
}
|
|
135
137
|
try {
|
|
136
138
|
for (var _h = (e_3 = void 0, __values(tc.children)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
137
139
|
var tcChild = _j.value;
|
|
138
140
|
if (tcChild instanceof Paragraph) {
|
|
139
|
-
var p = renderParagraph(word, tcChild,
|
|
141
|
+
var p = renderParagraph(word, tcChild, renderSpace);
|
|
140
142
|
appendChild(tdEl, p);
|
|
141
143
|
}
|
|
142
144
|
else if (tcChild instanceof Table) {
|
|
143
|
-
|
|
145
|
+
// 如果已经有表格的话,就不再渲染空段落了,避免底部多个空行
|
|
146
|
+
renderSpace = false;
|
|
144
147
|
appendChild(tdEl, renderTable(word, tcChild));
|
|
145
148
|
}
|
|
146
149
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { applyStyle, addClassName, addClassNames } from '../util/dom.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 设置元素样式,因为好几个地方用所以统一一下
|
|
@@ -8,7 +8,12 @@ function setElementStyle(word, element, properties) {
|
|
|
8
8
|
return;
|
|
9
9
|
}
|
|
10
10
|
if (properties.cssStyle) {
|
|
11
|
-
|
|
11
|
+
applyStyle(element, properties.cssStyle);
|
|
12
|
+
// 需要依赖这个 class 才能实现水平分布
|
|
13
|
+
// https://stackoverflow.com/a/21199162
|
|
14
|
+
if (properties.cssStyle['text-align'] === 'justify') {
|
|
15
|
+
addClassName(element, 'justify');
|
|
16
|
+
}
|
|
12
17
|
}
|
|
13
18
|
if (properties.pStyle) {
|
|
14
19
|
addClassNames(element, word.getStyleClassName(properties.pStyle));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const behindIndex = "1";
|
package/esm/util/blob.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 将 blob 转成 data url
|
|
3
3
|
*/
|
|
4
|
-
function blobToDataURL(blob) {
|
|
5
|
-
return new Promise(function (resolve, reject) {
|
|
6
|
-
var reader = new FileReader();
|
|
7
|
-
reader.onload = function (_e) { return resolve(reader.result); };
|
|
8
|
-
reader.onerror = function (_e) { return reject(reader.error); };
|
|
9
|
-
reader.onabort = function (_e) { return reject(new Error('Read aborted')); };
|
|
10
|
-
reader.readAsDataURL(blob);
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
4
|
/**
|
|
14
5
|
* 下载 blob
|
|
15
6
|
* https://dev.to/nombrekeff/download-file-from-blob-21ho
|
|
@@ -36,4 +27,4 @@ function downloadBlob(blob, name) {
|
|
|
36
27
|
document.body.removeChild(link);
|
|
37
28
|
}
|
|
38
29
|
|
|
39
|
-
export {
|
|
30
|
+
export { downloadBlob };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 处理颜色相关的函数,目前只支持 rgb
|
|
3
|
+
*/
|
|
4
|
+
export declare class Color {
|
|
5
|
+
r: number;
|
|
6
|
+
g: number;
|
|
7
|
+
b: number;
|
|
8
|
+
isValid: boolean;
|
|
9
|
+
constructor(input: string);
|
|
10
|
+
static fromHSL(h: number, s: number, l: number): Color;
|
|
11
|
+
static fromRGB(r: number, g: number, b: number): Color;
|
|
12
|
+
/**
|
|
13
|
+
* 设置 lum
|
|
14
|
+
*/
|
|
15
|
+
lum(l: number): this;
|
|
16
|
+
/**
|
|
17
|
+
* 改变 lum 百分比,其实不太对,但差不太多
|
|
18
|
+
* @param l 百分比,比如 2 相当于 200 %
|
|
19
|
+
*/
|
|
20
|
+
lumMod(l: number): this;
|
|
21
|
+
/**
|
|
22
|
+
* 改变百分比
|
|
23
|
+
* @param l 百分比,比如 -0.2 相当于减少 20 %
|
|
24
|
+
*/
|
|
25
|
+
lumOff(l: number): this;
|
|
26
|
+
/**
|
|
27
|
+
* h 取值范围是 0-1
|
|
28
|
+
*/
|
|
29
|
+
hue(h: number): this;
|
|
30
|
+
hueMod(h: number): this;
|
|
31
|
+
hueOff(h: number): this;
|
|
32
|
+
sat(s: number): this;
|
|
33
|
+
satMod(s: number): this;
|
|
34
|
+
satOff(s: number): this;
|
|
35
|
+
/**
|
|
36
|
+
* 修改 hsl 中某个部分的值
|
|
37
|
+
*/
|
|
38
|
+
changeHsl(num: number, com: 'h' | 's' | 'l', changeType: 'set' | 'mod' | 'off'): this;
|
|
39
|
+
/**
|
|
40
|
+
* 互补色
|
|
41
|
+
*/
|
|
42
|
+
comp(): this;
|
|
43
|
+
shade(s: number): void;
|
|
44
|
+
tint(t: number): void;
|
|
45
|
+
inv(): this;
|
|
46
|
+
toHex(): string;
|
|
47
|
+
toRgba(alpha: number): string;
|
|
48
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 处理颜色相关的函数,目前只支持 rgb
|
|
3
|
+
*/
|
|
4
|
+
// 颜色转换来自 https://gist.github.com/mjackson/5311256
|
|
5
|
+
function rgbToHsl(r, g, b) {
|
|
6
|
+
(r /= 255), (g /= 255), (b /= 255);
|
|
7
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
8
|
+
var h = 0, s, l = (max + min) / 2;
|
|
9
|
+
if (max == min) {
|
|
10
|
+
h = s = 0; // achromatic
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
var d = max - min;
|
|
14
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
15
|
+
switch (max) {
|
|
16
|
+
case r:
|
|
17
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
18
|
+
break;
|
|
19
|
+
case g:
|
|
20
|
+
h = (b - r) / d + 2;
|
|
21
|
+
break;
|
|
22
|
+
case b:
|
|
23
|
+
h = (r - g) / d + 4;
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
h /= 6;
|
|
27
|
+
}
|
|
28
|
+
return { h: h, s: s, l: l };
|
|
29
|
+
}
|
|
30
|
+
function hue2rgb(p, q, t) {
|
|
31
|
+
if (t < 0)
|
|
32
|
+
t += 1;
|
|
33
|
+
if (t > 1)
|
|
34
|
+
t -= 1;
|
|
35
|
+
if (t < 1 / 6)
|
|
36
|
+
return p + (q - p) * 6 * t;
|
|
37
|
+
if (t < 1 / 2)
|
|
38
|
+
return q;
|
|
39
|
+
if (t < 2 / 3)
|
|
40
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
41
|
+
return p;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Converts an HSL color value to RGB. Conversion formula
|
|
45
|
+
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
46
|
+
* Assumes h, s, and l are contained in the set [0, 1] and
|
|
47
|
+
* returns r, g, and b in the set [0, 255].
|
|
48
|
+
*
|
|
49
|
+
* @param Number h The hue
|
|
50
|
+
* @param Number s The saturation
|
|
51
|
+
* @param Number l The lightness
|
|
52
|
+
* @return Array The RGB representation
|
|
53
|
+
*/
|
|
54
|
+
function hslToRgb(h, s, l) {
|
|
55
|
+
if (h > 1) {
|
|
56
|
+
h = h / 360;
|
|
57
|
+
}
|
|
58
|
+
var r, g, b;
|
|
59
|
+
if (s == 0) {
|
|
60
|
+
r = g = b = l; // achromatic
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
64
|
+
var p = 2 * l - q;
|
|
65
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
66
|
+
g = hue2rgb(p, q, h);
|
|
67
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
68
|
+
}
|
|
69
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
70
|
+
}
|
|
71
|
+
function pad2(c) {
|
|
72
|
+
return c.length == 1 ? '0' + c : '' + c;
|
|
73
|
+
}
|
|
74
|
+
// `rgbToHex`
|
|
75
|
+
// Converts an RGB color to hex
|
|
76
|
+
// Assumes r, g, and b are contained in the set [0, 255]
|
|
77
|
+
// Returns a 3 or 6 character hex
|
|
78
|
+
function rgbToHex(r, g, b) {
|
|
79
|
+
var hex = [
|
|
80
|
+
pad2(Math.round(r).toString(16)),
|
|
81
|
+
pad2(Math.round(g).toString(16)),
|
|
82
|
+
pad2(Math.round(b).toString(16))
|
|
83
|
+
];
|
|
84
|
+
return hex.join('').toUpperCase();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 避免颜色值超出范围,适用于 rgb
|
|
88
|
+
*/
|
|
89
|
+
function toValidColor(c) {
|
|
90
|
+
return Math.min(Math.max(c, 0), 255);
|
|
91
|
+
}
|
|
92
|
+
var Color = /** @class */ (function () {
|
|
93
|
+
function Color(input) {
|
|
94
|
+
var m = input.match(/^#?([0-9a-f]{6})$/i);
|
|
95
|
+
if (m) {
|
|
96
|
+
this.r = parseInt(m[1].substring(0, 2), 16);
|
|
97
|
+
this.g = parseInt(m[1].substring(2, 4), 16);
|
|
98
|
+
this.b = parseInt(m[1].substring(4, 6), 16);
|
|
99
|
+
this.isValid = true;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
Color.fromHSL = function (h, s, l) {
|
|
103
|
+
var rgb = hslToRgb(h, s, l);
|
|
104
|
+
return new Color("#".concat(rgbToHex(rgb.r, rgb.g, rgb.b)));
|
|
105
|
+
};
|
|
106
|
+
Color.fromRGB = function (r, g, b) {
|
|
107
|
+
var rgb = rgbToHex(r, g, b);
|
|
108
|
+
return new Color("#".concat(rgb));
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* 设置 lum
|
|
112
|
+
*/
|
|
113
|
+
Color.prototype.lum = function (l) {
|
|
114
|
+
return this.changeHsl(l, 'l', 'set');
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* 改变 lum 百分比,其实不太对,但差不太多
|
|
118
|
+
* @param l 百分比,比如 2 相当于 200 %
|
|
119
|
+
*/
|
|
120
|
+
Color.prototype.lumMod = function (l) {
|
|
121
|
+
return this.changeHsl(l, 'l', 'mod');
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* 改变百分比
|
|
125
|
+
* @param l 百分比,比如 -0.2 相当于减少 20 %
|
|
126
|
+
*/
|
|
127
|
+
Color.prototype.lumOff = function (l) {
|
|
128
|
+
return this.changeHsl(l, 'l', 'off');
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* h 取值范围是 0-1
|
|
132
|
+
*/
|
|
133
|
+
Color.prototype.hue = function (h) {
|
|
134
|
+
return this.changeHsl(h, 'h', 'set');
|
|
135
|
+
};
|
|
136
|
+
Color.prototype.hueMod = function (h) {
|
|
137
|
+
return this.changeHsl(h, 'h', 'mod');
|
|
138
|
+
};
|
|
139
|
+
Color.prototype.hueOff = function (h) {
|
|
140
|
+
return this.changeHsl(h, 'h', 'off');
|
|
141
|
+
};
|
|
142
|
+
Color.prototype.sat = function (s) {
|
|
143
|
+
return this.changeHsl(s, 's', 'set');
|
|
144
|
+
};
|
|
145
|
+
Color.prototype.satMod = function (s) {
|
|
146
|
+
return this.changeHsl(s, 's', 'mod');
|
|
147
|
+
};
|
|
148
|
+
Color.prototype.satOff = function (s) {
|
|
149
|
+
return this.changeHsl(s, 's', 'off');
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* 修改 hsl 中某个部分的值
|
|
153
|
+
*/
|
|
154
|
+
Color.prototype.changeHsl = function (num, com, changeType) {
|
|
155
|
+
var hsl = rgbToHsl(this.r, this.g, this.b);
|
|
156
|
+
if (changeType === 'set') {
|
|
157
|
+
hsl[com] = num;
|
|
158
|
+
}
|
|
159
|
+
else if (changeType === 'mod') {
|
|
160
|
+
hsl[com] = hsl[com] * num;
|
|
161
|
+
}
|
|
162
|
+
else if (changeType === 'off') {
|
|
163
|
+
hsl[com] += hsl[com] * num;
|
|
164
|
+
}
|
|
165
|
+
var rgb = hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
166
|
+
this.r = rgb.r;
|
|
167
|
+
this.g = rgb.g;
|
|
168
|
+
this.b = rgb.b;
|
|
169
|
+
return this;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* 互补色
|
|
173
|
+
*/
|
|
174
|
+
Color.prototype.comp = function () {
|
|
175
|
+
var hsl = rgbToHsl(this.r, this.g, this.b);
|
|
176
|
+
hsl.h = hsl.h + 0.5;
|
|
177
|
+
if (hsl.h > 1) {
|
|
178
|
+
hsl.h -= 1;
|
|
179
|
+
}
|
|
180
|
+
var rgb = hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
181
|
+
this.r = rgb.r;
|
|
182
|
+
this.g = rgb.g;
|
|
183
|
+
this.b = rgb.b;
|
|
184
|
+
return this;
|
|
185
|
+
};
|
|
186
|
+
Color.prototype.shade = function (s) {
|
|
187
|
+
this.r = toValidColor(this.r - 256 * s);
|
|
188
|
+
this.g = toValidColor(this.g - 256 * s);
|
|
189
|
+
this.b = toValidColor(this.b - 256 * s);
|
|
190
|
+
};
|
|
191
|
+
Color.prototype.tint = function (t) {
|
|
192
|
+
this.r = toValidColor(this.r + 256 * t);
|
|
193
|
+
this.g = toValidColor(this.g + 256 * t);
|
|
194
|
+
this.b = toValidColor(this.b + 256 * t);
|
|
195
|
+
};
|
|
196
|
+
Color.prototype.inv = function () {
|
|
197
|
+
this.r = 255 - this.r;
|
|
198
|
+
this.g = 255 - this.g;
|
|
199
|
+
this.b = 255 - this.b;
|
|
200
|
+
return this;
|
|
201
|
+
};
|
|
202
|
+
Color.prototype.toHex = function () {
|
|
203
|
+
return '#' + rgbToHex(this.r, this.g, this.b);
|
|
204
|
+
};
|
|
205
|
+
Color.prototype.toRgba = function (alpha) {
|
|
206
|
+
return "rgba(".concat(this.r, ", ").concat(this.g, ", ").concat(this.b, ", ").concat(alpha, ")");
|
|
207
|
+
};
|
|
208
|
+
return Color;
|
|
209
|
+
}());
|
|
210
|
+
|
|
211
|
+
export { Color };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 拷贝自 amis 里的方法,避免依赖
|
|
3
|
+
*/
|
|
4
|
+
export declare function createObject(superProps?: {
|
|
5
|
+
[propName: string]: any;
|
|
6
|
+
}, props?: {
|
|
7
|
+
[propName: string]: any;
|
|
8
|
+
}, properties?: any): object;
|
|
9
|
+
export declare function cloneObject(target: any, persistOwnProps?: boolean): any;
|
|
10
|
+
export declare function isObject(obj: any): any;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __assign } from 'tslib';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 拷贝自 amis 里的方法,避免依赖
|
|
5
|
+
*/
|
|
6
|
+
function createObject(superProps, props, properties) {
|
|
7
|
+
if (superProps && Object.isFrozen(superProps)) {
|
|
8
|
+
superProps = cloneObject(superProps);
|
|
9
|
+
}
|
|
10
|
+
var obj = superProps
|
|
11
|
+
? Object.create(superProps, __assign(__assign({}, properties), { __super: {
|
|
12
|
+
value: superProps,
|
|
13
|
+
writable: false,
|
|
14
|
+
enumerable: false
|
|
15
|
+
} }))
|
|
16
|
+
: Object.create(Object.prototype, properties);
|
|
17
|
+
props &&
|
|
18
|
+
isObject(props) &&
|
|
19
|
+
Object.keys(props).forEach(function (key) { return (obj[key] = props[key]); });
|
|
20
|
+
return obj;
|
|
21
|
+
}
|
|
22
|
+
function cloneObject(target, persistOwnProps) {
|
|
23
|
+
if (persistOwnProps === void 0) { persistOwnProps = true; }
|
|
24
|
+
var obj = target && target.__super
|
|
25
|
+
? Object.create(target.__super, {
|
|
26
|
+
__super: {
|
|
27
|
+
value: target.__super,
|
|
28
|
+
writable: false,
|
|
29
|
+
enumerable: false
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
: Object.create(Object.prototype);
|
|
33
|
+
persistOwnProps &&
|
|
34
|
+
target &&
|
|
35
|
+
Object.keys(target).forEach(function (key) { return (obj[key] = target[key]); });
|
|
36
|
+
return obj;
|
|
37
|
+
}
|
|
38
|
+
function isObject(obj) {
|
|
39
|
+
var typename = typeof obj;
|
|
40
|
+
return (obj &&
|
|
41
|
+
typename !== 'string' &&
|
|
42
|
+
typename !== 'number' &&
|
|
43
|
+
typename !== 'boolean' &&
|
|
44
|
+
typename !== 'function' &&
|
|
45
|
+
!Array.isArray(obj));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { cloneObject, createObject, isObject };
|
package/esm/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/esm/util/dom.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __spreadArray, __read } from '
|
|
1
|
+
import { __spreadArray, __read } from 'tslib';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* dom 相关的操作
|
|
@@ -20,11 +20,14 @@ function styleToText(style) {
|
|
|
20
20
|
/**
|
|
21
21
|
* 设置元素样式
|
|
22
22
|
*/
|
|
23
|
-
function
|
|
23
|
+
function applyStyle(el, style) {
|
|
24
|
+
if (!style) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
24
27
|
for (var key in style) {
|
|
25
28
|
var value = style[key];
|
|
26
29
|
if (value != null && value !== '') {
|
|
27
|
-
el.style.setProperty(key,
|
|
30
|
+
el.style.setProperty(key, String(value));
|
|
28
31
|
}
|
|
29
32
|
}
|
|
30
33
|
}
|
|
@@ -34,6 +37,12 @@ function setStyle(el, style) {
|
|
|
34
37
|
function createElement(tagName) {
|
|
35
38
|
return document.createElement(tagName);
|
|
36
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* 创建 SVG 元素
|
|
42
|
+
*/
|
|
43
|
+
function createSVGElement(tagName) {
|
|
44
|
+
return document.createElementNS('http://www.w3.org/2000/svg', tagName);
|
|
45
|
+
}
|
|
37
46
|
/**
|
|
38
47
|
* 添加子节点,会做一些判断避免报错
|
|
39
48
|
*/
|
|
@@ -42,6 +51,14 @@ function appendChild(parent, child) {
|
|
|
42
51
|
parent.appendChild(child);
|
|
43
52
|
}
|
|
44
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* 删除子节点,会做一些判断避免报错
|
|
56
|
+
*/
|
|
57
|
+
function removeChild(parent, child) {
|
|
58
|
+
if (parent && child) {
|
|
59
|
+
parent.removeChild(child);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
45
62
|
/**
|
|
46
63
|
* 添加 css 类
|
|
47
64
|
*/
|
|
@@ -60,4 +77,4 @@ function addClassNames(el, classNames) {
|
|
|
60
77
|
}
|
|
61
78
|
}
|
|
62
79
|
|
|
63
|
-
export { addClassName, addClassNames, appendChild, createElement,
|
|
80
|
+
export { addClassName, addClassNames, appendChild, applyStyle, createElement, createSVGElement, removeChild, styleToText };
|
package/esm/util/get.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore#_get
|
|
3
|
+
*/
|
|
4
|
+
var get = function (obj, path, defaultValue) {
|
|
5
|
+
if (defaultValue === void 0) { defaultValue = undefined; }
|
|
6
|
+
var travel = function (regexp) {
|
|
7
|
+
return String.prototype.split
|
|
8
|
+
.call(path, regexp)
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.reduce(function (res, key) {
|
|
11
|
+
return res !== null && res !== undefined ? res[key] : res;
|
|
12
|
+
}, obj);
|
|
13
|
+
};
|
|
14
|
+
var result = travel(/[,[\]]+?/) || travel(/[,[\].]+?/);
|
|
15
|
+
return result === undefined || result === obj ? defaultValue : result;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { get };
|
package/esm/util/mergeRun.js
CHANGED
|
@@ -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,54 @@
|
|
|
1
|
+
import { __awaiter, __generator } from 'tslib';
|
|
2
|
+
|
|
3
|
+
function loadIframeImages(images) {
|
|
4
|
+
var _this = this;
|
|
5
|
+
var promises = images.map(function (image) { return __awaiter(_this, void 0, void 0, function () {
|
|
6
|
+
return __generator(this, function (_a) {
|
|
7
|
+
switch (_a.label) {
|
|
8
|
+
case 0:
|
|
9
|
+
if (!(image.src && image.src !== window.location.href)) return [3 /*break*/, 2];
|
|
10
|
+
return [4 /*yield*/, loadIframeImage(image)];
|
|
11
|
+
case 1:
|
|
12
|
+
_a.sent();
|
|
13
|
+
_a.label = 2;
|
|
14
|
+
case 2: return [2 /*return*/];
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}); });
|
|
18
|
+
return Promise.all(promises);
|
|
19
|
+
}
|
|
20
|
+
function loadIframeImage(image) {
|
|
21
|
+
return new Promise(function (resolve) {
|
|
22
|
+
var pollImage = function () {
|
|
23
|
+
!image ||
|
|
24
|
+
typeof image.naturalWidth === 'undefined' ||
|
|
25
|
+
image.naturalWidth === 0 ||
|
|
26
|
+
!image.complete
|
|
27
|
+
? setTimeout(pollImage, 500)
|
|
28
|
+
: resolve();
|
|
29
|
+
};
|
|
30
|
+
pollImage();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function performPrint(iframe) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
(_a = iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.print();
|
|
36
|
+
(_b = iframe.parentNode) === null || _b === void 0 ? void 0 : _b.removeChild(iframe);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 打印 iframe,参考了 print.js 里的部分实现
|
|
40
|
+
* @param iframe
|
|
41
|
+
*/
|
|
42
|
+
function printIframe(iframe) {
|
|
43
|
+
var printDocument = iframe.contentDocument;
|
|
44
|
+
// If printing images, wait for them to load inside the iframe
|
|
45
|
+
var images = printDocument.getElementsByTagName('img');
|
|
46
|
+
if (images.length > 0) {
|
|
47
|
+
loadIframeImages(Array.from(images)).then(function () { return performPrint(iframe); });
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
performPrint(iframe);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { 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;
|