Skip to content

Commit 45990cd

Browse files
author
Scott Sidwell
committed
fix: prevent suggestions from being active when editor is readonly
1 parent ab4a0e2 commit 45990cd

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

packages/suggestion/src/suggestion.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,18 @@ export function Suggestion({
169169

170170
// Apply changes to the plugin state from a view transaction.
171171
apply(transaction, prev, oldState, state) {
172+
const { isEditable } = editor
172173
const { composing } = editor.view
173174
const { selection } = transaction
174175
const { empty, from } = selection
175176
const next = { ...prev }
176177

177178
next.composing = composing
178179

179-
// We can only be suggesting if there is no selection
180-
// or a composition is active (see: https://github.com/ueberdosis/tiptap/issues/1449)
181-
if (empty || editor.view.composing) {
180+
// We can only be suggesting if the view is editable, and:
181+
// * there is no selection, or
182+
// * a composition is active (see: https://github.com/ueberdosis/tiptap/issues/1449)
183+
if (isEditable && (empty || editor.view.composing)) {
182184
// Reset active state if we just left the previous suggestion range
183185
if (
184186
(from < prev.range.from || from > prev.range.to)

0 commit comments

Comments
 (0)