handle ignore context menu

This commit is contained in:
SrGooglo 2022-11-24 14:15:10 +00:00
parent 88d868cce5
commit cfd6d75408
2 changed files with 15 additions and 1 deletions

View File

@ -11,6 +11,9 @@ function copyToClipboard(text) {
} }
export default { export default {
"ignore": () => {
return false
},
"postCard-context": (parent, element, control) => { "postCard-context": (parent, element, control) => {
const items = [ const items = [
{ {

View File

@ -66,6 +66,10 @@ export default class ContextMenuCore extends Core {
} }
} }
if (!items) {
return null
}
// fullfill each item with a correspondent index if missing declared // fullfill each item with a correspondent index if missing declared
items = items.map((item, index) => { items = items.map((item, index) => {
if (!item.index) { if (!item.index) {
@ -104,13 +108,20 @@ export default class ContextMenuCore extends Core {
return return
} }
const items = this.generateItems(component)
if (!items) {
console.warn("No context menu items found, aborting")
return false
}
this.show({ this.show({
cords: { cords: {
x, x,
y, y,
}, },
clickedComponent: component, clickedComponent: component,
items: this.generateItems(component), items: items,
}) })
} }