-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Comments
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 |
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 |
Still an issue. Fix proposed. |
I'm experiencing the same issue, is there any update on this? |
I am still having the same problem in 2024. |
I can also confirm that this is still an issue with 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;
} |
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 ofrenderText
.Which browser was this experienced in? Are any special extensions installed?
N/A
How can we reproduce the bug on our side?
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:
renderText
for text nodes contained within specific parents (this produced a number of other exotic outcomes and felt like a hack)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 theclipboardTextSerializer
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?
Are you sponsoring us?
The text was updated successfully, but these errors were encountered: