Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[#45782] moved drag event handling in ckeditor

Eric Schubert2f8f329d2fab
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
index d2b9227f845..994c19603fe 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts
@@ -175,19 +175,9 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
return editor;
}
- private stopDragging() {
- // The attachment list listens globally for drag events, but when
- // an item gets dropped in the editor, this event never makes it to the list.
- // Manually dispatching the event makes sure the `op-attachments` component
- // knows we are certainly not dragging anymore.
- const event = new DragEvent('dragleave');
- document.body.dispatchEvent(event);
- }
-
private setupAttachmentAddedCallback(editor:ICKEditorInstance) {
editor.model.on('op:attachment-added', () => {
this.states.forResource(this.resource!)!.putValue(this.resource);
- this.stopDragging();
});
}
@@ -210,7 +200,6 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin impl
}
this.attachments = _.clone(resource!.attachments.elements);
- this.stopDragging();
});
}
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
index 6ee876ce2e1..82df969f600 100644
--- a/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
+++ b/frontend/src/app/shared/components/editor/components/ckeditor/op-ckeditor.component.ts
@@ -27,14 +27,22 @@
//++
import {
- Component, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output, ViewChild,
+ Component,
+ ElementRef,
+ EventEmitter,
+ Input,
+ OnDestroy,
+ OnInit,
+ Output,
+ ViewChild,
} from '@angular/core';
import { ToastService } from 'core-app/shared/components/toaster/toast.service';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { ConfigurationService } from 'core-app/core/config/configuration.service';
import {
ICKEditorContext,
- ICKEditorInstance, ICKEditorWatchdog,
+ ICKEditorInstance,
+ ICKEditorWatchdog,
} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';
import { CKEditorSetupService } from 'core-app/shared/components/editor/components/ckeditor/ckeditor-setup.service';
@@ -209,6 +217,12 @@ export class OpCkeditorComponent implements OnInit, OnDestroy {
watchdog.editor.on('op:source-code-enabled', () => this.enableManualMode());
watchdog.editor.on('op:source-code-disabled', () => this.disableManualMode());
+ const model = watchdog.editor.model as unknown&{ on:(ev:string, callback:() => unknown) => void };
+ model.on('op:attachment-added', () => document.body.dispatchEvent(new DragEvent('dragend')));
+ model.on('op:attachment-removed', () => document.body.dispatchEvent(new DragEvent('dragend')));
+
+ this.$element.on('dragleave', () => document.body.dispatchEvent(new DragEvent('dragleave')));
+
this.onInitialized.emit(watchdog.editor);
return watchdog.editor;
});