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

fix: Copy to clipboard all text nodes as text #5014

Merged
merged 4 commits into from Apr 5, 2022
Merged

Conversation

Fausto95
Copy link
Member

@Fausto95 Fausto95 commented Apr 5, 2022

fixes bugs introduced by #5013

@Fausto95 Fausto95 requested review from dwelle and ad1992 April 5, 2022 14:21
@vercel
Copy link

vercel bot commented Apr 5, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

excalidraw – ./

🔍 Inspect: https://vercel.com/excalidraw/excalidraw/9g4KkkeVUE4QSjidYrjXuuVFVEFs
✅ Preview: https://excalidraw-git-fix-copy-text-nodes-excalidraw.vercel.app

excalidraw-package-example – ./src/packages/excalidraw

🔍 Inspect: https://vercel.com/excalidraw/excalidraw-package-example/2ZX4BWU1cT45ptAV73TB8yBr9xQE
✅ Preview: https://excalidraw-package-example-git-fix-copy-text-nodes-excalidraw.vercel.app

Comment on lines 5484 to 5486
const isTextNodesOnly = selectedElements.every((element) =>
isTextElement(element),
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there actually a downside to allowing mixed elements? For example when you want to copy the whole canvas texts, so that you don't need to select items one by one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no downsides!
That's the use-case I wasn't thinking of, will add it!

const selectedElements = getSelectedElements(
getNonDeletedElements(elements),
appState,
true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be false since we are not including bound text elements

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we should include bound text elements?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Earlier since we decided to show only for text elements that's where I thought it could cause confusion for bound text, but now we are showing for mixed elements so let's include bound text too

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@Fausto95
Copy link
Member Author

Fausto95 commented Apr 5, 2022

Everything should be working now!

@Fausto95
Copy link
Member Author

Fausto95 commented Apr 5, 2022

I completely forgotten about using selectedElements in the first PR  😅 my bad

);

const text = selectedElements.reduce((acc, element) => {
if (element.type === "text") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (element.type === "text") {
if (isTextElement(element)) {

since we have a util already


const text = selectedElements.reduce((acc, element) => {
if (isTextElement(element)) {
return `${acc}${element.text}\n\n`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be single newline ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, we actually want to have two newlines so we can distinguish the nodes!

@Fausto95 Fausto95 requested review from dwelle and ad1992 April 5, 2022 16:39
@Fausto95 Fausto95 merged commit 8947109 into master Apr 5, 2022
@Fausto95 Fausto95 deleted the fix-copy-text-nodes branch April 5, 2022 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants