Skip to content
Code-Schnipsel Gruppen Projekte
Commit b092921f erstellt von Florian Bogner's avatar Florian Bogner
Dateien durchsuchen

feat: Further improved plugin management (upload and activation and toolbar compatibility

Übergeordneter a20dc2e8
No related branches found
No related tags found
Keine zugehörigen Merge Requests gefunden
werden angezeigt mit 52 Ergänzungen und 1334 Löschungen
......@@ -223,18 +223,12 @@ define('package/quiqqer/ckeditor4/bin/Editor', [
Settings.getConfig().then(function (config) {
var plugins = config.plugins;
console.log(config);
console.log(plugins);
plugins = self.$parseToolbarToPlugins(toolbar).concat(plugins);
plugins = plugins.unique();
var pluginPath = config.pluginPath;
var extraPlugins = plugins.join(",");
console.log(extraPlugins);
for (var i = 0, len = plugins.length; i < len; i++) {
var pluginName = plugins[i];
......@@ -252,7 +246,7 @@ define('package/quiqqer/ckeditor4/bin/Editor', [
basePath : URL_DIR,
height : height,
width : width,
//toolbar : toolbar,
toolbar : toolbar,
allowedContent : true,
extraAllowedContent : 'div(*)[*]{*}; iframe(*)[*]{*}; img(*)[*]{*}; script(*)[*]{*}',
stylesSet : styles,
......
......@@ -22,6 +22,14 @@
<de><![CDATA[Das angegebene Plugin ist bereits deaktiviert]]></de>
<en><![CDATA[The given plugin is not active]]></en>
</locale>
<locale name="exception.plugin.activate.blacklisted">
<de><![CDATA[Das gewählte Plugin ist nicht kompatibel.]]></de>
<en><![CDATA[The chosen plugin is not compatible.]]></en>
</locale>
<locale name="exception.plugin.install.wrong.format">
<de><![CDATA[Der Inhalt des Zip-Archivs hat eine inkompatible Struktur]]></de>
<en><![CDATA[The content of the zip archive has the wrong structure]]></en>
</locale>
<!--Upload-->
<locale name="window.upload.title">
......
div.cke_dialog_ui_input_select, .cke_dialog_ui_input_select{ width: 100%; }
.select2-drop, .select2-dropdown, .select2-container{ z-index: 100000 !important; }
.select2-dropdown{ margin-left: 8px; }
.select2-chosen{ margin-top: 7px; }
.select2-results__option span{ color: #000; font-size: 12px !important; font-family: Arial; display:block; white-space: nowrap; overflow:hidden; }
\ No newline at end of file
CKEDITOR.dialog.add('ckawesomeDialog', function( editor ) {
function getCKAwesomeIcons(selectList ){
var result = [];
var scriptUrl = editor.fontawesomePath;
$.ajax({
url: scriptUrl,
type: 'get',
dataType: 'html',
async: false,
success: function(response) {
var excludeStyles = [".fa.",".fa",".fa-lg",".fa-2x",".fa-3x",".fa-4x",".fa-5x",".fa-fw",".fa-ul",".fa-ul>",".fa-li",".fa-border",".fa-pull-left",".fa-pull-right",".fa-spin",".fa-pulse",".fa-rotate-90",".fa-rotate-180",".fa-rotate-270",".fa-flip-horizontal",".fa-flip-vertical",".fa-stack",".fa-stack-1x",".fa-stack-2x",".fa-inverse"];
var regxstyles = new RegExp(/\.[a-zA-Z_][\w-_]*[^\.\s\{#:\,;]/,"g" );
var styles = response.match(regxstyles);
styles.sort();
$.each(styles, function( index, value ) {
var xstart=value.substring(0, 3).substring(1);
if (xstart != 'fa' || excludeStyles.indexOf(value) > 0){ return; }
value = value.substring(1);
selectList.add(value, value);
})
},
error: function (jqXHR, exception) {
alert("Error loading Font Awesome css: \n" + scriptUrl);
},
});
}
function getSelectionOptions(selectList, start, inc, many){
var result = [];
var val = start;
result.push(start);
many = many > 0 ? many : 5;
for(var i = 0; i < many; i++){
val += inc;
result.push(val);
}
$.each(result, function( index, value ) {
selectList.add(value, value);
})
}
function formatCKAwesome (icon) {
if (!icon.id) { return icon.text; }
var text = icon.text.replace(/fa-|\.|\-/gi, " ");
var icon = $('<span class="ckawesome_options"><i class="fa ' + icon.element.value + ' fa-fw"></i> ' + text + "</span>");
return icon;
};
return {
title: 'Insert CKAwesome',
minWidth: 200,
minHeight: 200,
contents: [
{
id: 'options',
label: 'Basic Settings',
elements: [
{
type: 'select',
id: 'ckawesomebox',
label: 'Select font Awesome',
validate: CKEDITOR.dialog.validate.notEmpty( "Font Awesome field cannot be empty." ),
items: [[ editor.lang.common.notSet, '' ]],
onLoad: function () {
getCKAwesomeIcons(this);
var selectbx = $('#' + this.getInputElement().getAttribute('id'));
$(selectbx).select2({ width: "100%", templateResult: formatCKAwesome, templateSelection: formatCKAwesome});
},
onShow: function(){
var selectbx = $('#' + this.getInputElement().getAttribute('id'));
$(selectbx).val('').trigger('change') ;
}
},
{
type: 'select',
id: 'textsize',
label: 'Select size',
items: [[ editor.lang.common.notSet, '' ]],
onLoad: function (widget) {
getSelectionOptions(this, 8, 1, 42);
}
},
{
type: "hbox",
padding: 0,
widths: ["80%", "20%"],
children: [
{
id: 'fontcolor',
type: 'text',
label: 'Select color',
onChange: function( element ) {
var idEl = $('#' +this.getInputElement().getAttribute('id'));
idEl.css("background-color", idEl.val());
},
onKeyUp: function( element ) {
var idEl = $('#' + this.getInputElement().getAttribute('id'));
idEl.css("background-color", idEl.val());
},
onShow: function(){
var idEl = $('#' + this.getInputElement().getAttribute('id'));
idEl.css("background-color", "");
}
},
{
type: "button",
id: "fontcolorChooser",
"class": "colorChooser",
label: "Color",
style: "margin-left: 8px",
onLoad: function () {
this.getElement().getParent().setStyle("vertical-align", "bottom")
},
onClick: function () {
editor.getColorFromDialog(function (color) {
color && this.getDialog().getContentElement("options", "fontcolor").setValue( color );
this.focus()
}, this)
}
}
]
}
]
},
],
onOk: function() {
var dialog = this;
var cka = editor.document.createElement( 'span' );
var cka_size = dialog.getValueOf( 'options', 'textsize' );
var cka_color = dialog.getValueOf( 'options', 'fontcolor' );
var cka_class = "fa fa-fw " + dialog.getValueOf( 'options', 'ckawesomebox' );
var cka_style = ( cka_size != '' ? 'font-size: '+cka_size+'px;' : '' ) + ( cka_color != '' ? 'color: '+cka_color+';' : '' ) ;
cka.setAttribute( 'class', cka_class );
if ( cka_style ) cka.setAttribute( 'style', cka_style );
editor.insertElement( cka );
}
};
});
plugins/ckeditor4/ckawesome/icons/ckawesome.png

1,49 KiB

/**
* CKAwesome
* =========
* http://blackdevelop.com/io/ckawesome/
*
* Copyright (C) 2017 by Blackdevelop.com
* Licence under GNU GPL v3.
*/
CKEDITOR.on('instanceReady',function () { CKEDITOR.document.appendStyleSheet(CKEDITOR.plugins.getPath('ckawesome') + 'resources/select2/select2.full.min.css'); });
CKEDITOR.on('instanceReady',function () { CKEDITOR.document.appendStyleSheet(CKEDITOR.plugins.getPath('ckawesome') + 'dialogs/ckawesome.css'); });
CKEDITOR.scriptLoader.load(CKEDITOR.plugins.getPath('ckawesome') + 'resources/select2/select2.full.min.js');
CKEDITOR.dtd.$removeEmpty.span = 0;
CKEDITOR.plugins.add('ckawesome', {
requires: 'colordialog',
icons: 'ckawesome',
init: function(editor) {
var config = editor.config;
editor.fontawesomePath = config.fontawesomePath ? config.fontawesomePath : CKEDITOR.plugins.getPath('ckawesome') + 'fontawesome/css/font-awesome.min.css';
CKEDITOR.document.appendStyleSheet(editor.fontawesomePath);
editor.addContentsCss(editor.fontawesomePath);
CKEDITOR.dialog.add('ckawesomeDialog', this.path + 'dialogs/ckawesome.js');
editor.addCommand( 'ckawesome', new CKEDITOR.dialogCommand( 'ckawesomeDialog', { allowedContent: 'span[class,style]{color,font-size}(*);' }));
editor.ui.addButton( 'ckawesome', {
label: 'Insert CKAwesome',
command: 'ckawesome',
toolbar: 'insert',
});
}
});
\ No newline at end of file
.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
Dieser Diff ist reduziert.
/.gitattributes export-ignore
/.gitignore export-ignore
/LICENSE export-ignore
/README.md export-ignore
/ckeditortablecellsselection.gif export-ignore
.idea
The MIT License (MIT)
Copyright (c) 2016 Valerij Ivashchenko
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# CKEditorTableCellsSelection
CKEditor plugin for intuitive table cells selection (like MS Excel or Google Docs).
This is wrapper for CKEditor about [tablecellsselection jQuery plugin](https://github.com/likemusic/tablecellsselection)
![CKEditorTableCellsSelection](ckeditortablecellsselection.gif)
#Usage example
```javascript
CKEDITOR.replace( 'editor1',{
extraPlugins:'ckeditortablecellsselection'
});
```
For more info see ["Installing Plugins" official documentation](http://docs.ckeditor.com/#!/guide/dev_plugins)
# TODO
Integrate with CKEditor Selection API.
# Licence
The MIT License (MIT).
plugins/ckeditor4/ckeditortablecellsselection/ckeditortablecellsselection.gif

496 KiB

Dieser Diff ist reduziert.
CKEDITOR.plugins.add('ckeditortablecellsselection', {
init: function (editor) {
var pluginDirectory = this.path;
//add custom css
editor.addContentsCss(pluginDirectory + 'styles/tablecellsselection.css');
//add custom script
CKEDITOR.scriptLoader.load(pluginDirectory + 'js/tablecellsselection.js');
//editor.ui.addToolbarGroup('tables',0);//todo: what sens if we cand add it dinamic at runtime (used predefined or user config)
//---------- Handlers
//--- LOAD
/*editor.on('loaded',function(event){
console.log('loaded');
});*/
/*editor.on('instanceReady',function(event) {
console.log('instanceReady');
});*/
/* //--- SNAPSHOT
editor.on('getSnapshot',function(event){
console.log('getSnapshot');
});
//todo: set tableCellsSelection here for undo/redo (delete on change)
editor.on('loadSnapshot',function(event){
console.log('loadSnapshot');
});
editor.on('lockSnapshot',function(event){
console.log('lockSnapshot');
});
editor.on('saveSnapshot',function(event){
console.log('saveSnapshot');
});
editor.on('unlockSnapshot',function(event){
console.log('unlockSnapshot');
});
editor.on('updateSnapshot',function(event){
console.log('updateSnapshot');
});
//--- MODE
editor.on('beforeModeUnload',function(event){
console.log('beforeModeUnload');
});
editor.on('beforeSetMode',function(event){
console.log('beforeSetMode');
});
editor.on('mode',function(event){
console.log('mode');
});
*/
//--- CONTENT DOM
editor.on('contentDom', function (event) {
//console.log('contentDom');
initTablesSelection(event.editor);
});
editor.on('contentDomUnload', function (event) {
//console.log('contentDomUnload');
var document = event.editor.document;
if (!document) return;
destroyTablesSelection($(document.$));
});
/*editor.on('contentDomInvalidated',function(event){
console.log('contentDomInvalidated');
});*/
//--- CHANGE
//on change make all tables selectable (tableCellsSelection-jquery-plugin support multiple initialization on same DOM-node)
editor.on('change', function (event) {
//console.log('change');
initTablesSelection(event.editor);
});
//--- INSERT
/*editor.on('insertHtml',function(event){
console.log('insertHtml');
});
editor.on('afterInsertHtml',function(event){
console.log('afterInsertHtml');
});
editor.on('insertElement',function(event){
console.log('insertElement');
});
editor.on('insertText',function(event){
console.log('insertText');
});
//--- COPY/PASTE
editor.on('paste',function(event){
console.log('afterPaste');
});
editor.on('afterPaste',function(event){
console.log('afterPaste');
});
*/
//--- DATA
//From magicline-ckeditor-plugin
// Thanks to that, an editor never yields data polluted by the box.
// Listen with very high priority, so line will be removed before other
// listeners will see it.
//при получении данных - удаляем классы добавленные jquery-плагином для эмуляции выделения ячеек
//todo: сделать тоже самое при getSnapshot, по идее тогда не будут сохраняться выделения для undo
editor.on('beforeGetData', function (event) {
//console.log('beforeGetData');
var document = event.editor.document;
if (!document) return;
var $document = $(document.$);
//чистим DOM от добавленных классов и других служебных изменений
$().tableCellsSelection('removeDocumentHtmlChanges', $document);
editor.once('getData', function () {
$().tableCellsSelection('addDocumentHtmlChanges', $document);
}, null, null, 1000);
}, null, null, 0);
/*editor.on('getData',function(event){
console.log('getData');
});
editor.on('dataFiltered',function(event){
console.log('dataFiltered');
});
editor.on('dataReady',function(event){
console.log('dataReady');
});
editor.on('setData',function(event){
console.log('setData');
});
*/
//--- FORMAT
/*editor.on('toDataFormat',function(event){
console.log('toDataFormat');
});
editor.on('toHtml',function(event){
console.log('toHtml');
});
//--- FOCUS/BLUR
editor.on('blur',function(event){
console.log('blur');
});
editor.on('focus',function(event){
console.log('focus');
});
//--- SELECTION
editor.on('selectionChange',function(event){
console.log('selectionChange');
});
*/
//todo: проверить нет ли повторного навешивания обработчика событий при редактировании и undo/redo
function initTablesSelection(editor) {
$document = $(editor.document.$);
var $tables = $document.find('table');
//инициализируем таблицы
if ($tables.length > 0) $tables.tableCellsSelection();
//и вешаем обработчик
//this.$table.off('copy');
/*var eventName = 'selectionchange.cellsselector';
$tables.on(eventName,onTableCellSelectionChange);
function onTableCellSelectionChange(event){
editor.fire( 'selectionChange', {
selection: editor.getSelection(),
path: editor.elementPath()
});
}*/
}
function destroyTablesSelection($document) {
var $tables = $document.find('table');
if ($tables.length > 0) $tables.tableCellsSelection('destroy');
}
//Overwrite tabletools-plugin commands
addCmd('cellMerge', createDef({
allowedContent: 'td[colspan,rowspan]',
requiredContent: 'td[colspan,rowspan]',
exec: function (editor) {
//replace tabletools>mergeCells() to mergeCellsByPlugin()
placeCursorInCell(mergeCellsByPlugin(editor.getSelection()), true);
}
}));
/* overwrite tabletools context menu items */
// If the "menu" plugin is loaded
if (editor.getMenuItem) {
var tableCellMenuItem = editor.getMenuItem('tablecell');
var prevGetItemsFunction = tableCellMenuItem.getItems;
tableCellMenuItem.getItems = function () {
//получаем предыдущие значения
var ret = prevGetItemsFunction();
var selection = editor.getSelection(),
cells = getSelectedCellsByTableCellsSelectionPlugin(selection);
//заменяем необходимые на свои
ret.tablecell_merge = mergeCellsByPlugin(selection, null, true) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;//объединение ячеек
ret.tablecell_properties = cells.length > 0 ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED;
return ret;
};
}
//---------- Helpers
/*full copy of tabletools>mergeCells() except:
- replace getSelectedCells() to getSelectedCellsByTableCellsSelectionPlugin();
*/
function mergeCellsByPlugin(selection, mergeDirection, isDetect) {
//var cells = getSelectedCells( selection );
var cells = getSelectedCellsByTableCellsSelectionPlugin(selection);
// Invalid merge request if:
// 1. In batch mode despite that less than two selected.
// 2. In solo mode while not exactly only one selected.
// 3. Cells distributed in different table groups (e.g. from both thead and tbody).
var commonAncestor;
if (( mergeDirection ? cells.length != 1 : cells.length < 2 ) || ( commonAncestor = selection.getCommonAncestor() ) && commonAncestor.type == CKEDITOR.NODE_ELEMENT && commonAncestor.is('table'))
return false;
var cell,
firstCell = cells[0],
table = firstCell.getAscendant('table'),
map = CKEDITOR.tools.buildTableMap(table),
mapHeight = map.length,
mapWidth = map[0].length,
startRow = firstCell.getParent().$.rowIndex,
startColumn = cellInRow(map, startRow, firstCell);
if (mergeDirection) {
var targetCell;
try {
var rowspan = parseInt(firstCell.getAttribute('rowspan'), 10) || 1;
var colspan = parseInt(firstCell.getAttribute('colspan'), 10) || 1;
targetCell = map[mergeDirection == 'up' ? ( startRow - rowspan ) : mergeDirection == 'down' ? ( startRow + rowspan ) : startRow][
mergeDirection == 'left' ?
( startColumn - colspan ) :
mergeDirection == 'right' ? ( startColumn + colspan ) : startColumn];
} catch (er) {
return false;
}
// 1. No cell could be merged.
// 2. Same cell actually.
if (!targetCell || firstCell.$ == targetCell)
return false;
// Sort in map order regardless of the DOM sequence.
cells[( mergeDirection == 'up' || mergeDirection == 'left' ) ? 'unshift' : 'push'](new CKEDITOR.dom.element(targetCell));
}
// Start from here are merging way ignorance (merge up/right, batch merge).
var doc = firstCell.getDocument(),
lastRowIndex = startRow,
totalRowSpan = 0,
totalColSpan = 0,
// Use a documentFragment as buffer when appending cell contents.
frag = !isDetect && new CKEDITOR.dom.documentFragment(doc),
dimension = 0;
for (var i = 0; i < cells.length; i++) {
cell = cells[i];
var tr = cell.getParent(),
cellFirstChild = cell.getFirst(),
colSpan = cell.$.colSpan,
rowSpan = cell.$.rowSpan,
rowIndex = tr.$.rowIndex,
colIndex = cellInRow(map, rowIndex, cell);
// Accumulated the actual places taken by all selected cells.
dimension += colSpan * rowSpan;
// Accumulated the maximum virtual spans from column and row.
totalColSpan = Math.max(totalColSpan, colIndex - startColumn + colSpan);
totalRowSpan = Math.max(totalRowSpan, rowIndex - startRow + rowSpan);
if (!isDetect) {
// Trim all cell fillers and check to remove empty cells.
if (trimCell(cell), cell.getChildren().count()) {
// Merge vertically cells as two separated paragraphs.
if (rowIndex != lastRowIndex && cellFirstChild && !( cellFirstChild.isBlockBoundary && cellFirstChild.isBlockBoundary({br: 1}) )) {
var last = frag.getLast(CKEDITOR.dom.walker.whitespaces(true));
if (last && !( last.is && last.is('br') ))
frag.append('br');
}
cell.moveChildren(frag);
}
i ? cell.remove() : cell.setHtml('');
}
lastRowIndex = rowIndex;
}
if (!isDetect) {
frag.moveChildren(firstCell);
firstCell.appendBogus();
if (totalColSpan >= mapWidth)
firstCell.removeAttribute('rowSpan');
else
firstCell.$.rowSpan = totalRowSpan;
if (totalRowSpan >= mapHeight)
firstCell.removeAttribute('colSpan');
else
firstCell.$.colSpan = totalColSpan;
// Swip empty <tr> left at the end of table due to the merging.
var trs = new CKEDITOR.dom.nodeList(table.$.rows),
count = trs.count();
for (i = count - 1; i >= 0; i--) {
var tailTr = trs.getItem(i);
if (!tailTr.$.cells.length) {
tailTr.remove();
count++;
continue;
}
}
return firstCell;
}
// Be able to merge cells only if actual dimension of selected
// cells equals to the caculated rectangle.
else {
return ( totalRowSpan * totalColSpan ) == dimension;
}
}
//---------- Helpers > plugin
/**
* Return selected cells by tableCellsSelection-jquery-plugin
*
* @param selection
* @returns {Array}
*/
function getSelectedCellsByTableCellsSelectionPlugin(selection) {
var ranges = selection.getRanges();
var range = ranges[0];
var startNode = range.getCommonAncestor();
var table = startNode.getAscendant('table', true);
var $selectedCells = $(table.$).tableCellsSelection('selectedCells');
var ret = [];
//jquery to ckeditor.dom.element[]
for (var i = 0; i < $selectedCells.length; i++) {
ret[i] = new CKEDITOR.dom.element($selectedCells[i]);
}
return ret;
}
//---------- Helpers > Imported
//from other plugins
//---------- Helpers > Imported > tabletools plugin
function createDef(def) {
return CKEDITOR.tools.extend(def || {}, {
contextSensitive: 1,
refresh: function (editor, path) {
this.setState(path.contains({
td: 1,
th: 1
}, 1) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED);
}
});
}
function addCmd(name, def) {
var cmd = editor.addCommand(name, def);
editor.addFeature(cmd);
}
// Remove filler at end and empty spaces around the cell content.
function trimCell(cell) {
var bogus = cell.getBogus();
bogus && bogus.remove();
cell.trim();
}
function placeCursorInCell(cell, placeAtEnd) {
var docInner = cell.getDocument(),
docOuter = CKEDITOR.document;
// Fixing "Unspecified error" thrown in IE10 by resetting
// selection the dirty and shameful way (#10308).
// We can not apply this hack to IE8 because
// it causes error (#11058).
if (CKEDITOR.env.ie && CKEDITOR.env.version == 10) {
docOuter.focus();
docInner.focus();
}
var range = new CKEDITOR.dom.range(docInner);
if (!range['moveToElementEdit' + ( placeAtEnd ? 'End' : 'Start' )](cell)) {
range.selectNodeContents(cell);
range.collapse(placeAtEnd ? false : true);
}
range.select(true);
}
function cellInRow(tableMap, rowIndex, cell) {
var oRow = tableMap[rowIndex];
if (typeof cell == 'undefined')
return oRow;
for (var c = 0; oRow && c < oRow.length; c++) {
if (cell.is && oRow[c] == cell.$)
return c;
else if (c == cell)
return new CKEDITOR.dom.element(oRow[c]);
}
return cell.is ? -1 : null;
}
}
});
\ No newline at end of file
.tcs::selection{
background-color: transparent;
}
.tcs td:not(.tcs-selection-enabled) > *,
.tcs th:not(.tcs-selection-enabled) > *,
.tcs td:not(.tcs-selection-enabled),
.tcs th:not(.tcs-selection-enabled){
-webkit-user-select: none !important;
-khtml-user-select: none !important;
-moz-user-select: none !important;
-ms-user-select: none !important;
user-select: none !important;
}
.tcs tr::selection,
.tcs td:not(.tcs-selection-enabled) > *::selection,
.tcs th:not(.tcs-selection-enabled) > *::selection,
.tcs td:not(.tcs-selection-enabled)::selection,
.tcs th:not(.tcs-selection-enabled)::selection,
.tcs br::selection{
background-color: transparent;
}
.tcs tr::-moz-selection, .tcs td:not(.tcs-selection-enabled)::-moz-selection, .tcs th:not(.tcs-selection-enabled)::-moz-selection{
background-color: transparent;
}
.tcs .tcs-selected:not(.sel-from){
border: 1px double #4887C7;
background-color: rgba(51, 122, 183, 0.2) !important;
}
\ No newline at end of file
......@@ -22,14 +22,19 @@ class Manager
protected $dependencies;
/**
* List of plugins which should be installed
* List of plugins which should not be installed
*
* @var array
*/
protected $blacklist = array(
"divarea",
"copyformatting"
"copyformatting",
"ckawesome",
"ckeditortablecellsselection",
"enhancedcolorbutton",
"footnotes"
);
......@@ -171,7 +176,7 @@ class Manager
}
/**
* Returns all installed plugins
* Returns all installed (not active) plugins
*
* @return string[] - array of plugin names
*/
......@@ -233,7 +238,29 @@ class Manager
throw new Exception(array("quiqqer/ckeditor4", "exception.install.file.extract.failed"));
}
foreach (scandir($tmpDir . "/content") as $entry) {
// Scan dir and remove '.' and '..'
$contents = scandir($tmpDir . "/content");
foreach (array_keys($contents, ".", true) as $key) {
unset($contents[$key]);
}
foreach (array_keys($contents, "..", true) as $key) {
unset($contents[$key]);
}
// Check if the zip contains only one folder
if (count($contents) !== 1) {
throw new Exception(array(
"quiqqer/ckeditor4",
"exception.plugin.install.wrong.format"
));
}
// Process the content
foreach ($contents as $entry) {
if ($entry == "." || $entry == "..") {
continue;
}
......@@ -279,6 +306,13 @@ class Manager
$pluginName = Orthos::clearPath($pluginName);
$pluginName = str_replace("/", "", $pluginName);
if (in_array($pluginName, $this->blacklist)) {
throw new Exception(array(
"quiqqer/ckeditor4",
"exception.plugin.activate.blacklisted"
));
}
if (!is_dir($this->installedPluginDir . "/" . $pluginName)) {
throw new Exception(array("quiqqer/ckeditor4", "exception.plugin.activate.plugin.not.found"));
}
......@@ -540,6 +574,11 @@ class Manager
}
}
/**
* Gets the plugin dirctory URL path
*
* @return mixed
*/
public function getPluginUrlPath()
{
// Build the web reachable path for the plugin directory
......
0% oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren