quill icon indicating copy to clipboard operation
quill copied to clipboard

Invalid delta `Length` and also `Delta.slice()` breaks latin unicode char in two parts e.g. ő

Open khaled4vokalz opened this issue 4 years ago • 9 comments

Steps for Reproduction

  • Enter latin character ő in Quill
  • delta.length() returns 2
  • selection range returns 1 as index if the cursor is after the latin character ő
  • delta.slice(0, range.index) returns 'o' only not the whole character
  • when you press backspace from the front of this character ő becomes O, whereas the whole character should've been removed

Expected behavior:

  • IMO, if the selection range returns 1 then delta.slice() should also behave accordingly. Now I'm not sure how to correctly split the delta when this type of unicode characters are used as delta
  • when you press backspace from the front of character ő, the whole character should be removed

Actual behavior:

  • delta.slice(0, 1) returns 'o' only not the whole character

Platforms: Ubutnu, Chrome

Version: 1.3.7

khaled4vokalz avatar Jun 24 '20 15:06 khaled4vokalz

Related https://github.com/quilljs/quill/issues/3138 https://github.com/quilljs/quill/issues/1230

benbro avatar Feb 03 '24 15:02 benbro

I think the issue has been fixed. Can you try the playground link?

luin avatar Feb 04 '24 02:02 luin

Hi @luin , First of all, thanks for taking the Repo and reviving it... :+1:

RE: This issue It seems like it's working now, from what I can see from the playground link... Can you give me the link of the PR that solves the problem?

khaled4vokalz avatar Feb 04 '24 02:02 khaled4vokalz

I tried v1.3.7 on https://quilljs.com/standalone/full and seems it also works.

delta.length() returns 2

This is expected as there is a trailing \n char.

luin avatar Feb 04 '24 02:02 luin

hmmmm... :thinking: ... that's odd... It's been a while I've created this issue, as this repo was dying I lost hope of some answers from the maintainers.... Not sure why it happened on my case... I'll see if I can reproduce it somewhere....

khaled4vokalz avatar Feb 04 '24 02:02 khaled4vokalz

okay, I tried to reproduce the problem a bit... It seems like it can be a copy pasting issue which doesn't work when I work the character from outside of quill.... here's a screencast...

quill-issue.webm

I also tried to find out the length issues in quill for this character... see this codepen... https://codepen.io/khaled4vokalz/pen/YzqWjgv?editors=0012

As you can see there's a discrepancy how emoji lengths are treated and how this character gets treated in regards to length..

image

khaled4vokalz avatar Feb 04 '24 03:02 khaled4vokalz

Thanks for the details. However I'm not sure if I understand the issue here. The codepen gives the correct results:

CleanShot 2024-02-04 at 12 42 53@2x

It's expected that the length of emojis is larger than 1

CleanShot 2024-02-04 at 12 44 49@2x

This does look like an issue when Backspace converted ő to o. Is there a way that I can reproduce it?

luin avatar Feb 04 '24 04:02 luin

Hi @luin , Sorry for the late reply.... As you can see from my video I copy pasted the character from browser console.... which made the backspace to fail.... like you can copy the character from the CodePen's browser console and then paste it into the editor in the quill playground..

khaled4vokalz avatar Feb 18 '24 03:02 khaled4vokalz

Thanks @khaled4vokalz ! I can reproduce it but looks like the native contenteditable also has the similar behavior (you can reproduce in codepen's code editor) so don't feel strongly that it's a Quill bug. Feel free to lmk if I missed anything.

luin avatar Feb 19 '24 14:02 luin

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray:

quill-bot avatar Apr 17 '24 11:04 quill-bot