@harbour-enterprises/superdoc 0.16.0-next.6 → 0.16.0-next.8

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 (26) hide show
  1. package/dist/chunks/{PdfViewer-C2jabOIC.es.js → PdfViewer-9PXb3rXA.es.js} +1 -1
  2. package/dist/chunks/{PdfViewer-Bo1mmRQc.cjs → PdfViewer-BgQbGxHT.cjs} +1 -1
  3. package/dist/chunks/{index-Cpz-BlCy.cjs → index-DUgJwepM.cjs} +3 -3
  4. package/dist/chunks/{index-BD1QDCEJ.es.js → index-YhT-JqcA.es.js} +3 -3
  5. package/dist/chunks/{super-editor.es-DA9uXxN3.cjs → super-editor.es-BG4kMZpU.cjs} +83 -25
  6. package/dist/chunks/{super-editor.es-FHwj0NoO.es.js → super-editor.es-DB_XiddH.es.js} +83 -25
  7. package/dist/super-editor/ai-writer.es.js +2 -2
  8. package/dist/super-editor/chunks/{converter-BHHM5A0T.js → converter-CY1WQn6N.js} +33 -6
  9. package/dist/super-editor/chunks/{docx-zipper-B-WaDouD.js → docx-zipper-DAn84JFm.js} +50 -19
  10. package/dist/super-editor/chunks/{editor-EpJu9duS.js → editor-C66ryrYS.js} +3 -3
  11. package/dist/super-editor/chunks/{toolbar-BDL5cHxp.js → toolbar-Br_su5P2.js} +2 -2
  12. package/dist/super-editor/converter.es.js +1 -1
  13. package/dist/super-editor/docx-zipper.es.js +2 -2
  14. package/dist/super-editor/editor.es.js +3 -3
  15. package/dist/super-editor/file-zipper.es.js +1 -1
  16. package/dist/super-editor/src/core/encoding-helpers.d.ts +27 -0
  17. package/dist/super-editor/src/core/utilities/clipboardUtils.d.ts +7 -17
  18. package/dist/super-editor/super-editor.es.js +6 -6
  19. package/dist/super-editor/toolbar.es.js +2 -2
  20. package/dist/super-editor.cjs +1 -1
  21. package/dist/super-editor.es.js +1 -1
  22. package/dist/superdoc.cjs +2 -2
  23. package/dist/superdoc.es.js +2 -2
  24. package/dist/superdoc.umd.js +84 -26
  25. package/dist/superdoc.umd.js.map +1 -1
  26. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import { J as JSZip } from "./chunks/docx-zipper-B-WaDouD.js";
1
+ import { J as JSZip } from "./chunks/docx-zipper-DAn84JFm.js";
2
2
  async function createZip(blobs, fileNames) {
3
3
  const zip = new JSZip();
4
4
  blobs.forEach((blob, index) => {
@@ -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;
@@ -1,22 +1,12 @@
1
1
  /**
2
- * Serializes the current selection in the editor state to HTML and plain text for clipboard use.
3
- * @param {EditorState} state - The ProseMirror editor state containing the current selection.
4
- * @returns {{ htmlString: string, text: string }} An object with the HTML string and plain text of the selection.
2
+ * Checks if clipboard read permission is granted and handles permission prompts.
3
+ * Returns true if clipboard-read permission is granted. If state is "prompt" it will
4
+ * proactively trigger a readText() call which will surface the browser permission
5
+ * dialog to the user. Falls back gracefully in older browsers that lack the
6
+ * Permissions API.
7
+ * @returns {Promise<boolean>} Whether clipboard read permission is granted
5
8
  */
6
- export function serializeSelectionToClipboard(state: EditorState): {
7
- htmlString: string;
8
- text: string;
9
- };
10
- /**
11
- * Writes HTML and plain text data to the system clipboard.
12
- * Uses the Clipboard API if available, otherwise falls back to plain text.
13
- * @param {{ htmlString: string, text: string }} param0 - The HTML and plain text to write to the clipboard.
14
- * @returns {Promise<void>} A promise that resolves when the clipboard write is complete.
15
- */
16
- export function writeToClipboard({ htmlString, text }: {
17
- htmlString: string;
18
- text: string;
19
- }): Promise<void>;
9
+ export function ensureClipboardPermission(): Promise<boolean>;
20
10
  /**
21
11
  * Reads content from the system clipboard and parses it into a ProseMirror fragment.
22
12
  * Attempts to read HTML first, falling back to plain text if necessary.
@@ -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-BHHM5A0T.js";
13
- import { aE, a4, d, a1 } from "./chunks/converter-BHHM5A0T.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-EpJu9duS.js";
15
- import { k, C, l, T, i, m, j } from "./chunks/editor-EpJu9duS.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-CY1WQn6N.js";
13
+ import { aE, a4, d, a1 } from "./chunks/converter-CY1WQn6N.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-C66ryrYS.js";
15
+ import { k, C, l, T, i, m, j } from "./chunks/editor-C66ryrYS.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-BDL5cHxp.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-Br_su5P2.js";
18
18
  import AIWriter from "./ai-writer.es.js";
19
- import { D } from "./chunks/docx-zipper-B-WaDouD.js";
19
+ import { D } from "./chunks/docx-zipper-DAn84JFm.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-BDL5cHxp.js";
3
- import "./chunks/editor-EpJu9duS.js";
2
+ import { T } from "./chunks/toolbar-Br_su5P2.js";
3
+ import "./chunks/editor-C66ryrYS.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-DA9uXxN3.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-BG4kMZpU.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-FHwj0NoO.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-DB_XiddH.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-DA9uXxN3.cjs");
4
- const superdoc = require("./chunks/index-Cpz-BlCy.cjs");
3
+ const superEditor_es = require("./chunks/super-editor.es-BG4kMZpU.cjs");
4
+ const superdoc = require("./chunks/index-DUgJwepM.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-FHwj0NoO.es.js";
2
- import { D, H, P, S as S2, m, l } from "./chunks/index-BD1QDCEJ.es.js";
1
+ import { a, E, b, S, d, i, j, n, p, q } from "./chunks/super-editor.es-DB_XiddH.es.js";
2
+ import { D, H, P, S as S2, m, l } from "./chunks/index-YhT-JqcA.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";
@@ -25412,10 +25412,36 @@
25412
25412
  function minMax(value = 0, min2 = 0, max2 = 0) {
25413
25413
  return Math.min(Math.max(value, min2), max2);
25414
25414
  }
25415
+ async function ensureClipboardPermission() {
25416
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
25417
+ return false;
25418
+ }
25419
+ if (!navigator.permissions || typeof navigator.permissions.query !== "function") {
25420
+ return true;
25421
+ }
25422
+ try {
25423
+ const status = await navigator.permissions.query({ name: "clipboard-read" });
25424
+ if (status.state === "granted") {
25425
+ return true;
25426
+ }
25427
+ if (status.state === "prompt") {
25428
+ try {
25429
+ await navigator.clipboard.readText();
25430
+ return true;
25431
+ } catch {
25432
+ return false;
25433
+ }
25434
+ }
25435
+ return false;
25436
+ } catch {
25437
+ return false;
25438
+ }
25439
+ }
25415
25440
  async function readFromClipboard(state2) {
25416
25441
  let html = "";
25417
25442
  let text = "";
25418
- if (navigator.clipboard && navigator.clipboard.read) {
25443
+ const hasPermission = await ensureClipboardPermission();
25444
+ if (hasPermission && navigator.clipboard && navigator.clipboard.read) {
25419
25445
  try {
25420
25446
  const items = await navigator.clipboard.read();
25421
25447
  for (const item of items) {
@@ -25427,10 +25453,11 @@
25427
25453
  }
25428
25454
  }
25429
25455
  } catch {
25430
- text = await navigator.clipboard.readText();
25456
+ try {
25457
+ text = await navigator.clipboard.readText();
25458
+ } catch {
25459
+ }
25431
25460
  }
25432
- } else {
25433
- text = await navigator.clipboard.readText();
25434
25461
  }
25435
25462
  let content = null;
25436
25463
  if (html) {
@@ -37720,7 +37747,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37720
37747
  return;
37721
37748
  }
37722
37749
  }
37723
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.5") {
37750
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.7") {
37724
37751
  const customLocation = "docProps/custom.xml";
37725
37752
  if (!docx[customLocation]) {
37726
37753
  docx[customLocation] = generateCustomXml();
@@ -38202,7 +38229,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
38202
38229
  function generateCustomXml() {
38203
38230
  return DEFAULT_CUSTOM_XML;
38204
38231
  }
38205
- function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.5") {
38232
+ function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.7") {
38206
38233
  return {
38207
38234
  type: "element",
38208
38235
  name: "property",
@@ -40541,6 +40568,40 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40541
40568
  }
40542
40569
  var jszip_minExports = requireJszip_min();
40543
40570
  const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1$1(jszip_minExports);
40571
+ const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
40572
+ function sniffEncoding(u8) {
40573
+ if (u8.length >= 2) {
40574
+ const b0 = u8[0], b1 = u8[1];
40575
+ if (b0 === 255 && b1 === 254) return "utf-16le";
40576
+ if (b0 === 254 && b1 === 255) return "utf-16be";
40577
+ }
40578
+ let nul = 0;
40579
+ for (let i2 = 0; i2 < Math.min(64, u8.length); i2++) if (u8[i2] === 0) nul++;
40580
+ if (nul > 16) return "utf-16le";
40581
+ return "utf-8";
40582
+ }
40583
+ function stripBOM(str) {
40584
+ return str && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
40585
+ }
40586
+ function ensureXmlString(content) {
40587
+ if (typeof content === "string") return stripBOM(content);
40588
+ let u8 = null;
40589
+ if (content && typeof content === "object") {
40590
+ if (content instanceof Uint8Array) {
40591
+ u8 = content;
40592
+ } else if (typeof Buffer2 !== "undefined" && Buffer2.isBuffer && Buffer2.isBuffer(content)) {
40593
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
40594
+ } else if (ArrayBuffer.isView && ArrayBuffer.isView(content)) {
40595
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
40596
+ } else if (content.constructor && (content instanceof ArrayBuffer || content.constructor.name === "ArrayBuffer")) {
40597
+ u8 = new Uint8Array(content);
40598
+ }
40599
+ }
40600
+ if (!u8) throw new Error("Unsupported content type for XML");
40601
+ const enc = sniffEncoding(u8);
40602
+ let xml = new TextDecoder(enc).decode(u8);
40603
+ return stripBOM(xml);
40604
+ }
40544
40605
  class DocxZipper {
40545
40606
  constructor(params2 = {}) {
40546
40607
  this.debug = params2.debug || false;
@@ -40571,32 +40632,29 @@ Please report this to https://github.com/markedjs/marked.`, e) {
40571
40632
  async getDocxData(file, isNode2 = false) {
40572
40633
  const extractedFiles = await this.unzip(file);
40573
40634
  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/") {
40635
+ for (const [, zipEntry] of files) {
40636
+ const name = zipEntry.name;
40637
+ if (isXmlLike(name)) {
40638
+ const u8 = await zipEntry.async("uint8array");
40639
+ const content = ensureXmlString(u8);
40640
+ this.files.push({ name, content });
40641
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
40584
40642
  if (isNode2) {
40585
40643
  const buffer2 = await zipEntry.async("nodebuffer");
40586
40644
  const fileBase64 = buffer2.toString("base64");
40587
- this.mediaFiles[zipEntry.name] = fileBase64;
40645
+ this.mediaFiles[name] = fileBase64;
40588
40646
  } else {
40589
40647
  const blob = await zipEntry.async("blob");
40590
- const extension = this.getFileExtension(zipEntry.name);
40648
+ const extension = this.getFileExtension(name);
40591
40649
  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;
40650
+ this.mediaFiles[name] = `data:image/${extension};base64,${fileBase64}`;
40651
+ const fileObj = new File([blob], name, { type: blob.type });
40652
+ const imageUrl = URL.createObjectURL(fileObj);
40653
+ this.media[name] = imageUrl;
40596
40654
  }
40597
- } else if (zipEntry.name.startsWith("word/fonts") && zipEntry.name !== "word/fonts/") {
40655
+ } else if (name.startsWith("word/fonts") && name !== "word/fonts/") {
40598
40656
  const uint8array = await zipEntry.async("uint8array");
40599
- this.fonts[zipEntry.name] = uint8array;
40657
+ this.fonts[name] = uint8array;
40600
40658
  }
40601
40659
  }
40602
40660
  return this.files;
@@ -54941,7 +54999,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
54941
54999
  * @returns {Object | void} Migration results
54942
55000
  */
54943
55001
  processCollaborationMigrations() {
54944
- console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.5");
55002
+ console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.7");
54945
55003
  if (!this.options.ydoc) return;
54946
55004
  const metaMap = this.options.ydoc.getMap("meta");
54947
55005
  let docVersion = metaMap.get("version");
@@ -104455,7 +104513,7 @@ ${style2}
104455
104513
  this.config.colors = shuffleArray(this.config.colors);
104456
104514
  this.userColorMap = /* @__PURE__ */ new Map();
104457
104515
  this.colorIndex = 0;
104458
- this.version = "0.16.0-next.5";
104516
+ this.version = "0.16.0-next.7";
104459
104517
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
104460
104518
  this.superdocId = config.superdocId || v4();
104461
104519
  this.colors = this.config.colors;