|
|
@ -1,27 +1,28 @@
|
|
|
|
import React from "react";
|
|
|
|
import React from "react";
|
|
|
|
import { getCommonBounds } from "../element/bounds";
|
|
|
|
import { getCommonBounds } from "../element/bounds";
|
|
|
|
import { mutateElement } from "../element/mutateElement";
|
|
|
|
import { mutateElement } from "../element/mutateElement";
|
|
|
|
import {
|
|
|
|
import { ExcalidrawElement } from "../element/types";
|
|
|
|
ExcalidrawElement,
|
|
|
|
|
|
|
|
NonDeletedExcalidrawElement,
|
|
|
|
|
|
|
|
} from "../element/types";
|
|
|
|
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import { KEYS } from "../keys";
|
|
|
|
import { KEYS } from "../keys";
|
|
|
|
import { getTargetElements } from "../scene";
|
|
|
|
import { getTargetElements } from "../scene";
|
|
|
|
|
|
|
|
import Scene from "../scene/Scene";
|
|
|
|
import { AppState, ExcalidrawProps } from "../types";
|
|
|
|
import { AppState, ExcalidrawProps } from "../types";
|
|
|
|
import { CloseIcon } from "./icons";
|
|
|
|
import { CloseIcon } from "./icons";
|
|
|
|
import { Island } from "./Island";
|
|
|
|
import { Island } from "./Island";
|
|
|
|
import "./Stats.scss";
|
|
|
|
import "./Stats.scss";
|
|
|
|
|
|
|
|
|
|
|
|
export const Stats = (props: {
|
|
|
|
interface StatsProps {
|
|
|
|
appState: AppState;
|
|
|
|
appState: AppState;
|
|
|
|
|
|
|
|
scene: Scene;
|
|
|
|
setAppState: React.Component<any, AppState>["setState"];
|
|
|
|
setAppState: React.Component<any, AppState>["setState"];
|
|
|
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
|
|
|
|
|
|
onClose: () => void;
|
|
|
|
onClose: () => void;
|
|
|
|
renderCustomStats: ExcalidrawProps["renderCustomStats"];
|
|
|
|
renderCustomStats: ExcalidrawProps["renderCustomStats"];
|
|
|
|
}) => {
|
|
|
|
}
|
|
|
|
const boundingBox = getCommonBounds(props.elements);
|
|
|
|
|
|
|
|
const selectedElements = getTargetElements(props.elements, props.appState);
|
|
|
|
export const Stats = (props: StatsProps) => {
|
|
|
|
|
|
|
|
const elements = props.scene.getNonDeletedElements();
|
|
|
|
|
|
|
|
const boundingBox = getCommonBounds(elements);
|
|
|
|
|
|
|
|
const selectedElements = getTargetElements(elements, props.appState);
|
|
|
|
const selectedBoundingBox = getCommonBounds(selectedElements);
|
|
|
|
const selectedBoundingBox = getCommonBounds(selectedElements);
|
|
|
|
|
|
|
|
|
|
|
|
const stats =
|
|
|
|
const stats =
|
|
|
@ -75,7 +76,7 @@ export const Stats = (props: {
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td>{t("stats.elements")}</td>
|
|
|
|
<td>{t("stats.elements")}</td>
|
|
|
|
<td>{props.elements.length}</td>
|
|
|
|
<td>{elements.length}</td>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<tr>
|
|
|
|
<td>{t("stats.width")}</td>
|
|
|
|
<td>{t("stats.width")}</td>
|
|
|
@ -89,7 +90,7 @@ export const Stats = (props: {
|
|
|
|
{Math.round(boundingBox[3]) - Math.round(boundingBox[1])}
|
|
|
|
{Math.round(boundingBox[3]) - Math.round(boundingBox[1])}
|
|
|
|
</td>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tr>
|
|
|
|
{props.renderCustomStats?.(props.elements, props.appState)}
|
|
|
|
{props.renderCustomStats?.(elements, props.appState)}
|
|
|
|
</tbody>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
@ -127,6 +128,7 @@ export const Stats = (props: {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input
|
|
|
|
<input
|
|
|
|
id={statsItem.label}
|
|
|
|
id={statsItem.label}
|
|
|
|
|
|
|
|
key={statsItem.value}
|
|
|
|
defaultValue={statsItem.value}
|
|
|
|
defaultValue={statsItem.value}
|
|
|
|
className="color-picker-input"
|
|
|
|
className="color-picker-input"
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|