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
feat(email): enable drag-to-resize for images in email compose (#2024)
Evan Hutnik12d1e04d5bae
diff --git a/js/app/packages/block-email/util/prepareEmailBody.ts b/js/app/packages/block-email/util/prepareEmailBody.tsindex 0d12ecfb78..fdbcb8ad4e 100644--- a/js/app/packages/block-email/util/prepareEmailBody.ts+++ b/js/app/packages/block-email/util/prepareEmailBody.ts@@ -388,6 +388,22 @@ function convertMentionsToLinks(root: ParentNode) {return mentions;}+function applyMediaScale(container: Element) {+ const mediaElements = container.querySelectorAll<HTMLElement>(+ 'img[data-scale], video[data-scale]'+ );+ mediaElements.forEach((el) => {+ const scale = parseFloat(el.getAttribute('data-scale') || '1');+ if (scale === 1) return;+ const width = parseInt(el.getAttribute('width') || '0', 10);+ const height = parseInt(el.getAttribute('height') || '0', 10);+ if (width > 0)+ el.setAttribute('width', Math.round(width * scale).toString());+ if (height > 0)+ el.setAttribute('height', Math.round(height * scale).toString());+ });+}+function flattenConsecutiveParagraphs(container: Element) {const paragraphs = container.querySelectorAll('p');const groups = [];@@ -467,6 +483,9 @@ export function prepareEmailBody(flattenConsecutiveParagraphs(parsed.body);+ // Apply image scale to width/height attributes so the recipient sees the resized dimensions+ applyMediaScale(parsed.body);+// Convert Macro document mentions to HTML links in the parsed DOMconst mentions = convertMentionsToLinks(parsed.body);diff --git a/js/app/packages/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx b/js/app/packages/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsxindex 7daa4ba473..25dba9ca91 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx@@ -294,26 +294,19 @@ export function MarkdownImage(props: ImageDecoratorProps) {setImageHover(false);}}>- <Show- when={- state() === 'ok' &&- editor()?.isEditable() &&- !props.constrainedWidth &&- !props.constrainedHeight- }- >+ <Show when={state() === 'ok' && editor()?.isEditable()}><ResizeHandlescale={scale}setScale={setScale}side="left"- imageDims={imageDims}+ imageDims={effectiveDims}containerRef={containerRef}/><ResizeHandlescale={scale}setScale={setScale}side="right"- imageDims={imageDims}+ imageDims={effectiveDims}containerRef={containerRef}/></Show>