Skip to content

Commit

Permalink
ESlint Pass
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed May 23, 2021
1 parent 77ac35a commit 4f83117
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 90 deletions.
3 changes: 3 additions & 0 deletions src/app.postcss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
.btn {
@apply bg-indigo-500 hover:bg-indigo-700 rounded px-4 shadow;
}
.action-btn {
@apply rounded p-2 bg-indigo-400 shadow flex-auto text-white hover:bg-indigo-500;
}
38 changes: 16 additions & 22 deletions src/lib/components/actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
const exportImage = (event: Event, exporter: Exporter) => {
const canvas: HTMLCanvasElement = document.createElement('canvas');
const svg: HTMLElement = document.querySelector('#container svg');
debugger;
const box: DOMRect = svg.getBoundingClientRect();
canvas.width = box.width;
canvas.height = box.height;
Expand Down Expand Up @@ -63,7 +62,7 @@
};
const isClipboardAvailable = () => {
return window?.hasOwnProperty('ClipboardItem');
return Object.prototype.hasOwnProperty.call(window, 'ClipboardItem');
};
const clipboardCopy: Exporter = (canvas, context, image) => {
Expand All @@ -72,9 +71,10 @@
canvas.toBlob((blob) => {
try {
// @ts-ignore
// @ts-ignore: https://github.com/microsoft/TypeScript-DOM-lib-generator/pull/1004/files
navigator.clipboard.write([
// @ts-ignore
/* eslint-disable no-undef */
// @ts-ignore: https://github.com/microsoft/TypeScript/issues/43821
new ClipboardItem({
[blob.type]: blob
})
Expand All @@ -86,15 +86,15 @@
};
};
const onCopyClipboard = (event) => {
const onCopyClipboard = (event: Event) => {
exportImage(event, clipboardCopy);
};
const onDownloadPNG = (event) => {
const onDownloadPNG = (event: Event) => {
exportImage(event, downloadImage);
};
const onDownloadSVG = (event) => {
const onDownloadSVG = () => {
simulateDownload(
`mermaid-diagram-${moment().format('YYYYMMDDHHmmss')}.svg`,
`data:image/svg+xml;base64,${getBase64SVG()}`
Expand All @@ -106,13 +106,13 @@
document.execCommand('Copy');
};
let iUrl;
let svgUrl;
let mdCode;
let iUrl: string;
let svgUrl: string;
let mdCode: string;
let imagemodeselected = 'auto';
let userimagesize = 1080;
const unsubscribe = base64State.subscribe((b64Code) => {
base64State.subscribe((b64Code) => {
iUrl = `https://mermaid.ink/img/${b64Code}`;
svgUrl = `https://mermaid.ink/svg/${b64Code}`;
mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}/edit#${b64Code})`;
Expand All @@ -122,21 +122,21 @@
<Card title="Actions" isOpen={false}>
<div class="flex flex-wrap gap-2 m-2">
{#if isClipboardAvailable()}
<button class="btn w-full" on:click={onCopyClipboard}
<button class="action-btn w-full" on:click={onCopyClipboard}
><i class="far fa-copy" /> Copy Image to clipboard
</button>
{/if}
<button class="btn flex-auto" on:click={onDownloadPNG}>
<button class="action-btn flex-auto" on:click={onDownloadPNG}>
<i class="fas fa-download" /> PNG
</button>
<button class="btn flex-auto" on:click={onDownloadSVG}>
<button class="action-btn flex-auto" on:click={onDownloadSVG}>
<i class="fas fa-download" /> SVG
</button>
<button class="btn flex-auto">
<button class="action-btn flex-auto">
<a class="link-style" target="_blank" href={iUrl}
><i class="fas fa-external-link-alt" /> PNG</a>
</button>
<button class="btn flex-auto">
<button class="action-btn flex-auto">
<a class="link-style" target="_blank" href={svgUrl}
><i class="fas fa-external-link-alt" /> SVG</a>
</button>
Expand All @@ -160,9 +160,3 @@
</div>
</div>
</Card>

<style>
.btn {
@apply rounded p-2 bg-indigo-400 shadow flex-auto text-white hover:bg-indigo-500;
}
</style>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const initEditor = (monaco) => {
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const initEditor = (monaco): void => {
monaco.languages.register({ id: 'mermaid' });

// Register a tokens provider for the language
Expand Down Expand Up @@ -47,7 +48,7 @@ export const initEditor = (monaco) => {
// Register a completion item provider for the new language
monaco.languages.registerCompletionItemProvider('mermaid', {
provideCompletionItems: () => {
var suggestions = [
const suggestions = [
{
label: 'simpleText',
kind: monaco.languages.CompletionItemKind.Text,
Expand Down
11 changes: 5 additions & 6 deletions src/lib/components/view.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
import type { Mermaid } from 'mermaid';
const mermaid: Mermaid = (window.mermaid as unknown) as Mermaid;
let code: string = '';
let code = '';
let container: HTMLDivElement;
let error: boolean = false;
let outOfSync: boolean = false;
let manualUpdate: boolean = true;
let error = false;
let outOfSync = false;
let manualUpdate = true;
onMount(async () => {
codeStore.subscribe((state) => {
try {
Expand All @@ -27,7 +27,7 @@
delete container.dataset.processed;
mermaid.initialize(Object.assign({}, JSON.parse(state.mermaid)));
mermaid.init(container);
mermaid.render('graph-div', code, insertSvg);
mermaid.render('graph-div', code);
container.parentElement.parentElement.parentElement.scrollTop = scroll;
} else if (manualUpdate) {
manualUpdate = false;
Expand All @@ -48,7 +48,6 @@
}
});
});
const insertSvg = (svgCode, bindFunctions) => {};
</script>

<div id="view" class="p-2" class:error class:outOfSync>
Expand Down
60 changes: 0 additions & 60 deletions src/lib/form.ts

This file was deleted.

0 comments on commit 4f83117

Please sign in to comment.