From 65a24a5691f508190fe8a13b45357c11ea14e2a5 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 27 Feb 2024 14:56:40 +0100 Subject: [PATCH] chore: revert codemirror and `lz-string` workaround --- packages/client/builtin/Monaco.vue | 2 +- packages/client/builtin/ShikiMagicMove.vue | 2 +- packages/client/modules/mermaid.ts | 2 +- packages/client/setup/codemirror.ts | 6 ++---- packages/client/utils.ts | 4 ---- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/client/builtin/Monaco.vue b/packages/client/builtin/Monaco.vue index 13d311ec8f..46889a4036 100644 --- a/packages/client/builtin/Monaco.vue +++ b/packages/client/builtin/Monaco.vue @@ -15,7 +15,7 @@ Learn more: https://sli.dev/guide/syntax.html#monaco-editor import type * as monaco from 'monaco-editor' import { computed, nextTick, onMounted, ref } from 'vue' import { debounce } from '@antfu/utils' -import { lz } from '../utils' +import lz from 'lz-string' import { makeId } from '../logic/utils' const props = withDefaults(defineProps<{ diff --git a/packages/client/builtin/ShikiMagicMove.vue b/packages/client/builtin/ShikiMagicMove.vue index dfbc6aa2fa..a3fbaf85fa 100644 --- a/packages/client/builtin/ShikiMagicMove.vue +++ b/packages/client/builtin/ShikiMagicMove.vue @@ -2,7 +2,7 @@ import { ShikiMagicMovePrecompiled } from 'shiki-magic-move/vue' import type { KeyedTokensInfo } from 'shiki-magic-move/types' import { onMounted, onUnmounted, ref, watchEffect } from 'vue' -import { lz } from '../utils' +import lz from 'lz-string' import { useSlideContext } from '../context' import { makeId } from '../logic/utils' diff --git a/packages/client/modules/mermaid.ts b/packages/client/modules/mermaid.ts index 3cf01ecd7e..a89eb173c2 100644 --- a/packages/client/modules/mermaid.ts +++ b/packages/client/modules/mermaid.ts @@ -1,6 +1,6 @@ import mermaid from 'mermaid/dist/mermaid.esm.mjs' +import lz from 'lz-string' import { clearUndefined } from '@antfu/utils' -import { lz } from '../utils' import setupMermaid from '../setup/mermaid' import { makeId } from '../logic/utils' diff --git a/packages/client/setup/codemirror.ts b/packages/client/setup/codemirror.ts index dbe1ae1244..93a44e9a36 100644 --- a/packages/client/setup/codemirror.ts +++ b/packages/client/setup/codemirror.ts @@ -1,7 +1,7 @@ import type { Ref, WritableComputedRef } from 'vue' import { onClickOutside } from '@vueuse/core' import { watch } from 'vue' -import * as _CodeMirror from 'codemirror' +import { fromTextArea } from 'codemirror' import 'codemirror/mode/javascript/javascript' import 'codemirror/mode/css/css' import 'codemirror/mode/markdown/markdown' @@ -10,14 +10,12 @@ import 'codemirror/mode/htmlmixed/htmlmixed' import 'codemirror/addon/display/placeholder' import 'codemirror/lib/codemirror.css' -const CodeMirror = _CodeMirror.default ?? ('fromTextArea' in _CodeMirror ? _CodeMirror : globalThis.CodeMirror) - export async function useCodeMirror( textarea: Ref, input: Ref | WritableComputedRef, options: CodeMirror.EditorConfiguration = {}, ) { - const cm = CodeMirror.fromTextArea( + const cm = fromTextArea( textarea.value!, { theme: 'vars', diff --git a/packages/client/utils.ts b/packages/client/utils.ts index e2bb8f0bbd..d12d3c2d88 100644 --- a/packages/client/utils.ts +++ b/packages/client/utils.ts @@ -1,8 +1,4 @@ import type { RouteRecordRaw } from 'vue-router' -import * as _lz from 'lz-string' - -// @ts-expect-error compat -export const lz: typeof _lz = _lz.default ?? ('compress' in _lz ? _lz : globalThis.LZString) export function getSlideClass(route?: RouteRecordRaw, extra = '') { const classes = ['slidev-page', extra]