mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
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:
parent
670ceafc84
commit
89471094ce
2 changed files with 20 additions and 14 deletions
|
@ -4,9 +4,8 @@ import { copyTextToSystemClipboard, copyToClipboard } from "../clipboard";
|
|||
import { actionDeleteSelected } from "./actionDeleteSelected";
|
||||
import { getSelectedElements } from "../scene/selection";
|
||||
import { exportCanvas } from "../data/index";
|
||||
import { getNonDeletedElements } from "../element";
|
||||
import { getNonDeletedElements, isTextElement } from "../element";
|
||||
import { t } from "../i18n";
|
||||
import { ExcalidrawTextElement } from "../element/types";
|
||||
|
||||
export const actionCopy = register({
|
||||
name: "copy",
|
||||
|
@ -131,10 +130,19 @@ export const actionCopyAsPng = register({
|
|||
export const copyAllTextNodesAsText = register({
|
||||
name: "copyAllTextNodesAsText",
|
||||
trackEvent: { category: "element" },
|
||||
perform: (elements) => {
|
||||
const text = (
|
||||
getNonDeletedElements(elements) as ExcalidrawTextElement[]
|
||||
).reduce((acc, element) => `${acc}${element.text}\n`, "");
|
||||
perform: (elements, appState) => {
|
||||
const selectedElements = getSelectedElements(
|
||||
getNonDeletedElements(elements),
|
||||
appState,
|
||||
true,
|
||||
);
|
||||
|
||||
const text = selectedElements.reduce((acc, element) => {
|
||||
if (isTextElement(element)) {
|
||||
return `${acc}${element.text}\n\n`;
|
||||
}
|
||||
return acc;
|
||||
}, "");
|
||||
copyTextToSystemClipboard(text);
|
||||
return {
|
||||
commitToHistory: false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue