@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,5 +1,5 @@
1
1
  import { m as defineComponent, B as h, O as Transition, $ as process$1, I as watchEffect, d as computed, r as ref, j as onMounted, W as onUnmounted, c as createElementBlock, o as openBlock, a as createBaseVNode, f as createCommentVNode, v as createVNode, x as unref } from "./vue-xvq3uP6K.es.js";
2
- import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-BD1QDCEJ.es.js";
2
+ import { d as derived, c, a as cB, f as fadeInTransition, b as cM, N as NBaseLoading, w as warnOnce, u as useConfig, e as useTheme, p as pxfy, g as createKey, h as useThemeClass, i as useCompitable, _ as _export_sfc, j as useSuperdocStore, s as storeToRefs, k as useSelection } from "./index-YhT-JqcA.es.js";
3
3
  function self(vars) {
4
4
  const {
5
5
  opacityDisabled,
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const vue = require("./vue-B6WOnFdF.cjs");
4
- const superdoc = require("./index-Cpz-BlCy.cjs");
4
+ const superdoc = require("./index-DUgJwepM.cjs");
5
5
  function self(vars) {
6
6
  const {
7
7
  opacityDisabled,
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- const superEditor_es = require("./super-editor.es-DA9uXxN3.cjs");
2
+ const superEditor_es = require("./super-editor.es-BG4kMZpU.cjs");
3
3
  const vue = require("./vue-B6WOnFdF.cjs");
4
4
  const jszip = require("./jszip-DmmUnPkH.cjs");
5
5
  const blankDocx = require("./blank-docx-CPqX9RF5.cjs");
@@ -17266,7 +17266,7 @@ const _sfc_main = {
17266
17266
  __name: "SuperDoc",
17267
17267
  emits: ["selection-update"],
17268
17268
  setup(__props, { emit: __emit }) {
17269
- const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-Bo1mmRQc.cjs")));
17269
+ const PdfViewer = vue.defineAsyncComponent(() => Promise.resolve().then(() => require("./PdfViewer-BgQbGxHT.cjs")));
17270
17270
  const superdocStore = useSuperdocStore();
17271
17271
  const commentsStore = useCommentsStore();
17272
17272
  const {
@@ -17909,7 +17909,7 @@ class SuperDoc extends eventemitter3.EventEmitter {
17909
17909
  this.config.colors = shuffleArray(this.config.colors);
17910
17910
  this.userColorMap = /* @__PURE__ */ new Map();
17911
17911
  this.colorIndex = 0;
17912
- this.version = "0.16.0-next.5";
17912
+ this.version = "0.16.0-next.7";
17913
17913
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
17914
17914
  this.superdocId = config.superdocId || uuid.v4();
17915
17915
  this.colors = this.config.colors;
@@ -1,4 +1,4 @@
1
- import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-FHwj0NoO.es.js";
1
+ import { q as index$1, C as CommentsPluginKey, h as TrackChangesBasePluginKey, E as Editor, n as getRichTextExtensions, f as SuperInput, e as SuperEditor, A as AIWriter, g as SuperToolbar, i as createZip } from "./super-editor.es-DB_XiddH.es.js";
2
2
  import { a0 as effectScope, r as ref, _ as markRaw, $ as process$1, a1 as toRaw, d as computed, a2 as isRef, a3 as isReactive, C as toRef, i as inject, p as getCurrentInstance, l as watch, x as unref, a4 as hasInjectionContext, M as reactive, s as nextTick, a5 as getCurrentScope, a6 as onScopeDispose, a7 as toRefs, g as global$1, J as shallowRef, N as readonly, j as onMounted, k as onBeforeUnmount, h as onBeforeMount, S as onActivated, q as onDeactivated, z as createTextVNode, F as Fragment, Q as Comment, m as defineComponent, D as provide, H as withDirectives, B as h, U as Teleport, R as renderSlot, V as isVNode, I as watchEffect, O as Transition, a8 as TransitionGroup, E as mergeProps, P as vShow, G as cloneVNode, T as Text, c as createElementBlock, o as openBlock, t as toDisplayString, v as createVNode, y as withCtx, a as createBaseVNode, A as normalizeStyle, f as createCommentVNode, u as createBlock, w as withModifiers, n as normalizeClass, a9 as resolveDirective, e as renderList, b as createApp, X as resolveDynamicComponent, aa as defineAsyncComponent } from "./vue-xvq3uP6K.es.js";
3
3
  import { B as Buffer$2 } from "./jszip-DXHu60h9.es.js";
4
4
  import { B as BlankDOCX } from "./blank-docx-iwdyG9RH.es.js";
@@ -17249,7 +17249,7 @@ const _sfc_main = {
17249
17249
  __name: "SuperDoc",
17250
17250
  emits: ["selection-update"],
17251
17251
  setup(__props, { emit: __emit }) {
17252
- const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-C2jabOIC.es.js"));
17252
+ const PdfViewer = defineAsyncComponent(() => import("./PdfViewer-9PXb3rXA.es.js"));
17253
17253
  const superdocStore = useSuperdocStore();
17254
17254
  const commentsStore = useCommentsStore();
17255
17255
  const {
@@ -17892,7 +17892,7 @@ class SuperDoc extends EventEmitter {
17892
17892
  this.config.colors = shuffleArray(this.config.colors);
17893
17893
  this.userColorMap = /* @__PURE__ */ new Map();
17894
17894
  this.colorIndex = 0;
17895
- this.version = "0.16.0-next.5";
17895
+ this.version = "0.16.0-next.7";
17896
17896
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
17897
17897
  this.superdocId = config.superdocId || v4();
17898
17898
  this.colors = this.config.colors;
@@ -17720,10 +17720,36 @@ function parseSizeUnit(val = "0") {
17720
17720
  function minMax(value = 0, min2 = 0, max2 = 0) {
17721
17721
  return Math.min(Math.max(value, min2), max2);
17722
17722
  }
17723
+ async function ensureClipboardPermission() {
17724
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
17725
+ return false;
17726
+ }
17727
+ if (!navigator.permissions || typeof navigator.permissions.query !== "function") {
17728
+ return true;
17729
+ }
17730
+ try {
17731
+ const status = await navigator.permissions.query({ name: "clipboard-read" });
17732
+ if (status.state === "granted") {
17733
+ return true;
17734
+ }
17735
+ if (status.state === "prompt") {
17736
+ try {
17737
+ await navigator.clipboard.readText();
17738
+ return true;
17739
+ } catch {
17740
+ return false;
17741
+ }
17742
+ }
17743
+ return false;
17744
+ } catch {
17745
+ return false;
17746
+ }
17747
+ }
17723
17748
  async function readFromClipboard(state2) {
17724
17749
  let html = "";
17725
17750
  let text = "";
17726
- if (navigator.clipboard && navigator.clipboard.read) {
17751
+ const hasPermission = await ensureClipboardPermission();
17752
+ if (hasPermission && navigator.clipboard && navigator.clipboard.read) {
17727
17753
  try {
17728
17754
  const items = await navigator.clipboard.read();
17729
17755
  for (const item of items) {
@@ -17735,10 +17761,11 @@ async function readFromClipboard(state2) {
17735
17761
  }
17736
17762
  }
17737
17763
  } catch {
17738
- text = await navigator.clipboard.readText();
17764
+ try {
17765
+ text = await navigator.clipboard.readText();
17766
+ } catch {
17767
+ }
17739
17768
  }
17740
- } else {
17741
- text = await navigator.clipboard.readText();
17742
17769
  }
17743
17770
  let content = null;
17744
17771
  if (html) {
@@ -30055,7 +30082,7 @@ const _SuperConverter = class _SuperConverter2 {
30055
30082
  return;
30056
30083
  }
30057
30084
  }
30058
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.5") {
30085
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.7") {
30059
30086
  const customLocation = "docProps/custom.xml";
30060
30087
  if (!docx[customLocation]) {
30061
30088
  docx[customLocation] = generateCustomXml();
@@ -30537,7 +30564,7 @@ function storeSuperdocVersion(docx) {
30537
30564
  function generateCustomXml() {
30538
30565
  return DEFAULT_CUSTOM_XML;
30539
30566
  }
30540
- function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.5") {
30567
+ function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.7") {
30541
30568
  return {
30542
30569
  type: "element",
30543
30570
  name: "property",
@@ -32876,6 +32903,40 @@ function requireJszip_min() {
32876
32903
  }
32877
32904
  var jszip_minExports = requireJszip_min();
32878
32905
  const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1(jszip_minExports);
32906
+ const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
32907
+ function sniffEncoding(u8) {
32908
+ if (u8.length >= 2) {
32909
+ const b0 = u8[0], b1 = u8[1];
32910
+ if (b0 === 255 && b1 === 254) return "utf-16le";
32911
+ if (b0 === 254 && b1 === 255) return "utf-16be";
32912
+ }
32913
+ let nul = 0;
32914
+ for (let i = 0; i < Math.min(64, u8.length); i++) if (u8[i] === 0) nul++;
32915
+ if (nul > 16) return "utf-16le";
32916
+ return "utf-8";
32917
+ }
32918
+ function stripBOM(str) {
32919
+ return str && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
32920
+ }
32921
+ function ensureXmlString(content) {
32922
+ if (typeof content === "string") return stripBOM(content);
32923
+ let u8 = null;
32924
+ if (content && typeof content === "object") {
32925
+ if (content instanceof Uint8Array) {
32926
+ u8 = content;
32927
+ } else if (typeof Buffer2 !== "undefined" && Buffer2.isBuffer && Buffer2.isBuffer(content)) {
32928
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
32929
+ } else if (ArrayBuffer.isView && ArrayBuffer.isView(content)) {
32930
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
32931
+ } else if (content.constructor && (content instanceof ArrayBuffer || content.constructor.name === "ArrayBuffer")) {
32932
+ u8 = new Uint8Array(content);
32933
+ }
32934
+ }
32935
+ if (!u8) throw new Error("Unsupported content type for XML");
32936
+ const enc = sniffEncoding(u8);
32937
+ let xml = new TextDecoder(enc).decode(u8);
32938
+ return stripBOM(xml);
32939
+ }
32879
32940
  class DocxZipper {
32880
32941
  constructor(params2 = {}) {
32881
32942
  this.debug = params2.debug || false;
@@ -32906,32 +32967,29 @@ class DocxZipper {
32906
32967
  async getDocxData(file, isNode2 = false) {
32907
32968
  const extractedFiles = await this.unzip(file);
32908
32969
  const files = Object.entries(extractedFiles.files);
32909
- const validTypes = ["xml", "rels"];
32910
- for (const file2 of files) {
32911
- const [, zipEntry] = file2;
32912
- if (validTypes.some((validType) => zipEntry.name.endsWith(validType))) {
32913
- const content = await zipEntry.async("string");
32914
- this.files.push({
32915
- name: zipEntry.name,
32916
- content
32917
- });
32918
- } else if (zipEntry.name.startsWith("word/media") && zipEntry.name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/") {
32970
+ for (const [, zipEntry] of files) {
32971
+ const name = zipEntry.name;
32972
+ if (isXmlLike(name)) {
32973
+ const u8 = await zipEntry.async("uint8array");
32974
+ const content = ensureXmlString(u8);
32975
+ this.files.push({ name, content });
32976
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
32919
32977
  if (isNode2) {
32920
32978
  const buffer2 = await zipEntry.async("nodebuffer");
32921
32979
  const fileBase64 = buffer2.toString("base64");
32922
- this.mediaFiles[zipEntry.name] = fileBase64;
32980
+ this.mediaFiles[name] = fileBase64;
32923
32981
  } else {
32924
32982
  const blob = await zipEntry.async("blob");
32925
- const extension = this.getFileExtension(zipEntry.name);
32983
+ const extension = this.getFileExtension(name);
32926
32984
  const fileBase64 = await zipEntry.async("base64");
32927
- this.mediaFiles[zipEntry.name] = `data:image/${extension};base64,${fileBase64}`;
32928
- const file3 = new File([blob], zipEntry.name, { type: blob.type });
32929
- const imageUrl = URL.createObjectURL(file3);
32930
- this.media[zipEntry.name] = imageUrl;
32985
+ this.mediaFiles[name] = `data:image/${extension};base64,${fileBase64}`;
32986
+ const fileObj = new File([blob], name, { type: blob.type });
32987
+ const imageUrl = URL.createObjectURL(fileObj);
32988
+ this.media[name] = imageUrl;
32931
32989
  }
32932
- } else if (zipEntry.name.startsWith("word/fonts") && zipEntry.name !== "word/fonts/") {
32990
+ } else if (name.startsWith("word/fonts") && name !== "word/fonts/") {
32933
32991
  const uint8array = await zipEntry.async("uint8array");
32934
- this.fonts[zipEntry.name] = uint8array;
32992
+ this.fonts[name] = uint8array;
32935
32993
  }
32936
32994
  }
32937
32995
  return this.files;
@@ -47276,7 +47334,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
47276
47334
  * @returns {Object | void} Migration results
47277
47335
  */
47278
47336
  processCollaborationMigrations() {
47279
- console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.5");
47337
+ console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.7");
47280
47338
  if (!this.options.ydoc) return;
47281
47339
  const metaMap = this.options.ydoc.getMap("meta");
47282
47340
  let docVersion = metaMap.get("version");
@@ -17703,10 +17703,36 @@ function parseSizeUnit(val = "0") {
17703
17703
  function minMax(value = 0, min2 = 0, max2 = 0) {
17704
17704
  return Math.min(Math.max(value, min2), max2);
17705
17705
  }
17706
+ async function ensureClipboardPermission() {
17707
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
17708
+ return false;
17709
+ }
17710
+ if (!navigator.permissions || typeof navigator.permissions.query !== "function") {
17711
+ return true;
17712
+ }
17713
+ try {
17714
+ const status = await navigator.permissions.query({ name: "clipboard-read" });
17715
+ if (status.state === "granted") {
17716
+ return true;
17717
+ }
17718
+ if (status.state === "prompt") {
17719
+ try {
17720
+ await navigator.clipboard.readText();
17721
+ return true;
17722
+ } catch {
17723
+ return false;
17724
+ }
17725
+ }
17726
+ return false;
17727
+ } catch {
17728
+ return false;
17729
+ }
17730
+ }
17706
17731
  async function readFromClipboard(state2) {
17707
17732
  let html = "";
17708
17733
  let text = "";
17709
- if (navigator.clipboard && navigator.clipboard.read) {
17734
+ const hasPermission = await ensureClipboardPermission();
17735
+ if (hasPermission && navigator.clipboard && navigator.clipboard.read) {
17710
17736
  try {
17711
17737
  const items = await navigator.clipboard.read();
17712
17738
  for (const item of items) {
@@ -17718,10 +17744,11 @@ async function readFromClipboard(state2) {
17718
17744
  }
17719
17745
  }
17720
17746
  } catch {
17721
- text = await navigator.clipboard.readText();
17747
+ try {
17748
+ text = await navigator.clipboard.readText();
17749
+ } catch {
17750
+ }
17722
17751
  }
17723
- } else {
17724
- text = await navigator.clipboard.readText();
17725
17752
  }
17726
17753
  let content = null;
17727
17754
  if (html) {
@@ -30038,7 +30065,7 @@ const _SuperConverter = class _SuperConverter2 {
30038
30065
  return;
30039
30066
  }
30040
30067
  }
30041
- static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.5") {
30068
+ static updateDocumentVersion(docx = this.convertedXml, version2 = "0.16.0-next.7") {
30042
30069
  const customLocation = "docProps/custom.xml";
30043
30070
  if (!docx[customLocation]) {
30044
30071
  docx[customLocation] = generateCustomXml();
@@ -30520,7 +30547,7 @@ function storeSuperdocVersion(docx) {
30520
30547
  function generateCustomXml() {
30521
30548
  return DEFAULT_CUSTOM_XML;
30522
30549
  }
30523
- function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.5") {
30550
+ function generateSuperdocVersion(pid = 2, version2 = "0.16.0-next.7") {
30524
30551
  return {
30525
30552
  type: "element",
30526
30553
  name: "property",
@@ -32859,6 +32886,40 @@ function requireJszip_min() {
32859
32886
  }
32860
32887
  var jszip_minExports = requireJszip_min();
32861
32888
  const JSZip = /* @__PURE__ */ getDefaultExportFromCjs$1(jszip_minExports);
32889
+ const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
32890
+ function sniffEncoding(u8) {
32891
+ if (u8.length >= 2) {
32892
+ const b0 = u8[0], b1 = u8[1];
32893
+ if (b0 === 255 && b1 === 254) return "utf-16le";
32894
+ if (b0 === 254 && b1 === 255) return "utf-16be";
32895
+ }
32896
+ let nul = 0;
32897
+ for (let i = 0; i < Math.min(64, u8.length); i++) if (u8[i] === 0) nul++;
32898
+ if (nul > 16) return "utf-16le";
32899
+ return "utf-8";
32900
+ }
32901
+ function stripBOM(str) {
32902
+ return str && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
32903
+ }
32904
+ function ensureXmlString(content) {
32905
+ if (typeof content === "string") return stripBOM(content);
32906
+ let u8 = null;
32907
+ if (content && typeof content === "object") {
32908
+ if (content instanceof Uint8Array) {
32909
+ u8 = content;
32910
+ } else if (typeof Buffer2 !== "undefined" && Buffer2.isBuffer && Buffer2.isBuffer(content)) {
32911
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
32912
+ } else if (ArrayBuffer.isView && ArrayBuffer.isView(content)) {
32913
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
32914
+ } else if (content.constructor && (content instanceof ArrayBuffer || content.constructor.name === "ArrayBuffer")) {
32915
+ u8 = new Uint8Array(content);
32916
+ }
32917
+ }
32918
+ if (!u8) throw new Error("Unsupported content type for XML");
32919
+ const enc = sniffEncoding(u8);
32920
+ let xml = new TextDecoder(enc).decode(u8);
32921
+ return stripBOM(xml);
32922
+ }
32862
32923
  class DocxZipper {
32863
32924
  constructor(params2 = {}) {
32864
32925
  this.debug = params2.debug || false;
@@ -32889,32 +32950,29 @@ class DocxZipper {
32889
32950
  async getDocxData(file, isNode2 = false) {
32890
32951
  const extractedFiles = await this.unzip(file);
32891
32952
  const files = Object.entries(extractedFiles.files);
32892
- const validTypes = ["xml", "rels"];
32893
- for (const file2 of files) {
32894
- const [, zipEntry] = file2;
32895
- if (validTypes.some((validType) => zipEntry.name.endsWith(validType))) {
32896
- const content = await zipEntry.async("string");
32897
- this.files.push({
32898
- name: zipEntry.name,
32899
- content
32900
- });
32901
- } else if (zipEntry.name.startsWith("word/media") && zipEntry.name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/") {
32953
+ for (const [, zipEntry] of files) {
32954
+ const name = zipEntry.name;
32955
+ if (isXmlLike(name)) {
32956
+ const u8 = await zipEntry.async("uint8array");
32957
+ const content = ensureXmlString(u8);
32958
+ this.files.push({ name, content });
32959
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
32902
32960
  if (isNode2) {
32903
32961
  const buffer2 = await zipEntry.async("nodebuffer");
32904
32962
  const fileBase64 = buffer2.toString("base64");
32905
- this.mediaFiles[zipEntry.name] = fileBase64;
32963
+ this.mediaFiles[name] = fileBase64;
32906
32964
  } else {
32907
32965
  const blob = await zipEntry.async("blob");
32908
- const extension = this.getFileExtension(zipEntry.name);
32966
+ const extension = this.getFileExtension(name);
32909
32967
  const fileBase64 = await zipEntry.async("base64");
32910
- this.mediaFiles[zipEntry.name] = `data:image/${extension};base64,${fileBase64}`;
32911
- const file3 = new File([blob], zipEntry.name, { type: blob.type });
32912
- const imageUrl = URL.createObjectURL(file3);
32913
- this.media[zipEntry.name] = imageUrl;
32968
+ this.mediaFiles[name] = `data:image/${extension};base64,${fileBase64}`;
32969
+ const fileObj = new File([blob], name, { type: blob.type });
32970
+ const imageUrl = URL.createObjectURL(fileObj);
32971
+ this.media[name] = imageUrl;
32914
32972
  }
32915
- } else if (zipEntry.name.startsWith("word/fonts") && zipEntry.name !== "word/fonts/") {
32973
+ } else if (name.startsWith("word/fonts") && name !== "word/fonts/") {
32916
32974
  const uint8array = await zipEntry.async("uint8array");
32917
- this.fonts[zipEntry.name] = uint8array;
32975
+ this.fonts[name] = uint8array;
32918
32976
  }
32919
32977
  }
32920
32978
  return this.files;
@@ -47259,7 +47317,7 @@ const _Editor = class _Editor2 extends EventEmitter$1 {
47259
47317
  * @returns {Object | void} Migration results
47260
47318
  */
47261
47319
  processCollaborationMigrations() {
47262
- console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.5");
47320
+ console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.7");
47263
47321
  if (!this.options.ydoc) return;
47264
47322
  const metaMap = this.options.ydoc.getMap("meta");
47265
47323
  let docVersion = metaMap.get("version");
@@ -1,6 +1,6 @@
1
1
  import { ref, onMounted, onUnmounted, computed, createElementBlock, openBlock, withModifiers, createElementVNode, withDirectives, unref, vModelText, createCommentVNode, nextTick } from "vue";
2
- import { T as TextSelection } from "./chunks/converter-BHHM5A0T.js";
3
- import { _ as _export_sfc } from "./chunks/editor-EpJu9duS.js";
2
+ import { T as TextSelection } from "./chunks/converter-CY1WQn6N.js";
3
+ import { _ as _export_sfc } from "./chunks/editor-C66ryrYS.js";
4
4
  const DEFAULT_API_ENDPOINT = "https://sd-dev-express-gateway-i6xtm.ondigitalocean.app/insights";
5
5
  const SYSTEM_PROMPT = "You are an expert copywriter and you are immersed in a document editor. You are to provide document related text responses based on the user prompts. Only write what is asked for. Do not provide explanations. Try to keep placeholders as short as possible. Do not output your prompt. Your instructions are: ";
6
6
  async function baseInsightsFetch(payload, options = {}) {
@@ -17701,10 +17701,36 @@ function parseSizeUnit(val = "0") {
17701
17701
  function minMax(value = 0, min2 = 0, max2 = 0) {
17702
17702
  return Math.min(Math.max(value, min2), max2);
17703
17703
  }
17704
+ async function ensureClipboardPermission() {
17705
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
17706
+ return false;
17707
+ }
17708
+ if (!navigator.permissions || typeof navigator.permissions.query !== "function") {
17709
+ return true;
17710
+ }
17711
+ try {
17712
+ const status = await navigator.permissions.query({ name: "clipboard-read" });
17713
+ if (status.state === "granted") {
17714
+ return true;
17715
+ }
17716
+ if (status.state === "prompt") {
17717
+ try {
17718
+ await navigator.clipboard.readText();
17719
+ return true;
17720
+ } catch {
17721
+ return false;
17722
+ }
17723
+ }
17724
+ return false;
17725
+ } catch {
17726
+ return false;
17727
+ }
17728
+ }
17704
17729
  async function readFromClipboard(state2) {
17705
17730
  let html = "";
17706
17731
  let text = "";
17707
- if (navigator.clipboard && navigator.clipboard.read) {
17732
+ const hasPermission = await ensureClipboardPermission();
17733
+ if (hasPermission && navigator.clipboard && navigator.clipboard.read) {
17708
17734
  try {
17709
17735
  const items = await navigator.clipboard.read();
17710
17736
  for (const item of items) {
@@ -17716,10 +17742,11 @@ async function readFromClipboard(state2) {
17716
17742
  }
17717
17743
  }
17718
17744
  } catch {
17719
- text = await navigator.clipboard.readText();
17745
+ try {
17746
+ text = await navigator.clipboard.readText();
17747
+ } catch {
17748
+ }
17720
17749
  }
17721
- } else {
17722
- text = await navigator.clipboard.readText();
17723
17750
  }
17724
17751
  let content = null;
17725
17752
  if (html) {
@@ -30036,7 +30063,7 @@ const _SuperConverter = class _SuperConverter {
30036
30063
  return;
30037
30064
  }
30038
30065
  }
30039
- static updateDocumentVersion(docx = this.convertedXml, version = "0.16.0-next.5") {
30066
+ static updateDocumentVersion(docx = this.convertedXml, version = "0.16.0-next.7") {
30040
30067
  const customLocation = "docProps/custom.xml";
30041
30068
  if (!docx[customLocation]) {
30042
30069
  docx[customLocation] = generateCustomXml();
@@ -30521,7 +30548,7 @@ function storeSuperdocVersion(docx) {
30521
30548
  function generateCustomXml() {
30522
30549
  return DEFAULT_CUSTOM_XML;
30523
30550
  }
30524
- function generateSuperdocVersion(pid = 2, version = "0.16.0-next.5") {
30551
+ function generateSuperdocVersion(pid = 2, version = "0.16.0-next.7") {
30525
30552
  return {
30526
30553
  type: "element",
30527
30554
  name: "property",
@@ -1,4 +1,4 @@
1
- import { H as process$1, av as commonjsGlobal, I as Buffer, aw as getDefaultExportFromCjs, ax as getContentTypesFromXml, ay as xmljs } from "./converter-BHHM5A0T.js";
1
+ import { H as process$1, av as commonjsGlobal, I as Buffer, aw as getDefaultExportFromCjs, ax as getContentTypesFromXml, ay as xmljs } from "./converter-CY1WQn6N.js";
2
2
  function commonjsRequire(path) {
3
3
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
4
4
  }
@@ -2315,6 +2315,40 @@ function requireJszip_min() {
2315
2315
  }
2316
2316
  var jszip_minExports = requireJszip_min();
2317
2317
  const JSZip = /* @__PURE__ */ getDefaultExportFromCjs(jszip_minExports);
2318
+ const isXmlLike = (name) => /\.xml$|\.rels$/i.test(name);
2319
+ function sniffEncoding(u8) {
2320
+ if (u8.length >= 2) {
2321
+ const b0 = u8[0], b1 = u8[1];
2322
+ if (b0 === 255 && b1 === 254) return "utf-16le";
2323
+ if (b0 === 254 && b1 === 255) return "utf-16be";
2324
+ }
2325
+ let nul = 0;
2326
+ for (let i = 0; i < Math.min(64, u8.length); i++) if (u8[i] === 0) nul++;
2327
+ if (nul > 16) return "utf-16le";
2328
+ return "utf-8";
2329
+ }
2330
+ function stripBOM(str) {
2331
+ return str && str.charCodeAt(0) === 65279 ? str.slice(1) : str;
2332
+ }
2333
+ function ensureXmlString(content) {
2334
+ if (typeof content === "string") return stripBOM(content);
2335
+ let u8 = null;
2336
+ if (content && typeof content === "object") {
2337
+ if (content instanceof Uint8Array) {
2338
+ u8 = content;
2339
+ } else if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(content)) {
2340
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
2341
+ } else if (ArrayBuffer.isView && ArrayBuffer.isView(content)) {
2342
+ u8 = new Uint8Array(content.buffer, content.byteOffset, content.byteLength);
2343
+ } else if (content.constructor && (content instanceof ArrayBuffer || content.constructor.name === "ArrayBuffer")) {
2344
+ u8 = new Uint8Array(content);
2345
+ }
2346
+ }
2347
+ if (!u8) throw new Error("Unsupported content type for XML");
2348
+ const enc = sniffEncoding(u8);
2349
+ let xml = new TextDecoder(enc).decode(u8);
2350
+ return stripBOM(xml);
2351
+ }
2318
2352
  class DocxZipper {
2319
2353
  constructor(params = {}) {
2320
2354
  this.debug = params.debug || false;
@@ -2345,32 +2379,29 @@ class DocxZipper {
2345
2379
  async getDocxData(file, isNode = false) {
2346
2380
  const extractedFiles = await this.unzip(file);
2347
2381
  const files = Object.entries(extractedFiles.files);
2348
- const validTypes = ["xml", "rels"];
2349
- for (const file2 of files) {
2350
- const [, zipEntry] = file2;
2351
- if (validTypes.some((validType) => zipEntry.name.endsWith(validType))) {
2352
- const content = await zipEntry.async("string");
2353
- this.files.push({
2354
- name: zipEntry.name,
2355
- content
2356
- });
2357
- } else if (zipEntry.name.startsWith("word/media") && zipEntry.name !== "word/media/" || zipEntry.name.startsWith("media") && zipEntry.name !== "media/") {
2382
+ for (const [, zipEntry] of files) {
2383
+ const name = zipEntry.name;
2384
+ if (isXmlLike(name)) {
2385
+ const u8 = await zipEntry.async("uint8array");
2386
+ const content = ensureXmlString(u8);
2387
+ this.files.push({ name, content });
2388
+ } else if (name.startsWith("word/media") && name !== "word/media/" || name.startsWith("media") && name !== "media/") {
2358
2389
  if (isNode) {
2359
2390
  const buffer = await zipEntry.async("nodebuffer");
2360
2391
  const fileBase64 = buffer.toString("base64");
2361
- this.mediaFiles[zipEntry.name] = fileBase64;
2392
+ this.mediaFiles[name] = fileBase64;
2362
2393
  } else {
2363
2394
  const blob = await zipEntry.async("blob");
2364
- const extension = this.getFileExtension(zipEntry.name);
2395
+ const extension = this.getFileExtension(name);
2365
2396
  const fileBase64 = await zipEntry.async("base64");
2366
- this.mediaFiles[zipEntry.name] = `data:image/${extension};base64,${fileBase64}`;
2367
- const file3 = new File([blob], zipEntry.name, { type: blob.type });
2368
- const imageUrl = URL.createObjectURL(file3);
2369
- this.media[zipEntry.name] = imageUrl;
2397
+ this.mediaFiles[name] = `data:image/${extension};base64,${fileBase64}`;
2398
+ const fileObj = new File([blob], name, { type: blob.type });
2399
+ const imageUrl = URL.createObjectURL(fileObj);
2400
+ this.media[name] = imageUrl;
2370
2401
  }
2371
- } else if (zipEntry.name.startsWith("word/fonts") && zipEntry.name !== "word/fonts/") {
2402
+ } else if (name.startsWith("word/fonts") && name !== "word/fonts/") {
2372
2403
  const uint8array = await zipEntry.async("uint8array");
2373
- this.fonts[zipEntry.name] = uint8array;
2404
+ this.fonts[name] = uint8array;
2374
2405
  }
2375
2406
  }
2376
2407
  return this.files;
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, g as getExtensionConfigField, b as getMarkType, d as getMarksFromSelection, e as getNodeType, f as getSchemaTypeNameByName, S as Schema$1, h as cleanSchemaItem, T as TextSelection, N as NodeSelection, i as canSplit, j as defaultBlockAt$1, l as liftTarget, A as AllSelection, k as canJoin, m as joinPoint, n as Selection, r as replaceStep$1, F as Fragment, R as ReplaceAroundStep$1, o as Slice, p as isTextSelection, q as getMarkRange, s as isMarkActive, t as isNodeActive, u as deleteProps, D as DOMParser$1, v as ReplaceStep, w as NodeRange, x as findWrapping, L as ListHelpers, y as findParentNode, z as isMacOS, B as isIOS, C as DOMSerializer, E as Mark$1, G as dropPoint, H as process$1, I as Buffer2, J as getSchemaTypeByName, K as inputRulesPlugin, O as TrackDeleteMarkName, Q as TrackInsertMarkName, U as v4, V as TrackFormatMarkName, W as comments_module_events, X as findMark, Y as objectIncludes, Z as AddMarkStep, _ as RemoveMarkStep, $ as twipsToLines, a0 as pixelsToTwips, a1 as helpers, a2 as posToDOMRect, a3 as CommandService, a4 as SuperConverter, a5 as createDocument, a6 as createDocFromMarkdown, a7 as createDocFromHTML, a8 as EditorState, a9 as hasSomeParentWithClass, aa as isActive, ab as unflattenListsInHtml, ac as parseSizeUnit, ad as minMax, ae as getLineHeightValueString, af as InputRule, ag as kebabCase, ah as getListItemStyleDefinitions, ai as docxNumberigHelpers, aj as parseIndentElement, ak as combineIndents, al as StepMap, am as getColStyleDeclaration, an as SelectionRange, ao as Transform, ap as findParentNodeClosestToPos, aq as isInTable$1, ar as createColGroup, as as generateDocxRandomId, at as insertNewRelationship, au as htmlHandler } from "./converter-BHHM5A0T.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, c as callOrGet, g as getExtensionConfigField, b as getMarkType, d as getMarksFromSelection, e as getNodeType, f as getSchemaTypeNameByName, S as Schema$1, h as cleanSchemaItem, T as TextSelection, N as NodeSelection, i as canSplit, j as defaultBlockAt$1, l as liftTarget, A as AllSelection, k as canJoin, m as joinPoint, n as Selection, r as replaceStep$1, F as Fragment, R as ReplaceAroundStep$1, o as Slice, p as isTextSelection, q as getMarkRange, s as isMarkActive, t as isNodeActive, u as deleteProps, D as DOMParser$1, v as ReplaceStep, w as NodeRange, x as findWrapping, L as ListHelpers, y as findParentNode, z as isMacOS, B as isIOS, C as DOMSerializer, E as Mark$1, G as dropPoint, H as process$1, I as Buffer2, J as getSchemaTypeByName, K as inputRulesPlugin, O as TrackDeleteMarkName, Q as TrackInsertMarkName, U as v4, V as TrackFormatMarkName, W as comments_module_events, X as findMark, Y as objectIncludes, Z as AddMarkStep, _ as RemoveMarkStep, $ as twipsToLines, a0 as pixelsToTwips, a1 as helpers, a2 as posToDOMRect, a3 as CommandService, a4 as SuperConverter, a5 as createDocument, a6 as createDocFromMarkdown, a7 as createDocFromHTML, a8 as EditorState, a9 as hasSomeParentWithClass, aa as isActive, ab as unflattenListsInHtml, ac as parseSizeUnit, ad as minMax, ae as getLineHeightValueString, af as InputRule, ag as kebabCase, ah as getListItemStyleDefinitions, ai as docxNumberigHelpers, aj as parseIndentElement, ak as combineIndents, al as StepMap, am as getColStyleDeclaration, an as SelectionRange, ao as Transform, ap as findParentNodeClosestToPos, aq as isInTable$1, ar as createColGroup, as as generateDocxRandomId, at as insertNewRelationship, au as htmlHandler } from "./converter-CY1WQn6N.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-B-WaDouD.js";
17
+ import { D as DocxZipper } from "./docx-zipper-DAn84JFm.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -14255,7 +14255,7 @@ const _Editor = class _Editor extends EventEmitter {
14255
14255
  * @returns {Object | void} Migration results
14256
14256
  */
14257
14257
  processCollaborationMigrations() {
14258
- console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.5");
14258
+ console.debug("[checkVersionMigrations] Current editor version", "0.16.0-next.7");
14259
14259
  if (!this.options.ydoc) return;
14260
14260
  const metaMap = this.options.ydoc.getMap("meta");
14261
14261
  let docVersion = metaMap.get("version");
@@ -1,6 +1,6 @@
1
1
  import { computed, createElementBlock, openBlock, createElementVNode, createCommentVNode, normalizeClass, normalizeStyle, ref, withKeys, unref, withModifiers, createBlock, toDisplayString, withDirectives, vModelText, nextTick, getCurrentInstance, createVNode, readonly, watch, onMounted, onBeforeUnmount, reactive, onBeforeMount, inject, onActivated, onDeactivated, createTextVNode, Fragment, Comment, defineComponent, provide, h, Teleport, toRef, renderSlot, isVNode, shallowRef, watchEffect, mergeProps, Transition, vShow, cloneVNode, Text, renderList, withCtx } from "vue";
2
- import { H as process$1 } from "./converter-BHHM5A0T.js";
3
- import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-EpJu9duS.js";
2
+ import { H as process$1 } from "./converter-CY1WQn6N.js";
3
+ import { _ as _export_sfc, u as useHighContrastMode, g as global$1 } from "./editor-C66ryrYS.js";
4
4
  const sanitizeNumber = (value, defaultNumber) => {
5
5
  let sanitized = value.replace(/[^0-9.]/g, "");
6
6
  sanitized = parseFloat(sanitized);
@@ -1,4 +1,4 @@
1
- import { a4 } from "./chunks/converter-BHHM5A0T.js";
1
+ import { a4 } from "./chunks/converter-CY1WQn6N.js";
2
2
  export {
3
3
  a4 as SuperConverter
4
4
  };
@@ -1,5 +1,5 @@
1
- import "./chunks/converter-BHHM5A0T.js";
2
- import { D } from "./chunks/docx-zipper-B-WaDouD.js";
1
+ import "./chunks/converter-CY1WQn6N.js";
2
+ import { D } from "./chunks/docx-zipper-DAn84JFm.js";
3
3
  export {
4
4
  D as default
5
5
  };
@@ -1,6 +1,6 @@
1
- import { E } from "./chunks/editor-EpJu9duS.js";
2
- import "./chunks/converter-BHHM5A0T.js";
3
- import "./chunks/docx-zipper-B-WaDouD.js";
1
+ import { E } from "./chunks/editor-C66ryrYS.js";
2
+ import "./chunks/converter-CY1WQn6N.js";
3
+ import "./chunks/docx-zipper-DAn84JFm.js";
4
4
  export {
5
5
  E as Editor
6
6
  };