1 import {EditorBasicButtonDefinition, EditorButtonDefinition} from "../../framework/buttons";
2 import tableIcon from "@icons/editor/table.svg";
3 import deleteIcon from "@icons/editor/table-delete.svg";
4 import deleteColumnIcon from "@icons/editor/table-delete-column.svg";
5 import deleteRowIcon from "@icons/editor/table-delete-row.svg";
6 import insertColumnAfterIcon from "@icons/editor/table-insert-column-after.svg";
7 import insertColumnBeforeIcon from "@icons/editor/table-insert-column-before.svg";
8 import insertRowAboveIcon from "@icons/editor/table-insert-row-above.svg";
9 import insertRowBelowIcon from "@icons/editor/table-insert-row-below.svg";
10 import {EditorUiContext} from "../../framework/core";
11 import {$getBlockElementNodesInSelection, $getNodeFromSelection, $getParentOfType} from "../../../helpers";
12 import {$getSelection} from "lexical";
13 import {$isCustomTableNode, CustomTableNode} from "../../../nodes/custom-table";
15 $deleteTableColumn, $deleteTableColumn__EXPERIMENTAL,
16 $deleteTableRow__EXPERIMENTAL,
17 $getTableRowIndexFromTableCellNode, $insertTableColumn, $insertTableColumn__EXPERIMENTAL,
18 $insertTableRow, $insertTableRow__EXPERIMENTAL,
22 } from "@lexical/table";
25 export const table: EditorBasicButtonDefinition = {
30 export const deleteTable: EditorButtonDefinition = {
31 label: 'Delete table',
33 action(context: EditorUiContext) {
34 context.editor.update(() => {
35 const table = $getNodeFromSelection($getSelection(), $isCustomTableNode);
46 export const insertRowAbove: EditorButtonDefinition = {
47 label: 'Insert row above',
48 icon: insertRowAboveIcon,
49 action(context: EditorUiContext) {
50 context.editor.update(() => {
51 $insertTableRow__EXPERIMENTAL(false);
59 export const insertRowBelow: EditorButtonDefinition = {
60 label: 'Insert row below',
61 icon: insertRowBelowIcon,
62 action(context: EditorUiContext) {
63 context.editor.update(() => {
64 $insertTableRow__EXPERIMENTAL(true);
72 export const deleteRow: EditorButtonDefinition = {
75 action(context: EditorUiContext) {
76 context.editor.update(() => {
77 $deleteTableRow__EXPERIMENTAL();
85 export const insertColumnBefore: EditorButtonDefinition = {
86 label: 'Insert column before',
87 icon: insertColumnBeforeIcon,
88 action(context: EditorUiContext) {
89 context.editor.update(() => {
90 $insertTableColumn__EXPERIMENTAL(false);
98 export const insertColumnAfter: EditorButtonDefinition = {
99 label: 'Insert column after',
100 icon: insertColumnAfterIcon,
101 action(context: EditorUiContext) {
102 context.editor.update(() => {
103 $insertTableColumn__EXPERIMENTAL(true);
111 export const deleteColumn: EditorButtonDefinition = {
112 label: 'Delete column',
113 icon: deleteColumnIcon,
114 action(context: EditorUiContext) {
115 context.editor.update(() => {
116 $deleteTableColumn__EXPERIMENTAL();