-
-
Notifications
You must be signed in to change notification settings - Fork 555
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
XWIKI-17664: When adding an annotation the focus should be inside WYSIWYG by default #3694
Conversation
…IWYG by default * Added a comment to explain a line of code that doesn't work with CKEditor anymore * Added a CKE config change so that it gets focus when loaded.
Assigning surli to this ticket since he reviewed and merged #3239 which was a very similar solution. |
// If the WYSIWYG editor used is CKEditor, we make sure its input gets focused as soon as it's loaded | ||
// Note that this CKE config is easier than having to handle custom eventListeners. | ||
// As of 17.0.0, this does not interfere with the inline editor, so this solution is okay. | ||
if(typeof CKEDITOR !== 'undefined') { |
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.
@mflorea I need your input there, is that the proper way to detect CKEditor?
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.
Note that this is the same as the way we used at 3b2b6f3 . If this is not a correct way, we would need to fix that place too.
According to tests on my local instance this works but I cannot attest to the stability of this solution.
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.
Hmm actually in the link you provided @mflorea made some comments about this check and about startupFocus.
Feels like it could be better to put that in an internal library that we would reuse where needed, and so if we need or want to change the way to perform this, we wouldn't need to check everywhere.
wdyt? does it worth it?
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.
As I said on my comment for 3b2b6f3 , I think it's wrong to hard-code the CKEditor usage. The solution should be generic, for any WYSIWYG editor:
- either by setting some attribute on the text area that is enhanced by CKEditor, before the WYSIWYG editor is loaded, and having some code in a CKEditor plugin that reacts to that attribute
- or by triggering some generic event that a CKEditor plugin can listen to and react
- or, if the previous two options are not possible, introduce some generic WYSIWYG editor JavaScript API that we implement for now in a CKEditor plugin, but this requires more work
…IWYG by default * (WIP)
…IWYG by default * Reverted unwanted change (WIP)
…IWYG by default (WIP)
…IWYG by default * Implemented a solution that does not assume there's CKEditor
…IWYG by default * Fixed codestyle
…IWYG by default * Removed uneeded change
In the last few commits, I implemented a new solution:
I added comments in the annotation and comment module templates to explain what is this weird assignation. The comments refer to CKEditor for the sake of clarity because as of now it's the only implementation of an editor using this config. The extra cost for other editors is only setting a boolean that won't be used. @mflorea Does this implementation look okay to you? Note that I included a fix on the code that was not in the PR initially. We want to keep things consistent, IMO it makes sense to include it in this very PR since it's not a lot of lines. Here is a quick demo of the updated changes: 2024-12-17.17-01-54.mp4Note that in order to make it work, I had to disable query caching in my browser, it got me stuck for a while (I was refreshing the page cache with Ctrl+Shift+R but it wasn't enough). |
...latform-annotation/xwiki-platform-annotation-ui/src/main/resources/AnnotationCode/Script.xml
Outdated
Show resolved
Hide resolved
...-platform-ckeditor/xwiki-platform-ckeditor-ui/src/main/resources/CKEditor/VelocityMacros.xml
Outdated
Show resolved
Hide resolved
...ingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/commentfield.vm
Outdated
Show resolved
Hide resolved
...xwiki-platform-ckeditor/xwiki-platform-ckeditor-ui/src/main/resources/CKEditor/EditSheet.xml
Outdated
Show resolved
Hide resolved
@@ -356,6 +356,8 @@ | |||
|
|||
#macro(displayAnnotationProperty $annotatedDocument $annotationObject $annotationProperty $mode) | |||
#if ($mode == 'edit' || $mode == 'create') | |||
## This startupFocus parameter is used by the CKEditor WYSIWYG editor. | |||
#set ($startupFocus = true) |
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.
I'm wondering if we shouldn't make his a bit more generic / extensible to prepare the ground for other configuration parameters we may need in the future:
#set ($startupFocus = true) | |
#set ($wysiwygEditorConfig = { | |
'startupFocus': true | |
}) |
This will make the configuration more explicit, and it will reduce the risk of naming conflicts with other entries from the script context. WDYT?
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.
…IWYG by default * Codestyle Co-authored-by: Marius Dumitru Florea <[email protected]>
…IWYG by default * Renamed the editor config option
…IWYG by default * Codestyle
|
||
var config = { | ||
filebrowserUploadUrl: uploadDisabled ? '' : getUploadURL(sourceDocument, 'filebrowser'), | ||
startupFocus, |
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.
shouldn't it be startupFocus: startupFocus
? it's a key: value config object no?
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's called "shorthand property name" see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#property_definitions (syntax sugar to reduce boilerplate).
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.
I didn't know this notation well enough to use it either ^^'
#3694 (comment)
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.
ok thanks for the information, I'm not sure I'd have changed it since IMO it's not helping much reading but that's fine :)
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.
Looks good, with just a small indentation issue.
@@ -72,8 +72,10 @@ | |||
|
|||
<label for="$name">$services.localization.render('core.viewers.comments.add.comment.label')</label> | |||
#initRequiredSkinExtensions() | |||
## This startupFocus parameter is used by the CKEditor WYSIWYG editor. | |||
#set ($startupFocus = true) | |||
## This startupFocus parameter is used by the CKEditor WYSIWYG editor. |
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.
## This startupFocus parameter is used by the CKEditor WYSIWYG editor. | |
## This startupFocus parameter is used by the CKEditor WYSIWYG editor. |
Wrong indentation.
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.
Thanks! Fixed in 27ead97 👍
…IWYG by default * Fixed indentation
…IWYG by default (#3694) * Added a comment to explain a line of code that doesn't work with CKEditor anymore * Added a CKE config change so that it gets focus when loaded. * Implemented a solution that does not assume there's CKEditor * Fixed codestyle --------- Co-authored-by: Marius Dumitru Florea <[email protected]> (cherry picked from commit 957d0e5)
…IWYG by default (#3694) * Added a comment to explain a line of code that doesn't work with CKEditor anymore * Added a CKE config change so that it gets focus when loaded. * Implemented a solution that does not assume there's CKEditor * Fixed codestyle --------- Co-authored-by: Marius Dumitru Florea <[email protected]> (cherry picked from commit 957d0e5)
Jira URL
https://jira.xwiki.org/browse/XWIKI-17664
Changes
Description
Clarifications
Screenshots & Video
On the video below, we can see a basic use case and experimentation with adjacent UIs (namely inline editing and comment edition).
2024-11-26.14-56-41.mp4
Executed Tests
Manual tests, see above.
I doubt the changes would change anything to tests since it's only a minor CKEditor config update (and the docker tests pretty much don't care about the focus state).
Built changes with
mvn clean install -f xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-ui
and then successfully passed the docker test suite:mvn clean install -f xwiki-platform-core/xwiki-platform-annotation/xwiki-platform-annotation-test/xwiki-platform-annotation-test-docker
.Expected merging strategy