Skip to content

How to add other themes? #181

Answered by onurusluca
onurusluca asked this question in Q&A
Discussion options

You must be logged in to vote

After some research, I have come up with this:

import { Codemirror } from "vue-codemirror";
import { json } from "@codemirror/lang-json";
import { oneDark } from "@codemirror/theme-one-dark";
import { EditorView } from "@codemirror/view";

const codeMirrorExtensions = computed(() => {
  const extensionConfig = [];
  extensionConfig.push(json(), EditorView.lineWrapping // This will wrap long lines of code );

  // If dark mode, add oneDark
  if (isDark.value) {
    extensionConfig.push(oneDark);
  }
  return extensionConfig;
});

This works fine enough. Though import { EditorView } from "@codemirror/view"; returns type error.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by onurusluca
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant