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

Review contents of this package #2800

Closed
Reinmar opened this issue May 7, 2017 · 18 comments · Fixed by ckeditor/ckeditor5-upload#81
Closed

Review contents of this package #2800

Reinmar opened this issue May 7, 2017 · 18 comments · Fixed by ckeditor/ckeditor5-upload#81
Assignees
Labels
package:upload status:discussion type:task This issue reports a chore (non-production change) and other types of "todos".
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented May 7, 2017

The main src/ dir contains now multiple plugins (only one is useful – ImageUpload) and some utils.

I'd propose something like:

src/
  ui/
  utils/
    all the file* stuff
  imageupoad/
    imageuploadcommand.js
    imageuploadengine.js
    imageuploadprogress.js
  imageupload.js
  imageuploadbutton.js

Also, I lost a bit the confidence that image upload should be together with upload. It surprised me here (I forgot about this decision in the meantime). I think it's weird now. The more I look at this the more it looks bad because of all this unnecessary coupling and confusion. Instead of increasing discoverability, we might've actually lowered it.

@Reinmar
Copy link
Member Author

Reinmar commented May 7, 2017

After we clean this package it also needs a better description cause the current "Upload feature." is rather confusing (and incorrect).

@Reinmar Reinmar changed the title The package needs some proper directory structure Review contents of this package Jun 12, 2017
@Reinmar
Copy link
Member Author

Reinmar commented Jun 12, 2017

Also, I lost a bit the confidence that image upload should be together with upload. It surprised me here (I forgot about this decision in the meantime). I think it's weird now.

I got this feeling again now, when refactoring all the commands.

Also, ImageUploadCommand is troubling me. First of all, it is not only about upload – it also inserts the image so the name is confusing. But most importantly – I'm not entirely sure whether it should be a command at all.

I've been thinking about some more general InsertImage command which could accept various arguments – a File like now and e.g. image data directly (i.e. src and alt) because it's now unclear how someone could programmatically insert an image. However, a master command would create references to the entire upload package so it'd be really heavy.

So perhaps we could have more granular methods – InsertImageByFile, InsertImage (by data), etc.

Or maybe I'm overcomplicating this and we could have UploadImage (by file) and InsertImage (by data).

@pjasiun
Copy link

pjasiun commented Jun 13, 2017

The point of having it as a command is that one may disable it, for instance, if there is no connection with the server.

@pjasiun
Copy link

pjasiun commented Jun 13, 2017

As for keeping image plugins here: it was because of the idea that whenever one will want to handle upload, he may want to enable it for all types of content that can be uploaded: images, media, files. If they are in the one place it's simpler to find all needed plugins. However, I also found it strange recently.

@Reinmar
Copy link
Member Author

Reinmar commented Jul 14, 2017

Also, ImageUploadCommand is troubling me. First of all, it is not only about upload – it also inserts the image so the name is confusing. But most importantly – I'm not entirely sure whether it should be a command at all.

I had this feeling again now, while getting back to this feature. There's something wrong with this command. It does too much and is named incorrectly.

@Reinmar
Copy link
Member Author

Reinmar commented Sep 29, 2017

I've just realised that the image upload feature is actually implemented by... ImageUploadProgress which makes little sense. Progress should be added by one plugin and handling for dropped and pasted images by another plugin.

OK, I got confused by the number of these plugins. The uploading capabilities are implemented by ImageUplodEngine, while progress is added in ImageUploadProgress. I got confused because ImageUpload requires ImageUploadProgress and because ImageUploadProgress doesn't really need ImageUploadEngine.

So, these coupling is unnecessary. ImageUploadProgress should be optional and should not unnecessarily depend on ImageUploadEngine. Then, ImageUpload will need to require both of these plugins which will make it clear what does what.

Compare this to inheritance chains. Requiring one plugin in another one is a bit like saying that one plugin inherits from the other one. The less often we do that, the better.

Strongly related to #425 (comment).

@Reinmar
Copy link
Member Author

Reinmar commented Sep 29, 2017

Another thing is that ImageUpload requires ImageUploadButton. Why? These are independent features.

@Reinmar
Copy link
Member Author

Reinmar commented Oct 10, 2017

Blocked by #488.

@Reinmar
Copy link
Member Author

Reinmar commented Oct 16, 2017

And Adapter should be called UploadAdapter (see https://stackoverflow.com/questions/46765197/how-to-enable-image-upload-support-in-ckeditor-5/46773627#46773627 why). Don't forget to update my answer after the rename is done.

@Reinmar
Copy link
Member Author

Reinmar commented Nov 13, 2017

One more detail to fix:

	/**
	 * Performs image loading. Image is read from the disk and temporary data is displayed, after uploading process
	 * is complete we replace temporary data with target image from the server.
	 *
	 * @protected
	 * @param {module:upload/filerepository~FileLoader} loader
	 * @param {module:engine/model/element~Element} imageElement
	 */
	load( loader, imageElement ) {

So is it protected or not?

@jodator
Copy link
Contributor

jodator commented Jan 31, 2018

So to sum up:

  1. Almost everybody agrees that generic ImageUpload* classes location inside Upload thing is at least confusing - so the question is do we do something with this? I can see two options:

    a) leave as is (but group files as @Reinmar proposed earlier)
    b) extract ckeditor5-imageupload as independent plugin
    c) move ImageUpload* to image

    a) vs b) - one is less discoverable but have less plugins the latter better defines features/plugins roles and is more discoverable

    b) vs c) - I can see a situation that one would like to have InsertImage without UploadImage - ie inserting an image by its URI (look below).

  2. Plugins coupling, naming and requires() of each other.

    The requires() chain should be flat like this:

    ImageUpload	----+--->	ImageUploadEditing			| was ImageUploadEngine
    				|
    				+--->	ImageUploadProgressEditing	| was   ImageUploadProgressEngine
    				|
    				+--->	ImageUploadUI				| was ImageUploadButton
    
  3. Some classes requires a bit better description as what they are meant for.

  4. The ImageUploadCommand require some work as it:

    • the name does not reflect that it: uploads image and then inserts it
    • is required for toolbar button states handlng (ie disable when no server conn)

    Maybe creating insertImage command makes sense - it might be used by ImageUpload feature after successful upload - also might be helpful for creating an InsertImage feature that will insert image by given file URI.

  5. Minor refactoring:

    • Rename Adapter to UploadAdapter
    • make load() method private (unless someone can tell my why this one is protected)

Things that I've found odd:

  • The insertImage toolbar name vs uploadImage used for command, feature name and other plugins - shouldn't this be uploadImage? (corresponds to point 4).
  • The FileRepository file have inner FileLoader class - shouldn't there be one class one file rule? I get that it is "internal" class of FileRepository and probably isn't useful as import elsewhere but.... I don't like it ()

@Reinmar
Copy link
Member Author

Reinmar commented Jan 31, 2018

@jodator, I'm afraid that you didn't notice that this is about moving stuff from ckeditor5-upload to ckeditor5-image. Could you update your comment?

@jodator
Copy link
Contributor

jodator commented Jan 31, 2018

@Reinmar yeah... there were so many ImageUpload there that I've fixated on that. I've updated first point to reflect current state and my feelings on UploadImage vs InsertImage.

@jodator
Copy link
Contributor

jodator commented Jan 31, 2018

So after F2F talks we're going to:

  1. Use option c)
  2. decouple and rename Plugins
  3. Add minimal descriptions to classes
  4. leave ImageUploadCommand as is but the toolbar button will be renamed to uploadImage
  5. as in summary.

@Reinmar
Copy link
Member Author

Reinmar commented Jan 31, 2018

leave ImageUploadCommand as is but the toolbar button will be renamed to uploadImage

To explain this choice – we may want to implement insertImage button one day. It would allow multiple methods of inserting images – from the file system, by URL, etc. Just like we designed in https://github.com/ckeditor/ckeditor5-image/issues/16.

So, to enable that, let's focus the current button on uploading. This way, we'll be able to later add a more comprehensive feature without touching this one.

@jodator
Copy link
Contributor

jodator commented Jan 31, 2018

@Reinmar as we're renaming Adapter to UploadAdapter in FileRepository should we change also:

  • FileRepository#createAdapter() to createUploadAdapter().
  • filerepository-no-adapter error to filerepository-no-upload-adapter.

ps.: It makes a sense for me as adapter alone in above might be not precise enough (one might think of FileAdapter.

@Reinmar
Copy link
Member Author

Reinmar commented Jan 31, 2018

Makes sense to me. WDYT @pjasiun?

@pjasiun
Copy link

pjasiun commented Feb 1, 2018

Yep, even recently someone asks what "adapter" is. Using "upload adapter" will make it cleaner.

Reinmar referenced this issue in ckeditor/ckeditor5-adapter-ckfinder Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-build-balloon Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-build-classic Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-build-inline Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-cloud-services Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-easy-image Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-image Feb 2, 2018
Feature: Intorduced the `ImageUpload` feature. It was moved from the `@ckeditor/ckeditor5-upload` package. See ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-theme-lark Feb 2, 2018
Internal: Changed image and upload packages use after ckeditor/ckeditor5-upload#22.
Reinmar referenced this issue in ckeditor/ckeditor5-upload Feb 2, 2018
Other: Moved the image upload plugins to the `@ckeditor/ckeditor5-image` package. Minor cleanup in the API. Closes #22.

BREAKING CHANGE: Renamed `Adapter` to `UploadAdapter`.
BREAKING CHANGE: Removed `ImageUpload` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadEngine` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadProgress` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Removed `ImageUploadButton` plugin. It can be no found in ckeditor5-image repository.
BREAKING CHANGE: Renamed `FileRepository#createAdapter()` to `FileRepository#createUploadAdapter()`.
BREAKING CHANGE: Renamed `filerepository-no-adapter` error to `filerepository-no-upload-adapter`.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-upload Oct 9, 2019
@mlewand mlewand added this to the iteration 14 milestone Oct 9, 2019
@mlewand mlewand added status:discussion type:task This issue reports a chore (non-production change) and other types of "todos". package:upload labels Oct 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:upload status:discussion type:task This issue reports a chore (non-production change) and other types of "todos".
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants