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
|
@@ -2,41 +2,146 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
7
|
+
var dom = require('../util/dom.js');
|
|
8
|
+
var renderParagraph = require('./renderParagraph.js');
|
|
9
|
+
var renderTable = require('./renderTable.js');
|
|
10
|
+
var Table = require('../openxml/word/Table.js');
|
|
11
|
+
var renderGeom = require('./renderGeom.js');
|
|
12
|
+
var renderCustGeom = require('./renderCustGeom.js');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 渲染图片
|
|
16
|
+
*/
|
|
17
|
+
function renderPic(pic, word, drawing) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
var blip = (_a = pic.blipFill) === null || _a === void 0 ? void 0 : _a.blip;
|
|
20
|
+
if (blip && blip.src) {
|
|
21
|
+
var img = document.createElement('img');
|
|
22
|
+
img.style.position = 'relative';
|
|
23
|
+
img.alt = pic.alt || '';
|
|
24
|
+
img.src = blip.src;
|
|
25
|
+
if (pic.alt && word.renderOptions.enableVar) {
|
|
26
|
+
if (pic.altVar) {
|
|
27
|
+
img.src = pic.altVar;
|
|
28
|
+
}
|
|
29
|
+
else if (pic.alt.startsWith('{{')) {
|
|
30
|
+
var src = word.replaceText(pic.alt);
|
|
31
|
+
if (src) {
|
|
32
|
+
img.src = src;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
var xfrm = (_b = pic.spPr) === null || _b === void 0 ? void 0 : _b.xfrm;
|
|
37
|
+
if (xfrm) {
|
|
38
|
+
var off = xfrm.off;
|
|
39
|
+
if (off) {
|
|
40
|
+
img.style.left = off.x;
|
|
41
|
+
img.style.top = off.y;
|
|
42
|
+
}
|
|
43
|
+
var ext = xfrm.ext;
|
|
44
|
+
if (ext) {
|
|
45
|
+
img.style.width = ext.cx;
|
|
46
|
+
img.style.height = ext.cy;
|
|
47
|
+
}
|
|
48
|
+
if (xfrm.rot) {
|
|
49
|
+
img.style.transform = "rotate(".concat(xfrm.rot, "deg)");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return img;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
5
56
|
/**
|
|
6
57
|
* 渲染图片,目前只支持 picture
|
|
7
58
|
* http://officeopenxml.com/drwOverview.php
|
|
59
|
+
* @param inHeader,如果在 header 中,位置计算要特殊处理
|
|
8
60
|
*
|
|
9
61
|
*/
|
|
10
|
-
function renderDrawing(word, drawing) {
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
62
|
+
function renderDrawing(word, drawing, inHeader) {
|
|
63
|
+
var e_1, _a;
|
|
64
|
+
var container = document.createElement('div');
|
|
65
|
+
if (drawing.position === 'inline') {
|
|
66
|
+
container.style.display = 'inline-block';
|
|
67
|
+
}
|
|
68
|
+
else if (drawing.position === 'anchor') ;
|
|
69
|
+
if (drawing.pic) {
|
|
70
|
+
dom.appendChild(container, renderPic(drawing.pic, word));
|
|
71
|
+
}
|
|
72
|
+
if (drawing.relativeFromV === 'page') {
|
|
73
|
+
console.warn('暂不支持 drawing.relativeFromV === "page"');
|
|
74
|
+
}
|
|
75
|
+
dom.applyStyle(container, drawing.containerStyle);
|
|
76
|
+
container.dataset.id = drawing.id || '';
|
|
77
|
+
container.dataset.name = drawing.name || '';
|
|
78
|
+
if (drawing.wps) {
|
|
79
|
+
var wps = drawing.wps;
|
|
80
|
+
var wpsStyle = wps.wpsStyle;
|
|
81
|
+
var spPr = wps.spPr;
|
|
82
|
+
dom.applyStyle(container, wps.style);
|
|
83
|
+
if (wpsStyle === null || wpsStyle === void 0 ? void 0 : wpsStyle.fontColor) {
|
|
84
|
+
container.style.color = wpsStyle.fontColor;
|
|
85
|
+
}
|
|
86
|
+
if (spPr === null || spPr === void 0 ? void 0 : spPr.xfrm) {
|
|
87
|
+
var ext = spPr.xfrm.ext;
|
|
88
|
+
if (ext) {
|
|
89
|
+
container.style.width = ext.cx;
|
|
90
|
+
container.style.height = ext.cy;
|
|
91
|
+
if (spPr.geom) {
|
|
92
|
+
var width = parseFloat(ext.cx.replace('px', ''));
|
|
93
|
+
var height = parseFloat(ext.cy.replace('px', ''));
|
|
94
|
+
dom.appendChild(container, renderGeom.renderGeom(spPr.geom, spPr, width, height, wps.wpsStyle));
|
|
21
95
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (off) {
|
|
27
|
-
img_1.style.left = off.x;
|
|
28
|
-
img_1.style.top = off.y;
|
|
96
|
+
if (spPr.custGeom) {
|
|
97
|
+
var width = parseFloat(ext.cx.replace('px', ''));
|
|
98
|
+
var height = parseFloat(ext.cy.replace('px', ''));
|
|
99
|
+
dom.appendChild(container, renderCustGeom.renderCustGeom(spPr.custGeom, spPr, width, height, wps.wpsStyle));
|
|
29
100
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
101
|
+
}
|
|
102
|
+
if (spPr.xfrm.rot) {
|
|
103
|
+
container.style.transform = "rotate(".concat(spPr.xfrm.rot, "deg)");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
var txbxContent = wps.txbxContent;
|
|
107
|
+
if (txbxContent.length) {
|
|
108
|
+
// 为了实现垂直居中,将父容器改成 table 布局
|
|
109
|
+
var textContainer = document.createElement('div');
|
|
110
|
+
textContainer.dataset.name = 'textContainer';
|
|
111
|
+
container.style.display = 'table';
|
|
112
|
+
textContainer.style.display = 'table-cell';
|
|
113
|
+
textContainer.style.verticalAlign = 'middle';
|
|
114
|
+
if (wps.style && wps.style['vertical-align']) {
|
|
115
|
+
textContainer.style.verticalAlign = wps.style['vertical-align'];
|
|
116
|
+
// 容器的 vertical-align 需要去掉,虽然也不影响
|
|
117
|
+
container.style.verticalAlign = '';
|
|
118
|
+
}
|
|
119
|
+
dom.appendChild(container, textContainer);
|
|
120
|
+
try {
|
|
121
|
+
for (var txbxContent_1 = tslib.__values(txbxContent), txbxContent_1_1 = txbxContent_1.next(); !txbxContent_1_1.done; txbxContent_1_1 = txbxContent_1.next()) {
|
|
122
|
+
var txbxContentChild = txbxContent_1_1.value;
|
|
123
|
+
if (txbxContentChild instanceof Paragraph.Paragraph) {
|
|
124
|
+
dom.appendChild(textContainer, renderParagraph["default"](word, txbxContentChild));
|
|
125
|
+
}
|
|
126
|
+
else if (txbxContentChild instanceof Table.Table) {
|
|
127
|
+
dom.appendChild(textContainer, renderTable["default"](word, txbxContentChild));
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
132
|
+
finally {
|
|
133
|
+
try {
|
|
134
|
+
if (txbxContent_1_1 && !txbxContent_1_1.done && (_a = txbxContent_1.return)) _a.call(txbxContent_1);
|
|
34
135
|
}
|
|
136
|
+
finally { if (e_1) throw e_1.error; }
|
|
35
137
|
}
|
|
36
|
-
return img_1;
|
|
37
138
|
}
|
|
38
139
|
}
|
|
39
|
-
|
|
140
|
+
// 如果没内容就不渲染了,避免高度导致撑开父节点
|
|
141
|
+
if (container.children.length === 0) {
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
return container;
|
|
40
145
|
}
|
|
41
146
|
|
|
42
147
|
exports.renderDrawing = renderDrawing;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var dom = require('../util/dom.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 渲染自定义字体样式
|
|
10
|
+
*/
|
|
11
|
+
function renderFont(fontTable) {
|
|
12
|
+
var e_1, _a;
|
|
13
|
+
if (!fontTable) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
var fonts = fontTable.fonts;
|
|
17
|
+
if (!fonts || !fonts.length) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
var style = dom.createElement('style');
|
|
21
|
+
var fontContent = '/** embedded fonts **/';
|
|
22
|
+
try {
|
|
23
|
+
for (var _b = tslib.__values(fontTable.fonts), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
24
|
+
var font = _c.value;
|
|
25
|
+
var fontName = font.name.replace(/['\\]/g, ''); // 简单防止 xss
|
|
26
|
+
var fontPath = font.url;
|
|
27
|
+
if (fontName && fontPath) {
|
|
28
|
+
fontContent += "\n @font-face {\n font-family: '".concat(fontName, "';\n src: url('").concat(fontPath, "');\n }\n ");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
33
|
+
finally {
|
|
34
|
+
try {
|
|
35
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
36
|
+
}
|
|
37
|
+
finally { if (e_1) throw e_1.error; }
|
|
38
|
+
}
|
|
39
|
+
style.innerHTML = fontContent;
|
|
40
|
+
return style;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
exports.renderFont = renderFont;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Geom } from '../openxml/drawing/Geom';
|
|
2
|
+
import { ShapePr } from '../openxml/drawing/ShapeProperties';
|
|
3
|
+
import { WPSStyle } from '../openxml/word/wps/WPSStyle';
|
|
4
|
+
export declare function renderGeom(geom: Geom, shapePr: ShapePr, width: number, height: number, wpsStyle?: WPSStyle): SVGElement | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var presetShape = require('../openxml/drawing/presetShape.js');
|
|
6
|
+
var shapeToSVG = require('../openxml/drawing/svg/shapeToSVG.js');
|
|
7
|
+
|
|
8
|
+
function renderGeom(geom, shapePr, width, height, wpsStyle) {
|
|
9
|
+
if (geom.prst) {
|
|
10
|
+
var shape = presetShape.presetShape[geom.prst];
|
|
11
|
+
if (shape) {
|
|
12
|
+
return shapeToSVG.shapeToSVG(shape, geom.avLst || [], shapePr, width, height, wpsStyle);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
exports.renderGeom = renderGeom;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
7
|
+
var renderParagraph = require('./renderParagraph.js');
|
|
8
|
+
var dom = require('../util/dom.js');
|
|
9
|
+
var renderTable = require('./renderTable.js');
|
|
10
|
+
var Table = require('../openxml/word/Table.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 渲染 header 内容
|
|
14
|
+
*/
|
|
15
|
+
function renderHeader(word, header) {
|
|
16
|
+
var e_1, _a;
|
|
17
|
+
var headerEl = dom.createElement('div');
|
|
18
|
+
try {
|
|
19
|
+
for (var _b = tslib.__values(header.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
20
|
+
var child = _c.value;
|
|
21
|
+
if (child instanceof Paragraph.Paragraph) {
|
|
22
|
+
var p = renderParagraph["default"](word, child, true, true);
|
|
23
|
+
dom.appendChild(headerEl, p);
|
|
24
|
+
}
|
|
25
|
+
else if (child instanceof Table.Table) {
|
|
26
|
+
var table = renderTable["default"](word, child);
|
|
27
|
+
dom.appendChild(headerEl, table);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
console.warn('unknown child', child);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
35
|
+
finally {
|
|
36
|
+
try {
|
|
37
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
38
|
+
}
|
|
39
|
+
finally { if (e_1) throw e_1.error; }
|
|
40
|
+
}
|
|
41
|
+
return headerEl;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.renderHeader = renderHeader;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
7
|
var Run = require('../openxml/word/Run.js');
|
|
8
8
|
var renderRun = require('./renderRun.js');
|
|
@@ -23,8 +23,11 @@ function renderHyperLink(word, hyperlink, paragraph) {
|
|
|
23
23
|
if (hyperlink.anchor) {
|
|
24
24
|
a.href = '#' + hyperlink.anchor;
|
|
25
25
|
}
|
|
26
|
+
if (hyperlink.tooltip) {
|
|
27
|
+
a.title = hyperlink.tooltip;
|
|
28
|
+
}
|
|
26
29
|
try {
|
|
27
|
-
for (var _b =
|
|
30
|
+
for (var _b = tslib.__values(hyperlink.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
28
31
|
var child = _c.value;
|
|
29
32
|
if (child instanceof Run.Run) {
|
|
30
33
|
var span = renderRun["default"](word, child, paragraph);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
7
|
var Run = require('../openxml/word/Run.js');
|
|
8
8
|
var Bookmark = require('../openxml/word/Bookmark.js');
|
|
@@ -17,7 +17,7 @@ var renderBookmark = require('./renderBookmark.js');
|
|
|
17
17
|
function renderInlineText(word, inlineText, parent) {
|
|
18
18
|
var e_1, _a;
|
|
19
19
|
try {
|
|
20
|
-
for (var _b =
|
|
20
|
+
for (var _b = tslib.__values(inlineText.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
21
21
|
var child = _c.value;
|
|
22
22
|
if (child instanceof Run.Run) {
|
|
23
23
|
dom.appendChild(parent, renderRun["default"](word, child));
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
7
|
var renderInlineText = require('./renderInlineText.js');
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ function renderInstrText(word, instrText) {
|
|
|
21
21
|
try {
|
|
22
22
|
// 其实不知道这样做是不是对的
|
|
23
23
|
// 另外就是这里有很多指令还不支持 http://webapp.docx4java.org/OnlineDemo/ecma376/WordML/FILENAME.html
|
|
24
|
-
for (var fldSimples_1 =
|
|
24
|
+
for (var fldSimples_1 = tslib.__values(fldSimples), fldSimples_1_1 = fldSimples_1.next(); !fldSimples_1_1.done; fldSimples_1_1 = fldSimples_1.next()) {
|
|
25
25
|
var fldSimple = fldSimples_1_1.value;
|
|
26
26
|
if (fldSimple.instr === text.trim() ||
|
|
27
27
|
text.startsWith(fldSimple.instr + ' ')) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var convertOOML = require('../openxml/math/convertOOML.js');
|
|
6
|
+
|
|
7
|
+
function renderOMath(word, math) {
|
|
8
|
+
return convertOOML.convertOOXML(math.element);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
exports.renderOMath = renderOMath;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderNoBreakHyphen(): HTMLElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var dom = require('../util/dom.js');
|
|
6
|
+
|
|
7
|
+
function renderNoBreakHyphen() {
|
|
8
|
+
var softHyphen = dom.createElement('span');
|
|
9
|
+
softHyphen.innerHTML = '–';
|
|
10
|
+
return softHyphen;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
exports.renderNoBreakHyphen = renderNoBreakHyphen;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Paragraph = require('../openxml/word/Paragraph.js');
|
|
7
|
+
var Table = require('../openxml/word/Table.js');
|
|
8
|
+
var dom = require('../util/dom.js');
|
|
9
|
+
var renderParagraph = require('./renderParagraph.js');
|
|
10
|
+
var renderTable = require('./renderTable.js');
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 渲染 footnotes 和 endnotes,这个需要最后执行
|
|
14
|
+
*/
|
|
15
|
+
function renderNote(word, noteRoot, type, id, note) {
|
|
16
|
+
var e_1, _a;
|
|
17
|
+
var noteChild = note.children;
|
|
18
|
+
var noteElement = dom.createElement('div');
|
|
19
|
+
var mark = dom.createElement('a');
|
|
20
|
+
var fName = type + '-' + id;
|
|
21
|
+
mark.name = fName;
|
|
22
|
+
mark.id = fName;
|
|
23
|
+
noteRoot.appendChild(noteElement);
|
|
24
|
+
try {
|
|
25
|
+
for (var noteChild_1 = tslib.__values(noteChild), noteChild_1_1 = noteChild_1.next(); !noteChild_1_1.done; noteChild_1_1 = noteChild_1.next()) {
|
|
26
|
+
var child = noteChild_1_1.value;
|
|
27
|
+
if (child instanceof Paragraph.Paragraph) {
|
|
28
|
+
var p = renderParagraph["default"](word, child);
|
|
29
|
+
dom.appendChild(noteElement, p);
|
|
30
|
+
}
|
|
31
|
+
else if (child instanceof Table.Table) {
|
|
32
|
+
dom.appendChild(noteElement, renderTable["default"](word, child));
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
console.warn('unknown child', child);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
40
|
+
finally {
|
|
41
|
+
try {
|
|
42
|
+
if (noteChild_1_1 && !noteChild_1_1.done && (_a = noteChild_1.return)) _a.call(noteChild_1);
|
|
43
|
+
}
|
|
44
|
+
finally { if (e_1) throw e_1.error; }
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/*
|
|
48
|
+
* 过滤掉 0 和 -1 后是否还有其他的值,没有的话就不需要渲染
|
|
49
|
+
*/
|
|
50
|
+
function hasNote(notes) {
|
|
51
|
+
if (!notes) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
for (var id in notes) {
|
|
55
|
+
if (id !== '0' && id !== '-1') {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function renderNotes(word) {
|
|
62
|
+
var noteRoot = dom.createElement('div');
|
|
63
|
+
if (hasNote(word.footNotes)) {
|
|
64
|
+
for (var fId in word.footNotes) {
|
|
65
|
+
renderNote(word, noteRoot, 'footnote', fId, word.footNotes[fId]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (hasNote(word.endNotes)) {
|
|
69
|
+
for (var fId in word.endNotes || {}) {
|
|
70
|
+
renderNote(word, noteRoot, 'endnote', fId, word.endNotes[fId]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (noteRoot.children.length) {
|
|
74
|
+
return noteRoot;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
exports.renderNotes = renderNotes;
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
|
-
var Types = require('../openxml/Types.js');
|
|
8
7
|
var setElementStyle = require('./setElementStyle.js');
|
|
9
8
|
|
|
10
9
|
/**
|
|
@@ -40,17 +39,17 @@ function romanize(num) {
|
|
|
40
39
|
*/
|
|
41
40
|
function convertNumToFormat(numFmt, num) {
|
|
42
41
|
switch (numFmt) {
|
|
43
|
-
case
|
|
42
|
+
case 'decimal':
|
|
44
43
|
return num.toString();
|
|
45
|
-
case
|
|
44
|
+
case 'lowerLetter':
|
|
46
45
|
return String.fromCharCode(96 + num);
|
|
47
|
-
case
|
|
46
|
+
case 'upperLetter':
|
|
48
47
|
return String.fromCharCode(64 + num);
|
|
49
|
-
case
|
|
48
|
+
case 'lowerRoman':
|
|
50
49
|
return romanize(num).toLowerCase();
|
|
51
|
-
case
|
|
50
|
+
case 'upperRoman':
|
|
52
51
|
return romanize(num).toUpperCase();
|
|
53
|
-
case
|
|
52
|
+
case 'bullet':
|
|
54
53
|
// 原本其实是用
|
|
55
54
|
return '•';
|
|
56
55
|
default:
|
|
@@ -80,7 +79,7 @@ function renderNumbering(p, word, numPr) {
|
|
|
80
79
|
var abstractNum = numbering.abstractNums[num.abstractNumId];
|
|
81
80
|
var lvls = abstractNum.lvls;
|
|
82
81
|
if (num.lvlOverride) {
|
|
83
|
-
lvls =
|
|
82
|
+
lvls = tslib.__assign(tslib.__assign({}, lvls), num.lvlOverride.lvls);
|
|
84
83
|
}
|
|
85
84
|
var lvl = lvls[numPr.ilvl];
|
|
86
85
|
if (!lvl) {
|
|
@@ -133,8 +132,7 @@ function renderNumbering(p, word, numPr) {
|
|
|
133
132
|
// 还不支持 lvlJc
|
|
134
133
|
// 还不支持 image
|
|
135
134
|
// http://officeopenxml.com/WPnumbering-imagesAsSymbol.php
|
|
136
|
-
if (lvl.numFmt !==
|
|
137
|
-
word.renderOptions.bulletUseFont) {
|
|
135
|
+
if (lvl.numFmt !== 'bullet' || word.renderOptions.bulletUseFont) {
|
|
138
136
|
element.innerText = lvlText;
|
|
139
137
|
}
|
|
140
138
|
else {
|
|
@@ -4,4 +4,4 @@ import { Paragraph } from '../openxml/word/Paragraph';
|
|
|
4
4
|
* 渲染段落
|
|
5
5
|
* @param renderEmptySpace 如果是 true 的话,当内容为空时会自动加上
|
|
6
6
|
*/
|
|
7
|
-
export default function renderParagraph(word: Word, paragraph: Paragraph, renderEmptySpace?: boolean): HTMLElement;
|
|
7
|
+
export default function renderParagraph(word: Word, paragraph: Paragraph, renderEmptySpace?: boolean, inHeader?: boolean): HTMLElement;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var tslib = require('tslib');
|
|
6
6
|
var dom = require('../util/dom.js');
|
|
7
7
|
var Run = require('../openxml/word/Run.js');
|
|
8
8
|
var Bookmark = require('../openxml/word/Bookmark.js');
|
|
@@ -12,46 +12,40 @@ var renderHyperLink = require('./renderHyperLink.js');
|
|
|
12
12
|
var renderBookmark = require('./renderBookmark.js');
|
|
13
13
|
var renderNumbering = require('./renderNumbering.js');
|
|
14
14
|
var setElementStyle = require('./setElementStyle.js');
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var renderInlineText = require('./renderInlineText.js');
|
|
15
|
+
var OMath = require('../openxml/math/OMath.js');
|
|
16
|
+
var renderMath = require('./renderMath.js');
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* 渲染段落
|
|
21
20
|
* @param renderEmptySpace 如果是 true 的话,当内容为空时会自动加上
|
|
22
21
|
*/
|
|
23
|
-
function renderParagraph(word, paragraph, renderEmptySpace) {
|
|
24
|
-
var e_1, _a
|
|
22
|
+
function renderParagraph(word, paragraph, renderEmptySpace, inHeader) {
|
|
23
|
+
var e_1, _a;
|
|
25
24
|
if (renderEmptySpace === void 0) { renderEmptySpace = true; }
|
|
25
|
+
if (inHeader === void 0) { inHeader = false; }
|
|
26
26
|
word.currentParagraph = paragraph;
|
|
27
27
|
var p = dom.createElement('p');
|
|
28
28
|
word.addClass(p, 'p');
|
|
29
29
|
var properties = paragraph.properties;
|
|
30
30
|
setElementStyle.setElementStyle(word, p, properties);
|
|
31
|
+
// 默认情况下 drawing 是相对段落的
|
|
32
|
+
p.style.position = 'relative';
|
|
31
33
|
// 渲染列表前缀
|
|
32
34
|
if (properties.numPr) {
|
|
33
35
|
dom.appendChild(p, renderNumbering.renderNumbering(p, word, properties.numPr));
|
|
34
36
|
}
|
|
35
|
-
|
|
36
|
-
try {
|
|
37
|
-
for (var _c = tslib_es6.__values(properties.tabs), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
38
|
-
var tab = _d.value;
|
|
39
|
-
dom.appendChild(p, renderTab.renderTab(word, tab));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
43
|
-
finally {
|
|
44
|
-
try {
|
|
45
|
-
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
46
|
-
}
|
|
47
|
-
finally { if (e_1) throw e_1.error; }
|
|
48
|
-
}
|
|
49
|
-
}
|
|
37
|
+
var inFldChar = false;
|
|
50
38
|
try {
|
|
51
|
-
for (var
|
|
52
|
-
var child =
|
|
39
|
+
for (var _b = tslib.__values(paragraph.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
40
|
+
var child = _c.value;
|
|
53
41
|
if (child instanceof Run.Run) {
|
|
54
|
-
|
|
42
|
+
if (child.fldChar === 'begin') {
|
|
43
|
+
inFldChar = true;
|
|
44
|
+
}
|
|
45
|
+
else if (child) {
|
|
46
|
+
inFldChar = false;
|
|
47
|
+
}
|
|
48
|
+
dom.appendChild(p, renderRun["default"](word, child, paragraph, inFldChar, inHeader));
|
|
55
49
|
}
|
|
56
50
|
else if (child instanceof Bookmark.BookmarkStart) {
|
|
57
51
|
dom.appendChild(p, renderBookmark.renderBookmarkStart(word, child));
|
|
@@ -60,17 +54,20 @@ function renderParagraph(word, paragraph, renderEmptySpace) {
|
|
|
60
54
|
var hyperlink = renderHyperLink.renderHyperLink(word, child, paragraph);
|
|
61
55
|
dom.appendChild(p, hyperlink);
|
|
62
56
|
}
|
|
63
|
-
else if (child instanceof
|
|
64
|
-
|
|
57
|
+
else if (child instanceof OMath.OMath) {
|
|
58
|
+
dom.appendChild(p, renderMath.renderOMath(word, child));
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
console.warn('unknow pargraph type', child);
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
|
-
catch (
|
|
65
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
69
66
|
finally {
|
|
70
67
|
try {
|
|
71
|
-
if (
|
|
68
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
72
69
|
}
|
|
73
|
-
finally { if (
|
|
70
|
+
finally { if (e_1) throw e_1.error; }
|
|
74
71
|
}
|
|
75
72
|
// 空行自动加个空格,不然会没高度
|
|
76
73
|
if (p.innerHTML === '' && renderEmptySpace) {
|