From be6ee9853c2eded705ef1ae673f87142f8260dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 21 Aug 2020 22:08:54 +0200 Subject: [PATCH] fix isEditable --- packages/core/src/Editor.ts | 7 +++++-- packages/extension-focus/index.ts | 7 +++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 9f30f39b..264d359d 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -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 = {}) { 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 } diff --git a/packages/extension-focus/index.ts b/packages/extension-focus/index.ts index 806464d9..ae00586c 100644 --- a/packages/extension-focus/index.ts +++ b/packages/extension-focus/index.ts @@ -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 }