jobisoft / quicktext

An extension for Thunderbird that lets you create templates that can be easily inserted into your own emails.
Mozilla Public License 2.0
184 stars 52 forks source link

Thunderbird 115 has issues with inserting templates when the cursor is at the end of a font tag directly before a hidden line break #377

Closed BT-Justice closed 11 months ago

BT-Justice commented 12 months ago

I have a client I do computer work for who uses this extension. Since the upgrade to Thunderbird 115, it doesn't seem to be working well. When he types up an email and goes to QuickText to select a signature, it will not go into the message body. If he selects a signature before typing, it seems to work, but (as a test) clicking to add another signature doesn't work.

jobisoft commented 12 months ago

It works here. I would need a step by step description of what the user is doing and what happens (or not). Errors logged to the console would be helpful.

Also please try in a fresh profile with a test template.

BT-Justice commented 11 months ago

He has a group called Signatures with the signatures in HTML within that group as templates. This makes a button called Signatures he clicks on whenever he types his message or reply. When he clicks the button and selects a signature, nothing gets inserted. Instead, the cursor where he wants the signature inserted disappears. When I click on the message body where the cursor was, it has moved up a line.

This has worked fine in the past and this is how he has done it for a couple of years now at least.

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIHTMLEditor.insertHTML]" nsresult: "0x80004005 (NS_ERROR_FAILURE)" location: "JS frame :: chrome://quicktext/content/quicktext.js :: insertBody :: line 530" data: no] quicktext.js:530:22 NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsICommandController.getCommandStateWithParams] goUpdateCommandState chrome://messenger/content/messengercompose/ComposerCommands.js:210 goUpdateComposerMenuItems chrome://messenger/content/messengercompose/ComposerCommands.js:281 oncommandupdate chrome://messenger/content/messengercompose/messengercompose.xhtml:1 observe chrome://messenger/content/messengercompose/editor.js:224 ComposerCommands.js:257:13 NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsICommandController.getCommandStateWithParams] goUpdateCommandState chrome://messenger/content/messengercompose/ComposerCommands.js:210 goUpdateComposerMenuItems chrome://messenger/content/messengercompose/ComposerCommands.js:281 oncommandupdate chrome://messenger/content/messengercompose/messengercompose.xhtml:1 observe chrome://messenger/content/messengercompose/editor.js:224 ComposerCommands.js:257:13

jobisoft commented 11 months ago

Can you send me the template in question? If it includes confidential information, please send it to my email directly. But I need a template - when imported into a fresh profile - triggers the bug reproducibly.

BT-Justice commented 11 months ago

Email sent from the user affected.

jobisoft commented 11 months ago

I still cannot reproduce it :-( All your signatures work. I opened a new email, typed something into the composer and then was able to insert all his signatures one after the other.

Please create a new Thunderbird Test-Profile, import the templates + scripts and try it in the new profile.

SamuelPlentz commented 11 months ago

Steps for Troubleshooting: https://github.com/jobisoft/quicktext/wiki/Troubleshooting

EcovoyCan commented 11 months ago

I have a similar issue. When I insert a template inside the body before other contents or in the title, all works fine, but when I try to insert a template at the bottom of the body, it doesn't work. I now work around this by typing a dot or dash and then moving cursor right before this character before inserting my template. This is a new issue that just started for me after installing TB 115.

BT-Justice commented 11 months ago

Created a fresh profile. Added one email account. Installed QuickText and ReplyWithHeader add-ons. Same error. Tried again without installing ReplyWithHeader. Same error.

NOW though if I insert a signature in a new mail and immediately try to insert a signature after that first signature, I can keep adding them. BUT, if I hit enter to make a new line, I cannot insert any signatures. Weird.

So type a new message, hit ENTER twice, and try to insert the HTML signature. It won't insert anything.

Start a new email but don't type anything yet, click on the message body, insert HTML signature, and now it will insert and keep inserting as long as the ENTER key is not pressed.

jobisoft commented 11 months ago

Start a new email but don't type anything yet, click on the message body, insert HTML signature, and now it will insert and keep inserting as long as the ENTER key is not pressed.

I was able to reproduce the effect after hitting ENTER. Will investigate.

jobisoft commented 11 months ago

The WebExtension version of QT has the same issue, so it is caused by the editor itself. We have to find a way around this bug.

Can you confirm it is triggered by <font>...</font> tags in the template? In my tests, I could make the issue go away by using style attributes and CSS to set the font instead of font tags.

If not, please reduce the offending templates until you could identify the part of the template, which is causing this for you.

jobisoft commented 11 months ago

Please also check if the template is syntactically correct. In the test templates I received, some font tags have not been closed and that caused additional issues.

ViperGeek commented 11 months ago

While not a fan of this issue's title, I recently upgraded to TB 115.2.2 (from 102) and lost the ability to insert HTML QuickText after any text written in an e-mail. Inserting the QT as the only text in an HTML reply works fine, as does inserting plain text below written plain text, but not below other rich (HTML) text.

My QT HTML is pretty boring:

<pre>---
Dave Dugal                                 Support: +1-408-555-1212
Principal Security Engineer                Direct:  +1-978-555-1212
</pre>
jobisoft commented 11 months ago

What happens if you add a p-tag around it? Or a div-tag?

<p>
<pre>---
Dave Dugal                                 Support: +1-408-555-1212
Principal Security Engineer                Direct:  +1-978-555-1212
</pre>
</p>
jobisoft commented 11 months ago

@ViperGeek : I do not seem to be able to reproduce your issue. Please create a dedicated issue with steps to reproduce (as detailed as possible)

SamuelPlentz commented 11 months ago

I improved the steps for Troubleshooting here: https://github.com/jobisoft/quicktext/wiki/Troubleshooting

I added the following and I think its relevant for all of you. @BT-Justice @EcovoyCan @ViperGeek

5. Reduce as far as possible

If there is a problem inserting a large Quicktext template into a long email, try to reduce the problem as much as possible.

6. Create an issue

[...]

ViperGeek commented 11 months ago

@ViperGeek : I do not seem to be able to reproduce your issue. Please create a dedicated issue with steps to reproduce (as detailed as possible)

https://github.com/jobisoft/quicktext/issues/378

Thanks!

BT-Justice commented 11 months ago

@jobisoft I updated the HTML, and it still will not work after typing a message, hitting enter twice, and then trying to insert a HTML signature from QuickText. I am sure it is something with the new Thunderbird 115 SuperNova version as everything worked fine for years. Apparently, you cannot revert to an older version of Thunderbird after upgrading to SuperNova.

@SamuelPlentz Thanks for your concern, but we are past the user error stage so no longer relevant to me. A bug has been discovered.

Here is an example of the HTML code used for one of the signatures which worked fine for years that has been anonymized (this clipboard will delete after 10/16/2023):

https://cl1p.net/QTSig

jobisoft commented 11 months ago

@jobisoft I updated the HTML, and it still will not work after typing a message.

What does the updated HTML template look like?

@SamuelPlentz Thanks for your concern, but we are past the user error stage so no longer relevant to me. A bug has been discovered.

It is undoubtably due to changes in the editor code (which is not Thunderbird code by the way, but code inherited from Firefox). But not all templates are broken, and we need to find out what tags/html is triggering this error.

So please do follow Samuel's advice and reduce your templates to the point where it works again, so we can identify the offending elements.

BT-Justice commented 11 months ago

@jobisoft All of the ones for my client do not work AFTER he types a message, hits ENTER twice, and then tries to insert a signature. They all work if he clicks the message body before typing a reply, inserts a signature, goes to the start of the signature, hits enter twice, goes back up, changes his font and size, and types his message.

Reducing the HTML code doesn't make them start working again. I took them all the way down to just having
for new lines as the only HTML code, and it still doesn't work. The only thing that works is making them TEXT signatures instead of HTML signatures. As text, they work fine after typing a message, hitting ENTER twice, and selecting a signature to insert.

The only fix I have for my client who needs his signatures to work for his business was to add:

<br>
<br>

...above the same HTML signatures. He can now type a message and at the end of his message, just select the HTML signature he wants which creates the signature 2 lines below his message as it used to be or insert the signature first then type a reply above the signature:

https://cl1p.net/QTSigBrBr

jobisoft commented 11 months ago

@jobisoft All of the ones for my client do not work AFTER he types a message, hits ENTER twice, and then tries to insert a signature. They all work if he clicks the message body before typing a reply, inserts a signature, goes to the start of the signature, hits enter twice, goes back up, changes his font and size, and types his message.

My current understanding is: QT fails, if the existing message in the composer before the cursor has a font tag. See #378

The only fix I have for my client who needs his signatures to work for his business was to add:

<br>
<br>

...above the same HTML signatures. He can now type a message and at the end of his message, just select the HTML signature he wants which creates the signature 2 lines below his message as it used to be or insert the signature first then type a reply above the signature

This still fails for me from time to time.

BT-Justice commented 11 months ago

@jobisoft My "fix" only works if you either do it right at the end of the last sentence typed or insert the signature in the message body before typing anything.

jobisoft commented 11 months ago

Understood.

Can you try if removing all font tags (select all and set as "Variable Width" font) before inserting a signature also fixes the issue (not as a workaround, but as the cause identification)?

jobisoft commented 11 months ago

I investigated in more detail what exactly is the offending situation: If the cursor is before a hidden br at the end of a font tag. You can play around with this using my HTML Source Editor: https://addons.thunderbird.net/addon/html-source-editor/

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>
    <p>
        <font face="Comic Sans MS">ff34534534</font>
    </p>
    <p>
        <font face="Comic Sans MS">zuof<br></font>
    </p>

</body>

</html>

If you save this html and then move the cursor to the end of the text, you will end up behind "zouf". The br is hidden, you cannot get on the next line. So the cursor is before the br.

Inserting templates will fail.

Any of the following will make inserting templates work again:

While it is tedious to remove trailing br's from the message before inserting templates, it may be a simple workaround to simply add a space wherever you currently are with your cursor (and where you want to add the template) and then go back one char to the left (so the space is behind the cursor) and then add the template.

Can you help me and play with your templates and the html source editor to confirm my findings? I will try to automate the removal of trailing br's before adding the template.

ViperGeek commented 11 months ago

Confirmed! <Enter><Space><Left Arrow><QuickText Insert> works every time.

Deleting the trailing <br> is less useful, since QuickText ends up inserting the text at the end of the line, rather than on a new line.

jobisoft commented 11 months ago

If you are on a new line, you need to remove all font tags from that line. This is the bad situation:

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>
    <p>
        <font face="Comic Sans MS">ff34534534</font>
    </p>
    <p>
        <font face="Comic Sans MS">zuof<br></font>
    </p>
    <p>
        <font face="Comic Sans MS"><br></font>
    </p>
</body>

</html>

This is the fixed one:

<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>
    <p>
        <font face="Comic Sans MS">ff34534534</font>
    </p>
    <p>
        <font face="Comic Sans MS">zuof<br></font>
    </p>
    <p>
       <br>
    </p>
</body>

</html>

It does need the <br> inside the <p></p>. Otherwise, the entire <p> becomes hidden, and the cursor will be behind "zouf" again, before the hidden <br> there, and it will again not work.

craigs100 commented 11 months ago

Since the recent upgrade in Mint Cinnamon to TB115.3.1 QuickText requires that I hit return and create as many new lines as the signature needs before it will insert. Very annoying. It won't just insert itself and move other content down.

jobisoft commented 11 months ago

I filed a Thunderbird bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1857788