diff --git a/src/components/Toolbar.tsx b/src/components/Toolbar.tsx index d5de7b9..c869d08 100644 --- a/src/components/Toolbar.tsx +++ b/src/components/Toolbar.tsx @@ -173,7 +173,9 @@ export default function Toolbar({ ? "Heading: H2 → H3" : editor?.isActive("heading", { level: 3 }) ? "Heading: H3 → Normal" - : "Heading: Normal → H1" + : editor?.isActive("bulletList") || editor?.isActive("orderedList") || editor?.isActive("taskList") + ? "Heading: List → H1" + : "Heading: Normal → H1" } icon={} /> diff --git a/src/features/editor/editorCommands.ts b/src/features/editor/editorCommands.ts index 0121abe..ec921be 100644 --- a/src/features/editor/editorCommands.ts +++ b/src/features/editor/editorCommands.ts @@ -169,6 +169,22 @@ export function setCodeBlockLanguage(editor: Editor, language: string): void { } export function cycleHeading(editor: Editor): void { + // If the cursor is inside a list item, first remove the list formatting, + // then convert the lifted paragraph to H1. + if (editor.isActive("bulletList")) { + editor.chain().focus().toggleBulletList().setHeading({ level: 1 }).run(); + return; + } + if (editor.isActive("orderedList")) { + editor.chain().focus().toggleOrderedList().setHeading({ level: 1 }).run(); + return; + } + if (editor.isActive("taskList")) { + // taskList has no built-in toggle command, so we use liftListItem directly. + editor.chain().focus().liftListItem("taskItem").setHeading({ level: 1 }).run(); + return; + } + if (editor.isActive("heading", { level: 1 })) { editor.chain().focus().setHeading({ level: 2 }).run(); } else if (editor.isActive("heading", { level: 2 })) {