@clevertask/scribe 0.1.29 → 0.1.31
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 +39 -53
- package/dist/BarMenu-Bm5IfWVV.js +302 -0
- package/dist/components/Menu/BarMenu.d.ts.map +1 -1
- package/dist/components/Menu/BarMenu.js +1 -2
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
- package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/LinkBubbleMenu.js +113 -103
- package/dist/components/Menu/LinkEditor.d.ts +0 -7
- package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
- package/dist/components/Menu/LinkEditor.js +148 -157
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +3 -3
- package/dist/components/Menu/TableHeightSettings.js +3 -11
- package/dist/components/Menu/TableLayoutOptions.js +1 -5
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.js +9 -5
- package/dist/components/Scribe/extension/callout.js +7 -7
- package/dist/components/Scribe/extension/emoji/suggest.js +2 -2
- package/dist/components/Scribe/extension/extension-link.js +1 -2
- 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 +0 -7
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/attributes.js +26 -51
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +5 -12
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/commands.js +56 -121
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts +4 -6
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/index.js +5 -41
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +1 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +17 -60
- package/dist/components/Scribe/extension/external-link-preview/schema.d.ts +2 -2
- package/dist/components/Scribe/extension/external-link-preview/schema.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/serialization.js +29 -51
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts +14 -17
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +1 -2
- package/dist/components/Scribe/extension/resizable-table.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +10 -14
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +2 -2
- package/dist/components/Scribe/extension/table-layout.js +1 -2
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.d.ts +3 -9
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +7 -21
- package/dist/{dist-DnVcys79.js → dist-BoAzo5MN.js} +491 -598
- package/dist/{dist-CDJRm4fL.js → dist-BqlzKS-_.js} +9 -17
- package/dist/{dist-B0xwy1Q5.js → dist-SM4NoN4h.js} +174 -385
- package/dist/document-node-capabilities.js +1 -1
- package/dist/{extension-BPeoqfHR.js → extension-dz0CIf3r.js} +1 -1
- package/dist/extension-link-DxIXGCtV.js +931 -0
- package/dist/{html-to-markdown-DF93it73.js → html-to-markdown-DeRG9OPm.js} +1 -1
- package/dist/main.css +1 -141
- package/dist/main.js +2 -2
- package/dist/{markdown-to-html-BoK5O_j-.js → markdown-to-html-tCPjQ5u6.js} +23 -70
- package/dist/{menus-scgppp2C.js → menus-BKxcTUsl.js} +36 -118
- package/dist/{purify.es-q6CUdJQi.js → purify.es-CSWcs7f1.js} +1 -23
- package/dist/{schema-extensions-ITR9LEgX.js → schema-extensions-B9hR1VrD.js} +1335 -1360
- package/dist/schema-extensions.js +1 -2
- package/dist/schema.js +1 -1
- package/dist/{table-layout-iVolql5p.js → table-layout-ClqaGg1E.js} +36 -36
- package/dist/{tippy.esm-MjWnmeEn.js → tippy.esm-C8V6GlaF.js} +5 -17
- package/dist/utils/create-scribe-editor.d.ts +1 -1
- package/dist/utils/create-scribe-editor.d.ts.map +1 -1
- package/dist/utils/create-scribe-editor.js +1 -2
- package/dist/utils/html-to-markdown.js +1 -2
- package/dist/utils/index.js +4 -4
- package/dist/utils/markdown-to-html.js +1 -2
- package/package.json +10 -10
- package/dist/BarMenu-BC8XoC6e.js +0 -302
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts +0 -13
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +0 -1
- package/dist/components/Menu/ExternalLinkDisplayOptions.js +0 -90
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +0 -3
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +0 -97
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +0 -7
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/normalization.js +0 -21
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +0 -8
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/paste.js +0 -53
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +0 -7
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/policy.js +0 -38
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +0 -23
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +0 -1
- package/dist/components/Scribe/extension/external-link-preview/resolver.js +0 -118
- package/dist/extension-link-RvaqaDqr.js +0 -934
|
@@ -1,89 +1,64 @@
|
|
|
1
1
|
import { EXTERNAL_LINK_PREVIEW_DISPLAYS as e } from "./types.js";
|
|
2
2
|
//#region lib/components/Scribe/extension/external-link-preview/attributes.ts
|
|
3
|
-
var t = /^\/(?![\\/])/, n = /^https?:\/\//i, r = 16384, i = 16384, a = 512, o = 2048, s = 256, c = 16384, l = 128, u = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/, d =
|
|
4
|
-
"pageTitle",
|
|
5
|
-
"description",
|
|
6
|
-
"siteName",
|
|
7
|
-
"faviconUrl",
|
|
8
|
-
"imageUrl",
|
|
9
|
-
"fetchedAt"
|
|
10
|
-
], f = (e) => {
|
|
3
|
+
var t = /^\/(?![\\/])/, n = /^https?:\/\//i, r = 16384, i = 16384, a = 512, o = 2048, s = 256, c = 16384, l = 128, u = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/, d = (e) => {
|
|
11
4
|
for (let t of e) {
|
|
12
5
|
let e = t.charCodeAt(0);
|
|
13
6
|
if (e <= 31 || e === 127) return !0;
|
|
14
7
|
}
|
|
15
8
|
return !1;
|
|
16
|
-
},
|
|
9
|
+
}, f = (e) => {
|
|
17
10
|
let t = e.indexOf("//") + 2, n = [
|
|
18
11
|
"/",
|
|
19
12
|
"?",
|
|
20
13
|
"#"
|
|
21
14
|
].map((n) => e.indexOf(n, t)).filter((e) => e >= 0), r = n.length ? Math.min(...n) : e.length;
|
|
22
15
|
return e.slice(t, r).includes("@");
|
|
23
|
-
},
|
|
16
|
+
}, p = "externalLinkPreview", m = "span[data-type=\"external-link-preview\"]", h = "a[data-link-preview-target]", g = (t) => typeof t == "string" && e.some((e) => e === t), _ = (e, t, { preserveWhitespace: n = !1 } = {}) => {
|
|
24
17
|
if (typeof e != "string") return null;
|
|
25
18
|
let r = n ? e : e.trim();
|
|
26
|
-
return !r.trim() || r.length > t ||
|
|
27
|
-
},
|
|
28
|
-
let t =
|
|
29
|
-
if (!t || t.includes("\\") || !n.test(t) ||
|
|
19
|
+
return !r.trim() || r.length > t || d(r) ? null : r;
|
|
20
|
+
}, v = (e) => _(e, i, { preserveWhitespace: !0 }), y = (e) => {
|
|
21
|
+
let t = _(e, r);
|
|
22
|
+
if (!t || t.includes("\\") || !n.test(t) || f(t)) return null;
|
|
30
23
|
try {
|
|
31
24
|
let e = new URL(t);
|
|
32
25
|
return e.protocol !== "http:" && e.protocol !== "https:" || e.username || e.password ? null : t;
|
|
33
26
|
} catch {
|
|
34
27
|
return null;
|
|
35
28
|
}
|
|
36
|
-
},
|
|
37
|
-
let r =
|
|
29
|
+
}, b = (e) => {
|
|
30
|
+
let r = _(e, c);
|
|
38
31
|
if (!r || r.includes("\\")) return null;
|
|
39
32
|
if (t.test(r)) return r;
|
|
40
|
-
if (!n.test(r) ||
|
|
33
|
+
if (!n.test(r) || f(r)) return null;
|
|
41
34
|
try {
|
|
42
35
|
let e = new URL(r);
|
|
43
36
|
return (e.protocol === "http:" || e.protocol === "https:") && !e.username && !e.password ? r : null;
|
|
44
37
|
} catch {
|
|
45
38
|
return null;
|
|
46
39
|
}
|
|
47
|
-
},
|
|
48
|
-
let t =
|
|
40
|
+
}, x = (e) => {
|
|
41
|
+
let t = _(e, l);
|
|
49
42
|
if (!t || !u.test(t)) return null;
|
|
50
43
|
let n = new Date(t);
|
|
51
44
|
return Number.isNaN(n.getTime()) ? null : n.toISOString();
|
|
52
|
-
},
|
|
53
|
-
pageTitle:
|
|
54
|
-
description:
|
|
55
|
-
siteName:
|
|
56
|
-
faviconUrl:
|
|
57
|
-
imageUrl:
|
|
58
|
-
fetchedAt:
|
|
59
|
-
}),
|
|
60
|
-
let t =
|
|
61
|
-
return d.forEach((r) => {
|
|
62
|
-
Object.prototype.hasOwnProperty.call(e, r) && e[r] !== void 0 && (n[r] = t[r]);
|
|
63
|
-
}), n;
|
|
64
|
-
}, T = (e) => {
|
|
65
|
-
let t = b(e.href);
|
|
45
|
+
}, S = (e) => ({
|
|
46
|
+
pageTitle: _(e?.pageTitle, a),
|
|
47
|
+
description: _(e?.description, o),
|
|
48
|
+
siteName: _(e?.siteName, s),
|
|
49
|
+
faviconUrl: b(e?.faviconUrl),
|
|
50
|
+
imageUrl: b(e?.imageUrl),
|
|
51
|
+
fetchedAt: x(e?.fetchedAt)
|
|
52
|
+
}), C = (e) => {
|
|
53
|
+
let t = y(e.href);
|
|
66
54
|
if (!t) return null;
|
|
67
|
-
let n =
|
|
55
|
+
let n = S(e);
|
|
68
56
|
return {
|
|
69
57
|
href: t,
|
|
70
|
-
linkText:
|
|
71
|
-
display:
|
|
58
|
+
linkText: v(e.linkText) ?? t,
|
|
59
|
+
display: g(e.display) ? e.display : "compact",
|
|
72
60
|
...n
|
|
73
61
|
};
|
|
74
|
-
}
|
|
75
|
-
try {
|
|
76
|
-
return new URL(e).hostname;
|
|
77
|
-
} catch {
|
|
78
|
-
return e;
|
|
79
|
-
}
|
|
80
|
-
}, D = (e) => {
|
|
81
|
-
try {
|
|
82
|
-
let t = new URL(e), n = t.pathname === "/" ? "" : t.pathname;
|
|
83
|
-
return `${t.host}${n}`;
|
|
84
|
-
} catch {
|
|
85
|
-
return e;
|
|
86
|
-
}
|
|
87
|
-
}, O = (e, t) => t === "compact" ? e.linkText === e.href ? D(e.href) : e.linkText : e.pageTitle || e.siteName || E(e.href), k = (e) => !!(e.pageTitle || e.description || e.siteName || e.faviconUrl || e.imageUrl);
|
|
62
|
+
};
|
|
88
63
|
//#endregion
|
|
89
|
-
export {
|
|
64
|
+
export { p as EXTERNAL_LINK_PREVIEW_NODE_NAME, m as EXTERNAL_LINK_PREVIEW_SELECTOR, h as EXTERNAL_LINK_PREVIEW_TARGET_SELECTOR, g as isExternalLinkPreviewDisplay, C as normalizeExternalLinkPreviewAttributes, y as normalizeExternalLinkPreviewHref, v as normalizeExternalLinkPreviewLinkText, b as normalizeExternalLinkPreviewMediaUrl, S as normalizeExternalLinkPreviewMetadata };
|
|
@@ -4,13 +4,13 @@ import type { ExternalLinkDisplay, ExternalLinkPreviewAttributes, InsertExternal
|
|
|
4
4
|
declare module "@tiptap/core" {
|
|
5
5
|
interface Commands<ReturnType> {
|
|
6
6
|
externalLinkPreview: {
|
|
7
|
-
/** Insert an
|
|
7
|
+
/** @deprecated Insert a legacy node rendered as an ordinary link; no metadata is fetched. */
|
|
8
8
|
insertExternalLinkPreview: (options: InsertExternalLinkPreviewOptions) => ReturnType;
|
|
9
|
-
/**
|
|
9
|
+
/** @deprecated Only explicit conversion to plain is supported; compact/card return false. */
|
|
10
10
|
setExternalLinkDisplay: (display: ExternalLinkDisplay, targetPosition?: number) => ReturnType;
|
|
11
11
|
/** Atomically convert a preview to a Plain link while applying its edited destination. */
|
|
12
12
|
convertExternalLinkPreviewToPlain: (href: string, targetPosition?: number) => ReturnType;
|
|
13
|
-
/**
|
|
13
|
+
/** @deprecated Metadata fetching is retired; this command returns false. */
|
|
14
14
|
refreshExternalLinkPreview: (targetPosition?: number) => ReturnType;
|
|
15
15
|
/** Safely update the selected preview's destination, fallback text, or metadata. */
|
|
16
16
|
updateExternalLinkPreview: (options: UpdateExternalLinkPreviewOptions, targetPosition?: number) => ReturnType;
|
|
@@ -21,13 +21,9 @@ interface PreviewContext {
|
|
|
21
21
|
attributes: ExternalLinkPreviewAttributes;
|
|
22
22
|
node: ProseMirrorNode;
|
|
23
23
|
position: number;
|
|
24
|
-
isSoleTextblockContent: boolean;
|
|
25
24
|
}
|
|
26
25
|
export declare const getSelectedExternalLinkPreview: (transaction: Transaction, targetPosition?: number) => PreviewContext | null;
|
|
27
|
-
export declare const createExternalLinkPreviewCommands: (
|
|
28
|
-
resolveMetadata: boolean;
|
|
29
|
-
shouldPreview?: (href: string) => boolean;
|
|
30
|
-
}) => {
|
|
26
|
+
export declare const createExternalLinkPreviewCommands: () => {
|
|
31
27
|
insertExternalLinkPreview: (options: InsertExternalLinkPreviewOptions) => ({ dispatch, tr }: {
|
|
32
28
|
dispatch?: (args?: unknown) => unknown;
|
|
33
29
|
tr: Transaction;
|
|
@@ -40,10 +36,7 @@ export declare const createExternalLinkPreviewCommands: ({ resolveMetadata, shou
|
|
|
40
36
|
dispatch?: (args?: unknown) => unknown;
|
|
41
37
|
tr: Transaction;
|
|
42
38
|
}) => boolean;
|
|
43
|
-
refreshExternalLinkPreview: (
|
|
44
|
-
dispatch?: (args?: unknown) => unknown;
|
|
45
|
-
tr: Transaction;
|
|
46
|
-
}) => boolean;
|
|
39
|
+
refreshExternalLinkPreview: (_targetPosition?: number) => () => boolean;
|
|
47
40
|
updateExternalLinkPreview: (options: UpdateExternalLinkPreviewOptions, targetPosition?: number) => ({ dispatch, tr }: {
|
|
48
41
|
dispatch?: (args?: unknown) => unknown;
|
|
49
42
|
tr: Transaction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQpD,OAAO,KAAK,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,mBAAmB,EAAE;YACnB,6FAA6F;YAC7F,yBAAyB,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,UAAU,CAAC;YACrF,6FAA6F;YAC7F,sBAAsB,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;YAC9F,0FAA0F;YAC1F,iCAAiC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;YACzF,4EAA4E;YAC5E,0BAA0B,EAAE,CAAC,cAAc,CAAC,EAAE,MAAM,KAAK,UAAU,CAAC;YACpE,oFAAoF;YACpF,yBAAyB,EAAE,CACzB,OAAO,EAAE,gCAAgC,EACzC,cAAc,CAAC,EAAE,MAAM,KACpB,UAAU,CAAC;SACjB,CAAC;KACH;CACF;AAED,UAAU,cAAc;IACtB,UAAU,EAAE,6BAA6B,CAAC;IAC1C,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,8BAA8B,gBAC5B,WAAW,mBACP,MAAM,KACtB,cAAc,GAAG,IA+BnB,CAAC;AA6BF,eAAO,MAAM,iCAAiC;IAC5C,yBAAyB,YACb,gCAAgC,wBACvB;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IA0BhF,sBAAsB,YACV,mBAAmB,mBAAmB,MAAM,wBACnC;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IAoBhF,iCAAiC,kBACf,MAAM,mBAAmB,MAAM,wBAC5B;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IAmBhF,0BAA0B,qBAAqB,MAAM;IACrD,yBAAyB,YACb,gCAAgC,mBAAmB,MAAM,wBAChD;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;CAuDhF,CAAC"}
|
|
@@ -1,135 +1,70 @@
|
|
|
1
|
-
import { v as e } from "../../../../dist-
|
|
2
|
-
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as t,
|
|
3
|
-
import { normalizeLinkUrl as
|
|
4
|
-
import {
|
|
5
|
-
import { NodeSelection as s, TextSelection as c } from "@tiptap/pm/state";
|
|
1
|
+
import { v as e } from "../../../../dist-BoAzo5MN.js";
|
|
2
|
+
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as t, normalizeExternalLinkPreviewAttributes as n, normalizeExternalLinkPreviewHref as r } from "./attributes.js";
|
|
3
|
+
import { normalizeLinkUrl as i } from "../../../Menu/linkUrl.js";
|
|
4
|
+
import { NodeSelection as a, TextSelection as o } from "@tiptap/pm/state";
|
|
6
5
|
//#region lib/components/Scribe/extension/external-link-preview/commands.ts
|
|
7
|
-
var
|
|
8
|
-
let { selection:
|
|
6
|
+
var s = (e, t) => {
|
|
7
|
+
let { selection: r } = e, i = typeof t == "number";
|
|
9
8
|
if (i && (!Number.isInteger(t) || t < 0 || t >= e.doc.content.size)) return null;
|
|
10
|
-
let
|
|
11
|
-
if (!
|
|
12
|
-
let c =
|
|
13
|
-
|
|
14
|
-
let l = e.doc.resolve(a);
|
|
15
|
-
return {
|
|
9
|
+
let o = i ? t : r.from, s = i ? e.doc.nodeAt(o) : r instanceof a ? r.node : null;
|
|
10
|
+
if (!s || s.type.name !== "externalLinkPreview") return null;
|
|
11
|
+
let c = n(s.attrs);
|
|
12
|
+
return c ? {
|
|
16
13
|
attributes: c,
|
|
17
|
-
node:
|
|
18
|
-
position:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
}, d = (e, t) => {
|
|
51
|
-
if (!t) return !0;
|
|
52
|
-
try {
|
|
53
|
-
return t(e);
|
|
54
|
-
} catch {
|
|
55
|
-
return !1;
|
|
56
|
-
}
|
|
57
|
-
}, f = (e, t) => {
|
|
58
|
-
e.setSelection(s.create(e.doc, t));
|
|
59
|
-
}, p = (e, t) => e.doc.type.schema.nodes.externalLinkPreview?.create(t) ?? null, m = (e, t, n = t.attributes.href, r = t.attributes.linkText) => {
|
|
14
|
+
node: s,
|
|
15
|
+
position: o
|
|
16
|
+
} : null;
|
|
17
|
+
}, c = (e, t) => {
|
|
18
|
+
e.setSelection(a.create(e.doc, t));
|
|
19
|
+
}, l = (e, t, n = t.attributes.href, r = t.attributes.linkText) => {
|
|
60
20
|
let i = e.doc.type.schema.marks.link, a = e.doc.resolve(t.position).parent;
|
|
61
21
|
if (!i || !a.type.allowsMarkType(i)) return !1;
|
|
62
|
-
let
|
|
63
|
-
return e.replaceWith(t.position, t.position + t.node.nodeSize,
|
|
64
|
-
},
|
|
65
|
-
insertExternalLinkPreview: (
|
|
66
|
-
let
|
|
67
|
-
...
|
|
68
|
-
linkText:
|
|
69
|
-
display:
|
|
70
|
-
}),
|
|
71
|
-
if (!
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return
|
|
22
|
+
let s = e.doc.type.schema.text(r, [i.create({ href: n })]);
|
|
23
|
+
return e.replaceWith(t.position, t.position + t.node.nodeSize, s), e.setSelection(o.create(e.doc, t.position, t.position + s.nodeSize)), !0;
|
|
24
|
+
}, u = () => ({
|
|
25
|
+
insertExternalLinkPreview: (e) => ({ dispatch: r, tr: i }) => {
|
|
26
|
+
let a = n({
|
|
27
|
+
...e,
|
|
28
|
+
linkText: e.linkText ?? e.href,
|
|
29
|
+
display: e.display ?? "compact"
|
|
30
|
+
}), o = i.doc.type.schema.nodes[t], { selection: s } = i;
|
|
31
|
+
if (!a || !o || !s.$from.sameParent(s.$to) || !s.$from.parent.isTextblock || !s.$from.parent.canReplaceWith(s.$from.index(), s.$to.index(), o)) return !1;
|
|
32
|
+
if (r) {
|
|
33
|
+
let e = s.from;
|
|
34
|
+
i.replaceRangeWith(s.from, s.to, o.create(a)), c(i, e);
|
|
35
|
+
}
|
|
36
|
+
return !0;
|
|
77
37
|
},
|
|
78
|
-
setExternalLinkDisplay: (t,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
let e = c.doc.type.schema.marks.link, t = c.doc.resolve(g.position).parent;
|
|
85
|
-
return !e || !t.type.allowsMarkType(e) ? h() : !a || m(c, g);
|
|
86
|
-
}
|
|
87
|
-
return t !== "compact" && t !== "card" || r && !e ? h() : !a || g.attributes.display === t || (c.setNodeMarkup(g.position, void 0, {
|
|
88
|
-
...g.attributes,
|
|
89
|
-
display: t
|
|
90
|
-
}), f(c, g.position), r && o(c, g.position, g.attributes.href), !0);
|
|
38
|
+
setExternalLinkDisplay: (t, n) => ({ dispatch: r, tr: i }) => {
|
|
39
|
+
if (t !== "plain") return i.setMeta("preventDispatch", !0), !1;
|
|
40
|
+
let a = s(i, n);
|
|
41
|
+
if (a) {
|
|
42
|
+
let e = i.doc.type.schema.marks.link, t = i.doc.resolve(a.position).parent;
|
|
43
|
+
return !!(e && t.type.allowsMarkType(e)) && (!r || l(i, a));
|
|
91
44
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (!_ || t === "plain" || t === "card" && !e || t === "card" && !_.isSoleTextblockContent || !d(_.href, s)) return t === "plain" && _ ? !0 : h();
|
|
95
|
-
let v = r({
|
|
96
|
-
href: _.href,
|
|
97
|
-
linkText: _.linkText,
|
|
98
|
-
display: t
|
|
99
|
-
}), y = v ? p(c, v) : null;
|
|
100
|
-
return !v || !y ? h() : !a || (c.replaceWith(_.from, _.to, y), f(c, _.from), t === "card" && o(c, _.from, v.href), !0);
|
|
45
|
+
let o = i.doc.type.schema.marks.link;
|
|
46
|
+
return typeof n != "number" && !!(o && e(i.selection.$from, o));
|
|
101
47
|
},
|
|
102
48
|
convertExternalLinkPreviewToPlain: (e, t) => ({ dispatch: n, tr: r }) => {
|
|
103
|
-
let
|
|
104
|
-
if (!o || !
|
|
105
|
-
let
|
|
106
|
-
return !
|
|
107
|
-
},
|
|
108
|
-
refreshExternalLinkPreview: (t) => ({ dispatch: n, tr: r }) => {
|
|
109
|
-
let i = l(r, t);
|
|
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);
|
|
49
|
+
let a = s(r, t), o = i(e), c = r.doc.type.schema.marks.link;
|
|
50
|
+
if (!a || !o || !c || !r.doc.resolve(a.position).parent.type.allowsMarkType(c)) return r.setMeta("preventDispatch", !0), !1;
|
|
51
|
+
let u = a.attributes.linkText === a.attributes.href ? o : a.attributes.linkText;
|
|
52
|
+
return !n || l(r, a, o, u);
|
|
111
53
|
},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
fetchedAt: null
|
|
124
|
-
} : {}, y = r({
|
|
125
|
-
...p.attributes,
|
|
126
|
-
...v,
|
|
127
|
-
..._,
|
|
128
|
-
href: h,
|
|
129
|
-
linkText: t.linkText ?? (g && p.attributes.linkText === p.attributes.href ? h : p.attributes.linkText)
|
|
54
|
+
refreshExternalLinkPreview: (e) => () => !1,
|
|
55
|
+
updateExternalLinkPreview: (e, t) => ({ dispatch: i, tr: a }) => {
|
|
56
|
+
let o = () => (a.setMeta("preventDispatch", !0), !1), l = s(a, t);
|
|
57
|
+
if (!l) return o();
|
|
58
|
+
let u = e.href ?? l.attributes.href, d = r(u), f = d !== l.attributes.href;
|
|
59
|
+
if (!d) return o();
|
|
60
|
+
let p = Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0)), m = n({
|
|
61
|
+
...l.attributes,
|
|
62
|
+
...p,
|
|
63
|
+
href: d,
|
|
64
|
+
linkText: e.linkText ?? (f && l.attributes.linkText === l.attributes.href ? d : l.attributes.linkText)
|
|
130
65
|
});
|
|
131
|
-
return
|
|
66
|
+
return m ? (!Object.entries(m).some(([e, t]) => l.attributes[e] !== t) || !i || (a.setNodeMarkup(l.position, void 0, m), c(a, l.position)), !0) : o();
|
|
132
67
|
}
|
|
133
68
|
});
|
|
134
69
|
//#endregion
|
|
135
|
-
export {
|
|
70
|
+
export { u as createExternalLinkPreviewCommands, s as getSelectedExternalLinkPreview };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type { ExternalLinkPreviewOptions } from "./types";
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* @experimental The link-preview API and built-in UI may change while this feature is tested.
|
|
2
|
+
* @deprecated Compatibility reader for saved external-link previews.
|
|
3
|
+
* Legacy attributes are retained, but links render as ordinary authored text.
|
|
4
|
+
* No metadata requests, preview creation UI, or automatic document conversions run.
|
|
7
5
|
*/
|
|
8
|
-
export declare const ExternalLinkPreview: import("@tiptap/core").Node<ExternalLinkPreviewOptions, any>;
|
|
6
|
+
export declare const ExternalLinkPreview: import("@tiptap/core").Node<import("./types").ExternalLinkPreviewOptions, any>;
|
|
9
7
|
export { EXTERNAL_LINK_PREVIEW_NODE_NAME } from "./attributes";
|
|
10
8
|
export { EXTERNAL_LINK_PREVIEW_DISPLAYS } from "./types";
|
|
11
9
|
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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,gFAI9B,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,46 +1,10 @@
|
|
|
1
1
|
import { EXTERNAL_LINK_PREVIEW_DISPLAYS as e } from "./types.js";
|
|
2
2
|
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as t } from "./attributes.js";
|
|
3
3
|
import { ExternalLinkPreviewSchema as n } from "./schema.js";
|
|
4
|
-
import { r } from "
|
|
5
|
-
import { createExternalLinkPreviewResolverPlugin as i } from "./resolver.js";
|
|
6
|
-
import { createExternalLinkPreviewCommands as a } from "./commands.js";
|
|
7
|
-
import { ExternalLinkPreviewNodeView as o } from "./node-view.js";
|
|
8
|
-
import { createExternalLinkPreviewNormalizationPlugin as s, createExternalLinkPreviewNormalizationTransaction as c } from "./normalization.js";
|
|
9
|
-
import { createExternalLinkPreviewPastePlugin as l } from "./paste.js";
|
|
10
|
-
import { createExternalLinkPreviewPolicyPlugin as u, createExternalLinkPreviewPolicyTransaction as d } from "./policy.js";
|
|
4
|
+
import { createExternalLinkPreviewCommands as r } from "./commands.js";
|
|
11
5
|
//#region lib/components/Scribe/extension/external-link-preview/index.ts
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
resolveMetadata: !!this.options.resolve,
|
|
16
|
-
shouldPreview: this.options.shouldPreview
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
addNodeView() {
|
|
20
|
-
return r(o, { trackNodeViewPosition: !0 });
|
|
21
|
-
},
|
|
22
|
-
onCreate() {
|
|
23
|
-
if (this.editor.isDestroyed) return;
|
|
24
|
-
let e = c(this.editor.state);
|
|
25
|
-
e && this.editor.view.dispatch(e.setMeta("addToHistory", !1));
|
|
26
|
-
let t = d(this.editor.state, this.options.shouldPreview);
|
|
27
|
-
t && this.editor.view.dispatch(t);
|
|
28
|
-
},
|
|
29
|
-
addProseMirrorPlugins() {
|
|
30
|
-
return [
|
|
31
|
-
l({
|
|
32
|
-
previewType: this.type,
|
|
33
|
-
autoPreviewOnPaste: this.options.autoPreviewOnPaste === !0,
|
|
34
|
-
shouldPreview: this.options.shouldPreview
|
|
35
|
-
}),
|
|
36
|
-
u(this.options.shouldPreview),
|
|
37
|
-
s(),
|
|
38
|
-
i({
|
|
39
|
-
editor: this.editor,
|
|
40
|
-
resolve: this.options.resolve
|
|
41
|
-
})
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
});
|
|
6
|
+
var i = n.extend({ addCommands() {
|
|
7
|
+
return r();
|
|
8
|
+
} });
|
|
45
9
|
//#endregion
|
|
46
|
-
export { e as EXTERNAL_LINK_PREVIEW_DISPLAYS, t as EXTERNAL_LINK_PREVIEW_NODE_NAME,
|
|
10
|
+
export { e as EXTERNAL_LINK_PREVIEW_DISPLAYS, t as EXTERNAL_LINK_PREVIEW_NODE_NAME, i as ExternalLinkPreview };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DOMOutputSpec } from "@tiptap/pm/model";
|
|
2
2
|
import type { ExternalLinkPreviewAttributes } from "./types";
|
|
3
|
+
/** Preserve the legacy wrapper and attributes while displaying only its authored link. */
|
|
3
4
|
export declare const renderExternalLinkPreviewHTML: ({ attributes, HTMLAttributes, }: {
|
|
4
5
|
attributes: ExternalLinkPreviewAttributes;
|
|
5
6
|
HTMLAttributes?: Record<string, unknown>;
|
|
@@ -1 +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;
|
|
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;AAEtD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAE7D,0FAA0F;AAC1F,eAAO,MAAM,6BAA6B,oCAGvC;IACD,UAAU,EAAE,6BAA6B,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,KAAG,aAaH,CAAC"}
|
|
@@ -1,62 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { getExternalLinkPreviewDataAttributes as r } from "./serialization.js";
|
|
1
|
+
import { B as e } from "../../../../dist-BoAzo5MN.js";
|
|
2
|
+
import { getExternalLinkPreviewDataAttributes as t } from "./serialization.js";
|
|
4
3
|
//#region lib/components/Scribe/extension/external-link-preview/render-html.ts
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
]), [
|
|
20
|
-
"span",
|
|
21
|
-
{ "data-link-preview-main": "" },
|
|
22
|
-
e.display === "card" && 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
|
-
};
|
|
4
|
+
var n = ({ attributes: n, HTMLAttributes: r }) => [
|
|
5
|
+
"span",
|
|
6
|
+
e(r ?? {}, t(n)),
|
|
7
|
+
[
|
|
8
|
+
"a",
|
|
9
|
+
{
|
|
10
|
+
"data-link-preview-target": "",
|
|
11
|
+
href: n.href,
|
|
12
|
+
target: "_blank",
|
|
13
|
+
rel: "noopener noreferrer"
|
|
14
|
+
},
|
|
15
|
+
n.linkText
|
|
16
|
+
]
|
|
17
|
+
];
|
|
61
18
|
//#endregion
|
|
62
|
-
export {
|
|
19
|
+
export { n as renderExternalLinkPreviewHTML };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Node } from "@tiptap/core";
|
|
2
2
|
import type { ExternalLinkPreviewOptions } from "./types";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Compatibility schema for saved external-link previews. Attributes survive
|
|
5
|
+
* round trips while both editor and headless output render ordinary authored links.
|
|
6
6
|
*/
|
|
7
7
|
export declare const ExternalLinkPreviewSchema: Node<ExternalLinkPreviewOptions, any>;
|
|
8
8
|
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e } from "../../../../dist-
|
|
1
|
+
import { a as e } from "../../../../dist-BoAzo5MN.js";
|
|
2
2
|
import { EXTERNAL_LINK_PREVIEW_NODE_NAME as t, isExternalLinkPreviewDisplay as n, normalizeExternalLinkPreviewAttributes as r, normalizeExternalLinkPreviewHref as i, normalizeExternalLinkPreviewLinkText as a, normalizeExternalLinkPreviewMediaUrl as o, normalizeExternalLinkPreviewMetadata as s } from "./attributes.js";
|
|
3
3
|
import { getExternalLinkPreviewAttributesFromElement as c } from "./serialization.js";
|
|
4
4
|
import { renderExternalLinkPreviewHTML as l } from "./render-html.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/serialization.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/serialization.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAc7D,eAAO,MAAM,2CAA2C,YAC7C,OAAO,KACf,6BAA6B,GAAG,IAiBlC,CAAC;AAEF,eAAO,MAAM,oCAAoC,eAAgB,6BAA6B,2BAgB7F,CAAC;AAEF,eAAO,MAAM,iCAAiC,YACnC,OAAO,cACJ,6BAA6B,SAe1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,YAAa,OAAO,KAAG,OAUtE,CAAC;AAEF,eAAO,MAAM,mCAAmC,SAAU,OAAO,KAAG,IAwBnE,CAAC"}
|