mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 13:41:19 +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) {
|
if (editor.selection && Range.isCollapsed(editor.selection) && marks) {
|
||||||
const { anchor } = editor.selection
|
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
|
state.hasMarkPlaceholder = true
|
||||||
|
|
||||||
const unset = Object.fromEntries(
|
const unset = Object.fromEntries(
|
||||||
@@ -792,8 +795,11 @@ export const Editable = (props: EditableProps) => {
|
|||||||
const { selection } = editor
|
const { selection } = editor
|
||||||
if (selection) {
|
if (selection) {
|
||||||
const { anchor } = selection
|
const { anchor } = selection
|
||||||
const { text, ...rest } = Node.leaf(editor, anchor.path)
|
const text = Node.leaf(editor, anchor.path)
|
||||||
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 (marks && !Text.equals(text, marks as Text, { loose: true })) {
|
||||||
EDITOR_TO_PENDING_INSERTION_MARKS.set(editor, marks)
|
EDITOR_TO_PENDING_INSERTION_MARKS.set(editor, marks)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user