Last active
November 2, 2016 18:50
-
-
Save towerofnix/a6e7a74ecc32e13fbda6a30d92f9fd7e to your computer and use it in GitHub Desktop.
Basic menu items
This file contains 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
const page = document.getElementById('page') | |
const initEditableElement = function(el) { | |
const menu = createContextMenu('Demo menu', [ | |
['Insert new div', [ | |
['Before', () => { | |
alert('Insert before') | |
}], | |
['After', () => { | |
alert('Insert after') | |
}] | |
]], | |
['Magical new menu item', menu => { | |
menu.addMenuItem(['Magic!', () => alert('Magic')]) | |
menu.preventClose() | |
}] | |
]) | |
el.addEventListener('contextmenu', evt => { | |
menu.invoke(evt.clientX, evt.clientY) | |
evt.preventDefault() | |
}) | |
} | |
initEditableElement(page) |
Author
towerofnix
commented
Nov 2, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment