Explorar o código

add window.location.hash in navigationcontainr.js

zahmis %!s(int64=5) %!d(string=hai) anos
pai
achega
4c03012883

+ 24 - 30
src/client/js/components/Navbar/ThreeStrandedButton.jsx

@@ -13,36 +13,30 @@ const ThreeStrandedButton = (props) => {
 
   return (
     <div className="btn-group grw-three-stranded-button" role="group " aria-label="three-stranded-button">
-      <a href="#view">
-        <button
-          type="button"
-          className="btn btn-outline-primary view-button"
-          onClick={() => { threeStrandedButtonClickedHandler('view') }}
-        >
-          <i className="icon-control-play icon-fw" />
-          { t('view') }
-        </button>
-      </a>
-      <a href="#edit">
-        <button
-          type="button"
-          className="btn btn-outline-primary edit-button"
-          onClick={() => { threeStrandedButtonClickedHandler('edit') }}
-        >
-          <i className="icon-note icon-fw" />
-          { t('Edit') }
-        </button>
-      </a>
-      <a href="#hackmd">
-        <button
-          type="button"
-          className="btn btn-outline-primary hackmd-button"
-          onClick={() => { threeStrandedButtonClickedHandler('hackmd') }}
-        >
-          <i className="fa fa-fw fa-file-text-o" />
-          { t('hackmd.hack_md') }
-        </button>
-      </a>
+      <button
+        type="button"
+        className="btn btn-outline-primary view-button"
+        onClick={() => { threeStrandedButtonClickedHandler('view') }}
+      >
+        <i className="icon-control-play icon-fw" />
+        { t('view') }
+      </button>
+      <button
+        type="button"
+        className="btn btn-outline-primary edit-button"
+        onClick={() => { threeStrandedButtonClickedHandler('edit') }}
+      >
+        <i className="icon-note icon-fw" />
+        { t('Edit') }
+      </button>
+      <button
+        type="button"
+        className="btn btn-outline-primary hackmd-button"
+        onClick={() => { threeStrandedButtonClickedHandler('hackmd') }}
+      >
+        <i className="fa fa-fw fa-file-text-o" />
+        { t('hackmd.hack_md') }
+      </button>
     </div>
   );
 

+ 8 - 0
src/client/js/services/NavigationContainer.js

@@ -91,17 +91,25 @@ export default class NavigationContainer extends Container {
       $('body').removeClass('on-edit');
       $('body').removeClass('builtin-editor');
       $('body').removeClass('hackmd');
+      if (window.location.hash === '') {
+        return;
+      }
+
+      window.history.replaceState('', '', window.location.href);
     }
 
     if (editorMode === 'edit') {
       $('body').addClass('on-edit');
       $('body').addClass('builtin-editor');
+      window.location.hash = '#edit';
     }
 
     if (editorMode === 'hackmd') {
       $('body').addClass('on-edit');
       $('body').addClass('hackmd');
       $('body').removeClass('builtin-editor');
+      window.location.hash = '#hackmd';
+
     }
 
     this.updateDrawerMode({ ...this.state, editorMode }); // generate newest state object