Skip to content

Commit

Permalink
Removing 'ckboxImageId' after replacing url: misc. fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
arkflpc committed Oct 13, 2023
1 parent db8c25c commit 1981593
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 0 additions & 5 deletions packages/ckeditor5-ckbox/src/ckboxediting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ export default class CKBoxEditing extends Plugin {
const isLibraryLoaded = !!window.CKBox;

if ( replaceImageSourceCommand ) {
// // After replacing image, "ckboxImageId" attribute will be removed.
// replaceImageSourceCommand.registerImageCallback( ( writer, image ) => {
// writer.removeAttribute( 'ckboxImageId', image );
// } );

this.listenTo<DecoratedMethodEvent<ReplaceImageSourceCommand, 'cleanupImage'>>(
replaceImageSourceCommand,
'cleanupImage',
Expand Down
13 changes: 12 additions & 1 deletion packages/ckeditor5-image/src/image/replaceimagesourcecommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ export default class ReplaceImageSourceCommand extends Command {
}

/**
* Cleanup some image attributes.
* Cleanup image attributes that are not relevant to the new source.
*
* Removed attributes are: 'srcset', 'sizes', 'sources', 'width', 'height', 'alt'.
*
* This method is decorated, to allow custom cleanup logic.
* For example, to remove 'myImageId' attribute after 'src' has changed:
*
* ```ts
* replaceImageSourceCommand.on( 'cleanupImage', ( eventInfo, [ writer, image ] ) => {
* writer.removeAttribute( 'myImageId', image );
* } );
* ```
*/
public cleanupImage( writer: Writer, image: Element ): void {
writer.removeAttribute( 'srcset', image );
Expand Down

0 comments on commit 1981593

Please sign in to comment.