File tree Expand file tree Collapse file tree 8 files changed +295
-0
lines changed
Expand file tree Collapse file tree 8 files changed +295
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ CodeForge 是一款轻量级、高性能的桌面代码执行器,专为开发
4141- ** Ruby**
4242- ** Rust**
4343- ** Shell**
44+ - ** SVG**
4445- ** Swift**
4546- ** TypeScript**
4647- ** TypeScript (Browser)**
Original file line number Diff line number Diff line change 1919 "@codemirror/lang-javascript" : " ^6.2.4" ,
2020 "@codemirror/lang-python" : " ^6.2.1" ,
2121 "@codemirror/lang-rust" : " ^6.0.2" ,
22+ "@codemirror/lang-xml" : " ^6.1.0" ,
2223 "@codemirror/language" : " ^6.11.2" ,
2324 "@codemirror/legacy-modes" : " ^6.5.1" ,
2425 "@codemirror/state" : " ^6.5.2" ,
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use crate::plugins::ruby::RubyPlugin;
1919use crate :: plugins:: rust:: RustPlugin ;
2020use crate :: plugins:: scala:: ScalaPlugin ;
2121use crate :: plugins:: shell:: ShellPlugin ;
22+ use crate :: plugins:: svg:: SvgPlugin ;
2223use crate :: plugins:: swift:: SwiftPlugin ;
2324use crate :: plugins:: typescript:: TypeScriptPlugin ;
2425use crate :: plugins:: typescript_browser:: TypeScriptBrowserPlugin ;
@@ -52,6 +53,7 @@ impl PluginManager {
5253 plugins. insert ( "groovy" . to_string ( ) , Box :: new ( GroovyPlugin ) ) ;
5354 plugins. insert ( "html" . to_string ( ) , Box :: new ( HtmlPlugin ) ) ;
5455 plugins. insert ( "css" . to_string ( ) , Box :: new ( CssPlugin ) ) ;
56+ plugins. insert ( "svg" . to_string ( ) , Box :: new ( SvgPlugin ) ) ;
5557 plugins. insert (
5658 "javascript-nodejs" . to_string ( ) ,
5759 Box :: new ( JavaScriptNodeJsPlugin ) ,
Original file line number Diff line number Diff line change @@ -390,6 +390,7 @@ pub mod ruby;
390390pub mod rust;
391391pub mod scala;
392392pub mod shell;
393+ pub mod svg;
393394pub mod swift;
394395pub mod typescript;
395396pub mod typescript_browser;
Original file line number Diff line number Diff line change 1+ use super :: { LanguagePlugin , PluginConfig } ;
2+ use std:: vec;
3+
4+ pub struct SvgPlugin ;
5+
6+ impl LanguagePlugin for SvgPlugin {
7+ fn get_order ( & self ) -> i32 {
8+ 22
9+ }
10+
11+ fn get_language_name ( & self ) -> & ' static str {
12+ "SVG"
13+ }
14+
15+ fn get_language_key ( & self ) -> & ' static str {
16+ "svg"
17+ }
18+
19+ fn get_file_extension ( & self ) -> String {
20+ self . get_config ( )
21+ . map ( |config| config. extension . clone ( ) )
22+ . unwrap_or_else ( || "svg" . to_string ( ) )
23+ }
24+
25+ fn get_version_args ( & self ) -> Vec < & ' static str > {
26+ vec ! [ "--" ]
27+ }
28+
29+ fn get_path_command ( & self ) -> String {
30+ "--" . to_string ( )
31+ }
32+
33+ fn get_default_config ( & self ) -> PluginConfig {
34+ PluginConfig {
35+ enabled : true ,
36+ language : String :: from ( "svg" ) ,
37+ before_compile : None ,
38+ extension : String :: from ( "svg" ) ,
39+ execute_home : None ,
40+ run_command : Some ( String :: from ( "cat $filename" ) ) ,
41+ after_compile : None ,
42+ template : Some ( String :: from (
43+ "<!-- 在这里输入 SVG 代码 -->\n <!-- SVG (Scalable Vector Graphics) 矢量图形 -->" ,
44+ ) ) ,
45+ timeout : Some ( 30 ) ,
46+ console_type : Some ( String :: from ( "web" ) ) ,
47+ }
48+ }
49+
50+ fn get_default_command ( & self ) -> String {
51+ self . get_config ( )
52+ . and_then ( |config| config. run_command . clone ( ) )
53+ . unwrap_or_else ( || "cat" . to_string ( ) )
54+ }
55+ }
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import {rust} from '@codemirror/lang-rust'
77import { cpp } from '@codemirror/lang-cpp'
88import { html } from '@codemirror/lang-html'
99import { css } from '@codemirror/lang-css'
10+ import { xml } from '@codemirror/lang-xml'
1011import { shell } from '@codemirror/legacy-modes/mode/shell'
1112import { swift } from '@codemirror/legacy-modes/mode/swift'
1213import { kotlin , scala } from '@codemirror/legacy-modes/mode/clike'
@@ -203,6 +204,8 @@ export function useCodeMirrorEditor(props: Props)
203204 return html ( )
204205 case 'css' :
205206 return css ( )
207+ case 'svg' :
208+ return xml ( )
206209 default :
207210 return null
208211 }
You can’t perform that action at this time.
0 commit comments