Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom renderText on editable node results in duplicate content copied to clipboard #3392

Closed
1 of 2 tasks
mylesj opened this issue Nov 8, 2022 · 6 comments · Fixed by #3410
Closed
1 of 2 tasks

Custom renderText on editable node results in duplicate content copied to clipboard #3392

mylesj opened this issue Nov 8, 2022 · 6 comments · Fixed by #3410
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@mylesj
Copy link
Contributor

mylesj commented Nov 8, 2022

What’s the bug you are facing?

I've specified a custom renderText on an editable node expecting to be able to customise the serialisation that is shared with the tiptap clipboard handler, however copy-pasting the node as plain text results in the text selection being appended in addition to the output of renderText.

Which browser was this experienced in? Are any special extensions installed?

N/A

How can we reproduce the bug on our side?

  • Define a custom node with a "hole" for text content
  • Select a range of text inclusive of the custom node
  • Paste (Shift-Paste) the plain text content to another document

Can you provide a CodeSandbox?

https://stackblitz.com/edit/react-ts-ysehpq?file=App.tsx

What did you expect to happen?

I expected the output of renderText to be the only content copied in relation to the node.

Anything to add? (optional)

I considered two ways of getting around this issue:

  • Extending the builtin text node in such away that I could nullify the renderText for text nodes contained within specific parents (this produced a number of other exotic outcomes and felt like a hack)
  • ProseMirror recently introduced a transformCopied API option that lets you manipulate a slice of content before it is passed to the clipboard-serialiser. It seems that TipTap doesn't support this yet, as the clipboardTextSerializer arguments are ignored in favour of a custom implementation.

This issue might be a feature request if supporting transformCopied is the better outcome.

Video example

Screen.Recording.2022-11-08.at.15.44.30.mov

Did you update your dependencies?

  • Yes, I’ve updated my dependencies to use the latest version of all packages.

Are you sponsoring us?

  • Yes, I’m a sponsor. 💖
@mylesj mylesj added the Type: Bug The issue or pullrequest is related to a bug label Nov 8, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added Info: Stale The issue or pullrequest has not been updated in a while and might be stale and removed Info: Stale The issue or pullrequest has not been updated in a while and might be stale labels Feb 7, 2023
@github-actions
Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label May 10, 2023
@mylesj
Copy link
Contributor Author

mylesj commented May 15, 2023

Still an issue. Fix proposed.

@github-actions github-actions bot removed the Info: Stale The issue or pullrequest has not been updated in a while and might be stale label May 16, 2023
@bdbch bdbch added this to Tiptap Aug 4, 2023
@github-project-automation github-project-automation bot moved this to Triage open in Tiptap Aug 4, 2023
@cvakodobro
Copy link

I'm experiencing the same issue, is there any update on this?

@msickpaler
Copy link

I am still having the same problem in 2024.
There seems to be no progress on this issue and PR, is the proposed PR not resolving the issue?

@mylesj
Copy link
Contributor Author

mylesj commented Mar 17, 2024

I can also confirm that this is still an issue with [email protected] and that the proposed fix still works. I don't know why this was never accepted but I've been using patch-package to address numerous issues locally. If it's any help, here is my patch file:

diff --git a/node_modules/@tiptap/core/dist/index.cjs b/node_modules/@tiptap/core/dist/index.cjs
index ffc83cc..03f31f7 100644
--- a/node_modules/@tiptap/core/dist/index.cjs
+++ b/node_modules/@tiptap/core/dist/index.cjs
@@ -1220,8 +1220,9 @@ function getTextBetween(startNode, range, options) {
                     range,
                 });
             }
+	    return false;
         }
-        else if (node.isText) {
+        if (node.isText) {
             text += (_a = node === null || node === void 0 ? void 0 : node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos); // eslint-disable-line
             separated = false;
         }
diff --git a/node_modules/@tiptap/core/dist/index.js b/node_modules/@tiptap/core/dist/index.js
index b6e061c..acf5a13 100644
--- a/node_modules/@tiptap/core/dist/index.js
+++ b/node_modules/@tiptap/core/dist/index.js
@@ -1216,8 +1216,9 @@ function getTextBetween(startNode, range, options) {
                     range,
                 });
             }
+	    return false;
         }
-        else if (node.isText) {
+        if (node.isText) {
             text += (_a = node === null || node === void 0 ? void 0 : node.text) === null || _a === void 0 ? void 0 : _a.slice(Math.max(from, pos) - pos, to - pos); // eslint-disable-line
             separated = false;
         }

@github-project-automation github-project-automation bot moved this from Triage open to Done in Tiptap Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants