fix(editor): keep html panel identity on upload refresh
This commit is contained in:
parent
5368e52f0d
commit
985c8d39fc
@ -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) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user