Skip to content

Commit

Permalink
MBlock Sortierung + Vendor Update (#8)
Browse files Browse the repository at this point in the history
MBlock Sortierung + Vendor Update
  • Loading branch information
pschuchmann authored Feb 21, 2020
2 parents 13d52d0 + 34d0960 commit 2920235
Show file tree
Hide file tree
Showing 99 changed files with 851 additions and 2,139 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CKEditor AddOn - Changelog
==========================

### Version 4.13.1 - 21. Februar 2020

* Update auf CKEditor v4.13.1 Full
* Der CKEditor friert nun nicht mehr ein bei der Neusortierung in MBlock.

### Version 4.13.0 - 16. Oktober 2019

* Update auf CKEditor v4.13.0 Full
Expand Down
95 changes: 32 additions & 63 deletions assets/redaxo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
CKEDITOR.replaceClass = '';

function rex_ckeditor_get_link_from_linkmap() {
var linkMap = openLinkMap();

$(linkMap).on('rex:selectLink', function(e, linkurl, linktext) {
$(linkMap).on('rex:selectLink', function (e, linkurl, linktext) {
e.preventDefault();
linkMap.close();

Expand All @@ -13,7 +15,7 @@ function rex_ckeditor_get_link_from_linkmap() {
function rex_ckeditor_get_link_from_mediapool() {
var mediapool = openMediaPool('ckeditor_medialink');

$(mediapool).on('rex:selectMedia', function(e, filename) {
$(mediapool).on('rex:selectMedia', function (e, filename) {
e.preventDefault();
mediapool.close();

Expand All @@ -23,12 +25,14 @@ function rex_ckeditor_get_link_from_mediapool() {
}

//CKEDITOR MBLOCK COMPAT
$(document).on('rex:ready', function(e, container) {
container.find('.ckeditor').each(function() {
$(document).on('rex:ready', function (e, container) {

container.find('.ckeditor').each(function () {
rex_ckeditor_init($(this));
});

// dialog changes
CKEDITOR.on('dialogDefinition', function(ev) {
CKEDITOR.on('dialogDefinition', function (ev) {
var dialogName = ev.data.name;
var dialogTabs = ev.data.definition;

Expand All @@ -46,7 +50,7 @@ $(document).on('rex:ready', function(e, container) {
label: 'Medienpool Link',
align: 'center',
style: 'display:inline-block; position: absolute; right: 23px; top: 116px;',
onClick: function() {
onClick: function () {
rex_ckeditor_get_link_from_mediapool();
}
});
Expand Down Expand Up @@ -75,7 +79,7 @@ $(document).on('rex:ready', function(e, container) {
];
var url = infoTab.get('url');
url['className'] = 'rex-url';
url['onKeyUp'] = function() {
url['onKeyUp'] = function () {
this.allowOnChange = false;
var protocolCmb = this.getDialog().getContentElement('info', 'protocol'),
url = this.getValue(),
Expand Down Expand Up @@ -108,11 +112,11 @@ $(document).on('rex:ready', function(e, container) {
['https://\u200E', 'https://'],
['<andere>', ''] //###lang
],
setup: function(data) {
setup: function (data) {
if (data.url)
this.setValue(data.url.protocol || '');
},
commit: function(data) {
commit: function (data) {
if (!data.url)
data.url = {};

Expand All @@ -124,10 +128,10 @@ $(document).on('rex:ready', function(e, container) {
label: 'URL', //###lang
required: true,
className: 'rex-url',
onLoad: function() {
onLoad: function () {
this.allowOnChange = true;
},
onKeyUp: function() {
onKeyUp: function () {
this.allowOnChange = false;
var protocolCmb = this.getDialog().getContentElement('info', 'protocol'),
url = this.getValue(),
Expand All @@ -143,11 +147,11 @@ $(document).on('rex:ready', function(e, container) {

this.allowOnChange = true;
},
onChange: function() {
onChange: function () {
if (this.allowOnChange) // Dont't call on dialog load.
this.onKeyUp();
},
validate: function() {
validate: function () {
var dialog = this.getDialog();

if (dialog.getContentElement('info', 'linkType') && dialog.getValueOf('info', 'linkType') != 'url')
Expand All @@ -164,14 +168,14 @@ $(document).on('rex:ready', function(e, container) {
var func = CKEDITOR.dialog.validate.notEmpty('URL fehlt'); //###lang
return func.apply(this);
},
setup: function(data) {
setup: function (data) {
this.allowOnChange = false;
if (data.url)
this.setValue(data.url.url);
this.allowOnChange = true;

},
commit: function(data) {
commit: function (data) {
// IE will not trigger the onChange event if the mouse has been used
// to carry all the operations #4724
this.onChange();
Expand All @@ -183,7 +187,7 @@ $(document).on('rex:ready', function(e, container) {
this.allowOnChange = false;
}
}],
setup: function(data) {
setup: function (data) {
if (!this.getDialog().getContentElement('info', 'linkType'))
this.getElement().show();
}
Expand All @@ -192,7 +196,7 @@ $(document).on('rex:ready', function(e, container) {
id: 'internallink',
label: 'Interner Link',
style: 'float : right;',
onClick: function() {
onClick: function () {
rex_ckeditor_get_link_from_linkmap();

}
Expand All @@ -201,7 +205,7 @@ $(document).on('rex:ready', function(e, container) {
id: 'medialink',
label: 'Medienpool Link',
style: 'float : right;',
onClick: function() {
onClick: function () {
rex_ckeditor_get_link_from_mediapool();
}
}]
Expand All @@ -217,29 +221,6 @@ $(document).on('rex:ready', function(e, container) {
}); // end dialogDefinition
});

$(document).on('ready', function() {
if (typeof mblock_module === 'object') {
// add callback for mblock
mblock_module.registerCallback('reindex_end', function() {
if ($('.ckeditor').length) {
if (mblock_module.lastAction === 'add_item') {
rex_ckeditor_destroy(mblock_module.affectedItem.find('.ckeditor'));
rex_ckeditor_init_all(mblock_module.affectedItem.find('.ckeditor'));



}
}
});
}
});

function rex_ckeditor_init_all(elements) {
elements.each(function() {
rex_ckeditor_init($(this));
});
}

function rex_ckeditor_init(element) {
if (!element.next().hasClass('ckeditor')) {

Expand Down Expand Up @@ -276,10 +257,8 @@ function rex_ckeditor_init(element) {
editor = document.getElementById(unique_id);
CKEDITOR.replace(editor, currentEditorConfig);



// smart strip/
$('form').submit(function() {
$('form').submit(function () {
if ($('.ckeditor-smartstrip').length) {
var data = CKEDITOR.instances[unique_id].getData();
var doDataUpdate = false;
Expand Down Expand Up @@ -321,27 +300,17 @@ function rex_ckeditor_init(element) {
return true;
}


});

}
}

function rex_ckeditor_destroy(elements) {
elements.each(function() {
let next = $(this).next();
if (next.length && (next.hasClass('ck-editor'))) {
next.remove();
}
});
}
$(document).on('rex:change', function (e, container) {

function rex_ckeditor_pastinit(element, sub_options) {
let next = element.next();
if (next.length && next.hasClass('ckeditor')) {
let editable = next.find('.ckeditor');
if (sub_options[0] != undefined) {
sub_options = sub_options[0];
}
}
}
let textarea = $(container).find('textarea');
let editor = $(container).find('.cke');
let id = $(editor).attr('id').replace('cke_', '');

CKEDITOR.instances[id].destroy();
rex_ckeditor_init(textarea);

});
Loading

0 comments on commit 2920235

Please sign in to comment.