Changeset 998


Ignore:
Timestamp:
05/01/08 12:33:36 (11 years ago)
Author:
ray
Message:
  • #1201 Add inwardHtml/outwardHtml functions to Config object
  • Improved method for finding editing position in Gecko/Webkit?
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/XinhaCore.js

    r994 r998  
    698698 
    699699 
    700   /** Sometimes we want to be able to replace some string in the html comng in and going out 
     700  /** Sometimes we want to be able to replace some string in the html coming in and going out 
    701701   *  so that in the editor we use the "internal" string, and outside and in the source view 
    702702   *  we use the "external" string  this is useful for say making special codes for 
     
    708708   */ 
    709709  this.specialReplacements = {}; //{ 'html_string' : 'wysiwyg_string' } 
     710   
     711  /** A filter function for the HTML used inside the editor<br /> 
     712   * Default: function (html) { return html } 
     713   *  
     714   * @param {String} html The whole document's HTML content 
     715   * @return {String} The processed HTML  
     716   */ 
     717  this.inwardHtml = function (html) { return html } 
     718   
     719  /** A filter function for the generated HTML<br /> 
     720   * Default: function (html) { return html } 
     721   *  
     722   * @param {String} html The whole document's HTML content 
     723   * @return {String} The processed HTML  
     724   */ 
     725  this.outwardHtml = function (html) { return html } 
    710726 
    711727 /** Set to true if you want Word code to be cleaned upon Paste. This only works if  
     
    48804896    html = Xinha.stripCoreCSS(html); 
    48814897  } 
    4882      
     4898 
     4899  if (typeof this.config.outwardHtml == 'function' ) 
     4900  { 
     4901    html = this.config.outwardHtml(html); 
     4902  } 
     4903 
    48834904  return html; 
    48844905}; 
     
    49264947    html = Xinha.addCoreCSS(html); 
    49274948  } 
    4928    
     4949 
     4950  if (typeof this.config.inwardHtml == 'function' ) 
     4951  { 
     4952    html = this.config.inwardHtml(html); 
     4953  } 
     4954 
    49294955  return html; 
    49304956}; 
  • trunk/modules/Gecko/Gecko.js

    r981 r998  
    782782    try 
    783783    { 
    784       this._iframe.contentWindow.find( this.cc ); 
    785       var sel = this.getSelection(); 
    786       sel.getRangeAt(0).deleteContents(); 
    787       this.scrollToElement(); 
     784      var doc = this._doc;  
     785      doc.body.innerHTML = doc.body.innerHTML.replace(new RegExp(this.cc),'<span id="XinhaEditingPostion"></span>'); 
     786      var posEl = doc.getElementById('XinhaEditingPostion'); 
     787      this.selectNodeContents(posEl); 
     788      posEl.scrollIntoView(true); 
     789      posEl.parentNode.removeChild(posEl); 
     790 
    788791      this._iframe.contentWindow.focus(); 
    789792    } catch (e) {} 
  • trunk/modules/WebKit/WebKit.js

    r963 r998  
    772772  { 
    773773    var self = this; 
    774     window.setTimeout(function  () // something's not working? try a timeout ;) 
    775     {  
    776       try  
    777       { 
    778         if( self._iframe.contentWindow.find( self.cc ) ) 
    779         { 
    780             var sel = self.getSelection(); 
    781             sel.getRangeAt(0).deleteContents(); 
    782                         sel.collapseToStart(); 
    783             self._iframe.contentWindow.focus(); 
    784          } 
    785       } catch (e) {alert(e)} 
    786     } 
    787     ,200); 
     774    try 
     775    { 
     776      var doc = this._doc;  
     777      doc.body.innerHTML = doc.body.innerHTML.replace(new RegExp(this.cc),'<span id="XinhaEditingPostion"></span>'); 
     778      var posEl = doc.getElementById('XinhaEditingPostion'); 
     779      this.selectNodeContents(posEl); 
     780      this.scrollToElement(posEl); 
     781      posEl.parentNode.removeChild(posEl); 
     782 
     783      this._iframe.contentWindow.focus(); 
     784    } catch (e) {} 
    788785  } 
    789786}; 
Note: See TracChangeset for help on using the changeset viewer.