wordinweb 0.1.19 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ export {
34
+ __require,
35
+ __commonJS,
36
+ __toESM
37
+ };
38
+ //# sourceMappingURL=chunk-7D4SUZUM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.d.ts CHANGED
@@ -1530,6 +1530,8 @@ interface TextItem {
1530
1530
  * the bookmark's page number (Word recomputes PAGEREF on open; the docx
1531
1531
  * cached result is stale in real TOCs). */
1532
1532
  pageRef?: string;
1533
+ /** DOCX bookmarks that begin on this text item. */
1534
+ bookmarks?: string[];
1533
1535
  /** Source m:oMath element when this text is a piece of an equation. */
1534
1536
  mathSrc?: XmlElement;
1535
1537
  href?: string;
package/dist/index.js CHANGED
@@ -1,34 +1,8 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
- }) : x)(function(x) {
10
- if (typeof require !== "undefined") return require.apply(this, arguments);
11
- throw Error('Dynamic require of "' + x + '" is not supported');
12
- });
13
- var __commonJS = (cb, mod2) => function __require2() {
14
- return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
15
- };
16
- var __copyProps = (to, from, except, desc) => {
17
- if (from && typeof from === "object" || typeof from === "function") {
18
- for (let key of __getOwnPropNames(from))
19
- if (!__hasOwnProp.call(to, key) && key !== except)
20
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
- }
22
- return to;
23
- };
24
- var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
25
- // If the importer is in node compatibility mode or this is not an ESM
26
- // file that has been converted to a CommonJS file using a Babel-
27
- // compatible transform (i.e. "__esModule" has not been set), then set
28
- // "default" to the CommonJS "module.exports" for node compatibility.
29
- isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
30
- mod2
31
- ));
1
+ import {
2
+ __commonJS,
3
+ __require,
4
+ __toESM
5
+ } from "./chunk-7D4SUZUM.js";
32
6
 
33
7
  // (disabled):fs
34
8
  var require_fs = __commonJS({
@@ -14453,6 +14427,7 @@ var Engine = class {
14453
14427
  }
14454
14428
  floatOffset = clearBannerForLine(line2, li, floatOffset);
14455
14429
  this.y += floatOffset;
14430
+ const lineItemStart = this.cur.items.length;
14456
14431
  this.emitLine(line2, this.cur, this.colX, this.y);
14457
14432
  if (props.tabs) {
14458
14433
  for (const t of props.tabs) {
@@ -14474,12 +14449,16 @@ var Engine = class {
14474
14449
  if (li === 0 && para.bookmarks) {
14475
14450
  const pg = this.cur.physIndex === -1 ? this.lastRealPage : this.cur;
14476
14451
  if (pg) {
14452
+ const target = this.cur.physIndex === -1 ? void 0 : this.cur.items.slice(lineItemStart).find((item) => item.kind === "text");
14453
+ const targets = [];
14477
14454
  for (const bm of para.bookmarks) {
14478
14455
  if (!this.bookmarkPages.has(bm)) {
14479
14456
  this.bookmarkPages.set(bm, formatNumber(pg.displayNumber, PAGE_FMT[pg.sp.pageNumberFormat ?? "decimal"] ?? "decimal"));
14480
14457
  this.bookmarkPageIndices.set(bm, pg.physIndex - 1);
14458
+ targets.push(bm);
14481
14459
  }
14482
14460
  }
14461
+ if (target && targets.length > 0) target.bookmarks = targets;
14483
14462
  }
14484
14463
  }
14485
14464
  if (li === 0 && this.styleRefTrack && this.styleRefTrack.size > 0) {
@@ -17440,9 +17419,6 @@ function firstText(el16) {
17440
17419
  return void 0;
17441
17420
  }
17442
17421
 
17443
- // ../core/src/render/dom.ts
17444
- import { convertEmfToDataUrl } from "emf-converter";
17445
-
17446
17422
  // ../core/src/render/tiff.ts
17447
17423
  var TYPE_SIZE = { 1: 1, 2: 1, 3: 2, 4: 4, 5: 8, 6: 1, 7: 1, 8: 2, 9: 4, 10: 8 };
17448
17424
  function decodeTiff(bytes) {
@@ -17650,194 +17626,6 @@ function packBits(input, expected) {
17650
17626
  return out;
17651
17627
  }
17652
17628
 
17653
- // ../core/src/render/wmf.ts
17654
- import * as WmfModule from "wmf";
17655
- var WMF = WmfModule.default ?? WmfModule;
17656
- var META_EOF = 0;
17657
- var META_SETBKCOLOR = 513;
17658
- var META_SETTEXTALIGN = 302;
17659
- var META_MOVETO = 532;
17660
- var META_LINETO = 531;
17661
- var META_POLYLINE = 805;
17662
- var META_ESCAPE = 1574;
17663
- var META_EXTTEXTOUT = 2610;
17664
- var PLACEABLE_KEY = 2596720087;
17665
- var SYMBOL_TEXT = {
17666
- p: "\u03C0",
17667
- "\xA5": "\u221E",
17668
- "\xB6": "\u2202",
17669
- \u00E5: "\u2211",
17670
- D: "\u0394"
17671
- };
17672
- function decodeWmfText(text, family) {
17673
- if (family === "Symbol") {
17674
- return { text: [...text].map((char) => SYMBOL_TEXT[char] ?? char).join(""), family };
17675
- }
17676
- if (family === "\xCB\xCE\xCC\xE5") {
17677
- return { text: text.replace(/£¨/g, "\uFF08").replace(/£©/g, "\uFF09"), family: "SimSun" };
17678
- }
17679
- return { text, family };
17680
- }
17681
- function record(fn, params) {
17682
- const length = 6 + params.length + (params.length & 1);
17683
- const out = new Uint8Array(length);
17684
- const view = new DataView(out.buffer);
17685
- view.setUint32(0, length / 2, true);
17686
- view.setUint16(4, fn, true);
17687
- out.set(params, 6);
17688
- return out;
17689
- }
17690
- function polyline(from, to) {
17691
- const params = new Uint8Array(10);
17692
- const view = new DataView(params.buffer);
17693
- view.setUint16(0, 2, true);
17694
- view.setInt16(2, from[0], true);
17695
- view.setInt16(4, from[1], true);
17696
- view.setInt16(6, to[0], true);
17697
- view.setInt16(8, to[1], true);
17698
- return record(META_POLYLINE, params);
17699
- }
17700
- function textRecord(char, x, y, advance) {
17701
- const params = new Uint8Array(12);
17702
- const view = new DataView(params.buffer);
17703
- view.setInt16(0, y, true);
17704
- view.setInt16(2, x, true);
17705
- view.setUint16(4, 1, true);
17706
- params[8] = char;
17707
- view.setInt16(10, advance, true);
17708
- return record(META_EXTTEXTOUT, params);
17709
- }
17710
- function isMathTypeEscape(bytes, offset, length) {
17711
- if (length < 18) return false;
17712
- const name = [77, 97, 116, 104, 84, 121, 112, 101];
17713
- return name.every((value, i) => bytes[offset + 10 + i] === value);
17714
- }
17715
- function hasMathTypeEscapes(bytes) {
17716
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17717
- let offset = 18;
17718
- while (offset + 6 <= bytes.length) {
17719
- const length = view.getUint32(offset, true) * 2;
17720
- if (length < 6 || offset + length > bytes.length) return false;
17721
- const fn = view.getUint16(offset + 4, true);
17722
- if (fn === META_ESCAPE && isMathTypeEscape(bytes, offset, length)) return true;
17723
- offset += length;
17724
- if (fn === META_EOF) break;
17725
- }
17726
- return false;
17727
- }
17728
- function prepareWmf(input) {
17729
- let bytes = input;
17730
- if (bytes.length >= 22 && new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength).getUint32(0, true) === PLACEABLE_KEY) {
17731
- bytes = bytes.subarray(22);
17732
- }
17733
- if (bytes.length < 18) return null;
17734
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
17735
- const mathType = hasMathTypeEscapes(bytes);
17736
- const parts = [bytes.slice(0, 18)];
17737
- let offset = 18;
17738
- let textAlign = 0;
17739
- let current = [0, 0];
17740
- let maxRecordWords = 0;
17741
- const append = (part) => {
17742
- parts.push(part);
17743
- maxRecordWords = Math.max(maxRecordWords, part.length / 2);
17744
- };
17745
- while (offset + 6 <= bytes.length) {
17746
- const length = view.getUint32(offset, true) * 2;
17747
- if (length < 6 || offset + length > bytes.length) return null;
17748
- const fn = view.getUint16(offset + 4, true);
17749
- const params = offset + 6;
17750
- if (fn === META_SETTEXTALIGN) {
17751
- textAlign = view.getUint16(params, true);
17752
- append(bytes.slice(offset, offset + length));
17753
- } else if (fn === META_MOVETO) {
17754
- current = [view.getInt16(params + 2, true), view.getInt16(params, true)];
17755
- } else if (fn === META_LINETO) {
17756
- const next = [view.getInt16(params + 2, true), view.getInt16(params, true)];
17757
- append(polyline(current, next));
17758
- current = next;
17759
- } else if (fn === META_EXTTEXTOUT) {
17760
- const y = view.getInt16(params, true);
17761
- const x = view.getInt16(params + 2, true);
17762
- const count = view.getUint16(params + 4, true);
17763
- const options = view.getUint16(params + 6, true);
17764
- let charsAt = params + 8 + (options & 6 ? 8 : 0);
17765
- const advancesAt = charsAt + count + (count & 1);
17766
- const hasAdvances = options === 0 && advancesAt + count * 2 <= offset + length;
17767
- if (hasAdvances) {
17768
- let position = textAlign & 1 ? current : [x, y];
17769
- for (let i = 0; i < count; i++) {
17770
- const advance = view.getInt16(advancesAt + i * 2, true);
17771
- append(textRecord(bytes[charsAt + i], position[0], position[1], advance));
17772
- position = [position[0] + advance, position[1]];
17773
- }
17774
- if (textAlign & 1) current = position;
17775
- } else {
17776
- const copy = bytes.slice(offset, offset + length);
17777
- if (textAlign & 1) {
17778
- const copyView = new DataView(copy.buffer, copy.byteOffset, copy.byteLength);
17779
- copyView.setInt16(6, current[1], true);
17780
- copyView.setInt16(8, current[0], true);
17781
- }
17782
- append(copy);
17783
- }
17784
- } else if (fn === META_ESCAPE && mathType) {
17785
- } else if (fn !== META_SETBKCOLOR) {
17786
- append(bytes.slice(offset, offset + length));
17787
- }
17788
- offset += length;
17789
- if (fn === META_EOF) break;
17790
- }
17791
- const total = parts.reduce((sum2, part) => sum2 + part.length, 0);
17792
- const out = new Uint8Array(total);
17793
- let at = 0;
17794
- for (const part of parts) {
17795
- out.set(part, at);
17796
- at += part.length;
17797
- }
17798
- const outView = new DataView(out.buffer);
17799
- outView.setUint32(6, total / 2, true);
17800
- outView.setUint32(12, maxRecordWords, true);
17801
- return out;
17802
- }
17803
- function renderWmf(bytes, width, height) {
17804
- var _a, _b;
17805
- try {
17806
- const prepared = prepareWmf(bytes);
17807
- if (!prepared) return null;
17808
- const [rawWidth, rawHeight] = WMF.image_size(prepared).map(Math.abs);
17809
- if (!rawWidth || !rawHeight) return null;
17810
- const scale = Math.max(1, window.devicePixelRatio || 1);
17811
- const canvas = document.createElement("canvas");
17812
- canvas.width = Math.max(1, Math.round(width * scale));
17813
- canvas.height = Math.max(1, Math.round(height * scale));
17814
- const ctx = canvas.getContext("2d");
17815
- if (!ctx) return null;
17816
- ctx.fillStyle = "#fff";
17817
- ctx.fillRect(0, 0, canvas.width, canvas.height);
17818
- ctx.fillStyle = "#000";
17819
- ctx.scale(canvas.width / rawWidth, canvas.height / rawHeight);
17820
- const actions = WMF.get_actions(prepared);
17821
- for (const action of actions) {
17822
- if (!action.s) continue;
17823
- delete action.s.Extent;
17824
- if (action.t === "text" && action.v !== void 0 && action.s.Font) {
17825
- const decoded = decodeWmfText(action.v, action.s.Font.Name);
17826
- action.v = decoded.text;
17827
- action.s.Font.Name = decoded.family;
17828
- }
17829
- if (action.t === "poly") {
17830
- (_a = action.s).Pen ?? (_a.Pen = { Style: 0, Width: 1, Color: 0 });
17831
- (_b = action.s).Brush ?? (_b.Brush = { Style: 1, Color: 0 });
17832
- }
17833
- }
17834
- WMF.render_canvas(actions, canvas);
17835
- return canvas.toDataURL("image/png");
17836
- } catch {
17837
- return null;
17838
- }
17839
- }
17840
-
17841
17629
  // ../core/src/render/dom.ts
17842
17630
  function isXmlish(v) {
17843
17631
  return typeof v === "object" && v !== null && "attrs" in v && "children" in v && "name" in v;
@@ -18014,6 +17802,12 @@ function renderPageShell(page, zoom, options) {
18014
17802
  el16.dataset.bodyTop = String(page.bodyTop);
18015
17803
  el16.dataset.bodyBottom = String(page.bodyBottom);
18016
17804
  el16.dataset.columnBands = JSON.stringify(page.columnBands);
17805
+ const bookmarks = {};
17806
+ for (const item of page.items) {
17807
+ if (item.kind !== "text" || !item.bookmarks) continue;
17808
+ for (const name of item.bookmarks) bookmarks[name] = (item.glyphTop ?? item.lineTop) * zoom;
17809
+ }
17810
+ if (Object.keys(bookmarks).length > 0) el16.dataset.bookmarks = JSON.stringify(bookmarks);
18017
17811
  return el16;
18018
17812
  }
18019
17813
  function renderEmptyPageRecord(page, zoom, options) {
@@ -18029,30 +17823,30 @@ function renderEmptyPageRecord(page, zoom, options) {
18029
17823
  mounted: false
18030
17824
  };
18031
17825
  }
18032
- function mountPageRecord(doc, record2, zoom, options) {
18033
- if (record2.mounted) return;
18034
- const rendered = renderPageRecord(doc, record2.page, zoom, options);
17826
+ function mountPageRecord(doc, record, zoom, options) {
17827
+ if (record.mounted) return;
17828
+ const rendered = renderPageRecord(doc, record.page, zoom, options);
18035
17829
  const surface = rendered.el.firstElementChild;
18036
- if (surface) record2.el.appendChild(surface);
18037
- record2.bindings = rendered.bindings;
18038
- record2.grips = rendered.grips;
18039
- record2.images = rendered.images;
18040
- record2.drawings = rendered.drawings;
18041
- record2.wordarts = rendered.wordarts;
18042
- record2.urls = rendered.urls;
18043
- record2.mounted = true;
18044
- }
18045
- function unmountPageRecord(record2) {
18046
- if (!record2.mounted) return;
18047
- for (const url of record2.urls) URL.revokeObjectURL(url);
18048
- record2.el.replaceChildren();
18049
- record2.bindings = [];
18050
- record2.grips = [];
18051
- record2.images = [];
18052
- record2.drawings = [];
18053
- record2.wordarts = [];
18054
- record2.urls = [];
18055
- record2.mounted = false;
17830
+ if (surface) record.el.appendChild(surface);
17831
+ record.bindings = rendered.bindings;
17832
+ record.grips = rendered.grips;
17833
+ record.images = rendered.images;
17834
+ record.drawings = rendered.drawings;
17835
+ record.wordarts = rendered.wordarts;
17836
+ record.urls = rendered.urls;
17837
+ record.mounted = true;
17838
+ }
17839
+ function unmountPageRecord(record) {
17840
+ if (!record.mounted) return;
17841
+ for (const url of record.urls) URL.revokeObjectURL(url);
17842
+ record.el.replaceChildren();
17843
+ record.bindings = [];
17844
+ record.grips = [];
17845
+ record.images = [];
17846
+ record.drawings = [];
17847
+ record.wordarts = [];
17848
+ record.urls = [];
17849
+ record.mounted = false;
18056
17850
  }
18057
17851
  function renderToDom(doc, layout, container, options = {}, prev) {
18058
17852
  const zoom = options.zoom ?? 1;
@@ -19018,8 +18812,18 @@ function renderItem(doc, item, urls, interactive) {
19018
18812
  }
19019
18813
  } else if (ext === "wmf") {
19020
18814
  const wmfKey = `wmf:${item.part}:${Math.round(item.width)}x${Math.round(item.height)}`;
19021
- decoded = docDerivedSrc(doc, wmfKey) ?? renderWmf(bytes, item.width, item.height);
19022
- if (decoded) setDocDerivedSrc(doc, wmfKey, decoded);
18815
+ const cachedWmf = docDerivedSrc(doc, wmfKey);
18816
+ if (cachedWmf) {
18817
+ decoded = cachedWmf;
18818
+ } else {
18819
+ void import("./wmf-53LMIKNI.js").then(({ renderWmf }) => {
18820
+ const url = renderWmf(bytes, item.width, item.height);
18821
+ if (url) {
18822
+ setDocDerivedSrc(doc, wmfKey, url);
18823
+ img.src = url;
18824
+ }
18825
+ });
18826
+ }
19023
18827
  } else if (ext === "emf") {
19024
18828
  const emfKey = `emf:${item.part}`;
19025
18829
  const cachedEmf = docDerivedSrc(doc, emfKey);
@@ -19027,7 +18831,7 @@ function renderItem(doc, item, urls, interactive) {
19027
18831
  decoded = cachedEmf;
19028
18832
  } else {
19029
18833
  const buf = bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
19030
- void convertEmfToDataUrl(buf).then((url) => {
18834
+ void import("emf-converter").then(({ convertEmfToDataUrl }) => convertEmfToDataUrl(buf)).then((url) => {
19031
18835
  if (url) {
19032
18836
  setDocDerivedSrc(doc, emfKey, url);
19033
18837
  img.src = url;
@@ -19638,17 +19442,22 @@ function renderText(item, interactive) {
19638
19442
  }
19639
19443
  if (item.href) {
19640
19444
  const anchor = el16;
19445
+ const bookmark = item.href.startsWith("#") ? item.href.slice(1) : void 0;
19641
19446
  anchor.href = item.href;
19642
- anchor.target = "_blank";
19643
- anchor.rel = "noreferrer noopener";
19447
+ if (!bookmark) {
19448
+ anchor.target = "_blank";
19449
+ anchor.rel = "noreferrer noopener";
19450
+ }
19644
19451
  anchor.title = item.href;
19645
- if (interactive) {
19452
+ if (interactive || bookmark) {
19646
19453
  anchor.addEventListener("mouseup", (event) => {
19647
19454
  if (event.metaKey || event.ctrlKey) event.stopPropagation();
19648
19455
  });
19649
19456
  anchor.addEventListener("click", (event) => {
19650
19457
  event.preventDefault();
19651
- if (event.metaKey || event.ctrlKey) {
19458
+ if (bookmark && (!interactive || event.metaKey || event.ctrlKey)) {
19459
+ scrollToBookmark(anchor, bookmark);
19460
+ } else if (!bookmark && (event.metaKey || event.ctrlKey)) {
19652
19461
  window.open(anchor.href, "_blank", "noopener,noreferrer");
19653
19462
  }
19654
19463
  });
@@ -19663,6 +19472,20 @@ function renderText(item, interactive) {
19663
19472
  setItemLayer(el16, item);
19664
19473
  return el16;
19665
19474
  }
19475
+ function scrollToBookmark(anchor, bookmark) {
19476
+ const root = anchor.closest(".dxw-pages");
19477
+ const container = root?.parentElement;
19478
+ if (!root || !container) return;
19479
+ for (const page of Array.from(root.children)) {
19480
+ if (!(page instanceof HTMLElement) || !page.dataset.bookmarks) continue;
19481
+ const bookmarks = JSON.parse(page.dataset.bookmarks);
19482
+ const y = bookmarks[bookmark];
19483
+ if (y === void 0) continue;
19484
+ const pageTop = page.getBoundingClientRect().top - container.getBoundingClientRect().top + container.scrollTop;
19485
+ container.scrollTo({ top: Math.max(0, pageTop + y - 24) });
19486
+ return;
19487
+ }
19488
+ }
19666
19489
  function renderEdge(x1, y1, x2, y2, border, rotate) {
19667
19490
  const el16 = document.createElement("div");
19668
19491
  el16.dataset.dxwEdge = "1";
@@ -34749,11 +34572,6 @@ function DocxView({
34749
34572
  const applyZoomRef = useRef3(null);
34750
34573
  const onPageCountChangeRef = useRef3(onPageCountChange);
34751
34574
  onPageCountChangeRef.current = onPageCountChange;
34752
- useEffect3(() => {
34753
- if (editable && typeof window !== "undefined" && !customElements.get("model-viewer")) {
34754
- void import("@google/model-viewer");
34755
- }
34756
- }, [editable]);
34757
34575
  const recomputeFit = useCallback2(() => {
34758
34576
  const c = containerRef.current;
34759
34577
  if (!c) return;
@@ -34847,6 +34665,9 @@ function DocxView({
34847
34665
  paintedModelVersion = doc.modelVersion;
34848
34666
  const container = containerRef.current;
34849
34667
  if (!container) return 0;
34668
+ if (editable && !customElements.get("model-viewer") && layout.pages.some((page) => page.items.some((item) => item.kind === "image" && item.model3D))) {
34669
+ void import("@google/model-viewer");
34670
+ }
34850
34671
  const { scrollTop, scrollLeft } = container;
34851
34672
  const prev = handle;
34852
34673
  const t2 = perf ? performance.now() : 0;