11

How can I add a new button in the WMD editor, like the code button? If I click on the button <info></info> tag will add on the selected text like code button.

1 Answer 1

3

There is a newer version of the repository called wmd-new. As described on the StackOverflow blog this version uses CSS sprites for better performance. So the toolbar is a single graphic:

enter image description here

There is a PSD (Photoshop) file for the toolbar in the repository that you can edit. Basically you need to add a new button to the wmd.css and the wmd.js files. Look around line 93 in the CSS and you'll see:

/* sprite button slicing style information */
#wmd-button-bar #wmd-bold-button    {left: 0px;   background-position: 0px 0;}
#wmd-button-bar #wmd-italic-button  {left: 25px;  background-position: -20px 0;}
#wmd-button-bar #wmd-spacer1        {left: 50px;}
#wmd-button-bar #wmd-link-button    {left: 75px;  background-position: -40px 0;}
#wmd-button-bar #wmd-quote-button   {left: 100px;  background-position: -60px 0;}
#wmd-button-bar #wmd-code-button    {left: 125px;  background-position: -80px 0;}
#wmd-button-bar #wmd-image-button   {left: 150px;  background-position: -100px 0;}
#wmd-button-bar #wmd-spacer2        {left: 175px;}
#wmd-button-bar #wmd-olist-button   {left: 200px;  background-position: -120px 0;}
#wmd-button-bar #wmd-ulist-button   {left: 225px; background-position: -140px 0;}
#wmd-button-bar #wmd-heading-button {left: 250px; background-position: -160px 0;}
#wmd-button-bar #wmd-hr-button      {left: 275px; background-position: -180px 0;}
#wmd-button-bar #wmd-spacer3        {left: 300px;}
#wmd-button-bar #wmd-undo-button    {left: 325px; background-position: -200px 0;}
#wmd-button-bar #wmd-redo-button    {left: 350px; background-position: -220px 0;}
#wmd-button-bar #wmd-help-button    {right: 0px; background-position: -240px 0;}

Note how the original styling of wmd-button-bar and the how left is being used above.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.