-
Notifications
You must be signed in to change notification settings - Fork 425
Sync Vue Nodes Right Click menu with full ContextMenu #6455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Myestery
wants to merge
37
commits into
main
Choose a base branch
from
right-click-vue-node-contextmenu
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,058
−670
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
1809eff
right click vue nodes with contextmenu WIP
Myestery 521b672
[feat] Add disabled state support for context menu items
Myestery b31e8d0
feat: add Extensions translation key to context menu
Myestery 5aa6388
feat: add category type support to menu items
Myestery 4eb5103
feat: implement menu ordering and extension categorization system
Myestery 083fb56
feat: restructure context menu sections with proper ordering
Myestery 2279888
feat: add search functionality to context menu
Myestery f827f48
fix: move Resize and Clone to structure operations section
Myestery 727ce2e
WIP scroll
Myestery 20c6aa4
feat: add viewport-aware positioning to prevent menu overflow
Myestery 942d5bd
refactor: make position types internal to prevent unused export warnings
Myestery b89b6ba
refactor: remove unused menuOptionExists function
Myestery 3a3940f
feat: add fuzzy search with debouncing to context menu
Myestery f8e005c
refactor: remove debug console logs from NodeOptions
Myestery 3a83b79
Merge remote-tracking branch 'origin/main' into right-click-vue-node-…
Myestery 929c8ef
fix searchbox color and add empty state
Myestery 53d0614
fix: adjust badge height and update search placeholder for better UX
Myestery 32cdb2c
fix: update search input autofocus behavior and add mobile viewport h…
Myestery b5a34b1
refactor: remove debug logging from context menu functions for cleane…
Myestery 1c2f913
Merge branch 'main' into right-click-vue-node-contextmenu
Myestery 94b0aa0
[feat] add shape option to node context menu and improve CSS positioning
Myestery ab1e207
refactor: Update submenu repositioning logic to use a direct content …
Myestery 03c8cf8
fix: dock menu to top of viewport when trigger is above
Myestery 07c5bc3
style: Replace `text-[12px]` with `text-xs` utility
Myestery e8e8ce3
feat: allow null values in context menu options and update related ty…
Myestery 17ab44e
feat: Replace custom search input with component in NodeOptions.
Myestery 16f3e43
Merge branch 'main' into right-click-vue-node-contextmenu
Myestery 5fcfe8e
[refactor] Replace NodeOptions with PrimeVue ContextMenu
Myestery 19856bb
[refactor] Rename SubmenuPopover to ColorPickerMenu
Myestery 06d3ea5
[chore] Remove unused positioning files and exports
Myestery dad2e8b
refactor: replace specific hover background colors with theme variabl…
Myestery 01cca71
style: enhance shortcut display in the node context menu.
Myestery dd2f20a
feat: ensure context menu's `isOpen` state is correctly updated on sh…
Myestery 7826e2f
test: add 500ms page timeout
Myestery f301223
fix: Correct 'Open in Mask Editor' text and remove redundant `isOpen`…
Myestery d6bc30c
feat: Constrain node context menu dimensions with overflow scrolling …
Myestery a8571f5
Merge branch 'main' into right-click-vue-node-contextmenu
Myestery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,179 @@ | ||
| <template> | ||
| <ContextMenu | ||
| ref="contextMenu" | ||
| :model="menuItems" | ||
| class="max-h-[80vh] overflow-y-auto max-w-72" | ||
| @show="onMenuShow" | ||
| @hide="onMenuHide" | ||
| > | ||
| <template #item="{ item, props, hasSubmenu }"> | ||
| <a | ||
| v-bind="props.action" | ||
| class="flex items-center gap-2 px-3 py-1.5" | ||
| @click="item.isColorSubmenu ? showColorPopover($event) : undefined" | ||
| > | ||
| <i v-if="item.icon" :class="[item.icon, 'size-4']" /> | ||
| <span class="flex-1">{{ item.label }}</span> | ||
| <span | ||
| v-if="item.shortcut" | ||
| class="flex h-3.5 min-w-3.5 items-center justify-center rounded bg-interface-menu-keybind-surface-default px-1 py-0 text-xs" | ||
| > | ||
| {{ item.shortcut }} | ||
| </span> | ||
| <i | ||
| v-if="hasSubmenu || item.isColorSubmenu" | ||
| class="icon-[lucide--chevron-right] size-4 opacity-60" | ||
| /> | ||
| </a> | ||
| </template> | ||
| </ContextMenu> | ||
|
|
||
| <!-- Color picker menu (custom with color circles) --> | ||
| <ColorPickerMenu | ||
| v-if="colorOption" | ||
| ref="colorPickerMenu" | ||
| :option="colorOption" | ||
| @submenu-click="handleColorSelect" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import ContextMenu from 'primevue/contextmenu' | ||
| import type { MenuItem } from 'primevue/menuitem' | ||
| import { computed, onMounted, onUnmounted, ref } from 'vue' | ||
|
|
||
| import { | ||
| registerNodeOptionsInstance, | ||
| useMoreOptionsMenu | ||
| } from '@/composables/graph/useMoreOptionsMenu' | ||
| import type { | ||
| MenuOption, | ||
| SubMenuOption | ||
| } from '@/composables/graph/useMoreOptionsMenu' | ||
|
|
||
| import ColorPickerMenu from './selectionToolbox/ColorPickerMenu.vue' | ||
|
|
||
| interface ExtendedMenuItem extends MenuItem { | ||
| isColorSubmenu?: boolean | ||
| shortcut?: string | ||
| originalOption?: MenuOption | ||
| } | ||
|
|
||
| const contextMenu = ref<InstanceType<typeof ContextMenu>>() | ||
| const colorPickerMenu = ref<InstanceType<typeof ColorPickerMenu>>() | ||
| const isOpen = ref(false) | ||
|
|
||
| const { menuOptions, bump } = useMoreOptionsMenu() | ||
|
|
||
| // Find color picker option | ||
| const colorOption = computed(() => | ||
| menuOptions.value.find((opt) => opt.isColorPicker) | ||
| ) | ||
|
|
||
| // Check if option is the color picker | ||
| function isColorOption(option: MenuOption): boolean { | ||
| return Boolean(option.isColorPicker) | ||
| } | ||
|
|
||
| // Convert MenuOption to PrimeVue MenuItem | ||
| function convertToMenuItem(option: MenuOption): ExtendedMenuItem { | ||
| if (option.type === 'divider') return { separator: true } | ||
|
|
||
| const isColor = isColorOption(option) | ||
|
|
||
| const item: ExtendedMenuItem = { | ||
| label: option.label, | ||
| icon: option.icon, | ||
| disabled: option.disabled, | ||
| shortcut: option.shortcut, | ||
| isColorSubmenu: isColor, | ||
| originalOption: option | ||
| } | ||
|
|
||
| // Native submenus for non-color options | ||
| if (option.hasSubmenu && option.submenu && !isColor) { | ||
| item.items = option.submenu.map((sub) => ({ | ||
| label: sub.label, | ||
| icon: sub.icon, | ||
| disabled: sub.disabled, | ||
| command: () => { | ||
| sub.action() | ||
| hide() | ||
| } | ||
| })) | ||
| } | ||
|
|
||
| // Regular action items | ||
| if (!option.hasSubmenu && option.action) { | ||
| item.command = () => { | ||
| option.action!() | ||
| hide() | ||
| } | ||
| } | ||
|
|
||
| return item | ||
| } | ||
|
|
||
| // Build menu items | ||
| const menuItems = computed<ExtendedMenuItem[]>(() => | ||
| menuOptions.value.map(convertToMenuItem) | ||
| ) | ||
|
|
||
| // Show context menu | ||
| function show(event: MouseEvent) { | ||
| bump() | ||
| isOpen.value = true | ||
| contextMenu.value?.show(event) | ||
| } | ||
|
|
||
| // Hide context menu | ||
| function hide() { | ||
| contextMenu.value?.hide() | ||
| colorPickerMenu.value?.hide() | ||
| } | ||
|
|
||
| // Toggle function for compatibility | ||
| function toggle( | ||
| event: Event, | ||
| _element?: HTMLElement, | ||
| _clickedFromToolbox?: boolean | ||
| ) { | ||
| if (isOpen.value) { | ||
| hide() | ||
| } else { | ||
| show(event as MouseEvent) | ||
| } | ||
| } | ||
|
|
||
| defineExpose({ toggle, hide, isOpen, show }) | ||
|
|
||
| function showColorPopover(event: MouseEvent) { | ||
| event.stopPropagation() | ||
| event.preventDefault() | ||
| const target = event.currentTarget as HTMLElement | ||
| colorPickerMenu.value?.toggle(target) | ||
| } | ||
|
|
||
| // Handle color selection | ||
| function handleColorSelect(subOption: SubMenuOption) { | ||
| subOption.action() | ||
| hide() | ||
| } | ||
|
|
||
| function onMenuShow() { | ||
| isOpen.value = true | ||
| } | ||
|
|
||
| function onMenuHide() { | ||
| isOpen.value = false | ||
| colorPickerMenu.value?.hide() | ||
| } | ||
|
|
||
| onMounted(() => { | ||
| registerNodeOptionsInstance({ toggle, hide, isOpen }) | ||
| }) | ||
|
|
||
| onUnmounted(() => { | ||
| registerNodeOptionsInstance(null) | ||
| }) | ||
| </script> |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.