mirror of
https://github.com/zadam/trilium.git
synced 2025-10-25 07:17:04 +08:00
chore(ckeditor5/codeblock): add command for copying to clipboard
This commit is contained in:
parent
5eecea52bf
commit
fc83f67d7c
1 changed files with 29 additions and 1 deletions
|
|
@ -1,8 +1,16 @@
|
|||
import { ButtonView, Plugin } from "ckeditor5";
|
||||
import { ButtonView, Command, Plugin } from "ckeditor5";
|
||||
import copyIcon from "../icons/copy.svg?raw";
|
||||
|
||||
export default class CopyToClipboardButton extends Plugin {
|
||||
|
||||
static get requires() {
|
||||
return [ CopyToClipboardEditing, CopyToClipboardUI ];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class CopyToClipboardUI extends Plugin {
|
||||
|
||||
public init() {
|
||||
const editor = this.editor;
|
||||
const componentFactory = editor.ui.componentFactory;
|
||||
|
|
@ -14,8 +22,28 @@ export default class CopyToClipboardButton extends Plugin {
|
|||
icon: copyIcon
|
||||
});
|
||||
|
||||
this.listenTo(button, "execute", () => {
|
||||
editor.execute("copyToClipboard");
|
||||
});
|
||||
|
||||
return button;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class CopyToClipboardEditing extends Plugin {
|
||||
|
||||
public init() {
|
||||
this.editor.commands.add("copyToClipboard", new CopyToClipboardCommand(this.editor));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class CopyToClipboardCommand extends Command {
|
||||
|
||||
execute(...args: Array<unknown>) {
|
||||
console.log("Copy to clipboard!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue