fix link example

This commit is contained in:
Philipp Kühn
2018-10-29 23:58:07 +01:00
parent 68793ea385
commit e608808c27
5 changed files with 23 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@@ -239,6 +239,13 @@ export default class Editor {
[name]: (attrs = {}) => markIsActive(this.state, mark, attrs),
}), {})
this.activeMarkAttrs = Object
.entries(this.schema.marks)
.reduce((marks, [name, mark]) => ({
...marks,
[name]: getMarkAttrs(this.state, mark),
}), {})
this.activeNodes = Object
.entries(this.schema.nodes)
.reduce((nodes, [name, node]) => ({
@@ -268,6 +275,10 @@ export default class Editor {
}
}
markAttrs(type = null) {
return this.activeMarkAttrs[type]
}
isActive(type = null, attrs = {}) {
const types = {
...this.activeMarks,