@particle-academy/react-fancy 4.9.0 → 4.10.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/dist/index.cjs +6 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2062,6 +2062,17 @@ interface EditorProps {
|
|
|
2062
2062
|
defaultValue?: string;
|
|
2063
2063
|
onChange?: (value: string) => void;
|
|
2064
2064
|
outputFormat?: "html" | "markdown";
|
|
2065
|
+
/**
|
|
2066
|
+
* The format of the INCOMING `value` / `defaultValue`. Default `"auto"`
|
|
2067
|
+
* keeps the historical sniff (`detectFormat`) — but real-world markdown that
|
|
2068
|
+
* merely mentions HTML-ish snippets (`<code>`, `<table`, …) flips the sniff
|
|
2069
|
+
* to html and renders as a wall of text. Callers with a KNOWN format
|
|
2070
|
+
* (file-typed content, values previously emitted with
|
|
2071
|
+
* `outputFormat="markdown"`) should declare it; explicit values bypass the
|
|
2072
|
+
* sniff entirely — in edit mode AND view mode.
|
|
2073
|
+
* @default "auto"
|
|
2074
|
+
*/
|
|
2075
|
+
valueFormat?: "markdown" | "html" | "auto";
|
|
2065
2076
|
lineSpacing?: number;
|
|
2066
2077
|
placeholder?: string;
|
|
2067
2078
|
/**
|
|
@@ -2099,7 +2110,7 @@ declare namespace EditorContent {
|
|
|
2099
2110
|
var displayName: string;
|
|
2100
2111
|
}
|
|
2101
2112
|
|
|
2102
|
-
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2113
|
+
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2103
2114
|
declare const Editor: typeof EditorRoot & {
|
|
2104
2115
|
Toolbar: typeof EditorToolbar & {
|
|
2105
2116
|
Separator: typeof EditorToolbarSeparator;
|
package/dist/index.d.ts
CHANGED
|
@@ -2062,6 +2062,17 @@ interface EditorProps {
|
|
|
2062
2062
|
defaultValue?: string;
|
|
2063
2063
|
onChange?: (value: string) => void;
|
|
2064
2064
|
outputFormat?: "html" | "markdown";
|
|
2065
|
+
/**
|
|
2066
|
+
* The format of the INCOMING `value` / `defaultValue`. Default `"auto"`
|
|
2067
|
+
* keeps the historical sniff (`detectFormat`) — but real-world markdown that
|
|
2068
|
+
* merely mentions HTML-ish snippets (`<code>`, `<table`, …) flips the sniff
|
|
2069
|
+
* to html and renders as a wall of text. Callers with a KNOWN format
|
|
2070
|
+
* (file-typed content, values previously emitted with
|
|
2071
|
+
* `outputFormat="markdown"`) should declare it; explicit values bypass the
|
|
2072
|
+
* sniff entirely — in edit mode AND view mode.
|
|
2073
|
+
* @default "auto"
|
|
2074
|
+
*/
|
|
2075
|
+
valueFormat?: "markdown" | "html" | "auto";
|
|
2065
2076
|
lineSpacing?: number;
|
|
2066
2077
|
placeholder?: string;
|
|
2067
2078
|
/**
|
|
@@ -2099,7 +2110,7 @@ declare namespace EditorContent {
|
|
|
2099
2110
|
var displayName: string;
|
|
2100
2111
|
}
|
|
2101
2112
|
|
|
2102
|
-
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2113
|
+
declare function EditorRoot({ children, className, value: controlledValue, defaultValue, onChange, outputFormat, valueFormat, lineSpacing, placeholder, mode: modeProp, extensions: instanceExtensions, unsafe, }: EditorProps): react.JSX.Element;
|
|
2103
2114
|
declare const Editor: typeof EditorRoot & {
|
|
2104
2115
|
Toolbar: typeof EditorToolbar & {
|
|
2105
2116
|
Separator: typeof EditorToolbarSeparator;
|
package/dist/index.js
CHANGED
|
@@ -11654,11 +11654,10 @@ function ContentRenderer({
|
|
|
11654
11654
|
);
|
|
11655
11655
|
}
|
|
11656
11656
|
ContentRenderer.displayName = "ContentRenderer";
|
|
11657
|
-
function toHtml(value, outputFormat, unsafe) {
|
|
11657
|
+
function toHtml(value, outputFormat, unsafe, valueFormat = "auto") {
|
|
11658
11658
|
if (!value) return "";
|
|
11659
11659
|
const raw = (() => {
|
|
11660
|
-
|
|
11661
|
-
const format = detectFormat(value);
|
|
11660
|
+
const format = valueFormat !== "auto" ? valueFormat : outputFormat === "html" ? "html" : detectFormat(value);
|
|
11662
11661
|
if (format === "html") return value;
|
|
11663
11662
|
return marked.parse(value, { async: false }).trim();
|
|
11664
11663
|
})();
|
|
@@ -11671,6 +11670,7 @@ function EditorRoot({
|
|
|
11671
11670
|
defaultValue = "",
|
|
11672
11671
|
onChange,
|
|
11673
11672
|
outputFormat = "html",
|
|
11673
|
+
valueFormat = "auto",
|
|
11674
11674
|
lineSpacing = 1.6,
|
|
11675
11675
|
placeholder,
|
|
11676
11676
|
mode: modeProp,
|
|
@@ -11682,13 +11682,13 @@ function EditorRoot({
|
|
|
11682
11682
|
const mode = useFieldMode(modeProp);
|
|
11683
11683
|
const isView = mode === "view";
|
|
11684
11684
|
const initialHtml = useMemo(
|
|
11685
|
-
() => toHtml(value, outputFormat, unsafe),
|
|
11685
|
+
() => toHtml(value, outputFormat, unsafe, valueFormat),
|
|
11686
11686
|
// Seed the contentEditable from the LIVE value when (re)entering edit mode.
|
|
11687
11687
|
// EditorContent reads this once on mount, and it only mounts in edit mode —
|
|
11688
11688
|
// so this captures the current value on view→edit, not a stale mount snapshot,
|
|
11689
11689
|
// and does NOT re-run on every keystroke.
|
|
11690
11690
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11691
|
-
[isView, outputFormat, unsafe]
|
|
11691
|
+
[isView, outputFormat, unsafe, valueFormat]
|
|
11692
11692
|
);
|
|
11693
11693
|
const extensions = useMemo(
|
|
11694
11694
|
() => mergeExtensions(instanceExtensions),
|
|
@@ -11765,7 +11765,7 @@ function EditorRoot({
|
|
|
11765
11765
|
ContentRenderer,
|
|
11766
11766
|
{
|
|
11767
11767
|
value,
|
|
11768
|
-
format: outputFormat,
|
|
11768
|
+
format: valueFormat !== "auto" ? valueFormat : outputFormat,
|
|
11769
11769
|
lineSpacing,
|
|
11770
11770
|
extensions: instanceExtensions,
|
|
11771
11771
|
unsafe,
|