docx-preview.js 172 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory(require("jszip"));
  4. else if(typeof define === 'function' && define.amd)
  5. define(["jszip"], factory);
  6. else if(typeof exports === 'object')
  7. exports["docx"] = factory(require("jszip"));
  8. else
  9. root["docx"] = factory(root["JSZip"]);
  10. })(globalThis, (__WEBPACK_EXTERNAL_MODULE_jszip__) => {
  11. return /******/ (() => { // webpackBootstrap
  12. /******/ "use strict";
  13. /******/ var __webpack_modules__ = ({
  14. /***/ "./src/mathml.scss":
  15. /*!*************************!*\
  16. !*** ./src/mathml.scss ***!
  17. \*************************/
  18. /***/ ((module, __webpack_exports__, __webpack_require__) => {
  19. __webpack_require__.r(__webpack_exports__);
  20. /* harmony export */ __webpack_require__.d(__webpack_exports__, {
  21. /* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__)
  22. /* harmony export */ });
  23. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../node_modules/css-loader/dist/runtime/sourceMaps.js */ "./node_modules/css-loader/dist/runtime/sourceMaps.js");
  24. /* harmony import */ var _node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0__);
  25. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../node_modules/css-loader/dist/runtime/api.js */ "./node_modules/css-loader/dist/runtime/api.js");
  26. /* harmony import */ var _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1__);
  27. /* harmony import */ var _node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node_modules/css-loader/dist/runtime/getUrl.js */ "./node_modules/css-loader/dist/runtime/getUrl.js");
  28. /* harmony import */ var _node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2__);
  29. // Imports
  30. var ___CSS_LOADER_URL_IMPORT_0___ = new URL(/* asset import */ __webpack_require__(/*! data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 20 100%27 preserveAspectRatio=%27none%27%3E%3Cpath d=%27m0,75 l5,0 l5,25 l10,-100%27 stroke=%27black%27 fill=%27none%27 vector-effect=%27non-scaling-stroke%27/%3E%3C/svg%3E */ "data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 20 100%27 preserveAspectRatio=%27none%27%3E%3Cpath d=%27m0,75 l5,0 l5,25 l10,-100%27 stroke=%27black%27 fill=%27none%27 vector-effect=%27non-scaling-stroke%27/%3E%3C/svg%3E"), __webpack_require__.b);
  31. var ___CSS_LOADER_EXPORT___ = _node_modules_css_loader_dist_runtime_api_js__WEBPACK_IMPORTED_MODULE_1___default()((_node_modules_css_loader_dist_runtime_sourceMaps_js__WEBPACK_IMPORTED_MODULE_0___default()));
  32. var ___CSS_LOADER_URL_REPLACEMENT_0___ = _node_modules_css_loader_dist_runtime_getUrl_js__WEBPACK_IMPORTED_MODULE_2___default()(___CSS_LOADER_URL_IMPORT_0___);
  33. // Module
  34. ___CSS_LOADER_EXPORT___.push([module.id, "@namespace \"http://www.w3.org/1998/Math/MathML\";\nmath {\n display: inline-block;\n line-height: initial;\n}\n\nmfrac {\n display: inline-block;\n vertical-align: -50%;\n text-align: center;\n}\nmfrac > :first-child {\n border-bottom: solid thin currentColor;\n}\nmfrac > * {\n display: block;\n}\n\nmsub > :nth-child(2) {\n font-size: smaller;\n vertical-align: sub;\n}\n\nmsup > :nth-child(2) {\n font-size: smaller;\n vertical-align: super;\n}\n\nmunder, mover, munderover {\n display: inline-flex;\n flex-flow: column nowrap;\n vertical-align: middle;\n text-align: center;\n}\nmunder > :not(:first-child), mover > :not(:first-child), munderover > :not(:first-child) {\n font-size: smaller;\n}\n\nmunderover > :last-child {\n order: -1;\n}\n\nmroot, msqrt {\n position: relative;\n display: inline-block;\n border-top: solid thin currentColor;\n margin-top: 0.5px;\n vertical-align: middle;\n margin-left: 1ch;\n}\nmroot:before, msqrt:before {\n content: \"\";\n display: inline-block;\n position: absolute;\n width: 1ch;\n left: -1ch;\n top: -1px;\n bottom: 0;\n background-image: url(" + ___CSS_LOADER_URL_REPLACEMENT_0___ + ");\n}", "",{"version":3,"sources":["webpack://./src/mathml.scss"],"names":[],"mappings":"AAAA,+CAAA;AAEA;EACI,qBAAA;EACA,oBAAA;AAAJ;;AAGA;EACI,qBAAA;EACA,oBAAA;EACA,kBAAA;AAAJ;AAEI;EACI,sCAAA;AAAR;AAGI;EACI,cAAA;AADR;;AAMI;EACI,kBAAA;EACA,mBAAA;AAHR;;AAQI;EACI,kBAAA;EACA,qBAAA;AALR;;AASA;EACI,oBAAA;EACA,wBAAA;EACA,sBAAA;EACA,kBAAA;AANJ;AAQI;EACI,kBAAA;AANR;;AAWI;EAAgB,SAAA;AAPpB;;AAUA;EACI,kBAAA;EACA,qBAAA;EACA,mCAAA;EACA,iBAAA;EACA,sBAAA;EACA,gBAAA;AAPJ;AASI;EACI,WAAA;EACA,qBAAA;EACA,kBAAA;EACA,UAAA;EACA,UAAA;EACA,SAAA;EACA,SAAA;EACA,yDAAA;AAPR","sourcesContent":["@namespace \"http://www.w3.org/1998/Math/MathML\";\r\n\r\nmath {\r\n display: inline-block;\r\n line-height: initial;\r\n}\r\n\r\nmfrac {\r\n display: inline-block;\r\n vertical-align: -50%;\r\n text-align: center;\r\n\r\n &>:first-child {\r\n border-bottom: solid thin currentColor;\r\n }\r\n\r\n &>* {\r\n display: block;\r\n }\r\n}\r\n\r\nmsub {\r\n &>:nth-child(2) {\r\n font-size: smaller;\r\n vertical-align: sub;\r\n }\r\n}\r\n\r\nmsup {\r\n &>:nth-child(2) {\r\n font-size: smaller;\r\n vertical-align: super;\r\n }\r\n}\r\n\r\nmunder, mover, munderover {\r\n display: inline-flex;\r\n flex-flow: column nowrap;\r\n vertical-align: middle;\r\n text-align: center;\r\n\r\n &>:not(:first-child) {\r\n font-size: smaller;\r\n }\r\n}\r\n\r\nmunderover {\r\n &>:last-child { order: -1; }\r\n}\r\n\r\nmroot, msqrt {\r\n position: relative;\r\n display: inline-block;\r\n border-top: solid thin currentColor; \r\n margin-top: 0.5px;\r\n vertical-align: middle; \r\n margin-left: 1ch; \r\n\r\n &:before {\r\n content: \"\";\r\n display: inline-block;\r\n position: absolute;\r\n width: 1ch;\r\n left: -1ch;\r\n top: -1px;\r\n bottom: 0;\r\n background-image: url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 100' preserveAspectRatio='none'%3E%3Cpath d='m0,75 l5,0 l5,25 l10,-100' stroke='black' fill='none' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E\");\r\n }\r\n}"],"sourceRoot":""}]);
  35. // Exports
  36. /* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (___CSS_LOADER_EXPORT___.toString());
  37. /***/ }),
  38. /***/ "./node_modules/css-loader/dist/runtime/api.js":
  39. /*!*****************************************************!*\
  40. !*** ./node_modules/css-loader/dist/runtime/api.js ***!
  41. \*****************************************************/
  42. /***/ ((module) => {
  43. /*
  44. MIT License http://www.opensource.org/licenses/mit-license.php
  45. Author Tobias Koppers @sokra
  46. */
  47. module.exports = function (cssWithMappingToString) {
  48. var list = [];
  49. // return the list of modules as css string
  50. list.toString = function toString() {
  51. return this.map(function (item) {
  52. var content = "";
  53. var needLayer = typeof item[5] !== "undefined";
  54. if (item[4]) {
  55. content += "@supports (".concat(item[4], ") {");
  56. }
  57. if (item[2]) {
  58. content += "@media ".concat(item[2], " {");
  59. }
  60. if (needLayer) {
  61. content += "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {");
  62. }
  63. content += cssWithMappingToString(item);
  64. if (needLayer) {
  65. content += "}";
  66. }
  67. if (item[2]) {
  68. content += "}";
  69. }
  70. if (item[4]) {
  71. content += "}";
  72. }
  73. return content;
  74. }).join("");
  75. };
  76. // import a list of modules into the list
  77. list.i = function i(modules, media, dedupe, supports, layer) {
  78. if (typeof modules === "string") {
  79. modules = [[null, modules, undefined]];
  80. }
  81. var alreadyImportedModules = {};
  82. if (dedupe) {
  83. for (var k = 0; k < this.length; k++) {
  84. var id = this[k][0];
  85. if (id != null) {
  86. alreadyImportedModules[id] = true;
  87. }
  88. }
  89. }
  90. for (var _k = 0; _k < modules.length; _k++) {
  91. var item = [].concat(modules[_k]);
  92. if (dedupe && alreadyImportedModules[item[0]]) {
  93. continue;
  94. }
  95. if (typeof layer !== "undefined") {
  96. if (typeof item[5] === "undefined") {
  97. item[5] = layer;
  98. } else {
  99. item[1] = "@layer".concat(item[5].length > 0 ? " ".concat(item[5]) : "", " {").concat(item[1], "}");
  100. item[5] = layer;
  101. }
  102. }
  103. if (media) {
  104. if (!item[2]) {
  105. item[2] = media;
  106. } else {
  107. item[1] = "@media ".concat(item[2], " {").concat(item[1], "}");
  108. item[2] = media;
  109. }
  110. }
  111. if (supports) {
  112. if (!item[4]) {
  113. item[4] = "".concat(supports);
  114. } else {
  115. item[1] = "@supports (".concat(item[4], ") {").concat(item[1], "}");
  116. item[4] = supports;
  117. }
  118. }
  119. list.push(item);
  120. }
  121. };
  122. return list;
  123. };
  124. /***/ }),
  125. /***/ "./node_modules/css-loader/dist/runtime/getUrl.js":
  126. /*!********************************************************!*\
  127. !*** ./node_modules/css-loader/dist/runtime/getUrl.js ***!
  128. \********************************************************/
  129. /***/ ((module) => {
  130. module.exports = function (url, options) {
  131. if (!options) {
  132. options = {};
  133. }
  134. if (!url) {
  135. return url;
  136. }
  137. url = String(url.__esModule ? url.default : url);
  138. // If url is already wrapped in quotes, remove them
  139. if (/^['"].*['"]$/.test(url)) {
  140. url = url.slice(1, -1);
  141. }
  142. if (options.hash) {
  143. url += options.hash;
  144. }
  145. // Should url be wrapped?
  146. // See https://drafts.csswg.org/css-values-3/#urls
  147. if (/["'() \t\n]|(%20)/.test(url) || options.needQuotes) {
  148. return "\"".concat(url.replace(/"/g, '\\"').replace(/\n/g, "\\n"), "\"");
  149. }
  150. return url;
  151. };
  152. /***/ }),
  153. /***/ "./node_modules/css-loader/dist/runtime/sourceMaps.js":
  154. /*!************************************************************!*\
  155. !*** ./node_modules/css-loader/dist/runtime/sourceMaps.js ***!
  156. \************************************************************/
  157. /***/ ((module) => {
  158. module.exports = function (item) {
  159. var content = item[1];
  160. var cssMapping = item[3];
  161. if (!cssMapping) {
  162. return content;
  163. }
  164. if (typeof btoa === "function") {
  165. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(cssMapping))));
  166. var data = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(base64);
  167. var sourceMapping = "/*# ".concat(data, " */");
  168. return [content].concat([sourceMapping]).join("\n");
  169. }
  170. return [content].join("\n");
  171. };
  172. /***/ }),
  173. /***/ "./src/common/open-xml-package.ts":
  174. /*!****************************************!*\
  175. !*** ./src/common/open-xml-package.ts ***!
  176. \****************************************/
  177. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  178. Object.defineProperty(exports, "__esModule", ({ value: true }));
  179. exports.OpenXmlPackage = void 0;
  180. const JSZip = __webpack_require__(/*! jszip */ "jszip");
  181. const xml_parser_1 = __webpack_require__(/*! ../parser/xml-parser */ "./src/parser/xml-parser.ts");
  182. const utils_1 = __webpack_require__(/*! ../utils */ "./src/utils.ts");
  183. const relationship_1 = __webpack_require__(/*! ./relationship */ "./src/common/relationship.ts");
  184. class OpenXmlPackage {
  185. constructor(_zip, options) {
  186. this._zip = _zip;
  187. this.options = options;
  188. this.xmlParser = new xml_parser_1.XmlParser();
  189. }
  190. get(path) {
  191. return this._zip.files[normalizePath(path)];
  192. }
  193. update(path, content) {
  194. this._zip.file(path, content);
  195. }
  196. static load(input, options) {
  197. return JSZip.loadAsync(input).then(zip => new OpenXmlPackage(zip, options));
  198. }
  199. save(type = "blob") {
  200. return this._zip.generateAsync({ type });
  201. }
  202. load(path, type = "string") {
  203. var _a, _b;
  204. return (_b = (_a = this.get(path)) === null || _a === void 0 ? void 0 : _a.async(type)) !== null && _b !== void 0 ? _b : Promise.resolve(null);
  205. }
  206. loadRelationships(path = null) {
  207. let relsPath = `_rels/.rels`;
  208. if (path != null) {
  209. const [f, fn] = (0, utils_1.splitPath)(path);
  210. relsPath = `${f}_rels/${fn}.rels`;
  211. }
  212. return this.load(relsPath)
  213. .then(txt => txt ? (0, relationship_1.parseRelationships)(this.parseXmlDocument(txt).firstElementChild, this.xmlParser) : null);
  214. }
  215. parseXmlDocument(txt) {
  216. return (0, xml_parser_1.parseXmlString)(txt, this.options.trimXmlDeclaration);
  217. }
  218. }
  219. exports.OpenXmlPackage = OpenXmlPackage;
  220. function normalizePath(path) {
  221. return path.startsWith('/') ? path.substr(1) : path;
  222. }
  223. /***/ }),
  224. /***/ "./src/common/part.ts":
  225. /*!****************************!*\
  226. !*** ./src/common/part.ts ***!
  227. \****************************/
  228. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  229. Object.defineProperty(exports, "__esModule", ({ value: true }));
  230. exports.Part = void 0;
  231. const xml_parser_1 = __webpack_require__(/*! ../parser/xml-parser */ "./src/parser/xml-parser.ts");
  232. class Part {
  233. constructor(_package, path) {
  234. this._package = _package;
  235. this.path = path;
  236. }
  237. load() {
  238. return Promise.all([
  239. this._package.loadRelationships(this.path).then(rels => {
  240. this.rels = rels;
  241. }),
  242. this._package.load(this.path).then(text => {
  243. const xmlDoc = this._package.parseXmlDocument(text);
  244. if (this._package.options.keepOrigin) {
  245. this._xmlDocument = xmlDoc;
  246. }
  247. this.parseXml(xmlDoc.firstElementChild);
  248. })
  249. ]);
  250. }
  251. save() {
  252. this._package.update(this.path, (0, xml_parser_1.serializeXmlString)(this._xmlDocument));
  253. }
  254. parseXml(root) {
  255. }
  256. }
  257. exports.Part = Part;
  258. /***/ }),
  259. /***/ "./src/common/relationship.ts":
  260. /*!************************************!*\
  261. !*** ./src/common/relationship.ts ***!
  262. \************************************/
  263. /***/ ((__unused_webpack_module, exports) => {
  264. Object.defineProperty(exports, "__esModule", ({ value: true }));
  265. exports.parseRelationships = exports.RelationshipTypes = void 0;
  266. var RelationshipTypes;
  267. (function (RelationshipTypes) {
  268. RelationshipTypes["OfficeDocument"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
  269. RelationshipTypes["FontTable"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable";
  270. RelationshipTypes["Image"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/image";
  271. RelationshipTypes["Numbering"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
  272. RelationshipTypes["Styles"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
  273. RelationshipTypes["StylesWithEffects"] = "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects";
  274. RelationshipTypes["Theme"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
  275. RelationshipTypes["Settings"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings";
  276. RelationshipTypes["WebSettings"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings";
  277. RelationshipTypes["Hyperlink"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
  278. RelationshipTypes["Footnotes"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes";
  279. RelationshipTypes["Endnotes"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes";
  280. RelationshipTypes["Footer"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer";
  281. RelationshipTypes["Header"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header";
  282. RelationshipTypes["ExtendedProperties"] = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties";
  283. RelationshipTypes["CoreProperties"] = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties";
  284. RelationshipTypes["CustomProperties"] = "http://schemas.openxmlformats.org/package/2006/relationships/metadata/custom-properties";
  285. })(RelationshipTypes = exports.RelationshipTypes || (exports.RelationshipTypes = {}));
  286. function parseRelationships(root, xml) {
  287. return xml.elements(root).map(e => ({
  288. id: xml.attr(e, "Id"),
  289. type: xml.attr(e, "Type"),
  290. target: xml.attr(e, "Target"),
  291. targetMode: xml.attr(e, "TargetMode")
  292. }));
  293. }
  294. exports.parseRelationships = parseRelationships;
  295. /***/ }),
  296. /***/ "./src/document-parser.ts":
  297. /*!********************************!*\
  298. !*** ./src/document-parser.ts ***!
  299. \********************************/
  300. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  301. Object.defineProperty(exports, "__esModule", ({ value: true }));
  302. exports.DocumentParser = exports.autos = void 0;
  303. const dom_1 = __webpack_require__(/*! ./document/dom */ "./src/document/dom.ts");
  304. const paragraph_1 = __webpack_require__(/*! ./document/paragraph */ "./src/document/paragraph.ts");
  305. const section_1 = __webpack_require__(/*! ./document/section */ "./src/document/section.ts");
  306. const xml_parser_1 = __webpack_require__(/*! ./parser/xml-parser */ "./src/parser/xml-parser.ts");
  307. const run_1 = __webpack_require__(/*! ./document/run */ "./src/document/run.ts");
  308. const bookmarks_1 = __webpack_require__(/*! ./document/bookmarks */ "./src/document/bookmarks.ts");
  309. const common_1 = __webpack_require__(/*! ./document/common */ "./src/document/common.ts");
  310. const vml_1 = __webpack_require__(/*! ./vml/vml */ "./src/vml/vml.ts");
  311. exports.autos = {
  312. shd: "inherit",
  313. color: "black",
  314. borderColor: "black",
  315. highlight: "transparent"
  316. };
  317. const supportedNamespaceURIs = [];
  318. const mmlTagMap = {
  319. "oMath": dom_1.DomType.MmlMath,
  320. "oMathPara": dom_1.DomType.MmlMathParagraph,
  321. "f": dom_1.DomType.MmlFraction,
  322. "num": dom_1.DomType.MmlNumerator,
  323. "den": dom_1.DomType.MmlDenominator,
  324. "rad": dom_1.DomType.MmlRadical,
  325. "deg": dom_1.DomType.MmlDegree,
  326. "e": dom_1.DomType.MmlBase,
  327. "sSup": dom_1.DomType.MmlSuperscript,
  328. "sSub": dom_1.DomType.MmlSubscript,
  329. "sup": dom_1.DomType.MmlSuperArgument,
  330. "sub": dom_1.DomType.MmlSubArgument,
  331. "d": dom_1.DomType.MmlDelimiter,
  332. "nary": dom_1.DomType.MmlNary,
  333. };
  334. class DocumentParser {
  335. constructor(options) {
  336. this.options = Object.assign({ ignoreWidth: false, debug: false }, options);
  337. }
  338. parseNotes(xmlDoc, elemName, elemClass) {
  339. var result = [];
  340. for (let el of xml_parser_1.default.elements(xmlDoc, elemName)) {
  341. const node = new elemClass();
  342. node.id = xml_parser_1.default.attr(el, "id");
  343. node.noteType = xml_parser_1.default.attr(el, "type");
  344. node.children = this.parseBodyElements(el);
  345. result.push(node);
  346. }
  347. return result;
  348. }
  349. parseDocumentFile(xmlDoc) {
  350. var xbody = xml_parser_1.default.element(xmlDoc, "body");
  351. var background = xml_parser_1.default.element(xmlDoc, "background");
  352. var sectPr = xml_parser_1.default.element(xbody, "sectPr");
  353. return {
  354. type: dom_1.DomType.Document,
  355. children: this.parseBodyElements(xbody),
  356. props: sectPr ? (0, section_1.parseSectionProperties)(sectPr, xml_parser_1.default) : {},
  357. cssStyle: background ? this.parseBackground(background) : {},
  358. };
  359. }
  360. parseBackground(elem) {
  361. var result = {};
  362. var color = xmlUtil.colorAttr(elem, "color");
  363. if (color) {
  364. result["background-color"] = color;
  365. }
  366. return result;
  367. }
  368. parseBodyElements(element) {
  369. var children = [];
  370. for (let elem of xml_parser_1.default.elements(element)) {
  371. switch (elem.localName) {
  372. case "p":
  373. children.push(this.parseParagraph(elem));
  374. break;
  375. case "tbl":
  376. children.push(this.parseTable(elem));
  377. break;
  378. case "sdt":
  379. children.push(...this.parseSdt(elem, e => this.parseBodyElements(e)));
  380. break;
  381. }
  382. }
  383. return children;
  384. }
  385. parseStylesFile(xstyles) {
  386. var result = [];
  387. xmlUtil.foreach(xstyles, n => {
  388. switch (n.localName) {
  389. case "style":
  390. result.push(this.parseStyle(n));
  391. break;
  392. case "docDefaults":
  393. result.push(this.parseDefaultStyles(n));
  394. break;
  395. }
  396. });
  397. return result;
  398. }
  399. parseDefaultStyles(node) {
  400. var result = {
  401. id: null,
  402. name: null,
  403. target: null,
  404. basedOn: null,
  405. styles: []
  406. };
  407. xmlUtil.foreach(node, c => {
  408. switch (c.localName) {
  409. case "rPrDefault":
  410. var rPr = xml_parser_1.default.element(c, "rPr");
  411. if (rPr)
  412. result.styles.push({
  413. target: "span",
  414. values: this.parseDefaultProperties(rPr, {})
  415. });
  416. break;
  417. case "pPrDefault":
  418. var pPr = xml_parser_1.default.element(c, "pPr");
  419. if (pPr)
  420. result.styles.push({
  421. target: "p",
  422. values: this.parseDefaultProperties(pPr, {})
  423. });
  424. break;
  425. }
  426. });
  427. return result;
  428. }
  429. parseStyle(node) {
  430. var result = {
  431. id: xml_parser_1.default.attr(node, "styleId"),
  432. isDefault: xml_parser_1.default.boolAttr(node, "default"),
  433. name: null,
  434. target: null,
  435. basedOn: null,
  436. styles: [],
  437. linked: null
  438. };
  439. switch (xml_parser_1.default.attr(node, "type")) {
  440. case "paragraph":
  441. result.target = "p";
  442. break;
  443. case "table":
  444. result.target = "table";
  445. break;
  446. case "character":
  447. result.target = "span";
  448. break;
  449. }
  450. xmlUtil.foreach(node, n => {
  451. switch (n.localName) {
  452. case "basedOn":
  453. result.basedOn = xml_parser_1.default.attr(n, "val");
  454. break;
  455. case "name":
  456. result.name = xml_parser_1.default.attr(n, "val");
  457. break;
  458. case "link":
  459. result.linked = xml_parser_1.default.attr(n, "val");
  460. break;
  461. case "next":
  462. result.next = xml_parser_1.default.attr(n, "val");
  463. break;
  464. case "aliases":
  465. result.aliases = xml_parser_1.default.attr(n, "val").split(",");
  466. break;
  467. case "pPr":
  468. result.styles.push({
  469. target: "p",
  470. values: this.parseDefaultProperties(n, {})
  471. });
  472. result.paragraphProps = (0, paragraph_1.parseParagraphProperties)(n, xml_parser_1.default);
  473. break;
  474. case "rPr":
  475. result.styles.push({
  476. target: "span",
  477. values: this.parseDefaultProperties(n, {})
  478. });
  479. result.runProps = (0, run_1.parseRunProperties)(n, xml_parser_1.default);
  480. break;
  481. case "tblPr":
  482. case "tcPr":
  483. result.styles.push({
  484. target: "td",
  485. values: this.parseDefaultProperties(n, {})
  486. });
  487. break;
  488. case "tblStylePr":
  489. for (let s of this.parseTableStyle(n))
  490. result.styles.push(s);
  491. break;
  492. case "rsid":
  493. case "qFormat":
  494. case "hidden":
  495. case "semiHidden":
  496. case "unhideWhenUsed":
  497. case "autoRedefine":
  498. case "uiPriority":
  499. break;
  500. default:
  501. this.options.debug && console.warn(`DOCX: Unknown style element: ${n.localName}`);
  502. }
  503. });
  504. return result;
  505. }
  506. parseTableStyle(node) {
  507. var result = [];
  508. var type = xml_parser_1.default.attr(node, "type");
  509. var selector = "";
  510. var modificator = "";
  511. switch (type) {
  512. case "firstRow":
  513. modificator = ".first-row";
  514. selector = "tr.first-row td";
  515. break;
  516. case "lastRow":
  517. modificator = ".last-row";
  518. selector = "tr.last-row td";
  519. break;
  520. case "firstCol":
  521. modificator = ".first-col";
  522. selector = "td.first-col";
  523. break;
  524. case "lastCol":
  525. modificator = ".last-col";
  526. selector = "td.last-col";
  527. break;
  528. case "band1Vert":
  529. modificator = ":not(.no-vband)";
  530. selector = "td.odd-col";
  531. break;
  532. case "band2Vert":
  533. modificator = ":not(.no-vband)";
  534. selector = "td.even-col";
  535. break;
  536. case "band1Horz":
  537. modificator = ":not(.no-hband)";
  538. selector = "tr.odd-row";
  539. break;
  540. case "band2Horz":
  541. modificator = ":not(.no-hband)";
  542. selector = "tr.even-row";
  543. break;
  544. default: return [];
  545. }
  546. xmlUtil.foreach(node, n => {
  547. switch (n.localName) {
  548. case "pPr":
  549. result.push({
  550. target: `${selector} p`,
  551. mod: modificator,
  552. values: this.parseDefaultProperties(n, {})
  553. });
  554. break;
  555. case "rPr":
  556. result.push({
  557. target: `${selector} span`,
  558. mod: modificator,
  559. values: this.parseDefaultProperties(n, {})
  560. });
  561. break;
  562. case "tblPr":
  563. case "tcPr":
  564. result.push({
  565. target: selector,
  566. mod: modificator,
  567. values: this.parseDefaultProperties(n, {})
  568. });
  569. break;
  570. }
  571. });
  572. return result;
  573. }
  574. parseNumberingFile(xnums) {
  575. var result = [];
  576. var mapping = {};
  577. var bullets = [];
  578. xmlUtil.foreach(xnums, n => {
  579. switch (n.localName) {
  580. case "abstractNum":
  581. this.parseAbstractNumbering(n, bullets)
  582. .forEach(x => result.push(x));
  583. break;
  584. case "numPicBullet":
  585. bullets.push(this.parseNumberingPicBullet(n));
  586. break;
  587. case "num":
  588. var numId = xml_parser_1.default.attr(n, "numId");
  589. var abstractNumId = xml_parser_1.default.elementAttr(n, "abstractNumId", "val");
  590. mapping[abstractNumId] = numId;
  591. break;
  592. }
  593. });
  594. result.forEach(x => x.id = mapping[x.id]);
  595. return result;
  596. }
  597. parseNumberingPicBullet(elem) {
  598. var pict = xml_parser_1.default.element(elem, "pict");
  599. var shape = pict && xml_parser_1.default.element(pict, "shape");
  600. var imagedata = shape && xml_parser_1.default.element(shape, "imagedata");
  601. return imagedata ? {
  602. id: xml_parser_1.default.intAttr(elem, "numPicBulletId"),
  603. src: xml_parser_1.default.attr(imagedata, "id"),
  604. style: xml_parser_1.default.attr(shape, "style")
  605. } : null;
  606. }
  607. parseAbstractNumbering(node, bullets) {
  608. var result = [];
  609. var id = xml_parser_1.default.attr(node, "abstractNumId");
  610. xmlUtil.foreach(node, n => {
  611. switch (n.localName) {
  612. case "lvl":
  613. result.push(this.parseNumberingLevel(id, n, bullets));
  614. break;
  615. }
  616. });
  617. return result;
  618. }
  619. parseNumberingLevel(id, node, bullets) {
  620. var result = {
  621. id: id,
  622. level: xml_parser_1.default.intAttr(node, "ilvl"),
  623. pStyleName: undefined,
  624. pStyle: {},
  625. rStyle: {},
  626. suff: "tab"
  627. };
  628. xmlUtil.foreach(node, n => {
  629. switch (n.localName) {
  630. case "pPr":
  631. this.parseDefaultProperties(n, result.pStyle);
  632. break;
  633. case "rPr":
  634. this.parseDefaultProperties(n, result.rStyle);
  635. break;
  636. case "lvlPicBulletId":
  637. var id = xml_parser_1.default.intAttr(n, "val");
  638. result.bullet = bullets.find(x => x.id == id);
  639. break;
  640. case "lvlText":
  641. result.levelText = xml_parser_1.default.attr(n, "val");
  642. break;
  643. case "pStyle":
  644. result.pStyleName = xml_parser_1.default.attr(n, "val");
  645. break;
  646. case "numFmt":
  647. result.format = xml_parser_1.default.attr(n, "val");
  648. break;
  649. case "suff":
  650. result.suff = xml_parser_1.default.attr(n, "val");
  651. break;
  652. }
  653. });
  654. return result;
  655. }
  656. parseSdt(node, parser) {
  657. const sdtContent = xml_parser_1.default.element(node, "sdtContent");
  658. return sdtContent ? parser(sdtContent) : [];
  659. }
  660. parseInserted(node, parentParser) {
  661. var _a, _b;
  662. return {
  663. type: dom_1.DomType.Inserted,
  664. children: (_b = (_a = parentParser(node)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []
  665. };
  666. }
  667. parseDeleted(node, parentParser) {
  668. var _a, _b;
  669. return {
  670. type: dom_1.DomType.Deleted,
  671. children: (_b = (_a = parentParser(node)) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : []
  672. };
  673. }
  674. parseParagraph(node) {
  675. var result = { type: dom_1.DomType.Paragraph, children: [] };
  676. for (let el of xml_parser_1.default.elements(node)) {
  677. switch (el.localName) {
  678. case "pPr":
  679. this.parseParagraphProperties(el, result);
  680. break;
  681. case "r":
  682. result.children.push(this.parseRun(el, result));
  683. break;
  684. case "hyperlink":
  685. result.children.push(this.parseHyperlink(el, result));
  686. break;
  687. case "bookmarkStart":
  688. result.children.push((0, bookmarks_1.parseBookmarkStart)(el, xml_parser_1.default));
  689. break;
  690. case "bookmarkEnd":
  691. result.children.push((0, bookmarks_1.parseBookmarkEnd)(el, xml_parser_1.default));
  692. break;
  693. case "oMath":
  694. case "oMathPara":
  695. result.children.push(this.parseMathElement(el));
  696. break;
  697. case "sdt":
  698. result.children.push(...this.parseSdt(el, e => this.parseParagraph(e).children));
  699. break;
  700. case "ins":
  701. result.children.push(this.parseInserted(el, e => this.parseParagraph(e)));
  702. break;
  703. case "del":
  704. result.children.push(this.parseDeleted(el, e => this.parseParagraph(e)));
  705. break;
  706. }
  707. }
  708. return result;
  709. }
  710. parseParagraphProperties(elem, paragraph) {
  711. this.parseDefaultProperties(elem, paragraph.cssStyle = {}, null, c => {
  712. if ((0, paragraph_1.parseParagraphProperty)(c, paragraph, xml_parser_1.default))
  713. return true;
  714. switch (c.localName) {
  715. case "pStyle":
  716. paragraph.styleName = xml_parser_1.default.attr(c, "val");
  717. break;
  718. case "cnfStyle":
  719. paragraph.className = values.classNameOfCnfStyle(c);
  720. break;
  721. case "framePr":
  722. this.parseFrame(c, paragraph);
  723. break;
  724. case "rPr":
  725. break;
  726. default:
  727. return false;
  728. }
  729. return true;
  730. });
  731. }
  732. parseFrame(node, paragraph) {
  733. var dropCap = xml_parser_1.default.attr(node, "dropCap");
  734. if (dropCap == "drop")
  735. paragraph.cssStyle["float"] = "left";
  736. }
  737. parseHyperlink(node, parent) {
  738. var result = { type: dom_1.DomType.Hyperlink, parent: parent, children: [] };
  739. var anchor = xml_parser_1.default.attr(node, "anchor");
  740. var relId = xml_parser_1.default.attr(node, "id");
  741. if (anchor)
  742. result.href = "#" + anchor;
  743. if (relId)
  744. result.id = relId;
  745. xmlUtil.foreach(node, c => {
  746. switch (c.localName) {
  747. case "r":
  748. result.children.push(this.parseRun(c, result));
  749. break;
  750. }
  751. });
  752. return result;
  753. }
  754. parseRun(node, parent) {
  755. var result = { type: dom_1.DomType.Run, parent: parent, children: [] };
  756. xmlUtil.foreach(node, c => {
  757. c = this.checkAlternateContent(c);
  758. switch (c.localName) {
  759. case "t":
  760. result.children.push({
  761. type: dom_1.DomType.Text,
  762. text: c.textContent
  763. });
  764. break;
  765. case "delText":
  766. result.children.push({
  767. type: dom_1.DomType.DeletedText,
  768. text: c.textContent
  769. });
  770. break;
  771. case "fldSimple":
  772. result.children.push({
  773. type: dom_1.DomType.SimpleField,
  774. instruction: xml_parser_1.default.attr(c, "instr"),
  775. lock: xml_parser_1.default.boolAttr(c, "lock", false),
  776. dirty: xml_parser_1.default.boolAttr(c, "dirty", false)
  777. });
  778. break;
  779. case "instrText":
  780. result.fieldRun = true;
  781. result.children.push({
  782. type: dom_1.DomType.Instruction,
  783. text: c.textContent
  784. });
  785. break;
  786. case "fldChar":
  787. result.fieldRun = true;
  788. result.children.push({
  789. type: dom_1.DomType.ComplexField,
  790. charType: xml_parser_1.default.attr(c, "fldCharType"),
  791. lock: xml_parser_1.default.boolAttr(c, "lock", false),
  792. dirty: xml_parser_1.default.boolAttr(c, "dirty", false)
  793. });
  794. break;
  795. case "noBreakHyphen":
  796. result.children.push({ type: dom_1.DomType.NoBreakHyphen });
  797. break;
  798. case "br":
  799. result.children.push({
  800. type: dom_1.DomType.Break,
  801. break: xml_parser_1.default.attr(c, "type") || "textWrapping"
  802. });
  803. break;
  804. case "lastRenderedPageBreak":
  805. result.children.push({
  806. type: dom_1.DomType.Break,
  807. break: "lastRenderedPageBreak"
  808. });
  809. break;
  810. case "sym":
  811. result.children.push({
  812. type: dom_1.DomType.Symbol,
  813. font: xml_parser_1.default.attr(c, "font"),
  814. char: xml_parser_1.default.attr(c, "char")
  815. });
  816. break;
  817. case "tab":
  818. result.children.push({ type: dom_1.DomType.Tab });
  819. break;
  820. case "footnoteReference":
  821. result.children.push({
  822. type: dom_1.DomType.FootnoteReference,
  823. id: xml_parser_1.default.attr(c, "id")
  824. });
  825. break;
  826. case "endnoteReference":
  827. result.children.push({
  828. type: dom_1.DomType.EndnoteReference,
  829. id: xml_parser_1.default.attr(c, "id")
  830. });
  831. break;
  832. case "drawing":
  833. let d = this.parseDrawing(c);
  834. if (d)
  835. result.children = [d];
  836. break;
  837. case "pict":
  838. result.children.push(this.parseVmlPicture(c));
  839. break;
  840. case "rPr":
  841. this.parseRunProperties(c, result);
  842. break;
  843. }
  844. });
  845. return result;
  846. }
  847. parseMathElement(elem) {
  848. const propsTag = `${elem.localName}Pr`;
  849. const result = { type: mmlTagMap[elem.localName], children: [] };
  850. for (const el of xml_parser_1.default.elements(elem)) {
  851. const childType = mmlTagMap[el.localName];
  852. if (childType) {
  853. result.children.push(this.parseMathElement(el));
  854. }
  855. else if (el.localName == "r") {
  856. var run = this.parseRun(el);
  857. run.type = dom_1.DomType.MmlRun;
  858. result.children.push(run);
  859. }
  860. else if (el.localName == propsTag) {
  861. result.props = this.parseMathProperies(el);
  862. }
  863. }
  864. return result;
  865. }
  866. parseMathProperies(elem) {
  867. const result = {};
  868. for (const el of xml_parser_1.default.elements(elem)) {
  869. switch (el.localName) {
  870. case "chr":
  871. result.char = xml_parser_1.default.attr(el, "val");
  872. break;
  873. case "degHide":
  874. result.hideDegree = xml_parser_1.default.boolAttr(el, "val");
  875. break;
  876. case "begChr":
  877. result.beginChar = xml_parser_1.default.attr(el, "val");
  878. break;
  879. case "endChr":
  880. result.endChar = xml_parser_1.default.attr(el, "val");
  881. break;
  882. }
  883. }
  884. return result;
  885. }
  886. parseRunProperties(elem, run) {
  887. this.parseDefaultProperties(elem, run.cssStyle = {}, null, c => {
  888. switch (c.localName) {
  889. case "rStyle":
  890. run.styleName = xml_parser_1.default.attr(c, "val");
  891. break;
  892. case "vertAlign":
  893. run.verticalAlign = values.valueOfVertAlign(c, true);
  894. break;
  895. default:
  896. return false;
  897. }
  898. return true;
  899. });
  900. }
  901. parseVmlPicture(elem) {
  902. const result = { type: dom_1.DomType.VmlPicture, children: [] };
  903. for (const el of xml_parser_1.default.elements(elem)) {
  904. const child = (0, vml_1.parseVmlElement)(el);
  905. child && result.children.push(child);
  906. }
  907. return result;
  908. }
  909. checkAlternateContent(elem) {
  910. var _a;
  911. if (elem.localName != 'AlternateContent')
  912. return elem;
  913. var choice = xml_parser_1.default.element(elem, "Choice");
  914. if (choice) {
  915. var requires = xml_parser_1.default.attr(choice, "Requires");
  916. var namespaceURI = elem.lookupNamespaceURI(requires);
  917. if (supportedNamespaceURIs.includes(namespaceURI))
  918. return choice.firstElementChild;
  919. }
  920. return (_a = xml_parser_1.default.element(elem, "Fallback")) === null || _a === void 0 ? void 0 : _a.firstElementChild;
  921. }
  922. parseDrawing(node) {
  923. for (var n of xml_parser_1.default.elements(node)) {
  924. switch (n.localName) {
  925. case "inline":
  926. case "anchor":
  927. return this.parseDrawingWrapper(n);
  928. }
  929. }
  930. }
  931. parseDrawingWrapper(node) {
  932. var _a;
  933. var result = { type: dom_1.DomType.Drawing, children: [], cssStyle: {} };
  934. var isAnchor = node.localName == "anchor";
  935. let wrapType = null;
  936. let simplePos = xml_parser_1.default.boolAttr(node, "simplePos");
  937. let posX = { relative: "page", align: "left", offset: "0" };
  938. let posY = { relative: "page", align: "top", offset: "0" };
  939. for (var n of xml_parser_1.default.elements(node)) {
  940. switch (n.localName) {
  941. case "simplePos":
  942. if (simplePos) {
  943. posX.offset = xml_parser_1.default.lengthAttr(n, "x", common_1.LengthUsage.Emu);
  944. posY.offset = xml_parser_1.default.lengthAttr(n, "y", common_1.LengthUsage.Emu);
  945. }
  946. break;
  947. case "extent":
  948. result.cssStyle["width"] = xml_parser_1.default.lengthAttr(n, "cx", common_1.LengthUsage.Emu);
  949. result.cssStyle["height"] = xml_parser_1.default.lengthAttr(n, "cy", common_1.LengthUsage.Emu);
  950. break;
  951. case "positionH":
  952. case "positionV":
  953. if (!simplePos) {
  954. let pos = n.localName == "positionH" ? posX : posY;
  955. var alignNode = xml_parser_1.default.element(n, "align");
  956. var offsetNode = xml_parser_1.default.element(n, "posOffset");
  957. pos.relative = (_a = xml_parser_1.default.attr(n, "relativeFrom")) !== null && _a !== void 0 ? _a : pos.relative;
  958. if (alignNode)
  959. pos.align = alignNode.textContent;
  960. if (offsetNode)
  961. pos.offset = xmlUtil.sizeValue(offsetNode, common_1.LengthUsage.Emu);
  962. }
  963. break;
  964. case "wrapTopAndBottom":
  965. wrapType = "wrapTopAndBottom";
  966. break;
  967. case "wrapNone":
  968. wrapType = "wrapNone";
  969. break;
  970. case "graphic":
  971. var g = this.parseGraphic(n);
  972. if (g)
  973. result.children.push(g);
  974. break;
  975. }
  976. }
  977. if (wrapType == "wrapTopAndBottom") {
  978. result.cssStyle['display'] = 'block';
  979. if (posX.align) {
  980. result.cssStyle['text-align'] = posX.align;
  981. result.cssStyle['width'] = "100%";
  982. }
  983. }
  984. else if (wrapType == "wrapNone") {
  985. result.cssStyle['display'] = 'block';
  986. result.cssStyle['position'] = 'relative';
  987. result.cssStyle["width"] = "0px";
  988. result.cssStyle["height"] = "0px";
  989. if (posX.offset)
  990. result.cssStyle["left"] = posX.offset;
  991. if (posY.offset)
  992. result.cssStyle["top"] = posY.offset;
  993. }
  994. else if (isAnchor && (posX.align == 'left' || posX.align == 'right')) {
  995. result.cssStyle["float"] = posX.align;
  996. }
  997. return result;
  998. }
  999. parseGraphic(elem) {
  1000. var graphicData = xml_parser_1.default.element(elem, "graphicData");
  1001. for (let n of xml_parser_1.default.elements(graphicData)) {
  1002. switch (n.localName) {
  1003. case "pic":
  1004. return this.parsePicture(n);
  1005. }
  1006. }
  1007. return null;
  1008. }
  1009. parsePicture(elem) {
  1010. var result = { type: dom_1.DomType.Image, src: "", cssStyle: {} };
  1011. var blipFill = xml_parser_1.default.element(elem, "blipFill");
  1012. var blip = xml_parser_1.default.element(blipFill, "blip");
  1013. result.src = xml_parser_1.default.attr(blip, "embed");
  1014. var spPr = xml_parser_1.default.element(elem, "spPr");
  1015. var xfrm = xml_parser_1.default.element(spPr, "xfrm");
  1016. result.cssStyle["position"] = "relative";
  1017. for (var n of xml_parser_1.default.elements(xfrm)) {
  1018. switch (n.localName) {
  1019. case "ext":
  1020. result.cssStyle["width"] = xml_parser_1.default.lengthAttr(n, "cx", common_1.LengthUsage.Emu);
  1021. result.cssStyle["height"] = xml_parser_1.default.lengthAttr(n, "cy", common_1.LengthUsage.Emu);
  1022. break;
  1023. case "off":
  1024. result.cssStyle["left"] = xml_parser_1.default.lengthAttr(n, "x", common_1.LengthUsage.Emu);
  1025. result.cssStyle["top"] = xml_parser_1.default.lengthAttr(n, "y", common_1.LengthUsage.Emu);
  1026. break;
  1027. }
  1028. }
  1029. return result;
  1030. }
  1031. parseTable(node) {
  1032. var result = { type: dom_1.DomType.Table, children: [] };
  1033. xmlUtil.foreach(node, c => {
  1034. switch (c.localName) {
  1035. case "tr":
  1036. result.children.push(this.parseTableRow(c));
  1037. break;
  1038. case "tblGrid":
  1039. result.columns = this.parseTableColumns(c);
  1040. break;
  1041. case "tblPr":
  1042. this.parseTableProperties(c, result);
  1043. break;
  1044. }
  1045. });
  1046. return result;
  1047. }
  1048. parseTableColumns(node) {
  1049. var result = [];
  1050. xmlUtil.foreach(node, n => {
  1051. switch (n.localName) {
  1052. case "gridCol":
  1053. result.push({ width: xml_parser_1.default.lengthAttr(n, "w") });
  1054. break;
  1055. }
  1056. });
  1057. return result;
  1058. }
  1059. parseTableProperties(elem, table) {
  1060. table.cssStyle = {};
  1061. table.cellStyle = {};
  1062. this.parseDefaultProperties(elem, table.cssStyle, table.cellStyle, c => {
  1063. switch (c.localName) {
  1064. case "tblStyle":
  1065. table.styleName = xml_parser_1.default.attr(c, "val");
  1066. break;
  1067. case "tblLook":
  1068. table.className = values.classNameOftblLook(c);
  1069. break;
  1070. case "tblpPr":
  1071. this.parseTablePosition(c, table);
  1072. break;
  1073. case "tblStyleColBandSize":
  1074. table.colBandSize = xml_parser_1.default.intAttr(c, "val");
  1075. break;
  1076. case "tblStyleRowBandSize":
  1077. table.rowBandSize = xml_parser_1.default.intAttr(c, "val");
  1078. break;
  1079. default:
  1080. return false;
  1081. }
  1082. return true;
  1083. });
  1084. switch (table.cssStyle["text-align"]) {
  1085. case "center":
  1086. delete table.cssStyle["text-align"];
  1087. table.cssStyle["margin-left"] = "auto";
  1088. table.cssStyle["margin-right"] = "auto";
  1089. break;
  1090. case "right":
  1091. delete table.cssStyle["text-align"];
  1092. table.cssStyle["margin-left"] = "auto";
  1093. break;
  1094. }
  1095. }
  1096. parseTablePosition(node, table) {
  1097. var topFromText = xml_parser_1.default.lengthAttr(node, "topFromText");
  1098. var bottomFromText = xml_parser_1.default.lengthAttr(node, "bottomFromText");
  1099. var rightFromText = xml_parser_1.default.lengthAttr(node, "rightFromText");
  1100. var leftFromText = xml_parser_1.default.lengthAttr(node, "leftFromText");
  1101. table.cssStyle["float"] = 'left';
  1102. table.cssStyle["margin-bottom"] = values.addSize(table.cssStyle["margin-bottom"], bottomFromText);
  1103. table.cssStyle["margin-left"] = values.addSize(table.cssStyle["margin-left"], leftFromText);
  1104. table.cssStyle["margin-right"] = values.addSize(table.cssStyle["margin-right"], rightFromText);
  1105. table.cssStyle["margin-top"] = values.addSize(table.cssStyle["margin-top"], topFromText);
  1106. }
  1107. parseTableRow(node) {
  1108. var result = { type: dom_1.DomType.Row, children: [] };
  1109. xmlUtil.foreach(node, c => {
  1110. switch (c.localName) {
  1111. case "tc":
  1112. result.children.push(this.parseTableCell(c));
  1113. break;
  1114. case "trPr":
  1115. this.parseTableRowProperties(c, result);
  1116. break;
  1117. }
  1118. });
  1119. return result;
  1120. }
  1121. parseTableRowProperties(elem, row) {
  1122. row.cssStyle = this.parseDefaultProperties(elem, {}, null, c => {
  1123. switch (c.localName) {
  1124. case "cnfStyle":
  1125. row.className = values.classNameOfCnfStyle(c);
  1126. break;
  1127. case "tblHeader":
  1128. row.isHeader = xml_parser_1.default.boolAttr(c, "val");
  1129. break;
  1130. default:
  1131. return false;
  1132. }
  1133. return true;
  1134. });
  1135. }
  1136. parseTableCell(node) {
  1137. var result = { type: dom_1.DomType.Cell, children: [] };
  1138. xmlUtil.foreach(node, c => {
  1139. switch (c.localName) {
  1140. case "tbl":
  1141. result.children.push(this.parseTable(c));
  1142. break;
  1143. case "p":
  1144. result.children.push(this.parseParagraph(c));
  1145. break;
  1146. case "tcPr":
  1147. this.parseTableCellProperties(c, result);
  1148. break;
  1149. }
  1150. });
  1151. return result;
  1152. }
  1153. parseTableCellProperties(elem, cell) {
  1154. cell.cssStyle = this.parseDefaultProperties(elem, {}, null, c => {
  1155. var _a;
  1156. switch (c.localName) {
  1157. case "gridSpan":
  1158. cell.span = xml_parser_1.default.intAttr(c, "val", null);
  1159. break;
  1160. case "vMerge":
  1161. cell.verticalMerge = (_a = xml_parser_1.default.attr(c, "val")) !== null && _a !== void 0 ? _a : "continue";
  1162. break;
  1163. case "cnfStyle":
  1164. cell.className = values.classNameOfCnfStyle(c);
  1165. break;
  1166. default:
  1167. return false;
  1168. }
  1169. return true;
  1170. });
  1171. }
  1172. parseDefaultProperties(elem, style = null, childStyle = null, handler = null) {
  1173. style = style || {};
  1174. xmlUtil.foreach(elem, c => {
  1175. if (handler === null || handler === void 0 ? void 0 : handler(c))
  1176. return;
  1177. switch (c.localName) {
  1178. case "jc":
  1179. style["text-align"] = values.valueOfJc(c);
  1180. break;
  1181. case "textAlignment":
  1182. style["vertical-align"] = values.valueOfTextAlignment(c);
  1183. break;
  1184. case "color":
  1185. style["color"] = xmlUtil.colorAttr(c, "val", null, exports.autos.color);
  1186. break;
  1187. case "sz":
  1188. style["font-size"] = style["min-height"] = xml_parser_1.default.lengthAttr(c, "val", common_1.LengthUsage.FontSize);
  1189. break;
  1190. case "shd":
  1191. style["background-color"] = xmlUtil.colorAttr(c, "fill", null, exports.autos.shd);
  1192. break;
  1193. case "highlight":
  1194. style["background-color"] = xmlUtil.colorAttr(c, "val", null, exports.autos.highlight);
  1195. break;
  1196. case "vertAlign":
  1197. break;
  1198. case "position":
  1199. style.verticalAlign = xml_parser_1.default.lengthAttr(c, "val", common_1.LengthUsage.FontSize);
  1200. break;
  1201. case "tcW":
  1202. if (this.options.ignoreWidth)
  1203. break;
  1204. case "tblW":
  1205. style["width"] = values.valueOfSize(c, "w");
  1206. break;
  1207. case "trHeight":
  1208. this.parseTrHeight(c, style);
  1209. break;
  1210. case "strike":
  1211. style["text-decoration"] = xml_parser_1.default.boolAttr(c, "val", true) ? "line-through" : "none";
  1212. break;
  1213. case "b":
  1214. style["font-weight"] = xml_parser_1.default.boolAttr(c, "val", true) ? "bold" : "normal";
  1215. break;
  1216. case "i":
  1217. style["font-style"] = xml_parser_1.default.boolAttr(c, "val", true) ? "italic" : "normal";
  1218. break;
  1219. case "caps":
  1220. style["text-transform"] = xml_parser_1.default.boolAttr(c, "val", true) ? "uppercase" : "none";
  1221. break;
  1222. case "smallCaps":
  1223. style["text-transform"] = xml_parser_1.default.boolAttr(c, "val", true) ? "lowercase" : "none";
  1224. break;
  1225. case "u":
  1226. this.parseUnderline(c, style);
  1227. break;
  1228. case "ind":
  1229. case "tblInd":
  1230. this.parseIndentation(c, style);
  1231. break;
  1232. case "rFonts":
  1233. this.parseFont(c, style);
  1234. break;
  1235. case "tblBorders":
  1236. this.parseBorderProperties(c, childStyle || style);
  1237. break;
  1238. case "tblCellSpacing":
  1239. style["border-spacing"] = values.valueOfMargin(c);
  1240. style["border-collapse"] = "separate";
  1241. break;
  1242. case "pBdr":
  1243. this.parseBorderProperties(c, style);
  1244. break;
  1245. case "bdr":
  1246. style["border"] = values.valueOfBorder(c);
  1247. break;
  1248. case "tcBorders":
  1249. this.parseBorderProperties(c, style);
  1250. break;
  1251. case "vanish":
  1252. if (xml_parser_1.default.boolAttr(c, "val", true))
  1253. style["display"] = "none";
  1254. break;
  1255. case "kern":
  1256. break;
  1257. case "noWrap":
  1258. break;
  1259. case "tblCellMar":
  1260. case "tcMar":
  1261. this.parseMarginProperties(c, childStyle || style);
  1262. break;
  1263. case "tblLayout":
  1264. style["table-layout"] = values.valueOfTblLayout(c);
  1265. break;
  1266. case "vAlign":
  1267. style["vertical-align"] = values.valueOfTextAlignment(c);
  1268. break;
  1269. case "spacing":
  1270. if (elem.localName == "pPr")
  1271. this.parseSpacing(c, style);
  1272. break;
  1273. case "wordWrap":
  1274. if (xml_parser_1.default.boolAttr(c, "val"))
  1275. style["overflow-wrap"] = "break-word";
  1276. break;
  1277. case "bCs":
  1278. case "iCs":
  1279. case "szCs":
  1280. case "tabs":
  1281. case "outlineLvl":
  1282. case "contextualSpacing":
  1283. case "tblStyleColBandSize":
  1284. case "tblStyleRowBandSize":
  1285. case "webHidden":
  1286. case "pageBreakBefore":
  1287. case "suppressLineNumbers":
  1288. case "keepLines":
  1289. case "keepNext":
  1290. case "lang":
  1291. case "widowControl":
  1292. case "bidi":
  1293. case "rtl":
  1294. case "noProof":
  1295. break;
  1296. default:
  1297. if (this.options.debug)
  1298. console.warn(`DOCX: Unknown document element: ${elem.localName}.${c.localName}`);
  1299. break;
  1300. }
  1301. });
  1302. return style;
  1303. }
  1304. parseUnderline(node, style) {
  1305. var val = xml_parser_1.default.attr(node, "val");
  1306. if (val == null)
  1307. return;
  1308. switch (val) {
  1309. case "dash":
  1310. case "dashDotDotHeavy":
  1311. case "dashDotHeavy":
  1312. case "dashedHeavy":
  1313. case "dashLong":
  1314. case "dashLongHeavy":
  1315. case "dotDash":
  1316. case "dotDotDash":
  1317. style["text-decoration-style"] = "dashed";
  1318. break;
  1319. case "dotted":
  1320. case "dottedHeavy":
  1321. style["text-decoration-style"] = "dotted";
  1322. break;
  1323. case "double":
  1324. style["text-decoration-style"] = "double";
  1325. break;
  1326. case "single":
  1327. case "thick":
  1328. style["text-decoration"] = "underline";
  1329. break;
  1330. case "wave":
  1331. case "wavyDouble":
  1332. case "wavyHeavy":
  1333. style["text-decoration-style"] = "wavy";
  1334. break;
  1335. case "words":
  1336. style["text-decoration"] = "underline";
  1337. break;
  1338. case "none":
  1339. style["text-decoration"] = "none";
  1340. break;
  1341. }
  1342. var col = xmlUtil.colorAttr(node, "color");
  1343. if (col)
  1344. style["text-decoration-color"] = col;
  1345. }
  1346. parseFont(node, style) {
  1347. var ascii = xml_parser_1.default.attr(node, "ascii");
  1348. var asciiTheme = values.themeValue(node, "asciiTheme");
  1349. var fonts = [ascii, asciiTheme].filter(x => x).join(', ');
  1350. if (fonts.length > 0)
  1351. style["font-family"] = fonts;
  1352. }
  1353. parseIndentation(node, style) {
  1354. var firstLine = xml_parser_1.default.lengthAttr(node, "firstLine");
  1355. var hanging = xml_parser_1.default.lengthAttr(node, "hanging");
  1356. var left = xml_parser_1.default.lengthAttr(node, "left");
  1357. var start = xml_parser_1.default.lengthAttr(node, "start");
  1358. var right = xml_parser_1.default.lengthAttr(node, "right");
  1359. var end = xml_parser_1.default.lengthAttr(node, "end");
  1360. if (firstLine)
  1361. style["text-indent"] = firstLine;
  1362. if (hanging)
  1363. style["text-indent"] = `-${hanging}`;
  1364. if (left || start)
  1365. style["margin-left"] = left || start;
  1366. if (right || end)
  1367. style["margin-right"] = right || end;
  1368. }
  1369. parseSpacing(node, style) {
  1370. var before = xml_parser_1.default.lengthAttr(node, "before");
  1371. var after = xml_parser_1.default.lengthAttr(node, "after");
  1372. var line = xml_parser_1.default.intAttr(node, "line", null);
  1373. var lineRule = xml_parser_1.default.attr(node, "lineRule");
  1374. if (before)
  1375. style["margin-top"] = before;
  1376. if (after)
  1377. style["margin-bottom"] = after;
  1378. if (line !== null) {
  1379. switch (lineRule) {
  1380. case "auto":
  1381. style["line-height"] = `${(line / 240).toFixed(2)}`;
  1382. break;
  1383. case "atLeast":
  1384. style["line-height"] = `calc(100% + ${line / 20}pt)`;
  1385. break;
  1386. default:
  1387. style["line-height"] = style["min-height"] = `${line / 20}pt`;
  1388. break;
  1389. }
  1390. }
  1391. }
  1392. parseMarginProperties(node, output) {
  1393. xmlUtil.foreach(node, c => {
  1394. switch (c.localName) {
  1395. case "left":
  1396. output["padding-left"] = values.valueOfMargin(c);
  1397. break;
  1398. case "right":
  1399. output["padding-right"] = values.valueOfMargin(c);
  1400. break;
  1401. case "top":
  1402. output["padding-top"] = values.valueOfMargin(c);
  1403. break;
  1404. case "bottom":
  1405. output["padding-bottom"] = values.valueOfMargin(c);
  1406. break;
  1407. }
  1408. });
  1409. }
  1410. parseTrHeight(node, output) {
  1411. switch (xml_parser_1.default.attr(node, "hRule")) {
  1412. case "exact":
  1413. output["height"] = xml_parser_1.default.lengthAttr(node, "val");
  1414. break;
  1415. case "atLeast":
  1416. default:
  1417. output["height"] = xml_parser_1.default.lengthAttr(node, "val");
  1418. break;
  1419. }
  1420. }
  1421. parseBorderProperties(node, output) {
  1422. xmlUtil.foreach(node, c => {
  1423. switch (c.localName) {
  1424. case "start":
  1425. case "left":
  1426. output["border-left"] = values.valueOfBorder(c);
  1427. break;
  1428. case "end":
  1429. case "right":
  1430. output["border-right"] = values.valueOfBorder(c);
  1431. break;
  1432. case "top":
  1433. output["border-top"] = values.valueOfBorder(c);
  1434. break;
  1435. case "bottom":
  1436. output["border-bottom"] = values.valueOfBorder(c);
  1437. break;
  1438. }
  1439. });
  1440. }
  1441. }
  1442. exports.DocumentParser = DocumentParser;
  1443. const knownColors = ['black', 'blue', 'cyan', 'darkBlue', 'darkCyan', 'darkGray', 'darkGreen', 'darkMagenta', 'darkRed', 'darkYellow', 'green', 'lightGray', 'magenta', 'none', 'red', 'white', 'yellow'];
  1444. class xmlUtil {
  1445. static foreach(node, cb) {
  1446. for (var i = 0; i < node.childNodes.length; i++) {
  1447. let n = node.childNodes[i];
  1448. if (n.nodeType == Node.ELEMENT_NODE)
  1449. cb(n);
  1450. }
  1451. }
  1452. static colorAttr(node, attrName, defValue = null, autoColor = 'black') {
  1453. var v = xml_parser_1.default.attr(node, attrName);
  1454. if (v) {
  1455. if (v == "auto") {
  1456. return autoColor;
  1457. }
  1458. else if (knownColors.includes(v)) {
  1459. return v;
  1460. }
  1461. return `#${v}`;
  1462. }
  1463. var themeColor = xml_parser_1.default.attr(node, "themeColor");
  1464. return themeColor ? `var(--docx-${themeColor}-color)` : defValue;
  1465. }
  1466. static sizeValue(node, type = common_1.LengthUsage.Dxa) {
  1467. return (0, common_1.convertLength)(node.textContent, type);
  1468. }
  1469. }
  1470. class values {
  1471. static themeValue(c, attr) {
  1472. var val = xml_parser_1.default.attr(c, attr);
  1473. return val ? `var(--docx-${val}-font)` : null;
  1474. }
  1475. static valueOfSize(c, attr) {
  1476. var type = common_1.LengthUsage.Dxa;
  1477. switch (xml_parser_1.default.attr(c, "type")) {
  1478. case "dxa": break;
  1479. case "pct":
  1480. type = common_1.LengthUsage.Percent;
  1481. break;
  1482. case "auto": return "auto";
  1483. }
  1484. return xml_parser_1.default.lengthAttr(c, attr, type);
  1485. }
  1486. static valueOfMargin(c) {
  1487. return xml_parser_1.default.lengthAttr(c, "w");
  1488. }
  1489. static valueOfBorder(c) {
  1490. var type = xml_parser_1.default.attr(c, "val");
  1491. if (type == "nil")
  1492. return "none";
  1493. var color = xmlUtil.colorAttr(c, "color");
  1494. var size = xml_parser_1.default.lengthAttr(c, "sz", common_1.LengthUsage.Border);
  1495. return `${size} solid ${color == "auto" ? exports.autos.borderColor : color}`;
  1496. }
  1497. static valueOfTblLayout(c) {
  1498. var type = xml_parser_1.default.attr(c, "val");
  1499. return type == "fixed" ? "fixed" : "auto";
  1500. }
  1501. static classNameOfCnfStyle(c) {
  1502. const val = xml_parser_1.default.attr(c, "val");
  1503. const classes = [
  1504. 'first-row', 'last-row', 'first-col', 'last-col',
  1505. 'odd-col', 'even-col', 'odd-row', 'even-row',
  1506. 'ne-cell', 'nw-cell', 'se-cell', 'sw-cell'
  1507. ];
  1508. return classes.filter((_, i) => val[i] == '1').join(' ');
  1509. }
  1510. static valueOfJc(c) {
  1511. var type = xml_parser_1.default.attr(c, "val");
  1512. switch (type) {
  1513. case "start":
  1514. case "left": return "left";
  1515. case "center": return "center";
  1516. case "end":
  1517. case "right": return "right";
  1518. case "both": return "justify";
  1519. }
  1520. return type;
  1521. }
  1522. static valueOfVertAlign(c, asTagName = false) {
  1523. var type = xml_parser_1.default.attr(c, "val");
  1524. switch (type) {
  1525. case "subscript": return "sub";
  1526. case "superscript": return asTagName ? "sup" : "super";
  1527. }
  1528. return asTagName ? null : type;
  1529. }
  1530. static valueOfTextAlignment(c) {
  1531. var type = xml_parser_1.default.attr(c, "val");
  1532. switch (type) {
  1533. case "auto":
  1534. case "baseline": return "baseline";
  1535. case "top": return "top";
  1536. case "center": return "middle";
  1537. case "bottom": return "bottom";
  1538. }
  1539. return type;
  1540. }
  1541. static addSize(a, b) {
  1542. if (a == null)
  1543. return b;
  1544. if (b == null)
  1545. return a;
  1546. return `calc(${a} + ${b})`;
  1547. }
  1548. static classNameOftblLook(c) {
  1549. const val = xml_parser_1.default.hexAttr(c, "val", 0);
  1550. let className = "";
  1551. if (xml_parser_1.default.boolAttr(c, "firstRow") || (val & 0x0020))
  1552. className += " first-row";
  1553. if (xml_parser_1.default.boolAttr(c, "lastRow") || (val & 0x0040))
  1554. className += " last-row";
  1555. if (xml_parser_1.default.boolAttr(c, "firstColumn") || (val & 0x0080))
  1556. className += " first-col";
  1557. if (xml_parser_1.default.boolAttr(c, "lastColumn") || (val & 0x0100))
  1558. className += " last-col";
  1559. if (xml_parser_1.default.boolAttr(c, "noHBand") || (val & 0x0200))
  1560. className += " no-hband";
  1561. if (xml_parser_1.default.boolAttr(c, "noVBand") || (val & 0x0400))
  1562. className += " no-vband";
  1563. return className.trim();
  1564. }
  1565. }
  1566. /***/ }),
  1567. /***/ "./src/document-props/core-props-part.ts":
  1568. /*!***********************************************!*\
  1569. !*** ./src/document-props/core-props-part.ts ***!
  1570. \***********************************************/
  1571. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1572. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1573. exports.CorePropsPart = void 0;
  1574. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  1575. const core_props_1 = __webpack_require__(/*! ./core-props */ "./src/document-props/core-props.ts");
  1576. class CorePropsPart extends part_1.Part {
  1577. parseXml(root) {
  1578. this.props = (0, core_props_1.parseCoreProps)(root, this._package.xmlParser);
  1579. }
  1580. }
  1581. exports.CorePropsPart = CorePropsPart;
  1582. /***/ }),
  1583. /***/ "./src/document-props/core-props.ts":
  1584. /*!******************************************!*\
  1585. !*** ./src/document-props/core-props.ts ***!
  1586. \******************************************/
  1587. /***/ ((__unused_webpack_module, exports) => {
  1588. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1589. exports.parseCoreProps = void 0;
  1590. function parseCoreProps(root, xmlParser) {
  1591. const result = {};
  1592. for (let el of xmlParser.elements(root)) {
  1593. switch (el.localName) {
  1594. case "title":
  1595. result.title = el.textContent;
  1596. break;
  1597. case "description":
  1598. result.description = el.textContent;
  1599. break;
  1600. case "subject":
  1601. result.subject = el.textContent;
  1602. break;
  1603. case "creator":
  1604. result.creator = el.textContent;
  1605. break;
  1606. case "keywords":
  1607. result.keywords = el.textContent;
  1608. break;
  1609. case "language":
  1610. result.language = el.textContent;
  1611. break;
  1612. case "lastModifiedBy":
  1613. result.lastModifiedBy = el.textContent;
  1614. break;
  1615. case "revision":
  1616. el.textContent && (result.revision = parseInt(el.textContent));
  1617. break;
  1618. }
  1619. }
  1620. return result;
  1621. }
  1622. exports.parseCoreProps = parseCoreProps;
  1623. /***/ }),
  1624. /***/ "./src/document-props/custom-props-part.ts":
  1625. /*!*************************************************!*\
  1626. !*** ./src/document-props/custom-props-part.ts ***!
  1627. \*************************************************/
  1628. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1629. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1630. exports.CustomPropsPart = void 0;
  1631. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  1632. const custom_props_1 = __webpack_require__(/*! ./custom-props */ "./src/document-props/custom-props.ts");
  1633. class CustomPropsPart extends part_1.Part {
  1634. parseXml(root) {
  1635. this.props = (0, custom_props_1.parseCustomProps)(root, this._package.xmlParser);
  1636. }
  1637. }
  1638. exports.CustomPropsPart = CustomPropsPart;
  1639. /***/ }),
  1640. /***/ "./src/document-props/custom-props.ts":
  1641. /*!********************************************!*\
  1642. !*** ./src/document-props/custom-props.ts ***!
  1643. \********************************************/
  1644. /***/ ((__unused_webpack_module, exports) => {
  1645. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1646. exports.parseCustomProps = void 0;
  1647. function parseCustomProps(root, xml) {
  1648. return xml.elements(root, "property").map(e => {
  1649. const firstChild = e.firstChild;
  1650. return {
  1651. formatId: xml.attr(e, "fmtid"),
  1652. name: xml.attr(e, "name"),
  1653. type: firstChild.nodeName,
  1654. value: firstChild.textContent
  1655. };
  1656. });
  1657. }
  1658. exports.parseCustomProps = parseCustomProps;
  1659. /***/ }),
  1660. /***/ "./src/document-props/extended-props-part.ts":
  1661. /*!***************************************************!*\
  1662. !*** ./src/document-props/extended-props-part.ts ***!
  1663. \***************************************************/
  1664. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1665. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1666. exports.ExtendedPropsPart = void 0;
  1667. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  1668. const extended_props_1 = __webpack_require__(/*! ./extended-props */ "./src/document-props/extended-props.ts");
  1669. class ExtendedPropsPart extends part_1.Part {
  1670. parseXml(root) {
  1671. this.props = (0, extended_props_1.parseExtendedProps)(root, this._package.xmlParser);
  1672. }
  1673. }
  1674. exports.ExtendedPropsPart = ExtendedPropsPart;
  1675. /***/ }),
  1676. /***/ "./src/document-props/extended-props.ts":
  1677. /*!**********************************************!*\
  1678. !*** ./src/document-props/extended-props.ts ***!
  1679. \**********************************************/
  1680. /***/ ((__unused_webpack_module, exports) => {
  1681. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1682. exports.parseExtendedProps = void 0;
  1683. function parseExtendedProps(root, xmlParser) {
  1684. const result = {};
  1685. for (let el of xmlParser.elements(root)) {
  1686. switch (el.localName) {
  1687. case "Template":
  1688. result.template = el.textContent;
  1689. break;
  1690. case "Pages":
  1691. result.pages = safeParseToInt(el.textContent);
  1692. break;
  1693. case "Words":
  1694. result.words = safeParseToInt(el.textContent);
  1695. break;
  1696. case "Characters":
  1697. result.characters = safeParseToInt(el.textContent);
  1698. break;
  1699. case "Application":
  1700. result.application = el.textContent;
  1701. break;
  1702. case "Lines":
  1703. result.lines = safeParseToInt(el.textContent);
  1704. break;
  1705. case "Paragraphs":
  1706. result.paragraphs = safeParseToInt(el.textContent);
  1707. break;
  1708. case "Company":
  1709. result.company = el.textContent;
  1710. break;
  1711. case "AppVersion":
  1712. result.appVersion = el.textContent;
  1713. break;
  1714. }
  1715. }
  1716. return result;
  1717. }
  1718. exports.parseExtendedProps = parseExtendedProps;
  1719. function safeParseToInt(value) {
  1720. if (typeof value === 'undefined')
  1721. return;
  1722. return parseInt(value);
  1723. }
  1724. /***/ }),
  1725. /***/ "./src/document/bookmarks.ts":
  1726. /*!***********************************!*\
  1727. !*** ./src/document/bookmarks.ts ***!
  1728. \***********************************/
  1729. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1730. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1731. exports.parseBookmarkEnd = exports.parseBookmarkStart = void 0;
  1732. const dom_1 = __webpack_require__(/*! ./dom */ "./src/document/dom.ts");
  1733. function parseBookmarkStart(elem, xml) {
  1734. return {
  1735. type: dom_1.DomType.BookmarkStart,
  1736. id: xml.attr(elem, "id"),
  1737. name: xml.attr(elem, "name"),
  1738. colFirst: xml.intAttr(elem, "colFirst"),
  1739. colLast: xml.intAttr(elem, "colLast")
  1740. };
  1741. }
  1742. exports.parseBookmarkStart = parseBookmarkStart;
  1743. function parseBookmarkEnd(elem, xml) {
  1744. return {
  1745. type: dom_1.DomType.BookmarkEnd,
  1746. id: xml.attr(elem, "id")
  1747. };
  1748. }
  1749. exports.parseBookmarkEnd = parseBookmarkEnd;
  1750. /***/ }),
  1751. /***/ "./src/document/border.ts":
  1752. /*!********************************!*\
  1753. !*** ./src/document/border.ts ***!
  1754. \********************************/
  1755. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1756. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1757. exports.parseBorders = exports.parseBorder = void 0;
  1758. const common_1 = __webpack_require__(/*! ./common */ "./src/document/common.ts");
  1759. function parseBorder(elem, xml) {
  1760. return {
  1761. type: xml.attr(elem, "val"),
  1762. color: xml.attr(elem, "color"),
  1763. size: xml.lengthAttr(elem, "sz", common_1.LengthUsage.Border),
  1764. offset: xml.lengthAttr(elem, "space", common_1.LengthUsage.Point),
  1765. frame: xml.boolAttr(elem, 'frame'),
  1766. shadow: xml.boolAttr(elem, 'shadow')
  1767. };
  1768. }
  1769. exports.parseBorder = parseBorder;
  1770. function parseBorders(elem, xml) {
  1771. var result = {};
  1772. for (let e of xml.elements(elem)) {
  1773. switch (e.localName) {
  1774. case "left":
  1775. result.left = parseBorder(e, xml);
  1776. break;
  1777. case "top":
  1778. result.top = parseBorder(e, xml);
  1779. break;
  1780. case "right":
  1781. result.right = parseBorder(e, xml);
  1782. break;
  1783. case "bottom":
  1784. result.bottom = parseBorder(e, xml);
  1785. break;
  1786. }
  1787. }
  1788. return result;
  1789. }
  1790. exports.parseBorders = parseBorders;
  1791. /***/ }),
  1792. /***/ "./src/document/common.ts":
  1793. /*!********************************!*\
  1794. !*** ./src/document/common.ts ***!
  1795. \********************************/
  1796. /***/ ((__unused_webpack_module, exports) => {
  1797. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1798. exports.parseCommonProperty = exports.convertPercentage = exports.convertBoolean = exports.convertLength = exports.LengthUsage = exports.ns = void 0;
  1799. exports.ns = {
  1800. wordml: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
  1801. drawingml: "http://schemas.openxmlformats.org/drawingml/2006/main",
  1802. picture: "http://schemas.openxmlformats.org/drawingml/2006/picture",
  1803. compatibility: "http://schemas.openxmlformats.org/markup-compatibility/2006",
  1804. math: "http://schemas.openxmlformats.org/officeDocument/2006/math"
  1805. };
  1806. exports.LengthUsage = {
  1807. Dxa: { mul: 0.05, unit: "pt" },
  1808. Emu: { mul: 1 / 12700, unit: "pt" },
  1809. FontSize: { mul: 0.5, unit: "pt" },
  1810. Border: { mul: 0.125, unit: "pt" },
  1811. Point: { mul: 1, unit: "pt" },
  1812. Percent: { mul: 0.02, unit: "%" },
  1813. LineHeight: { mul: 1 / 240, unit: "" },
  1814. VmlEmu: { mul: 1 / 12700, unit: "" },
  1815. };
  1816. function convertLength(val, usage = exports.LengthUsage.Dxa) {
  1817. if (val == null || /.+(p[xt]|[%])$/.test(val)) {
  1818. return val;
  1819. }
  1820. return `${(parseInt(val) * usage.mul).toFixed(2)}${usage.unit}`;
  1821. }
  1822. exports.convertLength = convertLength;
  1823. function convertBoolean(v, defaultValue = false) {
  1824. switch (v) {
  1825. case "1": return true;
  1826. case "0": return false;
  1827. case "on": return true;
  1828. case "off": return false;
  1829. case "true": return true;
  1830. case "false": return false;
  1831. default: return defaultValue;
  1832. }
  1833. }
  1834. exports.convertBoolean = convertBoolean;
  1835. function convertPercentage(val) {
  1836. return val ? parseInt(val) / 100 : null;
  1837. }
  1838. exports.convertPercentage = convertPercentage;
  1839. function parseCommonProperty(elem, props, xml) {
  1840. if (elem.namespaceURI != exports.ns.wordml)
  1841. return false;
  1842. switch (elem.localName) {
  1843. case "color":
  1844. props.color = xml.attr(elem, "val");
  1845. break;
  1846. case "sz":
  1847. props.fontSize = xml.lengthAttr(elem, "val", exports.LengthUsage.FontSize);
  1848. break;
  1849. default:
  1850. return false;
  1851. }
  1852. return true;
  1853. }
  1854. exports.parseCommonProperty = parseCommonProperty;
  1855. /***/ }),
  1856. /***/ "./src/document/document-part.ts":
  1857. /*!***************************************!*\
  1858. !*** ./src/document/document-part.ts ***!
  1859. \***************************************/
  1860. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1861. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1862. exports.DocumentPart = void 0;
  1863. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  1864. class DocumentPart extends part_1.Part {
  1865. constructor(pkg, path, parser) {
  1866. super(pkg, path);
  1867. this._documentParser = parser;
  1868. }
  1869. parseXml(root) {
  1870. this.body = this._documentParser.parseDocumentFile(root);
  1871. }
  1872. }
  1873. exports.DocumentPart = DocumentPart;
  1874. /***/ }),
  1875. /***/ "./src/document/dom.ts":
  1876. /*!*****************************!*\
  1877. !*** ./src/document/dom.ts ***!
  1878. \*****************************/
  1879. /***/ ((__unused_webpack_module, exports) => {
  1880. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1881. exports.DomType = void 0;
  1882. var DomType;
  1883. (function (DomType) {
  1884. DomType["Document"] = "document";
  1885. DomType["Paragraph"] = "paragraph";
  1886. DomType["Run"] = "run";
  1887. DomType["Break"] = "break";
  1888. DomType["NoBreakHyphen"] = "noBreakHyphen";
  1889. DomType["Table"] = "table";
  1890. DomType["Row"] = "row";
  1891. DomType["Cell"] = "cell";
  1892. DomType["Hyperlink"] = "hyperlink";
  1893. DomType["Drawing"] = "drawing";
  1894. DomType["Image"] = "image";
  1895. DomType["Text"] = "text";
  1896. DomType["Tab"] = "tab";
  1897. DomType["Symbol"] = "symbol";
  1898. DomType["BookmarkStart"] = "bookmarkStart";
  1899. DomType["BookmarkEnd"] = "bookmarkEnd";
  1900. DomType["Footer"] = "footer";
  1901. DomType["Header"] = "header";
  1902. DomType["FootnoteReference"] = "footnoteReference";
  1903. DomType["EndnoteReference"] = "endnoteReference";
  1904. DomType["Footnote"] = "footnote";
  1905. DomType["Endnote"] = "endnote";
  1906. DomType["SimpleField"] = "simpleField";
  1907. DomType["ComplexField"] = "complexField";
  1908. DomType["Instruction"] = "instruction";
  1909. DomType["VmlPicture"] = "vmlPicture";
  1910. DomType["MmlMath"] = "mmlMath";
  1911. DomType["MmlMathParagraph"] = "mmlMathParagraph";
  1912. DomType["MmlFraction"] = "mmlFraction";
  1913. DomType["MmlNumerator"] = "mmlNumerator";
  1914. DomType["MmlDenominator"] = "mmlDenominator";
  1915. DomType["MmlRadical"] = "mmlRadical";
  1916. DomType["MmlBase"] = "mmlBase";
  1917. DomType["MmlDegree"] = "mmlDegree";
  1918. DomType["MmlSuperscript"] = "mmlSuperscript";
  1919. DomType["MmlSubscript"] = "mmlSubscript";
  1920. DomType["MmlSubArgument"] = "mmlSubArgument";
  1921. DomType["MmlSuperArgument"] = "mmlSuperArgument";
  1922. DomType["MmlNary"] = "mmlNary";
  1923. DomType["MmlDelimiter"] = "mmlDelimiter";
  1924. DomType["MmlRun"] = "mmlRun";
  1925. DomType["VmlElement"] = "vmlElement";
  1926. DomType["Inserted"] = "inserted";
  1927. DomType["Deleted"] = "deleted";
  1928. DomType["DeletedText"] = "deletedText";
  1929. })(DomType = exports.DomType || (exports.DomType = {}));
  1930. /***/ }),
  1931. /***/ "./src/document/line-spacing.ts":
  1932. /*!**************************************!*\
  1933. !*** ./src/document/line-spacing.ts ***!
  1934. \**************************************/
  1935. /***/ ((__unused_webpack_module, exports) => {
  1936. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1937. exports.parseLineSpacing = void 0;
  1938. function parseLineSpacing(elem, xml) {
  1939. return {
  1940. before: xml.lengthAttr(elem, "before"),
  1941. after: xml.lengthAttr(elem, "after"),
  1942. line: xml.intAttr(elem, "line"),
  1943. lineRule: xml.attr(elem, "lineRule")
  1944. };
  1945. }
  1946. exports.parseLineSpacing = parseLineSpacing;
  1947. /***/ }),
  1948. /***/ "./src/document/paragraph.ts":
  1949. /*!***********************************!*\
  1950. !*** ./src/document/paragraph.ts ***!
  1951. \***********************************/
  1952. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  1953. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1954. exports.parseNumbering = exports.parseTabs = exports.parseParagraphProperty = exports.parseParagraphProperties = void 0;
  1955. const common_1 = __webpack_require__(/*! ./common */ "./src/document/common.ts");
  1956. const section_1 = __webpack_require__(/*! ./section */ "./src/document/section.ts");
  1957. const line_spacing_1 = __webpack_require__(/*! ./line-spacing */ "./src/document/line-spacing.ts");
  1958. const run_1 = __webpack_require__(/*! ./run */ "./src/document/run.ts");
  1959. function parseParagraphProperties(elem, xml) {
  1960. let result = {};
  1961. for (let el of xml.elements(elem)) {
  1962. parseParagraphProperty(el, result, xml);
  1963. }
  1964. return result;
  1965. }
  1966. exports.parseParagraphProperties = parseParagraphProperties;
  1967. function parseParagraphProperty(elem, props, xml) {
  1968. if (elem.namespaceURI != common_1.ns.wordml)
  1969. return false;
  1970. if ((0, common_1.parseCommonProperty)(elem, props, xml))
  1971. return true;
  1972. switch (elem.localName) {
  1973. case "tabs":
  1974. props.tabs = parseTabs(elem, xml);
  1975. break;
  1976. case "sectPr":
  1977. props.sectionProps = (0, section_1.parseSectionProperties)(elem, xml);
  1978. break;
  1979. case "numPr":
  1980. props.numbering = parseNumbering(elem, xml);
  1981. break;
  1982. case "spacing":
  1983. props.lineSpacing = (0, line_spacing_1.parseLineSpacing)(elem, xml);
  1984. return false;
  1985. break;
  1986. case "textAlignment":
  1987. props.textAlignment = xml.attr(elem, "val");
  1988. return false;
  1989. break;
  1990. case "keepNext":
  1991. props.keepLines = xml.boolAttr(elem, "val", true);
  1992. break;
  1993. case "keepNext":
  1994. props.keepNext = xml.boolAttr(elem, "val", true);
  1995. break;
  1996. case "pageBreakBefore":
  1997. props.pageBreakBefore = xml.boolAttr(elem, "val", true);
  1998. break;
  1999. case "outlineLvl":
  2000. props.outlineLevel = xml.intAttr(elem, "val");
  2001. break;
  2002. case "pStyle":
  2003. props.styleName = xml.attr(elem, "val");
  2004. break;
  2005. case "rPr":
  2006. props.runProps = (0, run_1.parseRunProperties)(elem, xml);
  2007. break;
  2008. default:
  2009. return false;
  2010. }
  2011. return true;
  2012. }
  2013. exports.parseParagraphProperty = parseParagraphProperty;
  2014. function parseTabs(elem, xml) {
  2015. return xml.elements(elem, "tab")
  2016. .map(e => ({
  2017. position: xml.lengthAttr(e, "pos"),
  2018. leader: xml.attr(e, "leader"),
  2019. style: xml.attr(e, "val")
  2020. }));
  2021. }
  2022. exports.parseTabs = parseTabs;
  2023. function parseNumbering(elem, xml) {
  2024. var result = {};
  2025. for (let e of xml.elements(elem)) {
  2026. switch (e.localName) {
  2027. case "numId":
  2028. result.id = xml.attr(e, "val");
  2029. break;
  2030. case "ilvl":
  2031. result.level = xml.intAttr(e, "val");
  2032. break;
  2033. }
  2034. }
  2035. return result;
  2036. }
  2037. exports.parseNumbering = parseNumbering;
  2038. /***/ }),
  2039. /***/ "./src/document/run.ts":
  2040. /*!*****************************!*\
  2041. !*** ./src/document/run.ts ***!
  2042. \*****************************/
  2043. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2044. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2045. exports.parseRunProperty = exports.parseRunProperties = void 0;
  2046. const common_1 = __webpack_require__(/*! ./common */ "./src/document/common.ts");
  2047. function parseRunProperties(elem, xml) {
  2048. let result = {};
  2049. for (let el of xml.elements(elem)) {
  2050. parseRunProperty(el, result, xml);
  2051. }
  2052. return result;
  2053. }
  2054. exports.parseRunProperties = parseRunProperties;
  2055. function parseRunProperty(elem, props, xml) {
  2056. if ((0, common_1.parseCommonProperty)(elem, props, xml))
  2057. return true;
  2058. return false;
  2059. }
  2060. exports.parseRunProperty = parseRunProperty;
  2061. /***/ }),
  2062. /***/ "./src/document/section.ts":
  2063. /*!*********************************!*\
  2064. !*** ./src/document/section.ts ***!
  2065. \*********************************/
  2066. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2067. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2068. exports.parseSectionProperties = exports.SectionType = void 0;
  2069. const xml_parser_1 = __webpack_require__(/*! ../parser/xml-parser */ "./src/parser/xml-parser.ts");
  2070. const border_1 = __webpack_require__(/*! ./border */ "./src/document/border.ts");
  2071. var SectionType;
  2072. (function (SectionType) {
  2073. SectionType["Continuous"] = "continuous";
  2074. SectionType["NextPage"] = "nextPage";
  2075. SectionType["NextColumn"] = "nextColumn";
  2076. SectionType["EvenPage"] = "evenPage";
  2077. SectionType["OddPage"] = "oddPage";
  2078. })(SectionType = exports.SectionType || (exports.SectionType = {}));
  2079. function parseSectionProperties(elem, xml = xml_parser_1.default) {
  2080. var _a, _b;
  2081. var section = {};
  2082. for (let e of xml.elements(elem)) {
  2083. switch (e.localName) {
  2084. case "pgSz":
  2085. section.pageSize = {
  2086. width: xml.lengthAttr(e, "w"),
  2087. height: xml.lengthAttr(e, "h"),
  2088. orientation: xml.attr(e, "orient")
  2089. };
  2090. break;
  2091. case "type":
  2092. section.type = xml.attr(e, "val");
  2093. break;
  2094. case "pgMar":
  2095. section.pageMargins = {
  2096. left: xml.lengthAttr(e, "left"),
  2097. right: xml.lengthAttr(e, "right"),
  2098. top: xml.lengthAttr(e, "top"),
  2099. bottom: xml.lengthAttr(e, "bottom"),
  2100. header: xml.lengthAttr(e, "header"),
  2101. footer: xml.lengthAttr(e, "footer"),
  2102. gutter: xml.lengthAttr(e, "gutter"),
  2103. };
  2104. break;
  2105. case "cols":
  2106. section.columns = parseColumns(e, xml);
  2107. break;
  2108. case "headerReference":
  2109. ((_a = section.headerRefs) !== null && _a !== void 0 ? _a : (section.headerRefs = [])).push(parseFooterHeaderReference(e, xml));
  2110. break;
  2111. case "footerReference":
  2112. ((_b = section.footerRefs) !== null && _b !== void 0 ? _b : (section.footerRefs = [])).push(parseFooterHeaderReference(e, xml));
  2113. break;
  2114. case "titlePg":
  2115. section.titlePage = xml.boolAttr(e, "val", true);
  2116. break;
  2117. case "pgBorders":
  2118. section.pageBorders = (0, border_1.parseBorders)(e, xml);
  2119. break;
  2120. case "pgNumType":
  2121. section.pageNumber = parsePageNumber(e, xml);
  2122. break;
  2123. }
  2124. }
  2125. return section;
  2126. }
  2127. exports.parseSectionProperties = parseSectionProperties;
  2128. function parseColumns(elem, xml) {
  2129. return {
  2130. numberOfColumns: xml.intAttr(elem, "num"),
  2131. space: xml.lengthAttr(elem, "space"),
  2132. separator: xml.boolAttr(elem, "sep"),
  2133. equalWidth: xml.boolAttr(elem, "equalWidth", true),
  2134. columns: xml.elements(elem, "col")
  2135. .map(e => ({
  2136. width: xml.lengthAttr(e, "w"),
  2137. space: xml.lengthAttr(e, "space")
  2138. }))
  2139. };
  2140. }
  2141. function parsePageNumber(elem, xml) {
  2142. return {
  2143. chapSep: xml.attr(elem, "chapSep"),
  2144. chapStyle: xml.attr(elem, "chapStyle"),
  2145. format: xml.attr(elem, "fmt"),
  2146. start: xml.intAttr(elem, "start")
  2147. };
  2148. }
  2149. function parseFooterHeaderReference(elem, xml) {
  2150. return {
  2151. id: xml.attr(elem, "id"),
  2152. type: xml.attr(elem, "type"),
  2153. };
  2154. }
  2155. /***/ }),
  2156. /***/ "./src/docx-preview.ts":
  2157. /*!*****************************!*\
  2158. !*** ./src/docx-preview.ts ***!
  2159. \*****************************/
  2160. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2161. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2162. exports.renderAsync = exports.praseAsync = exports.defaultOptions = void 0;
  2163. const word_document_1 = __webpack_require__(/*! ./word-document */ "./src/word-document.ts");
  2164. const document_parser_1 = __webpack_require__(/*! ./document-parser */ "./src/document-parser.ts");
  2165. const html_renderer_1 = __webpack_require__(/*! ./html-renderer */ "./src/html-renderer.ts");
  2166. exports.defaultOptions = {
  2167. ignoreHeight: false,
  2168. ignoreWidth: false,
  2169. ignoreFonts: false,
  2170. breakPages: true,
  2171. debug: false,
  2172. experimental: false,
  2173. className: "docx",
  2174. inWrapper: true,
  2175. trimXmlDeclaration: true,
  2176. ignoreLastRenderedPageBreak: true,
  2177. renderHeaders: true,
  2178. renderFooters: true,
  2179. renderFootnotes: true,
  2180. renderEndnotes: true,
  2181. useBase64URL: false,
  2182. useMathMLPolyfill: false,
  2183. renderChanges: false
  2184. };
  2185. function praseAsync(data, userOptions = null) {
  2186. const ops = Object.assign(Object.assign({}, exports.defaultOptions), userOptions);
  2187. return word_document_1.WordDocument.load(data, new document_parser_1.DocumentParser(ops), ops);
  2188. }
  2189. exports.praseAsync = praseAsync;
  2190. function renderAsync(data, bodyContainer, styleContainer = null, userOptions = null) {
  2191. const ops = Object.assign(Object.assign({}, exports.defaultOptions), userOptions);
  2192. const renderer = new html_renderer_1.HtmlRenderer(window.document);
  2193. return word_document_1.WordDocument
  2194. .load(data, new document_parser_1.DocumentParser(ops), ops)
  2195. .then(doc => {
  2196. renderer.render(doc, bodyContainer, styleContainer, ops);
  2197. return doc;
  2198. });
  2199. }
  2200. exports.renderAsync = renderAsync;
  2201. /***/ }),
  2202. /***/ "./src/font-table/font-table.ts":
  2203. /*!**************************************!*\
  2204. !*** ./src/font-table/font-table.ts ***!
  2205. \**************************************/
  2206. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2207. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2208. exports.FontTablePart = void 0;
  2209. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  2210. const fonts_1 = __webpack_require__(/*! ./fonts */ "./src/font-table/fonts.ts");
  2211. class FontTablePart extends part_1.Part {
  2212. parseXml(root) {
  2213. this.fonts = (0, fonts_1.parseFonts)(root, this._package.xmlParser);
  2214. }
  2215. }
  2216. exports.FontTablePart = FontTablePart;
  2217. /***/ }),
  2218. /***/ "./src/font-table/fonts.ts":
  2219. /*!*********************************!*\
  2220. !*** ./src/font-table/fonts.ts ***!
  2221. \*********************************/
  2222. /***/ ((__unused_webpack_module, exports) => {
  2223. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2224. exports.parseEmbedFontRef = exports.parseFont = exports.parseFonts = void 0;
  2225. const embedFontTypeMap = {
  2226. embedRegular: 'regular',
  2227. embedBold: 'bold',
  2228. embedItalic: 'italic',
  2229. embedBoldItalic: 'boldItalic',
  2230. };
  2231. function parseFonts(root, xml) {
  2232. return xml.elements(root).map(el => parseFont(el, xml));
  2233. }
  2234. exports.parseFonts = parseFonts;
  2235. function parseFont(elem, xml) {
  2236. let result = {
  2237. name: xml.attr(elem, "name"),
  2238. embedFontRefs: []
  2239. };
  2240. for (let el of xml.elements(elem)) {
  2241. switch (el.localName) {
  2242. case "family":
  2243. result.family = xml.attr(el, "val");
  2244. break;
  2245. case "altName":
  2246. result.altName = xml.attr(el, "val");
  2247. break;
  2248. case "embedRegular":
  2249. case "embedBold":
  2250. case "embedItalic":
  2251. case "embedBoldItalic":
  2252. result.embedFontRefs.push(parseEmbedFontRef(el, xml));
  2253. break;
  2254. }
  2255. }
  2256. return result;
  2257. }
  2258. exports.parseFont = parseFont;
  2259. function parseEmbedFontRef(elem, xml) {
  2260. return {
  2261. id: xml.attr(elem, "id"),
  2262. key: xml.attr(elem, "fontKey"),
  2263. type: embedFontTypeMap[elem.localName]
  2264. };
  2265. }
  2266. exports.parseEmbedFontRef = parseEmbedFontRef;
  2267. /***/ }),
  2268. /***/ "./src/header-footer/elements.ts":
  2269. /*!***************************************!*\
  2270. !*** ./src/header-footer/elements.ts ***!
  2271. \***************************************/
  2272. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2273. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2274. exports.WmlFooter = exports.WmlHeader = void 0;
  2275. const dom_1 = __webpack_require__(/*! ../document/dom */ "./src/document/dom.ts");
  2276. class WmlHeader {
  2277. constructor() {
  2278. this.type = dom_1.DomType.Header;
  2279. this.children = [];
  2280. this.cssStyle = {};
  2281. }
  2282. }
  2283. exports.WmlHeader = WmlHeader;
  2284. class WmlFooter {
  2285. constructor() {
  2286. this.type = dom_1.DomType.Footer;
  2287. this.children = [];
  2288. this.cssStyle = {};
  2289. }
  2290. }
  2291. exports.WmlFooter = WmlFooter;
  2292. /***/ }),
  2293. /***/ "./src/header-footer/parts.ts":
  2294. /*!************************************!*\
  2295. !*** ./src/header-footer/parts.ts ***!
  2296. \************************************/
  2297. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2298. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2299. exports.FooterPart = exports.HeaderPart = exports.BaseHeaderFooterPart = void 0;
  2300. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  2301. const elements_1 = __webpack_require__(/*! ./elements */ "./src/header-footer/elements.ts");
  2302. class BaseHeaderFooterPart extends part_1.Part {
  2303. constructor(pkg, path, parser) {
  2304. super(pkg, path);
  2305. this._documentParser = parser;
  2306. }
  2307. parseXml(root) {
  2308. this.rootElement = this.createRootElement();
  2309. this.rootElement.children = this._documentParser.parseBodyElements(root);
  2310. }
  2311. }
  2312. exports.BaseHeaderFooterPart = BaseHeaderFooterPart;
  2313. class HeaderPart extends BaseHeaderFooterPart {
  2314. createRootElement() {
  2315. return new elements_1.WmlHeader();
  2316. }
  2317. }
  2318. exports.HeaderPart = HeaderPart;
  2319. class FooterPart extends BaseHeaderFooterPart {
  2320. createRootElement() {
  2321. return new elements_1.WmlFooter();
  2322. }
  2323. }
  2324. exports.FooterPart = FooterPart;
  2325. /***/ }),
  2326. /***/ "./src/html-renderer.ts":
  2327. /*!******************************!*\
  2328. !*** ./src/html-renderer.ts ***!
  2329. \******************************/
  2330. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  2331. Object.defineProperty(exports, "__esModule", ({ value: true }));
  2332. exports.HtmlRenderer = void 0;
  2333. const dom_1 = __webpack_require__(/*! ./document/dom */ "./src/document/dom.ts");
  2334. const utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
  2335. const javascript_1 = __webpack_require__(/*! ./javascript */ "./src/javascript.ts");
  2336. const mathml_scss_1 = __webpack_require__(/*! ./mathml.scss */ "./src/mathml.scss");
  2337. const ns = {
  2338. svg: "http://www.w3.org/2000/svg",
  2339. mathML: "http://www.w3.org/1998/Math/MathML"
  2340. };
  2341. class HtmlRenderer {
  2342. constructor(htmlDocument) {
  2343. this.htmlDocument = htmlDocument;
  2344. this.className = "docx";
  2345. this.styleMap = {};
  2346. this.currentPart = null;
  2347. this.tableVerticalMerges = [];
  2348. this.currentVerticalMerge = null;
  2349. this.tableCellPositions = [];
  2350. this.currentCellPosition = null;
  2351. this.footnoteMap = {};
  2352. this.endnoteMap = {};
  2353. this.currentEndnoteIds = [];
  2354. this.usedHederFooterParts = [];
  2355. this.currentTabs = [];
  2356. this.tabsTimeout = 0;
  2357. this.createElement = createElement;
  2358. }
  2359. render(document, bodyContainer, styleContainer = null, options) {
  2360. var _a;
  2361. this.document = document;
  2362. this.options = options;
  2363. this.className = options.className;
  2364. this.rootSelector = options.inWrapper ? `.${this.className}-wrapper` : ':root';
  2365. this.styleMap = null;
  2366. styleContainer = styleContainer || bodyContainer;
  2367. removeAllElements(styleContainer);
  2368. removeAllElements(bodyContainer);
  2369. appendComment(styleContainer, "docxjs library predefined styles");
  2370. styleContainer.appendChild(this.renderDefaultStyle());
  2371. if (!window.MathMLElement && options.useMathMLPolyfill) {
  2372. appendComment(styleContainer, "docxjs mathml polyfill styles");
  2373. styleContainer.appendChild(createStyleElement(mathml_scss_1.default));
  2374. }
  2375. if (document.themePart) {
  2376. appendComment(styleContainer, "docxjs document theme values");
  2377. this.renderTheme(document.themePart, styleContainer);
  2378. }
  2379. if (document.stylesPart != null) {
  2380. this.styleMap = this.processStyles(document.stylesPart.styles);
  2381. appendComment(styleContainer, "docxjs document styles");
  2382. styleContainer.appendChild(this.renderStyles(document.stylesPart.styles));
  2383. }
  2384. if (document.numberingPart) {
  2385. this.prodessNumberings(document.numberingPart.domNumberings);
  2386. appendComment(styleContainer, "docxjs document numbering styles");
  2387. styleContainer.appendChild(this.renderNumbering(document.numberingPart.domNumberings, styleContainer));
  2388. }
  2389. if (document.footnotesPart) {
  2390. this.footnoteMap = (0, utils_1.keyBy)(document.footnotesPart.notes, x => x.id);
  2391. }
  2392. if (document.endnotesPart) {
  2393. this.endnoteMap = (0, utils_1.keyBy)(document.endnotesPart.notes, x => x.id);
  2394. }
  2395. if (document.settingsPart) {
  2396. this.defaultTabSize = (_a = document.settingsPart.settings) === null || _a === void 0 ? void 0 : _a.defaultTabStop;
  2397. }
  2398. if (!options.ignoreFonts && document.fontTablePart)
  2399. this.renderFontTable(document.fontTablePart, styleContainer);
  2400. var sectionElements = this.renderSections(document.documentPart.body);
  2401. if (this.options.inWrapper) {
  2402. bodyContainer.appendChild(this.renderWrapper(sectionElements));
  2403. }
  2404. else {
  2405. appendChildren(bodyContainer, sectionElements);
  2406. }
  2407. this.refreshTabStops();
  2408. }
  2409. renderTheme(themePart, styleContainer) {
  2410. var _a, _b;
  2411. const variables = {};
  2412. const fontScheme = (_a = themePart.theme) === null || _a === void 0 ? void 0 : _a.fontScheme;
  2413. if (fontScheme) {
  2414. if (fontScheme.majorFont) {
  2415. variables['--docx-majorHAnsi-font'] = fontScheme.majorFont.latinTypeface;
  2416. }
  2417. if (fontScheme.minorFont) {
  2418. variables['--docx-minorHAnsi-font'] = fontScheme.minorFont.latinTypeface;
  2419. }
  2420. }
  2421. const colorScheme = (_b = themePart.theme) === null || _b === void 0 ? void 0 : _b.colorScheme;
  2422. if (colorScheme) {
  2423. for (let [k, v] of Object.entries(colorScheme.colors)) {
  2424. variables[`--docx-${k}-color`] = `#${v}`;
  2425. }
  2426. }
  2427. const cssText = this.styleToString(`.${this.className}`, variables);
  2428. styleContainer.appendChild(createStyleElement(cssText));
  2429. }
  2430. renderFontTable(fontsPart, styleContainer) {
  2431. for (let f of fontsPart.fonts) {
  2432. for (let ref of f.embedFontRefs) {
  2433. this.document.loadFont(ref.id, ref.key).then(fontData => {
  2434. const cssValues = {
  2435. 'font-family': f.name,
  2436. 'src': `url(${fontData})`
  2437. };
  2438. if (ref.type == "bold" || ref.type == "boldItalic") {
  2439. cssValues['font-weight'] = 'bold';
  2440. }
  2441. if (ref.type == "italic" || ref.type == "boldItalic") {
  2442. cssValues['font-style'] = 'italic';
  2443. }
  2444. appendComment(styleContainer, `docxjs ${f.name} font`);
  2445. const cssText = this.styleToString("@font-face", cssValues);
  2446. styleContainer.appendChild(createStyleElement(cssText));
  2447. this.refreshTabStops();
  2448. });
  2449. }
  2450. }
  2451. }
  2452. processStyleName(className) {
  2453. return className ? `${this.className}_${(0, utils_1.escapeClassName)(className)}` : this.className;
  2454. }
  2455. processStyles(styles) {
  2456. const stylesMap = (0, utils_1.keyBy)(styles.filter(x => x.id != null), x => x.id);
  2457. for (const style of styles.filter(x => x.basedOn)) {
  2458. var baseStyle = stylesMap[style.basedOn];
  2459. if (baseStyle) {
  2460. style.paragraphProps = (0, utils_1.mergeDeep)(style.paragraphProps, baseStyle.paragraphProps);
  2461. style.runProps = (0, utils_1.mergeDeep)(style.runProps, baseStyle.runProps);
  2462. for (const baseValues of baseStyle.styles) {
  2463. const styleValues = style.styles.find(x => x.target == baseValues.target);
  2464. if (styleValues) {
  2465. this.copyStyleProperties(baseValues.values, styleValues.values);
  2466. }
  2467. else {
  2468. style.styles.push(Object.assign(Object.assign({}, baseValues), { values: Object.assign({}, baseValues.values) }));
  2469. }
  2470. }
  2471. }
  2472. else if (this.options.debug)
  2473. console.warn(`Can't find base style ${style.basedOn}`);
  2474. }
  2475. for (let style of styles) {
  2476. style.cssName = this.processStyleName(style.id);
  2477. }
  2478. return stylesMap;
  2479. }
  2480. prodessNumberings(numberings) {
  2481. var _a;
  2482. for (let num of numberings.filter(n => n.pStyleName)) {
  2483. const style = this.findStyle(num.pStyleName);
  2484. if ((_a = style === null || style === void 0 ? void 0 : style.paragraphProps) === null || _a === void 0 ? void 0 : _a.numbering) {
  2485. style.paragraphProps.numbering.level = num.level;
  2486. }
  2487. }
  2488. }
  2489. processElement(element) {
  2490. if (element.children) {
  2491. for (var e of element.children) {
  2492. e.parent = element;
  2493. if (e.type == dom_1.DomType.Table) {
  2494. this.processTable(e);
  2495. }
  2496. else {
  2497. this.processElement(e);
  2498. }
  2499. }
  2500. }
  2501. }
  2502. processTable(table) {
  2503. for (var r of table.children) {
  2504. for (var c of r.children) {
  2505. c.cssStyle = this.copyStyleProperties(table.cellStyle, c.cssStyle, [
  2506. "border-left", "border-right", "border-top", "border-bottom",
  2507. "padding-left", "padding-right", "padding-top", "padding-bottom"
  2508. ]);
  2509. this.processElement(c);
  2510. }
  2511. }
  2512. }
  2513. copyStyleProperties(input, output, attrs = null) {
  2514. if (!input)
  2515. return output;
  2516. if (output == null)
  2517. output = {};
  2518. if (attrs == null)
  2519. attrs = Object.getOwnPropertyNames(input);
  2520. for (var key of attrs) {
  2521. if (input.hasOwnProperty(key) && !output.hasOwnProperty(key))
  2522. output[key] = input[key];
  2523. }
  2524. return output;
  2525. }
  2526. createSection(className, props) {
  2527. var elem = this.createElement("section", { className });
  2528. if (props) {
  2529. if (props.pageMargins) {
  2530. elem.style.paddingLeft = props.pageMargins.left;
  2531. elem.style.paddingRight = props.pageMargins.right;
  2532. elem.style.paddingTop = props.pageMargins.top;
  2533. elem.style.paddingBottom = props.pageMargins.bottom;
  2534. }
  2535. if (props.pageSize) {
  2536. if (!this.options.ignoreWidth)
  2537. elem.style.width = props.pageSize.width;
  2538. if (!this.options.ignoreHeight)
  2539. elem.style.minHeight = props.pageSize.height;
  2540. }
  2541. if (props.columns && props.columns.numberOfColumns) {
  2542. elem.style.columnCount = `${props.columns.numberOfColumns}`;
  2543. elem.style.columnGap = props.columns.space;
  2544. if (props.columns.separator) {
  2545. elem.style.columnRule = "1px solid black";
  2546. }
  2547. }
  2548. }
  2549. return elem;
  2550. }
  2551. renderSections(document) {
  2552. const result = [];
  2553. this.processElement(document);
  2554. const sections = this.splitBySection(document.children);
  2555. let prevProps = null;
  2556. for (let i = 0, l = sections.length; i < l; i++) {
  2557. this.currentFootnoteIds = [];
  2558. const section = sections[i];
  2559. const props = section.sectProps || document.props;
  2560. const sectionElement = this.createSection(this.className, props);
  2561. this.renderStyleValues(document.cssStyle, sectionElement);
  2562. this.options.renderHeaders && this.renderHeaderFooter(props.headerRefs, props, result.length, prevProps != props, sectionElement);
  2563. var contentElement = this.createElement("article");
  2564. this.renderElements(section.elements, contentElement);
  2565. sectionElement.appendChild(contentElement);
  2566. if (this.options.renderFootnotes) {
  2567. this.renderNotes(this.currentFootnoteIds, this.footnoteMap, sectionElement);
  2568. }
  2569. if (this.options.renderEndnotes && i == l - 1) {
  2570. this.renderNotes(this.currentEndnoteIds, this.endnoteMap, sectionElement);
  2571. }
  2572. this.options.renderFooters && this.renderHeaderFooter(props.footerRefs, props, result.length, prevProps != props, sectionElement);
  2573. result.push(sectionElement);
  2574. prevProps = props;
  2575. }
  2576. return result;
  2577. }
  2578. renderHeaderFooter(refs, props, page, firstOfSection, into) {
  2579. var _a, _b;
  2580. if (!refs)
  2581. return;
  2582. var ref = (_b = (_a = (props.titlePage && firstOfSection ? refs.find(x => x.type == "first") : null)) !== null && _a !== void 0 ? _a : (page % 2 == 1 ? refs.find(x => x.type == "even") : null)) !== null && _b !== void 0 ? _b : refs.find(x => x.type == "default");
  2583. var part = ref && this.document.findPartByRelId(ref.id, this.document.documentPart);
  2584. if (part) {
  2585. this.currentPart = part;
  2586. if (!this.usedHederFooterParts.includes(part.path)) {
  2587. this.processElement(part.rootElement);
  2588. this.usedHederFooterParts.push(part.path);
  2589. }
  2590. this.renderElements([part.rootElement], into);
  2591. this.currentPart = null;
  2592. }
  2593. }
  2594. isPageBreakElement(elem) {
  2595. if (elem.type != dom_1.DomType.Break)
  2596. return false;
  2597. if (elem.break == "lastRenderedPageBreak")
  2598. return !this.options.ignoreLastRenderedPageBreak;
  2599. return elem.break == "page";
  2600. }
  2601. splitBySection(elements) {
  2602. var _a;
  2603. var current = { sectProps: null, elements: [] };
  2604. var result = [current];
  2605. for (let elem of elements) {
  2606. if (elem.type == dom_1.DomType.Paragraph) {
  2607. const s = this.findStyle(elem.styleName);
  2608. if ((_a = s === null || s === void 0 ? void 0 : s.paragraphProps) === null || _a === void 0 ? void 0 : _a.pageBreakBefore) {
  2609. current.sectProps = sectProps;
  2610. current = { sectProps: null, elements: [] };
  2611. result.push(current);
  2612. }
  2613. }
  2614. current.elements.push(elem);
  2615. if (elem.type == dom_1.DomType.Paragraph) {
  2616. const p = elem;
  2617. var sectProps = p.sectionProps;
  2618. var pBreakIndex = -1;
  2619. var rBreakIndex = -1;
  2620. if (this.options.breakPages && p.children) {
  2621. pBreakIndex = p.children.findIndex(r => {
  2622. var _a, _b;
  2623. rBreakIndex = (_b = (_a = r.children) === null || _a === void 0 ? void 0 : _a.findIndex(this.isPageBreakElement.bind(this))) !== null && _b !== void 0 ? _b : -1;
  2624. return rBreakIndex != -1;
  2625. });
  2626. }
  2627. if (sectProps || pBreakIndex != -1) {
  2628. current.sectProps = sectProps;
  2629. current = { sectProps: null, elements: [] };
  2630. result.push(current);
  2631. }
  2632. if (pBreakIndex != -1) {
  2633. let breakRun = p.children[pBreakIndex];
  2634. let splitRun = rBreakIndex < breakRun.children.length - 1;
  2635. if (pBreakIndex < p.children.length - 1 || splitRun) {
  2636. var children = elem.children;
  2637. var newParagraph = Object.assign(Object.assign({}, elem), { children: children.slice(pBreakIndex) });
  2638. elem.children = children.slice(0, pBreakIndex);
  2639. current.elements.push(newParagraph);
  2640. if (splitRun) {
  2641. let runChildren = breakRun.children;
  2642. let newRun = Object.assign(Object.assign({}, breakRun), { children: runChildren.slice(0, rBreakIndex) });
  2643. elem.children.push(newRun);
  2644. breakRun.children = runChildren.slice(rBreakIndex);
  2645. }
  2646. }
  2647. }
  2648. }
  2649. }
  2650. let currentSectProps = null;
  2651. for (let i = result.length - 1; i >= 0; i--) {
  2652. if (result[i].sectProps == null) {
  2653. result[i].sectProps = currentSectProps;
  2654. }
  2655. else {
  2656. currentSectProps = result[i].sectProps;
  2657. }
  2658. }
  2659. return result;
  2660. }
  2661. renderWrapper(children) {
  2662. return this.createElement("div", { className: `${this.className}-wrapper` }, children);
  2663. }
  2664. renderDefaultStyle() {
  2665. var c = this.className;
  2666. var styleText = `
  2667. .${c}-wrapper { background: gray; padding: 30px; padding-bottom: 0px; display: flex; flex-flow: column; align-items: center; }
  2668. .${c}-wrapper>section.${c} { background: white; box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); margin-bottom: 30px; }
  2669. .${c} { color: black; }
  2670. section.${c} { box-sizing: border-box; display: flex; flex-flow: column nowrap; position: relative; overflow: hidden; }
  2671. section.${c}>article { margin-bottom: auto; }
  2672. .${c} table { border-collapse: collapse; }
  2673. .${c} table td, .${c} table th { vertical-align: top; }
  2674. .${c} p { margin: 0pt; min-height: 1em; }
  2675. .${c} span { white-space: pre-wrap; overflow-wrap: break-word; }
  2676. .${c} a { color: inherit; text-decoration: inherit; }
  2677. `;
  2678. return createStyleElement(styleText);
  2679. }
  2680. renderNumbering(numberings, styleContainer) {
  2681. var styleText = "";
  2682. var rootCounters = [];
  2683. for (var num of numberings) {
  2684. var selector = `p.${this.numberingClass(num.id, num.level)}`;
  2685. var listStyleType = "none";
  2686. if (num.bullet) {
  2687. let valiable = `--${this.className}-${num.bullet.src}`.toLowerCase();
  2688. styleText += this.styleToString(`${selector}:before`, {
  2689. "content": "' '",
  2690. "display": "inline-block",
  2691. "background": `var(${valiable})`
  2692. }, num.bullet.style);
  2693. this.document.loadNumberingImage(num.bullet.src).then(data => {
  2694. var text = `${this.rootSelector} { ${valiable}: url(${data}) }`;
  2695. styleContainer.appendChild(createStyleElement(text));
  2696. });
  2697. }
  2698. else if (num.levelText) {
  2699. let counter = this.numberingCounter(num.id, num.level);
  2700. if (num.level > 0) {
  2701. styleText += this.styleToString(`p.${this.numberingClass(num.id, num.level - 1)}`, {
  2702. "counter-reset": counter
  2703. });
  2704. }
  2705. else {
  2706. rootCounters.push(counter);
  2707. }
  2708. styleText += this.styleToString(`${selector}:before`, Object.assign({ "content": this.levelTextToContent(num.levelText, num.suff, num.id, this.numFormatToCssValue(num.format)), "counter-increment": counter }, num.rStyle));
  2709. }
  2710. else {
  2711. listStyleType = this.numFormatToCssValue(num.format);
  2712. }
  2713. styleText += this.styleToString(selector, Object.assign({ "display": "list-item", "list-style-position": "inside", "list-style-type": listStyleType }, num.pStyle));
  2714. }
  2715. if (rootCounters.length > 0) {
  2716. styleText += this.styleToString(this.rootSelector, {
  2717. "counter-reset": rootCounters.join(" ")
  2718. });
  2719. }
  2720. return createStyleElement(styleText);
  2721. }
  2722. renderStyles(styles) {
  2723. var _a;
  2724. var styleText = "";
  2725. const stylesMap = this.styleMap;
  2726. const defautStyles = (0, utils_1.keyBy)(styles.filter(s => s.isDefault), s => s.target);
  2727. for (const style of styles) {
  2728. var subStyles = style.styles;
  2729. if (style.linked) {
  2730. var linkedStyle = style.linked && stylesMap[style.linked];
  2731. if (linkedStyle)
  2732. subStyles = subStyles.concat(linkedStyle.styles);
  2733. else if (this.options.debug)
  2734. console.warn(`Can't find linked style ${style.linked}`);
  2735. }
  2736. for (const subStyle of subStyles) {
  2737. var selector = `${(_a = style.target) !== null && _a !== void 0 ? _a : ''}.${style.cssName}`;
  2738. if (style.target != subStyle.target)
  2739. selector += ` ${subStyle.target}`;
  2740. if (defautStyles[style.target] == style)
  2741. selector = `.${this.className} ${style.target}, ` + selector;
  2742. styleText += this.styleToString(selector, subStyle.values);
  2743. }
  2744. }
  2745. return createStyleElement(styleText);
  2746. }
  2747. renderNotes(noteIds, notesMap, into) {
  2748. var notes = noteIds.map(id => notesMap[id]).filter(x => x);
  2749. if (notes.length > 0) {
  2750. var result = this.createElement("ol", null, this.renderElements(notes));
  2751. into.appendChild(result);
  2752. }
  2753. }
  2754. renderElement(elem) {
  2755. switch (elem.type) {
  2756. case dom_1.DomType.Paragraph:
  2757. return this.renderParagraph(elem);
  2758. case dom_1.DomType.BookmarkStart:
  2759. return this.renderBookmarkStart(elem);
  2760. case dom_1.DomType.BookmarkEnd:
  2761. return null;
  2762. case dom_1.DomType.Run:
  2763. return this.renderRun(elem);
  2764. case dom_1.DomType.Table:
  2765. return this.renderTable(elem);
  2766. case dom_1.DomType.Row:
  2767. return this.renderTableRow(elem);
  2768. case dom_1.DomType.Cell:
  2769. return this.renderTableCell(elem);
  2770. case dom_1.DomType.Hyperlink:
  2771. return this.renderHyperlink(elem);
  2772. case dom_1.DomType.Drawing:
  2773. return this.renderDrawing(elem);
  2774. case dom_1.DomType.Image:
  2775. return this.renderImage(elem);
  2776. case dom_1.DomType.Text:
  2777. return this.renderText(elem);
  2778. case dom_1.DomType.Text:
  2779. return this.renderText(elem);
  2780. case dom_1.DomType.DeletedText:
  2781. return this.renderDeletedText(elem);
  2782. case dom_1.DomType.Tab:
  2783. return this.renderTab(elem);
  2784. case dom_1.DomType.Symbol:
  2785. return this.renderSymbol(elem);
  2786. case dom_1.DomType.Break:
  2787. return this.renderBreak(elem);
  2788. case dom_1.DomType.Footer:
  2789. return this.renderContainer(elem, "footer");
  2790. case dom_1.DomType.Header:
  2791. return this.renderContainer(elem, "header");
  2792. case dom_1.DomType.Footnote:
  2793. case dom_1.DomType.Endnote:
  2794. return this.renderContainer(elem, "li");
  2795. case dom_1.DomType.FootnoteReference:
  2796. return this.renderFootnoteReference(elem);
  2797. case dom_1.DomType.EndnoteReference:
  2798. return this.renderEndnoteReference(elem);
  2799. case dom_1.DomType.NoBreakHyphen:
  2800. return this.createElement("wbr");
  2801. case dom_1.DomType.VmlPicture:
  2802. return this.renderVmlPicture(elem);
  2803. case dom_1.DomType.VmlElement:
  2804. return this.renderVmlElement(elem);
  2805. case dom_1.DomType.MmlMath:
  2806. return this.renderContainerNS(elem, ns.mathML, "math", { xmlns: ns.mathML });
  2807. case dom_1.DomType.MmlMathParagraph:
  2808. return this.renderContainer(elem, "span");
  2809. case dom_1.DomType.MmlFraction:
  2810. return this.renderContainerNS(elem, ns.mathML, "mfrac");
  2811. case dom_1.DomType.MmlNumerator:
  2812. case dom_1.DomType.MmlDenominator:
  2813. return this.renderContainerNS(elem, ns.mathML, "mrow");
  2814. case dom_1.DomType.MmlRadical:
  2815. return this.renderMmlRadical(elem);
  2816. case dom_1.DomType.MmlDegree:
  2817. return this.renderContainerNS(elem, ns.mathML, "mn");
  2818. case dom_1.DomType.MmlSuperscript:
  2819. return this.renderContainerNS(elem, ns.mathML, "msup");
  2820. case dom_1.DomType.MmlSubscript:
  2821. return this.renderContainerNS(elem, ns.mathML, "msub");
  2822. case dom_1.DomType.MmlBase:
  2823. return this.renderContainerNS(elem, ns.mathML, "mrow");
  2824. case dom_1.DomType.MmlSuperArgument:
  2825. return this.renderContainerNS(elem, ns.mathML, "mn");
  2826. case dom_1.DomType.MmlSubArgument:
  2827. return this.renderContainerNS(elem, ns.mathML, "mn");
  2828. case dom_1.DomType.MmlDelimiter:
  2829. return this.renderMmlDelimiter(elem);
  2830. case dom_1.DomType.MmlRun:
  2831. return this.renderMmlRun(elem);
  2832. case dom_1.DomType.MmlNary:
  2833. return this.renderMmlNary(elem);
  2834. case dom_1.DomType.Inserted:
  2835. return this.renderInserted(elem);
  2836. case dom_1.DomType.Deleted:
  2837. return this.renderDeleted(elem);
  2838. }
  2839. return null;
  2840. }
  2841. renderChildren(elem, into) {
  2842. return this.renderElements(elem.children, into);
  2843. }
  2844. renderElements(elems, into) {
  2845. if (elems == null)
  2846. return null;
  2847. var result = elems.flatMap(e => this.renderElement(e)).filter(e => e != null);
  2848. if (into)
  2849. appendChildren(into, result);
  2850. return result;
  2851. }
  2852. renderContainer(elem, tagName, props) {
  2853. return this.createElement(tagName, props, this.renderChildren(elem));
  2854. }
  2855. renderContainerNS(elem, ns, tagName, props) {
  2856. return createElementNS(ns, tagName, props, this.renderChildren(elem));
  2857. }
  2858. renderParagraph(elem) {
  2859. var _a, _b, _c, _d;
  2860. var result = this.createElement("p");
  2861. const style = this.findStyle(elem.styleName);
  2862. (_a = elem.tabs) !== null && _a !== void 0 ? _a : (elem.tabs = (_b = style === null || style === void 0 ? void 0 : style.paragraphProps) === null || _b === void 0 ? void 0 : _b.tabs);
  2863. this.renderClass(elem, result);
  2864. this.renderChildren(elem, result);
  2865. this.renderStyleValues(elem.cssStyle, result);
  2866. this.renderCommonProperties(result.style, elem);
  2867. const numbering = (_c = elem.numbering) !== null && _c !== void 0 ? _c : (_d = style === null || style === void 0 ? void 0 : style.paragraphProps) === null || _d === void 0 ? void 0 : _d.numbering;
  2868. if (numbering) {
  2869. result.classList.add(this.numberingClass(numbering.id, numbering.level));
  2870. }
  2871. return result;
  2872. }
  2873. renderRunProperties(style, props) {
  2874. this.renderCommonProperties(style, props);
  2875. }
  2876. renderCommonProperties(style, props) {
  2877. if (props == null)
  2878. return;
  2879. if (props.color) {
  2880. style["color"] = props.color;
  2881. }
  2882. if (props.fontSize) {
  2883. style["font-size"] = props.fontSize;
  2884. }
  2885. }
  2886. renderHyperlink(elem) {
  2887. var result = this.createElement("a");
  2888. this.renderChildren(elem, result);
  2889. this.renderStyleValues(elem.cssStyle, result);
  2890. if (elem.href) {
  2891. result.href = elem.href;
  2892. }
  2893. else if (elem.id) {
  2894. const rel = this.document.documentPart.rels
  2895. .find(it => it.id == elem.id && it.targetMode === "External");
  2896. result.href = rel === null || rel === void 0 ? void 0 : rel.target;
  2897. }
  2898. return result;
  2899. }
  2900. renderDrawing(elem) {
  2901. var result = this.createElement("div");
  2902. result.style.display = "inline-block";
  2903. result.style.position = "relative";
  2904. result.style.textIndent = "0px";
  2905. this.renderChildren(elem, result);
  2906. this.renderStyleValues(elem.cssStyle, result);
  2907. return result;
  2908. }
  2909. renderImage(elem) {
  2910. let result = this.createElement("img");
  2911. this.renderStyleValues(elem.cssStyle, result);
  2912. if (this.document) {
  2913. this.document.loadDocumentImage(elem.src, this.currentPart).then(x => {
  2914. result.src = x;
  2915. });
  2916. }
  2917. return result;
  2918. }
  2919. renderText(elem) {
  2920. return this.htmlDocument.createTextNode(elem.text);
  2921. }
  2922. renderDeletedText(elem) {
  2923. return this.options.renderEndnotes ? this.htmlDocument.createTextNode(elem.text) : null;
  2924. }
  2925. renderBreak(elem) {
  2926. if (elem.break == "textWrapping") {
  2927. return this.createElement("br");
  2928. }
  2929. return null;
  2930. }
  2931. renderInserted(elem) {
  2932. if (this.options.renderChanges)
  2933. return this.renderContainer(elem, "ins");
  2934. return this.renderChildren(elem);
  2935. }
  2936. renderDeleted(elem) {
  2937. if (this.options.renderChanges)
  2938. return this.renderContainer(elem, "del");
  2939. return null;
  2940. }
  2941. renderSymbol(elem) {
  2942. var span = this.createElement("span");
  2943. span.style.fontFamily = elem.font;
  2944. span.innerHTML = `&#x${elem.char};`;
  2945. return span;
  2946. }
  2947. renderFootnoteReference(elem) {
  2948. var result = this.createElement("sup");
  2949. this.currentFootnoteIds.push(elem.id);
  2950. result.textContent = `${this.currentFootnoteIds.length}`;
  2951. return result;
  2952. }
  2953. renderEndnoteReference(elem) {
  2954. var result = this.createElement("sup");
  2955. this.currentEndnoteIds.push(elem.id);
  2956. result.textContent = `${this.currentEndnoteIds.length}`;
  2957. return result;
  2958. }
  2959. renderTab(elem) {
  2960. var _a;
  2961. var tabSpan = this.createElement("span");
  2962. tabSpan.innerHTML = "&emsp;";
  2963. if (this.options.experimental) {
  2964. tabSpan.className = this.tabStopClass();
  2965. var stops = (_a = findParent(elem, dom_1.DomType.Paragraph)) === null || _a === void 0 ? void 0 : _a.tabs;
  2966. this.currentTabs.push({ stops, span: tabSpan });
  2967. }
  2968. return tabSpan;
  2969. }
  2970. renderBookmarkStart(elem) {
  2971. var result = this.createElement("span");
  2972. result.id = elem.name;
  2973. return result;
  2974. }
  2975. renderRun(elem) {
  2976. if (elem.fieldRun)
  2977. return null;
  2978. const result = this.createElement("span");
  2979. if (elem.id)
  2980. result.id = elem.id;
  2981. this.renderClass(elem, result);
  2982. this.renderStyleValues(elem.cssStyle, result);
  2983. if (elem.verticalAlign) {
  2984. const wrapper = this.createElement(elem.verticalAlign);
  2985. this.renderChildren(elem, wrapper);
  2986. result.appendChild(wrapper);
  2987. }
  2988. else {
  2989. this.renderChildren(elem, result);
  2990. }
  2991. return result;
  2992. }
  2993. renderTable(elem) {
  2994. let result = this.createElement("table");
  2995. this.tableCellPositions.push(this.currentCellPosition);
  2996. this.tableVerticalMerges.push(this.currentVerticalMerge);
  2997. this.currentVerticalMerge = {};
  2998. this.currentCellPosition = { col: 0, row: 0 };
  2999. if (elem.columns)
  3000. result.appendChild(this.renderTableColumns(elem.columns));
  3001. this.renderClass(elem, result);
  3002. this.renderChildren(elem, result);
  3003. this.renderStyleValues(elem.cssStyle, result);
  3004. this.currentVerticalMerge = this.tableVerticalMerges.pop();
  3005. this.currentCellPosition = this.tableCellPositions.pop();
  3006. return result;
  3007. }
  3008. renderTableColumns(columns) {
  3009. let result = this.createElement("colgroup");
  3010. for (let col of columns) {
  3011. let colElem = this.createElement("col");
  3012. if (col.width)
  3013. colElem.style.width = col.width;
  3014. result.appendChild(colElem);
  3015. }
  3016. return result;
  3017. }
  3018. renderTableRow(elem) {
  3019. let result = this.createElement("tr");
  3020. this.currentCellPosition.col = 0;
  3021. this.renderClass(elem, result);
  3022. this.renderChildren(elem, result);
  3023. this.renderStyleValues(elem.cssStyle, result);
  3024. this.currentCellPosition.row++;
  3025. return result;
  3026. }
  3027. renderTableCell(elem) {
  3028. let result = this.createElement("td");
  3029. const key = this.currentCellPosition.col;
  3030. if (elem.verticalMerge) {
  3031. if (elem.verticalMerge == "restart") {
  3032. this.currentVerticalMerge[key] = result;
  3033. result.rowSpan = 1;
  3034. }
  3035. else if (this.currentVerticalMerge[key]) {
  3036. this.currentVerticalMerge[key].rowSpan += 1;
  3037. result.style.display = "none";
  3038. }
  3039. }
  3040. else {
  3041. this.currentVerticalMerge[key] = null;
  3042. }
  3043. this.renderClass(elem, result);
  3044. this.renderChildren(elem, result);
  3045. this.renderStyleValues(elem.cssStyle, result);
  3046. if (elem.span)
  3047. result.colSpan = elem.span;
  3048. this.currentCellPosition.col += result.colSpan;
  3049. return result;
  3050. }
  3051. renderVmlPicture(elem) {
  3052. var result = createElement("div");
  3053. this.renderChildren(elem, result);
  3054. return result;
  3055. }
  3056. renderVmlElement(elem) {
  3057. var _a, _b;
  3058. var container = createSvgElement("svg");
  3059. container.setAttribute("style", elem.cssStyleText);
  3060. const result = createSvgElement(elem.tagName);
  3061. Object.entries(elem.attrs).forEach(([k, v]) => result.setAttribute(k, v));
  3062. if ((_a = elem.imageHref) === null || _a === void 0 ? void 0 : _a.id) {
  3063. (_b = this.document) === null || _b === void 0 ? void 0 : _b.loadDocumentImage(elem.imageHref.id, this.currentPart).then(x => result.setAttribute("href", x));
  3064. }
  3065. container.appendChild(result);
  3066. setTimeout(() => {
  3067. const bb = container.firstElementChild.getBBox();
  3068. container.setAttribute("width", `${Math.ceil(bb.x + bb.width)}`);
  3069. container.setAttribute("height", `${Math.ceil(bb.y + bb.height)}`);
  3070. }, 0);
  3071. return container;
  3072. }
  3073. renderMmlRadical(elem) {
  3074. var _a;
  3075. const base = elem.children.find(el => el.type == dom_1.DomType.MmlBase);
  3076. if ((_a = elem.props) === null || _a === void 0 ? void 0 : _a.hideDegree) {
  3077. return createElementNS(ns.mathML, "msqrt", null, this.renderElements([base]));
  3078. }
  3079. const degree = elem.children.find(el => el.type == dom_1.DomType.MmlDegree);
  3080. return createElementNS(ns.mathML, "mroot", null, this.renderElements([base, degree]));
  3081. }
  3082. renderMmlDelimiter(elem) {
  3083. var _a, _b;
  3084. const children = [];
  3085. children.push(createElementNS(ns.mathML, "mo", null, [(_a = elem.props.beginChar) !== null && _a !== void 0 ? _a : '(']));
  3086. children.push(...this.renderElements(elem.children));
  3087. children.push(createElementNS(ns.mathML, "mo", null, [(_b = elem.props.endChar) !== null && _b !== void 0 ? _b : ')']));
  3088. return createElementNS(ns.mathML, "mrow", null, children);
  3089. }
  3090. renderMmlNary(elem) {
  3091. var _a;
  3092. const children = [];
  3093. const grouped = (0, utils_1.keyBy)(elem.children, x => x.type);
  3094. const sup = grouped[dom_1.DomType.MmlSuperArgument];
  3095. const sub = grouped[dom_1.DomType.MmlSubArgument];
  3096. const supElem = sup ? createElementNS(ns.mathML, "mo", null, (0, utils_1.asArray)(this.renderElement(sup))) : null;
  3097. const subElem = sub ? createElementNS(ns.mathML, "mo", null, (0, utils_1.asArray)(this.renderElement(sub))) : null;
  3098. if ((_a = elem.props) === null || _a === void 0 ? void 0 : _a.char) {
  3099. const charElem = createElementNS(ns.mathML, "mo", null, [elem.props.char]);
  3100. if (supElem || subElem) {
  3101. children.push(createElementNS(ns.mathML, "munderover", null, [charElem, subElem, supElem]));
  3102. }
  3103. else if (supElem) {
  3104. children.push(createElementNS(ns.mathML, "mover", null, [charElem, supElem]));
  3105. }
  3106. else if (subElem) {
  3107. children.push(createElementNS(ns.mathML, "munder", null, [charElem, subElem]));
  3108. }
  3109. else {
  3110. children.push(charElem);
  3111. }
  3112. }
  3113. children.push(...this.renderElements(grouped[dom_1.DomType.MmlBase].children));
  3114. return createElementNS(ns.mathML, "mrow", null, children);
  3115. }
  3116. renderMmlRun(elem) {
  3117. const result = createElementNS(ns.mathML, "ms");
  3118. this.renderClass(elem, result);
  3119. this.renderStyleValues(elem.cssStyle, result);
  3120. this.renderChildren(elem, result);
  3121. return result;
  3122. }
  3123. renderStyleValues(style, ouput) {
  3124. Object.assign(ouput.style, style);
  3125. }
  3126. renderClass(input, ouput) {
  3127. if (input.className)
  3128. ouput.className = input.className;
  3129. if (input.styleName)
  3130. ouput.classList.add(this.processStyleName(input.styleName));
  3131. }
  3132. findStyle(styleName) {
  3133. var _a;
  3134. return styleName && ((_a = this.styleMap) === null || _a === void 0 ? void 0 : _a[styleName]);
  3135. }
  3136. numberingClass(id, lvl) {
  3137. return `${this.className}-num-${id}-${lvl}`;
  3138. }
  3139. tabStopClass() {
  3140. return `${this.className}-tab-stop`;
  3141. }
  3142. styleToString(selectors, values, cssText = null) {
  3143. let result = `${selectors} {\r\n`;
  3144. for (const key in values) {
  3145. result += ` ${key}: ${values[key]};\r\n`;
  3146. }
  3147. if (cssText)
  3148. result += cssText;
  3149. return result + "}\r\n";
  3150. }
  3151. numberingCounter(id, lvl) {
  3152. return `${this.className}-num-${id}-${lvl}`;
  3153. }
  3154. levelTextToContent(text, suff, id, numformat) {
  3155. var _a;
  3156. const suffMap = {
  3157. "tab": "\\9",
  3158. "space": "\\a0",
  3159. };
  3160. var result = text.replace(/%\d*/g, s => {
  3161. let lvl = parseInt(s.substring(1), 10) - 1;
  3162. return `"counter(${this.numberingCounter(id, lvl)}, ${numformat})"`;
  3163. });
  3164. return `"${result}${(_a = suffMap[suff]) !== null && _a !== void 0 ? _a : ""}"`;
  3165. }
  3166. numFormatToCssValue(format) {
  3167. var mapping = {
  3168. "none": "none",
  3169. "bullet": "disc",
  3170. "decimal": "decimal",
  3171. "lowerLetter": "lower-alpha",
  3172. "upperLetter": "upper-alpha",
  3173. "lowerRoman": "lower-roman",
  3174. "upperRoman": "upper-roman",
  3175. };
  3176. return mapping[format] || format;
  3177. }
  3178. refreshTabStops() {
  3179. if (!this.options.experimental)
  3180. return;
  3181. clearTimeout(this.tabsTimeout);
  3182. this.tabsTimeout = setTimeout(() => {
  3183. const pixelToPoint = (0, javascript_1.computePixelToPoint)();
  3184. for (let tab of this.currentTabs) {
  3185. (0, javascript_1.updateTabStop)(tab.span, tab.stops, this.defaultTabSize, pixelToPoint);
  3186. }
  3187. }, 500);
  3188. }
  3189. }
  3190. exports.HtmlRenderer = HtmlRenderer;
  3191. function createElement(tagName, props, children) {
  3192. return createElementNS(undefined, tagName, props, children);
  3193. }
  3194. function createSvgElement(tagName, props, children) {
  3195. return createElementNS(ns.svg, tagName, props, children);
  3196. }
  3197. function createElementNS(ns, tagName, props, children) {
  3198. var result = ns ? document.createElementNS(ns, tagName) : document.createElement(tagName);
  3199. Object.assign(result, props);
  3200. children && appendChildren(result, children);
  3201. return result;
  3202. }
  3203. function removeAllElements(elem) {
  3204. elem.innerHTML = '';
  3205. }
  3206. function appendChildren(elem, children) {
  3207. children.forEach(c => elem.appendChild((0, utils_1.isString)(c) ? document.createTextNode(c) : c));
  3208. }
  3209. function createStyleElement(cssText) {
  3210. return createElement("style", { innerHTML: cssText });
  3211. }
  3212. function appendComment(elem, comment) {
  3213. elem.appendChild(document.createComment(comment));
  3214. }
  3215. function findParent(elem, type) {
  3216. var parent = elem.parent;
  3217. while (parent != null && parent.type != type)
  3218. parent = parent.parent;
  3219. return parent;
  3220. }
  3221. /***/ }),
  3222. /***/ "./src/javascript.ts":
  3223. /*!***************************!*\
  3224. !*** ./src/javascript.ts ***!
  3225. \***************************/
  3226. /***/ ((__unused_webpack_module, exports) => {
  3227. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3228. exports.updateTabStop = exports.computePixelToPoint = void 0;
  3229. const defaultTab = { pos: 0, leader: "none", style: "left" };
  3230. const maxTabs = 50;
  3231. function computePixelToPoint(container = document.body) {
  3232. const temp = document.createElement("div");
  3233. temp.style.width = '100pt';
  3234. container.appendChild(temp);
  3235. const result = 100 / temp.offsetWidth;
  3236. container.removeChild(temp);
  3237. return result;
  3238. }
  3239. exports.computePixelToPoint = computePixelToPoint;
  3240. function updateTabStop(elem, tabs, defaultTabSize, pixelToPoint = 72 / 96) {
  3241. const p = elem.closest("p");
  3242. const ebb = elem.getBoundingClientRect();
  3243. const pbb = p.getBoundingClientRect();
  3244. const pcs = getComputedStyle(p);
  3245. const tabStops = (tabs === null || tabs === void 0 ? void 0 : tabs.length) > 0 ? tabs.map(t => ({
  3246. pos: lengthToPoint(t.position),
  3247. leader: t.leader,
  3248. style: t.style
  3249. })).sort((a, b) => a.pos - b.pos) : [defaultTab];
  3250. const lastTab = tabStops[tabStops.length - 1];
  3251. const pWidthPt = pbb.width * pixelToPoint;
  3252. const size = lengthToPoint(defaultTabSize);
  3253. let pos = lastTab.pos + size;
  3254. if (pos < pWidthPt) {
  3255. for (; pos < pWidthPt && tabStops.length < maxTabs; pos += size) {
  3256. tabStops.push(Object.assign(Object.assign({}, defaultTab), { pos: pos }));
  3257. }
  3258. }
  3259. const marginLeft = parseFloat(pcs.marginLeft);
  3260. const pOffset = pbb.left + marginLeft;
  3261. const left = (ebb.left - pOffset) * pixelToPoint;
  3262. const tab = tabStops.find(t => t.style != "clear" && t.pos > left);
  3263. if (tab == null)
  3264. return;
  3265. let width = 1;
  3266. if (tab.style == "right" || tab.style == "center") {
  3267. const tabStops = Array.from(p.querySelectorAll(`.${elem.className}`));
  3268. const nextIdx = tabStops.indexOf(elem) + 1;
  3269. const range = document.createRange();
  3270. range.setStart(elem, 1);
  3271. if (nextIdx < tabStops.length) {
  3272. range.setEndBefore(tabStops[nextIdx]);
  3273. }
  3274. else {
  3275. range.setEndAfter(p);
  3276. }
  3277. const mul = tab.style == "center" ? 0.5 : 1;
  3278. const nextBB = range.getBoundingClientRect();
  3279. const offset = nextBB.left + mul * nextBB.width - (pbb.left - marginLeft);
  3280. width = tab.pos - offset * pixelToPoint;
  3281. }
  3282. else {
  3283. width = tab.pos - left;
  3284. }
  3285. elem.innerHTML = "&nbsp;";
  3286. elem.style.textDecoration = "inherit";
  3287. elem.style.wordSpacing = `${width.toFixed(0)}pt`;
  3288. switch (tab.leader) {
  3289. case "dot":
  3290. case "middleDot":
  3291. elem.style.textDecoration = "underline";
  3292. elem.style.textDecorationStyle = "dotted";
  3293. break;
  3294. case "hyphen":
  3295. case "heavy":
  3296. case "underscore":
  3297. elem.style.textDecoration = "underline";
  3298. break;
  3299. }
  3300. }
  3301. exports.updateTabStop = updateTabStop;
  3302. function lengthToPoint(length) {
  3303. return parseFloat(length);
  3304. }
  3305. /***/ }),
  3306. /***/ "./src/notes/elements.ts":
  3307. /*!*******************************!*\
  3308. !*** ./src/notes/elements.ts ***!
  3309. \*******************************/
  3310. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3311. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3312. exports.WmlEndnote = exports.WmlFootnote = exports.WmlBaseNote = void 0;
  3313. const dom_1 = __webpack_require__(/*! ../document/dom */ "./src/document/dom.ts");
  3314. class WmlBaseNote {
  3315. constructor() {
  3316. this.children = [];
  3317. this.cssStyle = {};
  3318. }
  3319. }
  3320. exports.WmlBaseNote = WmlBaseNote;
  3321. class WmlFootnote extends WmlBaseNote {
  3322. constructor() {
  3323. super(...arguments);
  3324. this.type = dom_1.DomType.Footnote;
  3325. }
  3326. }
  3327. exports.WmlFootnote = WmlFootnote;
  3328. class WmlEndnote extends WmlBaseNote {
  3329. constructor() {
  3330. super(...arguments);
  3331. this.type = dom_1.DomType.Endnote;
  3332. }
  3333. }
  3334. exports.WmlEndnote = WmlEndnote;
  3335. /***/ }),
  3336. /***/ "./src/notes/parts.ts":
  3337. /*!****************************!*\
  3338. !*** ./src/notes/parts.ts ***!
  3339. \****************************/
  3340. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3341. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3342. exports.EndnotesPart = exports.FootnotesPart = exports.BaseNotePart = void 0;
  3343. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  3344. const elements_1 = __webpack_require__(/*! ./elements */ "./src/notes/elements.ts");
  3345. class BaseNotePart extends part_1.Part {
  3346. constructor(pkg, path, parser) {
  3347. super(pkg, path);
  3348. this._documentParser = parser;
  3349. }
  3350. }
  3351. exports.BaseNotePart = BaseNotePart;
  3352. class FootnotesPart extends BaseNotePart {
  3353. constructor(pkg, path, parser) {
  3354. super(pkg, path, parser);
  3355. }
  3356. parseXml(root) {
  3357. this.notes = this._documentParser.parseNotes(root, "footnote", elements_1.WmlFootnote);
  3358. }
  3359. }
  3360. exports.FootnotesPart = FootnotesPart;
  3361. class EndnotesPart extends BaseNotePart {
  3362. constructor(pkg, path, parser) {
  3363. super(pkg, path, parser);
  3364. }
  3365. parseXml(root) {
  3366. this.notes = this._documentParser.parseNotes(root, "endnote", elements_1.WmlEndnote);
  3367. }
  3368. }
  3369. exports.EndnotesPart = EndnotesPart;
  3370. /***/ }),
  3371. /***/ "./src/numbering/numbering-part.ts":
  3372. /*!*****************************************!*\
  3373. !*** ./src/numbering/numbering-part.ts ***!
  3374. \*****************************************/
  3375. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3376. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3377. exports.NumberingPart = void 0;
  3378. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  3379. const numbering_1 = __webpack_require__(/*! ./numbering */ "./src/numbering/numbering.ts");
  3380. class NumberingPart extends part_1.Part {
  3381. constructor(pkg, path, parser) {
  3382. super(pkg, path);
  3383. this._documentParser = parser;
  3384. }
  3385. parseXml(root) {
  3386. Object.assign(this, (0, numbering_1.parseNumberingPart)(root, this._package.xmlParser));
  3387. this.domNumberings = this._documentParser.parseNumberingFile(root);
  3388. }
  3389. }
  3390. exports.NumberingPart = NumberingPart;
  3391. /***/ }),
  3392. /***/ "./src/numbering/numbering.ts":
  3393. /*!************************************!*\
  3394. !*** ./src/numbering/numbering.ts ***!
  3395. \************************************/
  3396. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3397. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3398. exports.parseNumberingBulletPicture = exports.parseNumberingLevelOverrride = exports.parseNumberingLevel = exports.parseAbstractNumbering = exports.parseNumbering = exports.parseNumberingPart = void 0;
  3399. const paragraph_1 = __webpack_require__(/*! ../document/paragraph */ "./src/document/paragraph.ts");
  3400. const run_1 = __webpack_require__(/*! ../document/run */ "./src/document/run.ts");
  3401. function parseNumberingPart(elem, xml) {
  3402. let result = {
  3403. numberings: [],
  3404. abstractNumberings: [],
  3405. bulletPictures: []
  3406. };
  3407. for (let e of xml.elements(elem)) {
  3408. switch (e.localName) {
  3409. case "num":
  3410. result.numberings.push(parseNumbering(e, xml));
  3411. break;
  3412. case "abstractNum":
  3413. result.abstractNumberings.push(parseAbstractNumbering(e, xml));
  3414. break;
  3415. case "numPicBullet":
  3416. result.bulletPictures.push(parseNumberingBulletPicture(e, xml));
  3417. break;
  3418. }
  3419. }
  3420. return result;
  3421. }
  3422. exports.parseNumberingPart = parseNumberingPart;
  3423. function parseNumbering(elem, xml) {
  3424. let result = {
  3425. id: xml.attr(elem, 'numId'),
  3426. overrides: []
  3427. };
  3428. for (let e of xml.elements(elem)) {
  3429. switch (e.localName) {
  3430. case "abstractNumId":
  3431. result.abstractId = xml.attr(e, "val");
  3432. break;
  3433. case "lvlOverride":
  3434. result.overrides.push(parseNumberingLevelOverrride(e, xml));
  3435. break;
  3436. }
  3437. }
  3438. return result;
  3439. }
  3440. exports.parseNumbering = parseNumbering;
  3441. function parseAbstractNumbering(elem, xml) {
  3442. let result = {
  3443. id: xml.attr(elem, 'abstractNumId'),
  3444. levels: []
  3445. };
  3446. for (let e of xml.elements(elem)) {
  3447. switch (e.localName) {
  3448. case "name":
  3449. result.name = xml.attr(e, "val");
  3450. break;
  3451. case "multiLevelType":
  3452. result.multiLevelType = xml.attr(e, "val");
  3453. break;
  3454. case "numStyleLink":
  3455. result.numberingStyleLink = xml.attr(e, "val");
  3456. break;
  3457. case "styleLink":
  3458. result.styleLink = xml.attr(e, "val");
  3459. break;
  3460. case "lvl":
  3461. result.levels.push(parseNumberingLevel(e, xml));
  3462. break;
  3463. }
  3464. }
  3465. return result;
  3466. }
  3467. exports.parseAbstractNumbering = parseAbstractNumbering;
  3468. function parseNumberingLevel(elem, xml) {
  3469. let result = {
  3470. level: xml.intAttr(elem, 'ilvl')
  3471. };
  3472. for (let e of xml.elements(elem)) {
  3473. switch (e.localName) {
  3474. case "start":
  3475. result.start = xml.attr(e, "val");
  3476. break;
  3477. case "lvlRestart":
  3478. result.restart = xml.intAttr(e, "val");
  3479. break;
  3480. case "numFmt":
  3481. result.format = xml.attr(e, "val");
  3482. break;
  3483. case "lvlText":
  3484. result.text = xml.attr(e, "val");
  3485. break;
  3486. case "lvlJc":
  3487. result.justification = xml.attr(e, "val");
  3488. break;
  3489. case "lvlPicBulletId":
  3490. result.bulletPictureId = xml.attr(e, "val");
  3491. break;
  3492. case "pStyle":
  3493. result.paragraphStyle = xml.attr(e, "val");
  3494. break;
  3495. case "pPr":
  3496. result.paragraphProps = (0, paragraph_1.parseParagraphProperties)(e, xml);
  3497. break;
  3498. case "rPr":
  3499. result.runProps = (0, run_1.parseRunProperties)(e, xml);
  3500. break;
  3501. }
  3502. }
  3503. return result;
  3504. }
  3505. exports.parseNumberingLevel = parseNumberingLevel;
  3506. function parseNumberingLevelOverrride(elem, xml) {
  3507. let result = {
  3508. level: xml.intAttr(elem, 'ilvl')
  3509. };
  3510. for (let e of xml.elements(elem)) {
  3511. switch (e.localName) {
  3512. case "startOverride":
  3513. result.start = xml.intAttr(e, "val");
  3514. break;
  3515. case "lvl":
  3516. result.numberingLevel = parseNumberingLevel(e, xml);
  3517. break;
  3518. }
  3519. }
  3520. return result;
  3521. }
  3522. exports.parseNumberingLevelOverrride = parseNumberingLevelOverrride;
  3523. function parseNumberingBulletPicture(elem, xml) {
  3524. var pict = xml.element(elem, "pict");
  3525. var shape = pict && xml.element(pict, "shape");
  3526. var imagedata = shape && xml.element(shape, "imagedata");
  3527. return imagedata ? {
  3528. id: xml.attr(elem, "numPicBulletId"),
  3529. referenceId: xml.attr(imagedata, "id"),
  3530. style: xml.attr(shape, "style")
  3531. } : null;
  3532. }
  3533. exports.parseNumberingBulletPicture = parseNumberingBulletPicture;
  3534. /***/ }),
  3535. /***/ "./src/parser/xml-parser.ts":
  3536. /*!**********************************!*\
  3537. !*** ./src/parser/xml-parser.ts ***!
  3538. \**********************************/
  3539. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3540. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3541. exports.XmlParser = exports.serializeXmlString = exports.parseXmlString = void 0;
  3542. const common_1 = __webpack_require__(/*! ../document/common */ "./src/document/common.ts");
  3543. function parseXmlString(xmlString, trimXmlDeclaration = false) {
  3544. if (trimXmlDeclaration)
  3545. xmlString = xmlString.replace(/<[?].*[?]>/, "");
  3546. const result = new DOMParser().parseFromString(xmlString, "application/xml");
  3547. const errorText = hasXmlParserError(result);
  3548. if (errorText)
  3549. throw new Error(errorText);
  3550. return result;
  3551. }
  3552. exports.parseXmlString = parseXmlString;
  3553. function hasXmlParserError(doc) {
  3554. var _a;
  3555. return (_a = doc.getElementsByTagName("parsererror")[0]) === null || _a === void 0 ? void 0 : _a.textContent;
  3556. }
  3557. function serializeXmlString(elem) {
  3558. return new XMLSerializer().serializeToString(elem);
  3559. }
  3560. exports.serializeXmlString = serializeXmlString;
  3561. class XmlParser {
  3562. elements(elem, localName = null) {
  3563. const result = [];
  3564. for (let i = 0, l = elem.childNodes.length; i < l; i++) {
  3565. let c = elem.childNodes.item(i);
  3566. if (c.nodeType == 1 && (localName == null || c.localName == localName))
  3567. result.push(c);
  3568. }
  3569. return result;
  3570. }
  3571. element(elem, localName) {
  3572. for (let i = 0, l = elem.childNodes.length; i < l; i++) {
  3573. let c = elem.childNodes.item(i);
  3574. if (c.nodeType == 1 && c.localName == localName)
  3575. return c;
  3576. }
  3577. return null;
  3578. }
  3579. elementAttr(elem, localName, attrLocalName) {
  3580. var el = this.element(elem, localName);
  3581. return el ? this.attr(el, attrLocalName) : undefined;
  3582. }
  3583. attrs(elem) {
  3584. return Array.from(elem.attributes);
  3585. }
  3586. attr(elem, localName) {
  3587. for (let i = 0, l = elem.attributes.length; i < l; i++) {
  3588. let a = elem.attributes.item(i);
  3589. if (a.localName == localName)
  3590. return a.value;
  3591. }
  3592. return null;
  3593. }
  3594. intAttr(node, attrName, defaultValue = null) {
  3595. var val = this.attr(node, attrName);
  3596. return val ? parseInt(val) : defaultValue;
  3597. }
  3598. hexAttr(node, attrName, defaultValue = null) {
  3599. var val = this.attr(node, attrName);
  3600. return val ? parseInt(val, 16) : defaultValue;
  3601. }
  3602. floatAttr(node, attrName, defaultValue = null) {
  3603. var val = this.attr(node, attrName);
  3604. return val ? parseFloat(val) : defaultValue;
  3605. }
  3606. boolAttr(node, attrName, defaultValue = null) {
  3607. return (0, common_1.convertBoolean)(this.attr(node, attrName), defaultValue);
  3608. }
  3609. lengthAttr(node, attrName, usage = common_1.LengthUsage.Dxa) {
  3610. return (0, common_1.convertLength)(this.attr(node, attrName), usage);
  3611. }
  3612. }
  3613. exports.XmlParser = XmlParser;
  3614. const globalXmlParser = new XmlParser();
  3615. exports["default"] = globalXmlParser;
  3616. /***/ }),
  3617. /***/ "./src/settings/settings-part.ts":
  3618. /*!***************************************!*\
  3619. !*** ./src/settings/settings-part.ts ***!
  3620. \***************************************/
  3621. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3622. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3623. exports.SettingsPart = void 0;
  3624. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  3625. const settings_1 = __webpack_require__(/*! ./settings */ "./src/settings/settings.ts");
  3626. class SettingsPart extends part_1.Part {
  3627. constructor(pkg, path) {
  3628. super(pkg, path);
  3629. }
  3630. parseXml(root) {
  3631. this.settings = (0, settings_1.parseSettings)(root, this._package.xmlParser);
  3632. }
  3633. }
  3634. exports.SettingsPart = SettingsPart;
  3635. /***/ }),
  3636. /***/ "./src/settings/settings.ts":
  3637. /*!**********************************!*\
  3638. !*** ./src/settings/settings.ts ***!
  3639. \**********************************/
  3640. /***/ ((__unused_webpack_module, exports) => {
  3641. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3642. exports.parseNoteProperties = exports.parseSettings = void 0;
  3643. function parseSettings(elem, xml) {
  3644. var result = {};
  3645. for (let el of xml.elements(elem)) {
  3646. switch (el.localName) {
  3647. case "defaultTabStop":
  3648. result.defaultTabStop = xml.lengthAttr(el, "val");
  3649. break;
  3650. case "footnotePr":
  3651. result.footnoteProps = parseNoteProperties(el, xml);
  3652. break;
  3653. case "endnotePr":
  3654. result.endnoteProps = parseNoteProperties(el, xml);
  3655. break;
  3656. case "autoHyphenation":
  3657. result.autoHyphenation = xml.boolAttr(el, "val");
  3658. break;
  3659. }
  3660. }
  3661. return result;
  3662. }
  3663. exports.parseSettings = parseSettings;
  3664. function parseNoteProperties(elem, xml) {
  3665. var result = {
  3666. defaultNoteIds: []
  3667. };
  3668. for (let el of xml.elements(elem)) {
  3669. switch (el.localName) {
  3670. case "numFmt":
  3671. result.nummeringFormat = xml.attr(el, "val");
  3672. break;
  3673. case "footnote":
  3674. case "endnote":
  3675. result.defaultNoteIds.push(xml.attr(el, "id"));
  3676. break;
  3677. }
  3678. }
  3679. return result;
  3680. }
  3681. exports.parseNoteProperties = parseNoteProperties;
  3682. /***/ }),
  3683. /***/ "./src/styles/styles-part.ts":
  3684. /*!***********************************!*\
  3685. !*** ./src/styles/styles-part.ts ***!
  3686. \***********************************/
  3687. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3688. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3689. exports.StylesPart = void 0;
  3690. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  3691. class StylesPart extends part_1.Part {
  3692. constructor(pkg, path, parser) {
  3693. super(pkg, path);
  3694. this._documentParser = parser;
  3695. }
  3696. parseXml(root) {
  3697. this.styles = this._documentParser.parseStylesFile(root);
  3698. }
  3699. }
  3700. exports.StylesPart = StylesPart;
  3701. /***/ }),
  3702. /***/ "./src/theme/theme-part.ts":
  3703. /*!*********************************!*\
  3704. !*** ./src/theme/theme-part.ts ***!
  3705. \*********************************/
  3706. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3707. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3708. exports.ThemePart = void 0;
  3709. const part_1 = __webpack_require__(/*! ../common/part */ "./src/common/part.ts");
  3710. const theme_1 = __webpack_require__(/*! ./theme */ "./src/theme/theme.ts");
  3711. class ThemePart extends part_1.Part {
  3712. constructor(pkg, path) {
  3713. super(pkg, path);
  3714. }
  3715. parseXml(root) {
  3716. this.theme = (0, theme_1.parseTheme)(root, this._package.xmlParser);
  3717. }
  3718. }
  3719. exports.ThemePart = ThemePart;
  3720. /***/ }),
  3721. /***/ "./src/theme/theme.ts":
  3722. /*!****************************!*\
  3723. !*** ./src/theme/theme.ts ***!
  3724. \****************************/
  3725. /***/ ((__unused_webpack_module, exports) => {
  3726. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3727. exports.parseFontInfo = exports.parseFontScheme = exports.parseColorScheme = exports.parseTheme = exports.DmlTheme = void 0;
  3728. class DmlTheme {
  3729. }
  3730. exports.DmlTheme = DmlTheme;
  3731. function parseTheme(elem, xml) {
  3732. var result = new DmlTheme();
  3733. var themeElements = xml.element(elem, "themeElements");
  3734. for (let el of xml.elements(themeElements)) {
  3735. switch (el.localName) {
  3736. case "clrScheme":
  3737. result.colorScheme = parseColorScheme(el, xml);
  3738. break;
  3739. case "fontScheme":
  3740. result.fontScheme = parseFontScheme(el, xml);
  3741. break;
  3742. }
  3743. }
  3744. return result;
  3745. }
  3746. exports.parseTheme = parseTheme;
  3747. function parseColorScheme(elem, xml) {
  3748. var result = {
  3749. name: xml.attr(elem, "name"),
  3750. colors: {}
  3751. };
  3752. for (let el of xml.elements(elem)) {
  3753. var srgbClr = xml.element(el, "srgbClr");
  3754. var sysClr = xml.element(el, "sysClr");
  3755. if (srgbClr) {
  3756. result.colors[el.localName] = xml.attr(srgbClr, "val");
  3757. }
  3758. else if (sysClr) {
  3759. result.colors[el.localName] = xml.attr(sysClr, "lastClr");
  3760. }
  3761. }
  3762. return result;
  3763. }
  3764. exports.parseColorScheme = parseColorScheme;
  3765. function parseFontScheme(elem, xml) {
  3766. var result = {
  3767. name: xml.attr(elem, "name"),
  3768. };
  3769. for (let el of xml.elements(elem)) {
  3770. switch (el.localName) {
  3771. case "majorFont":
  3772. result.majorFont = parseFontInfo(el, xml);
  3773. break;
  3774. case "minorFont":
  3775. result.minorFont = parseFontInfo(el, xml);
  3776. break;
  3777. }
  3778. }
  3779. return result;
  3780. }
  3781. exports.parseFontScheme = parseFontScheme;
  3782. function parseFontInfo(elem, xml) {
  3783. return {
  3784. latinTypeface: xml.elementAttr(elem, "latin", "typeface"),
  3785. eaTypeface: xml.elementAttr(elem, "ea", "typeface"),
  3786. csTypeface: xml.elementAttr(elem, "cs", "typeface"),
  3787. };
  3788. }
  3789. exports.parseFontInfo = parseFontInfo;
  3790. /***/ }),
  3791. /***/ "./src/utils.ts":
  3792. /*!**********************!*\
  3793. !*** ./src/utils.ts ***!
  3794. \**********************/
  3795. /***/ ((__unused_webpack_module, exports) => {
  3796. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3797. exports.asArray = exports.formatCssRules = exports.parseCssRules = exports.mergeDeep = exports.isString = exports.isObject = exports.blobToBase64 = exports.keyBy = exports.resolvePath = exports.splitPath = exports.escapeClassName = void 0;
  3798. function escapeClassName(className) {
  3799. return className === null || className === void 0 ? void 0 : className.replace(/[ .]+/g, '-').replace(/[&]+/g, 'and').toLowerCase();
  3800. }
  3801. exports.escapeClassName = escapeClassName;
  3802. function splitPath(path) {
  3803. let si = path.lastIndexOf('/') + 1;
  3804. let folder = si == 0 ? "" : path.substring(0, si);
  3805. let fileName = si == 0 ? path : path.substring(si);
  3806. return [folder, fileName];
  3807. }
  3808. exports.splitPath = splitPath;
  3809. function resolvePath(path, base) {
  3810. try {
  3811. const prefix = "http://docx/";
  3812. const url = new URL(path, prefix + base).toString();
  3813. return url.substring(prefix.length);
  3814. }
  3815. catch (_a) {
  3816. return `${base}${path}`;
  3817. }
  3818. }
  3819. exports.resolvePath = resolvePath;
  3820. function keyBy(array, by) {
  3821. return array.reduce((a, x) => {
  3822. a[by(x)] = x;
  3823. return a;
  3824. }, {});
  3825. }
  3826. exports.keyBy = keyBy;
  3827. function blobToBase64(blob) {
  3828. return new Promise((resolve, _) => {
  3829. const reader = new FileReader();
  3830. reader.onloadend = () => resolve(reader.result);
  3831. reader.readAsDataURL(blob);
  3832. });
  3833. }
  3834. exports.blobToBase64 = blobToBase64;
  3835. function isObject(item) {
  3836. return item && typeof item === 'object' && !Array.isArray(item);
  3837. }
  3838. exports.isObject = isObject;
  3839. function isString(item) {
  3840. return item && typeof item === 'string' || item instanceof String;
  3841. }
  3842. exports.isString = isString;
  3843. function mergeDeep(target, ...sources) {
  3844. var _a;
  3845. if (!sources.length)
  3846. return target;
  3847. const source = sources.shift();
  3848. if (isObject(target) && isObject(source)) {
  3849. for (const key in source) {
  3850. if (isObject(source[key])) {
  3851. const val = (_a = target[key]) !== null && _a !== void 0 ? _a : (target[key] = {});
  3852. mergeDeep(val, source[key]);
  3853. }
  3854. else {
  3855. target[key] = source[key];
  3856. }
  3857. }
  3858. }
  3859. return mergeDeep(target, ...sources);
  3860. }
  3861. exports.mergeDeep = mergeDeep;
  3862. function parseCssRules(text) {
  3863. const result = {};
  3864. for (const rule of text.split(';')) {
  3865. const [key, val] = rule.split(':');
  3866. result[key] = val;
  3867. }
  3868. return result;
  3869. }
  3870. exports.parseCssRules = parseCssRules;
  3871. function formatCssRules(style) {
  3872. return Object.entries(style).map((k, v) => `${k}: ${v}`).join(';');
  3873. }
  3874. exports.formatCssRules = formatCssRules;
  3875. function asArray(val) {
  3876. return Array.isArray(val) ? val : [val];
  3877. }
  3878. exports.asArray = asArray;
  3879. /***/ }),
  3880. /***/ "./src/vml/vml.ts":
  3881. /*!************************!*\
  3882. !*** ./src/vml/vml.ts ***!
  3883. \************************/
  3884. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3885. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3886. exports.parseVmlElement = exports.VmlElement = void 0;
  3887. const common_1 = __webpack_require__(/*! ../document/common */ "./src/document/common.ts");
  3888. const dom_1 = __webpack_require__(/*! ../document/dom */ "./src/document/dom.ts");
  3889. const xml_parser_1 = __webpack_require__(/*! ../parser/xml-parser */ "./src/parser/xml-parser.ts");
  3890. class VmlElement {
  3891. constructor() {
  3892. this.type = dom_1.DomType.VmlElement;
  3893. this.attrs = {};
  3894. this.chidren = [];
  3895. }
  3896. }
  3897. exports.VmlElement = VmlElement;
  3898. function parseVmlElement(elem) {
  3899. var result = new VmlElement();
  3900. switch (elem.localName) {
  3901. case "rect":
  3902. result.tagName = "rect";
  3903. Object.assign(result.attrs, { width: '100%', height: '100%' });
  3904. break;
  3905. case "oval":
  3906. result.tagName = "ellipse";
  3907. Object.assign(result.attrs, { cx: "50%", cy: "50%", rx: "50%", ry: "50%" });
  3908. break;
  3909. case "line":
  3910. result.tagName = "line";
  3911. break;
  3912. case "shape":
  3913. result.tagName = "g";
  3914. break;
  3915. default:
  3916. return null;
  3917. }
  3918. for (const at of xml_parser_1.default.attrs(elem)) {
  3919. switch (at.localName) {
  3920. case "style":
  3921. result.cssStyleText = at.value;
  3922. break;
  3923. case "fillcolor":
  3924. result.attrs.fill = at.value;
  3925. break;
  3926. case "from":
  3927. const [x1, y1] = parsePoint(at.value);
  3928. Object.assign(result.attrs, { x1, y1 });
  3929. break;
  3930. case "to":
  3931. const [x2, y2] = parsePoint(at.value);
  3932. Object.assign(result.attrs, { x2, y2 });
  3933. break;
  3934. }
  3935. }
  3936. for (const el of xml_parser_1.default.elements(elem)) {
  3937. switch (el.localName) {
  3938. case "stroke":
  3939. Object.assign(result.attrs, parseStroke(el));
  3940. break;
  3941. case "fill":
  3942. Object.assign(result.attrs, parseFill(el));
  3943. break;
  3944. case "imagedata":
  3945. result.tagName = "image";
  3946. Object.assign(result.attrs, { width: '100%', height: '100%' });
  3947. result.imageHref = {
  3948. id: xml_parser_1.default.attr(el, "id"),
  3949. title: xml_parser_1.default.attr(el, "title"),
  3950. };
  3951. break;
  3952. default:
  3953. const child = parseVmlElement(el);
  3954. child && result.chidren.push(child);
  3955. break;
  3956. }
  3957. }
  3958. return result;
  3959. }
  3960. exports.parseVmlElement = parseVmlElement;
  3961. function parseStroke(el) {
  3962. var _a;
  3963. return {
  3964. 'stroke': xml_parser_1.default.attr(el, "color"),
  3965. 'stroke-width': (_a = xml_parser_1.default.lengthAttr(el, "weight", common_1.LengthUsage.Emu)) !== null && _a !== void 0 ? _a : '1px'
  3966. };
  3967. }
  3968. function parseFill(el) {
  3969. return {};
  3970. }
  3971. function parsePoint(val) {
  3972. return val.split(",");
  3973. }
  3974. function convertPath(path) {
  3975. return path.replace(/([mlxe])|([-\d]+)|([,])/g, (m) => {
  3976. if (/[-\d]/.test(m))
  3977. return (0, common_1.convertLength)(m, common_1.LengthUsage.VmlEmu);
  3978. if (/[ml,]/.test(m))
  3979. return m;
  3980. return '';
  3981. });
  3982. }
  3983. /***/ }),
  3984. /***/ "./src/word-document.ts":
  3985. /*!******************************!*\
  3986. !*** ./src/word-document.ts ***!
  3987. \******************************/
  3988. /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
  3989. Object.defineProperty(exports, "__esModule", ({ value: true }));
  3990. exports.deobfuscate = exports.WordDocument = void 0;
  3991. const relationship_1 = __webpack_require__(/*! ./common/relationship */ "./src/common/relationship.ts");
  3992. const font_table_1 = __webpack_require__(/*! ./font-table/font-table */ "./src/font-table/font-table.ts");
  3993. const open_xml_package_1 = __webpack_require__(/*! ./common/open-xml-package */ "./src/common/open-xml-package.ts");
  3994. const document_part_1 = __webpack_require__(/*! ./document/document-part */ "./src/document/document-part.ts");
  3995. const utils_1 = __webpack_require__(/*! ./utils */ "./src/utils.ts");
  3996. const numbering_part_1 = __webpack_require__(/*! ./numbering/numbering-part */ "./src/numbering/numbering-part.ts");
  3997. const styles_part_1 = __webpack_require__(/*! ./styles/styles-part */ "./src/styles/styles-part.ts");
  3998. const parts_1 = __webpack_require__(/*! ./header-footer/parts */ "./src/header-footer/parts.ts");
  3999. const extended_props_part_1 = __webpack_require__(/*! ./document-props/extended-props-part */ "./src/document-props/extended-props-part.ts");
  4000. const core_props_part_1 = __webpack_require__(/*! ./document-props/core-props-part */ "./src/document-props/core-props-part.ts");
  4001. const theme_part_1 = __webpack_require__(/*! ./theme/theme-part */ "./src/theme/theme-part.ts");
  4002. const parts_2 = __webpack_require__(/*! ./notes/parts */ "./src/notes/parts.ts");
  4003. const settings_part_1 = __webpack_require__(/*! ./settings/settings-part */ "./src/settings/settings-part.ts");
  4004. const custom_props_part_1 = __webpack_require__(/*! ./document-props/custom-props-part */ "./src/document-props/custom-props-part.ts");
  4005. const topLevelRels = [
  4006. { type: relationship_1.RelationshipTypes.OfficeDocument, target: "word/document.xml" },
  4007. { type: relationship_1.RelationshipTypes.ExtendedProperties, target: "docProps/app.xml" },
  4008. { type: relationship_1.RelationshipTypes.CoreProperties, target: "docProps/core.xml" },
  4009. { type: relationship_1.RelationshipTypes.CustomProperties, target: "docProps/custom.xml" },
  4010. ];
  4011. class WordDocument {
  4012. constructor() {
  4013. this.parts = [];
  4014. this.partsMap = {};
  4015. }
  4016. static load(blob, parser, options) {
  4017. var d = new WordDocument();
  4018. d._options = options;
  4019. d._parser = parser;
  4020. return open_xml_package_1.OpenXmlPackage.load(blob, options)
  4021. .then(pkg => {
  4022. d._package = pkg;
  4023. return d._package.loadRelationships();
  4024. }).then(rels => {
  4025. d.rels = rels;
  4026. const tasks = topLevelRels.map(rel => {
  4027. var _a;
  4028. const r = (_a = rels.find(x => x.type === rel.type)) !== null && _a !== void 0 ? _a : rel;
  4029. return d.loadRelationshipPart(r.target, r.type);
  4030. });
  4031. return Promise.all(tasks);
  4032. }).then(() => d);
  4033. }
  4034. save(type = "blob") {
  4035. return this._package.save(type);
  4036. }
  4037. loadRelationshipPart(path, type) {
  4038. if (this.partsMap[path])
  4039. return Promise.resolve(this.partsMap[path]);
  4040. if (!this._package.get(path))
  4041. return Promise.resolve(null);
  4042. let part = null;
  4043. switch (type) {
  4044. case relationship_1.RelationshipTypes.OfficeDocument:
  4045. this.documentPart = part = new document_part_1.DocumentPart(this._package, path, this._parser);
  4046. break;
  4047. case relationship_1.RelationshipTypes.FontTable:
  4048. this.fontTablePart = part = new font_table_1.FontTablePart(this._package, path);
  4049. break;
  4050. case relationship_1.RelationshipTypes.Numbering:
  4051. this.numberingPart = part = new numbering_part_1.NumberingPart(this._package, path, this._parser);
  4052. break;
  4053. case relationship_1.RelationshipTypes.Styles:
  4054. this.stylesPart = part = new styles_part_1.StylesPart(this._package, path, this._parser);
  4055. break;
  4056. case relationship_1.RelationshipTypes.Theme:
  4057. this.themePart = part = new theme_part_1.ThemePart(this._package, path);
  4058. break;
  4059. case relationship_1.RelationshipTypes.Footnotes:
  4060. this.footnotesPart = part = new parts_2.FootnotesPart(this._package, path, this._parser);
  4061. break;
  4062. case relationship_1.RelationshipTypes.Endnotes:
  4063. this.endnotesPart = part = new parts_2.EndnotesPart(this._package, path, this._parser);
  4064. break;
  4065. case relationship_1.RelationshipTypes.Footer:
  4066. part = new parts_1.FooterPart(this._package, path, this._parser);
  4067. break;
  4068. case relationship_1.RelationshipTypes.Header:
  4069. part = new parts_1.HeaderPart(this._package, path, this._parser);
  4070. break;
  4071. case relationship_1.RelationshipTypes.CoreProperties:
  4072. this.corePropsPart = part = new core_props_part_1.CorePropsPart(this._package, path);
  4073. break;
  4074. case relationship_1.RelationshipTypes.ExtendedProperties:
  4075. this.extendedPropsPart = part = new extended_props_part_1.ExtendedPropsPart(this._package, path);
  4076. break;
  4077. case relationship_1.RelationshipTypes.CustomProperties:
  4078. part = new custom_props_part_1.CustomPropsPart(this._package, path);
  4079. break;
  4080. case relationship_1.RelationshipTypes.Settings:
  4081. this.settingsPart = part = new settings_part_1.SettingsPart(this._package, path);
  4082. break;
  4083. }
  4084. if (part == null)
  4085. return Promise.resolve(null);
  4086. this.partsMap[path] = part;
  4087. this.parts.push(part);
  4088. return part.load().then(() => {
  4089. if (part.rels == null || part.rels.length == 0)
  4090. return part;
  4091. const [folder] = (0, utils_1.splitPath)(part.path);
  4092. const rels = part.rels.map(rel => {
  4093. return this.loadRelationshipPart((0, utils_1.resolvePath)(rel.target, folder), rel.type);
  4094. });
  4095. return Promise.all(rels).then(() => part);
  4096. });
  4097. }
  4098. loadDocumentImage(id, part) {
  4099. return this.loadResource(part !== null && part !== void 0 ? part : this.documentPart, id, "blob")
  4100. .then(x => this.blobToURL(x));
  4101. }
  4102. loadNumberingImage(id) {
  4103. return this.loadResource(this.numberingPart, id, "blob")
  4104. .then(x => this.blobToURL(x));
  4105. }
  4106. loadFont(id, key) {
  4107. return this.loadResource(this.fontTablePart, id, "uint8array")
  4108. .then(x => x ? this.blobToURL(new Blob([deobfuscate(x, key)])) : x);
  4109. }
  4110. blobToURL(blob) {
  4111. if (!blob)
  4112. return null;
  4113. if (this._options.useBase64URL) {
  4114. return (0, utils_1.blobToBase64)(blob);
  4115. }
  4116. return URL.createObjectURL(blob);
  4117. }
  4118. findPartByRelId(id, basePart = null) {
  4119. var _a;
  4120. var rel = ((_a = basePart.rels) !== null && _a !== void 0 ? _a : this.rels).find(r => r.id == id);
  4121. const folder = basePart ? (0, utils_1.splitPath)(basePart.path)[0] : '';
  4122. return rel ? this.partsMap[(0, utils_1.resolvePath)(rel.target, folder)] : null;
  4123. }
  4124. getPathById(part, id) {
  4125. const rel = part.rels.find(x => x.id == id);
  4126. const [folder] = (0, utils_1.splitPath)(part.path);
  4127. return rel ? (0, utils_1.resolvePath)(rel.target, folder) : null;
  4128. }
  4129. loadResource(part, id, outputType) {
  4130. const path = this.getPathById(part, id);
  4131. return path ? this._package.load(path, outputType) : Promise.resolve(null);
  4132. }
  4133. }
  4134. exports.WordDocument = WordDocument;
  4135. function deobfuscate(data, guidKey) {
  4136. const len = 16;
  4137. const trimmed = guidKey.replace(/{|}|-/g, "");
  4138. const numbers = new Array(len);
  4139. for (let i = 0; i < len; i++)
  4140. numbers[len - i - 1] = parseInt(trimmed.substr(i * 2, 2), 16);
  4141. for (let i = 0; i < 32; i++)
  4142. data[i] = data[i] ^ numbers[i % len];
  4143. return data;
  4144. }
  4145. exports.deobfuscate = deobfuscate;
  4146. /***/ }),
  4147. /***/ "data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 20 100%27 preserveAspectRatio=%27none%27%3E%3Cpath d=%27m0,75 l5,0 l5,25 l10,-100%27 stroke=%27black%27 fill=%27none%27 vector-effect=%27non-scaling-stroke%27/%3E%3C/svg%3E":
  4148. /*!********************************************************************************************************************************************************************************************************************************************************************!*\
  4149. !*** data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 20 100%27 preserveAspectRatio=%27none%27%3E%3Cpath d=%27m0,75 l5,0 l5,25 l10,-100%27 stroke=%27black%27 fill=%27none%27 vector-effect=%27non-scaling-stroke%27/%3E%3C/svg%3E ***!
  4150. \********************************************************************************************************************************************************************************************************************************************************************/
  4151. /***/ ((module) => {
  4152. module.exports = "data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 20 100%27 preserveAspectRatio=%27none%27%3E%3Cpath d=%27m0,75 l5,0 l5,25 l10,-100%27 stroke=%27black%27 fill=%27none%27 vector-effect=%27non-scaling-stroke%27/%3E%3C/svg%3E";
  4153. /***/ }),
  4154. /***/ "jszip":
  4155. /*!**************************************************************************************!*\
  4156. !*** external {"root":"JSZip","commonjs":"jszip","commonjs2":"jszip","amd":"jszip"} ***!
  4157. \**************************************************************************************/
  4158. /***/ ((module) => {
  4159. module.exports = __WEBPACK_EXTERNAL_MODULE_jszip__;
  4160. /***/ })
  4161. /******/ });
  4162. /************************************************************************/
  4163. /******/ // The module cache
  4164. /******/ var __webpack_module_cache__ = {};
  4165. /******/
  4166. /******/ // The require function
  4167. /******/ function __webpack_require__(moduleId) {
  4168. /******/ // Check if module is in cache
  4169. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  4170. /******/ if (cachedModule !== undefined) {
  4171. /******/ return cachedModule.exports;
  4172. /******/ }
  4173. /******/ // Create a new module (and put it into the cache)
  4174. /******/ var module = __webpack_module_cache__[moduleId] = {
  4175. /******/ id: moduleId,
  4176. /******/ // no module.loaded needed
  4177. /******/ exports: {}
  4178. /******/ };
  4179. /******/
  4180. /******/ // Execute the module function
  4181. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  4182. /******/
  4183. /******/ // Return the exports of the module
  4184. /******/ return module.exports;
  4185. /******/ }
  4186. /******/
  4187. /******/ // expose the modules object (__webpack_modules__)
  4188. /******/ __webpack_require__.m = __webpack_modules__;
  4189. /******/
  4190. /************************************************************************/
  4191. /******/ /* webpack/runtime/compat get default export */
  4192. /******/ (() => {
  4193. /******/ // getDefaultExport function for compatibility with non-harmony modules
  4194. /******/ __webpack_require__.n = (module) => {
  4195. /******/ var getter = module && module.__esModule ?
  4196. /******/ () => (module['default']) :
  4197. /******/ () => (module);
  4198. /******/ __webpack_require__.d(getter, { a: getter });
  4199. /******/ return getter;
  4200. /******/ };
  4201. /******/ })();
  4202. /******/
  4203. /******/ /* webpack/runtime/define property getters */
  4204. /******/ (() => {
  4205. /******/ // define getter functions for harmony exports
  4206. /******/ __webpack_require__.d = (exports, definition) => {
  4207. /******/ for(var key in definition) {
  4208. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  4209. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  4210. /******/ }
  4211. /******/ }
  4212. /******/ };
  4213. /******/ })();
  4214. /******/
  4215. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  4216. /******/ (() => {
  4217. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  4218. /******/ })();
  4219. /******/
  4220. /******/ /* webpack/runtime/make namespace object */
  4221. /******/ (() => {
  4222. /******/ // define __esModule on exports
  4223. /******/ __webpack_require__.r = (exports) => {
  4224. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  4225. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  4226. /******/ }
  4227. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  4228. /******/ };
  4229. /******/ })();
  4230. /******/
  4231. /******/ /* webpack/runtime/jsonp chunk loading */
  4232. /******/ (() => {
  4233. /******/ __webpack_require__.b = document.baseURI || self.location.href;
  4234. /******/
  4235. /******/ // object to store loaded and loading chunks
  4236. /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
  4237. /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
  4238. /******/ var installedChunks = {
  4239. /******/ "docx-preview": 0
  4240. /******/ };
  4241. /******/
  4242. /******/ // no chunk on demand loading
  4243. /******/
  4244. /******/ // no prefetching
  4245. /******/
  4246. /******/ // no preloaded
  4247. /******/
  4248. /******/ // no HMR
  4249. /******/
  4250. /******/ // no HMR manifest
  4251. /******/
  4252. /******/ // no on chunks loaded
  4253. /******/
  4254. /******/ // no jsonp function
  4255. /******/ })();
  4256. /******/
  4257. /************************************************************************/
  4258. /******/
  4259. /******/ // startup
  4260. /******/ // Load entry module and return exports
  4261. /******/ // This entry module is referenced by other modules so it can't be inlined
  4262. /******/ var __webpack_exports__ = __webpack_require__("./src/docx-preview.ts");
  4263. /******/
  4264. /******/ return __webpack_exports__;
  4265. /******/ })()
  4266. ;
  4267. });
  4268. //# sourceMappingURL=docx-preview.js.map