refactoring
This commit is contained in:
@@ -17,9 +17,9 @@ export default function getMarkAttributes(state: EditorState, typeOrName: string
|
||||
|
||||
const mark = marks.find(markItem => markItem.type.name === type.name)
|
||||
|
||||
if (mark) {
|
||||
return { ...mark.attrs }
|
||||
if (!mark) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return {}
|
||||
return { ...mark.attrs }
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ export default function getNodeAttributes(state: EditorState, typeOrName: string
|
||||
.reverse()
|
||||
.find(nodeItem => nodeItem.type.name === type.name)
|
||||
|
||||
if (node) {
|
||||
return { ...node.attrs }
|
||||
if (!node) {
|
||||
return {}
|
||||
}
|
||||
|
||||
return {}
|
||||
return { ...node.attrs }
|
||||
}
|
||||
|
||||
@@ -14,7 +14,5 @@ export default function getRenderedAttributes(nodeOrMark: Node | Mark, extension
|
||||
|
||||
return item.attribute.renderHTML(nodeOrMark.attrs) || {}
|
||||
})
|
||||
.reduce((attributes, attribute) => {
|
||||
return mergeAttributes(attributes, attribute)
|
||||
}, {})
|
||||
.reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
import { MarkType, NodeType, Schema } from 'prosemirror-model'
|
||||
|
||||
export default function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null {
|
||||
if (schema.nodes[name]) {
|
||||
return schema.nodes[name]
|
||||
}
|
||||
|
||||
if (schema.marks[name]) {
|
||||
return schema.marks[name]
|
||||
}
|
||||
|
||||
return null
|
||||
return schema.nodes[name] || schema.marks[name] || null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user