getMenuOptions
Returns the default card context menu items: Edit card, Duplicate card, and Delete card. The CardContextMenu and CardActionMenu wrappers use these items by default. Each item has a built-in id that the wrappers route to the matching kanban action.
Use it as a base for adding custom items while keeping the defaults.
Usage
import { getMenuOptions } from "@svar-ui/vue-kanban";
getMenuOptions(): { id: string; text: string; icon: string }[];
Returns:
[
{ id: "edit-card", text: "Edit card", icon: "wxi-edit" },
{ id: "duplicate-card", text: "Duplicate card", icon: "wxi-content-copy" },
{ id: "delete-card", text: "Delete card", icon: "wxi-delete" },
];
The card menu wrappers run built-in ids before onclick, including built-in ids in a custom options array. Custom ids reach only the onclick callback.
Example
Use the defaults as-is:
<script setup>
import { Kanban, CardContextMenu } from "@svar-ui/vue-kanban";
import { ref } from "vue";
const api = ref(null);
</script>
<template>
<CardContextMenu :api="api">
<Kanban ref="api" :cards="cards" :columns="columns" />
</CardContextMenu>
</template>
Extend with a custom item:
<script setup>
import { Kanban, CardContextMenu, getMenuOptions } from "@svar-ui/vue-kanban";
import { ref } from "vue";
const api = ref(null);
const options = [
...getMenuOptions(),
{ id: "archive-card", text: "Archive", icon: "wxi-empty" },
];
function onclick({ action, context }) {
if (action.id === "archive-card") {
api.value.exec("update-card", {
id: context.id,
card: { archived: true },
});
}
}
</script>
<template>
<CardContextMenu :api="api" :options="options" :onclick="onclick">
<Kanban ref="api" :cards="cards" :columns="columns" />
</CardContextMenu>
</template>
Related
- Card menu guide - right-click menu and per-card button
- CardContextMenu - right-click card menu that uses these options by default
- CardActionMenu - card
⋯button menu that uses these options by default - getColumnMenuOptions - default column menu options