]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blame - sources/plugins/selectall/plugin.js
Initial commit
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / selectall / plugin.js
CommitLineData
7adcb81e
IB
1/**\r
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r
3 * For licensing, see LICENSE.md or http://ckeditor.com/license\r
4 */\r
5\r
6/**\r
7 * @fileOverview The "selectall" plugin provides an editor command that\r
8 * allows selecting the entire content of editable area.\r
9 * This plugin also enables a toolbar button for the feature.\r
10 */\r
11\r
12( function() {\r
13 CKEDITOR.plugins.add( 'selectall', {\r
14 // jscs:disable maximumLineLength\r
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%\r
16 // jscs:enable maximumLineLength\r
17 icons: 'selectall', // %REMOVE_LINE_CORE%\r
18 hidpi: true, // %REMOVE_LINE_CORE%\r
19 init: function( editor ) {\r
20 editor.addCommand( 'selectAll', { modes: { wysiwyg: 1, source: 1 },\r
21 exec: function( editor ) {\r
22 var editable = editor.editable();\r
23\r
24 if ( editable.is( 'textarea' ) ) {\r
25 var textarea = editable.$;\r
26\r
27 if ( CKEDITOR.env.ie )\r
28 textarea.createTextRange().execCommand( 'SelectAll' );\r
29 else {\r
30 textarea.selectionStart = 0;\r
31 textarea.selectionEnd = textarea.value.length;\r
32 }\r
33\r
34 textarea.focus();\r
35 } else {\r
36 if ( editable.is( 'body' ) )\r
37 editor.document.$.execCommand( 'SelectAll', false, null );\r
38 else {\r
39 var range = editor.createRange();\r
40 range.selectNodeContents( editable );\r
41 range.select();\r
42 }\r
43\r
44 // Force triggering selectionChange (#7008)\r
45 editor.forceNextSelectionCheck();\r
46 editor.selectionChange();\r
47 }\r
48\r
49 },\r
50 canUndo: false\r
51 } );\r
52\r
53 editor.ui.addButton && editor.ui.addButton( 'SelectAll', {\r
54 label: editor.lang.selectall.toolbar,\r
55 command: 'selectAll',\r
56 toolbar: 'selection,10'\r
57 } );\r
58 }\r
59 } );\r
60} )();\r