SlideShare una empresa de Scribd logo
1 de 69
Descargar para leer sin conexión
HTMLarea → CKEditor
Frans Saris
2
■ developer @beech.it (in the Netherlands)
■ TYPO3 core/extension dev
■ slack/typo3.org: minifranske
■ twitter: @franssaris
■ github: fsaris - frans-beech-it - beechit
Why the switch
to CKEditor?
3
Why the switch to CKEditor?
■ We don’t have to fully maintain it our self
■ Superb browser support
■ Complying with the latest web accessibility standards
■ Inline editing features
■ Advanced Content Filter
4
The big changes
5
Big changes
6
■ Presets in YAML
■ <p> are now saved in database!
■ No <typolink> anymore
■ No automatic migration of existing configs
But why YAML?
7
Why YAML
8
■ CKEditor uses plain javascript for configuration
■ typoscript for BE config is confusing for newcomers
■ A new structure (new start)
separate “processing” and Editor-related configuration
■ Allows options to be extend
but no conditions or unsetting values
Presets
9
What do these presets do?
10
■ Define editor appearance
■ Define what tags and styles are allowed
■ Define what plugin’s to load
■ Define database processing `RTE.proc`
Preset: default
11
●
Preset: minimal
12
●
Preset: full
13
●
So I want my
own preset
14
Add your own preset
15
// Register or own text-element config
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['text-element'] =
'EXT:config_examples/Configuration/RTE/TextElement.yaml';
ext_localconf.php
Configure your own preset
16
# Load default processing options
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
# Minimal configuration for the editor
editor:
config:
toolbarGroups:
- { name: basicstyles, groups: [ basicstyles ] }
removeButtons:
- Underline
- Strike
EXT:config_examples/Configuration/RTE/TextElement.yaml
Configure your own preset
17
editor:
config:
# Limit the height of the editor
height: 200
extraPlugins:
- justify
removePlugins:
- image
YAML
CKEditor js to YAML
CKEDITOR.editorConfig = function( config ) {
config.toolbarGroups = [
{ name: 'basicstyles', groups: [ 'basicstyles' ] }
];
config.removeButtons = 'Underline,Strike';
};
http://ckeditor.com/tmp/4.5.0-beta/ckeditor/samples/toolbarconfigurator/ js
editor:
config:
toolbarGroups:
- { name: basicstyles, groups: [ basicstyles ] }
removeButtons:
- Underline
- Strike
YAML
Define some custom style options
19
editor:
config:
stylesSet:
# block level styles
- { name: "Orange title H2", element: "h2", styles: { color: "orange", background: "blue" } }
- { name: "Orange title H3", element: "h3", styles: { color: "orange", background: "blue" } }
- { name: "Quote / Citation", element: "blockquote" }
- { name: "Code block", element: "code" }
# Inline styles
- { name: "Yellow marker", element: "span", styles: { background-color: "yellow" } }
yaml
Paragraph format options
20
editor:
config:
format_tags: "p;h2;h3;pre"
http://docs.ckeditor.com/#!/guide/dev_format yaml
Migrate existing
config
21
PageTS -> YAML
editor:
config:
toolbar:
- [ 'Bold', 'Italic', 'Underline', '-']
- [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ]
- [ 'NumberedList', 'BulletedList', '-', 'Indent', 'Outdent' ]
- '/'
- [ 'HorizontalRule', 'Link', 'RemoveFormat', '-' ]
- [ 'Copy', 'Cut', 'Paste', '-', 'Undo', 'Redo' ]
extraPlugins:
- justify
RTE.default {
showButtons (
bold, italic, underline,
left, center, right, justifyfull,
orderedlist, unorderedlist, indent, outdent,
line, link, removeformat,
copy, cut, paste, undo, redo
)
toolbarOrder (
bold, italic, underline, bar,
left, center, right, justifyfull,
orderedlist, unorderedlist, bar, indent, outdent, linebreak,
line, link, removeformat, bar,
copy, cut, paste, bar, undo, redo
)
}
pageTS
yaml
Advanced
Content Filter
23
Advanced Content Filter?
24
■ Only tags/classes/styles that are configured are kept
■ Filters content during editing and paste
■ Enabled by default
■ Makes `processing` config most of the times obsolete
“RTE.proc”
Disable Advanced Content Filter
25
editor:
config:
allowedContent: true
YAML
Using your own
preset
26
Set default RTE preset
27
RTE.default.preset = my_config
PageTSconfig
Set preset in TCA
28
'content' => [
'label' => 'LLL:EXT:lang/Res...eneral.xlf:LGL.text',
'config' => [
'type' => 'text',
'cols' => 48,
'rows' => 5,
'enableRichtext' => true,
'richtextConfiguration' => 'minimal',
],
],
Using PageTS to define what specific preset to use
29
RTE {
config {
[table].[field].preset = something
[table].[field].types.[type].preset = something
}
}
RTE {
config {
tt_content {
bodytext {
preset = minimal
types {
textmedia.preset = default
my_ce.preset = full
}
}
}
}
}
Using PageTS to define preset to use
30
Plugins
31
Plugins delivered by TYPO3
32
■ Default set provided by CKEditor
typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/plugins/
■ typo3link
■ quicktables
Using a CKEditor core plugin
33
editor:
extraPlugins:
- justify
YAML
Using external plugins
34
editor:
externalPlugins:
quicktable: { resource:
"EXT:rte_ckeditor/Resources/Public/JavaScript/Plugins/quicktable/plugin.js" }
typo3/sysext/rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml
Adding plugins
35
■ Donwload from //ckeditor.com/addons/plugins
■ Add to EXT:my_ext/Resources/Public/Javascript/Plugins/*
■ Register it in your YAML as external plugin
Create your own
plugin
36
Our goal
37
■ A custom button in the toolbar of the RTE
■ Some magic happening when we click that button
So what do we need
38
■ Our own plugin.js
■ Tell TYPO3 to use our plugin
■ An icon for our button
example_plugin.js
39
'use strict';
(function () {
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
console.log('example_plugin is loaded');
}
});
})();
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Tell TYPO3 to use our plugin
40
# Load default processing options
imports:
- { resource: "EXT:rte_ckeditor/Configuration/RTE/Default.yaml"
}
editor:
# Load my plugin as external plugin
externalPlugins:
example_plugin: { resource: "EXT:...path.../example_plugin.js" }
EXT:config_examples/Configuration/RTE/PluginExample.yaml
Tell TYPO3 to use our plugin
41
// Register or own plugin-example config
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['plugin-example'] =
'EXT:config_examples/Configuration/RTE/PluginExample.yaml';
EXT:config_examples/ext_localconf.php
Tell TYPO3 to use our plugin
42
RTE.default.preset = plugin-example
PageTS
The result
43
So let’s add
a button
44
So let’s add our button
45
'use strict';
(function () {
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
editor.ui.addButton( 'ExamplePlugin', {
label: 'My button',
toolbar: 'basicstyles'
});
}
});
})();
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Select a visible toolbar
46
'use strict';
(function () {
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
editor.ui.addButton( 'ExamplePlugin', {
label: 'My button',
toolbar: 'basicstyles'
});
}
});
})();
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Cool we have a button
47
Add some magic to the button
48
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
editor.ui.addButton( 'ExamplePlugin', {
label: 'My button',
toolbar: 'basicstyles',
command: 'insertTimestamp'
});
editor.addCommand( 'insertTimestamp', {
exec: function( editor ) {}
});
}
});
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Add some magic to the button
49
editor.addCommand( 'insertTimestamp', {
exec: function( editor ) {
var now = new Date();
editor.insertHtml(
'The current date and time is: <em>' +
now.toString() + '</em>'
);
}
});
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
The magic works
50
But we want
an icon
51
Register the icon
52
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
icons: 'exampleplugin',
editor.ui.addButton( 'ExamplePlugin', {
label: 'My button',
toolbar: 'basicstyles',
command: 'insertTimestamp'
});
…
}
});
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Yeah
53
next step
adding some interaction
54
Let’s use the TYPO3 modal
55
CKEDITOR.plugins.add('example_plugin', {
init: function (editor) {
editor.ui.addButton( 'ExamplePlugin', {
label: 'My button',
toolbar: 'basicstyles',
command: 'openExampleModal'
});
editor.addCommand( 'openExampleModal', {
exec: openModal
});
}
});
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Let’s use the TYPO3 modal
56
…
exec: openModal
});
}
});
function openModal(editor) {
require([
'TYPO3/CMS/Backend/Modal'
], function (Modal) {
Modal.show(
'Example plugin',
'hi'
);
});
}
EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
Our modal
57
Get the selected text
58
function openModal(editor) {
var selection = editor.getSelection(),
content = 'No text selected';
if (selection && selection.getSelectedText()) {
content =
'<em>You selected:</em> ' +
selection.getSelectedText();
}
require([
'TYPO3/CMS/Backend/Modal'
], function (Modal) {
Modal.show(
'Example plugin',
content
);
});
}
Some text selected
59
Do something with the selected text
60
require([
'TYPO3/CMS/Backend/Modal'
], function (Modal) {
if (selection && selection.getSelectedText()) {
content = '<em>Remove:</em> ' +
selection.getSelectedText();
Modal.confirm(
'Example plugin',
content
)
} else {
Modal.show(
'Example plugin',
content
);
}
});
Do something with the selected text
61
Modal.confirm(
'Example plugin',
content
).on('confirm.button.cancel', function () {
Modal.dismiss();
}).on('confirm.button.ok', function () {
var range = editor.getSelection().getRanges()[0];
range.deleteContents();
range.select();
Modal.dismiss();
});
And the real interaction
62
Loading stuff over ajax
63
Tell TYPO3 what route you want to use
64
editor:
# Load my plugin as external plugin
externalPlugins:
example_plugin:
resource: "EXT:...path.../example_plugin.js"
route: "configexamples_some_route"
EXT:config_examples/Configuration/RTE/PluginExample.yaml
Open an modal with iframe
65
function openModal(editor) {
var url = editor.config.example_plugin.routeUrl;
require([
'TYPO3/CMS/Backend/Modal'
], function (Modal) {
Modal.advanced({
type: Modal.types.iframe,
title: 'Example plugin',
content: url,
size: Modal.sizes.large
});
});
}
But I don’t want
to switch :(
66
Some things to consider
67
■ Deprecated in TYPO3 8 LTS
■ Moved to FriendsOfTYPO3/rtehtmlarea for 9
■ https://github.com/FriendsOfTYPO3/rtehtmlarea
Questions?
68
And now?
69
■ github.com/frans-beech-it/t3ext-config_examples
■ github.com/netresearch/t3x-rte_ckeditor_image
■ typo3worx.eu/2017/02/configure-ckeditor-in-typo3/
■ docs.typo3.org/typo3cms/extensions/core/Changelog/8.6/Featur
e-79216-AddYAMLConfigurationForCKEditorRTE.html
■ docs.ckeditor.com/#!/api/CKEDITOR.config

Más contenido relacionado

Similar a HTMLarea to CKEditor - create presets and your own plugin for TYPO3

Similar a HTMLarea to CKEditor - create presets and your own plugin for TYPO3 (20)

2017 - TYPO3 CertiFUNcation: Frans Saris - TYPO3 CKeditor for Integrators
2017 - TYPO3 CertiFUNcation: Frans Saris - TYPO3 CKeditor for Integrators2017 - TYPO3 CertiFUNcation: Frans Saris - TYPO3 CKeditor for Integrators
2017 - TYPO3 CertiFUNcation: Frans Saris - TYPO3 CKeditor for Integrators
 
TYPO3 CKEditor for integrators
TYPO3 CKEditor for integratorsTYPO3 CKEditor for integrators
TYPO3 CKEditor for integrators
 
TYPO3 create a CKEditor plugin
TYPO3 create a CKEditor pluginTYPO3 create a CKEditor plugin
TYPO3 create a CKEditor plugin
 
2017 - TYPO3 CertiFUNcation: Frans-Saris - TYPO3 create CKeditor plugin
2017 - TYPO3 CertiFUNcation: Frans-Saris - TYPO3 create CKeditor plugin2017 - TYPO3 CertiFUNcation: Frans-Saris - TYPO3 create CKeditor plugin
2017 - TYPO3 CertiFUNcation: Frans-Saris - TYPO3 create CKeditor plugin
 
TYPO3 + CKEditor: Heaven for TYPO3 Developer & Editor
TYPO3 + CKEditor: Heaven for TYPO3 Developer & EditorTYPO3 + CKEditor: Heaven for TYPO3 Developer & Editor
TYPO3 + CKEditor: Heaven for TYPO3 Developer & Editor
 
TYPO3 6.1. What's new
TYPO3 6.1. What's newTYPO3 6.1. What's new
TYPO3 6.1. What's new
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builder
 
Odoo Experience 2018 - From a Web Controller to a Full CMS
Odoo Experience 2018 - From a Web Controller to a Full CMSOdoo Experience 2018 - From a Web Controller to a Full CMS
Odoo Experience 2018 - From a Web Controller to a Full CMS
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to Griffon
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
Datagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and BackgridDatagrids with Symfony 2, Backbone and Backgrid
Datagrids with Symfony 2, Backbone and Backgrid
 
Backbone.js
Backbone.jsBackbone.js
Backbone.js
 
Mini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico CesMini Curso Django Ii Congresso Academico Ces
Mini Curso Django Ii Congresso Academico Ces
 
IntroJs
IntroJsIntroJs
IntroJs
 
The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202The Ring programming language version 1.8 book - Part 95 of 202
The Ring programming language version 1.8 book - Part 95 of 202
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
Nagios Conference 2013 - Jake Omann - Developing Nagios XI Components and Wiz...
 
Building Your First App with Shawn Mcarthy
Building Your First App with Shawn Mcarthy Building Your First App with Shawn Mcarthy
Building Your First App with Shawn Mcarthy
 
How to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular FrameworkHow to Implement Micro Frontend Architecture using Angular Framework
How to Implement Micro Frontend Architecture using Angular Framework
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

HTMLarea to CKEditor - create presets and your own plugin for TYPO3

  • 2. Frans Saris 2 ■ developer @beech.it (in the Netherlands) ■ TYPO3 core/extension dev ■ slack/typo3.org: minifranske ■ twitter: @franssaris ■ github: fsaris - frans-beech-it - beechit
  • 3. Why the switch to CKEditor? 3
  • 4. Why the switch to CKEditor? ■ We don’t have to fully maintain it our self ■ Superb browser support ■ Complying with the latest web accessibility standards ■ Inline editing features ■ Advanced Content Filter 4
  • 6. Big changes 6 ■ Presets in YAML ■ <p> are now saved in database! ■ No <typolink> anymore ■ No automatic migration of existing configs
  • 8. Why YAML 8 ■ CKEditor uses plain javascript for configuration ■ typoscript for BE config is confusing for newcomers ■ A new structure (new start) separate “processing” and Editor-related configuration ■ Allows options to be extend but no conditions or unsetting values
  • 10. What do these presets do? 10 ■ Define editor appearance ■ Define what tags and styles are allowed ■ Define what plugin’s to load ■ Define database processing `RTE.proc`
  • 14. So I want my own preset 14
  • 15. Add your own preset 15 // Register or own text-element config $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['text-element'] = 'EXT:config_examples/Configuration/RTE/TextElement.yaml'; ext_localconf.php
  • 16. Configure your own preset 16 # Load default processing options imports: - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" } - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" } # Minimal configuration for the editor editor: config: toolbarGroups: - { name: basicstyles, groups: [ basicstyles ] } removeButtons: - Underline - Strike EXT:config_examples/Configuration/RTE/TextElement.yaml
  • 17. Configure your own preset 17 editor: config: # Limit the height of the editor height: 200 extraPlugins: - justify removePlugins: - image YAML
  • 18. CKEditor js to YAML CKEDITOR.editorConfig = function( config ) { config.toolbarGroups = [ { name: 'basicstyles', groups: [ 'basicstyles' ] } ]; config.removeButtons = 'Underline,Strike'; }; http://ckeditor.com/tmp/4.5.0-beta/ckeditor/samples/toolbarconfigurator/ js editor: config: toolbarGroups: - { name: basicstyles, groups: [ basicstyles ] } removeButtons: - Underline - Strike YAML
  • 19. Define some custom style options 19 editor: config: stylesSet: # block level styles - { name: "Orange title H2", element: "h2", styles: { color: "orange", background: "blue" } } - { name: "Orange title H3", element: "h3", styles: { color: "orange", background: "blue" } } - { name: "Quote / Citation", element: "blockquote" } - { name: "Code block", element: "code" } # Inline styles - { name: "Yellow marker", element: "span", styles: { background-color: "yellow" } } yaml
  • 20. Paragraph format options 20 editor: config: format_tags: "p;h2;h3;pre" http://docs.ckeditor.com/#!/guide/dev_format yaml
  • 22. PageTS -> YAML editor: config: toolbar: - [ 'Bold', 'Italic', 'Underline', '-'] - [ 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] - [ 'NumberedList', 'BulletedList', '-', 'Indent', 'Outdent' ] - '/' - [ 'HorizontalRule', 'Link', 'RemoveFormat', '-' ] - [ 'Copy', 'Cut', 'Paste', '-', 'Undo', 'Redo' ] extraPlugins: - justify RTE.default { showButtons ( bold, italic, underline, left, center, right, justifyfull, orderedlist, unorderedlist, indent, outdent, line, link, removeformat, copy, cut, paste, undo, redo ) toolbarOrder ( bold, italic, underline, bar, left, center, right, justifyfull, orderedlist, unorderedlist, bar, indent, outdent, linebreak, line, link, removeformat, bar, copy, cut, paste, bar, undo, redo ) } pageTS yaml
  • 24. Advanced Content Filter? 24 ■ Only tags/classes/styles that are configured are kept ■ Filters content during editing and paste ■ Enabled by default ■ Makes `processing` config most of the times obsolete “RTE.proc”
  • 25. Disable Advanced Content Filter 25 editor: config: allowedContent: true YAML
  • 27. Set default RTE preset 27 RTE.default.preset = my_config PageTSconfig
  • 28. Set preset in TCA 28 'content' => [ 'label' => 'LLL:EXT:lang/Res...eneral.xlf:LGL.text', 'config' => [ 'type' => 'text', 'cols' => 48, 'rows' => 5, 'enableRichtext' => true, 'richtextConfiguration' => 'minimal', ], ],
  • 29. Using PageTS to define what specific preset to use 29 RTE { config { [table].[field].preset = something [table].[field].types.[type].preset = something } }
  • 30. RTE { config { tt_content { bodytext { preset = minimal types { textmedia.preset = default my_ce.preset = full } } } } } Using PageTS to define preset to use 30
  • 32. Plugins delivered by TYPO3 32 ■ Default set provided by CKEditor typo3/sysext/rte_ckeditor/Resources/Public/JavaScript/Contrib/plugins/ ■ typo3link ■ quicktables
  • 33. Using a CKEditor core plugin 33 editor: extraPlugins: - justify YAML
  • 34. Using external plugins 34 editor: externalPlugins: quicktable: { resource: "EXT:rte_ckeditor/Resources/Public/JavaScript/Plugins/quicktable/plugin.js" } typo3/sysext/rte_ckeditor/Configuration/RTE/Editor/Plugins.yaml
  • 35. Adding plugins 35 ■ Donwload from //ckeditor.com/addons/plugins ■ Add to EXT:my_ext/Resources/Public/Javascript/Plugins/* ■ Register it in your YAML as external plugin
  • 37. Our goal 37 ■ A custom button in the toolbar of the RTE ■ Some magic happening when we click that button
  • 38. So what do we need 38 ■ Our own plugin.js ■ Tell TYPO3 to use our plugin ■ An icon for our button
  • 39. example_plugin.js 39 'use strict'; (function () { CKEDITOR.plugins.add('example_plugin', { init: function (editor) { console.log('example_plugin is loaded'); } }); })(); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 40. Tell TYPO3 to use our plugin 40 # Load default processing options imports: - { resource: "EXT:rte_ckeditor/Configuration/RTE/Default.yaml" } editor: # Load my plugin as external plugin externalPlugins: example_plugin: { resource: "EXT:...path.../example_plugin.js" } EXT:config_examples/Configuration/RTE/PluginExample.yaml
  • 41. Tell TYPO3 to use our plugin 41 // Register or own plugin-example config $GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['plugin-example'] = 'EXT:config_examples/Configuration/RTE/PluginExample.yaml'; EXT:config_examples/ext_localconf.php
  • 42. Tell TYPO3 to use our plugin 42 RTE.default.preset = plugin-example PageTS
  • 44. So let’s add a button 44
  • 45. So let’s add our button 45 'use strict'; (function () { CKEDITOR.plugins.add('example_plugin', { init: function (editor) { editor.ui.addButton( 'ExamplePlugin', { label: 'My button', toolbar: 'basicstyles' }); } }); })(); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 46. Select a visible toolbar 46 'use strict'; (function () { CKEDITOR.plugins.add('example_plugin', { init: function (editor) { editor.ui.addButton( 'ExamplePlugin', { label: 'My button', toolbar: 'basicstyles' }); } }); })(); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 47. Cool we have a button 47
  • 48. Add some magic to the button 48 CKEDITOR.plugins.add('example_plugin', { init: function (editor) { editor.ui.addButton( 'ExamplePlugin', { label: 'My button', toolbar: 'basicstyles', command: 'insertTimestamp' }); editor.addCommand( 'insertTimestamp', { exec: function( editor ) {} }); } }); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 49. Add some magic to the button 49 editor.addCommand( 'insertTimestamp', { exec: function( editor ) { var now = new Date(); editor.insertHtml( 'The current date and time is: <em>' + now.toString() + '</em>' ); } }); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 51. But we want an icon 51
  • 52. Register the icon 52 CKEDITOR.plugins.add('example_plugin', { init: function (editor) { icons: 'exampleplugin', editor.ui.addButton( 'ExamplePlugin', { label: 'My button', toolbar: 'basicstyles', command: 'insertTimestamp' }); … } }); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 54. next step adding some interaction 54
  • 55. Let’s use the TYPO3 modal 55 CKEDITOR.plugins.add('example_plugin', { init: function (editor) { editor.ui.addButton( 'ExamplePlugin', { label: 'My button', toolbar: 'basicstyles', command: 'openExampleModal' }); editor.addCommand( 'openExampleModal', { exec: openModal }); } }); EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 56. Let’s use the TYPO3 modal 56 … exec: openModal }); } }); function openModal(editor) { require([ 'TYPO3/CMS/Backend/Modal' ], function (Modal) { Modal.show( 'Example plugin', 'hi' ); }); } EXT:config_examples/Resources/Public/CkEditorPlugins/example_plugin.js
  • 58. Get the selected text 58 function openModal(editor) { var selection = editor.getSelection(), content = 'No text selected'; if (selection && selection.getSelectedText()) { content = '<em>You selected:</em> ' + selection.getSelectedText(); } require([ 'TYPO3/CMS/Backend/Modal' ], function (Modal) { Modal.show( 'Example plugin', content ); }); }
  • 60. Do something with the selected text 60 require([ 'TYPO3/CMS/Backend/Modal' ], function (Modal) { if (selection && selection.getSelectedText()) { content = '<em>Remove:</em> ' + selection.getSelectedText(); Modal.confirm( 'Example plugin', content ) } else { Modal.show( 'Example plugin', content ); } });
  • 61. Do something with the selected text 61 Modal.confirm( 'Example plugin', content ).on('confirm.button.cancel', function () { Modal.dismiss(); }).on('confirm.button.ok', function () { var range = editor.getSelection().getRanges()[0]; range.deleteContents(); range.select(); Modal.dismiss(); });
  • 62. And the real interaction 62
  • 64. Tell TYPO3 what route you want to use 64 editor: # Load my plugin as external plugin externalPlugins: example_plugin: resource: "EXT:...path.../example_plugin.js" route: "configexamples_some_route" EXT:config_examples/Configuration/RTE/PluginExample.yaml
  • 65. Open an modal with iframe 65 function openModal(editor) { var url = editor.config.example_plugin.routeUrl; require([ 'TYPO3/CMS/Backend/Modal' ], function (Modal) { Modal.advanced({ type: Modal.types.iframe, title: 'Example plugin', content: url, size: Modal.sizes.large }); }); }
  • 66. But I don’t want to switch :( 66
  • 67. Some things to consider 67 ■ Deprecated in TYPO3 8 LTS ■ Moved to FriendsOfTYPO3/rtehtmlarea for 9 ■ https://github.com/FriendsOfTYPO3/rtehtmlarea
  • 69. And now? 69 ■ github.com/frans-beech-it/t3ext-config_examples ■ github.com/netresearch/t3x-rte_ckeditor_image ■ typo3worx.eu/2017/02/configure-ckeditor-in-typo3/ ■ docs.typo3.org/typo3cms/extensions/core/Changelog/8.6/Featur e-79216-AddYAMLConfigurationForCKEditorRTE.html ■ docs.ckeditor.com/#!/api/CKEDITOR.config