Added "Paste code block"
This commit is contained in:
parent
b9a5d8bcf9
commit
580d075bc8
12
main.ts
12
main.ts
|
@ -21,7 +21,7 @@ export default class CodeBlockPlugin extends Plugin {
|
|||
await this.loadSettings();
|
||||
|
||||
this.addCommand({
|
||||
id: 'Code block',
|
||||
id: 'Add code block',
|
||||
name: 'Add code block',
|
||||
editorCallback: (editor: Editor) => {
|
||||
const selection = editor.getSelection();
|
||||
|
@ -35,6 +35,16 @@ export default class CodeBlockPlugin extends Plugin {
|
|||
}
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: 'Paste code block',
|
||||
name: 'Paste code block',
|
||||
editorCallback: (editor: Editor) => {
|
||||
navigator.clipboard.readText().then(text => {
|
||||
editor.replaceSelection(CodeBlockPlugin.addCodeBlock(this.getLanguage(text), text));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.addSettingTab(new CodeBlockTab(this.app, this));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue