Skip to content

Commit

Permalink
fix(RichTextEditor): spacing [WPB-15264] (#18625)
Browse files Browse the repository at this point in the history
* fix(RichTextEditor): spacing

* refactor(RichTextEditor): remove unused comments and clean up code structure
  • Loading branch information
olafsulich authored Jan 20, 2025
1 parent 0cc5447 commit 0a00986
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const RichTextEditor = ({
return;
}

const markdown = $convertToMarkdownString(markdownTransformers);
const markdown = $convertToMarkdownString(markdownTransformers, undefined, true);

const text = transformMessage({replaceEmojis, markdown});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ export function EditedMessagePlugin({message, showMarkdownPreview}: Props): null
// During the transformation, we have to tell the editor to transofrm mentions as well.
// We can't do that by diretcly updating the $root (e.g. $root.appent(...MentionNodes)), because this function will overwrite the result.
// One way of overcoming this issue is to use a custom transformer (quite a hacky way). Transformers are responisble for converting the text to the desired format (e.g. **bold** to bold).
$convertFromMarkdownString(wrappedWithTags, [mentionMarkdownTransformer, ...markdownTransformers]);
$convertFromMarkdownString(
wrappedWithTags,
[mentionMarkdownTransformer, ...markdownTransformers],
undefined,
true,
);

editor.focus();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const useEditorDraftState = ({editorRef, saveDraftState, replaceEmojis}:
}

editor.getEditorState().read(() => {
const markdown = $convertToMarkdownString(markdownTransformers);
const markdown = $convertToMarkdownString(markdownTransformers, undefined, true);
saveDraftState(JSON.stringify(editor.getEditorState().toJSON()), transformMessage({replaceEmojis, markdown}));
});
}, [editorRef, saveDraftState, replaceEmojis]);
Expand Down

0 comments on commit 0a00986

Please sign in to comment.