Avoid instantiating serializer on each copy

This commit is contained in:
Tom Moor committed 2025-02-05 22:53:41 -05:00
1 parent 96de47eb18
commit 6af2fc91d7
1 file changed
+6 -7
@@ -3,8 +3,7 @@ import Extension from "@shared/editor/lib/Extension";
/**
* A plugin that allows overriding the default behavior of the editor to allow
* copying text for nodes that do not inherently have text children by defining
* a `toPlainText` method in the node spec.
* copying text including the markdown formatting.
*/
export default class ClipboardTextSerializer extends Extension {
get name() {
@@ -12,16 +11,16 @@ export default class ClipboardTextSerializer extends Extension {
}
get plugins() {
const serializer = this.editor.extensions.serializer();
return [
new Plugin({
key: new PluginKey("clipboardTextSerializer"),
props: {
clipboardTextSerializer: (slice) => {
const serializer = this.editor.extensions.serializer();
return serializer.serialize(slice.content, {
clipboardTextSerializer: (slice) =>
serializer.serialize(slice.content, {
softBreak: true,
});
},
}),
},
}),
];