mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Copy to clipboard all text nodes as text (#5013)
* Copy to clipboard all text nodes as text * fix: only show the option for text elements
This commit is contained in:
parent
873afdacd3
commit
670ceafc84
5 changed files with 35 additions and 1 deletions
|
@ -11,6 +11,7 @@ import {
|
|||
actionCopy,
|
||||
actionCopyAsPng,
|
||||
actionCopyAsSvg,
|
||||
copyAllTextNodesAsText,
|
||||
actionCopyStyles,
|
||||
actionCut,
|
||||
actionDeleteSelected,
|
||||
|
@ -5475,6 +5476,8 @@ class App extends React.Component<AppProps, AppState> {
|
|||
|
||||
const elements = this.scene.getElements();
|
||||
|
||||
const isTextNodesOnly = elements.every((element) => isTextElement(element));
|
||||
|
||||
const options: ContextMenuOption[] = [];
|
||||
if (probablySupportsClipboardBlob && elements.length > 0) {
|
||||
options.push(actionCopyAsPng);
|
||||
|
@ -5483,6 +5486,14 @@ class App extends React.Component<AppProps, AppState> {
|
|||
if (probablySupportsClipboardWriteText && elements.length > 0) {
|
||||
options.push(actionCopyAsSvg);
|
||||
}
|
||||
|
||||
if (
|
||||
probablySupportsClipboardWriteText &&
|
||||
elements.length > 0 &&
|
||||
isTextNodesOnly
|
||||
) {
|
||||
options.push(copyAllTextNodesAsText);
|
||||
}
|
||||
if (type === "canvas") {
|
||||
const viewModeOptions = [
|
||||
...options,
|
||||
|
@ -5526,6 +5537,10 @@ class App extends React.Component<AppProps, AppState> {
|
|||
probablySupportsClipboardWriteText &&
|
||||
elements.length > 0 &&
|
||||
actionCopyAsSvg,
|
||||
probablySupportsClipboardWriteText &&
|
||||
elements.length > 0 &&
|
||||
isTextNodesOnly &&
|
||||
copyAllTextNodesAsText,
|
||||
((probablySupportsClipboardBlob && elements.length > 0) ||
|
||||
(probablySupportsClipboardWriteText && elements.length > 0)) &&
|
||||
separator,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue