@gilav21/shadcn-angular-rte 0.1.1

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 ADDED
@@ -0,0 +1,176 @@
1
+ # @gilav21/shadcn-angular-rte
2
+
3
+ The shadcn-angular rich-text editor, compiled and published as a normal npm
4
+ package: the base editor plus all 13 addons (`RTE_FULL`).
5
+
6
+ Same `ui-*` selectors, the same inputs and the same behaviour as the CLI copy
7
+ model — but nothing lands in your source tree, and `npm update` brings the
8
+ fixes.
9
+
10
+ ## Requirements
11
+
12
+ - **Angular 20 or 21** (peer `>=20.0.0 <22.0.0`). Both majors are covered by
13
+ the e2e suite, which installs this package's real tarball into a pristine
14
+ Angular 20 app and a pristine Angular 21 app and builds both.
15
+ - **Tailwind CSS v4**.
16
+ - Works in zoneless apps.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @gilav21/shadcn-angular-rte
22
+ npm install -D tailwindcss @tailwindcss/postcss postcss
23
+ ```
24
+
25
+ If you do not already have Tailwind wired up, add `.postcssrc.json`:
26
+
27
+ ```json
28
+ { "plugins": { "@tailwindcss/postcss": {} } }
29
+ ```
30
+
31
+ ## Styles
32
+
33
+ Add these three lines to your global stylesheet:
34
+
35
+ ```css
36
+ @import "tailwindcss";
37
+ @source "../node_modules/@gilav21/shadcn-angular-rte";
38
+ @import "@gilav21/shadcn-angular-rte/theme.css";
39
+ ```
40
+
41
+ - The `@source` line is **required**. Tailwind v4 does not scan `node_modules`
42
+ by default, so without it none of the editor's utility classes are generated
43
+ and the editor renders unstyled.
44
+ - The `theme.css` import ships the design tokens (`:root` / `.dark` custom
45
+ properties, `@theme inline`, base layer). **Skip it if your app is already
46
+ CLI-initialised** (`npx shadcn-angular init` wrote the same tokens into your
47
+ own stylesheet, and importing both duplicates the `:root` block).
48
+
49
+ ## Usage
50
+
51
+ ### Simple — everything on
52
+
53
+ ```ts
54
+ import { Component, signal } from '@angular/core';
55
+ import { FormsModule } from '@angular/forms';
56
+ import { RichTextEditorComponent, RTE_FULL } from '@gilav21/shadcn-angular-rte';
57
+
58
+ @Component({
59
+ selector: 'app-root',
60
+ imports: [FormsModule, RichTextEditorComponent, RTE_FULL],
61
+ template: `<ui-rich-text-editor uiRteFull mode="html" [(ngModel)]="html" />`,
62
+ })
63
+ export class AppComponent {
64
+ html = signal('<p>Hello</p>');
65
+ }
66
+ ```
67
+
68
+ ### Custom — pick the addons you want
69
+
70
+ ```ts
71
+ import {
72
+ RichTextEditorComponent,
73
+ RichTextMentionsDirective,
74
+ RichTextActionsDirective,
75
+ type MentionItem,
76
+ type RichTextEntitySearchFn,
77
+ type RichTextActionDefinition,
78
+ } from '@gilav21/shadcn-angular-rte';
79
+
80
+ @Component({
81
+ imports: [RichTextEditorComponent, RichTextMentionsDirective, RichTextActionsDirective],
82
+ template: `
83
+ <ui-rich-text-editor
84
+ uiRteMentions [uiRteMentionsSearch]="search"
85
+ uiRteActions [uiRteActions]="actions"
86
+ locale="he" />
87
+ `,
88
+ })
89
+ export class DocComponent {
90
+ readonly search: RichTextEntitySearchFn<MentionItem> =
91
+ q => [{ id: '1', value: 'ann', label: `Ann ${q}` }];
92
+ readonly actions: RichTextActionDefinition[] = [/* … */];
93
+ }
94
+ ```
95
+
96
+ ## Addons
97
+
98
+ `RTE_FULL` turns on all 13. To pick individually, import the directive and add
99
+ its attribute to `<ui-rich-text-editor>`:
100
+
101
+ | Directive | Attribute |
102
+ |---|---|
103
+ | `RichTextActionsDirective` | `uiRteActions` |
104
+ | `RichTextAiDirective` | `uiRteAi` |
105
+ | `RichTextColorsDirective` | `uiRteColors` |
106
+ | `RichTextEmojiDirective` | `uiRteEmoji` |
107
+ | `RichTextFileImportDirective` | `uiRteFileImport` |
108
+ | `RichTextHistoryDirective` | `uiRteHistory` |
109
+ | `RichTextImagesDirective` | `uiRteImages` |
110
+ | `RichTextLinksDirective` | `uiRteLinks` |
111
+ | `RichTextMentionsDirective` | `uiRteMentions` |
112
+ | `RichTextOutlineDirective` | `uiRteOutline` |
113
+ | `RichTextSlashCommandsDirective` | `uiRteSlashCommands` |
114
+ | `RichTextTablesDirective` | `uiRteTables` |
115
+ | `RichTextTypographyDirective` | `uiRteTypography` |
116
+
117
+ The document parsers behind `uiRteFileImport` (PDF, DOCX) are **lazy** — they
118
+ download only when a user actually imports a file.
119
+
120
+ ## Locale, RTL and density
121
+
122
+ `[locale]` is set per editor instance (`locale="he"`), and RTL follows the
123
+ document direction. Density is driven by the CSS custom properties in
124
+ `theme.css`; override `--density` (or `--density-rich-text-editor`) in your own
125
+ stylesheet to scale spacing.
126
+
127
+ ## Selectors are fixed
128
+
129
+ The CLI's `--prefix` flag has no equivalent here. Compiled components carry the
130
+ selectors they were built with, so the tags are always `ui-*` and the addon
131
+ attributes always `uiRte*`.
132
+
133
+ ## Configuration is inputs-only
134
+
135
+ There is no provider or injection-token configuration API. Everything is
136
+ configured through component inputs — the same as the copy model.
137
+
138
+ ## Mixing with CLI-copied components
139
+
140
+ You can use this package and CLI-copied components in the same app. Selectors
141
+ coexist, and both render fine.
142
+
143
+ One thing to know: the package carries **its own** singletons. A
144
+ `ShortcutBindingService`, i18n token or `AddonSlotRegistry` instance from your
145
+ copied `src/components/ui/**` is *not* the same instance the package's editor
146
+ uses. In practice:
147
+
148
+ - A shortcut registered on the copied service is invisible to the package
149
+ editor, and vice versa.
150
+ - `[locale]` must be set on the package editor itself; setting it on a copied
151
+ component does not carry over.
152
+
153
+ ## Troubleshooting
154
+
155
+ **Nothing is styled.** The `@source` line is missing or points at the wrong
156
+ path. It must resolve, from the stylesheet's own location, to this package
157
+ inside `node_modules`.
158
+
159
+ **Colours are missing / everything is transparent.** `theme.css` was not
160
+ imported and your app has no shadcn token block of its own. Add the third CSS
161
+ line.
162
+
163
+ **`npm install` fails with a peer error on `@angular/core`.** This package
164
+ supports Angular 20 and 21. On Angular 19 or older, use the CLI copy model
165
+ instead — `npx shadcn-angular add rich-text-editor/full`.
166
+
167
+ ## Versioning
168
+
169
+ This package versions independently of the `shadcn-angular` CLI. A component fix
170
+ reaches CLI users when it lands on `master`, but reaches package users only in
171
+ the next package release. Angular major upgrades require a rebuild and a new
172
+ major.
173
+
174
+ ## License
175
+
176
+ MIT