1111 * @since 6.0
1212 */
1313
14- import { Command , Plugin } from "@ckeditor/ckeditor5-core" ;
14+ import { Plugin } from "@ckeditor/ckeditor5-core" ;
1515import type {
1616 DocumentSelection ,
1717 DowncastAttributeEvent ,
@@ -22,7 +22,6 @@ import type {
2222 Selection ,
2323} from "@ckeditor/ckeditor5-engine" ;
2424import { ImageUtils } from "@ckeditor/ckeditor5-image" ;
25- import { ObservableSetEvent } from "@ckeditor/ckeditor5-utils" ;
2625
2726export class WoltlabImage extends Plugin {
2827 static get pluginName ( ) {
@@ -34,10 +33,6 @@ export class WoltlabImage extends Plugin {
3433 }
3534
3635 init ( ) {
37- this . #decorateCommand( this . editor . commands . get ( "uploadImage" ) ! ) ;
38- this . #decorateCommand( this . editor . commands . get ( "insertImage" ) ! ) ;
39- this . #decorateCommand( this . editor . commands . get ( "replaceImageSource" ) ! ) ;
40-
4136 const { conversion } = this . editor ;
4237
4338 const imageTypes = [ "imageBlock" , "imageInline" ] as const ;
@@ -151,39 +146,6 @@ export class WoltlabImage extends Plugin {
151146 imageUtils . findViewImgElement ( viewElement ) ! ,
152147 ) ;
153148 }
154-
155- #decorateCommand( command : Command ) {
156- const imageUtils : ImageUtils = this . editor . plugins . get ( "ImageUtils" ) ;
157- command . on < ObservableSetEvent < boolean > > (
158- "set:isEnabled" ,
159- ( evt , _ , value ) => {
160- if ( ! value ) {
161- return ;
162- }
163- const selection = this . editor . model . document . selection ;
164- const element = imageUtils . getClosestSelectedImageElement ( selection ) ;
165- if ( ! element ) {
166- return ;
167- }
168- evt . return = ! ( this . #isAttachment( element ) || this . #isMedia( element ) ) ;
169- } ,
170- { priority : "high" } ,
171- ) ;
172- }
173-
174- #isAttachment( element : Element ) : boolean {
175- return (
176- element . getAttribute ( "classList" ) === "woltlabAttachment" ||
177- element . hasAttribute ( "attachmentId" )
178- ) ;
179- }
180-
181- #isMedia( element : Element ) : boolean {
182- return (
183- element . getAttribute ( "classList" ) === "woltlabSuiteMedia" ||
184- element . hasAttribute ( "mediaId" )
185- ) ;
186- }
187149}
188150
189151export default WoltlabImage ;
0 commit comments