@particle-academy/react-fancy 4.15.0 → 4.15.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 +9 -0
- package/dist/index.cjs +13 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -11958,15 +11958,20 @@ function EditorRoot({
|
|
|
11958
11958
|
);
|
|
11959
11959
|
const mode = useFieldMode(modeProp);
|
|
11960
11960
|
const isView = mode === "view";
|
|
11961
|
+
const lastEmitted = useRef(null);
|
|
11962
|
+
const [externalSeed, setExternalSeed] = useState(0);
|
|
11963
|
+
useEffect(() => {
|
|
11964
|
+
if (value !== lastEmitted.current) setExternalSeed((n) => n + 1);
|
|
11965
|
+
}, [value]);
|
|
11961
11966
|
const initialHtml = useMemo(
|
|
11962
11967
|
() => toHtml(value, outputFormat, unsafe, valueFormat),
|
|
11963
11968
|
// Seed the contentEditable from the LIVE value when (re)entering edit mode —
|
|
11964
11969
|
// and when returning from the raw-source view, which may have rewritten the
|
|
11965
|
-
// value out from under the rich-text surface.
|
|
11966
|
-
//
|
|
11967
|
-
//
|
|
11970
|
+
// value out from under the rich-text surface. `value` itself stays out of
|
|
11971
|
+
// the deps so typing never re-seeds (which would fight the caret);
|
|
11972
|
+
// `externalSeed` covers the externally-driven case instead.
|
|
11968
11973
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
11969
|
-
[isView, outputFormat, unsafe, valueFormat, showSource]
|
|
11974
|
+
[isView, outputFormat, unsafe, valueFormat, showSource, externalSeed]
|
|
11970
11975
|
);
|
|
11971
11976
|
const extensions = useMemo(
|
|
11972
11977
|
() => mergeExtensions(instanceExtensions),
|
|
@@ -11981,7 +11986,9 @@ function EditorRoot({
|
|
|
11981
11986
|
const handleInput = useCallback(() => {
|
|
11982
11987
|
const el = contentRef.current;
|
|
11983
11988
|
if (!el) return;
|
|
11984
|
-
|
|
11989
|
+
const next = getOutputValue(el.innerHTML);
|
|
11990
|
+
lastEmitted.current = next;
|
|
11991
|
+
setValue(next);
|
|
11985
11992
|
}, [setValue, getOutputValue]);
|
|
11986
11993
|
const exec = useCallback(
|
|
11987
11994
|
(command, arg) => {
|
|
@@ -12005,6 +12012,7 @@ function EditorRoot({
|
|
|
12005
12012
|
);
|
|
12006
12013
|
const handleSourceInput = useCallback(
|
|
12007
12014
|
(next) => {
|
|
12015
|
+
lastEmitted.current = next;
|
|
12008
12016
|
setValue(next);
|
|
12009
12017
|
},
|
|
12010
12018
|
[setValue]
|