From d864c811c7e610ff9b48a1c2d8a34b7788c3e52e Mon Sep 17 00:00:00 2001 From: lovefields Date: Fri, 11 Oct 2024 20:50:23 +0900 Subject: [PATCH] fix: editor image --- package.json | 2 +- src/runtime/components/DragonEditor.vue | 2 +- src/runtime/utils/block.ts | 4 ++-- src/runtime/utils/convertor.ts | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 35cf7c7..8fc4a06 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dragon-editor", - "version": "3.4.1", + "version": "3.4.2", "description": "Javascript WYSIWYG editor in Nuxt3!", "repository": { "type": "git", diff --git a/src/runtime/components/DragonEditor.vue b/src/runtime/components/DragonEditor.vue index d3e7e5c..eaced1c 100644 --- a/src/runtime/components/DragonEditor.vue +++ b/src/runtime/components/DragonEditor.vue @@ -604,7 +604,7 @@ function getContentData(): DEContentData { } function setContentData(data: DEContentData) { - _setContentData(data, editorStore); + _setContentData(data, editorStore, props.imageHostURL); } function moveBlock(type: "up" | "down") { diff --git a/src/runtime/utils/block.ts b/src/runtime/utils/block.ts index 7ba1c0d..ab264cd 100644 --- a/src/runtime/utils/block.ts +++ b/src/runtime/utils/block.ts @@ -95,7 +95,7 @@ export function _createListItemBlock(child: DEListItem = { textContent: "", clas } // 이미지 블럭 생성 -export function _createImageBlock(data: DEImageBlock): HTMLDivElement { +export function _createImageBlock(data: DEImageBlock, imageHostURL: string): HTMLDivElement { const $wrap = document.createElement("div") as HTMLDivElement; const $div = document.createElement("div") as HTMLDivElement; const $leftBtn = document.createElement("button") as HTMLButtonElement; @@ -117,7 +117,7 @@ export function _createImageBlock(data: DEImageBlock): HTMLDivElement { $div.dataset["maxwidth"] = String(data.maxWidth); } - $image.src = data.src; + $image.src = imageHostURL + data.src; $image.width = data.width; $image.height = data.height; $image.draggable = false; diff --git a/src/runtime/utils/convertor.ts b/src/runtime/utils/convertor.ts index 4278433..78822bf 100644 --- a/src/runtime/utils/convertor.ts +++ b/src/runtime/utils/convertor.ts @@ -37,7 +37,7 @@ export function _getContentData($content: HTMLDivElement, imageHostURL: string): } // 데이터를 화면으로 변환 -export function _setContentData(data: DEContentData, store: any) { +export function _setContentData(data: DEContentData, store: any, imageHostURL: string) { const childList: HTMLElement[] = []; data.forEach((item) => { @@ -52,7 +52,7 @@ export function _setContentData(data: DEContentData, store: any) { childList.push(_createListBlock(item)); break; case "image": - childList.push(_createImageBlock(item)); + childList.push(_createImageBlock(item,imageHostURL)); break; case "code": childList.push(_createCodeBlock(item));