tldraw
Version:
A tiny little drawing editor.
94 lines (93 loc) • 4 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var DefaultVideoToolbarContent_exports = {};
__export(DefaultVideoToolbarContent_exports, {
DefaultVideoToolbarContent: () => DefaultVideoToolbarContent
});
module.exports = __toCommonJS(DefaultVideoToolbarContent_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_editor = require("@tldraw/editor");
var import_react = require("react");
var import_actions = require("../../context/actions");
var import_events = require("../../context/events");
var import_useTranslation = require("../../hooks/useTranslation/useTranslation");
var import_TldrawUiButton = require("../primitives/Button/TldrawUiButton");
var import_TldrawUiButtonIcon = require("../primitives/Button/TldrawUiButtonIcon");
var import_TldrawUiToolbar = require("../primitives/TldrawUiToolbar");
const DefaultVideoToolbarContent = (0, import_editor.track)(function DefaultVideoToolbarContent2({
videoShapeId,
onEditAltTextStart
}) {
const editor = (0, import_editor.useEditor)();
const trackEvent = (0, import_events.useUiEvents)();
const msg = (0, import_useTranslation.useTranslation)();
const source = "video-toolbar";
const isReadonly = editor.getIsReadonly();
const actions = (0, import_actions.useActions)();
const handleVideoReplace = (0, import_react.useCallback)(
() => actions["video-replace"].onSelect("video-toolbar"),
[actions]
);
const handleVideoDownload = (0, import_react.useCallback)(
() => actions["download-original"].onSelect("video-toolbar"),
[actions]
);
const altText = (0, import_editor.useValue)(
"altText",
() => editor.getShape(videoShapeId).props.altText,
[editor, videoShapeId]
);
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
!isReadonly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_TldrawUiButton.TldrawUiButton,
{
type: "icon",
title: msg("tool.replace-media"),
onClick: handleVideoReplace,
"data-testid": "tool.video-replace",
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "tool-media" })
}
),
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_TldrawUiButton.TldrawUiButton,
{
type: "icon",
title: msg("action.download-original"),
onClick: handleVideoDownload,
"data-testid": "tool.video-download",
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "download" })
}
),
(altText || !isReadonly) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
import_TldrawUiToolbar.TldrawUiToolbarButton,
{
type: "icon",
isActive: !!altText,
title: msg("tool.media-alt-text"),
"data-testid": "tool.video-alt-text",
onClick: () => {
trackEvent("alt-text-start", { source });
onEditAltTextStart();
},
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_TldrawUiButtonIcon.TldrawUiButtonIcon, { small: true, icon: "alt" })
}
)
] });
});
//# sourceMappingURL=DefaultVideoToolbarContent.js.map