add topNode option
This commit is contained in:
@@ -57,7 +57,7 @@ export class Editor extends EventEmitter {
|
|||||||
|
|
||||||
private createSchema() {
|
private createSchema() {
|
||||||
this.schema = new Schema({
|
this.schema = new Schema({
|
||||||
// topNode: this.options.topNode,
|
topNode: this.extensionManager.topNode,
|
||||||
nodes: this.extensionManager.nodes,
|
nodes: this.extensionManager.nodes,
|
||||||
marks: this.extensionManager.marks,
|
marks: this.extensionManager.marks,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -14,6 +14,14 @@ export default class ExtensionManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get topNode() {
|
||||||
|
const topNode = this.extensions.find(extension => extension.topNode)
|
||||||
|
|
||||||
|
if (topNode) {
|
||||||
|
return topNode.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get nodes(): any {
|
get nodes(): any {
|
||||||
return collect(this.extensions)
|
return collect(this.extensions)
|
||||||
.where('type', 'node')
|
.where('type', 'node')
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export default abstract class Node extends Extension {
|
|||||||
|
|
||||||
public type = 'node'
|
public type = 'node'
|
||||||
|
|
||||||
|
public topNode = false
|
||||||
|
|
||||||
// get type() {
|
// get type() {
|
||||||
// return 'node'
|
// return 'node'
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import { Node } from '@tiptap/core'
|
|||||||
|
|
||||||
export default class Document extends Node {
|
export default class Document extends Node {
|
||||||
|
|
||||||
name = 'doc'
|
name = 'document'
|
||||||
|
|
||||||
|
topNode = true
|
||||||
|
|
||||||
schema = {
|
schema = {
|
||||||
content: 'block+',
|
content: 'block+',
|
||||||
|
|||||||
Reference in New Issue
Block a user