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
Add table drag-to-move and Ask Macro button to editors (#7487)
Jacob Beckermanaacca8ed713d
diff --git a/apps/web/src/features/block-pptx/browser-test/pptx-ribbon.browser.e2e.ts b/apps/web/src/features/block-pptx/browser-test/pptx-ribbon.browser.e2e.tsindex dbd11d6856..d13e225707 100644--- a/apps/web/src/features/block-pptx/browser-test/pptx-ribbon.browser.e2e.ts+++ b/apps/web/src/features/block-pptx/browser-test/pptx-ribbon.browser.e2e.ts@@ -193,6 +193,45 @@ test('edits table cells in place and merges a range', async ({ page }) => {.toEqual([2, 2]);});+test('drags an unselected table to move it', async ({ page }) => {+ await open(page);+ await goToSlide(page, 5);+ const table = (await outline(page)).slides[5].shapes.find(+ (s) => s.kind === 'table'+ );+ if (!table?.table) throw new Error('No table on slide 6.');+ const inside = await screen(+ page,+ table.x + table.table.columnWidths[0] / 2,+ table.y + table.table.laidOutRowHeights[0] / 2+ );+ const target = await screen(+ page,+ table.x + table.table.columnWidths[0] / 2 + 40,+ table.y + table.table.laidOutRowHeights[0] / 2 + 30+ );+ // A press inside a cell of a table that isn't selected grabs the table.+ await page.mouse.move(inside.x, inside.y);+ await page.mouse.down();+ await page.mouse.move(target.x, target.y, { steps: 8 });+ await page.mouse.up();+ await expect+ .poll(async () => {+ const moved = (await outline(page)).slides[5].shapes.find(+ (s) => s.id === table.id+ );+ // Smart guides may snap the drop by a few points.+ return !!moved && moved.x - table.x > 30 && moved.y - table.y > 20;+ })+ .toBe(true);+ await expect(page.getByTestId('pptx-caret')).not.toBeAttached();+ // A click without dragging still types in the cell.+ await page.keyboard.press('Escape');+ await page.mouse.click(10, 10);+ await page.mouse.click(target.x, target.y);+ await expect(page.getByTestId('pptx-caret')).toBeAttached();+});+test('inserts a chart and edits its data', async ({ page }) => {await open(page);await page.getByTestId('pptx-tab-insert').click();diff --git a/apps/web/src/features/block-pptx/pptx-block.tsx b/apps/web/src/features/block-pptx/pptx-block.tsxindex 32c818f4c4..8bbebfe491 100644--- a/apps/web/src/features/block-pptx/pptx-block.tsx+++ b/apps/web/src/features/block-pptx/pptx-block.tsx@@ -3,6 +3,7 @@* presentation editor, wired to the worker engine and document storage.*/+import { ChatWithAgentButton } from '@app/features/chat/ChatWithAgentButton';import { useBlockEntityCommands } from '@app/features/next-soup/actions';import {ResponsiveBlockToolbar,@@ -296,6 +297,19 @@ export default function PptxBlock(props: { share?: string }) {<SplitHeaderRight><BlockLiveIndicators /></SplitHeaderRight>+ <SplitHeaderRight>+ <div class="order-[999] flex items-center">+ <ChatWithAgentButton+ label="Ask Macro"+ entity={{+ type: 'document',+ id: documentId,+ name: name(),+ fileType: 'pptx',+ }}+ />+ </div>+ </SplitHeaderRight><ResponsivePermissionsBadge /><ResponsiveBlockToolbarid={documentId}diff --git a/apps/web/src/features/block-pptx/views/pptx-editor.tsx b/apps/web/src/features/block-pptx/views/pptx-editor.tsxindex b48a315169..884baed702 100644--- a/apps/web/src/features/block-pptx/views/pptx-editor.tsx+++ b/apps/web/src/features/block-pptx/views/pptx-editor.tsx@@ -216,6 +216,8 @@ interface TableRange {/** A pointer gesture inside a table. */type TableGesture =| { kind: 'cells'; shape: number; from: CellRef; at: Point; moved: boolean }+ /** Pressed on an unselected table: a drag moves it, a click edits the cell. */+ | { kind: 'frame'; shape: number; from: CellRef; at: Point }| {kind: 'border';shape: number;@@ -894,6 +896,17 @@ export function PptxEditor() {};return;}+ // A table that isn't selected yet is grabbed whole: dragging moves it,+ // a click puts the caret in the cell. Once selected, drags pick cells.+ if (!editor.selectedIds().includes(t.shape.id)) {+ if (edit) editor.stopEditing();+ setTableRange(null);+ editor.pointerDown(at, { shift: false, detail: e.detail });+ tableGesture = { kind: 'frame', shape: t.shape.id, from: t.cell, at };+ e.preventDefault();+ focusStage();+ return;+ }if (edit) editor.stopEditing();editor.select(t.shape.id);setTableRange(null);@@ -968,6 +981,10 @@ export function PptxEditor() {setBorderGuide({ ...g });return;}+ if (g?.kind === 'frame') {+ editor.pointerMove(at, { shift: e.shiftKey, alt: e.altKey });+ return;+ }if (g?.kind === 'cells') {const shape = editor.findShape(g.shape);const geometry = shape && tableGeometry(shape);@@ -1002,6 +1019,15 @@ export function PptxEditor() {void commands.resizeGrid?.(g.shape, g.axis, g.index, delta);return;}+ if (g?.kind === 'frame') {+ const moved = !!editor.drag()?.active;+ void editor.pointerUp().then(() => {+ if (moved) return;+ const shape = editor.findShape(g.shape);+ if (shape) void editCell(shape, g.from, g.at);+ });+ return;+ }if (g?.kind === 'cells') {void editor.pointerUp();if (!g.moved && !editor.editing()?.cell) {diff --git a/apps/web/src/features/block-spreadsheet/components/SpreadsheetGrid.tsx b/apps/web/src/features/block-spreadsheet/components/SpreadsheetGrid.tsxindex ac913d54cd..19ac57a256 100644--- a/apps/web/src/features/block-spreadsheet/components/SpreadsheetGrid.tsx+++ b/apps/web/src/features/block-spreadsheet/components/SpreadsheetGrid.tsx@@ -1631,7 +1631,7 @@ export function SpreadsheetGrid(props: {'var(--spreadsheet-cell-padding-y)','line-height': CELL_LINE_HEIGHT,}}- class="absolute top-0 bottom-0 flex flex-col border-b border-r border-edge-muted bg-surface text-ink select-none"+ class="absolute top-0 bottom-0 flex flex-col border-b border-r border-edge-muted bg-panel text-ink select-none"classList={{'font-semibold': look()?.bold ?? cell()?.bold,'tabular-nums': numeric(),@@ -1771,7 +1771,7 @@ export function SpreadsheetGrid(props: {(isTouchDevice() && !!props.referenceSelection)}onSelectionChange={props.onTextSelection}- class="absolute inset-0 size-full resize-none overflow-hidden bg-surface px-[var(--spreadsheet-cell-padding)] py-[var(--spreadsheet-cell-padding-y)] font-normal text-left text-ink outline-none select-text"+ class="absolute inset-0 size-full resize-none overflow-hidden bg-panel px-[var(--spreadsheet-cell-padding)] py-[var(--spreadsheet-cell-padding-y)] font-normal text-left text-ink outline-none select-text"value={props.draft}onInput={props.onDraft}onKeyDown={editKeyDown}diff --git a/apps/web/src/features/block-spreadsheet/components/SpreadsheetSkeleton.tsx b/apps/web/src/features/block-spreadsheet/components/SpreadsheetSkeleton.tsxindex 383c2ce0d5..b0f2a88d9c 100644--- a/apps/web/src/features/block-spreadsheet/components/SpreadsheetSkeleton.tsx+++ b/apps/web/src/features/block-spreadsheet/components/SpreadsheetSkeleton.tsx@@ -29,7 +29,7 @@ export function SpreadsheetSkeleton(props: { label?: string }) {role="status"aria-busy="true"aria-label={label()}- class="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-surface opacity-100 transition-opacity duration-300 starting:opacity-0"+ class="relative flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-panel opacity-100 transition-opacity duration-300 starting:opacity-0"><span class="sr-only">{label()}…</span><divdiff --git a/apps/web/src/features/block-spreadsheet/views/SpreadsheetEditor.tsx b/apps/web/src/features/block-spreadsheet/views/SpreadsheetEditor.tsxindex 940997fff3..42cdf952b1 100644--- a/apps/web/src/features/block-spreadsheet/views/SpreadsheetEditor.tsx+++ b/apps/web/src/features/block-spreadsheet/views/SpreadsheetEditor.tsx@@ -574,7 +574,7 @@ export function SpreadsheetEditor(props: {return (<sectionref={editorElement}- class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-surface text-ink"+ class="flex size-full min-h-0 min-w-0 flex-col overflow-hidden bg-panel text-ink"aria-label={`${props.name} spreadsheet`}onKeyDown={(event) => {if (diff --git a/apps/web/src/features/block-write/DocxBlock.tsx b/apps/web/src/features/block-write/DocxBlock.tsxindex ca8a591c3c..26b816c88f 100644--- a/apps/web/src/features/block-write/DocxBlock.tsx+++ b/apps/web/src/features/block-write/DocxBlock.tsx@@ -1,3 +1,4 @@+import { ChatWithAgentButton } from '@app/features/chat/ChatWithAgentButton';import {ResponsiveBlockToolbar,ResponsivePermissionsBadge,@@ -112,6 +113,19 @@ export default function DocxBlock(props: { share?: string }) {<SplitHeaderRight><BlockLiveIndicators /></SplitHeaderRight>+ <SplitHeaderRight>+ <div class="order-[999] flex items-center">+ <ChatWithAgentButton+ label="Ask Macro"+ entity={{+ type: 'document',+ id: documentId,+ name: name(),+ fileType: 'docx',+ }}+ />+ </div>+ </SplitHeaderRight><ResponsivePermissionsBadge /><ResponsiveBlockToolbarid={documentId}diff --git a/apps/web/src/features/block-write/components/DocxToolbar.tsx b/apps/web/src/features/block-write/components/DocxToolbar.tsxindex 3c4e793ea1..828e118900 100644--- a/apps/web/src/features/block-write/components/DocxToolbar.tsx+++ b/apps/web/src/features/block-write/components/DocxToolbar.tsx@@ -285,14 +285,15 @@ const keepEditorFocus = (event: PointerEvent | MouseEvent) => {export function DocxToolbar(props: DocxToolbarProps) {return (<div- class="flex w-full shrink-0 justify-center overflow-x-auto px-3 py-2"+ class="shrink-0 border-b border-edge-muted"onPointerDown={keepEditorFocus}onMouseDown={keepEditorFocus}>+ {/* Docked under the header like the spreadsheet toolbar, not floating. */}<Toolbarsize="icon-sm"aria-label="Document formatting"- class="max-w-full"+ class="flex h-10 w-full min-w-0 gap-0.5 overflow-x-auto overscroll-x-contain rounded-none border-0 bg-transparent px-3 py-0 touch:h-[48px] touch:touch-pan-x touch:px-1 [&_[data-button]]:size-7 [&_[data-button]>svg]:size-[18px]! [&_select]:h-7"><Show when={props.canEdit}><Toolbar.Group>@@ -311,7 +312,7 @@ export function DocxToolbar(props: DocxToolbarProps) {<ArrowClockwise /></Toolbar.Button></Toolbar.Group>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><selectaria-label="Paragraph style"class="h-6 max-w-36 rounded-md border border-edge-muted bg-input px-1.5 text-xs text-ink"@@ -387,7 +388,7 @@ export function DocxToolbar(props: DocxToolbarProps) {)}</For></select>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><Toolbar.Group><For each={INLINE}>{(item) => (@@ -452,7 +453,7 @@ export function DocxToolbar(props: DocxToolbarProps) {<TextTSlash /></Toolbar.Button></Toolbar.Group>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><Toolbar.Group><Toolbar.Buttonlabel="Bulleted list"@@ -467,7 +468,7 @@ export function DocxToolbar(props: DocxToolbarProps) {<ListNumbers /></Toolbar.Button></Toolbar.Group>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><Toolbar.Group><For each={ALIGNMENTS}>{(item) => (@@ -515,7 +516,7 @@ export function DocxToolbar(props: DocxToolbarProps) {</For></ToolbarMenu></Toolbar.Group>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><Toolbar.Buttonlabel="Insert table"onClick={() => props.onInsertTable()}@@ -553,7 +554,7 @@ export function DocxToolbar(props: DocxToolbarProps) {</For></ToolbarMenu></Show>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /><Toolbar.Group><Toolbar.Buttonlabel={props.tracking ? 'Stop tracking changes' : 'Track changes'}@@ -605,7 +606,7 @@ export function DocxToolbar(props: DocxToolbarProps) {</Toolbar.Button></Show></Toolbar.Group>- <Toolbar.Divider />+ <Toolbar.Divider class="mx-1.5 my-2.5" /></Show><Show when={props.canComment}><Toolbar.Buttondiff --git a/apps/web/src/features/block-write/views/DocxEditorView.tsx b/apps/web/src/features/block-write/views/DocxEditorView.tsxindex e9cf6f54cb..00777ecf26 100644--- a/apps/web/src/features/block-write/views/DocxEditorView.tsx+++ b/apps/web/src/features/block-write/views/DocxEditorView.tsx@@ -314,7 +314,7 @@ export function DocxEditorView(props: DocxEditorViewProps) {);return (- <div class="flex size-full min-h-0 min-w-0 flex-col">+ <div class="flex size-full min-h-0 min-w-0 flex-col bg-panel">{/* A DOCX is authored for paper: the engine draws white sheets with thedocument's own colours whatever the app theme is. */}<style>{`.docx-sheet { background: #fff; }diff --git a/apps/web/src/features/block-write/views/DocxPages.tsx b/apps/web/src/features/block-write/views/DocxPages.tsxindex 6f6c854622..2d13b7fce5 100644--- a/apps/web/src/features/block-write/views/DocxPages.tsx+++ b/apps/web/src/features/block-write/views/DocxPages.tsx@@ -101,7 +101,7 @@ function Page(props: {return (<divref={element}- class="docx-sheet absolute overflow-hidden rounded-[2px] shadow-md"+ class="docx-sheet absolute cursor-text overflow-hidden rounded-[2px] shadow-md ring-1 ring-edge-muted"data-docx-page={props.index}style={{left: `${props.box.left}px`,diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.mdindex be6f0ad5e3..56aa5ad8a9 100644--- a/docs/AGENT_GUIDE/documents.md+++ b/docs/AGENT_GUIDE/documents.md@@ -564,7 +564,9 @@ Layout and test hooks:caret lies across the rotated line, and arrow keys follow the screen (intext rotated 90°, Down is the next character and Left the next line).Turning a text box that resizes to fit its text swaps its width and height.-- **Tables**: click a cell to type in it in place (same caret); Tab and+- **Tables**: press a table that isn't selected and drag to move it, or+ release without dragging to type in the clicked cell in place (same+ caret); Tab andShift+Tab move between cells (Tab in the last cell adds a row); drag acrosscells to select a range (`pptx-cell-range`), which the Table Design/Layouttabs and the table menu act on (merge/split, shading `pptx-cell-shading`,@@ -572,7 +574,8 @@ Layout and test hooks:and columns, distribute, alignment, and Text Direction`pptx-cell-text-direction`, items `pptx-cell-text-direction-<value>`; avertical cell's row grows to its text). Drag a column or row border of a- selected table to resize it; drag near the frame's edge to move the table.+ selected table to resize it. To move a table that is already selected,+ drag near the frame's edge, or click outside it first.- **Charts**: double-click a chart, or **Edit data** (`pptx-chart-edit-data`)on Chart Design, opens the data grid (`pptx-chart-data`, cells`pptx-chart-cell-<row>-<col>`, **Apply** `pptx-chart-apply`); Chart Design@@ -909,6 +912,8 @@ and as colored dots on the thumbnails of slides they are on. A viewer who opensa deck nobody has shared yet, or anyone when the sync service is unreachable,gets the stored file read-only.+**Ask Macro**, in the header beside **Share**, opens a new agent session in a+split with the deck mentioned in the composer (nothing sends automatically).Macro AI reads decks with `ReadPresentation` (slides, layouts, theme colors,sections, transitions, header and footer, and every shape with its id, kind,placeholder role, position in points, text, table cells with merges and style,@@ -1768,7 +1773,8 @@ updates live and shows each collaborator's caret with their name(labelled `Document text`); it must have focus, which a click on a pagegives it. Read text back from another tab or after a download, not fromthe page.-- Editors get a toolbar labelled `Document formatting`: `Undo`, `Redo`, the+- Editors get a toolbar labelled `Document formatting`, docked full width+ under the header (like the spreadsheet toolbar): `Undo`, `Redo`, the`Paragraph style`, `Font` and `Font size` selects, `Bold`, `Italic`,`Underline`, `Strikethrough`, `Superscript`, `Subscript`, the `Text color`and `Highlight` menus (`[data-docx-menu="color"]`,@@ -1849,6 +1855,9 @@ updates live and shows each collaborator's caret with their namethreads and are not written into the file.- The stored upload is not rewritten yet. Search, the PDF export and AI`ReadContent` still see the original file.+- **Ask Macro**, in the header beside **Share**, opens a new agent session in+ a split with the document mentioned in the composer (nothing sends+ automatically).- AI `ReadWordDocument` and `EditWordDocument` read and edit the live copy, soopen editors patch agent edits in as they land. `ReadWordDocument` listsevery paragraph, table cell and content control with its id. `EditWordDocument`