smartrte-react 1.0.0-beta.4 → 1.0.0-beta.5
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
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.5
|
|
4
|
+
|
|
5
|
+
- 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`.
|
|
6
|
+
|
|
3
7
|
## 1.0.0-beta.4
|
|
4
8
|
|
|
5
9
|
- 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.
|
|
@@ -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
|
|
@@ -22,6 +22,13 @@ export interface CanonicalAuthorityEditorProps {
|
|
|
22
22
|
onChange?: (change: SmartEditorChange) => void;
|
|
23
23
|
/** Transitional serialization callback for hosts that still persist HTML. */
|
|
24
24
|
onHtmlChange?: (html: string) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Bakes real KaTeX-rendered HTML into onHtmlChange's formula elements
|
|
27
|
+
* instead of leaving them as empty placeholders - see
|
|
28
|
+
* canonicalEditorRuntime.ts's CanonicalEditorRuntimeOptions for the full
|
|
29
|
+
* rationale. Construction-time only, same contract as `preset`.
|
|
30
|
+
*/
|
|
31
|
+
renderFormulaHtml?: boolean;
|
|
25
32
|
onClipboardDiagnostic?: (report: ClipboardDiagnosticReport) => void;
|
|
26
33
|
/** Host-owned upload/search/remove boundary for canonical media insertion. */
|
|
27
34
|
mediaProvider?: MediaProvider;
|
|
@@ -102,7 +102,7 @@ const parseBorderShorthand = (value) => {
|
|
|
102
102
|
const isCollapsedTextSelection = (selection) => selection.type === "text" && selection.anchor.offset === selection.head.offset
|
|
103
103
|
&& selection.anchor.path.length === selection.head.path.length
|
|
104
104
|
&& selection.anchor.path.every((part, index) => part === selection.head.path[index]);
|
|
105
|
-
export const CanonicalAuthorityEditor = forwardRef(function CanonicalAuthorityEditor({ defaultValue, preset, onChange, onHtmlChange, onClipboardDiagnostic, mediaProvider, mediaPicker: MediaPicker = DefaultMediaPicker, mediaManager = true, versionProvider, commentProvider, suggestionProvider, authorId, placeholder = "Type here…", minHeight = 200, maxHeight = 500, readOnly = false, className, onRuntime, }, forwardedRef) {
|
|
105
|
+
export const CanonicalAuthorityEditor = forwardRef(function CanonicalAuthorityEditor({ defaultValue, preset, renderFormulaHtml, onChange, onHtmlChange, onClipboardDiagnostic, mediaProvider, mediaPicker: MediaPicker = DefaultMediaPicker, mediaManager = true, versionProvider, commentProvider, suggestionProvider, authorId, placeholder = "Type here…", minHeight = 200, maxHeight = 500, readOnly = false, className, onRuntime, }, forwardedRef) {
|
|
106
106
|
ensureStyleSheet();
|
|
107
107
|
const rootRef = useRef(null);
|
|
108
108
|
const importRef = useRef(null);
|
|
@@ -147,7 +147,7 @@ export const CanonicalAuthorityEditor = forwardRef(function CanonicalAuthorityEd
|
|
|
147
147
|
// selection.head differs from this value.
|
|
148
148
|
const [linkOverlayDismissedAt, setLinkOverlayDismissedAt] = useState(null);
|
|
149
149
|
if (!runtimeRef.current)
|
|
150
|
-
runtimeRef.current = new CanonicalEditorRuntime({ initialValue: defaultValue, preset, onChange, onHtmlChange, onClipboardDiagnostic });
|
|
150
|
+
runtimeRef.current = new CanonicalEditorRuntime({ initialValue: defaultValue, preset, renderFormulaHtml, onChange, onHtmlChange, onClipboardDiagnostic });
|
|
151
151
|
const runtime = runtimeRef.current;
|
|
152
152
|
const [, setEditorTick] = useState(0);
|
|
153
153
|
runtime.setCallbacks(onChange, onHtmlChange);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smartrte-react",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.5",
|
|
4
4
|
"description": "A powerful, feature-rich Rich Text Editor for React with support for tables, mathematical formulas (LaTeX/KaTeX), and media management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"lucide-react": "^1.35.0",
|
|
85
85
|
"mammoth": "^1.11.0",
|
|
86
86
|
"pdfjs-dist": "^5.4.530",
|
|
87
|
-
"smartrte-core": "^1.0.0-beta.
|
|
87
|
+
"smartrte-core": "^1.0.0-beta.2"
|
|
88
88
|
},
|
|
89
89
|
"scripts": {
|
|
90
90
|
"build": "rm -rf dist && tsc -p tsconfig.json",
|