UNPKG

@chayns-components/core

Version:

A set of beautiful React components for developing your own applications with chayns.

52 lines (51 loc) 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.shareWithUrl = exports.shareWithApp = exports.copyToClipboard = void 0; var _chaynsApi = require("chayns-api"); const copyToClipboard = link => { const aux = document.createElement('input'); const range = document.createRange(); aux.setAttribute('value', link); aux.setAttribute('contenteditable', 'true'); aux.setAttribute('readonly', 'true'); document.body.appendChild(aux); aux.select(); range.selectNodeContents(aux); const s = window.getSelection(); if (!s) { return; } s.removeAllRanges(); s.addRange(range); aux.setSelectionRange(0, 999999); document.execCommand('copy'); document.body.removeChild(aux); void (0, _chaynsApi.createDialog)({ type: _chaynsApi.DialogType.TOAST, showCloseIcon: true, toastType: 1, text: 'kopiert' }).open(); }; exports.copyToClipboard = copyToClipboard; const shareWithApp = link => { window.location.href = `mailto:?subject=&body=${encodeURIComponent(link)}`; }; exports.shareWithApp = shareWithApp; const shareWithUrl = link => { if (link.startsWith('mailto')) { window.open(link); } else if (link.indexOf('chaynsqrcodegenerator') > 0) { void (0, _chaynsApi.openImage)({ items: [{ url: link }] }); } else { window.open(link, '_blank'); } }; exports.shareWithUrl = shareWithUrl; //# sourceMappingURL=sharingBar.js.map