mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Revert "Checked whether initialHtml in lexical input has a paragraph"
This reverts commit dd26448dcf
.
This commit is contained in:
parent
dd26448dcf
commit
07e979698d
1 changed files with 3 additions and 15 deletions
|
@ -125,20 +125,8 @@ export default class KoenigLexicalEditorInput extends Component {
|
|||
props.onChangeHtml?.(cleanedHtml);
|
||||
};
|
||||
|
||||
const hasParagraphWrapper = (html) => {
|
||||
const domParser = new DOMParser();
|
||||
const doc = domParser.parseFromString(html, 'text/html');
|
||||
|
||||
return doc.body.firstElementChild.tagName === 'P';
|
||||
};
|
||||
|
||||
const getInitialHtml = () => {
|
||||
if (!props.html) {
|
||||
return null;
|
||||
}
|
||||
// wrap in a paragraph, so it gets parsed correctly
|
||||
return hasParagraphWrapper(props.html) ? props.html : `<p>${props.html}</p>`;
|
||||
};
|
||||
// wrap in a paragraph, so it gets parsed correctly
|
||||
const initialHtml = props.html ? `<p>${props.html}</p>` : null;
|
||||
|
||||
return (
|
||||
<div className={['koenig-react-editor', this.args.className].filter(Boolean).join(' ')}>
|
||||
|
@ -158,7 +146,7 @@ export default class KoenigLexicalEditorInput extends Component {
|
|||
placeholderText={props.placeholderText}
|
||||
placeholderClassName="koenig-lexical-editor-input-placeholder"
|
||||
>
|
||||
<HtmlOutputPlugin html={getInitialHtml()} setHtml={cleanHtml} />
|
||||
<HtmlOutputPlugin html={initialHtml} setHtml={cleanHtml} />
|
||||
</KoenigComposableEditor>
|
||||
</KoenigComposer>
|
||||
</Suspense>
|
||||
|
|
Loading…
Add table
Reference in a new issue