Skip to content

Commit

Permalink
fix: fix table menu entry always manipulating the menu icon of the la…
Browse files Browse the repository at this point in the history
…st initialized editor instance
  • Loading branch information
b-kelly committed Feb 25, 2022
1 parent b69c3e0 commit cc592c1
Showing 1 changed file with 32 additions and 31 deletions.
63 changes: 32 additions & 31 deletions src/rich-text/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,38 +181,39 @@ function markActive(mark: MarkType) {
};
}

const tableDropdown = makeMenuDropdown(
"Table",
"Edit table",
"table-dropdown",
(state: EditorState) => inTable(state.selection),
const tableDropdown = () =>
makeMenuDropdown(
"Table",
"Edit table",
"table-dropdown",
(state: EditorState) => inTable(state.selection),

dropdownSection("Column", "columnSection"),
dropdownItem("Remove column", removeColumnCommand, "remove-column-btn"),
dropdownItem(
"Insert column before",
insertTableColumnBeforeCommand,
"insert-column-before-btn"
),
dropdownItem(
"Insert column after",
insertTableColumnAfterCommand,
"insert-column-after-btn"
),
dropdownSection("Column", "columnSection"),
dropdownItem("Remove column", removeColumnCommand, "remove-column-btn"),
dropdownItem(
"Insert column before",
insertTableColumnBeforeCommand,
"insert-column-before-btn"
),
dropdownItem(
"Insert column after",
insertTableColumnAfterCommand,
"insert-column-after-btn"
),

dropdownSection("Row", "rowSection"),
dropdownItem("Remove row", removeRowCommand, "remove-row-btn"),
dropdownItem(
"Insert row before",
insertTableRowBeforeCommand,
"insert-row-before-btn"
),
dropdownItem(
"Insert row after",
insertTableRowAfterCommand,
"insert-row-after-btn"
)
);
dropdownSection("Row", "rowSection"),
dropdownItem("Remove row", removeRowCommand, "remove-row-btn"),
dropdownItem(
"Insert row before",
insertTableRowBeforeCommand,
"insert-row-before-btn"
),
dropdownItem(
"Insert row after",
insertTableRowAfterCommand,
"insert-row-after-btn"
)
);

export const createMenu = (options: CommonViewOptions): Plugin =>
createMenuPlugin(
Expand Down Expand Up @@ -289,7 +290,7 @@ export const createMenu = (options: CommonViewOptions): Plugin =>
},
options.parserFeatures.tables
),
addIf(tableDropdown, options.parserFeatures.tables),
addIf(tableDropdown(), options.parserFeatures.tables),
makeMenuSpacerEntry(),
{
key: "toggleOrderedList",
Expand Down

0 comments on commit cc592c1

Please sign in to comment.