diff options
Diffstat (limited to 'sources/plugins/selectall/plugin.js')
-rw-r--r-- | sources/plugins/selectall/plugin.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/sources/plugins/selectall/plugin.js b/sources/plugins/selectall/plugin.js new file mode 100644 index 00000000..c8cc3182 --- /dev/null +++ b/sources/plugins/selectall/plugin.js | |||
@@ -0,0 +1,60 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved. | ||
3 | * For licensing, see LICENSE.md or http://ckeditor.com/license | ||
4 | */ | ||
5 | |||
6 | /** | ||
7 | * @fileOverview The "selectall" plugin provides an editor command that | ||
8 | * allows selecting the entire content of editable area. | ||
9 | * This plugin also enables a toolbar button for the feature. | ||
10 | */ | ||
11 | |||
12 | ( function() { | ||
13 | CKEDITOR.plugins.add( 'selectall', { | ||
14 | // jscs:disable maximumLineLength | ||
15 | lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE% | ||
16 | // jscs:enable maximumLineLength | ||
17 | icons: 'selectall', // %REMOVE_LINE_CORE% | ||
18 | hidpi: true, // %REMOVE_LINE_CORE% | ||
19 | init: function( editor ) { | ||
20 | editor.addCommand( 'selectAll', { modes: { wysiwyg: 1, source: 1 }, | ||
21 | exec: function( editor ) { | ||
22 | var editable = editor.editable(); | ||
23 | |||
24 | if ( editable.is( 'textarea' ) ) { | ||
25 | var textarea = editable.$; | ||
26 | |||
27 | if ( CKEDITOR.env.ie ) | ||
28 | textarea.createTextRange().execCommand( 'SelectAll' ); | ||
29 | else { | ||
30 | textarea.selectionStart = 0; | ||
31 | textarea.selectionEnd = textarea.value.length; | ||
32 | } | ||
33 | |||
34 | textarea.focus(); | ||
35 | } else { | ||
36 | if ( editable.is( 'body' ) ) | ||
37 | editor.document.$.execCommand( 'SelectAll', false, null ); | ||
38 | else { | ||
39 | var range = editor.createRange(); | ||
40 | range.selectNodeContents( editable ); | ||
41 | range.select(); | ||
42 | } | ||
43 | |||
44 | // Force triggering selectionChange (#7008) | ||
45 | editor.forceNextSelectionCheck(); | ||
46 | editor.selectionChange(); | ||
47 | } | ||
48 | |||
49 | }, | ||
50 | canUndo: false | ||
51 | } ); | ||
52 | |||
53 | editor.ui.addButton && editor.ui.addButton( 'SelectAll', { | ||
54 | label: editor.lang.selectall.toolbar, | ||
55 | command: 'selectAll', | ||
56 | toolbar: 'selection,10' | ||
57 | } ); | ||
58 | } | ||
59 | } ); | ||
60 | } )(); | ||