3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
4 <title>The source code</title>
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <body onload="prettyPrint();">
9 <pre class="prettyprint lang-js">/*!
10 * Ext JS Library 3.2.1
11 * Copyright(c) 2006-2010 Ext JS, Inc.
13 * http://www.extjs.com/license
15 <div id="cls-Ext.form.HtmlEditor"></div>/**
16 * @class Ext.form.HtmlEditor
17 * @extends Ext.form.Field
18 * Provides a lightweight HTML Editor component. Some toolbar features are not supported by Safari and will be
19 * automatically hidden when needed. These are noted in the config options where appropriate.
20 * <br><br>The editor's toolbar buttons have tooltips defined in the {@link #buttonTips} property, but they are not
21 * enabled by default unless the global {@link Ext.QuickTips} singleton is {@link Ext.QuickTips#init initialized}.
22 * <br><br><b>Note: The focus/blur and validation marking functionality inherited from Ext.form.Field is NOT
23 * supported by this editor.</b>
24 * <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
25 * any element that has display set to 'none' can cause problems in Safari and Firefox due to their default iframe reloading bugs.
26 * <br><br>Example usage:
28 // Simple example rendered with default options:
29 Ext.QuickTips.init(); // enable tooltips
30 new Ext.form.HtmlEditor({
31 renderTo: Ext.getBody(),
36 // Passed via xtype into a container and with custom options:
37 Ext.QuickTips.init(); // enable tooltips
40 renderTo: Ext.getBody(),
48 enableAlignments: false
53 * Create a new HtmlEditor
54 * @param {Object} config
58 Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
59 <div id="cfg-Ext.form.HtmlEditor-enableFormat"></div>/**
60 * @cfg {Boolean} enableFormat Enable the bold, italic and underline buttons (defaults to true)
63 <div id="cfg-Ext.form.HtmlEditor-enableFontSize"></div>/**
64 * @cfg {Boolean} enableFontSize Enable the increase/decrease font size buttons (defaults to true)
66 enableFontSize : true,
67 <div id="cfg-Ext.form.HtmlEditor-enableColors"></div>/**
68 * @cfg {Boolean} enableColors Enable the fore/highlight color buttons (defaults to true)
71 <div id="cfg-Ext.form.HtmlEditor-enableAlignments"></div>/**
72 * @cfg {Boolean} enableAlignments Enable the left, center, right alignment buttons (defaults to true)
74 enableAlignments : true,
75 <div id="cfg-Ext.form.HtmlEditor-enableLists"></div>/**
76 * @cfg {Boolean} enableLists Enable the bullet and numbered list buttons. Not available in Safari. (defaults to true)
79 <div id="cfg-Ext.form.HtmlEditor-enableSourceEdit"></div>/**
80 * @cfg {Boolean} enableSourceEdit Enable the switch to source edit button. Not available in Safari. (defaults to true)
82 enableSourceEdit : true,
83 <div id="cfg-Ext.form.HtmlEditor-enableLinks"></div>/**
84 * @cfg {Boolean} enableLinks Enable the create link button. Not available in Safari. (defaults to true)
87 <div id="cfg-Ext.form.HtmlEditor-enableFont"></div>/**
88 * @cfg {Boolean} enableFont Enable font selection. Not available in Safari. (defaults to true)
91 <div id="cfg-Ext.form.HtmlEditor-createLinkText"></div>/**
92 * @cfg {String} createLinkText The default text for the create link prompt
94 createLinkText : 'Please enter the URL for the link:',
95 <div id="cfg-Ext.form.HtmlEditor-defaultLinkValue"></div>/**
96 * @cfg {String} defaultLinkValue The default value for the create link prompt (defaults to http:/ /)
98 defaultLinkValue : 'http:/'+'/',
99 <div id="cfg-Ext.form.HtmlEditor-fontFamilies"></div>/**
100 * @cfg {Array} fontFamilies An array of available font families
109 defaultFont: 'tahoma',
110 <div id="cfg-Ext.form.HtmlEditor-defaultValue"></div>/**
111 * @cfg {String} defaultValue A default value to be put into the editor to resolve focus issues (defaults to   (Non-breaking space) in Opera and IE6, ​ (Zero-width space) in all other browsers).
113 defaultValue: (Ext.isOpera || Ext.isIE6) ? ' ' : '​',
115 // private properties
117 validationEvent : false,
121 sourceEditMode : false,
122 onFocus : Ext.emptyFn,
125 defaultAutoCreate : {
127 style:"width:500px;height:300px;",
132 initComponent : function(){
134 <div id="event-Ext.form.HtmlEditor-initialize"></div>/**
136 * Fires when the editor is fully initialized (including the iframe)
137 * @param {HtmlEditor} this
140 <div id="event-Ext.form.HtmlEditor-activate"></div>/**
142 * Fires when the editor is first receives the focus. Any insertion must wait
143 * until after this event.
144 * @param {HtmlEditor} this
147 <div id="event-Ext.form.HtmlEditor-beforesync"></div>/**
149 * Fires before the textarea is updated with content from the editor iframe. Return false
150 * to cancel the sync.
151 * @param {HtmlEditor} this
152 * @param {String} html
155 <div id="event-Ext.form.HtmlEditor-beforepush"></div>/**
157 * Fires before the iframe editor is updated with content from the textarea. Return false
158 * to cancel the push.
159 * @param {HtmlEditor} this
160 * @param {String} html
163 <div id="event-Ext.form.HtmlEditor-sync"></div>/**
165 * Fires when the textarea is updated with content from the editor iframe.
166 * @param {HtmlEditor} this
167 * @param {String} html
170 <div id="event-Ext.form.HtmlEditor-push"></div>/**
172 * Fires when the iframe editor is updated with content from the textarea.
173 * @param {HtmlEditor} this
174 * @param {String} html
177 <div id="event-Ext.form.HtmlEditor-editmodechange"></div>/**
178 * @event editmodechange
179 * Fires when the editor switches edit modes
180 * @param {HtmlEditor} this
181 * @param {Boolean} sourceEdit True if source edit, false if standard editing.
188 createFontOptions : function(){
189 var buf = [], fs = this.fontFamilies, ff, lc;
190 for(var i = 0, len = fs.length; i< len; i++){
192 lc = ff.toLowerCase();
194 '<option value="',lc,'" style="font-family:',ff,';"',
195 (this.defaultFont == lc ? ' selected="true">' : '>'),
204 * Protected method that will not generally be called directly. It
205 * is called when the editor creates its toolbar. Override this method if you need to
206 * add custom toolbar buttons.
207 * @param {HtmlEditor} editor
209 createToolbar : function(editor){
211 var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
214 function btn(id, toggle, handler){
218 iconCls: 'x-edit-'+id,
219 enableToggle:toggle !== false,
221 handler:handler||editor.relayBtnCmd,
222 clickEvent:'mousedown',
223 tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
224 overflowText: editor.buttonTips[id].title || undefined,
230 if(this.enableFont && !Ext.isSafari2){
231 var fontSelectItem = new Ext.Toolbar.Item({
235 html: this.createFontOptions()
245 if(this.enableFormat){
253 if(this.enableFontSize){
256 btn('increasefontsize', false, this.adjustFont),
257 btn('decreasefontsize', false, this.adjustFont)
261 if(this.enableColors){
266 iconCls: 'x-edit-forecolor',
267 clickEvent:'mousedown',
268 tooltip: tipsEnabled ? editor.buttonTips.forecolor || undefined : undefined,
270 menu : new Ext.menu.ColorMenu({
277 select: function(cp, color){
278 this.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
282 clickEvent:'mousedown'
287 iconCls: 'x-edit-backcolor',
288 clickEvent:'mousedown',
289 tooltip: tipsEnabled ? editor.buttonTips.backcolor || undefined : undefined,
291 menu : new Ext.menu.ColorMenu({
298 select: function(cp, color){
300 this.execCmd('useCSS', false);
301 this.execCmd('hilitecolor', color);
302 this.execCmd('useCSS', true);
305 this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
310 clickEvent:'mousedown'
316 if(this.enableAlignments){
320 btn('justifycenter'),
326 if(this.enableLinks){
329 btn('createlink', false, this.createLink)
333 if(this.enableLists){
336 btn('insertorderedlist'),
337 btn('insertunorderedlist')
340 if(this.enableSourceEdit){
343 btn('sourceedit', true, function(btn){
344 this.toggleSourceEdit(!this.sourceEditMode);
351 var tb = new Ext.Toolbar({
352 renderTo: this.wrap.dom.firstChild,
356 if (fontSelectItem) {
357 this.fontSelect = fontSelectItem.el;
359 this.mon(this.fontSelect, 'change', function(){
360 var font = this.fontSelect.dom.value;
361 this.relayCmd('fontname', font);
367 this.mon(tb.el, 'click', function(e){
375 onDisable: function(){
377 Ext.form.HtmlEditor.superclass.onDisable.call(this);
380 onEnable: function(){
382 Ext.form.HtmlEditor.superclass.onEnable.call(this);
385 setReadOnly: function(readOnly){
387 Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly);
388 if(this.initialized){
390 this.getEditorBody().contentEditable = !readOnly;
392 this.setDesignMode(!readOnly);
394 var bd = this.getEditorBody();
396 bd.style.cursor = this.readOnly ? 'default' : 'text';
398 this.disableItems(readOnly);
402 <div id="method-Ext.form.HtmlEditor-getDocMarkup"></div>/**
403 * Protected method that will not generally be called directly. It
404 * is called when the editor initializes the iframe with HTML contents. Override this method if you
405 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
407 * Note: IE8-Standards has unwanted scroller behavior, so the default meta tag forces IE7 compatibility
409 getDocMarkup : function(){
410 var h = Ext.fly(this.iframe).getHeight() - this.iframePad * 2;
411 return String.format('<html><head><style type="text/css">body{border: 0; margin: 0; padding: {0}px; height: {1}px; cursor: text}</style></head><body></body></html>', this.iframePad, h);
415 getEditorBody : function(){
416 var doc = this.getDoc();
417 return doc.body || doc.documentElement;
422 return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
427 return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
431 onRender : function(ct, position){
432 Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
433 this.el.dom.style.border = '0 none';
434 this.el.dom.setAttribute('tabIndex', -1);
435 this.el.addClass('x-hidden');
436 if(Ext.isIE){ // fix IE 1px bogus margin
437 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;');
439 this.wrap = this.el.wrap({
440 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
443 this.createToolbar(this);
445 this.disableItems(true);
452 var sz = this.el.getSize();
453 this.setSize(sz.width, this.height || sz.height);
455 this.resizeEl = this.positionEl = this.wrap;
458 createIFrame: function(){
459 var iframe = document.createElement('iframe');
460 iframe.name = Ext.id();
461 iframe.frameBorder = '0';
462 iframe.style.overflow = 'auto';
464 this.wrap.dom.appendChild(iframe);
465 this.iframe = iframe;
467 this.monitorTask = Ext.TaskMgr.start({
468 run: this.checkDesignMode,
474 initFrame : function(){
475 Ext.TaskMgr.stop(this.monitorTask);
476 var doc = this.getDoc();
477 this.win = this.getWin();
480 doc.write(this.getDocMarkup());
483 var task = { // must defer to wait for browser to be ready
485 var doc = this.getDoc();
486 if(doc.body || doc.readyState == 'complete'){
487 Ext.TaskMgr.stop(task);
488 this.setDesignMode(true);
489 this.initEditor.defer(10, this);
496 Ext.TaskMgr.start(task);
500 checkDesignMode : function(){
501 if(this.wrap && this.wrap.dom.offsetWidth){
502 var doc = this.getDoc();
506 if(!doc.editorInitialized || this.getDesignMode() != 'on'){
513 * set current design mode. To enable, mode can be true or 'on', off otherwise
515 setDesignMode : function(mode){
517 if(doc = this.getDoc()){
521 doc.designMode = (/on|true/i).test(String(mode).toLowerCase()) ?'on':'off';
527 getDesignMode : function(){
528 var doc = this.getDoc();
529 if(!doc){ return ''; }
530 return String(doc.designMode).toLowerCase();
534 disableItems: function(disabled){
536 this.fontSelect.dom.disabled = disabled;
538 this.tb.items.each(function(item){
539 if(item.getItemId() != 'sourceedit'){
540 item.setDisabled(disabled);
546 onResize : function(w, h){
547 Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
548 if(this.el && this.iframe){
550 var aw = w - this.wrap.getFrameWidth('lr');
551 this.el.setWidth(aw);
552 this.tb.setWidth(aw);
553 this.iframe.style.width = Math.max(aw, 0) + 'px';
556 var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
557 this.el.setHeight(ah);
558 this.iframe.style.height = Math.max(ah, 0) + 'px';
559 var bd = this.getEditorBody();
561 bd.style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
567 <div id="method-Ext.form.HtmlEditor-toggleSourceEdit"></div>/**
568 * Toggles the editor between standard and source edit mode.
569 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
571 toggleSourceEdit : function(sourceEditMode){
576 if (sourceEditMode === undefined) {
577 sourceEditMode = !this.sourceEditMode;
579 this.sourceEditMode = sourceEditMode === true;
580 var btn = this.tb.getComponent('sourceedit');
582 if (btn.pressed !== this.sourceEditMode) {
583 btn.toggle(this.sourceEditMode);
584 if (!btn.xtbHidden) {
588 if (this.sourceEditMode) {
589 // grab the height of the containing panel before we hide the iframe
592 iframeHeight = Ext.get(this.iframe).getHeight();
594 this.disableItems(true);
596 this.iframe.className = 'x-hidden';
597 this.el.removeClass('x-hidden');
598 this.el.dom.removeAttribute('tabIndex');
600 this.el.dom.style.height = iframeHeight + 'px';
603 elHeight = parseInt(this.el.dom.style.height, 10);
604 if (this.initialized) {
605 this.disableItems(this.readOnly);
608 this.iframe.className = '';
609 this.el.addClass('x-hidden');
610 this.el.dom.setAttribute('tabIndex', -1);
614 this.iframe.style.height = elHeight + 'px';
616 this.fireEvent('editmodechange', this, this.sourceEditMode);
619 // private used internally
620 createLink : function() {
621 var url = prompt(this.createLinkText, this.defaultLinkValue);
622 if(url && url != 'http:/'+'/'){
623 this.relayCmd('createlink', url);
628 initEvents : function(){
629 this.originalValue = this.getValue();
632 <div id="method-Ext.form.HtmlEditor-markInvalid"></div>/**
633 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
636 markInvalid : Ext.emptyFn,
638 <div id="method-Ext.form.HtmlEditor-clearInvalid"></div>/**
639 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
642 clearInvalid : Ext.emptyFn,
644 // docs inherit from Field
645 setValue : function(v){
646 Ext.form.HtmlEditor.superclass.setValue.call(this, v);
651 <div id="method-Ext.form.HtmlEditor-cleanHtml"></div>/**
652 * Protected method that will not generally be called directly. If you need/want
653 * custom HTML cleanup, this is the method you should override.
654 * @param {String} html The HTML to be cleaned
655 * @return {String} The cleaned HTML
657 cleanHtml: function(html) {
659 if(Ext.isWebKit){ // strip safari nonsense
660 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
664 * Neat little hack. Strips out all the non-digit characters from the default
665 * value and compares it to the character code of the first character in the string
666 * because it can cause encoding issues when posted to the server.
668 if(html.charCodeAt(0) == this.defaultValue.replace(/\D/g, '')){
669 html = html.substring(1);
674 <div id="method-Ext.form.HtmlEditor-syncValue"></div>/**
675 * Protected method that will not generally be called directly. Syncs the contents
676 * of the editor iframe with the textarea.
678 syncValue : function(){
679 if(this.initialized){
680 var bd = this.getEditorBody();
681 var html = bd.innerHTML;
683 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
684 var m = bs.match(/text-align:(.*?);/i);
686 html = '<div style="'+m[0]+'">' + html + '</div>';
689 html = this.cleanHtml(html);
690 if(this.fireEvent('beforesync', this, html) !== false){
691 this.el.dom.value = html;
692 this.fireEvent('sync', this, html);
697 //docs inherit from Field
698 getValue : function() {
699 this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
700 return Ext.form.HtmlEditor.superclass.getValue.call(this);
703 <div id="method-Ext.form.HtmlEditor-pushValue"></div>/**
704 * Protected method that will not generally be called directly. Pushes the value of the textarea
705 * into the iframe editor.
707 pushValue : function(){
708 if(this.initialized){
709 var v = this.el.dom.value;
710 if(!this.activated && v.length < 1){
711 v = this.defaultValue;
713 if(this.fireEvent('beforepush', this, v) !== false){
714 this.getEditorBody().innerHTML = v;
716 // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8
717 this.setDesignMode(false); //toggle off first
718 this.setDesignMode(true);
720 this.fireEvent('push', this, v);
727 deferFocus : function(){
728 this.focus.defer(10, this);
731 // docs inherit from Field
733 if(this.win && !this.sourceEditMode){
741 initEditor : function(){
742 //Destroying the component during/before initEditor can cause issues.
744 var dbody = this.getEditorBody(),
745 ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),
749 ss['background-attachment'] = 'fixed'; // w3c
750 dbody.bgProperties = 'fixed'; // ie
752 Ext.DomHelper.applyStyles(dbody, ss);
758 Ext.EventManager.removeAll(doc);
763 * We need to use createDelegate here, because when using buffer, the delayed task is added
764 * as a property to the function. When the listener is removed, the task is deleted from the function.
765 * Since onEditorEvent is shared on the prototype, if we have multiple html editors, the first time one of the editors
766 * is destroyed, it causes the fn to be deleted from the prototype, which causes errors. Essentially, we're just anonymizing the function.
768 fn = this.onEditorEvent.createDelegate(this);
769 Ext.EventManager.on(doc, {
778 Ext.EventManager.on(doc, 'keypress', this.applyCommand, this);
780 if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
781 Ext.EventManager.on(doc, 'keydown', this.fixKeys, this);
783 doc.editorInitialized = true;
784 this.initialized = true;
786 this.setReadOnly(this.readOnly);
787 this.fireEvent('initialize', this);
792 onDestroy : function(){
793 if(this.monitorTask){
794 Ext.TaskMgr.stop(this.monitorTask);
797 Ext.destroy(this.tb);
798 var doc = this.getDoc();
801 Ext.EventManager.removeAll(doc);
802 for (var prop in doc){
808 this.wrap.dom.innerHTML = '';
814 this.el.removeAllListeners();
817 this.purgeListeners();
821 onFirstFocus : function(){
822 this.activated = true;
823 this.disableItems(this.readOnly);
824 if(Ext.isGecko){ // prevent silly gecko errors
826 var s = this.win.getSelection();
827 if(!s.focusNode || s.focusNode.nodeType != 3){
828 var r = s.getRangeAt(0);
829 r.selectNodeContents(this.getEditorBody());
834 this.execCmd('useCSS', true);
835 this.execCmd('styleWithCSS', false);
838 this.fireEvent('activate', this);
842 adjustFont: function(btn){
843 var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
845 v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
846 if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
848 // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px
862 v = v.constrain(1, 6);
864 if(Ext.isSafari){ // safari
867 v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
869 this.execCmd('FontSize', v);
873 onEditorEvent : function(e){
874 this.updateToolbar();
878 <div id="method-Ext.form.HtmlEditor-updateToolbar"></div>/**
879 * Protected method that will not generally be called directly. It triggers
880 * a toolbar update by reading the markup state of the current selection in the editor.
882 updateToolbar: function(){
893 var btns = this.tb.items.map,
896 if(this.enableFont && !Ext.isSafari2){
897 var name = (doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
898 if(name != this.fontSelect.dom.value){
899 this.fontSelect.dom.value = name;
902 if(this.enableFormat){
903 btns.bold.toggle(doc.queryCommandState('bold'));
904 btns.italic.toggle(doc.queryCommandState('italic'));
905 btns.underline.toggle(doc.queryCommandState('underline'));
907 if(this.enableAlignments){
908 btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
909 btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
910 btns.justifyright.toggle(doc.queryCommandState('justifyright'));
912 if(!Ext.isSafari2 && this.enableLists){
913 btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
914 btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
917 Ext.menu.MenuMgr.hideAll();
923 relayBtnCmd : function(btn){
924 this.relayCmd(btn.getItemId());
927 <div id="method-Ext.form.HtmlEditor-relayCmd"></div>/**
928 * Executes a Midas editor command on the editor document and performs necessary focus and
929 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
930 * @param {String} cmd The Midas command
931 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
933 relayCmd : function(cmd, value){
936 this.execCmd(cmd, value);
937 this.updateToolbar();
941 <div id="method-Ext.form.HtmlEditor-execCmd"></div>/**
942 * Executes a Midas editor command directly on the editor document.
943 * For visual commands, you should use {@link #relayCmd} instead.
944 * <b>This should only be called after the editor is initialized.</b>
945 * @param {String} cmd The Midas command
946 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
948 execCmd : function(cmd, value){
949 var doc = this.getDoc();
950 doc.execCommand(cmd, false, value === undefined ? null : value);
955 applyCommand : function(e){
957 var c = e.getCharCode(), cmd;
959 c = String.fromCharCode(c);
981 <div id="method-Ext.form.HtmlEditor-insertAtCursor"></div>/**
982 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
984 * @param {String} text
986 insertAtCursor : function(text){
992 var doc = this.getDoc(),
993 r = doc.selection.createRange();
1001 this.execCmd('InsertHTML', text);
1007 fixKeys : function(){ // load time branching for fastest keydown performance
1011 doc = this.getDoc(),
1015 r = doc.selection.createRange();
1018 r.pasteHTML(' ');
1021 }else if(k == e.ENTER){
1022 r = doc.selection.createRange();
1024 var target = r.parentElement();
1025 if(!target || target.tagName.toLowerCase() != 'li'){
1027 r.pasteHTML('<br />');
1034 }else if(Ext.isOpera){
1040 this.execCmd('InsertHTML',' ');
1044 }else if(Ext.isWebKit){
1049 this.execCmd('InsertText','\t');
1051 }else if(k == e.ENTER){
1053 this.execCmd('InsertHtml','<br /><br />');
1060 <div id="method-Ext.form.HtmlEditor-getToolbar"></div>/**
1061 * Returns the editor's toolbar. <b>This is only available after the editor has been rendered.</b>
1062 * @return {Ext.Toolbar}
1064 getToolbar : function(){
1068 <div id="prop-Ext.form.HtmlEditor-buttonTips"></div>/**
1069 * Object collection of toolbar tooltips for the buttons in the editor. The key
1070 * is the command id associated with that button and the value is a valid QuickTips object.
1075 title: 'Bold (Ctrl+B)',
1076 text: 'Make the selected text bold.',
1077 cls: 'x-html-editor-tip'
1080 title: 'Italic (Ctrl+I)',
1081 text: 'Make the selected text italic.',
1082 cls: 'x-html-editor-tip'
1090 title: 'Bold (Ctrl+B)',
1091 text: 'Make the selected text bold.',
1092 cls: 'x-html-editor-tip'
1095 title: 'Italic (Ctrl+I)',
1096 text: 'Make the selected text italic.',
1097 cls: 'x-html-editor-tip'
1100 title: 'Underline (Ctrl+U)',
1101 text: 'Underline the selected text.',
1102 cls: 'x-html-editor-tip'
1104 increasefontsize : {
1106 text: 'Increase the font size.',
1107 cls: 'x-html-editor-tip'
1109 decreasefontsize : {
1110 title: 'Shrink Text',
1111 text: 'Decrease the font size.',
1112 cls: 'x-html-editor-tip'
1115 title: 'Text Highlight Color',
1116 text: 'Change the background color of the selected text.',
1117 cls: 'x-html-editor-tip'
1120 title: 'Font Color',
1121 text: 'Change the color of the selected text.',
1122 cls: 'x-html-editor-tip'
1125 title: 'Align Text Left',
1126 text: 'Align text to the left.',
1127 cls: 'x-html-editor-tip'
1130 title: 'Center Text',
1131 text: 'Center text in the editor.',
1132 cls: 'x-html-editor-tip'
1135 title: 'Align Text Right',
1136 text: 'Align text to the right.',
1137 cls: 'x-html-editor-tip'
1139 insertunorderedlist : {
1140 title: 'Bullet List',
1141 text: 'Start a bulleted list.',
1142 cls: 'x-html-editor-tip'
1144 insertorderedlist : {
1145 title: 'Numbered List',
1146 text: 'Start a numbered list.',
1147 cls: 'x-html-editor-tip'
1151 text: 'Make the selected text a hyperlink.',
1152 cls: 'x-html-editor-tip'
1155 title: 'Source Edit',
1156 text: 'Switch to source editing mode.',
1157 cls: 'x-html-editor-tip'
1161 // hide stuff that is not compatible
1162 <div id="event-Ext.form.HtmlEditor-blur"></div>/**
1166 <div id="event-Ext.form.HtmlEditor-change"></div>/**
1170 <div id="event-Ext.form.HtmlEditor-focus"></div>/**
1174 <div id="event-Ext.form.HtmlEditor-specialkey"></div>/**
1178 <div id="cfg-Ext.form.HtmlEditor-fieldClass"></div>/**
1179 * @cfg {String} fieldClass @hide
1181 <div id="cfg-Ext.form.HtmlEditor-focusClass"></div>/**
1182 * @cfg {String} focusClass @hide
1184 <div id="cfg-Ext.form.HtmlEditor-autoCreate"></div>/**
1185 * @cfg {String} autoCreate @hide
1187 <div id="cfg-Ext.form.HtmlEditor-inputType"></div>/**
1188 * @cfg {String} inputType @hide
1190 <div id="cfg-Ext.form.HtmlEditor-invalidClass"></div>/**
1191 * @cfg {String} invalidClass @hide
1193 <div id="cfg-Ext.form.HtmlEditor-invalidText"></div>/**
1194 * @cfg {String} invalidText @hide
1196 <div id="cfg-Ext.form.HtmlEditor-msgFx"></div>/**
1197 * @cfg {String} msgFx @hide
1199 <div id="cfg-Ext.form.HtmlEditor-validateOnBlur"></div>/**
1200 * @cfg {String} validateOnBlur @hide
1202 <div id="cfg-Ext.form.HtmlEditor-allowDomMove"></div>/**
1203 * @cfg {Boolean} allowDomMove @hide
1205 <div id="cfg-Ext.form.HtmlEditor-applyTo"></div>/**
1206 * @cfg {String} applyTo @hide
1208 <div id="cfg-Ext.form.HtmlEditor-autoHeight"></div>/**
1209 * @cfg {String} autoHeight @hide
1211 <div id="cfg-Ext.form.HtmlEditor-autoWidth"></div>/**
1212 * @cfg {String} autoWidth @hide
1214 <div id="cfg-Ext.form.HtmlEditor-cls"></div>/**
1215 * @cfg {String} cls @hide
1217 <div id="cfg-Ext.form.HtmlEditor-disabled"></div>/**
1218 * @cfg {String} disabled @hide
1220 <div id="cfg-Ext.form.HtmlEditor-disabledClass"></div>/**
1221 * @cfg {String} disabledClass @hide
1223 <div id="cfg-Ext.form.HtmlEditor-msgTarget"></div>/**
1224 * @cfg {String} msgTarget @hide
1226 <div id="cfg-Ext.form.HtmlEditor-readOnly"></div>/**
1227 * @cfg {String} readOnly @hide
1229 <div id="cfg-Ext.form.HtmlEditor-style"></div>/**
1230 * @cfg {String} style @hide
1232 <div id="cfg-Ext.form.HtmlEditor-validationDelay"></div>/**
1233 * @cfg {String} validationDelay @hide
1235 <div id="cfg-Ext.form.HtmlEditor-validationEvent"></div>/**
1236 * @cfg {String} validationEvent @hide
1238 <div id="cfg-Ext.form.HtmlEditor-tabIndex"></div>/**
1239 * @cfg {String} tabIndex @hide
1241 <div id="prop-Ext.form.HtmlEditor-disabled"></div>/**
1242 * @property disabled
1245 <div id="method-Ext.form.HtmlEditor-applyToMarkup"></div>/**
1246 * @method applyToMarkup
1249 <div id="method-Ext.form.HtmlEditor-disable"></div>/**
1253 <div id="method-Ext.form.HtmlEditor-enable"></div>/**
1257 <div id="method-Ext.form.HtmlEditor-validate"></div>/**
1261 <div id="event-Ext.form.HtmlEditor-valid"></div>/**
1265 <div id="method-Ext.form.HtmlEditor-setDisabled"></div>/**
1266 * @method setDisabled
1269 <div id="cfg-Ext.form.HtmlEditor-null"></div>/**
1274 Ext.reg('htmleditor', Ext.form.HtmlEditor);