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

* fix: Copy to clipboard all text nodes as text

* fix: support copying text even if there are selected elements that are no text

* patch: makes paragraphs betwen texts of each element

* patch: allow copying text for bound text
This commit is contained in:
Faustino Kialungila 2022-04-05 21:48:59 +02:00 committed by GitHub
parent 670ceafc84
commit 89471094ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 14 deletions

View file

@ -5476,7 +5476,10 @@ class App extends React.Component<AppProps, AppState> {
const elements = this.scene.getElements();
const isTextNodesOnly = elements.every((element) => isTextElement(element));
const selectedElements = getSelectedElements(
this.scene.getElements(),
this.state,
);
const options: ContextMenuOption[] = [];
if (probablySupportsClipboardBlob && elements.length > 0) {
@ -5487,11 +5490,7 @@ class App extends React.Component<AppProps, AppState> {
options.push(actionCopyAsSvg);
}
if (
probablySupportsClipboardWriteText &&
elements.length > 0 &&
isTextNodesOnly
) {
if (probablySupportsClipboardWriteText && selectedElements.length > 0) {
options.push(copyAllTextNodesAsText);
}
if (type === "canvas") {
@ -5538,8 +5537,7 @@ class App extends React.Component<AppProps, AppState> {
elements.length > 0 &&
actionCopyAsSvg,
probablySupportsClipboardWriteText &&
elements.length > 0 &&
isTextNodesOnly &&
selectedElements.length > 0 &&
copyAllTextNodesAsText,
((probablySupportsClipboardBlob && elements.length > 0) ||
(probablySupportsClipboardWriteText && elements.length > 0)) &&