wordinweb 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -346,6 +346,7 @@ For your own application, source your own fonts.
346
346
  Add a separate `@font-face` rule for every weight and style you use.
347
347
 
348
348
  When the browser can't render a requested face, `onMissingFonts` reports it so you can warn the user that the on-screen layout may drift from Word.
349
+ `CollabEditor` accepts the same `onMissingFonts` callback and forwards it to the live view.
349
350
 
350
351
  ## Development
351
352
 
@@ -8825,22 +8825,18 @@ var _DocxDocument = class _DocxDocument {
8825
8825
  }
8826
8826
  findParentOf(target) {
8827
8827
  const roots = this.contentRoots();
8828
+ if (roots.includes(target)) return void 0;
8828
8829
  const memo = this._parentMemo.get(target);
8829
8830
  if (memo && memo.children.includes(target) && this.memoIsLive(memo, roots)) return memo;
8830
8831
  const walk2 = (el26) => {
8831
8832
  for (const c of el26.children) {
8832
8833
  this._parentMemo.set(c, el26);
8833
- if (c === target) return el26;
8834
- const hit = walk2(c);
8835
- if (hit) return hit;
8834
+ walk2(c);
8836
8835
  }
8837
- return void 0;
8838
8836
  };
8839
- for (const root of roots) {
8840
- const hit = walk2(root);
8841
- if (hit) return hit;
8842
- }
8843
- return void 0;
8837
+ for (const root of roots) walk2(root);
8838
+ const found = this._parentMemo.get(target);
8839
+ return found && found.children.includes(target) && this.memoIsLive(found, roots) ? found : void 0;
8844
8840
  }
8845
8841
  /** Record a parent link the caller just created (a splice), so the next
8846
8842
  * lookup skips the full-document walk. Advisory only — findParentOf
@@ -10502,6 +10498,11 @@ var METRIC_SUBSTITUTES = {
10502
10498
  // DECLARING ascii="MS Gothic" must keep the pre-CJK canvas fallback so its
10503
10499
  // line height stays normal — wild-athabasca's header "\u2264" run.)
10504
10500
  };
10501
+ var METRIC_COMPATIBLE = /* @__PURE__ */ new Set(["Carlito", "Caladea", "Times New Roman"]);
10502
+ function metricCompatibleSubstitute(family) {
10503
+ const substitute = METRIC_SUBSTITUTES[family.toLowerCase()];
10504
+ return substitute && METRIC_COMPATIBLE.has(substitute) ? substitute : void 0;
10505
+ }
10505
10506
  var WORD_FONT_METRICS = {
10506
10507
  calibri: { asc: 0.952148, desc: 0.268555, gap: 0 },
10507
10508
  "calibri light": { asc: 0.952148, desc: 0.268555, gap: 0 },
@@ -45368,7 +45369,9 @@ function detectMissingFonts(layout) {
45368
45369
  const viaSerif = width(`32px "${family}", serif`);
45369
45370
  const faceMissing = viaMono === mono && viaSerif === serif && mono !== serif;
45370
45371
  if (faceMissing) {
45371
- missing.push({ family, sample });
45372
+ const substitute = metricCompatibleSubstitute(family);
45373
+ const substitutePresent = !!substitute && !(width(`32px "${substitute}", monospace`) === mono && width(`32px "${substitute}", serif`) === serif);
45374
+ if (!substitutePresent) missing.push({ family, sample });
45372
45375
  continue;
45373
45376
  }
45374
45377
  const nonLatin = sample.replace(/[\u0000-ɏ]+/g, "");
@@ -55760,4 +55763,4 @@ export {
55760
55763
  cfb/cfb.js:
55761
55764
  (*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com *)
55762
55765
  */
55763
- //# sourceMappingURL=chunk-VL6YPZSD.js.map
55766
+ //# sourceMappingURL=chunk-D6MZHDCC.js.map