-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
i/7794: Introduce Insert Image via URL feature. #7835
Conversation
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 in the review, the most important case here is the API for the ImageUploadPanelView
class.
* @param {Object} [options.integrations={insertImageViaUrl:'insertImageViaUrl'}] Integrations object that contain | ||
* components (or tokens for components) to be shown in the panel view. By default it has `insertImageViaUrl` view. | ||
*/ | ||
constructor( locale, options = { integrations: { insertImageViaUrl: 'insertImageViaUrl' } } ) { |
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.
TL;DR: integrations
should be the second parameter. It should be an array that keeps View
instances.
And short "ADR" how I figured it out.
I would change the API a little bit:
constructor( locale, options = { integrations: { insertImageViaUrl: 'insertImageViaUrl' } } ) { | |
constructor( locale, integrations ) { |
And integrations
will be an array now. Items of the array could be:
[
// Passing a `View` instance that renders the component.
{ name: 'name-for-integration-01', view: new CustomIntegrationView( /* ... */ ),
// Passing a name of the View that is provided by the class by default.
{ name: 'integration-02', view: 'insertImageViaUrl'},
// It won't happen directly since `prepareIntegrations()` function will filter out the invalid value. However, the class itself does not check what is being added.
// We could assume that view will be always an instance of the `View` class.
{ name: 'integration-03', view: 'non-existing-item'},
]
The order of items in the array could determine the order in the Image Upload Panel view. Hence, the name
key could be omitted and we could pass only View
instances or the default string.
And at this point, I don't see any sense to support the string value here. From the ImageUploadPanelView
class point of view, integrations should represent a collection (the array) of View
elements.
Preparing proper values/view instances should be done a layer earlier.
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.
Since the proposed (the comment above) changes will cause changes in the class itself, I am skipping reviewing this file and its tests.
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 think we should ask others. But ATM it looks like a followup.
* @private | ||
* @returns {module:ui/labeledfield/labeledfieldview~LabeledFieldView} | ||
*/ | ||
_createLabeledInputView( locale ) { |
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's sad that you can type whatever in the input and it won't be checked. I am unsure of what could we do here. Check whether passed a relative path or an absolute to the resource and validate the later one? I am thinking about the AutoLink regexp.
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.
label: t( 'Insert image via URL' ) | ||
} ); | ||
labeledInputView.fieldView.placeholder = 'https://example.com/src/image.png'; | ||
labeledInputView.infoText = t( 'Paste the image source URL' ); |
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.
labeledInputView.infoText = t( 'Paste the image source URL' ); | |
labeledInputView.infoText = t( 'Paste the image source URL.' ); |
Don't forget about updating contexts.json
.
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.
Same in L156. Missing the dot at the end of the sentence.
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.
Same in L156. Missing the dot at the end of the sentence.
But it's a form label. It shouldn't end with the dot 🤔
@pomek changes applied, I hope it will 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.
LGTM.
This comment has been minimized.
This comment has been minimized.
I've got doubts regarding how this feature should be proposed – as a separate plugin, an opt-in feature of the current I'll write a separate RFC for that. |
We made a decision regarding how to propose this feature: #7794 (comment). @panr, could you adjust the code? It may require a bit more changes as this will be a button or a split button depending on the config option. |
@Reinmar did the changes, now I'm on the docs update. |
Suggested merge commit message (convention)
Feature (image): Introduced insert image via URL feature. Closes #7794.
Other (image): Update
ImageUploadUI
plugin. From now the plugin appears as a dropdown with the split button. Primary action shows the native dialog for picking the images from the disk, and the arrow button opens the dropdown with the form for inserting an image via URL and configured integrations.BREAKING CHANGE (image): Keep the
ImageUploadCommand
enabled when an image in the editor's content is selected. This allows us to replace the source URL of the image without the need to remove it.