diff --git a/src/editor/index.ts b/src/editor/index.ts index 4715f3b..beb18e2 100644 --- a/src/editor/index.ts +++ b/src/editor/index.ts @@ -5,5 +5,7 @@ export * from "./tiptap/shared"; export * from "./tiptap/extensions"; export * from "./tiptap/useTiptapEditor"; export * from "./tiptap/useTiptapView"; +export { supportedCodeLanguages } from "../utils/Prism"; +export type { CodeLanguageOption } from "../utils/Prism"; export { default as PrismCodeBlock } from "./tiptap/PrismCodeBlock"; export { enhancePrismCodeBlock } from "./tiptap/PrismCodeBlockView"; diff --git a/src/utils/Prism.ts b/src/utils/Prism.ts index 5985c8c..d96877f 100644 --- a/src/utils/Prism.ts +++ b/src/utils/Prism.ts @@ -18,6 +18,34 @@ import "prismjs/components/prism-sql"; import "prismjs/components/prism-typescript"; import "prismjs/components/prism-yaml"; +/** Prism 已加载并支持语法高亮的代码语言。 */ +export type CodeLanguageOption = { + label: string; + value: string; +}; + +/** 编辑器可用的代码语言,按名称首字母排序。 */ +export const supportedCodeLanguages: CodeLanguageOption[] = [ + { label: "Apache Config", value: "apacheconf" }, + { label: "Bash", value: "bash" }, + { label: "CSS", value: "css" }, + { label: "HTML", value: "html" }, + { label: "INI", value: "ini" }, + { label: "Java", value: "java" }, + { label: "JavaScript", value: "javascript" }, + { label: "JSON", value: "json" }, + { label: "Less", value: "less" }, + { label: "Nginx", value: "nginx" }, + { label: "PHP", value: "php" }, + { label: "Properties", value: "properties" }, + { label: "Shell", value: "sh" }, + { label: "SQL", value: "sql" }, + { label: "TypeScript", value: "typescript" }, + { label: "Vue", value: "vue" }, + { label: "XML", value: "xml" }, + { label: "YAML", value: "yaml" } +]; + const prismLanguageAliasMap: Record = { html: "markup", xml: "markup",