cryptee / web-client

Cryptee's web client source code for all platforms.
https://crypt.ee
Other
444 stars 22 forks source link

[Bug] Font reverts to Josefin Sans when all text of a paragraph is deleted #136

Closed npickens closed 2 years ago

npickens commented 2 years ago

Describe the bug Font reverts to default (Josefin Sans) when all text of a paragraph is deleted.

To Reproduce

  1. Open a new document.
  2. Set the font to any font other than Josefin Sans.
  3. Type some text.
  4. Press delete/backspace until the paragraph is blank.
  5. Type some text again.
  6. :boom: Font is Josefin Sans.

Expected behavior Font choice is preserved.

Screenshots FontNotPreserved

System Information:

npickens commented 2 years ago

Note: if the text of the paragraph is selected and then new text is typed to replace it (without first deleting), the font choice is preserved. The issue only arises when the content is explicitly deleted and the paragraph becomes empty.

johnozbay commented 2 years ago

Hi there! 👋🏻

Thanks a million for filing this issue!

My apologies for the delayed response. We've been busy working on our new paper-mode, which essentially changed the entire editor, so we thought it's best to first get that out the door before taking a look at this again.

So, there's actually two edge-cases here: 1) empty document, the first, only and last paragraph.

2) a document that has some text / paragraphs with different fonts / sizes etc, and the paragraph in which you delete the text isn't the very last / only one.

We've just released a fix (66cec12f2b15639bab9f9b3a34b579fb1784c104) and it fixes case 2 from happening.

As for Case 1) this is in some ways the expected behaviour of our text editor engine QuillJS –  Once you delete all text in the editor, essentially there is no text / content left = there's no style information left in the editor, because it's contents are entirely empty, so it's basically the equivalent of an empty JS object like {}... and only when you put even a single line break etc, this will start working as expected again.

We're looking into band-aid fixing this somehow – by remembering the last font/font-size/style etc before the editor was emptied out.

However, we'll have to do this carefully, since keeping some style information in mind before it's deleted could in theory cause some privacy issues in a few specific scenarios. i.e. if the last/only paragraph you're deleting actually has a remotely loaded image, and by keeping the style information in memory, we'd actually be keeping the image's source URL / dimensions etc. thus could cause the editor to keep more stuff in its memory than it needs to. This could cause issues like leaking image urls if you look into the browser's memory OR causing lots of memory use if the image is loaded inline using Base64 for example.

So for the time being I'll close this issue, since 66cec12f2b15639bab9f9b3a34b579fb1784c104 should address most use-cases, and we'll start working on a solution for the Case 1 (last/only paragraph-scenario) in the meantime.

Hoping all this makes sense 😅

Many million thanks for filing this, and for your patience with us while we fix these pesky bugs!

Best, J