@clevertask/scribe 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/index.js +2 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +2 -1
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -1
- package/dist/components/Scribe/extension/external-link-preview/paste.js +15 -15
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts +5 -0
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -156,15 +156,17 @@ function DocumentEditor() {
|
|
|
156
156
|
externalLinkPreview={{
|
|
157
157
|
resolve: resolveLinkPreview,
|
|
158
158
|
shouldPreview,
|
|
159
|
+
// Defaults to false. Enable only if standalone pastes should fetch immediately.
|
|
160
|
+
autoPreviewOnPaste: false,
|
|
159
161
|
}}
|
|
160
162
|
/>
|
|
161
163
|
);
|
|
162
164
|
}
|
|
163
165
|
```
|
|
164
166
|
|
|
165
|
-
|
|
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.
|
|
166
168
|
|
|
167
|
-
The resolver runs only after an explicit
|
|
169
|
+
The resolver runs only after an explicit conversion, programmatic preview insertion, preview destination edit, refresh, or—when 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.
|
|
168
170
|
|
|
169
171
|
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.
|
|
170
172
|
|
|
@@ -250,7 +252,7 @@ If your content arrives as HTML (for example from a server), use the helper belo
|
|
|
250
252
|
| `autoFocus` | `boolean` | `false` | Controls whether the editor should automatically focus when mounted. |
|
|
251
253
|
| `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) |
|
|
252
254
|
| `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. |
|
|
253
|
-
| `externalLinkPreview` | `Partial<ExternalLinkPreviewOptions>` | `undefined` | Experimental. Opts into external-link metadata resolution and enhanced Compact/Card presentation. The consumer owns fetching and destination policy.
|
|
255
|
+
| `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. |
|
|
254
256
|
| `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) |
|
|
255
257
|
| `showBarMenu` | `boolean` | `true` | Determines whether to show the text editor top menu bar or not. This menu bar shows options to format the text |
|
|
256
258
|
| `placeholderText` | `string` | `Type "/" for commands...` | Change the initial placeholder for your text editor |
|
|
@@ -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,
|
|
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"}
|
|
@@ -32,6 +32,7 @@ var b = (e) => {
|
|
|
32
32
|
addOptions() {
|
|
33
33
|
return {
|
|
34
34
|
HTMLAttributes: {},
|
|
35
|
+
autoPreviewOnPaste: !1,
|
|
35
36
|
resolve: void 0,
|
|
36
37
|
shouldPreview: void 0
|
|
37
38
|
};
|
|
@@ -122,6 +123,7 @@ var b = (e) => {
|
|
|
122
123
|
return [
|
|
123
124
|
_({
|
|
124
125
|
previewType: this.type,
|
|
126
|
+
autoPreviewOnPaste: this.options.autoPreviewOnPaste === !0,
|
|
125
127
|
resolveMetadata: !!this.options.resolve,
|
|
126
128
|
shouldPreview: this.options.shouldPreview
|
|
127
129
|
}),
|
|
@@ -1,7 +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, resolveMetadata, shouldPreview, }: {
|
|
3
|
+
export declare const createExternalLinkPreviewPastePlugin: ({ previewType, autoPreviewOnPaste, resolveMetadata, shouldPreview, }: {
|
|
4
4
|
previewType: NodeType;
|
|
5
|
+
autoPreviewOnPaste: boolean;
|
|
5
6
|
resolveMetadata: boolean;
|
|
6
7
|
shouldPreview?: (href: string) => boolean;
|
|
7
8
|
}) => Plugin<any>;
|
|
@@ -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,
|
|
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"}
|
|
@@ -22,32 +22,32 @@ var s = new o("scribeExternalLinkPreviewPaste"), c = (e) => {
|
|
|
22
22
|
return n.$from.parent.forEach((e) => {
|
|
23
23
|
(!e.isText || e.textContent.trim()) && (r = !1);
|
|
24
24
|
}), !n.empty || n.$from.parent.type.name !== "paragraph" || !r ? !1 : n.$from.parent.canReplaceWith(0, n.$from.parent.childCount, t);
|
|
25
|
-
}, d = ({ previewType: o,
|
|
25
|
+
}, d = ({ previewType: o, autoPreviewOnPaste: d, resolveMetadata: f, shouldPreview: p }) => new a({
|
|
26
26
|
key: s,
|
|
27
27
|
props: { handlePaste(a, s) {
|
|
28
|
-
let
|
|
29
|
-
if (!
|
|
30
|
-
let
|
|
31
|
-
if (!a.state.selection.empty &&
|
|
32
|
-
let e = l(a,
|
|
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
33
|
return e && s.preventDefault(), e;
|
|
34
34
|
}
|
|
35
|
-
let
|
|
36
|
-
if (!d || !
|
|
35
|
+
let g = n(m);
|
|
36
|
+
if (!d || !f || !g || !u(a, o)) return !1;
|
|
37
37
|
try {
|
|
38
|
-
if (
|
|
38
|
+
if (p && !p(g)) return !1;
|
|
39
39
|
} catch {
|
|
40
40
|
return !1;
|
|
41
41
|
}
|
|
42
|
-
let
|
|
43
|
-
href:
|
|
44
|
-
linkText:
|
|
42
|
+
let _ = t({
|
|
43
|
+
href: g,
|
|
44
|
+
linkText: m,
|
|
45
45
|
display: "compact"
|
|
46
46
|
});
|
|
47
|
-
if (!
|
|
47
|
+
if (!_) return !1;
|
|
48
48
|
s.preventDefault();
|
|
49
|
-
let
|
|
50
|
-
return
|
|
49
|
+
let v = a.state.selection.$from.start(), y = v + a.state.selection.$from.parent.content.size, b = v, x = a.state.tr.replaceWith(v, y, o.create(_));
|
|
50
|
+
return x.setSelection(i.create(x.doc, b)), f && r(x, b, g), a.dispatch(x.scrollIntoView()), !0;
|
|
51
51
|
} }
|
|
52
52
|
});
|
|
53
53
|
//#endregion
|
|
@@ -32,6 +32,11 @@ export type ExternalLinkPreviewResolver = (href: string, context: ExternalLinkPr
|
|
|
32
32
|
/** @experimental Part of Scribe's evolving external-link-preview contract. */
|
|
33
33
|
export interface ExternalLinkPreviewOptions {
|
|
34
34
|
HTMLAttributes?: Record<string, unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Automatically turn a standalone pasted URL into a Compact preview.
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
autoPreviewOnPaste?: boolean;
|
|
35
40
|
resolve?: ExternalLinkPreviewResolver;
|
|
36
41
|
shouldPreview?: (href: string) => boolean;
|
|
37
42
|
}
|
|
@@ -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,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,C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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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clevertask/scribe",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
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": [
|