Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
fix(email): incorrect enter key spacing for emails (#1078)
dev-rb1b54d06f524b
diff --git a/js/app/packages/block-email/util/prepareEmailBody.ts b/js/app/packages/block-email/util/prepareEmailBody.tsindex 4173b120e3..b1131d1054 100644--- a/js/app/packages/block-email/util/prepareEmailBody.ts+++ b/js/app/packages/block-email/util/prepareEmailBody.ts@@ -394,6 +394,64 @@ function convertMentionsToLinks(root: ParentNode) {return mentions;}+function flattenConsecutiveParagraphs(container: Element) {+ const paragraphs = container.querySelectorAll('p');+ const groups = [];+ let currentGroup: Element[] = [];++ for (let i = 0; i < paragraphs.length; i++) {+ if (i === 0) {+ currentGroup.push(paragraphs[i]);+ continue;+ }++ // Check if this paragraph immediately follows the previous one+ const prev = paragraphs[i - 1];+ if (prev.nextElementSibling === paragraphs[i]) {+ currentGroup.push(paragraphs[i]);+ } else {+ // Start a new group+ groups.push(currentGroup);+ currentGroup = [paragraphs[i]];+ }+ }++ // Don't forget the last group+ if (currentGroup.length > 0) {+ groups.push(currentGroup);+ }++ // Combine each group and replace in the DOM+ for (let i = 0; i < groups.length; i++) {+ const group = groups[i];+ const div = document.createElement('div');++ for (let j = 0; j < group.length; j++) {+ const p = group[j];++ const isEmpty =+ !p.textContent?.trim() &&+ !p.querySelector('img, video, iframe, canvas');++ if (p.childNodes.length) {+ div.append(...p.childNodes);+ }++ if (j < group.length - 1 && !isEmpty) {+ div.appendChild(document.createElement('br'));+ }+ }++ // Replace the first paragraph with the combined div+ group[0]?.parentNode?.replaceChild(div, group[0]);++ // Remove the rest of the paragraphs in this group+ for (let j = 1; j < group.length; j++) {+ group[j].remove();+ }+ }+}+export function prepareEmailBody(editor: LexicalEditor | undefined,// if this argument is provided, we append the message being replied to the html email body@@ -413,6 +471,8 @@ export function prepareEmailBody(const parsed = new DOMParser().parseFromString(generatedHtml, 'text/html');+ flattenConsecutiveParagraphs(parsed.body);+// Convert Macro document mentions to HTML links in the parsed DOMconst mentions = convertMentionsToLinks(parsed.body);