0.0.8 • Published 2 years ago

rete-context-menu-plugin-react v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Rete context menu plugin - (React only version)

Rete.js plugin

import ContextMenuPlugin, { 
    ReactMenu,
} from 'rete-context-menu-plugin';

editor.use(ContextMenuPlugin, {
    Menu: ReactMenu, // required
    searchBar: false, // true by default
    searchKeep: title => true, // leave item when searching, optional. For example, title => ['Refresh'].includes(title)
    delay: 100,
    allocate(component) {
        return ['Submenu'];
    },
    rename(component) {
        return component.name;
    },
    items: {
        'Click me'(){ console.log('Works!') }
    },
    nodeItems: {
        'Click me'(){ console.log('Works for node!') }
    }
});
OptionsDescriptionDefault
Menu
searchBarShowing search bartrue
delayDelay hide, ms1000
allocatefunction for placing of components into submenu() => []
renamefunction for renaming of itemscomponent => component.name
itemscustom items (Object with nested objects and functions){}
nodeItemscustom items for Node menu{}

You can arbitrarily put a component in a submenu. Examples:

allocate() { return ["Single submenu"] }
allocate(component) { return component.path } // where path is a stack of menu for every component
allocate(component) { return null } // exclude component from menu items

To change the items that create nodes, you may need to change the name.

class MyComponent {
    constructor() {
        super("My comp");
        this.contextMenuName = "Add My comp";
    }
}
///
rename(component) { return component.contextMenuName || component.name }
0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago