Przeglądaj źródła

Merge branch 'master' into remove-jlicon-rendermime-interfaces

Max Klein 5 lat temu
rodzic
commit
59b2713711

+ 16 - 7
packages/docmanager-extension/src/index.ts

@@ -486,16 +486,25 @@ function addCommands(
           buttons: [Dialog.okButton()]
         });
       }
-      return showDialog({
-        title: `Reload ${type} from Disk`,
-        body: `Are you sure you want to reload
+      if (context.model.dirty) {
+        return showDialog({
+          title: `Reload ${type} from Disk`,
+          body: `Are you sure you want to reload
           the ${type} from the disk?`,
-        buttons: [Dialog.cancelButton(), Dialog.warnButton({ label: 'Reload' })]
-      }).then(result => {
-        if (result.button.accept && !context.isDisposed) {
+          buttons: [
+            Dialog.cancelButton(),
+            Dialog.warnButton({ label: 'Reload' })
+          ]
+        }).then(result => {
+          if (result.button.accept && !context.isDisposed) {
+            return context.revert();
+          }
+        });
+      } else {
+        if (!context.isDisposed) {
           return context.revert();
         }
-      });
+      }
     }
   });
 

+ 5 - 2
packages/htmlviewer/src/index.tsx

@@ -90,8 +90,11 @@ export class HTMLViewer extends DocumentWidget<IFrame>
       'refresh',
       new ToolbarButton({
         icon: refreshIcon,
-        onClick: () => {
-          this.content.url = this.content.url;
+        onClick: async () => {
+          if (!this.context.model.dirty) {
+            await this.context.revert();
+            this.update();
+          }
         },
         tooltip: 'Rerender HTML Document'
       })