-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Example] Adjust ckeditor configuration #77
base: master
Are you sure you want to change the base?
Conversation
assets/admin/package.json
Outdated
@@ -8,6 +8,7 @@ | |||
"watch": "webpack --mode development -w" | |||
}, | |||
"dependencies": { | |||
"@ckeditor/ckeditor5-font": "^18.0.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is important that the plugin version is compatible with the ckeditor version used in the project. The ckeditor version of the project can be outputted by executing npm list @ckeditor/ckeditor5-core
.
Maybe important hint. It asks you here you have to say "N". |
59ef217
to
2de7e1d
Compare
@TheCadien We changed this now by adding a new |
I tried this example with // Implement custom extensions here
import {ckeditorPluginRegistry, ckeditorConfigRegistry} from 'sulu-admin-bundle/containers';
import HorizontalLine from '@ckeditor/ckeditor5-horizontal-line/src/horizontalline';
ckeditorPluginRegistry.add(HorizontalLine);
ckeditorConfigRegistry.add((config) => ({
toolbar: [...config.toolbar, 'horizontalLine'],
})); (that is the only code I added to index.js, besides adding "@ckeditor/ckeditor5-horizontal-line" to package.json) But all I get is
What am I missing? Edit: The answer is hidden in the code review comment The plugin needs to match the CKeditor version. |
@ampaze Thx for the response we will try to readd the comment after the 2.4.0 release with the new version. I did also had in mind to validate this things saldy not all ckeditor packages are following this type of versioning. |
Hello, tried many Node version, but can't build the assets.
Tried using docker, & manual build; same issue. Maybe a package-lock is missing in the assets ? |
@benjaminrobinet Please make sure you did update sulu to the latest version which adds a new plugin for transpiling or add the plugin manually: sulu/skeleton#155. Background: babel/babel#14059 |
Hey, what about manipulating the CKEditor itself (i.e. not the config or plugins)? The answer to this question https://stackoverflow.com/questions/57906914/adding-classes-to-links-in-ckeditor suggests accessing Or maybe the base question: How can I allow my editors to select/manipulate the classes of a link in a text field? Sulu uses its own link properties UI, so maybe the solution differs at all. Greets |
@spackmat Personally I would say a content manager should not get into contact with But if possible a developer should take care of it via Still if you want to add classes to some files you would need to create an own plugin or you can use exist options like the |
Hey, thanks for the verbose answer. In that case, the link classes are more of a semantic type, not of a presentational. I wrote about link classes, not CSS classes for a reason. That in mind I strongly disapprove your suspicion that giving editors access to some predefined link types is not primarily a content related decision, although I too saw many of those primarily presentational implementations, which I also never found smart. But think of (inline!) primary and secondary buttons or a marking for different types of links: Internal for the organization, but not inside Sulu vs. really external. Or links with some kind of spoiler or trigger warning icon. Or links that should show a Wikipedia-like preview tooltip. Or whatever marking editors want to give a link from a content perspective and where the presentation is not their business. Or think of other semantic attributes, if you see the class attribute as a mostly presentational feature for some reason. Saying all those do not separate content from presentation and thus are restrained in Sulu IMHO flushes the baby with the bath (is this a valid translation from that german phrase?). For some of my usecases, I can build an own content element (e.g. for the call to action button), but not for others. Primarily because those are inline links, so also abusing the headings feature doesn't help here neither. That brings me back to the basic question in other words: Is there a way to implement such semantic typing of links in Sulu? As The CKEditor originally has that feature, but Sulu replaces it with its own link-property-form. Maybe there is a way to extend that link-property-form, where I already can change a link's target and such? |
2de7e1d
to
cca5e5b
Compare
Hello, I had a similar issue and we solved it in a way. Maybe this helps for future attempts. Here is an example structure you can use in your app.js within your assets for the admin build for your SULU CMS to add your own colors to the font color pallet. Provided that you installed via npm the needed ckeditor5 plugins (if not already present). My problem at this point was, I got confused by the "fontColor" and "colors" structure and didn't realized I needed both encapsulated. Hope it helps.
|
Stumbled on this by doing a search in my preferred search engine. Unfortunately the current documentation does not cover ckeditor in any page: https://docs.sulu.io/en/2.5/search.html?q=ckeditor&check_keywords=yes&area=default |
If you want to define custom text classes, don't forget to add converterPriority, to your definition, even that you don't have element definition without classes. ckeditorConfigRegistry.add((config) => ({
heading: {
options: [
{
model: 'paragraphSmall',
view: { name: 'p', classes: 'small' },
class: 'ck-heading_paragraph_small',
title: 'Paragraph default 14px',
converterPriority: 'high'
},
{model: 'paragraphMedium', view: { name: 'p', classes: 'medium'}, class: 'ck-heading_paragraph_medium', title: 'Paragraph medium 18px', converterPriority: 'high'},
{model: 'paragraphLarge', view: { name: 'p', classes: 'large'}, class: 'ck-heading_paragraph_large', title: 'Paragraph large 22px', converterPriority: 'high'},
{model: 'heading2', view: 'h2', title: 'Heading 2', class: 'ck-heading_heading2'},
{model: 'heading3', view: 'h3', title: 'Heading 3', class: 'ck-heading_heading3'},
{model: 'heading4', view: 'h4', title: 'Heading 4', class: 'ck-heading_heading4'},
]
}
})); |
We are getting the following error, when we try to open the admin area: New line in package.json:
Code in app.js: // Add project specific javascript code and import of additional bundles here:
import {ckeditorPluginRegistry, ckeditorConfigRegistry} from 'sulu-admin-bundle/containers';
// pkg.dependencies: "@ckeditor/ckeditor5-font": "^27.1.0",
// see https://github.com/sulu/sulu-demo/pull/77
import Font from "@ckeditor/ckeditor5-font/src/font";
// import FontColor from "@ckeditor/ckeditor5-font/src/fontcolor";
// import FontColorEditing from "@ckeditor/ckeditor5-font/src/fontcolor/fontcolorediting";
// import FontColorUI from "@ckeditor/ckeditor5-font/src/fontcolor/fontcolorui";
ckeditorPluginRegistry.add(Font);
// ckeditorPluginRegistry.add(FontColor);
// ckeditorPluginRegistry.add(FontColorEditing);
// ckeditorPluginRegistry.add(FontColorUI);
ckeditorConfigRegistry.add((config) => ({
toolbar: [...config.toolbar, 'fontcolor'],
fontColor: {
colors: [
{
color: 'hsl(186, 95%, 32%)',
label: 'Primary blue (dark blue)'
},
{
color: '',
label: 'default (reset)'
},
// add more colors here like above if you want
]
}
})); |
Ok, seems to work with |
@DanielRuf you did install a incompatible version. See comment. #77 (comment) |
@alexander-schranz I know, that's why I had posted an update afterwards =) How and where can we add this crucial information to the documentation? |
@DanielRuf I personally recommend normally go with the prebuild admin JS build aslong as possible and avoid custom builds. We don't want that its normal to have your own Admin Build for simpliest website because fighting down bc breaks in JS dependencies are hard and sadly very common aslong as you go with the prebuild of Sulu you don't need to fight the JS world there :). To your questions, all JavaScript components and frontend of the Admin UI has its own documentation, the ckeditor documentation you will find here: https://jsdocs.sulu.io/2.5/#ckeditor5 |
Unfortunately our design and marketing team needs a single specific addition in the ckeditor. So in our case we have to extend the configuration of ckeditor (and it works so far)
Ah, perfect. I was not aware of that. I had to search in more detail and I guess I found the link to this at https://docs.sulu.io/en/2.5/book/extend-admin.html?highlight=javascript#extend-admin-ui in these big paragraphs. Much to read. But still no mention of ckeditor (which was the word I was searching for) at https://docs.sulu.io/en/2.5/book/extend-admin.html. |
@DanielRuf are you able to share a screenshot of the website or design where you require special CKEditor plugins? I'm very curious about your usages and requirements for it, specially how we maybe can make this work maybe out of the box in future without the need of. |
@alexander-schranz I don't think another abstraction as solution makes sense (and personally as developer I prefer the possibility to freely extend the ckeditor configuration). We add the font plugin (see #77 (comment)) for this: Our design team wants to make single words / text in a specific color without us developers to hardcode this in the React code. The website itself is not yet public. I found the PR here just by accident after searching also in all repos for ckeditor in the text. |
I advocate always Separating Content from Presentation for longevity and flexibility across design changes. I like to ask the question what does the highlighted text mean in point of for blind and color blind people. Explore the meanings of While designers may prefer direct design control, we seek balance here to avoid design decision for the content managers aslong as possible and try to make content management a nobrainer of putting text and media in it. Still things such new tags could be interesting, but educating content managers on these tags is the hard part when we maybe in future want to add beside I personally like that its a little bit hidden the CKEditor docs as mostly people would try to extend it without thinking what is the Sulu way / our recommended way of doing this things are. Why people sure completely free how they build their templates. Not in your special case but |
I can not really follow. That is what a WYSIWYG editor like ckeditor is meant to be used like. The color setting is wanted by the design team to color single words in the wysiwyg text. |
This is just the "yellow" native mark (backkground color, not text color as defined by me via the ckeditor configuration, text color is not comparable to mark[er]), this is not what is needed by the design team and not our goal. I think the reasoning behind the configuration is not really relevant and was not my initial question.
I don't think this is needed. Too many abstraction layers will break in the near future, especially when you deal with third-party APIs like ckeditor. My only problem from the start of our discussion is: the example PRs are not discoverable from the docs and nowhere mentioned, that's all =) I can understand your point of view, but when you have a CMS and a WYSIWYG editor, the separation between presentation (ckeditor configuration is meant to add WYSIWYG features, the example PR does exactly that) and content always fades. That's by nature. Coloring a single word in a sentence is not possible without this approach. I'm ok to disagree here. The native |
@DanielRuf Just to make sure, I dont suggest to use the "yellow" marker but style the |
@@ -9,6 +9,7 @@ | |||
"watch": "webpack --mode development --watch" | |||
}, | |||
"dependencies": { | |||
"@ckeditor/ckeditor5-font": "^27.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is required to use the correct version of a plugin which matche Sulu CKEditor version: #77 (comment)
What's in this PR?
This PR demonstrates how to configure the ckeditor instance which is used for
text_editor
properties. It utilizes theckeditorPluginRegistry
andckeditorConfigRegistry
of Sulu to add and configure the CKEditor 5 font feature.additional plugins need to be added to the
package.json
e.g.:@ckeditor/ckeditor5-font
, the correct version is important:A hint that you installed a wrong version of your plugin is the following error message:
To apply the changes, the administration frontend application needs to be rebuilt by executing
bin/console sulu:admin:update-build
.