fix editable
This commit is contained in:
@@ -32,8 +32,9 @@ interface EditorOptions {
|
|||||||
element: Element,
|
element: Element,
|
||||||
content: EditorContent,
|
content: EditorContent,
|
||||||
extensions: (Extension | Node | Mark)[],
|
extensions: (Extension | Node | Mark)[],
|
||||||
injectCSS: Boolean,
|
injectCSS: boolean,
|
||||||
autoFocus: 'start' | 'end' | number | boolean | null,
|
autoFocus: 'start' | 'end' | number | boolean | null,
|
||||||
|
editable: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
@magicMethods
|
@magicMethods
|
||||||
@@ -54,6 +55,7 @@ export class Editor extends EventEmitter {
|
|||||||
injectCSS: true,
|
injectCSS: true,
|
||||||
extensions: [],
|
extensions: [],
|
||||||
autoFocus: false,
|
autoFocus: false,
|
||||||
|
editable: true,
|
||||||
}
|
}
|
||||||
public isFocused = false
|
public isFocused = false
|
||||||
public isEditable = true
|
public isEditable = true
|
||||||
@@ -88,11 +90,19 @@ export class Editor extends EventEmitter {
|
|||||||
return (...args: any) => command(...args)
|
return (...args: any) => command(...args)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setOptions(options: Partial<EditorOptions> = {}) {
|
||||||
|
this.options = { ...this.options, ...options }
|
||||||
|
|
||||||
|
if (this.view && this.state) {
|
||||||
|
this.view.updateState(this.state)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public get state() {
|
public get state() {
|
||||||
return this.view.state
|
return this.view.state
|
||||||
}
|
}
|
||||||
|
|
||||||
public registerCommands(commands: CommandSpec): void {
|
public registerCommands(commands: CommandSpec) {
|
||||||
Object
|
Object
|
||||||
.entries(commands)
|
.entries(commands)
|
||||||
.forEach(([name, command]) => this.registerCommand(name, command))
|
.forEach(([name, command]) => this.registerCommand(name, command))
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ import Editor from '../..'
|
|||||||
export default (editor: Editor) => new Plugin({
|
export default (editor: Editor) => new Plugin({
|
||||||
key: new PluginKey('editable'),
|
key: new PluginKey('editable'),
|
||||||
props: {
|
props: {
|
||||||
editable: () => editor.isEditable,
|
editable: () => editor.options.editable,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user