]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/div/plugin.js
0faaa5fc2b73a4e6d7bf3d32a2d5d81a6beaab34
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 * @fileOverview The "div" plugin. It wraps the selected block level elements with a 'div' element with specified styles and attributes.
12 CKEDITOR
.plugins
.add( 'div', {
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: 'creatediv', // %REMOVE_LINE_CORE%
18 hidpi: true, // %REMOVE_LINE_CORE%
19 init: function( editor
) {
20 if ( editor
.blockless
)
23 var lang
= editor
.lang
.div
,
26 if ( CKEDITOR
.dialog
.isTabEnabled( editor
, 'editdiv', 'advanced' ) )
27 allowed
+= ';div[dir,id,lang,title]{*}';
29 editor
.addCommand( 'creatediv', new CKEDITOR
.dialogCommand( 'creatediv', {
30 allowedContent: allowed
,
31 requiredContent: 'div',
32 contextSensitive: true,
33 refresh: function( editor
, path
) {
34 var context
= editor
.config
.div_wrapTable
? path
.root : path
.blockLimit
;
35 this.setState( 'div' in context
.getDtd() ? CKEDITOR
.TRISTATE_OFF : CKEDITOR
.TRISTATE_DISABLED
);
39 editor
.addCommand( 'editdiv', new CKEDITOR
.dialogCommand( 'editdiv', { requiredContent: 'div' } ) );
40 editor
.addCommand( 'removediv', {
41 requiredContent: 'div',
42 exec: function( editor
) {
43 var selection
= editor
.getSelection(),
44 ranges
= selection
&& selection
.getRanges(),
46 bookmarks
= selection
.createBookmarks(),
50 function findDiv( node
) {
51 var div
= CKEDITOR
.plugins
.div
.getSurroundDiv( editor
, node
);
52 if ( div
&& !div
.data( 'cke-div-added' ) ) {
54 div
.data( 'cke-div-added' );
58 for ( var i
= 0; i
< ranges
.length
; i
++ ) {
60 if ( range
.collapsed
)
61 findDiv( selection
.getStartElement() );
63 walker
= new CKEDITOR
.dom
.walker( range
);
64 walker
.evaluator
= findDiv
;
69 for ( i
= 0; i
< toRemove
.length
; i
++ )
70 toRemove
[ i
].remove( true );
72 selection
.selectBookmarks( bookmarks
);
76 editor
.ui
.addButton
&& editor
.ui
.addButton( 'CreateDiv', {
82 if ( editor
.addMenuItems
) {
83 editor
.addMenuItems( {
99 if ( editor
.contextMenu
) {
100 editor
.contextMenu
.addListener( function( element
) {
101 if ( !element
|| element
.isReadOnly() )
105 if ( CKEDITOR
.plugins
.div
.getSurroundDiv( editor
) ) {
107 editdiv: CKEDITOR
.TRISTATE_OFF
,
108 removediv: CKEDITOR
.TRISTATE_OFF
117 CKEDITOR
.dialog
.add( 'creatediv', this.path
+ 'dialogs/div.js' );
118 CKEDITOR
.dialog
.add( 'editdiv', this.path
+ 'dialogs/div.js' );
122 CKEDITOR
.plugins
.div
= {
123 getSurroundDiv: function( editor
, start
) {
124 var path
= editor
.elementPath( start
);
125 return editor
.elementPath( path
.blockLimit
).contains( function( node
) {
126 // Avoid read-only (i.e. contenteditable="false") divs (#11083).
127 return node
.is( 'div' ) && !node
.isReadOnly();