Fix menu postiion, fix copy and paste in menu not working

This commit is contained in:
Andrew Kingston 2023-04-20 08:58:49 +01:00
parent 6bf6d15849
commit fe5ab61941
3 changed files with 8 additions and 9 deletions

View File

@ -42,7 +42,7 @@
<Menu> <Menu>
<MenuItem <MenuItem
icon="Copy" icon="Copy"
on:click={clipboard.actions.copyCell} on:click={clipboard.actions.copy}
on:click={menu.actions.close} on:click={menu.actions.close}
> >
Copy Copy
@ -50,7 +50,7 @@
<MenuItem <MenuItem
icon="Paste" icon="Paste"
disabled={$copiedCell == null} disabled={$copiedCell == null}
on:click={clipboard.actions.pasteCell} on:click={clipboard.actions.paste}
on:click={menu.actions.close} on:click={menu.actions.close}
> >
Paste Paste
@ -85,7 +85,7 @@
.menu { .menu {
position: absolute; position: absolute;
background: var(--cell-background); background: var(--cell-background);
border: var(--cell-border); border: 1px solid var(--spectrum-global-color-gray-300);
width: 180px; width: 180px;
border-radius: 4px; border-radius: 4px;
display: flex; display: flex;

View File

@ -2,20 +2,17 @@ import { writable, get } from "svelte/store"
export const createStores = () => { export const createStores = () => {
const copiedCell = writable(null) const copiedCell = writable(null)
const copiedRow = writable(null)
return { return {
copiedCell, copiedCell,
copiedRow,
} }
} }
export const deriveStores = context => { export const deriveStores = context => {
const { copiedCell, copiedRow, focusedCellAPI } = context const { copiedCell, focusedCellAPI } = context
const copy = () => { const copy = () => {
copiedCell.set(get(focusedCellAPI)?.getValue()) copiedCell.set(get(focusedCellAPI)?.getValue())
copiedRow.set(null)
} }
const paste = () => { const paste = () => {

View File

@ -1,4 +1,5 @@
import { writable, get } from "svelte/store" import { writable, get } from "svelte/store"
import { GutterWidth } from "../lib/constants"
export const createStores = () => { export const createStores = () => {
const menu = writable({ const menu = writable({
@ -22,8 +23,9 @@ export const deriveStores = context => {
e.preventDefault() e.preventDefault()
focusedCellId.set(cellId) focusedCellId.set(cellId)
menu.set({ menu.set({
left: e.clientX - $bounds.left + 44 + ($stickyColumn?.width || 0), left:
top: e.clientY - $bounds.top + $rowHeight + 4, e.clientX - $bounds.left + GutterWidth + ($stickyColumn?.width || 0),
top: e.clientY - $bounds.top + $rowHeight,
visible: true, visible: true,
}) })
} }