-
Notifications
You must be signed in to change notification settings - Fork 26
T/42: Various issues when dropping or inserting files. SRP in the command #47
Conversation
…e features use it.
…uperfluous tests and corrected test for inserting image at disallowed position.
src/utils.js
Outdated
@@ -19,3 +21,47 @@ export function isImageType( file ) { | |||
return types.test( file.type ); | |||
} | |||
|
|||
/** | |||
* Returns a model position which is optimal (in terms of UX) for inserting and image. |
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.
for inserting and image?
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.
"an image" ofc. I'll fix it.
src/utils.js
Outdated
/** | ||
* Returns a model position which is optimal (in terms of UX) for inserting and image. | ||
* | ||
* For instance, if a selection is in a middle of a paragraph, position before this paragraph |
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.
"For instance", and then you described all cases ;)
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.
No, I didn't. Element selection, edge cases like no blocks, etc.
const selectedElement = selection.getSelectedElement(); | ||
|
||
if ( selectedElement ) { | ||
return ModelPosition.createAfter( selectedElement ); |
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.
Comment what case it is?
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 code reads so easily that I don't know what else you can write. If there's some element selected, return position after this selected element. It's nearly 1:1 to natural language :D
The code looks and works great. After you update docs and comments you can merge this PR. |
Suggested merge commit message (convention)
Fix: Fixed two issues related to dropping images. First, when dropping a file into an empty paragraph, that paragraph should be replaced with that image. Second, drop position should be read correctly when the editor is focused upon drop. Closes ckeditor/ckeditor5#2814. Closes ckeditor/ckeditor5#2802.
BREAKING CHANGE:
UploadImageCommand
doesn't optimize the drop position itself anymore. Instead, a separatefindOptimalInsertionPosition()
function was introduced.BREAKING CHANGE:
UploadImageCommand
doesn't verify the type of file anymore. This needs to be done by the caller.Additional information
I started with minimal changes, but it soon turned out that they lead to a lot more changes. I added some missing tests and it's possible that I actually fixed a few more bugs, but I didn't check if those things didn't work in the past.