refactoring

This commit is contained in:
Philipp Kühn
2018-09-04 22:33:50 +02:00
parent 90bf692da3
commit 91691f5e0a
4 changed files with 8 additions and 27 deletions

View File

@@ -61,15 +61,6 @@ export default class ExtensionManager {
...extensionKeymaps,
...nodeMarkKeymaps,
].map(keys => keymap(keys))
// return this.extensions
// .filter(extension => ['node', 'mark'].includes(extension.type))
// .filter(extension => extension.keys)
// .map(extension => extension.keys({
// type: schema[`${extension.type}s`][extension.name],
// schema,
// }))
// .map(keys => keymap(keys))
}
inputRules({ schema }) {

View File

@@ -8,19 +8,13 @@ export default function ({ schema, state, commands }) {
const command = commands[name] ? commands[name] : () => {}
return { name, active, command }
})
.reduce((actions, { name, active, command }) => Object.assign({}, actions, {
.reduce((actions, { name, active, command }) => ({
...actions,
[name]: {
active,
command,
},
}), {})
// .reduce((actions, { name, active, command }) => ({
// ...actions,
// [name]: {
// active,
// command,
// },
// }), {})
const marks = Object.entries(schema.marks)
.map(([name]) => {
@@ -34,21 +28,14 @@ export default function ({ schema, state, commands }) {
command,
}
})
.reduce((actions, { name, active, attrs, command }) => Object.assign({}, actions, {
.reduce((actions, { name, active, attrs, command }) => ({
...actions,
[name]: {
active,
attrs,
command,
},
}), {})
// .reduce((actions, { name, active, attrs, command }) => ({
// ...actions,
// [name]: {
// active,
// attrs,
// command,
// },
// }), {})
return {
nodes,

View File

@@ -2,9 +2,11 @@ import ComponentView from './ComponentView'
export default function initNodeViews({ nodes, editable }) {
const nodeViews = {}
Object.keys(nodes).forEach(nodeName => {
nodeViews[nodeName] = (node, view, getPos, decorations) => {
const component = nodes[nodeName]
return new ComponentView(component, {
node,
view,
@@ -14,5 +16,6 @@ export default function initNodeViews({ nodes, editable }) {
})
}
})
return nodeViews
}

View File

@@ -26,7 +26,6 @@ class Toolbar {
return
}
// Otherwise, reposition it and update its content
this.show()
const { from, to } = state.selection
@@ -54,6 +53,7 @@ class Toolbar {
if (event && event.relatedTarget) {
return
}
this.element.style.visibility = 'hidden'
this.element.style.opacity = 0
}