diff --git a/src/components/App.tsx b/src/components/App.tsx index 4891a94e..fcd0bd15 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -457,6 +457,7 @@ class App extends React.Component { {this.state.showStats && ( diff --git a/src/components/Stats.tsx b/src/components/Stats.tsx index 3780691e..56b3e2c0 100644 --- a/src/components/Stats.tsx +++ b/src/components/Stats.tsx @@ -1,4 +1,6 @@ import React, { useEffect, useState } from "react"; +import { copyTextToSystemClipboard } from "../clipboard"; +import { DEFAULT_VERSION } from "../constants"; import { getCommonBounds } from "../element/bounds"; import { NonDeletedExcalidrawElement } from "../element/types"; import { @@ -9,7 +11,7 @@ import { t } from "../i18n"; import useIsMobile from "../is-mobile"; import { getTargetElements } from "../scene"; import { AppState } from "../types"; -import { debounce, nFormatter } from "../utils"; +import { debounce, getVersion, nFormatter } from "../utils"; import { close } from "./icons"; import { Island } from "./Island"; import "./Stats.scss"; @@ -25,6 +27,7 @@ const getStorageSizes = debounce((cb: (sizes: StorageSizes) => void) => { export const Stats = (props: { appState: AppState; + setAppState: React.Component["setState"]; elements: readonly NonDeletedExcalidrawElement[]; onClose: () => void; }) => { @@ -50,6 +53,17 @@ export const Stats = (props: { return null; } + const version = getVersion(); + let hash; + let timestamp; + + if (version !== DEFAULT_VERSION) { + timestamp = version.slice(0, 16).replace("T", " "); + hash = version.slice(21); + } else { + timestamp = t("stats.versionNotAvailable"); + } + return (
@@ -156,6 +170,28 @@ export const Stats = (props: { )} + + {t("stats.version")} + + + { + try { + await copyTextToSystemClipboard(getVersion()); + props.setAppState({ + toastMessage: t("toast.copyToClipboard"), + }); + } catch {} + }} + title={t("stats.versionCopy")} + > + {timestamp} +
+ {hash} + +
diff --git a/src/locales/en.json b/src/locales/en.json index 88580089..2759d496 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -235,10 +235,14 @@ "storage": "Storage", "title": "Stats for nerds", "total": "Total", + "version": "Version", + "versionCopy": "Click to copy", + "versionNotAvailable": "Version not available", "width": "Width" }, "toast": { "copyStyles": "Copied styles.", + "copyToClipboard": "Copied to clipboard.", "copyToClipboardAsPng": "Copied to clipboard as PNG." } }