Skip to content

Commit

Permalink
Desktop: Fixes laurent22#9786: Rich text editor: Fix newline behavior…
Browse files Browse the repository at this point in the history
… in new notes
  • Loading branch information
personalizedrefrigerator committed Jan 31, 2024
1 parent 582f085 commit 19fdbee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions packages/app-desktop/gui/NoteEditor/NoteBody/TinyMCE/TinyMCE.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -867,7 +874,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:
Expand Down

0 comments on commit 19fdbee

Please sign in to comment.