diff --git a/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.cs b/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.cs
index 17691c82..43cb45bf 100644
--- a/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.cs
+++ b/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.cs
@@ -1,4 +1,4 @@
-// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
+// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
@@ -117,6 +117,13 @@ protected override async Task InvokeInitAsync()
///
public async Task Resize() => await InvokeVoidAsync("resize");
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task InsertTextAsync(string data) => await InvokeVoidAsync("insertText", Id, data);
+
///
///
///
diff --git a/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.js b/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.js
index 91a6761e..6d36741a 100644
--- a/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.js
+++ b/src/components/BootstrapBlazor.CodeEditor/Components/CodeEditor/CodeEditor.razor.js
@@ -1,4 +1,4 @@
-import { addLink, addScript } from '../../../BootstrapBlazor/modules/utility.js'
+import { addLink, addScript } from '../../../BootstrapBlazor/modules/utility.js'
import Data from '../../../BootstrapBlazor/modules/data.js'
import EventHandler from "../../../BootstrapBlazor/modules/event-handler.js"
@@ -76,7 +76,22 @@ export async function init(id, interop, options) {
});
}
-// Update the editor options
+export function insertText(id, insertData) {
+ const wrapper = Data.get(id);
+ if (!wrapper) return;
+
+ const editor = wrapper.editor;
+ const selection = editor.getSelection();
+ editor.executeEdits('insert-custom-text', [
+ {
+ range: selection,
+ text: insertData,
+ forceMoveMarkers: true
+ }
+ ]);
+ editor.focus();
+}
+
export function monacoSetOptions(id, options) {
var editor = Data.get(id);
if (editor) {