smartrte-react 1.0.0-beta.5 → 1.0.0-beta.8
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/CHANGELOG.md +15 -0
- package/README.md +94 -0
- package/dist/components/CanonicalAuthorityEditor.d.ts +15 -1
- package/dist/components/CanonicalAuthorityEditor.js +198 -46
- package/dist/components/MediaDetailsPopover.d.ts +35 -0
- package/dist/components/MediaDetailsPopover.js +136 -0
- package/dist/components/MediaOverlay.d.ts +10 -21
- package/dist/components/MediaOverlay.js +128 -63
- package/dist/components/ToolbarPrimitives.d.ts +14 -0
- package/dist/components/ToolbarPrimitives.js +45 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/standalone/classic-editor-embed.js +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +6 -2
- package/dist/toolbarTools.d.ts +89 -0
- package/dist/toolbarTools.js +16 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.8
|
|
4
|
+
|
|
5
|
+
- Add a `tools` prop (`ClassicEditor`, `CanonicalAuthorityEditor`, and the standalone embed) letting a host hide any individual toolbar tool — Bold, Video, Version history, Review, and around 40 others — without wrapping or restyling the component. Every tool is visible by default; composes with existing gates (a required provider or capability must still be present). See the README's "Hiding individual toolbar tools" section for the full list and usage.
|
|
6
|
+
- Retire the never-shipped `showVersionHistory`/`showReview` props in favor of `tools.versionHistory`/`tools.comments`/`tools.suggestions`.
|
|
7
|
+
- Also export `EditorCapabilityPreset` from the package's public entry point (previously only reachable indirectly through `CanonicalAuthorityEditorProps`).
|
|
8
|
+
|
|
9
|
+
## 1.0.0-beta.7
|
|
10
|
+
|
|
11
|
+
- Fix the mobile "More tools" overflow menu getting clipped almost entirely off-screen when the editor is embedded inside a host container with `overflow: hidden` — the same fix already applied to the desktop toolbar dropdowns, now also covering this menu (the only overflow affordance on narrow viewports).
|
|
12
|
+
- Add the "List preset" control (decimal/lower-alpha/upper-alpha/roman-numeral/outline numbering styles, plus bullet-glyph presets) to the mobile "More tools" menu — previously only reachable from the desktop toolbar's "More list tools" dropdown, leaving narrow-viewport users with no way to use anything beyond plain bulleted/numbered/checklist lists.
|
|
13
|
+
|
|
14
|
+
## 1.0.0-beta.6
|
|
15
|
+
|
|
16
|
+
- Replace the media Edit overlay's plain alt-text prompt with a full "Media details" panel: link (with open-in-new-tab), corner radius, alignment, and license fields (description, source URL, type, version, attribution), matching the pre-canonical editor's own edit-panel field set. A library-picked image's existing license metadata is now carried onto the inserted atom instead of being discarded. Depends on `smartrte-core@1.0.0-beta.3`.
|
|
17
|
+
|
|
3
18
|
## 1.0.0-beta.5
|
|
4
19
|
|
|
5
20
|
- Add an opt-in `renderFormulaHtml` prop (on `ClassicEditor`/`CanonicalAuthorityEditor`) that bakes real KaTeX-rendered HTML into the formula elements of `onChange`'s exported HTML, instead of an empty placeholder — for hosts that display saved content directly (e.g. a read-only preview panel) without also running KaTeX against it. Depends on `smartrte-core@1.0.0-beta.2`.
|
package/README.md
CHANGED
|
@@ -96,6 +96,7 @@ export default App;
|
|
|
96
96
|
| `defaultFont` | `string` | `undefined` | Default font family for the editor content |
|
|
97
97
|
| `theme` | `"light" \| "dark"` | `"light"` | Built-in theme mode |
|
|
98
98
|
| `className` | `string` | `undefined` | Custom CSS class for theming via CSS variable overrides |
|
|
99
|
+
| `tools` | `Partial<ToolbarTools>` | every tool `true` | Hide individual toolbar tools (Bold, Video, Version history, etc.) — see [Hiding individual toolbar tools](#hiding-individual-toolbar-tools) below |
|
|
99
100
|
|
|
100
101
|
### Advanced Examples
|
|
101
102
|
|
|
@@ -118,6 +119,99 @@ import { ClassicEditor } from 'smartrte-react';
|
|
|
118
119
|
/>
|
|
119
120
|
```
|
|
120
121
|
|
|
122
|
+
#### Hiding individual toolbar tools
|
|
123
|
+
|
|
124
|
+
The `table`/`media`/`formula` props above turn off a whole *capability* — no
|
|
125
|
+
tables anywhere, or media/formulas removed from the schema entirely. If you
|
|
126
|
+
just want a **smaller toolbar** while keeping every capability intact (e.g.
|
|
127
|
+
hide Video, Audio, Version history, and Review for a specific product
|
|
128
|
+
surface, without touching what content the editor can actually store), use
|
|
129
|
+
`tools` instead. It's a plain object: name the tools you want off, everything
|
|
130
|
+
else stays on by default. No wrapping, no CSS overrides, no forking the
|
|
131
|
+
component.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { ClassicEditor } from 'smartrte-react';
|
|
135
|
+
|
|
136
|
+
<ClassicEditor
|
|
137
|
+
tools={{
|
|
138
|
+
video: false,
|
|
139
|
+
audio: false,
|
|
140
|
+
versionHistory: false,
|
|
141
|
+
comments: false,
|
|
142
|
+
suggestions: false,
|
|
143
|
+
}}
|
|
144
|
+
/>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**How it composes with everything else:** a tool only ever needs *both*
|
|
148
|
+
things to be true to show up — your `tools` flag says yes, *and* whatever
|
|
149
|
+
that tool actually depends on is present. So:
|
|
150
|
+
|
|
151
|
+
- `tools.video`/`tools.audio`/`tools.image` also need a `mediaProvider` (or
|
|
152
|
+
`mediaManager`) to be configured at all — turning the flag on can't make
|
|
153
|
+
media insertion appear out of nowhere if you never wired up a provider.
|
|
154
|
+
- `tools.versionHistory` also needs a `versionProvider`; `tools.comments`
|
|
155
|
+
needs a `commentProvider`; `tools.suggestions` needs a `suggestionProvider`.
|
|
156
|
+
- `tools.insertTable` also needs the table capability to actually be enabled
|
|
157
|
+
(i.e. you haven't set `table={false}`) — you can't use `tools` to bring
|
|
158
|
+
back a capability you turned off elsewhere.
|
|
159
|
+
|
|
160
|
+
In other words: `tools` can only ever hide something, never force something
|
|
161
|
+
into existence that isn't otherwise configured. This means it's always safe
|
|
162
|
+
to leave `tools` unset — every consumer who doesn't pass it sees the exact
|
|
163
|
+
toolbar they see today.
|
|
164
|
+
|
|
165
|
+
**Every toggleable key**, grouped the way they appear in the toolbar:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
interface ToolbarTools {
|
|
169
|
+
// Text formatting
|
|
170
|
+
bold, italic, underline, strikethrough, code,
|
|
171
|
+
superscript, subscript, textColor, backgroundColor, fontSize, fontFamily,
|
|
172
|
+
|
|
173
|
+
// Paragraph
|
|
174
|
+
blockType, // the Paragraph/Heading/Code block dropdown
|
|
175
|
+
alignLeft, alignCenter, alignRight, alignJustify, quote,
|
|
176
|
+
|
|
177
|
+
// Lists
|
|
178
|
+
bulletedList, numberedList, checklist,
|
|
179
|
+
listPreset, // the numbered-list style picker (1,2,3 / a,b,c / i,ii,iii / A,B,C / I,II,III)
|
|
180
|
+
|
|
181
|
+
// Insert
|
|
182
|
+
link, removeLink, image, video, audio, insertFormula, specialCharacters, insertTable,
|
|
183
|
+
|
|
184
|
+
// Document
|
|
185
|
+
import,
|
|
186
|
+
saveAsHtml, saveAsMarkdown, saveAsWord, saveAsPdf, saveAsSmartRte,
|
|
187
|
+
versionHistory, comments, suggestions,
|
|
188
|
+
|
|
189
|
+
// History
|
|
190
|
+
undo, redo,
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
A few notes on what's *not* in this list, on purpose: actions that only ever
|
|
195
|
+
apply to something you already have selected — moving a block up/down,
|
|
196
|
+
indenting a list item, adding/removing a table row or column, resizing a
|
|
197
|
+
selected image — aren't individually toggleable. They only make sense as
|
|
198
|
+
part of using the tool that created them (a table, a list, an image), so
|
|
199
|
+
they follow that tool's own visibility rather than needing a separate flag
|
|
200
|
+
each. If you turn off `insertTable`, its row/column tools go with it
|
|
201
|
+
automatically — there's no separate flag to remember.
|
|
202
|
+
|
|
203
|
+
If you're using the exported `CanonicalAuthorityEditor` directly instead of
|
|
204
|
+
`ClassicEditor`, `tools` works exactly the same way. And if you're using the
|
|
205
|
+
standalone embed (`window.SmartRTE.ClassicEditor.init(...)`), pass `tools`
|
|
206
|
+
in the same options object you pass `target`/`value`/etc.
|
|
207
|
+
|
|
208
|
+
```ts
|
|
209
|
+
window.SmartRTE.ClassicEditor.init({
|
|
210
|
+
target: document.getElementById('editor'),
|
|
211
|
+
tools: { video: false, audio: false },
|
|
212
|
+
});
|
|
213
|
+
```
|
|
214
|
+
|
|
121
215
|
#### Complete Example with All Features
|
|
122
216
|
|
|
123
217
|
```tsx
|
|
@@ -6,6 +6,7 @@ import type { CommentProvider } from "../commentProvider.js";
|
|
|
6
6
|
import type { SuggestionProvider } from "../suggestionProvider.js";
|
|
7
7
|
import { type MediaPickerComponent } from "./MediaPicker.js";
|
|
8
8
|
import type { EditorCapabilityPreset } from "../capabilityPresets.js";
|
|
9
|
+
import { type ToolbarTools } from "../toolbarTools.js";
|
|
9
10
|
import { CanonicalEditorRuntime, type SmartEditorChange, type SmartEditorHandle } from "../canonicalEditorRuntime.js";
|
|
10
11
|
export interface CanonicalAuthorityEditorProps {
|
|
11
12
|
/** Initial value only. Later replacements must use SmartEditorHandle.replaceValue. */
|
|
@@ -42,7 +43,20 @@ export interface CanonicalAuthorityEditorProps {
|
|
|
42
43
|
* for images too.
|
|
43
44
|
*/
|
|
44
45
|
mediaManager?: boolean;
|
|
45
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Per-tool toolbar visibility - "developers should be able to hide tools
|
|
48
|
+
* which are not for their use" (docs/bugs/per-tool-toolbar-visibility.md).
|
|
49
|
+
* Every tool defaults to visible; a host only needs to name the ones they
|
|
50
|
+
* want off (`tools={{ video: false, versionHistory: false }}`). Composes
|
|
51
|
+
* with, never overrides, the deeper existing gates: a tool whose required
|
|
52
|
+
* provider is absent (`versionProvider`/`commentProvider`/
|
|
53
|
+
* `suggestionProvider`/`mediaProvider`) or whose plugin was excluded via
|
|
54
|
+
* `preset` (e.g. `insertTable` under `preset="simple"`) still won't
|
|
55
|
+
* render even if explicitly set to `true` here - see ToolbarTools.ts's
|
|
56
|
+
* own doc comment for the full contract and scoping decisions.
|
|
57
|
+
*/
|
|
58
|
+
tools?: Partial<ToolbarTools>;
|
|
59
|
+
/** Host-owned save/list/load/remove boundary for document version history. */
|
|
46
60
|
versionProvider?: VersionProvider;
|
|
47
61
|
/** Host-owned save/list/remove boundary for comment threads. Absent hides the comment toolbar buttons and markers entirely, mirroring versionProvider's absent-disables-the-feature contract. */
|
|
48
62
|
commentProvider?: CommentProvider;
|