diff --git a/packages/editor/src/views/editor/layouts/sidebar/SidebarHtmlPanel.vue b/packages/editor/src/views/editor/layouts/sidebar/SidebarHtmlPanel.vue index 9c0d8f1..2f1bcdc 100644 --- a/packages/editor/src/views/editor/layouts/sidebar/SidebarHtmlPanel.vue +++ b/packages/editor/src/views/editor/layouts/sidebar/SidebarHtmlPanel.vue @@ -53,7 +53,7 @@ function update(method: string){ if(data.type === 'panel' && object.isHtmlPanel) return; if(data.type === 'sprite' && object.isHtmlSprite) return; - const _json = object.toJSON(); + const _json = object.toJSON() as any; _json.object.type = data.type === 'panel' ? 'HtmlSprite' : 'HtmlPanel'; _json.object.options.isSprite = !_json.object.options.isSprite; @@ -135,19 +135,24 @@ function updateFileList(fList: UploadFileInfo[]) { isSprite: data.type ==='sprite', fileName: file.name }).then(htmlPlaneObj => { - data.codes = htmlPlaneObj.options.codes; + object.options.codes = htmlPlaneObj.options.codes; + object.options.isSingleHtml = htmlPlaneObj.options.isSingleHtml; - const _json = object.toJSON(); - Loader.objectLoader.copyAttrByData(htmlPlaneObj, _json.object) + data.codes = object.options.codes; - object.parent?.add(htmlPlaneObj); + // Keep object identity (id/uuid) so scene tree and context menu references stay valid. + while (object.element.firstChild) { + object.element.removeChild(object.element.firstChild); + } - object.parent?.remove(object); + while (htmlPlaneObj.element.firstChild) { + object.element.appendChild(htmlPlaneObj.element.firstChild); + } - App.selected = htmlPlaneObj; - - Hooks.useDispatchSignal("objectSelected", htmlPlaneObj); - }).catch((e:Error) => window.$message?.error(e.message)); + App.selected = object; + Hooks.useDispatchSignal("objectSelected", object); + }).catch((e:Error) => window.$message?.error(e.message)) + .finally(() => URL.revokeObjectURL(tempURL)); } function getCanEdit(name: string) {