refactoring
This commit is contained in:
@@ -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 }) {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user