feat: add format action to code composable
This commit is contained in:
@@ -2,7 +2,7 @@ import { useStorage } from "@vueuse/core"
|
|||||||
import copyTextToClipboard from "copy-text-to-clipboard"
|
import copyTextToClipboard from "copy-text-to-clipboard"
|
||||||
import qs from "query-string"
|
import qs from "query-string"
|
||||||
import { reactive, ref, watch } from "vue"
|
import { reactive, ref, watch } from "vue"
|
||||||
import { getCodeByQuery, submit } from "../api"
|
import { formatCode, getCodeByQuery, submit } from "../api"
|
||||||
import { sources } from "../templates"
|
import { sources } from "../templates"
|
||||||
import { Cache, Code, LANGUAGE, Status } from "../types"
|
import { Cache, Code, LANGUAGE, Status } from "../types"
|
||||||
import { atou, utoa } from "../utils"
|
import { atou, utoa } from "../utils"
|
||||||
@@ -136,3 +136,7 @@ export function share() {
|
|||||||
qs.stringifyUrl({ url: location.href, query: { share: base64 } }),
|
qs.stringifyUrl({ url: location.href, query: { share: base64 } }),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function format() {
|
||||||
|
code.value = await formatCode(code.value, code.language)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user