@clevertask/scribe 0.0.11 → 0.0.13
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 +80 -4
- package/dist/assets/index.css +1 -1
- package/dist/components/Menu/BarMenu.js +21 -21
- package/dist/components/Menu/BubbleMenu.js +1 -1
- package/dist/components/Menu/Mobile/ListOptionBar.d.ts +6 -0
- package/dist/components/Menu/Mobile/ListOptionBar.js +37 -0
- package/dist/components/Scribe/extension/emoji/suggest.js +5 -6
- package/dist/components/Scribe/extension/extension-link.js +240 -244
- package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
- package/dist/components/Scribe/extension/index.d.ts +1 -1
- package/dist/components/Scribe/extension/index.js +24 -25
- package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +5 -5
- package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
- package/dist/components/Scribe/extension/slashCommand/items.js +6 -7
- package/dist/components/Scribe/extension/slashCommand/renderItems.js +10 -11
- package/dist/components/Scribe/index.d.ts +1 -0
- package/dist/components/Scribe/index.js +101 -79
- package/dist/index-BfaHEr44.js +159 -0
- package/dist/index-Bvgjhwaj.js +2349 -0
- package/dist/{index-CasgquAq.js → index-CWvaDN_2.js} +16838 -5196
- package/dist/{index-DeZ8laak.js → index-flsxByQS.js} +1587 -1527
- package/dist/main.css +4 -4
- package/dist/main.js +8 -6
- package/dist/marked.esm-H7n4rMcO.js +1554 -0
- package/dist/purify.es-DcWaZU6I.js +552 -0
- package/dist/turndown.browser.es-RmA_HBaI.js +649 -0
- package/dist/utils/convert-legacy-math-delimiters.d.ts +1 -0
- package/dist/utils/convert-legacy-math-delimiters.js +13 -0
- package/dist/utils/create-scribe-editor.js +7 -6
- package/dist/utils/html-to-markdown.js +7 -6
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +8 -6
- package/dist/utils/markdown-to-html.js +4 -3
- package/package.json +57 -53
- package/dist/browser-BJWkU9cc.js +0 -2106
- package/dist/components/Scribe/extension/math-extension.d.ts +0 -2
- package/dist/components/Scribe/extension/math-extension.js +0 -11770
- package/dist/index-BqFHWqw6.js +0 -156
- package/dist/index-C_aWB8qt.js +0 -2291
- package/dist/turndown.browser.es-C1wFFc_i.js +0 -1172
package/README.md
CHANGED
|
@@ -14,10 +14,12 @@ A versatile, block-based rich text editor for diverse applications, built with T
|
|
|
14
14
|
- [@clevertask/scribe](#clevertaskscribe)
|
|
15
15
|
- [Installation](#installation)
|
|
16
16
|
- [Usage](#usage)
|
|
17
|
+
- [Math Expressions](#math-expressions)
|
|
17
18
|
- [Props](#props)
|
|
18
19
|
- [Helper Functions](#helper-functions)
|
|
19
20
|
- [md2html](#md2html)
|
|
20
21
|
- [html2md](#html2md)
|
|
22
|
+
- [convertLegacyMathDelimiters](#convertlegacymathdelimiters)
|
|
21
23
|
- [Roadmap](#roadmap)
|
|
22
24
|
- [Release Process](#release-process)
|
|
23
25
|
- [License](#license)
|
|
@@ -38,9 +40,12 @@ import "@clevertask/scribe/dist/main.css";
|
|
|
38
40
|
import { Scribe, ScribeOnChangeContents } from "@clevertask/scribe";
|
|
39
41
|
|
|
40
42
|
function App() {
|
|
41
|
-
const onContentChange = useCallback(
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
const onContentChange = useCallback(
|
|
44
|
+
({ markdownContent, htmlContent, jsonContent }: ScribeOnChangeContents) => {
|
|
45
|
+
console.log(markdownContent, htmlContent, jsonContent);
|
|
46
|
+
},
|
|
47
|
+
[],
|
|
48
|
+
);
|
|
44
49
|
|
|
45
50
|
return <Scribe onContentChange={onContentChange} />;
|
|
46
51
|
}
|
|
@@ -90,6 +95,35 @@ function App() {
|
|
|
90
95
|
}
|
|
91
96
|
```
|
|
92
97
|
|
|
98
|
+
## Math Expressions
|
|
99
|
+
|
|
100
|
+
Scribe ships with `@tiptap/extension-mathematics`. The extension renders math when it receives math nodes in the HTML:
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
<span data-type="inline-math" data-latex="\alpha"></span>
|
|
104
|
+
<div data-type="block-math" data-latex="\sum_{i=1}^{n} x_i"></div>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Typing Delimiters (Input Rules)
|
|
108
|
+
|
|
109
|
+
When typing directly in the editor, the built-in input rules use:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Inline: $$\alpha$$
|
|
113
|
+
Block: $$$\sum_{i=1}^{n} x_i$$$
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Markdown Delimiters
|
|
117
|
+
|
|
118
|
+
If you are parsing markdown with the Tiptap Markdown extension (not `md2html`), the tokenizer expects:
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
Inline: $\alpha$
|
|
122
|
+
Block: $$\sum_{i=1}^{n} x_i$$
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
93
127
|
## Props
|
|
94
128
|
|
|
95
129
|
| Prop | Type | Default | Description |
|
|
@@ -134,7 +168,11 @@ const ChatMessages = () => {
|
|
|
134
168
|
return messages.map((message) => (
|
|
135
169
|
<Flex key={message.id} direction="column" mb="4">
|
|
136
170
|
<Heading size="4">{`${message.role}: `}</Heading>
|
|
137
|
-
<Scribe
|
|
171
|
+
<Scribe
|
|
172
|
+
editable={false}
|
|
173
|
+
showBarMenu={false}
|
|
174
|
+
content={md2html(message.content)}
|
|
175
|
+
/>
|
|
138
176
|
</Flex>
|
|
139
177
|
));
|
|
140
178
|
};
|
|
@@ -160,6 +198,44 @@ const md = html2md("<h1>Hello world</h1>"); // Output: # Hello world
|
|
|
160
198
|
|
|
161
199
|
> **Note**: The Scribe component already exposes a property called `markdownContent` when the `onContentChange` is used. In fact, the `markdownContent` is the output of the usage of the `html2md` function.
|
|
162
200
|
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
### `convertLegacyMathDelimiters`
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
export declare function convertLegacyMathDelimiters(input: string): string;
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Convert legacy math delimiters into the HTML nodes required by the mathematics extension. This is useful when you receive HTML from a server that contains legacy math like `\(...\)` or `\[...\]`.
|
|
210
|
+
|
|
211
|
+
This helper is primarily for consumers upgrading from older Scribe versions who stored math expressions using the legacy formats. It aims to be accurate, but the previous format was ambiguous (no explicit `$$` delimiters), so conversion is best-effort and not guaranteed in every case.
|
|
212
|
+
|
|
213
|
+
**Supported legacy delimiters**:
|
|
214
|
+
|
|
215
|
+
- `\(...\)` for inline math
|
|
216
|
+
- `\[...\]` for block math
|
|
217
|
+
- `(...)` and `[...]` when the content looks like LaTeX (contains `\`, `^`, or `_`)
|
|
218
|
+
|
|
219
|
+
**Usage Example**:
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
import {
|
|
223
|
+
convertLegacyMathDelimiters,
|
|
224
|
+
md2html,
|
|
225
|
+
Scribe,
|
|
226
|
+
} from "@clevertask/scribe";
|
|
227
|
+
|
|
228
|
+
const html = md2html(convertLegacyMathDelimiters(rawMarkdown));
|
|
229
|
+
|
|
230
|
+
// OR
|
|
231
|
+
|
|
232
|
+
const html = convertLegacyMathDelimiters(htmlContent);
|
|
233
|
+
|
|
234
|
+
<Scribe editable={false} showBarMenu={false} content={html} />;
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
If you already receive HTML from the server, call `convertLegacyMathDelimiters` directly on that HTML before rendering.
|
|
238
|
+
|
|
163
239
|
## Roadmap
|
|
164
240
|
|
|
165
241
|
We're constantly working to improve @clevertask/scribe. Here are some features we're planning to implement:
|