mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-09-03 04:02:33 +02:00
Fix backspace for more grapheme clusters (#5890)
* Fix backspace for more grapheme clusters (#5887) This fix is specifically for the following languages: - Burmese - Hindi - Khmer - Malayalam - Oriya - Punjabi - Tamil - Telugu * Clean up code formatting around fixing backspace with grapheme clusters * Add changeset for backspace fix for additional grapheme clusters * Improve code formatting to align with prettier code style
This commit is contained in:
5
.changeset/nasty-lizards-serve.md
Normal file
5
.changeset/nasty-lizards-serve.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'slate': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handle backspace correctly for grapheme clusters in Burmese, Hindi, Khmer, Malayalam, Oriya, Punjabi, Tamil, and Telugu.
|
@@ -174,12 +174,22 @@ export const deleteText: TextTransforms['delete'] = (editor, options = {}) => {
|
|||||||
// Therefore, the remaining code points should be inserted back.
|
// Therefore, the remaining code points should be inserted back.
|
||||||
// Bengali: \u0980-\u09FF
|
// Bengali: \u0980-\u09FF
|
||||||
// Thai: \u0E00-\u0E7F
|
// Thai: \u0E00-\u0E7F
|
||||||
|
// Burmese (Myanmar): \u1000-\u109F
|
||||||
|
// Hindi (Devanagari): \u0900-\u097F
|
||||||
|
// Khmer: \u1780-\u17FF
|
||||||
|
// Malayalam: \u0D00-\u0D7F
|
||||||
|
// Oriya: \u0B00-\u0B7F
|
||||||
|
// Punjabi (Gurmukhi): \u0A00-\u0A7F
|
||||||
|
// Tamil: \u0B80-\u0BFF
|
||||||
|
// Telugu: \u0C00-\u0C7F
|
||||||
if (
|
if (
|
||||||
isCollapsed &&
|
isCollapsed &&
|
||||||
reverse &&
|
reverse &&
|
||||||
unit === 'character' &&
|
unit === 'character' &&
|
||||||
removedText.length > 1 &&
|
removedText.length > 1 &&
|
||||||
removedText.match(/[\u0980-\u09FF\u0E00-\u0E7F]+/)
|
removedText.match(
|
||||||
|
/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
Transforms.insertText(
|
Transforms.insertText(
|
||||||
editor,
|
editor,
|
||||||
|
Reference in New Issue
Block a user