@clevertask/scribe 0.1.15 → 0.1.17

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 (32) hide show
  1. package/README.md +19 -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/dist/components/Scribe/extension/index.d.ts.map +1 -1
  24. package/dist/components/Scribe/extension/index.js +1 -1
  25. package/dist/components/Scribe/index.d.ts +8 -0
  26. package/dist/components/Scribe/index.d.ts.map +1 -1
  27. package/dist/components/Scribe/index.js +1 -1
  28. package/dist/{extension-dRUfQQo6.js → extension-CwuvxVkr.js} +2 -1
  29. package/dist/utils/create-scribe-editor.d.ts +6 -1
  30. package/dist/utils/create-scribe-editor.d.ts.map +1 -1
  31. package/dist/utils/index.js +7 -4
  32. 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
 
@@ -241,6 +243,18 @@ Block: $$\sum_{i=1}^{n} x_i$$
241
243
 
242
244
  If your content arrives as HTML (for example from a server), use the helper below to convert legacy delimiters into the HTML nodes that the math extension understands.
243
245
 
246
+ ## External Undo and Redo Ownership
247
+
248
+ Scribe enables its built-in undo and redo history by default. Set `enableUndoRedo={false}` when a different extension owns history, such as Tiptap Collaboration:
249
+
250
+ ```tsx
251
+ <Scribe enableUndoRedo={false} extensions={[Collaboration.configure({ document: ydoc })]} />
252
+ ```
253
+
254
+ Scribe reads this option when it creates the editor. Remount Scribe to change it. If you pass an `externalEditor`, configure history on that editor instead. Do not add another ordinary history extension through `extensions` when collaboration owns undo and redo.
255
+
256
+ The `createScribeEditor` helper accepts the same `enableUndoRedo` option.
257
+
244
258
  ## Props
245
259
 
246
260
  | Prop | Type | Default | Description |
@@ -252,6 +266,7 @@ If your content arrives as HTML (for example from a server), use the helper belo
252
266
  | `autoFocus` | `boolean` | `false` | Controls whether the editor should automatically focus when mounted. |
253
267
  | `extensions` | `Extension[]` | `undefined` | You can set your own extensions for the text editor. For more information, [check the tip tap extensions docs](https://tiptap.dev/docs/editor/core-concepts/extensions) |
254
268
  | `externalEditor` | `Editor` | `undefined` | Uses a caller-owned Tiptap editor. The caller remains responsible for its extension and plugin lifecycle, including table resizing, and for destroying it. |
269
+ | `enableUndoRedo` | `boolean` | `true` | Enables Scribe's built-in undo and redo history. Set it to `false` when another extension owns history. This creation-time option does not configure a caller-owned `externalEditor`. |
255
270
  | `externalLinkPreview` | `Partial<ExternalLinkPreviewOptions>` | `undefined` | Experimental. Opts into external-link metadata resolution and enhanced Compact/Card presentation. The consumer owns fetching and destination policy; automatic previews on paste default to disabled. |
256
271
  | `editorProps` | `EditorProps` | `undefined` | A tiptap-based prop to handle advanced use cases, you can read about it on their [documentation](https://tiptap.dev/docs/editor/api/editor#editorprops) |
257
272
  | `showBarMenu` | `boolean` | `true` | Determines whether to show the text editor top menu bar or not. This menu bar shows options to format the text |
@@ -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,4BAA4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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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BACnC;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IAiFhF,iCAAiC,kBACf,MAAM,mBAAmB,MAAM,wBAC5B;QAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IA+BhF,0BAA0B,oBACN,MAAM,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,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C;QAAC,EAAE,EAAE,WAAW,CAAA;KAAE;IAsBhF,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,118 +1,119 @@
1
1
  import { v as e } from "../../../../dist-tNcpTcFT.js";
2
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";
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;AAC9E,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,8EAA8E;AAC9E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,8EAA8E;AAC9E,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,0BAA0B,CAAC;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,8EAA8E;AAC9E,MAAM,WAAW,kCAAkC;IACjD,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,8EAA8E;AAC9E,MAAM,MAAM,2BAA2B,GAAG,CACxC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,kCAAkC,KACxC,OAAO,CAAC,2BAA2B,GAAG,IAAI,CAAC,CAAC;AAEjD,8EAA8E;AAC9E,MAAM,WAAW,0BAA0B;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,OAAO,CAAC,EAAE,2BAA2B,CAAC;IACtC,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3C;AAED,8EAA8E;AAC9E,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,0BAA0B,CAAC;CACtC;AAED,8EAA8E;AAC9E,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,0BAA0B,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,mCAAmC,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC"}
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;AAC9E,MAAM,MAAM,0BAA0B,GAAG,CAAC,OAAO,8BAA8B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEzF,8EAA8E;AAC9E,MAAM,WAAW,2BAA2B;IAC1C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1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,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,0BAA0B,CAAC;CACtC;AAED,8EAA8E;AAC9E,MAAM,WAAW,gCAAiC,SAAQ,2BAA2B;IACnF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,0BAA0B,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,MAAM,mCAAmC,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAwBtC,eAAO,MAAM,cAAc,UAAW,WAAW;;;;;;;;;;;;;;;;;4kCA0FhD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../lib/components/Scribe/extension/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAwBtC,eAAO,MAAM,cAAc,UAAW,WAAW;;;;;;;;;;;;;;;;;4kCA2FhD,CAAC"}
@@ -1,2 +1,2 @@
1
- import { t as e } from "../../../extension-dRUfQQo6.js";
1
+ import { t as e } from "../../../extension-CwuvxVkr.js";
2
2
  export { e as initExtensions };
@@ -67,6 +67,14 @@ export interface ScribeProps {
67
67
  * @experimental The link-preview API and built-in UI may change while this feature is tested.
68
68
  */
69
69
  externalLinkPreview?: Partial<ExternalLinkPreviewOptions>;
70
+ /**
71
+ * Enables Scribe's built-in undo and redo history. Disable this when another
72
+ * extension, such as Tiptap Collaboration, owns history for the editor.
73
+ *
74
+ * Scribe reads this option when it creates the editor. It does not configure
75
+ * a caller-owned `externalEditor`.
76
+ */
77
+ enableUndoRedo?: boolean;
70
78
  /** @experimental Enables Scribe's app-owned table-of-contents API. */
71
79
  enableTableOfContents?: boolean;
72
80
  /** @experimental Receives the current table-of-contents items when they change. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/components/Scribe/index.tsx"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAK9B,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AAGxC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,KAAK,EACV,kCAAkC,EAElC,iCAAiC,EAClC,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,OAAO,EACP,MAAM,EAGN,SAAS,EACT,WAAW,EACX,gBAAgB,EAEjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,oBAAoB,EAMrB,MAAM,OAAO,CAAC;AAGf,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,8BAA8B,EAC9B,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,YAAY,EACV,kCAAkC,EAClC,yBAAyB,EACzB,iCAAiC,GAClC,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,mBAAmB,EACnB,6BAA6B,EAC7B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,kCAAkC,EAClC,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,mCAAmC,CAAC;AAE3C,MAAM,MAAM,sBAAsB,GAAG;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,GAAG,cAAc,CAAC;CACjC,CAAC;AA+BF,MAAM,WAAW,SA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AAsE;IACtE,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,uBAAuB,CAAC,EAAE,kCAAkC,CAAC;CAC9D;AAqbD,eAAO,MAAM,MAAM,mGAMlB,CAAC"}
@@ -4,7 +4,7 @@ import i from "../Menu/CalloutBubbleMenu.js";
4
4
  import a from "../Menu/LinkBubbleMenu.js";
5
5
  import o from "../Menu/TableBubbleMenu.js";
6
6
  import { t as s } from "../../html-to-markdown-nbQ6qHyO.js";
7
- import { t as c } from "../../extension-dRUfQQo6.js";
7
+ import { t as c } from "../../extension-CwuvxVkr.js";
8
8
  import { SuggestionItemType as l } from "./extension/slashCommand/items.js";
9
9
  import "./extension/tableOfContents.js";
10
10
  import "../../utils/index.js";
@@ -55218,7 +55218,8 @@ var Ul = new Te("emojiSuggestion"), Wl = /:([a-zA-Z0-9_+-]+):$/, Gl = /(^|\s):([
55218
55218
  width: 4,
55219
55219
  color: "#ebf6fe"
55220
55220
  },
55221
- link: !1
55221
+ link: !1,
55222
+ ...e.enableUndoRedo === !1 ? { undoRedo: !1 } : {}
55222
55223
  }),
55223
55224
  Se.configure(e.externalLinkPreview),
55224
55225
  ce,
@@ -3,6 +3,11 @@ import type { ExternalLinkPreviewOptions } from "../components/Scribe/extension/
3
3
  export type CreateEditorOptions = {
4
4
  content?: string;
5
5
  editable?: boolean;
6
+ /**
7
+ * Enables Scribe's built-in undo and redo history. Disable this when another
8
+ * extension owns history for the editor.
9
+ */
10
+ enableUndoRedo?: boolean;
6
11
  /** @experimental The link-preview API and built-in UI may change while this feature is tested. */
7
12
  externalLinkPreview?: Partial<ExternalLinkPreviewOptions>;
8
13
  onContentChange?: (content: {
@@ -11,5 +16,5 @@ export type CreateEditorOptions = {
11
16
  markdownContent: string;
12
17
  }) => void;
13
18
  };
14
- export declare function createScribeEditor({ content, editable, externalLinkPreview, onContentChange, }: CreateEditorOptions): Editor;
19
+ export declare function createScribeEditor({ content, editable, enableUndoRedo, externalLinkPreview, onContentChange, }: CreateEditorOptions): Editor;
15
20
  //# sourceMappingURL=create-scribe-editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-scribe-editor.d.ts","sourceRoot":"","sources":["../../lib/utils/create-scribe-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAEvG,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kGAAkG;IAClG,mBAAmB,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAC1B,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,WAAW,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,KAAK,IAAI,CAAC;CACZ,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EACjC,OAAY,EACZ,QAAgB,EAChB,mBAAmB,EACnB,eAAe,GAChB,EAAE,mBAAmB,GAAG,MAAM,CAoB9B"}
1
+ {"version":3,"file":"create-scribe-editor.d.ts","sourceRoot":"","sources":["../../lib/utils/create-scribe-editor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGnD,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,sDAAsD,CAAC;AAEvG,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,kGAAkG;IAClG,mBAAmB,CAAC,EAAE,OAAO,CAAC,0BAA0B,CAAC,CAAC;IAC1D,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE;QAC1B,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,WAAW,CAAC;QACzB,eAAe,EAAE,MAAM,CAAC;KACzB,KAAK,IAAI,CAAC;CACZ,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,EACjC,OAAY,EACZ,QAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,EAAE,mBAAmB,GAAG,MAAM,CAoB9B"}
@@ -3,15 +3,18 @@ import { t } from "../html-to-markdown-nbQ6qHyO.js";
3
3
  import { t as n } from "../markdown-to-html-B-KKCZRs.js";
4
4
  import { isInViewport as r } from "./is-in-viewport.js";
5
5
  import { convertLegacyMathDelimiters as i } from "./convert-legacy-math-delimiters.js";
6
- import { t as a } from "../extension-dRUfQQo6.js";
6
+ import { t as a } from "../extension-CwuvxVkr.js";
7
7
  //#region lib/utils/create-scribe-editor.ts
8
- function o({ content: n = "", editable: r = !1, externalLinkPreview: i, onContentChange: o }) {
8
+ function o({ content: n = "", editable: r = !1, enableUndoRedo: i, externalLinkPreview: o, onContentChange: s }) {
9
9
  return new e({
10
10
  content: n,
11
11
  editable: r,
12
- extensions: a({ externalLinkPreview: i }),
12
+ extensions: a({
13
+ enableUndoRedo: i,
14
+ externalLinkPreview: o
15
+ }),
13
16
  onUpdate({ editor: e }) {
14
- o && o({
17
+ s && s({
15
18
  htmlContent: e.getHTML(),
16
19
  jsonContent: e.getJSON(),
17
20
  markdownContent: t(e.getHTML())
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clevertask/scribe",
3
- "version": "0.1.15",
3
+ "version": "0.1.17",
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": [