office-viewer 0.1.0 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/esm/OpenXML.d.ts +19 -0
- package/esm/OpenXML.js +43 -2
- package/esm/Word.d.ts +132 -15
- package/esm/Word.js +239 -54
- package/esm/openxml/ContentType.js +20 -6
- package/esm/openxml/Settings.d.ts +10 -0
- package/esm/openxml/Settings.js +93 -0
- package/esm/openxml/Style.d.ts +1 -1
- package/esm/openxml/Style.js +12 -12
- package/esm/openxml/Theme.js +30 -6
- package/esm/openxml/Types.d.ts +179 -2472
- package/esm/openxml/drawing/Blip.d.ts +7 -0
- package/esm/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{lib/openxml/word → esm/openxml}/drawing/BlipFill.d.ts +1 -1
- package/esm/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/esm/openxml/drawing/CustomGeom.d.ts +9 -0
- package/esm/openxml/drawing/CustomGeom.js +17 -0
- package/esm/openxml/drawing/Drawing.d.ts +37 -0
- package/esm/openxml/drawing/Drawing.js +173 -0
- package/esm/openxml/drawing/Geom.d.ts +11 -0
- package/esm/openxml/drawing/Geom.js +34 -0
- package/esm/openxml/drawing/Path.d.ts +37 -0
- package/esm/openxml/drawing/Pic.d.ts +16 -0
- package/esm/openxml/drawing/Pic.js +26 -0
- package/esm/openxml/drawing/Shape.d.ts +20 -0
- package/esm/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/esm/openxml/drawing/ShapeProperties.js +119 -0
- package/{lib/openxml/word → esm/openxml}/drawing/Transform.d.ts +4 -1
- package/esm/openxml/drawing/Transform.js +63 -0
- package/esm/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/esm/openxml/drawing/diagram/Diagram.js +24 -0
- package/esm/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/esm/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/esm/openxml/drawing/presetShape.d.ts +3 -0
- package/esm/openxml/drawing/presetShape.js +38785 -0
- package/esm/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/esm/openxml/drawing/svg/arcToA.js +88 -0
- package/esm/openxml/drawing/svg/formulas.d.ts +29 -0
- package/esm/openxml/drawing/svg/formulas.js +103 -0
- package/esm/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/esm/openxml/drawing/svg/generateDefines.js +144 -0
- package/esm/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/esm/openxml/drawing/svg/presetVal.js +53 -0
- package/esm/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/esm/openxml/drawing/svg/shapeToSVG.js +151 -0
- package/esm/openxml/math/OMath.d.ts +5 -0
- package/esm/openxml/math/OMath.js +12 -0
- package/esm/openxml/math/convertOOML.d.ts +4 -0
- package/esm/openxml/math/convertOOML.js +13 -0
- package/esm/openxml/math/xsl.d.ts +4 -0
- package/esm/openxml/math/xsl.js +8 -0
- package/esm/openxml/word/Body.js +11 -7
- package/esm/openxml/word/Break.js +1 -3
- package/esm/openxml/word/Font.d.ts +16 -0
- package/esm/openxml/word/Font.js +78 -0
- package/esm/openxml/word/FontTable.d.ts +9 -0
- package/esm/openxml/word/FontTable.js +34 -0
- package/esm/openxml/word/Header.d.ts +11 -0
- package/esm/openxml/word/Header.js +54 -0
- package/esm/openxml/word/Hyperlink.d.ts +1 -0
- package/esm/openxml/word/Hyperlink.js +7 -3
- package/esm/openxml/word/InlineText.js +1 -1
- package/esm/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/esm/openxml/word/NoBreakHyphen.js +7 -0
- package/esm/openxml/word/Note.d.ts +12 -0
- package/esm/openxml/word/Note.js +48 -0
- package/esm/openxml/word/Paragraph.d.ts +2 -2
- package/esm/openxml/word/Paragraph.js +10 -9
- package/esm/openxml/word/Pict.d.ts +1 -2
- package/esm/openxml/word/Pict.js +5 -3
- package/esm/openxml/word/Ruby.js +1 -1
- package/esm/openxml/word/Run.d.ts +7 -3
- package/esm/openxml/word/Run.js +28 -4
- package/esm/openxml/word/Section.d.ts +18 -5
- package/esm/openxml/word/Section.js +46 -2
- package/esm/openxml/word/Separator.d.ts +5 -0
- package/esm/openxml/word/Separator.js +10 -0
- package/esm/openxml/word/SoftHyphen.d.ts +5 -0
- package/esm/openxml/word/SoftHyphen.js +10 -0
- package/esm/openxml/word/Tab.d.ts +1 -1
- package/esm/openxml/word/Table.d.ts +4 -9
- package/esm/openxml/word/Table.js +0 -235
- package/esm/openxml/word/WDocument.d.ts +1 -2
- package/esm/openxml/word/WDocument.js +53 -7
- package/esm/openxml/word/numbering/AbstractNum.js +4 -2
- package/esm/openxml/word/numbering/Lvl.js +10 -4
- package/esm/openxml/word/numbering/Num.js +12 -4
- package/esm/openxml/word/numbering/NumberProperties.js +2 -2
- package/esm/openxml/word/numbering/Numbering.js +1 -1
- package/esm/openxml/word/table/Tc.d.ts +1 -22
- package/esm/openxml/word/table/Tc.js +1 -221
- package/esm/openxml/word/table/Tr.d.ts +0 -5
- package/esm/openxml/word/table/Tr.js +0 -97
- package/esm/openxml/word/wps/WPG.d.ts +14 -0
- package/esm/openxml/word/wps/WPG.js +56 -0
- package/esm/openxml/word/wps/WPS.d.ts +18 -0
- package/esm/openxml/word/wps/WPS.js +148 -0
- package/esm/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/esm/openxml/word/wps/WPSStyle.js +42 -0
- package/esm/package/PackageParser.d.ts +1 -1
- package/esm/package/XMLPackageParser.d.ts +3 -3
- package/esm/package/ZipPackageParser.d.ts +1 -1
- package/esm/package/ZipPackageParser.js +7 -8
- package/esm/parse/Footnotes.d.ts +3 -0
- package/esm/parse/Footnotes.js +25 -0
- package/esm/parse/colorNameMap.d.ts +6 -0
- package/esm/parse/colorNameMap.js +201 -0
- package/esm/parse/jcToTextAlign.js +1 -0
- package/esm/parse/mergeSdt.d.ts +4 -0
- package/esm/parse/mergeSdt.js +57 -0
- package/esm/parse/modifyColor.d.ts +1 -0
- package/esm/parse/modifyColor.js +106 -0
- package/esm/parse/parseBorder.js +2 -21
- package/esm/parse/parseCellMargin.d.ts +2 -0
- package/esm/parse/parseCellMargin.js +38 -0
- package/esm/parse/parseChildColor.d.ts +5 -0
- package/esm/parse/parseChildColor.js +66 -0
- package/esm/parse/parseColor.d.ts +4 -0
- package/esm/parse/parseColor.js +41 -46
- package/esm/parse/parseEndnotes.d.ts +3 -0
- package/esm/parse/parseEndnotes.js +25 -0
- package/esm/parse/parseFont.js +1 -1
- package/esm/parse/parseInsideBorders.d.ts +9 -0
- package/esm/parse/parseInsideBorders.js +24 -0
- package/esm/parse/parsePr.d.ts +3 -0
- package/esm/parse/parsePr.js +108 -11
- package/esm/parse/parseRelationship.js +1 -1
- package/esm/parse/parseSdt.d.ts +5 -0
- package/esm/parse/parseShape.d.ts +10 -0
- package/esm/parse/parseShape.js +239 -0
- package/esm/parse/parseSize.d.ts +2 -1
- package/esm/parse/parseSize.js +7 -1
- package/esm/parse/parseSpacing.js +1 -1
- package/esm/parse/parseTable.d.ts +3 -0
- package/esm/parse/parseTable.js +62 -0
- package/esm/parse/parseTablePr.d.ts +3 -0
- package/esm/parse/parseTablePr.js +185 -0
- package/esm/parse/parseTblWidth.d.ts +4 -0
- package/esm/parse/parseTblWidth.js +23 -0
- package/esm/parse/parseTc.d.ts +10 -0
- package/esm/parse/parseTc.js +64 -0
- package/esm/parse/parseTcPr.d.ts +5 -0
- package/esm/parse/parseTcPr.js +99 -0
- package/esm/parse/parseTextDirection.js +4 -6
- package/esm/parse/parseTr.d.ts +6 -0
- package/esm/parse/parseTr.js +49 -0
- package/esm/parse/parseTrPr.d.ts +3 -0
- package/esm/parse/parseTrPr.js +59 -0
- package/esm/render/fixAbsolutePosition.d.ts +8 -0
- package/esm/render/renderBody.d.ts +6 -2
- package/esm/render/renderBody.js +184 -30
- package/esm/render/renderBr.d.ts +2 -1
- package/esm/render/renderBr.js +4 -1
- package/esm/render/renderCustGeom.d.ts +4 -0
- package/esm/render/renderCustGeom.js +10 -0
- package/esm/render/renderDocument.d.ts +2 -2
- package/esm/render/renderDocument.js +2 -2
- package/esm/render/renderDrawing.d.ts +3 -2
- package/esm/render/renderDrawing.js +238 -21
- package/esm/render/renderFont.d.ts +5 -0
- package/esm/render/renderFont.js +39 -0
- package/esm/render/renderGeom.d.ts +4 -0
- package/esm/render/renderGeom.js +14 -0
- package/esm/render/renderHeader.d.ts +6 -0
- package/esm/render/renderHeader.js +40 -0
- package/esm/render/renderHyperLink.js +4 -1
- package/esm/render/renderInlineText.js +1 -1
- package/esm/render/renderInstrText.js +1 -1
- package/esm/render/renderMath.d.ts +3 -0
- package/esm/render/renderMath.js +7 -0
- package/esm/render/renderNoBreakHyphen.d.ts +1 -0
- package/esm/render/renderNoBreakHyphen.js +9 -0
- package/esm/render/renderNotes.d.ts +5 -0
- package/esm/render/renderNotes.js +77 -0
- package/esm/render/renderNumbering.js +8 -10
- package/esm/render/renderParagraph.d.ts +1 -1
- package/esm/render/renderParagraph.js +58 -18
- package/esm/render/renderPict.js +5 -10
- package/esm/render/renderRuby.js +1 -1
- package/esm/render/renderRun.d.ts +4 -2
- package/esm/render/renderRun.js +42 -12
- package/esm/render/renderSection.d.ts +3 -2
- package/esm/render/renderSection.js +79 -5
- package/esm/render/renderSeparator.d.ts +1 -0
- package/esm/render/renderSeparator.js +9 -0
- package/esm/render/renderSoftHyphen.d.ts +1 -0
- package/esm/render/renderSoftHyphen.js +9 -0
- package/esm/render/renderStyle.js +36 -35
- package/esm/render/renderTab.d.ts +2 -1
- package/esm/render/renderTab.js +10 -6
- package/esm/render/renderTable.js +23 -20
- package/esm/render/setElementStyle.js +7 -2
- package/esm/render/zindex.d.ts +1 -0
- package/esm/util/blob.js +1 -10
- package/esm/util/color.d.ts +48 -0
- package/esm/util/color.js +211 -0
- package/esm/util/createObject.d.ts +10 -0
- package/esm/util/createObject.js +48 -0
- package/esm/util/dom.d.ts +8 -4
- package/esm/util/dom.js +21 -4
- package/esm/util/get.d.ts +4 -0
- package/esm/util/get.js +18 -0
- package/esm/util/mergeRun.js +1 -1
- package/esm/util/parseSides.d.ts +11 -0
- package/esm/util/print.d.ts +5 -0
- package/esm/util/print.js +54 -0
- package/esm/util/replaceVar.d.ts +10 -0
- package/esm/util/replaceVar.js +215 -0
- package/esm/util/xml.js +4 -1
- package/lib/OpenXML.d.ts +19 -0
- package/lib/OpenXML.js +44 -1
- package/lib/Word.d.ts +132 -15
- package/lib/Word.js +244 -59
- package/lib/openxml/ContentType.js +20 -6
- package/lib/openxml/Settings.d.ts +10 -0
- package/lib/openxml/Settings.js +97 -0
- package/lib/openxml/Style.d.ts +1 -1
- package/lib/openxml/Style.js +15 -15
- package/lib/openxml/Theme.js +31 -7
- package/lib/openxml/Types.d.ts +179 -2472
- package/lib/openxml/drawing/Blip.d.ts +7 -0
- package/lib/openxml/{word/drawing → drawing}/Blip.js +2 -1
- package/{esm/openxml/word → lib/openxml}/drawing/BlipFill.d.ts +1 -1
- package/lib/openxml/{word/drawing → drawing}/BlipFill.js +1 -1
- package/lib/openxml/drawing/CustomGeom.d.ts +9 -0
- package/lib/openxml/drawing/CustomGeom.js +21 -0
- package/lib/openxml/drawing/Drawing.d.ts +37 -0
- package/lib/openxml/drawing/Drawing.js +177 -0
- package/lib/openxml/drawing/Geom.d.ts +11 -0
- package/lib/openxml/drawing/Geom.js +38 -0
- package/lib/openxml/drawing/Path.d.ts +37 -0
- package/lib/openxml/drawing/Pic.d.ts +16 -0
- package/lib/openxml/drawing/Pic.js +30 -0
- package/lib/openxml/drawing/Shape.d.ts +20 -0
- package/lib/openxml/drawing/ShapeProperties.d.ts +22 -0
- package/lib/openxml/drawing/ShapeProperties.js +123 -0
- package/{esm/openxml/word → lib/openxml}/drawing/Transform.d.ts +4 -1
- package/lib/openxml/drawing/Transform.js +67 -0
- package/lib/openxml/drawing/diagram/Diagram.d.ts +7 -0
- package/lib/openxml/drawing/diagram/Diagram.js +28 -0
- package/lib/openxml/drawing/diagram/Sp.d.ts +2 -0
- package/lib/openxml/drawing/diagram/SpTree.d.ts +5 -0
- package/lib/openxml/drawing/presetShape.d.ts +3 -0
- package/lib/openxml/drawing/presetShape.js +38789 -0
- package/lib/openxml/drawing/svg/arcToA.d.ts +13 -0
- package/lib/openxml/drawing/svg/arcToA.js +92 -0
- package/lib/openxml/drawing/svg/formulas.d.ts +29 -0
- package/lib/openxml/drawing/svg/formulas.js +108 -0
- package/lib/openxml/drawing/svg/generateDefines.d.ts +12 -0
- package/lib/openxml/drawing/svg/generateDefines.js +148 -0
- package/lib/openxml/drawing/svg/presetVal.d.ts +43 -0
- package/lib/openxml/drawing/svg/presetVal.js +57 -0
- package/lib/openxml/drawing/svg/shapeToSVG.d.ts +9 -0
- package/lib/openxml/drawing/svg/shapeToSVG.js +155 -0
- package/lib/openxml/math/OMath.d.ts +5 -0
- package/lib/openxml/math/OMath.js +16 -0
- package/lib/openxml/math/convertOOML.d.ts +4 -0
- package/lib/openxml/math/convertOOML.js +17 -0
- package/lib/openxml/math/xsl.d.ts +4 -0
- package/lib/openxml/math/xsl.js +12 -0
- package/lib/openxml/word/Body.js +11 -7
- package/lib/openxml/word/Break.js +1 -3
- package/lib/openxml/word/Font.d.ts +16 -0
- package/lib/openxml/word/Font.js +83 -0
- package/lib/openxml/word/FontTable.d.ts +9 -0
- package/lib/openxml/word/FontTable.js +38 -0
- package/lib/openxml/word/Header.d.ts +11 -0
- package/lib/openxml/word/Header.js +58 -0
- package/lib/openxml/word/Hyperlink.d.ts +1 -0
- package/lib/openxml/word/Hyperlink.js +8 -4
- package/lib/openxml/word/InlineText.js +2 -2
- package/lib/openxml/word/NoBreakHyphen.d.ts +2 -0
- package/lib/openxml/word/NoBreakHyphen.js +11 -0
- package/lib/openxml/word/Note.d.ts +12 -0
- package/lib/openxml/word/Note.js +52 -0
- package/lib/openxml/word/Paragraph.d.ts +2 -2
- package/lib/openxml/word/Paragraph.js +11 -10
- package/lib/openxml/word/Pict.d.ts +1 -2
- package/lib/openxml/word/Pict.js +5 -3
- package/lib/openxml/word/Ruby.js +4 -4
- package/lib/openxml/word/Run.d.ts +7 -3
- package/lib/openxml/word/Run.js +29 -5
- package/lib/openxml/word/Section.d.ts +18 -5
- package/lib/openxml/word/Section.js +47 -3
- package/lib/openxml/word/Separator.d.ts +5 -0
- package/lib/openxml/word/Separator.js +14 -0
- package/lib/openxml/word/SoftHyphen.d.ts +5 -0
- package/lib/openxml/word/SoftHyphen.js +14 -0
- package/lib/openxml/word/Tab.d.ts +1 -1
- package/lib/openxml/word/Table.d.ts +4 -9
- package/lib/openxml/word/Table.js +0 -235
- package/lib/openxml/word/WDocument.d.ts +1 -2
- package/lib/openxml/word/WDocument.js +53 -7
- package/lib/openxml/word/numbering/AbstractNum.js +5 -3
- package/lib/openxml/word/numbering/Lvl.js +11 -5
- package/lib/openxml/word/numbering/Num.js +12 -4
- package/lib/openxml/word/numbering/NumberProperties.js +2 -2
- package/lib/openxml/word/numbering/Numbering.js +3 -3
- package/lib/openxml/word/table/Tc.d.ts +1 -22
- package/lib/openxml/word/table/Tc.js +0 -224
- package/lib/openxml/word/table/Tr.d.ts +0 -5
- package/lib/openxml/word/table/Tr.js +0 -97
- package/lib/openxml/word/wps/WPG.d.ts +14 -0
- package/lib/openxml/word/wps/WPG.js +60 -0
- package/lib/openxml/word/wps/WPS.d.ts +18 -0
- package/lib/openxml/word/wps/WPS.js +152 -0
- package/lib/openxml/word/wps/WPSStyle.d.ts +10 -0
- package/lib/openxml/word/wps/WPSStyle.js +46 -0
- package/lib/package/PackageParser.d.ts +1 -1
- package/lib/package/XMLPackageParser.d.ts +3 -3
- package/lib/package/ZipPackageParser.d.ts +1 -1
- package/lib/package/ZipPackageParser.js +7 -8
- package/lib/parse/Footnotes.d.ts +3 -0
- package/lib/parse/Footnotes.js +29 -0
- package/lib/parse/colorNameMap.d.ts +6 -0
- package/lib/parse/colorNameMap.js +205 -0
- package/lib/parse/jcToTextAlign.js +1 -0
- package/lib/parse/mergeSdt.d.ts +4 -0
- package/lib/parse/mergeSdt.js +61 -0
- package/lib/parse/modifyColor.d.ts +1 -0
- package/lib/parse/modifyColor.js +110 -0
- package/lib/parse/parseBorder.js +3 -22
- package/lib/parse/parseCellMargin.d.ts +2 -0
- package/lib/parse/parseCellMargin.js +42 -0
- package/lib/parse/parseChildColor.d.ts +5 -0
- package/lib/parse/parseChildColor.js +70 -0
- package/lib/parse/parseColor.d.ts +4 -0
- package/lib/parse/parseColor.js +41 -45
- package/lib/parse/parseEndnotes.d.ts +3 -0
- package/lib/parse/parseEndnotes.js +29 -0
- package/lib/parse/parseFont.js +2 -2
- package/lib/parse/parseInsideBorders.d.ts +9 -0
- package/lib/parse/parseInsideBorders.js +28 -0
- package/lib/parse/parsePr.d.ts +3 -0
- package/lib/parse/parsePr.js +109 -12
- package/lib/parse/parseRelationship.js +2 -2
- package/lib/parse/parseSdt.d.ts +5 -0
- package/lib/parse/parseShape.d.ts +10 -0
- package/lib/parse/parseShape.js +247 -0
- package/lib/parse/parseSize.d.ts +2 -1
- package/lib/parse/parseSize.js +7 -0
- package/lib/parse/parseSpacing.js +1 -1
- package/lib/parse/parseTable.d.ts +3 -0
- package/lib/parse/parseTable.js +66 -0
- package/lib/parse/parseTablePr.d.ts +3 -0
- package/lib/parse/parseTablePr.js +189 -0
- package/lib/parse/parseTblWidth.d.ts +4 -0
- package/lib/parse/parseTblWidth.js +27 -0
- package/lib/parse/parseTc.d.ts +10 -0
- package/lib/parse/parseTc.js +68 -0
- package/lib/parse/parseTcPr.d.ts +5 -0
- package/lib/parse/parseTcPr.js +104 -0
- package/lib/parse/parseTextDirection.js +4 -6
- package/lib/parse/parseTr.d.ts +6 -0
- package/lib/parse/parseTr.js +53 -0
- package/lib/parse/parseTrPr.d.ts +3 -0
- package/lib/parse/parseTrPr.js +63 -0
- package/lib/render/fixAbsolutePosition.d.ts +8 -0
- package/lib/render/renderBody.d.ts +6 -2
- package/lib/render/renderBody.js +183 -29
- package/lib/render/renderBr.d.ts +2 -1
- package/lib/render/renderBr.js +4 -1
- package/lib/render/renderCustGeom.d.ts +4 -0
- package/lib/render/renderCustGeom.js +14 -0
- package/lib/render/renderDocument.d.ts +2 -2
- package/lib/render/renderDocument.js +2 -2
- package/lib/render/renderDrawing.d.ts +3 -2
- package/lib/render/renderDrawing.js +238 -21
- package/lib/render/renderFont.d.ts +5 -0
- package/lib/render/renderFont.js +43 -0
- package/lib/render/renderGeom.d.ts +4 -0
- package/lib/render/renderGeom.js +18 -0
- package/lib/render/renderHeader.d.ts +6 -0
- package/lib/render/renderHeader.js +44 -0
- package/lib/render/renderHyperLink.js +5 -2
- package/lib/render/renderInlineText.js +2 -2
- package/lib/render/renderInstrText.js +2 -2
- package/lib/render/renderMath.d.ts +3 -0
- package/lib/render/renderMath.js +11 -0
- package/lib/render/renderNoBreakHyphen.d.ts +1 -0
- package/lib/render/renderNoBreakHyphen.js +13 -0
- package/lib/render/renderNotes.d.ts +5 -0
- package/lib/render/renderNotes.js +81 -0
- package/lib/render/renderNumbering.js +9 -11
- package/lib/render/renderParagraph.d.ts +1 -1
- package/lib/render/renderParagraph.js +58 -18
- package/lib/render/renderPict.js +5 -10
- package/lib/render/renderRuby.js +3 -3
- package/lib/render/renderRun.d.ts +4 -2
- package/lib/render/renderRun.js +41 -11
- package/lib/render/renderSection.d.ts +3 -2
- package/lib/render/renderSection.js +79 -5
- package/lib/render/renderSeparator.d.ts +1 -0
- package/lib/render/renderSeparator.js +13 -0
- package/lib/render/renderSoftHyphen.d.ts +1 -0
- package/lib/render/renderSoftHyphen.js +13 -0
- package/lib/render/renderStyle.js +37 -36
- package/lib/render/renderTab.d.ts +2 -1
- package/lib/render/renderTab.js +10 -6
- package/lib/render/renderTable.js +25 -22
- package/lib/render/setElementStyle.js +6 -1
- package/lib/render/zindex.d.ts +1 -0
- package/lib/util/blob.js +0 -10
- package/lib/util/color.d.ts +48 -0
- package/lib/util/color.js +215 -0
- package/lib/util/createObject.d.ts +10 -0
- package/lib/util/createObject.js +54 -0
- package/lib/util/dom.d.ts +8 -4
- package/lib/util/dom.js +24 -5
- package/lib/util/get.d.ts +4 -0
- package/lib/util/get.js +22 -0
- package/lib/util/mergeRun.js +5 -5
- package/lib/util/parseSides.d.ts +11 -0
- package/lib/util/print.d.ts +5 -0
- package/lib/util/print.js +58 -0
- package/lib/util/replaceVar.d.ts +10 -0
- package/lib/util/replaceVar.js +220 -0
- package/lib/util/xml.js +4 -0
- package/package.json +17 -7
- package/esm/node_modules/tslib/tslib.es6.js +0 -120
- package/esm/openxml/Types.js +0 -1003
- package/esm/openxml/word/CustomXml.d.ts +0 -8
- package/esm/openxml/word/SmartTag.d.ts +0 -8
- package/esm/openxml/word/SmartTag.js +0 -18
- package/esm/openxml/word/drawing/Blip.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.d.ts +0 -6
- package/esm/openxml/word/drawing/Drawing.js +0 -15
- package/esm/openxml/word/drawing/Pic.d.ts +0 -8
- package/esm/openxml/word/drawing/Pic.js +0 -16
- package/esm/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/esm/openxml/word/drawing/ShapeProperties.js +0 -20
- package/esm/openxml/word/drawing/Transform.js +0 -30
- package/lib/node_modules/tslib/tslib.es6.js +0 -129
- package/lib/openxml/Types.js +0 -1005
- package/lib/openxml/word/CustomXml.d.ts +0 -8
- package/lib/openxml/word/SmartTag.d.ts +0 -8
- package/lib/openxml/word/SmartTag.js +0 -22
- package/lib/openxml/word/drawing/Blip.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.d.ts +0 -6
- package/lib/openxml/word/drawing/Drawing.js +0 -19
- package/lib/openxml/word/drawing/Pic.d.ts +0 -8
- package/lib/openxml/word/drawing/Pic.js +0 -20
- package/lib/openxml/word/drawing/ShapeProperties.d.ts +0 -9
- package/lib/openxml/word/drawing/ShapeProperties.js +0 -24
- package/lib/openxml/word/drawing/Transform.js +0 -34
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __values } from '
|
|
1
|
+
import { __values } from 'tslib';
|
|
2
2
|
import { createElement, appendChild } from '../util/dom.js';
|
|
3
3
|
import { Run } from '../openxml/word/Run.js';
|
|
4
4
|
import { BookmarkStart } from '../openxml/word/Bookmark.js';
|
|
@@ -9,45 +9,82 @@ import { renderBookmarkStart } from './renderBookmark.js';
|
|
|
9
9
|
import { renderNumbering } from './renderNumbering.js';
|
|
10
10
|
import { setElementStyle } from './setElementStyle.js';
|
|
11
11
|
import { renderTab } from './renderTab.js';
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
12
|
+
import { OMath } from '../openxml/math/OMath.js';
|
|
13
|
+
import { renderOMath } from './renderMath.js';
|
|
14
|
+
import { Tab } from '../openxml/word/Tab.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* 渲染段落
|
|
17
18
|
* @param renderEmptySpace 如果是 true 的话,当内容为空时会自动加上
|
|
18
19
|
*/
|
|
19
|
-
function renderParagraph(word, paragraph, renderEmptySpace) {
|
|
20
|
-
var e_1, _a, e_2, _b;
|
|
20
|
+
function renderParagraph(word, paragraph, renderEmptySpace, inHeader) {
|
|
21
|
+
var e_1, _a, e_2, _b, e_3, _c;
|
|
21
22
|
if (renderEmptySpace === void 0) { renderEmptySpace = true; }
|
|
23
|
+
if (inHeader === void 0) { inHeader = false; }
|
|
22
24
|
word.currentParagraph = paragraph;
|
|
23
25
|
var p = createElement('p');
|
|
24
26
|
word.addClass(p, 'p');
|
|
25
27
|
var properties = paragraph.properties;
|
|
26
28
|
setElementStyle(word, p, properties);
|
|
29
|
+
// 默认情况下 drawing 是相对段落的
|
|
30
|
+
p.style.position = 'relative';
|
|
27
31
|
// 渲染列表前缀
|
|
28
32
|
if (properties.numPr) {
|
|
29
33
|
appendChild(p, renderNumbering(p, word, properties.numPr));
|
|
30
34
|
}
|
|
31
|
-
|
|
35
|
+
var inFldChar = false;
|
|
36
|
+
if (properties.tabs && properties.tabs.length) {
|
|
37
|
+
// 目前只支持渲染第一个,因为第二个位置取决于前面内容位置,挺麻烦
|
|
38
|
+
// 虽然目前这个实现很 hack,但可以支持常见情况
|
|
39
|
+
appendChild(p, renderTab(word, properties.tabs[0], true));
|
|
40
|
+
// 同时删掉第一个 run 中的 tab
|
|
41
|
+
var done = false;
|
|
32
42
|
try {
|
|
33
|
-
for (var
|
|
34
|
-
var
|
|
35
|
-
|
|
43
|
+
for (var _d = __values(paragraph.children), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
44
|
+
var child = _e.value;
|
|
45
|
+
if (done) {
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (child instanceof Run) {
|
|
49
|
+
try {
|
|
50
|
+
for (var _f = (e_2 = void 0, __values(child.children)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
51
|
+
var runChild = _g.value;
|
|
52
|
+
if (runChild instanceof Tab) {
|
|
53
|
+
child.children.splice(child.children.indexOf(runChild), 1);
|
|
54
|
+
done = true;
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
63
|
+
}
|
|
64
|
+
finally { if (e_2) throw e_2.error; }
|
|
65
|
+
}
|
|
66
|
+
}
|
|
36
67
|
}
|
|
37
68
|
}
|
|
38
69
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
39
70
|
finally {
|
|
40
71
|
try {
|
|
41
|
-
if (
|
|
72
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
42
73
|
}
|
|
43
74
|
finally { if (e_1) throw e_1.error; }
|
|
44
75
|
}
|
|
45
76
|
}
|
|
46
77
|
try {
|
|
47
|
-
for (var
|
|
48
|
-
var child =
|
|
78
|
+
for (var _h = __values(paragraph.children), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
79
|
+
var child = _j.value;
|
|
49
80
|
if (child instanceof Run) {
|
|
50
|
-
|
|
81
|
+
if (child.fldChar === 'begin') {
|
|
82
|
+
inFldChar = true;
|
|
83
|
+
}
|
|
84
|
+
else if (child) {
|
|
85
|
+
inFldChar = false;
|
|
86
|
+
}
|
|
87
|
+
appendChild(p, renderRun(word, child, paragraph, inFldChar, inHeader));
|
|
51
88
|
}
|
|
52
89
|
else if (child instanceof BookmarkStart) {
|
|
53
90
|
appendChild(p, renderBookmarkStart(word, child));
|
|
@@ -56,17 +93,20 @@ function renderParagraph(word, paragraph, renderEmptySpace) {
|
|
|
56
93
|
var hyperlink = renderHyperLink(word, child, paragraph);
|
|
57
94
|
appendChild(p, hyperlink);
|
|
58
95
|
}
|
|
59
|
-
else if (child instanceof
|
|
60
|
-
|
|
96
|
+
else if (child instanceof OMath) {
|
|
97
|
+
appendChild(p, renderOMath(word, child));
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.warn('unknow pargraph type', child);
|
|
61
101
|
}
|
|
62
102
|
}
|
|
63
103
|
}
|
|
64
|
-
catch (
|
|
104
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
65
105
|
finally {
|
|
66
106
|
try {
|
|
67
|
-
if (
|
|
107
|
+
if (_j && !_j.done && (_c = _h.return)) _c.call(_h);
|
|
68
108
|
}
|
|
69
|
-
finally { if (
|
|
109
|
+
finally { if (e_3) throw e_3.error; }
|
|
70
110
|
}
|
|
71
111
|
// 空行自动加个空格,不然会没高度
|
|
72
112
|
if (p.innerHTML === '' && renderEmptySpace) {
|
package/esm/render/renderPict.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
* 老的 vml 格式,目前只支持图片
|
|
3
3
|
*/
|
|
4
4
|
function renderPict(word, pict) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (url) {
|
|
11
|
-
img_1.src = url;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
return img_1;
|
|
5
|
+
if (pict.src) {
|
|
6
|
+
var img = document.createElement('img');
|
|
7
|
+
img.style.position = 'relative';
|
|
8
|
+
img.src = pict.src;
|
|
9
|
+
return img;
|
|
15
10
|
}
|
|
16
11
|
return null;
|
|
17
12
|
}
|
package/esm/render/renderRuby.js
CHANGED
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import Word from '../Word';
|
|
5
5
|
import { Run } from '../openxml/word/Run';
|
|
6
|
-
import type { Paragraph } from '
|
|
6
|
+
import type { Paragraph } from '../openxml/word/Paragraph';
|
|
7
7
|
/**
|
|
8
8
|
* 更新文档里的所有变量
|
|
9
9
|
*/
|
|
10
10
|
export declare function updateVariableText(word: Word): void;
|
|
11
11
|
/**
|
|
12
12
|
* 渲染 run 节点
|
|
13
|
+
*
|
|
14
|
+
* @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
|
|
13
15
|
*/
|
|
14
|
-
export default function renderRun(word: Word, run: Run, paragraph?: Paragraph): HTMLElement;
|
|
16
|
+
export default function renderRun(word: Word, run: Run, paragraph?: Paragraph, inFldChar?: boolean, inHeader?: boolean): HTMLElement;
|
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
|
|
@@ -29,12 +35,14 @@ function renderText(span, word, text, paragraph) {
|
|
|
29
35
|
var _a;
|
|
30
36
|
// 简单过滤一下提升性能
|
|
31
37
|
if (text.indexOf('{{') === -1) {
|
|
38
|
+
var finalText = void 0;
|
|
32
39
|
if ((_a = paragraph === null || paragraph === void 0 ? void 0 : paragraph.properties) === null || _a === void 0 ? void 0 : _a.autoSpace) {
|
|
33
|
-
|
|
40
|
+
finalText = cjkspace(text.split(''));
|
|
34
41
|
}
|
|
35
42
|
else {
|
|
36
|
-
|
|
43
|
+
finalText = text;
|
|
37
44
|
}
|
|
45
|
+
span.textContent = finalText;
|
|
38
46
|
}
|
|
39
47
|
else {
|
|
40
48
|
span.dataset.originText = text;
|
|
@@ -42,6 +50,9 @@ function renderText(span, word, text, paragraph) {
|
|
|
42
50
|
span.classList.add(VARIABLE_CLASS_NAME);
|
|
43
51
|
span.textContent = word.replaceText(text);
|
|
44
52
|
}
|
|
53
|
+
// 大于两个空格才转成 nbsp
|
|
54
|
+
var html = span.innerHTML.split(' ').join(' ');
|
|
55
|
+
span.innerHTML = html;
|
|
45
56
|
}
|
|
46
57
|
/**
|
|
47
58
|
* 更新文档里的所有变量
|
|
@@ -56,31 +67,41 @@ function updateVariableText(word) {
|
|
|
56
67
|
}
|
|
57
68
|
/**
|
|
58
69
|
* 渲染 run 节点
|
|
70
|
+
*
|
|
71
|
+
* @param inFldChar 是否在 complex field 里,预留功能,目前还不支持
|
|
59
72
|
*/
|
|
60
|
-
function renderRun(word, run, paragraph) {
|
|
73
|
+
function renderRun(word, run, paragraph, inFldChar, inHeader) {
|
|
61
74
|
var e_1, _a;
|
|
75
|
+
var _b, _c;
|
|
62
76
|
var span = createElement('span');
|
|
63
77
|
word.addClass(span, 'r');
|
|
64
78
|
setElementStyle(word, span, run.properties);
|
|
79
|
+
// run 不好通过 class 来设置 rStyle,所以单独支持一下
|
|
80
|
+
if ((_b = run.properties) === null || _b === void 0 ? void 0 : _b.rStyle) {
|
|
81
|
+
var style = word.getStyle(run.properties.rStyle);
|
|
82
|
+
if ((_c = style === null || style === void 0 ? void 0 : style.rPr) === null || _c === void 0 ? void 0 : _c.cssStyle) {
|
|
83
|
+
applyStyle(span, style.rPr.cssStyle);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
65
86
|
if (run.children.length === 1 && run.children[0] instanceof Text) {
|
|
66
87
|
var text = run.children[0];
|
|
67
88
|
renderText(span, word, text.text, paragraph);
|
|
68
89
|
}
|
|
69
90
|
else {
|
|
70
91
|
try {
|
|
71
|
-
for (var
|
|
72
|
-
var child =
|
|
92
|
+
for (var _d = __values(run.children), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
93
|
+
var child = _e.value;
|
|
73
94
|
if (child instanceof Text) {
|
|
74
95
|
var newSpan = createElement('span');
|
|
75
|
-
renderText(
|
|
96
|
+
renderText(newSpan, word, child.text, paragraph);
|
|
76
97
|
appendChild(span, newSpan);
|
|
77
98
|
}
|
|
78
99
|
else if (child instanceof Break) {
|
|
79
|
-
var br = renderBr(child);
|
|
100
|
+
var br = renderBr(word, child);
|
|
80
101
|
appendChild(span, br);
|
|
81
102
|
}
|
|
82
103
|
else if (child instanceof Drawing) {
|
|
83
|
-
appendChild(span, renderDrawing(word, child));
|
|
104
|
+
appendChild(span, renderDrawing(word, child, inHeader));
|
|
84
105
|
}
|
|
85
106
|
else if (child instanceof Tab) {
|
|
86
107
|
appendChild(span, renderTab(word, child));
|
|
@@ -97,6 +118,15 @@ function renderRun(word, run, paragraph) {
|
|
|
97
118
|
else if (child instanceof Sym) {
|
|
98
119
|
appendChild(span, renderSym(word, child));
|
|
99
120
|
}
|
|
121
|
+
else if (child instanceof SoftHyphen) {
|
|
122
|
+
appendChild(span, renderSoftHyphen());
|
|
123
|
+
}
|
|
124
|
+
else if (child instanceof NoBreakHyphen) {
|
|
125
|
+
appendChild(span, renderNoBreakHyphen());
|
|
126
|
+
}
|
|
127
|
+
else if (child instanceof Separator) {
|
|
128
|
+
appendChild(span, renderSeparator());
|
|
129
|
+
}
|
|
100
130
|
else {
|
|
101
131
|
console.warn('unknown child', child);
|
|
102
132
|
}
|
|
@@ -105,7 +135,7 @@ function renderRun(word, run, paragraph) {
|
|
|
105
135
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
106
136
|
finally {
|
|
107
137
|
try {
|
|
108
|
-
if (
|
|
138
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
109
139
|
}
|
|
110
140
|
finally { if (e_1) throw e_1.error; }
|
|
111
141
|
}
|
|
@@ -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 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
|
|
|
@@ -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/esm/render/renderTab.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
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
|
-
function renderTab(word, tab) {
|
|
8
|
+
function renderTab(word, tab, renderWidth) {
|
|
9
|
+
if (renderWidth === void 0) { renderWidth = false; }
|
|
9
10
|
var tabElement = createElement('span');
|
|
10
11
|
tabElement.style.display = 'inline-block';
|
|
11
|
-
tabElement.style.width =
|
|
12
|
-
tabElement.innerHTML = '&
|
|
13
|
-
if (tab.leader ===
|
|
14
|
-
tabElement.style.borderBottom = '
|
|
12
|
+
tabElement.style.width = '2em';
|
|
13
|
+
tabElement.innerHTML = ' ';
|
|
14
|
+
if (tab.leader === 'dot') {
|
|
15
|
+
tabElement.style.borderBottom = '1pt dotted';
|
|
16
|
+
}
|
|
17
|
+
if (renderWidth && tab.pos && (tab.type === 'start' || tab.type == 'left')) {
|
|
18
|
+
tabElement.style.width = tab.pos;
|
|
15
19
|
}
|
|
16
20
|
return tabElement;
|
|
17
21
|
}
|