-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fullscreen mode feature bootstrap #17897
base: ck/epic/1235-fullscreen-mode
Are you sure you want to change the base?
Conversation
@@ -41,9 +41,9 @@ You can use all the collaboration features **for {@link features/collaboration#a | |||
|
|||
Apart from the real-time collaboration tools, the module provides various other plugins. The {@link features/format-painter format painter} feature lets users consistently style the edited text, while the {@link features/mentions mentions} feature allows you to tag other users in comments. Meanwhile, {@link features/slash-commands slash commands} let you create, insert, and format rich content on the go by typing the `/` character and choosing from many predefined actions, such as text formatting, and inserting headings, tables, or lists. | |||
|
|||
### Full-screen mode | |||
### Fullscreen mode |
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.
IIRC, fullscreen for Drupal is a separate Drupal module that we created, dedicated for Drupal. After we release the official plugin, we need to make decision what do we do with the module. I don't know whether it offers anything beyond what we will offer in the official plugin, so I wouldn't be surprised if we depracte/remove it. /cc @andrzejkala
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.
In general I am fine with how this feature is structured and bootstrapped. One thing that I'd like to see more focus on is to try to standarize how Classic and Decoupled editors behave. I wrote more in one of comments.
} else if ( editor instanceof DecoupledEditor ) { | ||
this._fullscreenHandler = new DecoupledEditorHandler( editor ); | ||
} else { | ||
this._fullscreenHandler = new AbstractEditorHandler(); |
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 think that both in case of supported and non-supported editor types, we should allow some customization (through a callback? or passing custom EditorHandler class?), but especially for non-supported editors.
IDK if this is planned for the first feature release or not, but this part of the code will probably change a bit.
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 discussed I added a custom callbacks in #enable()
and #disable()
methods.
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 am not even sure if we need this kind of plugin because fullscreen is fully UI related plugin. We can keep it this way as it is aligned to how we typically split feature's code. And we should have a separate plugin with the UI (toolbar and menu bar buttons in this case), and separate plugin holding the logic. However, all of this happens solely in the command as of now, so maybe it would be enough just to have the UI plugin or just the main plugin.
This is an interesting plugin from the perspective of how we split feature's code and how we could change it in future. We discussed it in the relation to our UI lib.
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 treated the editing plugin registering the command as holding the logic so it made sense to me it's there, but if not the convention we have then probably it wouldn't make much sense. But the separation may still be useful at some point.
* Moves the given element to the fullscreen mode container, leaving a placeholder in its place. | ||
*/ | ||
public moveToFullscreen( elementToMove: HTMLElement, placeholderName: string ): void { | ||
const placeholderElement = createElement( document, 'div' ); |
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 was a bit surprised that we call document
just like that. There's no even any global
declaration at the beginning of the file. Linter allows for that?
How we do it in other places of code? I remember we had something like import globalThis
and then we used globalThis.document
🤔 .
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.
There's no one rule how document
is used throughout the codebase, in some places there's a global declaration used, sometimes globalThis
, and sometimes nothing. Linter doesn't yell 🤔
} | ||
|
||
/** | ||
* Returns the moved elements to their original places. |
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.
* Returns the moved elements to their original places. | |
* Returns the moved elements to their original places. |
This method also removes the container so I'd consider renaming it and changing this piece of API docs.
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 requested in another comment I moved the logic to the #disable()
method so this one was removed.
</div> | ||
`; | ||
|
||
document.body.appendChild( this._container ); |
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 am not sure of differences, but I expected this will be added to the BodyCollection
not directly to the <body>
. We put all our "remote" elements like e.g. contextual balloon in BodyCollection
. For sure it makes less mess on the customer's website.
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.
Putting the container into the default BodyCollection
will cause issues with ck-reset_all
again. We can again hack it and create a custom BodyCollection
without reset, but I'm not convinced it's a better solution 🤔
public override enable(): void { | ||
const editorUI = this._editor.ui; | ||
const editorUIView = editorUI.view; | ||
|
||
this.moveToFullscreen( editorUI.getEditableElement()!, 'editor' ); | ||
this.moveToFullscreen( editorUIView.toolbar.element!, 'toolbar' ); | ||
|
||
// In classic editor, the `dir` attribute is set on the top-level container and it affects the styling | ||
// in both menu bar and toolbar (adding the side padding to the elements). | ||
// Since we don't move the whole container but only parts, we need to reapply the attribute value manually. | ||
// Decupled editor doesn't have this issue because there is no top-level container, so `dir` is set on each component separately. | ||
this.getContainer().setAttribute( 'dir', editorUIView.element!.getAttribute( 'dir' )! ); | ||
|
||
if ( !this._editor.config.get( 'fullscreen.menuBar.isVisible' ) ) { | ||
return; | ||
} | ||
|
||
if ( !editorUIView.menuBarView ) { | ||
editorUIView.menuBarView = new MenuBarView( this._editor.locale ); | ||
editorUIView.menuBarView.render(); | ||
editorUI.initMenuBar( editorUIView.menuBarView ); | ||
} | ||
|
||
this.moveToFullscreen( editorUIView.menuBarView.element!, 'menu-bar' ); | ||
} |
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.
Let's see how this will evolve and return to this after we finish implementing all functionalities.
I'd love if we don't actually need separate handlers for Classic, Decoupled and others. We should anyway move into direction where various editor "areas" (like sidebars, toolbar, menu bar, editable areas) are "registered" in a common place, in a standarized way. So features like fullscreen can use them without recognizing what is the editor type.
If there are just minor differences between editors, I'd strongly encourage changes for example in ClassicEditor
so that at least classic and decoupled behave the same. It will simplify the code here and also have future benefits.
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 agree with this feedback. I registered it as a task on board and if there's enough time after doing the most important integrations, we can get back to it.
Suggested merge commit message (convention)
Internal (fullscreen): Introduce a fullscreen mode feature.
Additional information
This PR contains a package bootstrap and a basic working feature.