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(split): bottom panel/drawer and refactor md debugger (#4133)
Seamus9d0cf654be13
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex 68075e4ff5..f82b13ddc1 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -16,6 +16,7 @@ import { toast } from '@core/component/Toast/Toast';import { ToastRegion } from '@core/component/Toast/ToastRegion';import { ChannelsContextProvider } from '@core/context/channels';import { QuickAccessProvider } from '@core/context/quickAccess';+import { TeamContextProvider } from '@core/context/team';import {UserContextProvider,useUserId,@@ -519,39 +520,41 @@ export function Root() {<GlobalShareInboxConflictDialog /><QuerySyncProviderWithUserId /><UserInfoSideEffects />- <ConfiguredGlobalAppStateProvider>- <MutationUndoProvider>- <ChannelsContextProvider>- <CallProvider>- <CallKitSync />- <CallStartedNotifier />- <QuickAccessProvider>- <SearchProvider>- <ChatAttachmentsInit />- <ReactiveFavicon />- <Title>{tabTitle()}</Title>- <Suspense>- <IsomorphicRouter- transformUrl={transformShortIdInUrlPathname}- root={Layout}- rootPreload={rootPreload}- base={ROUTER_BASE}- >- {{- path: '/',- component: TauriRouteListener,- children: ROUTES,- }}- </IsomorphicRouter>- </Suspense>- <InitialInteractiveOnboardingModal />- <ToastRegion />- </SearchProvider>- </QuickAccessProvider>- </CallProvider>- </ChannelsContextProvider>- </MutationUndoProvider>- </ConfiguredGlobalAppStateProvider>+ <TeamContextProvider>+ <ConfiguredGlobalAppStateProvider>+ <MutationUndoProvider>+ <ChannelsContextProvider>+ <CallProvider>+ <CallKitSync />+ <CallStartedNotifier />+ <QuickAccessProvider>+ <SearchProvider>+ <ChatAttachmentsInit />+ <ReactiveFavicon />+ <Title>{tabTitle()}</Title>+ <Suspense>+ <IsomorphicRouter+ transformUrl={transformShortIdInUrlPathname}+ root={Layout}+ rootPreload={rootPreload}+ base={ROUTER_BASE}+ >+ {{+ path: '/',+ component: TauriRouteListener,+ children: ROUTES,+ }}+ </IsomorphicRouter>+ </Suspense>+ <InitialInteractiveOnboardingModal />+ <ToastRegion />+ </SearchProvider>+ </QuickAccessProvider>+ </CallProvider>+ </ChannelsContextProvider>+ </MutationUndoProvider>+ </ConfiguredGlobalAppStateProvider>+ </TeamContextProvider></UserContextProvider></EntityProvider></PosthogProvider>diff --git a/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsxindex b88a3ec788..80803f95d9 100644--- a/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx+++ b/js/app/packages/app/component/split-layout/components/PopoverSplitRenderer.tsx@@ -99,6 +99,8 @@ function PopoverSplitModal(props: {panelSize: { width: null, height: null },contentOffsetTop,setContentOffsetTop,+ bottomPanel: () => undefined,+ registerBottomPanel: () => () => {},previewState: [previewState, setPreviewState] as [typeof previewState,typeof setPreviewState,diff --git a/js/app/packages/app/component/split-layout/components/SplitBottomPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitBottomPanel.tsxnew file mode 100644index 0000000000..43806ab6c8--- /dev/null+++ b/js/app/packages/app/component/split-layout/components/SplitBottomPanel.tsx@@ -0,0 +1,25 @@+import { children, createEffect, onCleanup, type ParentProps } from 'solid-js';+import { useSplitPanelOrThrow } from '../layoutUtils';++export function SplitBottomPanel(+ props: ParentProps<{+ id: string;+ title?: string;+ onClose?: () => void;+ }>+) {+ const splitPanel = useSplitPanelOrThrow();+ const resolved = children(() => props.children);++ createEffect(() => {+ const unregister = splitPanel.registerBottomPanel({+ id: props.id,+ title: props.title,+ content: resolved,+ onClose: props.onClose,+ });+ onCleanup(unregister);+ });++ return null;+}diff --git a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx b/js/app/packages/app/component/split-layout/components/SplitPanel.tsxindex 00db462407..d7e82eec3d 100644--- a/js/app/packages/app/component/split-layout/components/SplitPanel.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitPanel.tsx@@ -5,8 +5,9 @@ import { isListViewID, LIST_VIEW_ID } from '@app/constants/list-views';import { globalSplitManager } from '@app/signal/splitLayout';import { splitContainerAttribute } from '@core/dom-selectors';import { isMobile } from '@core/mobile/isMobile';+import CloseIcon from '@phosphor/x.svg';import { createElementSize } from '@solid-primitives/resize-observer';-import { cn, Panel } from '@ui';+import { Button, cn, Panel } from '@ui';import { useHotkeyDOMScope } from 'core/hotkey/hotkeys';import {createEffect,@@ -19,7 +20,11 @@ import {Suspense,} from 'solid-js';import { Dynamic } from 'solid-js/web';-import { SplitPanelContext, type SplitPanelContextType } from '../context';+import {+ type SplitBottomPanelRegistration,+ SplitPanelContext,+ type SplitPanelContextType,+} from '../context';import { useSplitLayout } from '../layout';import type { SplitHandle, SplitState } from '../layoutManager';import { registerSplitHotkeys } from '../registerSplitHotkeys';@@ -43,6 +48,8 @@ export function SplitPanel(props: SplitPanelProps) {const [panelRef, setPanelRef] = createSignal<HTMLDivElement | null>(null);const [contentOffsetTop, setContentOffsetTop] = createSignal(0);const [previewState, setPreviewState] = createSignal(false);+ const [bottomPanel, setBottomPanel] =+ createSignal<SplitBottomPanelRegistration>();const panelSize = createElementSize(panelRef);const layoutRefs: SplitPanelContextType['layoutRefs'] = {};@@ -137,6 +144,15 @@ export function SplitPanel(props: SplitPanelProps) {setContentOffsetTop,contentOffsetTop,splitHotkeyScope,+ bottomPanel,+ registerBottomPanel: (panel) => {+ setBottomPanel(panel);+ return () => {+ setBottomPanel((current) =>+ current?.id === panel.id ? undefined : current+ );+ };+ },headerCollapser,layoutRefs,panelSize,@@ -201,12 +217,41 @@ export function SplitPanel(props: SplitPanelProps) {</Panel.Toolbar><Panel.Body>- <div class="@container/split size-full overflow-hidden relative">- <Suspense>- <SoupViewContextProvider soup={nextSoup}>- <Dynamic component={props.split.mount.element} />- </SoupViewContextProvider>- </Suspense>+ <div class="@container/split size-full min-h-0 overflow-hidden relative flex flex-col">+ <div+ class={cn(+ 'min-h-0 min-w-0 overflow-hidden relative',+ bottomPanel() ? 'h-1/2' : 'h-full'+ )}+ >+ <Suspense>+ <SoupViewContextProvider soup={nextSoup}>+ <Dynamic component={props.split.mount.element} />+ </SoupViewContextProvider>+ </Suspense>+ </div>+ <Show when={bottomPanel()}>+ {(panel) => (+ <div class="h-1/2 min-h-0 min-w-0 border-t border-edge-muted bg-surface flex flex-col">+ <div class="flex h-10 shrink-0 items-center gap-2 border-b border-edge-muted px-2">+ <h3 class="min-w-0 flex-1 truncate text-sm font-medium text-content-secondary">+ {panel().title}+ </h3>+ <Button+ variant="ghost"+ size="icon-sm"+ label="Close"+ onClick={() => panel().onClose?.()}+ >+ <CloseIcon />+ </Button>+ </div>+ <div class="min-h-0 flex-1 overflow-hidden">+ {panel().content()}+ </div>+ </div>+ )}+ </Show></div></Panel.Body></Panel>diff --git a/js/app/packages/app/component/split-layout/context.ts b/js/app/packages/app/component/split-layout/context.tsindex 60e5d98eb2..14f3b5eecc 100644--- a/js/app/packages/app/component/split-layout/context.ts+++ b/js/app/packages/app/component/split-layout/context.ts@@ -2,6 +2,7 @@ import type { NullableSize } from '@solid-primitives/resize-observer';import {type Accessor,createContext,+ type JSX,type Setter,type Signal,} from 'solid-js';@@ -37,6 +38,13 @@ export type HalfSplitState = {side: 'left' | 'right';};+export type SplitBottomPanelRegistration = {+ id: string;+ title?: JSX.Element;+ content: () => JSX.Element;+ onClose?: () => void;+};+export type SplitPanelContextType = {handle: SplitHandle;splitHotkeyScope: string;@@ -46,6 +54,8 @@ export type SplitPanelContextType = {contentOffsetTop: Accessor<number>;setContentOffsetTop: Setter<number>;halfSplitState?: Accessor<HalfSplitState | undefined>;+ bottomPanel: Accessor<SplitBottomPanelRegistration | undefined>;+ registerBottomPanel: (panel: SplitBottomPanelRegistration) => () => void;previewState: Signal<boolean>;layoutRefs: {headerLeft?: HTMLDivElement;diff --git a/js/app/packages/block-md/component/InstructionsEditor.tsx b/js/app/packages/block-md/component/InstructionsEditor.tsxindex c724463978..d8741b47cc 100644--- a/js/app/packages/block-md/component/InstructionsEditor.tsx+++ b/js/app/packages/block-md/component/InstructionsEditor.tsx@@ -1,3 +1,4 @@+import { SplitBottomPanel } from '@app/component/split-layout/components/SplitBottomPanel';import { markdownBlockErrorSignal } from '@block-md/signal/error';import { revisionsSignal, rewriteSignal } from '@block-md/signal/rewriteSignal';import { useBlockId } from '@core/block';@@ -74,10 +75,13 @@ import type { MarkdownRewriteOutput } from '../signal/rewriteSignal';import { useBlockSave, useSaveMarkdownDocument } from '../signal/save';import { MarkdownCollabProvider } from './MarkdownCollabProvider';-const DEBUG = false;const EDITOR_PADDING_BOTTOM = 120;-export function InstructionsEditor(props: { loroManager: LoroManager }) {+export function InstructionsEditor(props: {+ loroManager: LoroManager;+ showLexicalStateDebugger?: boolean;+ onLexicalStateDebuggerClose?: () => void;+}) {const blockData = blockDataSignal.get;const blockId = useBlockId();@@ -440,10 +444,16 @@ export function InstructionsEditor(props: { loroManager: LoroManager }) {sourceDocumentId={blockId}/>- <Show when={DEBUG}>+ <Show when={props.showLexicalStateDebugger}><Show when={state()}>{(state) => (- <LexicalStateDebugger state={state()}></LexicalStateDebugger>+ <SplitBottomPanel+ id="lexical-state-debugger"+ title="Lexical state debugger"+ onClose={props.onLexicalStateDebuggerClose}+ >+ <LexicalStateDebugger state={state()}></LexicalStateDebugger>+ </SplitBottomPanel>)}</Show></Show>diff --git a/js/app/packages/block-md/component/MarkdownEditor.tsx b/js/app/packages/block-md/component/MarkdownEditor.tsxindex 54ba9893f4..2d8b1d059e 100644--- a/js/app/packages/block-md/component/MarkdownEditor.tsx+++ b/js/app/packages/block-md/component/MarkdownEditor.tsx@@ -1,3 +1,4 @@+import { SplitBottomPanel } from '@app/component/split-layout/components/SplitBottomPanel';import { URL_PARAMS as CHANNEL_PARAMS } from '@block-channel/constants';import { CommentsProvider } from '@block-md/comments/CommentsProvider';import { URL_PARAMS } from '@block-md/constants';@@ -124,12 +125,10 @@ import {ENABLE_MARKDOWN_COMMENTS,ENABLE_MARKDOWN_DIFF,ENABLE_MARKDOWN_LIVE_COLLABORATION,- LOCAL_ONLY,} from '@core/constant/featureFlags';import { IS_MAC } from '@core/constant/isMac';import { useUserId } from '@core/context/user';import { fileFolderDrop } from '@core/directive/fileFolderDrop';-import { isMobile } from '@core/mobile/isMobile';import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';import { blockElementSignal } from '@core/signal/blockElement';import {@@ -193,8 +192,6 @@ import { MarkdownPopup } from './MarkdownPopup';false && fileFolderDrop;-const DEBUG = LOCAL_ONLY;-// There is an invisible div below the editor that clicks to set editor focus// and add a new line. This constant is the minimum height of that element (in pixels)// once the editor has at least one full page of content.@@ -218,6 +215,8 @@ function getBlankMarkdownPlaceholder(canEdit: boolean) {export function MarkdownEditor(props: {autoFocusOnMount?: boolean;loroManager: LoroManager;+ showLexicalStateDebugger?: boolean;+ onLexicalStateDebuggerClose?: () => void;}) {const blockData = blockDataSignal.get;const blockId = useBlockId();@@ -1113,10 +1112,16 @@ export function MarkdownEditor(props: {/></Show>- <Show when={DEBUG && !isMobile()}>+ <Show when={props.showLexicalStateDebugger}><Show when={state()}>{(state) => (- <LexicalStateDebugger state={state()}></LexicalStateDebugger>+ <SplitBottomPanel+ id="lexical-state-debugger"+ title="Lexical state debugger"+ onClose={props.onLexicalStateDebuggerClose}+ >+ <LexicalStateDebugger state={state()}></LexicalStateDebugger>+ </SplitBottomPanel>)}</Show></Show>diff --git a/js/app/packages/block-md/component/Notebook.tsx b/js/app/packages/block-md/component/Notebook.tsxindex a2399fd6e3..1cedcf7c55 100644--- a/js/app/packages/block-md/component/Notebook.tsx+++ b/js/app/packages/block-md/component/Notebook.tsx@@ -11,9 +11,12 @@ import type { LoroManager } from '@core/collab/manager';import { editorFocusSignal } from '@core/component/LexicalMarkdown/utils';import { ParamsProvider } from '@core/component/ParamsProvider';import {+ DEV_MODE_ENV,ENABLE_MARKDOWN_COMMENTS,ENABLE_RAIL_CHAT_TASK_COMMENTS,+ LOCAL_ONLY,} from '@core/constant/featureFlags';+import { useIsMacroTeam } from '@core/context/team';import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';import {@@ -39,7 +42,10 @@ import { MarkdownEditor } from './MarkdownEditor';import { TaskDiscussion } from './TaskDiscussion';import { TaskDuplicateMatchPill } from './TaskDuplicateMatches';import { TitleEditor } from './TitleEditor';-import { registerMarkdownCommands } from './useMarkdownCommands';+import {+ registerLexicalStateDebuggerCommand,+ registerMarkdownCommands,+} from './useMarkdownCommands';const NoteTargetWidth = 768;const CommentTargetWidth = 320;@@ -70,6 +76,14 @@ const widthToMode = (width: number): CommentLayoutMode => {return CommentLayoutMode.none;};+function useCanUseLexicalStateDebugger() {+ const isMacroTeam = useIsMacroTeam();+ return createMemo(() => {+ if (LOCAL_ONLY || DEV_MODE_ENV) return true;+ return isMacroTeam();+ });+}+export function Notebook(props: { loroManager: LoroManager }) {const blockElement = blockElementSignal.get;const setStore = mdStore.set;@@ -87,6 +101,9 @@ export function Notebook(props: { loroManager: LoroManager }) {const [layoutMode, setLayoutMode] = createSignal(CommentLayoutMode.none);const [width, setWidth] = createSignal(0);const [leftFloatX, setLeftFloatX] = createSignal(0);+ const [showLexicalStateDebugger, setShowLexicalStateDebugger] =+ createSignal(false);+ const canUseLexicalStateDebugger = useCanUseLexicalStateDebugger();const comments = commentsStore.get;const hasComment = createMemo(() => {@@ -183,10 +200,18 @@ export function Notebook(props: { loroManager: LoroManager }) {createEffect(() => {if (!scopeId()) return;const group = untrack(() =>- registerMarkdownCommands(scopeId(), () => md.editor, editorHasFocus)+ registerMarkdownCommands(scopeId(), () => md.editor, editorHasFocus, {+ canUseStateDebugger: canUseLexicalStateDebugger,+ toggleStateDebugger: () => setShowLexicalStateDebugger((prev) => !prev),+ }));onCleanup(() => group.dispose());});+ createEffect(() => {+ if (!canUseLexicalStateDebugger() && showLexicalStateDebugger()) {+ setShowLexicalStateDebugger(false);+ }+ });// In preview mode, switching between Soup tabs was causing this createEffect to overflow the stack. We should figure out that root cause, this flag fixes it for now.let hasRun = false;@@ -274,7 +299,15 @@ export function Notebook(props: { loroManager: LoroManager }) {<TaskDuplicateMatchPill /></div><ParamsProvider>- <MarkdownEditor loroManager={props.loroManager} />+ <MarkdownEditor+ loroManager={props.loroManager}+ showLexicalStateDebugger={+ canUseLexicalStateDebugger() && showLexicalStateDebugger()+ }+ onLexicalStateDebuggerClose={() =>+ setShowLexicalStateDebugger(false)+ }+ /><Show when={ENABLE_RAIL_CHAT_TASK_COMMENTS && isTask}><TaskDiscussion /></Show>@@ -297,6 +330,10 @@ export function Notebook(props: { loroManager: LoroManager }) {export function InstructionsNotebook(props: { loroManager: LoroManager }) {const setStore = mdStore.set;+ const scopeId = blockHotkeyScopeSignal.get;+ const [showLexicalStateDebugger, setShowLexicalStateDebugger] =+ createSignal(false);+ const canUseLexicalStateDebugger = useCanUseLexicalStateDebugger();let notebookRef!: HTMLDivElement;let contentRef!: HTMLDivElement;@@ -316,13 +353,35 @@ export function InstructionsNotebook(props: { loroManager: LoroManager }) {});});+ createEffect(() => {+ if (!scopeId()) return;+ const group = untrack(() =>+ registerLexicalStateDebuggerCommand(scopeId(), {+ canUseStateDebugger: canUseLexicalStateDebugger,+ toggleStateDebugger: () => setShowLexicalStateDebugger((prev) => !prev),+ })+ );+ onCleanup(() => group.dispose());+ });+ createEffect(() => {+ if (!canUseLexicalStateDebugger() && showLexicalStateDebugger()) {+ setShowLexicalStateDebugger(false);+ }+ });+return (<divclass="flex relative text-ink min-h-full min-w-0 px-6"ref={notebookRef}><div class="grow max-w-3xl pt-12 min-w-0 mx-auto" ref={contentRef}>- <InstructionsEditor loroManager={props.loroManager} />+ <InstructionsEditor+ loroManager={props.loroManager}+ showLexicalStateDebugger={+ canUseLexicalStateDebugger() && showLexicalStateDebugger()+ }+ onLexicalStateDebuggerClose={() => setShowLexicalStateDebugger(false)}+ /></div></div>);diff --git a/js/app/packages/block-md/component/useMarkdownCommands.ts b/js/app/packages/block-md/component/useMarkdownCommands.tsindex a5ff724efd..21d3e366a8 100644--- a/js/app/packages/block-md/component/useMarkdownCommands.ts+++ b/js/app/packages/block-md/component/useMarkdownCommands.ts@@ -3,6 +3,7 @@ import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';import type { HotkeyToken } from '@core/hotkey/tokens';import { TOKENS } from '@core/hotkey/tokens';import type { ValidHotkey } from '@core/hotkey/types';+import BugIcon from '@phosphor/bug.svg';import TextCode from '@phosphor/code.svg';import TextHighlight from '@phosphor/paint-roller.svg';import TextBold from '@phosphor/text-b.svg';@@ -103,6 +104,41 @@ const ACTION_ID_TO_TOKEN: Record<string, HotkeyToken> = {hr: TOKENS.md.divider,};+type LexicalStateDebuggerCommandOptions = {+ canUseStateDebugger?: () => boolean;+ toggleStateDebugger: () => void;+};++function registerLexicalStateDebuggerHotkey(+ scopeId: string,+ options: LexicalStateDebuggerCommandOptions,+ group: ReturnType<typeof createHotkeyGroup>+) {+ registerHotkey({+ scopeId,+ runWithInputFocused: true,+ hotkeyToken: TOKENS.md.toggleStateDebugger,+ description: 'Toggle lexical state debugger',+ icon: BugIcon,+ hide: () => options.canUseStateDebugger?.() === false,+ condition: () => options.canUseStateDebugger?.() !== false,+ keyDownHandler: () => {+ if (options.canUseStateDebugger?.() === false) return false;+ options.toggleStateDebugger();+ return true;+ },+ }).withGroup(group);+}++export function registerLexicalStateDebuggerCommand(+ scopeId: string,+ options: LexicalStateDebuggerCommandOptions+) {+ const group = createHotkeyGroup();+ registerLexicalStateDebuggerHotkey(scopeId, options, group);+ return group;+}+/*** Registers markdown formatting commands on the block hotkey scope so they* appear in the command menu (Cmd+K). Inline formats that already have@@ -116,7 +152,11 @@ const ACTION_ID_TO_TOKEN: Record<string, HotkeyToken> = {export function registerMarkdownCommands(scopeId: string,getEditor: () => LexicalEditor | undefined,- condition?: () => boolean+ condition?: () => boolean,+ options?: {+ canUseStateDebugger?: () => boolean;+ toggleStateDebugger?: () => void;+ }) {const group = createHotkeyGroup();const hide = condition ? () => !condition() : undefined;@@ -171,5 +211,16 @@ export function registerMarkdownCommands(}).withGroup(group);}+ if (options?.toggleStateDebugger) {+ registerLexicalStateDebuggerHotkey(+ scopeId,+ {+ canUseStateDebugger: options.canUseStateDebugger,+ toggleStateDebugger: options.toggleStateDebugger,+ },+ group+ );+ }+return group;}diff --git a/js/app/packages/core/component/LexicalMarkdown/component/debug/LexicalStateDebugger.tsx b/js/app/packages/core/component/LexicalMarkdown/component/debug/LexicalStateDebugger.tsxindex ca913716b9..6e6cb809d2 100644--- a/js/app/packages/core/component/LexicalMarkdown/component/debug/LexicalStateDebugger.tsx+++ b/js/app/packages/core/component/LexicalMarkdown/component/debug/LexicalStateDebugger.tsx@@ -1,4 +1,3 @@-import { blockElementSignal } from '@core/signal/blockElement';import { CodeNode } from '@lexical/code';import type { CommentNode, ElementName } from '@lexical-core';import {@@ -10,9 +9,7 @@ import {ImageNode,UserMentionNode,} from '@lexical-core';-import Collapse from '@phosphor/arrow-down-right.svg';-import Expand from '@phosphor/arrow-up-left.svg';-import { cn } from '@ui';+import { cn, Layer } from '@ui';import {$getNodeByKey,$getRoot,@@ -26,8 +23,7 @@ import {type TextFormatType,TextNode,} from 'lexical';-import { createMemo, createSignal, For, Match, Show, Switch } from 'solid-js';-import { Portal } from 'solid-js/web';+import { createMemo, For, Match, Show, Switch } from 'solid-js';import { nodeType } from '../../plugins';import { markNodeKeysToIDs } from '../../plugins/comments/commentPlugin';@@ -94,8 +90,8 @@ const colors: Record<DebugNodeType, string> = {};const selectionColors = {- rangeSelection: 'bg-accent-270',- nodeSelection: 'bg-accent-240',+ rangeSelection: '',+ nodeSelection: '',noSelection: '',anchor: 'bg-[hotpink]',focus: 'bg-[gold]',@@ -314,8 +310,6 @@ function Selection(props: { selection?: SelectionRenderable; class?: string }) {}export function LexicalStateDebugger(props: { state: EditorState }) {- const [blockElement] = blockElementSignal;-const state = createMemo(() => {let nodes = EditorStateToNodeList(props.state);const selection = EditorStateToSelection(props.state);@@ -323,130 +317,108 @@ export function LexicalStateDebugger(props: { state: EditorState }) {return { nodeList: selectableNodes, selection: selection };});- const [collapsed, setCollapsed] = createSignal(true);return (- <Show when={blockElement()}>- <Portal mount={blockElement()}>- <div- class="absolute font-mono bottom-6 right-6 size-1/2 p-2 text-ink bg-surface text-xs rounded-sm border border-edge opacity-95 z-30 flex flex-col space-y-1"- classList={{- 'size-12 overflow-hidden overflow-y-hidden': collapsed(),- }}- style={{- transition: 'width 0.1s ease, height 0.1s ease',- }}- >- <div- class="top-2 left-2 size-4 flex items-center justify-center bg-surface rounded-sm shadow-sm"- role="button"- onClick={() => {- setCollapsed((prev) => !prev);- }}- tabIndex={0}- >- <Show- when={collapsed()}- fallback={<Collapse width={12} height={12} />}- >- <Expand width={12} height={12} />- </Show>- </div>- <Show when={!collapsed()}>- <div class="overflow-y-auto h-full bg-surface rounded-sm border-edge border select-children">- <For each={state().nodeList}>- {(node) => {- return (- <div- style={{ 'margin-left': `${node.depth * 24}px` }}- class="flex relative"+ <div class="font-mono text-ink bg-surface text-xs size-full min-h-0 flex flex-col overflow-hidden">+ <Layer depth={0}>+ <div class="bg-surface m-2 min-h-0 flex-1 overflow-y-auto select-children rounded-md p-1 border border-edge">+ <div class="px-1">+ <For each={state().nodeList}>+ {(node) => {+ return (+ <div+ style={{ 'margin-left': `${node.depth * 24}px` }}+ class="flex relative"+ >+ <span>+ {' '}+ {node.depth > 0 ? '↳' : ''}[{node.key}]+ </span>+ <Show when={node.id}>+ <span class="px-1 text-ink-extra-muted">{node.id}</span>+ </Show>+ <Show when={node.peerId}>+ <span class="bg-accent-30/15 border border-accent-30/30 text-accent-30 mx-0.5">+ Peer ID: {node.peerId}+ </span>+ </Show>+ <Show+ when={node.sharedPeers && node.sharedPeers.length > 0}>- <span>- {' '}- {node.depth > 0 ? '↳' : ''}[{node.key}]+ <span class="bg-accent-30/15 border border-accent-30/30 text-accent-30 mx-0.5">+ <For each={node.sharedPeers}>+ {(id) => <span>{id}</span>}+ </For></span>- <Show when={node.id}>- <span class="px-1 text-ink-extra-muted">{node.id}</span>- </Show>- <Show when={node.peerId}>- <span class="bg-accent-30/15 border border-accent-30/30 text-accent-30 mx-0.5">- Peer ID: {node.peerId}- </span>- </Show>- <Show- when={node.sharedPeers && node.sharedPeers.length > 0}- >- <span class="bg-accent-30/15 border border-accent-30/30 text-accent-30 mx-0.5">- <For each={node.sharedPeers}>- {(id) => <span>{id}</span>}- </For>+ </Show>+ <span+ class={cn('inline-block px-1 mx-1', colors[node.type])}+ >+ {node.type}+ </span>+ <For each={node.styles}>+ {(style) => (+ <span class="bg-accent-60/15 border border-accent-60/30 text-accent-60 mx-0.5">+ {style}</span>- </Show>- <span- class={cn('inline-block px-1 mx-1', colors[node.type])}- >- {node.type}+ )}+ </For>+ <span class="inline-block">{node.text}</span>+ <SelectionIndicator+ anchor={node.isAnchor}+ focus={node.isFocus}+ selected={node.selected}+ class=""+ />+ <Show+ when={+ node.type === 'mark' || node.type === 'comment-mark'+ }+ >+ <span class="bg-accent-90/15 border border-accent-90/30 text-accent-90 mx-0.5">+ {markNodeKeysToIDs.get(node.key)?.join(', ') ?? ''}</span>- <For each={node.styles}>- {(style) => (- <span class="bg-accent-60/15 border border-accent-60/30 text-accent-60 mx-0.5">- {style}- </span>- )}- </For>- <span class="inline-block">{node.text}</span>- <SelectionIndicator- anchor={node.isAnchor}- focus={node.isFocus}- selected={node.selected}- class=""- />- <Show- when={- node.type === 'mark' || node.type === 'comment-mark'- }- >- <span class="bg-accent-90/15 border border-accent-90/30 text-accent-90 mx-0.5">- {markNodeKeysToIDs.get(node.key)?.join(', ') ?? ''}- </span>- <Show when={node.type === 'comment-mark'}>- {(_) => {- const commentNode = () =>- $getNodeByKey(- node.key,- props.state- ) as CommentNode | null;- return (- <Show when={commentNode()}>- {(commentNode) => (- <span- class="bg-accent-90/15 border border-accent-90/30 text-accent-90 mx-0.5"- classList={{- 'bg-accent-30/30':- commentNode().getIsDraft(),- 'bg-accent-30/5':- !commentNode().getIsDraft(),- }}- >- {commentNode().getThreadId() ?? 'NO # ID'}- </span>- )}- </Show>- );- }}- </Show>+ <Show when={node.type === 'comment-mark'}>+ {(_) => {+ const commentNode = () =>+ $getNodeByKey(+ node.key,+ props.state+ ) as CommentNode | null;+ return (+ <Show when={commentNode()}>+ {(commentNode) => (+ <span+ class="bg-accent-90/15 border border-accent-90/30 text-accent-90 mx-0.5"+ classList={{+ 'bg-accent-30/30':+ commentNode().getIsDraft(),+ 'bg-accent-30/5':+ !commentNode().getIsDraft(),+ }}+ >+ {commentNode().getThreadId() ?? 'NO # ID'}+ </span>+ )}+ </Show>+ );+ }}</Show>- </div>- );- }}- </For>- </div>- </Show>+ </Show>+ </div>+ );+ }}+ </For>+ </div>+ </div>+ </Layer>+ <Layer depth={0}>+ <div class="bg-surface m-2 shrink-0"><Selectionselection={state().selection}- class="bg-edge p-1 border border-edge"+ class="bg-surface p-1 border border-edge rounded-md"/></div>- </Portal>- </Show>+ </Layer>+ </div>);}diff --git a/js/app/packages/core/context/team.tsx b/js/app/packages/core/context/team.tsxnew file mode 100644index 0000000000..1b0ade8d3e--- /dev/null+++ b/js/app/packages/core/context/team.tsx@@ -0,0 +1,25 @@+import { useCurrentTeamQuery } from '@queries/team/teams';+import { type Accessor, createMemo } from 'solid-js';+import { createAssertedContextProvider } from './createContext';++export const MACRO_TEAM_SLUG = 'MACRO';++type TeamContextValue = {+ isMacroTeam: Accessor<boolean>;+};++export const [TeamContextProvider, useTeamContext] =+ createAssertedContextProvider('TeamContext', (): TeamContextValue => {+ const currentTeam = useCurrentTeamQuery();+ const isMacroTeam = createMemo(+ () => currentTeam.data?.team.slug === MACRO_TEAM_SLUG+ );++ return {+ isMacroTeam,+ };+ });++export function useIsMacroTeam() {+ return useTeamContext().isMacroTeam;+}diff --git a/js/app/packages/core/hotkey/tokens.ts b/js/app/packages/core/hotkey/tokens.tsindex 48f40430fb..776d05d49c 100644--- a/js/app/packages/core/hotkey/tokens.ts+++ b/js/app/packages/core/hotkey/tokens.ts@@ -226,6 +226,7 @@ export const TOKENS = {math: 'md.math',table: 'md.table',divider: 'md.divider',+ toggleStateDebugger: 'md.toggleStateDebugger',},// create menu