-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Widget upload feature for Easy Image #1483
Conversation
…ept with some logs and ugly commented code.
…et upload feature.
…e plugin.It's going to be extracted later. This type will be passed into Upload Widget Feature. The Idea is to have the ability to implement a different progress indicators for other widgets.
…ion of progress indicator with Easy Image itself.
…get upload feature. Extracted custom progress indicators types and styles into a common files.
Also removed good old conole logs.
… filled in 100% instead of being empty.
…g CIRCLE_THICKNESS const. Also removed stray CSS code.
There were also a couple minor code style corrections.
…y. Adjusted API docs.
This is done as a temp workaround, as the objects that we're passing as definition to features, are copies of the original definition. In other words any modifications to definition done at runtime (by other features setUps or at a widget runtime) are not available in setUp function. Because of that definition.name was not available (because it's assigned by the widget system at a widget construction time).
…ure by dropping onto readonly editor.
…ite passes faster.
Pushed a set of fixes that also brings:
This PR does not cover following cases:
These limitations will be addressed in future releases. |
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.
Just few things to polish:
-
Language files were not regenerated.
-
As support for PFW was added, it would be nice to add some tests covering it (manual for sure, unit test maybe, WDYT?):
- Support for converting any pasted base64 encoded image.
- This also handles images pasted from Word.
-
Small issue with circle progress reporter - as it creates some overlay over image during upload it is not possible to edit caption during upload.
-
Direct image paste works funny on OS X, but I suppose it is an OS "feature":
@@ -4,3 +4,4 @@ | |||
altText = Label for button converting image to assign an alternative text. | |||
fullImage = Label for button converting image to a full width. | |||
sideImage = Label for button converting image to be a side 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.
Shouldn't it be commands.altText
, commands. fullImage
, commands. sideImage
?
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 out of scope of this issue, but it is a good catch, please extract it.
plugins/easyimage/lang/en.js
Outdated
@@ -8,5 +8,6 @@ CKEDITOR.plugins.setLang( 'easyimage', 'en', { | |||
fullImage: 'Full Size Image', | |||
sideImage: 'Side Image', | |||
altText: 'Change image alternative text' | |||
} | |||
}, | |||
uploadFailed: 'Your image could not be downloaded due to network error.' |
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.
Your image could not be downloaded due to network error
or rather
Your image could not be uploaded due to a network error
?
} ); | ||
} | ||
|
||
function setImageWidth( widget, height ) { |
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 somehow a little less consistent, but from practical point of view makes much sense. Let's leave it as is 👍
plugins/imagebase/plugin.js
Outdated
* @param {String} blobUrl Blob URL of an image. | ||
* @param {Boolean} [finalize=true] If `false` widget will not be automatically finalized (added to {@link CKEDITOR.plugins.widget.repository}) | ||
* but returned as a {@link CKEDITOR.dom.element} instance. | ||
* @returns {CKEDITOR.plugins.widget/CKEDITOR.dom.element} The widget instance or {@link CKEDITOR.dom.element} of a widget wrapper if `finalize` was set to `false`. |
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 docs for data
param.
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.
All other methods docs are public /**
, only this one is private /*
, is there any specific reason for this? (same for upload* events below)
plugins/imagebase/plugin.js
Outdated
/** | ||
* Widget feature dedicated for handling seamless file uploads. | ||
* | ||
* This type serves solely as a mixing, and should be added using |
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.
Shouldn't it be
This type serves solely as a mixin
g, and should be...
?
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.
Also, I think we should add @since
tag here.
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.
As for @since
tag, I don't see much sense for that here as CKEDITOR.plugins.imagebase
namespace is added in 4.9.0
so it seems natural to me that this info is not needed.
I'll report a feature request in Umberto to inherit/"cascade" since tag.
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.
FYI: reported as cksource/umberto#466
plugins/imagebase/plugin.js
Outdated
* | ||
* @private | ||
* @param {CKEDITOR.editor} editor | ||
* @param {Blob/String} fileOrData See {@link CKEDITOR.fileTools.fileLoader}. |
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 fileOrData
docs param name doesn't match with the file
param in the code.
plugins/imagebase/plugin.js
Outdated
updated: function() {}, | ||
|
||
/** | ||
* To be called when the progress should be marked as complete. |
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 thinking about making it more consistent (Method to be called
versus To be called
), but I think something like Marks the progress as complete.
or Refreshes the progress.
sounds better, WDYT?
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.
Great idea! It's simpler. The original text looks redundant compared to that.
* @param {CKEDITOR.editor} editor | ||
* @param {Object} options | ||
* @param {File[]} [options.files=[]] Files to be dropped. | ||
* @param {Function} options.callback Function to be called after the paste event. |
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 would change order of options.files
and options.callback
so the required one is first.
* {@link CKEDITOR.plugins.imageBase.progressReporter}. | ||
* @returns {Function} | ||
*/ | ||
getProgressOverlapType: function( editor, ProgressReporter ) { |
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 have a mixed feelings about ProgressReporter
instead of progressReporter
, but I see what was the intention here.
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.
Well we don't have an official and strict rule about this. My intention was to uppercase a local variable in case it stores a type. Does it make sense?
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, it may be a good way to distinguish it 👍
/* | ||
* Returns a type that implements a progress indicator that puts a | ||
* circle-shaped progress bar. | ||
* |
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.
Missing @param
docs.
Good point, however our lang tool seems to be broken, as I'm adding easyimage plugin to list of plugins tracked by lang tools and it still doesn't work. I'll extract it to a separate ticket, especially that original entries need a fix too.
As for manual test it's a good idea (added in 44e6f43). As for unit test, TBH I don't find it necessary at this point. We have a good coverage with base64 encoded tests, and this is what our Paste form Word produces. If we ever have some problem on integration between the two, we'll add a proper unit testing for integration.
This is used just for tests, it's purpose is just to visualize the flexibility of this feature. It looks good enough as it is. We'd have to worry about that if it was our main progress reporter.
I don't have a Mac to check it at this point, but I suppose it transforms image into base64-encoded one, thus following feature apply:
Pushed fixes. |
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.
Looks good, nice work 👍
I don't have a Mac to check it at this point, but I suppose it transforms image into base64-encoded one, thus following feature apply:
Support for converting any pasted base64 encoded image.
Looks like works according to the feature. The image (I mean the icon) is properly uploaded to CS.
* {@link CKEDITOR.plugins.imageBase.progressReporter}. | ||
* @returns {Function} | ||
*/ | ||
getProgressOverlapType: function( editor, ProgressReporter ) { |
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, it may be a good way to distinguish it 👍
…minor doc fixes. Docs: simplified reporter methods description and corrected uploadStarted event docs.
What is the purpose of this pull request?
New feature
Does your PR contain necessary tests?
All patches which change the editor code must include tests. You can always read more
on PR testing,
how to set the testing environment and
how to create tests
in the official CKEditor documentation.
This PR contains
What changes did you make?
This pull request adds a widget upload feature.
It can be hooked to any widget.
Allowed accepted file types can specified using
supportedTypes
property in widget definition (similarly as it is inuploadwidget
).Also allows for easy progress bar customization by
progressReporterType
property in widget definition.It also fixes several other issues:
I have targetted this PR into a upload widget feature branch, as it still needs undo integration before being merged into EI feature.