fix isEditable
This commit is contained in:
@@ -49,6 +49,7 @@ export class Editor extends EventEmitter {
|
||||
public schema!: Schema
|
||||
public view!: EditorView
|
||||
public selection = { from: 0, to: 0 }
|
||||
public isFocused = false
|
||||
public options: EditorOptions = {
|
||||
element: document.createElement('div'),
|
||||
content: '',
|
||||
@@ -57,8 +58,6 @@ export class Editor extends EventEmitter {
|
||||
autoFocus: false,
|
||||
editable: true,
|
||||
}
|
||||
public isFocused = false
|
||||
public isEditable = true
|
||||
|
||||
constructor(options: Partial<EditorOptions> = {}) {
|
||||
super()
|
||||
@@ -98,6 +97,10 @@ export class Editor extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
public get isEditable() {
|
||||
return this.view && this.view.editable
|
||||
}
|
||||
|
||||
public get state() {
|
||||
return this.view.state
|
||||
}
|
||||
|
||||
@@ -26,13 +26,12 @@ export default class Focus extends Extension {
|
||||
return [
|
||||
new Plugin({
|
||||
props: {
|
||||
decorations: ({ doc, plugins, selection }) => {
|
||||
const { isFocused, isEditable } = this.editor
|
||||
const isActive = isEditable && this.options.className
|
||||
decorations: ({ doc, selection }) => {
|
||||
const { isEditable, isFocused } = this.editor
|
||||
const { anchor } = selection
|
||||
const decorations: Decoration[] = []
|
||||
|
||||
if (!isActive || !isFocused) {
|
||||
if (!isEditable || !isFocused) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user