mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-12 21:00:02 +08:00
refactoring
This commit is contained in:
parent
1bc75751b3
commit
7aa173f45a
@ -1,3 +1,4 @@
|
|||||||
|
import collect from 'collect.js'
|
||||||
import { EventEmitter } from 'events'
|
import { EventEmitter } from 'events'
|
||||||
import { EditorState, TextSelection } from 'prosemirror-state'
|
import { EditorState, TextSelection } from 'prosemirror-state'
|
||||||
import { EditorView} from 'prosemirror-view'
|
import { EditorView} from 'prosemirror-view'
|
||||||
@ -182,27 +183,17 @@ export class Editor extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setActiveNodesAndMarks() {
|
setActiveNodesAndMarks() {
|
||||||
this.activeMarks = Object
|
this.activeMarks = collect(this.schema.marks)
|
||||||
.entries(this.schema.marks)
|
.mapWithKeys((mark: any) => [mark.name, () => markIsActive(this.state, mark)])
|
||||||
.reduce((marks, [name, mark]) => ({
|
.all()
|
||||||
...marks,
|
|
||||||
// [name]: (attrs = {}) => markIsActive(this.state, mark, attrs),
|
|
||||||
[name]: () => markIsActive(this.state, mark),
|
|
||||||
}), {})
|
|
||||||
|
|
||||||
this.activeMarkAttrs = Object
|
this.activeMarkAttrs = collect(this.schema.marks)
|
||||||
.entries(this.schema.marks)
|
.mapWithKeys((mark: any) => [mark.name, () => getMarkAttrs(this.state, mark)])
|
||||||
.reduce((marks, [name, mark]) => ({
|
.all()
|
||||||
...marks,
|
|
||||||
[name]: getMarkAttrs(this.state, mark),
|
|
||||||
}), {})
|
|
||||||
|
|
||||||
this.activeNodes = Object
|
this.activeNodes = collect(this.schema.nodes)
|
||||||
.entries(this.schema.nodes)
|
.mapWithKeys((node: any) => [node.name, (attrs = {}) => nodeIsActive(this.state, node, attrs)])
|
||||||
.reduce((nodes, [name, node]) => ({
|
.all()
|
||||||
...nodes,
|
|
||||||
[name]: (attrs = {}) => nodeIsActive(this.state, node, attrs),
|
|
||||||
}), {})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getMarkAttrs(name: string) {
|
getMarkAttrs(name: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user