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, ...extensionKeymaps,
...nodeMarkKeymaps, ...nodeMarkKeymaps,
].map(keys => keymap(keys)) ].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 }) { inputRules({ schema }) {

View File

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

View File

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

View File

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