Skip to content

Commit

Permalink
editor: encode text with base64 in pasteText (closes #1078)
Browse files Browse the repository at this point in the history
  • Loading branch information
bummoblizard committed May 14, 2024
1 parent 9db4d6b commit 4e1c549
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,9 @@ extension MonacoImplementation: EditorImplementation {
}

func pasteText(text: String) async {
guard let encoded = text.base64Encoded() else { return }
_ = try? await monacoWebView.evaluateJavaScriptAsync(
"editor.executeEdits('source',[{identifier: {major: 1, minor: 1}, range: editor.getSelection(), text: decodeURIComponent(escape(window.atob('\(text)'))), forceMoveMarkers: true}])"
"editor.executeEdits('source',[{identifier: {major: 1, minor: 1}, range: editor.getSelection(), text: decodeURIComponent(escape(window.atob('\(encoded)'))), forceMoveMarkers: true}])"
)
}

Expand Down

0 comments on commit 4e1c549

Please sign in to comment.