office-viewer 0.1.0 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/esm/OpenXML.d.ts +19 -0
- package/esm/OpenXML.js +43 -2
- package/esm/Word.d.ts +132 -15
- package/esm/Word.js +233 -54
- package/esm/openxml/ContentType.js +20 -6
- package/esm/openxml/Settings.d.ts +10 -0
- package/esm/openxml/Settings.js +93 -0
- package/esm/openxml/Style.d.ts +1 -1
- package/esm/openxml/Style.js +12 -12
- package/esm/openxml/Theme.js +30 -6
- package/esm/openxml/Types.d.ts +179 -2472
- package/esm/openxml/drawing/Blip.d.ts +7 -0
- package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
- package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
- package/esm/openxml/drawing/CustomGeom.js +17 -0
- package/esm/openxml/drawing/Drawing.d.ts +35 -0
- package/esm/openxml/drawing/Drawing.js +169 -0
- package/esm/openxml/drawing/Geom.d.ts +11 -0
- package/esm/openxml/drawing/Geom.js +34 -0
- package/esm/openxml/drawing/Path.d.ts +37 -0
- package/esm/openxml/drawing/Pic.d.ts +16 -0
- package/esm/openxml/drawing/Pic.js +26 -0
- package/esm/openxml/drawing/Shape.d.ts +20 -0
- package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/esm/openxml/drawing/ShapeProperties.js +119 -0
- package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +2 -1
- package/esm/openxml/{word/drawing → drawing}/Transform.js +7 -3
- package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/esm/openxml/drawing/diagram/Diagram.js +24 -0
- package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/esm/openxml/drawing/presetShape.d.ts +3 -0
- package/esm/openxml/drawing/presetShape.js +38785 -0
- package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/esm/openxml/drawing/svg/arcToA.js +88 -0
- package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
- package/esm/openxml/drawing/svg/formulas.js +103 -0
- package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/esm/openxml/drawing/svg/generateDefines.js +144 -0
- package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/esm/openxml/drawing/svg/presetVal.js +53 -0
- package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
- package/esm/openxml/math/OMath.d.ts +5 -0
- package/esm/openxml/math/OMath.js +12 -0
- package/esm/openxml/math/convertOOML.d.ts +4 -0
- package/esm/openxml/math/convertOOML.js +13 -0
- package/esm/openxml/math/xsl.d.ts +4 -0
- package/esm/openxml/math/xsl.js +8 -0
- package/esm/openxml/word/Body.js +11 -7
- package/esm/openxml/word/Break.js +1 -3
- package/esm/openxml/word/Font.d.ts +16 -0
- package/esm/openxml/word/Font.js +78 -0
- package/esm/openxml/word/FontTable.d.ts +9 -0
- package/esm/openxml/word/FontTable.js +34 -0
- package/esm/openxml/word/Header.d.ts +11 -0
- package/esm/openxml/word/Header.js +54 -0
- package/esm/openxml/word/Hyperlink.d.ts +1 -0
- package/esm/openxml/word/Hyperlink.js +7 -3
- package/esm/openxml/word/InlineText.js +1 -1
- package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/esm/openxml/word/NoBreakHyphen.js +7 -0
- package/esm/openxml/word/Note.d.ts +12 -0
- package/esm/openxml/word/Note.js +48 -0
- package/esm/openxml/word/Paragraph.d.ts +2 -2
- package/esm/openxml/word/Paragraph.js +10 -9
- package/esm/openxml/word/Pict.d.ts +1 -2
- package/esm/openxml/word/Pict.js +5 -3
- package/esm/openxml/word/Ruby.js +1 -1
- package/esm/openxml/word/Run.d.ts +7 -3
- package/esm/openxml/word/Run.js +28 -4
- package/esm/openxml/word/Section.d.ts +18 -5
- package/esm/openxml/word/Section.js +46 -2
- package/esm/openxml/word/Separator.d.ts +5 -0
- package/esm/openxml/word/Separator.js +10 -0
- package/esm/openxml/word/SoftHyphen.d.ts +5 -0
- package/esm/openxml/word/SoftHyphen.js +10 -0
- package/esm/openxml/word/Table.d.ts +4 -9
- package/esm/openxml/word/Table.js +0 -235
- package/esm/openxml/word/WDocument.d.ts +1 -2
- package/esm/openxml/word/WDocument.js +53 -7
- package/esm/openxml/word/numbering/AbstractNum.js +4 -2
- package/esm/openxml/word/numbering/Lvl.js +10 -4
- package/esm/openxml/word/numbering/Num.js +12 -4
- package/esm/openxml/word/numbering/NumberProperties.js +2 -2
- package/esm/openxml/word/numbering/Numbering.js +1 -1
- package/esm/openxml/word/table/Tc.d.ts +1 -22
- package/esm/openxml/word/table/Tc.js +1 -221
- package/esm/openxml/word/table/Tr.d.ts +0 -5
- package/esm/openxml/word/table/Tr.js +0 -97
- package/esm/openxml/word/wps/WPG.d.ts +5 -0
- package/esm/openxml/word/wps/WPS.d.ts +18 -0
- package/esm/openxml/word/wps/WPS.js +147 -0
- package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/esm/openxml/word/wps/WPSStyle.js +42 -0
- package/esm/package/PackageParser.d.ts +1 -1
- package/esm/package/XMLPackageParser.d.ts +3 -3
- package/esm/package/ZipPackageParser.d.ts +1 -1
- package/esm/package/ZipPackageParser.js +7 -8
- package/esm/parse/Footnotes.d.ts +3 -0
- package/esm/parse/Footnotes.js +25 -0
- package/esm/parse/colorNameMap.d.ts +6 -0
- package/esm/parse/colorNameMap.js +201 -0
- package/esm/parse/jcToTextAlign.js +1 -0
- package/esm/parse/mergeSdt.d.ts +4 -0
- package/esm/parse/mergeSdt.js +57 -0
- package/esm/parse/modifyColor.d.ts +1 -0
- package/esm/parse/modifyColor.js +106 -0
- package/esm/parse/parseBorder.js +2 -21
- package/esm/parse/parseCellMargin.d.ts +2 -0
- package/esm/parse/parseCellMargin.js +38 -0
- package/esm/parse/parseChildColor.d.ts +5 -0
- package/esm/parse/parseChildColor.js +66 -0
- package/esm/parse/parseColor.d.ts +4 -0
- package/esm/parse/parseColor.js +41 -46
- package/esm/parse/parseEndnotes.d.ts +3 -0
- package/esm/parse/parseEndnotes.js +25 -0
- package/esm/parse/parseFont.js +1 -1
- package/esm/parse/parseInsideBorders.d.ts +9 -0
- package/esm/parse/parseInsideBorders.js +24 -0
- package/esm/parse/parsePr.d.ts +3 -0
- package/esm/parse/parsePr.js +108 -11
- package/esm/parse/parseRelationship.js +1 -1
- package/esm/parse/parseSdt.d.ts +5 -0
- package/esm/parse/parseShape.d.ts +10 -0
- package/esm/parse/parseShape.js +239 -0
- package/esm/parse/parseSize.d.ts +2 -1
- package/esm/parse/parseSize.js +7 -1
- package/esm/parse/parseSpacing.js +1 -1
- package/esm/parse/parseTable.d.ts +3 -0
- package/esm/parse/parseTable.js +62 -0
- package/esm/parse/parseTablePr.d.ts +3 -0
- package/esm/parse/parseTablePr.js +185 -0
- package/esm/parse/parseTblWidth.d.ts +4 -0
- package/esm/parse/parseTblWidth.js +23 -0
- package/esm/parse/parseTc.d.ts +10 -0
- package/esm/parse/parseTc.js +64 -0
- package/esm/parse/parseTcPr.d.ts +5 -0
- package/esm/parse/parseTcPr.js +99 -0
- package/esm/parse/parseTextDirection.js +4 -6
- package/esm/parse/parseTr.d.ts +6 -0
- package/esm/parse/parseTr.js +49 -0
- package/esm/parse/parseTrPr.d.ts +3 -0
- package/esm/parse/parseTrPr.js +59 -0
- package/esm/render/fixAbsolutePosition.d.ts +8 -0
- package/esm/render/renderBody.d.ts +6 -2
- package/esm/render/renderBody.js +184 -30
- package/esm/render/renderBr.d.ts +2 -1
- package/esm/render/renderBr.js +4 -1
- package/esm/render/renderCustGeom.d.ts +4 -0
- package/esm/render/renderCustGeom.js +10 -0
- package/esm/render/renderDocument.d.ts +2 -2
- package/esm/render/renderDocument.js +2 -2
- package/esm/render/renderDrawing.d.ts +3 -2
- package/esm/render/renderDrawing.js +129 -24
- package/esm/render/renderFont.d.ts +5 -0
- package/esm/render/renderFont.js +39 -0
- package/esm/render/renderGeom.d.ts +4 -0
- package/esm/render/renderGeom.js +14 -0
- package/esm/render/renderHeader.d.ts +6 -0
- package/esm/render/renderHeader.js +40 -0
- package/esm/render/renderHyperLink.js +4 -1
- package/esm/render/renderInlineText.js +1 -1
- package/esm/render/renderInstrText.js +1 -1
- package/esm/render/renderMath.d.ts +3 -0
- package/esm/render/renderMath.js +7 -0
- package/esm/render/renderNoBreakHyphen.d.ts +1 -0
- package/esm/render/renderNoBreakHyphen.js +9 -0
- package/esm/render/renderNotes.d.ts +5 -0
- package/esm/render/renderNotes.js +77 -0
- package/esm/render/renderNumbering.js +8 -10
- package/esm/render/renderParagraph.d.ts +1 -1
- package/esm/render/renderParagraph.js +26 -29
- package/esm/render/renderPict.js +5 -10
- package/esm/render/renderRuby.js +1 -1
- package/esm/render/renderRun.d.ts +4 -2
- package/esm/render/renderRun.js +35 -10
- package/esm/render/renderSection.d.ts +3 -2
- package/esm/render/renderSection.js +79 -5
- package/esm/render/renderSeparator.d.ts +1 -0
- package/esm/render/renderSeparator.js +9 -0
- package/esm/render/renderSoftHyphen.d.ts +1 -0
- package/esm/render/renderSoftHyphen.js +9 -0
- package/esm/render/renderStyle.js +36 -35
- package/esm/render/renderTab.d.ts +1 -0
- package/esm/render/renderTab.js +4 -6
- package/esm/render/renderTable.js +23 -20
- package/esm/render/setElementStyle.js +7 -2
- package/esm/render/zindex.d.ts +1 -0
- package/esm/util/blob.js +1 -10
- package/esm/util/color.d.ts +48 -0
- package/esm/util/color.js +211 -0
- package/esm/util/createObject.d.ts +10 -0
- package/esm/util/createObject.js +48 -0
- package/esm/util/dom.d.ts +8 -4
- package/esm/util/dom.js +21 -4
- package/esm/util/mergeRun.js +1 -1
- package/esm/util/parseSides.d.ts +11 -0
- package/esm/util/print.d.ts +5 -0
- package/esm/util/print.js +54 -0
- package/esm/util/replaceVar.d.ts +10 -0
- package/esm/util/replaceVar.js +214 -0
- package/esm/util/xml.js +4 -1
- package/lib/OpenXML.d.ts +19 -0
- package/lib/OpenXML.js +44 -1
- package/lib/Word.d.ts +132 -15
- package/lib/Word.js +238 -59
- package/lib/openxml/ContentType.js +20 -6
- package/lib/openxml/Settings.d.ts +10 -0
- package/lib/openxml/Settings.js +97 -0
- package/lib/openxml/Style.d.ts +1 -1
- package/lib/openxml/Style.js +15 -15
- package/lib/openxml/Theme.js +31 -7
- package/lib/openxml/Types.d.ts +179 -2472
- package/lib/openxml/drawing/Blip.d.ts +7 -0
- package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
- package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
- package/lib/openxml/drawing/CustomGeom.js +21 -0
- package/lib/openxml/drawing/Drawing.d.ts +35 -0
- package/lib/openxml/drawing/Drawing.js +173 -0
- package/lib/openxml/drawing/Geom.d.ts +11 -0
- package/lib/openxml/drawing/Geom.js +38 -0
- package/lib/openxml/drawing/Path.d.ts +37 -0
- package/lib/openxml/drawing/Pic.d.ts +16 -0
- package/lib/openxml/drawing/Pic.js +30 -0
- package/lib/openxml/drawing/Shape.d.ts +20 -0
- package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/lib/openxml/drawing/ShapeProperties.js +123 -0
- package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +2 -1
- package/lib/openxml/{word/drawing → drawing}/Transform.js +7 -3
- package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/lib/openxml/drawing/diagram/Diagram.js +28 -0
- package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/lib/openxml/drawing/presetShape.d.ts +3 -0
- package/lib/openxml/drawing/presetShape.js +38789 -0
- package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/lib/openxml/drawing/svg/arcToA.js +92 -0
- package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
- package/lib/openxml/drawing/svg/formulas.js +108 -0
- package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/lib/openxml/drawing/svg/generateDefines.js +148 -0
- package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/lib/openxml/drawing/svg/presetVal.js +57 -0
- package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
- package/lib/openxml/math/OMath.d.ts +5 -0
- package/lib/openxml/math/OMath.js +16 -0
- package/lib/openxml/math/convertOOML.d.ts +4 -0
- package/lib/openxml/math/convertOOML.js +17 -0
- package/lib/openxml/math/xsl.d.ts +4 -0
- package/lib/openxml/math/xsl.js +12 -0
- package/lib/openxml/word/Body.js +11 -7
- package/lib/openxml/word/Break.js +1 -3
- package/lib/openxml/word/Font.d.ts +16 -0
- package/lib/openxml/word/Font.js +83 -0
- package/lib/openxml/word/FontTable.d.ts +9 -0
- package/lib/openxml/word/FontTable.js +38 -0
- package/lib/openxml/word/Header.d.ts +11 -0
- package/lib/openxml/word/Header.js +58 -0
- package/lib/openxml/word/Hyperlink.d.ts +1 -0
- package/lib/openxml/word/Hyperlink.js +8 -4
- package/lib/openxml/word/InlineText.js +2 -2
- package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/lib/openxml/word/NoBreakHyphen.js +11 -0
- package/lib/openxml/word/Note.d.ts +12 -0
- package/lib/openxml/word/Note.js +52 -0
- package/lib/openxml/word/Paragraph.d.ts +2 -2
- package/lib/openxml/word/Paragraph.js +11 -10
- package/lib/openxml/word/Pict.d.ts +1 -2
- package/lib/openxml/word/Pict.js +5 -3
- package/lib/openxml/word/Ruby.js +4 -4
- package/lib/openxml/word/Run.d.ts +7 -3
- package/lib/openxml/word/Run.js +29 -5
- package/lib/openxml/word/Section.d.ts +18 -5
- package/lib/openxml/word/Section.js +47 -3
- package/lib/openxml/word/Separator.d.ts +5 -0
- package/lib/openxml/word/Separator.js +14 -0
- package/lib/openxml/word/SoftHyphen.d.ts +5 -0
- package/lib/openxml/word/SoftHyphen.js +14 -0
- package/lib/openxml/word/Table.d.ts +4 -9
- package/lib/openxml/word/Table.js +0 -235
- package/lib/openxml/word/WDocument.d.ts +1 -2
- package/lib/openxml/word/WDocument.js +53 -7
- package/lib/openxml/word/numbering/AbstractNum.js +5 -3
- package/lib/openxml/word/numbering/Lvl.js +11 -5
- package/lib/openxml/word/numbering/Num.js +12 -4
- package/lib/openxml/word/numbering/NumberProperties.js +2 -2
- package/lib/openxml/word/numbering/Numbering.js +3 -3
- package/lib/openxml/word/table/Tc.d.ts +1 -22
- package/lib/openxml/word/table/Tc.js +0 -224
- package/lib/openxml/word/table/Tr.d.ts +0 -5
- package/lib/openxml/word/table/Tr.js +0 -97
- package/lib/openxml/word/wps/WPG.d.ts +5 -0
- package/lib/openxml/word/wps/WPS.d.ts +18 -0
- package/lib/openxml/word/wps/WPS.js +151 -0
- package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/lib/openxml/word/wps/WPSStyle.js +46 -0
- package/lib/package/PackageParser.d.ts +1 -1
- package/lib/package/XMLPackageParser.d.ts +3 -3
- package/lib/package/ZipPackageParser.d.ts +1 -1
- package/lib/package/ZipPackageParser.js +7 -8
- package/lib/parse/Footnotes.d.ts +3 -0
- package/lib/parse/Footnotes.js +29 -0
- package/lib/parse/colorNameMap.d.ts +6 -0
- package/lib/parse/colorNameMap.js +205 -0
- package/lib/parse/jcToTextAlign.js +1 -0
- package/lib/parse/mergeSdt.d.ts +4 -0
- package/lib/parse/mergeSdt.js +61 -0
- package/lib/parse/modifyColor.d.ts +1 -0
- package/lib/parse/modifyColor.js +110 -0
- package/lib/parse/parseBorder.js +3 -22
- package/lib/parse/parseCellMargin.d.ts +2 -0
- package/lib/parse/parseCellMargin.js +42 -0
- package/lib/parse/parseChildColor.d.ts +5 -0
- package/lib/parse/parseChildColor.js +70 -0
- package/lib/parse/parseColor.d.ts +4 -0
- package/lib/parse/parseColor.js +41 -45
- package/lib/parse/parseEndnotes.d.ts +3 -0
- package/lib/parse/parseEndnotes.js +29 -0
- package/lib/parse/parseFont.js +2 -2
- package/lib/parse/parseInsideBorders.d.ts +9 -0
- package/lib/parse/parseInsideBorders.js +28 -0
- package/lib/parse/parsePr.d.ts +3 -0
- package/lib/parse/parsePr.js +109 -12
- package/lib/parse/parseRelationship.js +2 -2
- package/lib/parse/parseSdt.d.ts +5 -0
- package/lib/parse/parseShape.d.ts +10 -0
- package/lib/parse/parseShape.js +247 -0
- package/lib/parse/parseSize.d.ts +2 -1
- package/lib/parse/parseSize.js +7 -0
- package/lib/parse/parseSpacing.js +1 -1
- package/lib/parse/parseTable.d.ts +3 -0
- package/lib/parse/parseTable.js +66 -0
- package/lib/parse/parseTablePr.d.ts +3 -0
- package/lib/parse/parseTablePr.js +189 -0
- package/lib/parse/parseTblWidth.d.ts +4 -0
- package/lib/parse/parseTblWidth.js +27 -0
- package/lib/parse/parseTc.d.ts +10 -0
- package/lib/parse/parseTc.js +68 -0
- package/lib/parse/parseTcPr.d.ts +5 -0
- package/lib/parse/parseTcPr.js +104 -0
- package/lib/parse/parseTextDirection.js +4 -6
- package/lib/parse/parseTr.d.ts +6 -0
- package/lib/parse/parseTr.js +53 -0
- package/lib/parse/parseTrPr.d.ts +3 -0
- package/lib/parse/parseTrPr.js +63 -0
- package/lib/render/fixAbsolutePosition.d.ts +8 -0
- package/lib/render/renderBody.d.ts +6 -2
- package/lib/render/renderBody.js +183 -29
- package/lib/render/renderBr.d.ts +2 -1
- package/lib/render/renderBr.js +4 -1
- package/lib/render/renderCustGeom.d.ts +4 -0
- package/lib/render/renderCustGeom.js +14 -0
- package/lib/render/renderDocument.d.ts +2 -2
- package/lib/render/renderDocument.js +2 -2
- package/lib/render/renderDrawing.d.ts +3 -2
- package/lib/render/renderDrawing.js +129 -24
- package/lib/render/renderFont.d.ts +5 -0
- package/lib/render/renderFont.js +43 -0
- package/lib/render/renderGeom.d.ts +4 -0
- package/lib/render/renderGeom.js +18 -0
- package/lib/render/renderHeader.d.ts +6 -0
- package/lib/render/renderHeader.js +44 -0
- package/lib/render/renderHyperLink.js +5 -2
- package/lib/render/renderInlineText.js +2 -2
- package/lib/render/renderInstrText.js +2 -2
- package/lib/render/renderMath.d.ts +3 -0
- package/lib/render/renderMath.js +11 -0
- package/lib/render/renderNoBreakHyphen.d.ts +1 -0
- package/lib/render/renderNoBreakHyphen.js +13 -0
- package/lib/render/renderNotes.d.ts +5 -0
- package/lib/render/renderNotes.js +81 -0
- package/lib/render/renderNumbering.js +9 -11
- package/lib/render/renderParagraph.d.ts +1 -1
- package/lib/render/renderParagraph.js +26 -29
- package/lib/render/renderPict.js +5 -10
- package/lib/render/renderRuby.js +3 -3
- package/lib/render/renderRun.d.ts +4 -2
- package/lib/render/renderRun.js +34 -9
- package/lib/render/renderSection.d.ts +3 -2
- package/lib/render/renderSection.js +79 -5
- package/lib/render/renderSeparator.d.ts +1 -0
- package/lib/render/renderSeparator.js +13 -0
- package/lib/render/renderSoftHyphen.d.ts +1 -0
- package/lib/render/renderSoftHyphen.js +13 -0
- package/lib/render/renderStyle.js +37 -36
- package/lib/render/renderTab.d.ts +1 -0
- package/lib/render/renderTab.js +4 -6
- package/lib/render/renderTable.js +25 -22
- package/lib/render/setElementStyle.js +6 -1
- package/lib/render/zindex.d.ts +1 -0
- package/lib/util/blob.js +0 -10
- package/lib/util/color.d.ts +48 -0
- package/lib/util/color.js +215 -0
- package/lib/util/createObject.d.ts +10 -0
- package/lib/util/createObject.js +54 -0
- package/lib/util/dom.d.ts +8 -4
- package/lib/util/dom.js +24 -5
- package/lib/util/mergeRun.js +5 -5
- package/lib/util/parseSides.d.ts +11 -0
- package/lib/util/print.d.ts +5 -0
- package/lib/util/print.js +58 -0
- package/lib/util/replaceVar.d.ts +10 -0
- package/lib/util/replaceVar.js +219 -0
- package/lib/util/xml.js +4 -0
- package/package.json +17 -6
- package/esm/node_modules/tslib/tslib.es6.js +0 -120
- package/esm/openxml/Types.js +0 -1003
- package/esm/openxml/word/CustomXml.d.ts +0 -8
- package/esm/openxml/word/SmartTag.d.ts +0 -8
- package/esm/openxml/word/SmartTag.js +0 -18
- package/esm/openxml/word/drawing/Blip.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.js +0 -15
- package/esm/openxml/word/drawing/Pic.d.ts +0 -8
- package/esm/openxml/word/drawing/Pic.js +0 -16
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
- package/lib/node_modules/tslib/tslib.es6.js +0 -129
- package/lib/openxml/Types.js +0 -1005
- package/lib/openxml/word/CustomXml.d.ts +0 -8
- package/lib/openxml/word/SmartTag.d.ts +0 -8
- package/lib/openxml/word/SmartTag.js +0 -22
- package/lib/openxml/word/drawing/Blip.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.js +0 -19
- package/lib/openxml/word/drawing/Pic.d.ts +0 -8
- package/lib/openxml/word/drawing/Pic.js +0 -20
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
package/esm/render/renderRun.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { __values } from '
|
|
1
|
+
import { __values } from 'tslib';
|
|
2
2
|
import { renderBr } from './renderBr.js';
|
|
3
|
-
import { createElement, appendChild } from '../util/dom.js';
|
|
3
|
+
import { createElement, applyStyle, appendChild } from '../util/dom.js';
|
|
4
4
|
import { Text } from '../openxml/word/Run.js';
|
|
5
5
|
import { Break } from '../openxml/word/Break.js';
|
|
6
|
-
import { Drawing } from '../openxml/
|
|
6
|
+
import { Drawing } from '../openxml/drawing/Drawing.js';
|
|
7
7
|
import { renderDrawing } from './renderDrawing.js';
|
|
8
8
|
import { setElementStyle } from './setElementStyle.js';
|
|
9
9
|
import { Tab } from '../openxml/word/Tab.js';
|
|
@@ -17,6 +17,12 @@ import { renderInstrText } from './renderInstrText.js';
|
|
|
17
17
|
import { Sym } from '../openxml/word/Sym.js';
|
|
18
18
|
import { renderSym } from './renderSym.js';
|
|
19
19
|
import { cjkspace } from '../util/autoSpace.js';
|
|
20
|
+
import { renderSoftHyphen } from './renderSoftHyphen.js';
|
|
21
|
+
import { SoftHyphen } from '../openxml/word/SoftHyphen.js';
|
|
22
|
+
import { NoBreakHyphen } from '../openxml/word/NoBreakHyphen.js';
|
|
23
|
+
import { renderNoBreakHyphen } from './renderNoBreakHyphen.js';
|
|
24
|
+
import { Separator } from '../openxml/word/Separator.js';
|
|
25
|
+
import { renderSeparator } from './renderSeparator.js';
|
|
20
26
|
|
|
21
27
|
/**
|
|
22
28
|
* run 相关的 http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/Run_1.html
|
|
@@ -56,31 +62,41 @@ function updateVariableText(word) {
|
|
|
56
62
|
}
|
|
57
63
|
/**
|
|
58
64
|
* 渲染 run 节点
|
|
65
|
+
*
|
|
66
|
+
* @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
|
|
59
67
|
*/
|
|
60
|
-
function renderRun(word, run, paragraph) {
|
|
68
|
+
function renderRun(word, run, paragraph, inFldChar, inHeader) {
|
|
61
69
|
var e_1, _a;
|
|
70
|
+
var _b, _c;
|
|
62
71
|
var span = createElement('span');
|
|
63
72
|
word.addClass(span, 'r');
|
|
64
73
|
setElementStyle(word, span, run.properties);
|
|
74
|
+
// run 不好通过 class 来设置 rStyle,所以单独支持一下
|
|
75
|
+
if ((_b = run.properties) === null || _b === void 0 ? void 0 : _b.rStyle) {
|
|
76
|
+
var style = word.getStyle(run.properties.rStyle);
|
|
77
|
+
if ((_c = style === null || style === void 0 ? void 0 : style.rPr) === null || _c === void 0 ? void 0 : _c.cssStyle) {
|
|
78
|
+
applyStyle(span, style.rPr.cssStyle);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
65
81
|
if (run.children.length === 1 && run.children[0] instanceof Text) {
|
|
66
82
|
var text = run.children[0];
|
|
67
83
|
renderText(span, word, text.text, paragraph);
|
|
68
84
|
}
|
|
69
85
|
else {
|
|
70
86
|
try {
|
|
71
|
-
for (var
|
|
72
|
-
var child =
|
|
87
|
+
for (var _d = __values(run.children), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
88
|
+
var child = _e.value;
|
|
73
89
|
if (child instanceof Text) {
|
|
74
90
|
var newSpan = createElement('span');
|
|
75
|
-
renderText(
|
|
91
|
+
renderText(newSpan, word, child.text, paragraph);
|
|
76
92
|
appendChild(span, newSpan);
|
|
77
93
|
}
|
|
78
94
|
else if (child instanceof Break) {
|
|
79
|
-
var br = renderBr(child);
|
|
95
|
+
var br = renderBr(word, child);
|
|
80
96
|
appendChild(span, br);
|
|
81
97
|
}
|
|
82
98
|
else if (child instanceof Drawing) {
|
|
83
|
-
appendChild(span, renderDrawing(word, child));
|
|
99
|
+
appendChild(span, renderDrawing(word, child, inHeader));
|
|
84
100
|
}
|
|
85
101
|
else if (child instanceof Tab) {
|
|
86
102
|
appendChild(span, renderTab(word, child));
|
|
@@ -97,6 +113,15 @@ function renderRun(word, run, paragraph) {
|
|
|
97
113
|
else if (child instanceof Sym) {
|
|
98
114
|
appendChild(span, renderSym(word, child));
|
|
99
115
|
}
|
|
116
|
+
else if (child instanceof SoftHyphen) {
|
|
117
|
+
appendChild(span, renderSoftHyphen());
|
|
118
|
+
}
|
|
119
|
+
else if (child instanceof NoBreakHyphen) {
|
|
120
|
+
appendChild(span, renderNoBreakHyphen());
|
|
121
|
+
}
|
|
122
|
+
else if (child instanceof Separator) {
|
|
123
|
+
appendChild(span, renderSeparator());
|
|
124
|
+
}
|
|
100
125
|
else {
|
|
101
126
|
console.warn('unknown child', child);
|
|
102
127
|
}
|
|
@@ -105,7 +130,7 @@ function renderRun(word, run, paragraph) {
|
|
|
105
130
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
106
131
|
finally {
|
|
107
132
|
try {
|
|
108
|
-
if (
|
|
133
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
109
134
|
}
|
|
110
135
|
finally { if (e_1) throw e_1.error; }
|
|
111
136
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { WDocument } from '../openxml/word/WDocument';
|
|
1
2
|
import { Section } from '../openxml/word/Section';
|
|
2
|
-
import Word from '../Word';
|
|
3
|
+
import Word, { WordRenderOptions } from '../Word';
|
|
3
4
|
/**
|
|
4
5
|
* 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
|
|
5
6
|
*/
|
|
6
|
-
export declare function renderSection(word: Word, section: Section): HTMLElement;
|
|
7
|
+
export declare function renderSection(word: Word, wDocument: WDocument, section: Section, renderOptions: WordRenderOptions): HTMLElement;
|
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import { createElement } from '../util/dom.js';
|
|
2
|
+
import { renderHeader } from './renderHeader.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 渲染「节」,在 word 中每个节都可以有自己的页边距和页面大小设置,但目前其实并没有实现分页展现,等后续再考虑
|
|
5
6
|
*/
|
|
6
|
-
function renderSection(word, section) {
|
|
7
|
+
function renderSection(word, wDocument, section, renderOptions) {
|
|
7
8
|
var sectionEl = createElement('section');
|
|
8
9
|
// 用于后续绝对定位
|
|
9
10
|
sectionEl.style.position = 'relative';
|
|
11
|
+
if (wDocument.backgroundColor) {
|
|
12
|
+
sectionEl.style.background = wDocument.backgroundColor;
|
|
13
|
+
}
|
|
14
|
+
if (renderOptions.page) {
|
|
15
|
+
if (renderOptions.pageMarginBottom) {
|
|
16
|
+
sectionEl.style.marginBottom = renderOptions.pageMarginBottom + 'px';
|
|
17
|
+
}
|
|
18
|
+
if (renderOptions.pageShadow) {
|
|
19
|
+
sectionEl.style.boxShadow = '0 0 8px rgba(0, 0, 0, 0.5)';
|
|
20
|
+
}
|
|
21
|
+
if (renderOptions.pageBackground) {
|
|
22
|
+
sectionEl.style.background = renderOptions.pageBackground;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
10
25
|
var props = section.properties;
|
|
11
26
|
var pageSize = props.pageSize;
|
|
12
27
|
if (pageSize) {
|
|
13
|
-
if (!
|
|
28
|
+
if (!renderOptions.ignoreWidth) {
|
|
14
29
|
sectionEl.style.width = pageSize.width;
|
|
15
30
|
}
|
|
16
|
-
if (!
|
|
31
|
+
if (!renderOptions.ignoreHeight) {
|
|
17
32
|
sectionEl.style.height = pageSize.height;
|
|
18
33
|
}
|
|
19
34
|
}
|
|
20
35
|
// 强制控制 padding
|
|
21
|
-
if (
|
|
22
|
-
sectionEl.style.padding =
|
|
36
|
+
if (renderOptions.padding) {
|
|
37
|
+
sectionEl.style.padding = renderOptions.padding;
|
|
23
38
|
}
|
|
24
39
|
else {
|
|
25
40
|
var pageMargin = props.pageMargin;
|
|
@@ -30,6 +45,65 @@ function renderSection(word, section) {
|
|
|
30
45
|
sectionEl.style.paddingBottom = pageMargin.bottom || '0';
|
|
31
46
|
}
|
|
32
47
|
}
|
|
48
|
+
if (props.cols) {
|
|
49
|
+
if (props.cols.num && props.cols.num > 1) {
|
|
50
|
+
sectionEl.style.columnCount = '' + props.cols.num;
|
|
51
|
+
if (props.cols.space) {
|
|
52
|
+
sectionEl.style.columnGap = props.cols.space;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
word.currentPage++;
|
|
57
|
+
var width = 'auto';
|
|
58
|
+
if (props.pageSize && props.pageSize.width) {
|
|
59
|
+
width = props.pageSize.width;
|
|
60
|
+
}
|
|
61
|
+
// 只有在分页模式下才渲染页眉
|
|
62
|
+
if (props.headers && renderOptions.page && renderOptions.renderHeader) {
|
|
63
|
+
var headers = props.headers;
|
|
64
|
+
var headerEl = null;
|
|
65
|
+
if (headers.even && word.currentPage % 2 === 0) {
|
|
66
|
+
headerEl = renderHeader(word, headers.even);
|
|
67
|
+
}
|
|
68
|
+
else if (headers.default) {
|
|
69
|
+
headerEl = renderHeader(word, headers.default);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.warn('can not find header', word.currentPage, props.headers);
|
|
73
|
+
}
|
|
74
|
+
if (headerEl) {
|
|
75
|
+
headerEl.style.position = 'absolute';
|
|
76
|
+
var pageMargin = props.pageMargin;
|
|
77
|
+
// todo: 在 word 里如果 header 内容较多会将内容区也撑开,但目前实现不了
|
|
78
|
+
if (pageMargin && pageMargin.header) {
|
|
79
|
+
headerEl.style.top = pageMargin.header;
|
|
80
|
+
headerEl.style.width = width;
|
|
81
|
+
}
|
|
82
|
+
sectionEl.appendChild(headerEl);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (props.footers && renderOptions.page && renderOptions.renderFooter) {
|
|
86
|
+
var footers = props.footers;
|
|
87
|
+
var footerEl = null;
|
|
88
|
+
if (footers.even && word.currentPage % 2 === 0) {
|
|
89
|
+
footerEl = renderHeader(word, footers.even);
|
|
90
|
+
}
|
|
91
|
+
else if (footers.default) {
|
|
92
|
+
footerEl = renderHeader(word, footers.default);
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
console.warn('can not find footer', word.currentPage, props.footers);
|
|
96
|
+
}
|
|
97
|
+
if (footerEl) {
|
|
98
|
+
footerEl.style.position = 'absolute';
|
|
99
|
+
var pageMargin = props.pageMargin;
|
|
100
|
+
if (pageMargin && pageMargin.footer) {
|
|
101
|
+
footerEl.style.bottom = pageMargin.footer;
|
|
102
|
+
footerEl.style.width = width;
|
|
103
|
+
}
|
|
104
|
+
sectionEl.appendChild(footerEl);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
33
107
|
return sectionEl;
|
|
34
108
|
}
|
|
35
109
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderSeparator(): HTMLElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderSoftHyphen(): HTMLElement;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { __values } from '
|
|
2
|
-
import { ST_TblStyleOverrideType } from '../openxml/Types.js';
|
|
1
|
+
import { __values } from 'tslib';
|
|
3
2
|
import { styleToText, createElement } from '../util/dom.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -9,6 +8,7 @@ import { styleToText, createElement } from '../util/dom.js';
|
|
|
9
8
|
* 文档基础默认样式
|
|
10
9
|
*/
|
|
11
10
|
function generateDefaultStyle(word) {
|
|
11
|
+
var _a;
|
|
12
12
|
var styles = word.styles;
|
|
13
13
|
var defaultStyle = styles.defaultStyle;
|
|
14
14
|
var defaultPStyle = '';
|
|
@@ -19,8 +19,9 @@ function generateDefaultStyle(word) {
|
|
|
19
19
|
if (defaultStyle === null || defaultStyle === void 0 ? void 0 : defaultStyle.rPr) {
|
|
20
20
|
defaultRStyle = styleToText(defaultStyle.rPr.cssStyle);
|
|
21
21
|
}
|
|
22
|
+
var hyphens = ((_a = word.settings) === null || _a === void 0 ? void 0 : _a.autoHyphenation) ? 'hyphens: auto;' : '';
|
|
22
23
|
var classPrefix = word.getClassPrefix();
|
|
23
|
-
return "\n .".concat(
|
|
24
|
+
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 white-space: pre-wrap;\n overflow-wrap: break-word;\n ").concat(defaultRStyle, "\n }\n ");
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* 生成表格级别样式
|
|
@@ -50,81 +51,81 @@ function generateTableStyle(classPrefix, styleDisplayId, style) {
|
|
|
50
51
|
return tblStyleText;
|
|
51
52
|
}
|
|
52
53
|
// 用于生成表格 override 相关的样式,用于行或列
|
|
53
|
-
function genTblOverrideStyle(
|
|
54
|
+
function genTblOverrideStyle(tblPrefix, classPrefix, overrideType, tblStylePrStyle) {
|
|
54
55
|
var _a, _b, _c, _d, _e, _f;
|
|
55
56
|
var styleText = '';
|
|
56
57
|
var trStyle = styleToText((_a = tblStylePrStyle.trPr) === null || _a === void 0 ? void 0 : _a.cssStyle);
|
|
57
58
|
var enableType = '';
|
|
58
59
|
// 在 tblLook 里可以通过这些属性来控制是否启用
|
|
59
60
|
switch (overrideType) {
|
|
60
|
-
case
|
|
61
|
+
case 'firstCol':
|
|
61
62
|
enableType = 'enable-firstColumn';
|
|
62
63
|
break;
|
|
63
|
-
case
|
|
64
|
+
case 'lastCol':
|
|
64
65
|
enableType = 'enable-lastColumn';
|
|
65
66
|
break;
|
|
66
|
-
case
|
|
67
|
+
case 'firstRow':
|
|
67
68
|
enableType = 'enable-firstRow';
|
|
68
69
|
break;
|
|
69
|
-
case
|
|
70
|
+
case 'lastRow':
|
|
70
71
|
enableType = 'enable-lastRow';
|
|
71
72
|
break;
|
|
72
|
-
case
|
|
73
|
-
case
|
|
73
|
+
case 'band1Horz':
|
|
74
|
+
case 'band2Horz':
|
|
74
75
|
enableType = 'enable-hBand';
|
|
75
76
|
break;
|
|
76
|
-
case
|
|
77
|
-
case
|
|
77
|
+
case 'band1Vert':
|
|
78
|
+
case 'band2Vert':
|
|
78
79
|
enableType = 'enable-vBand';
|
|
79
80
|
break;
|
|
80
81
|
}
|
|
81
82
|
if (trStyle) {
|
|
82
|
-
styleText += "\n ".concat(
|
|
83
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr.").concat(overrideType, "{\n ").concat(trStyle, "\n }\n ");
|
|
83
84
|
}
|
|
84
85
|
var tcStyle = styleToText((_b = tblStylePrStyle.tcPr) === null || _b === void 0 ? void 0 : _b.cssStyle);
|
|
85
86
|
if (tcStyle) {
|
|
86
|
-
styleText += "\n ".concat(
|
|
87
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n ").concat(tcStyle, "\n }\n ");
|
|
87
88
|
if ((_c = tblStylePrStyle.tcPr) === null || _c === void 0 ? void 0 : _c.insideBorder) {
|
|
88
89
|
var insideBorder = (_d = tblStylePrStyle.tcPr) === null || _d === void 0 ? void 0 : _d.insideBorder;
|
|
89
90
|
if (insideBorder.H) {
|
|
90
|
-
styleText += "\n ".concat(
|
|
91
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-top: ").concat(insideBorder.H, ";\n }");
|
|
91
92
|
}
|
|
92
93
|
if (insideBorder.V) {
|
|
93
94
|
// 这个主要是为了应对 GridTable5Dark-Accent5 里 firstRow 的情况,它其实有 right 设置,也得去掉
|
|
94
95
|
if (insideBorder.V === 'none') {
|
|
95
|
-
styleText += "\n ".concat(
|
|
96
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: none;\n border-right: none;\n }");
|
|
96
97
|
}
|
|
97
98
|
else {
|
|
98
|
-
styleText += "\n ".concat(
|
|
99
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " {\n border-left: ").concat(insideBorder.V, ";\n }");
|
|
99
100
|
}
|
|
100
101
|
}
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
var pStyle = styleToText((_e = tblStylePrStyle.pPr) === null || _e === void 0 ? void 0 : _e.cssStyle);
|
|
104
105
|
if (pStyle) {
|
|
105
|
-
styleText += "\n ".concat(
|
|
106
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p {\n ").concat(pStyle, "\n }\n ");
|
|
106
107
|
}
|
|
107
108
|
var rStyle = styleToText((_f = tblStylePrStyle.rPr) === null || _f === void 0 ? void 0 : _f.cssStyle);
|
|
108
109
|
if (rStyle) {
|
|
109
|
-
styleText += "\n ".concat(
|
|
110
|
+
styleText += "\n ".concat(tblPrefix, ".").concat(enableType, " > tbody > tr > td.").concat(overrideType, " > .").concat(classPrefix, "-p > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
|
|
110
111
|
}
|
|
111
112
|
return styleText;
|
|
112
113
|
}
|
|
113
114
|
// 表格覆盖样式的顺序,权重高的放后面
|
|
114
115
|
var overrideTypeOrder = new Set([
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
116
|
+
'wholeTable',
|
|
117
|
+
'band1Horz',
|
|
118
|
+
'band2Horz',
|
|
119
|
+
'band1Vert',
|
|
120
|
+
'band2Vert',
|
|
121
|
+
'firstCol',
|
|
122
|
+
'firstRow',
|
|
123
|
+
'lastCol',
|
|
124
|
+
'lastRow',
|
|
125
|
+
'neCell',
|
|
126
|
+
'nwCell',
|
|
127
|
+
'seCell',
|
|
128
|
+
'swCell'
|
|
128
129
|
]);
|
|
129
130
|
// 生成表格覆盖样式
|
|
130
131
|
function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
|
|
@@ -139,7 +140,7 @@ function genOverrideTblStylePr(classPrefix, styleDisplayId, tblStylePr) {
|
|
|
139
140
|
var overrideType = overrideTypeOrder_1_1.value;
|
|
140
141
|
if (overrideType in tblStylePr) {
|
|
141
142
|
var overrideStylePr = tblStylePr[overrideType];
|
|
142
|
-
tblStylePrText += genTblOverrideStyle(stylePrefix, overrideType, overrideStylePr);
|
|
143
|
+
tblStylePrText += genTblOverrideStyle(stylePrefix, classPrefix, overrideType, overrideStylePr);
|
|
143
144
|
}
|
|
144
145
|
}
|
|
145
146
|
}
|
|
@@ -172,7 +173,7 @@ function generateStyle(word) {
|
|
|
172
173
|
var rStyleText = '';
|
|
173
174
|
if (styleData.rPr) {
|
|
174
175
|
var rStyle = styleToText(styleData.rPr.cssStyle);
|
|
175
|
-
rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .r {\n ").concat(rStyle, "\n }\n ");
|
|
176
|
+
rStyleText = "\n .".concat(classPrefix, " .").concat(styleDisplayId, " > .").concat(classPrefix, "-r {\n ").concat(rStyle, "\n }\n ");
|
|
176
177
|
}
|
|
177
178
|
var tblStyleText = generateTableStyle(classPrefix, styleDisplayId, styleData);
|
|
178
179
|
var tblStylePr = genOverrideTblStylePr(classPrefix, styleDisplayId, styleData.tblStylePr);
|
|
@@ -187,7 +188,7 @@ function renderStyle(word) {
|
|
|
187
188
|
var style = createElement('style');
|
|
188
189
|
var docDefaults = generateDefaultStyle(word);
|
|
189
190
|
var styleText = generateStyle(word);
|
|
190
|
-
style.
|
|
191
|
+
style.textContent = "\n ".concat(docDefaults, "\n\n ").concat(styleText, "\n ");
|
|
191
192
|
return style;
|
|
192
193
|
}
|
|
193
194
|
|
package/esm/render/renderTab.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { ST_TabTlc } from '../openxml/Types.js';
|
|
2
1
|
import { createElement } from '../util/dom.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* 渲染 tab
|
|
5
|
+
* 不支持 tabs 里的自定义宽度,因为要算渲染后的宽度,比较麻烦
|
|
6
6
|
* http://officeopenxml.com/WPtab.php
|
|
7
7
|
*/
|
|
8
8
|
function renderTab(word, tab) {
|
|
9
9
|
var tabElement = createElement('span');
|
|
10
|
-
tabElement.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (tab.leader === ST_TabTlc.dot) {
|
|
14
|
-
tabElement.style.borderBottom = '1px dotted';
|
|
10
|
+
tabElement.innerHTML = ' ';
|
|
11
|
+
if (tab.leader === 'dot') {
|
|
12
|
+
tabElement.style.borderBottom = '1pt dotted';
|
|
15
13
|
}
|
|
16
14
|
return tabElement;
|
|
17
15
|
}
|
|
@@ -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
|
+
}
|