UNPKG

@mdxeditor/editor

Version:

React component for rich text markdown editing

42 lines (41 loc) 1.63 kB
import React__default from "react"; import styles from "../../../styles/ui.module.css.js"; import { $isCodeBlockNode } from "../../codeblock/CodeBlockNode.js"; import { editorInFocus$, activeEditor$, iconComponentFor$, useTranslation } from "../../core/index.js"; import { sandpackConfig$ } from "../../sandpack/index.js"; import { ButtonWithTooltip } from "../primitives/toolbar.js"; import { useCellValues } from "@mdxeditor/gurx"; const ShowSandpackInfo = () => { const [editorInFocus, theEditor, iconComponentFor, sandpackConfig] = useCellValues( editorInFocus$, activeEditor$, iconComponentFor$, sandpackConfig$ ); const t = useTranslation(); const sandpackNode = $isCodeBlockNode(editorInFocus.rootNode) ? editorInFocus.rootNode : null; if (!sandpackNode) { return null; } const preset = sandpackConfig.presets.find((preset2) => preset2.meta === sandpackNode.getMeta()); return /* @__PURE__ */ React__default.createElement("div", { className: styles.selectWithLabel }, /* @__PURE__ */ React__default.createElement( ButtonWithTooltip, { title: t("toolbar.deleteSandpack", "Delete this code block"), onClick: () => { theEditor == null ? void 0 : theEditor.update(() => { if (sandpackNode.getNextSibling()) { sandpackNode.selectNext(); } else { sandpackNode.selectPrevious(); } sandpackNode.remove(); }); } }, iconComponentFor("delete_big") ), /* @__PURE__ */ React__default.createElement("label", null, "Sandpack preset: ", preset.name)); }; export { ShowSandpackInfo };