3 * Copyright(c) 2006-2009 Ext JS, LLC
5 * http://www.extjs.com/license
8 * @class Ext.form.HtmlEditor
\r
9 * @extends Ext.form.Field
\r
10 * Provides a lightweight HTML Editor component. Some toolbar features are not supported by Safari and will be
\r
11 * automatically hidden when needed. These are noted in the config options where appropriate.
\r
12 * <br><br>The editor's toolbar buttons have tooltips defined in the {@link #buttonTips} property, but they are not
\r
13 * enabled by default unless the global {@link Ext.QuickTips} singleton is {@link Ext.QuickTips#init initialized}.
\r
14 * <br><br><b>Note: The focus/blur and validation marking functionality inherited from Ext.form.Field is NOT
\r
15 * supported by this editor.</b>
\r
16 * <br><br>An Editor is a sensitive component that can't be used in all spots standard fields can be used. Putting an Editor within
\r
17 * any element that has display set to 'none' can cause problems in Safari and Firefox due to their default iframe reloading bugs.
\r
18 * <br><br>Example usage:
\r
20 // Simple example rendered with default options:
\r
21 Ext.QuickTips.init(); // enable tooltips
\r
22 new Ext.form.HtmlEditor({
\r
23 renderTo: Ext.getBody(),
\r
28 // Passed via xtype into a container and with custom options:
\r
29 Ext.QuickTips.init(); // enable tooltips
\r
31 title: 'HTML Editor',
\r
32 renderTo: Ext.getBody(),
\r
38 xtype: 'htmleditor',
\r
39 enableColors: false,
\r
40 enableAlignments: false
\r
45 * Create a new HtmlEditor
\r
46 * @param {Object} config
\r
50 Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
\r
52 * @cfg {Boolean} enableFormat Enable the bold, italic and underline buttons (defaults to true)
\r
54 enableFormat : true,
\r
56 * @cfg {Boolean} enableFontSize Enable the increase/decrease font size buttons (defaults to true)
\r
58 enableFontSize : true,
\r
60 * @cfg {Boolean} enableColors Enable the fore/highlight color buttons (defaults to true)
\r
62 enableColors : true,
\r
64 * @cfg {Boolean} enableAlignments Enable the left, center, right alignment buttons (defaults to true)
\r
66 enableAlignments : true,
\r
68 * @cfg {Boolean} enableLists Enable the bullet and numbered list buttons. Not available in Safari. (defaults to true)
\r
72 * @cfg {Boolean} enableSourceEdit Enable the switch to source edit button. Not available in Safari. (defaults to true)
\r
74 enableSourceEdit : true,
\r
76 * @cfg {Boolean} enableLinks Enable the create link button. Not available in Safari. (defaults to true)
\r
80 * @cfg {Boolean} enableFont Enable font selection. Not available in Safari. (defaults to true)
\r
84 * @cfg {String} createLinkText The default text for the create link prompt
\r
86 createLinkText : 'Please enter the URL for the link:',
\r
88 * @cfg {String} defaultLinkValue The default value for the create link prompt (defaults to http:/ /)
\r
90 defaultLinkValue : 'http:/'+'/',
\r
92 * @cfg {Array} fontFamilies An array of available font families
\r
101 defaultFont: 'tahoma',
\r
103 * @cfg {String} defaultValue A default value to be put into the editor to resolve focus issues (defaults to ​ (Zero-width space), (Non-breaking space) in Opera and IE6).
\r
105 defaultValue: (Ext.isOpera || Ext.isIE6) ? ' ' : '​',
\r
107 // private properties
\r
108 actionMode: 'wrap',
\r
109 validationEvent : false,
\r
111 initialized : false,
\r
113 sourceEditMode : false,
\r
114 onFocus : Ext.emptyFn,
\r
116 hideMode:'offsets',
\r
117 defaultAutoCreate : {
\r
119 style:"width:500px;height:300px;",
\r
120 autocomplete: "off"
\r
124 initComponent : function(){
\r
127 * @event initialize
\r
128 * Fires when the editor is fully initialized (including the iframe)
\r
129 * @param {HtmlEditor} this
\r
134 * Fires when the editor is first receives the focus. Any insertion must wait
\r
135 * until after this event.
\r
136 * @param {HtmlEditor} this
\r
140 * @event beforesync
\r
141 * Fires before the textarea is updated with content from the editor iframe. Return false
\r
142 * to cancel the sync.
\r
143 * @param {HtmlEditor} this
\r
144 * @param {String} html
\r
148 * @event beforepush
\r
149 * Fires before the iframe editor is updated with content from the textarea. Return false
\r
150 * to cancel the push.
\r
151 * @param {HtmlEditor} this
\r
152 * @param {String} html
\r
157 * Fires when the textarea is updated with content from the editor iframe.
\r
158 * @param {HtmlEditor} this
\r
159 * @param {String} html
\r
164 * Fires when the iframe editor is updated with content from the textarea.
\r
165 * @param {HtmlEditor} this
\r
166 * @param {String} html
\r
170 * @event editmodechange
\r
171 * Fires when the editor switches edit modes
\r
172 * @param {HtmlEditor} this
\r
173 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
\r
180 createFontOptions : function(){
\r
181 var buf = [], fs = this.fontFamilies, ff, lc;
\r
182 for(var i = 0, len = fs.length; i< len; i++){
\r
184 lc = ff.toLowerCase();
\r
186 '<option value="',lc,'" style="font-family:',ff,';"',
\r
187 (this.defaultFont == lc ? ' selected="true">' : '>'),
\r
192 return buf.join('');
\r
196 * Protected method that will not generally be called directly. It
\r
197 * is called when the editor creates its toolbar. Override this method if you need to
\r
198 * add custom toolbar buttons.
\r
199 * @param {HtmlEditor} editor
\r
201 createToolbar : function(editor){
\r
203 var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
\r
205 function btn(id, toggle, handler){
\r
208 cls : 'x-btn-icon',
\r
209 iconCls: 'x-edit-'+id,
\r
210 enableToggle:toggle !== false,
\r
212 handler:handler||editor.relayBtnCmd,
\r
213 clickEvent:'mousedown',
\r
214 tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
\r
215 overflowText: editor.buttonTips[id].title || undefined,
\r
220 // build the toolbar
\r
221 var tb = new Ext.Toolbar({
\r
222 renderTo:this.wrap.dom.firstChild
\r
225 // stop form submits
\r
226 this.mon(tb.el, 'click', function(e){
\r
227 e.preventDefault();
\r
230 if(this.enableFont && !Ext.isSafari2){
\r
231 this.fontSelect = tb.el.createChild({
\r
233 cls:'x-font-select',
\r
234 html: this.createFontOptions()
\r
236 this.mon(this.fontSelect, 'change', function(){
\r
237 var font = this.fontSelect.dom.value;
\r
238 this.relayCmd('fontname', font);
\r
243 this.fontSelect.dom,
\r
248 if(this.enableFormat){
\r
256 if(this.enableFontSize){
\r
259 btn('increasefontsize', false, this.adjustFont),
\r
260 btn('decreasefontsize', false, this.adjustFont)
\r
264 if(this.enableColors){
\r
267 itemId:'forecolor',
\r
269 iconCls: 'x-edit-forecolor',
\r
270 clickEvent:'mousedown',
\r
271 tooltip: tipsEnabled ? editor.buttonTips.forecolor || undefined : undefined,
\r
273 menu : new Ext.menu.ColorMenu({
\r
274 allowReselect: true,
\r
275 focus: Ext.emptyFn,
\r
280 select: function(cp, color){
\r
281 this.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
\r
285 clickEvent:'mousedown'
\r
288 itemId:'backcolor',
\r
290 iconCls: 'x-edit-backcolor',
\r
291 clickEvent:'mousedown',
\r
292 tooltip: tipsEnabled ? editor.buttonTips.backcolor || undefined : undefined,
\r
294 menu : new Ext.menu.ColorMenu({
\r
295 focus: Ext.emptyFn,
\r
298 allowReselect: true,
\r
301 select: function(cp, color){
\r
303 this.execCmd('useCSS', false);
\r
304 this.execCmd('hilitecolor', color);
\r
305 this.execCmd('useCSS', true);
\r
308 this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
\r
313 clickEvent:'mousedown'
\r
319 if(this.enableAlignments){
\r
322 btn('justifyleft'),
\r
323 btn('justifycenter'),
\r
324 btn('justifyright')
\r
328 if(!Ext.isSafari2){
\r
329 if(this.enableLinks){
\r
332 btn('createlink', false, this.createLink)
\r
336 if(this.enableLists){
\r
339 btn('insertorderedlist'),
\r
340 btn('insertunorderedlist')
\r
343 if(this.enableSourceEdit){
\r
346 btn('sourceedit', true, function(btn){
\r
347 this.toggleSourceEdit(!this.sourceEditMode);
\r
357 * Protected method that will not generally be called directly. It
\r
358 * is called when the editor initializes the iframe with HTML contents. Override this method if you
\r
359 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
\r
361 getDocMarkup : function(){
\r
362 return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
\r
366 getEditorBody : function(){
\r
367 return this.doc.body || this.doc.documentElement;
\r
371 getDoc : function(){
\r
372 return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
\r
376 getWin : function(){
\r
377 return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
\r
381 onRender : function(ct, position){
\r
382 Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
\r
383 this.el.dom.style.border = '0 none';
\r
384 this.el.dom.setAttribute('tabIndex', -1);
\r
385 this.el.addClass('x-hidden');
\r
386 if(Ext.isIE){ // fix IE 1px bogus margin
\r
387 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
\r
389 this.wrap = this.el.wrap({
\r
390 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
\r
393 this.createToolbar(this);
\r
395 this.disableItems(true);
\r
397 // this.tb.doLayout();
\r
399 this.createIFrame();
\r
402 var sz = this.el.getSize();
\r
403 this.setSize(sz.width, this.height || sz.height);
\r
407 createIFrame: function(){
\r
408 var iframe = document.createElement('iframe');
\r
409 iframe.name = Ext.id();
\r
410 iframe.frameBorder = '0';
\r
411 iframe.src = Ext.isIE ? Ext.SSL_SECURE_URL : "javascript:;";
\r
412 this.wrap.dom.appendChild(iframe);
\r
414 this.iframe = iframe;
\r
416 this.monitorTask = Ext.TaskMgr.start({
\r
417 run: this.checkDesignMode,
\r
423 initFrame : function(){
\r
424 Ext.TaskMgr.stop(this.monitorTask);
\r
425 this.doc = this.getDoc();
\r
426 this.win = this.getWin();
\r
429 this.doc.write(this.getDocMarkup());
\r
432 var task = { // must defer to wait for browser to be ready
\r
434 if(this.doc.body || this.doc.readyState == 'complete'){
\r
435 Ext.TaskMgr.stop(task);
\r
436 this.doc.designMode="on";
\r
437 this.initEditor.defer(10, this);
\r
444 Ext.TaskMgr.start(task);
\r
448 checkDesignMode : function(){
\r
449 if(this.wrap && this.wrap.dom.offsetWidth){
\r
450 var doc = this.getDoc();
\r
454 if(!doc.editorInitialized || String(doc.designMode).toLowerCase() != 'on'){
\r
460 disableItems: function(disabled){
\r
461 if(this.fontSelect){
\r
462 this.fontSelect.dom.disabled = disabled;
\r
464 this.tb.items.each(function(item){
\r
465 if(item.itemId != 'sourceedit'){
\r
466 item.setDisabled(disabled);
\r
472 onResize : function(w, h){
\r
473 Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
\r
474 if(this.el && this.iframe){
\r
475 if(typeof w == 'number'){
\r
476 var aw = w - this.wrap.getFrameWidth('lr');
\r
477 this.el.setWidth(this.adjustWidth('textarea', aw));
\r
478 this.tb.setWidth(aw);
\r
479 this.iframe.style.width = Math.max(aw, 0) + 'px';
\r
481 if(typeof h == 'number'){
\r
482 var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
\r
483 this.el.setHeight(this.adjustWidth('textarea', ah));
\r
484 this.iframe.style.height = Math.max(ah, 0) + 'px';
\r
486 this.getEditorBody().style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
\r
493 * Toggles the editor between standard and source edit mode.
\r
494 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
\r
496 toggleSourceEdit : function(sourceEditMode){
\r
497 if(sourceEditMode === undefined){
\r
498 sourceEditMode = !this.sourceEditMode;
\r
500 this.sourceEditMode = sourceEditMode === true;
\r
501 var btn = this.tb.items.get('sourceedit');
\r
502 if(btn.pressed !== this.sourceEditMode){
\r
503 btn.toggle(this.sourceEditMode);
\r
504 if(!btn.xtbHidden){
\r
508 if(this.sourceEditMode){
\r
509 this.disableItems(true);
\r
511 this.iframe.className = 'x-hidden';
\r
512 this.el.removeClass('x-hidden');
\r
513 this.el.dom.removeAttribute('tabIndex');
\r
516 if(this.initialized){
\r
517 this.disableItems(false);
\r
520 this.iframe.className = '';
\r
521 this.el.addClass('x-hidden');
\r
522 this.el.dom.setAttribute('tabIndex', -1);
\r
525 var lastSize = this.lastSize;
\r
527 delete this.lastSize;
\r
528 this.setSize(lastSize);
\r
530 this.fireEvent('editmodechange', this, this.sourceEditMode);
\r
533 // private used internally
\r
534 createLink : function(){
\r
535 var url = prompt(this.createLinkText, this.defaultLinkValue);
\r
536 if(url && url != 'http:/'+'/'){
\r
537 this.relayCmd('createlink', url);
\r
541 // private (for BoxComponent)
\r
542 adjustSize : Ext.BoxComponent.prototype.adjustSize,
\r
544 // private (for BoxComponent)
\r
545 getResizeEl : function(){
\r
549 // private (for BoxComponent)
\r
550 getPositionEl : function(){
\r
555 initEvents : function(){
\r
556 this.originalValue = this.getValue();
\r
560 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
\r
563 markInvalid : Ext.emptyFn,
\r
566 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
\r
569 clearInvalid : Ext.emptyFn,
\r
571 // docs inherit from Field
\r
572 setValue : function(v){
\r
573 Ext.form.HtmlEditor.superclass.setValue.call(this, v);
\r
579 * Protected method that will not generally be called directly. If you need/want
\r
580 * custom HTML cleanup, this is the method you should override.
\r
581 * @param {String} html The HTML to be cleaned
\r
582 * @return {String} The cleaned HTML
\r
584 cleanHtml : function(html){
\r
585 html = String(html);
\r
586 if(html.length > 5){
\r
587 if(Ext.isWebKit){ // strip safari nonsense
\r
588 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
\r
591 if(html == this.defaultValue){
\r
598 * Protected method that will not generally be called directly. Syncs the contents
\r
599 * of the editor iframe with the textarea.
\r
601 syncValue : function(){
\r
602 if(this.initialized){
\r
603 var bd = this.getEditorBody();
\r
604 var html = bd.innerHTML;
\r
606 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
\r
607 var m = bs.match(/text-align:(.*?);/i);
\r
609 html = '<div style="'+m[0]+'">' + html + '</div>';
\r
612 html = this.cleanHtml(html);
\r
613 if(this.fireEvent('beforesync', this, html) !== false){
\r
614 this.el.dom.value = html;
\r
615 this.fireEvent('sync', this, html);
\r
620 //docs inherit from Field
\r
621 getValue : function() {
\r
622 this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
\r
623 return Ext.form.HtmlEditor.superclass.getValue.call(this);
\r
627 * Protected method that will not generally be called directly. Pushes the value of the textarea
\r
628 * into the iframe editor.
\r
630 pushValue : function(){
\r
631 if(this.initialized){
\r
632 var v = this.el.dom.value;
\r
633 if(!this.activated && v.length < 1){
\r
634 v = this.defaultValue;
\r
636 if(this.fireEvent('beforepush', this, v) !== false){
\r
637 this.getEditorBody().innerHTML = v;
\r
639 // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8
\r
641 mode = d.designMode.toLowerCase();
\r
643 d.designMode = mode.toggle('on', 'off');
\r
644 d.designMode = mode;
\r
646 this.fireEvent('push', this, v);
\r
652 deferFocus : function(){
\r
653 this.focus.defer(10, this);
\r
656 // docs inherit from Field
\r
657 focus : function(){
\r
658 if(this.win && !this.sourceEditMode){
\r
666 initEditor : function(){
\r
667 //Destroying the component during/before initEditor can cause issues.
\r
669 var dbody = this.getEditorBody();
\r
670 var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
\r
671 ss['background-attachment'] = 'fixed'; // w3c
\r
672 dbody.bgProperties = 'fixed'; // ie
\r
674 Ext.DomHelper.applyStyles(dbody, ss);
\r
678 Ext.EventManager.removeAll(this.doc);
\r
682 this.doc = this.getDoc();
\r
684 Ext.EventManager.on(this.doc, {
\r
685 'mousedown': this.onEditorEvent,
\r
686 'dblclick': this.onEditorEvent,
\r
687 'click': this.onEditorEvent,
\r
688 'keyup': this.onEditorEvent,
\r
694 Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
\r
696 if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
\r
697 Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
\r
699 this.initialized = true;
\r
700 this.fireEvent('initialize', this);
\r
701 this.doc.editorInitialized = true;
\r
707 onDestroy : function(){
\r
708 if(this.monitorTask){
\r
709 Ext.TaskMgr.stop(this.monitorTask);
\r
712 Ext.destroy(this.tb);
\r
714 this.wrap.dom.innerHTML = '';
\r
715 this.wrap.remove();
\r
719 this.el.removeAllListeners();
\r
725 Ext.EventManager.removeAll(this.doc);
\r
726 for (var prop in this.doc){
\r
727 delete this.doc[prop];
\r
731 this.purgeListeners();
\r
735 onFirstFocus : function(){
\r
736 this.activated = true;
\r
737 this.disableItems(false);
\r
738 if(Ext.isGecko){ // prevent silly gecko errors
\r
740 var s = this.win.getSelection();
\r
741 if(!s.focusNode || s.focusNode.nodeType != 3){
\r
742 var r = s.getRangeAt(0);
\r
743 r.selectNodeContents(this.getEditorBody());
\r
748 this.execCmd('useCSS', true);
\r
749 this.execCmd('styleWithCSS', false);
\r
752 this.fireEvent('activate', this);
\r
756 adjustFont: function(btn){
\r
757 var adjust = btn.itemId == 'increasefontsize' ? 1 : -1;
\r
759 var v = parseInt(this.doc.queryCommandValue('FontSize') || 2, 10);
\r
760 if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
\r
762 // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px
\r
776 v = v.constrain(1, 6);
\r
778 if(Ext.isSafari){ // safari
\r
781 v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
\r
783 this.execCmd('FontSize', v);
\r
787 onEditorEvent : function(e){
\r
788 this.updateToolbar();
\r
793 * Protected method that will not generally be called directly. It triggers
\r
794 * a toolbar update by reading the markup state of the current selection in the editor.
\r
796 updateToolbar: function(){
\r
798 if(!this.activated){
\r
799 this.onFirstFocus();
\r
803 var btns = this.tb.items.map, doc = this.doc;
\r
805 if(this.enableFont && !Ext.isSafari2){
\r
806 var name = (this.doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
\r
807 if(name != this.fontSelect.dom.value){
\r
808 this.fontSelect.dom.value = name;
\r
811 if(this.enableFormat){
\r
812 btns.bold.toggle(doc.queryCommandState('bold'));
\r
813 btns.italic.toggle(doc.queryCommandState('italic'));
\r
814 btns.underline.toggle(doc.queryCommandState('underline'));
\r
816 if(this.enableAlignments){
\r
817 btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
\r
818 btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
\r
819 btns.justifyright.toggle(doc.queryCommandState('justifyright'));
\r
821 if(!Ext.isSafari2 && this.enableLists){
\r
822 btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
\r
823 btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
\r
826 Ext.menu.MenuMgr.hideAll();
\r
832 relayBtnCmd : function(btn){
\r
833 this.relayCmd(btn.itemId);
\r
837 * Executes a Midas editor command on the editor document and performs necessary focus and
\r
838 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
\r
839 * @param {String} cmd The Midas command
\r
840 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
\r
842 relayCmd : function(cmd, value){
\r
845 this.execCmd(cmd, value);
\r
846 this.updateToolbar();
\r
847 }).defer(10, this);
\r
851 * Executes a Midas editor command directly on the editor document.
\r
852 * For visual commands, you should use {@link #relayCmd} instead.
\r
853 * <b>This should only be called after the editor is initialized.</b>
\r
854 * @param {String} cmd The Midas command
\r
855 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
\r
857 execCmd : function(cmd, value){
\r
858 this.doc.execCommand(cmd, false, value === undefined ? null : value);
\r
863 applyCommand : function(e){
\r
865 var c = e.getCharCode(), cmd;
\r
867 c = String.fromCharCode(c);
\r
883 e.preventDefault();
\r
890 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
\r
892 * @param {String} text
\r
894 insertAtCursor : function(text){
\r
895 if(!this.activated){
\r
900 var r = this.doc.selection.createRange();
\r
907 }else if(Ext.isGecko || Ext.isOpera){
\r
909 this.execCmd('InsertHTML', text);
\r
911 }else if(Ext.isWebKit){
\r
912 this.execCmd('InsertText', text);
\r
918 fixKeys : function(){ // load time branching for fastest keydown performance
\r
920 return function(e){
\r
921 var k = e.getKey(), r;
\r
924 r = this.doc.selection.createRange();
\r
927 r.pasteHTML(' ');
\r
930 }else if(k == e.ENTER){
\r
931 r = this.doc.selection.createRange();
\r
933 var target = r.parentElement();
\r
934 if(!target || target.tagName.toLowerCase() != 'li'){
\r
936 r.pasteHTML('<br />');
\r
943 }else if(Ext.isOpera){
\r
944 return function(e){
\r
945 var k = e.getKey();
\r
949 this.execCmd('InsertHTML',' ');
\r
953 }else if(Ext.isWebKit){
\r
954 return function(e){
\r
955 var k = e.getKey();
\r
958 this.execCmd('InsertText','\t');
\r
966 * Returns the editor's toolbar. <b>This is only available after the editor has been rendered.</b>
\r
967 * @return {Ext.Toolbar}
\r
969 getToolbar : function(){
\r
974 * Object collection of toolbar tooltips for the buttons in the editor. The key
\r
975 * is the command id associated with that button and the value is a valid QuickTips object.
\r
980 title: 'Bold (Ctrl+B)',
\r
981 text: 'Make the selected text bold.',
\r
982 cls: 'x-html-editor-tip'
\r
985 title: 'Italic (Ctrl+I)',
\r
986 text: 'Make the selected text italic.',
\r
987 cls: 'x-html-editor-tip'
\r
995 title: 'Bold (Ctrl+B)',
\r
996 text: 'Make the selected text bold.',
\r
997 cls: 'x-html-editor-tip'
\r
1000 title: 'Italic (Ctrl+I)',
\r
1001 text: 'Make the selected text italic.',
\r
1002 cls: 'x-html-editor-tip'
\r
1005 title: 'Underline (Ctrl+U)',
\r
1006 text: 'Underline the selected text.',
\r
1007 cls: 'x-html-editor-tip'
\r
1009 increasefontsize : {
\r
1010 title: 'Grow Text',
\r
1011 text: 'Increase the font size.',
\r
1012 cls: 'x-html-editor-tip'
\r
1014 decreasefontsize : {
\r
1015 title: 'Shrink Text',
\r
1016 text: 'Decrease the font size.',
\r
1017 cls: 'x-html-editor-tip'
\r
1020 title: 'Text Highlight Color',
\r
1021 text: 'Change the background color of the selected text.',
\r
1022 cls: 'x-html-editor-tip'
\r
1025 title: 'Font Color',
\r
1026 text: 'Change the color of the selected text.',
\r
1027 cls: 'x-html-editor-tip'
\r
1030 title: 'Align Text Left',
\r
1031 text: 'Align text to the left.',
\r
1032 cls: 'x-html-editor-tip'
\r
1035 title: 'Center Text',
\r
1036 text: 'Center text in the editor.',
\r
1037 cls: 'x-html-editor-tip'
\r
1040 title: 'Align Text Right',
\r
1041 text: 'Align text to the right.',
\r
1042 cls: 'x-html-editor-tip'
\r
1044 insertunorderedlist : {
\r
1045 title: 'Bullet List',
\r
1046 text: 'Start a bulleted list.',
\r
1047 cls: 'x-html-editor-tip'
\r
1049 insertorderedlist : {
\r
1050 title: 'Numbered List',
\r
1051 text: 'Start a numbered list.',
\r
1052 cls: 'x-html-editor-tip'
\r
1055 title: 'Hyperlink',
\r
1056 text: 'Make the selected text a hyperlink.',
\r
1057 cls: 'x-html-editor-tip'
\r
1060 title: 'Source Edit',
\r
1061 text: 'Switch to source editing mode.',
\r
1062 cls: 'x-html-editor-tip'
\r
1066 // hide stuff that is not compatible
\r
1080 * @event specialkey
\r
1084 * @cfg {String} fieldClass @hide
\r
1087 * @cfg {String} focusClass @hide
\r
1090 * @cfg {String} autoCreate @hide
\r
1093 * @cfg {String} inputType @hide
\r
1096 * @cfg {String} invalidClass @hide
\r
1099 * @cfg {String} invalidText @hide
\r
1102 * @cfg {String} msgFx @hide
\r
1105 * @cfg {String} validateOnBlur @hide
\r
1108 * @cfg {Boolean} allowDomMove @hide
\r
1111 * @cfg {String} applyTo @hide
\r
1114 * @cfg {String} autoHeight @hide
\r
1117 * @cfg {String} autoWidth @hide
\r
1120 * @cfg {String} cls @hide
\r
1123 * @cfg {String} disabled @hide
\r
1126 * @cfg {String} disabledClass @hide
\r
1129 * @cfg {String} msgTarget @hide
\r
1132 * @cfg {String} readOnly @hide
\r
1135 * @cfg {String} style @hide
\r
1138 * @cfg {String} validationDelay @hide
\r
1141 * @cfg {String} validationEvent @hide
\r
1144 * @cfg {String} tabIndex @hide
\r
1147 * @property disabled
\r
1151 * @method applyToMarkup
\r
1163 * @method validate
\r
1171 * @method setDisabled
\r
1179 Ext.reg('htmleditor', Ext.form.HtmlEditor);