smartrte-react 1.0.0-beta.1 → 1.0.0-beta.10
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 +45 -0
- package/README.md +99 -0
- package/dist/canonicalEditorRuntime.d.ts +12 -0
- package/dist/canonicalEditorRuntime.js +2 -1
- package/dist/components/CanonicalAuthorityEditor.d.ts +22 -1
- package/dist/components/CanonicalAuthorityEditor.js +271 -57
- package/dist/components/ColorPickerPopover.js +3 -1
- package/dist/components/MediaDetailsPopover.d.ts +35 -0
- package/dist/components/MediaDetailsPopover.js +136 -0
- package/dist/components/MediaManager.js +5 -5
- package/dist/components/MediaOverlay.d.ts +12 -21
- package/dist/components/MediaOverlay.js +129 -64
- package/dist/components/TableBorderPopover.js +3 -1
- package/dist/components/TableResizeHandles.js +22 -0
- package/dist/components/ToolbarPrimitives.d.ts +32 -0
- package/dist/components/ToolbarPrimitives.js +95 -4
- package/dist/components/fixedPositioning.d.ts +25 -0
- package/dist/components/fixedPositioning.js +42 -0
- 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 +90 -33
- package/dist/toolbarTools.d.ts +95 -0
- package/dist/toolbarTools.js +17 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.10
|
|
4
|
+
|
|
5
|
+
- Fix a table row resize regression: dragging a row boundary back to where it started (after an earlier drag hit a row's natural content floor) inflated the neighboring row instead of restoring the original layout — the only way back was Undo. Reversing a boundary drag now correctly shrinks the table's total height instead of growing a neighbor that never actually had slack to give.
|
|
6
|
+
|
|
7
|
+
- Fix a horizontal line/page break appearing to be "not selectable": clicking one already set real node selection, but right-clicking showed no UI at all, unlike every other atom (image/video/audio/formula). Right-click now shows the same Delete-only action menu formula already gets (never Edit — neither atom has an editable field, and neither ever gets resize handles).
|
|
8
|
+
- Add a "Line spacing" toolbar dropdown (Paragraph group) with presets (1, 1.15, 1.5, 2, 2.5), a "Default" entry that clears the override, and a custom numeric value entry, matching Google Docs' own line-spacing picker shape. Shows a checkmark on the current value, or no checkmark at all when the selection spans blocks with differing values. New `tools.lineHeight` visibility flag (default visible). Depends on `smartrte-core@1.0.0-beta.5`.
|
|
9
|
+
- Add "Horizontal line" and "Page break" toolbar tools (in the "More to insert" group, plus wide-viewport-promoted standalone copies), and matching `tools.horizontalLine`/`tools.pageBreak` visibility flags. A page break renders as a dashed, labeled marker in the live editor — distinct from a horizontal line — and produces real pagination in both the exported HTML and this package's "Save as PDF" (a real browser print of that same HTML). Depends on `smartrte-core@1.0.0-beta.5`.
|
|
10
|
+
- Fix formulas rendering invisible in "Save as PDF" output (see `smartrte-core@1.0.0-beta.5`'s own changelog entry for the root cause).
|
|
11
|
+
- Rename the "Save as PDF" toolbar entry to "Print / Save as PDF" — it opens the browser's print dialog rather than triggering a direct file download like its "Save as ..." siblings; the new label sets the correct expectation instead of implying a one-click download.
|
|
12
|
+
|
|
13
|
+
## 1.0.0-beta.9
|
|
14
|
+
|
|
15
|
+
- Fix toolbar dropdowns, the mobile "More tools" kebab menu, and the text/background colour and table-border popovers rendering far from their own trigger when the editor is embedded inside a host container that has its own CSS `transform` on an ancestor - e.g. a Radix/shadcn `Dialog`'s own centering transform. These overlays now correctly account for the resulting change of containing block instead of assuming it's always the viewport.
|
|
16
|
+
|
|
17
|
+
## 1.0.0-beta.8
|
|
18
|
+
|
|
19
|
+
- 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.
|
|
20
|
+
- Retire the never-shipped `showVersionHistory`/`showReview` props in favor of `tools.versionHistory`/`tools.comments`/`tools.suggestions`.
|
|
21
|
+
- Also export `EditorCapabilityPreset` from the package's public entry point (previously only reachable indirectly through `CanonicalAuthorityEditorProps`).
|
|
22
|
+
|
|
23
|
+
## 1.0.0-beta.7
|
|
24
|
+
|
|
25
|
+
- 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).
|
|
26
|
+
- 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.
|
|
27
|
+
|
|
28
|
+
## 1.0.0-beta.6
|
|
29
|
+
|
|
30
|
+
- 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`.
|
|
31
|
+
|
|
32
|
+
## 1.0.0-beta.5
|
|
33
|
+
|
|
34
|
+
- 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`.
|
|
35
|
+
|
|
36
|
+
## 1.0.0-beta.4
|
|
37
|
+
|
|
38
|
+
- Fix blockquote, table header, and dialog (media library, comments, suggestions, version history) backgrounds/text staying in their light-mode colors even when the host page is in dark mode — these now follow the host's own dark-mode CSS variables directly, the same way the rest of the editor's colors already did, instead of depending solely on the `.srte-dark` class reaching the editor correctly.
|
|
39
|
+
|
|
40
|
+
## 1.0.0-beta.3
|
|
41
|
+
|
|
42
|
+
- Fix toolbar dropdown menus (e.g. "More text styles", "More paragraph tools") getting visually clipped to unusable fragments when the editor is embedded inside a host container with `overflow: hidden` (e.g. a rounded card or a clipped split-pane panel) — the menu now positions itself relative to the viewport instead of the nearest ancestor, so it can never be clipped regardless of host layout.
|
|
43
|
+
|
|
44
|
+
## 1.0.0-beta.2
|
|
45
|
+
|
|
46
|
+
- Fix the toolbar promoting extra buttons based on the browser window's width instead of the editor's own rendered width — broke embedding the editor in a split pane or any container narrower than the window, causing overlapping/mashed toolbar labels and misdirected clicks that looked like an unresponsive toolbar.
|
|
47
|
+
|
|
3
48
|
## 1.0.0-beta.1
|
|
4
49
|
|
|
5
50
|
**BREAKING CHANGE.** `ClassicEditor` is now unconditionally the canonical, schema-driven editor (`CanonicalAuthorityEditor` underneath). The DOM-authoritative legacy editor and its rollback path have been fully removed; every published version through 0.3.4 defaulted to the DOM-authoritative implementation, so this changes real runtime behavior for every existing consumer, not just internals.
|
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,104 @@ 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,
|
|
176
|
+
lineHeight, // the line-spacing dropdown (1/1.15/1.5/2/2.5 presets plus a custom value)
|
|
177
|
+
quote,
|
|
178
|
+
|
|
179
|
+
// Lists
|
|
180
|
+
bulletedList, numberedList, checklist,
|
|
181
|
+
listPreset, // the numbered-list style picker (1,2,3 / a,b,c / i,ii,iii / A,B,C / I,II,III)
|
|
182
|
+
|
|
183
|
+
// Insert
|
|
184
|
+
link, removeLink, image, video, audio, insertFormula, specialCharacters,
|
|
185
|
+
horizontalLine, // inserts a divider (<hr>)
|
|
186
|
+
pageBreak, // inserts a print/export pagination marker - distinct from horizontalLine
|
|
187
|
+
insertTable,
|
|
188
|
+
|
|
189
|
+
// Document
|
|
190
|
+
import,
|
|
191
|
+
saveAsHtml, saveAsMarkdown, saveAsWord, saveAsPdf, saveAsSmartRte,
|
|
192
|
+
versionHistory, comments, suggestions,
|
|
193
|
+
|
|
194
|
+
// History
|
|
195
|
+
undo, redo,
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
A few notes on what's *not* in this list, on purpose: actions that only ever
|
|
200
|
+
apply to something you already have selected — moving a block up/down,
|
|
201
|
+
indenting a list item, adding/removing a table row or column, resizing a
|
|
202
|
+
selected image — aren't individually toggleable. They only make sense as
|
|
203
|
+
part of using the tool that created them (a table, a list, an image), so
|
|
204
|
+
they follow that tool's own visibility rather than needing a separate flag
|
|
205
|
+
each. If you turn off `insertTable`, its row/column tools go with it
|
|
206
|
+
automatically — there's no separate flag to remember.
|
|
207
|
+
|
|
208
|
+
If you're using the exported `CanonicalAuthorityEditor` directly instead of
|
|
209
|
+
`ClassicEditor`, `tools` works exactly the same way. And if you're using the
|
|
210
|
+
standalone embed (`window.SmartRTE.ClassicEditor.init(...)`), pass `tools`
|
|
211
|
+
in the same options object you pass `target`/`value`/etc.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
window.SmartRTE.ClassicEditor.init({
|
|
215
|
+
target: document.getElementById('editor'),
|
|
216
|
+
tools: { video: false, audio: false },
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
121
220
|
#### Complete Example with All Features
|
|
122
221
|
|
|
123
222
|
```tsx
|
|
@@ -57,6 +57,17 @@ export interface CanonicalEditorRuntimeOptions {
|
|
|
57
57
|
contentVisibility?: boolean;
|
|
58
58
|
/** Which built-in plugins this instance is constructed with - see capabilityPresets.ts. Defaults to "full" (every plugin), matching this runtime's only behavior before this option existed. */
|
|
59
59
|
preset?: EditorCapabilityPreset;
|
|
60
|
+
/**
|
|
61
|
+
* Bakes real KaTeX-rendered HTML into `onHtmlChange`'s formula elements
|
|
62
|
+
* instead of leaving them as empty placeholders (docs/bugs/
|
|
63
|
+
* formula-not-rendered-in-static-html-consumers.md). Off by default -
|
|
64
|
+
* the live editing surface already renders formulas correctly on its
|
|
65
|
+
* own via surface/renderer.ts's imperative katex.render() calls, which
|
|
66
|
+
* this option has no effect on; it exists purely for consumers that take
|
|
67
|
+
* this HTML string and display it *without* also running KaTeX against
|
|
68
|
+
* it themselves (e.g. a read-only preview panel built from saved HTML).
|
|
69
|
+
*/
|
|
70
|
+
renderFormulaHtml?: boolean;
|
|
60
71
|
}
|
|
61
72
|
/** Persistent, React-independent owner for one product editor instance. */
|
|
62
73
|
export declare class CanonicalEditorRuntime implements SmartEditorHandle {
|
|
@@ -70,6 +81,7 @@ export declare class CanonicalEditorRuntime implements SmartEditorHandle {
|
|
|
70
81
|
private onHtmlChange?;
|
|
71
82
|
private readonly onClipboardDiagnostic?;
|
|
72
83
|
private readonly contentVisibility;
|
|
84
|
+
private readonly renderFormulaHtml;
|
|
73
85
|
private htmlChangeTimer;
|
|
74
86
|
private pendingHtmlDocument;
|
|
75
87
|
constructor(options?: CanonicalEditorRuntimeOptions);
|
|
@@ -99,6 +99,7 @@ export class CanonicalEditorRuntime {
|
|
|
99
99
|
this.onHtmlChange = options.onHtmlChange;
|
|
100
100
|
this.onClipboardDiagnostic = options.onClipboardDiagnostic;
|
|
101
101
|
this.contentVisibility = options.contentVisibility === true;
|
|
102
|
+
this.renderFormulaHtml = options.renderFormulaHtml === true;
|
|
102
103
|
}
|
|
103
104
|
setCallbacks(onChange, onHtmlChange) {
|
|
104
105
|
this.onChange = onChange;
|
|
@@ -120,7 +121,7 @@ export class CanonicalEditorRuntime {
|
|
|
120
121
|
const pending = this.pendingHtmlDocument;
|
|
121
122
|
this.pendingHtmlDocument = null;
|
|
122
123
|
if (pending && this.onHtmlChange)
|
|
123
|
-
this.onHtmlChange(serializeCanonicalListHtml(pending, { clean: true }));
|
|
124
|
+
this.onHtmlChange(serializeCanonicalListHtml(pending, { clean: true, renderFormulaHtml: this.renderFormulaHtml }));
|
|
124
125
|
};
|
|
125
126
|
if (view) {
|
|
126
127
|
// Transitional HTML serialization is intentionally debounced outside the
|
|
@@ -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. */
|
|
@@ -22,6 +23,13 @@ export interface CanonicalAuthorityEditorProps {
|
|
|
22
23
|
onChange?: (change: SmartEditorChange) => void;
|
|
23
24
|
/** Transitional serialization callback for hosts that still persist HTML. */
|
|
24
25
|
onHtmlChange?: (html: string) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Bakes real KaTeX-rendered HTML into onHtmlChange's formula elements
|
|
28
|
+
* instead of leaving them as empty placeholders - see
|
|
29
|
+
* canonicalEditorRuntime.ts's CanonicalEditorRuntimeOptions for the full
|
|
30
|
+
* rationale. Construction-time only, same contract as `preset`.
|
|
31
|
+
*/
|
|
32
|
+
renderFormulaHtml?: boolean;
|
|
25
33
|
onClipboardDiagnostic?: (report: ClipboardDiagnosticReport) => void;
|
|
26
34
|
/** Host-owned upload/search/remove boundary for canonical media insertion. */
|
|
27
35
|
mediaProvider?: MediaProvider;
|
|
@@ -35,7 +43,20 @@ export interface CanonicalAuthorityEditorProps {
|
|
|
35
43
|
* for images too.
|
|
36
44
|
*/
|
|
37
45
|
mediaManager?: boolean;
|
|
38
|
-
/**
|
|
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. */
|
|
39
60
|
versionProvider?: VersionProvider;
|
|
40
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. */
|
|
41
62
|
commentProvider?: CommentProvider;
|