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.3.1
11 * Copyright(c) 2006-2010 Sencha Inc.
12 * licensing@sencha.com
13 * http://www.sencha.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.
185 Ext.form.HtmlEditor.superclass.initComponent.call(this);
189 createFontOptions : function(){
190 var buf = [], fs = this.fontFamilies, ff, lc;
191 for(var i = 0, len = fs.length; i< len; i++){
193 lc = ff.toLowerCase();
195 '<option value="',lc,'" style="font-family:',ff,';"',
196 (this.defaultFont == lc ? ' selected="true">' : '>'),
205 * Protected method that will not generally be called directly. It
206 * is called when the editor creates its toolbar. Override this method if you need to
207 * add custom toolbar buttons.
208 * @param {HtmlEditor} editor
210 createToolbar : function(editor){
212 var tipsEnabled = Ext.QuickTips && Ext.QuickTips.isEnabled();
215 function btn(id, toggle, handler){
219 iconCls: 'x-edit-'+id,
220 enableToggle:toggle !== false,
222 handler:handler||editor.relayBtnCmd,
223 clickEvent:'mousedown',
224 tooltip: tipsEnabled ? editor.buttonTips[id] || undefined : undefined,
225 overflowText: editor.buttonTips[id].title || undefined,
231 if(this.enableFont && !Ext.isSafari2){
232 var fontSelectItem = new Ext.Toolbar.Item({
236 html: this.createFontOptions()
246 if(this.enableFormat){
254 if(this.enableFontSize){
257 btn('increasefontsize', false, this.adjustFont),
258 btn('decreasefontsize', false, this.adjustFont)
262 if(this.enableColors){
267 iconCls: 'x-edit-forecolor',
268 clickEvent:'mousedown',
269 tooltip: tipsEnabled ? editor.buttonTips.forecolor || undefined : undefined,
271 menu : new Ext.menu.ColorMenu({
278 select: function(cp, color){
279 this.execCmd('forecolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
283 clickEvent:'mousedown'
288 iconCls: 'x-edit-backcolor',
289 clickEvent:'mousedown',
290 tooltip: tipsEnabled ? editor.buttonTips.backcolor || undefined : undefined,
292 menu : new Ext.menu.ColorMenu({
299 select: function(cp, color){
301 this.execCmd('useCSS', false);
302 this.execCmd('hilitecolor', color);
303 this.execCmd('useCSS', true);
306 this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isWebKit || Ext.isIE ? '#'+color : color);
311 clickEvent:'mousedown'
317 if(this.enableAlignments){
321 btn('justifycenter'),
327 if(this.enableLinks){
330 btn('createlink', false, this.createLink)
334 if(this.enableLists){
337 btn('insertorderedlist'),
338 btn('insertunorderedlist')
341 if(this.enableSourceEdit){
344 btn('sourceedit', true, function(btn){
345 this.toggleSourceEdit(!this.sourceEditMode);
352 var tb = new Ext.Toolbar({
353 renderTo: this.wrap.dom.firstChild,
357 if (fontSelectItem) {
358 this.fontSelect = fontSelectItem.el;
360 this.mon(this.fontSelect, 'change', function(){
361 var font = this.fontSelect.dom.value;
362 this.relayCmd('fontname', font);
368 this.mon(tb.el, 'click', function(e){
376 onDisable: function(){
378 Ext.form.HtmlEditor.superclass.onDisable.call(this);
381 onEnable: function(){
383 Ext.form.HtmlEditor.superclass.onEnable.call(this);
386 setReadOnly: function(readOnly){
388 Ext.form.HtmlEditor.superclass.setReadOnly.call(this, readOnly);
389 if(this.initialized){
391 this.getEditorBody().contentEditable = !readOnly;
393 this.setDesignMode(!readOnly);
395 var bd = this.getEditorBody();
397 bd.style.cursor = this.readOnly ? 'default' : 'text';
399 this.disableItems(readOnly);
403 <div id="method-Ext.form.HtmlEditor-getDocMarkup"></div>/**
404 * Protected method that will not generally be called directly. It
405 * is called when the editor initializes the iframe with HTML contents. Override this method if you
406 * want to change the initialization markup of the iframe (e.g. to add stylesheets).
408 * Note: IE8-Standards has unwanted scroller behavior, so the default meta tag forces IE7 compatibility
410 getDocMarkup : function(){
411 var h = Ext.fly(this.iframe).getHeight() - this.iframePad * 2;
412 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);
416 getEditorBody : function(){
417 var doc = this.getDoc();
418 return doc.body || doc.documentElement;
423 return Ext.isIE ? this.getWin().document : (this.iframe.contentDocument || this.getWin().document);
428 return Ext.isIE ? this.iframe.contentWindow : window.frames[this.iframe.name];
432 onRender : function(ct, position){
433 Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
434 this.el.dom.style.border = '0 none';
435 this.el.dom.setAttribute('tabIndex', -1);
436 this.el.addClass('x-hidden');
437 if(Ext.isIE){ // fix IE 1px bogus margin
438 this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;');
440 this.wrap = this.el.wrap({
441 cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
444 this.createToolbar(this);
446 this.disableItems(true);
453 var sz = this.el.getSize();
454 this.setSize(sz.width, this.height || sz.height);
456 this.resizeEl = this.positionEl = this.wrap;
459 createIFrame: function(){
460 var iframe = document.createElement('iframe');
461 iframe.name = Ext.id();
462 iframe.frameBorder = '0';
463 iframe.style.overflow = 'auto';
464 iframe.src = Ext.SSL_SECURE_URL;
466 this.wrap.dom.appendChild(iframe);
467 this.iframe = iframe;
469 this.monitorTask = Ext.TaskMgr.start({
470 run: this.checkDesignMode,
476 initFrame : function(){
477 Ext.TaskMgr.stop(this.monitorTask);
478 var doc = this.getDoc();
479 this.win = this.getWin();
482 doc.write(this.getDocMarkup());
485 var task = { // must defer to wait for browser to be ready
487 var doc = this.getDoc();
488 if(doc.body || doc.readyState == 'complete'){
489 Ext.TaskMgr.stop(task);
490 this.setDesignMode(true);
491 this.initEditor.defer(10, this);
498 Ext.TaskMgr.start(task);
502 checkDesignMode : function(){
503 if(this.wrap && this.wrap.dom.offsetWidth){
504 var doc = this.getDoc();
508 if(!doc.editorInitialized || this.getDesignMode() != 'on'){
515 * set current design mode. To enable, mode can be true or 'on', off otherwise
517 setDesignMode : function(mode){
518 var doc = this.getDoc();
523 doc.designMode = (/on|true/i).test(String(mode).toLowerCase()) ?'on':'off';
529 getDesignMode : function(){
530 var doc = this.getDoc();
531 if(!doc){ return ''; }
532 return String(doc.designMode).toLowerCase();
536 disableItems: function(disabled){
538 this.fontSelect.dom.disabled = disabled;
540 this.tb.items.each(function(item){
541 if(item.getItemId() != 'sourceedit'){
542 item.setDisabled(disabled);
548 onResize : function(w, h){
549 Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
550 if(this.el && this.iframe){
552 var aw = w - this.wrap.getFrameWidth('lr');
553 this.el.setWidth(aw);
554 this.tb.setWidth(aw);
555 this.iframe.style.width = Math.max(aw, 0) + 'px';
558 var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
559 this.el.setHeight(ah);
560 this.iframe.style.height = Math.max(ah, 0) + 'px';
561 var bd = this.getEditorBody();
563 bd.style.height = Math.max((ah - (this.iframePad*2)), 0) + 'px';
569 <div id="method-Ext.form.HtmlEditor-toggleSourceEdit"></div>/**
570 * Toggles the editor between standard and source edit mode.
571 * @param {Boolean} sourceEdit (optional) True for source edit, false for standard
573 toggleSourceEdit : function(sourceEditMode){
577 if (sourceEditMode === undefined) {
578 sourceEditMode = !this.sourceEditMode;
580 this.sourceEditMode = sourceEditMode === true;
581 var btn = this.tb.getComponent('sourceedit');
583 if (btn.pressed !== this.sourceEditMode) {
584 btn.toggle(this.sourceEditMode);
585 if (!btn.xtbHidden) {
589 if (this.sourceEditMode) {
590 // grab the height of the containing panel before we hide the iframe
591 this.previousSize = this.getSize();
593 iframeHeight = Ext.get(this.iframe).getHeight();
595 this.disableItems(true);
597 this.iframe.className = 'x-hidden';
598 this.el.removeClass('x-hidden');
599 this.el.dom.removeAttribute('tabIndex');
601 this.el.dom.style.height = iframeHeight + 'px';
604 elHeight = parseInt(this.el.dom.style.height, 10);
605 if (this.initialized) {
606 this.disableItems(this.readOnly);
609 this.iframe.className = '';
610 this.el.addClass('x-hidden');
611 this.el.dom.setAttribute('tabIndex', -1);
614 this.setSize(this.previousSize);
615 delete this.previousSize;
616 this.iframe.style.height = elHeight + 'px';
618 this.fireEvent('editmodechange', this, this.sourceEditMode);
621 // private used internally
622 createLink : function() {
623 var url = prompt(this.createLinkText, this.defaultLinkValue);
624 if(url && url != 'http:/'+'/'){
625 this.relayCmd('createlink', url);
630 initEvents : function(){
631 this.originalValue = this.getValue();
634 <div id="method-Ext.form.HtmlEditor-markInvalid"></div>/**
635 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
638 markInvalid : Ext.emptyFn,
640 <div id="method-Ext.form.HtmlEditor-clearInvalid"></div>/**
641 * Overridden and disabled. The editor element does not support standard valid/invalid marking. @hide
644 clearInvalid : Ext.emptyFn,
646 // docs inherit from Field
647 setValue : function(v){
648 Ext.form.HtmlEditor.superclass.setValue.call(this, v);
653 <div id="method-Ext.form.HtmlEditor-cleanHtml"></div>/**
654 * Protected method that will not generally be called directly. If you need/want
655 * custom HTML cleanup, this is the method you should override.
656 * @param {String} html The HTML to be cleaned
657 * @return {String} The cleaned HTML
659 cleanHtml: function(html) {
661 if(Ext.isWebKit){ // strip safari nonsense
662 html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
666 * Neat little hack. Strips out all the non-digit characters from the default
667 * value and compares it to the character code of the first character in the string
668 * because it can cause encoding issues when posted to the server.
670 if(html.charCodeAt(0) == this.defaultValue.replace(/\D/g, '')){
671 html = html.substring(1);
676 <div id="method-Ext.form.HtmlEditor-syncValue"></div>/**
677 * Protected method that will not generally be called directly. Syncs the contents
678 * of the editor iframe with the textarea.
680 syncValue : function(){
681 if(this.initialized){
682 var bd = this.getEditorBody();
683 var html = bd.innerHTML;
685 var bs = bd.getAttribute('style'); // Safari puts text-align styles on the body element!
686 var m = bs.match(/text-align:(.*?);/i);
688 html = '<div style="'+m[0]+'">' + html + '</div>';
691 html = this.cleanHtml(html);
692 if(this.fireEvent('beforesync', this, html) !== false){
693 this.el.dom.value = html;
694 this.fireEvent('sync', this, html);
699 //docs inherit from Field
700 getValue : function() {
701 this[this.sourceEditMode ? 'pushValue' : 'syncValue']();
702 return Ext.form.HtmlEditor.superclass.getValue.call(this);
705 <div id="method-Ext.form.HtmlEditor-pushValue"></div>/**
706 * Protected method that will not generally be called directly. Pushes the value of the textarea
707 * into the iframe editor.
709 pushValue : function(){
710 if(this.initialized){
711 var v = this.el.dom.value;
712 if(!this.activated && v.length < 1){
713 v = this.defaultValue;
715 if(this.fireEvent('beforepush', this, v) !== false){
716 this.getEditorBody().innerHTML = v;
718 // Gecko hack, see: https://bugzilla.mozilla.org/show_bug.cgi?id=232791#c8
719 this.setDesignMode(false); //toggle off first
720 this.setDesignMode(true);
722 this.fireEvent('push', this, v);
729 deferFocus : function(){
730 this.focus.defer(10, this);
733 // docs inherit from Field
735 if(this.win && !this.sourceEditMode){
743 initEditor : function(){
744 //Destroying the component during/before initEditor can cause issues.
746 var dbody = this.getEditorBody(),
747 ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat', 'background-color', 'color'),
751 ss['background-attachment'] = 'fixed'; // w3c
752 dbody.bgProperties = 'fixed'; // ie
754 Ext.DomHelper.applyStyles(dbody, ss);
760 Ext.EventManager.removeAll(doc);
765 * We need to use createDelegate here, because when using buffer, the delayed task is added
766 * as a property to the function. When the listener is removed, the task is deleted from the function.
767 * Since onEditorEvent is shared on the prototype, if we have multiple html editors, the first time one of the editors
768 * is destroyed, it causes the fn to be deleted from the prototype, which causes errors. Essentially, we're just anonymizing the function.
770 fn = this.onEditorEvent.createDelegate(this);
771 Ext.EventManager.on(doc, {
780 Ext.EventManager.on(doc, 'keypress', this.applyCommand, this);
782 if(Ext.isIE || Ext.isWebKit || Ext.isOpera){
783 Ext.EventManager.on(doc, 'keydown', this.fixKeys, this);
785 doc.editorInitialized = true;
786 this.initialized = true;
788 this.setReadOnly(this.readOnly);
789 this.fireEvent('initialize', this);
794 beforeDestroy : function(){
795 if(this.monitorTask){
796 Ext.TaskMgr.stop(this.monitorTask);
799 Ext.destroy(this.tb);
800 var doc = this.getDoc();
803 Ext.EventManager.removeAll(doc);
804 for (var prop in doc){
810 this.wrap.dom.innerHTML = '';
814 Ext.form.HtmlEditor.superclass.beforeDestroy.call(this);
818 onFirstFocus : function(){
819 this.activated = true;
820 this.disableItems(this.readOnly);
821 if(Ext.isGecko){ // prevent silly gecko errors
823 var s = this.win.getSelection();
824 if(!s.focusNode || s.focusNode.nodeType != 3){
825 var r = s.getRangeAt(0);
826 r.selectNodeContents(this.getEditorBody());
831 this.execCmd('useCSS', true);
832 this.execCmd('styleWithCSS', false);
835 this.fireEvent('activate', this);
839 adjustFont: function(btn){
840 var adjust = btn.getItemId() == 'increasefontsize' ? 1 : -1,
842 v = parseInt(doc.queryCommandValue('FontSize') || 2, 10);
843 if((Ext.isSafari && !Ext.isSafari2) || Ext.isChrome || Ext.isAir){
845 // 1 = 10px, 2 = 13px, 3 = 16px, 4 = 18px, 5 = 24px, 6 = 32px
859 v = v.constrain(1, 6);
861 if(Ext.isSafari){ // safari
864 v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
866 this.execCmd('FontSize', v);
870 onEditorEvent : function(e){
871 this.updateToolbar();
875 <div id="method-Ext.form.HtmlEditor-updateToolbar"></div>/**
876 * Protected method that will not generally be called directly. It triggers
877 * a toolbar update by reading the markup state of the current selection in the editor.
879 updateToolbar: function(){
890 var btns = this.tb.items.map,
893 if(this.enableFont && !Ext.isSafari2){
894 var name = (doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
895 if(name != this.fontSelect.dom.value){
896 this.fontSelect.dom.value = name;
899 if(this.enableFormat){
900 btns.bold.toggle(doc.queryCommandState('bold'));
901 btns.italic.toggle(doc.queryCommandState('italic'));
902 btns.underline.toggle(doc.queryCommandState('underline'));
904 if(this.enableAlignments){
905 btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
906 btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
907 btns.justifyright.toggle(doc.queryCommandState('justifyright'));
909 if(!Ext.isSafari2 && this.enableLists){
910 btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
911 btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
914 Ext.menu.MenuMgr.hideAll();
920 relayBtnCmd : function(btn){
921 this.relayCmd(btn.getItemId());
924 <div id="method-Ext.form.HtmlEditor-relayCmd"></div>/**
925 * Executes a Midas editor command on the editor document and performs necessary focus and
926 * toolbar updates. <b>This should only be called after the editor is initialized.</b>
927 * @param {String} cmd The Midas command
928 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
930 relayCmd : function(cmd, value){
933 this.execCmd(cmd, value);
934 this.updateToolbar();
938 <div id="method-Ext.form.HtmlEditor-execCmd"></div>/**
939 * Executes a Midas editor command directly on the editor document.
940 * For visual commands, you should use {@link #relayCmd} instead.
941 * <b>This should only be called after the editor is initialized.</b>
942 * @param {String} cmd The Midas command
943 * @param {String/Boolean} value (optional) The value to pass to the command (defaults to null)
945 execCmd : function(cmd, value){
946 var doc = this.getDoc();
947 doc.execCommand(cmd, false, value === undefined ? null : value);
952 applyCommand : function(e){
954 var c = e.getCharCode(), cmd;
956 c = String.fromCharCode(c);
978 <div id="method-Ext.form.HtmlEditor-insertAtCursor"></div>/**
979 * Inserts the passed text at the current cursor position. Note: the editor must be initialized and activated
981 * @param {String} text
983 insertAtCursor : function(text){
989 var doc = this.getDoc(),
990 r = doc.selection.createRange();
998 this.execCmd('InsertHTML', text);
1004 fixKeys : function(){ // load time branching for fastest keydown performance
1008 doc = this.getDoc(),
1012 r = doc.selection.createRange();
1015 r.pasteHTML(' ');
1018 }else if(k == e.ENTER){
1019 r = doc.selection.createRange();
1021 var target = r.parentElement();
1022 if(!target || target.tagName.toLowerCase() != 'li'){
1024 r.pasteHTML('<br />');
1031 }else if(Ext.isOpera){
1037 this.execCmd('InsertHTML',' ');
1041 }else if(Ext.isWebKit){
1046 this.execCmd('InsertText','\t');
1048 }else if(k == e.ENTER){
1050 this.execCmd('InsertHtml','<br /><br />');
1057 <div id="method-Ext.form.HtmlEditor-getToolbar"></div>/**
1058 * Returns the editor's toolbar. <b>This is only available after the editor has been rendered.</b>
1059 * @return {Ext.Toolbar}
1061 getToolbar : function(){
1065 <div id="prop-Ext.form.HtmlEditor-buttonTips"></div>/**
1066 * Object collection of toolbar tooltips for the buttons in the editor. The key
1067 * is the command id associated with that button and the value is a valid QuickTips object.
1072 title: 'Bold (Ctrl+B)',
1073 text: 'Make the selected text bold.',
1074 cls: 'x-html-editor-tip'
1077 title: 'Italic (Ctrl+I)',
1078 text: 'Make the selected text italic.',
1079 cls: 'x-html-editor-tip'
1087 title: 'Bold (Ctrl+B)',
1088 text: 'Make the selected text bold.',
1089 cls: 'x-html-editor-tip'
1092 title: 'Italic (Ctrl+I)',
1093 text: 'Make the selected text italic.',
1094 cls: 'x-html-editor-tip'
1097 title: 'Underline (Ctrl+U)',
1098 text: 'Underline the selected text.',
1099 cls: 'x-html-editor-tip'
1101 increasefontsize : {
1103 text: 'Increase the font size.',
1104 cls: 'x-html-editor-tip'
1106 decreasefontsize : {
1107 title: 'Shrink Text',
1108 text: 'Decrease the font size.',
1109 cls: 'x-html-editor-tip'
1112 title: 'Text Highlight Color',
1113 text: 'Change the background color of the selected text.',
1114 cls: 'x-html-editor-tip'
1117 title: 'Font Color',
1118 text: 'Change the color of the selected text.',
1119 cls: 'x-html-editor-tip'
1122 title: 'Align Text Left',
1123 text: 'Align text to the left.',
1124 cls: 'x-html-editor-tip'
1127 title: 'Center Text',
1128 text: 'Center text in the editor.',
1129 cls: 'x-html-editor-tip'
1132 title: 'Align Text Right',
1133 text: 'Align text to the right.',
1134 cls: 'x-html-editor-tip'
1136 insertunorderedlist : {
1137 title: 'Bullet List',
1138 text: 'Start a bulleted list.',
1139 cls: 'x-html-editor-tip'
1141 insertorderedlist : {
1142 title: 'Numbered List',
1143 text: 'Start a numbered list.',
1144 cls: 'x-html-editor-tip'
1148 text: 'Make the selected text a hyperlink.',
1149 cls: 'x-html-editor-tip'
1152 title: 'Source Edit',
1153 text: 'Switch to source editing mode.',
1154 cls: 'x-html-editor-tip'
1158 // hide stuff that is not compatible
1159 <div id="event-Ext.form.HtmlEditor-blur"></div>/**
1163 <div id="event-Ext.form.HtmlEditor-change"></div>/**
1167 <div id="event-Ext.form.HtmlEditor-focus"></div>/**
1171 <div id="event-Ext.form.HtmlEditor-specialkey"></div>/**
1175 <div id="cfg-Ext.form.HtmlEditor-fieldClass"></div>/**
1176 * @cfg {String} fieldClass @hide
1178 <div id="cfg-Ext.form.HtmlEditor-focusClass"></div>/**
1179 * @cfg {String} focusClass @hide
1181 <div id="cfg-Ext.form.HtmlEditor-autoCreate"></div>/**
1182 * @cfg {String} autoCreate @hide
1184 <div id="cfg-Ext.form.HtmlEditor-inputType"></div>/**
1185 * @cfg {String} inputType @hide
1187 <div id="cfg-Ext.form.HtmlEditor-invalidClass"></div>/**
1188 * @cfg {String} invalidClass @hide
1190 <div id="cfg-Ext.form.HtmlEditor-invalidText"></div>/**
1191 * @cfg {String} invalidText @hide
1193 <div id="cfg-Ext.form.HtmlEditor-msgFx"></div>/**
1194 * @cfg {String} msgFx @hide
1196 <div id="cfg-Ext.form.HtmlEditor-validateOnBlur"></div>/**
1197 * @cfg {String} validateOnBlur @hide
1199 <div id="cfg-Ext.form.HtmlEditor-allowDomMove"></div>/**
1200 * @cfg {Boolean} allowDomMove @hide
1202 <div id="cfg-Ext.form.HtmlEditor-applyTo"></div>/**
1203 * @cfg {String} applyTo @hide
1205 <div id="cfg-Ext.form.HtmlEditor-autoHeight"></div>/**
1206 * @cfg {String} autoHeight @hide
1208 <div id="cfg-Ext.form.HtmlEditor-autoWidth"></div>/**
1209 * @cfg {String} autoWidth @hide
1211 <div id="cfg-Ext.form.HtmlEditor-cls"></div>/**
1212 * @cfg {String} cls @hide
1214 <div id="cfg-Ext.form.HtmlEditor-disabled"></div>/**
1215 * @cfg {String} disabled @hide
1217 <div id="cfg-Ext.form.HtmlEditor-disabledClass"></div>/**
1218 * @cfg {String} disabledClass @hide
1220 <div id="cfg-Ext.form.HtmlEditor-msgTarget"></div>/**
1221 * @cfg {String} msgTarget @hide
1223 <div id="cfg-Ext.form.HtmlEditor-readOnly"></div>/**
1224 * @cfg {String} readOnly @hide
1226 <div id="cfg-Ext.form.HtmlEditor-style"></div>/**
1227 * @cfg {String} style @hide
1229 <div id="cfg-Ext.form.HtmlEditor-validationDelay"></div>/**
1230 * @cfg {String} validationDelay @hide
1232 <div id="cfg-Ext.form.HtmlEditor-validationEvent"></div>/**
1233 * @cfg {String} validationEvent @hide
1235 <div id="cfg-Ext.form.HtmlEditor-tabIndex"></div>/**
1236 * @cfg {String} tabIndex @hide
1238 <div id="prop-Ext.form.HtmlEditor-disabled"></div>/**
1239 * @property disabled
1242 <div id="method-Ext.form.HtmlEditor-applyToMarkup"></div>/**
1243 * @method applyToMarkup
1246 <div id="method-Ext.form.HtmlEditor-disable"></div>/**
1250 <div id="method-Ext.form.HtmlEditor-enable"></div>/**
1254 <div id="method-Ext.form.HtmlEditor-validate"></div>/**
1258 <div id="event-Ext.form.HtmlEditor-valid"></div>/**
1262 <div id="method-Ext.form.HtmlEditor-setDisabled"></div>/**
1263 * @method setDisabled
1266 <div id="cfg-Ext.form.HtmlEditor-null"></div>/**
1271 Ext.reg('htmleditor', Ext.form.HtmlEditor);