Skip to content

Commit

Permalink
Merge pull request #139 from anstiftung/issue-125-replace-ckeditor
Browse files Browse the repository at this point in the history
Issue 125 replace ckeditor
  • Loading branch information
mrothauer authored Feb 15, 2024
2 parents c76593b + 0982547 commit 4899c4c
Show file tree
Hide file tree
Showing 26 changed files with 274 additions and 291 deletions.
5 changes: 4 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ module.exports = {
"jquery": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 2020
},
"ignorePatterns": ["webroot/js/elFinder/"],
"globals": {
"Chart": true,
"ChartDataLabels": true,
"CKEDITOR": true,
"ClipboardJS": true,
"Jodit": true,
"MappedRepairEvents": true,
"PruneCluster": true,
"PruneClusterForLeaflet": true,
Expand Down
6 changes: 3 additions & 3 deletions config/app_config.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
define('CACHE_PERSISTENT_DIR', CACHE_DIR . 'persistent/');
define('CACHE_VIEWS_DIR', CACHE_DIR . 'views/');

define('ALLOWED_TAGS_CKEDITOR_USER', '<a><b><strong><i><img><p><h1><h2><ul><li><hr><em><br>');
define('ALLOWED_TAGS_CKEDITOR_ADMIN', ALLOWED_TAGS_CKEDITOR_USER . '<iframe>');
define('ALLOWED_TAGS_USER', '<a><b><strong><i><br><p><ul><li>'); // für textfelder (zb. additional_contact)
define('ALLOWED_TAGS_EDITOR_USER', '<a><b><strong><i><img><p><h1><h2><h3><ul><ol><li><hr><em><br>');
define('ALLOWED_TAGS_EDITOR_ADMIN', ALLOWED_TAGS_EDITOR_USER . '<iframe>');
define('ALLOWED_TAGS_USER', '<a><b><strong><i><br><p><ul><ol><li>'); // für textfelder (zb. additional_contact)

define('FILES_DIR', '/files/');

Expand Down
8 changes: 8 additions & 0 deletions config/asset_compress.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ paths[] = WEBROOT/node_modules
cachePath = WEBROOT/cache/
filters[] = SimpleCssMin
paths[] = WEBROOT/css
paths[] = WEBROOT/js
paths[] = WEBROOT/node_modules

[_base.css]
Expand All @@ -23,6 +24,9 @@ files[] = @fortawesome/fontawesome-free/css/all.css
files[] = frontend.css
files[] = table.css
files[] = right.css
files[] = elfinder/css/elfinder.full.css
files[] = elfinder/css/theme.css
files[] = jodit/es2021/jodit.css
files[] = featherlight/src/featherlight.css
files[] = featherlight/src/featherlight.gallery.css
files[] = jQuery-Impromptu/dist/jquery-impromptu.css
Expand Down Expand Up @@ -62,6 +66,10 @@ files[] = speakingurl/lib/speakingurl.js
files[] = jquery-slugify/dist/slugify.js
files[] = select2/dist/js/select2.full.js
files[] = select2/dist/js/i18n/de.js
files[] = elfinder/js/elfinder.min.js
files[] = jodit/es2021/jodit.js
files[] = editor.js
files[] = modal-elfinder.js
files[] = detect.js
files[] = clipboard/dist/clipboard.js
files[] = helper.js
Expand Down
83 changes: 0 additions & 83 deletions config/elfinder/elfinder.html

This file was deleted.

1 change: 0 additions & 1 deletion devtools/npm-post-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ cp -R $APP/webroot/node_modules/@fortawesome/fontawesome-free/webfonts $APP/webr
cp -R $APP/webroot/node_modules/jquery-ui/dist/themes/smoothness/images $APP/webroot/cache
cp -R $APP/webroot/node_modules/leaflet/dist/images $APP/webroot/cache

cp $APP/config/elfinder/elfinder.html $APP/webroot/js/elfinder/elfinder.html
cp $APP/config/elfinder/php/connector.minimal.php $APP/webroot/js/elfinder/php/connector.minimal.php
6 changes: 3 additions & 3 deletions plugins/Admin/templates/Knowledges/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
<?php
echo $this->element('cancelAndSaveButton');
?>
<div class="ckeditor-edit">
<div class="editor-edit">
<?php
echo $this->element('ckeditorEdit', [
echo $this->element('editorEdit', [
'value' => $knowledge->text,
'name' => 'Knowledges.text',
'uid' => $uid,
Expand All @@ -80,4 +80,4 @@

</div>

<div class="sc"></div> <?php /* wegen ckeditor */ ?>
<div class="sc"></div> <?php /* wegen editor */ ?>
6 changes: 3 additions & 3 deletions plugins/Admin/templates/Pages/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
echo $this->element('cancelAndSaveButton');
?>

<div class="ckeditor-edit">
<div class="editor-edit">
<?php
echo $this->element('ckeditorEdit', [
echo $this->element('editorEdit', [
'value' => $page->text,
'name' => 'Pages.text',
'uid' => $uid,
Expand All @@ -75,4 +75,4 @@

</div>

<div class="sc"></div> <?php /* wegen ckeditor */ ?>
<div class="sc"></div> <?php /* wegen editor */ ?>
6 changes: 3 additions & 3 deletions plugins/Admin/templates/Posts/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@
<?php
echo $this->element('cancelAndSaveButton');
?>
<div class="ckeditor-edit">
<div class="editor-edit">
<?php
echo $this->element('ckeditorEdit', [
echo $this->element('editorEdit', [
'value' => $post->text,
'name' => 'Posts.text',
'uid' => $uid,
Expand All @@ -87,4 +87,4 @@

</div>

<div class="sc"></div> <?php /* wegen ckeditor */ ?>
<div class="sc"></div> <?php /* wegen editor */ ?>
3 changes: 0 additions & 3 deletions plugins/Admin/templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@
<?php
echo $this->AssetCompress->script('_admin', array('raw' => Configure::read('debug')));

echo $this->Html->script('/node_modules/ckeditor4/ckeditor.js?v4.19.0');
echo $this->Html->script('/node_modules/ckeditor4/adapters/jquery.js?v4.19.0');

echo $this->Html->scriptBlock(
$this->Html->wrapJavascriptBlock(
JS_NAMESPACE.".Admin.init();"
Expand Down
6 changes: 3 additions & 3 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ protected function stripTagsFromFields($entity, $modelName)
$entity->$field = strip_tags($data, ALLOWED_TAGS_USER);
}
} else if ($field == 'text') {
// ckeditor feld heißt normalerweise 'text'
$allowedTags = ALLOWED_TAGS_CKEDITOR_USER;
// editor feld heißt normalerweise 'text'
$allowedTags = ALLOWED_TAGS_EDITOR_USER;
if ($this->isAdmin() && in_array($modelName, ['Post', 'Page', 'Knowledge'])) {
$allowedTags = ALLOWED_TAGS_CKEDITOR_ADMIN;
$allowedTags = ALLOWED_TAGS_EDITOR_ADMIN;
}
if (!is_null($data)) {
$entity->$field = strip_tags($data, $allowedTags);
Expand Down
6 changes: 3 additions & 3 deletions templates/Workshops/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@
</div>


<div class="ckeditor-edit">
<div class="editor-edit">
<?php
echo $this->element('ckeditorEdit', [
echo $this->element('editorEdit', [
'value' => $workshop->text,
'name' => 'Workshops.text',
'uid' => $workshop->uid,
Expand All @@ -141,4 +141,4 @@

</div>

<div class="sc"></div> <?php /* wegen ckeditor */ ?>
<div class="sc"></div> <?php /* wegen editor */ ?>
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
if ($uid === null) {
echo '<p style="margin-bottom: 10px;clear: both;">Um Bilder und Dateien hochzuladen, bitte zuerst speichern.</p>';
$this->element('addScript', ['script' =>
JS_NAMESPACE . ".Helper.initCkeditorWithoutElfinder('".$convertedName."', ".$this->request->getSession()->read('isMobile').");"
JS_NAMESPACE . ".Editor.init('".$convertedName."', ".$this->request->getSession()->read('isMobile').");"
]);
} else {
$this->element('addScript', ['script' =>
JS_NAMESPACE . ".Helper.initCkeditor('".$convertedName."', ".$this->request->getSession()->read('isMobile').");"
JS_NAMESPACE . ".Editor.initWithUpload('".$convertedName."', ".$this->request->getSession()->read('isMobile').");"
]);
}

if (isset($objectType) && isset($uid)) {
$_SESSION['ELFINDER'] = [];
$_SESSION['ELFINDER']['uploadUrl'] = "/files/kcfinder/".$objectType."/".$uid;
$uploadDir = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']."files/kcfinder/".$objectType."/".$uid);
$uploadDir = str_replace('//', '/', $_SERVER['DOCUMENT_ROOT']."/files/kcfinder/".$objectType."/".$uid);
$_SESSION['ELFINDER']['uploadPath'] = $uploadDir;
}

Expand All @@ -27,7 +27,6 @@
'value' => $value,
'label' => '',
'style' => 'width:610px;',
'class' => 'ckeditor'
]
);

Expand Down
4 changes: 2 additions & 2 deletions templates/element/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}

//detail
echo '<div class="ckeditor-text">';
echo '<div class="editor-text">';

if ($showImage) {
if ($type == 'preview') {
Expand All @@ -106,7 +106,7 @@

echo '<br /><br />';

echo '</div>'; // .ckeditor-text
echo '</div>'; // .editor-text
echo '</div>'; // .image-text-wrapper

echo '</div>'; // .text-wrapper
Expand Down
3 changes: 0 additions & 3 deletions templates/layout/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,6 @@

echo $this->AssetCompress->script('_frontend' . ($this->request->getSession()->read('isMobile') ? '_mobile' : ''), ['raw' => Configure::read('debug')]);

echo $this->Html->script('/node_modules/ckeditor4/ckeditor.js?v4.19.0');
echo $this->Html->script('/node_modules/ckeditor4/adapters/jquery.js?v4.19.0');

// add script BEFORE all scripts that are loaded in views (block)
echo $this->Html->scriptBlock(
$this->Html->wrapJavascriptBlock(
Expand Down
Loading

0 comments on commit 4899c4c

Please sign in to comment.