-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Table Menu for add row/column, delete, merge, cell color etc.
- Loading branch information
Showing
5 changed files
with
765 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
packages/svelte-lexical/src/lib/components/generic/colorpicker/ColorPickerDialog.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<script lang="ts"> | ||
import {getCommands} from '$lib/core/commands.js'; | ||
import {getEditor} from '$lib/core/composerContext.js'; | ||
import CloseCircleButton from '../../generic/button/CloseCircleButton.svelte'; | ||
import ModalDialog from '../../generic/dialog/ModalDialog.svelte'; | ||
import ColorPicker from './ColorPicker.svelte'; | ||
export let color: string; | ||
export let title: string; | ||
let onChange: | ||
| ((value: string, skipHistoryStack: boolean) => void) | ||
| undefined; | ||
const editor = getEditor(); | ||
export let showModal = false; | ||
export function open(onChangeCallback: (value: string) => void) { | ||
onChange = onChangeCallback; | ||
showModal = true; | ||
} | ||
function close() { | ||
showModal = false; | ||
getCommands().FocusEditor.execute(editor); | ||
} | ||
function onColorChange(value: string) { | ||
if (onChange) { | ||
onChange(value, true); | ||
} | ||
close(); | ||
} | ||
</script> | ||
|
||
<ModalDialog bind:showModal> | ||
<CloseCircleButton on:click={close} /> | ||
|
||
<div class="modal"> | ||
<h2 class="Modal__title">{title}</h2> | ||
<div class="Modal__content"> | ||
<ColorPicker {color} onChange={onColorChange} /> | ||
</div> | ||
</div> | ||
</ModalDialog> |
24 changes: 24 additions & 0 deletions
24
packages/svelte-lexical/src/lib/components/generic/portal/Portal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<script lang="ts"> | ||
import {onMount, onDestroy} from 'svelte'; | ||
// eslint-disable-next-line no-undef | ||
export let target: HTMLElement | null | undefined = globalThis.document?.body; | ||
let ref: HTMLElement; | ||
onMount(() => { | ||
if (target) { | ||
target.appendChild(ref); | ||
} | ||
}); | ||
onDestroy(() => { | ||
if (ref?.parentNode) { | ||
ref.parentNode?.removeChild(ref); | ||
} | ||
}); | ||
</script> | ||
|
||
<div bind:this={ref}> | ||
<slot /> | ||
</div> |
Oops, something went wrong.