@superdoc-dev/cli 0.12.1-next.9 → 0.13.0-next.10

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 +444 -128
  2. package/package.json +8 -8
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-k7GHkV-c.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")
@@ -76728,6 +76728,10 @@ function resolveRunProperties(params3, inlineRpr, resolvedPpr, tableInfo = null,
76728
76728
  inlineRpr = {};
76729
76729
  if (inlineRpr?.underline)
76730
76730
  delete inlineRpr.underline;
76731
+ if (inlineRpr?.vanish)
76732
+ delete inlineRpr.vanish;
76733
+ if (inlineRpr?.specVanish)
76734
+ delete inlineRpr.specVanish;
76731
76735
  styleChain = [
76732
76736
  ...defaultsChain,
76733
76737
  tableStyleProps,
@@ -89268,6 +89272,36 @@ function updateSectionMargins(target, updates = {}) {
89268
89272
  }
89269
89273
  throw new Error(`updateSectionMargins: unsupported target type: ${target.type}`);
89270
89274
  }
89275
+ function binaryStringToBase64(binary) {
89276
+ if (typeof globalThis.btoa === "function")
89277
+ return globalThis.btoa(binary);
89278
+ if (typeof Buffer3 !== "undefined")
89279
+ return Buffer3.from(binary, "latin1").toString("base64");
89280
+ throw new Error("[base64] encode requires btoa (browser) or Buffer (Node)");
89281
+ }
89282
+ function base64ToBinaryString(b64) {
89283
+ if (typeof globalThis.atob === "function")
89284
+ return globalThis.atob(b64);
89285
+ if (typeof Buffer3 !== "undefined")
89286
+ return Buffer3.from(b64, "base64").toString("latin1");
89287
+ throw new Error("[base64] decode requires atob (browser) or Buffer (Node)");
89288
+ }
89289
+ function encodeUtf8Base64(input) {
89290
+ return binaryStringToBase64(encodeURIComponent(input).replace(/%([0-9A-F]{2})/g, (_, hex) => String.fromCharCode(parseInt(hex, 16))));
89291
+ }
89292
+ function decodeUtf8Base64(b64) {
89293
+ if (!b64)
89294
+ return "";
89295
+ try {
89296
+ const bin = base64ToBinaryString(b64);
89297
+ let pct = "";
89298
+ for (let i$1 = 0;i$1 < bin.length; i$1 += 1)
89299
+ pct += `%${bin.charCodeAt(i$1).toString(16).padStart(2, "0")}`;
89300
+ return decodeURIComponent(pct);
89301
+ } catch {
89302
+ return "";
89303
+ }
89304
+ }
89271
89305
  function collectReferencedImageMediaForClipboard(sliceJsonString, editor) {
89272
89306
  if (!sliceJsonString || !editor?.storage?.image?.media)
89273
89307
  return "";
@@ -89402,36 +89436,6 @@ function applySuperdocClipboardMedia(editor, clipboardData, sliceJson = null, me
89402
89436
  }
89403
89437
  return outSlice;
89404
89438
  }
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
89439
  function bodySectPrShouldEmbed(bodySectPr) {
89436
89440
  if (!bodySectPr || typeof bodySectPr !== "object")
89437
89441
  return false;
@@ -96258,6 +96262,33 @@ function _getReferencedTableStyles(tableStyleReference, params3) {
96258
96262
  ...styleProps
96259
96263
  };
96260
96264
  }
96265
+ function buildFieldResultRuns(params3, outputMarks) {
96266
+ const { node: node3 } = params3;
96267
+ const contentNodes = (node3.content ?? []).flatMap((child) => exportSchemaToJson({
96268
+ ...params3,
96269
+ node: child
96270
+ }));
96271
+ if (contentNodes.length > 0)
96272
+ return contentNodes;
96273
+ const resolvedText = node3.attrs?.resolvedText;
96274
+ if (typeof resolvedText !== "string" || resolvedText.length === 0)
96275
+ return [];
96276
+ const textAttributes = /^\s|\s$/.test(resolvedText) ? { "xml:space": "preserve" } : undefined;
96277
+ return [{
96278
+ name: "w:r",
96279
+ elements: [{
96280
+ name: "w:rPr",
96281
+ elements: outputMarks
96282
+ }, {
96283
+ name: "w:t",
96284
+ attributes: textAttributes,
96285
+ elements: [{
96286
+ text: resolvedText,
96287
+ type: "text"
96288
+ }]
96289
+ }]
96290
+ }];
96291
+ }
96261
96292
  function parseTarget(instruction) {
96262
96293
  if (!instruction)
96263
96294
  return "";
@@ -96311,7 +96342,19 @@ function parseCitationSourceIds(instruction) {
96311
96342
  function extractResolvedText$1(content$2) {
96312
96343
  if (!Array.isArray(content$2))
96313
96344
  return "";
96314
- return content$2.filter((n) => n.type === "text").map((n) => n.text || "").join("");
96345
+ let out = "";
96346
+ const walk = (nodes) => {
96347
+ for (const node3 of nodes) {
96348
+ if (!node3)
96349
+ continue;
96350
+ if (node3.type === "text")
96351
+ out += node3.text || "";
96352
+ else if (Array.isArray(node3.content))
96353
+ walk(node3.content);
96354
+ }
96355
+ };
96356
+ walk(content$2);
96357
+ return out;
96315
96358
  }
96316
96359
  function parseTaInstruction(instruction) {
96317
96360
  let longCitation = "";
@@ -97709,8 +97752,12 @@ function handleShapeTextWatermarkImport({ pict }) {
97709
97752
  marginTop: styleObj["margin-top"] || "0"
97710
97753
  };
97711
97754
  const rotation = parseFloat(styleObj.rotation) || 0;
97712
- const hPosition = styleObj["mso-position-horizontal"] || "center";
97713
- const vPosition = styleObj["mso-position-vertical"] || "center";
97755
+ const explicitHPosition = styleObj["mso-position-horizontal"];
97756
+ const explicitVPosition = styleObj["mso-position-vertical"];
97757
+ const hasExplicitMarginLeft = styleObj["margin-left"] != null;
97758
+ const hasExplicitMarginTop = styleObj["margin-top"] != null;
97759
+ const hPosition = explicitHPosition || (hasExplicitMarginLeft ? undefined : DEFAULT_VML_TEXT_WATERMARK_ALIGNMENT);
97760
+ const vPosition = explicitVPosition || (hasExplicitMarginTop ? undefined : DEFAULT_VML_TEXT_WATERMARK_ALIGNMENT);
97714
97761
  const hRelativeTo = styleObj["mso-position-horizontal-relative"] || "margin";
97715
97762
  const vRelativeTo = styleObj["mso-position-vertical-relative"] || "margin";
97716
97763
  const textAnchor = styleObj["v-text-anchor"] || "middle";
@@ -97719,7 +97766,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97719
97766
  const rawFillColor2 = fillAttrs.color2 || "#3f3f3f";
97720
97767
  const fillColor = sanitizeColor(rawFillColor, "silver");
97721
97768
  const fillColor2 = sanitizeColor(rawFillColor2, "#3f3f3f");
97722
- const opacity = fillAttrs.opacity || "0.5";
97769
+ const opacity = fillAttrs.opacity ?? String(DEFAULT_VML_TEXT_WATERMARK_OPACITY);
97723
97770
  const fillType = fillAttrs.type || "solid";
97724
97771
  const strokeAttrs = shape.elements?.find((el) => el.name === "v:stroke")?.attributes || {};
97725
97772
  const stroked = shapeAttrs.stroked || "f";
@@ -97727,10 +97774,9 @@ function handleShapeTextWatermarkImport({ pict }) {
97727
97774
  const strokeJoinstyle = strokeAttrs.joinstyle || "round";
97728
97775
  const strokeEndcap = strokeAttrs.endcap || "flat";
97729
97776
  const textStyleObj = parseVmlStyle(textpathAttrs.style || "");
97730
- const rawFontFamily = textStyleObj["font-family"]?.replace(/['"]/g, "");
97731
- const fontFamily = sanitizeFontFamily(rawFontFamily);
97777
+ const fontFamily = sanitizeFontFamily(decodeXmlEntities(textStyleObj["font-family"] || "").replace(/['"]/g, ""));
97732
97778
  const fontSize = textStyleObj["font-size"] || "1pt";
97733
- const fitshape = textpathAttrs.fitshape || "t";
97779
+ const shouldFitShape = (textpathAttrs.fitshape || "t") === "t";
97734
97780
  const trim = textpathAttrs.trim || "t";
97735
97781
  const textpathOn = textpathAttrs.on || "t";
97736
97782
  const pathAttrs = shape.elements?.find((el) => el.name === "v:path")?.attributes || {};
@@ -97739,7 +97785,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97739
97785
  const wrapType = wrapAttrs.type || "none";
97740
97786
  const widthPx = convertToPixels(width);
97741
97787
  const heightPx = convertToPixels(height);
97742
- const sanitizedOpacity = sanitizeNumeric(parseFloat(opacity), 0.5, 0, 1);
97788
+ const sanitizedOpacity = sanitizeNumeric(parseVmlOpacity(opacity), DEFAULT_VML_TEXT_WATERMARK_OPACITY, 0, 1);
97743
97789
  const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
97744
97790
  const svgResult = generateTextWatermarkSVG({
97745
97791
  text: watermarkText,
@@ -97753,12 +97799,44 @@ function handleShapeTextWatermarkImport({ pict }) {
97753
97799
  textStyle: {
97754
97800
  fontFamily,
97755
97801
  fontSize
97756
- }
97802
+ },
97803
+ fitShape: shouldFitShape
97757
97804
  });
97805
+ const svgDataUri = svgResult.dataUri;
97806
+ const centerOffsetTop = getTextWatermarkCenterOffset({
97807
+ hPosition,
97808
+ vPosition,
97809
+ hRelativeTo,
97810
+ vRelativeTo,
97811
+ height: heightPx,
97812
+ rotation: sanitizedRotation
97813
+ });
97814
+ const marginOffset = resolveTextWatermarkMarginOffset({
97815
+ hPosition,
97816
+ vPosition,
97817
+ hRelativeTo,
97818
+ vRelativeTo,
97819
+ marginLeft: convertToPixels(position2.marginLeft),
97820
+ marginTop: convertToPixels(position2.marginTop),
97821
+ width: widthPx,
97822
+ height: heightPx,
97823
+ svgWidth: svgResult.svgWidth,
97824
+ svgHeight: svgResult.svgHeight,
97825
+ centerOffsetTop,
97826
+ rotation: sanitizedRotation
97827
+ });
97828
+ const anchorData = {
97829
+ hRelativeFrom: hRelativeTo,
97830
+ vRelativeFrom: vRelativeTo
97831
+ };
97832
+ if (hPosition)
97833
+ anchorData.alignH = hPosition;
97834
+ if (vPosition)
97835
+ anchorData.alignV = vPosition;
97758
97836
  return {
97759
97837
  type: "image",
97760
97838
  attrs: {
97761
- src: svgResult.dataUri,
97839
+ src: svgDataUri,
97762
97840
  alt: watermarkText,
97763
97841
  title: watermarkText,
97764
97842
  extension: "svg",
@@ -97777,20 +97855,12 @@ function handleShapeTextWatermarkImport({ pict }) {
97777
97855
  type: wrapType === "none" ? "None" : wrapType,
97778
97856
  attrs: { behindDoc: true }
97779
97857
  },
97780
- anchorData: {
97781
- hRelativeFrom: hRelativeTo,
97782
- vRelativeFrom: vRelativeTo,
97783
- alignH: hPosition,
97784
- alignV: vPosition
97785
- },
97858
+ anchorData,
97786
97859
  size: {
97787
97860
  width: svgResult.svgWidth,
97788
97861
  height: svgResult.svgHeight
97789
97862
  },
97790
- marginOffset: {
97791
- horizontal: hPosition === "center" && hRelativeTo === "margin" ? 0 : convertToPixels(position2.marginLeft),
97792
- top: vPosition === "center" && vRelativeTo === "margin" ? 0 : convertToPixels(position2.marginTop)
97793
- },
97863
+ marginOffset,
97794
97864
  textWatermarkData: {
97795
97865
  text: watermarkText,
97796
97866
  rotation: sanitizedRotation,
@@ -97813,7 +97883,7 @@ function handleShapeTextWatermarkImport({ pict }) {
97813
97883
  },
97814
97884
  textpath: {
97815
97885
  on: textpathOn === "t",
97816
- fitshape: fitshape === "t",
97886
+ fitshape: shouldFitShape,
97817
97887
  trim: trim === "t",
97818
97888
  textpathok: textpathok === "t"
97819
97889
  }
@@ -97824,21 +97894,84 @@ function handleShapeTextWatermarkImport({ pict }) {
97824
97894
  function sanitizeFontFamily(fontFamily) {
97825
97895
  if (!fontFamily || typeof fontFamily !== "string")
97826
97896
  return "Arial";
97827
- return fontFamily.replace(/[^a-zA-Z0-9\s,\-]/g, "").trim() || "Arial";
97897
+ return fontFamily.replace(/[^a-zA-Z0-9\s,-]/g, "").trim() || "Arial";
97828
97898
  }
97829
97899
  function sanitizeColor(color2, defaultColor = "silver") {
97830
97900
  if (!color2 || typeof color2 !== "string")
97831
97901
  return defaultColor;
97832
97902
  return color2.replace(/[^a-zA-Z0-9#%(),.]/g, "").trim() || defaultColor;
97833
97903
  }
97904
+ function normalizeVmlColor(color2) {
97905
+ return {
97906
+ black: "#000000",
97907
+ blue: "#0000FF",
97908
+ gray: "#808080",
97909
+ green: "#008000",
97910
+ lime: "#00FF00",
97911
+ red: "#FF0000",
97912
+ silver: "#C0C0C0",
97913
+ white: "#FFFFFF",
97914
+ yellow: "#FFFF00"
97915
+ }[typeof color2 === "string" ? color2.trim().toLowerCase() : ""] || color2;
97916
+ }
97917
+ function decodeXmlEntities(value) {
97918
+ 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)));
97919
+ }
97920
+ function decodeCodePoint(codePoint) {
97921
+ if (!Number.isInteger(codePoint) || codePoint < 0 || codePoint > 1114111)
97922
+ return "";
97923
+ return String.fromCodePoint(codePoint);
97924
+ }
97834
97925
  function sanitizeNumeric(value, defaultValue, min4 = -Infinity, max4 = Infinity) {
97835
97926
  const num = typeof value === "number" ? value : parseFloat(value);
97836
97927
  if (isNaN(num) || !isFinite(num))
97837
97928
  return defaultValue;
97838
97929
  return Math.max(min4, Math.min(max4, num));
97839
97930
  }
97840
- function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill, textStyle }) {
97841
- let fontSize = height * 0.9;
97931
+ function parseVmlOpacity(value) {
97932
+ if (typeof value === "number")
97933
+ return value;
97934
+ if (!value || typeof value !== "string")
97935
+ return NaN;
97936
+ const normalized = value.trim().toLowerCase();
97937
+ if (normalized.endsWith("%"))
97938
+ return Number.parseFloat(normalized.slice(0, -1)) / 100;
97939
+ if (normalized.endsWith("f"))
97940
+ return Number.parseInt(normalized.slice(0, -1), 10) / 65536;
97941
+ return Number.parseFloat(normalized);
97942
+ }
97943
+ function getTextWatermarkCenterOffset({ hPosition, vPosition, hRelativeTo, vRelativeTo, height, rotation }) {
97944
+ if (!(hPosition === "center" && vPosition === "center" && hRelativeTo === "margin" && vRelativeTo === "margin") || rotation === 0)
97945
+ return 0;
97946
+ return sanitizeNumeric(height, 0, 0, MAX_ROTATED_CENTERED_WATERMARK_OFFSET_HEIGHT_PX) * ROTATED_CENTERED_WATERMARK_TOP_OFFSET_RATIO;
97947
+ }
97948
+ function resolveTextWatermarkMarginOffset({ hPosition, vPosition, hRelativeTo, vRelativeTo, marginLeft, marginTop, width, height, svgWidth, svgHeight, centerOffsetTop, rotation }) {
97949
+ const isCenteredHorizontally = hPosition === "center" && hRelativeTo === "margin";
97950
+ const isCenteredVertically = vPosition === "center" && vRelativeTo === "margin";
97951
+ return {
97952
+ horizontal: isCenteredHorizontally ? 0 : getAbsoluteShapeOffset({
97953
+ position: hPosition,
97954
+ margin: marginLeft,
97955
+ shapeSize: width,
97956
+ svgSize: svgWidth,
97957
+ rotation
97958
+ }),
97959
+ top: isCenteredVertically ? centerOffsetTop : getAbsoluteShapeOffset({
97960
+ position: vPosition,
97961
+ margin: marginTop,
97962
+ shapeSize: height,
97963
+ svgSize: svgHeight,
97964
+ rotation
97965
+ })
97966
+ };
97967
+ }
97968
+ function getAbsoluteShapeOffset({ position: position2, margin, shapeSize, svgSize, rotation }) {
97969
+ if (position2 || rotation === 0)
97970
+ return margin;
97971
+ return margin + shapeSize / 2 - svgSize / 2;
97972
+ }
97973
+ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill, textStyle, fitShape }) {
97974
+ let fontSize = height * 1.12;
97842
97975
  if (textStyle?.fontSize && textStyle.fontSize.trim() !== "1pt") {
97843
97976
  const match = textStyle.fontSize.match(/^([\d.]+)(pt|px)?$/);
97844
97977
  if (match) {
@@ -97847,9 +97980,9 @@ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill,
97847
97980
  }
97848
97981
  }
97849
97982
  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);
97983
+ const color2 = normalizeVmlColor(sanitizeColor(fill?.color, "silver"));
97984
+ const opacity = sanitizeNumeric(fill?.opacity, DEFAULT_VML_TEXT_WATERMARK_OPACITY, 0, 1);
97985
+ const fontFamily = resolveSvgFontFamily(sanitizeFontFamily(textStyle?.fontFamily));
97853
97986
  const sanitizedRotation = sanitizeNumeric(rotation, 0, -360, 360);
97854
97987
  const sanitizedWidth = sanitizeNumeric(width, 100, 1, 1e4);
97855
97988
  const sanitizedHeight = sanitizeNumeric(height, 100, 1, 1e4);
@@ -97863,24 +97996,40 @@ function generateTextWatermarkSVG({ text: text$2, width, height, rotation, fill,
97863
97996
  const svgHeight = Math.max(sanitizedHeight, rotatedHeight) * 1.1;
97864
97997
  const centerX = svgWidth / 2;
97865
97998
  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
97999
  return {
97879
- dataUri: `data:image/svg+xml,${encodeURIComponent(svg)}`,
98000
+ 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;">
98001
+ <text ${[
98002
+ `x="${centerX}"`,
98003
+ `y="${centerY}"`,
98004
+ 'text-anchor="middle"',
98005
+ 'dominant-baseline="middle"',
98006
+ `font-family="${fontFamily}"`,
98007
+ `font-size="${sanitizedFontSize}px"`,
98008
+ ...fitShape ? [`textLength="${sanitizedWidth}"`, 'lengthAdjust="spacingAndGlyphs"'] : [],
98009
+ `fill="${color2}"`,
98010
+ `fill-opacity="${opacity}"`,
98011
+ `transform="rotate(${sanitizedRotation} ${centerX} ${centerY})"`
98012
+ ].map((attribute) => ` ${attribute}`).join(`
98013
+ `)}>${escapeXml(text$2)}</text>
98014
+ </svg>`)}`,
97880
98015
  svgWidth,
97881
98016
  svgHeight
97882
98017
  };
97883
98018
  }
98019
+ function resolveSvgFontFamily(fontFamily) {
98020
+ if (!fontFamily || typeof fontFamily !== "string")
98021
+ return "Arial, sans-serif";
98022
+ const normalized = fontFamily.trim();
98023
+ if (normalized.includes(","))
98024
+ return normalized;
98025
+ return `${normalized}, ${new Set([
98026
+ "cambria",
98027
+ "constantia",
98028
+ "georgia",
98029
+ "times new roman",
98030
+ "times"
98031
+ ]).has(normalized.toLowerCase()) ? "serif" : "Arial, sans-serif"}`;
98032
+ }
97884
98033
  function escapeXml(text$2) {
97885
98034
  return text$2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
97886
98035
  }
@@ -97888,7 +98037,7 @@ function parseVmlStyle(style) {
97888
98037
  const result = {};
97889
98038
  if (!style)
97890
98039
  return result;
97891
- const declarations = style.split(";").filter((s) => s.trim());
98040
+ const declarations = decodeXmlEntities(style).split(";").filter((s) => s.trim());
97892
98041
  for (const decl of declarations) {
97893
98042
  const colonIndex = decl.indexOf(":");
97894
98043
  if (colonIndex === -1)
@@ -118358,10 +118507,7 @@ var isRegExp = (value) => {
118358
118507
  }, decode$20 = (params3) => {
118359
118508
  const { node: node3 } = params3;
118360
118509
  const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
118361
- const contentNodes = (node3.content ?? []).flatMap((n) => exportSchemaToJson({
118362
- ...params3,
118363
- node: n
118364
- }));
118510
+ const contentNodes = buildFieldResultRuns(params3, outputMarks);
118365
118511
  const instructionElements = buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens);
118366
118512
  return [
118367
118513
  {
@@ -118426,10 +118572,7 @@ var isRegExp = (value) => {
118426
118572
  }, decode$19 = (params3) => {
118427
118573
  const { node: node3 } = params3;
118428
118574
  const outputMarks = processOutputMarks(node3.attrs?.marksAsAttrs || []);
118429
- const contentNodes = (node3.content ?? []).flatMap((n) => exportSchemaToJson({
118430
- ...params3,
118431
- node: n
118432
- }));
118575
+ const contentNodes = buildFieldResultRuns(params3, outputMarks);
118433
118576
  const instructionElements = buildInstructionElements(node3.attrs?.instruction, node3.attrs?.instructionTokens);
118434
118577
  return [
118435
118578
  {
@@ -120688,7 +120831,7 @@ var isRegExp = (value) => {
120688
120831
  if (!settings)
120689
120832
  return false;
120690
120833
  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) => {
120834
+ }, 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
120835
  if (!sectPr)
120693
120836
  return {
120694
120837
  type: "element",
@@ -121569,7 +121712,7 @@ var isRegExp = (value) => {
121569
121712
  state.kern = kernNode.attributes["w:val"];
121570
121713
  }
121571
121714
  }, SuperConverter;
121572
- var init_SuperConverter_opYK_HD4_es = __esm(() => {
121715
+ var init_SuperConverter_k7GHkV_c_es = __esm(() => {
121573
121716
  init_rolldown_runtime_Bg48TavK_es();
121574
121717
  init_jszip_C49i9kUs_es();
121575
121718
  init_xml_js_CqGKpaft_es();
@@ -159749,7 +159892,7 @@ var init_SuperConverter_opYK_HD4_es = __esm(() => {
159749
159892
  };
159750
159893
  });
159751
159894
 
159752
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-xjqjtPWl.es.js
159895
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-dycevpY9.es.js
159753
159896
  function parseSizeUnit(val = "0") {
159754
159897
  const length3 = val.toString() || "0";
159755
159898
  const value = Number.parseFloat(length3);
@@ -167548,6 +167691,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
167548
167691
  const src = node3.attrs?.src;
167549
167692
  if (typeof src !== "string" || src.length === 0)
167550
167693
  return false;
167694
+ if (node3.attrs?.vmlTextWatermark)
167695
+ return false;
167551
167696
  if (src.startsWith("word/media"))
167552
167697
  return false;
167553
167698
  if (src.startsWith("data:") && node3.attrs?.rId)
@@ -169772,8 +169917,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, Extension = class Extension2 {
169772
169917
  }
169773
169918
  };
169774
169919
  };
169775
- var init_create_headless_toolbar_xjqjtPWl_es = __esm(() => {
169776
- init_SuperConverter_opYK_HD4_es();
169920
+ var init_create_headless_toolbar_dycevpY9_es = __esm(() => {
169921
+ init_SuperConverter_k7GHkV_c_es();
169777
169922
  init_uuid_qzgm05fK_es();
169778
169923
  init_constants_DrU4EASo_es();
169779
169924
  init_dist_B8HfvhaK_es();
@@ -173202,7 +173347,7 @@ var require_decode_codepoint = __commonJS((exports) => {
173202
173347
  Object.defineProperty(exports, "__esModule", { value: true });
173203
173348
  exports.fromCodePoint = undefined;
173204
173349
  exports.replaceCodePoint = replaceCodePoint;
173205
- exports.decodeCodePoint = decodeCodePoint;
173350
+ exports.decodeCodePoint = decodeCodePoint2;
173206
173351
  var decodeMap = new Map([
173207
173352
  [0, 65533],
173208
173353
  [128, 8364],
@@ -173250,7 +173395,7 @@ var require_decode_codepoint = __commonJS((exports) => {
173250
173395
  }
173251
173396
  return (_a2 = decodeMap.get(codePoint)) !== null && _a2 !== undefined ? _a2 : codePoint;
173252
173397
  }
173253
- function decodeCodePoint(codePoint) {
173398
+ function decodeCodePoint2(codePoint) {
173254
173399
  return (0, exports.fromCodePoint)(replaceCodePoint(codePoint));
173255
173400
  }
173256
173401
  });
@@ -218978,7 +219123,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
218978
219123
  init_remark_gfm_BhnWr3yf_es();
218979
219124
  });
218980
219125
 
218981
- // ../../packages/superdoc/dist/chunks/src-CZSemHps.es.js
219126
+ // ../../packages/superdoc/dist/chunks/src-CY28yu-i.es.js
218982
219127
  function deleteProps(obj, propOrProps) {
218983
219128
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
218984
219129
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -220865,6 +221010,86 @@ function backfillCapability(metaMap, ydoc) {
220865
221010
  function createReplacer(data) {
220866
221011
  return ({ part }) => replacePartData(part, data);
220867
221012
  }
221013
+ function normalizeYjsFragmentForSchema(fragment2) {
221014
+ if (!isTraversableYjsXml(fragment2))
221015
+ return false;
221016
+ let changed = false;
221017
+ const normalize4 = () => {
221018
+ changed = stripSchemaAtomChildren(fragment2) || changed;
221019
+ };
221020
+ if (fragment2.doc)
221021
+ fragment2.doc.transact(normalize4, NORMALIZE_YJS_FRAGMENT_ORIGIN);
221022
+ else
221023
+ normalize4();
221024
+ return changed;
221025
+ }
221026
+ function normalizeYjsFragmentEventsForSchema(events, fallbackFragment) {
221027
+ if (!Array.isArray(events) || events.length === 0)
221028
+ return normalizeYjsFragmentForSchema(fallbackFragment);
221029
+ if (events.some((event) => event?.transaction?.origin === NORMALIZE_YJS_FRAGMENT_ORIGIN))
221030
+ return false;
221031
+ let changed = false;
221032
+ const normalize4 = () => {
221033
+ const visited = /* @__PURE__ */ new Set;
221034
+ for (const event of events) {
221035
+ const target = findNormalizableEventTarget(event?.target);
221036
+ if (!isTraversableYjsXml(target) || visited.has(target))
221037
+ continue;
221038
+ visited.add(target);
221039
+ changed = stripSchemaAtomChildren(target) || changed;
221040
+ }
221041
+ };
221042
+ const doc$12 = fallbackFragment?.doc || findEventDoc(events);
221043
+ if (doc$12)
221044
+ doc$12.transact(normalize4, NORMALIZE_YJS_FRAGMENT_ORIGIN);
221045
+ else
221046
+ normalize4();
221047
+ return changed;
221048
+ }
221049
+ function stripSchemaAtomChildren(parent) {
221050
+ if (!isTraversableYjsXml(parent))
221051
+ return false;
221052
+ if (parent instanceof YXmlElement && SCHEMA_ATOM_NODE_NAMES.has(parent.nodeName)) {
221053
+ if (parent.length === 0)
221054
+ return false;
221055
+ parent.delete(0, parent.length);
221056
+ return true;
221057
+ }
221058
+ let changed = false;
221059
+ for (const child of parent.toArray()) {
221060
+ if (!(child instanceof YXmlElement))
221061
+ continue;
221062
+ if (SCHEMA_ATOM_NODE_NAMES.has(child.nodeName)) {
221063
+ if (child.length > 0) {
221064
+ child.delete(0, child.length);
221065
+ changed = true;
221066
+ }
221067
+ continue;
221068
+ }
221069
+ changed = stripSchemaAtomChildren(child) || changed;
221070
+ }
221071
+ return changed;
221072
+ }
221073
+ function findNormalizableEventTarget(target) {
221074
+ let current = target;
221075
+ while (current) {
221076
+ if (current instanceof YXmlElement && SCHEMA_ATOM_NODE_NAMES.has(current.nodeName))
221077
+ return current;
221078
+ current = current.parent;
221079
+ }
221080
+ return target;
221081
+ }
221082
+ function findEventDoc(events) {
221083
+ for (const event of events) {
221084
+ const doc$12 = event?.target?.doc;
221085
+ if (doc$12)
221086
+ return doc$12;
221087
+ }
221088
+ return null;
221089
+ }
221090
+ function isTraversableYjsXml(value) {
221091
+ return Boolean(value && typeof value.toArray === "function");
221092
+ }
220868
221093
  function getEditorSurfaceElement(editor) {
220869
221094
  if (!editor)
220870
221095
  return null;
@@ -221367,13 +221592,8 @@ function splitBlockPatch(state, dispatch, editor) {
221367
221592
  atStart = $from.start(d) == $from.pos - ($from.depth - d);
221368
221593
  deflt = defaultBlockAt($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));
221369
221594
  const sourceParagraphStyleId = node3.attrs?.paragraphProperties?.styleId;
221370
- paragraphAttrs = {
221371
- ...node3.attrs,
221372
- sdBlockId: null,
221373
- sdBlockRev: null,
221374
- paraId: null,
221375
- textId: null
221376
- };
221595
+ const extensionAttrs = editor?.extensionService?.attributes ?? [];
221596
+ paragraphAttrs = Attribute2.getSplittedAttributes(extensionAttrs, node3.type.name, node3.attrs);
221377
221597
  paragraphAttrs = clearInheritedLinkedStyleId(paragraphAttrs, editor, { emptyParagraph: atEnd });
221378
221598
  if (atEnd && $from.parent.type.name === "run") {
221379
221599
  if (!isLinkedParagraphStyleId(editor, sourceParagraphStyleId))
@@ -223092,12 +223312,10 @@ function createListBoundaryNavigationPlugin() {
223092
223312
  const paragraph2 = getParagraphContext$1(selection.$from);
223093
223313
  if (!paragraph2 || !isListParagraph(paragraph2.node))
223094
223314
  return false;
223095
- if (isRtlParagraph$1(paragraph2.node))
223096
- return false;
223097
223315
  const bounds = getParagraphTextBounds2(paragraph2.node, paragraph2.start);
223098
223316
  if (!bounds)
223099
223317
  return false;
223100
- const direction = event.key === "ArrowLeft" ? -1 : 1;
223318
+ const direction = isRtlParagraph$1(paragraph2.node) ? event.key === "ArrowRight" ? -1 : 1 : event.key === "ArrowLeft" ? -1 : 1;
223101
223319
  const atLeftBoundary = direction < 0 && selection.from <= bounds.first;
223102
223320
  const atRightBoundary = direction > 0 && selection.from >= bounds.last;
223103
223321
  if (!atLeftBoundary && !atRightBoundary)
@@ -242474,10 +242692,7 @@ function tablesSplitAdapter(editor, input2, options) {
242474
242692
  const rEnd = tr.mapping.slice(mapFrom).map(rowPositions[i4] + tableNode.child(i4).nodeSize);
242475
242693
  tr.delete(rp, rEnd);
242476
242694
  }
242477
- const newTableAttrs = { ...tableNode.attrs };
242478
- delete newTableAttrs.sdBlockId;
242479
- delete newTableAttrs.paraId;
242480
- delete newTableAttrs.textId;
242695
+ const newTableAttrs = Attribute2.getSplittedAttributes(editor.extensionService?.attributes ?? [], tableNode.type.name, tableNode.attrs);
242481
242696
  const newTable = schema.nodes.table.create(newTableAttrs, secondTableRows);
242482
242697
  const separatorParagraph = createSeparatorParagraph(schema);
242483
242698
  if (!separatorParagraph)
@@ -269265,13 +269480,13 @@ function bookmarkEndNodeToRun(params$1) {
269265
269480
  };
269266
269481
  return run2;
269267
269482
  }
269268
- function tabNodeToRun({ node: node3, positions, storyKey, tabOrdinal, paragraphAttrs, inheritedMarks, sdtMetadata }) {
269483
+ function tabNodeToRun({ node: node3, positions, storyKey, tabOrdinal, paragraphAttrs, inheritedMarks, sdtMetadata, runProperties, converterContext, inlineRunProperties }) {
269269
269484
  const pos = positions.get(node3);
269270
269485
  if (!pos)
269271
269486
  return null;
269272
269487
  const tabStops = paragraphAttrs.tabs;
269273
269488
  const indent2 = paragraphAttrs.indent;
269274
- const run2 = {
269489
+ let run2 = {
269275
269490
  kind: "tab",
269276
269491
  text: "\t",
269277
269492
  pmStart: pos.start,
@@ -269283,6 +269498,8 @@ function tabNodeToRun({ node: node3, positions, storyKey, tabOrdinal, paragraphA
269283
269498
  };
269284
269499
  if (sdtMetadata)
269285
269500
  run2.sdt = sdtMetadata;
269501
+ if (runProperties)
269502
+ run2 = applyInlineRunProperties(run2, runProperties, converterContext, inlineRunProperties);
269286
269503
  const marks = [...node3.marks ?? [], ...inheritedMarks ?? []];
269287
269504
  if (marks.length > 0)
269288
269505
  applyMarksToRun(run2, marks, undefined, undefined, undefined, true, storyKey);
@@ -270699,7 +270916,7 @@ function toFlowBlocks(pmDoc, options) {
270699
270916
  blockCounts,
270700
270917
  bookmarks: bookmarks.size
270701
270918
  });
270702
- const mergedBlocks = mergeDropCapParagraphs(hydrateImageBlocks(blocks2, options?.mediaFiles));
270919
+ const mergedBlocks = mergeFusedParagraphs(mergeDropCapParagraphs(hydrateImageBlocks(blocks2, options?.mediaFiles)));
270703
270920
  flowBlockCache?.commit();
270704
270921
  return {
270705
270922
  blocks: mergedBlocks,
@@ -270736,6 +270953,32 @@ function mergeDropCapParagraphs(blocks2) {
270736
270953
  }
270737
270954
  return result;
270738
270955
  }
270956
+ function mergeFusedParagraphs(blocks2) {
270957
+ const result = [];
270958
+ for (const block of blocks2) {
270959
+ const prev = result.length > 0 ? result[result.length - 1] : undefined;
270960
+ if (block.kind === "paragraph" && prev?.kind === "paragraph" && prev.attrs?.suppressParagraphBreak) {
270961
+ const head = prev;
270962
+ const tail = block;
270963
+ const mergedAttrs = { ...head.attrs };
270964
+ if (tail.attrs?.suppressParagraphBreak)
270965
+ mergedAttrs.suppressParagraphBreak = true;
270966
+ else
270967
+ delete mergedAttrs.suppressParagraphBreak;
270968
+ const merged = {
270969
+ kind: "paragraph",
270970
+ id: head.id,
270971
+ runs: [...head.runs, ...tail.runs],
270972
+ attrs: mergedAttrs,
270973
+ ...head.sourceAnchor ? { sourceAnchor: head.sourceAnchor } : {}
270974
+ };
270975
+ result[result.length - 1] = merged;
270976
+ continue;
270977
+ }
270978
+ result.push(block);
270979
+ }
270980
+ return result;
270981
+ }
270739
270982
  function normalizeConverterContext(context, defaultFont, defaultSize) {
270740
270983
  if (!context)
270741
270984
  context = {
@@ -278857,7 +279100,7 @@ var Node$13 = class Node$14 {
278857
279100
  let $pos = doc$12.resolve(this.pos);
278858
279101
  return GapCursor.valid($pos) ? new GapCursor($pos) : Selection.near($pos);
278859
279102
  }
278860
- }, handleKeyDown2, Gapcursor, PARTS_MAP_KEY = "parts", META_MAP_KEY = "meta", META_PARTS_SCHEMA_VERSION_KEY = "partsSchemaVersion", META_PARTS_MIGRATION_KEY = "partsMigration", META_PARTS_LAST_HYDRATED_AT_KEY = "partsLastHydratedAt", META_PARTS_FALLBACK_MODE_KEY = "partsFallbackMode", META_PARTS_CAPABILITY_KEY = "partsCapability", SOURCE_COLLAB_REMOTE_PARTS = "collab:remote:parts", SOURCE_COLLAB_REMOTE_PREFIX = "collab:remote:", EXCLUDED_PART_IDS, CRITICAL_PART_IDS, isApplyingRemoteParts = false, headlessBindingStateByEditor, headlessCleanupRegisteredEditors, META_BODY_SECT_PR_KEY = "bodySectPr", BODY_SECT_PR_SYNC_META_KEY = "bodySectPrSync", collaborationCleanupByEditor, registerHeadlessBindingCleanup = (editor, cleanup) => {
279103
+ }, handleKeyDown2, Gapcursor, PARTS_MAP_KEY = "parts", META_MAP_KEY = "meta", META_PARTS_SCHEMA_VERSION_KEY = "partsSchemaVersion", META_PARTS_MIGRATION_KEY = "partsMigration", META_PARTS_LAST_HYDRATED_AT_KEY = "partsLastHydratedAt", META_PARTS_FALLBACK_MODE_KEY = "partsFallbackMode", META_PARTS_CAPABILITY_KEY = "partsCapability", SOURCE_COLLAB_REMOTE_PARTS = "collab:remote:parts", SOURCE_COLLAB_REMOTE_PREFIX = "collab:remote:", EXCLUDED_PART_IDS, CRITICAL_PART_IDS, isApplyingRemoteParts = false, SCHEMA_ATOM_NODE_NAMES, NORMALIZE_YJS_FRAGMENT_ORIGIN, headlessBindingStateByEditor, headlessCleanupRegisteredEditors, META_BODY_SECT_PR_KEY = "bodySectPr", BODY_SECT_PR_SYNC_META_KEY = "bodySectPrSync", collaborationCleanupByEditor, registerHeadlessBindingCleanup = (editor, cleanup) => {
278861
279104
  if (!cleanup || headlessCleanupRegisteredEditors.has(editor))
278862
279105
  return;
278863
279106
  headlessCleanupRegisteredEditors.add(editor);
@@ -278941,6 +279184,7 @@ var Node$13 = class Node$14 {
278941
279184
  if (!cleanup)
278942
279185
  return;
278943
279186
  cleanup.syncListenerCleanup?.();
279187
+ cleanup.fragmentNormalizeCleanup?.();
278944
279188
  cleanup.mediaMap?.unobserve?.(cleanup.mediaMapObserver);
278945
279189
  cleanup.metaMap?.unobserve?.(cleanup.metaMapObserver);
278946
279190
  cleanup.partSyncHandle?.destroy();
@@ -278951,12 +279195,23 @@ var Node$13 = class Node$14 {
278951
279195
  collaborationCleanupByEditor.delete(editor);
278952
279196
  }, createSyncPlugin = (ydoc, editor) => {
278953
279197
  const fragment2 = ydoc.getXmlFragment("supereditor");
279198
+ normalizeYjsFragmentForSchema(fragment2);
278954
279199
  const onFirstRender = () => {
278955
279200
  if (!editor.options.isNewFile)
278956
279201
  return;
278957
279202
  initializeMetaMap(ydoc, editor);
278958
279203
  };
278959
279204
  return [ySyncPlugin(fragment2, { onFirstRender }), fragment2];
279205
+ }, registerYjsFragmentNormalizer = (fragment2) => {
279206
+ if (!fragment2 || typeof fragment2.observeDeep !== "function" || typeof fragment2.unobserveDeep !== "function")
279207
+ return () => {};
279208
+ const normalize4 = (events) => {
279209
+ normalizeYjsFragmentEventsForSchema(events, fragment2);
279210
+ };
279211
+ fragment2.observeDeep(normalize4);
279212
+ return () => {
279213
+ fragment2.unobserveDeep(normalize4);
279214
+ };
278960
279215
  }, initializeMetaMap = (ydoc, editor) => {
278961
279216
  seedPartsFromEditor(editor, ydoc);
278962
279217
  const mediaMap = ydoc.getMap("media");
@@ -295772,7 +296027,7 @@ menclose::after {
295772
296027
  menclose.setAttribute("notation", notations.join(" "));
295773
296028
  menclose.appendChild(innerMrow);
295774
296029
  return menclose;
295775
- }, MATHML_NS = "http://www.w3.org/1998/Math/MathML", MATH_OBJECT_REGISTRY, ARGUMENT_ELEMENTS, resolveOrBuildFragmentIdentity = (fragment2, story, existing) => buildLayoutSourceIdentityForFragment(existing ? {
296030
+ }, 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
296031
  ...fragment2,
295777
296032
  layoutSourceIdentity: existing,
295778
296033
  sourceAnchor: fragment2.sourceAnchor ?? existing.sourceAnchor
@@ -300764,6 +301019,8 @@ menclose::after {
300764
301019
  pageBreakBefore: resolvedParagraphProperties.pageBreakBefore,
300765
301020
  directionContext
300766
301021
  };
301022
+ if (resolvedParagraphProperties.runProperties?.vanish === true || paragraphProperties.runProperties?.vanish === true)
301023
+ paragraphAttrs.suppressParagraphBreak = true;
300767
301024
  if (normalizedNumberingProperties && normalizedListRendering) {
300768
301025
  const markerRunAttrs = computeRunAttrs(resolveRunProperties(converterContext, resolvedParagraphProperties.runProperties, resolvedParagraphProperties, converterContext.tableInfo, true, Boolean(paragraphProperties.numberingProperties)), converterContext);
300769
301026
  let markerFontFallback;
@@ -306337,6 +306594,8 @@ menclose::after {
306337
306594
  this.#emitModeChanged();
306338
306595
  this.#emitEditingContext(editor);
306339
306596
  this.#deps?.notifyInputBridgeTargetChanged();
306597
+ this.#deps?.setPendingDocChange();
306598
+ this.#deps?.scheduleRerender();
306340
306599
  return editor;
306341
306600
  } catch (error3) {
306342
306601
  console.error("[HeaderFooterSessionManager] Unexpected error in enterMode:", error3);
@@ -306452,6 +306711,13 @@ menclose::after {
306452
306711
  this.#updateModeBanner();
306453
306712
  this.#syncActiveBorder();
306454
306713
  }
306714
+ #isActiveDecoration(kind, headerFooterRefId, pageNumber) {
306715
+ if (this.#session.mode !== kind)
306716
+ return false;
306717
+ if (headerFooterRefId && this.#session.headerFooterRefId)
306718
+ return headerFooterRefId === this.#session.headerFooterRefId;
306719
+ return this.#session.pageNumber === pageNumber;
306720
+ }
306455
306721
  #emitEditingContext(editor) {
306456
306722
  this.#callbacks.onEditingContext?.({
306457
306723
  kind: this.#session.mode,
@@ -307139,9 +307405,12 @@ menclose::after {
307139
307405
  const rawLayoutHeight$1 = rIdLayout.layout.height ?? 0;
307140
307406
  const metrics$1 = this.#computeMetrics(kind, rawLayoutHeight$1, box$1, pageHeight$1, margins$1?.footer ?? 0);
307141
307407
  const layoutMinY$1 = rIdLayout.layout.minY ?? 0;
307408
+ const normalizedFragments$1 = normalizeDecorationFragments(fragments$1, layoutMinY$1);
307409
+ const normalizedItems$1 = normalizeDecorationItems(alignedItems, layoutMinY$1);
307410
+ const isActiveHeaderFooter$1 = this.#isActiveDecoration(kind, sectionRId, pageNumber);
307142
307411
  return {
307143
- fragments: normalizeDecorationFragments(fragments$1, layoutMinY$1),
307144
- items: normalizeDecorationItems(alignedItems, layoutMinY$1),
307412
+ fragments: normalizedFragments$1,
307413
+ items: normalizedItems$1,
307145
307414
  height: metrics$1.containerHeight,
307146
307415
  contentHeight: metrics$1.layoutHeight > 0 ? metrics$1.layoutHeight : metrics$1.containerHeight,
307147
307416
  offset: metrics$1.offset,
@@ -307149,6 +307418,7 @@ menclose::after {
307149
307418
  contentWidth: effectiveWidth,
307150
307419
  headerFooterRefId: sectionRId,
307151
307420
  sectionType: headerFooterType,
307421
+ isActiveHeaderFooter: isActiveHeaderFooter$1,
307152
307422
  minY: layoutMinY$1,
307153
307423
  box: {
307154
307424
  x: box$1.x,
@@ -307189,9 +307459,12 @@ menclose::after {
307189
307459
  const rawLayoutHeight = variant.layout.height ?? 0;
307190
307460
  const metrics = this.#computeMetrics(kind, rawLayoutHeight, box, pageHeight, margins?.footer ?? 0);
307191
307461
  const layoutMinY = variant.layout.minY ?? 0;
307462
+ const normalizedFragments = normalizeDecorationFragments(fragments, layoutMinY);
307463
+ const normalizedItems = normalizeDecorationItems(alignedVariantItems, layoutMinY);
307464
+ const isActiveHeaderFooter = this.#isActiveDecoration(kind, finalHeaderId, pageNumber);
307192
307465
  return {
307193
- fragments: normalizeDecorationFragments(fragments, layoutMinY),
307194
- items: normalizeDecorationItems(alignedVariantItems, layoutMinY),
307466
+ fragments: normalizedFragments,
307467
+ items: normalizedItems,
307195
307468
  height: metrics.containerHeight,
307196
307469
  contentHeight: metrics.layoutHeight > 0 ? metrics.layoutHeight : metrics.containerHeight,
307197
307470
  offset: metrics.offset,
@@ -307199,6 +307472,7 @@ menclose::after {
307199
307472
  contentWidth: box.width,
307200
307473
  headerFooterRefId: finalHeaderId,
307201
307474
  sectionType: headerFooterType,
307475
+ isActiveHeaderFooter,
307202
307476
  minY: layoutMinY,
307203
307477
  box: {
307204
307478
  x: box.x,
@@ -307489,13 +307763,13 @@ menclose::after {
307489
307763
  return;
307490
307764
  console.log(...args$1);
307491
307765
  }, 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(() => {
307766
+ var init_src_CY28yu_i_es = __esm(() => {
307493
307767
  init_rolldown_runtime_Bg48TavK_es();
307494
- init_SuperConverter_opYK_HD4_es();
307768
+ init_SuperConverter_k7GHkV_c_es();
307495
307769
  init_jszip_C49i9kUs_es();
307496
307770
  init_xml_js_CqGKpaft_es();
307497
307771
  init_uuid_qzgm05fK_es();
307498
- init_create_headless_toolbar_xjqjtPWl_es();
307772
+ init_create_headless_toolbar_dycevpY9_es();
307499
307773
  init_constants_DrU4EASo_es();
307500
307774
  init_dist_B8HfvhaK_es();
307501
307775
  init_unified_Dsuw2be5_es();
@@ -308717,6 +308991,8 @@ ${err.toString()}`);
308717
308991
  "word/_rels/document.xml.rels",
308718
308992
  "[Content_Types].xml"
308719
308993
  ]);
308994
+ SCHEMA_ATOM_NODE_NAMES = new Set(["crossReference", "citation"]);
308995
+ NORMALIZE_YJS_FRAGMENT_ORIGIN = Symbol.for("superdoc/yjs-fragment-normalize");
308720
308996
  new PluginKey("collaboration");
308721
308997
  headlessBindingStateByEditor = /* @__PURE__ */ new WeakMap;
308722
308998
  headlessCleanupRegisteredEditors = /* @__PURE__ */ new WeakSet;
@@ -308744,6 +309020,7 @@ ${err.toString()}`);
308744
309020
  const syncListenerCleanup = initSyncListener(this.options.ydoc, this.editor, this);
308745
309021
  const [syncPlugin, fragment2] = createSyncPlugin(this.options.ydoc, this.editor);
308746
309022
  this.options.fragment = fragment2;
309023
+ const fragmentNormalizeCleanup = registerYjsFragmentNormalizer(fragment2);
308747
309024
  const mediaMap = this.options.ydoc.getMap("media");
308748
309025
  const mediaMapObserver = (event) => {
308749
309026
  event.changes.keys.forEach((_$1, key2) => {
@@ -308758,6 +309035,7 @@ ${err.toString()}`);
308758
309035
  syncListenerCleanup,
308759
309036
  mediaMap,
308760
309037
  mediaMapObserver,
309038
+ fragmentNormalizeCleanup,
308761
309039
  metaMap: null,
308762
309040
  metaMapObserver: null,
308763
309041
  partSyncHandle: null,
@@ -310376,8 +310654,14 @@ ${err.toString()}`);
310376
310654
  },
310377
310655
  addAttributes() {
310378
310656
  return {
310379
- paraId: { rendered: false },
310380
- textId: { rendered: false },
310657
+ paraId: {
310658
+ rendered: false,
310659
+ keepOnSplit: false
310660
+ },
310661
+ textId: {
310662
+ rendered: false,
310663
+ keepOnSplit: false
310664
+ },
310381
310665
  rsidR: { rendered: false },
310382
310666
  rsidRDefault: { rendered: false },
310383
310667
  rsidP: { rendered: false },
@@ -313359,8 +313643,16 @@ ${err.toString()}`);
313359
313643
  },
313360
313644
  isAnchor: { rendered: false },
313361
313645
  vmlWatermark: { rendered: false },
313646
+ vmlTextWatermark: { rendered: false },
313647
+ textWatermarkData: { rendered: false },
313648
+ vmlStyle: { rendered: false },
313362
313649
  vmlAttributes: { rendered: false },
313363
313650
  vmlImagedata: { rendered: false },
313651
+ vmlTextpathAttributes: { rendered: false },
313652
+ vmlPathAttributes: { rendered: false },
313653
+ vmlFillAttributes: { rendered: false },
313654
+ vmlStrokeAttributes: { rendered: false },
313655
+ vmlWrapAttributes: { rendered: false },
313364
313656
  transformData: {
313365
313657
  default: {},
313366
313658
  renderDOM: ({ transformData }) => {
@@ -331526,6 +331818,7 @@ function print() { __p += __j.call(arguments, '') }
331526
331818
  }
331527
331819
  #telemetry = null;
331528
331820
  #documentOpenTracked = false;
331821
+ #constructorFragment = null;
331529
331822
  constructor(options) {
331530
331823
  super();
331531
331824
  this.extensionStorage = {};
@@ -331631,6 +331924,7 @@ function print() { __p += __j.call(arguments, '') }
331631
331924
  resolvedOptions.element = null;
331632
331925
  resolvedOptions.selector = null;
331633
331926
  }
331927
+ this.#constructorFragment = resolvedOptions.fragment ?? null;
331634
331928
  this.#checkHeadless(resolvedOptions);
331635
331929
  this.setOptions(resolvedOptions);
331636
331930
  this.#renderer = resolvedOptions.renderer ?? (domAvailable ? new ProseMirrorRenderer : null);
@@ -331752,6 +332046,7 @@ function print() { __p += __j.call(arguments, '') }
331752
332046
  try {
331753
332047
  const resolvedMode = options?.mode ?? this.options.mode ?? "docx";
331754
332048
  const explicitIsNewFile = options?.isNewFile;
332049
+ const hasOpenFragment = Object.prototype.hasOwnProperty.call(options ?? {}, "fragment");
331755
332050
  const resolvedOptions = {
331756
332051
  ...this.options,
331757
332052
  mode: resolvedMode,
@@ -331760,7 +332055,8 @@ function print() { __p += __j.call(arguments, '') }
331760
332055
  documentMode: options?.documentMode ?? this.options.documentMode ?? "editing",
331761
332056
  html: options?.html,
331762
332057
  markdown: options?.markdown,
331763
- jsonOverride: options?.json ?? null
332058
+ jsonOverride: options?.json ?? null,
332059
+ fragment: hasOpenFragment ? options?.fragment ?? null : this.options.fragment ?? this.#constructorFragment
331764
332060
  };
331765
332061
  const loadOptions = options?.password ? { password: options.password } : undefined;
331766
332062
  if (typeof source === "string")
@@ -331894,6 +332190,7 @@ function print() { __p += __j.call(arguments, '') }
331894
332190
  this.options.initialState = null;
331895
332191
  this.options.content = "";
331896
332192
  this.options.fileSource = null;
332193
+ this.options.fragment = null;
331897
332194
  this._state = undefined;
331898
332195
  }
331899
332196
  #initProtectionState() {
@@ -332598,8 +332895,10 @@ function print() { __p += __j.call(arguments, '') }
332598
332895
  });
332599
332896
  else if (this.options.jsonOverride)
332600
332897
  doc$12 = this.schema.nodeFromJSON(this.options.jsonOverride);
332601
- if (fragment2)
332898
+ if (fragment2) {
332899
+ normalizeYjsFragmentForSchema(fragment2);
332602
332900
  doc$12 = yXmlFragmentToProseMirrorRootNode(fragment2, this.schema);
332901
+ }
332603
332902
  }
332604
332903
  else if (mode === "text" || mode === "html")
332605
332904
  if (loadFromSchema && hasJsonContent(content3))
@@ -333165,12 +333464,13 @@ function print() { __p += __j.call(arguments, '') }
333165
333464
  isHeadless: !(config2?.element != null || config2?.selector != null),
333166
333465
  ...config2
333167
333466
  };
333168
- const { html: html3, markdown, json, isCommentsEnabled, suppressDefaultDocxStyles, documentMode, content: content3, mediaFiles, fonts, isNewFile, password, ...editorConfig } = resolvedConfig;
333467
+ const { html: html3, markdown, json, fragment: fragment2, isCommentsEnabled, suppressDefaultDocxStyles, documentMode, content: content3, mediaFiles, fonts, isNewFile, password, ...editorConfig } = resolvedConfig;
333169
333468
  const openOptions = {
333170
333469
  mode: resolvedConfig.mode,
333171
333470
  html: html3,
333172
333471
  markdown,
333173
333472
  json,
333473
+ fragment: fragment2,
333174
333474
  isCommentsEnabled,
333175
333475
  suppressDefaultDocxStyles,
333176
333476
  documentMode,
@@ -334878,6 +335178,7 @@ function print() { __p += __j.call(arguments, '') }
334878
335178
  behindDocFragments.forEach(({ fragment: fragment2, originalIndex }) => {
334879
335179
  const resolvedItem = data.items?.[originalIndex];
334880
335180
  const fragEl = this.renderFragment(fragment2, context, undefined, betweenBorderFlags.get(originalIndex), resolvedItem);
335181
+ this.applyHeaderFooterTextWatermarkPreviewOpacity(fragEl, data.isActiveHeaderFooter === true);
334881
335182
  const isPageRelative = this.isPageRelativeAnchoredFragment(fragment2, resolvedItem);
334882
335183
  let pageY;
334883
335184
  if (isPageRelative && kind === "footer")
@@ -334895,6 +335196,7 @@ function print() { __p += __j.call(arguments, '') }
334895
335196
  normalFragments.forEach(({ fragment: fragment2, originalIndex }) => {
334896
335197
  const resolvedItem = data.items?.[originalIndex];
334897
335198
  const fragEl = this.renderFragment(fragment2, context, undefined, betweenBorderFlags.get(originalIndex), resolvedItem);
335199
+ this.applyHeaderFooterTextWatermarkPreviewOpacity(fragEl, data.isActiveHeaderFooter === true);
334898
335200
  const isPageRelative = this.isPageRelativeAnchoredFragment(fragment2, resolvedItem);
334899
335201
  if (isPageRelative && kind === "footer")
334900
335202
  fragEl.style.top = `${fragment2.y + footerAnchorContainerOffsetY}px`;
@@ -335649,6 +335951,8 @@ function print() { __p += __j.call(arguments, '') }
335649
335951
  }
335650
335952
  this.applySdtDataset(fragmentEl, block.attrs?.sdt);
335651
335953
  this.applyContainerSdtDataset(fragmentEl, block.attrs?.containerSdt);
335954
+ if (this.isVmlTextWatermarkImage(block))
335955
+ fragmentEl.dataset.vmlTextWatermark = "true";
335652
335956
  if (block.id)
335653
335957
  fragmentEl.setAttribute("data-sd-block-id", block.id);
335654
335958
  const imgPmStart = resolvedItem?.pmStart;
@@ -337736,7 +338040,11 @@ function print() { __p += __j.call(arguments, '') }
337736
338040
  shouldRenderBehindPageContent(fragment2, section, resolvedItem) {
337737
338041
  if (fragment2.behindDoc === true || fragment2.behindDoc == null && "zIndex" in fragment2 && fragment2.zIndex === 0)
337738
338042
  return true;
337739
- return section === "header" && fragment2.kind === "drawing" && this.isHeaderWordArtWatermark(resolvedItem?.block);
338043
+ if (section !== "header")
338044
+ return false;
338045
+ if (fragment2.kind === "drawing")
338046
+ return this.isHeaderWordArtWatermark(resolvedItem?.block);
338047
+ return this.isVmlTextWatermarkImage(resolvedItem?.block);
337740
338048
  }
337741
338049
  isHeaderWordArtWatermark(block) {
337742
338050
  if (!block || block.kind !== "drawing" || block.drawingKind !== "vectorShape")
@@ -337745,6 +338053,14 @@ function print() { __p += __j.call(arguments, '') }
337745
338053
  const hasTextContent = Array.isArray(block.textContent?.parts) && block.textContent.parts.length > 0;
337746
338054
  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
338055
  }
338056
+ isVmlTextWatermarkImage(block) {
338057
+ return block?.kind === "image" && block.attrs?.vmlTextWatermark === true;
338058
+ }
338059
+ applyHeaderFooterTextWatermarkPreviewOpacity(el, isActiveHeaderFooter) {
338060
+ if (el.dataset.vmlTextWatermark !== "true")
338061
+ return;
338062
+ el.style.opacity = isActiveHeaderFooter ? ACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY : INACTIVE_HEADER_FOOTER_WATERMARK_PREVIEW_OPACITY;
338063
+ }
337748
338064
  resolveFragmentWrapperZIndex(fragment2, resolvedZIndex) {
337749
338065
  if (!this.isAnchoredMediaFragment(fragment2))
337750
338066
  return "";
@@ -345268,11 +345584,11 @@ function print() { __p += __j.call(arguments, '') }
345268
345584
  ];
345269
345585
  });
345270
345586
 
345271
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DqYtj3Jy.es.js
345587
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-BLDU9pTd.es.js
345272
345588
  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();
345589
+ var init_create_super_doc_ui_BLDU9pTd_es = __esm(() => {
345590
+ init_SuperConverter_k7GHkV_c_es();
345591
+ init_create_headless_toolbar_dycevpY9_es();
345276
345592
  MOD_ALIASES = new Set([
345277
345593
  "Mod",
345278
345594
  "Meta",
@@ -345314,16 +345630,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
345314
345630
 
345315
345631
  // ../../packages/superdoc/dist/super-editor.es.js
345316
345632
  var init_super_editor_es = __esm(() => {
345317
- init_src_CZSemHps_es();
345318
- init_SuperConverter_opYK_HD4_es();
345633
+ init_src_CY28yu_i_es();
345634
+ init_SuperConverter_k7GHkV_c_es();
345319
345635
  init_jszip_C49i9kUs_es();
345320
345636
  init_xml_js_CqGKpaft_es();
345321
- init_create_headless_toolbar_xjqjtPWl_es();
345637
+ init_create_headless_toolbar_dycevpY9_es();
345322
345638
  init_constants_DrU4EASo_es();
345323
345639
  init_dist_B8HfvhaK_es();
345324
345640
  init_unified_Dsuw2be5_es();
345325
345641
  init_DocxZipper_CZMPWpOp_es();
345326
- init_create_super_doc_ui_DqYtj3Jy_es();
345642
+ init_create_super_doc_ui_BLDU9pTd_es();
345327
345643
  init_ui_C5PAS9hY_es();
345328
345644
  init_eventemitter3_BnGqBE_Q_es();
345329
345645
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.12.1-next.9",
3
+ "version": "0.13.0-next.10",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -25,20 +25,20 @@
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
27
  "@superdoc/document-api": "0.0.1",
28
- "@superdoc/pm-adapter": "0.0.0",
28
+ "@superdoc/super-editor": "0.0.1",
29
29
  "superdoc": "1.35.0",
30
- "@superdoc/super-editor": "0.0.1"
30
+ "@superdoc/pm-adapter": "0.0.0"
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.12.1-next.9",
38
- "@superdoc-dev/cli-darwin-x64": "0.12.1-next.9",
39
- "@superdoc-dev/cli-linux-arm64": "0.12.1-next.9",
40
- "@superdoc-dev/cli-windows-x64": "0.12.1-next.9",
41
- "@superdoc-dev/cli-linux-x64": "0.12.1-next.9"
37
+ "@superdoc-dev/cli-darwin-arm64": "0.13.0-next.10",
38
+ "@superdoc-dev/cli-darwin-x64": "0.13.0-next.10",
39
+ "@superdoc-dev/cli-windows-x64": "0.13.0-next.10",
40
+ "@superdoc-dev/cli-linux-x64": "0.13.0-next.10",
41
+ "@superdoc-dev/cli-linux-arm64": "0.13.0-next.10"
42
42
  },
43
43
  "scripts": {
44
44
  "predev": "node scripts/ensure-superdoc-build.js",