compose.setComposeDetails does not detect citations in plaintext
Categories
(Thunderbird :: Add-Ons: Extensions API, defect)
Tracking
(Not tracked)
People
(Reporter: jan.kiszka, Assigned: TbSync)
References
Details
Attachments
(1 file)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0
Steps to reproduce:
In an addon call something like
let details = await messenger.compose.getComposeDetails(tab.id);
messenger.compose.setComposeDetails(tab.id, {
plainTextBody: details.plainTextBody
});
Actual results:
When in plaintext composition mode, citations in the original message are not detected as such and wrap around on long lines. Color highlighting is also removed.
Expected results:
The message in the composer window should appear as it was, permitting programmatic modifications to it without destroying the formatting otherwise.
The reason seems to be that setting plainTextBody is treated like a manual select-all + cut + paste which has the same effect. Instead, citation marks should be detected, and corresponding lines should be treated like on the composer window setup when replying.
Assignee | ||
Comment 1•4 years ago
|
||
Plaintext is somewhat special, as it does not contain formatting. So I am not totally surprised that getting the content as plaintext and then re-setting the content via plainTextBody will remove formats.
To understand this better:
In your test case, you worked on an HTML email?
What is the default compose mode of the used identity?
Reporter | ||
Comment 2•4 years ago
|
||
See the issue I cited. Editing mode is plaintext only.
By now, the extension tries to workaround this API limitation by modifying the DOM tree of the composer window directly (https://github.com/4ch1m/mozext/pull/18). That avoids this issue, but it is fragile as well because it is not in sync with the internal state of TB.
Assignee | ||
Comment 3•2 years ago
|
||
Magnus, there seems to be only one method which is responsible for the quotation color, which is InsertTextWithQuotations(aBuf)
in m-c:
https://searchfox.org/comm-central/search?q=insertTextWithQuotations&path=&case=false®exp=false
It should be used here:
https://searchfox.org/comm-central/rev/36c713a3d0bf0d0ca2208fdf74f8a133d4ed7edd/mail/components/compose/content/MsgComposeCommands.js#5343
But it is not exposed to JS (Error: editor.insertTextWithQuotations is not a function).
Can I add a wrapper to nsMsgCompose.cpp or should I ask m-c to add that function to the idl and expose it to JS?
Assignee | ||
Updated•2 years ago
|
Comment 4•2 years ago
|
||
It would probably be best to expose it in nsIEditorMailSupport
Masayuki, what do you think?
Assignee | ||
Comment 5•2 years ago
|
||
Updated•2 years ago
|
Assignee | ||
Comment 6•2 years ago
|
||
I created a patch for m-c in bug 1768057, but did not know who to pick as reviewer. I selected Magnus, hoping he knows who to pick.
Comment 7•2 years ago
|
||
Yes, changing it into a new interface method is fine if it's not called from another method in editor (because editor classes are really complicated so that we need to restrict and clarify the entrances), but as I reviewed, please add new automated tests for every interface method adding newly. Such automated tests prevent regressions at least they test. Otherwise, any changes in mozilla-central could case break such features which are used only in comm-central. I'll add the new one into the table.
Assignee | ||
Updated•2 years ago
|
Pushed by geoff@darktrojan.net:
https://hg.mozilla.org/comm-central/rev/a5da4c3f4345
Use insertTextWithQuotations() for SetComposeDetails() to improve citation handling. r=mkmelin
Updated•2 years ago
|
Comment 10•2 years ago
|
||
Pushed by geoff@darktrojan.net: https://hg.mozilla.org/comm-central/rev/5170990b3aaf follow-up - Fix linting error. rs=linting
Assignee | ||
Comment 11•2 years ago
|
||
Hi Masayuki,
we encountered an unexpected regression after switching to InsertTextWithQuotations()
: If the editor has the Ci.nsIEditor.eEditorReadonlyMask
flag set, the function updates the text, but removes the quotation.
We run into this issue, when a user has clicked on the "send" button to send a message. The editor is not closed directly, but is locked and set to read-only. There are a few checks done in the background and if the send process fails, we unlock the editor and the user can continue to edit it. One of these checks is to ask installed add-ons if they want to manipulate the message and if so, update the content using InsertTextWithQuotations()
(while the editor is still locked and set to read-only).
I guess we can fix this on our side by lifting the flag before we update the editor. However, I think the behaviour is somewhat inconsistent. Should we file an m-c bug about this?
Assignee | ||
Updated•2 years ago
|
Comment 12•2 years ago
|
||
Sorry, I missed this needinfo request.
(In reply to John Bieling (:TbSync) from comment #11)
we encountered an unexpected regression after switching to
InsertTextWithQuotations()
: If the editor has theCi.nsIEditor.eEditorReadonlyMask
flag set, the function updates the text, but removes the quotation.I guess we can fix this on our side by lifting the flag before we update the editor. However, I think the behaviour is somewhat inconsistent. Should we file an m-c bug about this?
Well, obviously, it's a bug missing to check the readonly state. I'll file a bug by myself and I'll fix it. Thank you for notifying me!
Assignee | ||
Comment 13•2 years ago
|
||
Hi Masayuki, can you link the new bug here, so we know when it has landed? I would like to remove our work-around if it is no longer needed.
Updated•2 years ago
|
Updated•2 years ago
|
Description
•