Files
fad_oa/ruoyi-ui/public/file-viewer/assets/docx-preview-CbKtHvXt.js

20 lines
73 KiB
JavaScript
Raw Normal View History

import{M as e}from"./package-Bop5TfAT.js";import{t}from"./jszip.min-CoyCHGS6.js";var n=e(t(),1),r;(function(e){e.OfficeDocument=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,e.FontTable=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable`,e.Image=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`,e.Numbering=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering`,e.Styles=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,e.StylesWithEffects=`http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects`,e.Theme=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,e.Settings=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings`,e.WebSettings=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings`,e.Hyperlink=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,e.Footnotes=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes`,e.Endnotes=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes`,e.Footer=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer`,e.Header=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/header`,e.ExtendedProperties=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties`,e.CoreProperties=`http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties`,e.CustomProperties=`http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties`,e.Comments=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/comments`,e.CommentsExtended=`http://schemas.microsoft.com/office/2011/relationships/commentsExtended`,e.AltChunk=`http://schemas.openxmlformats.org/officeDocument/2006/relationships/aFChunk`})(r||={});function i(e,t){return t.elements(e).map(e=>({id:t.attr(e,`Id`),type:t.attr(e,`Type`),target:t.attr(e,`Target`),targetMode:t.attr(e,`TargetMode`)}))}function a(e){return e?.replace(/[ .]+/g,`-`).replace(/[&]+/g,`and`).toLowerCase()}function o(e){return/^[^"'].*\s.*[^"']$/.test(e)?`'${e}'`:e}function s(e){let t=e.lastIndexOf(`/`)+1;return[t==0?``:e.substring(0,t),t==0?e:e.substring(t)]}function c(e,t){try{return new URL(e,`http://docx/`+t).toString().substring(12)}catch{return`${t}${e}`}}function l(e,t){return e.reduce((e,n)=>(e[t(n)]=n,e),{})}function u(e){return new Promise((t,n)=>{let r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=()=>n(),r.readAsDataURL(e)})}function d(e){return e&&typeof e==`object`&&!Array.isArray(e)}function f(e){return typeof e==`string`||e instanceof String}function p(e,...t){if(!t.length)return e;let n=t.shift();if(d(e)&&d(n))for(let t in n)d(n[t])?p(e[t]??(e[t]={}),n[t]):e[t]=n[t];return p(e,...t)}function m(e){return Array.isArray(e)?e:[e]}function h(e,t,n){return t>e?t:n<e?n:e}var g={wordml:`http://schemas.openxmlformats.org/wordprocessingml/2006/main`},_={Dxa:{mul:.05,unit:`pt`},Emu:{mul:1/12700,unit:`pt`},FontSize:{mul:.5,unit:`pt`},Border:{mul:.125,unit:`pt`,min:.25,max:12},Point:{mul:1,unit:`pt`},Percent:{mul:.02,unit:`%`}};function v(e,t=_.Dxa){if(e==null||/.+(p[xt]|[%])$/.test(e))return e;var n=parseInt(e)*t.mul;return t.min&&t.max&&(n=h(n,t.min,t.max)),`${n.toFixed(2)}${t.unit}`}function ee(e,t=!1){switch(e){case`1`:return!0;case`0`:return!1;case`on`:return!0;case`off`:return!1;case`true`:return!0;case`false`:return!1;default:return t}}function y(e,t,n){if(e.namespaceURI!=g.wordml)return!1;switch(e.localName){case`color`:t.color=n.attr(e,`val`);break;case`sz`:t.fontSize=n.lengthAttr(e,`val`,_.FontSize);break;default:return!1}return!0}function te(e,t=!1){t&&(e=e.replace(/<[?].*[?]>/,``)),e=re(e);let n=new DOMParser().parseFromString(e,`application/xml`),r=ne(n);if(r)throw Error(r);return n}function ne(e){return e.getElementsByTagName(`parsererror`)[0]?.textContent}function re(e){return e.charCodeAt(0)===65279?e.substring(1):e}funct
.${e}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }
.${e}-wrapper>section.${e} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }`;this.options.hideWrapperOnPrint&&(t=`@media not print { ${t} }`);var n=`${t}
.${e} { color: black; hyphens: auto; text-underline-position: from-font; }
section.${e} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }
section.${e}>article { margin-bottom: auto; z-index: 1; }
section.${e}>footer { z-index: 1; }
.${e} table { border-collapse: collapse; }
.${e} table td, .${e} table th { vertical-align: top; }
.${e} p { margin: 0pt; min-height: 1em; }
.${e} span { white-space: pre-wrap; overflow-wrap: break-word; }
.${e} a { color: inherit; text-decoration: inherit; }
.${e} svg { fill: transparent; }
`;return this.options.renderComments&&(n+=`
.${e}-comment-ref { cursor: default; }
.${e}-comment-popover { display: none; z-index: 1000; padding: 0.5rem; background: white; position: absolute; box-shadow: 0 0 0.25rem rgba(0, 0, 0, 0.25); width: 30ch; }
.${e}-comment-ref:hover~.${e}-comment-popover { display: block; }
.${e}-comment-author,.${e}-comment-date { font-size: 0.875rem; color: #888; }
`),this.createStyleElement(n)}renderNumbering(e,t){var n=``,r=[];for(var i of e){var a=`p.${this.numberingClass(i.id,i.level)}`,o=`none`;if(i.bullet){let e=`--${this.className}-${i.bullet.src}`.toLowerCase();n+=this.styleToString(`${a}:before`,{content:`' '`,display:`inline-block`,background:`var(${e})`},i.bullet.style),this.tasks.push(this.document.loadNumberingImage(i.bullet.src).then(n=>{var r=`${this.rootSelector} { ${e}: url(${n}) }`;t.appendChild(this.createStyleElement(r))}))}else if(i.levelText){let e=this.numberingCounter(i.id,i.level),t=e+` `+(i.start-1);i.level>0&&(n+=this.styleToString(`p.${this.numberingClass(i.id,i.level-1)}`,{"counter-set":t})),r.push(t),n+=this.styleToString(`${a}:before`,{content:this.levelTextToContent(i.levelText,i.suff,i.id,this.numFormatToCssValue(i.format)),"counter-increment":e,...i.rStyle})}else o=this.numFormatToCssValue(i.format);n+=this.styleToString(a,{display:`list-item`,"list-style-position":`inside`,"list-style-type":o,...i.pStyle})}return r.length>0&&(n+=this.styleToString(this.rootSelector,{"counter-reset":r.join(` `)})),this.createStyleElement(n)}renderStyles(e){var t=``;let n=this.styleMap,r=l(e.filter(e=>e.isDefault),e=>e.target);for(let s of e){var i=s.styles;if(s.linked){var a=s.linked&&n[s.linked];a?i=i.concat(a.styles):this.options.debug&&console.warn(`Can't find linked style ${s.linked}`)}for(let e of i){var o=`${s.target??``}.${s.cssName}`;s.target!=e.target&&(o+=` ${e.target}`),r[s.target]==s&&(o=`.${this.className} ${s.target}, `+o),t+=this.styleToString(o,e.values)}}return this.createStyleElement(t)}renderNotes(e,t,n){var r=e.map(e=>t[e]).filter(e=>e);if(r.length>0){var i=this.createElement(`ol`,null,this.renderElements(r));n.appendChild(i)}}renderElement(e){switch(e.type){case j.Paragraph:return this.renderParagraph(e);case j.BookmarkStart:return this.renderBookmarkStart(e);case j.BookmarkEnd:return null;case j.Run:return this.renderRun(e);case j.Table:return this.renderTable(e);case j.Row:return this.renderTableRow(e);case j.Cell:return this.renderTableCell(e);case j.Hyperlink:return this.renderHyperlink(e);case j.SmartTag:return this.renderSmartTag(e);case j.Drawing:return this.renderDrawing(e);case j.Image:return this.renderImage(e);case j.Text:return this.renderText(e);case j.Text:return this.renderText(e);case j.DeletedText:return this.renderDeletedText(e);case j.Tab:return this.renderTab(e);case j.Symbol:return this.renderSymbol(e);case j.Break:return this.renderBreak(e);case j.Footer:return this.renderContainer(e,`footer`);case j.Header:return this.renderContainer(e,`header`);case j.Footnote:case j.Endnote:return this.renderContainer(e,`li`);case j.FootnoteReference:return this.renderFootnoteReference(e);case j.EndnoteReference:return this.renderEndnoteReference(e);case j.NoBreakHyphen:return this.createElement(`wbr`);case j.VmlPicture:return this.renderVmlPicture(e);case j.VmlElement:return this.renderVmlElement(e);case j.MmlMath:return this.renderContainerNS(e,J.mathML,`math`,{xmlns:J.mathML});case j.MmlMathParagraph:return this.renderContainer(e,`span`);case j.MmlFraction:return this.renderContainerNS(e,J.mathML,`mfrac`);case j.MmlBase:return this.renderContainerNS(e,J.mathML,e.parent.type==j.MmlMatrixRow?`mtd`:`mrow`);case j.MmlNumerator:case j.MmlDenominator:case j.MmlFunction:case j.MmlLimit:case j.MmlBox:return this.renderContainerNS(e,J.mathML,`mrow`);case j.MmlGroupChar:return this.renderMmlGroupChar(e);case j.MmlLimitLower:return this.renderContainerNS(e,J.mathML,`munder`);case j.MmlMatrix:return this.renderContainerNS(e,J.mathML,`mtable`);case j.MmlMatrixRow:return this.renderContainerNS(e,J.mathML,`mtr`);case j.MmlRadical:return this.renderMmlRadical(e);case j.MmlSuperscript:return this.renderContainerNS(e,J.mathML,`msup`);case j.MmlSubscript:return this.renderContainerNS(e,J.mathML,`msub`);case j.MmlDegree:case j.MmlSuperArgument:case j.MmlSubArgument:return this.renderContainerNS(e,J.mathML,`mn`);case j.MmlFunctionName:return this.renderContainerNS(e,J.mathML,`ms`);case j.MmlDelimiter:return this.renderMmlDelimiter(e);case j.MmlRun:retur
`}numberingCounter(e,t){return`${this.className}-num-${e}-${t}`}levelTextToContent(e,t,n,r){return`"${e.replace(/%\d*/g,e=>{let t=parseInt(e.substring(1),10)-1;return`"counter(${this.numberingCounter(n,t)}, ${r})"`})}${{tab:`\\9`,space:`\\a0`}[t]??``}"`}numFormatToCssValue(e){return{none:`none`,bullet:`disc`,decimal:`decimal`,lowerLetter:`lower-alpha`,upperLetter:`upper-alpha`,lowerRoman:`lower-roman`,upperRoman:`upper-roman`,decimalZero:`decimal-leading-zero`,aiueo:`katakana`,aiueoFullWidth:`katakana`,chineseCounting:`simp-chinese-informal`,chineseCountingThousand:`simp-chinese-informal`,chineseLegalSimplified:`simp-chinese-formal`,chosung:`hangul-consonant`,ideographDigital:`cjk-ideographic`,ideographTraditional:`cjk-heavenly-stem`,ideographLegalTraditional:`trad-chinese-formal`,ideographZodiac:`cjk-earthly-branch`,iroha:`katakana-iroha`,irohaFullWidth:`katakana-iroha`,japaneseCounting:`japanese-informal`,japaneseDigitalTenThousand:`cjk-decimal`,japaneseLegal:`japanese-formal`,thaiNumbers:`thai`,koreanCounting:`korean-hangul-formal`,koreanDigital:`korean-hangul-formal`,koreanDigital2:`korean-hanja-informal`,hebrew1:`hebrew`,hebrew2:`hebrew`,hindiNumbers:`devanagari`,ganada:`hangul`,taiwaneseCounting:`cjk-ideographic`,taiwaneseCountingThousand:`cjk-ideographic`,taiwaneseDigital:`cjk-decimal`}[e]??e}refreshTabStops(){this.options.experimental&&setTimeout(()=>{let e=dt();for(let t of this.currentTabs)ft(t.span,t.stops,this.defaultTabSize,e)},500)}createElementNS(e,t,n,r){var i=e?this.htmlDocument.createElementNS(e,t):this.htmlDocument.createElement(t);return Object.assign(i,n),r&&X(i,r),i}createElement(e,t,n){return this.createElementNS(void 0,e,t,n)}createSvgElement(e,t,n){return this.createElementNS(J.svg,e,t,n)}createStyleElement(e){return this.createElement(`style`,{innerHTML:e})}createComment(e){return this.htmlDocument.createComment(e)}later(e){this.postRenderTasks.push(e)}};function Y(e){e.innerHTML=``}function X(e,t){t.forEach(t=>e.appendChild(f(t)?document.createTextNode(t):t))}function mt(e,t){for(var n=e.parent;n!=null&&n.type!=t;)n=n.parent;return n}var Z={ignoreHeight:!1,ignoreWidth:!1,ignoreFonts:!1,breakPages:!0,debug:!1,experimental:!1,className:`docx`,inWrapper:!0,hideWrapperOnPrint:!1,trimXmlDeclaration:!0,ignoreLastRenderedPageBreak:!0,renderHeaders:!0,renderFooters:!0,renderFootnotes:!0,renderEndnotes:!0,useBase64URL:!1,renderChanges:!1,renderComments:!1,renderAltChunks:!0};function Q(e,t){let n={...Z,...t};return Ze.load(e,new ct(n),n)}async function $(e,t,n,r){let i={...Z,...r};return await new pt(window.document).render(e,t,n,i)}async function ht(e,t,n,r){let i=await Q(e,r);return await $(i,t,n,r),i}export{Z as defaultOptions,Q as parseAsync,ht as renderAsync,$ as renderDocument};