"Hello World!" autosuggestion provider (JS) - adamwojs/ezplatform-omnibox GitHub Wiki
In order to create custom autosuggestion provider in your bundle:
- Create /src/bundle/Resources/public/js/ezomnibox-helloworld.js:
((window, document) => {
document.addEventListener('ezplatform.omnibox.init', (event) => {
event.detail.providers.push({
name: 'helloworld',
displayKey: 'value',
source: (query, callback) => {
const data = [
{
value: 'Hello world!'
}
];
callback(data);
},
templates: {
suggestion: (suggestion, answer) => {
return suggestion.value;
}
}
});
})
})(window, window.document);
2. Add entry to bundle configuration src/bundle/Resources/encore/ez.config.manager.js:
const path = require('path');
module.exports = (eZConfig, eZConfigManager) => {
eZConfigManager.add({
eZConfig,
entryName: 'ezplatform-admin-ui-layout-js',
newItems: [
path.resolve(__dirname, '../public/js/ezomnibox-helloworld.js')
],
});
};