mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fix clipboardTextSerializer for single lines
This commit is contained in:
@@ -20,6 +20,20 @@ export const MarkdownClipboard = Extension.create({
|
|||||||
key: new PluginKey("markdownClipboard"),
|
key: new PluginKey("markdownClipboard"),
|
||||||
props: {
|
props: {
|
||||||
clipboardTextSerializer: (slice) => {
|
clipboardTextSerializer: (slice) => {
|
||||||
|
const listTypes = ["bulletList", "orderedList", "taskList"];
|
||||||
|
let topLevelCount = 0;
|
||||||
|
let hasList = false;
|
||||||
|
slice.content.forEach((node) => {
|
||||||
|
if (listTypes.includes(node.type.name)) {
|
||||||
|
hasList = true;
|
||||||
|
topLevelCount += node.childCount;
|
||||||
|
} else {
|
||||||
|
topLevelCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!hasList || topLevelCount < 2) return null;
|
||||||
|
|
||||||
const div = document.createElement("div");
|
const div = document.createElement("div");
|
||||||
const serializer = DOMSerializer.fromSchema(this.editor.schema);
|
const serializer = DOMSerializer.fromSchema(this.editor.schema);
|
||||||
const fragment = serializer.serializeFragment(slice.content);
|
const fragment = serializer.serializeFragment(slice.content);
|
||||||
|
|||||||
Reference in New Issue
Block a user