refactoring
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
<div class="editor">
|
<div class="editor">
|
||||||
<editor-menu-bubble class="menububble" :editor="editor">
|
<editor-menu-bubble class="menububble" :editor="editor">
|
||||||
<div
|
<div
|
||||||
slot-scope="{ commands, isActive, markAttrs, menu }"
|
slot-scope="{ commands, isActive, getMarkAttrs, menu }"
|
||||||
class="menububble"
|
class="menububble"
|
||||||
:class="{ 'is-active': menu.isActive }"
|
:class="{ 'is-active': menu.isActive }"
|
||||||
:style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`"
|
:style="`left: ${menu.left}px; bottom: ${menu.bottom}px;`"
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
<template v-else>
|
<template v-else>
|
||||||
<button
|
<button
|
||||||
class="menububble__button"
|
class="menububble__button"
|
||||||
@click="showLinkMenu(markAttrs('link'))"
|
@click="showLinkMenu(getMarkAttrs('link'))"
|
||||||
:class="{ 'is-active': isActive.link() }"
|
:class="{ 'is-active': isActive.link() }"
|
||||||
>
|
>
|
||||||
<span>Add Link</span>
|
<span>Add Link</span>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default {
|
|||||||
focus: this.editor.focus,
|
focus: this.editor.focus,
|
||||||
commands: this.editor.commands,
|
commands: this.editor.commands,
|
||||||
isActive: this.editor.isActive,
|
isActive: this.editor.isActive,
|
||||||
markAttrs: this.editor.markAttrs.bind(this.editor),
|
getMarkAttrs: this.editor.getMarkAttrs.bind(this.editor),
|
||||||
menu: this.menu,
|
menu: this.menu,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export default {
|
|||||||
focus: this.editor.focus,
|
focus: this.editor.focus,
|
||||||
commands: this.editor.commands,
|
commands: this.editor.commands,
|
||||||
isActive: this.editor.isActive,
|
isActive: this.editor.isActive,
|
||||||
markAttrs: this.editor.markAttrs.bind(this.editor),
|
getMarkAttrs: this.editor.getMarkAttrs.bind(this.editor),
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export default {
|
|||||||
focus: this.editor.focus,
|
focus: this.editor.focus,
|
||||||
commands: this.editor.commands,
|
commands: this.editor.commands,
|
||||||
isActive: this.editor.isActive,
|
isActive: this.editor.isActive,
|
||||||
markAttrs: this.editor.markAttrs.bind(this.editor),
|
getMarkAttrs: this.editor.getMarkAttrs.bind(this.editor),
|
||||||
menu: this.menu,
|
menu: this.menu,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -280,23 +280,20 @@ export default class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
markAttrs(type = null) {
|
getMarkAttrs(type = null) {
|
||||||
return this.activeMarkAttrs[type]
|
return this.activeMarkAttrs[type]
|
||||||
}
|
}
|
||||||
|
|
||||||
get isActive() {
|
get isActive() {
|
||||||
const types = {
|
return Object
|
||||||
...this.activeMarks,
|
.entries({
|
||||||
...this.activeNodes,
|
...this.activeMarks,
|
||||||
}
|
...this.activeNodes,
|
||||||
|
|
||||||
Object
|
|
||||||
.entries(types)
|
|
||||||
.forEach(([name, value]) => {
|
|
||||||
types[name] = (attrs = {}) => value(attrs)
|
|
||||||
})
|
})
|
||||||
|
.reduce((types, [name, value]) => ({
|
||||||
return types
|
...types,
|
||||||
|
[name]: (attrs = {}) => value(attrs),
|
||||||
|
}), {})
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
|
|||||||
Reference in New Issue
Block a user