diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 17858327..f4f6f285 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -44,6 +44,7 @@ module.exports = { ], '@typescript-eslint/no-unsafe-member-access': 'off', '@typescript-eslint/no-unsafe-assignment': 'off', - 'es/no-regexp-lookbehind-assertions': 'error' + 'es/no-regexp-lookbehind-assertions': 'error', + curly: ['error', 'all'] } }; diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 49ae58b5..5498b747 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -48,4 +48,3 @@ jobs: parallel: true env: CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} - MERMAID_DISABLE_DEBOUNCE: 'true' diff --git a/.github/workflows/update-browserlist.yml b/.github/workflows/update-browserlist.yml index 450692d7..3e278a67 100644 --- a/.github/workflows/update-browserlist.yml +++ b/.github/workflows/update-browserlist.yml @@ -1,10 +1,9 @@ name: Update Browserslist on: - workflow_dispatch: push: - branches: - - develop - + branches-ignore: + - 'develop' + - 'master' jobs: build: runs-on: ubuntu-latest diff --git a/.vscode/settings.json b/.vscode/settings.json index 451f836e..70dc2f2f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "vitest.commandLine": "yarn test:unit", "vitest.enable": true, "testing.autoRun.mode": "rerun", - "svelte.enable-ts-plugin": true + "svelte.enable-ts-plugin": true, + "githubPullRequests.ignoredPullRequestBranches": ["develop"] } diff --git a/Dockerfile b/Dockerfile index 2f5182d0..b3ec27c9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ # Stop : press ctrl + c # or # docker stop mermaid-live-editor -FROM node:18.9.0 as mermaid-live-editor-builder +FROM node:18.11.0 as mermaid-live-editor-builder COPY --chown=node:node . /home WORKDIR /home RUN yarn install diff --git a/cypress/e2e/diagramUpdate.spec.ts b/cypress/e2e/diagramUpdate.spec.ts index b6b415f3..533a1adc 100644 --- a/cypress/e2e/diagramUpdate.spec.ts +++ b/cypress/e2e/diagramUpdate.spec.ts @@ -9,8 +9,10 @@ describe('Auto sync tests', () => { it('should dim diagram when code is edited', () => { cy.contains('Auto sync').click(); cy.get('#view').should('not.have.class', 'outOfSync'); + cy.get('#view').should('not.contain.text', 'Diagram out of sync.'); getEditor().type(' C --> Test'); cy.get('#view').should('have.class', 'outOfSync'); + cy.get('#view').should('contain.text', 'Diagram out of sync.'); cy.getLocalStorage('codeStore').snapshot(); }); @@ -19,7 +21,9 @@ describe('Auto sync tests', () => { cy.get('#view').should('not.have.class', 'outOfSync'); getEditor().type(' C --> Test'); cy.get('#view').should('have.class', 'outOfSync'); + cy.get('#view').should('contain.text', 'Diagram out of sync.'); getEditor().type(`${cmd}{enter}`); + cy.get('#view').should('not.contain.text', 'Diagram out of sync.'); cy.get('#view').should('not.have.class', 'outOfSync'); }); diff --git a/cypress/snapshots.js b/cypress/snapshots.js index 8f216dc0..a66a23cb 100644 --- a/cypress/snapshots.js +++ b/cypress/snapshots.js @@ -16,7 +16,7 @@ module.exports = { "1": "{\"code\":\"graph TD\\n A[Party] -->|Get money| B(Go shopping!!)\\n \",\"mermaid\":\"{\\n \\\"theme\\\": \\\"forest\\\",\\n \\\"test\\\": \\\"hello world\\\"\\n}\",\"autoSync\":true,\"updateDiagram\":true,\"loader\":{\"type\":\"files\",\"config\":{\"codeURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/code.mmd\",\"configURL\":\"https://gist.githubusercontent.com/sidharthv96/6268a23e673a533dcb198f241fd7012a/raw/4eb03887e6a41397e80bdcdbf94017c498f8f1e2/config.json\"}}}" } }, - "__version": "10.7.0", + "__version": "10.10.0", "Auto sync tests": { "should dim diagram when code is edited": { "1": "{\"code\":\"graph TD\\n A[Christmas] -->|Get money| B(Go shopping)\\n B --> C{Let me think}\\n C -->|One| D[Laptop]\\n C -->|Two| E[iPhone]\\n C -->|Three| F[fa:fa-car Car]\\n C --> Test\",\"mermaid\":\"{\\n \\\"theme\\\": \\\"default\\\"\\n}\",\"autoSync\":false,\"updateDiagram\":false}" diff --git a/package.json b/package.json index abefbebd..bb729565 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "license": "MIT", "scripts": { "dev": "vite dev", - "dev:test": "MERMAID_DISABLE_DEBOUNCE=true yarn dev", + "dev:test": "yarn dev", "build": "vite build", "preview": "vite preview", "lint": "prettier --check --cache --plugin-search-dir=. .;eslint --ignore-path .gitignore .", @@ -22,56 +22,55 @@ }, "devDependencies": { "@cypress/snapshot": "2.1.7", - "@sveltejs/adapter-static": "1.0.0-next.42", - "@sveltejs/kit": "1.0.0-next.480", + "@sveltejs/adapter-static": "1.0.0-next.44", + "@sveltejs/kit": "1.0.0-next.516", "@testing-library/jest-dom": "5.16.5", - "@testing-library/svelte": "3.2.1", + "@testing-library/svelte": "3.2.2", "@types/pako": "2.0.0", "@types/uuid": "8.3.4", - "@typescript-eslint/eslint-plugin": "5.36.2", - "@typescript-eslint/parser": "5.36.2", - "@vitest/ui": "0.23.1", - "autoprefixer": "10.4.8", + "@typescript-eslint/eslint-plugin": "5.40.1", + "@typescript-eslint/parser": "5.40.1", + "@vitest/ui": "0.24.3", + "autoprefixer": "10.4.12", "c8": "7.12.0", "chai": "4.3.6", "cssnano": "5.1.13", - "cy-verify-downloads": "0.1.8", - "cypress": "10.7.0", + "cy-verify-downloads": "0.1.11", + "cypress": "10.10.0", "cypress-localstorage-commands": "2.2.1", - "eslint": "8.23.0", + "eslint": "8.25.0", "eslint-config-prettier": "8.5.0", "eslint-plugin-cypress": "2.12.1", "eslint-plugin-es": "4.1.0", "eslint-plugin-postcss-modules": "2.0.0", "eslint-plugin-svelte3": "4.0.0", - "eslint-plugin-tailwindcss": "3.6.1", - "eslint-plugin-vitest": "0.0.8", + "eslint-plugin-tailwindcss": "3.6.2", + "eslint-plugin-vitest": "0.0.11", "esserializer": "1.3.2", "husky": "8.0.1", - "jsdom": "20.0.0", + "jsdom": "20.0.1", "lint-staged": "13.0.3", - "node-html-parser": "6.0.0", - "postcss": "8.4.16", + "node-html-parser": "6.1.1", + "postcss": "8.4.18", "postcss-load-config": "4.0.1", "prettier": "2.7.1", - "prettier-plugin-svelte": "2.7.0", - "svelte": "3.50.1", + "prettier-plugin-svelte": "2.8.0", + "svelte": "3.52.0", "svelte-preprocess": "4.10.7", "tailwindcss": "3.1.8", "tslib": "2.4.0", - "typescript": "4.8.3", - "vite": "3.1.0", - "vitest": "0.23.1" + "typescript": "4.8.4", + "vite": "3.1.8", + "vitest": "0.24.3" }, "dependencies": { - "@analytics/google-analytics": "1.0.3", "analytics": "0.8.1", "analytics-plugin-plausible": "0.0.6", - "daisyui": "2.25.0", + "daisyui": "2.31.0", "js-base64": "3.7.2", "mermaid": "9.2.0-rc1", "moment": "2.29.4", - "monaco-editor": "0.34.0", + "monaco-editor": "0.34.1", "monaco-mermaid": "1.0.6", "pako": "2.0.4", "random-word-slugs": "0.1.6", diff --git a/renovate.json b/renovate.json index 86d2a300..619bbb26 100644 --- a/renovate.json +++ b/renovate.json @@ -14,10 +14,6 @@ { "matchUpdateTypes": ["minor", "patch", "pin", "digest"], "automerge": true - }, - { - "matchDatasources": ["npm"], - "stabilityDays": 3 } ], "dependencyDashboard": true, diff --git a/src/app.html b/src/app.html index 9ad39ec3..4224cc58 100644 --- a/src/app.html +++ b/src/app.html @@ -11,7 +11,9 @@ - + + + %sveltekit.head% diff --git a/src/lib/components/actions.svelte b/src/lib/components/actions.svelte index 56476363..48784ef1 100644 --- a/src/lib/components/actions.svelte +++ b/src/lib/components/actions.svelte @@ -115,19 +115,19 @@ const onCopyClipboard = (event: Event) => { exportImage(event, clipboardCopy); - void logEvent('copyClipboard'); + logEvent('copyClipboard'); }; const onDownloadPNG = (event: Event) => { exportImage(event, downloadImage); - void logEvent('download', { + logEvent('download', { type: 'png' }); }; const onDownloadSVG = () => { simulateDownload(getFileName('svg'), `data:image/svg+xml;base64,${getBase64SVG()}`); - void logEvent('download', { + logEvent('download', { type: 'svg' }); }; @@ -135,7 +135,7 @@ const onCopyMarkdown = () => { (document.getElementById('markdown') as HTMLInputElement).select(); document.execCommand('Copy'); - void logEvent('copyMarkdown'); + logEvent('copyMarkdown'); }; let gistURL = ''; @@ -151,7 +151,7 @@ alert('Please enter a Gist URL first'); } window.location.href = `${window.location.pathname}?gist=${gistURL}`; - void logEvent('loadGist'); + logEvent('loadGist'); }; let iUrl: string; @@ -166,7 +166,7 @@ isNetlify = true; } stateStore.subscribe(({ code, serialized }) => { - iUrl = `${rendererUrl}/img/${serialized}`; + iUrl = `${rendererUrl}/img/${serialized}?type=png`; svgUrl = `${rendererUrl}/svg/${serialized}`; krokiUrl = `${krokiRendererUrl}/mermaid/svg/${pakoSerde.serialize(code)}`; mdCode = `[![](${iUrl})](${window.location.protocol}//${window.location.host}${window.location.pathname}#${serialized})`; @@ -180,26 +180,24 @@ > Copy Image to clipboard {/if} - - - - - - - - - - diff --git a/src/lib/components/card/card.svelte b/src/lib/components/card/card.svelte index 27008d9e..24ea56f4 100644 --- a/src/lib/components/card/card.svelte +++ b/src/lib/components/card/card.svelte @@ -14,7 +14,8 @@
(isOpen = !isOpen)}> + on:click={() => (isOpen = !isOpen)} + on:keypress={() => (isOpen = !isOpen)}>
diff --git a/src/lib/components/card/tabs.svelte b/src/lib/components/card/tabs.svelte index 0f99e362..433d6628 100644 --- a/src/lib/components/card/tabs.svelte +++ b/src/lib/components/card/tabs.svelte @@ -19,7 +19,10 @@
- (isOpen = !isOpen)}> + (isOpen = !isOpen)} + on:keypress|stopPropagation={() => (isOpen = !isOpen)}> {#if isCloseable} {/if} @@ -29,7 +32,8 @@ {#each tabs as tab}
toggleTabs(tab)}> + on:click|stopPropagation={() => toggleTabs(tab)} + on:keypress|stopPropagation={() => toggleTabs(tab)}> {tab.title}
diff --git a/src/lib/components/editor.svelte b/src/lib/components/editor.svelte index 0b5b8572..e7a971e0 100644 --- a/src/lib/components/editor.svelte +++ b/src/lib/components/editor.svelte @@ -7,7 +7,6 @@ import { onMount } from 'svelte'; import initEditor from 'monaco-mermaid'; import { logEvent } from '$lib/util/stats'; - import { debounceEnabled } from '$lib/util/env'; let divEl: HTMLDivElement = null; let editor: monaco.editor.IStandaloneCodeEditor; @@ -37,10 +36,8 @@ Monaco?.editor.setModelLanguage(editor.getModel(), language); } - // Display errors if present - if (errorMarkers.length > 0) { - Monaco?.editor.setModelMarkers(editor.getModel(), 'test', errorMarkers); - } + // Display/clear errors + Monaco?.editor.setModelMarkers(editor.getModel(), 'mermaid', errorMarkers); }); themeStore.subscribe(({ isDark }) => { @@ -55,21 +52,6 @@ } }; - // Debounce state updates to avoid performance issues - let debounce: { [key: string]: number } = {}; - const updateHandler = (newText: string) => { - text = newText; - const mode = $stateStore.editorMode; - if (debounceEnabled) { - clearTimeout(debounce[mode]); - debounce[mode] = window.setTimeout(() => { - handleUpdate(text, mode); - }, 300); - } else { - handleUpdate(text, mode); - } - }; - const loadMonaco = async () => { let i = 0; while (i++ < 500) { @@ -89,7 +71,8 @@ initEditor(Monaco); editor = Monaco.editor.create(divEl, editorOptions); editor.onDidChangeModelContent(() => { - updateHandler(editor.getValue()); + text = editor.getValue(); + handleUpdate(text, $stateStore.editorMode); }); editor.addAction({ id: 'mermaid-render-diagram', @@ -97,7 +80,7 @@ keybindings: [Monaco.KeyMod.CtrlCmd | Monaco.KeyCode.Enter], run: function () { syncDiagram(); - void logEvent('renderDiagram', { + logEvent('renderDiagram', { method: 'keyboadShortcut' }); } diff --git a/src/lib/components/history/history.svelte b/src/lib/components/history/history.svelte index 45d16380..35d3da43 100644 --- a/src/lib/components/history/history.svelte +++ b/src/lib/components/history/history.svelte @@ -161,6 +161,7 @@ {name} {:else} diff --git a/src/lib/components/navbar.svelte b/src/lib/components/navbar.svelte index bdaf56b0..99e3a309 100644 --- a/src/lib/components/navbar.svelte +++ b/src/lib/components/navbar.svelte @@ -39,7 +39,7 @@ ]; -