@clevertask/scribe 0.1.12 → 0.1.14

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 (91) hide show
  1. package/README.md +51 -1
  2. package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-x4sf3ECS.js} +1 -1
  3. package/dist/assets/index.css +1 -1
  4. package/dist/components/Menu/BarMenu.js +1 -1
  5. package/dist/components/Menu/BubbleMenu.js +2 -2
  6. package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
  7. package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts +13 -0
  8. package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +1 -0
  9. package/dist/components/Menu/ExternalLinkDisplayOptions.js +90 -0
  10. package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
  11. package/dist/components/Menu/LinkBubbleMenu.js +161 -61
  12. package/dist/components/Menu/LinkEditor.d.ts +9 -0
  13. package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
  14. package/dist/components/Menu/LinkEditor.js +117 -64
  15. package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
  16. package/dist/components/Menu/TableBubbleMenu.js +2 -2
  17. package/dist/components/Menu/contextualMenuOwner.d.ts +1 -1
  18. package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -1
  19. package/dist/components/Menu/contextualMenuOwner.js +9 -6
  20. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +24 -1
  21. package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
  22. package/dist/components/Menu/linkBubbleMenuPlugin.js +43 -6
  23. package/dist/components/Scribe/extension/callout.js +1 -1
  24. package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
  25. package/dist/components/Scribe/extension/extension-link.js +1 -1
  26. package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
  27. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  28. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts +18 -0
  29. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -0
  30. package/dist/components/Scribe/extension/external-link-preview/attributes.js +82 -0
  31. package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +53 -0
  32. package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -0
  33. package/dist/components/Scribe/extension/external-link-preview/commands.js +134 -0
  34. package/dist/components/Scribe/extension/external-link-preview/index.d.ts +13 -0
  35. package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -0
  36. package/dist/components/Scribe/extension/external-link-preview/index.js +138 -0
  37. package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +3 -0
  38. package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +1 -0
  39. package/dist/components/Scribe/extension/external-link-preview/node-view.js +97 -0
  40. package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +7 -0
  41. package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +1 -0
  42. package/dist/components/Scribe/extension/external-link-preview/normalization.js +21 -0
  43. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +8 -0
  44. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -0
  45. package/dist/components/Scribe/extension/external-link-preview/paste.js +54 -0
  46. package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +7 -0
  47. package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +1 -0
  48. package/dist/components/Scribe/extension/external-link-preview/policy.js +38 -0
  49. package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +7 -0
  50. package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -0
  51. package/dist/components/Scribe/extension/external-link-preview/render-html.js +62 -0
  52. package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +23 -0
  53. package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +1 -0
  54. package/dist/components/Scribe/extension/external-link-preview/resolver.js +118 -0
  55. package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts +10 -0
  56. package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -0
  57. package/dist/components/Scribe/extension/external-link-preview/serialization.js +69 -0
  58. package/dist/components/Scribe/extension/external-link-preview/types.d.ts +53 -0
  59. package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -0
  60. package/dist/components/Scribe/extension/external-link-preview/types.js +4 -0
  61. package/dist/components/Scribe/extension/index.d.ts +1 -1
  62. package/dist/components/Scribe/extension/index.d.ts.map +1 -1
  63. package/dist/components/Scribe/extension/index.js +1 -1
  64. package/dist/components/Scribe/extension/resizable-table.js +1 -1
  65. package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
  66. package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
  67. package/dist/components/Scribe/extension/tableOfContents.js +1 -1
  68. package/dist/components/Scribe/index.d.ts +14 -0
  69. package/dist/components/Scribe/index.d.ts.map +1 -1
  70. package/dist/components/Scribe/index.js +5 -5
  71. package/dist/{dist-Dw4STOPE.js → dist-DDjaA1Pn.js} +309 -150
  72. package/dist/{dist-DFua_Xbu.js → dist-tNcpTcFT.js} +893 -430
  73. package/dist/{extension-_8uh0Ik9.js → extension-dRUfQQo6.js} +2097 -2059
  74. package/dist/{extension-link-CjfUZ90W.js → extension-link-RYtPpHwt.js} +52 -51
  75. package/dist/{html-to-markdown-C920nQtn.js → html-to-markdown-nbQ6qHyO.js} +173 -162
  76. package/dist/main.css +148 -0
  77. package/dist/main.d.ts +1 -0
  78. package/dist/main.d.ts.map +1 -1
  79. package/dist/main.js +12 -9
  80. package/dist/{markdown-to-html-CW0Nb9Ye.js → markdown-to-html-B-KKCZRs.js} +115 -111
  81. package/dist/{menus-_EXlLMjz.js → menus-U2HdvQnu.js} +18 -18
  82. package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-m0AzovsZ.js} +42 -24
  83. package/dist/{slashCommand-CxX07Nbk.js → slashCommand-CtvgnL0Z.js} +2 -2
  84. package/dist/utils/create-scribe-editor.d.ts +4 -1
  85. package/dist/utils/create-scribe-editor.d.ts.map +1 -1
  86. package/dist/utils/html-to-markdown.d.ts.map +1 -1
  87. package/dist/utils/html-to-markdown.js +1 -1
  88. package/dist/utils/index.js +7 -7
  89. package/dist/utils/markdown-to-html.d.ts.map +1 -1
  90. package/dist/utils/markdown-to-html.js +1 -1
  91. package/package.json +48 -48
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../BarMenu-5M9g9Y1j.js";
1
+ import { t as e } from "../../BarMenu-x4sf3ECS.js";
2
2
  export { e as default };
@@ -1,6 +1,6 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { s as e } from "../../dist-DDjaA1Pn.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-_EXlLMjz.js";
3
+ import { t as n } from "../../menus-U2HdvQnu.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,6 +1,6 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { s as e } from "../../dist-DDjaA1Pn.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
- import { t as n } from "../../menus-_EXlLMjz.js";
3
+ import { t as n } from "../../menus-U2HdvQnu.js";
4
4
  import { CalloutIcon as r, RemoveCalloutIcon as i } from "../../icons/CalloutIcon.js";
5
5
  import { CALLOUT_VARIANTS as a, CALLOUT_VARIANT_LABELS as o, isCalloutVariant as s } from "../Scribe/extension/callout.js";
6
6
  import { calloutBubbleMenuPluginKey as c, getSelectionCalloutContext as l } from "./calloutBubbleMenuPlugin.js";
@@ -0,0 +1,13 @@
1
+ import type { Editor } from "@tiptap/react";
2
+ import type { ExternalLinkDisplay } from "../Scribe/extension/external-link-preview/types";
3
+ export type { ExternalLinkDisplay } from "../Scribe/extension/external-link-preview/types";
4
+ export interface ExternalLinkDisplayOptionsProps {
5
+ currentDisplay: ExternalLinkDisplay;
6
+ editor: Editor;
7
+ executeDisplayChange?: (display: ExternalLinkDisplay) => boolean;
8
+ onDisplayChange?: (display: ExternalLinkDisplay) => void;
9
+ targetPosition?: number;
10
+ }
11
+ declare const ExternalLinkDisplayOptions: ({ currentDisplay, editor, executeDisplayChange, onDisplayChange, targetPosition, }: ExternalLinkDisplayOptionsProps) => import("react").JSX.Element | null;
12
+ export default ExternalLinkDisplayOptions;
13
+ //# sourceMappingURL=ExternalLinkDisplayOptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExternalLinkDisplayOptions.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/ExternalLinkDisplayOptions.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAE3F,YAAY,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AAE3F,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,mBAAmB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,oBAAoB,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,OAAO,CAAC;IACjE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAuCD,QAAA,MAAM,0BAA0B,uFAM7B,+BAA+B,uCA4FjC,CAAC;eAEa,0BAA0B"}
@@ -0,0 +1,90 @@
1
+ import { Button as e, Flex as t, Text as n } from "@radix-ui/themes";
2
+ import { useCallback as r, useId as i } from "react";
3
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ //#region lib/components/Menu/ExternalLinkDisplayOptions.tsx
5
+ var s = [
6
+ {
7
+ description: "Show a regular text link.",
8
+ display: "plain",
9
+ label: "Plain link"
10
+ },
11
+ {
12
+ description: "Show the page title and site icon.",
13
+ display: "compact",
14
+ label: "Compact"
15
+ },
16
+ {
17
+ description: "Show an image, title, and description.",
18
+ display: "card",
19
+ label: "Preview card"
20
+ }
21
+ ], c = (e) => e.commands, l = (e) => e.can(), u = ({ currentDisplay: u, editor: d, executeDisplayChange: f, onDisplayChange: p, targetPosition: m }) => {
22
+ let h = i(), g = c(d), _ = l(d), v = typeof g.setExternalLinkDisplay == "function", y = (e) => typeof m == "number" ? !!_.setExternalLinkDisplay?.(e, m) : !!_.setExternalLinkDisplay?.(e), b = {
23
+ plain: u === "plain" || y("plain"),
24
+ compact: u === "compact" || y("compact"),
25
+ card: u === "card" || y("card")
26
+ }, x = v && b.compact, S = v && b.card, C = u !== "plain" || x || S, w = r((e) => {
27
+ e !== u && (f?.(e) ?? (typeof m == "number" ? d.chain().focus().setExternalLinkDisplay(e, m).run() : c(d).setExternalLinkDisplay?.(e))) && p?.(e);
28
+ }, [
29
+ u,
30
+ d,
31
+ f,
32
+ p,
33
+ m
34
+ ]);
35
+ return !v || !C ? null : /* @__PURE__ */ o(t, {
36
+ direction: "column",
37
+ gap: "2",
38
+ children: [/* @__PURE__ */ a(n, {
39
+ as: "p",
40
+ size: "2",
41
+ weight: "medium",
42
+ children: "Display as"
43
+ }), /* @__PURE__ */ a(t, {
44
+ role: "group",
45
+ "aria-label": "Display as",
46
+ direction: "column",
47
+ gap: "1",
48
+ children: s.map((r) => {
49
+ let i = u === r.display, s = b[r.display], c = `${h}-${r.display}-description`, l = r.display === "card" && !s ? "Preview card needs its own line." : r.description;
50
+ return /* @__PURE__ */ a(e, {
51
+ type: "button",
52
+ "aria-describedby": c,
53
+ "aria-label": r.label,
54
+ "aria-pressed": i,
55
+ color: "gray",
56
+ disabled: !s,
57
+ variant: i ? "soft" : "ghost",
58
+ onClick: () => w(r.display),
59
+ style: {
60
+ height: "auto",
61
+ justifyContent: "flex-start",
62
+ paddingBottom: 8,
63
+ paddingTop: 8,
64
+ textAlign: "left",
65
+ width: "100%"
66
+ },
67
+ children: /* @__PURE__ */ o(t, {
68
+ direction: "column",
69
+ gap: "1",
70
+ align: "start",
71
+ children: [/* @__PURE__ */ a(n, {
72
+ as: "span",
73
+ size: "2",
74
+ weight: "medium",
75
+ children: r.label
76
+ }), /* @__PURE__ */ a(n, {
77
+ id: c,
78
+ as: "span",
79
+ size: "1",
80
+ color: "gray",
81
+ children: l
82
+ })]
83
+ })
84
+ }, r.display);
85
+ })
86
+ })]
87
+ });
88
+ };
89
+ //#endregion
90
+ export { u as default };
@@ -1 +1 @@
1
- {"version":3,"file":"LinkBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,EAAE,EAAqD,MAAM,OAAO,CAAC;AAS9E,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAID,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CA+J3C,CAAC;eAEa,cAAc"}
1
+ {"version":3,"file":"LinkBubbleMenu.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkBubbleMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAkB,MAAM,eAAe,CAAC;AAKvD,OAAO,EAAE,EAAE,EAA2E,MAAM,OAAO,CAAC;AAepG,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB;AAiCD,QAAA,MAAM,cAAc,EAAE,EAAE,CAAC,mBAAmB,CAia3C,CAAC;eAEa,cAAc"}
@@ -1,92 +1,192 @@
1
- import { a as e } from "../../dist-Dw4STOPE.js";
1
+ import { s as e } from "../../dist-DDjaA1Pn.js";
2
2
  import { getPopupMountTarget as t } from "../Scribe/extension/getPopupMountTarget.js";
3
3
  import n from "./LinkEditor.js";
4
- import { hideLinkBubbleMenu as r, linkBubbleMenuPluginKey as i, showLinkBubbleMenu as a } from "./linkBubbleMenuPlugin.js";
5
- import { t as o } from "../../menus-_EXlLMjz.js";
6
- import { Box as s } from "@radix-ui/themes";
7
- import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
8
- import { jsx as p } from "react/jsx-runtime";
4
+ import { getExternalLinkPreviewHostname as r } from "../Scribe/extension/external-link-preview/attributes.js";
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-U2HdvQnu.js";
7
+ import { getSelectionContextualMenuOwner as d } from "./contextualMenuOwner.js";
8
+ import { getExternalLinkPreviewResolutionStatus as f } from "../Scribe/extension/external-link-preview/resolver.js";
9
+ import { Box as p } from "@radix-ui/themes";
10
+ import { useCallback as m, useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
11
+ import { jsx as y } from "react/jsx-runtime";
9
12
  //#region lib/components/Menu/LinkBubbleMenu.tsx
10
- var m = ({ editor: m }) => {
11
- let [h, g] = f(""), _ = d(null), v = d(null), y = e({
12
- editor: m,
13
+ var b = /auto|overlay|scroll/, x = (e) => {
14
+ let t = e.ownerDocument.defaultView;
15
+ if (!t) return [];
16
+ let n = [], r = e.parentElement;
17
+ for (; r && r !== e.ownerDocument.body && r !== e.ownerDocument.documentElement;) {
18
+ let e = t.getComputedStyle(r);
19
+ b.test(`${e.overflow} ${e.overflowX} ${e.overflowY}`) && n.push(r), r = r.parentElement;
20
+ }
21
+ return n;
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({
24
+ editor: b,
13
25
  selector: ({ editor: e }) => {
14
- let { from: t, to: n } = e.state.selection;
15
- return {
16
- from: t,
17
- href: e.getAttributes("link").href ?? "",
18
- to: n
26
+ let t = o(e.state);
27
+ return !t || t.kind === "plain" ? {
28
+ canRefresh: !1,
29
+ context: t,
30
+ status: "idle",
31
+ statusLabel: ""
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)
19
37
  };
20
38
  }
21
39
  });
22
- l(() => {
23
- g(y.href);
40
+ h(() => {
41
+ C(j.context?.href ?? "");
24
42
  }, [
25
- y.from,
26
- y.href,
27
- y.to
28
- ]), l(() => () => {
29
- v.current !== null && window.cancelAnimationFrame(v.current);
30
- }, []), l(() => {
31
- if (m.isDestroyed) return;
32
- let e = m.view.dom, t = null, n = !1, r = (r) => {
33
- if (r.button !== 0 || !m.isEditable) return;
43
+ j.context?.from,
44
+ j.context?.href,
45
+ j.context?.to
46
+ ]), h(() => () => {
47
+ A.current !== null && window.cancelAnimationFrame(A.current);
48
+ }, []), h(() => {
49
+ if (b.isDestroyed) return;
50
+ let e = b.view.dom, t = null, n = (e) => !e || (b.commands.setTextSelection({
51
+ from: e.from,
52
+ to: e.to
53
+ }), d(b.state) !== "link") ? !1 : (l(b, "url"), !0), r = (n) => {
54
+ if (n.button !== 0 || !b.isEditable) return;
55
+ let r = n.target?.closest?.("a");
56
+ !r || !e.contains(r) || r.closest("[data-type=\"external-link-preview\"]") || (t = {
57
+ x: n.clientX,
58
+ y: n.clientY
59
+ });
60
+ }, i = (r) => {
61
+ if (r.button !== 0 || !b.isEditable) return;
34
62
  let i = r.target?.closest?.("a");
35
- !i || !e.contains(i) || (t !== null && window.clearTimeout(t), t = window.setTimeout(() => {
36
- if (t = null, n || m.isDestroyed || !m.isEditable || !r.defaultPrevented) return;
37
- let { from: e, to: i } = m.state.selection;
38
- e === i || !m.isActive("link") || a(m);
63
+ if (!i || !e.contains(i) || i.closest("[data-type=\"external-link-preview\"]")) return;
64
+ let o = r.detail > 0 && t !== null && Math.hypot(r.clientX - t.x, r.clientY - t.y) > 4;
65
+ if (t = null, o) return;
66
+ let s;
67
+ try {
68
+ s = b.view.posAtDOM(i, 0);
69
+ } catch {
70
+ return;
71
+ }
72
+ let c = a(b.state, s), l = c ? b.view.nodeDOM(c.from) : null;
73
+ !l || !i.contains(l) || n(c) && r.preventDefault();
74
+ };
75
+ return e.addEventListener("mousedown", r), e.addEventListener("click", i), () => {
76
+ e.removeEventListener("mousedown", r), e.removeEventListener("click", i);
77
+ };
78
+ }, [b]), h(() => {
79
+ let e = b.view.dom, t = (e) => {
80
+ if (e.key !== "F10" || !e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || !b.isEditable) return;
81
+ let t = o(b.state);
82
+ t?.kind === "plain" && (b.chain().extendMarkRange("link").run(), t = o(b.state)), !(!t || d(b.state) !== "link") && (e.preventDefault(), e.stopImmediatePropagation(), l(b, t.kind === "preview" ? "dialog" : "url"));
83
+ };
84
+ return e.addEventListener("keydown", t, !0), () => e.removeEventListener("keydown", t, !0);
85
+ }, [b]), h(() => {
86
+ let e = b.view.dom.ownerDocument, t = e.defaultView;
87
+ if (!t) return;
88
+ let n = (e) => {
89
+ let n = O.current;
90
+ !n?.isConnected || !(e instanceof t.Node) || n.contains(e) || b.view.dom.contains(e) || s(b);
91
+ }, r = (e) => n(e.target), i = (e) => n(e.target);
92
+ return e.addEventListener("pointerdown", r, !0), e.addEventListener("focusin", i), () => {
93
+ e.removeEventListener("pointerdown", r, !0), e.removeEventListener("focusin", i);
94
+ };
95
+ }, [b]), h(() => {
96
+ let e = b.view.dom.ownerDocument.defaultView;
97
+ if (!e) return;
98
+ let t = x(b.view.dom), n = null, r = () => {
99
+ n === null && (n = e.requestAnimationFrame(() => {
100
+ n = null, b.isDestroyed || b.view.dispatch(b.state.tr.setMeta(c, "updatePosition"));
39
101
  }));
40
102
  };
41
- return e.addEventListener("mouseup", r), () => {
42
- n = !0, t !== null && window.clearTimeout(t), e.removeEventListener("mouseup", r);
103
+ return e.addEventListener("scroll", r, { passive: !0 }), t.forEach((e) => {
104
+ e.addEventListener("scroll", r, { passive: !0 });
105
+ }), () => {
106
+ n !== null && e.cancelAnimationFrame(n), e.removeEventListener("scroll", r), t.forEach((e) => {
107
+ e.removeEventListener("scroll", r);
108
+ });
109
+ };
110
+ }, [b]), h(() => {
111
+ let e = b.view.dom.closest("[data-scribe-root]"), t = b.view.dom.ownerDocument.defaultView;
112
+ if (!e || !t) return;
113
+ let n = () => {
114
+ let t = e.getBoundingClientRect().width;
115
+ D(t > 0 ? Math.max(t - 16, 0) : null);
116
+ };
117
+ if (n(), !t.ResizeObserver) return;
118
+ let r = new t.ResizeObserver(n);
119
+ return r.observe(e), () => r.disconnect();
120
+ }, [b]);
121
+ let M = m(() => {
122
+ if (b.isDestroyed) return;
123
+ let e = b.state.selection.to;
124
+ s(b), b.chain().setTextSelection(e).focus().run();
125
+ }, [b]), N = m(() => {
126
+ let e = o(b.state);
127
+ e?.kind === "preview" && b.commands.refreshExternalLinkPreview(e.position);
128
+ }, [b]), P = m(() => {
129
+ A.current !== null && window.cancelAnimationFrame(A.current);
130
+ let e = o(b.state), t = i(b), n = () => {
131
+ t === "dialog" ? O.current?.focus() : (k.current?.focus(), k.current?.select());
43
132
  };
44
- }, [m]);
45
- let b = c(() => {
46
- if (m.isDestroyed) return;
47
- let e = m.state.selection.to;
48
- r(m), m.chain().setTextSelection(e).focus().run();
49
- }, [m]), x = c(() => {
50
- v.current !== null && window.cancelAnimationFrame(v.current), v.current = window.requestAnimationFrame(() => {
51
- _.current?.focus(), _.current?.select(), v.current = null;
133
+ C(e?.href ?? ""), T((e) => e + 1), n(), A.current = window.requestAnimationFrame(() => {
134
+ n(), A.current = null;
52
135
  });
53
- }, []), S = c(({ editor: e, element: t, from: n, to: r }) => {
54
- let i = t.contains(t.ownerDocument.activeElement);
55
- return e.isEditable && n !== r && e.isActive("link") && i;
56
- }, []), C = c(() => t(m), [m]), w = u(() => ({
136
+ }, [b]), F = m(() => {
137
+ A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null);
138
+ }, []), I = m((e) => {
139
+ e.key === "Escape" && (e.preventDefault(), e.stopPropagation(), M());
140
+ }, [M]), L = m(({ editor: e, element: t, state: n }) => {
141
+ let r = t.contains(t.ownerDocument.activeElement);
142
+ return e.isEditable && !!o(n) && d(n) === "link" && r;
143
+ }, []), R = m(() => t(b), [b]), z = g(() => ({
57
144
  strategy: "fixed",
58
145
  placement: "bottom",
59
146
  offset: 8,
60
147
  flip: {},
61
148
  shift: { padding: 8 },
62
149
  inline: !0,
63
- onShow: x
64
- }), [x]);
65
- return /* @__PURE__ */ p(o, {
66
- editor: m,
67
- pluginKey: i,
150
+ onHide: F,
151
+ onShow: P
152
+ }), [F, P]), B = j.context;
153
+ return /* @__PURE__ */ y(u, {
154
+ editor: b,
155
+ pluginKey: c,
68
156
  updateDelay: 0,
69
- appendTo: C,
70
- shouldShow: S,
71
- options: w,
72
- children: /* @__PURE__ */ p(s, {
157
+ resizeDelay: 0,
158
+ appendTo: R,
159
+ shouldShow: L,
160
+ options: z,
161
+ children: /* @__PURE__ */ y(p, {
162
+ ref: O,
73
163
  className: "scribe-link-popover",
74
164
  role: "dialog",
75
165
  "aria-label": "Edit link",
166
+ "aria-keyshortcuts": "Alt+F10",
167
+ tabIndex: -1,
168
+ onKeyDown: I,
76
169
  style: {
77
- maxWidth: "calc(100vw - 32px)",
170
+ maxWidth: E === null ? "calc(100vw - 32px)" : `min(${E}px, calc(100vw - 32px))`,
78
171
  width: 320
79
172
  },
80
- children: /* @__PURE__ */ p(n, {
81
- editor: m,
82
- existingHref: y.href,
83
- inputRef: _,
84
- onClose: b,
85
- onValueChange: g,
86
- value: h
173
+ children: /* @__PURE__ */ y(n, {
174
+ canRefreshPreview: j.canRefresh,
175
+ currentDisplay: B?.display ?? "plain",
176
+ editor: b,
177
+ existingHref: B?.href ?? "",
178
+ inputRef: k,
179
+ onClose: M,
180
+ onRefreshPreview: N,
181
+ onValueChange: C,
182
+ previewStatus: j.status,
183
+ previewStatusLabel: j.statusLabel,
184
+ resetToken: w,
185
+ targetPosition: B?.kind === "preview" ? B.position : void 0,
186
+ value: S
87
187
  })
88
188
  })
89
189
  });
90
190
  };
91
191
  //#endregion
92
- export { m as default };
192
+ export { S as default };
@@ -1,12 +1,21 @@
1
1
  import { Editor } from "@tiptap/react";
2
2
  import { FC, RefObject } from "react";
3
+ import type { ExternalLinkPreviewResolutionStatus } from "../Scribe/extension/external-link-preview/types";
4
+ import type { ExternalLinkDisplay } from "./ExternalLinkDisplayOptions";
3
5
  export interface LinkEditorProps {
6
+ canRefreshPreview?: boolean;
7
+ currentDisplay?: ExternalLinkDisplay;
4
8
  editor: Editor;
5
9
  existingHref: string;
6
10
  inputRef?: RefObject<HTMLInputElement | null>;
7
11
  onClose: () => void;
12
+ onRefreshPreview?: () => void;
8
13
  onValueChange: (value: string) => void;
14
+ previewStatus?: ExternalLinkPreviewResolutionStatus;
15
+ previewStatusLabel?: string;
16
+ resetToken?: number;
9
17
  selectTextblockEndAfterSave?: boolean;
18
+ targetPosition?: number;
10
19
  value: string;
11
20
  }
12
21
  declare const LinkEditor: FC<LinkEditorProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"LinkEditor.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,EAAE,EAGF,SAAS,EAKV,MAAM,OAAO,CAAC;AAGf,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAkJnC,CAAC;eAEa,UAAU"}
1
+ {"version":3,"file":"LinkEditor.d.ts","sourceRoot":"","sources":["../../../lib/components/Menu/LinkEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EACL,EAAE,EAGF,SAAS,EAKV,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iDAAiD,CAAC;AAE3G,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAGxE,MAAM,WAAW,eAAe;IAC9B,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,cAAc,CAAC,EAAE,mBAAmB,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;IAC9C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC9B,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,aAAa,CAAC,EAAE,mCAAmC,CAAC;IACpD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2BAA2B,CAAC,EAAE,OAAO,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,UAAU,EAAE,EAAE,CAAC,eAAe,CAkRnC,CAAC;eAEa,UAAU"}