0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Fixed AdminX HTML editor always making forms dirty (#17741)

refs https://github.com/TryGhost/Product/issues/3545
This commit is contained in:
Jono M 2023-08-16 19:20:07 +01:00 committed by GitHub
parent f1266c6b9f
commit b6b50a388e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -120,6 +120,13 @@ const KoenigWrapper: React.FC<HtmlEditorProps & { editor: EditorResource }> = ({
MINIMAL_NODES: koenig.MINIMAL_TRANSFORMERS
};
const handleSetHtml = (html: string) => {
// Koenig sends this event on load without changing the value, so this prevents forms from being marked as unsaved
if (html !== value) {
onChange?.(html);
}
};
return (
<koenig.KoenigComposer
nodes={koenig[nodes || 'DEFAULT_NODES']}
@ -135,7 +142,7 @@ const KoenigWrapper: React.FC<HtmlEditorProps & { editor: EditorResource }> = ({
singleParagraph={true}
onBlur={onBlur}
>
<koenig.HtmlOutputPlugin html={value} setHtml={onChange} />
<koenig.HtmlOutputPlugin html={value} setHtml={handleSetHtml} />
</koenig.KoenigComposableEditor>
</koenig.KoenigComposer>
);