mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
chore(ckeditor5/codeblock): add command for copying to clipboard
This commit is contained in:
parent
5eecea52bf
commit
fc83f67d7c
@ -1,8 +1,16 @@
|
|||||||
import { ButtonView, Plugin } from "ckeditor5";
|
import { ButtonView, Command, Plugin } from "ckeditor5";
|
||||||
import copyIcon from "../icons/copy.svg?raw";
|
import copyIcon from "../icons/copy.svg?raw";
|
||||||
|
|
||||||
export default class CopyToClipboardButton extends Plugin {
|
export default class CopyToClipboardButton extends Plugin {
|
||||||
|
|
||||||
|
static get requires() {
|
||||||
|
return [ CopyToClipboardEditing, CopyToClipboardUI ];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export class CopyToClipboardUI extends Plugin {
|
||||||
|
|
||||||
public init() {
|
public init() {
|
||||||
const editor = this.editor;
|
const editor = this.editor;
|
||||||
const componentFactory = editor.ui.componentFactory;
|
const componentFactory = editor.ui.componentFactory;
|
||||||
@ -14,8 +22,28 @@ export default class CopyToClipboardButton extends Plugin {
|
|||||||
icon: copyIcon
|
icon: copyIcon
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.listenTo(button, "execute", () => {
|
||||||
|
editor.execute("copyToClipboard");
|
||||||
|
});
|
||||||
|
|
||||||
return button;
|
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…
x
Reference in New Issue
Block a user