@superdoc-dev/cli 0.2.0-next.93 → 0.2.0-next.95

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 +109 -21
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -96229,7 +96229,7 @@ var init_remark_stringify_D8vxv_XI_es = __esm(() => {
96229
96229
  eol = /\r?\n|\r/g;
96230
96230
  });
96231
96231
 
96232
- // ../../packages/superdoc/dist/chunks/DocxZipper-Dd7pl56D.es.js
96232
+ // ../../packages/superdoc/dist/chunks/DocxZipper-Dt7MDO2A.es.js
96233
96233
  function getLens2(b64) {
96234
96234
  var len$1 = b64.length;
96235
96235
  if (len$1 % 4 > 0)
@@ -96401,6 +96401,10 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96401
96401
  async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
96402
96402
  const additionalPartNames = Object.keys(updatedDocs || {});
96403
96403
  const newMediaTypes = Object.keys(media).map((name) => this.getFileExtension(name)).filter((ext) => ext && IMAGE_EXTS.has(ext));
96404
+ const extensionlessMediaOverrides = Object.entries(media).filter(([name]) => !this.getFileExtension(name)).map(([name, value]) => ({
96405
+ name,
96406
+ contentType: this.#detectImageContentType(value)
96407
+ })).filter((entry) => entry.contentType);
96404
96408
  const contentTypesPath = "[Content_Types].xml";
96405
96409
  let contentTypesXml;
96406
96410
  if (fromJson)
@@ -96423,6 +96427,13 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96423
96427
  seenTypes.add(type);
96424
96428
  }
96425
96429
  const types3 = JSON.parse(import_lib3.xml2json(contentTypesXml, null, 2)).elements?.find((el) => el.name === "Types") || {};
96430
+ const hasPartOverride = (partName) => types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === partName);
96431
+ for (const { name, contentType } of extensionlessMediaOverrides) {
96432
+ const partName = `/${name}`;
96433
+ if (hasPartOverride(partName))
96434
+ continue;
96435
+ typesString += `<Override PartName="${partName}" ContentType="${contentType}" />`;
96436
+ }
96426
96437
  const hasComments = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/comments.xml");
96427
96438
  const hasCommentsExtended = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/commentsExtended.xml");
96428
96439
  const hasCommentsIds = types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === "/word/commentsIds.xml");
@@ -96596,8 +96607,24 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
96596
96607
  await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
96597
96608
  return unzippedOriginalDocx;
96598
96609
  }
96610
+ #detectImageContentType(value) {
96611
+ if (value == null)
96612
+ return null;
96613
+ if (typeof value === "string" && value.startsWith("data:image/"))
96614
+ return value.match(/^data:(image\/[a-zA-Z0-9.+-]+);/i)?.[1]?.toLowerCase() || null;
96615
+ let detectedType = null;
96616
+ if (value instanceof ArrayBuffer)
96617
+ detectedType = detectImageType(new Uint8Array(value));
96618
+ else if (ArrayBuffer.isView(value))
96619
+ detectedType = detectImageType(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));
96620
+ else if (typeof value === "string")
96621
+ detectedType = detectImageType(value.startsWith("data:") ? value.split(",", 2)[1] : value);
96622
+ if (!detectedType)
96623
+ return null;
96624
+ return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
96625
+ }
96599
96626
  }, DocxZipper_default;
96600
- var init_DocxZipper_Dd7pl56D_es = __esm(() => {
96627
+ var init_DocxZipper_Dt7MDO2A_es = __esm(() => {
96601
96628
  init_rolldown_runtime_B2q5OVn9_es();
96602
96629
  init_jszip_ChlR43oI_es();
96603
96630
  init_xml_js_DLE8mr0n_es();
@@ -98231,7 +98258,10 @@ var init_DocxZipper_Dd7pl56D_es = __esm(() => {
98231
98258
  "svg",
98232
98259
  "webp"
98233
98260
  ]);
98234
- MIME_TYPE_FOR_EXT = { tif: "tiff" };
98261
+ MIME_TYPE_FOR_EXT = {
98262
+ tif: "tiff",
98263
+ jpg: "jpeg"
98264
+ };
98235
98265
  DocxZipper_default = DocxZipper;
98236
98266
  });
98237
98267
 
@@ -121884,9 +121914,9 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
121884
121914
  init_remark_gfm_z_sDF4ss_es();
121885
121915
  });
121886
121916
 
121887
- // ../../packages/superdoc/dist/chunks/src-DJwSvw2I.es.js
121888
- var exports_src_DJwSvw2I_es = {};
121889
- __export(exports_src_DJwSvw2I_es, {
121917
+ // ../../packages/superdoc/dist/chunks/src-BciUeGjt.es.js
121918
+ var exports_src_BciUeGjt_es = {};
121919
+ __export(exports_src_BciUeGjt_es, {
121890
121920
  zt: () => defineMark,
121891
121921
  z: () => cM,
121892
121922
  yt: () => removeAwarenessStates,
@@ -180667,11 +180697,53 @@ var Node$13 = class Node$14 {
180667
180697
  });
180668
180698
  }, derivePreferredFileName = (src) => {
180669
180699
  if (typeof src !== "string" || src.length === 0)
180670
- return "image.bin";
180700
+ return "image.jpg";
180671
180701
  if (src.startsWith("data:"))
180672
180702
  return getBase64FileMeta(src).filename;
180673
- return (src.split("/").pop() ?? "").split(/[?#]/)[0] || "image.bin";
180674
- }, handleNodePath = (foundImages, editor, state) => {
180703
+ const trimmed = (src.split("/").pop() ?? "").split(/[?#]/)[0];
180704
+ if (!trimmed)
180705
+ return "image.jpg";
180706
+ if (!trimmed.includes("."))
180707
+ return `${trimmed}.jpg`;
180708
+ return trimmed;
180709
+ }, parsePositiveInt = (value) => {
180710
+ const parsed = Number.parseInt(String(value), 10);
180711
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : null;
180712
+ }, parseSizeFromImageUrl = (src) => {
180713
+ if (typeof src !== "string" || src.length === 0 || !src.startsWith("http"))
180714
+ return null;
180715
+ try {
180716
+ const url = new URL(src);
180717
+ const width = parsePositiveInt(url.searchParams.get("width")) ?? parsePositiveInt(url.searchParams.get("w")) ?? parsePositiveInt(url.searchParams.get("imgw"));
180718
+ const height = parsePositiveInt(url.searchParams.get("height")) ?? parsePositiveInt(url.searchParams.get("h")) ?? parsePositiveInt(url.searchParams.get("imgh"));
180719
+ if (width && height)
180720
+ return {
180721
+ width,
180722
+ height
180723
+ };
180724
+ const segments = url.pathname.split("/").filter(Boolean);
180725
+ const last2 = parsePositiveInt(segments.at(-1));
180726
+ const secondLast = parsePositiveInt(segments.at(-2));
180727
+ if (secondLast && last2)
180728
+ return {
180729
+ width: secondLast,
180730
+ height: last2
180731
+ };
180732
+ const compact = segments.at(-1)?.match(/^(\d{1,5})x(\d{1,5})$/i);
180733
+ if (compact) {
180734
+ const compactWidth = parsePositiveInt(compact[1]);
180735
+ const compactHeight = parsePositiveInt(compact[2]);
180736
+ if (compactWidth && compactHeight)
180737
+ return {
180738
+ width: compactWidth,
180739
+ height: compactHeight
180740
+ };
180741
+ }
180742
+ } catch {
180743
+ return null;
180744
+ }
180745
+ return null;
180746
+ }, hasFinitePositiveSize = (size$2) => Number.isFinite(size$2?.width) && size$2.width > 0 && Number.isFinite(size$2?.height) && size$2.height > 0, handleNodePath = (foundImages, editor, state) => {
180675
180747
  const { tr } = state;
180676
180748
  const mediaStore = editor.storage.image.media ?? {};
180677
180749
  if (!editor.storage.image.media)
@@ -180687,8 +180759,10 @@ var Node$13 = class Node$14 {
180687
180759
  editor,
180688
180760
  path: mediaPath.startsWith("word/") ? mediaPath.slice(5) : mediaPath
180689
180761
  });
180762
+ const inferredSize = hasFinitePositiveSize(node3.attrs?.size) ? null : parseSizeFromImageUrl(src);
180690
180763
  tr.setNodeMarkup(pos, undefined, {
180691
180764
  ...node3.attrs,
180765
+ ...inferredSize ? { size: inferredSize } : {},
180692
180766
  src: mediaPath,
180693
180767
  rId
180694
180768
  });
@@ -199108,7 +199182,7 @@ var Node$13 = class Node$14 {
199108
199182
  trackedChanges: context.trackedChanges ?? []
199109
199183
  });
199110
199184
  }, _hoisted_1$6, _hoisted_2$2, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, _hoisted_2$1, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_HEIGHT_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, POPOVER_VERTICAL_OFFSET_PX = 15, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
199111
- var init_src_DJwSvw2I_es = __esm(() => {
199185
+ var init_src_BciUeGjt_es = __esm(() => {
199112
199186
  init_rolldown_runtime_B2q5OVn9_es();
199113
199187
  init_SuperConverter_6i_hCnOE_es();
199114
199188
  init_jszip_ChlR43oI_es();
@@ -199117,7 +199191,7 @@ var init_src_DJwSvw2I_es = __esm(() => {
199117
199191
  init_unified_BRHLwnjP_es();
199118
199192
  init_remark_gfm_z_sDF4ss_es();
199119
199193
  init_remark_stringify_D8vxv_XI_es();
199120
- init_DocxZipper_Dd7pl56D_es();
199194
+ init_DocxZipper_Dt7MDO2A_es();
199121
199195
  init_vue_q66HzpoR_es();
199122
199196
  init__plugin_vue_export_helper_HmhZBO0u_es();
199123
199197
  init_eventemitter3_DGBTyUUP_es();
@@ -213818,6 +213892,7 @@ function print() { __p += __j.call(arguments, '') }
213818
213892
  this.mount.insertBefore(this.virtualPagesEl, this.bottomSpacerEl);
213819
213893
  this.mount.appendChild(this.bottomSpacerEl);
213820
213894
  let prevIndex = null;
213895
+ let cursor = this.virtualPagesEl.firstChild;
213821
213896
  for (const idx of mounted) {
213822
213897
  if (prevIndex != null && idx > prevIndex + 1) {
213823
213898
  const gap = this.doc.createElement("div");
@@ -213827,10 +213902,13 @@ function print() { __p += __j.call(arguments, '') }
213827
213902
  const gapHeight = this.topOfIndex(idx) - this.topOfIndex(prevIndex) - this.virtualHeights[prevIndex] - this.virtualGap * 2;
213828
213903
  gap.style.height = `${Math.max(0, Math.floor(gapHeight))}px`;
213829
213904
  this.virtualGapSpacers.push(gap);
213830
- this.virtualPagesEl.appendChild(gap);
213905
+ this.virtualPagesEl.insertBefore(gap, cursor);
213831
213906
  }
213832
213907
  const state = this.pageIndexToState.get(idx);
213833
- this.virtualPagesEl.appendChild(state.element);
213908
+ if (state.element === cursor)
213909
+ cursor = state.element.nextSibling;
213910
+ else
213911
+ this.virtualPagesEl.insertBefore(state.element, cursor);
213834
213912
  prevIndex = idx;
213835
213913
  }
213836
213914
  this.changedBlocks.clear();
@@ -219244,12 +219322,22 @@ function print() { __p += __j.call(arguments, '') }
219244
219322
  return;
219245
219323
  this.#pendingDocChange = false;
219246
219324
  this.#isRerendering = true;
219325
+ const activeHfEditor = (this.#headerFooterSession?.session?.mode ?? "body") !== "body" ? this.#headerFooterSession?.activeEditor : null;
219326
+ const hadHfFocus = activeHfEditor?.view?.hasFocus?.() ?? false;
219247
219327
  try {
219248
219328
  await this.#rerender();
219249
219329
  } finally {
219250
219330
  this.#isRerendering = false;
219251
219331
  if (this.#pendingDocChange)
219252
219332
  this.#scheduleRerender();
219333
+ if (hadHfFocus && activeHfEditor?.view && this.#headerFooterSession?.activeEditor === activeHfEditor) {
219334
+ const doc$2 = this.#visibleHost.ownerDocument;
219335
+ const editorDom = activeHfEditor.view.dom;
219336
+ if (doc$2 && !editorDom.contains(doc$2.activeElement))
219337
+ try {
219338
+ activeHfEditor.view.focus();
219339
+ } catch {}
219340
+ }
219253
219341
  }
219254
219342
  }
219255
219343
  async#rerender() {
@@ -230845,8 +230933,8 @@ function print() { __p += __j.call(arguments, '') }
230845
230933
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
230846
230934
  };
230847
230935
  stubFalse_default = stubFalse;
230848
- freeExports$2 = typeof exports_src_DJwSvw2I_es == "object" && exports_src_DJwSvw2I_es && !exports_src_DJwSvw2I_es.nodeType && exports_src_DJwSvw2I_es;
230849
- freeModule$2 = freeExports$2 && typeof module_src_DJwSvw2I_es == "object" && module_src_DJwSvw2I_es && !module_src_DJwSvw2I_es.nodeType && module_src_DJwSvw2I_es;
230936
+ freeExports$2 = typeof exports_src_BciUeGjt_es == "object" && exports_src_BciUeGjt_es && !exports_src_BciUeGjt_es.nodeType && exports_src_BciUeGjt_es;
230937
+ freeModule$2 = freeExports$2 && typeof module_src_BciUeGjt_es == "object" && module_src_BciUeGjt_es && !module_src_BciUeGjt_es.nodeType && module_src_BciUeGjt_es;
230850
230938
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
230851
230939
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
230852
230940
  typedArrayTags = {};
@@ -230854,8 +230942,8 @@ function print() { __p += __j.call(arguments, '') }
230854
230942
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
230855
230943
  _baseIsTypedArray_default = baseIsTypedArray;
230856
230944
  _baseUnary_default = baseUnary;
230857
- freeExports$1 = typeof exports_src_DJwSvw2I_es == "object" && exports_src_DJwSvw2I_es && !exports_src_DJwSvw2I_es.nodeType && exports_src_DJwSvw2I_es;
230858
- freeModule$1 = freeExports$1 && typeof module_src_DJwSvw2I_es == "object" && module_src_DJwSvw2I_es && !module_src_DJwSvw2I_es.nodeType && module_src_DJwSvw2I_es;
230945
+ freeExports$1 = typeof exports_src_BciUeGjt_es == "object" && exports_src_BciUeGjt_es && !exports_src_BciUeGjt_es.nodeType && exports_src_BciUeGjt_es;
230946
+ freeModule$1 = freeExports$1 && typeof module_src_BciUeGjt_es == "object" && module_src_BciUeGjt_es && !module_src_BciUeGjt_es.nodeType && module_src_BciUeGjt_es;
230859
230947
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
230860
230948
  _nodeUtil_default = function() {
230861
230949
  try {
@@ -230960,8 +231048,8 @@ function print() { __p += __j.call(arguments, '') }
230960
231048
  Stack.prototype.has = _stackHas_default;
230961
231049
  Stack.prototype.set = _stackSet_default;
230962
231050
  _Stack_default = Stack;
230963
- freeExports = typeof exports_src_DJwSvw2I_es == "object" && exports_src_DJwSvw2I_es && !exports_src_DJwSvw2I_es.nodeType && exports_src_DJwSvw2I_es;
230964
- freeModule = freeExports && typeof module_src_DJwSvw2I_es == "object" && module_src_DJwSvw2I_es && !module_src_DJwSvw2I_es.nodeType && module_src_DJwSvw2I_es;
231051
+ freeExports = typeof exports_src_BciUeGjt_es == "object" && exports_src_BciUeGjt_es && !exports_src_BciUeGjt_es.nodeType && exports_src_BciUeGjt_es;
231052
+ freeModule = freeExports && typeof module_src_BciUeGjt_es == "object" && module_src_BciUeGjt_es && !module_src_BciUeGjt_es.nodeType && module_src_BciUeGjt_es;
230965
231053
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
230966
231054
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
230967
231055
  _cloneBuffer_default = cloneBuffer;
@@ -239041,13 +239129,13 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
239041
239129
 
239042
239130
  // ../../packages/superdoc/dist/super-editor.es.js
239043
239131
  var init_super_editor_es = __esm(() => {
239044
- init_src_DJwSvw2I_es();
239132
+ init_src_BciUeGjt_es();
239045
239133
  init_SuperConverter_6i_hCnOE_es();
239046
239134
  init_jszip_ChlR43oI_es();
239047
239135
  init_xml_js_DLE8mr0n_es();
239048
239136
  init_constants_CMPtQbp7_es();
239049
239137
  init_unified_BRHLwnjP_es();
239050
- init_DocxZipper_Dd7pl56D_es();
239138
+ init_DocxZipper_Dt7MDO2A_es();
239051
239139
  init_vue_q66HzpoR_es();
239052
239140
  init_eventemitter3_DGBTyUUP_es();
239053
239141
  init_zipper_DqXT7uTa_es();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superdoc-dev/cli",
3
- "version": "0.2.0-next.93",
3
+ "version": "0.2.0-next.95",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -20,21 +20,21 @@
20
20
  "@types/bun": "^1.3.8",
21
21
  "@types/node": "22.19.2",
22
22
  "typescript": "^5.9.2",
23
- "@superdoc/document-api": "0.0.1",
24
- "@superdoc/super-editor": "0.0.1",
25
23
  "@superdoc/pm-adapter": "0.0.0",
26
- "superdoc": "1.17.0"
24
+ "superdoc": "1.17.0",
25
+ "@superdoc/super-editor": "0.0.1",
26
+ "@superdoc/document-api": "0.0.1"
27
27
  },
28
28
  "module": "src/index.ts",
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.93",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.93",
35
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.93",
36
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.93",
37
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.93"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.95",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.95",
35
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.95",
36
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.95",
37
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.95"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",