Browse Source

Add `strict` option in Command module configs #1881

pull/1918/head
Artur Arseniev 8 years ago
parent
commit
01a3053270
  1. 4
      src/commands/config/config.js
  2. 4
      src/commands/index.js

4
src/commands/config/config.js

@ -5,6 +5,10 @@ module.exports = {
defaults: [],
// If true, stateful commands (with `run` and `stop` methods) can't be runned multiple times.
// So, if the command is already active, running it again will not execute the `run` method
strict: 1,
// Editor model
// @deprecated
em: null,

4
src/commands/index.js

@ -330,7 +330,7 @@ module.exports = () => {
const id = command.id;
const editor = em.get('Editor');
if (!this.isActive(id) || options.force) {
if (!this.isActive(id) || options.force || !c.strict) {
if (id && command.stop && !command.noStop) {
active[id] = result;
}
@ -355,7 +355,7 @@ module.exports = () => {
const id = command.id;
const editor = em.get('Editor');
if (this.isActive(id) || options.force) {
if (this.isActive(id) || options.force || !c.strict) {
if (id) delete active[id];
result = command.callStop(editor, options);
}

Loading…
Cancel
Save