@superdoc-dev/cli 0.13.0-next.1 → 0.13.0-next.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.
Files changed (2) hide show
  1. package/dist/index.js +245 -96
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -67593,7 +67593,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
67593
67593
  emptyOptions2 = {};
67594
67594
  });
67595
67595
 
67596
- // ../../packages/superdoc/dist/chunks/SuperConverter-opYK-HD4.es.js
67596
+ // ../../packages/superdoc/dist/chunks/SuperConverter-zMJ6NmqZ.es.js
67597
67597
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
67598
67598
  const fieldValue = extension$1.config[field];
67599
67599
  if (typeof fieldValue === "function")
@@ -89268,6 +89268,36 @@ function updateSectionMargins(target, updates = {}) {
89268
89268
  }
89269
89269
  throw new Error(`updateSectionMargins: unsupported target type: ${target.type}`);
89270
89270
  }
89271
+ function binaryStringToBase64(binary) {
89272
+ if (typeof globalThis.btoa === "function")
89273
+ return globalThis.btoa(binary);
89274
+ if (typeof Buffer3 !== "undefined")
89275
+ return Buffer3.from(binary, "latin1").toString("base64");
89276
+ throw new Error("[base64] encode requires btoa (browser) or Buffer (Node)");
89277
+ }
89278
+ function base64ToBinaryString(b64) {
89279
+ if (typeof globalThis.atob === "function")
89280
+ return globalThis.atob(b64);
89281
+ if (typeof Buffer3 !== "undefined")
89282
+ return Buffer3.from(b64, "base64").toString("latin1");
89283
+ throw new Error("[base64] decode requires atob (browser) or Buffer (Node)");
89284
+ }
89285
+ function encodeUtf8Base64(input) {
89286
+ return binaryStringToBase64(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))));
89287
+ }
89288
+ function decodeUtf8Base64(b64) {
89289
+ if (!b64)
89290
+ return "";
89291
+ try {
89292
+ const bin = base64ToBinaryString(b64);
89293
+ let pct = "";
89294
+ for (let i$1 = 0;i$1 < bin.length; i$1 += 1)
89295
+ pct += `%${bin.charCodeAt(i$1).toString(16).padStart(2, "0")}`;
89296
+ return decodeURIComponent(pct);
89297
+ } catch {
89298
+ return "";
89299
+ }
89300
+ }
89271
89301
  function collectReferencedImageMediaForClipboard(sliceJsonString, editor) {
89272
89302
  if (!sliceJsonString || !editor?.storage?.image?.media)
89273
89303
  return "";
@@ -89402,36 +89432,6 @@ function applySuperdocClipboardMedia(editor, clipboardData, sliceJson = null, me
89402
89432
  }
89403
89433
  return outSlice;
89404
89434
  }
89405
- function binaryStringToBase64(binary) {
89406
- if (typeof globalThis.btoa === "function")
89407
- return globalThis.btoa(binary);
89408
- if (typeof Buffer3 !== "undefined")
89409
- return Buffer3.from(binary, "latin1").toString("base64");
89410
- throw new Error("[superdocClipboardSlice] base64 encode requires btoa (browser) or Buffer (Node)");
89411
- }
89412
- function base64ToBinaryString(b64) {
89413
- if (typeof globalThis.atob === "function")
89414
- return globalThis.atob(b64);
89415
- if (typeof Buffer3 !== "undefined")
89416
- return Buffer3.from(b64, "base64").toString("latin1");
89417
- throw new Error("[superdocClipboardSlice] base64 decode requires atob (browser) or Buffer (Node)");
89418
- }
89419
- function encodeUtf8Base64(input) {
89420
- return binaryStringToBase64(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))));
89421
- }
89422
- function decodeUtf8Base64(b64) {
89423
- if (!b64)
89424
- return "";
89425
- try {
89426
- const bin = base64ToBinaryString(b64);
89427
- let pct = "";
89428
- for (let i$1 = 0;i$1 < bin.length; i$1 += 1)
89429
- pct += `%${bin.charCodeAt(i$1).toString(16).padStart(2, "0")}`;
89430
- return decodeURIComponent(pct);
89431
- } catch {
89432
- return "";
89433
- }
89434
- }
89435
89435
  function bodySectPrShouldEmbed(bodySectPr) {
89436
89436
  if (!bodySectPr || typeof bodySectPr !== "object")
89437
89437
  return false;
@@ -97709,8 +97709,12 @@ function handleShapeTextWatermarkImport({ pict }) {
97709
97709
  marginTop: styleObj["margin-top"] || "0"
97710
97710
  };
97711
97711
  const rotation = parseFloat(styleObj.rotation) || 0;
97712
- const hPosition = styleObj["mso-position-horizontal"] || "center";
97713
- const vPosition = styleObj["mso-position-vertical"] || "center";
97712
+ const explicitHPosition = styleObj["mso-position-horizontal"];
97713
+ const explicitVPosition = styleObj["mso-position-vertical"];
97714
+ const hasExplicitMarginLeft = styleObj["margin-left"] != null;
97715
+ const hasExplicitMarginTop = styleObj["margin-top"] != null;
97716
+ const hPosition = explicitHPosition || (hasExplicitMarginLeft ? undefined : DEFAULT_VML_TEXT_WATERMARK_ALIGNMENT);
97717
+ const vPosition = explicitVPosition || (hasExplicitMarginTop ? undefined : DEFAULT_VML_TEXT_WATERMARK_ALIGNMENT);
97714
97718
  const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
97715
97719
  const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
97716
97720
  const textAnchor = styleObj["v-text-anchor"] || "middle";
@@ -97719,7 +97723,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97719
97723
  const rawFillColor2 = fillAttrs.color2 || "#3f3f3f";
97720
97724
  const fillColor = sanitizeColor(rawFillColor, "silver");
97721
97725
  const fillColor2 = sanitizeColor(rawFillColor2, "#3f3f3f");
97722
- const opacity = fillAttrs.opacity || "0.5";
97726
+ const opacity = fillAttrs.opacity ?? String(DEFAULT_VML_TEXT_WATERMARK_OPACITY);
97723
97727
  const fillType = fillAttrs.type || "solid";
97724
97728
  const strokeAttrs = shape.elements?.find((el) => el.name === "v:stroke")?.attributes || {};
97725
97729
  const stroked = shapeAttrs.stroked || "f";
@@ -97727,10 +97731,9 @@ function handleShapeTextWatermarkImport({ pict }) {
97727
97731
  const strokeJoinstyle = strokeAttrs.joinstyle || "round";
97728
97732
  const strokeEndcap = strokeAttrs.endcap || "flat";
97729
97733
  const textStyleObj = parseVmlStyle(textpathAttrs.style || "");
97730
- const rawFontFamily = textStyleObj["font-family"]?.replace(/['"]/g, "");
97731
- const fontFamily = sanitizeFontFamily(rawFontFamily);
97734
+ const fontFamily = sanitizeFontFamily(decodeXmlEntities(textStyleObj["font-family"] || "").replace(/['"]/g, ""));
97732
97735
  const fontSize = textStyleObj["font-size"] || "1pt";
97733
- const fitshape = textpathAttrs.fitshape || "t";
97736
+ const shouldFitShape = (textpathAttrs.fitshape || "t") === "t";
97734
97737
  const trim = textpathAttrs.trim || "t";
97735
97738
  const textpathOn = textpathAttrs.on || "t";
97736
97739
  const pathAttrs = shape.elements?.find((el) => el.name === "v:path")?.attributes || {};
@@ -97739,7 +97742,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97739
97742
  const wrapType = wrapAttrs.type || "none";
97740
97743
  const widthPx = convertToPixels(width);
97741
97744
  const heightPx = convertToPixels(height);
97742
- const sanitizedOpacity = sanitizeNumeric(parseFloat(opacity), 0.5, 0, 1);
97745
+ const sanitizedOpacity = sanitizeNumeric(parseVmlOpacity(opacity), DEFAULT_VML_TEXT_WATERMARK_OPACITY, 0, 1);
97743
97746
  const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
97744
97747
  const svgResult = generateTextWatermarkSVG({
97745
97748
  text: watermarkText,
@@ -97753,12 +97756,44 @@ function handleShapeTextWatermarkImport({ pict }) {
97753
97756
  textStyle: {
97754
97757
  fontFamily,
97755
97758
  fontSize
97756
- }
97759
+ },
97760
+ fitShape: shouldFitShape
97761
+ });
97762
+ const svgDataUri = svgResult.dataUri;
97763
+ const centerOffsetTop = getTextWatermarkCenterOffset({
97764
+ hPosition,
97765
+ vPosition,
97766
+ hRelativeTo,
97767
+ vRelativeTo,
97768
+ height: heightPx,
97769
+ rotation: sanitizedRotation
97770
+ });
97771
+ const marginOffset = resolveTextWatermarkMarginOffset({
97772
+ hPosition,
97773
+ vPosition,
97774
+ hRelativeTo,
97775
+ vRelativeTo,
97776
+ marginLeft: convertToPixels(position2.marginLeft),
97777
+ marginTop: convertToPixels(position2.marginTop),
97778
+ width: widthPx,
97779
+ height: heightPx,
97780
+ svgWidth: svgResult.svgWidth,
97781
+ svgHeight: svgResult.svgHeight,
97782
+ centerOffsetTop,
97783
+ rotation: sanitizedRotation
97757
97784
  });
97785
+ const anchorData = {
97786
+ hRelativeFrom: hRelativeTo,
97787
+ vRelativeFrom: vRelativeTo
97788
+ };
97789
+ if (hPosition)
97790
+ anchorData.alignH = hPosition;
97791
+ if (vPosition)
97792
+ anchorData.alignV = vPosition;
97758
97793
  return {
97759
97794
  type: "image",
97760
97795
  attrs: {
97761
- src: svgResult.dataUri,
97796
+ src: svgDataUri,
97762
97797
  alt: watermarkText,
97763
97798
  title: watermarkText,
97764
97799
  extension: "svg",
@@ -97777,20 +97812,12 @@ function handleShapeTextWatermarkImport({ pict }) {
97777
97812
  type: wrapType === "none" ? "None" : wrapType,
97778
97813
  attrs: { behindDoc: true }
97779
97814
  },
97780
- anchorData: {
97781
- hRelativeFrom: hRelativeTo,
97782
- vRelativeFrom: vRelativeTo,
97783
- alignH: hPosition,
97784
- alignV: vPosition
97785
- },
97815
+ anchorData,
97786
97816
  size: {
97787
97817
  width: svgResult.svgWidth,
97788
97818
  height: svgResult.svgHeight
97789
97819
  },
97790
- marginOffset: {
97791
- horizontal: hPosition === "center" && hRelativeTo === "margin" ? 0 : convertToPixels(position2.marginLeft),
97792
- top: vPosition === "center" && vRelativeTo === "margin" ? 0 : convertToPixels(position2.marginTop)
97793
- },
97820
+ marginOffset,
97794
97821
  textWatermarkData: {
97795
97822
  text: watermarkText,
97796
97823
  rotation: sanitizedRotation,
@@ -97813,7 +97840,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97813
97840
  },
97814
97841
  textpath: {
97815
97842
  on: textpathOn === "t",
97816
- fitshape: fitshape === "t",
97843
+ fitshape: shouldFitShape,
97817
97844
  trim: trim === "t",
97818
97845
  textpathok: textpathok === "t"
97819
97846
  }
@@ -97824,21 +97851,84 @@ function handleShapeTextWatermarkImport({ pict }) {
97824
97851
  function sanitizeFontFamily(fontFamily) {
97825
97852
  if (!fontFamily || typeof fontFamily !== "string")
97826
97853
  return "Arial";
97827
- return fontFamily.replace(/[^a-zA-Z0-9\s,\-]/g, "").trim() || "Arial";
97854
+ return fontFamily.replace(/[^a-zA-Z0-9\s,-]/g, "").trim() || "Arial";
97828
97855
  }
97829
97856
  function sanitizeColor(color2, defaultColor = "silver") {
97830
97857
  if (!color2 || typeof color2 !== "string")
97831
97858
  return defaultColor;
97832
97859
  return color2.replace(/[^a-zA-Z0-9#%(),.]/g, "").trim() || defaultColor;
97833
97860
  }
97861
+ function normalizeVmlColor(color2) {
97862
+ return {
97863
+ black: "#000000",
97864
+ blue: "#0000FF",
97865
+ gray: "#808080",
97866
+ green: "#008000",
97867
+ lime: "#00FF00",
97868
+ red: "#FF0000",
97869
+ silver: "#C0C0C0",
97870
+ white: "#FFFFFF",
97871
+ yellow: "#FFFF00"
97872
+ }[typeof color2 === "string" ? color2.trim().toLowerCase() : ""] || color2;
97873
+ }
97874
+ function decodeXmlEntities(value) {
97875
+ return value.replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&").replace(/&#(\d+);/g, (_, code$1) => decodeCodePoint(Number(code$1))).replace(/&#x([0-9a-fA-F]+);/g, (_, code$1) => decodeCodePoint(Number.parseInt(code$1, 16)));
97876
+ }
97877
+ function decodeCodePoint(codePoint) {
97878
+ if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111)
97879
+ return "";
97880
+ return String.fromCodePoint(codePoint);
97881
+ }
97834
97882
  function sanitizeNumeric(value, defaultValue, min4 = -Infinity, max4 = Infinity) {
97835
97883
  const num = typeof value === "number" ? value : parseFloat(value);
97836
97884
  if (isNaN(num) || !isFinite(num))
97837
97885
  return defaultValue;
97838
97886
  return Math.max(min4, Math.min(max4, num));
97839
97887
  }
97840
- function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill, textStyle }) {
97841
- let fontSize = height * 0.9;
97888
+ function parseVmlOpacity(value) {
97889
+ if (typeof value === "number")
97890
+ return value;
97891
+ if (!value || typeof value !== "string")
97892
+ return NaN;
97893
+ const normalized = value.trim().toLowerCase();
97894
+ if (normalized.endsWith("%"))
97895
+ return Number.parseFloat(normalized.slice(0, -1)) / 100;
97896
+ if (normalized.endsWith("f"))
97897
+ return Number.parseInt(normalized.slice(0, -1), 10) / 65536;
97898
+ return Number.parseFloat(normalized);
97899
+ }
97900
+ function getTextWatermarkCenterOffset({ hPosition, vPosition, hRelativeTo, vRelativeTo, height, rotation }) {
97901
+ if (!(hPosition === "center" && vPosition === "center" && hRelativeTo === "margin" && vRelativeTo === "margin") || rotation === 0)
97902
+ return 0;
97903
+ return sanitizeNumeric(height, 0, 0, MAX_ROTATED_CENTERED_WATERMARK_OFFSET_HEIGHT_PX) * ROTATED_CENTERED_WATERMARK_TOP_OFFSET_RATIO;
97904
+ }
97905
+ function resolveTextWatermarkMarginOffset({ hPosition, vPosition, hRelativeTo, vRelativeTo, marginLeft, marginTop, width, height, svgWidth, svgHeight, centerOffsetTop, rotation }) {
97906
+ const isCenteredHorizontally = hPosition === "center" && hRelativeTo === "margin";
97907
+ const isCenteredVertically = vPosition === "center" && vRelativeTo === "margin";
97908
+ return {
97909
+ horizontal: isCenteredHorizontally ? 0 : getAbsoluteShapeOffset({
97910
+ position: hPosition,
97911
+ margin: marginLeft,
97912
+ shapeSize: width,
97913
+ svgSize: svgWidth,
97914
+ rotation
97915
+ }),
97916
+ top: isCenteredVertically ? centerOffsetTop : getAbsoluteShapeOffset({
97917
+ position: vPosition,
97918
+ margin: marginTop,
97919
+ shapeSize: height,
97920
+ svgSize: svgHeight,
97921
+ rotation
97922
+ })
97923
+ };
97924
+ }
97925
+ function getAbsoluteShapeOffset({ position: position2, margin, shapeSize, svgSize, rotation }) {
97926
+ if (position2 || rotation === 0)
97927
+ return margin;
97928
+ return margin + shapeSize / 2 - svgSize / 2;
97929
+ }
97930
+ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill, textStyle, fitShape }) {
97931
+ let fontSize = height * 1.12;
97842
97932
  if (textStyle?.fontSize && textStyle.fontSize.trim() !== "1pt") {
97843
97933
  const match = textStyle.fontSize.match(/^([\d.]+)(pt|px)?$/);
97844
97934
  if (match) {
@@ -97847,9 +97937,9 @@ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill,
97847
97937
  }
97848
97938
  }
97849
97939
  fontSize = Math.max(fontSize, 48);
97850
- const color2 = sanitizeColor(fill?.color, "silver");
97851
- const opacity = sanitizeNumeric(fill?.opacity, 0.5, 0, 1);
97852
- const fontFamily = sanitizeFontFamily(textStyle?.fontFamily);
97940
+ const color2 = normalizeVmlColor(sanitizeColor(fill?.color, "silver"));
97941
+ const opacity = sanitizeNumeric(fill?.opacity, DEFAULT_VML_TEXT_WATERMARK_OPACITY, 0, 1);
97942
+ const fontFamily = resolveSvgFontFamily(sanitizeFontFamily(textStyle?.fontFamily));
97853
97943
  const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
97854
97944
  const sanitizedWidth = sanitizeNumeric(width, 100, 1, 1e4);
97855
97945
  const sanitizedHeight = sanitizeNumeric(height, 100, 1, 1e4);
@@ -97863,24 +97953,40 @@ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill,
97863
97953
  const svgHeight = Math.max(sanitizedHeight, rotatedHeight) * 1.1;
97864
97954
  const centerX = svgWidth / 2;
97865
97955
  const centerY = svgHeight / 2;
97866
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${svgWidth}" height="${svgHeight}" viewBox="0 0 ${svgWidth} ${svgHeight}" style="overflow: visible;">
97867
- <text
97868
- x="${centerX}"
97869
- y="${centerY}"
97870
- text-anchor="middle"
97871
- dominant-baseline="middle"
97872
- font-family="${fontFamily}"
97873
- font-size="${sanitizedFontSize}px"
97874
- fill="${color2}"
97875
- opacity="${opacity}"
97876
- transform="rotate(${sanitizedRotation} ${centerX} ${centerY})">${escapeXml(text$2)}</text>
97877
- </svg>`;
97878
97956
  return {
97879
- dataUri: `data:image/svg+xml,${encodeURIComponent(svg)}`,
97957
+ dataUri: `data:image/svg+xml;base64,${encodeUtf8Base64(`<svg xmlns="http://www.w3.org/2000/svg" width="${svgWidth}" height="${svgHeight}" viewBox="0 0 ${svgWidth} ${svgHeight}" style="overflow: visible;">
97958
+ <text ${[
97959
+ `x="${centerX}"`,
97960
+ `y="${centerY}"`,
97961
+ 'text-anchor="middle"',
97962
+ 'dominant-baseline="middle"',
97963
+ `font-family="${fontFamily}"`,
97964
+ `font-size="${sanitizedFontSize}px"`,
97965
+ ...fitShape ? [`textLength="${sanitizedWidth}"`, 'lengthAdjust="spacingAndGlyphs"'] : [],
97966
+ `fill="${color2}"`,
97967
+ `fill-opacity="${opacity}"`,
97968
+ `transform="rotate(${sanitizedRotation} ${centerX} ${centerY})"`
97969
+ ].map((attribute) => ` ${attribute}`).join(`
97970
+ `)}>${escapeXml(text$2)}</text>
97971
+ </svg>`)}`,
97880
97972
  svgWidth,
97881
97973
  svgHeight
97882
97974
  };
97883
97975
  }
97976
+ function resolveSvgFontFamily(fontFamily) {
97977
+ if (!fontFamily || typeof fontFamily !== "string")
97978
+ return "Arial, sans-serif";
97979
+ const normalized = fontFamily.trim();
97980
+ if (normalized.includes(","))
97981
+ return normalized;
97982
+ return `${normalized}, ${new Set([
97983
+ "cambria",
97984
+ "constantia",
97985
+ "georgia",
97986
+ "times new roman",
97987
+ "times"
97988
+ ]).has(normalized.toLowerCase()) ? "serif" : "Arial, sans-serif"}`;
97989
+ }
97884
97990
  function escapeXml(text$2) {
97885
97991
  return text$2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
97886
97992
  }
@@ -97888,7 +97994,7 @@ function parseVmlStyle(style) {
97888
97994
  const result = {};
97889
97995
  if (!style)
97890
97996
  return result;
97891
- const declarations = style.split(";").filter((s) => s.trim());
97997
+ const declarations = decodeXmlEntities(style).split(";").filter((s) => s.trim());
97892
97998
  for (const decl of declarations) {
97893
97999
  const colonIndex = decl.indexOf(":");
97894
98000
  if (colonIndex === -1)
@@ -120688,7 +120794,7 @@ var isRegExp = (value) => {
120688
120794
  if (!settings)
120689
120795
  return false;
120690
120796
  return resolveEvenAndOddHeadersFromSettingsPart(settings) ?? false;
120691
- }, FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT = 1.33, XML_NODE_NAME = "w:pict", SD_NODE_NAME, validXmlAttributes, config, translator$29, DEFAULT_SECTION_PROPS_TWIPS, ensureSectionLayoutDefaults = (sectPr, converter) => {
120797
+ }, ROTATED_CENTERED_WATERMARK_TOP_OFFSET_RATIO = 0.25, MAX_ROTATED_CENTERED_WATERMARK_OFFSET_HEIGHT_PX = 1e4, DEFAULT_VML_TEXT_WATERMARK_OPACITY = 1, DEFAULT_VML_TEXT_WATERMARK_ALIGNMENT = "center", FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT = 1.33, XML_NODE_NAME = "w:pict", SD_NODE_NAME, validXmlAttributes, config, translator$29, DEFAULT_SECTION_PROPS_TWIPS, ensureSectionLayoutDefaults = (sectPr, converter) => {
120692
120798
  if (!sectPr)
120693
120799
  return {
120694
120800
  type: "element",
@@ -121569,7 +121675,7 @@ var isRegExp = (value) => {
121569
121675
  state.kern = kernNode.attributes["w:val"];
121570
121676
  }
121571
121677
  }, SuperConverter;
121572
- var init_SuperConverter_opYK_HD4_es = __esm(() => {
121678
+ var init_SuperConverter_zMJ6NmqZ_es = __esm(() => {
121573
121679
  init_rolldown_runtime_Bg48TavK_es();
121574
121680
  init_jszip_C49i9kUs_es();
121575
121681
  init_xml_js_CqGKpaft_es();
@@ -159749,7 +159855,7 @@ var init_SuperConverter_opYK_HD4_es = __esm(() => {
159749
159855
  };
159750
159856
  });
159751
159857
 
159752
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-xjqjtPWl.es.js
159858
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CoZdlJbj.es.js
159753
159859
  function parseSizeUnit(val = "0") {
159754
159860
  const length3 = val.toString() || "0";
159755
159861
  const value = Number.parseFloat(length3);
@@ -167548,6 +167654,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
167548
167654
  const src = node3.attrs?.src;
167549
167655
  if (typeof src !== "string" || src.length === 0)
167550
167656
  return false;
167657
+ if (node3.attrs?.vmlTextWatermark)
167658
+ return false;
167551
167659
  if (src.startsWith("word/media"))
167552
167660
  return false;
167553
167661
  if (src.startsWith("data:") && node3.attrs?.rId)
@@ -169772,8 +169880,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
169772
169880
  }
169773
169881
  };
169774
169882
  };
169775
- var init_create_headless_toolbar_xjqjtPWl_es = __esm(() => {
169776
- init_SuperConverter_opYK_HD4_es();
169883
+ var init_create_headless_toolbar_CoZdlJbj_es = __esm(() => {
169884
+ init_SuperConverter_zMJ6NmqZ_es();
169777
169885
  init_uuid_qzgm05fK_es();
169778
169886
  init_constants_DrU4EASo_es();
169779
169887
  init_dist_B8HfvhaK_es();
@@ -173202,7 +173310,7 @@ var require_decode_codepoint = __commonJS((exports) => {
173202
173310
  Object.defineProperty(exports, "__esModule", { value: true });
173203
173311
  exports.fromCodePoint = undefined;
173204
173312
  exports.replaceCodePoint = replaceCodePoint;
173205
- exports.decodeCodePoint = decodeCodePoint;
173313
+ exports.decodeCodePoint = decodeCodePoint2;
173206
173314
  var decodeMap = new Map([
173207
173315
  [0, 65533],
173208
173316
  [128, 8364],
@@ -173250,7 +173358,7 @@ var require_decode_codepoint = __commonJS((exports) => {
173250
173358
  }
173251
173359
  return (_a2 = decodeMap.get(codePoint)) !== null && _a2 !== undefined ? _a2 : codePoint;
173252
173360
  }
173253
- function decodeCodePoint(codePoint) {
173361
+ function decodeCodePoint2(codePoint) {
173254
173362
  return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
173255
173363
  }
173256
173364
  });
@@ -218978,7 +219086,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
218978
219086
  init_remark_gfm_BhnWr3yf_es();
218979
219087
  });
218980
219088
 
218981
- // ../../packages/superdoc/dist/chunks/src-CZSemHps.es.js
219089
+ // ../../packages/superdoc/dist/chunks/src-QKGB098Q.es.js
218982
219090
  function deleteProps(obj, propOrProps) {
218983
219091
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
218984
219092
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -295772,7 +295880,7 @@ menclose::after {
295772
295880
  menclose.setAttribute("notation", notations.join(" "));
295773
295881
  menclose.appendChild(innerMrow);
295774
295882
  return menclose;
295775
- }, MATHML_NS = "http://www.w3.org/1998/Math/MathML", MATH_OBJECT_REGISTRY, ARGUMENT_ELEMENTS, resolveOrBuildFragmentIdentity = (fragment2, story, existing) => buildLayoutSourceIdentityForFragment(existing ? {
295883
+ }, MATHML_NS = "http://www.w3.org/1998/Math/MathML", MATH_OBJECT_REGISTRY, ARGUMENT_ELEMENTS, ACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY = "1", INACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY = "0.5", resolveOrBuildFragmentIdentity = (fragment2, story, existing) => buildLayoutSourceIdentityForFragment(existing ? {
295776
295884
  ...fragment2,
295777
295885
  layoutSourceIdentity: existing,
295778
295886
  sourceAnchor: fragment2.sourceAnchor ?? existing.sourceAnchor
@@ -306337,6 +306445,8 @@ menclose::after {
306337
306445
  this.#emitModeChanged();
306338
306446
  this.#emitEditingContext(editor);
306339
306447
  this.#deps?.notifyInputBridgeTargetChanged();
306448
+ this.#deps?.setPendingDocChange();
306449
+ this.#deps?.scheduleRerender();
306340
306450
  return editor;
306341
306451
  } catch (error3) {
306342
306452
  console.error("[HeaderFooterSessionManager] Unexpected error in enterMode:", error3);
@@ -306452,6 +306562,13 @@ menclose::after {
306452
306562
  this.#updateModeBanner();
306453
306563
  this.#syncActiveBorder();
306454
306564
  }
306565
+ #isActiveDecoration(kind, headerFooterRefId, pageNumber) {
306566
+ if (this.#session.mode !== kind)
306567
+ return false;
306568
+ if (headerFooterRefId && this.#session.headerFooterRefId)
306569
+ return headerFooterRefId === this.#session.headerFooterRefId;
306570
+ return this.#session.pageNumber === pageNumber;
306571
+ }
306455
306572
  #emitEditingContext(editor) {
306456
306573
  this.#callbacks.onEditingContext?.({
306457
306574
  kind: this.#session.mode,
@@ -307139,9 +307256,12 @@ menclose::after {
307139
307256
  const rawLayoutHeight$1 = rIdLayout.layout.height ?? 0;
307140
307257
  const metrics$1 = this.#computeMetrics(kind, rawLayoutHeight$1, box$1, pageHeight$1, margins$1?.footer ?? 0);
307141
307258
  const layoutMinY$1 = rIdLayout.layout.minY ?? 0;
307259
+ const normalizedFragments$1 = normalizeDecorationFragments(fragments$1, layoutMinY$1);
307260
+ const normalizedItems$1 = normalizeDecorationItems(alignedItems, layoutMinY$1);
307261
+ const isActiveHeaderFooter$1 = this.#isActiveDecoration(kind, sectionRId, pageNumber);
307142
307262
  return {
307143
- fragments: normalizeDecorationFragments(fragments$1, layoutMinY$1),
307144
- items: normalizeDecorationItems(alignedItems, layoutMinY$1),
307263
+ fragments: normalizedFragments$1,
307264
+ items: normalizedItems$1,
307145
307265
  height: metrics$1.containerHeight,
307146
307266
  contentHeight: metrics$1.layoutHeight > 0 ? metrics$1.layoutHeight : metrics$1.containerHeight,
307147
307267
  offset: metrics$1.offset,
@@ -307149,6 +307269,7 @@ menclose::after {
307149
307269
  contentWidth: effectiveWidth,
307150
307270
  headerFooterRefId: sectionRId,
307151
307271
  sectionType: headerFooterType,
307272
+ isActiveHeaderFooter: isActiveHeaderFooter$1,
307152
307273
  minY: layoutMinY$1,
307153
307274
  box: {
307154
307275
  x: box$1.x,
@@ -307189,9 +307310,12 @@ menclose::after {
307189
307310
  const rawLayoutHeight = variant.layout.height ?? 0;
307190
307311
  const metrics = this.#computeMetrics(kind, rawLayoutHeight, box, pageHeight, margins?.footer ?? 0);
307191
307312
  const layoutMinY = variant.layout.minY ?? 0;
307313
+ const normalizedFragments = normalizeDecorationFragments(fragments, layoutMinY);
307314
+ const normalizedItems = normalizeDecorationItems(alignedVariantItems, layoutMinY);
307315
+ const isActiveHeaderFooter = this.#isActiveDecoration(kind, finalHeaderId, pageNumber);
307192
307316
  return {
307193
- fragments: normalizeDecorationFragments(fragments, layoutMinY),
307194
- items: normalizeDecorationItems(alignedVariantItems, layoutMinY),
307317
+ fragments: normalizedFragments,
307318
+ items: normalizedItems,
307195
307319
  height: metrics.containerHeight,
307196
307320
  contentHeight: metrics.layoutHeight > 0 ? metrics.layoutHeight : metrics.containerHeight,
307197
307321
  offset: metrics.offset,
@@ -307199,6 +307323,7 @@ menclose::after {
307199
307323
  contentWidth: box.width,
307200
307324
  headerFooterRefId: finalHeaderId,
307201
307325
  sectionType: headerFooterType,
307326
+ isActiveHeaderFooter,
307202
307327
  minY: layoutMinY,
307203
307328
  box: {
307204
307329
  x: box.x,
@@ -307489,13 +307614,13 @@ menclose::after {
307489
307614
  return;
307490
307615
  console.log(...args$1);
307491
307616
  }, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
307492
- var init_src_CZSemHps_es = __esm(() => {
307617
+ var init_src_QKGB098Q_es = __esm(() => {
307493
307618
  init_rolldown_runtime_Bg48TavK_es();
307494
- init_SuperConverter_opYK_HD4_es();
307619
+ init_SuperConverter_zMJ6NmqZ_es();
307495
307620
  init_jszip_C49i9kUs_es();
307496
307621
  init_xml_js_CqGKpaft_es();
307497
307622
  init_uuid_qzgm05fK_es();
307498
- init_create_headless_toolbar_xjqjtPWl_es();
307623
+ init_create_headless_toolbar_CoZdlJbj_es();
307499
307624
  init_constants_DrU4EASo_es();
307500
307625
  init_dist_B8HfvhaK_es();
307501
307626
  init_unified_Dsuw2be5_es();
@@ -313359,8 +313484,16 @@ ${err.toString()}`);
313359
313484
  },
313360
313485
  isAnchor: { rendered: false },
313361
313486
  vmlWatermark: { rendered: false },
313487
+ vmlTextWatermark: { rendered: false },
313488
+ textWatermarkData: { rendered: false },
313489
+ vmlStyle: { rendered: false },
313362
313490
  vmlAttributes: { rendered: false },
313363
313491
  vmlImagedata: { rendered: false },
313492
+ vmlTextpathAttributes: { rendered: false },
313493
+ vmlPathAttributes: { rendered: false },
313494
+ vmlFillAttributes: { rendered: false },
313495
+ vmlStrokeAttributes: { rendered: false },
313496
+ vmlWrapAttributes: { rendered: false },
313364
313497
  transformData: {
313365
313498
  default: {},
313366
313499
  renderDOM: ({ transformData }) => {
@@ -334878,6 +335011,7 @@ function print() { __p += __j.call(arguments, '') }
334878
335011
  behindDocFragments.forEach(({ fragment: fragment2, originalIndex }) => {
334879
335012
  const resolvedItem = data.items?.[originalIndex];
334880
335013
  const fragEl = this.renderFragment(fragment2, context, undefined, betweenBorderFlags.get(originalIndex), resolvedItem);
335014
+ this.applyHeaderFooterTextWatermarkPreviewOpacity(fragEl, data.isActiveHeaderFooter === true);
334881
335015
  const isPageRelative = this.isPageRelativeAnchoredFragment(fragment2, resolvedItem);
334882
335016
  let pageY;
334883
335017
  if (isPageRelative && kind === "footer")
@@ -334895,6 +335029,7 @@ function print() { __p += __j.call(arguments, '') }
334895
335029
  normalFragments.forEach(({ fragment: fragment2, originalIndex }) => {
334896
335030
  const resolvedItem = data.items?.[originalIndex];
334897
335031
  const fragEl = this.renderFragment(fragment2, context, undefined, betweenBorderFlags.get(originalIndex), resolvedItem);
335032
+ this.applyHeaderFooterTextWatermarkPreviewOpacity(fragEl, data.isActiveHeaderFooter === true);
334898
335033
  const isPageRelative = this.isPageRelativeAnchoredFragment(fragment2, resolvedItem);
334899
335034
  if (isPageRelative && kind === "footer")
334900
335035
  fragEl.style.top = `${fragment2.y + footerAnchorContainerOffsetY}px`;
@@ -335649,6 +335784,8 @@ function print() { __p += __j.call(arguments, '') }
335649
335784
  }
335650
335785
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
335651
335786
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
335787
+ if (this.isVmlTextWatermarkImage(block))
335788
+ fragmentEl.dataset.vmlTextWatermark = "true";
335652
335789
  if (block.id)
335653
335790
  fragmentEl.setAttribute("data-sd-block-id", block.id);
335654
335791
  const imgPmStart = resolvedItem?.pmStart;
@@ -337736,7 +337873,11 @@ function print() { __p += __j.call(arguments, '') }
337736
337873
  shouldRenderBehindPageContent(fragment2, section, resolvedItem) {
337737
337874
  if (fragment2.behindDoc === true || fragment2.behindDoc == null && "zIndex" in fragment2 && fragment2.zIndex === 0)
337738
337875
  return true;
337739
- return section === "header" && fragment2.kind === "drawing" && this.isHeaderWordArtWatermark(resolvedItem?.block);
337876
+ if (section !== "header")
337877
+ return false;
337878
+ if (fragment2.kind === "drawing")
337879
+ return this.isHeaderWordArtWatermark(resolvedItem?.block);
337880
+ return this.isVmlTextWatermarkImage(resolvedItem?.block);
337740
337881
  }
337741
337882
  isHeaderWordArtWatermark(block) {
337742
337883
  if (!block || block.kind !== "drawing" || block.drawingKind !== "vectorShape")
@@ -337745,6 +337886,14 @@ function print() { __p += __j.call(arguments, '') }
337745
337886
  const hasTextContent = Array.isArray(block.textContent?.parts) && block.textContent.parts.length > 0;
337746
337887
  return attrs.isWordArt === true && attrs.isTextBox === true && hasTextContent && block.anchor?.isAnchored === true && block.anchor.hRelativeFrom === "page" && block.anchor.alignH === "center" && block.anchor.vRelativeFrom === "page" && block.anchor.alignV === "center" && block.wrap?.type === "None";
337747
337888
  }
337889
+ isVmlTextWatermarkImage(block) {
337890
+ return block?.kind === "image" && block.attrs?.vmlTextWatermark === true;
337891
+ }
337892
+ applyHeaderFooterTextWatermarkPreviewOpacity(el, isActiveHeaderFooter) {
337893
+ if (el.dataset.vmlTextWatermark !== "true")
337894
+ return;
337895
+ el.style.opacity = isActiveHeaderFooter ? ACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY : INACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY;
337896
+ }
337748
337897
  resolveFragmentWrapperZIndex(fragment2, resolvedZIndex) {
337749
337898
  if (!this.isAnchoredMediaFragment(fragment2))
337750
337899
  return "";
@@ -345268,11 +345417,11 @@ function print() { __p += __j.call(arguments, '') }
345268
345417
  ];
345269
345418
  });
345270
345419
 
345271
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DqYtj3Jy.es.js
345420
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DM_6uPhc.es.js
345272
345421
  var MOD_ALIASES, ALT_ALIASES, CTRL_ALIASES, SHIFT_ALIASES, BUILTIN_CONTEXT_MENU_GROUPS, BUILTIN_GROUP_ORDER, RESERVED_PROXY_PROPERTY_NAMES, ALL_TOOLBAR_COMMAND_IDS, EMPTY_ACTIVE_IDS;
345273
- var init_create_super_doc_ui_DqYtj3Jy_es = __esm(() => {
345274
- init_SuperConverter_opYK_HD4_es();
345275
- init_create_headless_toolbar_xjqjtPWl_es();
345422
+ var init_create_super_doc_ui_DM_6uPhc_es = __esm(() => {
345423
+ init_SuperConverter_zMJ6NmqZ_es();
345424
+ init_create_headless_toolbar_CoZdlJbj_es();
345276
345425
  MOD_ALIASES = new Set([
345277
345426
  "Mod",
345278
345427
  "Meta",
@@ -345314,16 +345463,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
345314
345463
 
345315
345464
  // ../../packages/superdoc/dist/super-editor.es.js
345316
345465
  var init_super_editor_es = __esm(() => {
345317
- init_src_CZSemHps_es();
345318
- init_SuperConverter_opYK_HD4_es();
345466
+ init_src_QKGB098Q_es();
345467
+ init_SuperConverter_zMJ6NmqZ_es();
345319
345468
  init_jszip_C49i9kUs_es();
345320
345469
  init_xml_js_CqGKpaft_es();
345321
- init_create_headless_toolbar_xjqjtPWl_es();
345470
+ init_create_headless_toolbar_CoZdlJbj_es();
345322
345471
  init_constants_DrU4EASo_es();
345323
345472
  init_dist_B8HfvhaK_es();
345324
345473
  init_unified_Dsuw2be5_es();
345325
345474
  init_DocxZipper_CZMPWpOp_es();
345326
- init_create_super_doc_ui_DqYtj3Jy_es();
345475
+ init_create_super_doc_ui_DM_6uPhc_es();
345327
345476
  init_ui_C5PAS9hY_es();
345328
345477
  init_eventemitter3_BnGqBE_Q_es();
345329
345478
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.13.0-next.1",
3
+ "version": "0.13.0-next.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,21 +24,21 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
- "@superdoc/pm-adapter": "0.0.0",
28
27
  "@superdoc/document-api": "0.0.1",
29
- "@superdoc/super-editor": "0.0.1",
30
- "superdoc": "1.35.0"
28
+ "@superdoc/pm-adapter": "0.0.0",
29
+ "superdoc": "1.35.0",
30
+ "@superdoc/super-editor": "0.0.1"
31
31
  },
32
32
  "module": "src/index.ts",
33
33
  "publishConfig": {
34
34
  "access": "public"
35
35
  },
36
36
  "optionalDependencies": {
37
- "@superdoc-dev/cli-darwin-arm64": "0.13.0-next.1",
38
- "@superdoc-dev/cli-darwin-x64": "0.13.0-next.1",
39
- "@superdoc-dev/cli-linux-x64": "0.13.0-next.1",
40
- "@superdoc-dev/cli-windows-x64": "0.13.0-next.1",
41
- "@superdoc-dev/cli-linux-arm64": "0.13.0-next.1"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.13.0-next.2",
38
+ "@superdoc-dev/cli-darwin-x64": "0.13.0-next.2",
39
+ "@superdoc-dev/cli-windows-x64": "0.13.0-next.2",
40
+ "@superdoc-dev/cli-linux-x64": "0.13.0-next.2",
41
+ "@superdoc-dev/cli-linux-arm64": "0.13.0-next.2"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",