feat: Enable block insertion in table cells from formatting menu

fix: Remove gutter controls from headers not at root
This commit is contained in:
Tom Moor
2024-06-01 12:21:33 -04:00
parent f2e9c0ab23
commit 938fd6ed2d
2 changed files with 27 additions and 17 deletions

View File

@@ -19,7 +19,6 @@ import {
Heading3Icon,
} from "outline-icons";
import { EditorState } from "prosemirror-state";
import { isInTable } from "prosemirror-tables";
import * as React from "react";
import isInCode from "@shared/editor/queries/isInCode";
import isInList from "@shared/editor/queries/isInList";
@@ -35,11 +34,9 @@ export default function formattingMenuItems(
dictionary: Dictionary
): MenuItem[] {
const { schema } = state;
const isTable = isInTable(state);
const isList = isInList(state);
const isCode = isInCode(state);
const isCodeBlock = isInCode(state, { onlyBlock: true });
const allowBlocks = !isTable && !isList;
return [
{
@@ -90,7 +87,7 @@ export default function formattingMenuItems(
},
{
name: "separator",
visible: allowBlocks && !isCode,
visible: !isCode,
},
{
name: "heading",
@@ -98,7 +95,7 @@ export default function formattingMenuItems(
icon: <Heading1Icon />,
active: isNodeActive(schema.nodes.heading, { level: 1 }),
attrs: { level: 1 },
visible: allowBlocks && !isCode,
visible: !isCode,
},
{
name: "heading",
@@ -106,7 +103,7 @@ export default function formattingMenuItems(
icon: <Heading2Icon />,
active: isNodeActive(schema.nodes.heading, { level: 2 }),
attrs: { level: 2 },
visible: allowBlocks && !isCode,
visible: !isCode,
},
{
name: "heading",
@@ -114,7 +111,7 @@ export default function formattingMenuItems(
icon: <Heading3Icon />,
active: isNodeActive(schema.nodes.heading, { level: 3 }),
attrs: { level: 3 },
visible: allowBlocks && !isCode,
visible: !isCode,
},
{
name: "blockquote",
@@ -122,11 +119,11 @@ export default function formattingMenuItems(
icon: <BlockQuoteIcon />,
active: isNodeActive(schema.nodes.blockquote),
attrs: { level: 2 },
visible: allowBlocks && !isCode,
visible: !isCode,
},
{
name: "separator",
visible: (allowBlocks || isList) && !isCode,
visible: !isCode,
},
{
name: "checkbox_list",
@@ -134,21 +131,21 @@ export default function formattingMenuItems(
icon: <TodoListIcon />,
keywords: "checklist checkbox task",
active: isNodeActive(schema.nodes.checkbox_list),
visible: (allowBlocks || isList) && !isCode,
visible: !isCode,
},
{
name: "bullet_list",
tooltip: dictionary.bulletList,
icon: <BulletedListIcon />,
active: isNodeActive(schema.nodes.bullet_list),
visible: (allowBlocks || isList) && !isCode,
visible: !isCode,
},
{
name: "ordered_list",
tooltip: dictionary.orderedList,
icon: <OrderedListIcon />,
active: isNodeActive(schema.nodes.ordered_list),
visible: (allowBlocks || isList) && !isCode,
visible: !isCode,
},
{
name: "outdentList",