Skip to content

Commit 02583b1

Browse files
committed
Revert "Disable the buttons to change url or upload new picture for attachments or media"
This reverts commit eef18ff.
1 parent eef18ff commit 02583b1

1 file changed

Lines changed: 1 addition & 39 deletions

File tree

plugins/ckeditor5-woltlab-image/src/woltlabimage.ts

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @since 6.0
1212
*/
1313

14-
import { Command, Plugin } from "@ckeditor/ckeditor5-core";
14+
import { Plugin } from "@ckeditor/ckeditor5-core";
1515
import type {
1616
DocumentSelection,
1717
DowncastAttributeEvent,
@@ -22,7 +22,6 @@ import type {
2222
Selection,
2323
} from "@ckeditor/ckeditor5-engine";
2424
import { ImageUtils } from "@ckeditor/ckeditor5-image";
25-
import { ObservableSetEvent } from "@ckeditor/ckeditor5-utils";
2625

2726
export 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

189151
export default WoltlabImage;

0 commit comments

Comments
 (0)