From 0e6b5b338ce86828ac48844bffe5f8467cd382f1 Mon Sep 17 00:00:00 2001 From: Henry Heino <46334387+personalizedrefrigerator@users.noreply.github.com> Date: Fri, 2 Feb 2024 09:56:58 -0800 Subject: [PATCH] Desktop: Fixes #9786: Rich text editor: Fix newline behavior in new notes (#9809) --- .../gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx index 0aa272e508..edbbea9850 100644 --- a/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx +++ b/packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx @@ -48,10 +48,17 @@ const supportedLocales = require('./supportedLocales'); // so as a workaround we manually add this
for empty documents, // which fixes the issue. // +// However, +//

+// breaks newline behaviour in new notes (see https://github.com/laurent22/joplin/issues/9786). +// Thus, we instead use +//

+// 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 === '
' ? '

' : html; +function awfulInitHack(html: string): string { + return html === '
' ? '

' : 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: