superdoc 1.12.0-next.2 → 1.12.0-next.3

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.
@@ -6143,6 +6143,60 @@
6143
6143
  }
6144
6144
  return { dom, contentDOM };
6145
6145
  }
6146
+ async function ensureClipboardPermission() {
6147
+ if (typeof navigator === "undefined" || !navigator.clipboard) {
6148
+ return false;
6149
+ }
6150
+ if (!navigator.permissions || typeof navigator.permissions.query !== "function") {
6151
+ return true;
6152
+ }
6153
+ try {
6154
+ const status = await navigator.permissions.query({ name: "clipboard-read" });
6155
+ if (status.state === "granted") {
6156
+ return true;
6157
+ }
6158
+ if (status.state === "prompt") {
6159
+ try {
6160
+ await navigator.clipboard.readText();
6161
+ return true;
6162
+ } catch {
6163
+ return false;
6164
+ }
6165
+ }
6166
+ return false;
6167
+ } catch {
6168
+ return false;
6169
+ }
6170
+ }
6171
+ async function readClipboardRaw() {
6172
+ let html2 = "";
6173
+ let text2 = "";
6174
+ const hasPermission = await ensureClipboardPermission();
6175
+ if (!navigator.clipboard) {
6176
+ return { html: html2, text: text2 || "" };
6177
+ }
6178
+ if (hasPermission && navigator.clipboard.read) {
6179
+ try {
6180
+ const items = await navigator.clipboard.read();
6181
+ for (const item of items) {
6182
+ if (item.types.includes("text/html")) {
6183
+ html2 = await (await item.getType("text/html")).text();
6184
+ }
6185
+ if (item.types.includes("text/plain")) {
6186
+ text2 = await (await item.getType("text/plain")).text();
6187
+ }
6188
+ }
6189
+ } catch {
6190
+ }
6191
+ }
6192
+ if (!text2 && navigator.clipboard.readText) {
6193
+ try {
6194
+ text2 = await navigator.clipboard.readText();
6195
+ } catch {
6196
+ }
6197
+ }
6198
+ return { html: html2, text: text2 || "" };
6199
+ }
6146
6200
  const PIXELS_PER_INCH$2 = 96;
6147
6201
  function inchesToTwips(inches) {
6148
6202
  if (inches == null) return;
@@ -34309,7 +34363,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
34309
34363
  const COMMUNITY_LICENSE_KEY = "community-and-eval-agplv3";
34310
34364
  function getSuperdocVersion() {
34311
34365
  try {
34312
- return true ? "1.12.0-next.2" : "unknown";
34366
+ return true ? "1.12.0-next.3" : "unknown";
34313
34367
  } catch {
34314
34368
  return "unknown";
34315
34369
  }
@@ -37580,7 +37634,7 @@ Please report this to https://github.com/markedjs/marked.`, e) {
37580
37634
  static getStoredSuperdocVersion(docx) {
37581
37635
  return SuperConverter.getStoredCustomProperty(docx, "SuperdocVersion");
37582
37636
  }
37583
- static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.12.0-next.2") {
37637
+ static setStoredSuperdocVersion(docx = this.convertedXml, version2 = "1.12.0-next.3") {
37584
37638
  return SuperConverter.setStoredCustomProperty(docx, "SuperdocVersion", version2, false);
37585
37639
  }
37586
37640
  /**
@@ -65026,7 +65080,7 @@ ${err.toString()}`);
65026
65080
  return false;
65027
65081
  }
65028
65082
  };
65029
- const summaryVersion = "1.12.0-next.2";
65083
+ const summaryVersion = "1.12.0-next.3";
65030
65084
  const nodeKeys = ["group", "content", "marks", "inline", "atom", "defining", "code", "tableRole", "summary"];
65031
65085
  const markKeys = ["group", "inclusive", "excludes", "spanning", "code"];
65032
65086
  function mapAttributes(attrs) {
@@ -67832,7 +67886,7 @@ ${err.toString()}`);
67832
67886
  * Process collaboration migrations
67833
67887
  */
67834
67888
  processCollaborationMigrations() {
67835
- console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.2");
67889
+ console.debug("[checkVersionMigrations] Current editor version", "1.12.0-next.3");
67836
67890
  if (!this.options.ydoc) return;
67837
67891
  const metaMap = this.options.ydoc.getMap("meta");
67838
67892
  let docVersion = metaMap.get("version");
@@ -150022,6 +150076,24 @@ ${style2}
150022
150076
  return null;
150023
150077
  }
150024
150078
  }
150079
+ const createPasteEventShim = (clipboard) => {
150080
+ const html2 = clipboard?.html || "";
150081
+ const text2 = clipboard?.text || "";
150082
+ return {
150083
+ type: "paste",
150084
+ preventDefault: () => {
150085
+ },
150086
+ stopPropagation: () => {
150087
+ },
150088
+ clipboardData: {
150089
+ getData: (type) => {
150090
+ if (type === "text/html") return html2;
150091
+ if (type === "text/plain") return text2;
150092
+ return "";
150093
+ }
150094
+ }
150095
+ };
150096
+ };
150025
150097
  const isModuleEnabled = (editorOptions, moduleName) => {
150026
150098
  switch (moduleName) {
150027
150099
  case "ai":
@@ -150238,13 +150310,24 @@ ${style2}
150238
150310
  label: TEXTS.paste,
150239
150311
  icon: ICONS.paste,
150240
150312
  isDefault: true,
150241
- action: (editor2) => {
150242
- const editorDom = editor2.view?.dom;
150243
- if (editorDom) {
150244
- editorDom.focus();
150245
- const success = document.execCommand("paste");
150246
- if (!success) {
150247
- console.warn("[Paste] execCommand paste failed - clipboard may be empty or inaccessible");
150313
+ action: async (editor2) => {
150314
+ const { view } = editor2 ?? {};
150315
+ if (!view) return;
150316
+ view.dom.focus();
150317
+ const { html: html2, text: text2 } = await readClipboardRaw();
150318
+ const handled = html2 ? handleClipboardPaste({ editor: editor2, view }, html2) : false;
150319
+ if (!handled) {
150320
+ const pasteEvent = createPasteEventShim({ html: html2, text: text2 });
150321
+ if (html2 && typeof view.pasteHTML === "function") {
150322
+ view.pasteHTML(html2, pasteEvent);
150323
+ return;
150324
+ }
150325
+ if (text2 && typeof view.pasteText === "function") {
150326
+ view.pasteText(text2, pasteEvent);
150327
+ return;
150328
+ }
150329
+ if (text2 && editor2.commands?.insertContent) {
150330
+ editor2.commands.insertContent(text2, { contentType: "text" });
150248
150331
  }
150249
150332
  }
150250
150333
  },
@@ -158470,7 +158553,7 @@ ${reason}`);
158470
158553
  this.config.colors = shuffleArray(this.config.colors);
158471
158554
  this.userColorMap = /* @__PURE__ */ new Map();
158472
158555
  this.colorIndex = 0;
158473
- this.version = "1.12.0-next.2";
158556
+ this.version = "1.12.0-next.3";
158474
158557
  this.#log("🦋 [superdoc] Using SuperDoc version:", this.version);
158475
158558
  this.superdocId = config2.superdocId || v4();
158476
158559
  this.colors = this.config.colors;