SlideShare ist ein Scribd-Unternehmen logo
1 von 69
Downloaden Sie, um offline zu lesen
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

Weitere ähnliche Inhalte

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

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 IntegratorsTYPO3 CertiFUNcation
 
TYPO3 CKEditor for integrators
TYPO3 CKEditor for integratorsTYPO3 CKEditor for integrators
TYPO3 CKEditor for integratorsFrans Saris
 
TYPO3 create a CKEditor plugin
TYPO3 create a CKEditor pluginTYPO3 create a CKEditor plugin
TYPO3 create a CKEditor pluginFrans Saris
 
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 pluginTYPO3 CertiFUNcation
 
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 & EditorNITSAN Technologies
 
TYPO3 6.1. What's new
TYPO3 6.1. What's newTYPO3 6.1. What's new
TYPO3 6.1. What's newRafal Brzeski
 
Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Apache Calcite Tutorial - BOSS 21
Apache Calcite Tutorial - BOSS 21Stamatis Zampetakis
 
How to create an Angular builder
How to create an Angular builderHow to create an Angular builder
How to create an Angular builderMaurizio Vitale
 
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 CMSElínAnna Jónasdóttir
 
Introduction to Griffon
Introduction to GriffonIntroduction to Griffon
Introduction to GriffonJames Williams
 
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 BackgridGiorgio Cefaro
 
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 Backgrideugenio pombi
 
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 CesLeonardo Fernandes
 
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 202Mahmoud Samir Fayed
 
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...Pantheon
 
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...Nagios
 
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 MongoDB
 
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 FrameworkRapidValue
 

Ähnlich wie 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
 

Kürzlich hochgeladen

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
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 DiscoveryTrustArc
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 

Kürzlich hochgeladen (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

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