@clevertask/scribe 0.1.12 → 0.1.14
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 +51 -1
- package/dist/{BarMenu-5M9g9Y1j.js → BarMenu-x4sf3ECS.js} +1 -1
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.js +1 -1
- package/dist/components/Menu/BubbleMenu.js +2 -2
- package/dist/components/Menu/CalloutBubbleMenu.js +2 -2
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts +13 -0
- package/dist/components/Menu/ExternalLinkDisplayOptions.d.ts.map +1 -0
- package/dist/components/Menu/ExternalLinkDisplayOptions.js +90 -0
- package/dist/components/Menu/LinkBubbleMenu.d.ts.map +1 -1
- package/dist/components/Menu/LinkBubbleMenu.js +161 -61
- package/dist/components/Menu/LinkEditor.d.ts +9 -0
- package/dist/components/Menu/LinkEditor.d.ts.map +1 -1
- package/dist/components/Menu/LinkEditor.js +117 -64
- package/dist/components/Menu/Mobile/ListOptionBar.js +1 -1
- package/dist/components/Menu/TableBubbleMenu.js +2 -2
- package/dist/components/Menu/contextualMenuOwner.d.ts +1 -1
- package/dist/components/Menu/contextualMenuOwner.d.ts.map +1 -1
- package/dist/components/Menu/contextualMenuOwner.js +9 -6
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts +24 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.d.ts.map +1 -1
- package/dist/components/Menu/linkBubbleMenuPlugin.js +43 -6
- package/dist/components/Scribe/extension/callout.js +1 -1
- package/dist/components/Scribe/extension/emoji/suggest.js +1 -1
- package/dist/components/Scribe/extension/extension-link.js +1 -1
- package/dist/components/Scribe/extension/extension-markdown-paste.js +2 -2
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts +18 -0
- package/dist/components/Scribe/extension/external-link-preview/attributes.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/attributes.js +82 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts +53 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/commands.js +134 -0
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts +13 -0
- package/dist/components/Scribe/extension/external-link-preview/index.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/index.js +138 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts +3 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/node-view.js +97 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/normalization.js +21 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts +8 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/paste.js +54 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/policy.js +38 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts +7 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/render-html.js +62 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts +23 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/resolver.js +118 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts +10 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/serialization.js +69 -0
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts +53 -0
- package/dist/components/Scribe/extension/external-link-preview/types.d.ts.map +1 -0
- package/dist/components/Scribe/extension/external-link-preview/types.js +4 -0
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.d.ts.map +1 -1
- package/dist/components/Scribe/extension/index.js +1 -1
- package/dist/components/Scribe/extension/resizable-table.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/index.js +1 -1
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +1 -1
- package/dist/components/Scribe/extension/tableOfContents.js +1 -1
- package/dist/components/Scribe/index.d.ts +14 -0
- package/dist/components/Scribe/index.d.ts.map +1 -1
- package/dist/components/Scribe/index.js +5 -5
- package/dist/{dist-Dw4STOPE.js → dist-DDjaA1Pn.js} +309 -150
- package/dist/{dist-DFua_Xbu.js → dist-tNcpTcFT.js} +893 -430
- package/dist/{extension-_8uh0Ik9.js → extension-dRUfQQo6.js} +2097 -2059
- package/dist/{extension-link-CjfUZ90W.js → extension-link-RYtPpHwt.js} +52 -51
- package/dist/{html-to-markdown-C920nQtn.js → html-to-markdown-nbQ6qHyO.js} +173 -162
- package/dist/main.css +148 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +12 -9
- package/dist/{markdown-to-html-CW0Nb9Ye.js → markdown-to-html-B-KKCZRs.js} +115 -111
- package/dist/{menus-_EXlLMjz.js → menus-U2HdvQnu.js} +18 -18
- package/dist/{resizable-table-Ddw3l6DJ.js → resizable-table-m0AzovsZ.js} +42 -24
- package/dist/{slashCommand-CxX07Nbk.js → slashCommand-CtvgnL0Z.js} +2 -2
- package/dist/utils/create-scribe-editor.d.ts +4 -1
- package/dist/utils/create-scribe-editor.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +1 -1
- package/dist/utils/index.js +7 -7
- package/dist/utils/markdown-to-html.d.ts.map +1 -1
- package/dist/utils/markdown-to-html.js +1 -1
- package/package.json +48 -48
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ A versatile, block-based rich text editor for diverse applications, built with T
|
|
|
11
11
|
- **Markdown Support:** Parse and render Markdown content effortlessly.
|
|
12
12
|
- **Markdown Paste:** Paste plain-text markdown into the editor and have it converted into rich content automatically.
|
|
13
13
|
- **Table Authoring:** Insert, resize, and edit tables with controls that stay next to the active table.
|
|
14
|
+
- **Experimental External Link Previews:** Opt into Compact and Preview card presentations while keeping ordinary links available.
|
|
14
15
|
- **Versatile Integration:** Easily integrate `@clevertask/scribe` into any project requiring rich text editing.
|
|
15
16
|
- **View and Edit:** Seamlessly switch between viewing and editing modes.
|
|
16
17
|
- **Experimental Table of Contents:** Subscribe to heading changes and render an app-owned table of contents outside the editor.
|
|
@@ -21,6 +22,7 @@ A versatile, block-based rich text editor for diverse applications, built with T
|
|
|
21
22
|
- [Installation](#installation)
|
|
22
23
|
- [Usage](#usage)
|
|
23
24
|
- [Table Authoring](#table-authoring)
|
|
25
|
+
- [External Link Previews](#external-link-previews)
|
|
24
26
|
- [Experimental Table of Contents](#experimental-table-of-contents)
|
|
25
27
|
- [Math Expressions](#math-expressions)
|
|
26
28
|
- [Props](#props)
|
|
@@ -36,7 +38,7 @@ A versatile, block-based rich text editor for diverse applications, built with T
|
|
|
36
38
|
## Installation
|
|
37
39
|
|
|
38
40
|
```bash
|
|
39
|
-
npm install --save-exact @clevertask/scribe @tiptap/pm@3.
|
|
41
|
+
npm install --save-exact @clevertask/scribe @tiptap/pm@3.30.1
|
|
40
42
|
```
|
|
41
43
|
|
|
42
44
|
Scribe shares this exact ProseMirror runtime with consumer extensions. Keeping one
|
|
@@ -119,6 +121,53 @@ Keyboard users can press `Alt + F10` while editing a table to focus its controls
|
|
|
119
121
|
|
|
120
122
|
Simple headed tables serialize as GFM Markdown. Tables with merged cells, multiple blocks in a cell, resized columns, or other structures that GFM cannot represent are kept as sanitized raw HTML inside the Markdown output so their structure is not silently lost.
|
|
121
123
|
|
|
124
|
+
## External Link Previews
|
|
125
|
+
|
|
126
|
+
> [!NOTE]
|
|
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
|
+
|
|
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.
|
|
130
|
+
|
|
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
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { Scribe, type ExternalLinkPreviewResolver } from "@clevertask/scribe";
|
|
135
|
+
import { useCallback } from "react";
|
|
136
|
+
|
|
137
|
+
function DocumentEditor() {
|
|
138
|
+
const resolveLinkPreview = useCallback<ExternalLinkPreviewResolver>(async (href, { signal }) => {
|
|
139
|
+
const response = await fetch(`/api/link-previews?url=${encodeURIComponent(href)}`, {
|
|
140
|
+
credentials: "include",
|
|
141
|
+
signal,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
return null;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return response.json();
|
|
149
|
+
}, []);
|
|
150
|
+
const shouldPreview = useCallback((href: string) => {
|
|
151
|
+
return new URL(href).origin !== window.location.origin;
|
|
152
|
+
}, []);
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<Scribe
|
|
156
|
+
externalLinkPreview={{
|
|
157
|
+
resolve: resolveLinkPreview,
|
|
158
|
+
shouldPreview,
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Pasting a standalone external URL into an empty paragraph creates a Compact preview. Pasting a URL over selected text 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
|
+
|
|
167
|
+
The resolver runs only after an explicit paste, conversion, destination edit, or refresh—not when 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
|
+
|
|
169
|
+
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
|
+
|
|
122
171
|
## Experimental Table of Contents
|
|
123
172
|
|
|
124
173
|
Scribe can expose table-of-contents data without rendering a table-of-contents block inside the editable document. Enable the experimental API with `enableTableOfContents`, keep the latest items in your app state, and call `scrollToTableOfContentsItem` when a user selects an entry.
|
|
@@ -201,6 +250,7 @@ If your content arrives as HTML (for example from a server), use the helper belo
|
|
|
201
250
|
| `autoFocus` | `boolean` | `false` | Controls whether the editor should automatically focus when mounted. |
|
|
202
251
|
| `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) |
|
|
203
252
|
| `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. |
|
|
204
254
|
| `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) |
|
|
205
255
|
| `showBarMenu` | `boolean` | `true` | Determines whether to show the text editor top menu bar or not. This menu bar shows options to format the text |
|
|
206
256
|
| `placeholderText` | `string` | `Type "/" for commands...` | Change the initial placeholder for your text editor |
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { s as e } from "./dist-DDjaA1Pn.js";
|
|
2
2
|
import { getPopupMountTarget as t } from "./components/Scribe/extension/getPopupMountTarget.js";
|
|
3
3
|
import n from "./components/Menu/LinkEditor.js";
|
|
4
4
|
import { hideLinkBubbleMenu as r } from "./components/Menu/linkBubbleMenuPlugin.js";
|