@file-viewer/docx 0.3.36 → 0.3.39

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
@@ -412,3 +412,9 @@ Manual dispatch defaults to a dry run and requires an existing release tag.
412
412
  Retries verify the packed SHA-512 against the registry before skipping an
413
413
  existing version. Different bytes or an uncertain write stop the run rather
414
414
  than changing the version or repeating an authentication prompt.
415
+
416
+ ### Picture layout in fixed-page previews
417
+
418
+ DrawingML `srcRect` cropping selects source pixels inside the authored picture frame, including asymmetric crops and rotation/mirroring. A cropped picture does not enlarge its surrounding paragraph or paint over following text.
419
+
420
+ During fixed-page pagination, an inline picture taller than a fresh page's body is scaled proportionally to fit, preserving the complete picture and its aspect ratio. Normal pictures keep their authored dimensions. This prevents repeatedly moving the same oversized picture through empty continuation pages. Continuous/flow previews keep their existing sizing behavior.
@@ -83,6 +83,7 @@ export declare class DocumentParser {
83
83
  parseDmlGroupTransform(elem: Element, parentTransform?: any): any;
84
84
  parseDmlPositionedPicture(elem: Element, transform?: any): IDomImage;
85
85
  parseDmlPositionedShape(elem: Element, transform?: any): IDomShape;
86
+ parseDmlRoundRectRadius(spPr: Element, width: number, height: number, transform?: any): string;
86
87
  parseDmlShapeBounds(spPr: Element, transform?: any): {
87
88
  left: number;
88
89
  top: number;
@@ -3737,6 +3737,8 @@
3737
3737
  result.tagName = "g";
3738
3738
  result.isGroup = true;
3739
3739
  break;
3740
+ case "roundrect":
3741
+ result.roundRectArc = 0.2;
3740
3742
  case "rect":
3741
3743
  result.tagName = "rect";
3742
3744
  Object.assign(result.attrs, { width: '100%', height: '100%' });
@@ -3771,6 +3773,10 @@
3771
3773
  case "coordsize":
3772
3774
  result.coordSize = parseNumericPoint(at.value);
3773
3775
  break;
3776
+ case "arcsize":
3777
+ if (result.roundRectArc != null)
3778
+ result.roundRectArc = parseRoundRectArc(at.value);
3779
+ break;
3774
3780
  case "inset":
3775
3781
  if (result.textInset) {
3776
3782
  const values = at.value.trim().split(/\s*,\s*|\s+/);
@@ -3868,6 +3874,13 @@
3868
3874
  }
3869
3875
  return result;
3870
3876
  }
3877
+ function parseRoundRectArc(value) {
3878
+ const source = value.trim();
3879
+ if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:%|f)?$/i.test(source))
3880
+ return 0.2;
3881
+ const fraction = parseFloat(source) / (/%$/.test(source) ? 100 : /f$/i.test(source) ? 65536 : 1);
3882
+ return Number.isFinite(fraction) ? Math.max(0, Math.min(1, fraction)) : 0.2;
3883
+ }
3871
3884
  function vmlImageAttrs(el) {
3872
3885
  const cropLeft = parseVmlFraction(globalXmlParser.attr(el, "cropleft"));
3873
3886
  const cropTop = parseVmlFraction(globalXmlParser.attr(el, "croptop"));
@@ -5425,6 +5438,9 @@
5425
5438
  const prstGeom = globalXmlParser.element(spPr, "prstGeom");
5426
5439
  const fillStyle = this.parseDmlFillStyle(spPr);
5427
5440
  const lineStyle = this.parseDmlLineStyle(globalXmlParser.element(spPr, "ln"));
5441
+ const roundedRadius = !geom ? this.parseDmlRoundRectRadius(spPr, bounds.width, bounds.height, transform) : null;
5442
+ if (roundedRadius != null)
5443
+ cssStyle["border-radius"] = roundedRadius;
5428
5444
  if (geom) {
5429
5445
  const path = this.parseDmlCustomGeometry(geom);
5430
5446
  return {
@@ -5462,6 +5478,23 @@
5462
5478
  alt: cNvPr ? globalXmlParser.attr(cNvPr, "descr") : null
5463
5479
  };
5464
5480
  }
5481
+ parseDmlRoundRectRadius(spPr, width, height, transform) {
5482
+ const preset = globalXmlParser.element(spPr, "prstGeom");
5483
+ if (!preset || globalXmlParser.attr(preset, "prst") != "roundRect")
5484
+ return null;
5485
+ const guides = globalXmlParser.element(preset, "avLst");
5486
+ const adjustment = (guides ? globalXmlParser.elements(guides, "gd") : [])
5487
+ .find(guide => globalXmlParser.attr(guide, "name") == "adj");
5488
+ const formula = adjustment ? globalXmlParser.attr(adjustment, "fmla") : "";
5489
+ const value = /^val\s+[+-]?(?:\d+(?:\.\d*)?|\.\d+)\s*$/.test(formula ?? "")
5490
+ ? Number(formula.trim().split(/\s+/)[1]) : 16667;
5491
+ const fraction = Math.max(0, Math.min(50000, value)) / 100000;
5492
+ const scaleX = Math.abs(transform?.scaleX ?? 1);
5493
+ const scaleY = Math.abs(transform?.scaleY ?? 1);
5494
+ const radius = Number.isFinite(scaleX) && Number.isFinite(scaleY) && scaleX > 0 && scaleY > 0
5495
+ ? Math.min(width / scaleX, height / scaleY) * fraction : 0;
5496
+ return `${this.pt(Number.isFinite(radius * scaleX) ? radius * scaleX : 0)} / ${this.pt(Number.isFinite(radius * scaleY) ? radius * scaleY : 0)}`;
5497
+ }
5465
5498
  parseDmlShapeBounds(spPr, transform) {
5466
5499
  const xfrm = globalXmlParser.element(spPr, "xfrm");
5467
5500
  const off = xfrm ? globalXmlParser.element(xfrm, "off") : null;
@@ -5598,6 +5631,7 @@
5598
5631
  return {
5599
5632
  dmlTextBox: true,
5600
5633
  textInsets: textInsetStyle,
5634
+ textCompatibleLineSpacing: bodyPr ? globalXmlParser.boolAttr(bodyPr, "compatLnSpc", false) : false,
5601
5635
  textVerticalAlign: this.dmlVerticalAlign(bodyPr)
5602
5636
  };
5603
5637
  }
@@ -5697,6 +5731,10 @@
5697
5731
  }
5698
5732
  parseDmlShapeProperties(elem, style) {
5699
5733
  const xfrm = globalXmlParser.element(elem, "xfrm");
5734
+ const bounds = this.parseDmlShapeBounds(elem);
5735
+ const roundedRadius = this.parseDmlRoundRectRadius(elem, bounds.width, bounds.height);
5736
+ if (roundedRadius != null)
5737
+ style["border-radius"] = roundedRadius;
5700
5738
  if (xfrm) {
5701
5739
  for (const n of globalXmlParser.elements(xfrm)) {
5702
5740
  switch (n.localName) {
@@ -6141,6 +6179,10 @@
6141
6179
  case "textAlignment":
6142
6180
  style["vertical-align"] = values.valueOfTextAlignment(c);
6143
6181
  break;
6182
+ case "autoSpaceDE":
6183
+ case "autoSpaceDN":
6184
+ style[c.localName == "autoSpaceDE" ? "--docx-auto-space-de" : "--docx-auto-space-dn"] = `${globalXmlParser.boolAttr(c, "val", true)}`;
6185
+ break;
6144
6186
  case "color":
6145
6187
  style["color"] = xmlUtil.colorAttr(c, "val", null, autos.color);
6146
6188
  break;
@@ -6439,6 +6481,7 @@
6439
6481
  fonts.push(...[asciiTheme, hAnsiTheme]
6440
6482
  .filter(x => x)
6441
6483
  .map(x => x.startsWith("var(") ? x : encloseFontFamily(x)));
6484
+ const latinFonts = fonts.slice();
6442
6485
  if (eastAsia) {
6443
6486
  fonts.push(...eastAsianFontFamilyStack(eastAsia, eastAsiaScript));
6444
6487
  }
@@ -6452,6 +6495,9 @@
6452
6495
  if (fonts.length > 0) {
6453
6496
  const currentFonts = (style["font-family"] ?? "").split(',').map(x => x.trim()).filter(x => x);
6454
6497
  style["font-family"] = [...new Set([...currentFonts, ...fonts])].join(', ');
6498
+ if (latinFonts.length)
6499
+ style["--docx-latin-font-family"] = [...new Set(latinFonts)].join(', ');
6500
+ style["--docx-partial-eastasia-font"] = !latinFonts.length && (eastAsia || eastAsiaTheme) && !cs && !csTheme ? "true" : "false";
6455
6501
  }
6456
6502
  }
6457
6503
  scriptThemeFontValue(value, language) {
@@ -8733,6 +8779,7 @@
8733
8779
  this.headingIndex = 0;
8734
8780
  this.tasks = [];
8735
8781
  this.postRenderTasks = [];
8782
+ this.compatibleTextBoxSpacing = false;
8736
8783
  this.h = h;
8737
8784
  this.darkModeVarNames = new Map();
8738
8785
  this.darkModePrintReset = {};
@@ -9658,6 +9705,29 @@
9658
9705
  effectiveParagraphCssValue(elem, style, name) {
9659
9706
  return elem.cssStyle?.[name] ?? this.styleValue(style, "p", name);
9660
9707
  }
9708
+ textBoxAutospace(elem, style, supports = (value) => typeof CSS == "undefined" || typeof CSS.supports != "function" || CSS.supports("text-autospace", value)) {
9709
+ const enabled = (key) => !/^(0|false|off)$/i.test(this.effectiveParagraphCssValue(elem, style, key) ?? "true");
9710
+ const alpha = enabled("--docx-auto-space-de"), numeric = enabled("--docx-auto-space-dn");
9711
+ const value = alpha && numeric ? "normal" : alpha ? "ideograph-alpha" : numeric ? "ideograph-numeric" : "no-autospace";
9712
+ return supports(value) ? value : "no-autospace";
9713
+ }
9714
+ applyTextBoxFontInheritance(elem, style, result) {
9715
+ if (!this.compatibleTextBoxSpacing)
9716
+ return;
9717
+ const paragraph = elem.type == DomType.Paragraph ? elem : this.currentParagraph;
9718
+ const paragraphStyle = this.findStyle(paragraph?.styleName);
9719
+ const defaults = this.document.stylesPart?.styles?.find(item => item.id == null);
9720
+ const levels = [elem.cssStyle, this.styleValuesForTarget(style, elem.type == DomType.Paragraph ? "p" : "span"),
9721
+ paragraph?.cssStyle, this.styleValuesForTarget(paragraphStyle, "span"), this.styleValuesForTarget(defaults, "span")];
9722
+ const value = (key) => levels.find(level => level?.[key] != null)?.[key];
9723
+ if (value("--docx-partial-eastasia-font") != "true")
9724
+ return;
9725
+ const latin = value("--docx-latin-font-family"), family = value("font-family");
9726
+ if (!latin || !family)
9727
+ return;
9728
+ this.setCssStyle(result, "--docx-latin-font-family", latin);
9729
+ this.setCssStyle(result, "font-family", `var(--docx-latin-font-family), ${family}`);
9730
+ }
9661
9731
  isInsideTableCell(elem) {
9662
9732
  for (let p = elem.parent; p; p = p.parent) {
9663
9733
  if (p.type == DomType.Cell)
@@ -10696,6 +10766,8 @@
10696
10766
  splitParagraphBlock(paragraph, page, nextArticle) {
10697
10767
  if (!paragraph.hasChildNodes())
10698
10768
  return false;
10769
+ if (this.fitOversizedInlinePicture(paragraph, page))
10770
+ return false;
10699
10771
  const clone = this.cloneBlockShell(paragraph);
10700
10772
  clone.dataset.docxContinued = "true";
10701
10773
  nextArticle.prepend(clone);
@@ -10718,6 +10790,44 @@
10718
10790
  this.rebalanceWidowOrphan(paragraph, clone, page);
10719
10791
  return true;
10720
10792
  }
10793
+ fitOversizedInlinePicture(paragraph, page) {
10794
+ const article = paragraph.parentElement;
10795
+ if (article?.localName !== "article" || article.firstElementChild !== paragraph
10796
+ || page.querySelector(":scope > article > *") !== paragraph
10797
+ || paragraph.textContent?.trim() || paragraph.querySelector("table,math,object,canvas,video,[data-docx-note-reference]"))
10798
+ return false;
10799
+ const drawings = Array.from(paragraph.querySelectorAll("[data-docx-drawing]"));
10800
+ const drawing = drawings[0];
10801
+ if (drawings.length !== 1 || !drawing || drawing.children.length !== 1
10802
+ || paragraph.querySelectorAll("img").length !== 1 || drawing.dataset.docxFloat)
10803
+ return false;
10804
+ const picture = drawing.firstElementChild;
10805
+ if (picture.localName !== "img" && picture.dataset.docxImageCrop !== "true")
10806
+ return false;
10807
+ const view = paragraph.ownerDocument.defaultView;
10808
+ const style = view?.getComputedStyle(drawing);
10809
+ if (!view || !style || style.position === "absolute" || style.position === "fixed"
10810
+ || style.transform !== "none" || style.cssFloat !== "none")
10811
+ return false;
10812
+ const paragraphRect = paragraph.getBoundingClientRect();
10813
+ const drawingRect = drawing.getBoundingClientRect();
10814
+ const pageRect = page.getBoundingClientRect();
10815
+ const screenScale = page.clientHeight > 0 ? pageRect.height / page.clientHeight : 1;
10816
+ const bottomMargin = (parseFloat(view.getComputedStyle(paragraph).marginBottom) || 0) * screenScale;
10817
+ const overhead = Math.max(0, paragraphRect.height - drawingRect.height);
10818
+ const available = this.getPageBodyBottom(page) - paragraphRect.top - overhead - bottomMargin - screenScale;
10819
+ const width = parseFloat(style.width), height = parseFloat(style.height);
10820
+ if (![available, width, height, drawingRect.height].every(Number.isFinite)
10821
+ || available <= 0 || width <= 0 || height <= 0 || drawingRect.height <= available)
10822
+ return false;
10823
+ const ratio = available / drawingRect.height;
10824
+ drawing.style.width = `${width * ratio}px`;
10825
+ drawing.style.height = `${height * ratio}px`;
10826
+ picture.style.width = "100%";
10827
+ picture.style.height = "100%";
10828
+ drawing.dataset.docxPageFitScale = `${ratio}`;
10829
+ return true;
10830
+ }
10721
10831
  splitTableBlock(table, page, nextArticle) {
10722
10832
  const rows = this.tableContentRows(table);
10723
10833
  if (rows.length <= 1)
@@ -11683,6 +11793,7 @@ section.${c}>footer { z-index: 1; }
11683
11793
  children = [flow];
11684
11794
  }
11685
11795
  var result = this.toHTML(elem, ns.html, "p", this.wrapTabLeaderChildren(children, true));
11796
+ this.applyTextBoxFontInheritance(elem, style, result);
11686
11797
  if (this.options.exposeDisplayTargets && elem.displayAddress) {
11687
11798
  const part = this.currentPart ?? this.document.documentPart;
11688
11799
  result.setAttribute("data-office-target", `${part.path}#${elem.displayAddress}`);
@@ -11716,6 +11827,16 @@ section.${c}>footer { z-index: 1; }
11716
11827
  result.dataset.docxWidowControl = "true";
11717
11828
  }
11718
11829
  this.applyDocumentGridLinePitch(elem, style, result);
11830
+ if (this.compatibleTextBoxSpacing)
11831
+ this.setCssStyle(result, "text-autospace", this.textBoxAutospace(elem, style));
11832
+ const lineRule = (elem.lineSpacing ?? style?.paragraphProps?.lineSpacing)?.lineRule;
11833
+ if (this.compatibleTextBoxSpacing && ["lines", "linesAndChars"].includes(this.currentSectionProps?.docGrid?.type)
11834
+ && this.paragraphUsesDocumentGrid(elem, style)
11835
+ && lineRule != "exact" && lineRule != "exactly") {
11836
+ result.dataset.docxTextboxGridPitch = this.currentSectionProps.docGrid.linePitch;
11837
+ result.dataset.docxTextboxBaseLineHeight = result.style.lineHeight ?? "";
11838
+ result.style.flexShrink = "0";
11839
+ }
11719
11840
  const leaderTab = elem.tabs?.find(t => this.isLeaderTabStop(t));
11720
11841
  if (leaderTab) {
11721
11842
  result.classList.add(`${this.className}-tab-leader-paragraph`);
@@ -11832,6 +11953,68 @@ section.${c}>footer { z-index: 1; }
11832
11953
  }
11833
11954
  return true;
11834
11955
  }
11956
+ textBoxGridLineHeight(natural, pitch) {
11957
+ if (!Number.isFinite(natural) || !Number.isFinite(pitch) || natural < 0 || pitch <= 0)
11958
+ return null;
11959
+ return Math.max(1, Math.ceil((natural - 1 / 64) / pitch)) * pitch;
11960
+ }
11961
+ refreshTextBoxLineGrid(root) {
11962
+ const view = root.ownerDocument?.defaultView;
11963
+ const paragraphs = Array.from(root.querySelectorAll("[data-docx-textbox-grid-pitch]"))
11964
+ .filter(paragraph => this.ownsLayoutElement(paragraph));
11965
+ if (!view || !paragraphs.length)
11966
+ return;
11967
+ const probe = root.ownerDocument.createElement("span");
11968
+ Object.assign(probe.style, {
11969
+ position: "absolute", visibility: "hidden", pointerEvents: "none", display: "inline-block",
11970
+ whiteSpace: "pre", width: "max-content", margin: "0", padding: "0", border: "0", minHeight: "0"
11971
+ });
11972
+ probe.setAttribute("aria-hidden", "true");
11973
+ const scope = root.getRootNode();
11974
+ const probeParent = scope.nodeType == 11 && "host" in scope ? scope : root.ownerDocument.body;
11975
+ probeParent.appendChild(probe);
11976
+ const setFont = (target, element, lineHeight = "normal") => {
11977
+ const style = view.getComputedStyle(element);
11978
+ Object.assign(target.style, {
11979
+ fontFamily: style.fontFamily, fontSize: style.fontSize, fontWeight: style.fontWeight,
11980
+ fontStyle: style.fontStyle, fontStretch: style.fontStretch, verticalAlign: style.verticalAlign, lineHeight
11981
+ });
11982
+ };
11983
+ try {
11984
+ for (const paragraph of paragraphs) {
11985
+ if (paragraph.querySelector("svg, img, table, math, [data-docx-drawing]"))
11986
+ continue;
11987
+ this.preserveGridInlineMetrics(paragraph);
11988
+ probe.style.height = paragraph.dataset.docxTextboxGridPitch;
11989
+ const pitch = parseFloat(view.getComputedStyle(probe).height);
11990
+ setFont(probe, paragraph, paragraph.dataset.docxTextboxBaseLineHeight || "normal");
11991
+ probe.style.height = "auto";
11992
+ probe.replaceChildren();
11993
+ const walker = root.ownerDocument.createTreeWalker(paragraph, 4);
11994
+ while (walker.nextNode()) {
11995
+ const node = walker.currentNode;
11996
+ const parent = node.parentElement;
11997
+ if (!node.textContent || !parent || !Array.from(parent.getClientRects()).some(rect => rect.width > 0 && rect.height > 0))
11998
+ continue;
11999
+ const lineHeight = parent == paragraph ? paragraph.dataset.docxTextboxBaseLineHeight : parent.style.lineHeight;
12000
+ const span = root.ownerDocument.createElement("span");
12001
+ setFont(span, parent, lineHeight || "normal");
12002
+ span.style.whiteSpace = "pre";
12003
+ span.textContent = node.textContent.replace(/[\r\n]/g, " ");
12004
+ probe.appendChild(span);
12005
+ }
12006
+ if (!probe.hasChildNodes())
12007
+ probe.textContent = "\u00a0";
12008
+ const natural = parseFloat(view.getComputedStyle(probe).height);
12009
+ const height = this.textBoxGridLineHeight(natural, pitch);
12010
+ if (height != null)
12011
+ paragraph.style.lineHeight = `${Math.round(height * 1000) / 1000}px`;
12012
+ }
12013
+ }
12014
+ finally {
12015
+ probe.remove();
12016
+ }
12017
+ }
11835
12018
  async prepareLayout(root, generation = getLayoutGeneration(root)) {
11836
12019
  if (!root.isConnected || !generation.isCurrent())
11837
12020
  return;
@@ -11852,6 +12035,7 @@ section.${c}>footer { z-index: 1; }
11852
12035
  (owner ?? root).appendChild(this.commentLayer.root);
11853
12036
  }
11854
12037
  }
12038
+ this.refreshTextBoxLineGrid(root);
11855
12039
  this.refreshTabStops(root);
11856
12040
  this.refreshAnchors(root);
11857
12041
  await this.commentLayer?.bind(root, generation);
@@ -12228,17 +12412,31 @@ section.${c}>footer { z-index: 1; }
12228
12412
  return result;
12229
12413
  }
12230
12414
  renderImage(elem) {
12231
- let result = this.toHTML(elem, ns.html, "img", []);
12415
+ const rect = elem.srcRect;
12416
+ const cropWidth = rect ? 1 - rect[0] - rect[2] : 1;
12417
+ const cropHeight = rect ? 1 - rect[1] - rect[3] : 1;
12418
+ const cropped = rect?.length === 4 && rect.some(x => x !== 0)
12419
+ && rect.every(Number.isFinite) && cropWidth > 0 && cropHeight > 0
12420
+ && Number.isFinite(100 / cropWidth) && Number.isFinite(100 / cropHeight);
12421
+ const result = this.toHTML(elem, ns.html, cropped ? "span" : "img", []);
12422
+ const image = cropped ? this.h({ tagName: "img" }) : result;
12232
12423
  let transform = elem.cssStyle?.transform;
12233
12424
  if (elem.alt)
12234
- result.alt = elem.alt;
12425
+ image.alt = elem.alt;
12235
12426
  if (elem.title)
12236
- result.title = elem.title;
12237
- if (elem.srcRect && elem.srcRect.some(x => x != 0)) {
12238
- var [left, top, right, bottom] = elem.srcRect;
12239
- transform = `${transform ?? ''} scale(${1 / (1 - left - right)}, ${1 / (1 - top - bottom)})`;
12240
- result.style.clipPath = `inset(${(100 * top).toFixed(2)}% ${(100 * right).toFixed(2)}% ${(100 * bottom).toFixed(2)}% ${(100 * left).toFixed(2)}%)`;
12241
- result.style.transformOrigin = "top left";
12427
+ image.title = elem.title;
12428
+ if (cropped) {
12429
+ result.setAttribute("data-docx-image-crop", "true");
12430
+ result.style.overflow = "hidden";
12431
+ result.style.position = "relative";
12432
+ Object.assign(image.style, {
12433
+ position: "absolute", display: "block", margin: "0",
12434
+ left: `${ -100 * rect[0] / cropWidth}%`,
12435
+ top: `${ -100 * rect[1] / cropHeight}%`,
12436
+ width: `${100 / cropWidth}%`, height: `${100 / cropHeight}%`,
12437
+ maxWidth: "none", maxHeight: "none", objectFit: "fill"
12438
+ });
12439
+ result.appendChild(image);
12242
12440
  }
12243
12441
  if (elem.rotation)
12244
12442
  transform = `rotate(${elem.rotation}deg) ${transform ?? ''}`;
@@ -12246,7 +12444,7 @@ section.${c}>footer { z-index: 1; }
12246
12444
  if (this.document && elem.src) {
12247
12445
  this.tasks.push(this.document.loadDocumentImage(elem.src, this.currentPart, this.options.externalResourcePolicy).then(x => {
12248
12446
  if (x)
12249
- result.setAttribute("src", x);
12447
+ image.setAttribute("src", x);
12250
12448
  }));
12251
12449
  }
12252
12450
  return result;
@@ -12268,9 +12466,17 @@ section.${c}>footer { z-index: 1; }
12268
12466
  }
12269
12467
  renderDmlTextBox(elem) {
12270
12468
  const previousParagraph = this.currentParagraph;
12469
+ const previousSpacing = this.compatibleTextBoxSpacing;
12271
12470
  this.currentParagraph = null;
12272
- const children = this.renderElements(elem.children);
12273
- this.currentParagraph = previousParagraph;
12471
+ this.compatibleTextBoxSpacing = elem.props?.textCompatibleLineSpacing === true;
12472
+ let children;
12473
+ try {
12474
+ children = this.renderElements(elem.children);
12475
+ }
12476
+ finally {
12477
+ this.currentParagraph = previousParagraph;
12478
+ this.compatibleTextBoxSpacing = previousSpacing;
12479
+ }
12274
12480
  const content = this.h({
12275
12481
  tagName: "div",
12276
12482
  className: `${this.className}-shape-textbox`,
@@ -13971,6 +14177,7 @@ section.${c}>footer { z-index: 1; }
13971
14177
  }
13972
14178
  const result = this.toHTML(elem, ns.html, "span", children);
13973
14179
  const style = this.findStyle(elem.styleName);
14180
+ this.applyTextBoxFontInheritance(elem, style, result);
13974
14181
  const snapToGrid = elem.cssStyle?.["--docx-snap-to-grid"] ?? this.styleValue(style, "span", "--docx-snap-to-grid");
13975
14182
  if (/^(0|false|off)$/i.test(snapToGrid ?? ""))
13976
14183
  result.style.letterSpacing = "normal";
@@ -14298,6 +14505,11 @@ section.${c}>footer { z-index: 1; }
14298
14505
  rect.setAttribute("width", `${bounds.width}`);
14299
14506
  rect.setAttribute("height", `${bounds.height}`);
14300
14507
  this.applyVmlAttributes(rect, elem.attrs, new Set(["x", "y", "width", "height"]));
14508
+ if (elem.roundRectArc != null) {
14509
+ const radius = Math.min(bounds.width, bounds.height) * elem.roundRectArc / 2;
14510
+ rect.setAttribute("rx", `${radius}`);
14511
+ rect.setAttribute("ry", `${radius}`);
14512
+ }
14301
14513
  result = rect;
14302
14514
  break;
14303
14515
  }
@@ -14711,8 +14923,11 @@ section.${c}>footer { z-index: 1; }
14711
14923
  if (!style)
14712
14924
  return style;
14713
14925
  const result = { ...style };
14714
- if (normalized)
14926
+ if (normalized) {
14715
14927
  delete result["font-family"];
14928
+ delete result["--docx-latin-font-family"];
14929
+ delete result["--docx-partial-eastasia-font"];
14930
+ }
14716
14931
  return result;
14717
14932
  }
14718
14933
  normalizeNumberingLevelText(text, format, runStyle) {