Skip to content

Commit

Permalink
fix(portable-text-editor): fix bug with removing annotations
Browse files Browse the repository at this point in the history
No need to merge adjacent spans in this function as it has already been taken care of
in withPortableTextMarkModel plugin (mergeSpans fn)
  • Loading branch information
skogsmaskin committed Oct 19, 2021
1 parent 0326d9c commit 9a9afa9
Showing 1 changed file with 0 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -427,31 +427,6 @@ export function createWithEditableAPI(
}
})
}
// Merge similar adjecent spans
if (changed) {
// eslint-disable-next-line max-depth
for (const [node] of Array.from(
Editor.nodes(editor, {
at: Editor.range(editor, [selection.anchor.path[0]], [selection.focus.path[0]]),
match: Text.isText,
})
).reverse()) {
const [parent] = Editor.node(editor, SlatePath.parent(path))
// eslint-disable-next-line max-depth
if (Editor.isBlock(editor, parent)) {
const nextPath = [path[0], path[1] + 1]
const nextTextNode = parent.children[nextPath[1]]
// eslint-disable-next-line max-depth
if (
nextTextNode &&
typeof nextTextNode.text === 'string' &&
isEqual(nextTextNode.marks, node.marks)
) {
Transforms.mergeNodes(editor, {at: nextPath, voids: true})
}
}
}
}
}
if (changed) {
editor.onChange()
Expand Down

3 comments on commit 9a9afa9

@vercel
Copy link

@vercel vercel bot commented on 9a9afa9 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

studio-workshop – ./dev/workshop

studio-workshop-git-next.sanity.build
studio-workshop.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 9a9afa9 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 9a9afa9 Oct 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

perf-studio – ./

perf-studio.sanity.build
perf-studio-git-next.sanity.build

Please sign in to comment.