mirror of
https://github.com/outline/outline.git
synced 2026-11-21 13:34:02 +03:00
29 lines
731 B
TypeScript
29 lines
731 B
TypeScript
import { Plugin, PluginKey } from "prosemirror-state";
|
|
import Extension from "@shared/editor/lib/Extension";
|
|
|
|
/**
|
|
* A plugin that allows overriding the default behavior of the editor to allow
|
|
* copying text including the markdown formatting.
|
|
*/
|
|
export default class ClipboardTextSerializer extends Extension {
|
|
get name() {
|
|
return "clipboardTextSerializer";
|
|
}
|
|
|
|
get plugins() {
|
|
const serializer = this.editor.extensions.serializer();
|
|
|
|
return [
|
|
new Plugin({
|
|
key: new PluginKey("clipboardTextSerializer"),
|
|
props: {
|
|
clipboardTextSerializer: (slice) =>
|
|
serializer.serialize(slice.content, {
|
|
softBreak: true,
|
|
}),
|
|
},
|
|
}),
|
|
];
|
|
}
|
|
}
|