@clevertask/scribe 0.1.13 → 0.1.15
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.
- package/README.md +52 -0
- package/dist/{BarMenu-O2IVhHXx.js → BarMenu-x4sf3ECS.js} +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts +13 -0
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +1 -0
- package/dist/components/Menu/ExternalLinkDisplayOptions.js +90 -0
- package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/LinkBubbleMenu.js +161 -61
- package/dist/components/Menu/LinkEditor.d.ts +9 -0
- package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
- package/dist/components/Menu/LinkEditor.js +117 -64
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +2 -2
- package/dist/components/Menu/contextualMenuOwner.d.ts +1 -1
- package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -1
- package/dist/components/Menu/contextualMenuOwner.js +9 -6
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +24 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.js +43 -6
- package/dist/components/Scribe/extension/callout.js +1 -1
- package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts +18 -0
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/attributes.js +82 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +53 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.js +134 -0
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts +13 -0
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/index.js +140 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +3 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +97 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.js +21 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +9 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.js +54 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.js +38 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +62 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +23 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.js +118 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts +10 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.js +69 -0
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts +58 -0
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/types.js +4 -0
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.d.ts +14 -0
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +5 -5
- package/dist/{dist-BoYfa2nz.js → dist-DDjaA1Pn.js} +309 -150
- package/dist/{dist-W9E-K577.js → dist-tNcpTcFT.js} +738 -637
- package/dist/{extension-D5WIAWhc.js → extension-dRUfQQo6.js} +1940 -1938
- package/dist/{extension-link-D8Zi7OSa.js → extension-link-RYtPpHwt.js} +28 -27
- package/dist/{html-to-markdown-C920nQtn.js → html-to-markdown-nbQ6qHyO.js} +173 -162
- package/dist/main.css +148 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +12 -9
- package/dist/{markdown-to-html-CW0Nb9Ye.js → markdown-to-html-B-KKCZRs.js} +115 -111
- package/dist/{menus-B1Zz0GjH.js → menus-U2HdvQnu.js} +11 -11
- package/dist/{resizable-table-Bf-fb9iv.js → resizable-table-m0AzovsZ.js} +14 -14
- package/dist/{slashCommand-47omO4ob.js → slashCommand-CtvgnL0Z.js} +1 -1
- package/dist/utils/create-scribe-editor.d.ts +4 -1
- package/dist/utils/create-scribe-editor.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +7 -7
- package/dist/utils/markdown-to-html.d.ts.map +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { v as e } from "../../../../dist-tNcpTcFT.js";
|
|
2
|
+
import { normalizeLinkUrl as t } from "../../../Menu/linkUrl.js";
|
|
3
|
+
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as n, normalizeExternalLinkPreviewAttributes as r, normalizeExternalLinkPreviewHref as i } from "./attributes.js";
|
|
4
|
+
import { startExternalLinkPreviewResolution as a } from "./resolver.js";
|
|
5
|
+
import { NodeSelection as o, TextSelection as s } from "@tiptap/pm/state";
|
|
6
|
+
//#region lib/components/Scribe/extension/external-link-preview/commands.ts
|
|
7
|
+
var c = (e, t) => {
|
|
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, s = i ? e.doc.nodeAt(a) : n instanceof o ? n.node : null;
|
|
11
|
+
if (!s || s.type.name !== "externalLinkPreview") return null;
|
|
12
|
+
let c = r(s.attrs);
|
|
13
|
+
if (!c) return null;
|
|
14
|
+
let l = e.doc.resolve(a);
|
|
15
|
+
return {
|
|
16
|
+
attributes: c,
|
|
17
|
+
node: s,
|
|
18
|
+
position: a,
|
|
19
|
+
isSoleTextblockContent: l.parent.isTextblock && l.parent.childCount === 1 && l.parent.content.size === s.nodeSize
|
|
20
|
+
};
|
|
21
|
+
}, l = (t) => {
|
|
22
|
+
let n = t.doc.type.schema.marks.link;
|
|
23
|
+
if (!n) return null;
|
|
24
|
+
let { selection: r } = t;
|
|
25
|
+
if (!r.$from.sameParent(r.$to) || !r.$from.parent.isTextblock) return null;
|
|
26
|
+
let a = e(r.$from, n), o = r.$from.start(), s = r.$from.parent;
|
|
27
|
+
if (!a) return null;
|
|
28
|
+
let c, l = !0, u = "";
|
|
29
|
+
t.doc.nodesBetween(a.from, a.to, (e, t) => {
|
|
30
|
+
if (!e.isText) {
|
|
31
|
+
e.isInline && (l = !1);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
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
|
+
if (!r || e.marks.some((e) => e.type !== n) || c && r.attrs.href !== c.attrs.href) {
|
|
36
|
+
l = !1;
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
c = r, u += e.text?.slice(i - t, o - t) ?? "";
|
|
40
|
+
});
|
|
41
|
+
let d = i(c?.attrs.href);
|
|
42
|
+
return !l || !c || !d ? null : {
|
|
43
|
+
href: d,
|
|
44
|
+
linkText: u || d,
|
|
45
|
+
mark: c,
|
|
46
|
+
from: a.from,
|
|
47
|
+
to: a.to,
|
|
48
|
+
isSoleTextblockContent: a.from === o && a.to === o + s.content.size
|
|
49
|
+
};
|
|
50
|
+
}, u = (e, t) => {
|
|
51
|
+
if (!t) return !0;
|
|
52
|
+
try {
|
|
53
|
+
return t(e);
|
|
54
|
+
} catch {
|
|
55
|
+
return !1;
|
|
56
|
+
}
|
|
57
|
+
}, d = (e, t) => {
|
|
58
|
+
e.setSelection(o.create(e.doc, t));
|
|
59
|
+
}, f = (e, t) => e.doc.type.schema.nodes.externalLinkPreview?.create(t) ?? null, p = (e, t, n = t.attributes.href, r = t.attributes.linkText) => {
|
|
60
|
+
let i = e.doc.type.schema.marks.link, a = e.doc.resolve(t.position).parent;
|
|
61
|
+
if (!i || !a.type.allowsMarkType(i)) return !1;
|
|
62
|
+
let o = e.doc.type.schema.text(r, [i.create({ href: n })]);
|
|
63
|
+
return e.replaceWith(t.position, t.position + t.node.nodeSize, o), e.setSelection(s.create(e.doc, t.position, t.position + o.nodeSize)), !0;
|
|
64
|
+
}, m = ({ resolveMetadata: e, shouldPreview: o }) => ({
|
|
65
|
+
insertExternalLinkPreview: (t) => ({ dispatch: i, tr: s }) => {
|
|
66
|
+
let c = r({
|
|
67
|
+
...t,
|
|
68
|
+
linkText: t.linkText ?? t.href,
|
|
69
|
+
display: t.display ?? "compact"
|
|
70
|
+
}), l = s.doc.type.schema.nodes[n], { selection: f } = s;
|
|
71
|
+
if (!e || !c || !l || !u(c.href, o) || !f.$from.sameParent(f.$to) || !f.$from.parent.isTextblock || c.display === "card" && f.$from.parent.content.size !== f.content().size) return !1;
|
|
72
|
+
let p = f.$from.index();
|
|
73
|
+
if (!f.$from.parent.canReplaceWith(p, p, l)) return !1;
|
|
74
|
+
if (!i) return !0;
|
|
75
|
+
let m = l.create(c), h = f.from;
|
|
76
|
+
return s.replaceRangeWith(f.from, f.to, m), d(s, h), e && a(s, h, c.href), !0;
|
|
77
|
+
},
|
|
78
|
+
setExternalLinkDisplay: (t, n) => ({ dispatch: i, tr: s }) => {
|
|
79
|
+
let m = () => (s.setMeta("preventDispatch", !0), !1), h = c(s, n);
|
|
80
|
+
if (h) {
|
|
81
|
+
if (t === "card" && !h.isSoleTextblockContent) return m();
|
|
82
|
+
if (t === "plain") {
|
|
83
|
+
let e = s.doc.type.schema.marks.link, t = s.doc.resolve(h.position).parent;
|
|
84
|
+
return !e || !t.type.allowsMarkType(e) ? m() : !i || p(s, h);
|
|
85
|
+
}
|
|
86
|
+
return t !== "compact" && t !== "card" ? m() : !i || h.attributes.display === t || (s.setNodeMarkup(h.position, void 0, {
|
|
87
|
+
...h.attributes,
|
|
88
|
+
display: t
|
|
89
|
+
}), d(s, h.position), !0);
|
|
90
|
+
}
|
|
91
|
+
if (typeof n == "number") return m();
|
|
92
|
+
let g = l(s);
|
|
93
|
+
if (!g || t === "plain" || !e || t === "card" && !g.isSoleTextblockContent || !u(g.href, o)) return t === "plain" && g ? !0 : m();
|
|
94
|
+
let _ = r({
|
|
95
|
+
href: g.href,
|
|
96
|
+
linkText: g.linkText,
|
|
97
|
+
display: t
|
|
98
|
+
}), v = _ ? f(s, _) : null;
|
|
99
|
+
return !_ || !v ? m() : !i || (s.replaceWith(g.from, g.to, v), d(s, g.from), e && a(s, g.from, _.href), !0);
|
|
100
|
+
},
|
|
101
|
+
convertExternalLinkPreviewToPlain: (e, n) => ({ dispatch: r, tr: i }) => {
|
|
102
|
+
let a = () => (i.setMeta("preventDispatch", !0), !1), o = c(i, n), s = t(e);
|
|
103
|
+
if (!o || !s) return a();
|
|
104
|
+
let l = i.doc.type.schema.marks.link, u = i.doc.resolve(o.position).parent;
|
|
105
|
+
return !l || !u.type.allowsMarkType(l) ? a() : !r || p(i, o, s, o.attributes.linkText === o.attributes.href ? s : o.attributes.linkText);
|
|
106
|
+
},
|
|
107
|
+
refreshExternalLinkPreview: (t) => ({ dispatch: n, tr: r }) => {
|
|
108
|
+
let i = c(r, t);
|
|
109
|
+
return !i || !e || !u(i.attributes.href, o) ? !1 : (n && (typeof t == "number" && d(r, i.position), a(r, i.position, i.attributes.href), r.setMeta("addToHistory", !1)), !0);
|
|
110
|
+
},
|
|
111
|
+
updateExternalLinkPreview: (t, n) => ({ dispatch: s, tr: l }) => {
|
|
112
|
+
let f = () => (l.setMeta("preventDispatch", !0), !1), p = c(l, n);
|
|
113
|
+
if (!p) return f();
|
|
114
|
+
let m = t.href ?? p.attributes.href, h = i(m), g = h !== p.attributes.href;
|
|
115
|
+
if (!h || !u(h, o)) return f();
|
|
116
|
+
let _ = Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0)), v = g ? {
|
|
117
|
+
pageTitle: null,
|
|
118
|
+
description: null,
|
|
119
|
+
siteName: null,
|
|
120
|
+
faviconUrl: null,
|
|
121
|
+
imageUrl: null,
|
|
122
|
+
fetchedAt: null
|
|
123
|
+
} : {}, y = r({
|
|
124
|
+
...p.attributes,
|
|
125
|
+
...v,
|
|
126
|
+
..._,
|
|
127
|
+
href: h,
|
|
128
|
+
linkText: t.linkText ?? (g && p.attributes.linkText === p.attributes.href ? h : p.attributes.linkText)
|
|
129
|
+
});
|
|
130
|
+
return y ? !Object.entries(y).some(([e, t]) => p.attributes[e] !== t) || !s || (l.setNodeMarkup(p.position, void 0, y), d(l, p.position), g && e && a(l, p.position, y.href), !0) : f();
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
//#endregion
|
|
134
|
+
export { m as createExternalLinkPreviewCommands, c as getSelectedExternalLinkPreview };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node } from "@tiptap/core";
|
|
2
|
+
import type { ExternalLinkPreviewOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Backend-agnostic enhanced external links. Consumers own metadata fetching through
|
|
5
|
+
* the optional resolver; Scribe owns only presentation, conversion, and persistence.
|
|
6
|
+
*
|
|
7
|
+
* @experimental The link-preview API and built-in UI may change while this feature is tested.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ExternalLinkPreview: Node<ExternalLinkPreviewOptions, any>;
|
|
10
|
+
export { EXTERNAL_LINK_PREVIEW_NODE_NAME } from "./attributes";
|
|
11
|
+
export { EXTERNAL_LINK_PREVIEW_DISPLAYS } from "./types";
|
|
12
|
+
export type { ExternalLinkDisplay, ExternalLinkPreviewAttributes, ExternalLinkPreviewDisplay, ExternalLinkPreviewMetadata, ExternalLinkPreviewOptions, ExternalLinkPreviewResolutionStatus, ExternalLinkPreviewResolver, ExternalLinkPreviewResolverContext, InsertExternalLinkPreviewOptions, UpdateExternalLinkPreviewOptions, } from "./types";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,uCAoJ9B,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"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { r as e } from "../../../../dist-DDjaA1Pn.js";
|
|
2
|
+
import { a as t } from "../../../../dist-tNcpTcFT.js";
|
|
3
|
+
import { EXTERNAL_LINK_PREVIEW_DISPLAYS as n } from "./types.js";
|
|
4
|
+
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as r, isExternalLinkPreviewDisplay as i, normalizeExternalLinkPreviewAttributes as a, normalizeExternalLinkPreviewHref as o, normalizeExternalLinkPreviewLinkText as s, normalizeExternalLinkPreviewMediaUrl as c, normalizeExternalLinkPreviewMetadata as l } from "./attributes.js";
|
|
5
|
+
import { createExternalLinkPreviewResolverPlugin as u } from "./resolver.js";
|
|
6
|
+
import { getExternalLinkPreviewAttributesFromElement as d } from "./serialization.js";
|
|
7
|
+
import { createExternalLinkPreviewCommands as f } from "./commands.js";
|
|
8
|
+
import { ExternalLinkPreviewNodeView as p } from "./node-view.js";
|
|
9
|
+
import { createExternalLinkPreviewNormalizationPlugin as m, createExternalLinkPreviewNormalizationTransaction as h } from "./normalization.js";
|
|
10
|
+
import { renderExternalLinkPreviewHTML as g } from "./render-html.js";
|
|
11
|
+
import { createExternalLinkPreviewPastePlugin as _ } from "./paste.js";
|
|
12
|
+
import { createExternalLinkPreviewPolicyPlugin as v, createExternalLinkPreviewPolicyTransaction as y } from "./policy.js";
|
|
13
|
+
//#region lib/components/Scribe/extension/external-link-preview/index.ts
|
|
14
|
+
var b = (e) => {
|
|
15
|
+
if (o(e) !== e) throw RangeError("External link previews require an absolute HTTP(S) URL.");
|
|
16
|
+
}, x = (e) => {
|
|
17
|
+
if (s(e) !== e) throw RangeError("External link previews require non-empty fallback link text.");
|
|
18
|
+
}, S = (e) => {
|
|
19
|
+
if (!i(e)) throw RangeError(`Invalid external link preview display: ${String(e)}`);
|
|
20
|
+
}, C = (e, t) => {
|
|
21
|
+
if (t !== null && l({ [e]: t })[e] !== t) throw RangeError(`Invalid external link preview ${e}.`);
|
|
22
|
+
}, w = (e, t) => {
|
|
23
|
+
if (t !== null && c(t) !== t) throw RangeError(`Invalid external link preview ${e}.`);
|
|
24
|
+
}, T = t.create({
|
|
25
|
+
name: r,
|
|
26
|
+
priority: 1100,
|
|
27
|
+
group: "inline",
|
|
28
|
+
inline: !0,
|
|
29
|
+
atom: !0,
|
|
30
|
+
selectable: !0,
|
|
31
|
+
draggable: !1,
|
|
32
|
+
addOptions() {
|
|
33
|
+
return {
|
|
34
|
+
HTMLAttributes: {},
|
|
35
|
+
autoPreviewOnPaste: !1,
|
|
36
|
+
resolve: void 0,
|
|
37
|
+
shouldPreview: void 0
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
addAttributes() {
|
|
41
|
+
return {
|
|
42
|
+
href: {
|
|
43
|
+
default: "",
|
|
44
|
+
rendered: !1,
|
|
45
|
+
validate: b
|
|
46
|
+
},
|
|
47
|
+
linkText: {
|
|
48
|
+
default: "",
|
|
49
|
+
rendered: !1,
|
|
50
|
+
validate: x
|
|
51
|
+
},
|
|
52
|
+
display: {
|
|
53
|
+
default: "compact",
|
|
54
|
+
rendered: !1,
|
|
55
|
+
validate: S
|
|
56
|
+
},
|
|
57
|
+
pageTitle: {
|
|
58
|
+
default: null,
|
|
59
|
+
rendered: !1,
|
|
60
|
+
validate: (e) => C("pageTitle", e)
|
|
61
|
+
},
|
|
62
|
+
description: {
|
|
63
|
+
default: null,
|
|
64
|
+
rendered: !1,
|
|
65
|
+
validate: (e) => C("description", e)
|
|
66
|
+
},
|
|
67
|
+
siteName: {
|
|
68
|
+
default: null,
|
|
69
|
+
rendered: !1,
|
|
70
|
+
validate: (e) => C("siteName", e)
|
|
71
|
+
},
|
|
72
|
+
faviconUrl: {
|
|
73
|
+
default: null,
|
|
74
|
+
rendered: !1,
|
|
75
|
+
validate: (e) => w("faviconUrl", e)
|
|
76
|
+
},
|
|
77
|
+
imageUrl: {
|
|
78
|
+
default: null,
|
|
79
|
+
rendered: !1,
|
|
80
|
+
validate: (e) => w("imageUrl", e)
|
|
81
|
+
},
|
|
82
|
+
fetchedAt: {
|
|
83
|
+
default: null,
|
|
84
|
+
rendered: !1,
|
|
85
|
+
validate: (e) => C("fetchedAt", e)
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
parseHTML() {
|
|
90
|
+
return [{
|
|
91
|
+
tag: "span[data-type=\"external-link-preview\"]",
|
|
92
|
+
getAttrs: (e) => d(e) ?? !1
|
|
93
|
+
}];
|
|
94
|
+
},
|
|
95
|
+
renderHTML({ node: e }) {
|
|
96
|
+
let t = a(e.attrs);
|
|
97
|
+
return t ? g({
|
|
98
|
+
attributes: t,
|
|
99
|
+
HTMLAttributes: this.options.HTMLAttributes
|
|
100
|
+
}) : [
|
|
101
|
+
"span",
|
|
102
|
+
{ "data-type": "external-link-preview" },
|
|
103
|
+
"Invalid external link"
|
|
104
|
+
];
|
|
105
|
+
},
|
|
106
|
+
addCommands() {
|
|
107
|
+
return f({
|
|
108
|
+
resolveMetadata: !!this.options.resolve,
|
|
109
|
+
shouldPreview: this.options.shouldPreview
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
addNodeView() {
|
|
113
|
+
return e(p, { trackNodeViewPosition: !0 });
|
|
114
|
+
},
|
|
115
|
+
onCreate() {
|
|
116
|
+
if (this.editor.isDestroyed) return;
|
|
117
|
+
let e = h(this.editor.state);
|
|
118
|
+
e && this.editor.view.dispatch(e.setMeta("addToHistory", !1));
|
|
119
|
+
let t = y(this.editor.state, this.options.shouldPreview);
|
|
120
|
+
t && this.editor.view.dispatch(t);
|
|
121
|
+
},
|
|
122
|
+
addProseMirrorPlugins() {
|
|
123
|
+
return [
|
|
124
|
+
_({
|
|
125
|
+
previewType: this.type,
|
|
126
|
+
autoPreviewOnPaste: this.options.autoPreviewOnPaste === !0,
|
|
127
|
+
resolveMetadata: !!this.options.resolve,
|
|
128
|
+
shouldPreview: this.options.shouldPreview
|
|
129
|
+
}),
|
|
130
|
+
v(this.options.shouldPreview),
|
|
131
|
+
m(),
|
|
132
|
+
u({
|
|
133
|
+
editor: this.editor,
|
|
134
|
+
resolve: this.options.resolve
|
|
135
|
+
})
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
//#endregion
|
|
140
|
+
export { n as EXTERNAL_LINK_PREVIEW_DISPLAYS, r as EXTERNAL_LINK_PREVIEW_NODE_NAME, T as ExternalLinkPreview };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-view.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/node-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAkB,MAAM,eAAe,CAAC;AAiCpF,eAAO,MAAM,2BAA2B,6BAA8B,aAAa,gCA6FlF,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { n as e, s as t } from "../../../../dist-DDjaA1Pn.js";
|
|
2
|
+
import { getExternalLinkPreviewHostname as n, getExternalLinkPreviewTitle as r, normalizeExternalLinkPreviewAttributes as i } from "./attributes.js";
|
|
3
|
+
import { showLinkBubbleMenu as a } from "../../../Menu/linkBubbleMenuPlugin.js";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
//#region lib/components/Scribe/extension/external-link-preview/node-view.tsx
|
|
6
|
+
var c = (e, t) => {
|
|
7
|
+
let n = e.state.doc.resolve(t), r = e.state.doc.nodeAt(t);
|
|
8
|
+
return !!(r && n.parent.isTextblock && n.parent.childCount === 1 && n.parent.content.size === r.nodeSize);
|
|
9
|
+
}, l = () => /* @__PURE__ */ o("svg", {
|
|
10
|
+
"aria-hidden": "true",
|
|
11
|
+
viewBox: "0 0 24 24",
|
|
12
|
+
width: "16",
|
|
13
|
+
height: "16",
|
|
14
|
+
children: /* @__PURE__ */ o("path", {
|
|
15
|
+
d: "M9.5 14.5l5-5m-7.25 7.25-1 1a3.18 3.18 0 004.5 4.5l3-3a3.18 3.18 0 000-4.5m3-7.5 1-1a3.18 3.18 0 014.5 4.5l-3 3a3.18 3.18 0 01-4.5 0",
|
|
16
|
+
fill: "none",
|
|
17
|
+
stroke: "currentColor",
|
|
18
|
+
strokeLinecap: "round",
|
|
19
|
+
strokeWidth: "1.5"
|
|
20
|
+
})
|
|
21
|
+
}), u = ({ editor: u, getPos: d, node: f }) => {
|
|
22
|
+
let p = i(f.attrs), m = t({
|
|
23
|
+
editor: u,
|
|
24
|
+
selector: ({ editor: e }) => {
|
|
25
|
+
let t = d();
|
|
26
|
+
return typeof t == "number" ? {
|
|
27
|
+
isEditable: e.isEditable,
|
|
28
|
+
isSoleTextblockContent: c(e, t)
|
|
29
|
+
} : {
|
|
30
|
+
isEditable: e.isEditable,
|
|
31
|
+
isSoleTextblockContent: !1
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
if (!p) return /* @__PURE__ */ o(e, {
|
|
36
|
+
as: "span",
|
|
37
|
+
className: "scribe-external-link-preview scribe-external-link-preview--invalid",
|
|
38
|
+
"data-type": "external-link-preview",
|
|
39
|
+
children: "Invalid external link"
|
|
40
|
+
});
|
|
41
|
+
let h = p.display === "card" && m.isSoleTextblockContent ? "card" : "compact", g = r(p), _ = p.siteName || n(p.href);
|
|
42
|
+
return /* @__PURE__ */ o(e, {
|
|
43
|
+
as: "span",
|
|
44
|
+
className: `scribe-external-link-preview scribe-external-link-preview--${h}`,
|
|
45
|
+
"data-type": "external-link-preview",
|
|
46
|
+
"data-display": h,
|
|
47
|
+
"data-configured-display": p.display,
|
|
48
|
+
contentEditable: !1,
|
|
49
|
+
children: /* @__PURE__ */ s("a", {
|
|
50
|
+
"data-link-preview-target": "",
|
|
51
|
+
href: p.href,
|
|
52
|
+
target: "_blank",
|
|
53
|
+
rel: "noopener noreferrer",
|
|
54
|
+
"aria-haspopup": m.isEditable ? "dialog" : void 0,
|
|
55
|
+
onClick: (e) => {
|
|
56
|
+
if (!m.isEditable) return;
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
let t = d();
|
|
59
|
+
typeof t == "number" && u.chain().focus().setNodeSelection(t).run() && a(u, "dialog");
|
|
60
|
+
},
|
|
61
|
+
children: [h === "card" && p.imageUrl ? /* @__PURE__ */ o("img", {
|
|
62
|
+
"data-link-preview-image": "",
|
|
63
|
+
src: p.imageUrl,
|
|
64
|
+
alt: ""
|
|
65
|
+
}) : null, /* @__PURE__ */ s("span", {
|
|
66
|
+
"data-link-preview-main": "",
|
|
67
|
+
children: [p.faviconUrl ? /* @__PURE__ */ o("img", {
|
|
68
|
+
"data-link-preview-favicon": "",
|
|
69
|
+
src: p.faviconUrl,
|
|
70
|
+
alt: ""
|
|
71
|
+
}) : /* @__PURE__ */ o("span", {
|
|
72
|
+
"data-link-preview-favicon-fallback": "",
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
children: /* @__PURE__ */ o(l, {})
|
|
75
|
+
}), /* @__PURE__ */ s("span", {
|
|
76
|
+
"data-link-preview-copy": "",
|
|
77
|
+
children: [
|
|
78
|
+
/* @__PURE__ */ o("span", {
|
|
79
|
+
"data-link-preview-title": "",
|
|
80
|
+
children: g
|
|
81
|
+
}),
|
|
82
|
+
_ ? /* @__PURE__ */ o("span", {
|
|
83
|
+
"data-link-preview-site": "",
|
|
84
|
+
children: _
|
|
85
|
+
}) : null,
|
|
86
|
+
h === "card" && p.description ? /* @__PURE__ */ o("span", {
|
|
87
|
+
"data-link-preview-description": "",
|
|
88
|
+
children: p.description
|
|
89
|
+
}) : null
|
|
90
|
+
]
|
|
91
|
+
})]
|
|
92
|
+
})]
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
97
|
+
export { u as ExternalLinkPreviewNodeView };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
2
|
+
import type { EditorState } from "@tiptap/pm/state";
|
|
3
|
+
export declare const externalLinkPreviewNormalizationPluginKey: PluginKey<any>;
|
|
4
|
+
export declare const createExternalLinkPreviewNormalizationTransaction: (state: EditorState) => import("@tiptap/pm/state").Transaction | null;
|
|
5
|
+
/** Keep the persisted display contract aligned with Card's sole-textblock requirement. */
|
|
6
|
+
export declare const createExternalLinkPreviewNormalizationPlugin: () => Plugin<any>;
|
|
7
|
+
//# sourceMappingURL=normalization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalization.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/normalization.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,eAAO,MAAM,yCAAyC,gBAErD,CAAC;AAEF,eAAO,MAAM,iDAAiD,UAAW,WAAW,kDA2BnF,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,4CAA4C,mBAerD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import "./attributes.js";
|
|
2
|
+
import { Plugin as e, PluginKey as t } from "@tiptap/pm/state";
|
|
3
|
+
//#region lib/components/Scribe/extension/external-link-preview/normalization.ts
|
|
4
|
+
var n = new t("scribeExternalLinkPreviewNormalization"), r = (e) => {
|
|
5
|
+
let t = e.tr, r = !1;
|
|
6
|
+
return e.doc.descendants((n, i) => {
|
|
7
|
+
if (n.type.name !== "externalLinkPreview" || n.attrs.display !== "card") return;
|
|
8
|
+
let a = e.doc.resolve(i);
|
|
9
|
+
a.parent.isTextblock && a.parent.childCount === 1 && a.parent.content.size === n.nodeSize || (t.setNodeMarkup(i, void 0, {
|
|
10
|
+
...n.attrs,
|
|
11
|
+
display: "compact"
|
|
12
|
+
}), r = !0);
|
|
13
|
+
}), r ? t.setMeta(n, !0) : null;
|
|
14
|
+
}, i = () => new e({
|
|
15
|
+
key: n,
|
|
16
|
+
appendTransaction(e, t, i) {
|
|
17
|
+
return !e.some((e) => e.docChanged) || e.some((e) => e.getMeta(n)) ? null : r(i);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
//#endregion
|
|
21
|
+
export { i as createExternalLinkPreviewNormalizationPlugin, r as createExternalLinkPreviewNormalizationTransaction, n as externalLinkPreviewNormalizationPluginKey };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NodeType } from "@tiptap/pm/model";
|
|
2
|
+
import { Plugin } from "@tiptap/pm/state";
|
|
3
|
+
export declare const createExternalLinkPreviewPastePlugin: ({ previewType, autoPreviewOnPaste, resolveMetadata, shouldPreview, }: {
|
|
4
|
+
previewType: NodeType;
|
|
5
|
+
autoPreviewOnPaste: boolean;
|
|
6
|
+
resolveMetadata: boolean;
|
|
7
|
+
shouldPreview?: (href: string) => boolean;
|
|
8
|
+
}) => Plugin<any>;
|
|
9
|
+
//# sourceMappingURL=paste.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paste.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/paste.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAiB,MAAM,EAAa,MAAM,kBAAkB,CAAC;AA8EpE,eAAO,MAAM,oCAAoC,yEAK9C;IACD,WAAW,EAAE,QAAQ,CAAC;IACtB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C,gBAyEG,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { normalizeLinkUrl as e } from "../../../Menu/linkUrl.js";
|
|
2
|
+
import { normalizeExternalLinkPreviewAttributes as t, normalizeExternalLinkPreviewHref as n } from "./attributes.js";
|
|
3
|
+
import { startExternalLinkPreviewResolution as r } from "./resolver.js";
|
|
4
|
+
import { NodeSelection as i, Plugin as a, PluginKey as o } from "@tiptap/pm/state";
|
|
5
|
+
//#region lib/components/Scribe/extension/external-link-preview/paste.ts
|
|
6
|
+
var s = new o("scribeExternalLinkPreviewPaste"), c = (e) => {
|
|
7
|
+
let t = e.clipboardData?.getData("text/plain");
|
|
8
|
+
if (!t) return null;
|
|
9
|
+
let n = t.trim();
|
|
10
|
+
return n && !/[\r\n]/.test(n) ? n : null;
|
|
11
|
+
}, l = (e, t) => {
|
|
12
|
+
let { selection: n, schema: r } = e.state, i = r.marks.link;
|
|
13
|
+
if (n.empty || !i) return !1;
|
|
14
|
+
let a = e.state.tr.setMeta("preventAutolink", !0), o = !1;
|
|
15
|
+
return e.state.doc.nodesBetween(n.from, n.to, (e, r, s) => {
|
|
16
|
+
if (!e.isText || !s?.isTextblock || !s.type.allowsMarkType(i)) return;
|
|
17
|
+
let c = Math.max(r, n.from), l = Math.min(r + e.nodeSize, n.to);
|
|
18
|
+
c < l && (a.addMark(c, l, i.create({ href: t })), o = !0);
|
|
19
|
+
}), o ? (e.dispatch(a), !0) : !1;
|
|
20
|
+
}, u = (e, t) => {
|
|
21
|
+
let { selection: n } = e.state, r = !0;
|
|
22
|
+
return n.$from.parent.forEach((e) => {
|
|
23
|
+
(!e.isText || e.textContent.trim()) && (r = !1);
|
|
24
|
+
}), !n.empty || n.$from.parent.type.name !== "paragraph" || !r ? !1 : n.$from.parent.canReplaceWith(0, n.$from.parent.childCount, t);
|
|
25
|
+
}, d = ({ previewType: o, autoPreviewOnPaste: d, resolveMetadata: f, shouldPreview: p }) => new a({
|
|
26
|
+
key: s,
|
|
27
|
+
props: { handlePaste(a, s) {
|
|
28
|
+
let m = c(s);
|
|
29
|
+
if (!m) return !1;
|
|
30
|
+
let h = e(m);
|
|
31
|
+
if (!a.state.selection.empty && h) {
|
|
32
|
+
let e = l(a, h);
|
|
33
|
+
return e && s.preventDefault(), e;
|
|
34
|
+
}
|
|
35
|
+
let g = n(m);
|
|
36
|
+
if (!d || !f || !g || !u(a, o)) return !1;
|
|
37
|
+
try {
|
|
38
|
+
if (p && !p(g)) return !1;
|
|
39
|
+
} catch {
|
|
40
|
+
return !1;
|
|
41
|
+
}
|
|
42
|
+
let _ = t({
|
|
43
|
+
href: g,
|
|
44
|
+
linkText: m,
|
|
45
|
+
display: "compact"
|
|
46
|
+
});
|
|
47
|
+
if (!_) return !1;
|
|
48
|
+
s.preventDefault();
|
|
49
|
+
let v = a.state.selection.$from.start(), y = v + a.state.selection.$from.parent.content.size, b = v, x = a.state.tr.replaceWith(v, y, o.create(_));
|
|
50
|
+
return x.setSelection(i.create(x.doc, b)), f && r(x, b, g), a.dispatch(x.scrollIntoView()), !0;
|
|
51
|
+
} }
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { d as createExternalLinkPreviewPastePlugin };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { EditorState, Transaction } from "@tiptap/pm/state";
|
|
2
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
3
|
+
export declare const externalLinkPreviewPolicyPluginKey: PluginKey<any>;
|
|
4
|
+
/** Convert previews rejected by a consumer policy into safe, ordinary link text. */
|
|
5
|
+
export declare const createExternalLinkPreviewPolicyTransaction: (state: EditorState, shouldPreview?: (href: string) => boolean) => Transaction | null;
|
|
6
|
+
export declare const createExternalLinkPreviewPolicyPlugin: (shouldPreview?: (href: string) => boolean) => Plugin<any>;
|
|
7
|
+
//# sourceMappingURL=policy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAMrD,eAAO,MAAM,kCAAkC,gBAAmD,CAAC;AA+BnG,oFAAoF;AACpF,eAAO,MAAM,0CAA0C,UAC9C,WAAW,kBACF,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,KACxC,WAAW,GAAG,IA2ChB,CAAC;AAEF,eAAO,MAAM,qCAAqC,mBAAoB,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,gBAa3F,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { normalizeExternalLinkPreviewAttributes as e } from "./attributes.js";
|
|
2
|
+
import { Plugin as t, PluginKey as n } from "@tiptap/pm/state";
|
|
3
|
+
//#region lib/components/Scribe/extension/external-link-preview/policy.ts
|
|
4
|
+
var r = new n("scribeExternalLinkPreviewPolicy"), i = (e, t) => {
|
|
5
|
+
try {
|
|
6
|
+
return t(e);
|
|
7
|
+
} catch {
|
|
8
|
+
return !1;
|
|
9
|
+
}
|
|
10
|
+
}, a = (t, n, r, i) => {
|
|
11
|
+
let a = e(n.attrs);
|
|
12
|
+
if (!a) return null;
|
|
13
|
+
let o = t.doc.resolve(r).parent, s = i && o.type.allowsMarkType(i) ? [i.create({ href: a.href })] : [];
|
|
14
|
+
return t.schema.text(a.linkText, s);
|
|
15
|
+
}, o = (t, n) => {
|
|
16
|
+
if (!n) return null;
|
|
17
|
+
let o = [];
|
|
18
|
+
if (t.doc.descendants((t, r) => {
|
|
19
|
+
if (t.type.name !== "externalLinkPreview") return;
|
|
20
|
+
let a = e(t.attrs);
|
|
21
|
+
(!a || !i(a.href, n)) && o.push({
|
|
22
|
+
node: t,
|
|
23
|
+
position: r
|
|
24
|
+
});
|
|
25
|
+
}), !o.length) return null;
|
|
26
|
+
let s = t.tr, c = t.schema.marks.link, l = !1;
|
|
27
|
+
return o.sort((e, t) => t.position - e.position).forEach(({ node: e, position: n }) => {
|
|
28
|
+
let r = a(t, e, n, c);
|
|
29
|
+
r && (s.replaceWith(n, n + e.nodeSize, r), l = !0);
|
|
30
|
+
}), l ? s.setMeta(r, !0).setMeta("addToHistory", !1) : null;
|
|
31
|
+
}, s = (e) => new t({
|
|
32
|
+
key: r,
|
|
33
|
+
appendTransaction(t, n, i) {
|
|
34
|
+
return !t.some((e) => e.docChanged) || t.some((e) => e.getMeta(r)) ? null : o(i, e);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
//#endregion
|
|
38
|
+
export { s as createExternalLinkPreviewPolicyPlugin, o as createExternalLinkPreviewPolicyTransaction, r as externalLinkPreviewPolicyPluginKey };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DOMOutputSpec } from "@tiptap/pm/model";
|
|
2
|
+
import type { ExternalLinkPreviewAttributes } from "./types";
|
|
3
|
+
export declare const renderExternalLinkPreviewHTML: ({ attributes, HTMLAttributes, }: {
|
|
4
|
+
attributes: ExternalLinkPreviewAttributes;
|
|
5
|
+
HTMLAttributes?: Record<string, unknown>;
|
|
6
|
+
}) => DOMOutputSpec;
|
|
7
|
+
//# sourceMappingURL=render-html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-html.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/render-html.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGtD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AA0B7D,eAAO,MAAM,6BAA6B,oCAGvC;IACD,UAAU,EAAE,6BAA6B,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,KAAG,aA4BH,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { L as e } from "../../../../dist-tNcpTcFT.js";
|
|
2
|
+
import { getExternalLinkPreviewHostname as t, getExternalLinkPreviewTitle as n } from "./attributes.js";
|
|
3
|
+
import { getExternalLinkPreviewDataAttributes as r } from "./serialization.js";
|
|
4
|
+
//#region lib/components/Scribe/extension/external-link-preview/render-html.ts
|
|
5
|
+
var i = (e) => {
|
|
6
|
+
let r = [[
|
|
7
|
+
"span",
|
|
8
|
+
{ "data-link-preview-title": "" },
|
|
9
|
+
n(e)
|
|
10
|
+
]], i = e.siteName || t(e.href);
|
|
11
|
+
return i && r.push([
|
|
12
|
+
"span",
|
|
13
|
+
{ "data-link-preview-site": "" },
|
|
14
|
+
i
|
|
15
|
+
]), e.display === "card" && e.description && r.push([
|
|
16
|
+
"span",
|
|
17
|
+
{ "data-link-preview-description": "" },
|
|
18
|
+
e.description
|
|
19
|
+
]), [
|
|
20
|
+
"span",
|
|
21
|
+
{ "data-link-preview-main": "" },
|
|
22
|
+
e.faviconUrl ? ["img", {
|
|
23
|
+
"data-link-preview-favicon": "",
|
|
24
|
+
src: e.faviconUrl,
|
|
25
|
+
alt: ""
|
|
26
|
+
}] : [
|
|
27
|
+
"span",
|
|
28
|
+
{
|
|
29
|
+
"data-link-preview-favicon-fallback": "",
|
|
30
|
+
"aria-hidden": "true"
|
|
31
|
+
},
|
|
32
|
+
"↗"
|
|
33
|
+
],
|
|
34
|
+
[
|
|
35
|
+
"span",
|
|
36
|
+
{ "data-link-preview-copy": "" },
|
|
37
|
+
...r
|
|
38
|
+
]
|
|
39
|
+
];
|
|
40
|
+
}, a = ({ attributes: t, HTMLAttributes: n }) => {
|
|
41
|
+
let a = [];
|
|
42
|
+
return t.display === "card" && t.imageUrl && a.push(["img", {
|
|
43
|
+
"data-link-preview-image": "",
|
|
44
|
+
src: t.imageUrl,
|
|
45
|
+
alt: ""
|
|
46
|
+
}]), a.push(i(t)), [
|
|
47
|
+
"span",
|
|
48
|
+
e(n ?? {}, r(t), { class: `scribe-external-link-preview scribe-external-link-preview--${t.display}` }),
|
|
49
|
+
[
|
|
50
|
+
"a",
|
|
51
|
+
{
|
|
52
|
+
"data-link-preview-target": "",
|
|
53
|
+
href: t.href,
|
|
54
|
+
target: "_blank",
|
|
55
|
+
rel: "noopener noreferrer"
|
|
56
|
+
},
|
|
57
|
+
...a
|
|
58
|
+
]
|
|
59
|
+
];
|
|
60
|
+
};
|
|
61
|
+
//#endregion
|
|
62
|
+
export { a as renderExternalLinkPreviewHTML };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/core";
|
|
2
|
+
import type { EditorState, Transaction } from "@tiptap/pm/state";
|
|
3
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
4
|
+
import type { ExternalLinkPreviewResolutionStatus, ExternalLinkPreviewResolver } from "./types";
|
|
5
|
+
interface ExternalLinkPreviewRequest {
|
|
6
|
+
href: string;
|
|
7
|
+
position: number;
|
|
8
|
+
status: Exclude<ExternalLinkPreviewResolutionStatus, "idle">;
|
|
9
|
+
token: number;
|
|
10
|
+
}
|
|
11
|
+
interface ExternalLinkPreviewResolverState {
|
|
12
|
+
nextToken: number;
|
|
13
|
+
requests: Map<number, ExternalLinkPreviewRequest>;
|
|
14
|
+
}
|
|
15
|
+
export declare const externalLinkPreviewResolverPluginKey: PluginKey<ExternalLinkPreviewResolverState>;
|
|
16
|
+
export declare const startExternalLinkPreviewResolution: (transaction: Transaction, position: number, href: string) => Transaction;
|
|
17
|
+
export declare const getExternalLinkPreviewResolutionStatus: (state: EditorState, position: number) => ExternalLinkPreviewResolutionStatus;
|
|
18
|
+
export declare const createExternalLinkPreviewResolverPlugin: ({ editor, resolve, }: {
|
|
19
|
+
editor: Editor;
|
|
20
|
+
resolve?: ExternalLinkPreviewResolver;
|
|
21
|
+
}) => Plugin<ExternalLinkPreviewResolverState>;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAiB,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAOpE,OAAO,KAAK,EAAE,mCAAmC,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAEhG,UAAU,0BAA0B;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC,mCAAmC,EAAE,MAAM,CAAC,CAAC;IAC7D,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,gCAAgC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,0BAA0B,CAAC,CAAC;CACnD;AAOD,eAAO,MAAM,oCAAoC,6CAEhD,CAAC;AAQF,eAAO,MAAM,kCAAkC,gBAChC,WAAW,YACd,MAAM,QACV,MAAM,gBASb,CAAC;AAEF,eAAO,MAAM,sCAAsC,UAC1C,WAAW,YACR,MAAM,KACf,mCAWF,CAAC;AAyHF,eAAO,MAAM,uCAAuC,yBAGjD;IACD,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,2BAA2B,CAAC;CACvC,6CAkEA,CAAC"}
|