1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-21 22:45:18 +02:00

Fix backspace for Bengali grapheme clusters (#5887)

This commit is contained in:
Joe Anderson
2025-06-02 15:43:28 +01:00
committed by GitHub
parent 8f8b957ba6
commit 293aca9c7a
2 changed files with 9 additions and 2 deletions

View File

@@ -0,0 +1,5 @@
---
'slate': patch
---
Handle backspace correctly for grapheme clusters in Bengali

View File

@@ -169,15 +169,17 @@ export const deleteText: TextTransforms['delete'] = (editor, options = {}) => {
})
}
// For Thai script, deleting N character(s) backward should delete
// For certain scripts, deleting N character(s) backward should delete
// N code point(s) instead of an entire grapheme cluster.
// Therefore, the remaining code points should be inserted back.
// Bengali: \u0980-\u09FF
// Thai: \u0E00-\u0E7F
if (
isCollapsed &&
reverse &&
unit === 'character' &&
removedText.length > 1 &&
removedText.match(/[\u0E00-\u0E7F]+/)
removedText.match(/[\u0980-\u09FF\u0E00-\u0E7F]+/)
) {
Transforms.insertText(
editor,