Coder Social home page Coder Social logo

cke5's Introduction

CKEditor5 for REDAXO CMS

Integrates the CKEditor5 into REDAXO CMS.

Screenshot

Features

  • WYSIWYG-Editor
  • Profile configurator with drag and drop support, profiles can be simply clicked together
  • Own fonts can be integrated and managed
  • Image upload category per profile adjustable
  • Media manager type adjustable per profile
  • Extra options allow you to customize the editor
  • The expert mode allows you to develop profiles in source code
  • Placeholders for all backend languages
  • Dark-mode support for REDAXO >= 5.13

Custom REDAXO Link-Widget

Screenshot

  • Linkmap-Support
  • YForm-Datasets
  • Tel: and Mailto: links
  • Medialinks
  • Custom link decorators possible

Editor Features

  • All free vendor plugins integrated
  • only supported formats will be pasted
  • plaintext pasting
  • Transformations allow converting of e.g. shortcuts to speacial chars from (c) to ©
  • Special char selector
  • Image upload into the media pool via drag & drop into the text field

Demo

Screenshot

Profile Editor

Configure your editor as you need it.

Screenshot

Code Examples

Use in general:

Input Code

 <textarea class="form-control cke5-editor" data-profile="default" data-lang="<?php echo \Cke5\Utils\Cke5Lang::getUserLang(); ?>" name="REX_INPUT_VALUE[1]">REX_VALUE[1]</textarea>

Output Code

REX_VALUE[id="1" output="html"]

Further data attributes can be used to control the minimum and maximum height as well as the language:

  • data-max-height
  • data-min-height
  • data-lang

Use in YForm

  • individual attribute field: {"class":"cke5-editor","data-profile":"default","data-lang":"en"}
  • further attributes possible separated by commas

Use in MForm

$mform = new MForm();
$mform->addTextAreaField(1, 
        array(
        'label'=>'Text',
        'class'=>'cke5-editor', 
        'data-lang'=>\Cke5\Utils\Cke5Lang::getUserLang(), 
        'data-profile'=>'default')
        );
echo $mform->show();

Use in MBlock

$id = 1;
$mform = new MForm();
$mform->addFieldset('Accordion');
$mform->addTextField("$id.0.titel", array('label'=>'Titel'));
$mform->addTextAreaField("$id.0.text", 
        array(
        'label'=>'Text',
        'class'=>'cke5-editor', 
        'data-lang'=>\Cke5\Utils\Cke5Lang::getUserLang(), 
        'data-profile'=>'default')
        );
echo MBlock::show($id, $mform->show());

Adding own fonts

Screenshot

To make the specified fonts visible in the backend, they must be loaded as assets in the backend. This can be done, for example, with the boot.php of Project AddOn or backend.css of Theme AddOn. The fonts should be defined in the usual CSS notation in the FontFamily section of the Profile Editor.

Customizing

The display of the editor can be adapted to the frontend output via CSS. For this a CSS file is available in the folder assets/addons/cke5_custom_data

CSS Content-Styles

CKE5 uses some own styles.

Link to Styleguide

The Styles are prefixed with .ck-content. You should add this class to your output element and load the included cke5_content_styles.css form the assets folder.

After installation of this AddOn you can use /assets/addons/cke5/cke5_content_styles.css or better make your own.

Keyboard support

Below is a list of the most important keystrokes supported by CKEditor 5 and its features:

Action PC Mac
Copy Ctrl + C + C
Paste Ctrl + V + V
Undo Ctrl + Z + Z
Redo Ctrl + Y
Ctrl + Shift + Z
+ Y
+ Shift + Z
Bold Ctrl + B + B
Italic Ctrl + I + I
Link Ctrl + K + K
Insert a hard break (e.g. a new paragraph) Enter
Insert a soft break (i.e. a <br>) Shift + Enter
Nest the current list item (when in a list) Tab
When a widget is selected (for example: image, table, horizontal line, etc.)
Insert a new paragraph directly after a widget Enter
Insert a new paragraph directly before a widget Shift + Enter
Display the caret to allow typing directly before a widget /
Display the caret to allow typing directly after a widget /
In a table cell
Move the selection to the next cell Tab
Move the selection to the previous cell Shift + Tab
Insert a new table row (when in the last cell of a table) Tab
Navigate through the table / / /

User interface and navigation

Use the following keystrokes for more efficient navigation in the CKEditor 5 user interface:

Action PC Mac
Close contextual balloons and UI components like dropdowns Esc
Move focus to the visible contextual balloon Tab
Move focus between fields (inputs and buttons) in contextual balloons Tab
Move focus to the toolbar Alt + F10 Alt + F10
(may require Fn)
Navigate through the toolbar / / /
Execute the currently focused button Enter

For Developers

Example Extra Options

{
    "removePlugins": ["Autoformat"],
    "heading": {
        "options": [{
                "model": "paragraph",
                "title": "Paragraph",
                "class": "ck-heading_paragraph"
            },
            {
                "model": "paragrap1tl",
                "view": {
                    "name": "span",
                    "classes": "uk-text-large"
                    
                },
                "title": "Fließtext groß",
                "class": "ck-heading_paragraph"
            },
            {
                "model": "heading1",
                "view": {
                    "name": "h1",
                    "classes": "uk-animation-fade uk-heading-large"   
                },
                "title": "Überschrift 1 sehr groß",
                "class": "ck-heading_heading1"
            }

        ]
    }
}

Example for a custom link decorator

Attention, keys should be lowercase

[{
    "newtab": {
        "mode": "manual",
        "label": "Open in a new tab",
        "attributes": {
            "target": "_blank",
            "rel": "noopener noreferrer"
        }
    }
}]
[{
    "arrowclass": {
        "mode": "manual",
        "label": "Link mit CSS Klasse",
        "defaultValue": "true",
         "attributes": {
            "class": "button light",
        }
    }
}]

Multiple link decorators

[
    {
        "buttonlink": {
            "mode": "manual",
            "label": "Als Button darstellen",
            "attributes": {
                "class": "uk-button uk-button-primary uk-margin-small-bottom"
            }
        },
        "buttonlink_style": {
            "mode": "manual",
            "label": "Link mobil volle Breite",
            "attributes": {
                "class": "uk-width-1-1@s uk-width-auto@m"
            }
        }
    }
]

YForm links

To replace the generated urls like rex_news://1, the following script must be added to the boot.php of the project AddOn. This would require the code for the urls to be modified.

rex_extension::register('OUTPUT_FILTER', function(\rex_extension_point $ep) {
    return preg_replace_callback(
        '@((rex_news|rex_person))://(\d+)(?:-(\d+))?/?@i',
        function ($matches) {
            // table = $matches[1]
            // id = $matches[3]
            $url = '';
            switch ($matches[1]) {
                case 'news':
                    // Example, if the Urls are generated via Url-AddOn  
                    $id = $matches[3];
                    if ($id) {
                       return rex_getUrl('', '', ['news' => $id]); 
                    }
                    break;
                case 'person':
                    // ein anderes Beispiel 
                    $url = '/index.php?person='.$matches[3];
                    break;
            }
            return $url;
        },
        $ep->getSubject()
    );
}, rex_extension::NORMAL);

Profile API

By using the API: Cke5\Creator\Cke5ProfilesApi::addProfile, it is possible to install own profiles beside of the profile editor.

Example:

    $create = \Cke5\Creator\Cke5ProfilesApi::addProfile(
        'profile_name_cke5',
        'API created Cke5 profile',
        '{
           "toolbar": ["link", "rexImage", "|", "undo", "redo", "|", "selectAll", "insertTable", "code", "codeBlock"],
           "removePlugins": ["Alignment", "Font", "FontFamily", "MediaEmbed", "Bold", "Italic", "BlockQuote", "Heading", "Alignment", "Highlight", "Strikethrough", "Underline", "Subscript", "Superscript", "Emoji", "RemoveFormat", "TodoList", "HorizontalLine", "PageBreak"],
           "link": {"rexlink": ["internal", "media"]},
           "image": {
             "toolbar": ["imageTextAlternative", "|", "imageStyle:full", "imageStyle:alignLeft", "imageStyle:alignRight", "imageStyle:alignCenter"],
             "styles": ["full", "alignLeft", "alignRight", "alignCenter"]
           },
           "table": {"toolbar": ["tableColumn", "tableRow", "mergeTableCells", "tableProperties", "tableCellProperties"]},
           "rexImage": {"media_path": "\/media\/"},
           "ckfinder": {"uploadUrl": ".\/index.php?cke5upload=1&media_path=media"},
           "placeholder_en": "Placeholder EN",
           "placeholder_de": "Placeholder DE",
           "codeBlock": {
             "languages": [{"language": "plaintext", "label": "Plain text", "class": ""}, {
               "language": "php",
               "label": "PHP",
               "class": "php-code"
             }]
           }
         }',
        '[{"min-height": 100}, {"max-height": 280}]'
    );
    echo (is_string($create)) ? $create : 'successful profile created';

Disable Autoformat

You can disable the Autoformat-Feature (markdown code replacement) by adding the following option to the extra option section:

{"removePlugins": ["Autoformat"]}

Bugtracker

If you have found a error or maybe you have an idea, You can create a Issue. Before you create a new issue, please search if there already exists an issue with your request, and read the Issue Guidelines (englisch) from Nicolas Gallagher.

Changelog

see CHANGELOG.md

Licenses

AddOn:MIT LICENSE CKEDITOR GPL LICENSE

Author

Friends Of REDAXO

Projekt-Lead

Joachim Dörr

Initiator:

KLXM Crossmedia / Thomas Skerbis

cke5's People

Contributors

aeberhard avatar alxndr-w avatar bio-github avatar crydotsnake avatar dergel avatar eace avatar imgbot[bot] avatar imgbotapp avatar interweave-media avatar joachimdoerr avatar marcohanke avatar nandes2062 avatar schuer avatar skerbis avatar staabm avatar tobiaskrais avatar viewsion avatar ynamite avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cke5's Issues

Editor Sprache ändert sich nicht

Es ist zwar vorgesehen aber die Auswahl einer Sprache für ein Profil wirkt sich nicht aus. Es muss die entsprechende Sprache von dem Folder assets/addons/cke5/vendor/ckeditor5-classic/translations geladen werden. Zudem sollte der Editor automatisch die Backend-Default-Sprache übernehmen sofern keine spezielle Sprache definiert wurde. Hierzu sollte es auch in der Profil-Edit-Maske ein Hinweis geben.

../media vermeiden

Wenn kein MediaManager-Effekt ausgewählt ist, werden die Medien mit ../media eingefügt. Lieber wäre mir /media/

Demo Module für MBlock, MForm etc.

Sollte als Liste vorhanden sein - ggf. mit blick in den Quelltext wie bei den MBlock Beispielen. Es wäre auch schick wenn man die dann aus der Liste heraus installieren können.

Readme Text

Die Readme beinhaltet aktuell nur eine Überschrift. Das ist natürlich etwas dünn.

yForm widget support

Hierzu müssen wir sehr wahrscheinlich ein Plugin für das cke5-link Plugin schreiben das sich darin einklinkt. ggf. lässt sich auch das rex5link plugin dahin gehend erweitern. Muss geprüft werden.

Feature Übersicht

Eine Seite mit einer Feature Übersicht wäre sehr gut, vor allem die Möglichkeit via Drag und Drop Bilder in den Editor ziehen zu können sollte näher erläutert werden.

Notiz: CSS für Bilder aus CKE5

figure.image {
max-width: 100%;
margin-bottom: 1.2em;
}

figure.image img {
max-width: 100%;
height: auto;
}

figure.image.image-style-align-center {
   max-width: 80%;
   margin-left: auto;
   margin-right: auto;
}

figure.image.image-style-align-right,
figure.image.image-style-align-left {
   max-width: 50%;
   margin-bottom: 0.5em;
   margin-top: 0.4em;
}

figure.image.image-style-align-right img,
figure.image.image-style-align-left img {
   max-width: 100%;

}

figure.image figcaption {
   font-size: 0.8em;
   line-height: 1.24em;
   padding-bottom: 0.5em;
}


.image-style-align-left {
   float: left;
   margin-right: 1em;
}
.image-style-align-right {
   float: right;
   margin-left: 1em;
}

Split CKE5 bases JS mit und Profil Editor JS

Momentan ist das JS in eine Datei gegossen, es würde sicher sinn machen das auseinander zu ziehen. Der Editor an sich hat mit dem Profil Edit nicht vie zu tun. Es wäre auch für die Performance besser würde das JS für den Profil-Edit nur auf den Profil-Edit Seiten geladen.

Eigene Stile definieren

gibts sowas im CKE5?
Also Textbereich markieren, Stil auswählen über Dropdown, wird dann in ein voreingestelltes Tag gewrappt mit Klassennamen etc.

Demo Inhalte Mehrsprachig

Momentan sind die Demo-Inhalte nur in deutsch vorhanden, es wäre schick diese auch noch in English bereit zu stellen.

ALLOWED_FIELDS in profile_edit.js nutzen

momentan sind die tags dort noch hart eingebaut, natürlich ist das viel besser wenn die standard tags via data Attribut ausgelesen werden könnten und somit dann an einer zentralen stelle im php gepflegt werden könnten.

Anleitung zur Verwendung

Die Demo ist schick aber man findet keinen Hinweis wie man den Editor einbinden kann. Das sollte durch ein Demo-Modul erledigt werden. Oder eine entsprechende Anleitung im Overview - Ggf. mit eigenem Link. Eventuell auch das Doku Plugin aber das macht dann schon wieder so massig Arbeit...

Custom Schriftarten

Man kann ja bereits Standard-Schriften wählen, es wäre durchaus sinnvoll ginge dies auch mit diversen Webfonts. Diese müssten dann ins Backend eingeladen werden.

Css/jss nur laden wenn nötig

Wäre es möglich die ganzen css/js includes nur dann zu laden, wenn auch ein editor in der aktuellen seite enthalten ist?

Aktuell lädt man hier viel zeug und braucht es oft nicht....

Triggered by redaxo/redaxo#1406

Frontend Helper

Marker und auch Bild-Ausrichtung werden vom Editor via CSS-classes gesetzt. Es wäre gut, wenn man eine Page hätte die einem ein CSS liefert welches man grundlegend an Hand des Config Settings als Vorlage nutzen könnte.

Markdown .?

Prüfen wie und ob es möglich ist mit Markdown arbeiten zu können. Der Editor sollte es können. Ich hab nur noch kein Plan wie...

Mediacategory für drag&drop pro Profil

Momentan werden die via Drag&Drop eingesetzten Bilder in die Media-Category 0 geladen. Es wäre gut wenn man diese pro Profil oder generell wählen könnte.

Umbau des internen JS Triggers von pjax:success zu rex:ready

Da im Core rex:ready als Status getriggert wird und Standard ist, wäre dieser Umbau super, da dies dann auch kompatibel zur YForm wäre, auch wenn es im Moment noch funktioniert. Dadurch wird auch doppeltes unkontrolliertes triggern vermieden.

Wunsch: Stylefilter

Herausfiltern ungewünschter Attribute / Stile ist aktuell nicht vorhanden.

Fehlerhafte Sprachen-Ausgabe

Im Bereich zum Bearbeiten von Profilen werden nicht alle Textbausteine korrekt in der ausgewählten Sprache ausgegeben.
Das sind die Felder:

  • cke5_profile_edit
  • cke5_media_manager_type
  • cke5_media_category

Im konkreten Fall wurden die spanischen statt der deutschen Begriffe ausgegeben.

neuer Linktyp: E-Mail

Es wäre bequem, einen eigenen Button E-Mail Link zu haben. Das "mailto:" von Hand eingeben zu müssen ist irgendwie ein Stilbruch :)

Mediatype für Images pro Profile

Momentan ist es nicht in den Rex-Plugins vorgesehen das Image Types gewählt werden können. Es wäre aber schon gut. Sobald es dies möglich ist wäre es gut, wenn man pro Profil ein Type festlegen könnte.

CKE5 Tabellen Plugin integrieren

Es wäre gut wenn das Tabellen Plugin integriert würde, das ist momentan leider noch nicht freit entwickelt. Aber sobald eine Beta raus ist könnte man mal schauen ob es eingebaut werden kann.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.