Changeset 6750
- Timestamp:
- 04/21/11 21:28:15 (2 years ago)
- Location:
- CKEditor/branches/features/readonly
- Files:
-
- 1 added
- 32 edited
-
_samples/index.html (modified) (1 diff)
-
_samples/readonly.html (added)
-
_source/core/dom/range.js (modified) (1 diff)
-
_source/core/editor.js (modified) (7 diffs)
-
_source/plugins/a11yhelp/plugin.js (modified) (1 diff)
-
_source/plugins/about/plugin.js (modified) (1 diff)
-
_source/plugins/basicstyles/plugin.js (modified) (1 diff)
-
_source/plugins/bidi/plugin.js (modified) (1 diff)
-
_source/plugins/blockquote/plugin.js (modified) (1 diff)
-
_source/plugins/button/plugin.js (modified) (1 diff)
-
_source/plugins/clipboard/plugin.js (modified) (1 diff)
-
_source/plugins/editingblock/plugin.js (modified) (3 diffs)
-
_source/plugins/elementspath/plugin.js (modified) (1 diff)
-
_source/plugins/enterkey/plugin.js (modified) (1 diff)
-
_source/plugins/find/dialogs/find.js (modified) (1 diff)
-
_source/plugins/find/plugin.js (modified) (1 diff)
-
_source/plugins/indent/plugin.js (modified) (1 diff)
-
_source/plugins/justify/plugin.js (modified) (1 diff)
-
_source/plugins/link/plugin.js (modified) (1 diff)
-
_source/plugins/list/plugin.js (modified) (1 diff)
-
_source/plugins/maximize/plugin.js (modified) (2 diffs)
-
_source/plugins/menu/plugin.js (modified) (1 diff)
-
_source/plugins/preview/plugin.js (modified) (1 diff)
-
_source/plugins/print/plugin.js (modified) (1 diff)
-
_source/plugins/richcombo/plugin.js (modified) (1 diff)
-
_source/plugins/save/plugin.js (modified) (1 diff)
-
_source/plugins/selection/plugin.js (modified) (1 diff)
-
_source/plugins/showblocks/plugin.js (modified) (1 diff)
-
_source/plugins/showborders/plugin.js (modified) (1 diff)
-
_source/plugins/sourcearea/plugin.js (modified) (2 diffs)
-
_source/plugins/toolbar/plugin.js (modified) (2 diffs)
-
_source/plugins/undo/plugin.js (modified) (1 diff)
-
_source/plugins/wysiwygarea/plugin.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/branches/features/readonly/_samples/index.html
r6711 r6750 77 77 Configuring CKEditor to produce HTML code that can be used with Adobe Flash. 78 78 </li> 79 <li><a class="samples" href="readonly.html">ReadOnly mode</a><br /> 80 Using the readOnly API to disallow making any change to the editor content. 81 </li> 79 82 </ul> 80 83 <h2 class="samples"> -
CKEditor/branches/features/readonly/_source/core/dom/range.js
r6682 r6750 1871 1871 } 1872 1872 // Range enclosed entirely in an editable element. 1873 else if ( node.is( ' body' )1873 else if ( node.is( 'html' ) 1874 1874 || node.getAttribute( 'contentEditable' ) == 'true' 1875 1875 && ( node.contains( anotherEnd ) || node.equals( anotherEnd ) ) ) -
CKEditor/branches/features/readonly/_source/core/editor.js
r6660 r6750 160 160 */ 161 161 editor.tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0; 162 163 /** 164 * Immutable field indicate the read-only state of this editor. 165 * @name CKEDITOR.editor.prototype.readOnly 166 * @see CKEDITOR.editor.prototype.setReadOnly 167 * @type Boolean 168 * @default CKEDITOR.config.readOnly 169 * @since 3.6 170 */ 171 editor.readOnly = !!( editor.config.readOnly || editor.element.getAttribute( 'disabled' ) ); 162 172 163 173 // Fire the "configLoaded" event. … … 395 405 }; 396 406 397 function updateCommands Mode()407 function updateCommands() 398 408 { 399 409 var command, … … 404 414 { 405 415 command = commands[ name ]; 406 command[ command.startDisabled ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ](); 416 command[ command.startDisabled ? 'disable' : 417 this.readOnly && !command.readOnly ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ](); 407 418 } 408 419 } … … 492 503 CKEDITOR.fire( 'instanceCreated', null, this ); 493 504 494 this.on( 'mode', updateCommands Mode, null, null, 1 );505 this.on( 'mode', updateCommands, null, null, 1 ); 495 506 496 507 initConfig( this, instanceConfig ); … … 712 723 713 724 !internal && this.fire( 'afterSetData', eventData ); 725 }, 726 727 /** 728 * Turn editor into read-only mode or restore it from read-only mode. 729 * @param enable {Boolean} 730 * @since 3.6 731 * <strong>Note:</strong> current editing block will be reloaded. 732 */ 733 setReadOnly : function( enable ) 734 { 735 if ( this.readOnly != enable ) 736 { 737 this.readOnly = !!enable; 738 // Reload current mode, then fire the event on editor. 739 this.fire( 'readOnly' ); 740 } 714 741 }, 715 742 … … 842 869 843 870 /** 871 * Whether to start the editor in read-only mode, otherwise it depends on if "disabled" attribute is presented on the host <textarea>. 872 * @name CKEDITOR.config.readOnly 873 * @see CKEDITOR.editor.setReadOnly 874 * @type Boolean 875 * @default false 876 * @since 3.6 877 * @example 878 * config.readOnly = true; 879 */ 880 881 /** 844 882 * Fired when a CKEDITOR instance is created, but still before initializing it. 845 883 * To interact with a fully initialized instance, use the … … 984 1022 * @param {Object} element The element to insert. 985 1023 */ 1024 1025 /** 1026 * Event fired once editor's {@link CKEDITOR.editor.prototype.readOnly} state has changed. 1027 * @name CKEDITOR.editor#readOnly 1028 * @event 1029 * @param {CKEDITOR.editor} editor This editor instance. 1030 */ -
CKEditor/branches/features/readonly/_source/plugins/a11yhelp/plugin.js
r6660 r6750 38 38 }, 39 39 modes : { wysiwyg:1, source:1 }, 40 readOnly : 1, 40 41 canUndo : false 41 42 }); -
CKEditor/branches/features/readonly/_source/plugins/about/plugin.js
r6660 r6750 12 12 command.modes = { wysiwyg:1, source:1 }; 13 13 command.canUndo = false; 14 command.readOnly = 1; 14 15 15 16 editor.ui.addButton( 'About', -
CKEditor/branches/features/readonly/_source/plugins/basicstyles/plugin.js
r6660 r6750 18 18 editor.attachStyleStateChange( style, function( state ) 19 19 { 20 editor.getCommand( commandName ).setState( state );20 !editor.readOnly && editor.getCommand( commandName ).setState( state ); 21 21 }); 22 22 -
CKEditor/branches/features/readonly/_source/plugins/bidi/plugin.js
r6660 r6750 23 23 var editor = evt.editor, 24 24 path = evt.data.path; 25 26 if ( editor.readOnly ) 27 return; 28 25 29 var useComputedState = editor.config.useComputedState, 26 30 selectedElement; -
CKEditor/branches/features/readonly/_source/plugins/blockquote/plugin.js
r6660 r6750 26 26 function onSelectionChange( evt ) 27 27 { 28 var editor = evt.editor, 29 command = editor.getCommand( 'blockquote' ); 28 var editor = evt.editor; 29 if ( editor.readOnly ) 30 return; 31 32 var command = editor.getCommand( 'blockquote' ); 30 33 command.state = getState( editor, evt.data.path ); 31 34 command.fire( 'state' ); -
CKEditor/branches/features/readonly/_source/plugins/button/plugin.js
r6660 r6750 150 150 { 151 151 var mode = editor.mode; 152 152 153 // Restore saved button state. 153 this.setState( this.modes[ mode ] ? 154 modeStates[ mode ] != undefined ? modeStates[ mode ] : 155 CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); 154 var state = this.modes[ mode ] ? modeStates[ mode ] != undefined ? modeStates[ mode ] : 155 CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 156 157 this.setState( editor.readOnly && !this.readOnly ? CKEDITOR.TRISTATE_DISABLED : state ); 156 158 }, this); 157 159 } -
CKEditor/branches/features/readonly/_source/plugins/clipboard/plugin.js
r6660 r6750 294 294 CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); 295 295 296 var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 296 var retval = CKEDITOR.TRISTATE_OFF; 297 try { retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; }catch( er ){} 298 297 299 depressBeforeEvent = 0; 298 300 return retval; -
CKEditor/branches/features/readonly/_source/plugins/editingblock/plugin.js
r6660 r6750 114 114 }); 115 115 116 // Force reload the mode to refresh all command states. 117 editor.on( 'readOnly', function() { 118 this.setMode( this.mode || this.config.startupMode, 1 ); 119 }); 120 116 121 editor.on( 'destroy', function () 117 122 { … … 152 157 * CKEDITOR.instances.editor1.setMode( 'source' ); 153 158 */ 154 CKEDITOR.editor.prototype.setMode = function( mode )159 CKEDITOR.editor.prototype.setMode = function( mode, forceReload ) 155 160 { 156 161 this.fire( 'beforeSetMode', { newMode : mode } ); … … 163 168 if ( this.mode ) 164 169 { 165 if ( mode == this.mode )170 if ( !forceReload && mode == this.mode ) 166 171 return; 167 172 -
CKEditor/branches/features/readonly/_source/plugins/elementspath/plugin.js
r6660 r6750 16 16 { 17 17 editorFocus : false, 18 readOnly : 1, 18 19 exec : function( editor ) 19 20 { -
CKEditor/branches/features/readonly/_source/plugins/enterkey/plugin.js
r6682 r6750 12 12 init : function( editor ) 13 13 { 14 var specialKeys = editor.specialKeys; 15 specialKeys[ 13 ] = enter; 16 specialKeys[ CKEDITOR.SHIFT + 13 ] = shiftEnter; 14 editor.addCommand( 'enter', { 15 modes : { wysiwyg:1 }, 16 editorFocus : false, 17 exec : enter 18 }); 19 20 editor.addCommand( 'shiftEnter', { 21 modes : { wysiwyg:1 }, 22 editorFocus : false, 23 exec : shiftEnter 24 }); 25 26 var keystrokes = editor.keystrokeHandler.keystrokes; 27 keystrokes[ 13 ] = 'enter'; 28 keystrokes[ CKEDITOR.SHIFT + 13 ] = 'shiftEnter'; 17 29 } 18 30 }); -
CKEditor/branches/features/readonly/_source/plugins/find/dialogs/find.js
r6681 r6750 855 855 856 856 this.selectPage( startupPage ); 857 858 this[ ( startupPage == 'find' && this._.editor.readOnly? 'hide' : 'show' ) + 'Page' ]( 'replace'); 857 859 }, 858 860 onHide : function() -
CKEditor/branches/features/readonly/_source/plugins/find/plugin.js
r6660 r6750 16 16 var findCommand = editor.addCommand( 'find', new CKEDITOR.dialogCommand( 'find' ) ); 17 17 findCommand.canUndo = false; 18 findCommand.readOnly = 1; 18 19 19 20 editor.ui.addButton( 'Replace', -
CKEditor/branches/features/readonly/_source/plugins/indent/plugin.js
r6660 r6750 16 16 function onSelectionChange( evt ) 17 17 { 18 if ( evt.editor.readOnly ) 19 return; 20 18 21 var editor = evt.editor, 19 22 elementPath = evt.data.path, -
CKEditor/branches/features/readonly/_source/plugins/justify/plugin.js
r6660 r6750 50 50 function onSelectionChange( evt ) 51 51 { 52 if ( evt.editor.readOnly ) 53 return; 54 52 55 var command = evt.editor.getCommand( this.name ); 53 56 command.state = getState.call( this, evt.editor, evt.data.path ); -
CKEditor/branches/features/readonly/_source/plugins/link/plugin.js
r6660 r6750 55 55 editor.on( 'selectionChange', function( evt ) 56 56 { 57 if ( editor.readOnly ) 58 return; 59 57 60 /* 58 61 * Despite our initial hope, document.queryCommandEnabled() does not work -
CKEditor/branches/features/readonly/_source/plugins/list/plugin.js
r6660 r6750 219 219 function onSelectionChange( evt ) 220 220 { 221 if ( evt.editor.readOnly ) 222 return; 223 221 224 var path = evt.data.path, 222 225 blockLimit = path.blockLimit, -
CKEditor/branches/features/readonly/_source/plugins/maximize/plugin.js
r6660 r6750 86 86 { 87 87 var one = all[ i ]; 88 if ( one.mode == 'wysiwyg' )88 if ( one.mode == 'wysiwyg' && !one.readOnly ) 89 89 { 90 90 var body = one.document.getBody(); … … 156 156 { 157 157 modes : { wysiwyg : 1, source : 1 }, 158 readOnly : 1, 158 159 editorFocus : false, 159 160 exec : function() -
CKEditor/branches/features/readonly/_source/plugins/menu/plugin.js
r6660 r6750 98 98 var item = this.editor.getMenuItem( itemName ); 99 99 100 if ( item )100 if ( item && ( !item.command || this.editor.getCommand( item.command ).state ) ) 101 101 { 102 item.state = listenerItems[ itemName ];102 item.state = listenerItems[ itemName ]; 103 103 this.add( item ); 104 104 } -
CKEditor/branches/features/readonly/_source/plugins/preview/plugin.js
r6660 r6750 14 14 modes : { wysiwyg:1, source:1 }, 15 15 canUndo : false, 16 readOnly : 1, 16 17 exec : function( editor ) 17 18 { -
CKEditor/branches/features/readonly/_source/plugins/print/plugin.js
r6660 r6750 38 38 }, 39 39 canUndo : false, 40 readOnly : 1, 40 41 modes : { wysiwyg : !( CKEDITOR.env.opera ) } // It is imposible to print the inner document in Opera. 41 42 }; -
CKEditor/branches/features/readonly/_source/plugins/richcombo/plugin.js
r6660 r6750 131 131 editor.on( 'mode', function() 132 132 { 133 this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED ); 133 var state = this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; 134 this.setState( editor.readOnly && !this.readOnly ? CKEDITOR.TRISTATE_DISABLED : state ); 134 135 this.setValue( '' ); 135 136 }, -
CKEditor/branches/features/readonly/_source/plugins/save/plugin.js
r6660 r6750 13 13 { 14 14 modes : { wysiwyg:1, source:1 }, 15 readOnly : 1, 15 16 16 17 exec : function( editor ) -
CKEditor/branches/features/readonly/_source/plugins/selection/plugin.js
r6660 r6750 93 93 { 94 94 modes : { wysiwyg : 1, source : 1 }, 95 readOnly : CKEDITOR.env.ie || CKEDITOR.env.webkit, 95 96 exec : function( editor ) 96 97 { -
CKEditor/branches/features/readonly/_source/plugins/showblocks/plugin.js
r6660 r6750 90 90 var commandDefinition = 91 91 { 92 readOnly : 1, 92 93 preserveState : true, 93 94 editorFocus : false, -
CKEditor/branches/features/readonly/_source/plugins/showborders/plugin.js
r6660 r6750 41 41 preserveState : true, 42 42 editorFocus : false, 43 readOnly: 1, 43 44 44 45 exec : function ( editor ) -
CKEditor/branches/features/readonly/_source/plugins/sourcearea/plugin.js
r6660 r6750 41 41 textarea.addClass( 'cke_source' ); 42 42 textarea.addClass( 'cke_enable_context_menu' ); 43 44 editor.readOnly && textarea.setAttribute( 'disabled', true ); 43 45 44 46 var styles = … … 182 184 modes : { wysiwyg:1, source:1 }, 183 185 editorFocus : false, 184 186 readOnly : 1, 185 187 exec : function( editor ) 186 188 { -
CKEditor/branches/features/readonly/_source/plugins/toolbar/plugin.js
r6748 r6750 37 37 { 38 38 modes : { wysiwyg : 1, source : 1 }, 39 readOnly : 1, 39 40 40 41 exec : function( editor ) … … 327 328 editor.addCommand( 'toolbarCollapse', 328 329 { 330 readOnly : 1, 329 331 exec : function( editor ) 330 332 { -
CKEditor/branches/features/readonly/_source/plugins/undo/plugin.js
r6660 r6750 91 91 editor.on( 'mode', function() 92 92 { 93 undoManager.enabled = editor. mode == 'wysiwyg';93 undoManager.enabled = editor.readOnly ? false : editor.mode == 'wysiwyg'; 94 94 undoManager.onChange(); 95 95 }); -
CKEditor/branches/features/readonly/_source/plugins/wysiwygarea/plugin.js
r6687 r6750 599 599 body.spellcheck = !editor.config.disableNativeSpellChecker; 600 600 601 var editable = !editor.readOnly; 602 601 603 if ( CKEDITOR.env.ie ) 602 604 { … … 607 609 // taking the editing focus at startup. (#141 / #523) 608 610 body.disabled = true; 609 body.contentEditable = true;611 body.contentEditable = editable; 610 612 body.removeAttribute( 'disabled' ); 611 613 } … … 619 621 if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 620 622 || CKEDITOR.env.opera ) 621 domDocument.$.body.contentEditable = true;623 domDocument.$.body.contentEditable = editable; 622 624 else if ( CKEDITOR.env.webkit ) 623 domDocument.$.body.parentNode.contentEditable = true;625 domDocument.$.body.parentNode.contentEditable = editable; 624 626 else 625 domDocument.$.designMode = 'on';627 domDocument.$.designMode = editable? 'off' : 'on'; 626 628 }, 0 ); 627 629 } 628 630 629 CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor );631 editable && CKEDITOR.env.gecko && CKEDITOR.tools.setTimeout( activateEditing, 0, null, editor ); 630 632 631 633 domWindow = editor.window = new CKEDITOR.dom.window( domWindow ); 632 634 domDocument = editor.document = new CKEDITOR.dom.document( domDocument ); 633 635 634 domDocument.on( 'dblclick', function( evt )636 editable && domDocument.on( 'dblclick', function( evt ) 635 637 { 636 638 var element = evt.data.getTarget(), … … 713 715 // IE standard compliant in editing frame doesn't focus the editor when 714 716 // clicking outside actual content, manually apply the focus. (#1659) 715 if ( CKEDITOR.env.ie716 && domDocument.$.compatMode == 'CSS1Compat'717 if ( editable && 718 CKEDITOR.env.ie && domDocument.$.compatMode == 'CSS1Compat' 717 719 || CKEDITOR.env.gecko 718 720 || CKEDITOR.env.opera ) … … 745 747 var doc = editor.document; 746 748 747 if ( CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 )749 if ( editable && CKEDITOR.env.gecko && CKEDITOR.env.version >= 10900 ) 748 750 blinkCursor(); 749 751 else if ( CKEDITOR.env.opera ) … … 763 765 764 766 var keystrokeHandler = editor.keystrokeHandler; 765 if ( keystrokeHandler ) 766 keystrokeHandler.attach( domDocument ); 767 // Prevent backspace from navigating off the page. 768 keystrokeHandler.blockedKeystrokes[ 8 ] = !editable; 769 keystrokeHandler.attach( domDocument ); 767 770 768 771 if ( CKEDITOR.env.ie ) … … 771 774 // Override keystrokes which should have deletion behavior 772 775 // on control types in IE . (#4047) 773 domDocument.on( 'keydown', function( evt )776 editable && domDocument.on( 'keydown', function( evt ) 774 777 { 775 778 var keyCode = evt.data.getKeystroke();
Note: See TracChangeset
for help on using the changeset viewer.
