Sha256: 681ad4ae9b41d14767bdf8616a88d12d132222c1d988e854e1f55205d11763e4
Contents?: true
Size: 1.77 KB
Versions: 10
Compression:
Stored size: 1.77 KB
Contents
/* eslint-disable no-console */ import Copyray from './copyray' import { isMac } from './util' declare global { interface Window { CopyTuner: { url: string toggle?: () => void // TODO: type data: object } } } import './copyray.css' // NOTE: 元々railsから出力されいてたマークアップに合わせてひとまず、、 const appendCopyTunerBar = (url: string) => { const bar = document.createElement('div') bar.id = 'copy-tuner-bar' bar.classList.add('copy-tuner-hidden') bar.innerHTML = ` <a class="copy-tuner-bar-button" target="_blank" href="${url}">CopyTuner</a> <a href="/copytuner" target="_blank" class="copy-tuner-bar-button">Sync</a> <a href="javascript:void(0)" class="copy-tuner-bar-open-log copy-tuner-bar-button js-copy-tuner-bar-open-log">Translations in this page</a> <input type="text" class="copy-tuner-bar__search js-copy-tuner-bar-search" placeholder="search"> ` document.body.append(bar) } const start = () => { const { url, data } = window.CopyTuner appendCopyTunerBar(url) const copyray = new Copyray(url, data) window.CopyTuner.toggle = () => copyray.toggle() document.addEventListener('keydown', (event) => { // @ts-expect-error TS2339 if (copyray.isShowing && ['Escape', 'Esc'].includes(event.key)) { copyray.hide() return } if (((isMac && event.metaKey) || (!isMac && event.ctrlKey)) && event.shiftKey && event.key.toLowerCase() === 'k') { copyray.toggle() } }) if (console) { console.log(`Ready to Copyray. Press ${isMac ? 'cmd+shift+k' : 'ctrl+shift+k'} to scan your UI.`) } } if (document.readyState === 'complete' || document.readyState !== 'loading') { start() } else { document.addEventListener('DOMContentLoaded', () => start()) }
Version data entries
10 entries across 10 versions & 1 rubygems