- // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)',\r
- // guard to distinguish from the ordinary sources( either\r
- // keyboard paste or execCommand ) (#4874).\r
- CKEDITOR.env.ie && ( depressBeforeEvent = 1 );\r
-\r
- var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;\r
- depressBeforeEvent = 0;\r
- return retval;\r
+ var retval;\r
+\r
+ if ( inReadOnly && command in { Paste : 1, Cut : 1 } )\r
+ return CKEDITOR.TRISTATE_DISABLED;\r
+\r
+ if ( command == 'Paste' )\r
+ {\r
+ // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)',\r
+ // guard to distinguish from the ordinary sources (either\r
+ // keyboard paste or execCommand) (#4874).\r
+ CKEDITOR.env.ie && ( depressBeforeEvent = 1 );\r
+ try\r
+ {\r
+ // Always return true for Webkit (which always returns false).\r
+ retval = editor.document.$.queryCommandEnabled( command ) || CKEDITOR.env.webkit;\r
+ }\r
+ catch( er ) {}\r
+ depressBeforeEvent = 0;\r
+ }\r
+ // Cut, Copy - check if the selection is not empty\r
+ else\r
+ {\r
+ var sel = editor.getSelection(),\r
+ ranges = sel && sel.getRanges();\r
+ retval = sel && !( ranges.length == 1 && ranges[ 0 ].collapsed );\r
+ }\r
+\r
+ return retval ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;\r