mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-18 22:36:14 +08:00
fix: prevent suggestions from being active when editor is readonly
This commit is contained in:
parent
ab4a0e2507
commit
45990cdc0f
@ -169,6 +169,7 @@ export function Suggestion({
|
||||
|
||||
// Apply changes to the plugin state from a view transaction.
|
||||
apply(transaction, prev, oldState, state) {
|
||||
const { isEditable } = editor
|
||||
const { composing } = editor.view
|
||||
const { selection } = transaction
|
||||
const { empty, from } = selection
|
||||
@ -176,9 +177,10 @@ export function Suggestion({
|
||||
|
||||
next.composing = composing
|
||||
|
||||
// We can only be suggesting if there is no selection
|
||||
// or a composition is active (see: https://github.com/ueberdosis/tiptap/issues/1449)
|
||||
if (empty || editor.view.composing) {
|
||||
// We can only be suggesting if the view is editable, and:
|
||||
// * there is no selection, or
|
||||
// * a composition is active (see: https://github.com/ueberdosis/tiptap/issues/1449)
|
||||
if (isEditable && (empty || editor.view.composing)) {
|
||||
// Reset active state if we just left the previous suggestion range
|
||||
if (
|
||||
(from < prev.range.from || from > prev.range.to)
|
||||
|
Loading…
Reference in New Issue
Block a user