0

I've created a mini browser RichText editor that implements basic stuff like bold, italic, underline, indent among others. Say I have these on my textarea (which is really an iframe):

This is a bold text.

and let's take the BOLD button to further describe my problem. When the insertion point is at this state: Thi|s is a bold text.

then the BOLD button would be on its normal state. However, if it is in this state: This is a bol|d text

then the BOLD button would be on a selected/active state. How will I know if the BOLD button should be on an active/selected state or if it should be on a normal state with respect to the location of the insertion point?

  • See this question:[How to get Cursor position in Textarea?](http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea) – Qqwy Nov 30 '11 at 17:15
  • Hi thanks @Colin. I did not want to go thru the codes of TinyMCE to satisfy my preference for the UI/UX/design. It would just be a simple editor so I wouldn't be using the other lines of codes of TinyMCE; ergo less loading time. :) – threepoint1416 Nov 30 '11 at 17:16

1 Answers1

2

For the bold command, you can use document.queryCommandState("bold").

Here's a more detailed answer to a similar question from a couple of days ago: https://stackoverflow.com/a/8298215/96100

Community
  • 1
  • 1
Tim Down
  • 318,141
  • 75
  • 454
  • 536