From 19e9e9880253cc6d3d36ace9bb4a3d12036ad9a6 Mon Sep 17 00:00:00 2001 From: Duong Thanh An Date: Sat, 31 Dec 2022 12:26:57 +0700 Subject: [PATCH] Fix shared property page wrong content when switching document --- app/pencil-core/common/DocumentHandler.js | 8 +++++--- app/pencil-core/common/pencil.js | 1 - app/views/PageDetailDialog.xhtml | 3 +++ app/views/editors/SharedPropertyEditor.js | 8 ++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/pencil-core/common/DocumentHandler.js b/app/pencil-core/common/DocumentHandler.js index 50828928..5de2138c 100644 --- a/app/pencil-core/common/DocumentHandler.js +++ b/app/pencil-core/common/DocumentHandler.js @@ -114,7 +114,7 @@ DocumentHandler.prototype.loadDocumentFromArguments = function (filePath) { FontLoader.instance.loadFonts(); this.controller.handleNewDocumentFromImage(filePath); } - + } DocumentHandler.prototype.pickupTargetFileToSave = function (callback) { @@ -269,7 +269,7 @@ DocumentHandler.prototype.newDocument = function () { parentPageId: null, activateAfterCreate: "activatePage" }; - + var page = thiz.controller.newPage(options); thiz.controller.modified = false; }, 50); @@ -296,9 +296,11 @@ DocumentHandler.prototype.resetDocument = function () { this.controller.applicationPane.pageListView.currentParentPage = null; FontLoader.instance.setDocumentRepoDir(path.join(this.tempDir.name, "fonts")); - + if (StencilCollectionBuilder.activeCollectionInfo) { StencilCollectionBuilder.cleanup(); CollectionManager.reloadActiveBuilderCollection(); } + + Pencil.invalidateSharedEditor(); }; diff --git a/app/pencil-core/common/pencil.js b/app/pencil-core/common/pencil.js index 07699695..c20032da 100644 --- a/app/pencil-core/common/pencil.js +++ b/app/pencil-core/common/pencil.js @@ -179,7 +179,6 @@ Pencil.boot = function (event) { }; Pencil.handleArguments = function() { var appArguments = remote.getGlobal('sharedObject').appArguments; - console.log("appArguments", appArguments); if (appArguments && appArguments.length > 1) { var filePath = null; for (var i = 1; i < appArguments.length; i ++) { diff --git a/app/views/PageDetailDialog.xhtml b/app/views/PageDetailDialog.xhtml index 36b5ab9a..bb60d1e6 100644 --- a/app/views/PageDetailDialog.xhtml +++ b/app/views/PageDetailDialog.xhtml @@ -56,6 +56,9 @@ align-items: center; margin-top: 0.5em; } + @copyLinksBox > * + * { + margin-left: 0.5em; + } @colorButton { margin-left: 0.5em; } diff --git a/app/views/editors/SharedPropertyEditor.js b/app/views/editors/SharedPropertyEditor.js index e2071ca1..41157968 100644 --- a/app/views/editors/SharedPropertyEditor.js +++ b/app/views/editors/SharedPropertyEditor.js @@ -29,7 +29,7 @@ SharedPropertyEditor.prototype.setup = function () { thiz.validationEditorUI(); }, false); - this.propertyContainer.style.display = "none"; + this.node().setAttribute("mode", "None"); this.propertyContainer.addEventListener("click", function(event) { if (event.target.getAttribute("command") && event.target.getAttribute("command") == "setDefault") { @@ -149,9 +149,7 @@ SharedPropertyEditor.prototype.attach = function (target) { var thiz = this; var currentGroupNode = null; - this.propertyContainer.style.display = "none"; this.propertyContainer.style.opacity = "0"; - this.noTargetMessagePane.style.display = "none"; var uuid = Util.newUUID(); this.currentExecutorUUID = uuid; @@ -195,7 +193,6 @@ SharedPropertyEditor.prototype.attach = function (target) { }, document, thiz)); } - thiz.propertyContainer.style.display = "flex"; thiz.propertyContainer.style.opacity = "1"; thiz.validationEditorUI(); return; @@ -311,7 +308,7 @@ SharedPropertyEditor.prototype.addPropertyTitle = function (title) { SharedPropertyEditor.prototype.detach = function () { this.propertyContainer.innerHTML = ""; this.target = null; - if (Pencil.controller.activePage) { + if (Pencil.controller.doc && Pencil.controller.activePage) { this.node().setAttribute("mode", "Page"); this.addPropertyTitle(Pencil.controller.activePage.name); this.pagePropertyWidget = new PageDetailDialog(); @@ -328,7 +325,6 @@ SharedPropertyEditor.prototype.detach = function () { Dom.emitEvent("p:TitleChanged", this.node(), {}); }; SharedPropertyEditor.prototype.savePageProperties = function (shouldReloadOnSaved) { - console.log("savePageProperties"); if (!this.isPagePropertyMode()) return; if (!this.pagePropertyWidget.isPageInfoValid()) { this.pagePropertyWidget.setup({