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
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var Types = require('../openxml/Types.js');
|
|
5
|
+
var tslib = require('tslib');
|
|
7
6
|
var dom = require('../util/dom.js');
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -13,6 +12,7 @@ var dom = require('../util/dom.js');
|
|
|
13
12
|
* 文档基础默认样式
|
|
14
13
|
*/
|
|
15
14
|
function generateDefaultStyle(word) {
|
|
15
|
+
var _a;
|
|
16
16
|
var styles = word.styles;
|
|
17
17
|
var defaultStyle = styles.defaultStyle;
|
|
18
18
|
var defaultPStyle = '';
|
|
@@ -23,8 +23,9 @@ function generateDefaultStyle(word) {
|
|
|
23
23
|
if (defaultStyle === null || defaultStyle === void 0 ? void 0 : defaultStyle.rPr) {
|
|
24
24
|
defaultRStyle = dom.styleToText(defaultStyle.rPr.cssStyle);
|
|
25
25
|
}
|
|
26
|
+
var hyphens = ((_a = word.settings) === null || _a === void 0 ? void 0 : _a.autoHyphenation) ? 'hyphens: auto;' : '';
|
|
26
27
|
var classPrefix = word.getClassPrefix();
|
|
27
|
-
return "\n .".concat(
|
|
28
|
+
return "\n\n\n /** docDefaults **/\n .".concat(classPrefix, " {\n --docx-theme-font-minorHAnsi: Calibri, Helvetica, Arial, 'Helvetica Neue';\n --docx-theme-font-minorEastAsia: 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', 'STHeiti',\n 'Microsoft YaHei';\n }\n\n .").concat(classPrefix, " p {\n margin: 0;\n padding: 0;\n line-height: 1.5;\n ").concat(hyphens, "\n }\n\n .").concat(classPrefix, " .justify:after {\n content: \"\";\n display: inline-block;\n width: 100%;\n }\n\n .").concat(classPrefix, " table {\n border-spacing: 0;\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-p {\n ").concat(defaultPStyle, "\n }\n\n .").concat(classPrefix, " .").concat(classPrefix, "-r {\n overflow-wrap: break-word;\n ").concat(defaultRStyle, "\n }\n ");
|
|
28
29
|
}
|
|
29
30
|
/**
|
|
30
31
|
* 生成表格级别样式
|
|
@@ -54,81 +55,81 @@ function generateTableStyle(classPrefix, styleDisplayId, style) {
|
|
|
54
55
|
return tblStyleText;
|
|
55
56
|
}
|
|
56
57
|
// 用于生成表格 override 相关的样式,用于行或列
|
|
57
|
-
function genTblOverrideStyle(
|
|
58
|
+
function genTblOverrideStyle(tblPrefix, classPrefix, overrideType, tblStylePrStyle) {
|
|
58
59
|
var _a, _b, _c, _d, _e, _f;
|
|
59
60
|
var styleText = '';
|
|
60
61
|
var trStyle = dom.styleToText((_a = tblStylePrStyle.trPr) === null || _a === void 0 ? void 0 : _a.cssStyle);
|
|
61
62
|
var enableType = '';
|
|
62
63
|
// 在 tblLook 里可以通过这些属性来控制是否启用
|
|
63
64
|
switch (overrideType) {
|
|
64
|
-
case
|
|
65
|
+
case 'firstCol':
|
|
65
66
|
enableType = 'enable-firstColumn';
|
|
66
67
|
break;
|
|
67
|
-
case
|
|
68
|
+
case 'lastCol':
|
|
68
69
|
enableType = 'enable-lastColumn';
|
|
69
70
|
break;
|
|
70
|
-
case
|
|
71
|
+
case 'firstRow':
|
|
71
72
|
enableType = 'enable-firstRow';
|
|
72
73
|
break;
|
|
73
|
-
case
|
|
74
|
+
case 'lastRow':
|
|
74
75
|
enableType = 'enable-lastRow';
|
|
75
76
|
break;
|
|
76
|
-
case
|
|
77
|
-
case
|
|
77
|
+
case 'band1Horz':
|
|
78
|
+
case 'band2Horz':
|
|
78
79
|
enableType = 'enable-hBand';
|
|
79
80
|
break;
|
|
80
|
-
case
|
|
81
|
-
case
|
|
81
|
+
case 'band1Vert':
|
|
82
|
+
case 'band2Vert':
|
|
82
83
|
enableType = 'enable-vBand';
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
85
86
|
if (trStyle) {
|
|
86
|
-
styleText += "\n ".concat(
|
|
87
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr.").concat(overrideType, "{\n ").concat(trStyle, "\n }\n ");
|
|
87
88
|
}
|
|
88
89
|
var tcStyle = dom.styleToText((_b = tblStylePrStyle.tcPr) === null || _b === void 0 ? void 0 : _b.cssStyle);
|
|
89
90
|
if (tcStyle) {
|
|
90
|
-
styleText += "\n ".concat(
|
|
91
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n ").concat(tcStyle, "\n }\n ");
|
|
91
92
|
if ((_c = tblStylePrStyle.tcPr) === null || _c === void 0 ? void 0 : _c.insideBorder) {
|
|
92
93
|
var insideBorder = (_d = tblStylePrStyle.tcPr) === null || _d === void 0 ? void 0 : _d.insideBorder;
|
|
93
94
|
if (insideBorder.H) {
|
|
94
|
-
styleText += "\n ".concat(
|
|
95
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-top: ").concat(insideBorder.H, ";\n }");
|
|
95
96
|
}
|
|
96
97
|
if (insideBorder.V) {
|
|
97
98
|
// 这个主要是为了应对 GridTable5Dark-Accent5 里 firstRow 的情况,它其实有 right 设置,也得去掉
|
|
98
99
|
if (insideBorder.V === 'none') {
|
|
99
|
-
styleText += "\n ".concat(
|
|
100
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: none;\n border-right: none;\n }");
|
|
100
101
|
}
|
|
101
102
|
else {
|
|
102
|
-
styleText += "\n ".concat(
|
|
103
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: ").concat(insideBorder.V, ";\n }");
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
var pStyle = dom.styleToText((_e = tblStylePrStyle.pPr) === null || _e === void 0 ? void 0 : _e.cssStyle);
|
|
108
109
|
if (pStyle) {
|
|
109
|
-
styleText += "\n ".concat(
|
|
110
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p {\n ").concat(pStyle, "\n }\n ");
|
|
110
111
|
}
|
|
111
112
|
var rStyle = dom.styleToText((_f = tblStylePrStyle.rPr) === null || _f === void 0 ? void 0 : _f.cssStyle);
|
|
112
113
|
if (rStyle) {
|
|
113
|
-
styleText += "\n ".concat(
|
|
114
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
|
|
114
115
|
}
|
|
115
116
|
return styleText;
|
|
116
117
|
}
|
|
117
118
|
// 表格覆盖样式的顺序,权重高的放后面
|
|
118
119
|
var overrideTypeOrder = new Set([
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
120
|
+
'wholeTable',
|
|
121
|
+
'band1Horz',
|
|
122
|
+
'band2Horz',
|
|
123
|
+
'band1Vert',
|
|
124
|
+
'band2Vert',
|
|
125
|
+
'firstCol',
|
|
126
|
+
'firstRow',
|
|
127
|
+
'lastCol',
|
|
128
|
+
'lastRow',
|
|
129
|
+
'neCell',
|
|
130
|
+
'nwCell',
|
|
131
|
+
'seCell',
|
|
132
|
+
'swCell'
|
|
132
133
|
]);
|
|
133
134
|
// 生成表格覆盖样式
|
|
134
135
|
function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
|
|
@@ -139,11 +140,11 @@ function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
|
|
|
139
140
|
var tblStylePrText = '';
|
|
140
141
|
var stylePrefix = ".".concat(classPrefix, " .").concat(styleDisplayId);
|
|
141
142
|
try {
|
|
142
|
-
for (var overrideTypeOrder_1 =
|
|
143
|
+
for (var overrideTypeOrder_1 = tslib.__values(overrideTypeOrder), overrideTypeOrder_1_1 = overrideTypeOrder_1.next(); !overrideTypeOrder_1_1.done; overrideTypeOrder_1_1 = overrideTypeOrder_1.next()) {
|
|
143
144
|
var overrideType = overrideTypeOrder_1_1.value;
|
|
144
145
|
if (overrideType in tblStylePr) {
|
|
145
146
|
var overrideStylePr = tblStylePr[overrideType];
|
|
146
|
-
tblStylePrText += genTblOverrideStyle(stylePrefix, overrideType, overrideStylePr);
|
|
147
|
+
tblStylePrText += genTblOverrideStyle(stylePrefix, classPrefix, overrideType, overrideStylePr);
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
}
|
|
@@ -176,7 +177,7 @@ function generateStyle(word) {
|
|
|
176
177
|
var rStyleText = '';
|
|
177
178
|
if (styleData.rPr) {
|
|
178
179
|
var rStyle = dom.styleToText(styleData.rPr.cssStyle);
|
|
179
|
-
rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .r {\n ").concat(rStyle, "\n }\n ");
|
|
180
|
+
rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
|
|
180
181
|
}
|
|
181
182
|
var tblStyleText = generateTableStyle(classPrefix, styleDisplayId, styleData);
|
|
182
183
|
var tblStylePr = genOverrideTblStylePr(classPrefix, styleDisplayId, styleData.tblStylePr);
|
|
@@ -191,7 +192,7 @@ function renderStyle(word) {
|
|
|
191
192
|
var style = dom.createElement('style');
|
|
192
193
|
var docDefaults = generateDefaultStyle(word);
|
|
193
194
|
var styleText = generateStyle(word);
|
|
194
|
-
style.
|
|
195
|
+
style.textContent = "\n ".concat(docDefaults, "\n\n ").concat(styleText, "\n ");
|
|
195
196
|
return style;
|
|
196
197
|
}
|
|
197
198
|
|
|
@@ -2,6 +2,7 @@ import { Tab } from '../openxml/word/Tab';
|
|
|
2
2
|
import Word from '../Word';
|
|
3
3
|
/**
|
|
4
4
|
* 渲染 tab
|
|
5
|
+
* 不支持 tabs 里的自定义宽度,因为要算渲染后的宽度,比较麻烦
|
|
5
6
|
* http://officeopenxml.com/WPtab.php
|
|
6
7
|
*/
|
|
7
|
-
export declare function renderTab(word: Word, tab: Tab): HTMLElement;
|
|
8
|
+
export declare function renderTab(word: Word, tab: Tab, renderWidth?: boolean): HTMLElement;
|
package/lib/render/renderTab.js
CHANGED
|
@@ -2,20 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var Types = require('../openxml/Types.js');
|
|
6
5
|
var dom = require('../util/dom.js');
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* 渲染 tab
|
|
9
|
+
* 不支持 tabs 里的自定义宽度,因为要算渲染后的宽度,比较麻烦
|
|
10
10
|
* http://officeopenxml.com/WPtab.php
|
|
11
11
|
*/
|
|
12
|
-
function renderTab(word, tab) {
|
|
12
|
+
function renderTab(word, tab, renderWidth) {
|
|
13
|
+
if (renderWidth === void 0) { renderWidth = false; }
|
|
13
14
|
var tabElement = dom.createElement('span');
|
|
14
15
|
tabElement.style.display = 'inline-block';
|
|
15
|
-
tabElement.style.width =
|
|
16
|
-
tabElement.innerHTML = '&
|
|
17
|
-
if (tab.leader ===
|
|
18
|
-
tabElement.style.borderBottom = '
|
|
16
|
+
tabElement.style.width = '2em';
|
|
17
|
+
tabElement.innerHTML = ' ';
|
|
18
|
+
if (tab.leader === 'dot') {
|
|
19
|
+
tabElement.style.borderBottom = '1pt dotted';
|
|
20
|
+
}
|
|
21
|
+
if (renderWidth && tab.pos && (tab.type === 'start' || tab.type == 'left')) {
|
|
22
|
+
tabElement.style.width = tab.pos;
|
|
19
23
|
}
|
|
20
24
|
return tabElement;
|
|
21
25
|
}
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
6
|
-
var Types = require('../openxml/Types.js');
|
|
5
|
+
var tslib = require('tslib');
|
|
7
6
|
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
8
7
|
var Table = require('../openxml/word/Table.js');
|
|
9
8
|
var dom = require('../util/dom.js');
|
|
@@ -18,51 +17,51 @@ var setElementStyle = require('./setElementStyle.js');
|
|
|
18
17
|
function setTdClassName(rowIndex, colIndex, rowLength, colLength, element, rowBandSize, colBandSize) {
|
|
19
18
|
// 左上角
|
|
20
19
|
if (rowIndex === 0 && colIndex === 0) {
|
|
21
|
-
element.classList.add(
|
|
20
|
+
element.classList.add('nwCell');
|
|
22
21
|
}
|
|
23
22
|
// 右上角
|
|
24
23
|
if (rowIndex === 0 && colIndex === colLength - 1) {
|
|
25
|
-
element.classList.add(
|
|
24
|
+
element.classList.add('neCell');
|
|
26
25
|
}
|
|
27
26
|
// 左下角
|
|
28
27
|
if (rowIndex === rowLength - 1 && colIndex === 0) {
|
|
29
|
-
element.classList.add(
|
|
28
|
+
element.classList.add('swCell');
|
|
30
29
|
}
|
|
31
30
|
// 右下角
|
|
32
31
|
if (rowIndex === rowLength - 1 && colIndex === colLength - 1) {
|
|
33
|
-
element.classList.add(
|
|
32
|
+
element.classList.add('seCell');
|
|
34
33
|
}
|
|
35
34
|
// 第一行
|
|
36
35
|
if (rowIndex === 0) {
|
|
37
|
-
element.classList.add(
|
|
36
|
+
element.classList.add('firstRow');
|
|
38
37
|
}
|
|
39
38
|
// 最后一行
|
|
40
39
|
if (rowIndex === rowLength - 1) {
|
|
41
|
-
element.classList.add(
|
|
40
|
+
element.classList.add('lastRow');
|
|
42
41
|
}
|
|
43
42
|
// 第一列
|
|
44
43
|
if (colIndex === 0) {
|
|
45
|
-
element.classList.add(
|
|
44
|
+
element.classList.add('firstCol');
|
|
46
45
|
}
|
|
47
46
|
// 最后一列
|
|
48
47
|
if (colIndex === colLength - 1) {
|
|
49
|
-
element.classList.add(
|
|
48
|
+
element.classList.add('lastCol');
|
|
50
49
|
}
|
|
51
50
|
// 奇数行
|
|
52
51
|
if (isOdd(rowIndex + 1)) {
|
|
53
|
-
element.classList.add(
|
|
52
|
+
element.classList.add('band1Horz');
|
|
54
53
|
}
|
|
55
54
|
// 偶数行
|
|
56
55
|
if (!isOdd(rowIndex + 1)) {
|
|
57
|
-
element.classList.add(
|
|
56
|
+
element.classList.add('band2Horz');
|
|
58
57
|
}
|
|
59
58
|
// 奇数列
|
|
60
59
|
if (isOdd(colIndex + 1)) {
|
|
61
|
-
element.classList.add(
|
|
60
|
+
element.classList.add('band1Vert');
|
|
62
61
|
}
|
|
63
62
|
// 偶数列
|
|
64
63
|
if (!isOdd(colIndex + 1)) {
|
|
65
|
-
element.classList.add(
|
|
64
|
+
element.classList.add('band2Vert');
|
|
66
65
|
}
|
|
67
66
|
}
|
|
68
67
|
/**
|
|
@@ -111,20 +110,20 @@ function renderTable(word, table) {
|
|
|
111
110
|
tableEl.appendChild(tbody);
|
|
112
111
|
var rowIndex = 0;
|
|
113
112
|
try {
|
|
114
|
-
for (var _d =
|
|
113
|
+
for (var _d = tslib.__values(table.trs), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
115
114
|
var tr = _e.value;
|
|
116
115
|
var trEl = document.createElement('tr');
|
|
117
116
|
tbody.appendChild(trEl);
|
|
118
117
|
var colIndex = 0;
|
|
119
118
|
try {
|
|
120
|
-
for (var _f = (e_2 = void 0,
|
|
119
|
+
for (var _f = (e_2 = void 0, tslib.__values(tr.tcs)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
121
120
|
var tc = _g.value;
|
|
122
121
|
var tdEl = document.createElement('td');
|
|
123
122
|
trEl.appendChild(tdEl);
|
|
124
123
|
setTdClassName(rowIndex, colIndex, table.trs.length, tr.tcs.length, tdEl, properties.rowBandSize, properties.colBandSize);
|
|
125
124
|
// tr 也能设置 tc style,所以先应用这个
|
|
126
125
|
if (tr.properties.tcStyle) {
|
|
127
|
-
dom.
|
|
126
|
+
dom.applyStyle(tdEl, tr.properties.tcStyle);
|
|
128
127
|
}
|
|
129
128
|
var tcPr = tc.properties;
|
|
130
129
|
setElementStyle.setElementStyle(word, tdEl, tcPr);
|
|
@@ -134,17 +133,21 @@ function renderTable(word, table) {
|
|
|
134
133
|
if (tcPr.rowSpan) {
|
|
135
134
|
tdEl.rowSpan = tcPr.rowSpan;
|
|
136
135
|
}
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
var renderSpace = true;
|
|
137
|
+
// 如果有 tcPr.hideMark 就不渲染空格
|
|
138
|
+
if (tcPr.hideMark) {
|
|
139
|
+
renderSpace = false;
|
|
140
|
+
}
|
|
139
141
|
try {
|
|
140
|
-
for (var _h = (e_3 = void 0,
|
|
142
|
+
for (var _h = (e_3 = void 0, tslib.__values(tc.children)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
141
143
|
var tcChild = _j.value;
|
|
142
144
|
if (tcChild instanceof Paragraph.Paragraph) {
|
|
143
|
-
var p = renderParagraph["default"](word, tcChild,
|
|
145
|
+
var p = renderParagraph["default"](word, tcChild, renderSpace);
|
|
144
146
|
dom.appendChild(tdEl, p);
|
|
145
147
|
}
|
|
146
148
|
else if (tcChild instanceof Table.Table) {
|
|
147
|
-
|
|
149
|
+
// 如果已经有表格的话,就不再渲染空段落了,避免底部多个空行
|
|
150
|
+
renderSpace = false;
|
|
148
151
|
dom.appendChild(tdEl, renderTable(word, tcChild));
|
|
149
152
|
}
|
|
150
153
|
else {
|
|
@@ -12,7 +12,12 @@ function setElementStyle(word, element, properties) {
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
if (properties.cssStyle) {
|
|
15
|
-
dom.
|
|
15
|
+
dom.applyStyle(element, properties.cssStyle);
|
|
16
|
+
// 需要依赖这个 class 才能实现水平分布
|
|
17
|
+
// https://stackoverflow.com/a/21199162
|
|
18
|
+
if (properties.cssStyle['text-align'] === 'justify') {
|
|
19
|
+
dom.addClassName(element, 'justify');
|
|
20
|
+
}
|
|
16
21
|
}
|
|
17
22
|
if (properties.pStyle) {
|
|
18
23
|
dom.addClassNames(element, word.getStyleClassName(properties.pStyle));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const behindIndex = "1";
|
package/lib/util/blob.js
CHANGED
|
@@ -5,15 +5,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
/**
|
|
6
6
|
* 将 blob 转成 data url
|
|
7
7
|
*/
|
|
8
|
-
function blobToDataURL(blob) {
|
|
9
|
-
return new Promise(function (resolve, reject) {
|
|
10
|
-
var reader = new FileReader();
|
|
11
|
-
reader.onload = function (_e) { return resolve(reader.result); };
|
|
12
|
-
reader.onerror = function (_e) { return reject(reader.error); };
|
|
13
|
-
reader.onabort = function (_e) { return reject(new Error('Read aborted')); };
|
|
14
|
-
reader.readAsDataURL(blob);
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
8
|
/**
|
|
18
9
|
* 下载 blob
|
|
19
10
|
* https://dev.to/nombrekeff/download-file-from-blob-21ho
|
|
@@ -40,5 +31,4 @@ function downloadBlob(blob, name) {
|
|
|
40
31
|
document.body.removeChild(link);
|
|
41
32
|
}
|
|
42
33
|
|
|
43
|
-
exports.blobToDataURL = blobToDataURL;
|
|
44
34
|
exports.downloadBlob = 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,215 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 处理颜色相关的函数,目前只支持 rgb
|
|
7
|
+
*/
|
|
8
|
+
// 颜色转换来自 https://gist.github.com/mjackson/5311256
|
|
9
|
+
function rgbToHsl(r, g, b) {
|
|
10
|
+
(r /= 255), (g /= 255), (b /= 255);
|
|
11
|
+
var max = Math.max(r, g, b), min = Math.min(r, g, b);
|
|
12
|
+
var h = 0, s, l = (max + min) / 2;
|
|
13
|
+
if (max == min) {
|
|
14
|
+
h = s = 0; // achromatic
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
var d = max - min;
|
|
18
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
19
|
+
switch (max) {
|
|
20
|
+
case r:
|
|
21
|
+
h = (g - b) / d + (g < b ? 6 : 0);
|
|
22
|
+
break;
|
|
23
|
+
case g:
|
|
24
|
+
h = (b - r) / d + 2;
|
|
25
|
+
break;
|
|
26
|
+
case b:
|
|
27
|
+
h = (r - g) / d + 4;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
h /= 6;
|
|
31
|
+
}
|
|
32
|
+
return { h: h, s: s, l: l };
|
|
33
|
+
}
|
|
34
|
+
function hue2rgb(p, q, t) {
|
|
35
|
+
if (t < 0)
|
|
36
|
+
t += 1;
|
|
37
|
+
if (t > 1)
|
|
38
|
+
t -= 1;
|
|
39
|
+
if (t < 1 / 6)
|
|
40
|
+
return p + (q - p) * 6 * t;
|
|
41
|
+
if (t < 1 / 2)
|
|
42
|
+
return q;
|
|
43
|
+
if (t < 2 / 3)
|
|
44
|
+
return p + (q - p) * (2 / 3 - t) * 6;
|
|
45
|
+
return p;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Converts an HSL color value to RGB. Conversion formula
|
|
49
|
+
* adapted from http://en.wikipedia.org/wiki/HSL_color_space.
|
|
50
|
+
* Assumes h, s, and l are contained in the set [0, 1] and
|
|
51
|
+
* returns r, g, and b in the set [0, 255].
|
|
52
|
+
*
|
|
53
|
+
* @param Number h The hue
|
|
54
|
+
* @param Number s The saturation
|
|
55
|
+
* @param Number l The lightness
|
|
56
|
+
* @return Array The RGB representation
|
|
57
|
+
*/
|
|
58
|
+
function hslToRgb(h, s, l) {
|
|
59
|
+
if (h > 1) {
|
|
60
|
+
h = h / 360;
|
|
61
|
+
}
|
|
62
|
+
var r, g, b;
|
|
63
|
+
if (s == 0) {
|
|
64
|
+
r = g = b = l; // achromatic
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
68
|
+
var p = 2 * l - q;
|
|
69
|
+
r = hue2rgb(p, q, h + 1 / 3);
|
|
70
|
+
g = hue2rgb(p, q, h);
|
|
71
|
+
b = hue2rgb(p, q, h - 1 / 3);
|
|
72
|
+
}
|
|
73
|
+
return { r: r * 255, g: g * 255, b: b * 255 };
|
|
74
|
+
}
|
|
75
|
+
function pad2(c) {
|
|
76
|
+
return c.length == 1 ? '0' + c : '' + c;
|
|
77
|
+
}
|
|
78
|
+
// `rgbToHex`
|
|
79
|
+
// Converts an RGB color to hex
|
|
80
|
+
// Assumes r, g, and b are contained in the set [0, 255]
|
|
81
|
+
// Returns a 3 or 6 character hex
|
|
82
|
+
function rgbToHex(r, g, b) {
|
|
83
|
+
var hex = [
|
|
84
|
+
pad2(Math.round(r).toString(16)),
|
|
85
|
+
pad2(Math.round(g).toString(16)),
|
|
86
|
+
pad2(Math.round(b).toString(16))
|
|
87
|
+
];
|
|
88
|
+
return hex.join('').toUpperCase();
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* 避免颜色值超出范围,适用于 rgb
|
|
92
|
+
*/
|
|
93
|
+
function toValidColor(c) {
|
|
94
|
+
return Math.min(Math.max(c, 0), 255);
|
|
95
|
+
}
|
|
96
|
+
var Color = /** @class */ (function () {
|
|
97
|
+
function Color(input) {
|
|
98
|
+
var m = input.match(/^#?([0-9a-f]{6})$/i);
|
|
99
|
+
if (m) {
|
|
100
|
+
this.r = parseInt(m[1].substring(0, 2), 16);
|
|
101
|
+
this.g = parseInt(m[1].substring(2, 4), 16);
|
|
102
|
+
this.b = parseInt(m[1].substring(4, 6), 16);
|
|
103
|
+
this.isValid = true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
Color.fromHSL = function (h, s, l) {
|
|
107
|
+
var rgb = hslToRgb(h, s, l);
|
|
108
|
+
return new Color("#".concat(rgbToHex(rgb.r, rgb.g, rgb.b)));
|
|
109
|
+
};
|
|
110
|
+
Color.fromRGB = function (r, g, b) {
|
|
111
|
+
var rgb = rgbToHex(r, g, b);
|
|
112
|
+
return new Color("#".concat(rgb));
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* 设置 lum
|
|
116
|
+
*/
|
|
117
|
+
Color.prototype.lum = function (l) {
|
|
118
|
+
return this.changeHsl(l, 'l', 'set');
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* 改变 lum 百分比,其实不太对,但差不太多
|
|
122
|
+
* @param l 百分比,比如 2 相当于 200 %
|
|
123
|
+
*/
|
|
124
|
+
Color.prototype.lumMod = function (l) {
|
|
125
|
+
return this.changeHsl(l, 'l', 'mod');
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* 改变百分比
|
|
129
|
+
* @param l 百分比,比如 -0.2 相当于减少 20 %
|
|
130
|
+
*/
|
|
131
|
+
Color.prototype.lumOff = function (l) {
|
|
132
|
+
return this.changeHsl(l, 'l', 'off');
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* h 取值范围是 0-1
|
|
136
|
+
*/
|
|
137
|
+
Color.prototype.hue = function (h) {
|
|
138
|
+
return this.changeHsl(h, 'h', 'set');
|
|
139
|
+
};
|
|
140
|
+
Color.prototype.hueMod = function (h) {
|
|
141
|
+
return this.changeHsl(h, 'h', 'mod');
|
|
142
|
+
};
|
|
143
|
+
Color.prototype.hueOff = function (h) {
|
|
144
|
+
return this.changeHsl(h, 'h', 'off');
|
|
145
|
+
};
|
|
146
|
+
Color.prototype.sat = function (s) {
|
|
147
|
+
return this.changeHsl(s, 's', 'set');
|
|
148
|
+
};
|
|
149
|
+
Color.prototype.satMod = function (s) {
|
|
150
|
+
return this.changeHsl(s, 's', 'mod');
|
|
151
|
+
};
|
|
152
|
+
Color.prototype.satOff = function (s) {
|
|
153
|
+
return this.changeHsl(s, 's', 'off');
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* 修改 hsl 中某个部分的值
|
|
157
|
+
*/
|
|
158
|
+
Color.prototype.changeHsl = function (num, com, changeType) {
|
|
159
|
+
var hsl = rgbToHsl(this.r, this.g, this.b);
|
|
160
|
+
if (changeType === 'set') {
|
|
161
|
+
hsl[com] = num;
|
|
162
|
+
}
|
|
163
|
+
else if (changeType === 'mod') {
|
|
164
|
+
hsl[com] = hsl[com] * num;
|
|
165
|
+
}
|
|
166
|
+
else if (changeType === 'off') {
|
|
167
|
+
hsl[com] += hsl[com] * num;
|
|
168
|
+
}
|
|
169
|
+
var rgb = hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
170
|
+
this.r = rgb.r;
|
|
171
|
+
this.g = rgb.g;
|
|
172
|
+
this.b = rgb.b;
|
|
173
|
+
return this;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* 互补色
|
|
177
|
+
*/
|
|
178
|
+
Color.prototype.comp = function () {
|
|
179
|
+
var hsl = rgbToHsl(this.r, this.g, this.b);
|
|
180
|
+
hsl.h = hsl.h + 0.5;
|
|
181
|
+
if (hsl.h > 1) {
|
|
182
|
+
hsl.h -= 1;
|
|
183
|
+
}
|
|
184
|
+
var rgb = hslToRgb(hsl.h, hsl.s, hsl.l);
|
|
185
|
+
this.r = rgb.r;
|
|
186
|
+
this.g = rgb.g;
|
|
187
|
+
this.b = rgb.b;
|
|
188
|
+
return this;
|
|
189
|
+
};
|
|
190
|
+
Color.prototype.shade = function (s) {
|
|
191
|
+
this.r = toValidColor(this.r - 256 * s);
|
|
192
|
+
this.g = toValidColor(this.g - 256 * s);
|
|
193
|
+
this.b = toValidColor(this.b - 256 * s);
|
|
194
|
+
};
|
|
195
|
+
Color.prototype.tint = function (t) {
|
|
196
|
+
this.r = toValidColor(this.r + 256 * t);
|
|
197
|
+
this.g = toValidColor(this.g + 256 * t);
|
|
198
|
+
this.b = toValidColor(this.b + 256 * t);
|
|
199
|
+
};
|
|
200
|
+
Color.prototype.inv = function () {
|
|
201
|
+
this.r = 255 - this.r;
|
|
202
|
+
this.g = 255 - this.g;
|
|
203
|
+
this.b = 255 - this.b;
|
|
204
|
+
return this;
|
|
205
|
+
};
|
|
206
|
+
Color.prototype.toHex = function () {
|
|
207
|
+
return '#' + rgbToHex(this.r, this.g, this.b);
|
|
208
|
+
};
|
|
209
|
+
Color.prototype.toRgba = function (alpha) {
|
|
210
|
+
return "rgba(".concat(this.r, ", ").concat(this.g, ", ").concat(this.b, ", ").concat(alpha, ")");
|
|
211
|
+
};
|
|
212
|
+
return Color;
|
|
213
|
+
}());
|
|
214
|
+
|
|
215
|
+
exports.Color = 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;
|