@brevitaz/brv-text-editor 1.0.0 → 1.1.0

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 CHANGED
@@ -13,9 +13,11 @@ Built on [Tiptap](https://tiptap.dev/) (ProseMirror) + [Lucide React](https://lu
13
13
  | **Headings** | H1, H2, H3 via dropdown |
14
14
  | **Lists** | Bullet, numbered, task (checkbox) lists |
15
15
  | **Blocks** | Blockquote, fenced code block, horizontal rule |
16
+ | **Callouts** | 6 themed callout blocks — Info, Success, Warning, Danger, Tip, Note |
16
17
  | **Alignment** | Left, center, right text alignment |
17
18
  | **Media** | Insert links (with edit/remove popover) and images by URL |
18
19
  | **History** | Undo / Redo (⌘Z / ⌘⇧Z) |
20
+ | **Configurable toolbar** | Enable/disable toolbar groups via the `toolbar` prop |
19
21
  | **Word count** | Live character and word count in the footer |
20
22
  | **Preview** | `RichTextPreview` renders saved HTML in a Basecamp-style card with tabbed source view and emoji reactions |
21
23
 
@@ -27,7 +29,7 @@ Built on [Tiptap](https://tiptap.dev/) (ProseMirror) + [Lucide React](https://lu
27
29
  npm install brv-text-editor
28
30
  ```
29
31
 
30
- > **Peer dependencies** – React 18+ must already be installed in your project.
32
+ > **Peer dependencies** – React 18 or 19 must already be installed in your project.
31
33
  > `react` and `react-dom` are **not** bundled inside the package.
32
34
 
33
35
  ```bash
@@ -121,6 +123,45 @@ function NotesPage() {
121
123
  | `showActions` | `boolean` | `true` | Whether to show the footer Save/Cancel bar |
122
124
  | `minHeight` | `number` | `140` | Minimum editor height in pixels |
123
125
  | `autofocus` | `boolean` | `false` | Whether to focus the editor on mount |
126
+ | `toolbar` | `object` | `DEFAULT_TOOLBAR` | Toggle toolbar groups (see below) |
127
+
128
+ #### Toolbar groups
129
+
130
+ The `toolbar` prop accepts a partial object. Omitted keys default to `true`.
131
+
132
+ ```jsx
133
+ // Show only formatting and callouts
134
+ <RichTextEditor toolbar={{ headings: false, alignment: false, lists: false, blocks: false, media: false, history: false }} />
135
+
136
+ // Hide callouts only
137
+ <RichTextEditor toolbar={{ callouts: false }} />
138
+ ```
139
+
140
+ | Group | Controls |
141
+ |---|---|
142
+ | `headings` | H1 / H2 / H3 dropdown |
143
+ | `formatting` | Bold, italic, underline, strikethrough, inline code |
144
+ | `alignment` | Left, center, right text alignment |
145
+ | `lists` | Bullet, numbered, task lists |
146
+ | `blocks` | Blockquote, code block, horizontal rule |
147
+ | `callouts` | Callout block dropdown (info, success, warning, danger, tip, note) |
148
+ | `media` | Link and image insert |
149
+ | `history` | Undo / redo |
150
+
151
+ #### Callout blocks
152
+
153
+ Six themed callout variants are available via the callout dropdown button in the toolbar. Each callout renders as a colored left-bordered block:
154
+
155
+ | Type | Color | Use case |
156
+ |---|---|---|
157
+ | `info` | Blue | General information |
158
+ | `success` | Green | Positive outcomes |
159
+ | `warning` | Amber | Caution / attention |
160
+ | `danger` | Red | Critical / breaking |
161
+ | `tip` | Purple | Helpful hints |
162
+ | `note` | Gray | Supplementary notes |
163
+
164
+ Callouts are stored as `<div data-callout="type">` in the HTML output, so they render correctly in `RichTextPreview` as well.
124
165
 
125
166
  ### `<RichTextPreview />`
126
167
 
@@ -253,6 +253,66 @@ body {
253
253
  color: var(--rte-text-muted);
254
254
  }
255
255
 
256
+ /* ─── Callout blocks ────────────────────────────────────────────────────── */
257
+
258
+ .rte-root .ProseMirror .rte-callout,
259
+ .rte-root .rtp-content .rte-callout {
260
+ border-left: 4px solid var(--_callout-color, #64748b);
261
+ background: var(--_callout-bg, #f8fafc);
262
+ border-radius: 0 var(--rte-radius) var(--rte-radius) 0;
263
+ padding: 12px 16px;
264
+ margin: 0.5em 0;
265
+ position: relative;
266
+ }
267
+
268
+ .rte-root .ProseMirror .rte-callout p:last-child,
269
+ .rte-root .rtp-content .rte-callout p:last-child {
270
+ margin-bottom: 0;
271
+ }
272
+
273
+ /* Info — blue */
274
+ .rte-root .ProseMirror .rte-callout--info,
275
+ .rte-root .rtp-content .rte-callout--info {
276
+ --_callout-color: #2563eb;
277
+ --_callout-bg: #eff6ff;
278
+ }
279
+
280
+ /* Success — green */
281
+ .rte-root .ProseMirror .rte-callout--success,
282
+ .rte-root .rtp-content .rte-callout--success {
283
+ --_callout-color: #16a34a;
284
+ --_callout-bg: #f0fdf4;
285
+ }
286
+
287
+ /* Warning — amber */
288
+ .rte-root .ProseMirror .rte-callout--warning,
289
+ .rte-root .rtp-content .rte-callout--warning {
290
+ --_callout-color: #d97706;
291
+ --_callout-bg: #fffbeb;
292
+ }
293
+
294
+ /* Danger — red */
295
+ .rte-root .ProseMirror .rte-callout--danger,
296
+ .rte-root .rtp-content .rte-callout--danger {
297
+ --_callout-color: #dc2626;
298
+ --_callout-bg: #fef2f2;
299
+ }
300
+
301
+ /* Tip — purple */
302
+ .rte-root .ProseMirror .rte-callout--tip,
303
+ .rte-root .rtp-content .rte-callout--tip {
304
+ --_callout-color: #7c3aed;
305
+ --_callout-bg: #faf5ff;
306
+ }
307
+
308
+ /* Note — gray */
309
+ .rte-root .ProseMirror .rte-callout--note,
310
+ .rte-root .rtp-content .rte-callout--note {
311
+ --_callout-color: #64748b;
312
+ --_callout-bg: #f8fafc;
313
+ }
314
+
315
+
256
316
  /* Placeholder */
257
317
  .rte-root .ProseMirror p.is-editor-empty:first-child::before {
258
318
  color: var(--rte-text-placeholder);