OK - Valid question re: CuteEditor_FilterHTML

Last post 02-09-2009, 12:24 AM by karl0. 8 replies.
Sort Posts: Previous Next
  •  01-26-2009, 11:59 PM 48081

    OK - Valid question re: CuteEditor_FilterHTML

    Hi
     
    failing to get an answer to http://cutesoft.net/forums/thread/47996.aspx, I decided to try another approach...
     
    function CuteEditor_FilterHTML(editor,code)
                {
                 
                    code = code.replace(/font-family:.*?>/ig, 'font-family: "Arial">');
                    code = code.replace(/font-size:.*?pt/ig, 'font-size: 12px');
                    return code;
                    
                   
                }

    I simply want to control font face and size especially if pasted from MS Word, so this works.... almost. The filtering is done correctly, but the visual display remains the same. In other words, if I paste in text from Word with 'Comic Sans MS' font face, the underlying html text is changed correctly, but not displayed correctly until the page is reloaded.
    How do I refresh the editor after the filter is applied?

    any ideas...


    Thanks


  •  01-27-2009, 1:36 PM 48111 in reply to 48081

    Re: OK - Valid question re: CuteEditor_FilterHTML

  •  01-27-2009, 10:14 PM 48128 in reply to 48111

    Re: OK - Valid question re: CuteEditor_FilterHTML

    no Adam, it didn't make any difference, again trying another approach, the following works for my purpose as I'm mainly concerned about pasted text...
    BUT as always there's an issue, this code does not work with firefox, any idea as to why not and is there a workaround?
     
    function CuteEditor_OnCommand(editor,command,ui,value)
                {
                   
                    if (command=="Paste")
                    {  
                    
                     var oEditor = document.getElementById(editor.id);
                     var oSelection = oEditor.GetSelection();
                     var oRange = oSelection.createRange();
                     
                   
                        oRange.execCommand("Paste");
                     
                        var sHTML = oEditor.getHTML();
                     
                        sHTML = sHTML.replace(/font-family:.*?>/ig, 'font-family: "Arial">');
                        sHTML = sHTML.replace(/font-size:.*?pt/ig, 'font-size: 12px');
                     
                        oEditor.setHTML(sHTML);
     
                       return true;

    }
     
     
     
    Thanks
     
     
  •  01-28-2009, 9:42 AM 48143 in reply to 48128

    Re: OK - Valid question re: CuteEditor_FilterHTML

    >>BUT as always there's an issue, this code does not work with firefox,
     
    var oRange = oSelection.createRange();
     
    This line will not work with firefox.
     
      if (document.selection) { // IE 
            var rng = document.selection.createRange(); 
        } 
        else { //Firefox 
            var sel = document.getSelection(); 
            var rng = window.getSelection().getRangeAt(0); 
        }

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  01-28-2009, 9:15 PM 48180 in reply to 48143

    Re: OK - Valid question re: CuteEditor_FilterHTML

    Thanks again Adam, But neither
     
     
    var sel = document.getSelection();
     
    or
     
    var rng = window.getSelection().getRangeAt(0); 
     
    don't work, neither get the text on the clipboard, both are empty.
     
    any other suggestions?
     
    for the record, all I'm trying to do is to restrict any text entered into the editor to Arial 12pt, you'd think this would be easy but I've already wasted lost of time on it. It's easy to do when typed straight into the editor using the editor body css, but the problem is when text is pasted in. As you can see I'm trying to strip the replace the font name and size, as I sai it works in IE, but not in FF. But if you know another way to accomplish what I want please let me know
     
     
    thanks
     
     
    ps I want to retain all other formatting like Bold and underline, it's just the font face and size I want to control.
     
     
  •  01-29-2009, 11:20 PM 48217 in reply to 48180

    Re: OK - Valid question re: CuteEditor_FilterHTML

    any more help on getting the clipboard selection in firefox?
  •  02-03-2009, 9:01 PM 48333 in reply to 48217

    Re: OK - Valid question re: CuteEditor_FilterHTML

    gotta make sure I don't slip off the first page before I get a reply
  •  02-04-2009, 12:10 PM 48371 in reply to 48217

    Re: OK - Valid question re: CuteEditor_FilterHTML

    Please use the following code:
     
     
      function getSelectedHTML(){
          var rng=null,html="";

          if (document.selection && document.selection.createRange){
            rng=editdoc.selection.createRange();
            html=rng.htmlText||"";
          }else if (window.getSelection){
            rng=editwin.getSelection();

            if (rng.rangeCount > 0 && window.XMLSerializer){
              rng=rng.getRangeAt(0);
              html=new XMLSerializer().serializeToString(rng.cloneContents());
            }
          }
          return html;
        }

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  02-09-2009, 12:24 AM 48478 in reply to 48371

    Re: OK - Valid question re: CuteEditor_FilterHTML

    This doesn't work either
     
    It's just a joke isn't it...
     
    trying to get the cute editor to be consistent with ctrl + v and context menu paste in both FF and IE is just a joke, and the biggest time waster I've encountered....
     
    surely with all the years experience and capability of the cute editor you would think that this would be a done and dusted formular, but every answer on this thread has been a dismal failure.
     
    what a waste of time...

     
    I mean.... what is editdoc and editwin in the above code, should it be document and window, not that it matters because it still doesn't work, you should't really paste code as an answer to a paying client on less you know it works, it basic customer service.

View as RSS news feed in XML