@clevertask/scribe 0.1.18 → 0.1.20

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 (53) hide show
  1. package/README.md +29 -1
  2. package/dist/{BarMenu-C9tCdvyV.js → BarMenu-sZGqMjQr.js} +1 -1
  3. package/dist/components/Menu/BarMenu.js +1 -1
  4. package/dist/components/Menu/BubbleMenu.js +2 -2
  5. package/dist/components/Menu/CalloutBubbleMenu.js +64 -64
  6. package/dist/components/Menu/LinkBubbleMenu.js +16 -16
  7. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  8. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  9. package/dist/components/Menu/linkBubbleMenuPlugin.js +1 -1
  10. package/dist/components/Scribe/extension/callout.js +2 -5
  11. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  12. package/dist/components/Scribe/extension/extension-link.js +1 -1
  13. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  14. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  15. package/dist/components/Scribe/extension/external-link-preview/commands.js +38 -38
  16. package/dist/components/Scribe/extension/external-link-preview/index.d.ts +1 -2
  17. package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -1
  18. package/dist/components/Scribe/extension/external-link-preview/index.js +20 -113
  19. package/dist/components/Scribe/extension/external-link-preview/node-view.js +6 -6
  20. package/dist/components/Scribe/extension/external-link-preview/paste.js +5 -5
  21. package/dist/components/Scribe/extension/external-link-preview/render-html.js +1 -1
  22. package/dist/components/Scribe/extension/external-link-preview/schema.d.ts +8 -0
  23. package/dist/components/Scribe/extension/external-link-preview/schema.d.ts.map +1 -0
  24. package/dist/components/Scribe/extension/external-link-preview/schema.js +100 -0
  25. package/dist/components/Scribe/extension/index.d.ts +2 -2
  26. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  27. package/dist/components/Scribe/extension/index.js +1 -1
  28. package/dist/components/Scribe/extension/resizable-table.js +1 -1
  29. package/dist/components/Scribe/extension/slashCommand/index.js +32 -2
  30. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  31. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  32. package/dist/components/Scribe/index.js +4 -4
  33. package/dist/{slashCommand-D35jcSNp.js → dist-Bm6rBIf2.js} +101 -110
  34. package/dist/{dist-DRPH9MfF.js → dist-BrbZZTdj.js} +21 -9
  35. package/dist/{dist-CkWsQ5Lj.js → dist-jjH04EIX.js} +585 -798
  36. package/dist/extension-BNjzWzJi.js +57 -0
  37. package/dist/{extension-link-yMrg9JOz.js → extension-link-7ta0X4tP.js} +2 -2
  38. package/dist/{html-to-markdown-CnlA8pb8.js → html-to-markdown-pY8ngCXa.js} +14 -14
  39. package/dist/main.js +6 -6
  40. package/dist/{markdown-to-html-BLzYd3Fu.js → markdown-to-html-BSuSwB4B.js} +42 -14
  41. package/dist/{menus-Dy2dj4QT.js → menus-i0cEakC3.js} +137 -135
  42. package/dist/{resizable-table-D0mls3aB.js → resizable-table-DFTyMlVu.js} +27 -30
  43. package/dist/{extension-DOo9QT6U.js → schema-extensions-B-U6SbYg.js} +51922 -51962
  44. package/dist/schema-extensions.d.ts +20 -0
  45. package/dist/schema-extensions.d.ts.map +1 -0
  46. package/dist/schema-extensions.js +2 -0
  47. package/dist/schema.d.ts +17 -0
  48. package/dist/schema.d.ts.map +1 -0
  49. package/dist/schema.js +5 -0
  50. package/dist/utils/html-to-markdown.js +1 -1
  51. package/dist/utils/index.js +4 -4
  52. package/dist/utils/markdown-to-html.js +1 -1
  53. package/package.json +57 -51
package/README.md CHANGED
@@ -20,6 +20,7 @@ A versatile, block-based rich text editor for diverse applications, built with T
20
20
 
21
21
  - [@clevertask/scribe](#clevertaskscribe)
22
22
  - [Installation](#installation)
23
+ - [Headless schema](#headless-schema)
23
24
  - [Usage](#usage)
24
25
  - [Table Authoring](#table-authoring)
25
26
  - [External Link Previews](#external-link-previews)
@@ -38,12 +39,39 @@ A versatile, block-based rich text editor for diverse applications, built with T
38
39
  ## Installation
39
40
 
40
41
  ```bash
41
- npm install --save-exact @clevertask/scribe @tiptap/pm@3.30.2
42
+ npm install --save-exact @clevertask/scribe @tiptap/pm@3.30.5
42
43
  ```
43
44
 
44
45
  Scribe shares this exact ProseMirror runtime with consumer extensions. Keeping one
45
46
  installed version prevents identity conflicts between built-in and custom plugins.
46
47
 
48
+ ## Headless schema
49
+
50
+ Use the schema subpath when a server or migration tool must parse Scribe content without loading
51
+ the React editor or Scribe's stylesheet:
52
+
53
+ ```bash
54
+ npm install --save-exact @clevertask/scribe @tiptap/core@3.30.5 @tiptap/html@3.30.5 @tiptap/pm@3.30.5
55
+ ```
56
+
57
+ ```ts
58
+ import { createScribeSchemaExtensions } from "@clevertask/scribe/schema";
59
+ import { generateJSON } from "@tiptap/html";
60
+
61
+ const extensions = createScribeSchemaExtensions({ enableUndoRedo: false });
62
+ const document = generateJSON(storedHtml, extensions);
63
+ ```
64
+
65
+ The returned extensions define Scribe's persistent nodes and marks without loading Scribe's React
66
+ editor UI. Use them with Tiptap's server-side HTML utilities; this is not a headless interactive
67
+ editor. Scribe's menus, placeholders, suggestions, and table-of-contents behavior are not part of
68
+ this entry point. Consumer-owned nodes must be appended to the list. For example, an application
69
+ that stores its own resource-reference node must provide that extension before parsing or rendering
70
+ content containing those references.
71
+
72
+ Pin Scribe and Tiptap to the exact versions used by the writing clients. This entry point makes the
73
+ schema reusable; it does not make different schema versions interchangeable.
74
+
47
75
  ## Usage
48
76
 
49
77
  ### Basic usage
@@ -1,4 +1,4 @@
1
- import { s as e } from "./dist-DRPH9MfF.js";
1
+ import { s as e } from "./dist-BrbZZTdj.js";
2
2
  import { getPopupMountTarget as t } from "./components/Scribe/extension/getPopupMountTarget.js";
3
3
  import n from "./components/Menu/LinkEditor.js";
4
4
  import { hideLinkBubbleMenu as r } from "./components/Menu/linkBubbleMenuPlugin.js";
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../BarMenu-C9tCdvyV.js";
1
+ import { t as e } from "../../BarMenu-sZGqMjQr.js";
2
2
  export { e as default };
@@ -1,6 +1,6 @@
1
- import { s as e } from "../../dist-DRPH9MfF.js";
1
+ import { s as e } from "../../dist-BrbZZTdj.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-Dy2dj4QT.js";
3
+ import { t as n } from "../../menus-i0cEakC3.js";
4
4
  import { Flex as r, IconButton as i } from "@radix-ui/themes";
5
5
  import { useCallback as a } from "react";
6
6
  import { jsx as o } from "react/jsx-runtime";
@@ -1,8 +1,8 @@
1
- import { s as e } from "../../dist-DRPH9MfF.js";
2
- import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-Dy2dj4QT.js";
4
- import { CalloutIcon as r, RemoveCalloutIcon as i } from "../../icons/CalloutIcon.js";
5
- import { CALLOUT_VARIANTS as a, CALLOUT_VARIANT_LABELS as o, isCalloutVariant as s } from "../Scribe/extension/callout.js";
1
+ import { CALLOUT_VARIANTS as e, CALLOUT_VARIANT_LABELS as t, isCalloutVariant as n } from "../Scribe/extension/callout.js";
2
+ import { s as r } from "../../dist-BrbZZTdj.js";
3
+ import { getPopupMountTarget as i } from "../Scribe/extension/getPopupMountTarget.js";
4
+ import { t as a } from "../../menus-i0cEakC3.js";
5
+ import { CalloutIcon as o, RemoveCalloutIcon as s } from "../../icons/CalloutIcon.js";
6
6
  import { calloutBubbleMenuPluginKey as c, getSelectionCalloutContext as l } from "./calloutBubbleMenuPlugin.js";
7
7
  import { getSelectionContextualMenuOwner as u } from "./contextualMenuOwner.js";
8
8
  import { Button as d, Flex as f, Separator as p } from "@radix-ui/themes";
@@ -14,11 +14,11 @@ var x = {
14
14
  tip: "green",
15
15
  warning: "amber",
16
16
  caution: "red"
17
- }, S = a.map((e) => ({
17
+ }, S = e.map((e) => ({
18
18
  color: x[e],
19
- label: o[e],
19
+ label: t[e],
20
20
  variant: e
21
- })), C = /auto|overlay|scroll/, w = (e) => s(e) ? e : "info", T = (e) => {
21
+ })), C = /auto|overlay|scroll/, w = (e) => n(e) ? e : "info", T = (e) => {
22
22
  let t = e.ownerDocument.defaultView;
23
23
  if (!t) return [];
24
24
  let n = [], r = e.parentElement;
@@ -27,9 +27,9 @@ var x = {
27
27
  C.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
28
28
  }
29
29
  return n;
30
- }, E = ({ editor: a }) => {
31
- let o = _(null), [s, x] = v(null), C = g(() => !!a.schema.nodes.callout && typeof a.commands.setCalloutVariant == "function" && typeof a.commands.unsetCallout == "function", [a]), E = e({
32
- editor: a,
30
+ }, E = ({ editor: e }) => {
31
+ let t = _(null), [n, x] = v(null), C = g(() => !!e.schema.nodes.callout && typeof e.commands.setCalloutVariant == "function" && typeof e.commands.unsetCallout == "function", [e]), E = r({
32
+ editor: e,
33
33
  selector: ({ editor: e }) => {
34
34
  let t = l(e.state);
35
35
  return t ? w(t.node.attrs.variant) : null;
@@ -38,48 +38,48 @@ var x = {
38
38
  let i = r.hasFocus() || t.contains(t.ownerDocument.activeElement);
39
39
  return C && e.isEditable && i && u(n) === "callout";
40
40
  }, [C]), O = m(() => {
41
- if (a.isDestroyed) return null;
42
- let e = l(a.state);
43
- if (!e) return null;
44
- let t = a.view.nodeDOM(e.position);
45
- return t instanceof HTMLElement ? t.closest("[data-type=\"callout\"]") ?? t.querySelector("[data-type=\"callout\"]") ?? t : null;
46
- }, [a]), k = m(() => t(a), [a]);
41
+ if (e.isDestroyed) return null;
42
+ let t = l(e.state);
43
+ if (!t) return null;
44
+ let n = e.view.nodeDOM(t.position);
45
+ return n instanceof HTMLElement ? n.closest("[data-type=\"callout\"]") ?? n.querySelector("[data-type=\"callout\"]") ?? n : null;
46
+ }, [e]), k = m(() => i(e), [e]);
47
47
  h(() => {
48
- let e = a.view.dom.ownerDocument.defaultView;
49
- if (!e) return;
50
- let t = T(a.view.dom), n = null, r = () => {
51
- n === null && (n = e.requestAnimationFrame(() => {
52
- n = null, a.isDestroyed || a.view.dispatch(a.state.tr.setMeta(c, "updatePosition"));
48
+ let t = e.view.dom.ownerDocument.defaultView;
49
+ if (!t) return;
50
+ let n = T(e.view.dom), r = null, i = () => {
51
+ r === null && (r = t.requestAnimationFrame(() => {
52
+ r = null, e.isDestroyed || e.view.dispatch(e.state.tr.setMeta(c, "updatePosition"));
53
53
  }));
54
54
  };
55
- return e.addEventListener("scroll", r, { passive: !0 }), t.forEach((e) => {
56
- e.addEventListener("scroll", r, { passive: !0 });
55
+ return t.addEventListener("scroll", i, { passive: !0 }), n.forEach((e) => {
56
+ e.addEventListener("scroll", i, { passive: !0 });
57
57
  }), () => {
58
- n !== null && e.cancelAnimationFrame(n), e.removeEventListener("scroll", r), t.forEach((e) => {
59
- e.removeEventListener("scroll", r);
58
+ r !== null && t.cancelAnimationFrame(r), t.removeEventListener("scroll", i), n.forEach((e) => {
59
+ e.removeEventListener("scroll", i);
60
60
  });
61
61
  };
62
- }, [a]), h(() => {
63
- let e = a.view.dom.closest("[data-scribe-root]"), t = a.view.dom.ownerDocument.defaultView;
64
- if (!e || !t) return;
65
- let n = () => {
66
- let t = e.getBoundingClientRect().width;
67
- x(t > 0 ? Math.max(t - 16, 0) : null);
62
+ }, [e]), h(() => {
63
+ let t = e.view.dom.closest("[data-scribe-root]"), n = e.view.dom.ownerDocument.defaultView;
64
+ if (!t || !n) return;
65
+ let r = () => {
66
+ let e = t.getBoundingClientRect().width;
67
+ x(e > 0 ? Math.max(e - 16, 0) : null);
68
68
  };
69
- if (n(), !t.ResizeObserver) return;
70
- let r = new t.ResizeObserver(n);
71
- return r.observe(e), () => r.disconnect();
72
- }, [a]), h(() => {
73
- let e = a.view.dom, t = (e) => {
74
- if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !a.isEditable || u(a.state) !== "callout") return;
75
- let t = o.current?.querySelector("button:not(:disabled)");
76
- t && (e.preventDefault(), t.focus());
69
+ if (r(), !n.ResizeObserver) return;
70
+ let i = new n.ResizeObserver(r);
71
+ return i.observe(t), () => i.disconnect();
72
+ }, [e]), h(() => {
73
+ let n = e.view.dom, r = (n) => {
74
+ if (n.key !== "F10" || !n.altKey || n.ctrlKey || n.metaKey || n.shiftKey || !e.isEditable || u(e.state) !== "callout") return;
75
+ let r = t.current?.querySelector("button:not(:disabled)");
76
+ r && (n.preventDefault(), r.focus());
77
77
  };
78
- return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
79
- }, [a]);
80
- let A = m((e) => {
81
- if (e.key === "Escape") {
82
- e.preventDefault(), a.chain().focus().run();
78
+ return n.addEventListener("keydown", r, !0), () => n.removeEventListener("keydown", r, !0);
79
+ }, [e]);
80
+ let A = m((t) => {
81
+ if (t.key === "Escape") {
82
+ t.preventDefault(), e.chain().focus().run();
83
83
  return;
84
84
  }
85
85
  if (![
@@ -89,20 +89,20 @@ var x = {
89
89
  "ArrowDown",
90
90
  "Home",
91
91
  "End"
92
- ].includes(e.key)) return;
93
- let t = Array.from(e.currentTarget.querySelectorAll("button:not(:disabled)"));
94
- if (t.length === 0) return;
95
- let n = e.currentTarget.ownerDocument.activeElement, r = t.findIndex((e) => e === n), i = r;
96
- i = e.key === "Home" ? 0 : e.key === "End" ? t.length - 1 : e.key === "ArrowLeft" || e.key === "ArrowUp" ? r <= 0 ? t.length - 1 : r - 1 : r < 0 || r === t.length - 1 ? 0 : r + 1, e.preventDefault(), t[i]?.focus();
97
- }, [a]), j = g(() => ({
92
+ ].includes(t.key)) return;
93
+ let n = Array.from(t.currentTarget.querySelectorAll("button:not(:disabled)"));
94
+ if (n.length === 0) return;
95
+ let r = t.currentTarget.ownerDocument.activeElement, i = n.findIndex((e) => e === r), a = i;
96
+ a = t.key === "Home" ? 0 : t.key === "End" ? n.length - 1 : t.key === "ArrowLeft" || t.key === "ArrowUp" ? i <= 0 ? n.length - 1 : i - 1 : i < 0 || i === n.length - 1 ? 0 : i + 1, t.preventDefault(), n[a]?.focus();
97
+ }, [e]), j = g(() => ({
98
98
  strategy: "fixed",
99
99
  placement: "top-start",
100
100
  offset: 8,
101
101
  flip: {},
102
102
  shift: { padding: 8 }
103
103
  }), []);
104
- return C ? /* @__PURE__ */ y(n, {
105
- editor: a,
104
+ return C ? /* @__PURE__ */ y(a, {
105
+ editor: e,
106
106
  pluginKey: c,
107
107
  updateDelay: 0,
108
108
  resizeDelay: 0,
@@ -111,7 +111,7 @@ var x = {
111
111
  getReferencedVirtualElement: O,
112
112
  options: j,
113
113
  children: /* @__PURE__ */ b(f, {
114
- ref: o,
114
+ ref: t,
115
115
  className: "scribe-callout-bubble-menu",
116
116
  role: "toolbar",
117
117
  "aria-label": "Callout type",
@@ -120,19 +120,19 @@ var x = {
120
120
  gap: "1",
121
121
  wrap: "wrap",
122
122
  onKeyDown: A,
123
- style: s === null ? void 0 : { maxWidth: s },
123
+ style: n === null ? void 0 : { maxWidth: n },
124
124
  children: [
125
- S.map(({ color: e, label: t, variant: n }) => /* @__PURE__ */ b(d, {
125
+ S.map(({ color: t, label: n, variant: r }) => /* @__PURE__ */ b(d, {
126
126
  type: "button",
127
127
  className: "scribe-callout-type-button",
128
128
  size: "1",
129
129
  radius: "medium",
130
- color: e,
131
- variant: E === n ? "soft" : "ghost",
132
- "aria-pressed": E === n,
133
- onClick: () => a.chain().focus().setCalloutVariant(n).run(),
134
- children: [/* @__PURE__ */ y(r, { variant: n }), t]
135
- }, n)),
130
+ color: t,
131
+ variant: E === r ? "soft" : "ghost",
132
+ "aria-pressed": E === r,
133
+ onClick: () => e.chain().focus().setCalloutVariant(r).run(),
134
+ children: [/* @__PURE__ */ y(o, { variant: r }), n]
135
+ }, r)),
136
136
  /* @__PURE__ */ y(p, {
137
137
  className: "scribe-callout-menu-separator",
138
138
  orientation: "vertical",
@@ -145,8 +145,8 @@ var x = {
145
145
  radius: "medium",
146
146
  color: "gray",
147
147
  variant: "ghost",
148
- onClick: () => a.chain().focus().unsetCallout().run(),
149
- children: [/* @__PURE__ */ y(i, {}), "Turn into text"]
148
+ onClick: () => e.chain().focus().unsetCallout().run(),
149
+ children: [/* @__PURE__ */ y(s, {}), "Turn into text"]
150
150
  })
151
151
  ]
152
152
  })
@@ -1,9 +1,9 @@
1
- import { s as e } from "../../dist-DRPH9MfF.js";
2
- import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import n from "./LinkEditor.js";
4
- import { getExternalLinkPreviewHostname as r } from "../Scribe/extension/external-link-preview/attributes.js";
1
+ import { getExternalLinkPreviewHostname as e } from "../Scribe/extension/external-link-preview/attributes.js";
2
+ import { s as t } from "../../dist-BrbZZTdj.js";
3
+ import { getPopupMountTarget as n } from "../Scribe/extension/getPopupMountTarget.js";
4
+ import r from "./LinkEditor.js";
5
5
  import { consumeLinkBubbleMenuFocusTarget as i, getPlainLinkContextAtPosition as a, getSelectionLinkContext as o, hideLinkBubbleMenu as s, linkBubbleMenuPluginKey as c, showLinkBubbleMenu as l } from "./linkBubbleMenuPlugin.js";
6
- import { t as u } from "../../menus-Dy2dj4QT.js";
6
+ import { t as u } from "../../menus-i0cEakC3.js";
7
7
  import { getSelectionContextualMenuOwner as d } from "./contextualMenuOwner.js";
8
8
  import { getExternalLinkPreviewResolutionStatus as f } from "../Scribe/extension/external-link-preview/resolver.js";
9
9
  import { Box as p } from "@radix-ui/themes";
@@ -20,20 +20,20 @@ var b = /auto|overlay|scroll/, x = (e) => {
20
20
  }
21
21
  return n;
22
22
  }, S = ({ editor: b }) => {
23
- let [S, C] = v(""), [w, T] = v(0), [E, D] = v(null), O = _(null), k = _(null), A = _(null), j = e({
23
+ let [S, C] = v(""), [w, T] = v(0), [E, D] = v(null), O = _(null), k = _(null), A = _(null), j = t({
24
24
  editor: b,
25
- selector: ({ editor: e }) => {
26
- let t = o(e.state);
27
- return !t || t.kind === "plain" ? {
25
+ selector: ({ editor: t }) => {
26
+ let n = o(t.state);
27
+ return !n || n.kind === "plain" ? {
28
28
  canRefresh: !1,
29
- context: t,
29
+ context: n,
30
30
  status: "idle",
31
31
  statusLabel: ""
32
32
  } : {
33
- canRefresh: e.can().refreshExternalLinkPreview(t.position),
34
- context: t,
35
- status: f(e.state, t.position),
36
- statusLabel: t.attributes.siteName || r(t.attributes.href)
33
+ canRefresh: t.can().refreshExternalLinkPreview(n.position),
34
+ context: n,
35
+ status: f(t.state, n.position),
36
+ statusLabel: n.attributes.siteName || e(n.attributes.href)
37
37
  };
38
38
  }
39
39
  });
@@ -140,7 +140,7 @@ var b = /auto|overlay|scroll/, x = (e) => {
140
140
  }, [M]), L = m(({ editor: e, element: t, state: n }) => {
141
141
  let r = t.contains(t.ownerDocument.activeElement);
142
142
  return e.isEditable && !!o(n) && d(n) === "link" && r;
143
- }, []), R = m(() => t(b), [b]), z = g(() => ({
143
+ }, []), R = m(() => n(b), [b]), z = g(() => ({
144
144
  strategy: "fixed",
145
145
  placement: "bottom",
146
146
  offset: 8,
@@ -170,7 +170,7 @@ var b = /auto|overlay|scroll/, x = (e) => {
170
170
  maxWidth: E === null ? "calc(100vw - 32px)" : `min(${E}px, calc(100vw - 32px))`,
171
171
  width: 320
172
172
  },
173
- children: /* @__PURE__ */ y(n, {
173
+ children: /* @__PURE__ */ y(r, {
174
174
  canRefreshPreview: j.canRefresh,
175
175
  currentDisplay: B?.display ?? "plain",
176
176
  editor: b,
@@ -1,4 +1,4 @@
1
- import { s as e } from "../../../dist-DRPH9MfF.js";
1
+ import { s as e } from "../../../dist-BrbZZTdj.js";
2
2
  import { Button as t, Flex as n } from "@radix-ui/themes";
3
3
  import { useCallback as r } from "react";
4
4
  import { jsx as i, jsxs as a } from "react/jsx-runtime";
@@ -1,6 +1,6 @@
1
- import { s as e } from "../../dist-DRPH9MfF.js";
1
+ import { s as e } from "../../dist-BrbZZTdj.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-Dy2dj4QT.js";
3
+ import { t as n } from "../../menus-i0cEakC3.js";
4
4
  import { getSelectionTableContext as r, tableBubbleMenuPluginKey as i } from "./tableBubbleMenuPlugin.js";
5
5
  import { getSelectionContextualMenuOwner as a } from "./contextualMenuOwner.js";
6
6
  import { Flex as o, IconButton as s, Separator as c } from "@radix-ui/themes";
@@ -1,4 +1,4 @@
1
- import { v as e } from "../../dist-CkWsQ5Lj.js";
1
+ import { v as e } from "../../dist-jjH04EIX.js";
2
2
  import { normalizeExternalLinkPreviewAttributes as t } from "../Scribe/extension/external-link-preview/attributes.js";
3
3
  import { NodeSelection as n, PluginKey as r } from "@tiptap/pm/state";
4
4
  //#region lib/components/Menu/linkBubbleMenuPlugin.ts
@@ -1,4 +1,4 @@
1
- import { A as e, L as t, a as n } from "../../../dist-CkWsQ5Lj.js";
1
+ import { A as e, L as t, a as n } from "../../../dist-jjH04EIX.js";
2
2
  import { TextSelection as r } from "@tiptap/pm/state";
3
3
  //#region lib/components/Scribe/extension/callout.ts
4
4
  var i = [
@@ -61,10 +61,7 @@ var i = [
61
61
  parseHTML() {
62
62
  return [{
63
63
  tag: "aside[data-type=\"callout\"]",
64
- contentElement: (e) => {
65
- let t = Array.from(e.children).find((e) => e.hasAttribute("data-callout-content"));
66
- return t instanceof HTMLElement ? t : e;
67
- }
64
+ contentElement: (e) => Array.from(e.children).find((e) => e.hasAttribute("data-callout-content")) ?? e
68
65
  }];
69
66
  },
70
67
  renderHTML({ HTMLAttributes: e }) {
@@ -1,4 +1,4 @@
1
- import { i as e } from "../../../../dist-DRPH9MfF.js";
1
+ import { i as e } from "../../../../dist-BrbZZTdj.js";
2
2
  import { getPopupMountTarget as t } from "../getPopupMountTarget.js";
3
3
  import { t as n } from "../../../../tippy.esm-DOXqN1Qm.js";
4
4
  import { EmojiList as r } from "./EmojiList.js";
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../../extension-link-yMrg9JOz.js";
1
+ import { t as e } from "../../../extension-link-7ta0X4tP.js";
2
2
  export { e as default };
@@ -1,5 +1,5 @@
1
- import { n as e } from "../../../dist-CkWsQ5Lj.js";
2
- import { n as t, t as n } from "../../../markdown-to-html-BLzYd3Fu.js";
1
+ import { n as e } from "../../../dist-jjH04EIX.js";
2
+ import { n as t, t as n } from "../../../markdown-to-html-BSuSwB4B.js";
3
3
  import { Plugin as r, PluginKey as i } from "@tiptap/pm/state";
4
4
  //#region lib/components/Scribe/extension/extension-markdown-paste.ts
5
5
  var a = new i("markdownPaste"), o = /* @__PURE__ */ new Set([
@@ -1,4 +1,4 @@
1
- import { n as e } from "../../../dist-CkWsQ5Lj.js";
1
+ import { n as e } from "../../../dist-jjH04EIX.js";
2
2
  //#region lib/components/Scribe/extension/extension-selectedText.ts
3
3
  var t = e.create({
4
4
  name: "SelectedText",
@@ -1,15 +1,15 @@
1
- import { v as e } from "../../../../dist-CkWsQ5Lj.js";
2
- import { normalizeLinkUrl as t } from "../../../Menu/linkUrl.js";
3
- import { EXTERNAL_LINK_PREVIEW_NODE_NAME as n, hasExternalLinkPreviewMetadata as r, normalizeExternalLinkPreviewAttributes as i, normalizeExternalLinkPreviewHref as a } from "./attributes.js";
1
+ import { v as e } from "../../../../dist-jjH04EIX.js";
2
+ import { EXTERNAL_LINK_PREVIEW_NODE_NAME as t, hasExternalLinkPreviewMetadata as n, normalizeExternalLinkPreviewAttributes as r, normalizeExternalLinkPreviewHref as i } from "./attributes.js";
3
+ import { normalizeLinkUrl as a } from "../../../Menu/linkUrl.js";
4
4
  import { startExternalLinkPreviewResolution as o } from "./resolver.js";
5
5
  import { NodeSelection as s, TextSelection as c } from "@tiptap/pm/state";
6
6
  //#region lib/components/Scribe/extension/external-link-preview/commands.ts
7
7
  var l = (e, t) => {
8
- let { selection: n } = e, r = typeof t == "number";
9
- if (r && (!Number.isInteger(t) || t < 0 || t >= e.doc.content.size)) return null;
10
- let a = r ? t : n.from, o = r ? e.doc.nodeAt(a) : n instanceof s ? n.node : null;
8
+ let { selection: n } = e, i = typeof t == "number";
9
+ if (i && (!Number.isInteger(t) || t < 0 || t >= e.doc.content.size)) return null;
10
+ let a = i ? t : n.from, o = i ? e.doc.nodeAt(a) : n instanceof s ? n.node : null;
11
11
  if (!o || o.type.name !== "externalLinkPreview") return null;
12
- let c = i(o.attrs);
12
+ let c = r(o.attrs);
13
13
  if (!c) return null;
14
14
  let l = e.doc.resolve(a);
15
15
  return {
@@ -23,29 +23,29 @@ var l = (e, t) => {
23
23
  if (!n) return null;
24
24
  let { selection: r } = t;
25
25
  if (!r.$from.sameParent(r.$to) || !r.$from.parent.isTextblock) return null;
26
- let i = e(r.$from, n), o = r.$from.start(), s = r.$from.parent;
27
- if (!i) return null;
26
+ let a = e(r.$from, n), o = r.$from.start(), s = r.$from.parent;
27
+ if (!a) return null;
28
28
  let c, l = !0, u = "";
29
- t.doc.nodesBetween(i.from, i.to, (e, t) => {
29
+ t.doc.nodesBetween(a.from, a.to, (e, t) => {
30
30
  if (!e.isText) {
31
31
  e.isInline && (l = !1);
32
32
  return;
33
33
  }
34
- let r = e.marks.find((e) => e.type === n), a = Math.max(i.from, t), o = Math.min(i.to, t + e.nodeSize);
34
+ let r = e.marks.find((e) => e.type === n), i = Math.max(a.from, t), o = Math.min(a.to, t + e.nodeSize);
35
35
  if (!r || e.marks.some((e) => e.type !== n) || c && r.attrs.href !== c.attrs.href) {
36
36
  l = !1;
37
37
  return;
38
38
  }
39
- c = r, u += e.text?.slice(a - t, o - t) ?? "";
39
+ c = r, u += e.text?.slice(i - t, o - t) ?? "";
40
40
  });
41
- let d = a(c?.attrs.href);
41
+ let d = i(c?.attrs.href);
42
42
  return !l || !c || !d ? null : {
43
43
  href: d,
44
44
  linkText: u || d,
45
45
  mark: c,
46
- from: i.from,
47
- to: i.to,
48
- isSoleTextblockContent: i.from === o && i.to === o + s.content.size
46
+ from: a.from,
47
+ to: a.to,
48
+ isSoleTextblockContent: a.from === o && a.to === o + s.content.size
49
49
  };
50
50
  }, d = (e, t) => {
51
51
  if (!t) return !0;
@@ -62,12 +62,12 @@ var l = (e, t) => {
62
62
  let o = e.doc.type.schema.text(r, [i.create({ href: n })]);
63
63
  return e.replaceWith(t.position, t.position + t.node.nodeSize, o), e.setSelection(c.create(e.doc, t.position, t.position + o.nodeSize)), !0;
64
64
  }, h = ({ resolveMetadata: e, shouldPreview: s }) => ({
65
- insertExternalLinkPreview: (t) => ({ dispatch: a, tr: c }) => {
66
- let l = i({
67
- ...t,
68
- linkText: t.linkText ?? t.href,
69
- display: t.display ?? "compact"
70
- }), u = c.doc.type.schema.nodes[n], { selection: p } = c, m = l?.display === "card" && !r(l);
65
+ insertExternalLinkPreview: (i) => ({ dispatch: a, tr: c }) => {
66
+ let l = r({
67
+ ...i,
68
+ linkText: i.linkText ?? i.href,
69
+ display: i.display ?? "compact"
70
+ }), u = c.doc.type.schema.nodes[t], { selection: p } = c, m = l?.display === "card" && !n(l);
71
71
  if (!l || !u || m && !e || !d(l.href, s) || !p.$from.sameParent(p.$to) || !p.$from.parent.isTextblock || l.display === "card" && p.$from.parent.content.size !== p.content().size) return !1;
72
72
  let h = p.$from.index();
73
73
  if (!p.$from.parent.canReplaceWith(h, h, u)) return !1;
@@ -75,44 +75,44 @@ var l = (e, t) => {
75
75
  let g = u.create(l), _ = p.from;
76
76
  return c.replaceRangeWith(p.from, p.to, g), f(c, _), m && o(c, _, l.href), !0;
77
77
  },
78
- setExternalLinkDisplay: (t, n) => ({ dispatch: a, tr: c }) => {
79
- let h = () => (c.setMeta("preventDispatch", !0), !1), g = l(c, n);
78
+ setExternalLinkDisplay: (t, i) => ({ dispatch: a, tr: c }) => {
79
+ let h = () => (c.setMeta("preventDispatch", !0), !1), g = l(c, i);
80
80
  if (g) {
81
- let n = t === "card" && !r(g.attributes);
81
+ let r = t === "card" && !n(g.attributes);
82
82
  if (t === "card" && !g.isSoleTextblockContent) return h();
83
83
  if (t === "plain") {
84
84
  let e = c.doc.type.schema.marks.link, t = c.doc.resolve(g.position).parent;
85
85
  return !e || !t.type.allowsMarkType(e) ? h() : !a || m(c, g);
86
86
  }
87
- return t !== "compact" && t !== "card" || n && !e ? h() : !a || g.attributes.display === t || (c.setNodeMarkup(g.position, void 0, {
87
+ return t !== "compact" && t !== "card" || r && !e ? h() : !a || g.attributes.display === t || (c.setNodeMarkup(g.position, void 0, {
88
88
  ...g.attributes,
89
89
  display: t
90
- }), f(c, g.position), n && o(c, g.position, g.attributes.href), !0);
90
+ }), f(c, g.position), r && o(c, g.position, g.attributes.href), !0);
91
91
  }
92
- if (typeof n == "number") return h();
92
+ if (typeof i == "number") return h();
93
93
  let _ = u(c);
94
94
  if (!_ || t === "plain" || t === "card" && !e || t === "card" && !_.isSoleTextblockContent || !d(_.href, s)) return t === "plain" && _ ? !0 : h();
95
- let v = i({
95
+ let v = r({
96
96
  href: _.href,
97
97
  linkText: _.linkText,
98
98
  display: t
99
99
  }), y = v ? p(c, v) : null;
100
100
  return !v || !y ? h() : !a || (c.replaceWith(_.from, _.to, y), f(c, _.from), t === "card" && o(c, _.from, v.href), !0);
101
101
  },
102
- convertExternalLinkPreviewToPlain: (e, n) => ({ dispatch: r, tr: i }) => {
103
- let a = () => (i.setMeta("preventDispatch", !0), !1), o = l(i, n), s = t(e);
104
- if (!o || !s) return a();
105
- let c = i.doc.type.schema.marks.link, u = i.doc.resolve(o.position).parent;
106
- return !c || !u.type.allowsMarkType(c) ? a() : !r || m(i, o, s, o.attributes.linkText === o.attributes.href ? s : o.attributes.linkText);
102
+ convertExternalLinkPreviewToPlain: (e, t) => ({ dispatch: n, tr: r }) => {
103
+ let i = () => (r.setMeta("preventDispatch", !0), !1), o = l(r, t), s = a(e);
104
+ if (!o || !s) return i();
105
+ let c = r.doc.type.schema.marks.link, u = r.doc.resolve(o.position).parent;
106
+ return !c || !u.type.allowsMarkType(c) ? i() : !n || m(r, o, s, o.attributes.linkText === o.attributes.href ? s : o.attributes.linkText);
107
107
  },
108
108
  refreshExternalLinkPreview: (t) => ({ dispatch: n, tr: r }) => {
109
109
  let i = l(r, t);
110
110
  return !i || i.attributes.display !== "card" || !e || !d(i.attributes.href, s) ? !1 : (n && (typeof t == "number" && f(r, i.position), o(r, i.position, i.attributes.href), r.setMeta("addToHistory", !1)), !0);
111
111
  },
112
- updateExternalLinkPreview: (t, n) => ({ dispatch: r, tr: c }) => {
112
+ updateExternalLinkPreview: (t, n) => ({ dispatch: a, tr: c }) => {
113
113
  let u = () => (c.setMeta("preventDispatch", !0), !1), p = l(c, n);
114
114
  if (!p) return u();
115
- let m = t.href ?? p.attributes.href, h = a(m), g = h !== p.attributes.href;
115
+ let m = t.href ?? p.attributes.href, h = i(m), g = h !== p.attributes.href;
116
116
  if (!h || !d(h, s)) return u();
117
117
  let _ = Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0)), v = g ? {
118
118
  pageTitle: null,
@@ -121,14 +121,14 @@ var l = (e, t) => {
121
121
  faviconUrl: null,
122
122
  imageUrl: null,
123
123
  fetchedAt: null
124
- } : {}, y = i({
124
+ } : {}, y = r({
125
125
  ...p.attributes,
126
126
  ...v,
127
127
  ..._,
128
128
  href: h,
129
129
  linkText: t.linkText ?? (g && p.attributes.linkText === p.attributes.href ? h : p.attributes.linkText)
130
130
  });
131
- return y ? !Object.entries(y).some(([e, t]) => p.attributes[e] !== t) || !r || (c.setNodeMarkup(p.position, void 0, y), f(c, p.position), g && p.attributes.display === "card" && e && o(c, p.position, y.href), !0) : u();
131
+ return y ? !Object.entries(y).some(([e, t]) => p.attributes[e] !== t) || !a || (c.setNodeMarkup(p.position, void 0, y), f(c, p.position), g && p.attributes.display === "card" && e && o(c, p.position, y.href), !0) : u();
132
132
  }
133
133
  });
134
134
  //#endregion
@@ -1,4 +1,3 @@
1
- import { Node } from "@tiptap/core";
2
1
  import type { ExternalLinkPreviewOptions } from "./types";
3
2
  /**
4
3
  * Backend-agnostic enhanced external links. Consumers own metadata fetching through
@@ -6,7 +5,7 @@ import type { ExternalLinkPreviewOptions } from "./types";
6
5
  *
7
6
  * @experimental The link-preview API and built-in UI may change while this feature is tested.
8
7
  */
9
- export declare const ExternalLinkPreview: Node<ExternalLinkPreviewOptions, any>;
8
+ export declare const ExternalLinkPreview: import("@tiptap/core").Node<ExternalLinkPreviewOptions, any>;
10
9
  export { EXTERNAL_LINK_PREVIEW_NODE_NAME } from "./attributes";
11
10
  export { EXTERNAL_LINK_PREVIEW_DISPLAYS } from "./types";
12
11
  export type { ExternalLinkDisplay, ExternalLinkPreviewAttributes, ExternalLinkPreviewDisplay, ExternalLinkPreviewMetadata, ExternalLinkPreviewOptions, ExternalLinkPreviewResolutionStatus, ExternalLinkPreviewResolver, ExternalLinkPreviewResolverContext, InsertExternalLinkPreviewOptions, UpdateExternalLinkPreviewOptions, } from "./types";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAyBpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAyC1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,uCAmJ9B,CAAC;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,2BAA2B,EAC3B,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/index.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,8DAoD9B,CAAC;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,2BAA2B,EAC3B,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,SAAS,CAAC"}