change isActive behavior

This commit is contained in:
Philipp Kühn
2018-11-14 10:05:34 +01:00
parent 55833ddc44
commit d6c4c236a3
11 changed files with 61 additions and 59 deletions

View File

@@ -42,7 +42,7 @@ export default {
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive.bind(this.editor),
isActive: this.editor.isActive,
markAttrs: this.editor.markAttrs.bind(this.editor),
menu: this.menu,
})

View File

@@ -14,7 +14,7 @@ export default {
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive.bind(this.editor),
isActive: this.editor.isActive,
markAttrs: this.editor.markAttrs.bind(this.editor),
})
},

View File

@@ -42,7 +42,7 @@ export default {
focused: this.editor.view.focused,
focus: this.editor.focus,
commands: this.editor.commands,
isActive: this.editor.isActive.bind(this.editor),
isActive: this.editor.isActive,
markAttrs: this.editor.markAttrs.bind(this.editor),
menu: this.menu,
})

View File

@@ -284,17 +284,19 @@ export default class Editor {
return this.activeMarkAttrs[type]
}
isActive(type = null, attrs = {}) {
get isActive() {
const types = {
...this.activeMarks,
...this.activeNodes,
}
if (!types[type]) {
return false
}
Object
.entries(types)
.forEach(([name, value]) => {
types[name] = (attrs = {}) => value(attrs)
})
return types[type](attrs)
return types
}
destroy() {