0

I am creating my own wysiwyg editor and I encountered an issue.

As for the editor itself, it is pretty standard, I am using contenteditable iframe with some execcommand buttons for bold text and so on.

Now for my issue, I am not sure how to keep the html structure neat and clean.

For example, user clicks a button to make text he selected floated to the right which takes the selected text and wraps it in

  <div style="float: right">selected text</div>

. But if the users selects the text multiple times floating it back and forth something like this be the result.

<div style="float: right">
   <div style="float: left>
      <div style="float: right">
         selected text
      </div>
   </div>
</div>

, that is of course pretty messy and ugly.

Is there some clean way how to handle this? (And I don't want to use some third party editors like MCE)

Thanks

snowp
  • 495
  • 1
  • 6
  • 22
user2079305
  • 121
  • 1
  • 6
  • Check this http://stackoverflow.com/questions/16074358/content-editable-text-editors/16085789#16085789 The answer will be clear. – Reinmar May 06 '13 at 10:23
  • I see. Well, I will think about just forcing users to use the bbcode instead, it's not that hard anyway. – user2079305 May 06 '13 at 12:43

0 Answers0