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(block-md): tab from the document title into the body (#8552)
Peter Chinmane2ea353addcc
diff --git a/apps/web/src/features/block-md/component/Notebook.tsx b/apps/web/src/features/block-md/component/Notebook.tsxindex a3ed723d60..e59a7df64e 100644--- a/apps/web/src/features/block-md/component/Notebook.tsx+++ b/apps/web/src/features/block-md/component/Notebook.tsx@@ -228,6 +228,25 @@ export function Notebook(props: {);});+ // The document shares its split scope with the view hosting it, and views+ // like Drive bind Tab there to cycle their tabs, which closes the document.+ // This override eclipses those commands while the document is mounted:+ // Tab is left to the editors (title to body, list indent) and to native+ // focus order.+ createEffect(() => {+ const currentScopeId = scopeId();+ if (!currentScopeId) return;+ untrack(() =>+ registerHotkey({+ hotkey: ['tab', 'shift+tab'],+ scopeId: currentScopeId,+ description: 'Move focus within document',+ keyDownHandler: () => false,+ hide: true,+ })+ );+ });+// Register markdown formatting commands on the block scope so they appear in// Cmd+K, but only when the editor has focus (not just the block container).const [editorHasFocus, setEditorHasFocus] = createSignal(false);diff --git a/apps/web/src/features/block-md/component/TitleEditor.tsx b/apps/web/src/features/block-md/component/TitleEditor.tsxindex 4358656a6f..923fa0c8d8 100644--- a/apps/web/src/features/block-md/component/TitleEditor.tsx+++ b/apps/web/src/features/block-md/component/TitleEditor.tsx@@ -35,6 +35,7 @@ import {KEY_ARROW_RIGHT_COMMAND,KEY_ENTER_COMMAND,KEY_ESCAPE_COMMAND,+ KEY_TAB_COMMAND,type LexicalEditor,} from 'lexical';import {@@ -124,6 +125,21 @@ function titleNavigationPlugin(return true;},COMMAND_PRIORITY_NORMAL+ ),+ // Press tab in the title. Without this the browser moves focus to the+ // tag controls below the title instead of the body.+ titleEditor.registerCommand(+ KEY_TAB_COMMAND,+ (event: KeyboardEvent) => {+ if (ignoreArrows()) return true;+ if (event.shiftKey) return false;++ event.preventDefault();+ documentEditor.getRootElement()?.focus({ preventScroll: true });+ documentEditor.update($selectDocumentStart);+ return true;+ },+ COMMAND_PRIORITY_NORMAL));}diff --git a/docs/agent-guide/documents.md b/docs/agent-guide/documents.mdindex 57a3893c2d..f008f23ade 100644--- a/docs/agent-guide/documents.md+++ b/docs/agent-guide/documents.md@@ -2294,7 +2294,12 @@ keeps the default behavior.1. `Create` → `Document D`. The app navigates to `/app/md/<uuid>` with the **title fieldfocused**.-2. `type_text` the title, then `submitKey: "Enter"` to drop into the body.+2. `type_text` the title, then `submitKey: "Enter"` to drop into the body. Tab+ from the title also moves to the start of the body, without inserting a+ paragraph. While a document is open, Tab and Shift+Tab never switch the+ hosting view's tabs (e.g. Drive's My Files / Recent): opened from Drive,+ focus a non-editable control in the document, press Tab, and the+ document must stay open.3. Type paragraphs with plain `type_text`; use Enter between paragraphs. Do NOT use `fill` —the editor is contenteditable and `fill` does not work on it.4. The document auto-saves continuously (collaborative CRDT; no save button). The tab title