A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
editor: copying a link from a list item shouldn't add spaces at the end
Abdullah Atta301a30a50ace
diff --git a/packages/editor/src/extensions/clipboard/clipboard.ts b/packages/editor/src/extensions/clipboard/clipboard.tsindex fa0664609..803c7ba37 100644--- a/packages/editor/src/extensions/clipboard/clipboard.ts+++ b/packages/editor/src/extensions/clipboard/clipboard.ts@@ -59,10 +59,7 @@ export function transformCopied(slice: Slice, view: EditorView): any {maybeList.childCount === 1 &&maybeList.firstChild) {- return transformCopied(- new Slice(maybeList.firstChild.content, slice.openStart, slice.openEnd),- view- );+ return transformCopied(Slice.maxOpen(maybeList.firstChild.content), view);}return slice;diff --git a/packages/editor/src/extensions/clipboard/tests/__snapshots__/clipboard-text-serializer.test.ts.snap b/packages/editor/src/extensions/clipboard/tests/__snapshots__/clipboard-text-serializer.test.ts.snapindex 6d7684096..d53f9214c 100644--- a/packages/editor/src/extensions/clipboard/tests/__snapshots__/clipboard-text-serializer.test.ts.snap+++ b/packages/editor/src/extensions/clipboard/tests/__snapshots__/clipboard-text-serializer.test.ts.snap@@ -13,6 +13,8 @@ exports[`copying a single list item shouldn't copy the list metadata 1`] = `"type": "paragraph",},],+ "openEnd": 1,+ "openStart": 1,}`;@@ -29,6 +31,10 @@ exports[`copying a single nested list item shouldn't copy the list metadata 1`]"type": "paragraph",},],+ "openEnd": 1,+ "openStart": 1,+}+`;exports[`copying multiple lists shouldn't copy only the first list 1`] = `{@@ -106,5 +112,32 @@ exports[`copying multiple lists shouldn't copy only the first list 1`] = `}`;+exports[`copying text from a list item shouldn't add extra spaces at the end 1`] = `+{+ "content": [+ {+ "content": [+ {+ "marks": [+ {+ "attrs": {+ "class": null,+ "href": "https://google.com/",+ "rel": "noopener noreferrer nofollow",+ "target": "_blank",+ "title": null,+ },+ "type": "link",+ },+ ],+ "text": "Hello",+ "type": "text",+ },+ ],+ "type": "paragraph",+ },+ ],+ "openEnd": 1,+ "openStart": 1,}`;diff --git a/packages/editor/src/extensions/clipboard/tests/clipboard-text-serializer.test.ts b/packages/editor/src/extensions/clipboard/tests/clipboard-text-serializer.test.tsindex 50c0e47d8..3f4192833 100644--- a/packages/editor/src/extensions/clipboard/tests/clipboard-text-serializer.test.ts+++ b/packages/editor/src/extensions/clipboard/tests/clipboard-text-serializer.test.ts@@ -25,6 +25,7 @@ import { transformCopied } from "../index";import { Paragraph } from "../../paragraph";import { ClipboardDOMSerializer } from "../clipboard-dom-serializer";import { clipboardTextSerializer } from "../clipboard-text-serializer";+import Link from "../../link";test("copied list items shouldn't contain extra newlines", (t) => {const { editor } = createEditor({@@ -83,6 +84,32 @@ test("copying a single list item shouldn't copy the list metadata", (t) => {).toMatchSnapshot();});+test("copying text from a list item shouldn't add extra spaces at the end", (t) => {+ const { editor } = createEditor({+ initialContent: h("div", [+ h("ol", [+ h("li", [+ h("p", ["I am ", h("a", ["Hello"], { href: "https://google.com/" })])+ ])+ ])+ ]).innerHTML,+ extensions: {+ orderedList: OrderedList,+ listItem: ListItem,+ link: Link+ }+ });++ t.expect(+ transformCopied(+ editor.state.doc.slice(+ editor.state.doc.nodeSize - 10,+ editor.state.doc.nodeSize - 2+ ),+ editor.view+ ).toJSON()+ ).toMatchSnapshot();+});test("copying multiple lists shouldn't copy only the first list", (t) => {const { editor } = createEditor({@@ -123,7 +150,8 @@ test("copying a single nested list item shouldn't copy the list metadata", (t) =t.expect(transformCopied(- editor.state.doc.slice(12, editor.state.doc.nodeSize - 2)+ editor.state.doc.slice(12, editor.state.doc.nodeSize - 2),+ editor.view).toJSON()).toMatchSnapshot();});