From 38b3efd6f9958b3d73c1314e4268c623cb00a7c7 Mon Sep 17 00:00:00 2001 From: umaranis Date: Wed, 13 Nov 2024 21:42:36 +1100 Subject: [PATCH] feat: Table Menu for add row/column, delete, merge, cell color etc. --- .../colorpicker/ColorPickerDialog.svelte | 44 ++ .../components/generic/portal/Portal.svelte | 24 + .../core/plugins/Table/TableActionMenu.svelte | 561 ++++++++++++++++++ .../Table/TableActionMenuPlugin.svelte | 134 +++++ .../src/routes/RichTextComposer.svelte | 2 + 5 files changed, 765 insertions(+) create mode 100644 packages/svelte-lexical/src/lib/components/generic/colorpicker/ColorPickerDialog.svelte create mode 100644 packages/svelte-lexical/src/lib/components/generic/portal/Portal.svelte create mode 100644 packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenu.svelte create mode 100644 packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenuPlugin.svelte diff --git a/packages/svelte-lexical/src/lib/components/generic/colorpicker/ColorPickerDialog.svelte b/packages/svelte-lexical/src/lib/components/generic/colorpicker/ColorPickerDialog.svelte new file mode 100644 index 0000000..51b4153 --- /dev/null +++ b/packages/svelte-lexical/src/lib/components/generic/colorpicker/ColorPickerDialog.svelte @@ -0,0 +1,44 @@ + + + + + + + diff --git a/packages/svelte-lexical/src/lib/components/generic/portal/Portal.svelte b/packages/svelte-lexical/src/lib/components/generic/portal/Portal.svelte new file mode 100644 index 0000000..4a48040 --- /dev/null +++ b/packages/svelte-lexical/src/lib/components/generic/portal/Portal.svelte @@ -0,0 +1,24 @@ + + +
+ +
diff --git a/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenu.svelte b/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenu.svelte new file mode 100644 index 0000000..1bd3bb0 --- /dev/null +++ b/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenu.svelte @@ -0,0 +1,561 @@ + + + + + + + + + + diff --git a/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenuPlugin.svelte b/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenuPlugin.svelte new file mode 100644 index 0000000..7260674 --- /dev/null +++ b/packages/svelte-lexical/src/lib/core/plugins/Table/TableActionMenuPlugin.svelte @@ -0,0 +1,134 @@ + + +
+ {#if $tableCellNode != null} + + {#if $isMenuOpen} + ($isMenuOpen = val)} + onClose={() => ($isMenuOpen = false)} + _tableCellNode={$tableCellNode} + {cellMerge} /> + {/if} + {/if} +
diff --git a/packages/svelte-lexical/src/routes/RichTextComposer.svelte b/packages/svelte-lexical/src/routes/RichTextComposer.svelte index 5406269..3cd8e80 100644 --- a/packages/svelte-lexical/src/routes/RichTextComposer.svelte +++ b/packages/svelte-lexical/src/routes/RichTextComposer.svelte @@ -50,6 +50,7 @@ import TablePlugin from '$lib/core/plugins/Table/TablePlugin.svelte'; import {TableCellNode, TableNode, TableRowNode} from '@lexical/table'; import TableHoverActionPlugin from '$lib/core/plugins/Table/TableHoverActionPlugin.svelte'; + import TableActionMenuPlugin from '$lib/core/plugins/Table/TableActionMenuPlugin.svelte'; let isSmallWidthViewport = true; let editorDiv; @@ -148,6 +149,7 @@ +