views:

262

answers:

2

Hi all !

I am trying to achieve project and i must do a WYSIWYG editor in JavaScript. I can't use an existing editor because I need use my plugins (for example a colorPicker or imagePicker)..

For this time I have this HTML :

<div class="K_editor" id="idExample">
   <div class="K_links">
      <div class="K_editor_link K_editor_linkBold">B</div>
      <div class="K_editor_link K_editor_linkItalic">I</div>
      <div class="K_editor_link K_editor_linkUnderline">U</div>
   </div>
   <iframe width="696" height="212" frameborder="0" src="js/myEditor_iFrame.php">
      <html>
         <head/>
         <body>
            <div id="contentIframe" contenteditable="true">
               This is a test code, with <strong>bold</strong> text and  <em>italic</em> text.
            </div>
         </body>
      </html>
   </iframe>
   <input type="submit"/>
</div>

On event click on ".K_editor_link", a function is open with arguments :

  • tagStart (exemple '<u>', or '<span style="color:#AB1;">')
  • tagEnd (exemple '</u>', or '</span>')
  • id (here 'idExample')

I know get a Selection on Textarea but "setSelectionRange()", ".selectionStart" and ".selectionEnd" are only for textbox (XUL), input (XHTML) or textarea (XHTML).

Why can I do for do that ??

I'm realy block..

Thank all !

PS : Sorry but I'm French and I do not speak English very well, I tried to make me understand but there are probably errors.

CactO_o's

A: 

You should really use a textarea instead of a div.

Jakob Kruse
Yes, but I can't stylize text in a textarea.
CactO_o's
A: 

Nobody can help me ?? :'( !

CactO_o's