Skip to content

Commit

Permalink
move the dispatcher service inside the editor addon
Browse files Browse the repository at this point in the history
it seems farfetched that the current code will evolve into an addon of its own,
it's more likely the dispatcher as it exists now will dissapear relatively soon.

this commit also make the loading of plugins a bit more defensive and
informative, if a plugin is configured in a profile but could not be loaded a
warning is printed
  • Loading branch information
nvdk committed Jul 1, 2021
1 parent f5145f9 commit acc1504
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ export default class RdfaEditorDispatcher extends Service {
for( var key in editorProfiles ) {
profileArrays = [...profileArrays, ...editorProfiles[key]];
}
this.pluginServices = A(profileArrays).uniq().map( (pluginName) => getOwner(this).lookup(`service:${pluginName}`));
const owner = getOwner(this);
const serviceNames = new Set(profileArrays);
this.pluginServices = [];
for (const name of serviceNames) {
const service = owner.lookup(`service:${name}`);
if (service) {
this.pluginServices.push(service);
}
else {
console.warn('could not find plugin ' + name);
}
}
}

/**
Expand All @@ -47,6 +58,7 @@ export default class RdfaEditorDispatcher extends Service {
*
*/
dispatch(profile, hintsRegistryIndex, rdfaBlocks, hintsRegistry, editor, extraInfo = []){
return new Promise.resolve();
const self = this;
return new RSVP.Promise((resolve) => {
const plugins = editorProfiles[profile];
Expand All @@ -73,6 +85,7 @@ export default class RdfaEditorDispatcher extends Service {
}

dispatchToExecute(plugin, pluginService, args) {
return;
if (typeof(get(pluginService, 'execute.perform')) == 'function') { // ember-concurrency task
next(() => { pluginService.get('execute').perform(...args); });
}
Expand All @@ -94,6 +107,7 @@ export default class RdfaEditorDispatcher extends Service {
}

async requestHints(profile, context, editor) {
return;
const plugins = editorProfiles[profile];
const hints = A();
if (plugins) {
Expand Down
Empty file.
16 changes: 0 additions & 16 deletions lib/plugin-system-dispatcher/index.js

This file was deleted.

11 changes: 0 additions & 11 deletions lib/plugin-system-dispatcher/package.json

This file was deleted.

5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@
"edition": "octane"
},
"ember-addon": {
"configPath": "tests/dummy/config",
"paths": [
"lib/plugin-system-dispatcher"
]
"configPath": "tests/dummy/config"
},
"browserslist": [
"last 1 Chrome version",
Expand Down

0 comments on commit acc1504

Please sign in to comment.