Skip to content

Commit

Permalink
Merge pull request #6 from WeeJeWel/master
Browse files Browse the repository at this point in the history
Copy Markdown
  • Loading branch information
knsv committed Jan 11, 2020
2 parents c91762c + 5d320bc commit 9314505
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
1 change: 1 addition & 0 deletions docs/bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -2476,5 +2476,6 @@
#view.svelte-1lgruaz{border:1px solor darkred;flex:1}.error.svelte-1lgruaz{opacity:0.5}
#card.svelte-94c5zs{border:1px solid lightgray;margin-bottom:16px}#title.svelte-94c5zs{border-bottom:1px solid lightgray}#content.svelte-94c5zs{padding-top:16px}.padding.svelte-94c5zs{padding:16px}
#tag.svelte-kzz8td{height:auto;margin:0 8px 0 0;padding:0 7px;font-size:12px;line-height:20px;white-space:nowrap;border:1px solid #d9d9d9;border-radius:4px;cursor:default;font-size:smaller;color:#52c41a;background:#f6ffed;border-color:#b7eb8f;margin-left:8px}
#markdown.svelte-13581ad{padding:7px;font-family:monospace;font-size:14px;width:300px}label[for="markdown"].svelte-13581ad{cursor:pointer;color:-webkit-link;color:-moz-link;color:blue;text-decoration:underline}
#editor-root.svelte-f0aro2{display:flex;height:100%}#col1.svelte-f0aro2{width:35%}#col2.svelte-f0aro2{width:65%;padding-left:32px}#app-title.svelte-f0aro2{border-bottom:1px solid lightgrey;padding-bottom:32px;margin-bottom:32px;font-size:28px;font-weight:400;margin-top:0}#power.svelte-f0aro2{width:100%;display:flex;justify-content:flex-end;align-items:center}
#view-page.svelte-ylwsal{display:flex;height:100%}
40 changes: 20 additions & 20 deletions docs/bundle.js

Large diffs are not rendered by default.

29 changes: 27 additions & 2 deletions src/components/Links.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,36 @@ export const onDownloadSVG = event => {
)}.svg`
console.log('event', event);
};
export const onCopyMarkdown = event => {
event.target.select();
document.execCommand('Copy');
}
let url = '/mermaid-live-editor/#/view';
let iUrl;
let mdCode;
const unsubscribe = codeStore.subscribe( state => {
url = '/mermaid-live-editor/#/view/' + Base64.encode(JSON.stringify(state));
iUrl = `https://mermaid.ink/img/${Base64.encode(JSON.stringify(state))}`;
mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#/edit/${Base64.encode(JSON.stringify(state))})`;
});
</script>

<style></style>
<style>
#markdown {
padding: 7px;
font-family: monospace;
font-size: 14px;
width: 300px;
}
label[for="markdown"] {
cursor: pointer;
color: -webkit-link;
color: -moz-link;
color: blue;
text-decoration: underline;
}
</style>

<div id="links" >
<a href="{url}" use:link>Link to view</a>
Expand All @@ -69,4 +89,9 @@ const unsubscribe = codeStore.subscribe( state => {
<a href="{url}" download='' on:click={onDownloadPNG}>
Download PNG
</a>
</div>
</div>

<p>
<label for="markdown">Copy Markdown</label>
<input id="markdown" type="text" value="{mdCode}" on:click={onCopyMarkdown} />
</p>

0 comments on commit 9314505

Please sign in to comment.