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

ImageTypeCommand: Provide Configuration For "Is Valid Image" (other than default relying on src/uploadId attribute) #15653

Open
mmichaelis opened this issue Jan 8, 2024 · 2 comments
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. package:image status:stale type:improvement This issue reports a possible enhancement of an existing feature.

Comments

@mmichaelis
Copy link

📝 Provide a description of the improvement

When it comes to using the ImageTypeCommand for images, for example, served from a CMS, the image model representation may miss a src attribute depending on the overall design.

Having this, image types ImageInline and ImageBlock cannot be toggled via ImageTypeCommand due to its hard-wired restriction to only work on images with valid src attribute (or as the only alternative, the uploadId).

See:

// Don't change image type if "src" is missing (a broken image), unless there's "uploadId" set.
// This state may happen during image upload (before it finishes) and it should be possible to change type
// of the image in the meantime.
if ( !attributes.src && !attributes.uploadId ) {
return null;
}

Our scenario requires a different approach (similar to the uploadId), that may benefit from some redesign to copy with the ImageTypeCommand restrictions, but just to sketch our scenario:

  • Our images are represented by an image element (custom grammar, no HTML; roughly sketched example):

    <img xlink:href="content/42"/>
  • The xlink:href denotes the "strategy to retrieve the image BLOB data".

  • In editing view, we load the BLOB lazily (and show a placeholder meanwhile) by eventually setting the src attribute to the "resolved BLOB data location". This src attribute later must not be stored in data layer (we currently prevent it even to appear in the model layer by blocking the corresponding upcast).

Thus, src is never part of the model, but instead some ID similar to uploadId.

💡 Suggestion

As possibly more concrete use-case, remove the hard-wired uploadId from ImageTypeCommand as it is a forward-reference to a possibly not even installed plugin.

Instead, let the image upload plugin use some to be specified API to register this "alternative src attribute", so that the ImageTypeCommand may respect it.

This API then could also be used by other image architectures like ours.

📃 Other details

  • Browser: Chrome
  • OS: Windows
  • CKEditor version: 39.0.2
  • Installed CKEditor plugins: Image

If you'd like to see this improvement implemented, add a 👍 reaction to this post.

@mmichaelis mmichaelis added the type:improvement This issue reports a possible enhancement of an existing feature. label Jan 8, 2024
@Witoso Witoso added package:image domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. labels Jan 9, 2024
@Witoso
Copy link
Member

Witoso commented Jan 9, 2024

Thanks for the request, we will discuss it internally.

@CKEditorBot
Copy link
Collaborator

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:dx This issue reports a developer experience problem or possible improvement. domain:integration-dx This issue reports a problem with the developer experience when integrating CKEditor into a system. package:image status:stale type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

No branches or pull requests

3 participants