-
Notifications
You must be signed in to change notification settings - Fork 2
Balloon Panel and related components #60
Conversation
this.hide(); | ||
} | ||
}; | ||
document.addEventListener( 'keydown', this._keyCloseCallback ); |
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.
We need to decide how we want to deal with keyboard events in UI components.
Right now this code is not testable, because it is difficult/not possible to dispatch Keyboard event with specified charCode
on Webkit
. Mostly we will need listener for Esc to close some popups, balloons etc, but I can imagine components with more advanced keyboard support (like #16).
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 should be done by
this.listenTo( document, 'keydown', () => {}` );
this.stopListening( document, 'keydown' );
which is via DOMEmitterMixin
class. See how ListDropdownView
works and its tests.
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.
Simulating key(Code) event should be possible via key
property instead of keyCode
which is marked as deprecated.
document.addEventListener( 'keydown', ( evt ) => console.log( evt ) );
document.dispatchEvent( new KeyboardEvent( 'keydown', { key: '20', keyCode: '20', code: '20' } ) );
BTW: KeyboardEvent.key
uses verbal description like "Escape"
.
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 I was trying by 'key' property too but I'll try your 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.
And yeah, KeboardEvent.key
is unsupported in Safari https://bugs.webkit.org/show_bug.cgi?id=69029#c13 :(
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.
Alright. Given the above mess I see no other option than:
- Checking if
this._keyCloseCallback
is called at all ondocument.body.dispatchEvent( new Event( 'keydown' )
; - Testing what happens if
this._keyCloseCallback
is called standalone with a syntheticevt
object containing differentkeyCodes
(would it callhide
then or not?).
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.
The tricky thing with keyCode
is that key
isn't supported in every browser yet. keyCode
is (with some exceptions – namely, onscreen keyboard on Android). This means that keyCode
is used by everyone anyway, so it doesn't actually change anything that it's deprecated – everyone use it.
|
||
// Attach keydown listener for closing panel on Esc press. | ||
this._keyCloseCallback = evt => { | ||
if ( evt.keyCode == 27 ) { |
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 condition lacks test coverage.
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.
Yep, I mentioned about it in comment below. There is a problem with dispatching Keyboard event with specified keyCode.
|
||
view = new LabeledInputView(); | ||
|
||
labeledInput = new LabeledInput( model, view ); |
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 guess we can live without LabeledInput
here too.
A more general impression: Do we need |
I've removed it. |
I guess there's some refactoring needed in inputs/labels/etc.
|
I was also wondering what to do with the First of all, some binding between the model and the Secondly, I wonder if the component is needed at all. ATM it exists just to wrap some elements in DOM and style them (simply align them to the right/left). It's an overkill to use JS and create yet another branch in the UI's DOM to do this. It might be a little bit easier if |
I checked and it's possible to extend the template with a new children export default class LinkBalloonPanelView extends BalloonPanelView {
/**
* @inheritDoc
*/
constructor( locale ) {
super( locale );
Template.extend( this.template, {
attributes: {
class: [
'ck-link-balloon-panel',
]
}
} );
this.template.definition.children = [
{
tag: 'div',
attributes: {
class: [
'moo'
]
}
}
];
}
} but it does not work via WDYT? Is is a different component because it comes with a new container/region for the buttons? Or maybe we should allow this kind of extension for the sake of similar container–like components in the future? |
I like it, I was trying to do exactly the same (I mean create a new region for buttons instead of using |
/** | ||
* Input instance. | ||
* | ||
* @member {ui.input.InputText} |
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.
Here will be more types in the feature.
…ight set of CSS classes.
Fixes #55 and #54
This PR introduces
BalloonPanel
component and related toLinkBalloonPanel
components.Components are moved from
ckeditor5-link
repository, little refactored, tested and documented.FollowUp for missing manual tests: #61
Related to: ckeditor/ckeditor5-theme-lark#34
[Edit] Now I see that this PR could be cut into smaller pieces. There is a lot of code :/