UNPKG

@redocly/theme

Version:

Shared UI components lib

33 lines 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ClipboardService = void 0; const copy_to_clipboard_1 = __importDefault(require("copy-to-clipboard")); class ClipboardService { static copyCustom(text) { return (0, copy_to_clipboard_1.default)(text); } static selectElement(element) { if (!element) { return; } let range; let selection; if (document.body.createTextRange) { range = document.body.createTextRange(); range.moveToElementText(element); range.select(); } else if (document.createRange && window.getSelection) { selection = window.getSelection(); range = document.createRange(); range.selectNodeContents(element); selection === null || selection === void 0 ? void 0 : selection.removeAllRanges(); selection === null || selection === void 0 ? void 0 : selection.addRange(range); } } } exports.ClipboardService = ClipboardService; //# sourceMappingURL=clipboard-service.js.map