Skip to content
This repository has been archived by the owner on Nov 16, 2024. It is now read-only.

Commit

Permalink
fix: unable to format script tag in Vue SFC
Browse files Browse the repository at this point in the history
  • Loading branch information
aiktb committed Oct 22, 2024
1 parent e712126 commit 1ba297d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion app/components/code-mirror-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import { EditorView, keymap } from "@codemirror/view";
import { githubDark, githubLight } from "@uiw/codemirror-theme-github";
import CodeMirror from "@uiw/react-codemirror";
import { useTheme } from "next-themes";
import * as parserBabel from "prettier/parser-babel";
import * as parserHtml from "prettier/parser-html";
import * as parserPostCSS from "prettier/parser-postcss";
import * as parserTypeScript from "prettier/parser-typescript";
import * as prettierPluginESTree from "prettier/plugins/estree";
import * as prettier from "prettier/standalone";

interface CodeMirrorEditorProps {
Expand Down Expand Up @@ -47,7 +50,13 @@ const CodeMirrorEditorProps = ({ code, onChange }: CodeMirrorEditorProps) => {
prettier
.formatWithCursor(editor.state.doc.toString(), {
parser: "vue",
plugins: [parserHtml, parserPostCSS],
plugins: [
prettierPluginESTree,
parserTypeScript,
parserBabel,
parserHtml,
parserPostCSS,
],
cursorOffset: editor.state.selection.main.head,
})
.then(({ formatted, cursorOffset }) => {
Expand Down

0 comments on commit 1ba297d

Please sign in to comment.