first commit
This commit is contained in:
55
libraries/ckeditor/plugins/texttransform/README.md
Normal file
55
libraries/ckeditor/plugins/texttransform/README.md
Normal file
@@ -0,0 +1,55 @@
|
||||
Text Transform Plugin for CKEditor
|
||||
================================
|
||||
|
||||
A very simple plugin which provides transforming selected text to new cases. You can transform selected text to uppercase, lowercase or simply capitalize it.
|
||||
|
||||
Available Transform Cases
|
||||
-------------------------
|
||||
|
||||
* Transform Text to Uppercase: Convert letters to uppercase
|
||||
* Transform Text to Lowercase: Convert letters to lowercase
|
||||
* Transform Capitalize: Capitalize each word of selected text
|
||||
* Transform Switcher: Loop through all cases
|
||||
|
||||
Internationalization
|
||||
-------------------------
|
||||
|
||||
Currently plugin supports 2 languages.
|
||||
|
||||
* en
|
||||
* tr
|
||||
|
||||
*Translations are welcomed.*
|
||||
|
||||
Usage
|
||||
-------------------------
|
||||
|
||||
1. Download source files and place them on to be created "texttransform" folder under the CKEditor's plugin base.
|
||||
|
||||
2. Define plugin in CKEDITOR config object.
|
||||
|
||||
CKEDITOR.config.extraPlugins = 'texttransform';
|
||||
|
||||
3. Add transform buttons to your editor toolbar.
|
||||
|
||||
CKEDITOR.config.toolbar = [
|
||||
{ name: 'texttransform', items: [ 'TransformTextToUppercase', 'TransformTextToLowercase', 'TransformTextCapitalize', 'TransformTextSwitcher' ] }
|
||||
];
|
||||
|
||||
4. Set your CKEDITOR language if you did not set it yet.
|
||||
|
||||
CKEDITOR.config.language = 'en';
|
||||
|
||||
Demo
|
||||
-------------------------
|
||||
|
||||
[View the live demo](http://jsfiddle.net/t99kV/5/) on jsFiddle.
|
||||
|
||||
|
||||
Cheers
|
||||
--------------------
|
||||
|
||||
Thanks to [CKEditor] [1] and [jsFiddle] [2] for their good work.
|
||||
|
||||
[1]: http://ckeditor.com "CKEditor"
|
||||
[2]: http://jsfiddle.net "jsFiddle"
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
17
libraries/ckeditor/plugins/texttransform/lang/en.js
Normal file
17
libraries/ckeditor/plugins/texttransform/lang/en.js
Normal file
@@ -0,0 +1,17 @@
|
||||
/**
|
||||
* @author: Önder Ceylan <onderceylan@gmail.com>
|
||||
* @copyright Copyright (c) 2013 - Önder Ceylan. All rights reserved.
|
||||
* @license Licensed under the terms of GPL, LGPL and MPL licenses.
|
||||
* @version 1.0
|
||||
*
|
||||
* Date: 5/10/13
|
||||
* Time: 9:45 AM
|
||||
*/
|
||||
|
||||
// set CKeditor lang
|
||||
CKEDITOR.plugins.setLang( 'texttransform', 'en', {
|
||||
transformTextSwitchLabel: 'Transform Text Switcher',
|
||||
transformTextToLowercaseLabel: 'Transform Text to Lowercase',
|
||||
transformTextToUppercaseLabel: 'Transform Text to Uppercase',
|
||||
transformTextCapitalizeLabel: 'Capitalize Text'
|
||||
});
|
||||
41
libraries/ckeditor/plugins/texttransform/lang/tr.js
Normal file
41
libraries/ckeditor/plugins/texttransform/lang/tr.js
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* @author: Önder Ceylan <onderceylan@gmail.com>
|
||||
* @copyright Copyright (c) 2013 - Önder Ceylan. All rights reserved.
|
||||
* @license Licensed under the terms of GPL, LGPL and MPL licenses.
|
||||
* @version 1.0
|
||||
*
|
||||
* Date: 5/10/13
|
||||
* Time: 9:45 AM
|
||||
*/
|
||||
|
||||
// define a prototype toUpperCase fn for Turkish character recognization
|
||||
String.prototype.trToUpperCase = function(){
|
||||
var string = this;
|
||||
var letters = { "i": "İ", "ş": "Ş", "ğ": "Ğ", "ü": "Ü", "ö": "Ö", "ç": "Ç", "ı": "I" };
|
||||
string = string.replace(/(([iışğüçö]))/g, function(letter){ return letters[letter]; });
|
||||
if (typeof(String.prototype.toLocaleUpperCase()) != 'undefined') {
|
||||
return string.toLocaleUpperCase();
|
||||
} else {
|
||||
return string.toUpperCase();
|
||||
}
|
||||
};
|
||||
|
||||
// define prototype toLowerCase fn for Turkish character recognization
|
||||
String.prototype.trToLowerCase = function(){
|
||||
var string = this;
|
||||
var letters = { "İ": "i", "I": "ı", "Ş": "ş", "Ğ": "ğ", "Ü": "ü", "Ö": "ö", "Ç": "ç" };
|
||||
string = string.replace(/(([İIŞĞÜÇÖ]))/g, function(letter){ return letters[letter]; });
|
||||
if (typeof(String.prototype.toLocaleLowerCase()) != 'undefined') {
|
||||
return string.toLocaleLowerCase();
|
||||
} else {
|
||||
return string.toLowerCase();
|
||||
}
|
||||
};
|
||||
|
||||
// set CKeditor lang
|
||||
CKEDITOR.plugins.setLang( 'texttransform', 'tr', {
|
||||
transformTextSwitchLabel: 'Harf Düzenini Değiştir',
|
||||
transformTextToLowercaseLabel: 'Küçük Harfe Dönüştür',
|
||||
transformTextToUppercaseLabel: 'Büyük Harfe Dönüştür',
|
||||
transformTextCapitalizeLabel: 'Baş Harfleri Büyüt'
|
||||
});
|
||||
151
libraries/ckeditor/plugins/texttransform/plugin.js
Normal file
151
libraries/ckeditor/plugins/texttransform/plugin.js
Normal file
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
* @authors: Önder Ceylan <onderceylan@gmail.com>, PPKRAUSS https://github.com/ppKrauss
|
||||
* @license Licensed under the terms of GPL, LGPL and MPL licenses.
|
||||
* @version 1.1
|
||||
* @history v1.0 at 2013-05-09 by onderceylan, v1.1 at 2013-08-27 by ppkrauss.
|
||||
*/
|
||||
|
||||
CKEDITOR.plugins.add('texttransform',
|
||||
{
|
||||
|
||||
// define lang codes for available lang files here
|
||||
lang: 'en,tr',
|
||||
|
||||
// plugin initialise
|
||||
init: function(editor)
|
||||
{
|
||||
// set num for switcher loop
|
||||
var num = 0;
|
||||
|
||||
// add transformTextSwitch command to be used with button
|
||||
editor.addCommand('transformTextSwitch',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
var selection = editor.getSelection();
|
||||
var commandArray = ['transformTextToUppercase', 'transformTextToLowercase', 'transformTextCapitalize'];
|
||||
|
||||
if (selection.getSelectedText().length > 0) {
|
||||
|
||||
selection.lock();
|
||||
|
||||
editor.execCommand( commandArray[num] );
|
||||
|
||||
selection.unlock(true);
|
||||
|
||||
if (num < commandArray.length - 1) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add transformTextToUppercase command to be used with buttons and 'execCommand' method
|
||||
editor.addCommand('transformTextToUppercase',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
var selection = editor.getSelection();
|
||||
if (selection.getSelectedText().length > 0) {
|
||||
var ranges = selection.getRanges(),
|
||||
walker = new CKEDITOR.dom.walker( ranges[0] ),
|
||||
node;
|
||||
while ( ( node = walker.next() ) )
|
||||
if ( node.type == CKEDITOR.NODE_TEXT && node.getText() )
|
||||
if (editor.langCode == "tr") {
|
||||
node.$.textContent = node.$.textContent.trToUpperCase();
|
||||
} else {
|
||||
node.$.textContent = node.$.textContent.toLocaleUpperCase();
|
||||
}
|
||||
}//if
|
||||
} //func
|
||||
});
|
||||
|
||||
// add transformTextToUppercase command to be used with buttons and 'execCommand' method
|
||||
editor.addCommand('transformTextToLowercase',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
var selection = editor.getSelection();
|
||||
if (selection.getSelectedText().length > 0) {
|
||||
var ranges = selection.getRanges(),
|
||||
walker = new CKEDITOR.dom.walker( ranges[0] ),
|
||||
node;
|
||||
while ( ( node = walker.next() ) )
|
||||
if ( node.type == CKEDITOR.NODE_TEXT && node.getText() )
|
||||
if (editor.langCode == "tr") {
|
||||
node.$.textContent = node.$.textContent.trToLowerCase();
|
||||
} else {
|
||||
node.$.textContent = node.$.textContent.toLocaleLowerCase();
|
||||
}
|
||||
|
||||
}//if
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// add transformTextCapitalize command to be used with buttons and 'execCommand' method
|
||||
editor.addCommand( 'transformTextCapitalize',
|
||||
{
|
||||
exec : function()
|
||||
{
|
||||
var selection = editor.getSelection();
|
||||
if (selection.getSelectedText().length > 0) {
|
||||
var ranges = selection.getRanges(),
|
||||
walker = new CKEDITOR.dom.walker( ranges[0] ),
|
||||
node;
|
||||
while ( ( node = walker.next() ) )
|
||||
if ( node.type == CKEDITOR.NODE_TEXT && node.getText() )
|
||||
node.$.textContent = node.$.textContent.replace(
|
||||
/[^\s]\S*/g,
|
||||
function(txt){
|
||||
if (editor.langCode == "tr") {
|
||||
return txt.charAt(0).trToUpperCase() +
|
||||
txt.substr(1).trToLowerCase();
|
||||
} else {
|
||||
return txt.charAt(0).toLocaleUpperCase() +
|
||||
txt.substr(1).toLocaleLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
}//if
|
||||
}
|
||||
});
|
||||
|
||||
// add TransformTextSwitcher button to editor
|
||||
editor.ui.addButton('TransformTextSwitcher',
|
||||
{
|
||||
label: editor.lang.texttransform.transformTextSwitchLabel,
|
||||
command: 'transformTextSwitch',
|
||||
icon: this.path + 'images/transformSwitcher.png'
|
||||
} );
|
||||
|
||||
// add TransformTextToLowercase button to editor
|
||||
editor.ui.addButton('TransformTextToLowercase',
|
||||
{
|
||||
label: editor.lang.texttransform.transformTextToLowercaseLabel,
|
||||
command: 'transformTextToLowercase',
|
||||
icon: this.path + 'images/transformToLower.png'
|
||||
} );
|
||||
|
||||
// add TransformTextToUppercase button to editor
|
||||
editor.ui.addButton('TransformTextToUppercase',
|
||||
{
|
||||
label: editor.lang.texttransform.transformTextToUppercaseLabel,
|
||||
command: 'transformTextToUppercase',
|
||||
icon: this.path + 'images/transformToUpper.png'
|
||||
} );
|
||||
|
||||
// add TransformTextCapitalize button to editor
|
||||
editor.ui.addButton('TransformTextCapitalize',
|
||||
{
|
||||
label: editor.lang.texttransform.transformTextCapitalizeLabel,
|
||||
command: 'transformTextCapitalize',
|
||||
icon: this.path + 'images/transformCapitalize.png'
|
||||
} );
|
||||
}
|
||||
} );
|
||||
Reference in New Issue
Block a user