Skip to content
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

Introduce the "insertImage" command #5171

Closed
jodator opened this issue Nov 13, 2018 · 8 comments · Fixed by ckeditor/ckeditor5-image#250
Closed

Introduce the "insertImage" command #5171

jodator opened this issue Nov 13, 2018 · 8 comments · Fixed by ckeditor/ckeditor5-image#250
Assignees
Labels
package:image type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Milestone

Comments

@jodator
Copy link
Contributor

jodator commented Nov 13, 2018

Right now we only have "imageUpload" command that uploads & inserts an image. Other features (ie file browser features) might do partially the same - insert an image (by its URL).

We could introduce the "insertImage" command that will insert an image for given URL in document selection. It will use findOptimalPostion() algorithm.

editor.execute( 'insertImage', { src: '/some/path/to/image.jpg' } );
@jodator
Copy link
Contributor Author

jodator commented Nov 15, 2018

@Reinmar Just a quick question:

  1. InsertImage
  2. ImageInsert (we have ImageUpload)

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2018

OMG, I knew we'll end up in this place :D Flip the coin, I guess.

But to be serious – imageInsert (we're talking about a command, right?) would be incorrect – it should be imageInsertion. The "upload" works as a noun in imageUpload(Feature). But imageInsertion looks ridiculous... so imageInsert. Yeah... let's go with this one and treat it as a compound of namespace + action. Let's be consistent locally (so with imageUpload).

@scofalik
Copy link
Contributor

scofalik commented Nov 15, 2018

Why not insertImage? (we could rename imageUpload to uploadImage too)

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2018

Hm... I think I recall that we anticipated this problem and we agreed that imageUpload is indeed a namespace + action. I had a feeling we were there already.

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2018

Why not insertImage?

Because we already have imageUpload. Which we have because the feature is called ImageUpload (it would be bad if feature was called differently than the button). We also have imageStyle:* and imageTextAlternative (plus, plugins called the same way).

We had a very long discussion about naming ~1 year ago and we agreed that a single naming convention doesn't fit all cases. We have features like undo/redo/bold (noun or verb) but also blockQuote or heading (noun). It's a bit of a mess. You would expect that a command name is a verb, but that caused issues, so we have to be flexible and as a rule of thumb consistent locally (within a package) rather than trying to be super consistent globally (impossible).

@jodator
Copy link
Contributor Author

jodator commented Nov 15, 2018

imageInsert and ImageInsertCommand to be 👯‍♂️

@jodator
Copy link
Contributor Author

jodator commented Nov 15, 2018

Another thing which we rather didn't do (apart from AttributeCommand which is a bit different case).

So I see that ImageUploadCommand and ImageInsertCommand will behave similarly. Mostly in the refresh() method. I would make ImageUploadCommand to extend ImageInsertCommand to not duplicate this part and rewrite the execute() part. Will this be OK?

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2018

One should not extend the other. They have different API signatures for execute(). That violates LSP. If anything, we should extract the common part and reuse it in both commands. I doubt it's worth at this stage.

Reinmar referenced this issue in ckeditor/ckeditor5-image Nov 22, 2018
Feature: Introduced the `'imageInsert'` command. Closes #245. Closes #251.

BREAKING CHANGE: The `'imageUpload'` command's `files` parameter was renamed to `file`. It still can accept an array of files.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-image Oct 9, 2019
@mlewand mlewand added this to the iteration 21 milestone Oct 9, 2019
@mlewand mlewand added status:confirmed type:feature This issue reports a feature request (an idea for a new functionality or a missing option). package:image labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:image type:feature This issue reports a feature request (an idea for a new functionality or a missing option).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants