async / await composer buttons.
-
- Best way to migrate this to async await and remove callback?
exports.filterComposerFormatting = function(payload, callback) { payload.options.push({ className: 'add-movie-source fa fa-video-camera', name: 'add_movie_source', title: 'Add movie source', }); payload.options.push({ className: 'add-movie-review fa fa-video-camera', name: 'add_movie_review', title: 'Add movie review', }); payload.options.push({ className: 'add-game-source fa fa-gamepad', name: 'add_game_source', title: 'Add game source', }); payload.options.push({ className: 'add-game-review fa fa-gamepad', name: 'add_game_review', title: 'Add game review', }); callback(null, payload); };
- Is there any nice way to include a client.js file only if the composer is started or open? Now i use scripts in plugin.json and the client.js will allway be included.
-
exports.filterComposerFormatting = async function(payload, callback) { payload.options.push({ className: 'add-movie-source fa fa-video-camera', name: 'add_movie_source', title: 'Add movie source', }); payload.options.push({ className: 'add-movie-review fa fa-video-camera', name: 'add_movie_review', title: 'Add movie review', }); payload.options.push({ className: 'add-game-source fa fa-gamepad', name: 'add_game_source', title: 'Add game source', }); payload.options.push({ className: 'add-game-review fa fa-gamepad', name: 'add_game_review', title: 'Add game review', }); return payload; };
- There is no way to do that - you need to have a
client.js
in thescripts
section of yourplugin.json
.
What problem you're trying to solve?
If you want to catch the activate/minimize/discard events - you can listen to these events:
- There is no way to do that - you need to have a
-
@antosik there actually is a way: you can define the stuff you want imported on composer launch as a requirejs module and
require
it in a script that does get included in the bundle. -
I fixed it this way
exports.filterComposerFormatting = async (data) => { data.options.push({ className: 'add-movie-source fa fa-video-camera', name: 'add_movie_source', title: 'Add movie source' }, { className: 'add-movie-review fa fa-video-camera', name: 'add_movie_review', title: 'Add movie review' }, { className: 'add-game-source fa fa-gamepad', name: 'add_game_source', title: 'Add game source' }, { className: 'add-game-review fa fa-gamepad', name: 'add_game_review', title: 'Add game review' }); return data; };
@baris any example for a noob like me? I just want to load client.js when composer is active due to that it only is needed when working it the composer
Copyright © 2024 NodeBB | Contributors