@threadlabs/looma 0.16.1 → 0.16.2

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.
@@ -8616,6 +8616,17 @@ function looksLikeMarkdown(value) {
8616
8616
  ].includes(child.type)));
8617
8617
  });
8618
8618
  }
8619
+ function hasRichClipboardStructure(value) {
8620
+ if (!value.trim()) return false;
8621
+ const body = new globalThis.DOMParser().parseFromString(value, "text/html").body;
8622
+ const pre = body.querySelector("pre");
8623
+ if (pre && body.textContent?.trim() === pre.textContent?.trim()) return false;
8624
+ const outsideSource = (selector) => [...body.querySelectorAll(selector)].some((element) => !element.closest("pre, code"));
8625
+ if (outsideSource("h1, h2, h3, h4, h5, h6, ul, ol, li, blockquote, table, th, td, strong, em, b, i, a, img, hr, [data-looma-chip], [data-looma-mention]")) return true;
8626
+ if (outsideSource("[style]")) return true;
8627
+ if (body.querySelector("[data-pm-slice]") && !body.querySelector("pre")) return true;
8628
+ return body.querySelectorAll("p").length > 1;
8629
+ }
8619
8630
  function parseHtmlSlice(schema, value) {
8620
8631
  const parsed = new globalThis.DOMParser().parseFromString(value, "text/html");
8621
8632
  if (parsed.body.style.display === "none") return Slice.empty;
@@ -8662,6 +8673,7 @@ var LoomaSmartPaste = Extension.create({
8662
8673
  if (selectionIsInsideCodeBlock(view.state.selection.$from.parent.type.name)) return false;
8663
8674
  const plainText = event.clipboardData.getData("text/plain");
8664
8675
  if (!plainText.trim()) return false;
8676
+ if (hasRichClipboardStructure(event.clipboardData.getData("text/html"))) return false;
8665
8677
  const slice = documentSlice(view.state.schema, plainText);
8666
8678
  if (!slice) return false;
8667
8679
  if (slice.size === 0) return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@threadlabs/looma",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "type": "module",
5
5
  "description": "Looma components as HTML, Vue, and plain DOM, with design tokens.",
6
6
  "license": "MIT",