@clevertask/scribe 0.0.12 → 0.0.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.
Files changed (69) hide show
  1. package/README.md +80 -4
  2. package/dist/assets/index.css +1 -1
  3. package/dist/components/Menu/BarMenu.d.ts +3 -2
  4. package/dist/components/Menu/BarMenu.d.ts.map +1 -0
  5. package/dist/components/Menu/BarMenu.js +21 -21
  6. package/dist/components/Menu/BubbleMenu.d.ts +3 -2
  7. package/dist/components/Menu/BubbleMenu.d.ts.map +1 -0
  8. package/dist/components/Menu/BubbleMenu.js +1 -1
  9. package/dist/components/Menu/Mobile/ListOptionBar.d.ts +2 -1
  10. package/dist/components/Menu/Mobile/ListOptionBar.d.ts.map +1 -0
  11. package/dist/components/Menu/Mobile/ListOptionBar.js +35 -38
  12. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts +2 -1
  13. package/dist/components/Scribe/extension/emoji/EmojiList.d.ts.map +1 -0
  14. package/dist/components/Scribe/extension/emoji/suggest.d.ts +1 -0
  15. package/dist/components/Scribe/extension/emoji/suggest.d.ts.map +1 -0
  16. package/dist/components/Scribe/extension/emoji/suggest.js +5 -6
  17. package/dist/components/Scribe/extension/extension-link.d.ts +2 -1
  18. package/dist/components/Scribe/extension/extension-link.d.ts.map +1 -0
  19. package/dist/components/Scribe/extension/extension-link.js +2 -2
  20. package/dist/components/Scribe/extension/extension-selectedText.d.ts +2 -1
  21. package/dist/components/Scribe/extension/extension-selectedText.d.ts.map +1 -0
  22. package/dist/components/Scribe/extension/extension-selectedText.js +1 -1
  23. package/dist/components/Scribe/extension/index.d.ts +3 -2
  24. package/dist/components/Scribe/extension/index.d.ts.map +1 -0
  25. package/dist/components/Scribe/extension/index.js +2 -2
  26. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts +3 -2
  27. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.d.ts.map +1 -0
  28. package/dist/components/Scribe/extension/slashCommand/SlashCommandList.js +4 -4
  29. package/dist/components/Scribe/extension/slashCommand/index.d.ts +3 -2
  30. package/dist/components/Scribe/extension/slashCommand/index.d.ts.map +1 -0
  31. package/dist/components/Scribe/extension/slashCommand/index.js +2 -2
  32. package/dist/components/Scribe/extension/slashCommand/items.d.ts +3 -2
  33. package/dist/components/Scribe/extension/slashCommand/items.d.ts.map +1 -0
  34. package/dist/components/Scribe/extension/slashCommand/items.js +6 -7
  35. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts +2 -1
  36. package/dist/components/Scribe/extension/slashCommand/renderItems.d.ts.map +1 -0
  37. package/dist/components/Scribe/extension/slashCommand/renderItems.js +10 -11
  38. package/dist/components/Scribe/index.d.ts +6 -4
  39. package/dist/components/Scribe/index.d.ts.map +1 -0
  40. package/dist/components/Scribe/index.js +78 -79
  41. package/dist/index-BfaHEr44.js +159 -0
  42. package/dist/{index-VneQGVTd.js → index-Bvgjhwaj.js} +11 -47
  43. package/dist/{index-CCS9HOYd.js → index-DAuPG8ME.js} +5313 -5425
  44. package/dist/{index-DoNRu1rY.js → index-flsxByQS.js} +17 -17
  45. package/dist/main.d.ts +4 -3
  46. package/dist/main.d.ts.map +1 -0
  47. package/dist/main.js +8 -6
  48. package/dist/marked.esm-H7n4rMcO.js +1554 -0
  49. package/dist/{purify.es-BGaRrCfO.js → purify.es-BRDuGiV2.js} +114 -115
  50. package/dist/utils/convert-legacy-math-delimiters.d.ts +2 -0
  51. package/dist/utils/convert-legacy-math-delimiters.d.ts.map +1 -0
  52. package/dist/utils/convert-legacy-math-delimiters.js +13 -0
  53. package/dist/utils/create-scribe-editor.d.ts +2 -1
  54. package/dist/utils/create-scribe-editor.d.ts.map +1 -0
  55. package/dist/utils/create-scribe-editor.js +3 -3
  56. package/dist/utils/html-to-markdown.d.ts +1 -0
  57. package/dist/utils/html-to-markdown.d.ts.map +1 -0
  58. package/dist/utils/html-to-markdown.js +1 -1
  59. package/dist/utils/index.d.ts +6 -4
  60. package/dist/utils/index.d.ts.map +1 -0
  61. package/dist/utils/index.js +8 -6
  62. package/dist/utils/is-in-viewport.d.ts +1 -0
  63. package/dist/utils/is-in-viewport.d.ts.map +1 -0
  64. package/dist/utils/markdown-to-html.d.ts +1 -0
  65. package/dist/utils/markdown-to-html.d.ts.map +1 -0
  66. package/dist/utils/markdown-to-html.js +2 -2
  67. package/package.json +46 -46
  68. package/dist/index-B0pieAxt.js +0 -160
  69. package/dist/marked.esm-BS_MmRZC.js +0 -1566
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(({ markdownContent, htmlContent, jsonContent }: ScribeOnChangeContents) => {
42
- console.log(markdownContent, htmlContent, jsonContent);
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 editable={false} showBarMenu={false} content={md2html(message.content)} />
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: