mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-20 06:01:24 +02:00
Cleanup and fix insertion placeholder mark compare (#5127)
This commit is contained in:
5
.changeset/pink-panthers-appear.md
Normal file
5
.changeset/pink-panthers-appear.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'slate-react': patch
|
||||
---
|
||||
|
||||
Cleanup and fix insertion placeholder mark compare
|
@@ -765,9 +765,12 @@ export const Editable = (props: EditableProps) => {
|
||||
|
||||
if (editor.selection && Range.isCollapsed(editor.selection) && marks) {
|
||||
const { anchor } = editor.selection
|
||||
const { text, ...rest } = Node.leaf(editor, anchor.path)
|
||||
const leaf = Node.leaf(editor, anchor.path)
|
||||
const { text, ...rest } = leaf
|
||||
|
||||
if (!Text.equals(rest as Text, marks as Text, { loose: true })) {
|
||||
// While marks isn't a 'complete' text, we can still use loose Text.equals
|
||||
// here which only compares marks anyway.
|
||||
if (!Text.equals(leaf, marks as Text, { loose: true })) {
|
||||
state.hasMarkPlaceholder = true
|
||||
|
||||
const unset = Object.fromEntries(
|
||||
@@ -792,8 +795,11 @@ export const Editable = (props: EditableProps) => {
|
||||
const { selection } = editor
|
||||
if (selection) {
|
||||
const { anchor } = selection
|
||||
const { text, ...rest } = Node.leaf(editor, anchor.path)
|
||||
if (!Text.equals(rest as Text, marks as Text, { loose: true })) {
|
||||
const text = Node.leaf(editor, anchor.path)
|
||||
|
||||
// While marks isn't a 'complete' text, we can still use loose Text.equals
|
||||
// here which only compares marks anyway.
|
||||
if (marks && !Text.equals(text, marks as Text, { loose: true })) {
|
||||
EDITOR_TO_PENDING_INSERTION_MARKS.set(editor, marks)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user