-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* js方法切换到ts支持 删除通过id管理编辑器 * 修改PR意见 * 修改pr意见 * 优化ts文件 * 增加Monaco Editor ts * 删除冲突文件 * Update src/Component/BlazorComponent.Web/package.json Co-authored-by: capdiem <[email protected]> * Update src/Component/BlazorComponent.Web/package.json Co-authored-by: capdiem <[email protected]> * 修改名称 * 修改editor * 更换ts方法顺序 --------- Co-authored-by: capdiem <[email protected]>
- Loading branch information
Showing
4 changed files
with
570 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/Component/BlazorComponent.Web/rollup.config.monaco-editor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig } from "rollup"; | ||
import { terser } from "rollup-plugin-terser"; | ||
|
||
import typescript from "@rollup/plugin-typescript"; | ||
|
||
export default defineConfig({ | ||
input: "./src/proxies/monaco-editor/index.ts", | ||
output: [ | ||
{ | ||
file: "../../../../MASA.Blazor/wwwroot/js/proxies/monaco-editor-proxy.js", | ||
format: "esm", | ||
sourcemap: true, | ||
}, | ||
], | ||
plugins: [typescript(), terser()], | ||
}); |
76 changes: 76 additions & 0 deletions
76
src/Component/BlazorComponent.Web/src/proxies/monaco-editor/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { editor as MonacoEditor } from "monaco-editor"; | ||
|
||
interface Monaco { | ||
editor: typeof MonacoEditor; | ||
} | ||
|
||
declare const monaco: Monaco; | ||
|
||
function init(id: string, options: MonacoEditor.IStandaloneEditorConstructionOptions) { | ||
return monaco.editor.create(document.getElementById(id), options); | ||
} | ||
|
||
function defineTheme(name, value: MonacoEditor.IStandaloneThemeData) { | ||
monaco.editor.defineTheme(name, value) | ||
} | ||
|
||
function remeasureFonts() { | ||
monaco.editor.remeasureFonts(); | ||
} | ||
|
||
function addKeybindingRules(rules: MonacoEditor.IKeybindingRule[]) { | ||
monaco.editor.addKeybindingRules(rules); | ||
} | ||
|
||
function addKeybindingRule(rule: MonacoEditor.IKeybindingRule) { | ||
monaco.editor.addKeybindingRule(rule); | ||
} | ||
|
||
function setTheme(theme: string) { | ||
monaco.editor.setTheme(theme); | ||
} | ||
|
||
function colorizeElement(id: string, options: any) { | ||
monaco.editor.colorizeElement(document.getElementById(id), options); | ||
} | ||
|
||
function getModels() { | ||
return monaco.editor.getModels(); | ||
} | ||
|
||
function updateOptions(instance: MonacoEditor.IStandaloneCodeEditor, options: any) { | ||
instance.updateOptions(options); | ||
} | ||
|
||
|
||
function getModel(instance: MonacoEditor.IStandaloneCodeEditor) { | ||
return instance.getModel(); | ||
} | ||
|
||
function getValue(instance: MonacoEditor.IStandaloneCodeEditor) { | ||
return instance.getValue(); | ||
} | ||
|
||
function setValue(instance: MonacoEditor.IStandaloneCodeEditor, value) { | ||
instance.setValue(value); | ||
} | ||
|
||
function setModelLanguage(instance: MonacoEditor.IStandaloneCodeEditor, languageId: string) { | ||
monaco.editor.setModelLanguage(instance.getModel(), languageId); | ||
} | ||
|
||
export { | ||
init, | ||
getValue, | ||
setValue, | ||
setTheme, | ||
getModels, | ||
getModel, | ||
setModelLanguage, | ||
remeasureFonts, | ||
addKeybindingRules, | ||
colorizeElement, | ||
defineTheme, | ||
updateOptions, | ||
addKeybindingRule | ||
} |
Oops, something went wrong.