fileList.append(createAttachmentFromFile(file, editor));
}
+type Context = {
+ tmpHash: string;
+};
+
export function setup(editorId: string): void {
const container = document.getElementById(`attachments_${editorId}`);
if (container === null) {
fileToAttachment(fileList!, event.detail, editor);
});
- listenToCkeditor(editor).uploadAttachment((payload) => {
- const event = new CustomEvent<CkeditorDropEvent>("ckeditorDrop", {
- detail: payload,
+ listenToCkeditor(editor)
+ .uploadAttachment((payload) => {
+ const event = new CustomEvent<CkeditorDropEvent>("ckeditorDrop", {
+ detail: payload,
+ });
+ uploadButton.dispatchEvent(event);
+ })
+ .collectMetaData((payload) => {
+ let context: Context | undefined = undefined;
+ try {
+ if (uploadButton.dataset.context !== undefined) {
+ context = JSON.parse(uploadButton.dataset.context);
+ }
+ } catch (e) {
+ if (window.ENABLE_DEBUG_MODE) {
+ console.warn("Unable to parse the context.", e);
+ }
+ }
+
+ if (context !== undefined) {
+ payload.metaData.tmpHash = context.tmpHash;
+ }
});
- uploadButton.dispatchEvent(event);
- });
const existingFiles = container.querySelector<HTMLElement>(".attachment__list__existingFiles");
if (existingFiles !== null) {
uploadButton.addEventListener("uploadStart", (event) => {
fileToAttachment(fileList, event.detail, editor);
});
- (0, Event_1.listenToCkeditor)(editor).uploadAttachment((payload) => {
+ (0, Event_1.listenToCkeditor)(editor)
+ .uploadAttachment((payload) => {
const event = new CustomEvent("ckeditorDrop", {
detail: payload,
});
uploadButton.dispatchEvent(event);
+ })
+ .collectMetaData((payload) => {
+ let context = undefined;
+ try {
+ if (uploadButton.dataset.context !== undefined) {
+ context = JSON.parse(uploadButton.dataset.context);
+ }
+ }
+ catch (e) {
+ if (window.ENABLE_DEBUG_MODE) {
+ console.warn("Unable to parse the context.", e);
+ }
+ }
+ if (context !== undefined) {
+ payload.metaData.tmpHash = context.tmpHash;
+ }
});
const existingFiles = container.querySelector(".attachment__list__existingFiles");
if (existingFiles !== null) {