Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(md): improve actions menu pattern, add task action (#2691)

Seamusb56ef0cbb4ca
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index a8b563be49..14bdd15fc2 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -275,6 +275,7 @@ registerComponent('task-compose', (params) => {
initialContent={params?.initialContent}
initialTitle={params?.initialTitle}
initialAssigneeId={params?.initialAssigneeId}
+ onSuccess={params?.onSuccess}
/>
);
});
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index 0a7d52d90e..128a9c6676 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -42,7 +42,7 @@ export type SplitContent =
| {
type: 'component';
id: string;
- params?: Record<string, string>;
+ params?: Record<string, unknown>;
};
export type SplitContentType = SplitContent['type'];
diff --git a/js/app/packages/block-md/component/ComposeTask.tsx b/js/app/packages/block-md/component/ComposeTask.tsx
index 2a732f319e..56d29a5cbe 100644
--- a/js/app/packages/block-md/component/ComposeTask.tsx
+++ b/js/app/packages/block-md/component/ComposeTask.tsx
@@ -154,6 +154,12 @@ function extractPropertyValue(
* @returns
*/
+export type ComposeTaskSuccess = {
+ documentId: string;
+ title: string;
+ content: string;
+};
+
export interface ComposeTaskProps {
onCreateTask?: (title: string, content: string) => void;
onClose?: () => void;
@@ -161,6 +167,11 @@ export interface ComposeTaskProps {
initialContent?: string;
placeholder?: string;
initialAssigneeId?: string;
+ /**
+ * When provided, replaces the default success behavior (auto-copy link +
+ * toast) so the caller can handle the created task however it needs.
+ */
+ onSuccess?: (result: ComposeTaskSuccess) => void;
}
export function ComposeTask(props: ComposeTaskProps) {
@@ -451,7 +462,11 @@ export function ComposeTask(props: ComposeTaskProps) {
return;
}
- showTaskCreatedToast(documentId, taskTitle, taskContent);
+ if (props.onSuccess) {
+ props.onSuccess({ documentId, title: taskTitle, content: taskContent });
+ } else {
+ showTaskCreatedToast(documentId, taskTitle, taskContent);
+ }
props.onCreateTask?.(taskTitle, taskContent);
return;
}
@@ -472,7 +487,11 @@ export function ComposeTask(props: ComposeTaskProps) {
// Success: clear draft and notify
clearTaskComposerDraft();
- showTaskCreatedToast(documentId, taskTitle, taskContent);
+ if (props.onSuccess) {
+ props.onSuccess({ documentId, title: taskTitle, content: taskContent });
+ } else {
+ showTaskCreatedToast(documentId, taskTitle, taskContent);
+ }
props.onCreateTask?.(taskTitle, taskContent);
if (createMore()) {
diff --git a/js/app/packages/block-md/component/useMarkdownCommands.ts b/js/app/packages/block-md/component/useMarkdownCommands.ts
index 8ccaf5ab3a..be4b98a1fc 100644
--- a/js/app/packages/block-md/component/useMarkdownCommands.ts
+++ b/js/app/packages/block-md/component/useMarkdownCommands.ts
@@ -158,6 +158,16 @@ export function registerMarkdownCommands(
editor.focus();
return true;
},
+ hide: () => {
+ const editor = getEditor();
+ if (!editor) return true;
+ return !editor.hasNodes(action.dependencies ?? []);
+ },
+ condition: () => {
+ const editor = getEditor();
+ if (!editor) return false;
+ return editor.hasNodes(action.dependencies ?? []);
+ },
}).withGroup(group);
}
diff --git a/js/app/packages/channel/Input/ChannelInput.tsx b/js/app/packages/channel/Input/ChannelInput.tsx
index 6ef835fdce..33985c414f 100644
--- a/js/app/packages/channel/Input/ChannelInput.tsx
+++ b/js/app/packages/channel/Input/ChannelInput.tsx
@@ -136,6 +136,7 @@ export function ChannelInput(props: ChannelInputProps) {
inputState.commands.attachFiles(entries.map((entry) => entry.file))
);
},
+ onAttachFromDisk: (files) => inputState.commands.attachFiles(files),
});
// On iOS, blur before clearing so dictation finalizes and discards its buffer
// (otherwise it re-injects the sent text into the cleared editor). Re-focus
diff --git a/js/app/packages/channel/Input/configured-markdown-editor.ts b/js/app/packages/channel/Input/configured-markdown-editor.ts
index e7d0f5b404..caece7a7ac 100644
--- a/js/app/packages/channel/Input/configured-markdown-editor.ts
+++ b/js/app/packages/channel/Input/configured-markdown-editor.ts
@@ -4,6 +4,10 @@ import {
type ItemMention,
keyboardShortcutsPlugin,
} from '@core/component/LexicalMarkdown/plugins';
+import {
+ ActionCategory,
+ type Action,
+} from '@core/component/LexicalMarkdown/plugins/actions/types';
import { iosCursorScrollPlugin } from '@core/component/LexicalMarkdown/plugins/ios-cursor-scroll';
import { tableCellResizerPlugin } from '@core/component/LexicalMarkdown/plugins/tables/tableCellResizerPlugin';
import { tablePlugin } from '@core/component/LexicalMarkdown/plugins/tables/tablePlugin';
@@ -11,6 +15,7 @@ import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';
import type { IUser } from '@core/user/types';
import { isIOS } from '@solid-primitives/platform';
import type { Accessor } from 'solid-js';
+import ImageIcon from '@icon/regular/image.svg';
type CreateConfiguredChannelMarkdownEditorOptions = {
namespace: string;
@@ -24,6 +29,8 @@ type CreateConfiguredChannelMarkdownEditorOptions = {
files: FileSystemFileEntry[],
directories: FileSystemDirectoryEntry[]
) => void;
+ /** Invoked when the user picks the "Image" slash action. Opens a file picker and hands files back. */
+ onAttachFromDisk?: (files: File[]) => void;
scrollContainer?: Accessor<HTMLElement | undefined>;
};
@@ -49,11 +56,37 @@ export function createConfiguredChannelMarkdownEditor(
editor
.withEmojis()
+ .withActions({ ignoreActionIds: ['hr', 'table', 'latex'] })
.withLinks({ floatingMenu: true })
.withHistory({ timeGap: 400 })
.withCode()
.withRestoreFocus()
- .withSelectionData()
+ .withSelectionData();
+
+ if (options.onAttachFromDisk) {
+ const onAttachFromDisk = options.onAttachFromDisk;
+ const attachFromDiskAction: Action = {
+ id: 'image',
+ name: 'Image',
+ keywords: ['picture', 'photo', 'img', 'upload', 'attach'],
+ category: ActionCategory.MEDIA,
+ icon: ImageIcon,
+ action: () => {
+ const input = document.createElement('input');
+ input.type = 'file';
+ input.multiple = true;
+ input.accept = 'image/*';
+ input.addEventListener('change', () => {
+ const files = Array.from(input.files ?? []);
+ if (files.length > 0) onAttachFromDisk(files);
+ });
+ input.click();
+ },
+ };
+ editor.withActions({ additionalActions: [attachFromDiskAction] });
+ }
+
+ editor
.use(
tablePlugin({
hasCellMerge: true,
diff --git a/js/app/packages/channel/Input/tests/input-slots.test.tsx b/js/app/packages/channel/Input/tests/input-slots.test.tsx
index d1b187f36f..5bbdca9e69 100644
--- a/js/app/packages/channel/Input/tests/input-slots.test.tsx
+++ b/js/app/packages/channel/Input/tests/input-slots.test.tsx
@@ -4,9 +4,9 @@
import userEvent from '@testing-library/user-event';
import { render, screen } from '@solidjs/testing-library';
-import { beforeAll, describe, expect, it, vi } from 'vitest';
+import { describe, expect, it, vi } from 'vitest';
-beforeAll(() => {
+vi.hoisted(() => {
Object.defineProperty(window, 'matchMedia', {
writable: true,
value: (query: string) => ({
@@ -90,6 +90,7 @@ vi.mock(
namespace: () => builder,
withMentions: () => builder,
withEmojis: () => builder,
+ withActions: () => builder,
withLinks: () => builder,
withHistory: () => builder,
withCode: () => builder,
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownConfigBuilder.ts b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownConfigBuilder.ts
index c5340f2ae2..c672eb43e9 100644
--- a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownConfigBuilder.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownConfigBuilder.ts
@@ -1,6 +1,7 @@
import type { LexicalEditor } from 'lexical';
import type { Store } from 'solid-js/store';
import type { PluginManager, SelectionData } from '../plugins';
+import type { Action } from '../plugins/actions/types';
import { buildHandleFromConfig } from './buildHandleFromConfig';
import type {
ActionsOptions,
@@ -116,7 +117,29 @@ export class EditorConfigBuilder implements EditorBuilder {
}
withActions(config: ActionsOptions = {}): this {
- this.state.actions = config;
+ const existing =
+ typeof this.state.actions === 'object' ? this.state.actions : {};
+
+ const existingAdditional = existing.additionalActions ?? [];
+ const incomingAdditional = config.additionalActions ?? [];
+ const byId = new Map<string, Action>();
+ for (const action of existingAdditional) byId.set(action.id, action);
+ for (const action of incomingAdditional) byId.set(action.id, action);
+ const mergedAdditional = Array.from(byId.values());
+
+ const mergedIgnore = Array.from(
+ new Set([
+ ...(existing.ignoreActionIds ?? []),
+ ...(config.ignoreActionIds ?? []),
+ ])
+ );
+
+ this.state.actions = {
+ ...existing,
+ ...config,
+ additionalActions: mergedAdditional.length ? mergedAdditional : undefined,
+ ignoreActionIds: mergedIgnore.length ? mergedIgnore : undefined,
+ };
return this;
}
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
index b197cb0d24..100c68650b 100644
--- a/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
@@ -254,10 +254,16 @@ export const MarkdownShell: Component<
<ActionMenu
editor={editor}
menu={menu()}
- useBlockBoundary={
- typeof builderConfig.actions === 'object'
- ? (builderConfig.actions.useBlockBoundary ?? false)
- : false
+ useBlockBoundary={false}
+ additionalActions={
+ (builderConfig.actions &&
+ builderConfig.actions.additionalActions) ||
+ undefined
+ }
+ ignoreActionIds={
+ (builderConfig.actions &&
+ builderConfig.actions.ignoreActionIds) ||
+ undefined
}
portalScope={props.portalScope}
/>
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/types.ts b/js/app/packages/core/component/LexicalMarkdown/builder/types.ts
index 02ee84fd1e..3631ee14eb 100644
--- a/js/app/packages/core/component/LexicalMarkdown/builder/types.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/types.ts
@@ -11,11 +11,16 @@ import type {
PluginManager,
SelectionData,
} from '../plugins';
+import type { Action } from '../plugins/actions/types';
import type { createMenuOperations } from '../shared/inlineMenu';
import type { MentionBucketId } from '../component/menu/MentionsMenu/MentionsMenuController';
export interface ActionsOptions {
useBlockBoundary?: boolean;
+ /** Extra actions to append to the default slash-menu actions. */
+ additionalActions?: Action[];
+ /** IDs of default actions to hide from the slash menu. */
+ ignoreActionIds?: string[];
}
export interface MentionsOptions {
diff --git a/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx b/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
index 5520c951c6..86db01415c 100644
--- a/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
+++ b/js/app/packages/core/component/LexicalMarkdown/component/menu/ActionsMenu.tsx
@@ -1,7 +1,6 @@
import { ClippedPanel } from '@core/component/ClippedPanel';
import { type PortalScope, ScopedPortal } from '@core/component/ScopedPortal';
import clickOutside from '@core/directive/clickOutside';
-import { isMobileWidth } from '@core/mobile/mobileWidth';
import { fuzzyFilter } from '@core/util/fuzzy';
import { debounce } from '@solid-primitives/scheduled';
import type { LexicalEditor } from 'lexical';
@@ -19,10 +18,12 @@ import { Dynamic } from 'solid-js/web';
import { floatWithElement } from '../../directive/floatWithElement';
import { floatWithSelection } from '../../directive/floatWithSelection';
import {
+ autoRegister,
CLOSE_ACTION_SEARCH_COMMAND,
REMOVE_ACTION_SEARCH_COMMAND,
} from '../../plugins';
-import { ACTIONS, type Action } from '../../plugins/actions/actions';
+import { ACTIONS } from '../../plugins/actions/actions';
+import type { Action } from '../../plugins/actions/types';
import type { MenuOperations } from '../../shared/inlineMenu';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import { useMenuKeyboardNavigation } from './useMenuKeyboardNavigation';
@@ -31,8 +32,8 @@ false && clickOutside;
false && floatWithSelection;
false && floatWithElement;
-// py-2 on the menu container = 8px top + 8px bottom
-const MENU_DECORATION_HEIGHT = 16;
+// ClippedPanel's p-px border (2px) + py-2 padding (16px)
+const PANEL_DECORATION_HEIGHT = 18;
export function ActionsMenuItem(props: {
action: Action;
@@ -42,8 +43,17 @@ export function ActionsMenuItem(props: {
setIndex: (index: number) => void;
setOpen: (open: boolean) => void;
}) {
+ let itemRef: HTMLDivElement | undefined;
+
+ createEffect(() => {
+ if (props.selected && itemRef) {
+ itemRef.scrollIntoView({ block: 'nearest' });
+ }
+ });
+
return (
<div
+ ref={itemRef}
on:mouseup={(e) => {
e.preventDefault();
e.stopPropagation();
@@ -56,9 +66,20 @@ export function ActionsMenuItem(props: {
e.preventDefault();
e.stopPropagation();
props.editor.dispatchCommand(REMOVE_ACTION_SEARCH_COMMAND, undefined);
- const action = props.action.action;
+ const { action, dependencies } = props.action;
if (action) {
- action(props.editor);
+ if (dependencies !== undefined) {
+ if (props.editor.hasNodes(dependencies)) {
+ action(props.editor);
+ } else {
+ console.error(
+ 'Dispatched Action with missing dependencies:',
+ props.action
+ );
+ }
+ } else {
+ action(props.editor);
+ }
}
props.setOpen(false);
}}
@@ -88,19 +109,29 @@ export function ActionMenu(props: {
portalScope?: PortalScope;
/** whether the menu checks against block boundary in floating middleware. uses floating-ui default if false. */
useBlockBoundary?: boolean;
+ /** Extra actions appended to the default action list. */
+ additionalActions?: Action[];
+ /** IDs of default actions to exclude from the menu. */
+ ignoreActionIds?: string[];
}) {
const { isOpen, setIsOpen } = props.menu;
const [selectedIndex, setSelectedIndex] = createSignal(0);
+
let menuRef!: HTMLDivElement;
+
const [mountSelection, setMountSelection] = createSignal<Selection | null>();
+
const [menuAvailableHeight, setMenuAvailableHeight] = createSignal<
number | undefined
>(undefined);
+
+ // Cap at 256px (16rem) so the menu stays compact when plenty of space is available,
+ // and floor at 0 after subtracting ClippedPanel decorations.
const contentMaxHeight = () => {
const h = menuAvailableHeight();
if (h === undefined) return undefined;
- return Math.max(0, h - MENU_DECORATION_HEIGHT);
+ return Math.min(256, Math.max(0, h - PANEL_DECORATION_HEIGHT));
};
const { isKeypressActive } = useIsKeyPressActive();
@@ -115,15 +146,27 @@ export function ActionMenu(props: {
60
);
- const maxItems = () => {
- return isMobileWidth() ? 4 : 8;
- };
-
const [, setEditorParent] = createSignal<HTMLElement>();
- const cleanupRootListener = props.editor.registerRootListener(() => {
- setEditorParent(props.editor.getRootElement()?.parentElement ?? undefined);
+ autoRegister(() =>
+ props.editor.registerRootListener(() => {
+ setEditorParent(
+ props.editor.getRootElement()?.parentElement ?? undefined
+ );
+ })
+ );
+
+ const merged: Action[] = [...ACTIONS];
+ for (const override of props.additionalActions ?? []) {
+ const idx = merged.findIndex((a) => a.id === override.id);
+ if (idx >= 0) merged[idx] = override;
+ else merged.push(override);
+ }
+ const validActions = merged.filter((action) => {
+ if (props.ignoreActionIds?.includes(action.id)) return false;
+ const { dependencies } = action;
+ if (dependencies === undefined || dependencies.length === 0) return true;
+ return props.editor.hasNodes(dependencies);
});
- onCleanup(cleanupRootListener);
createEffect(() => {
setSelectedIndex(0);
@@ -131,9 +174,9 @@ export function ActionMenu(props: {
});
const filteredItems = createMemo(() => {
- return fuzzyFilter(searchTerm(), ACTIONS, (item) =>
+ return fuzzyFilter(searchTerm(), validActions, (item) =>
[item.name, ...item.keywords].join(' ')
- ).slice(0, maxItems());
+ );
});
const [escapeSpaceState, setEscapeSpaceState] = createSignal<
diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/actions/actions.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/actions.ts
index b6588283d4..02cf0d3024 100644
--- a/js/app/packages/core/component/LexicalMarkdown/plugins/actions/actions.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/actions.ts
@@ -1,3 +1,4 @@
+import CheckSquare from '@icon/regular/check-square.svg';
import CodeBlock from '@icon/regular/code-block.svg';
import VideoIcon from '@icon/regular/file-video.svg';
import MathIcon from '@icon/regular/function.svg';
@@ -13,35 +14,28 @@ import TextH1 from '@icon/regular/text-h-one.svg';
import TextH3 from '@icon/regular/text-h-three.svg';
import TextH2 from '@icon/regular/text-h-two.svg';
import TextT from '@icon/regular/text-t.svg';
-import { INSERT_TABLE_COMMAND } from '@lexical/table';
+import { INSERT_TABLE_COMMAND, TableNode } from '@lexical/table';
import type { LexicalEditor } from 'lexical';
-import type { Component } from 'solid-js';
import { INSERT_HORIZONTAL_RULE_COMMAND } from '..';
import { TRY_INSERT_EQUATION_COMMAND } from '../katex';
import { TRY_INSERT_LINK_COMMAND } from '../links';
import { TRY_INSERT_MEDIA_UPLOAD_COMMAND } from '../media';
+import { INSERT_DOCUMENT_MENTION_COMMAND } from '../mentions/mentionsPlugin';
import { NODE_TRANSFORM } from '../node-transform';
-
-export type ActionIcon = string;
-
-export type Action = {
- id: string;
- name: string;
- keywords: string[];
- icon: Component<{ class: string }>;
- category: string;
- action: (editor: LexicalEditor) => void;
- shortcut?: string;
-};
-
-// TODO (seamus): Actaully oragnize the items based on category.
-export enum ActionCategory {
- BASIC = 'Basic',
- FORMAT = 'Formatting',
- ELEMENT = 'Elements',
- MEDIA = 'Media',
- ADVANCED = 'Advanced',
-}
+import { HeadingNode, QuoteNode } from '@lexical/rich-text';
+import {
+ CustomCodeNode,
+ DocumentMentionNode,
+ EquationNode,
+ HorizontalRuleNode,
+ ImageNode,
+ VideoNode,
+} from '@lexical-core';
+import { ListNode } from '@lexical/list';
+import { LinkNode } from '@lexical/link';
+import { globalSplitManager } from '@app/signal/splitLayout';
+import type { ComposeTaskSuccess } from '@block-md/component/ComposeTask';
+import { type Action, ActionCategory } from './types';
export const ACTIONS: Action[] = [
{
@@ -64,6 +58,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'heading1');
},
+ dependencies: [HeadingNode],
},
{
id: 'heading2',
@@ -75,6 +70,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'heading2');
},
+ dependencies: [HeadingNode],
},
{
id: 'heading3',
@@ -86,6 +82,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'heading3');
},
+ dependencies: [HeadingNode],
},
{
id: 'quote',
@@ -97,6 +94,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'quote');
},
+ dependencies: [QuoteNode],
},
{
id: 'code',
@@ -108,6 +106,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'code');
},
+ dependencies: [CustomCodeNode],
},
{
id: 'list-bullet',
@@ -119,6 +118,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'list-bullet');
},
+ dependencies: [ListNode],
},
{
id: 'list-number',
@@ -130,6 +130,7 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'list-number');
},
+ dependencies: [ListNode],
},
{
id: 'list-check',
@@ -141,6 +142,34 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(NODE_TRANSFORM, 'list-check');
},
+ dependencies: [ListNode],
+ },
+ {
+ id: 'task',
+ name: 'Task',
+ keywords: ['task', 'todo', 'create'],
+ category: ActionCategory.ELEMENT,
+ icon: CheckSquare,
+ action: (editor: LexicalEditor) => {
+ const splitManager = globalSplitManager();
+ if (!splitManager) return;
+ splitManager.createPopoverSplit({
+ content: {
+ type: 'component',
+ id: 'task-compose',
+ params: {
+ onSuccess: (result: ComposeTaskSuccess) => {
+ editor.dispatchCommand(INSERT_DOCUMENT_MENTION_COMMAND, {
+ documentId: result.documentId,
+ documentName: result.title,
+ blockName: 'task',
+ });
+ },
+ },
+ },
+ });
+ },
+ dependencies: [DocumentMentionNode],
},
{
id: 'image',
@@ -153,6 +182,7 @@ export const ACTIONS: Action[] = [
editor.dispatchCommand(TRY_INSERT_MEDIA_UPLOAD_COMMAND, 'all');
});
},
+ dependencies: [ImageNode, VideoNode],
},
{
id: 'video',
@@ -165,6 +195,7 @@ export const ACTIONS: Action[] = [
editor.dispatchCommand(TRY_INSERT_MEDIA_UPLOAD_COMMAND, 'all');
});
},
+ dependencies: [ImageNode, VideoNode],
},
{
id: 'link',
@@ -177,6 +208,7 @@ export const ACTIONS: Action[] = [
editor.dispatchCommand(TRY_INSERT_LINK_COMMAND, undefined);
});
},
+ dependencies: [LinkNode],
},
{
id: 'latex',
@@ -189,6 +221,7 @@ export const ACTIONS: Action[] = [
editor.dispatchCommand(TRY_INSERT_EQUATION_COMMAND, undefined);
});
},
+ dependencies: [EquationNode],
},
{
id: 'table',
@@ -205,6 +238,7 @@ export const ACTIONS: Action[] = [
});
});
},
+ dependencies: [TableNode],
},
{
id: 'hr',
@@ -216,5 +250,6 @@ export const ACTIONS: Action[] = [
action: (editor: LexicalEditor) => {
editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined);
},
+ dependencies: [HorizontalRuleNode],
},
];
diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/actions/index.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/index.ts
index 8760b87419..995705facf 100644
--- a/js/app/packages/core/component/LexicalMarkdown/plugins/actions/index.ts
+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/index.ts
@@ -1,4 +1,5 @@
export * from './actions';
+export * from './types';
export {
actionsPlugin,
CLOSE_ACTION_SEARCH_COMMAND,
diff --git a/js/app/packages/core/component/LexicalMarkdown/plugins/actions/types.ts b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/types.ts
new file mode 100644
index 0000000000..73a2962a89
--- /dev/null
+++ b/js/app/packages/core/component/LexicalMarkdown/plugins/actions/types.ts
@@ -0,0 +1,24 @@
+import type { KlassConstructor, LexicalEditor, LexicalNode } from 'lexical';
+import type { Component } from 'solid-js';
+
+export type ActionIcon = string;
+
+export type Action = {
+ id: string;
+ name: string;
+ keywords: string[];
+ icon: Component<{ class: string }>;
+ category: string;
+ action: (editor: LexicalEditor) => void;
+ shortcut?: string;
+ dependencies?: Array<KlassConstructor<typeof LexicalNode>>;
+};
+
+// TODO (seamus): Actually organize the items based on category.
+export enum ActionCategory {
+ BASIC = 'Basic',
+ FORMAT = 'Formatting',
+ ELEMENT = 'Elements',
+ MEDIA = 'Media',
+ ADVANCED = 'Advanced',
+}