context menu refactor

This commit is contained in:
Jan Prochazka
2021-04-07 17:57:05 +02:00
parent e84d231a10
commit 82b63c70ed
4 changed files with 31 additions and 4 deletions

View File

@@ -48,6 +48,7 @@
import { createEventDispatcher } from 'svelte';
import { onMount } from 'svelte';
import { commands } from '../stores';
import { extractMenuItems } from '../utility/contextMenu';
export let items;
export let top;
@@ -66,6 +67,8 @@
onMount(() => {
fixPopupPlacement(element);
});
$: extracted = extractMenuItems(items);
</script>
<ul
@@ -74,7 +77,7 @@
on:clickOutside={() => dispatch('close')}
bind:this={element}
>
{#each _.compact(items.map(x => mapItem(x, $commands))) as item}
{#each _.compact(extracted.map(x => mapItem(x, $commands))) as item}
{#if item.divider}
<li class="divider" />
{:else}