diff --git a/src/app/components/editor/output.ts b/src/app/components/editor/output.ts
index 5310012bb1..cc626fc8cc 100644
--- a/src/app/components/editor/output.ts
+++ b/src/app/components/editor/output.ts
@@ -187,7 +187,7 @@ export const toPlainText = (node: Descendant | Descendant[], isMarkdown: boolean
export const customHtmlEqualsPlainText = (customHtml: string, plain: string): boolean =>
customHtml.replace(/
/g, '\n') === sanitizeText(plain);
-export const trimCustomHtml = (customHtml: string) => customHtml.replace(/
$/g, '').trim();
+export const trimCustomHtml = (customHtml: string) => customHtml.replace(/^(
)+|(
)+$/g, '').trim();
export const trimCommand = (cmdName: string, str: string) => {
const cmdRegX = new RegExp(`^(\\s+)?(\\/${sanitizeForRegex(cmdName)})([^\\S\n]+)?`);