2
* @license Copyright (c) 2003-2014, CKSource - Frederico Knabben. All rights reserved.
3
* For licensing, see LICENSE.md or http://ckeditor.com/license
6
CKEDITOR.plugins.add( 'table', {
8
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,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
9
icons: 'table', // %REMOVE_LINE_CORE%
10
hidpi: true, // %REMOVE_LINE_CORE%
11
init: function( editor ) {
12
if ( editor.blockless )
15
var table = CKEDITOR.plugins.table,
16
lang = editor.lang.table;
18
editor.addCommand( 'table', new CKEDITOR.dialogCommand( 'table', {
20
allowedContent: 'table{width,height}[align,border,cellpadding,cellspacing,summary];' +
21
'caption tbody thead tfoot;' +
23
( editor.plugins.dialogadvtab ? 'table' + editor.plugins.dialogadvtab.allowedContent() : '' ),
24
requiredContent: 'table',
25
contentTransformations: [
26
[ 'table{width}: sizeToStyle', 'table[width]: sizeToAttribute' ]
30
function createDef( def ) {
31
return CKEDITOR.tools.extend( def || {}, {
33
refresh: function( editor, path ) {
34
this.setState( path.contains( 'table', 1 ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
39
editor.addCommand( 'tableProperties', new CKEDITOR.dialogCommand( 'tableProperties', createDef() ) );
40
editor.addCommand( 'tableDelete', createDef( {
41
exec: function( editor ) {
42
var path = editor.elementPath(),
43
table = path.contains( 'table', 1 );
48
// If the table's parent has only one child remove it as well (unless it's the body or a table cell) (#5416, #6289)
49
var parent = table.getParent();
50
if ( parent.getChildCount() == 1 && !parent.is( 'body', 'td', 'th' ) )
53
var range = editor.createRange();
54
range.moveToPosition( table, CKEDITOR.POSITION_BEFORE_START );
60
editor.ui.addButton && editor.ui.addButton( 'Table', {
66
CKEDITOR.dialog.add( 'table', this.path + 'dialogs/table.js' );
67
CKEDITOR.dialog.add( 'tableProperties', this.path + 'dialogs/table.js' );
69
// If the "menu" plugin is loaded, register the menu items.
70
if ( editor.addMenuItems ) {
71
editor.addMenuItems( {
74
command: 'tableProperties',
80
label: lang.deleteTable,
81
command: 'tableDelete',
88
editor.on( 'doubleclick', function( evt ) {
89
var element = evt.data.element;
91
if ( element.is( 'table' ) )
92
evt.data.dialog = 'tableProperties';
95
// If the "contextmenu" plugin is loaded, register the listeners.
96
if ( editor.contextMenu ) {
97
editor.contextMenu.addListener( function() {
98
// menu item state is resolved on commands.
100
tabledelete: CKEDITOR.TRISTATE_OFF,
101
table: CKEDITOR.TRISTATE_OFF