@superdoc-dev/cli 0.16.0-next.15 → 0.16.0-next.16

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 +118 -40
  2. package/package.json +8 -8
package/dist/index.js CHANGED
@@ -68110,7 +68110,7 @@ var init_remark_gfm_BhnWr3yf_es = __esm(() => {
68110
68110
  emptyOptions2 = {};
68111
68111
  });
68112
68112
 
68113
- // ../../packages/superdoc/dist/chunks/SuperConverter-CvwFiCth.es.js
68113
+ // ../../packages/superdoc/dist/chunks/SuperConverter-EumzHoTv.es.js
68114
68114
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
68115
68115
  const fieldValue = extension$1.config[field];
68116
68116
  if (typeof fieldValue === "function")
@@ -100894,11 +100894,37 @@ function translateHeadingNode(params3) {
100894
100894
  function mergeMcIgnorable(defaultIgnorable = "", originalIgnorable = "") {
100895
100895
  return [...new Set([...defaultIgnorable.split(/\s+/).filter(Boolean), ...originalIgnorable.split(/\s+/).filter(Boolean)])].join(" ");
100896
100896
  }
100897
+ function normalizeDocumentBackgroundColorForExport(value) {
100898
+ if (typeof value !== "string")
100899
+ return null;
100900
+ const trimmed = value.trim();
100901
+ const hex = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
100902
+ if (!/^[0-9a-fA-F]{6}$/.test(hex))
100903
+ return null;
100904
+ return hex.toUpperCase();
100905
+ }
100906
+ function translateDocumentBackgroundNode(params3) {
100907
+ const background = params3?.node?.attrs?.documentBackground;
100908
+ if (!background || typeof background !== "object")
100909
+ return null;
100910
+ if (background.originalXml && typeof background.originalXml === "object")
100911
+ return carbonCopy(background.originalXml);
100912
+ const color2 = normalizeDocumentBackgroundColorForExport(background.color);
100913
+ if (!color2)
100914
+ return null;
100915
+ return {
100916
+ type: "element",
100917
+ name: "w:background",
100918
+ attributes: { "w:color": color2 },
100919
+ elements: []
100920
+ };
100921
+ }
100897
100922
  function translateDocumentNode(params3) {
100898
100923
  const bodyNode = {
100899
100924
  type: "body",
100900
100925
  content: params3.node.content
100901
100926
  };
100927
+ const translatedBackgroundNode = translateDocumentBackgroundNode(params3);
100902
100928
  const translatedBodyNode = exportSchemaToJson({
100903
100929
  ...params3,
100904
100930
  node: bodyNode
@@ -100913,7 +100939,7 @@ function translateDocumentNode(params3) {
100913
100939
  attributes["mc:Ignorable"] = mergedIgnorable;
100914
100940
  const node3 = {
100915
100941
  name: "w:document",
100916
- elements: [translatedBodyNode],
100942
+ elements: translatedBackgroundNode ? [translatedBackgroundNode, translatedBodyNode] : [translatedBodyNode],
100917
100943
  attributes
100918
100944
  };
100919
100945
  normalizePgMarTwipsInTree(node3);
@@ -126838,7 +126864,23 @@ var isRegExp = (value) => {
126838
126864
  } catch {
126839
126865
  return /* @__PURE__ */ new Map;
126840
126866
  }
126841
- }, readTrackedChangeSourceIdMap = (docx) => parseTrackedChangeSourceIdMap(readCustomProperty(docx, TRACKED_CHANGE_SOURCE_ID_MAP_PROPERTY)), detectCommentThreadingProfile = (docx) => {
126867
+ }, readTrackedChangeSourceIdMap = (docx) => parseTrackedChangeSourceIdMap(readCustomProperty(docx, TRACKED_CHANGE_SOURCE_ID_MAP_PROPERTY)), normalizeDocumentBackgroundColor = (value) => {
126868
+ if (typeof value !== "string")
126869
+ return null;
126870
+ const trimmed = value.trim();
126871
+ if (!/^[0-9a-fA-F]{6}$/.test(trimmed))
126872
+ return null;
126873
+ return `#${trimmed.toUpperCase()}`;
126874
+ }, getDocumentBackground = (documentNode) => {
126875
+ const background = documentNode?.elements?.find((el) => el?.name === "w:background");
126876
+ const color2 = normalizeDocumentBackgroundColor(background?.attributes?.["w:color"] ?? background?.attributes?.color);
126877
+ if (!background || !color2)
126878
+ return null;
126879
+ return {
126880
+ color: color2,
126881
+ originalXml: carbonCopy(background)
126882
+ };
126883
+ }, detectCommentThreadingProfile = (docx) => {
126842
126884
  const hasCommentsExtended = !!docx["word/commentsExtended.xml"];
126843
126885
  const hasCommentsExtensible = !!docx["word/commentsExtensible.xml"];
126844
126886
  const hasCommentsIds = !!docx["word/commentsIds.xml"];
@@ -126855,6 +126897,7 @@ var isRegExp = (value) => {
126855
126897
  const json = carbonCopy(getInitialJSON(docx));
126856
126898
  if (!json)
126857
126899
  return null;
126900
+ const documentBackground = getDocumentBackground(json.elements?.[0]);
126858
126901
  if (converter) {
126859
126902
  importFootnotePropertiesFromSettings(docx, converter);
126860
126903
  importViewSettingFromSettings(docx, converter);
@@ -126925,17 +126968,22 @@ var isRegExp = (value) => {
126925
126968
  parsedContent = normalizeTableBookmarksInContent(parsedContent, editor);
126926
126969
  collapseWhitespaceNextToInlinePassthrough(parsedContent);
126927
126970
  parsedContent = normalizeDuplicateBlockIdentitiesInContent(parsedContent);
126971
+ const result = {
126972
+ type: "doc",
126973
+ content: parsedContent,
126974
+ attrs: {
126975
+ attributes: json.elements[0].attributes,
126976
+ ...bodySectPr ? { bodySectPr } : {},
126977
+ ...documentBackground ? { documentBackground } : {}
126978
+ }
126979
+ };
126980
+ const pageStyles = getDocumentStyles(node3, docx, converter, editor, numbering, translatedNumbering, translatedLinkedStyles);
126981
+ if (documentBackground)
126982
+ pageStyles.documentBackground = { color: documentBackground.color };
126928
126983
  return {
126929
- pmDoc: {
126930
- type: "doc",
126931
- content: parsedContent,
126932
- attrs: {
126933
- attributes: json.elements[0].attributes,
126934
- ...bodySectPr ? { bodySectPr } : {}
126935
- }
126936
- },
126984
+ pmDoc: result,
126937
126985
  savedTagsToRestore: node3,
126938
- pageStyles: getDocumentStyles(node3, docx, converter, editor, numbering, translatedNumbering, translatedLinkedStyles),
126986
+ pageStyles,
126939
126987
  comments,
126940
126988
  footnotes,
126941
126989
  endnotes,
@@ -131045,7 +131093,7 @@ var isRegExp = (value) => {
131045
131093
  state.kern = kernNode.attributes["w:val"];
131046
131094
  }
131047
131095
  }, SuperConverter;
131048
- var init_SuperConverter_CvwFiCth_es = __esm(() => {
131096
+ var init_SuperConverter_EumzHoTv_es = __esm(() => {
131049
131097
  init_rolldown_runtime_Bg48TavK_es();
131050
131098
  init_jszip_C49i9kUs_es();
131051
131099
  init_xml_js_CqGKpaft_es();
@@ -169838,7 +169886,7 @@ var init_SuperConverter_CvwFiCth_es = __esm(() => {
169838
169886
  };
169839
169887
  });
169840
169888
 
169841
- // ../../packages/superdoc/dist/chunks/create-headless-toolbar-DdDLS67b.es.js
169889
+ // ../../packages/superdoc/dist/chunks/create-headless-toolbar-CRyPCXZF.es.js
169842
169890
  function parseSizeUnit(val = "0") {
169843
169891
  const length3 = val.toString() || "0";
169844
169892
  const value = Number.parseFloat(length3);
@@ -180169,8 +180217,8 @@ var CSS_DIMENSION_REGEX, DOM_SIZE_UNITS, normalizeActorId = (value) => {
180169
180217
  }
180170
180218
  };
180171
180219
  };
180172
- var init_create_headless_toolbar_DdDLS67b_es = __esm(() => {
180173
- init_SuperConverter_CvwFiCth_es();
180220
+ var init_create_headless_toolbar_CRyPCXZF_es = __esm(() => {
180221
+ init_SuperConverter_EumzHoTv_es();
180174
180222
  init_uuid_qzgm05fK_es();
180175
180223
  init_constants_D_X7xF4s_es();
180176
180224
  init_dist_B8HfvhaK_es();
@@ -229333,7 +229381,7 @@ var init_remark_gfm_eZN6yzWQ_es = __esm(() => {
229333
229381
  init_remark_gfm_BhnWr3yf_es();
229334
229382
  });
229335
229383
 
229336
- // ../../packages/superdoc/dist/chunks/src-BbNQjpxw.es.js
229384
+ // ../../packages/superdoc/dist/chunks/src-CibMiO0y.es.js
229337
229385
  function deleteProps(obj, propOrProps) {
229338
229386
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
229339
229387
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -269851,7 +269899,8 @@ function resolveLayout(input2) {
269851
269899
  version: 1,
269852
269900
  flowMode,
269853
269901
  pageGap: layout.pageGap ?? 0,
269854
- pages
269902
+ pages,
269903
+ ...layout.documentBackground ? { documentBackground: layout.documentBackground } : {}
269855
269904
  };
269856
269905
  if (blocks2.length > 0)
269857
269906
  resolved.blockVersions = Object.fromEntries(blocks2.map((block) => [block.id, computeBlockVersion(block.id, blockMap, blockVersionCache)]));
@@ -274464,6 +274513,7 @@ function layoutDocument(blocks2, measures, options = {}) {
274464
274513
  return {
274465
274514
  pageSize,
274466
274515
  pages,
274516
+ ...options.documentBackground ? { documentBackground: options.documentBackground } : {},
274467
274517
  columns: activeColumns.count > 1 ? cloneColumnLayout(activeColumns) : undefined
274468
274518
  };
274469
274519
  }
@@ -311626,16 +311676,17 @@ menclose::after {
311626
311676
  this.mount = mount;
311627
311677
  this.beginPaintSnapshot(resolvedLayout);
311628
311678
  this.totalPages = resolvedLayout.pages.length;
311679
+ const previousLayout = this.currentLayout;
311680
+ this.currentLayout = resolvedLayout;
311629
311681
  if (this.isSemanticFlow) {
311630
311682
  applyStyles(mount, containerStyles);
311631
311683
  mount.style.gap = "0px";
311632
311684
  mount.style.alignItems = "stretch";
311633
- if (!this.currentLayout || this.pageStates.length === 0)
311685
+ if (!previousLayout || this.pageStates.length === 0)
311634
311686
  this.fullRender(resolvedLayout);
311635
311687
  else
311636
311688
  this.patchLayout(resolvedLayout);
311637
311689
  this.setMountedPageIndices(this.createAllPageIndices(resolvedLayout.pages.length));
311638
- this.currentLayout = resolvedLayout;
311639
311690
  this.changedBlocks.clear();
311640
311691
  this.currentMapping = null;
311641
311692
  return;
@@ -311675,7 +311726,7 @@ menclose::after {
311675
311726
  this.currentMapping = null;
311676
311727
  } else {
311677
311728
  mount.style.gap = `${this.pageGap}px`;
311678
- if (!this.currentLayout || this.pageStates.length === 0)
311729
+ if (!previousLayout || this.pageStates.length === 0)
311679
311730
  this.fullRender(resolvedLayout);
311680
311731
  else {
311681
311732
  this.patchLayout(resolvedLayout);
@@ -312497,22 +312548,26 @@ menclose::after {
312497
312548
  }
312498
312549
  }
312499
312550
  getEffectivePageStyles() {
312500
- if (this.isSemanticFlow) {
312501
- const base5 = this.options.pageStyles ?? {};
312551
+ const documentBackgroundColor = this.currentLayout?.documentBackground?.color;
312552
+ const base5 = this.options.pageStyles ?? {};
312553
+ const baseWithDocumentBackground = documentBackgroundColor ? {
312554
+ ...base5,
312555
+ background: documentBackgroundColor
312556
+ } : base5;
312557
+ if (this.isSemanticFlow)
312502
312558
  return {
312503
- ...base5,
312504
- background: base5.background ?? "var(--sd-layout-page-bg, #fff)",
312559
+ ...baseWithDocumentBackground,
312560
+ background: baseWithDocumentBackground.background ?? "var(--sd-layout-page-bg, #fff)",
312505
312561
  boxShadow: "none",
312506
312562
  border: "none",
312507
312563
  margin: "0"
312508
312564
  };
312509
- }
312510
312565
  if (this.virtualEnabled && this.layoutMode === "vertical")
312511
312566
  return {
312512
- ...this.options.pageStyles ?? {},
312567
+ ...baseWithDocumentBackground,
312513
312568
  margin: "0 auto"
312514
312569
  };
312515
- return this.options.pageStyles;
312570
+ return documentBackgroundColor ? baseWithDocumentBackground : this.options.pageStyles;
312516
312571
  }
312517
312572
  renderFragment(fragment2, context, sdtBoundary, betweenInfo, resolvedItem) {
312518
312573
  if (fragment2.kind === "para")
@@ -322804,13 +322859,13 @@ menclose::after {
322804
322859
  return;
322805
322860
  console.log(...args$1);
322806
322861
  }, 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, TRACKED_MARK_NAMES;
322807
- var init_src_BbNQjpxw_es = __esm(() => {
322862
+ var init_src_CibMiO0y_es = __esm(() => {
322808
322863
  init_rolldown_runtime_Bg48TavK_es();
322809
- init_SuperConverter_CvwFiCth_es();
322864
+ init_SuperConverter_EumzHoTv_es();
322810
322865
  init_jszip_C49i9kUs_es();
322811
322866
  init_xml_js_CqGKpaft_es();
322812
322867
  init_uuid_qzgm05fK_es();
322813
- init_create_headless_toolbar_DdDLS67b_es();
322868
+ init_create_headless_toolbar_CRyPCXZF_es();
322814
322869
  init_constants_D_X7xF4s_es();
322815
322870
  init_dist_B8HfvhaK_es();
322816
322871
  init_unified_Dsuw2be5_es();
@@ -325654,6 +325709,10 @@ ${err.toString()}`);
325654
325709
  bodySectPr: {
325655
325710
  rendered: false,
325656
325711
  default: null
325712
+ },
325713
+ documentBackground: {
325714
+ rendered: false,
325715
+ default: null
325657
325716
  }
325658
325717
  };
325659
325718
  },
@@ -350720,6 +350779,7 @@ function print() { __p += __j.call(arguments, '') }
350720
350779
  #hiddenHost;
350721
350780
  #hiddenHostWrapper;
350722
350781
  #layoutOptions;
350782
+ #configuredDocumentBackground;
350723
350783
  #layoutState = {
350724
350784
  blocks: [],
350725
350785
  measures: [],
@@ -350835,6 +350895,7 @@ function print() { __p += __j.call(arguments, '') }
350835
350895
  } : undefined;
350836
350896
  const requestedFlowMode = options.layoutEngineOptions?.flowMode === "semantic" ? "semantic" : "paginated";
350837
350897
  const requestedLayoutMode = options.layoutEngineOptions?.layoutMode ?? "vertical";
350898
+ this.#configuredDocumentBackground = this.#coerceDocumentBackground(options.layoutEngineOptions?.documentBackground);
350838
350899
  this.#layoutOptions = {
350839
350900
  pageSize: options.layoutEngineOptions?.pageSize ?? DEFAULT_PAGE_SIZE,
350840
350901
  margins: options.layoutEngineOptions?.margins ?? DEFAULT_MARGINS,
@@ -350843,6 +350904,7 @@ function print() { __p += __j.call(arguments, '') }
350843
350904
  enabled: false
350844
350905
  } : options.layoutEngineOptions?.virtualization,
350845
350906
  zoom: options.layoutEngineOptions?.zoom ?? 1,
350907
+ ...this.#configuredDocumentBackground ? { documentBackground: this.#configuredDocumentBackground } : {},
350846
350908
  pageStyles: options.layoutEngineOptions?.pageStyles,
350847
350909
  debugLabel: options.layoutEngineOptions?.debugLabel,
350848
350910
  layoutMode: requestedFlowMode === "semantic" ? "vertical" : requestedLayoutMode,
@@ -355150,6 +355212,11 @@ function print() { __p += __j.call(arguments, '') }
355150
355212
  this.#layoutOptions.pageSize = pageSize;
355151
355213
  this.#layoutOptions.margins = margins;
355152
355214
  const flowMode = this.#layoutOptions.flowMode ?? "paginated";
355215
+ const documentBackground = this.#resolveDocumentBackground();
355216
+ if (documentBackground)
355217
+ this.#layoutOptions.documentBackground = documentBackground;
355218
+ else
355219
+ delete this.#layoutOptions.documentBackground;
355153
355220
  const resolvedMargins = {
355154
355221
  top: margins.top,
355155
355222
  right: margins.right,
@@ -355189,7 +355256,8 @@ function print() { __p += __j.call(arguments, '') }
355189
355256
  marginTop: semanticMargins.top,
355190
355257
  marginBottom: semanticMargins.bottom
355191
355258
  },
355192
- sectionMetadata
355259
+ sectionMetadata,
355260
+ ...documentBackground ? { documentBackground } : {}
355193
355261
  };
355194
355262
  }
355195
355263
  this.#hiddenHost.style.width = `${pageSize.w}px`;
@@ -355198,6 +355266,7 @@ function print() { __p += __j.call(arguments, '') }
355198
355266
  flowMode: "paginated",
355199
355267
  pageSize,
355200
355268
  margins: resolvedMargins,
355269
+ ...documentBackground ? { documentBackground } : {},
355201
355270
  ...columns ? { columns } : {},
355202
355271
  sectionMetadata,
355203
355272
  alternateHeaders
@@ -355217,6 +355286,15 @@ function print() { __p += __j.call(arguments, '') }
355217
355286
  out.push(...blocks2);
355218
355287
  return out;
355219
355288
  }
355289
+ #coerceDocumentBackground(candidate) {
355290
+ if (!candidate || typeof candidate !== "object")
355291
+ return;
355292
+ const color2 = candidate.color;
355293
+ return typeof color2 === "string" && color2.length > 0 ? { color: color2 } : undefined;
355294
+ }
355295
+ #resolveDocumentBackground() {
355296
+ return this.#coerceDocumentBackground(this.#editor?.state?.doc?.attrs?.documentBackground) ?? (this.#configuredDocumentBackground ? { ...this.#configuredDocumentBackground } : undefined);
355297
+ }
355220
355298
  #buildHeaderFooterInput() {
355221
355299
  if (this.#isSemanticFlowMode())
355222
355300
  return null;
@@ -357186,11 +357264,11 @@ function print() { __p += __j.call(arguments, '') }
357186
357264
  ]);
357187
357265
  });
357188
357266
 
357189
- // ../../packages/superdoc/dist/chunks/create-super-doc-ui-Dzh6dolN.es.js
357267
+ // ../../packages/superdoc/dist/chunks/create-super-doc-ui-DcawZW5k.es.js
357190
357268
  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;
357191
- var init_create_super_doc_ui_Dzh6dolN_es = __esm(() => {
357192
- init_SuperConverter_CvwFiCth_es();
357193
- init_create_headless_toolbar_DdDLS67b_es();
357269
+ var init_create_super_doc_ui_DcawZW5k_es = __esm(() => {
357270
+ init_SuperConverter_EumzHoTv_es();
357271
+ init_create_headless_toolbar_CRyPCXZF_es();
357194
357272
  MOD_ALIASES = new Set([
357195
357273
  "Mod",
357196
357274
  "Meta",
@@ -357232,16 +357310,16 @@ var init_zipper_yaJVJ4z9_es = __esm(() => {
357232
357310
 
357233
357311
  // ../../packages/superdoc/dist/super-editor.es.js
357234
357312
  var init_super_editor_es = __esm(() => {
357235
- init_src_BbNQjpxw_es();
357236
- init_SuperConverter_CvwFiCth_es();
357313
+ init_src_CibMiO0y_es();
357314
+ init_SuperConverter_EumzHoTv_es();
357237
357315
  init_jszip_C49i9kUs_es();
357238
357316
  init_xml_js_CqGKpaft_es();
357239
- init_create_headless_toolbar_DdDLS67b_es();
357317
+ init_create_headless_toolbar_CRyPCXZF_es();
357240
357318
  init_constants_D_X7xF4s_es();
357241
357319
  init_dist_B8HfvhaK_es();
357242
357320
  init_unified_Dsuw2be5_es();
357243
357321
  init_DocxZipper_nv_KfOqb_es();
357244
- init_create_super_doc_ui_Dzh6dolN_es();
357322
+ init_create_super_doc_ui_DcawZW5k_es();
357245
357323
  init_ui_C5PAS9hY_es();
357246
357324
  init_eventemitter3_BnGqBE_Q_es();
357247
357325
  init_errors_CNaD6vcg_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.16.0-next.15",
3
+ "version": "0.16.0-next.16",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -24,20 +24,20 @@
24
24
  "@types/node": "22.19.2",
25
25
  "@types/ws": "^8.5.13",
26
26
  "typescript": "^5.9.2",
27
+ "@superdoc/super-editor": "0.0.1",
27
28
  "@superdoc/document-api": "0.0.1",
28
- "superdoc": "1.38.0",
29
- "@superdoc/super-editor": "0.0.1"
29
+ "superdoc": "1.38.0"
30
30
  },
31
31
  "module": "src/index.ts",
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
35
  "optionalDependencies": {
36
- "@superdoc-dev/cli-darwin-arm64": "0.16.0-next.15",
37
- "@superdoc-dev/cli-darwin-x64": "0.16.0-next.15",
38
- "@superdoc-dev/cli-linux-x64": "0.16.0-next.15",
39
- "@superdoc-dev/cli-linux-arm64": "0.16.0-next.15",
40
- "@superdoc-dev/cli-windows-x64": "0.16.0-next.15"
36
+ "@superdoc-dev/cli-darwin-arm64": "0.16.0-next.16",
37
+ "@superdoc-dev/cli-darwin-x64": "0.16.0-next.16",
38
+ "@superdoc-dev/cli-linux-x64": "0.16.0-next.16",
39
+ "@superdoc-dev/cli-linux-arm64": "0.16.0-next.16",
40
+ "@superdoc-dev/cli-windows-x64": "0.16.0-next.16"
41
41
  },
42
42
  "scripts": {
43
43
  "predev": "node scripts/ensure-superdoc-build.js",