@harbour-enterprises/superdoc 0.16.0-next.5 → 0.16.0-next.7

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 (27) hide show
  1. package/dist/chunks/{PdfViewer-D7bVM19y.cjs → PdfViewer-C5x7AU8q.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-Dz8QpLUf.es.js → PdfViewer-Dxf6Q8xr.es.js} +1 -1
  3. package/dist/chunks/{index-BJ2MMpR2.es.js → index-BjIQt0Ko.es.js} +3 -3
  4. package/dist/chunks/{index-BotsOjBq.cjs → index-FvnrFhAG.cjs} +3 -3
  5. package/dist/chunks/{super-editor.es-mYLEB3b5.cjs → super-editor.es-C1fdpMgg.cjs} +58 -24
  6. package/dist/chunks/{super-editor.es-kVtdRZQ7.es.js → super-editor.es-DuPg67jP.es.js} +58 -24
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/super-editor/ai-writer.es.js +2 -2
  9. package/dist/super-editor/chunks/{converter-qGVsOSrM.js → converter-BNYWJQ3Z.js} +2 -2
  10. package/dist/super-editor/chunks/{docx-zipper-DHlP7hwm.js → docx-zipper-Csj1FkZx.js} +50 -19
  11. package/dist/super-editor/chunks/{editor-CNRZtptp.js → editor-DvMBcEqO.js} +9 -6
  12. package/dist/super-editor/chunks/{toolbar-CZA8K--6.js → toolbar--6fQXx6v.js} +2 -2
  13. package/dist/super-editor/converter.es.js +1 -1
  14. package/dist/super-editor/docx-zipper.es.js +2 -2
  15. package/dist/super-editor/editor.es.js +3 -3
  16. package/dist/super-editor/file-zipper.es.js +1 -1
  17. package/dist/super-editor/src/core/commands/insertContentAt.d.ts +3 -1
  18. package/dist/super-editor/src/core/encoding-helpers.d.ts +27 -0
  19. package/dist/super-editor/super-editor.es.js +6 -6
  20. package/dist/super-editor/toolbar.es.js +2 -2
  21. package/dist/super-editor.cjs +1 -1
  22. package/dist/super-editor.es.js +1 -1
  23. package/dist/superdoc.cjs +2 -2
  24. package/dist/superdoc.es.js +2 -2
  25. package/dist/superdoc.umd.js +59 -25
  26. package/dist/superdoc.umd.js.map +1 -1
  27. package/package.json +1 -1
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Hex dump for optional debugging
3
+ * @param {Uint8Array|ArrayBuffer} bytes
4
+ * @param {number} n
5
+ * @returns {string} Hex dump
6
+ */
7
+ export function hex(bytes: Uint8Array | ArrayBuffer, n?: number): string;
8
+ /**
9
+ * Try to detect encoding by BOM / null density
10
+ * @param {Uint8Array} u8
11
+ * @returns {string} Detected encoding
12
+ */
13
+ export function sniffEncoding(u8: Uint8Array): string;
14
+ /**
15
+ * Remove leading BOM from already-decoded JS string
16
+ * @param {string} str
17
+ * @returns {string} Cleaned string without BOM
18
+ */
19
+ export function stripBOM(str: string): string;
20
+ /**
21
+ * Decode XML/RELS content to a clean JS string.
22
+ * Accepts: string | Uint8Array | ArrayBuffer
23
+ * @param {string|Uint8Array|ArrayBuffer} content
24
+ * @returns {string} Clean XML string
25
+ */
26
+ export function ensureXmlString(content: string | Uint8Array | ArrayBuffer): string;
27
+ export function isXmlLike(name: string): boolean;
@@ -9,14 +9,14 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
11
11
  var _SuperToolbar_instances, initToolbarGroups_fn, _interceptedCommands, makeToolbarItems_fn, initDefaultFonts_fn, updateHighlightColors_fn, deactivateAll_fn, updateToolbarHistory_fn, runCommandWithArgumentOnly_fn;
12
- import { aw as getDefaultExportFromCjs, U as v4, T as TextSelection$1, q as getMarkRange, az as vClickOutside, y as findParentNode, aA as getActiveFormatting, aq as isInTable, aB as readFromClipboard, aC as handleClipboardPaste, aD as getFileObject, a as Plugin } from "./chunks/converter-qGVsOSrM.js";
13
- import { aE, a4, d, a1 } from "./chunks/converter-qGVsOSrM.js";
14
- import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, s as startImageUpload, y as yUndoPluginKey, d as undoDepth, r as redoDepth, S as SlashMenuPluginKey, E as Editor, e as getStarterExtensions, P as Placeholder, f as getRichTextExtensions, M as Mark, h as Extension, A as Attribute, N as Node } from "./chunks/editor-CNRZtptp.js";
15
- import { k, C, l, T, i, m, j } from "./chunks/editor-CNRZtptp.js";
12
+ import { aw as getDefaultExportFromCjs, U as v4, T as TextSelection$1, q as getMarkRange, az as vClickOutside, y as findParentNode, aA as getActiveFormatting, aq as isInTable, aB as readFromClipboard, aC as handleClipboardPaste, aD as getFileObject, a as Plugin } from "./chunks/converter-BNYWJQ3Z.js";
13
+ import { aE, a4, d, a1 } from "./chunks/converter-BNYWJQ3Z.js";
14
+ import { _ as _export_sfc, u as useHighContrastMode, a as getQuickFormatList, b as generateLinkedStyleString, c as getFileOpener, s as startImageUpload, y as yUndoPluginKey, d as undoDepth, r as redoDepth, S as SlashMenuPluginKey, E as Editor, e as getStarterExtensions, P as Placeholder, f as getRichTextExtensions, M as Mark, h as Extension, A as Attribute, N as Node } from "./chunks/editor-DvMBcEqO.js";
15
+ import { k, C, l, T, i, m, j } from "./chunks/editor-DvMBcEqO.js";
16
16
  import { ref, onMounted, createElementBlock, openBlock, normalizeClass, unref, Fragment, renderList, createElementVNode, withModifiers, toDisplayString, createCommentVNode, normalizeStyle, computed, watch, withDirectives, withKeys, vModelText, createTextVNode, createVNode, h, createApp, markRaw, nextTick, onBeforeUnmount, reactive, onUnmounted, renderSlot, shallowRef, createBlock, withCtx, resolveDynamicComponent, normalizeProps, guardReactiveProps } from "vue";
17
- import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, m as magicWandIcon, p as plusIconSvg, a as trashIconSvg, l as linkIconSvg, b as tableIconSvg, c as scissorsIconSvg, d as copyIconSvg, e as pasteIconSvg, f as borderNoneIconSvg, g as arrowsToDotIconSvg, h as arrowsLeftRightIconSvg, w as wrenchIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar-CZA8K--6.js";
17
+ import { t as toolbarIcons, s as sanitizeNumber, T as Toolbar, m as magicWandIcon, p as plusIconSvg, a as trashIconSvg, l as linkIconSvg, b as tableIconSvg, c as scissorsIconSvg, d as copyIconSvg, e as pasteIconSvg, f as borderNoneIconSvg, g as arrowsToDotIconSvg, h as arrowsLeftRightIconSvg, w as wrenchIconSvg, u as useMessage, N as NSkeleton } from "./chunks/toolbar--6fQXx6v.js";
18
18
  import AIWriter from "./ai-writer.es.js";
19
- import { D } from "./chunks/docx-zipper-DHlP7hwm.js";
19
+ import { D } from "./chunks/docx-zipper-Csj1FkZx.js";
20
20
  import { createZip } from "./file-zipper.es.js";
21
21
  var eventemitter3 = { exports: {} };
22
22
  var hasRequiredEventemitter3;
@@ -1,6 +1,6 @@
1
1
  import "vue";
2
- import { T } from "./chunks/toolbar-CZA8K--6.js";
3
- import "./chunks/editor-CNRZtptp.js";
2
+ import { T } from "./chunks/toolbar--6fQXx6v.js";
3
+ import "./chunks/editor-DvMBcEqO.js";
4
4
  export {
5
5
  T as default
6
6
  };
@@ -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-mYLEB3b5.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-C1fdpMgg.cjs");
4
4
  require("./chunks/vue-B6WOnFdF.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, q } from "./chunks/super-editor.es-kVtdRZQ7.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, q } from "./chunks/super-editor.es-DuPg67jP.es.js";
2
2
  import "./chunks/vue-xvq3uP6K.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-mYLEB3b5.cjs");
4
- const superdoc = require("./chunks/index-BotsOjBq.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-C1fdpMgg.cjs");
4
+ const superdoc = require("./chunks/index-FvnrFhAG.cjs");
5
5
  require("./chunks/vue-B6WOnFdF.cjs");
6
6
  require("./chunks/jszip-DmmUnPkH.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, p, q } from "./chunks/super-editor.es-kVtdRZQ7.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-BJ2MMpR2.es.js";
1
+ import { a, E, b, S, d, i, j, n, p, q } from "./chunks/super-editor.es-DuPg67jP.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-BjIQt0Ko.es.js";
3
3
  import "./chunks/vue-xvq3uP6K.es.js";
4
4
  import "./chunks/jszip-DXHu60h9.es.js";
5
5
  import { B } from "./chunks/blank-docx-iwdyG9RH.es.js";
@@ -37720,7 +37720,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37720
37720
  return;
37721
37721
  }
37722
37722
  }
37723
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.4") {
37723
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.6") {
37724
37724
  const customLocation = "docProps/custom.xml";
37725
37725
  if (!docx[customLocation]) {
37726
37726
  docx[customLocation] = generateCustomXml();
@@ -38202,7 +38202,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38202
38202
  function generateCustomXml() {
38203
38203
  return DEFAULT_CUSTOM_XML;
38204
38204
  }
38205
- function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.4") {
38205
+ function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.6") {
38206
38206
  return {
38207
38207
  type: "element",
38208
38208
  name: "property",
@@ -40541,6 +40541,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40541
40541
  }
40542
40542
  var jszip_minExports = requireJszip_min();
40543
40543
  const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1$1(jszip_minExports);
40544
+ const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
40545
+ function sniffEncoding(u8) {
40546
+ if (u8.length >= 2) {
40547
+ const b0 = u8[0], b1 = u8[1];
40548
+ if (b0 === 255 && b1 === 254) return "utf-16le";
40549
+ if (b0 === 254 && b1 === 255) return "utf-16be";
40550
+ }
40551
+ let nul = 0;
40552
+ for (let i2 = 0; i2 < Math.min(64, u8.length); i2++) if (u8[i2] === 0) nul++;
40553
+ if (nul > 16) return "utf-16le";
40554
+ return "utf-8";
40555
+ }
40556
+ function stripBOM(str) {
40557
+ return str && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
40558
+ }
40559
+ function ensureXmlString(content) {
40560
+ if (typeof content === "string") return stripBOM(content);
40561
+ let u8 = null;
40562
+ if (content && typeof content === "object") {
40563
+ if (content instanceof Uint8Array) {
40564
+ u8 = content;
40565
+ } else if (typeof Buffer2 !== "undefined" && Buffer2.isBuffer && Buffer2.isBuffer(content)) {
40566
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
40567
+ } else if (ArrayBuffer.isView && ArrayBuffer.isView(content)) {
40568
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
40569
+ } else if (content.constructor && (content instanceof ArrayBuffer || content.constructor.name === "ArrayBuffer")) {
40570
+ u8 = new Uint8Array(content);
40571
+ }
40572
+ }
40573
+ if (!u8) throw new Error("Unsupported content type for XML");
40574
+ const enc = sniffEncoding(u8);
40575
+ let xml = new TextDecoder(enc).decode(u8);
40576
+ return stripBOM(xml);
40577
+ }
40544
40578
  class DocxZipper {
40545
40579
  constructor(params2 = {}) {
40546
40580
  this.debug = params2.debug || false;
@@ -40571,32 +40605,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40571
40605
  async getDocxData(file, isNode2 = false) {
40572
40606
  const extractedFiles = await this.unzip(file);
40573
40607
  const files = Object.entries(extractedFiles.files);
40574
- const validTypes = ["xml", "rels"];
40575
- for (const file2 of files) {
40576
- const [, zipEntry] = file2;
40577
- if (validTypes.some((validType) => zipEntry.name.endsWith(validType))) {
40578
- const content = await zipEntry.async("string");
40579
- this.files.push({
40580
- name: zipEntry.name,
40581
- content
40582
- });
40583
- } else if (zipEntry.name.startsWith("word/media") && zipEntry.name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/") {
40608
+ for (const [, zipEntry] of files) {
40609
+ const name = zipEntry.name;
40610
+ if (isXmlLike(name)) {
40611
+ const u8 = await zipEntry.async("uint8array");
40612
+ const content = ensureXmlString(u8);
40613
+ this.files.push({ name, content });
40614
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
40584
40615
  if (isNode2) {
40585
40616
  const buffer2 = await zipEntry.async("nodebuffer");
40586
40617
  const fileBase64 = buffer2.toString("base64");
40587
- this.mediaFiles[zipEntry.name] = fileBase64;
40618
+ this.mediaFiles[name] = fileBase64;
40588
40619
  } else {
40589
40620
  const blob = await zipEntry.async("blob");
40590
- const extension = this.getFileExtension(zipEntry.name);
40621
+ const extension = this.getFileExtension(name);
40591
40622
  const fileBase64 = await zipEntry.async("base64");
40592
- this.mediaFiles[zipEntry.name] = `data:image/${extension};base64,${fileBase64}`;
40593
- const file3 = new File([blob], zipEntry.name, { type: blob.type });
40594
- const imageUrl = URL.createObjectURL(file3);
40595
- this.media[zipEntry.name] = imageUrl;
40623
+ this.mediaFiles[name] = `data:image/${extension};base64,${fileBase64}`;
40624
+ const fileObj = new File([blob], name, { type: blob.type });
40625
+ const imageUrl = URL.createObjectURL(fileObj);
40626
+ this.media[name] = imageUrl;
40596
40627
  }
40597
- } else if (zipEntry.name.startsWith("word/fonts") && zipEntry.name !== "word/fonts/") {
40628
+ } else if (name.startsWith("word/fonts") && name !== "word/fonts/") {
40598
40629
  const uint8array = await zipEntry.async("uint8array");
40599
- this.fonts[zipEntry.name] = uint8array;
40630
+ this.fonts[name] = uint8array;
40600
40631
  }
40601
40632
  }
40602
40633
  return this.files;
@@ -42756,12 +42787,15 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42756
42787
  return false;
42757
42788
  }
42758
42789
  let { from: from2, to } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
42759
- let isOnlyTextContent = true;
42790
+ const forceTextInsert = typeof value === "string" || Array.isArray(value) && value.every((v2) => typeof v2 === "string" || v2 && typeof v2.text === "string") || value && typeof value === "object" && typeof value.text === "string";
42791
+ let isOnlyTextContent = forceTextInsert;
42760
42792
  let isOnlyBlockContent = true;
42761
42793
  const nodes = isFragment(content) ? content : [content];
42762
42794
  nodes.forEach((node2) => {
42763
42795
  node2.check();
42764
- isOnlyTextContent = isOnlyTextContent ? node2.isText && node2.marks.length === 0 : false;
42796
+ if (!forceTextInsert) {
42797
+ isOnlyTextContent = isOnlyTextContent ? node2.isText && node2.marks.length === 0 : false;
42798
+ }
42765
42799
  isOnlyBlockContent = isOnlyBlockContent ? node2.isBlock : false;
42766
42800
  });
42767
42801
  if (from2 === to && isOnlyBlockContent) {
@@ -42775,7 +42809,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
42775
42809
  let newContent;
42776
42810
  if (isOnlyTextContent) {
42777
42811
  if (Array.isArray(value)) {
42778
- newContent = value.map((v2) => v2.text || "").join("");
42812
+ newContent = value.map((v2) => typeof v2 === "string" ? v2 : v2 && v2.text || "").join("");
42779
42813
  } else if (typeof value === "object" && !!value && !!value.text) {
42780
42814
  newContent = value.text;
42781
42815
  } else {
@@ -54938,7 +54972,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54938
54972
  * @returns {Object | void} Migration results
54939
54973
  */
54940
54974
  processCollaborationMigrations() {
54941
- console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.4");
54975
+ console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.6");
54942
54976
  if (!this.options.ydoc) return;
54943
54977
  const metaMap = this.options.ydoc.getMap("meta");
54944
54978
  let docVersion = metaMap.get("version");
@@ -104452,7 +104486,7 @@ ${style2}
104452
104486
  this.config.colors = shuffleArray(this.config.colors);
104453
104487
  this.userColorMap = /* @__PURE__ */ new Map();
104454
104488
  this.colorIndex = 0;
104455
- this.version = "0.16.0-next.4";
104489
+ this.version = "0.16.0-next.6";
104456
104490
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
104457
104491
  this.superdocId = config.superdocId || v4();
104458
104492
  this.colors = this.config.colors;