fires when a context menu item has been clicked
| id | id | the item id |
webix.ui({
type: "space",
cols: [
{
view: "editor",
value: "<p>Some text</p>",
menubar: true,
contextMenu: [
{
id: "print-selection",
value: "Print selection",
icon: "rti-print"
},
// other context menu options
],
upload: "https://docs.webix.com/editor-backend/images",
on: {
onContextMenuItemClick(action) {
if (action == "print-selection") {
const [start, end] = this.getService(
"operations"
).getCursor();
if (end) {
const s = window.getSelection();
const range = s.getRangeAt(0);
const clonedSelection = range.cloneContents();
webix.html.addCss(document.body, "webix_print");
const wrap = webix.html.create("div", {
class: "webix_ui_print webix_view",
});
wrap.appendChild(clonedSelection);
webix.html.insertBefore(wrap, "", document.body);
window.print();
webix.html.remove(wrap);
webix.html.removeCss(document.body, "webix_print");
}
}
}
}
}
]
});