We are using the Webix Document Manager in our application and want to customize the right click menu, but haven’t been able to figure out how to do so.
Here is how we load the document manager into our react component:
class FileManager extends Component {
constructor(props) {
super(props);
this.scriptSrcElements = [];
this.timeouts = [];
}
componentDidMount() {
const scriptSrcs = [
{
src: `/external-lib/webix/webix/webix.js`
},
{
src: `/external-lib/webix/docmanager.js`,
onload: this.webixScriptLoaded,
},
];
scriptSrcs.forEach((scriptSrc) => {
const script = document.createElement('script');
script.src = scriptSrc.src;
script.async = false;
script.onload = scriptSrc.onload ? scriptSrc.onload : () => {};
script.onerror = (error) => {
console.log(error);
};
document.body.appendChild(script);
this.scriptSrcElements.push(script);
});
}
componentWillUnmount() {
this.scriptSrcElements.forEach((script) => {
document.body.removeChild(script);
});
if (this.ui) {
this.ui.destructor();
this.ui = null;
for (const to of this.timeouts) {
window.clearTimeout(to);
}
}
}
webixScriptLoaded = () => {
const self = this;
webix.ready(function () {
self.ui = webix.ui({
view: 'docmanager',
url: `${baseURL}/files/`,
editor: false,
container: 'webix-container',
id: 'webix-filemanager',
css: 'webix-filemanager',
minHeight: 600,
override: new Map([[docManager.services.Backend, Backend]]),
on: {
onInit: (app) => {
const state = app.getState();
// Overrides
const uploader = app.getService('upload').getUploader();
if (uploader) {
uploader.attachEvent('onAfterFileAdd', self.onAfterFileAdd);
}
app.getService('operations').download = self.onDownload;
app.getService('operations').open = self.onOpen;
},
},
onContext: {},
});
// We use this event to handle overrides where we modify the ajax call
webix.attachEvent('onBeforeAjax', self.onBeforeAjax);
// This responds to window resize and scales the webix layout appropriately
webix.event(window, 'resize', function () {
self.ui.resize();
});
});
};
render() {
return (
<div>
<Helmet>
<link
rel="stylesheet"
href={`/external-lib/webix/webix/webix.css`}
/>
<link
rel="stylesheet"
href={`/external-lib/webix/docmanager.css`}
/>
</Helmet>
<div id="webix-container" className="webix-container" />
</div>
);
}
}
I have tried all the ways to attach in the Context Menu documentation
The closest I was able to get was to add this right after the docmanager webix.ui:
webix.ui({
view: 'contextmenu',
id: 'customContextMenu',
data: ['Custom'],
master: 'webix-container',
});
This adds a custom right click menu in the sidebar and top bar, but not when clicking files/folders. Changing the master to ‘webix-filemanager’ does not work.
Any help is appreciated!