@brevitaz/brv-text-editor 1.1.0 → 1.2.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
@@ -1,7 +1,10 @@
1
- # brv-text-editor
1
+ # @brevitaz/brv-text-editor
2
2
 
3
- A fully-functional React rich text editor and preview component inspired by Basecamp 3.
4
- Built on [Tiptap](https://tiptap.dev/) (ProseMirror) + [Lucide React](https://lucide.dev/) icons.
3
+ A fully-featured React rich text editor and preview component built on [Tiptap](https://tiptap.dev/) (ProseMirror) + [Lucide React](https://lucide.dev/) icons.
4
+
5
+ ![Editor](./screenshots/editor.png)
6
+
7
+ ![Preview](./screenshots/preview.png)
5
8
 
6
9
  ---
7
10
 
@@ -16,20 +19,21 @@ Built on [Tiptap](https://tiptap.dev/) (ProseMirror) + [Lucide React](https://lu
16
19
  | **Callouts** | 6 themed callout blocks — Info, Success, Warning, Danger, Tip, Note |
17
20
  | **Alignment** | Left, center, right text alignment |
18
21
  | **Media** | Insert links (with edit/remove popover) and images by URL |
19
- | **History** | Undo / Redo (⌘Z / ⌘⇧Z) |
22
+ | **History** | Undo / Redo |
20
23
  | **Configurable toolbar** | Enable/disable toolbar groups via the `toolbar` prop |
21
24
  | **Word count** | Live character and word count in the footer |
22
- | **Preview** | `RichTextPreview` renders saved HTML in a Basecamp-style card with tabbed source view and emoji reactions |
25
+ | **Theming** | Built-in presets + full CSS variable customisation via `createTheme()` |
26
+ | **Preview** | `RichTextPreview` renders saved HTML in a styled card with emoji reactions |
23
27
 
24
28
  ---
25
29
 
26
30
  ## Installation
27
31
 
28
32
  ```bash
29
- npm install brv-text-editor
33
+ npm install @brevitaz/brv-text-editor
30
34
  ```
31
35
 
32
- > **Peer dependencies** React 18 or 19 must already be installed in your project.
36
+ > **Peer dependencies** React 19 must already be installed in your project.
33
37
  > `react` and `react-dom` are **not** bundled inside the package.
34
38
 
35
39
  ```bash
@@ -45,13 +49,13 @@ npm install react react-dom
45
49
 
46
50
  ```js
47
51
  // main.jsx / main.tsx / _app.jsx
48
- import 'brv-text-editor/dist/brv-text-editor.css'
52
+ import '@brevitaz/brv-text-editor/dist/brv-text-editor.css'
49
53
  ```
50
54
 
51
55
  ### 2. Use the editor
52
56
 
53
57
  ```jsx
54
- import { RichTextEditor } from 'brv-text-editor'
58
+ import { RichTextEditor } from '@brevitaz/brv-text-editor'
55
59
 
56
60
  function MyPage() {
57
61
  const handleSave = (html) => {
@@ -74,16 +78,14 @@ function MyPage() {
74
78
 
75
79
  ```jsx
76
80
  import { useState } from 'react'
77
- import { RichTextEditor, RichTextPreview } from 'brv-text-editor'
78
-
79
- const AUTHOR = { name: 'Jane Doe', initials: 'JD', avatarColor: '#1a6b3c' }
81
+ import { RichTextEditor, RichTextPreview } from '@brevitaz/brv-text-editor'
80
82
 
81
83
  function NotesPage() {
82
84
  const [notes, setNotes] = useState([])
83
85
 
84
86
  const handleSave = (html) => {
85
87
  setNotes(prev => [
86
- { id: Date.now(), html, timestamp: new Date().toLocaleString() },
88
+ { id: Date.now(), html },
87
89
  ...prev,
88
90
  ])
89
91
  }
@@ -93,13 +95,7 @@ function NotesPage() {
93
95
  <RichTextEditor onSubmit={handleSave} submitLabel="Post" showActions />
94
96
 
95
97
  {notes.map(note => (
96
- <RichTextPreview
97
- key={note.id}
98
- html={note.html}
99
- author={AUTHOR}
100
- timestamp={note.timestamp}
101
- onDismiss={() => setNotes(n => n.filter(x => x.id !== note.id))}
102
- />
98
+ <RichTextPreview key={note.id} html={note.html} />
103
99
  ))}
104
100
  </>
105
101
  )
@@ -124,6 +120,9 @@ function NotesPage() {
124
120
  | `minHeight` | `number` | `140` | Minimum editor height in pixels |
125
121
  | `autofocus` | `boolean` | `false` | Whether to focus the editor on mount |
126
122
  | `toolbar` | `object` | `DEFAULT_TOOLBAR` | Toggle toolbar groups (see below) |
123
+ | `theme` | `string` | `'unleashteams'` | Built-in theme preset |
124
+ | `themeVars` | `object` | `{}` | CSS variable overrides for custom theming |
125
+ | `className` | `string` | `''` | Additional class for the root wrapper |
127
126
 
128
127
  #### Toolbar groups
129
128
 
@@ -168,184 +167,76 @@ Callouts are stored as `<div data-callout="type">` in the HTML output, so they r
168
167
  | Prop | Type | Default | Description |
169
168
  |---|---|---|---|
170
169
  | `html` | `string` | `''` | Raw HTML string to render |
171
- | `author` | `{ name, initials, avatarColor? }` | `{ name:'Anonymous', initials:'A' }` | Author info shown in the card header |
172
- | `timestamp` | `string` | `''` | Human-readable timestamp string |
173
- | `onDismiss` | `() => void` | — | If provided, shows a × button to remove the card |
174
170
  | `showReactions` | `boolean` | `true` | Whether to show the emoji reactions row |
175
171
  | `reactions` | `string[]` | `['👍','❤️','🎉','🙌']` | Emoji list for the reactions row |
172
+ | `theme` | `string` | `'unleashteams'` | Built-in theme preset |
173
+ | `themeVars` | `object` | `{}` | CSS variable overrides for custom theming |
176
174
 
177
175
  ---
178
176
 
179
- ## Publishing for your company
180
-
181
- You have two options: a **private npm registry** (recommended) or a **direct Git dependency**.
182
-
183
- ---
184
-
185
- ### Option A — Private npm registry (recommended)
186
-
187
- This is the cleanest approach. Developers run a single `npm install` and get the package like any other.
188
-
189
- #### Step 1 — Set up a registry
190
-
191
- Choose one:
192
-
193
- | Option | Notes |
194
- |---|---|
195
- | **GitHub Packages** | Free for private repos; scoped package (`@your-org/brv-text-editor`). Good if you already use GitHub. |
196
- | **npm private registry** | Paid; works with unscoped names. |
197
- | **Verdaccio** (self-hosted) | Free, runs on your own server/container. Full npm protocol compatible. |
198
- | **AWS CodeArtifact / JFrog** | Enterprise options; cost depends on usage. |
199
-
200
- #### Step 2 — Scope the package (recommended for private registries)
201
-
202
- In `package.json`, rename to a scoped name:
203
-
204
- ```json
205
- {
206
- "name": "@your-org/brv-text-editor"
207
- }
208
- ```
209
-
210
- This prevents name collisions with the public registry.
211
-
212
- #### Step 3 — Authenticate and publish
213
-
214
- **GitHub Packages example:**
215
-
216
- ```bash
217
- # 1. Create a Personal Access Token (PAT) with write:packages scope on GitHub
218
-
219
- # 2. Login to the GitHub registry
220
- npm login --registry=https://npm.pkg.github.com --scope=@your-org
221
-
222
- # 3. Build the library
223
- npm run build:lib
224
-
225
- # 4. Publish
226
- npm publish --registry=https://npm.pkg.github.com
227
- ```
228
-
229
- **Verdaccio example:**
230
-
231
- ```bash
232
- # 1. Start Verdaccio (or point to your hosted instance)
233
- npx verdaccio # → http://localhost:4873
234
-
235
- # 2. Create an account (first time only)
236
- npm adduser --registry http://localhost:4873
237
-
238
- # 3. Build and publish
239
- npm run build:lib
240
- npm publish --registry http://localhost:4873
241
- ```
242
-
243
- #### Step 4 — Configure developers' machines
177
+ ## Theming
244
178
 
245
- Developers need to tell npm where to find your scoped packages.
246
- Create or update `.npmrc` in their project (or the monorepo root):
179
+ Every color, font, border, and spacing value is driven by a CSS custom property. Override them at any scope.
247
180
 
248
- ```ini
249
- # .npmrc – checked into source control
250
- @your-org:registry=https://npm.pkg.github.com
251
- # or for Verdaccio:
252
- # @your-org:registry=http://your-verdaccio-host:4873
253
- ```
254
-
255
- They also need to authenticate once:
181
+ ### Built-in presets
256
182
 
257
- ```bash
258
- npm login --registry=https://npm.pkg.github.com --scope=@your-org
183
+ ```jsx
184
+ <RichTextEditor theme="classic" />
259
185
  ```
260
186
 
261
- For CI/CD, use an automation token stored as a secret:
187
+ ### Custom overrides via props
262
188
 
263
- ```ini
264
- # .npmrc in CI environment
265
- //npm.pkg.github.com/:_authToken=${NPM_TOKEN}
266
- @your-org:registry=https://npm.pkg.github.com
189
+ ```jsx
190
+ <RichTextEditor themeVars={{ '--rte-color-primary': '#7c3aed' }} />
267
191
  ```
268
192
 
269
- #### Step 5 — Developers install and use it
270
-
271
- ```bash
272
- npm install @your-org/brv-text-editor
273
- ```
193
+ ### Using `createTheme()`
274
194
 
275
195
  ```jsx
276
- import '@your-org/brv-text-editor/dist/brv-text-editor.css'
277
- import { RichTextEditor, RichTextPreview } from '@your-org/brv-text-editor'
196
+ import { RichTextEditor, createTheme } from '@brevitaz/brv-text-editor'
197
+
198
+ const myTheme = createTheme({
199
+ '--rte-color-primary': '#7c3aed',
200
+ '--rte-btn-active-bg': '#ede9fe',
201
+ '--rte-btn-active-color': '#7c3aed',
202
+ '--rte-color-primary-hover': '#faf5ff',
203
+ '--rte-focus-border': '#a78bfa',
204
+ '--rte-focus-ring': 'rgba(124, 58, 237, 0.18)',
205
+ '--rte-blockquote-border': '#a78bfa',
206
+ '--rte-checkbox-accent': '#7c3aed',
207
+ '--rte-selection-bg': '#ede9fe',
208
+ })
209
+
210
+ <RichTextEditor themeVars={myTheme} />
278
211
  ```
279
212
 
280
- #### Step 6 — Publishing updates
281
-
282
- ```bash
283
- # Bump the version (choose: patch | minor | major)
284
- npm version patch
285
-
286
- # Rebuild and publish
287
- npm run build:lib && npm publish --registry <your-registry-url>
288
- ```
213
+ ### Available CSS variables
289
214
 
290
- Use semantic versioning:
291
- - `patch` (1.0.1) — bug fixes
292
- - `minor` (1.1.0) new features, backwards-compatible
293
- - `major` (2.0.0) breaking changes
215
+ | Variable | Description |
216
+ |---|---|
217
+ | `--rte-color-primary` | Primary action color |
218
+ | `--rte-color-primary-hover` | Primary hover state |
219
+ | `--rte-btn-active-bg` / `--rte-btn-active-color` | Active button styling |
220
+ | `--rte-surface` / `--rte-surface-toolbar` | Background colors |
221
+ | `--rte-border` / `--rte-border-toolbar` | Border colors |
222
+ | `--rte-text` / `--rte-text-muted` / `--rte-text-placeholder` | Text colors |
223
+ | `--rte-code-bg` / `--rte-code-color` | Code styling |
224
+ | `--rte-blockquote-border` / `--rte-blockquote-color` | Blockquote styling |
225
+ | `--rte-checkbox-accent` | Task list checkbox color |
226
+ | `--rte-focus-border` / `--rte-focus-ring` | Focus states |
227
+ | `--rte-font-family` | Font stack |
228
+ | `--rte-radius` / `--rte-radius-sm` / `--rte-radius-lg` | Border radii |
294
229
 
295
230
  ---
296
231
 
297
- ### Option B — Git dependency (no registry needed)
298
-
299
- If you just want to share quickly within your organization without setting up a registry, push the repo to your internal Git host and developers install directly from Git:
232
+ ## Local development
300
233
 
301
234
  ```bash
302
- npm install git+https://github.com/your-org/brv-text-editor.git
303
- # or SSH:
304
- npm install git+ssh://git@github.com/your-org/brv-text-editor.git
305
- ```
306
-
307
- **Important:** The `dist/` folder must be committed to the repo for this to work, because npm won't run `build:lib` automatically on install.
235
+ # Start the demo app
236
+ npm run dev
308
237
 
309
- ```bash
310
- # Before pushing for the first time (and after each release):
238
+ # Build the distributable library
311
239
  npm run build:lib
312
- git add dist/
313
- git commit -m "chore: rebuild dist for v1.0.x"
314
- git push
315
- ```
316
-
317
- To pin to a specific version, use a tag:
318
-
319
- ```bash
320
- # Tag a release
321
- git tag v1.0.1
322
- git push origin v1.0.1
323
-
324
- # Install that exact tag
325
- npm install git+https://github.com/your-org/brv-text-editor.git#v1.0.1
326
- ```
327
-
328
- ---
329
-
330
- ## Local development / testing the library
331
-
332
- ```bash
333
- # In this repo — build the library and create a local link
334
- npm run build:lib
335
- npm link
336
-
337
- # In your consumer app's folder
338
- npm link brv-text-editor # or @your-org/brv-text-editor
339
- ```
340
-
341
- Or use `npm pack` to simulate exactly what gets published:
342
-
343
- ```bash
344
- npm pack
345
- # → brv-text-editor-1.0.0.tgz
346
-
347
- # In your consumer app:
348
- npm install /path/to/brv-text-editor-1.0.0.tgz
349
240
  ```
350
241
 
351
242
  ---
@@ -354,16 +245,18 @@ npm install /path/to/brv-text-editor-1.0.0.tgz
354
245
 
355
246
  ```
356
247
  rich-text-editor/
357
- ├── dist/ ← Library output (git-ignored for private registry flow)
248
+ ├── dist/ ← Library output
358
249
  │ ├── brv-text-editor.es.js ← ES module bundle
359
250
  │ ├── brv-text-editor.umd.js ← UMD/CJS bundle
360
251
  │ └── brv-text-editor.css ← Extracted stylesheet
361
252
  ├── src/
362
253
  │ ├── index.js ← Library entry (exports both components)
363
- │ ├── index.css ← All styles (ProseMirror + preview)
254
+ │ ├── index.css ← All styles (editor + preview)
364
255
  │ ├── components/
365
256
  │ │ ├── RichTextEditor.jsx ← Editor component
366
257
  │ │ └── RichTextPreview.jsx ← Preview card component
258
+ │ ├── extensions/
259
+ │ │ └── Callout.js ← Custom callout block extension
367
260
  │ ├── App.jsx ← Demo application
368
261
  │ └── main.jsx ← Demo entry point
369
262
  ├── vite.config.js ← Demo app Vite config
@@ -379,11 +272,11 @@ rich-text-editor/
379
272
  |---|---|
380
273
  | `npm run dev` | Start the demo app dev server |
381
274
  | `npm run build` | Build the demo app |
382
- | `npm run build:lib` | Build the distributable library `dist/` |
275
+ | `npm run build:lib` | Build the distributable library into `dist/` |
383
276
  | `npm run preview` | Preview the built demo app |
384
277
 
385
278
  ---
386
279
 
387
280
  ## License
388
281
 
389
- MIT
282
+ MIT — [Brevitaz Systems](https://brevitaz.com)
@@ -1,15 +1,11 @@
1
- *, *::before, *::after {
1
+ /* Scoped reset — only affects the editor component, not the host application */
2
+ .rte-root,
3
+ .rte-root *,
4
+ .rte-root *::before,
5
+ .rte-root *::after {
2
6
  box-sizing: border-box;
3
7
  }
4
8
 
5
- body {
6
- margin: 0;
7
- font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
8
- background: #f0f4f8;
9
- color: #1a202c;
10
- -webkit-font-smoothing: antialiased;
11
- }
12
-
13
9
  /* ─── Design Tokens ─────────────────────────────────────────────────────────
14
10
  *
15
11
  * All visual values in RichTextEditor and RichTextPreview are driven by these
@@ -26,7 +22,7 @@ body {
26
22
  *
27
23
  * ─────────────────────────────────────────────────────────────────────────── */
28
24
 
29
- /* Default theme — UnleashTeams teal/cyan palette */
25
+ /* Default theme — Teal palette */
30
26
  .rte-root {
31
27
  /* ── Brand ───────────────────────────────────────────── */
32
28
  --rte-color-primary: #065666; /* primary CTA / active icon color */
@@ -86,7 +82,7 @@ body {
86
82
  }
87
83
 
88
84
 
89
- /* ─── Classic theme preset (warm Basecamp-inspired palette) ─────────────── */
85
+ /* ─── Classic theme preset (warm earthy palette) ─────────────────────────── */
90
86
  .rte-root[data-rte-theme="classic"] {
91
87
  --rte-color-primary: #1a6b3c;
92
88
  --rte-color-primary-hover: #f0fdf4;