mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-18 12:30:02 +02:00
* API: updating CKEDITOR to version 3.6.2, altering editor modes and availability of toolbar options
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
(function()
|
||||
{
|
||||
function placeholderDialog( editor, isEdit )
|
||||
{
|
||||
|
||||
var lang = editor.lang.placeholder,
|
||||
generalLabel = editor.lang.common.generalTab;
|
||||
return {
|
||||
title : lang.title,
|
||||
minWidth : 300,
|
||||
minHeight : 80,
|
||||
contents :
|
||||
[
|
||||
{
|
||||
id : 'info',
|
||||
label : generalLabel,
|
||||
title : generalLabel,
|
||||
elements :
|
||||
[
|
||||
{
|
||||
id : 'text',
|
||||
type : 'text',
|
||||
style : 'width: 100%;',
|
||||
label : lang.text,
|
||||
'default' : '',
|
||||
required : true,
|
||||
validate : CKEDITOR.dialog.validate.notEmpty( lang.textMissing ),
|
||||
setup : function( element )
|
||||
{
|
||||
if ( isEdit )
|
||||
this.setValue( element.getText().slice( 2, -2 ) );
|
||||
},
|
||||
commit : function( element )
|
||||
{
|
||||
var text = '[[' + this.getValue() + ']]';
|
||||
// The placeholder must be recreated.
|
||||
CKEDITOR.plugins.placeholder.createPlaceholder( editor, element, text );
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
onShow : function()
|
||||
{
|
||||
if ( isEdit )
|
||||
this._element = CKEDITOR.plugins.placeholder.getSelectedPlaceHoder( editor );
|
||||
|
||||
this.setupContent( this._element );
|
||||
},
|
||||
onOk : function()
|
||||
{
|
||||
this.commitContent( this._element );
|
||||
delete this._element;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
CKEDITOR.dialog.add( 'createplaceholder', function( editor )
|
||||
{
|
||||
return placeholderDialog( editor );
|
||||
});
|
||||
CKEDITOR.dialog.add( 'editplaceholder', function( editor )
|
||||
{
|
||||
return placeholderDialog( editor, 1 );
|
||||
});
|
||||
} )();
|
16
phpgwapi/js/ckeditor3/_source/plugins/placeholder/lang/en.js
Normal file
16
phpgwapi/js/ckeditor3/_source/plugins/placeholder/lang/en.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.setLang( 'placeholder', 'en',
|
||||
{
|
||||
placeholder :
|
||||
{
|
||||
title : 'Placeholder Properties',
|
||||
toolbar : 'Create Placeholder',
|
||||
text : 'Placeholder Text',
|
||||
edit : 'Edit Placeholder',
|
||||
textMissing : 'The placeholder must contain text.'
|
||||
}
|
||||
});
|
16
phpgwapi/js/ckeditor3/_source/plugins/placeholder/lang/he.js
Normal file
16
phpgwapi/js/ckeditor3/_source/plugins/placeholder/lang/he.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.setLang( 'placeholder', 'he',
|
||||
{
|
||||
placeholder :
|
||||
{
|
||||
title : 'מאפייני שומר מקום',
|
||||
toolbar : 'צור שומר מקום',
|
||||
text : 'תוכן שומר המקום',
|
||||
edit : 'ערוך שומר מקום',
|
||||
textMissing : 'שומר המקום חייב להכיל טקסט.'
|
||||
}
|
||||
});
|
Binary file not shown.
After Width: | Height: | Size: 96 B |
171
phpgwapi/js/ckeditor3/_source/plugins/placeholder/plugin.js
Normal file
171
phpgwapi/js/ckeditor3/_source/plugins/placeholder/plugin.js
Normal file
@@ -0,0 +1,171 @@
|
||||
/*
|
||||
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileOverview The "placeholder" plugin.
|
||||
*
|
||||
*/
|
||||
|
||||
(function()
|
||||
{
|
||||
var placeholderReplaceRegex = /\[\[[^\]]+\]\]/g;
|
||||
CKEDITOR.plugins.add( 'placeholder',
|
||||
{
|
||||
requires : [ 'dialog' ],
|
||||
lang : [ 'en', 'he' ],
|
||||
init : function( editor )
|
||||
{
|
||||
var lang = editor.lang.placeholder;
|
||||
|
||||
editor.addCommand( 'createplaceholder', new CKEDITOR.dialogCommand( 'createplaceholder' ) );
|
||||
editor.addCommand( 'editplaceholder', new CKEDITOR.dialogCommand( 'editplaceholder' ) );
|
||||
|
||||
editor.ui.addButton( 'CreatePlaceholder',
|
||||
{
|
||||
label : lang.toolbar,
|
||||
command :'createplaceholder',
|
||||
icon : this.path + 'placeholder.gif'
|
||||
});
|
||||
|
||||
if ( editor.addMenuItems )
|
||||
{
|
||||
editor.addMenuGroup( 'placeholder', 20 );
|
||||
editor.addMenuItems(
|
||||
{
|
||||
editplaceholder :
|
||||
{
|
||||
label : lang.edit,
|
||||
command : 'editplaceholder',
|
||||
group : 'placeholder',
|
||||
order : 1,
|
||||
icon : this.path + 'placeholder.gif'
|
||||
}
|
||||
} );
|
||||
|
||||
if ( editor.contextMenu )
|
||||
{
|
||||
editor.contextMenu.addListener( function( element, selection )
|
||||
{
|
||||
if ( !element || !element.data( 'cke-placeholder' ) )
|
||||
return null;
|
||||
|
||||
return { editplaceholder : CKEDITOR.TRISTATE_OFF };
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
editor.on( 'doubleclick', function( evt )
|
||||
{
|
||||
if ( CKEDITOR.plugins.placeholder.getSelectedPlaceHoder( editor ) )
|
||||
evt.data.dialog = 'editplaceholder';
|
||||
});
|
||||
|
||||
editor.addCss(
|
||||
'.cke_placeholder' +
|
||||
'{' +
|
||||
'background-color: #ffff00;' +
|
||||
( CKEDITOR.env.gecko ? 'cursor: default;' : '' ) +
|
||||
'}'
|
||||
);
|
||||
|
||||
editor.on( 'contentDom', function()
|
||||
{
|
||||
editor.document.getBody().on( 'resizestart', function( evt )
|
||||
{
|
||||
if ( editor.getSelection().getSelectedElement().data( 'cke-placeholder' ) )
|
||||
evt.data.preventDefault();
|
||||
});
|
||||
});
|
||||
|
||||
CKEDITOR.dialog.add( 'createplaceholder', this.path + 'dialogs/placeholder.js' );
|
||||
CKEDITOR.dialog.add( 'editplaceholder', this.path + 'dialogs/placeholder.js' );
|
||||
},
|
||||
afterInit : function( editor )
|
||||
{
|
||||
var dataProcessor = editor.dataProcessor,
|
||||
dataFilter = dataProcessor && dataProcessor.dataFilter,
|
||||
htmlFilter = dataProcessor && dataProcessor.htmlFilter;
|
||||
|
||||
if ( dataFilter )
|
||||
{
|
||||
dataFilter.addRules(
|
||||
{
|
||||
text : function( text )
|
||||
{
|
||||
return text.replace( placeholderReplaceRegex, function( match )
|
||||
{
|
||||
return CKEDITOR.plugins.placeholder.createPlaceholder( editor, null, match, 1 );
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ( htmlFilter )
|
||||
{
|
||||
htmlFilter.addRules(
|
||||
{
|
||||
elements :
|
||||
{
|
||||
'span' : function( element )
|
||||
{
|
||||
if ( element.attributes && element.attributes[ 'data-cke-placeholder' ] )
|
||||
delete element.name;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
CKEDITOR.plugins.placeholder =
|
||||
{
|
||||
createPlaceholder : function( editor, oldElement, text, isGet )
|
||||
{
|
||||
var element = new CKEDITOR.dom.element( 'span', editor.document );
|
||||
element.setAttributes(
|
||||
{
|
||||
contentEditable : 'false',
|
||||
'data-cke-placeholder' : 1,
|
||||
'class' : 'cke_placeholder'
|
||||
}
|
||||
);
|
||||
|
||||
text && element.setText( text );
|
||||
|
||||
if ( isGet )
|
||||
return element.getOuterHtml();
|
||||
|
||||
if ( oldElement )
|
||||
{
|
||||
if ( CKEDITOR.env.ie )
|
||||
{
|
||||
element.insertAfter( oldElement );
|
||||
// Some time is required for IE before the element is removed.
|
||||
setTimeout( function()
|
||||
{
|
||||
oldElement.remove();
|
||||
element.focus();
|
||||
}, 10 );
|
||||
}
|
||||
else
|
||||
element.replace( oldElement );
|
||||
}
|
||||
else
|
||||
editor.insertElement( element );
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
getSelectedPlaceHoder : function( editor )
|
||||
{
|
||||
var range = editor.getSelection().getRanges()[ 0 ];
|
||||
range.shrink( CKEDITOR.SHRINK_TEXT );
|
||||
var node = range.startContainer;
|
||||
while( node && !( node.type == CKEDITOR.NODE_ELEMENT && node.data( 'cke-placeholder' ) ) )
|
||||
node = node.getParent();
|
||||
return node;
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user