Open Jettonn opened 2 months ago
I'm trying to copy the current selection as markdown.
theEditor.editor.action((ctx: Ctx) => {
const editorView = ctx.get(editorViewCtx);
let selection = editorView.state.tr.selection;
// now what...?
// I searched through `selection`'s fields, recursively,
// but could not find a method to get the markdown.
});
Perhaps, something like selection.getMarkdown()
would solve mine and would subsume your code block copy?
Then it's just a matter of navigator.clipboard.write()
, isn't it?
Initial checklist
Problem
Code Block component is really useful, but since it's created not to be extended by the user it's hard to add a copy-to-clipboard functionality to the component (although you can change the icons, buttons, etc for language selector).
Solution
It would be handy to be able to add functionalities yourself (extend the components) or just support copy to the clipboard button.
Alternatives
Let users extend milkdown components and plugins