insert HTML button

Discussion of general topics about Mozilla Thunderbird
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

insert HTML button

Post by indkal »

Is there a way to add a insert HTML button to the formatting toolbar of Thunderbird Message composer. Instead of going to Insert Menu and selecting HTML option, a button will be more handy.

Thanks.
User avatar
Freee!!
Posts: 15562
Joined: January 28th, 2005, 5:52 am
Location: Home, with my son!
Contact:

Re: insert HTML button

Post by Freee!! »

indkal wrote:Is there a way to add a insert HTML button to the formatting toolbar of Thunderbird Message composer. Instead of going to Insert Menu and selecting HTML option, a button will be more handy.

Thanks.

Even better, you can do it directly from the keyboard with <Ctrl>-L, no need to take your hand from the keyboard, grab the mouse, move the mouse pointer and click at which point you move your hand back to the keyboard.
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

Freee!! wrote:
indkal wrote:Is there a way to add a insert HTML button to the formatting toolbar of Thunderbird Message composer. Instead of going to Insert Menu and selecting HTML option, a button will be more handy.

Thanks.

Even better, you can do it directly from the keyboard with <Ctrl>-L, no need to take your hand from the keyboard, grab the mouse, move the mouse pointer and click at which point you move your hand back to the keyboard.


CTRL-L will only open the Link properties dialog window.
User avatar
Rod Whiteley
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Re: insert HTML button

Post by Rod Whiteley »

Using the keyboard: Alt+IH   An extension could add a formatting button, but I do not know one that does. The Custom Buttons extension can add a button to the main toolbar — the code is: goDoCommand("cmd_insertHTMLWithDialog")
Rod
User avatar
Freee!!
Posts: 15562
Joined: January 28th, 2005, 5:52 am
Location: Home, with my son!
Contact:

Re: insert HTML button

Post by Freee!! »

indkal wrote:CTRL-L will only open the Link properties dialog window.
Oops, apologies, misread the request. But links are the only HTML I explicitly use in email normally.
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

Rod Whiteley wrote:Using the keyboard: Alt+IH   An extension could add a formatting button, but I do not know one that does. The Custom Buttons extension can add a button to the main toolbar — the code is: goDoCommand("cmd_insertHTMLWithDialog")


The Custom Button is a Firefox extension. Is there a similar feature for Thunderbird.
User avatar
Rod Whiteley
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Re: insert HTML button

Post by Rod Whiteley »

I am using it in Thunderbird 3.0.4, after disabling Thunderbird's compatibility checking. See the knowledge base: http://kb.mozillazine.org/Updating_add-ons
Rod
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

Rod Whiteley wrote:I am using it in Thunderbird 3.0.4, after disabling Thunderbird's compatibility checking. See the knowledge base: http://kb.mozillazine.org/Updating_add-ons

Great. I got it installed in TB. But, the button does not appear in the Composition Toolbar. When you try to customize it is not there. On the other hand, it appears in the Mail toolbar during customization. For the button to work it has to appear in the Message Composition toolbar.
User avatar
Rod Whiteley
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Re: insert HTML button

Post by Rod Whiteley »

You are right, and it is my turn to apologise. :oops: That extension does indeed only work in the main window.

You can add a button to the formatting toolbar by using a Binding.

The binding is:

Code: Select all

<binding id="format">
  <content>
    <children/>
    <xul:toolbarbutton id="custom-html-button"
      tooltiptext="Insert HTML"
      observes="cmd_renderedHTMLEnabler"
      oncommand="goDoCommand('cmd_insertHTMLWithDialog')"/>
    <children includes="spacer"/>
    </content>
  </binding>

And the CSS is:

Code: Select all

#FormatToolbar {
  -moz-binding: url(chrome://userchrome/content/userChrome.xml#format);
  }
 
#custom-html-button {
  list-style-image: none !important;
  }
 
#custom-html-button image {
  background-color: orange;
  width: 16px;
  height: 16px;
  }
 
#custom-html-button[disabled] image {
  background-color: threedshadow;
  opacity: .5;
  }

You might like an additional CSS rule to enlarge the Insert HTML dialog:

Code: Select all

dialog[title="Insert HTML"] #srcInput {
  min-width: 60em;
  min-height: 30em;
  font-family: monospace;
  }
Last edited by Rod Whiteley on May 25th, 2010, 8:24 am, edited 1 time in total.
Rod
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

Wow!! Got it working. One question: Is it possible to have some icon for the button. Currently it is just a light orange rectangle.

Thanks.
User avatar
Rod Whiteley
Posts: 11480
Joined: December 6th, 2004, 3:41 am
Location: UK

Re: insert HTML button

Post by Rod Whiteley »

Yes, if you can find or make a 16 by 16-pixel image, put the image file in the same place as the other files and change list-style-image from none to something like: url(my_image_file.png)

By the way, I removed the line that said -moz-appearance: none !important; because it seemed to be doing nothing useful.
Rod
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

I recently did a new install of TB 24.1. Now the above instructions on Insert HTML button in Formatting Bar does not work. In fact, once the chrome folder is created in profile, the formatting bar in Write Message window disappears. Any suggestions??

Thanks.
morat
Posts: 6432
Joined: February 3rd, 2009, 6:29 pm

Re: insert HTML button

Post by morat »

Rod Whiteley's chrome.xpi extension broke in Gecko 2.0 because xpi files are no longer unpacked when extensions are installed.

Fix:

chrome.manifest

Code: Select all

content userchrome ../../chrome/

install.rdf

Code: Select all

<?xml version="1.0"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">

  <Description about="urn:mozilla:install-manifest">

    <em:id>chrome@user</em:id>
    <em:name>User Chrome</em:name>
    <em:version>1.1</em:version>
    <em:type>2</em:type>
    <em:unpack>true</em:unpack>
    <em:creator>Rod Whiteley</em:creator>
    <em:description>User chrome enabler.</em:description>

    <em:targetApplication><!-- Firefox -->
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>4.0</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:targetApplication><!-- Thunderbird -->
      <Description>
        <em:id>{3550f703-e582-4d05-9a08-453d09bdfdc6}</em:id>
        <em:minVersion>5.0</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:targetApplication><!-- SeaMonkey -->
      <Description>
        <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
        <em:minVersion>2.1</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:targetApplication><!-- Gecko Toolkit -->
      <Description>
        <em:id>toolkit@mozilla.org</em:id>
        <em:minVersion>2.0</em:minVersion>
        <em:maxVersion>99.*</em:maxVersion>
      </Description>
    </em:targetApplication>

  </Description>

</RDF>

zip chrome.zip chrome.manifest install.rdf
ren chrome.zip chrome.xpi

http://kb.mozillazine.org/Bindings

https://developer.mozilla.org/docs/Chrome_Registration
https://developer.mozilla.org/docs/Install_Manifests

BTW,

The Custom Buttons extension works with the menu bar and composition toolbar in the compose window.

https://addons.mozilla.org/thunderbird/addon/2707
indkal
Posts: 58
Joined: February 29th, 2008, 12:59 pm

Re: insert HTML button

Post by indkal »

Thanks for the update. It works. By the way, as far as Custom Buttons extension, I don't know what the code should be for Insert HTML.

Thanks again.
morat
Posts: 6432
Joined: February 3rd, 2009, 6:29 pm

Re: insert HTML button

Post by morat »

indkal wrote:I don't know what the code should be for Insert HTML.

Code: Select all

/*Code*/
goDoCommand("cmd_insertHTMLWithDialog");
Post Reply