Desktop: Fixes #9786: Rich text editor: Fix newline behavior in new notes (#9809)

pull/9827/head^2
Henry Heino 2024-02-02 09:56:58 -08:00 committed by GitHub
parent ddbd3601ab
commit 0e6b5b338c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -48,10 +48,17 @@ const supportedLocales = require('./supportedLocales');
// so as a workaround we manually add this <br> for empty documents,
// which fixes the issue.
//
// However,
// <div id="rendered-md"><br/></div>
// breaks newline behaviour in new notes (see https://github.com/laurent22/joplin/issues/9786).
// Thus, we instead use
// <div id="rendered-md"><p></p></div>
// which also seems to work around the list issue.
//
// Perhaps upgrading the list plugin (which is a fork of TinyMCE own list plugin)
// would help?
function awfulBrHack(html: string): string {
return html === '<div id="rendered-md"></div>' ? '<div id="rendered-md"><br/></div>' : html;
function awfulInitHack(html: string): string {
return html === '<div id="rendered-md"></div>' ? '<div id="rendered-md"><p></p></div>' : html;
}
function findEditableContainer(node: any): any {
@ -875,7 +882,7 @@ const TinyMCE = (props: NoteBodyEditorProps, ref: any) => {
);
if (cancelled) return;
editor.setContent(awfulBrHack(result.html));
editor.setContent(awfulInitHack(result.html));
if (lastOnChangeEventInfo.current.contentKey !== props.contentKey) {
// Need to clear UndoManager to avoid this problem: