Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed May 4, 2021
1 parent 068de0c commit a22e499
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<link rel="icon" type="image/png" href="favicon.png" />
<link rel="stylesheet" href="styles.css" />
<link rel="stylesheet" href="dist/bundle.css" />
<link rel="stylesheet" href="bundle.css" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css"
Expand Down Expand Up @@ -55,6 +55,6 @@
/>
</head>
<body>
<script src="dist/bundle.js"></script>
<script src="bundle.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@
"yarn": "1.22.10",
"npm": "7.11.2"
}
}
}
14 changes: 8 additions & 6 deletions src/code-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export const updateConfig = (config, updateEditor) => {
codeStore.set({ ...state, mermaid: config, updateEditor });
};

const unsubscribe = codeStore.subscribe((state) => {
const currentLocation = get(location).split('/')[1];
replace(
`/${currentLocation || 'edit'}/` + Base64.encodeURI(JSON.stringify(state))
);
});
export const initURLSubscription = () => {
codeStore.subscribe((state) => {
const currentLocation = get(location).split('/')[1];
replace(
`/${currentLocation || 'edit'}/` + Base64.encodeURI(JSON.stringify(state))
);
});
};
13 changes: 9 additions & 4 deletions src/routes/Edit.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<script>
import { onMount } from 'svelte';
import { codeStore, updateCode, updateCodeStore } from '../code-store.js';
import {
codeStore,
updateCode,
updateCodeStore,
initURLSubscription,
} from '../code-store.js';
import Editor from '../components/Editor.svelte';
import Config from '../components/Config.svelte';
import View from '../components/View.svelte';
Expand All @@ -11,6 +16,8 @@
import pkg from '@mermaid/package.json';
import moment from 'moment';
export let mermaidVersion = pkg.version;
export let params = {};
let historyList = [];
onMount(async () => {
ga('send', 'pageview');
Expand All @@ -20,7 +27,6 @@
historyList = JSON.parse(localStorage.getItem(historyListKey) || '[]');
let hisCode =
historyList.length > 0 ? historyList[historyList.length - 1] : null;
if (params.data) {
fromUrl(params.data);
} else if (hisCode) {
Expand All @@ -32,7 +38,7 @@
} else {
loadSampleDiagram('Flow Chart');
}
initURLSubscription();
let code = null;
codeStore.subscribe((state) => {
code = (state && state.code) || code;
Expand All @@ -54,7 +60,6 @@
}, 1 * 60 * 1000);
});
export let params = {};
const samples = {
'Flow Chart': `graph TD
A[Christmas] -->|Get money| B(Go shopping)
Expand Down
5 changes: 5 additions & 0 deletions src/routes/View.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<script>
import { onMount } from 'svelte';
import View from '../components/View.svelte';
import { fromUrl } from '../code-store.js';
export let params = {};
onMount(async () => {
ga('send', 'pageview');
if (params.data) {
fromUrl(params.data);
}
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = {
mainFields: ['svelte', 'browser', 'module', 'main'],
},
output: {
path: __dirname + '/docs/dist',
path: path.join(__dirname, '/docs'),
filename: '[name].js',
chunkFilename: '[name].[id].js',
},
Expand Down

0 comments on commit a22e499

Please sign in to comment.