remove old commands

This commit is contained in:
Philipp Kühn 2018-10-28 22:17:21 +01:00
parent dcba6686dc
commit 1e88fa1cb6
4 changed files with 13 additions and 38 deletions

View File

@ -1,36 +1,36 @@
<template>
<div class="editor">
<menu-bar class="menubar" :editor="editor">
<template slot-scope="{ nodes, marks, newCommands }">
<template slot-scope="{ nodes, marks, commands }">
<button
class="menubar__button"
@click="newCommands.history"
v-if="newCommands.history"
@click="commands.history"
v-if="commands.history"
>
</button>
<button
class="menubar__button"
@click="newCommands.undo"
v-if="newCommands.undo"
@click="commands.undo"
v-if="commands.undo"
>
</button>
<button
class="menubar__button"
@click="newCommands.redo"
v-if="newCommands.redo"
@click="commands.redo"
v-if="commands.redo"
>
</button>
<button
class="menubar__button"
@click="newCommands.undoRedo"
v-if="newCommands.undoRedo"
@click="commands.undoRedo"
v-if="commands.undoRedo"
>
undoredo
</button>

View File

@ -12,7 +12,7 @@ export default {
marks: this.editor.menuActions.marks,
focused: this.editor.view.focused,
focus: this.editor.focus,
newCommands: this.editor.newCommands,
commands: this.editor.commands,
}))
}
},

View File

@ -53,13 +53,6 @@ export default class Editor {
this.view = this.createView()
this.commands = this.createCommands()
this.newCommands = this.extensions.newCommands({
schema: this.schema,
view: this.view,
})
console.log(this.newCommands)
this.updateMenuActions()
this.emit('init')

View File

@ -87,31 +87,13 @@ export default class ExtensionManager {
}
commands({ schema, view }) {
return this.extensions
.filter(extension => ['node', 'mark'].includes(extension.type))
.filter(extension => extension.command)
.reduce((commands, { name, type, command }) => ({
...commands,
[name]: attrs => {
view.focus()
const provider = command({
type: schema[`${type}s`][name],
attrs,
schema,
})
const callbacks = Array.isArray(provider) ? provider : [provider]
callbacks.forEach(callback => callback(view.state, view.dispatch, view))
},
}), {})
}
newCommands({ schema, view }) {
return this.extensions
.filter(extension => extension.commands)
.reduce((allCommands, { name, type, commands: provider }) => {
// TODO
// view.focus()
const commands = {}
const value = provider({
schema,