CKEditor 4.3 promises to bring CKEditor Widgets.
CKEditor Widgets have been specifically developped for us (see http://dev.ckeditor.com/ticket/9764) and tailored to our specific needs, so we want to get them in immediately, possibly already with a 4.3 Release Candidate.
Back then in December, the proof of concept for Widgets was a requirement and a key argument to choose CKEditor over other alternatives, see #1260052-121: Candidate WYSIWYG editors ff.
Currently it doesn't look like CKEditor 4.3 would also bring us blacklisting support (see #2023629: Remove our CKEditor ACF work-around once ACF supports blacklisting.
But support for #1993928: Language of parts: Introduce a language toolbar button is still on the 4.3 Roadmap, see http://dev.ckeditor.com/ticket/7987.
This blocks:
- #1993928: Language of parts: Introduce a language toolbar button
- #2239419: Include CKEditor's AutoGrow plug-in
See also:
Comment | File | Size | Author |
---|---|---|---|
#35 | ckeditor_4.4-2039163-35.patch | 3.48 MB | Wim Leers |
Comments
Comment #1
Wim LeersThere will first be a beta: http://ckeditor.com/blog/CKEditor-Weekly-for-September-09-2013.
Comment #2
Reinmar CreditAttribution: Reinmar commentedUpdated CKEditor package to: https://github.com/cksource/ckeditor-dev/commit/0e3084a8
Patch contains also a prototype of Drupal's captioned image reusing CKEditor's image2 plugin. It replaces current drupalimagecaption which implements part of the image2's logic itself.
Known issue: Icons that Drupal provides for its buttons in CKEditor's toolbar are not displayed.
Comment #3
Wim LeersHurray, thanks Reinmar! :)
I'm looking into that known issue now and reviewing the changes on the Drupal side :)
Comment #4
Wim LeersTogether with Reinmar and w_walc, I debugged the missing icons and we found the cause:
this.path
used to behttp://yoursite.com/core/modules/ckeditor/js/plugins/drupallink/plugin.js
, but now it's justhttp://yoursite.com/core/modules/ckeditor/js/plugins/drupallink/
. Hence the breakage. This is a bug in CKE 4.3, and they will fix it.I will continue in the mean time with everything else.
Comment #5
Wim LeersReroll that fixes the icons, and makes them HiDPI-enabled as well.
Comment #6
Wim Leers.
Comment #7
Reinmar CreditAttribution: Reinmar commentedThe path has changed because of http://dev.ckeditor.com/ticket/10913. At the beginning we thought that it is a bug, but it turned out to be broken before 10913. The path should not contain a filename and since CKEditor 4.2.2 and 4.3 it will not.
So, to add a button it is now enough to add filename to the path:
Comment #8
Wim Leers#7: great, the patch in #5 already assumes that that is the case, so it will work fine! :)
Comment #9
Reinmar CreditAttribution: Reinmar commentedI'm attaching a full drupalimagecaption plugin.js file with code comments. It's also aligned to the latest changes in CKEditor's image2 plugin.
Comment #10
Wim LeersNote to self: the updated drupalimagecaption plugin.js file works against the latest 4.3, not the 4.3 beta, because bugs have been fixed since the 4.3 beta that we need, so I must update the CKE 4.3 build included in preceding patches, to the latest of https://github.com/cksource/ckeditor-dev/tree/d8, i.e. https://github.com/cksource/ckeditor-dev/commit/aaf6fa42080bf92f38b1be81....
Comment #11
Wim LeersThis issue is now blocked on CKEditor.
Reinmar has graciously updated our code to use CKEditor 4.3, and better yet, gotten rid of our custom
drupalimagecaption
plugin and instead leveraging CKE 4.3'simage2
plugin to achieve the same results, and more (e.g. live image resizing).However,
image2
has several significant regressions:See the "The thing about flexible content styling
" thread in the CKEditor-dev mailing list.
So, for now, postponed.
Comment #12
Wim LeersAs per #11.
Comment #12.0
Wim LeersThis does not block #2027181: Use a CKEditor Widget to create a stellar UX for captioning and aligning images.
Comment #13
Wim Leers4.3 has been released: http://ckeditor.com/blog/CKEditor-4.3-Released.
However, due to #11, we cannot yet start using it.
Comment #14
cosmicdreams CreditAttribution: cosmicdreams commentedWhere do we go from here?
Comment #15
Wim LeersWe wait for the CKE guys to fix this.
Comment #16
effulgentsia CreditAttribution: effulgentsia commentedWould it make sense to update to 4.3 anyway, but still use drupalimagecaption, and then open a new issue for switching to image2?
Comment #17
Wim Leers#16:
drupalimagecaption
would need to be changed significantly, because the Widget API has been changed significantly. (As far as I know at least.)Comment #18
sunAny updates here? Is the CKEditor team aware of the bugs listed in #11, and are they tracked somewhere upstream?
Comment #19
Reinmar CreditAttribution: Reinmar commentedI confirm that CKEditor is aware of bugs listed in #11 :). They are already fixed, but the changes on CKEditor side have not yet been finally reviewed (due to some small pending tasks), so we didn't propose the final solution.
* Ticket on CKEditor's issue tracker: http://dev.ckeditor.com/ticket/11300
* Branch in which we keep the progress of image2 and drupalimagecaption integration: https://github.com/oleq/drupal/tree/ckeditor
Comment #20
sunThanks for the update, @Reinmar!
Based on the upstream issue, we will need to update to 4.4 instead of 4.3.
Would it make sense if we would replace our copy in core with a dev snapshot of https://github.com/oleq/drupal/tree/ckeditor, so we can help with testing, and so as to ensure that we won't run into unexpected issues with 4.4?
Comment #21
Wim Leers@sun: we can't just update to 4.4, because Drupal's custom image plugin would break completely due to changes in the Widget API. I've been closely collaborating with the CKEditor developers on this issue. We're removing as much as possible from Drupal's custom image plugin, and relying instead on CKE >=4.3's
image2
plugin. The custom plugin will continue to exist, but will be a wrapper that is as thin as possible, causing us to use a Drupal-native dialog (and alterable form) instead of a CKEditor dialog.For these reasons, it's more than a simple update, it's a collaboration where we (Drupal) help ensure the CKEditor Widget API is as expressive as it needs to be, where we (Drupal + CKEditor) help make the
image2
as flexible and generic as necessary, so that Drupal can upgrade to the latest version of CKEditor without breaking the existing image integration.Hopefully that's sufficiently clarifying.
Comment #22
Wim LeersOver the past few months, the CKEditor team has been steadily chipping away at fixing all of the remaining things for Drupal:
image2
plugin which allows us to remove almost all complexity in ourdrupalimage
anddrupalimagecaption
plugins for CKEDitor —image2
is also much more complete and much more robust than the code we had (it even supports images indisplay:inline
parents, which was impossible before). All that thedrupalimage
anddrupalimagecaption
plugins have to do now, is selectively extending and overridingimage2
. At a glance:drupalimage
plugin (just like in current HEAD). Thedrupalimage
plugin extendsimage2
with two specific things: handling/requiring thedata-editor-file-uuid
attribute, and integrating with\Drupal\editor\Form\EditorImageDialog
instead of CKEditor's own dialog.90% of the code in
drupalimage
is about integrating with Drupal's dialogs, anddrupalimagecaption
then uses that too.filter_caption
plugin, thedrupalimagecaption
plugin will be loaded automatically (again, just like in current HEAD). Thedrupalimagecaption
plugin extends thedrupalimage
plugin, with again two specific things: handling thedata-caption
&data-align
attributes, and a customized upcast to handle upcasting from a plain<img>
tag withdata-
attributes (image2
's upcasting happens from a full<figure><img><figcaption></figure>
structure, which Drupal doesn't want in its DB).This hugely improves the maintainability of those plugins: much, much easier to understand code, and less logic to maintain. Plus, we get to benefit from future improvements to
image2
at the same time — one example is the fact that this has made images on-the-fly resizable!style
andon*
attributes that Drupal'sfilter_html
performs. http://dev.ckeditor.com/ticket/10202 and http://dev.ckeditor.com/ticket/10276 were committed in the last week, so now we can get rid of that hack. And in fact we have to do it as part of this issue, because our existing hack won't work anymore.Just before posting this patch, I noticed one bug: with the
drupalimagecaption
plugin (which is enabled by default for the "Basic HTML" text format), it's impossible to insert a new image without a caption. I'm looking into that bug. But I don't want to delay any code reviews.The CKEditor developers will review the
drupalimage
anddrupalimagecaption
code also.Comment #23
jessebeach CreditAttribution: jessebeach commentedOh man, this is huge :) I'm glad to see that on balance, the changes in
/core/modules
show a net decline in lines of code:12 files changed, 505 insertions(+), 754 deletions(-)
I'm glad that something so obviously indicated as a hack is being removed from
/core/modules/ckeditor/js/ckeditor.js
. How was this hack resolved?I assume we can now blacklist content with the CKEditor update? I see changes in
generateAllowedContentSetting
that seem to suggest this, but now we also havegetDefaultDisallowedContentConfig
?This is not lovely, but then, that's JavaScript. Would be nice to get callback registration for events, but that's not blocking progress here.
Using ES5 objects and methods worries me here. If this were a straight-up admin-facing feature, it would fit our guidelines. But a site might put a CKEditor format on a comment box and allow images. Now, anyone using IE8 is going to get an error just leaving a comment with an image on the site. I think we need to back off to more common objects and methods.
Comment #24
Wim LeersSee #22, point 2.
The latter only exists in a test, to get the default expected value for
disallowedContent
.The former is "actual code" and lives in the
Internal
CKEditor plugin (which represents all plugins that are part of our CKEditor build). It used to be responsible for callingFilterFormat::getHtmlRestrictions()
and then generating theallowedContent
setting. But now we also need to generatedisallowedContent
fromFilterFormat::getHtmlRestrictions()
. Therefore, I've renamedgenerateAllowedContentSetting()
togenerateACFSettings()
, which now generates bothallowedContent
anddisallowedContent
. Since this is a protected method, this does not constitute an API change.Not sure what you mean by this. Could you clarify?
Using ES5 objects and methods worries me here. […] But a site might put a CKEditor format on a comment box and allow images. […]
If that's the case, they're also going to load
file.js
, which also callsObject.keys()
. Andnode-new-comment-links.js
also usesObject.keys()
.Using
Object.keys()
in these situations was decided a long time ago AFAIK. Let's not reopen that bikeshed in this issue.Comment #25
Wim LeersFrom #22:
This patch fixes that.
It also fixes some JS coding style things. And finally, it removes
'#return_value' => TRUE
from thehasCaption
checkbox, since that leads to0
ortrue
to be returned, rather thanfalse
ortrue
. Better to be consistent then, and just have it return0
or1
, which is the default.Comment #26
cosmicdreams CreditAttribution: cosmicdreams commentedWhat an education reading that.
Yes it's a 3M patch but there's only little change needed to use the new hotness. Nothing seems wrong or out of place.
Comment #27
nod_nitpicks in drupalimagecaption:
extra comma.
we use separate var to declare variables. Comes up in few places.
Would prefer less nesting in the drupalimagecaption code. A few functions don't need to be declared inside other functions.
Comment #28
nod_And about the ES5 things, like wim said, it's good to go. It's the kind of stuff that's easy to polyfill in ie8 module.
Comment #29
jessebeach CreditAttribution: jessebeach commentedLe sigh. The IE8 module is going to be a soft dependency for Drupal 8 then. Not just for this patch given
Object.keys
in file.js. Well, that ship has sailed.Comment #30
Wim Leers#29: We can still choose to change this later — it's just out of scope to be discussing it here.
Comment #31
wiifmComment #32
Reinmar CreditAttribution: Reinmar commentedFirst of all - nice to see all components we developed together during last two years starting to work together :)! But it's a review, so now a darker part :P.
Legend: DI = Drupal image, DIC = Drupal image caption, #Line.
Functional
<img>
without data-caption). That's because none of the conditions inside DIC's upcast handles this case.<img>
. This is very similar to configuring editor to use enter mode BR. This mode is full of unclear cases because it mixes inline content with block content (somehow like MS Word). Setting editor to use this mode is not recommended and I saw that in nested editable it will be handled worse than in normal editable. Therefore I highly recommend making caption a block content container or inline content container. For image2 we chose only inline content.Code
<img>
form (like DIC), it should override allowedContent completely. Otherwise DI will allow figure and figcaption. DIC should override allowedContent too. BTW. This allowedContent should equal this of editdrupalimage command, however, I think that you don't have to set allowedContent for that command at all. The DrupalImage button uses 'image' command which inherits allowedContent from widget, so toolbar configurator should understand that.<img>
elements in any conditions.Other
Disallowed content rules do not have to blacklist style attribute, because style and class attributes are handled separately. So if you didn't allow styles in allowed content rules, then you don't need to disallow them.
Comment #33
Wim Leers#32: thanks for the review!
Functional
Xss::filter()
, minus the block-level content ones.Code
image2
from DIC, since DIC depends on DI, which depends onimage2
already. (I thought that CKEditor did not resolve dependencies, which is why I did things this way.)Other
Done.
Besides the above, also updated to CKEditor 4.4.0, which was released in the mean time.
Comment #34
Reinmar CreditAttribution: Reinmar commentedThree more things:
<p>
and<div>
elements which image2 uses for centering. DI and DIC do not need them so in both cases you can deleteallowedContent.p&div
<br />
s from the caption. Similarly like in a blockless editor (e.g. editor initialized on<h1>
element) in caption enter inserts<br />
s. We were analyzing the possibility to totally block enter, but that would require introducing totally new enter mode and was beyond our capabilities. However, I would like to see this feature one day.All the rest looks good.
Comment #35
Wim Leers#34:
image2
's link support/integration and sent me this snippet of code that does it: https://gist.github.com/Reinmar/84fddafd02bf17bd647c. That's now integrated intodrupalimage/plugin.js
.With that, no known problems remain! :) (FYI: JSHint also reports zero errors.)
Can I has RTBC? :) Will be good to finally close this after many, many months!
Comment #36
Reinmar CreditAttribution: Reinmar commentedPerfecto! :D
Comment #37
webchickWicked, thanks Reinmar!
Given this has sign-off from both Wim (Drupal side) and Reinmar (CKEditor side), I feel comfortable committing this and fixing whatever fallout in subsequent patches. In glancing through the changes outside of core/assets/vendor/ckeditor and .../ckeditor/plugins/ it only seemed like good clean-up that removes a ton of stuff. I did ping nod_ for a review, but wasn't able to catch him. I think though that if there are things that need clean-up after this, it's going to be easier to do in dedicated follow-ups.
Therefore!
Committed and pushed to 8.x. Thanks!
Comment #39
Wim LeersAwesome — glad to finally close this one! This also allowed us to remove the
hackwork-around we had: #2023629: Remove our CKEditor ACF work-around once ACF supports blacklisting.The last important step for CKEditor in Drupal 8 UX-wise is #2239419: Include CKEditor's AutoGrow plug-in.
Comment #40
giorgio79 CreditAttribution: giorgio79 commentedAnother important step would be doing sg with CKEditor's Android incompatibility http://ckeditor.com/support/faq/features#question9
Comment #41
hass CreditAttribution: hass commentedOT, but will we upgrade core ckeditor to v5 after D8 is out or is this postponed to D9 than? Android support sounds crucial to me.
Comment #42
nod_Kinda gray area, minor 4.x releases sure. I think it'll depend on how much API change there'll be between 4.x and 5.x. In my mind it'd be possible to do so in 8.x but it really depends on what 5.x looks like.
Comment #43
yched CreditAttribution: yched commentedFYI : #2268941: Removing caption from a previously captioned image fails to remove the caption-related classes
Comment #44
Reinmar CreditAttribution: Reinmar commentedAs for the Android support, we made a research recently about CKEditor on iOS and Android. We have been surprised because it turned out that CKEditor works out of the box on Chrome on Android. This is more or less the same browser than on desktop and AFAIK it's preinstalled on some Android devices and is available for most of them.
Of course, the support is not perfect, mostly because of the UX. We are willing to improve this by fixing most important bugs, so we are looking for funding of this task, because it will be very demanding and time consuming. That's about CKEditor 4.
As for CKEditor 5, we plan to have real support for most popular mobile environments. This most likely means having totally separate UI for mobiles and desktops. However, we'll never support every available mobile browsers (especially on Android). We will focus only on most promising ones with good support for contenteditable.
The CKEditor 5 design and development process will be made open soon and we invite the Drupal community to participate in it. So far we worked together on most important CKEditor 4 features introduced recently (like ACF and widgets) and the feedback we got helped in making them better even before release. We are sure that the Drupal community can help us in making CKEditor 5 too :).
Some links: