fix msword paste
[roojs1] / docs / src / Roo_HtmlEditorCore.js.html
index 3db7cdc..49bf095 100644 (file)
      * 
      */
     </span><span class="jsdoc-var">stylesheets</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">,
+     </span><span class="jsdoc-comment">/**
+     * @cfg {String} language default en - language of text (usefull for rtl languages)
+     * 
+     */
+    </span><span class="jsdoc-var">language</span><span class="jsdoc-syntax">: </span><span class="jsdoc-string">'en'</span><span class="jsdoc-syntax">,
 
     </span><span class="jsdoc-comment">/**
      * @cfg {boolean} allowComments - default false - allow comments in HTML source
             </span><span class="jsdoc-string">'IMG { cursor: pointer } ' </span><span class="jsdoc-syntax">+
         </span><span class="jsdoc-string">'&lt;/style&gt;'</span><span class="jsdoc-syntax">;
 
-        </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">cls </span><span class="jsdoc-syntax">= </span><span class="jsdoc-string">'roo-htmleditor-body'</span><span class="jsdoc-syntax">;
+        </span><span class="jsdoc-var">st </span><span class="jsdoc-syntax">+= </span><span class="jsdoc-string">'&lt;meta name=&quot;google&quot; content=&quot;notranslate&quot;&gt;'</span><span class="jsdoc-syntax">;
+
+        </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">cls </span><span class="jsdoc-syntax">= </span><span class="jsdoc-string">'notranslate roo-htmleditor-body'</span><span class="jsdoc-syntax">;
 
         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.bodyCls.length</span><span class="jsdoc-syntax">){
             </span><span class="jsdoc-var">cls </span><span class="jsdoc-syntax">+= </span><span class="jsdoc-string">' ' </span><span class="jsdoc-syntax">+ </span><span class="jsdoc-var">this.bodyCls</span><span class="jsdoc-syntax">;
         }
 
-        </span><span class="jsdoc-keyword">return </span><span class="jsdoc-string">'&lt;html&gt;&lt;head&gt;' </span><span class="jsdoc-syntax">+ </span><span class="jsdoc-var">st  </span><span class="jsdoc-syntax">+
+        </span><span class="jsdoc-keyword">return </span><span class="jsdoc-string">'&lt;html  class=&quot;notranslate&quot; translate=&quot;no&quot;&gt;&lt;head&gt;' </span><span class="jsdoc-syntax">+ </span><span class="jsdoc-var">st  </span><span class="jsdoc-syntax">+
             </span><span class="jsdoc-comment">//&lt;style type=&quot;text/css&quot;&gt;' +
             //'body{border:0;margin:0;padding:3px;height:98%;cursor:text;}' +
             //'&lt;/style&gt;' +
      * @param {String} html The HTML to be cleaned
      * return {String} The cleaned HTML
      */
-    </span><span class="jsdoc-var">cleanHtml </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">html</span><span class="jsdoc-syntax">){
+    </span><span class="jsdoc-var">cleanHtml </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">html</span><span class="jsdoc-syntax">)
+    {
         </span><span class="jsdoc-var">html </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">String</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">html</span><span class="jsdoc-syntax">);
         </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">html.length </span><span class="jsdoc-syntax">&gt; 5){
             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Roo.isSafari</span><span class="jsdoc-syntax">){ </span><span class="jsdoc-comment">// strip safari nonsense
             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">bd </span><span class="jsdoc-syntax">= (</span><span class="jsdoc-var">this.doc.body </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">this.doc.documentElement</span><span class="jsdoc-syntax">);
 
 
+            </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">sel </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.win.getSelection</span><span class="jsdoc-syntax">();
 
             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">div </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">document.createElement</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'div'</span><span class="jsdoc-syntax">);
             </span><span class="jsdoc-var">div.innerHTML </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">bd.innerHTML</span><span class="jsdoc-syntax">;
+            </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">gtx </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">div.getElementsByClassName</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'gtx-trans-icon'</span><span class="jsdoc-syntax">); </span><span class="jsdoc-comment">// google translate - really annoying and difficult to get rid of.
+            </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">gtx.length </span><span class="jsdoc-syntax">&gt; 0) {
+                </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">rm </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">gtx.item</span><span class="jsdoc-syntax">(0)</span><span class="jsdoc-var">.parentNode</span><span class="jsdoc-syntax">;
+                </span><span class="jsdoc-var">rm.parentNode.removeChild</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">rm</span><span class="jsdoc-syntax">);
+            }
 
 
             </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.enableBlocks</span><span class="jsdoc-syntax">) {
                 </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterBlock</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">div </span><span class="jsdoc-syntax">});
             }
             </span><span class="jsdoc-comment">//?? tidy?
+            </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">tidy </span><span class="jsdoc-syntax">= </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.TidySerializer</span><span class="jsdoc-syntax">({
+                </span><span class="jsdoc-var">inner</span><span class="jsdoc-syntax">:  </span><span class="jsdoc-keyword">true
+            </span><span class="jsdoc-syntax">});
+            </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">html  </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">tidy.serialize</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">div</span><span class="jsdoc-syntax">);
 
 
-            </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">html </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">div.innerHTML</span><span class="jsdoc-syntax">;
             </span><span class="jsdoc-keyword">if</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Roo.isSafari</span><span class="jsdoc-syntax">){
                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">bs </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">bd.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'style'</span><span class="jsdoc-syntax">); </span><span class="jsdoc-comment">// Safari puts text-align styles on the body element!
                 </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">m </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">bs </span><span class="jsdoc-syntax">? </span><span class="jsdoc-var">bs.match</span><span class="jsdoc-syntax">(/text-align:(.*?);/i) : </span><span class="jsdoc-keyword">false</span><span class="jsdoc-syntax">;
             </span><span class="jsdoc-syntax">}
 
             </span><span class="jsdoc-var">Roo.htmleditor.Block.initAll</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc.body</span><span class="jsdoc-syntax">);
+            </span><span class="jsdoc-var">this.updateLanguage</span><span class="jsdoc-syntax">();
 
             </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">lc </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.doc.body.lastChild</span><span class="jsdoc-syntax">;
             </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">lc </span><span class="jsdoc-syntax">&amp;&amp; </span><span class="jsdoc-var">lc.nodeType </span><span class="jsdoc-syntax">== 1 &amp;&amp; </span><span class="jsdoc-var">lc.getAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">&quot;contenteditable&quot;</span><span class="jsdoc-syntax">) == </span><span class="jsdoc-string">&quot;false&quot;</span><span class="jsdoc-syntax">) {
         //var ss = this.el.getStyles( 'background-image', 'background-repeat');
         //ss['background-attachment'] = 'fixed'; // w3c
         </span><span class="jsdoc-var">dbody.bgProperties </span><span class="jsdoc-syntax">= </span><span class="jsdoc-string">'fixed'</span><span class="jsdoc-syntax">; </span><span class="jsdoc-comment">// ie
-        //Roo.DomHelper.applyStyles(dbody, ss);
+        </span><span class="jsdoc-var">dbody.setAttribute</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">&quot;translate&quot;</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">&quot;no&quot;</span><span class="jsdoc-syntax">);
+
+        </span><span class="jsdoc-comment">//Roo.DomHelper.applyStyles(dbody, ss);
         </span><span class="jsdoc-var">Roo.EventManager.on</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.doc</span><span class="jsdoc-syntax">, {
-            </span><span class="jsdoc-comment">//'mousedown': this.onEditorEvent,
+
             </span><span class="jsdoc-string">'mouseup'</span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">this.onEditorEvent</span><span class="jsdoc-syntax">,
             </span><span class="jsdoc-string">'dblclick'</span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">this.onEditorEvent</span><span class="jsdoc-syntax">,
             </span><span class="jsdoc-string">'click'</span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">this.onEditorEvent</span><span class="jsdoc-syntax">,
         </span><span class="jsdoc-var">this.owner.fireEvent</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">'initialize'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">);
         </span><span class="jsdoc-var">this.pushValue</span><span class="jsdoc-syntax">();
     },
+    </span><span class="jsdoc-comment">// this is to prevent a href clicks resulting in a redirect?
 
     </span><span class="jsdoc-var">onPasteEvent </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">e</span><span class="jsdoc-syntax">,</span><span class="jsdoc-var">v</span><span class="jsdoc-syntax">)
     {
             });
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterBlack</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">tag </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">this.black</span><span class="jsdoc-syntax">});
             </span><span class="jsdoc-comment">// should be fonts..
-            </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterKeepChildren</span><span class="jsdoc-syntax">({</span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">tag </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'FONT' </span><span class="jsdoc-syntax">]} );
+            </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterKeepChildren</span><span class="jsdoc-syntax">({</span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">tag </span><span class="jsdoc-syntax">: [ </span><span class="jsdoc-string">'FONT'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'O:P' </span><span class="jsdoc-syntax">]} );
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterParagraph</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterSpan</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
             </span><span class="jsdoc-keyword">new </span><span class="jsdoc-var">Roo.htmleditor.FilterLongBr</span><span class="jsdoc-syntax">({ </span><span class="jsdoc-var">node </span><span class="jsdoc-syntax">: </span><span class="jsdoc-var">d </span><span class="jsdoc-syntax">});
     </span><span class="jsdoc-var">onEditorEvent </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">e</span><span class="jsdoc-syntax">)
     {
 
+
         </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">e </span><span class="jsdoc-syntax">&amp;&amp; (</span><span class="jsdoc-var">e.ctrlKey </span><span class="jsdoc-syntax">|| </span><span class="jsdoc-var">e.metaKey</span><span class="jsdoc-syntax">) &amp;&amp; </span><span class="jsdoc-var">e.keyCode </span><span class="jsdoc-syntax">=== 90) {
             </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">; </span><span class="jsdoc-comment">// we do not handle this.. (undo manager does..)
         </span><span class="jsdoc-syntax">}
 
 
 
-
         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">range </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this.createRange</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.getSelection</span><span class="jsdoc-syntax">())</span><span class="jsdoc-var">.cloneRange</span><span class="jsdoc-syntax">();
 
         </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">Roo.isIE</span><span class="jsdoc-syntax">) {
 
         </span><span class="jsdoc-keyword">return </span><span class="jsdoc-var">nodes</span><span class="jsdoc-syntax">[0];
     },
+
+
     </span><span class="jsdoc-var">createRange</span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">sel</span><span class="jsdoc-syntax">)
     {
         </span><span class="jsdoc-comment">// this has strange effects when using with 
 
     },
 
+
+    </span><span class="jsdoc-var">updateLanguage </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">()
+    {
+        </span><span class="jsdoc-keyword">if </span><span class="jsdoc-syntax">(!</span><span class="jsdoc-var">this.iframe </span><span class="jsdoc-syntax">|| !</span><span class="jsdoc-var">this.iframe.contentDocument</span><span class="jsdoc-syntax">) {
+            </span><span class="jsdoc-keyword">return</span><span class="jsdoc-syntax">;
+        }
+        </span><span class="jsdoc-var">Roo.get</span><span class="jsdoc-syntax">(</span><span class="jsdoc-var">this.iframe.contentDocument.body</span><span class="jsdoc-syntax">)</span><span class="jsdoc-var">.attr</span><span class="jsdoc-syntax">(</span><span class="jsdoc-string">&quot;lang&quot;</span><span class="jsdoc-syntax">, </span><span class="jsdoc-var">this.language</span><span class="jsdoc-syntax">);
+    },
+
+
     </span><span class="jsdoc-var">removeStylesheets </span><span class="jsdoc-syntax">: </span><span class="jsdoc-keyword">function</span><span class="jsdoc-syntax">()
     {
         </span><span class="jsdoc-keyword">var </span><span class="jsdoc-var">_this </span><span class="jsdoc-syntax">= </span><span class="jsdoc-var">this</span><span class="jsdoc-syntax">;
         </span><span class="jsdoc-string">'IFRAME'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'LAYER'</span><span class="jsdoc-syntax">,  </span><span class="jsdoc-string">'LINK'</span><span class="jsdoc-syntax">,     </span><span class="jsdoc-string">'META'</span><span class="jsdoc-syntax">,    </span><span class="jsdoc-string">'OBJECT'</span><span class="jsdoc-syntax">,
         </span><span class="jsdoc-string">'SCRIPT'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'STYLE' </span><span class="jsdoc-syntax">,</span><span class="jsdoc-string">'TITLE'</span><span class="jsdoc-syntax">,  </span><span class="jsdoc-string">'XML'</span><span class="jsdoc-syntax">,
         </span><span class="jsdoc-comment">//'FONT' // CLEAN LATER..
-        </span><span class="jsdoc-string">'COLGROUP'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'COL'  </span><span class="jsdoc-comment">// messy tables.
+        </span><span class="jsdoc-string">'COLGROUP'</span><span class="jsdoc-syntax">, </span><span class="jsdoc-string">'COL'   </span><span class="jsdoc-comment">// messy tables.
+
 
 </span><span class="jsdoc-syntax">];
 </span><span class="jsdoc-var">Roo.HtmlEditorCore.clean </span><span class="jsdoc-syntax">= [ </span><span class="jsdoc-comment">// ?? needed???