@clevertask/scribe 0.1.15 → 0.1.16

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 (23) hide show
  1. package/README.md +6 -4
  2. package/dist/components/Menu/ExternalLinkDisplayOptions.js +2 -2
  3. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts +4 -1
  4. package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -1
  5. package/dist/components/Scribe/extension/external-link-preview/attributes.js +9 -2
  6. package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -1
  7. package/dist/components/Scribe/extension/external-link-preview/commands.js +67 -66
  8. package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -1
  9. package/dist/components/Scribe/extension/external-link-preview/index.js +0 -1
  10. package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +1 -1
  11. package/dist/components/Scribe/extension/external-link-preview/node-view.js +2 -2
  12. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +1 -2
  13. package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -1
  14. package/dist/components/Scribe/extension/external-link-preview/paste.js +24 -25
  15. package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -1
  16. package/dist/components/Scribe/extension/external-link-preview/render-html.js +3 -3
  17. package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +1 -1
  18. package/dist/components/Scribe/extension/external-link-preview/resolver.js +1 -1
  19. package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -1
  20. package/dist/components/Scribe/extension/external-link-preview/serialization.js +3 -3
  21. package/dist/components/Scribe/extension/external-link-preview/types.d.ts +3 -1
  22. package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -1
  23. package/package.json +1 -1
package/README.md CHANGED
@@ -126,7 +126,7 @@ Simple headed tables serialize as GFM Markdown. Tables with merged cells, multip
126
126
  > [!NOTE]
127
127
  > External Link Previews are experimental. Their public API, built-in card presentation, and link-options UI may change as we test them in real document workflows.
128
128
 
129
- External link previews are opt-in. Scribe owns their editor behavior and presentation, while your app owns metadata fetching. Pass a resolver that calls an authenticated app endpoint; Scribe never requests the destination website directly.
129
+ Compact links work locally without a metadata provider. Scribe builds their visible label from authored link text or, for a raw URL, from its hostname and path. The exact destination—including its query and fragment—remains unchanged. Preview cards are opt-in: Scribe owns their editor behavior and presentation, while your app owns metadata fetching. Pass a resolver that calls an authenticated app endpoint; Scribe never requests the destination website directly.
130
130
 
131
131
  That endpoint should validate the destination, block private or reserved network addresses, re-check redirects, and enforce response-size and timeout limits before returning sanitized metadata.
132
132
 
@@ -156,7 +156,7 @@ function DocumentEditor() {
156
156
  externalLinkPreview={{
157
157
  resolve: resolveLinkPreview,
158
158
  shouldPreview,
159
- // Defaults to false. Enable only if standalone pastes should fetch immediately.
159
+ // Defaults to false. When enabled, standalone pastes become local Compact links.
160
160
  autoPreviewOnPaste: false,
161
161
  }}
162
162
  />
@@ -164,9 +164,11 @@ function DocumentEditor() {
164
164
  }
165
165
  ```
166
166
 
167
- By default, pasting a standalone external URL creates an ordinary link and does not call the resolver. Select the link and choose Compact or Preview card to request metadata. Set `autoPreviewOnPaste: true` if standalone URL pastes should become Compact previews automatically. Pasting a URL over selected text always keeps an ordinary labeled link. While editing, select a Plain, Compact, or Card link to open its contextual menu. From there you can edit or open the destination, refresh preview metadata, or switch presentation; a Preview card is available only when the link has its own line. Keyboard users can press `Alt + F10` from a selected link to open the same menu and press Escape to return to the document.
167
+ By default, pasting a standalone external URL creates an ordinary link. Select it and choose Compact to shorten only its presentation, with no metadata request. A meaningful authored label is kept; a raw URL is shown as `hostname/path` without its query or fragment. Switching back to Plain restores the original label and exact destination. Set `autoPreviewOnPaste: true` only if standalone URL pastes should become local Compact links automatically. Pasting a URL over selected text always keeps an ordinary labeled link.
168
168
 
169
- The resolver runs only after an explicit conversion, programmatic preview insertion, preview destination edit, refresh, orwhen deliberately enabled—an automatic standalone paste. It never runs merely because a saved document opens. It receives an `AbortSignal`, and can return `pageTitle`, `description`, `siteName`, `faviconUrl`, `imageUrl`, and `fetchedAt`. Use `shouldPreview` to keep app-owned or otherwise unsupported destinations on the ordinary-link path.
169
+ While editing, select a Plain, Compact, or Card link to open its contextual menu. From there you can edit or open the destination, or switch presentation. A Preview card is available only when the link has its own line and metadata is already stored or a resolver is configured. Refresh is available only for Preview cards with a resolver. Keyboard users can press `Alt + F10` from a selected link to open the same menu and press Escape to return to the document.
170
+
171
+ The resolver runs only when a Preview card needs metadata: after explicit Card conversion, programmatic Card insertion, a Card destination edit, or Card refresh. Compact creation, editing, automatic paste, and document reopen make no metadata request. The resolver receives an `AbortSignal`, and can return `pageTitle`, `description`, `siteName`, `faviconUrl`, `imageUrl`, and `fetchedAt`. Use `shouldPreview` to keep app-owned or otherwise unsupported destinations on the ordinary-link path.
170
172
 
171
173
  Preview nodes use sanitized raw HTML when content is serialized as Markdown, so their metadata and presentation survive Scribe's current Markdown round trip. A caller-owned `externalEditor` must register `ExternalLinkPreview` itself.
172
174
 
@@ -9,7 +9,7 @@ var s = [
9
9
  label: "Plain link"
10
10
  },
11
11
  {
12
- description: "Show the page title and site icon.",
12
+ description: "Show a concise label without fetching metadata.",
13
13
  display: "compact",
14
14
  label: "Compact"
15
15
  },
@@ -46,7 +46,7 @@ var s = [
46
46
  direction: "column",
47
47
  gap: "1",
48
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;
49
+ let i = u === r.display, s = b[r.display], c = `${h}-${r.display}-description`, l = r.display === "card" && !s ? "Preview cards require metadata support and their own line." : r.description;
50
50
  return /* @__PURE__ */ a(e, {
51
51
  type: "button",
52
52
  "aria-describedby": c,
@@ -14,5 +14,8 @@ export declare const normalizeExternalLinkPreviewMetadata: (metadata: ExternalLi
14
14
  export declare const normalizeExternalLinkPreviewMetadataPatch: (metadata: ExternalLinkPreviewMetadata) => Partial<Required<ExternalLinkPreviewMetadata>>;
15
15
  export declare const normalizeExternalLinkPreviewAttributes: (input: Partial<Record<keyof ExternalLinkPreviewAttributes, unknown>>) => ExternalLinkPreviewAttributes | null;
16
16
  export declare const getExternalLinkPreviewHostname: (href: string) => string;
17
- export declare const getExternalLinkPreviewTitle: (attributes: Pick<ExternalLinkPreviewAttributes, "href" | "pageTitle" | "siteName">) => string;
17
+ /** Build a concise, presentation-only label without changing the authored destination. */
18
+ export declare const getExternalLinkPreviewReadableLabel: (href: string) => string;
19
+ export declare const getExternalLinkPreviewTitle: (attributes: Pick<ExternalLinkPreviewAttributes, "href" | "linkText" | "pageTitle" | "siteName">, display: ExternalLinkPreviewDisplay) => string;
20
+ export declare const hasExternalLinkPreviewMetadata: (attributes: Pick<ExternalLinkPreviewAttributes, "pageTitle" | "description" | "siteName" | "faviconUrl" | "imageUrl">) => boolean;
18
21
  //# sourceMappingURL=attributes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,SAAS,CAAC;AA8CjB,8EAA8E;AAC9E,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,8BAA8B,8CAA4C,CAAC;AACxF,eAAO,MAAM,qCAAqC,gCAAgC,CAAC;AAEnF,eAAO,MAAM,4BAA4B,UAAW,OAAO,KAAG,KAAK,IAAI,0BAC2B,CAAC;AAwBnG,eAAO,MAAM,oCAAoC,UAAW,OAAO,KAAG,MAAM,GAAG,IACE,CAAC;AAElF,oGAAoG;AACpG,eAAO,MAAM,gCAAgC,UAAW,OAAO,KAAG,MAAM,GAAG,IAuB1E,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,oCAAoC,UAAW,OAAO,KAAG,MAAM,GAAG,IAwB9E,CAAC;AAcF,eAAO,MAAM,oCAAoC,aACrC,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KACjF,QAAQ,CAAC,2BAA2B,CAOrC,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,yCAAyC,aAC1C,2BAA2B,KACpC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAW/C,CAAC;AAEF,eAAO,MAAM,sCAAsC,UAC1C,OAAO,CAAC,MAAM,CAAC,MAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC,KACnE,6BAA6B,GAAG,IAgBlC,CAAC;AAEF,eAAO,MAAM,8BAA8B,SAAU,MAAM,WAM1D,CAAC;AAEF,eAAO,MAAM,2BAA2B,eAC1B,IAAI,CAAC,6BAA6B,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,CAAC,WACe,CAAC"}
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,SAAS,CAAC;AA8CjB,8EAA8E;AAC9E,eAAO,MAAM,+BAA+B,wBAAwB,CAAC;AACrE,eAAO,MAAM,8BAA8B,8CAA4C,CAAC;AACxF,eAAO,MAAM,qCAAqC,gCAAgC,CAAC;AAEnF,eAAO,MAAM,4BAA4B,UAAW,OAAO,KAAG,KAAK,IAAI,0BAC2B,CAAC;AAwBnG,eAAO,MAAM,oCAAoC,UAAW,OAAO,KAAG,MAAM,GAAG,IACE,CAAC;AAElF,oGAAoG;AACpG,eAAO,MAAM,gCAAgC,UAAW,OAAO,KAAG,MAAM,GAAG,IAuB1E,CAAC;AAEF,sFAAsF;AACtF,eAAO,MAAM,oCAAoC,UAAW,OAAO,KAAG,MAAM,GAAG,IAwB9E,CAAC;AAcF,eAAO,MAAM,oCAAoC,aACrC,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,KACjF,QAAQ,CAAC,2BAA2B,CAOrC,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,yCAAyC,aAC1C,2BAA2B,KACpC,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAC,CAW/C,CAAC;AAEF,eAAO,MAAM,sCAAsC,UAC1C,OAAO,CAAC,MAAM,CAAC,MAAM,6BAA6B,EAAE,OAAO,CAAC,CAAC,KACnE,6BAA6B,GAAG,IAgBlC,CAAC;AAEF,eAAO,MAAM,8BAA8B,SAAU,MAAM,WAM1D,CAAC;AAEF,0FAA0F;AAC1F,eAAO,MAAM,mCAAmC,SAAU,MAAM,WAS/D,CAAC;AAEF,eAAO,MAAM,2BAA2B,eAC1B,IAAI,CAAC,6BAA6B,EAAE,MAAM,GAAG,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC,WACtF,0BAA0B,WAWpC,CAAC;AAEF,eAAO,MAAM,8BAA8B,eAC7B,IAAI,CACd,6BAA6B,EAC7B,WAAW,GAAG,aAAa,GAAG,UAAU,GAAG,YAAY,GAAG,UAAU,CACrE,YAQA,CAAC"}
@@ -77,6 +77,13 @@ var t = /^\/(?![\\/])/, n = /^https?:\/\//i, r = 16384, i = 16384, a = 512, o =
77
77
  } catch {
78
78
  return e;
79
79
  }
80
- }, D = (e) => e.pageTitle || e.siteName || E(e.href);
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);
81
88
  //#endregion
82
- export { m as EXTERNAL_LINK_PREVIEW_NODE_NAME, h as EXTERNAL_LINK_PREVIEW_SELECTOR, g as EXTERNAL_LINK_PREVIEW_TARGET_SELECTOR, E as getExternalLinkPreviewHostname, D as getExternalLinkPreviewTitle, _ as isExternalLinkPreviewDisplay, T as normalizeExternalLinkPreviewAttributes, b as normalizeExternalLinkPreviewHref, y as normalizeExternalLinkPreviewLinkText, x as normalizeExternalLinkPreviewMediaUrl, C as normalizeExternalLinkPreviewMetadata, w as normalizeExternalLinkPreviewMetadataPatch };
89
+ export { m as EXTERNAL_LINK_PREVIEW_NODE_NAME, h as EXTERNAL_LINK_PREVIEW_SELECTOR, g as EXTERNAL_LINK_PREVIEW_TARGET_SELECTOR, E as getExternalLinkPreviewHostname, D as getExternalLinkPreviewReadableLabel, O as getExternalLinkPreviewTitle, k as hasExternalLinkPreviewMetadata, _ as isExternalLinkPreviewDisplay, T as normalizeExternalLinkPreviewAttributes, b as normalizeExternalLinkPreviewHref, y as normalizeExternalLinkPreviewLinkText, x as normalizeExternalLinkPreviewMediaUrl, C as normalizeExternalLinkPreviewMetadata, w as normalizeExternalLinkPreviewMetadataPatch };
@@ -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,EAAQ,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AASpD,OAAO,KAAK,EACV,mBAAmB,EACnB,6BAA6B,EAE7B,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,mBAAmB,EAAE;YACnB,iEAAiE;YACjE,yBAAyB,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,UAAU,CAAC;YACrF,yFAAyF;YACzF,sBAAsB,EAAE,CAAC,OAAO,EAAE,mBAAmB,EAAE,c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,wBACL;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IAqBhF,yBAAyB,YACb,gCAAgC,mBAAmB,MAAM,wBAChD;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;CAsEhF,CAAC"}
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/commands.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAUpD,OAAO,KAAK,EACV,mBAAmB,EACnB,6BAA6B,EAE7B,gCAAgC,EAChC,gCAAgC,EACjC,MAAM,SAAS,CAAC;AAEjB,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,mBAAmB,EAAE;YACnB,iEAAiE;YACjE,yBAAyB,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,UAAU,CAAC;YACrF,yFAAyF;YACzF,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,kEAAkE;YAClE,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;I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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";
3
+ import { EXTERNAL_LINK_PREVIEW_NODE_NAME as n, hasExternalLinkPreviewMetadata as r, normalizeExternalLinkPreviewAttributes as i, normalizeExternalLinkPreviewHref as a } from "./attributes.js";
4
+ import { startExternalLinkPreviewResolution as o } from "./resolver.js";
5
+ import { NodeSelection as s, TextSelection as c } from "@tiptap/pm/state";
6
6
  //#region lib/components/Scribe/extension/external-link-preview/commands.ts
7
- 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);
7
+ var l = (e, t) => {
8
+ let { selection: n } = e, r = typeof t == "number";
9
+ if (r && (!Number.isInteger(t) || t < 0 || t >= e.doc.content.size)) return null;
10
+ let a = r ? t : n.from, o = r ? e.doc.nodeAt(a) : n instanceof s ? n.node : null;
11
+ if (!o || o.type.name !== "externalLinkPreview") return null;
12
+ let c = i(o.attrs);
13
13
  if (!c) return null;
14
14
  let l = e.doc.resolve(a);
15
15
  return {
16
16
  attributes: c,
17
- node: s,
17
+ node: o,
18
18
  position: a,
19
- isSoleTextblockContent: l.parent.isTextblock && l.parent.childCount === 1 && l.parent.content.size === s.nodeSize
19
+ isSoleTextblockContent: l.parent.isTextblock && l.parent.childCount === 1 && l.parent.content.size === o.nodeSize
20
20
  };
21
- }, l = (t) => {
21
+ }, u = (t) => {
22
22
  let n = t.doc.type.schema.marks.link;
23
23
  if (!n) return null;
24
24
  let { selection: r } = t;
25
25
  if (!r.$from.sameParent(r.$to) || !r.$from.parent.isTextblock) return null;
26
- let a = e(r.$from, n), o = r.$from.start(), s = r.$from.parent;
27
- if (!a) return null;
26
+ let i = e(r.$from, n), o = r.$from.start(), s = r.$from.parent;
27
+ if (!i) return null;
28
28
  let c, l = !0, u = "";
29
- t.doc.nodesBetween(a.from, a.to, (e, t) => {
29
+ t.doc.nodesBetween(i.from, i.to, (e, t) => {
30
30
  if (!e.isText) {
31
31
  e.isInline && (l = !1);
32
32
  return;
33
33
  }
34
- let r = e.marks.find((e) => e.type === n), i = Math.max(a.from, t), o = Math.min(a.to, t + e.nodeSize);
34
+ let r = e.marks.find((e) => e.type === n), a = Math.max(i.from, t), o = Math.min(i.to, t + e.nodeSize);
35
35
  if (!r || e.marks.some((e) => e.type !== n) || c && r.attrs.href !== c.attrs.href) {
36
36
  l = !1;
37
37
  return;
38
38
  }
39
- c = r, u += e.text?.slice(i - t, o - t) ?? "";
39
+ c = r, u += e.text?.slice(a - t, o - t) ?? "";
40
40
  });
41
- let d = i(c?.attrs.href);
41
+ let d = a(c?.attrs.href);
42
42
  return !l || !c || !d ? null : {
43
43
  href: d,
44
44
  linkText: u || d,
45
45
  mark: c,
46
- from: a.from,
47
- to: a.to,
48
- isSoleTextblockContent: a.from === o && a.to === o + s.content.size
46
+ from: i.from,
47
+ to: i.to,
48
+ isSoleTextblockContent: i.from === o && i.to === o + s.content.size
49
49
  };
50
- }, u = (e, t) => {
50
+ }, d = (e, t) => {
51
51
  if (!t) return !0;
52
52
  try {
53
53
  return t(e);
54
54
  } catch {
55
55
  return !1;
56
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) => {
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) => {
60
60
  let i = e.doc.type.schema.marks.link, a = e.doc.resolve(t.position).parent;
61
61
  if (!i || !a.type.allowsMarkType(i)) return !1;
62
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({
63
+ return e.replaceWith(t.position, t.position + t.node.nodeSize, o), e.setSelection(c.create(e.doc, t.position, t.position + o.nodeSize)), !0;
64
+ }, h = ({ resolveMetadata: e, shouldPreview: s }) => ({
65
+ insertExternalLinkPreview: (t) => ({ dispatch: a, tr: c }) => {
66
+ let l = i({
67
67
  ...t,
68
68
  linkText: t.linkText ?? t.href,
69
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;
70
+ }), u = c.doc.type.schema.nodes[n], { selection: p } = c, m = l?.display === "card" && !r(l);
71
+ if (!l || !u || m && !e || !d(l.href, s) || !p.$from.sameParent(p.$to) || !p.$from.parent.isTextblock || l.display === "card" && p.$from.parent.content.size !== p.content().size) return !1;
72
+ let h = p.$from.index();
73
+ if (!p.$from.parent.canReplaceWith(h, h, u)) return !1;
74
+ if (!a) return !0;
75
+ let g = u.create(l), _ = p.from;
76
+ return c.replaceRangeWith(p.from, p.to, g), f(c, _), m && o(c, _, l.href), !0;
77
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();
78
+ setExternalLinkDisplay: (t, n) => ({ dispatch: a, tr: c }) => {
79
+ let h = () => (c.setMeta("preventDispatch", !0), !1), g = l(c, n);
80
+ if (g) {
81
+ let n = t === "card" && !r(g.attributes);
82
+ if (t === "card" && !g.isSoleTextblockContent) return h();
82
83
  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);
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);
85
86
  }
86
- return t !== "compact" && t !== "card" ? m() : !i || h.attributes.display === t || (s.setNodeMarkup(h.position, void 0, {
87
- ...h.attributes,
87
+ return t !== "compact" && t !== "card" || n && !e ? h() : !a || g.attributes.display === t || (c.setNodeMarkup(g.position, void 0, {
88
+ ...g.attributes,
88
89
  display: t
89
- }), d(s, h.position), !0);
90
+ }), f(c, g.position), n && o(c, g.position, g.attributes.href), !0);
90
91
  }
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,
92
+ if (typeof n == "number") return h();
93
+ let _ = u(c);
94
+ if (!_ || t === "plain" || t === "card" && !e || t === "card" && !_.isSoleTextblockContent || !d(_.href, s)) return t === "plain" && _ ? !0 : h();
95
+ let v = i({
96
+ href: _.href,
97
+ linkText: _.linkText,
97
98
  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);
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);
100
101
  },
101
102
  convertExternalLinkPreviewToPlain: (e, n) => ({ dispatch: r, tr: i }) => {
102
- let a = () => (i.setMeta("preventDispatch", !0), !1), o = c(i, n), s = t(e);
103
+ let a = () => (i.setMeta("preventDispatch", !0), !1), o = l(i, n), s = t(e);
103
104
  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);
105
+ let c = i.doc.type.schema.marks.link, u = i.doc.resolve(o.position).parent;
106
+ return !c || !u.type.allowsMarkType(c) ? a() : !r || m(i, o, s, o.attributes.linkText === o.attributes.href ? s : o.attributes.linkText);
106
107
  },
107
108
  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);
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);
110
111
  },
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();
112
+ updateExternalLinkPreview: (t, n) => ({ dispatch: r, tr: c }) => {
113
+ let u = () => (c.setMeta("preventDispatch", !0), !1), p = l(c, n);
114
+ if (!p) return u();
115
+ let m = t.href ?? p.attributes.href, h = a(m), g = h !== p.attributes.href;
116
+ if (!h || !d(h, s)) return u();
116
117
  let _ = Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0)), v = g ? {
117
118
  pageTitle: null,
118
119
  description: null,
@@ -120,15 +121,15 @@ var c = (e, t) => {
120
121
  faviconUrl: null,
121
122
  imageUrl: null,
122
123
  fetchedAt: null
123
- } : {}, y = r({
124
+ } : {}, y = i({
124
125
  ...p.attributes,
125
126
  ...v,
126
127
  ..._,
127
128
  href: h,
128
129
  linkText: t.linkText ?? (g && p.attributes.linkText === p.attributes.href ? h : p.attributes.linkText)
129
130
  });
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
+ return y ? !Object.entries(y).some(([e, t]) => p.attributes[e] !== t) || !r || (c.setNodeMarkup(p.position, void 0, y), f(c, p.position), g && p.attributes.display === "card" && e && o(c, p.position, y.href), !0) : u();
131
132
  }
132
133
  });
133
134
  //#endregion
134
- export { m as createExternalLinkPreviewCommands, c as getSelectedExternalLinkPreview };
135
+ export { h as createExternalLinkPreviewCommands, l as getSelectedExternalLinkPreview };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAyBpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAyC1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAyBpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAyC1D;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,uCAmJ9B,CAAC;AAEH,OAAO,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,mCAAmC,EACnC,2BAA2B,EAC3B,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,SAAS,CAAC"}
@@ -124,7 +124,6 @@ var b = (e) => {
124
124
  _({
125
125
  previewType: this.type,
126
126
  autoPreviewOnPaste: this.options.autoPreviewOnPaste === !0,
127
- resolveMetadata: !!this.options.resolve,
128
127
  shouldPreview: this.options.shouldPreview
129
128
  }),
130
129
  v(this.options.shouldPreview),
@@ -1 +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"}
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,gCAgGlF,CAAC"}
@@ -38,7 +38,7 @@ var c = (e, t) => {
38
38
  "data-type": "external-link-preview",
39
39
  children: "Invalid external link"
40
40
  });
41
- let h = p.display === "card" && m.isSoleTextblockContent ? "card" : "compact", g = r(p), _ = p.siteName || n(p.href);
41
+ let h = p.display === "card" && m.isSoleTextblockContent ? "card" : "compact", g = r(p, h), _ = h === "card" ? p.siteName || n(p.href) : null;
42
42
  return /* @__PURE__ */ o(e, {
43
43
  as: "span",
44
44
  className: `scribe-external-link-preview scribe-external-link-preview--${h}`,
@@ -64,7 +64,7 @@ var c = (e, t) => {
64
64
  alt: ""
65
65
  }) : null, /* @__PURE__ */ s("span", {
66
66
  "data-link-preview-main": "",
67
- children: [p.faviconUrl ? /* @__PURE__ */ o("img", {
67
+ children: [h === "card" && p.faviconUrl ? /* @__PURE__ */ o("img", {
68
68
  "data-link-preview-favicon": "",
69
69
  src: p.faviconUrl,
70
70
  alt: ""
@@ -1,9 +1,8 @@
1
1
  import type { NodeType } from "@tiptap/pm/model";
2
2
  import { Plugin } from "@tiptap/pm/state";
3
- export declare const createExternalLinkPreviewPastePlugin: ({ previewType, autoPreviewOnPaste, resolveMetadata, shouldPreview, }: {
3
+ export declare const createExternalLinkPreviewPastePlugin: ({ previewType, autoPreviewOnPaste, shouldPreview, }: {
4
4
  previewType: NodeType;
5
5
  autoPreviewOnPaste: boolean;
6
- resolveMetadata: boolean;
7
6
  shouldPreview?: (href: string) => boolean;
8
7
  }) => Plugin<any>;
9
8
  //# sourceMappingURL=paste.d.ts.map
@@ -1 +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"}
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;AA6EpE,eAAO,MAAM,oCAAoC,wDAI9C;IACD,WAAW,EAAE,QAAQ,CAAC;IACtB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C,gBAgEG,CAAC"}
@@ -1,14 +1,13 @@
1
1
  import { normalizeLinkUrl as e } from "../../../Menu/linkUrl.js";
2
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";
3
+ import { NodeSelection as r, Plugin as i, PluginKey as a } from "@tiptap/pm/state";
5
4
  //#region lib/components/Scribe/extension/external-link-preview/paste.ts
6
- var s = new o("scribeExternalLinkPreviewPaste"), c = (e) => {
5
+ var o = new a("scribeExternalLinkPreviewPaste"), s = (e) => {
7
6
  let t = e.clipboardData?.getData("text/plain");
8
7
  if (!t) return null;
9
8
  let n = t.trim();
10
9
  return n && !/[\r\n]/.test(n) ? n : null;
11
- }, l = (e, t) => {
10
+ }, c = (e, t) => {
12
11
  let { selection: n, schema: r } = e.state, i = r.marks.link;
13
12
  if (n.empty || !i) return !1;
14
13
  let a = e.state.tr.setMeta("preventAutolink", !0), o = !1;
@@ -17,38 +16,38 @@ var s = new o("scribeExternalLinkPreviewPaste"), c = (e) => {
17
16
  let c = Math.max(r, n.from), l = Math.min(r + e.nodeSize, n.to);
18
17
  c < l && (a.addMark(c, l, i.create({ href: t })), o = !0);
19
18
  }), o ? (e.dispatch(a), !0) : !1;
20
- }, u = (e, t) => {
19
+ }, l = (e, t) => {
21
20
  let { selection: n } = e.state, r = !0;
22
21
  return n.$from.parent.forEach((e) => {
23
22
  (!e.isText || e.textContent.trim()) && (r = !1);
24
23
  }), !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;
24
+ }, u = ({ previewType: a, autoPreviewOnPaste: u, shouldPreview: d }) => new i({
25
+ key: o,
26
+ props: { handlePaste(i, o) {
27
+ let f = s(o);
28
+ if (!f) return !1;
29
+ let p = e(f);
30
+ if (!i.state.selection.empty && p) {
31
+ let e = c(i, p);
32
+ return e && o.preventDefault(), e;
34
33
  }
35
- let g = n(m);
36
- if (!d || !f || !g || !u(a, o)) return !1;
34
+ let m = n(f);
35
+ if (!u || !m || !l(i, a)) return !1;
37
36
  try {
38
- if (p && !p(g)) return !1;
37
+ if (d && !d(m)) return !1;
39
38
  } catch {
40
39
  return !1;
41
40
  }
42
- let _ = t({
43
- href: g,
44
- linkText: m,
41
+ let h = t({
42
+ href: m,
43
+ linkText: f,
45
44
  display: "compact"
46
45
  });
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;
46
+ if (!h) return !1;
47
+ o.preventDefault();
48
+ let g = i.state.selection.$from.start(), _ = g + i.state.selection.$from.parent.content.size, v = g, y = i.state.tr.replaceWith(g, _, a.create(h));
49
+ return y.setSelection(r.create(y.doc, v)), i.dispatch(y.scrollIntoView()), !0;
51
50
  } }
52
51
  });
53
52
  //#endregion
54
- export { d as createExternalLinkPreviewPastePlugin };
53
+ export { u as createExternalLinkPreviewPastePlugin };
@@ -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;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"}
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;AAiC7D,eAAO,MAAM,6BAA6B,oCAGvC;IACD,UAAU,EAAE,6BAA6B,CAAC;IAC1C,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,KAAG,aA4BH,CAAC"}
@@ -6,8 +6,8 @@ var i = (e) => {
6
6
  let r = [[
7
7
  "span",
8
8
  { "data-link-preview-title": "" },
9
- n(e)
10
- ]], i = e.siteName || t(e.href);
9
+ n(e, e.display)
10
+ ]], i = e.display === "card" ? e.siteName || t(e.href) : null;
11
11
  return i && r.push([
12
12
  "span",
13
13
  { "data-link-preview-site": "" },
@@ -19,7 +19,7 @@ var i = (e) => {
19
19
  ]), [
20
20
  "span",
21
21
  { "data-link-preview-main": "" },
22
- e.faviconUrl ? ["img", {
22
+ e.display === "card" && e.faviconUrl ? ["img", {
23
23
  "data-link-preview-favicon": "",
24
24
  src: e.faviconUrl,
25
25
  alt: ""
@@ -1 +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"}
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;AAUF,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"}
@@ -1,7 +1,7 @@
1
1
  import { normalizeExternalLinkPreviewAttributes as e, normalizeExternalLinkPreviewMetadataPatch as t } from "./attributes.js";
2
2
  import { NodeSelection as n, Plugin as r, PluginKey as i } from "@tiptap/pm/state";
3
3
  //#region lib/components/Scribe/extension/external-link-preview/resolver.ts
4
- var a = new i("scribeExternalLinkPreviewResolver"), o = (e, t) => e?.type.name === "externalLinkPreview" && e.attrs.href === t, s = (e, t) => Array.from(e.requests.values()).find((e) => e.token === t), c = (e, t, n) => (e.setMeta(a, {
4
+ var a = new i("scribeExternalLinkPreviewResolver"), o = (e, t) => e?.type.name === "externalLinkPreview" && e.attrs.display === "card" && e.attrs.href === t, s = (e, t) => Array.from(e.requests.values()).find((e) => e.token === t), c = (e, t, n) => (e.setMeta(a, {
5
5
  type: "start",
6
6
  href: n,
7
7
  position: t
@@ -1 +1 @@
1
- {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/serialization.ts"],"names":[],"mappings":"AAOA,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;AAWF,eAAO,MAAM,iCAAiC,YACnC,OAAO,cACJ,6BAA6B,SA4D1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,YAAa,OAAO,KAAG,OAUtE,CAAC;AAEF,eAAO,MAAM,mCAAmC,SAAU,OAAO,KAAG,IAwBnE,CAAC"}
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/serialization.ts"],"names":[],"mappings":"AAOA,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;AAWF,eAAO,MAAM,iCAAiC,YACnC,OAAO,cACJ,6BAA6B,SAmE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,YAAa,OAAO,KAAG,OAUtE,CAAC;AAEF,eAAO,MAAM,mCAAmC,SAAU,OAAO,KAAG,IAwBnE,CAAC"}
@@ -40,15 +40,15 @@ var a = {
40
40
  let e = i.createElement("img");
41
41
  e.setAttribute("data-link-preview-image", ""), e.setAttribute("src", t.imageUrl), e.setAttribute("alt", ""), a.append(e);
42
42
  }
43
- if (o.setAttribute("data-link-preview-main", ""), t.faviconUrl) {
43
+ if (o.setAttribute("data-link-preview-main", ""), t.display === "card" && t.faviconUrl) {
44
44
  let e = i.createElement("img");
45
45
  e.setAttribute("data-link-preview-favicon", ""), e.setAttribute("src", t.faviconUrl), e.setAttribute("alt", ""), o.append(e);
46
46
  } else {
47
47
  let e = c(i, "data-link-preview-favicon-fallback", "↗");
48
48
  e.setAttribute("aria-hidden", "true"), o.append(e);
49
49
  }
50
- l.setAttribute("data-link-preview-copy", ""), l.append(c(i, "data-link-preview-title", r(t)));
51
- let u = t.siteName || n(t.href);
50
+ l.setAttribute("data-link-preview-copy", ""), l.append(c(i, "data-link-preview-title", r(t, t.display)));
51
+ let u = t.display === "card" ? t.siteName || n(t.href) : null;
52
52
  u && l.append(c(i, "data-link-preview-site", u)), t.display === "card" && t.description && l.append(c(i, "data-link-preview-description", t.description)), o.append(l), a.append(o), e.replaceChildren(a);
53
53
  }, u = (e) => {
54
54
  let t = o(e);
@@ -33,10 +33,12 @@ export type ExternalLinkPreviewResolver = (href: string, context: ExternalLinkPr
33
33
  export interface ExternalLinkPreviewOptions {
34
34
  HTMLAttributes?: Record<string, unknown>;
35
35
  /**
36
- * Automatically turn a standalone pasted URL into a Compact preview.
36
+ * Automatically turn a standalone pasted URL into a local Compact preview.
37
+ * This does not request metadata.
37
38
  * @default false
38
39
  */
39
40
  autoPreviewOnPaste?: boolean;
41
+ /** Resolve metadata when a Preview card needs enrichment. */
40
42
  resolve?: ExternalLinkPreviewResolver;
41
43
  shouldPreview?: (href: string) => boolean;
42
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../lib/components/Scribe/extension/external-link-preview/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,eAAO,MAAM,8BAA8B,YAAI,SAAS,EAAE,MAAM,CAAU,CAAC;AAE3E,8EAA8E;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AC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,mCAAmC,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "private": false,
5
5
  "description": "A Radix-based Tiptap rich text editor with a Notion-style block interface for viewing and creating content. Perfect for diverse needs like notes, documents, AI chat, Markdown parsing, and comments.",
6
6
  "keywords": [