@harbour-enterprises/superdoc 0.19.0-next.3 → 0.19.0-next.4

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.
@@ -4225,7 +4225,7 @@ const _sfc_main$1 = {
4225
4225
  required: false
4226
4226
  },
4227
4227
  fileSource: {
4228
- type: File,
4228
+ type: [File, Blob],
4229
4229
  required: false
4230
4230
  },
4231
4231
  state: {
@@ -4505,7 +4505,7 @@ const _sfc_main$1 = {
4505
4505
  };
4506
4506
  }
4507
4507
  };
4508
- const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-dc9f9cb3"]]);
4508
+ const SuperEditor = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-8b2f8c17"]]);
4509
4509
  const _hoisted_1 = ["innerHTML"];
4510
4510
  const _sfc_main = {
4511
4511
  __name: "SuperInput",
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-BbN2QJLe.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-B_u6OGsf.cjs");
4
4
  require("./chunks/vue-DWle4Cai.cjs");
5
5
  exports.AIWriter = superEditor_es.AIWriter;
6
6
  exports.AnnotatorHelpers = superEditor_es.AnnotatorHelpers;
@@ -1,4 +1,4 @@
1
- import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-Dga1v3zZ.es.js";
1
+ import { A, a, _, C, D, E, b, S, c, d, e, f, g, T, h, i, j, k, l, m, n, o, p, r, q } from "./chunks/super-editor.es-C2QwEj1z.es.js";
2
2
  import "./chunks/vue-CXxsqYcP.es.js";
3
3
  export {
4
4
  A as AIWriter,
package/dist/superdoc.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const superEditor_es = require("./chunks/super-editor.es-BbN2QJLe.cjs");
4
- const superdoc = require("./chunks/index-Dg8DEGbE.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-B_u6OGsf.cjs");
4
+ const superdoc = require("./chunks/index-CWQGBk3Z.cjs");
5
5
  require("./chunks/vue-DWle4Cai.cjs");
6
6
  require("./chunks/jszip-b7l8QkfH.cjs");
7
7
  const blankDocx = require("./chunks/blank-docx-CPqX9RF5.cjs");
@@ -1,5 +1,5 @@
1
- import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-Dga1v3zZ.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-Bgbca9Qo.es.js";
1
+ import { a, E, b, S, d, i, j, n, r, p, q } from "./chunks/super-editor.es-C2QwEj1z.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-C_oHQN7n.es.js";
3
3
  import "./chunks/vue-CXxsqYcP.es.js";
4
4
  import "./chunks/jszip-B8KIZSNe.es.js";
5
5
  import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";
@@ -88708,7 +88708,7 @@ ${style2}
88708
88708
  required: false
88709
88709
  },
88710
88710
  fileSource: {
88711
- type: File,
88711
+ type: [File, Blob],
88712
88712
  required: false
88713
88713
  },
88714
88714
  state: {
@@ -88988,7 +88988,7 @@ ${style2}
88988
88988
  };
88989
88989
  }
88990
88990
  };
88991
- const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-dc9f9cb3"]]);
88991
+ const SuperEditor = /* @__PURE__ */ _export_sfc$1(_sfc_main$1$1, [["__scopeId", "data-v-8b2f8c17"]]);
88992
88992
  const _hoisted_1$h = ["innerHTML"];
88993
88993
  const _sfc_main$i = {
88994
88994
  __name: "SuperInput",
@@ -90300,6 +90300,59 @@ ${style2}
90300
90300
  return refs;
90301
90301
  }
90302
90302
  }
90303
+ const extractBrowserFile = (input) => {
90304
+ if (!input) return null;
90305
+ if (typeof File === "function" && input instanceof File) return input;
90306
+ if (typeof Blob === "function" && input instanceof Blob) {
90307
+ const hasFileCtor = typeof File === "function";
90308
+ if (hasFileCtor) {
90309
+ const name = input.name || "document";
90310
+ return new File([input], name, { type: input.type });
90311
+ }
90312
+ return input;
90313
+ }
90314
+ if (input.originFileObj) return extractBrowserFile(input.originFileObj);
90315
+ if (input.file) return extractBrowserFile(input.file);
90316
+ if (input.raw) return extractBrowserFile(input.raw);
90317
+ return null;
90318
+ };
90319
+ const inferTypeFromName = (name = "") => {
90320
+ const lower = String(name).toLowerCase();
90321
+ if (lower.endsWith(".docx")) return DOCX;
90322
+ if (lower.endsWith(".pdf")) return PDF;
90323
+ if (lower.endsWith(".html") || lower.endsWith(".htm")) return HTML;
90324
+ if (lower.endsWith(".md") || lower.endsWith(".markdown")) return "text/markdown";
90325
+ return "";
90326
+ };
90327
+ const normalizeDocumentEntry = (entry) => {
90328
+ const maybeFile = extractBrowserFile(entry);
90329
+ if (maybeFile) {
90330
+ const name = (
90331
+ /** @type {any} */
90332
+ maybeFile.name || entry && entry.name || "document"
90333
+ );
90334
+ const type2 = maybeFile.type || inferTypeFromName(name) || DOCX;
90335
+ return {
90336
+ type: type2,
90337
+ data: maybeFile,
90338
+ name,
90339
+ isNewFile: true
90340
+ };
90341
+ }
90342
+ if (entry && typeof entry === "object" && "data" in entry) {
90343
+ const file = extractBrowserFile(entry.data);
90344
+ if (file) {
90345
+ const type2 = entry.type || file.type || inferTypeFromName(file.name) || DOCX;
90346
+ return {
90347
+ ...entry,
90348
+ type: type2,
90349
+ data: file,
90350
+ name: entry.name || file.name || "document"
90351
+ };
90352
+ }
90353
+ }
90354
+ return entry;
90355
+ };
90303
90356
  function useFieldValueWatcher(field, originalValue) {
90304
90357
  const fieldId = field.itemid;
90305
90358
  const rawField = field;
@@ -92155,13 +92208,39 @@ ${reason}`);
92155
92208
  }
92156
92209
  }
92157
92210
  };
92211
+ const _blobToFile = (blob, name, type2) => {
92212
+ return new File([blob], name, { type: type2 });
92213
+ };
92158
92214
  const _initializeDocumentData = async (doc2) => {
92215
+ doc2 = normalizeDocumentEntry(doc2);
92159
92216
  if (currentConfig.value?.html) doc2.html = currentConfig.value.html;
92160
92217
  if (!doc2.data && doc2.url && !doc2.type) doc2.type = DOCX;
92161
92218
  if (currentConfig.value?.modules.collaboration && !doc2.isNewFile) {
92162
92219
  return { ...doc2, data: null, url: null };
92163
92220
  }
92164
- if (doc2.data) return doc2;
92221
+ if (doc2.data instanceof File) {
92222
+ let fileName = doc2.name;
92223
+ const extension = doc2.type === DOCX ? ".docx" : doc2.type === PDF ? ".pdf" : ".bin";
92224
+ if (!fileName) {
92225
+ fileName = `document${extension}`;
92226
+ } else if (!fileName.includes(".")) {
92227
+ fileName = `${fileName}${extension}`;
92228
+ }
92229
+ if (doc2.data.name !== fileName) {
92230
+ const fileObject = _blobToFile(doc2.data, fileName, doc2.data.type || doc2.type);
92231
+ return { ...doc2, name: fileName, data: fileObject };
92232
+ }
92233
+ if (!doc2.name) return { ...doc2, name: fileName };
92234
+ return doc2;
92235
+ } else if (doc2.data instanceof Blob) {
92236
+ let fileName = doc2.name;
92237
+ if (!fileName) {
92238
+ const extension = doc2.type === DOCX ? ".docx" : doc2.type === PDF ? ".pdf" : ".bin";
92239
+ fileName = `document${extension}`;
92240
+ }
92241
+ const fileObject = _blobToFile(doc2.data, fileName, doc2.data.type || doc2.type);
92242
+ return { ...doc2, data: fileObject };
92243
+ } else if (doc2.data) return doc2;
92165
92244
  else if (doc2.url && doc2.type) {
92166
92245
  if (doc2.type.toLowerCase() === "docx") doc2.type = DOCX;
92167
92246
  else if (doc2.type.toLowerCase() === "pdf") doc2.type = PDF;
@@ -105371,7 +105450,7 @@ ${style2}
105371
105450
  __name: "HtmlViewer",
105372
105451
  props: {
105373
105452
  fileSource: {
105374
- type: File,
105453
+ type: [File, Blob],
105375
105454
  required: true
105376
105455
  },
105377
105456
  documentId: {
@@ -105426,7 +105505,7 @@ ${style2}
105426
105505
  };
105427
105506
  }
105428
105507
  };
105429
- const HtmlViewer = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-7bd2cb5d"]]);
105508
+ const HtmlViewer = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-da3494ba"]]);
105430
105509
  const _hoisted_1$2 = {
105431
105510
  class: "ai-highlight-container",
105432
105511
  id: "aiHighlightContainer"
@@ -106304,13 +106383,15 @@ ${style2}
106304
106383
  const doc2 = this.config.document;
106305
106384
  const hasDocumentConfig = !!doc2 && typeof doc2 === "object" && Object.keys(this.config.document)?.length;
106306
106385
  const hasDocumentUrl = !!doc2 && typeof doc2 === "string" && doc2.length > 0;
106307
- const hasDocumentFile = !!doc2 && doc2 instanceof File;
106386
+ const hasDocumentFile = !!doc2 && typeof File === "function" && doc2 instanceof File;
106387
+ const hasDocumentBlob = !!doc2 && doc2 instanceof Blob && !(doc2 instanceof File);
106308
106388
  const hasListOfDocuments = this.config.documents && this.config.documents?.length;
106309
106389
  if (hasDocumentConfig && hasListOfDocuments) {
106310
106390
  console.warn("🦋 [superdoc] You can only provide one of document or documents");
106311
106391
  }
106312
106392
  if (hasDocumentConfig) {
106313
- this.config.documents = [this.config.document];
106393
+ const normalized = normalizeDocumentEntry(this.config.document);
106394
+ this.config.documents = [normalized];
106314
106395
  } else if (hasDocumentUrl) {
106315
106396
  this.config.documents = [
106316
106397
  {
@@ -106329,6 +106410,25 @@ ${style2}
106329
106410
  isNewFile: true
106330
106411
  }
106331
106412
  ];
106413
+ } else if (hasDocumentBlob) {
106414
+ const docType = this.config.document.type || DOCX;
106415
+ let extension = ".docx";
106416
+ if (docType === PDF) {
106417
+ extension = ".pdf";
106418
+ } else if (docType === HTML) {
106419
+ extension = ".html";
106420
+ }
106421
+ this.config.documents = [
106422
+ {
106423
+ type: docType,
106424
+ data: this.config.document,
106425
+ name: `document${extension}`,
106426
+ isNewFile: true
106427
+ }
106428
+ ];
106429
+ }
106430
+ if (Array.isArray(this.config.documents) && this.config.documents.length > 0) {
106431
+ this.config.documents = this.config.documents.map((d2) => normalizeDocumentEntry(d2));
106332
106432
  }
106333
106433
  }
106334
106434
  #initVueApp() {