Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

t/263: Implemented public show and hide methods in the ContextualToolbar plugin #270

Merged
merged 4 commits into from
Jul 12, 2017

Conversation

oleq
Copy link
Member

@oleq oleq commented Jul 10, 2017

Suggested merge commit message (convention)

Other: Implemented public show and hide methods in the ContextualToolbar plugin. Closes ckeditor/ckeditor5#5383.

…bar plugin. Closes #263.

Extended enableToolbarKeyboardFocus helper with beforeFocus and afterBlur callbacks.
* Removes panel from the {@link: #_balloon}.
*
* @private
* Removes the toolbar from the {@link: #_balloon} which hides it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't reference private stuff in public docs.

// of lines of text. Using getClientRects() allows us to browse micro–ranges
// that would normally make up the bounding client rect.
const rangeRects = editingView.domConverter.viewRangeToDom( editingView.selection.getFirstRange() ).getClientRects();
const range = editingView.selection.getFirstRange();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How's this change related to this PR?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's strongly related and it's all about https://github.com/ckeditor/ckeditor5-utils/issues/168.

When we first implemented CT it was for non–collapsed selections only and hence it was immune to some weird DOMRange vs. ClientRect issues. Now that it gains public show() and hide(), it can be displayed for collapsed selections and it means it broke a lot.

So the following change

- // getBoundingClientRect() makes no sense when the selection spans across number
- // of lines of text. Using getClientRects() allows us to browse micro–ranges
- // that would normally make up the bounding client rect.
- const rangeRects = editingView.domConverter.viewRangeToDom( editingView.selection.getFirstRange() ).getClientRects();
+ const range = editingView.selection.getFirstRange();
+ const rangeRects = Rect.getDomRangeRects( editingView.domConverter.viewRangeToDom( range )

uses the power of the Rect class to avoid weird bugs, keep us safe and DRY.

@@ -24,7 +24,9 @@ export default function enableToolbarKeyboardFocus( {
origin,
originKeystrokeHandler,
originFocusTracker,
toolbar
toolbar,
beforeFocus,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing documentation for these two new properties.

@@ -33,7 +35,12 @@ export default function enableToolbarKeyboardFocus( {
// Focus the toolbar on the keystroke, if not already focused.
originKeystrokeHandler.set( 'Alt+F10', ( data, cancel ) => {
if ( originFocusTracker.isFocused && !toolbar.focusTracker.isFocused ) {
if ( beforeFocus ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I commented in the other PR. Calling this callback beforeFocus() makes it a bit hard to read. It took me a couple of minutes to understand this. Unfortunately... now it makes perfect sense, so I can't find some new ideas :D.

@Reinmar Reinmar merged commit eb4caab into master Jul 12, 2017
@Reinmar Reinmar deleted the t/263 branch July 12, 2017 14:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement public show/hide methods in ContextualToolbar (independent of focus and selection)
2 participants