mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-28 15:49:23 +08:00
refactoring
This commit is contained in:
parent
486d0e0f5f
commit
a067259da1
@ -11,14 +11,16 @@ import { gapCursor } from 'prosemirror-gapcursor'
|
||||
import elementFromString from './utils/elementFromString'
|
||||
import injectCSS from './utils/injectCSS'
|
||||
import ExtensionManager from './ExtensionManager'
|
||||
import Extension from './Extension'
|
||||
import Node from './Node'
|
||||
|
||||
type EditorContent = string | JSON
|
||||
type Command = (next: Function, editor: Editor, ...args: any) => any
|
||||
|
||||
interface Options {
|
||||
element?: Node
|
||||
element?: globalThis.Node
|
||||
content: EditorContent
|
||||
extensions: [any?]
|
||||
extensions: (Extension | Node)[]
|
||||
injectCSS: Boolean
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,9 @@ export default abstract class Extension {
|
||||
|
||||
public type = 'extension'
|
||||
|
||||
protected created() {}
|
||||
public created() {}
|
||||
|
||||
protected bindEditor(editor: Editor): void {
|
||||
public bindEditor(editor: Editor): void {
|
||||
this.editor = editor
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,14 @@
|
||||
import { keymap } from 'prosemirror-keymap'
|
||||
import collect from 'collect.js'
|
||||
import { Editor } from './Editor'
|
||||
import Extension from './Extension'
|
||||
import Node from './Node'
|
||||
|
||||
export default class ExtensionManager {
|
||||
|
||||
extensions: [any?]
|
||||
extensions: (Extension | Node)[]
|
||||
|
||||
constructor(extensions: any = [], editor: Editor) {
|
||||
constructor(extensions: (Extension | Node)[], editor: Editor) {
|
||||
this.extensions = extensions
|
||||
this.extensions.forEach(extension => {
|
||||
extension.bindEditor(editor)
|
||||
@ -15,7 +17,7 @@ export default class ExtensionManager {
|
||||
}
|
||||
|
||||
get topNode() {
|
||||
const topNode = this.extensions.find(extension => extension.topNode)
|
||||
const topNode = collect(this.extensions).firstWhere('topNode', true)
|
||||
|
||||
if (topNode) {
|
||||
return topNode.name
|
||||
|
Loading…
Reference in New Issue
Block a user