Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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/

Expand Down Expand Up @@ -117,6 +117,13 @@ protected override async Task InvokeInitAsync()
/// <returns></returns>
public async Task Resize() => await InvokeVoidAsync("resize");

/// <summary>
///
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public async Task InsertTextAsync(string data) => await InvokeVoidAsync("insertText", Id, data);

/// <summary>
///
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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) {
Expand Down