Loading ...
Sorry, an error occurred while loading the content.

Re: clearEditorDoc() doesnt clear RTE in IE

Expand Messages
  • sai.kumar_gv
    Hi , Thanks for the reply . Plz find the details IE Version : 6.0.2900.xx FireFox Version : 3.0.6 YUI Version : 2.7 ( Same in 2.6 also ) Sample code
    Message 1 of 7 , Mar 1, 2009
    • 0 Attachment
      Hi ,
      Thanks for the reply . Plz find the details

      IE Version : 6.0.2900.xx
      FireFox Version : 3.0.6
      YUI Version : 2.7 ( Same in 2.6 also )

      Sample code
      ==================
      requirementsEditor.toolbar.on('refreshClick', function(ev) {

      requirementsEditor.clearEditorDoc();

      }, requirementsEditor, true);


      Full code :
      ==================




      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=utf-8">
      <title>Icon Insertion</title>


      <link rel="stylesheet" type="text/css"
      href="../../build/menu/assets/skins/sam/menu.css" />
      <link rel="stylesheet" type="text/css"
      href="../../build/button/assets/skins/sam/button.css" />
      <link rel="stylesheet" type="text/css"
      href="../../build/fonts/fonts-min.css" />
      <link rel="stylesheet" type="text/css"
      href="../../build/container/assets/skins/sam/container.css" />
      <link rel="stylesheet" type="text/css"
      href="../../build/editor/assets/skins/sam/editor.css" />
      <script type="text/javascript"
      src="../../build/utilities/utilities.js"></script>

      <script type="text/javascript"
      src="../../build/container/container-min.js"></script>
      <script type="text/javascript"
      src="../../build/menu/menu-min.js"></script>
      <script type="text/javascript"
      src="../../build/button/button-min.js"></script>
      <script type="text/javascript"
      src="../../build/editor/editor-min.js"></script>

      <!--there is no custom header content for this example-->




      <!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

      <style>
      .yui-skin-sam .yui-toolbar-container .yui-toolbar-mark
      span.yui-toolbar-icon {
      background-image: url( s.gif );
      background-position: 1px 0px;
      left: 5px;
      }
      .yui-skin-sam .yui-toolbar-container .yui-toolbar-removeformat
      span.yui-toolbar-icon {
      background-image: url( c.gif );
      background-position: 1px 0px;
      left: 5px;
      }

      .yui-skin-sam .yui-toolbar-container .yui-toolbar-import
      span.yui-toolbar-icon {
      background-image: url( i.gif );
      background-position: 1px 0px;
      left: 5px;
      }
      .yui-skin-sam .yui-toolbar-container .yui-toolbar-refresh
      span.yui-toolbar-icon {
      background-image: url( r.gif );
      background-position: 1px 0px;
      left: 5px;
      }

      </style>
      <script>
      (function() {
      var myConfig = {
      height: '300px',
      width: '600px',
      animate: false,
      dompath: false,
      limitCommands :true,
      toolbar: {
      buttons: [

      { group: 'commands', label: ' ',
      buttons: [
      {type: 'push',value: 'insertunorderedlist',label: 'List'},
      { type: 'separator' },
      { type: 'push', label: 'MarkCR', value: 'mark',
      disabled: false },
      { type: 'separator' },
      { type: 'push', label: 'UnMarkCR', value: 'removeformat',
      disabled: true },
      { type: 'separator' },
      { type: 'push', label: 'ImportSections', value: 'import',
      disabled: false },
      { type: 'separator' },
      { type: 'push', label: 'Clear And Refresh', value: 'refresh',
      disabled: false }

      ]
      }]
      }


      };

      requirementsEditor = new YAHOO.widget.Editor('editor', myConfig);


      // Toolbar events

      requirementsEditor.on('toolbarLoaded', function() {

      requirementsEditor.toolbar.on('markClick', function(ev) {

      getSelectedCr();

      }, requirementsEditor, true);

      requirementsEditor.toolbar.on('importClick', function(ev) {


      }, requirementsEditor, true);

      requirementsEditor.toolbar.on('refreshClick', function(ev) {

      requirementsEditor.clearEditorDoc();

      }, requirementsEditor, true);


      });

      requirementsEditor.render();

      })();


      function getSelectedCr() {

      var el = requirementsEditor._getSelectedElement();

      if(requirementsEditor._hasSelection()){

      if (requirementsEditor._isElement(el, 'li')){

      if(!requirementsEditor.browser.ie){
      // only for FireFox , List CR selction bug


      var elementText= el.innerHTML;

      if (elementText==requirementsEditor._getSelection()){


      el.innerHTML="<font style=\"FONT-WEIGHT: bold;
      COLOR:blue\">"+elementText+"</span>";

      requirementsEditor._selectNode(requirementsEditor.currentElement[0]);

      return;
      }

      }
      }

      requirementsEditor._createCurrentElement('font',{color:'blue' ,
      'fontWeight': 'bold' } );
      requirementsEditor._selectNode(requirementsEditor.currentElement[0]);

      var ta = requirementsEditor.get('element'),
      iframe = requirementsEditor.get('iframe').get('element');


      Dom.removeClass(iframe, 'editor-hidden');
      Dom.addClass(ta, 'editor-hidden');
      requirementsEditor.show();
      requirementsEditor._focusWindow();
      requirementsEditor.cleanHTML();
      requirementsEditor._selectNode(requirementsEditor.currentElement[0]);


      }

      }


      function Print(){

      requirementsEditor.saveHTML();
      var html = requirementsEditor.get('element').value;
      var txtNode=document.createTextNode(html);
      var textArea=document.getElementsByTagName("textarea")[1];
      textArea.value=html;

      }

      function CleanWordHTML( wordContent )
      {
      wordDiv = document.createElement("DIV");
      wordDiv.innerHTML = wordContent;

      for (var i=0;i<wordDiv.all.length;i++)
      {
      wordDiv.all[i].removeAttribute("className","",0);
      wordDiv.all[i].removeAttribute("style","",0);
      }
      wordContent = wordDiv.innerHTML;
      wordContent = String(wordContent).replace(/<\\?\?xml[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?o:p[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?v:[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?o:[^>]*>/g,"");
      wordContent = String(wordContent).replace(/ /g,"");//<p> </p>
      wordContent = String(wordContent).replace(/<\/?SPAN[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?FONT[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?STRONG[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?P[^>]*><\/P>/g,"");
      wordContent = String(wordContent).replace(/<\/?H1[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?H2[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?H3[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?H4[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?H5[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?H6[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?st1[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?P[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?TABLE[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?TBODY[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?TR[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?TD[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?DIV[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?A[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?STRONG[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?EM[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?DIV[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?BR[^>]*>/g,"");
      wordContent = String(wordContent).replace(/<\/?U[^>]*>/g,"");

      return(wordContent);

      }



      // EVENTS of YUI


      requirementsEditor.on('beforeEditorKeyDown', function(ev) {

      if (ev.ev.ctrlKey && ev.ev.keyCode==86) {

      var data=window.clipboardData.getData('Text');
      requirementsEditor.get('element').value=CleanWordHTML(data);

      return false;
      }
      });



      requirementsEditor.on('cleanHTML', function(ev) {
      requirementsEditor.get('element').value = ev.html;


      }, true);

      YAHOO.util.Event.on('markcr', 'click', getSelectedCr);
      YAHOO.util.Event.on('unmarkcr', 'click', unSelectcr);







      </script>
      </head>

      <body class="yui-skin-sam">

      <form method="post" action="#" id="form1">
      <textarea id="editor" name="editor" rows="20" cols="75">
      This is some more test text.<br>This is some more test text.<br>This
      is some more test text.<br>This is some more test text.<br>This is
      some more test text.<br>This is some more test text.<br>This is some
      more test text.<br>
      </textarea>
      </form>



      <input type="button" value="Mark CR#" id="markcr">
      <input type="button" value="UnMark CR#" id="unmarkcr" >
      <input type="button" value="Submit" name="b3" onclick="Print()">
      <input type="button" value="Submit" name="toggle" >
      <H3>Source Here </H3>
      <textarea id="editor1" name="editor" rows="20" cols="75">

      </textarea>

      </form>


      </body>
      </html>


      --- In ydn-javascript@yahoogroups.com, "cjavajim" <cjavajim@...> wrote:
      >
      > --- In ydn-javascript@yahoogroups.com, "sai.kumar_gv"
      > <sai.kumar_gv@> wrote:
      > >
      > > clearEditorDoc() doesnt clear RTE in IE but fine in FireFox.
      > >
      > > Is there any work around in IE to clear text in RTE . reset ,set
      method
      > > doesnt help.
      > >
      > >
      > > Regards
      > > Sai
      > >
      >
      >
      > 1. Which version of IE are your referring to? And which version of
      > FireFox?
      >
      > 2. What version of YUI are you using?
      >
      > 3. Post a URL to your code so we can help you.
      >
    • sai.kumar_gv
      Hi , clearEditorDoc(); clears the text that we key in on RTE . but if the text is already present in This is not cleared . How do we
      Message 2 of 7 , Mar 2, 2009
      • 0 Attachment
        Hi ,
        clearEditorDoc(); clears the text that we key in on RTE . but if the
        text is already present in <textarea> This is not cleared </textarea>
        . How do we clear both default text and text we key in . Where as in
        firefox it clears both .


        Even .setEditorHTML('<br>'); doesnt clear default text

        Regards
        Sai

        --- In ydn-javascript@yahoogroups.com, Dav Glass <davglass@...> wrote:
        >
        > Please file a bug, it should work..
        >
        > You can also do i this way:
        >
        > myEditor.setEditorHTML('<br>');
        >
        > Dav
        >
        > --
        > Dav Glass
        > davglass@...
        > blog.davglass.com
        >
        >
        > + Windows: n. - The most successful computer virus, ever. +
        > + A computer without a Microsoft operating system is like a dog
        > without bricks tied to its head +
        > + A Microsoft Certified Systems Engineer is to computing what a
        > McDonalds Certified Food Specialist is to fine cuisine +
        >
        >
        >
        > On Sun, Mar 1, 2009 at 8:53 AM, sai.kumar_gv <sai.kumar_gv@...> wrote:
        > > clearEditorDoc() is working fine in FireFox , but not in IE.
        > >
        > > Is there any woraround for IE . reset , set('element',"",true) doesnt
        > > work.
        > >
        > > Please suggest.
        > >
        > > Regards
        > > Sai
        > >
        > >
        >
      • Dav Glass
        First clear the Editor with setEditorHTML, then clear the textarea: myEditor.setEditorHTML( ); myEditor.get( element ).value = ; Dav -- Dav Glass
        Message 3 of 7 , Mar 2, 2009
        • 0 Attachment
          First clear the Editor with setEditorHTML, then clear the textarea:
          myEditor.setEditorHTML('<br>');
          myEditor.get('element').value = '';

          Dav

          --
          Dav Glass
          davglass@...
          blog.davglass.com


          + Windows: n. - The most successful computer virus, ever. +
          + A computer without a Microsoft operating system is like a dog
          without bricks tied to its head +
          + A Microsoft Certified Systems Engineer is to computing what a
          McDonalds Certified Food Specialist is to fine cuisine +



          On Mon, Mar 2, 2009 at 12:39 AM, sai.kumar_gv <sai.kumar_gv@...> wrote:
          > Hi ,
          > clearEditorDoc(); clears the text that we key in on RTE . but if the
          > text is already present in <textarea> This is not cleared </textarea>
          > . How do we clear both default text and text we key in . Where as in
          > firefox it clears both .
          >
          > Even .setEditorHTML('<br>'); doesnt clear default text
          >
          > Regards
          > Sai
          >
          > --- In ydn-javascript@yahoogroups.com, Dav Glass <davglass@...> wrote:
          >>
          >> Please file a bug, it should work..
          >>
          >> You can also do i this way:
          >>
          >> myEditor.setEditorHTML('<br>');
          >>
          >> Dav
          >>
          >> --
          >> Dav Glass
          >> davglass@...
          >> blog.davglass.com
          >>
          >>
          >> + Windows: n. - The most successful computer virus, ever. +
          >> + A computer without a Microsoft operating system is like a dog
          >> without bricks tied to its head +
          >> + A Microsoft Certified Systems Engineer is to computing what a
          >> McDonalds Certified Food Specialist is to fine cuisine +
          >>
          >>
          >>
          >> On Sun, Mar 1, 2009 at 8:53 AM, sai.kumar_gv <sai.kumar_gv@...> wrote:
          >> > clearEditorDoc() is working fine in FireFox , but not in IE.
          >> >
          >> > Is there any woraround for IE . reset , set('element',"",true) doesnt
          >> > work.
          >> >
          >> > Please suggest.
          >> >
          >> > Regards
          >> > Sai
          >> >
          >> >
          >>
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.