From b0c5f54a5a085b00b3a2209b5f44a8b4f2e15a0f Mon Sep 17 00:00:00 2001 From: Alexandre Date: Thu, 5 Sep 2024 12:20:18 -0300 Subject: [PATCH] Remove thumbnail --- src/components/editor/Editor.ts | 11 +--- src/components/feature-image/Thumbnail.ts | 70 ----------------------- 2 files changed, 1 insertion(+), 80 deletions(-) delete mode 100644 src/components/feature-image/Thumbnail.ts diff --git a/src/components/editor/Editor.ts b/src/components/editor/Editor.ts index 966e698..e19417d 100644 --- a/src/components/editor/Editor.ts +++ b/src/components/editor/Editor.ts @@ -12,7 +12,6 @@ import { IMemento } from "@/core/IMemento"; import { DependencyContainer } from "@/core/DependencyContainer"; import { MediaInputter } from "../media-inputter/MediaInputter"; import { InputLinkBoxWrapper } from "../floating-toolbar/link-box/InputLinkBoxWrapper"; -import { Thumbnail } from "../feature-image/Thumbnail"; export class Editor extends BaseUIComponent { @@ -22,7 +21,6 @@ export class Editor extends BaseUIComponent { private memento: IMemento; private title?: Title; - private thumbnail?: Thumbnail; private content?: Content; private addBlock: AddBlockWrapper; private textFloatingToolbar: TextContextFloatingToolbar; @@ -36,7 +34,6 @@ export class Editor extends BaseUIComponent { blockOperationsService: IBlockOperationsService, memento: IMemento, title: Title, - thumbnail: Thumbnail, content: Content, addBlock: AddBlockWrapper, floatingToolbar: TextContextFloatingToolbar, @@ -50,7 +47,6 @@ export class Editor extends BaseUIComponent { elementFactoryService: elementFactoryService, blockOperationsService: blockOperationsService, title: title, - thumbnail: thumbnail, content: content, addBlock: addBlock, floatingToolbar: floatingToolbar, @@ -93,10 +89,6 @@ export class Editor extends BaseUIComponent { contentWrapper.appendChild(this.props.title.htmlElement); } - if (window.editorConfig?.enableThumbnail || false) { - contentWrapper.appendChild(this.props.thumbnail.htmlElement); - } - // Content is required contentWrapper.appendChild(this.props.content.htmlElement); @@ -134,10 +126,9 @@ export class Editor extends BaseUIComponent { const blockOperationsService = DependencyContainer.Instance.resolve("IBlockOperationsService"); const memento = DependencyContainer.Instance.resolve("IMemento"); const inputLinkBoxWrapper = new InputLinkBoxWrapper(); - const thumbnail = new Thumbnail(); if (!Editor.instance) { - Editor.instance = new Editor(elementFactoryService, blockOperationsService, memento, title, thumbnail, content, addBlock, textFloatingToolbar, quickMenu, tableFloatingToolbar, mediaInputter, inputLinkBoxWrapper); + Editor.instance = new Editor(elementFactoryService, blockOperationsService, memento, title, content, addBlock, textFloatingToolbar, quickMenu, tableFloatingToolbar, mediaInputter, inputLinkBoxWrapper); } return Editor.instance; diff --git a/src/components/feature-image/Thumbnail.ts b/src/components/feature-image/Thumbnail.ts deleted file mode 100644 index aee8d8e..0000000 --- a/src/components/feature-image/Thumbnail.ts +++ /dev/null @@ -1,70 +0,0 @@ -import { BaseUIComponent } from "../common/BaseUIComponent"; - -export class Thumbnail extends BaseUIComponent { - - constructor() { - super({}); - } - - init() { - const div = document.createElement("div"); - div.id = "setFeaturedImage"; - div.classList.add("upload-content", "content-data"); - - div.style.marginLeft = "1.3rem"; - - const label = document.createElement("label"); - label.classList.add("blue-button"); - label.innerText = "Set featured image"; - - div.appendChild(label); - - label.addEventListener('click', () => { - this.promptFileUpload(); - }); - - return div; - } - - promptFileUpload(): void { - const fileInput = document.createElement('input'); - fileInput.type = 'file'; - fileInput.accept = 'image/*'; - fileInput.style.display = 'none'; - - document.body.appendChild(fileInput); - - fileInput.addEventListener('change', async (event: Event) => { - const file = (event.target as HTMLInputElement).files?.[0]; - if (file) { - const imageUrl = await this.uploadImage(file); - this.setFeaturedImage(imageUrl); - } - - document.body.removeChild(fileInput); - }); - - fileInput.click(); - } - - async uploadImage(file: File): Promise { - const formData = new FormData(); - formData.append('image', file); - - const response = await fetch('your-upload-url', { - method: 'POST', - body: formData - }); - const data = await response.json(); - return data.imageUrl; - } - - setFeaturedImage(imageUrl: string): void { - const imageElement = document.createElement('img'); - imageElement.src = imageUrl; - imageElement.style.width = '100%'; - - const container = document.getElementById('setFeaturedImage'); - container?.appendChild(imageElement); - } -} \ No newline at end of file