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