Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Cited text shows up as ordinary text after returning from external editor #66

Closed

Description

@nicoroeser

When the external editor opens, and you save the text and quit the external editor, all text shows up as “normal text”. Even lines that had been marked as cited before (blue on white in the default Thunderbird setup; pressing Enter in such a block auto-inserts “> ” at the start of the next line, and such) become ordinary text lines, too (black on white in the default setup).

I think this might be related to #42.

Activity

  1. guiraldelli commented on May 14, 2020

    @guiraldelli
    Contributor

    @nicoroeser, I spent the last two days also bugged by this problem.

    I could not find a solution yet, but I found out the following:

    • Thunderbird 68 (the one I tested it) is adding a white-space just before the greater-than sign.
    • Looking in the source code, I think the editor.insertText() might be the cause of problem: I guess it looks for the greater-than symbol in the beginning of a line and prepend it with a white-space.
    • Calling "Edit→Rewrap" or "Edit→Paste as Quotation" in the editor window "fixes" the problem (introducing others, such as rewrapping the text where it shouldn't or adding an extra greater-than symbol in the pasted message).

    I have zero knowledge about the Mozilla code-base and JavaScript (used to develop this extension), but I hope this information will help the maintainers to hunt down this bug.

    EDIT:

    It seems there is a function called insertTextWithQuotations() that I have the feeling it could be correct one instead of insertText() given they have the same function signature.

  2. snipsnipsnip commented on May 25, 2020

    @snipsnipsnip
    Member

    Hi, thanks for report and investigation.

    Unfortunately, insertTextWithQuotations() is already removed (patch), so we can't use that function on Thunderbird 68 :(. In fact, current code is a product of workaround for that removal.

    I haven't found a way to fix this issue with some simple API call. Maybe External Editor could do a rewrap after closing the editor, but it has some side effects as you mention.

    External Editor can style the message as a HTML even when it is a plaintext, so it can replicate the Thunderbird functionality in principle. (i.e. parsing quotation >s and redo highlight as the rewrap command do). But it requires some work.

  3. nicoroeser commented on May 28, 2020

    @nicoroeser
    ContributorAuthor

    @snipsnipsnip, you wrote:

    External Editor can style the message as a HTML even when it is a plaintext,

    I am sorry, I don’t know what you mean by this. I hope that it will still be possible to use text-only (text/plain) messages in Thunderbird?

    so it can replicate the Thunderbird functionality in principle. (i.e. parsing quotation >s and redo highlight as the rewrap command do). But it requires some work.

    As I am bitten by this issue every day, I am willing to invest a bit of time here and try to produce code that can help. Unfortunately I do not understand the way of going forward which you are outlining here. If you could explain the idea a bit further or could share a few pointers into the code or relevant methods or whatever, I’d be grateful, and will happily give it a try!

  4. nicoroeser commented on Aug 24, 2020

    @nicoroeser
    ContributorAuthor

    editor is an nsIEditor at the moment, and we are using its insertText method. Am I right?

    And there is insertAsCitedQuotation in nsIEditorMailSupport, which can insert a piece of text as a quotation.

    So it seems to me that we have to parse the text in the JavaScript code of the External Editor addon. We need to alternately call insertText and insertAsCitedQuotation (with the leading > or > removed on each line because it will be re-inserted). This should properly move all of the text to the editor in Thunderbird.

    I do not understand yet how to move the cursor or how to position Node objects within the document, but we probably do not need it at all if we handle everything in succession.

    I’ve only had a brief look at the source code, and am not an expert on this. Please correct me if I’m wrong.

  5. added a commit that references this issue on Aug 26, 2020
    7beb86e
  6. nicoroeser commented on Sep 16, 2020

    @nicoroeser
    ContributorAuthor

    I’ve been using #75 for some time now without any problems. Has anyone else tried it and can give feedback?

  7. added a commit that references this issue on Oct 22, 2020
    d1c080f
  8. nicoroeser commented on Oct 22, 2020

    @nicoroeser
    ContributorAuthor

    Pull request updated and repaired. Tested with several empty and non-empty messages. Looks good to me now. 😄

  9. added a commit that references this issue on Sep 11, 2025
    dd73e60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions