0

I'm trying to wrap up a really simple RTE for private purposes. I'd like to toggle the bold/italic/underline buttons when a user clicks in the text. I've been reading several posts but they all include a selection either selected by mouse or double click. Also jQuery's select works on a selection, and not a point where was clicked. I understand there's not really any css for a cursor location, so I would like to select the word where the user clicked.

How can I get the css properties of word from the index clicked? I'm using a div that's editable.

Some of the posts I've been reading:

  1. jQuery select()
  2. Get the current word in paragraph on click event in jquery
Community
  • 1
  • 1
Ben Fransen
  • 10,884
  • 18
  • 76
  • 129
  • CSS is not dynamic and is just read and applied - so that is not a path. Seems like you would need to click and then span everything into an array and then based on click x and y find the span and get the data... but also doesn't sound possible. – sheriffderek Oct 15 '15 at 07:25
  • `I'd like to toggle the bold/italic/underline buttons when a user clicks in the text.` emphasis a bit more .. – Alexander Solonik Oct 15 '15 at 07:25
  • 1
    @AlexanderSolonik, for example when a word is bold, the bold button should be "active", visually clear that the text is bold. – Ben Fransen Oct 15 '15 at 07:29
  • @sheriffderek I think that would become a bit slow when there will be lots of text in the editor. Applying a `` to each word sounds a bit aggresive. – Ben Fransen Oct 15 '15 at 07:34
  • Yes, it sounds terrible. Most TinyMCE text input areas - like in WordPress etc have what I think you are talking about. You can check into that - or maybe even use one. – sheriffderek Oct 15 '15 at 17:46

0 Answers0