UNPKG

@mui/internal-docs-infra

Version:

MUI Infra - internal documentation creation tools.

28 lines 897 B
import _typeof from "@babel/runtime/helpers/esm/typeof"; import * as React from 'react'; import { stringOrHastToString } from "../pipeline/hastUtils/index.js"; import { useCopier } from "../useCopier/index.js"; /** * Hook for managing copy-to-clipboard functionality */ export function useCopyFunctionality(_ref) { var selectedFile = _ref.selectedFile, copyOpts = _ref.copyOpts; var sourceFileToText = React.useCallback(function () { if (!selectedFile) { return undefined; } if (typeof selectedFile === 'string') { return selectedFile; } if (selectedFile && _typeof(selectedFile) === 'object' && 'hastJson' in selectedFile) { return selectedFile.hastJson; } return stringOrHastToString(selectedFile); }, [selectedFile]); var _useCopier = useCopier(sourceFileToText, copyOpts), copy = _useCopier.copy; return { copy: copy }; }