MaaxGr / ang-jsoneditor

Jsoneditor for Angular 11, 12, 13 and 14
MIT License
13 stars 16 forks source link

how to use onCreateMenu to filter the menus? #12

Open MichaelPanwenjie opened 2 years ago

MichaelPanwenjie commented 2 years ago

I want to delete some menus when operating, but when i use onCreateMenu function,It has no any parameter but the ordinary liberary has parameter,How can I use it?

In ordinary liberary : this.editorOptions.onCreateMenu = (items, node) => { items.filter()... }

but now:

image

Can anyone help to use onCreateMenu to filter the menus? Thanks!

MichaelPanwenjie commented 2 years ago

onCreateMenu: function (items, node) { // next, just for fun, let's remove any menu separators (again just at the // top level menu). A menu separator is an item with a type : 'separator' // property items = items.filter(function (item) { return item.type !== 'separator' })

  // finally we need to return the items array. If we don't, the menu
  // will be empty.
  return items

}

How to let above codes work duo to there is no items and node parameter in the Angular Wapper?

MaaxGr commented 2 years ago

I currently don't use this library and have the time maintaining it. Feel free to create a MR. :)