-
Notifications
You must be signed in to change notification settings - Fork 37
Arrow keys handling #17
Conversation
// | ||
// @param {module:engine/model/selection~Selection} modelSelection | ||
// @returns {module:engine/model/element~Element|null} | ||
function getSelectedElement( modelSelection ) { |
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 wondering whether this should stay here or be moved as model's selection method. We have similar one in view's selection.
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.
Makes sense moving it there. But it needs to have the same semantics like the method in the view. Are they identical?
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.
Yes, they have same semantics. I will create an issue in ckeditor5-engine.
…s no place to move selection.
I've fixed issue from previous comment and added test checking it. But I noticed one thing - when data is loaded and image is the first element in the document filler is added before it. This is probably an engine issue, could you confirm? |
Hm... Hard to tell. The So, I think that this is a bug in the engine. I'll report a ticket for it, but please change this sample so image isn't the first element in the root. |
const modelDocument = this.editor.document; | ||
const schema = modelDocument.schema; | ||
const modelSelection = modelDocument.selection; | ||
const objectElement = getSelectedElement( modelSelection ); |
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.
Should use the new engine function
const objectElement = getSelectedElement( modelSelection ); | ||
|
||
// if object element is selected. | ||
if ( objectElement && schema.objects.has( objectElement.name ) ) { |
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 code has nothing to do with widgets. This is interesting, cause it means that we can move all that to the engine easily. That can be a good option. Perhaps it will be easily doable to have basic widget constructs in the engine. However, as a what? Addition to the editing controller? Maaaybe. But it's so much unnecessary code that I don't know ;|.
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.
That's a valid point. We can make a discussion about it when we will extracting widgets functionalities from image plugin.
Fixes ckeditor/ckeditor5#5038. Please review after closing: ckeditor/ckeditor5-engine#717.