@superdoc-dev/cli 0.2.0-next.140 → 0.2.0-next.142

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 +110 -18
  2. package/package.json +6 -6
package/dist/index.js CHANGED
@@ -110306,7 +110306,7 @@ var init_remark_stringify_D8vxv_XI_es = __esm(() => {
110306
110306
  eol = /\r?\n|\r/g;
110307
110307
  });
110308
110308
 
110309
- // ../../packages/superdoc/dist/chunks/DocxZipper-_tW4mTs0.es.js
110309
+ // ../../packages/superdoc/dist/chunks/DocxZipper-BmRnFofk.es.js
110310
110310
  function getLens2(b64) {
110311
110311
  var len$1 = b64.length;
110312
110312
  if (len$1 % 4 > 0)
@@ -110616,7 +110616,7 @@ function syncPackageMetadata({ baseFiles, updatedDocs }) {
110616
110616
  relsXml: serializeXml(relsParsed)
110617
110617
  };
110618
110618
  }
110619
- var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", buffer2, base64Js2, lookup2, revLookup2, Arr2, code4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i2, len2, ieee7542, Buffer3, isXmlLike = (name) => /\.xml$|\.rels$/i.test(name), MANAGED_PACKAGE_PARTS, import_lib$12, RELATIONSHIPS_NS = "http://schemas.openxmlformats.org/package/2006/relationships", import_lib3, import_jszip_min, IMAGE_EXTS, MIME_TYPE_FOR_EXT, CUSTOM_XML_ITEM_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", DocxZipper = class {
110619
+ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", buffer2, base64Js2, lookup2, revLookup2, Arr2, code4 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", i2, len2, ieee7542, Buffer3, isXmlLike = (name) => /\.xml$|\.rels$/i.test(name), MANAGED_PACKAGE_PARTS, import_lib$12, RELATIONSHIPS_NS = "http://schemas.openxmlformats.org/package/2006/relationships", import_lib3, import_jszip_min, IMAGE_EXTS, MIME_TYPE_FOR_EXT, CUSTOM_XML_ITEM_PROPS_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.customXmlProperties+xml", FONT_CONTENT_TYPES, DocxZipper = class {
110620
110620
  constructor(params = {}) {
110621
110621
  this.debug = params.debug || false;
110622
110622
  this.zip = new import_jszip_min.default;
@@ -110672,7 +110672,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110672
110672
  return null;
110673
110673
  return fileSplit[fileSplit.length - 1];
110674
110674
  }
110675
- async updateContentTypes(docx, media, fromJson, updatedDocs = {}) {
110675
+ async updateContentTypes(docx, media, fromJson, updatedDocs = {}, fonts = {}) {
110676
110676
  const additionalPartNames = Object.keys(updatedDocs || {});
110677
110677
  const newMediaTypes = Object.keys(media).map((name) => this.getFileExtension(name)).filter((ext) => ext && IMAGE_EXTS.has(ext));
110678
110678
  const extensionlessMediaOverrides = Object.entries(media).filter(([name]) => !this.getFileExtension(name)).map(([name, value]) => ({
@@ -110700,6 +110700,17 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110700
110700
  typesString += newContentType;
110701
110701
  seenTypes.add(type);
110702
110702
  }
110703
+ if (fonts) {
110704
+ const fontExts = new Set(Object.keys(fonts).map((name) => this.getFileExtension(name)).filter((ext) => ext && FONT_CONTENT_TYPES[ext]));
110705
+ for (const ext of fontExts) {
110706
+ if (defaultMediaTypes.includes(ext))
110707
+ continue;
110708
+ if (seenTypes.has(ext))
110709
+ continue;
110710
+ typesString += `<Default Extension="${ext}" ContentType="${FONT_CONTENT_TYPES[ext]}"/>`;
110711
+ seenTypes.add(ext);
110712
+ }
110713
+ }
110703
110714
  const types3 = JSON.parse(import_lib3.xml2json(contentTypesXml, null, 2)).elements?.find((el) => el.name === "Types") || {};
110704
110715
  const hasPartOverride = (partName) => types3.elements?.some((el) => el.name === "Override" && el.attributes.PartName === partName);
110705
110716
  for (const { name, contentType } of extensionlessMediaOverrides) {
@@ -110854,7 +110865,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110854
110865
  async updateZip({ docx, updatedDocs, originalDocxFile, media, fonts, isHeadless, compression = "DEFLATE" }) {
110855
110866
  let zip;
110856
110867
  if (originalDocxFile)
110857
- zip = await this.exportFromOriginalFile(originalDocxFile, updatedDocs, media);
110868
+ zip = await this.exportFromOriginalFile(originalDocxFile, updatedDocs, media, fonts);
110858
110869
  else
110859
110870
  zip = await this.exportFromCollaborativeDocx(docx, updatedDocs, media, fonts);
110860
110871
  const exportType = isHeadless ? "nodebuffer" : "blob";
@@ -110884,11 +110895,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110884
110895
  });
110885
110896
  for (const [fontName, fontUintArray] of Object.entries(fonts))
110886
110897
  zip.file(fontName, fontUintArray);
110887
- await this.updateContentTypes(zip, media, false, updatedDocs);
110898
+ await this.updateContentTypes(zip, media, false, updatedDocs, fonts);
110888
110899
  await this.#syncPackageMetadataInZip(zip);
110889
110900
  return zip;
110890
110901
  }
110891
- async exportFromOriginalFile(originalDocxFile, updatedDocs, media) {
110902
+ async exportFromOriginalFile(originalDocxFile, updatedDocs, media, fonts) {
110892
110903
  const unzippedOriginalDocx = await this.unzip(originalDocxFile);
110893
110904
  const filePromises = [];
110894
110905
  unzippedOriginalDocx.forEach((relativePath, zipEntry) => {
@@ -110907,7 +110918,10 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110907
110918
  Object.keys(media).forEach((path2) => {
110908
110919
  unzippedOriginalDocx.file(path2, media[path2]);
110909
110920
  });
110910
- await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs);
110921
+ if (fonts)
110922
+ for (const [fontName, fontUintArray] of Object.entries(fonts))
110923
+ unzippedOriginalDocx.file(fontName, fontUintArray);
110924
+ await this.updateContentTypes(unzippedOriginalDocx, media, false, updatedDocs, fonts);
110911
110925
  await this.#syncPackageMetadataInZip(unzippedOriginalDocx);
110912
110926
  return unzippedOriginalDocx;
110913
110927
  }
@@ -110928,7 +110942,7 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
110928
110942
  return `image/${MIME_TYPE_FOR_EXT[detectedType] || detectedType}`;
110929
110943
  }
110930
110944
  }, DocxZipper_default;
110931
- var init_DocxZipper__tW4mTs0_es = __esm(() => {
110945
+ var init_DocxZipper_BmRnFofk_es = __esm(() => {
110932
110946
  init_rolldown_runtime_B2q5OVn9_es();
110933
110947
  init_jszip_ChlR43oI_es();
110934
110948
  init_xml_js_DLE8mr0n_es();
@@ -112589,6 +112603,11 @@ var init_DocxZipper__tW4mTs0_es = __esm(() => {
112589
112603
  tif: "tiff",
112590
112604
  jpg: "jpeg"
112591
112605
  };
112606
+ FONT_CONTENT_TYPES = {
112607
+ odttf: "application/vnd.openxmlformats-officedocument.obfuscatedFont",
112608
+ ttf: "application/x-font-ttf",
112609
+ otf: "application/vnd.ms-opentype"
112610
+ };
112592
112611
  DocxZipper_default = DocxZipper;
112593
112612
  });
112594
112613
 
@@ -136026,7 +136045,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
136026
136045
  init_remark_gfm_z_sDF4ss_es();
136027
136046
  });
136028
136047
 
136029
- // ../../packages/superdoc/dist/chunks/src-D8pRcaK_.es.js
136048
+ // ../../packages/superdoc/dist/chunks/src-DLZxEXCY.es.js
136030
136049
  function deleteProps(obj, propOrProps) {
136031
136050
  const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
136032
136051
  const removeNested = (target, pathParts, index2 = 0) => {
@@ -138924,7 +138943,7 @@ function createPositionTrackerPlugin() {
138924
138943
  }
138925
138944
  },
138926
138945
  props: { decorations() {
138927
- return DecorationSet.empty;
138946
+ return null;
138928
138947
  } }
138929
138948
  });
138930
138949
  }
@@ -215721,6 +215740,7 @@ var Node$13 = class Node$14 {
215721
215740
  #footerRegions = /* @__PURE__ */ new Map;
215722
215741
  #session = { mode: "body" };
215723
215742
  #activeEditor = null;
215743
+ #activeEditorEventCleanup = null;
215724
215744
  #hoverOverlay = null;
215725
215745
  #hoverTooltip = null;
215726
215746
  #modeBanner = null;
@@ -215838,6 +215858,7 @@ var Node$13 = class Node$14 {
215838
215858
  resetSession: () => {
215839
215859
  this.#managerCleanups = [];
215840
215860
  this.#session = { mode: "body" };
215861
+ this.#teardownActiveEditorEventBridge();
215841
215862
  this.#activeEditor = null;
215842
215863
  this.#deps?.notifyInputBridgeTargetChanged();
215843
215864
  },
@@ -215992,6 +216013,7 @@ var Node$13 = class Node$14 {
215992
216013
  this.#activeEditor.setEditable(false);
215993
216014
  this.#activeEditor.setOptions({ documentMode: "viewing" });
215994
216015
  }
216016
+ this.#teardownActiveEditorEventBridge();
215995
216017
  this.#overlayManager?.hideEditingOverlay();
215996
216018
  this.#overlayManager?.showSelectionOverlay();
215997
216019
  this.#activeEditor = null;
@@ -216025,6 +216047,7 @@ var Node$13 = class Node$14 {
216025
216047
  this.#activeEditor.setEditable(false);
216026
216048
  this.#activeEditor.setOptions({ documentMode: "viewing" });
216027
216049
  }
216050
+ this.#teardownActiveEditorEventBridge();
216028
216051
  this.#overlayManager.hideEditingOverlay();
216029
216052
  this.#activeEditor = null;
216030
216053
  this.#session = { mode: "body" };
@@ -216152,6 +216175,7 @@ var Node$13 = class Node$14 {
216152
216175
  }
216153
216176
  this.#overlayManager.hideSelectionOverlay();
216154
216177
  this.#activeEditor = editor;
216178
+ this.#setupActiveEditorEventBridge(editor);
216155
216179
  this.#session = {
216156
216180
  mode: region.kind,
216157
216181
  kind: region.kind,
@@ -216175,6 +216199,7 @@ var Node$13 = class Node$14 {
216175
216199
  this.#overlayManager?.hideEditingOverlay();
216176
216200
  this.#overlayManager?.showSelectionOverlay();
216177
216201
  this.clearHover();
216202
+ this.#teardownActiveEditorEventBridge();
216178
216203
  this.#activeEditor = null;
216179
216204
  this.#session = { mode: "body" };
216180
216205
  } catch (cleanupError) {
@@ -216234,6 +216259,46 @@ var Node$13 = class Node$14 {
216234
216259
  const message = this.#session.mode === "body" ? "Exited header/footer edit mode." : `Editing ${this.#session.kind === "header" ? "Header" : "Footer"} (${this.#session.sectionType ?? "default"})`;
216235
216260
  this.#callbacks.onAnnounce?.(message);
216236
216261
  }
216262
+ #setupActiveEditorEventBridge(editor) {
216263
+ this.#teardownActiveEditorEventBridge();
216264
+ const emitSurfaceUpdate = () => {
216265
+ if (this.#session.mode !== "header" && this.#session.mode !== "footer")
216266
+ return;
216267
+ this.#callbacks.onSurfaceUpdate?.({
216268
+ sourceEditor: editor,
216269
+ surface: this.#session.mode,
216270
+ headerId: this.#session.headerId ?? null,
216271
+ sectionType: this.#session.sectionType ?? null
216272
+ });
216273
+ };
216274
+ const emitSurfaceTransaction = ({ transaction, duration }) => {
216275
+ if (this.#session.mode !== "header" && this.#session.mode !== "footer")
216276
+ return;
216277
+ this.#callbacks.onSurfaceTransaction?.({
216278
+ sourceEditor: editor,
216279
+ surface: this.#session.mode,
216280
+ headerId: this.#session.headerId ?? null,
216281
+ sectionType: this.#session.sectionType ?? null,
216282
+ transaction,
216283
+ duration
216284
+ });
216285
+ };
216286
+ editor.on("update", emitSurfaceUpdate);
216287
+ editor.on("transaction", emitSurfaceTransaction);
216288
+ this.#activeEditorEventCleanup = () => {
216289
+ editor.off?.("update", emitSurfaceUpdate);
216290
+ editor.off?.("transaction", emitSurfaceTransaction);
216291
+ };
216292
+ }
216293
+ #teardownActiveEditorEventBridge() {
216294
+ try {
216295
+ this.#activeEditorEventCleanup?.();
216296
+ } catch (error) {
216297
+ console.warn("[HeaderFooterSessionManager] Failed to clean up active editor bridge:", error);
216298
+ } finally {
216299
+ this.#activeEditorEventCleanup = null;
216300
+ }
216301
+ }
216237
216302
  #updateModeBanner() {
216238
216303
  if (!this.#modeBanner)
216239
216304
  return;
@@ -216650,6 +216715,7 @@ var Node$13 = class Node$14 {
216650
216715
  return pages[0];
216651
216716
  }
216652
216717
  destroy() {
216718
+ this.#teardownActiveEditorEventBridge();
216653
216719
  this.#managerCleanups.forEach((fn) => {
216654
216720
  try {
216655
216721
  fn();
@@ -221809,7 +221875,7 @@ var Node$13 = class Node$14 {
221809
221875
  return false;
221810
221876
  return Boolean(checker(attrs));
221811
221877
  }, SuperToolbar, ICONS, TEXTS, tableActionsOptions;
221812
- var init_src_D8pRcaK__es = __esm(() => {
221878
+ var init_src_DLZxEXCY_es = __esm(() => {
221813
221879
  init_rolldown_runtime_B2q5OVn9_es();
221814
221880
  init_SuperConverter_BParsWaS_es();
221815
221881
  init_jszip_ChlR43oI_es();
@@ -221818,7 +221884,7 @@ var init_src_D8pRcaK__es = __esm(() => {
221818
221884
  init_unified_BRHLwnjP_es();
221819
221885
  init_remark_gfm_z_sDF4ss_es();
221820
221886
  init_remark_stringify_D8vxv_XI_es();
221821
- init_DocxZipper__tW4mTs0_es();
221887
+ init_DocxZipper_BmRnFofk_es();
221822
221888
  init_vue_DQHWm9lq_es();
221823
221889
  init__plugin_vue_export_helper_HmhZBO0u_es();
221824
221890
  init_eventemitter3_DGBTyUUP_es();
@@ -231442,7 +231508,7 @@ function print() { __p += __j.call(arguments, '') }
231442
231508
  resolvedOptions.isNewFile = explicitIsNewFile ?? false;
231443
231509
  this.#sourcePath = null;
231444
231510
  }
231445
- } else if (resolvedMode === "docx" && !options?.content && !options?.html && !options?.markdown && !options?.json) {
231511
+ } else if (resolvedMode === "docx" && !options?.content && !options?.html && !options?.markdown) {
231446
231512
  const arrayBuffer = await getArrayBufferFromUrl(BLANK_DOCX_DATA_URI);
231447
231513
  const canUseBuffer = typeof process$1$1 !== "undefined" && !!process$1$1.versions?.node && typeof Buffer3 !== "undefined";
231448
231514
  const uint8Array = new Uint8Array(arrayBuffer);
@@ -231455,8 +231521,14 @@ function print() { __p += __j.call(arguments, '') }
231455
231521
  throw new Error("Blob is not available to create blank DOCX");
231456
231522
  const [docx, _media, mediaFiles, fonts] = await Editor2.loadXmlData(fileSource, canUseBuffer);
231457
231523
  resolvedOptions.content = docx;
231458
- resolvedOptions.mediaFiles = mediaFiles;
231459
- resolvedOptions.fonts = fonts;
231524
+ resolvedOptions.mediaFiles = {
231525
+ ...mediaFiles,
231526
+ ...options?.mediaFiles ?? {}
231527
+ };
231528
+ resolvedOptions.fonts = {
231529
+ ...fonts,
231530
+ ...options?.fonts ?? {}
231531
+ };
231460
231532
  resolvedOptions.fileSource = fileSource;
231461
231533
  resolvedOptions.isNewFile = explicitIsNewFile ?? true;
231462
231534
  this.#sourcePath = null;
@@ -232513,7 +232585,7 @@ function print() { __p += __j.call(arguments, '') }
232513
232585
  }
232514
232586
  const zipper = new DocxZipper_default;
232515
232587
  if (getUpdatedDocs) {
232516
- updatedDocs["[Content_Types].xml"] = await zipper.updateContentTypes({ files: this.options.content }, media2, true, updatedDocs);
232588
+ updatedDocs["[Content_Types].xml"] = await zipper.updateContentTypes({ files: this.options.content }, media2, true, updatedDocs, this.options.fonts);
232517
232589
  const content3 = this.options.content;
232518
232590
  const { contentTypesXml, relsXml } = syncPackageMetadata({
232519
232591
  baseFiles: Array.isArray(content3) || content3 && typeof content3 === "object" ? content3 : null,
@@ -242344,6 +242416,26 @@ function print() { __p += __j.call(arguments, '') }
242344
242416
  },
242345
242417
  onUpdateAwarenessSession: () => {
242346
242418
  this.#updateAwarenessSession();
242419
+ },
242420
+ onSurfaceUpdate: ({ sourceEditor, surface, headerId, sectionType }) => {
242421
+ this.emit("headerFooterUpdate", {
242422
+ editor: this.#editor,
242423
+ sourceEditor,
242424
+ surface,
242425
+ headerId,
242426
+ sectionType
242427
+ });
242428
+ },
242429
+ onSurfaceTransaction: ({ sourceEditor, surface, headerId, sectionType, transaction, duration }) => {
242430
+ this.emit("headerFooterTransaction", {
242431
+ editor: this.#editor,
242432
+ sourceEditor,
242433
+ surface,
242434
+ headerId,
242435
+ sectionType,
242436
+ transaction,
242437
+ duration
242438
+ });
242347
242439
  }
242348
242440
  });
242349
242441
  this.#headerFooterSession.initialize();
@@ -255633,13 +255725,13 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
255633
255725
 
255634
255726
  // ../../packages/superdoc/dist/super-editor.es.js
255635
255727
  var init_super_editor_es = __esm(() => {
255636
- init_src_D8pRcaK__es();
255728
+ init_src_DLZxEXCY_es();
255637
255729
  init_SuperConverter_BParsWaS_es();
255638
255730
  init_jszip_ChlR43oI_es();
255639
255731
  init_xml_js_DLE8mr0n_es();
255640
255732
  init_constants_CMPtQbp7_es();
255641
255733
  init_unified_BRHLwnjP_es();
255642
- init_DocxZipper__tW4mTs0_es();
255734
+ init_DocxZipper_BmRnFofk_es();
255643
255735
  init_vue_DQHWm9lq_es();
255644
255736
  init_eventemitter3_DGBTyUUP_es();
255645
255737
  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.140",
3
+ "version": "0.2.0-next.142",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "superdoc": "./dist/index.js"
@@ -30,11 +30,11 @@
30
30
  "access": "public"
31
31
  },
32
32
  "optionalDependencies": {
33
- "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.140",
34
- "@superdoc-dev/cli-darwin-x64": "0.2.0-next.140",
35
- "@superdoc-dev/cli-linux-arm64": "0.2.0-next.140",
36
- "@superdoc-dev/cli-windows-x64": "0.2.0-next.140",
37
- "@superdoc-dev/cli-linux-x64": "0.2.0-next.140"
33
+ "@superdoc-dev/cli-darwin-arm64": "0.2.0-next.142",
34
+ "@superdoc-dev/cli-darwin-x64": "0.2.0-next.142",
35
+ "@superdoc-dev/cli-linux-x64": "0.2.0-next.142",
36
+ "@superdoc-dev/cli-linux-arm64": "0.2.0-next.142",
37
+ "@superdoc-dev/cli-windows-x64": "0.2.0-next.142"
38
38
  },
39
39
  "scripts": {
40
40
  "dev": "bun run src/index.ts",