-
Notifications
You must be signed in to change notification settings - Fork 342
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
Custom and configurable ckeditor for mini text editors for title and labels or other usecases #5214
Comments
You've already made the same suggestion as your proposed solution in #4898 (comment), and I haven't changed my mind about my following comment. I think this quickly gets out of hand, resulting in many different configs, and it is not clear from looking at it what it really does. However, I can see that limiting the number HTML tags makes sense. And I could imagine that CKEditor supports that somehow. The first thing that comes to my mind is to remove some plugins using the configuration. This example shows that this is at least possible for the Heading, and stuff like lists are also implemented as plugins. So I could imagine that we could deactivate everything here already, without the need of implementing something like this in the serverside code. |
Yesterday another solution came to my mind: What about using |
@danrot Must say xincludes is for me like saying ignore the problem and tell the developers you need implement it yourself always and you will have no possibility to effect third party bundles editors. |
Ok, I've added this to the wrong issue... But the initial problem here could be solved by a But why I've suggested that, is because you seem to want to combine multiple different settings into a named And by enabling them to do so by using xincludes, we would solve the same problem for other content types as well. I could e.g. imagine that somebody also wants to reuse the presentation values of a smart content in multiple different smart contents. Or would you also create a |
Hi all, I will now do my sulu setup and put up a PR in the next days with code as far as I come. :) |
Different fixed configurations will alway fall short for someone. For example, at the moment I want to add a toolbar button for It is crazy that there is no way to just enable or disable toolbar buttons for the most basic stuff. |
Hello, I am back at it. ckeditorConfigRegistry.add((config) => {
return {
toolbar: ['bold', 'italic'],
}
}); I would like to go with that, but "field" specific (like using params) |
@benjaminrobinet This issue is still open and there is not yet a solution yet to achieve different editors configs in sulu. So currently you can only create a custom field and content type for it: sulu/sulu-demo#79 |
My idea is that the configuration of editors is excluded from the admin build. We load configurations asynchronously and initiate our editors after loading them. Configurations only contain config-related JS, e.g.
So we can do other stuff (e.g. loading different css files for different webspaces) right here too. An use of the configurations could look like this:
These configs will only be loaded when the given property / field (here: "content") is present. |
Upvoted! While a full ckeditor (even enhanced !) is nice to have for articles, a simpler text formatting option (like bold/italic) would make the experience much smoother for users in many other use cases without the need of using things like "html tags in textareas" (meh !). The best implementation I can think of, for now, as already described in the previous comments would be something kind of like : app.js ckeditorPluginRegistry.add(font);
// Enhanced global configuration
ckeditorConfigRegistry.add((config) => ({
toolbar: [...config.toolbar, 'fontSize', 'fontFamily', 'fontColor', 'fontBackgroundColor'],
}));
// Custom configuration
ckeditorConfigRegistry.add('minimal', (config) => {
config.toolbar = ['bold', 'italic'];
}); component.xml <!-- Standard (thus enhanced) ckEditor -->
<property name="content" type="text_editor">
</property>
<!-- Custom profile -->
<property name="content" type="text_editor">
<params>
<param name="editor_profile" value="minimal" />
</params>
</property>
Shoutout to whoever can make this happen ! 😄 |
Problem description
It would be great to have a mini text editor which does only contains inline html elements. The usecase is mostly for titles or labels which contains just some bold, italics words or link:
Example:
Block tags like
p
,ul
,table
,h2
, ... are not allowed inside alabel
tag only inline tags likestrong
,em
,a
,br
, ... are allowed here.In Sulu 1.6. this was possible by configuring
enterMode
toBR
instead ofP
tag to avoid the wrappingp
tag which was used by the SuluFormBundle.Proposed solution
To think bigger it would be great define different configs and use them the following way:
The ckeditor registry could look like this (but better would it maybe comes from the backend):
As I think ckeditor does not support avoiding the
p
tag I would go with removing it in the content type as I think we don't want to implement such logic in the js which personally would prefer to have it also be saved without the p tag:The
strip_p_tags
will replace</p><p>
with<br/><br/>
and remove<p>
and</p>
in the content type.Requirements for MiniEditor:
<p>
or any other tag<h2>{{ block.title|raw }}</h2>
(h2 do not allow p tag inside it only<br>
)The text was updated successfully, but these errors were encountered: