mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-12 00:19:02 +08:00
remove old commands
This commit is contained in:
parent
dcba6686dc
commit
1e88fa1cb6
@ -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>
|
||||
|
@ -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,
|
||||
}))
|
||||
}
|
||||
},
|
||||
|
@ -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')
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user