copy_tuner_client 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CLAUDE.md +4 -1
- data/README.md +6 -2
- data/app/assets/javascripts/copytuner.js +162 -255
- data/biome.json +39 -0
- data/index.html +9 -11
- data/lib/copy_tuner_client/copyray_middleware.rb +0 -6
- data/lib/copy_tuner_client/engine.rb +1 -1
- data/lib/copy_tuner_client/version.rb +1 -1
- data/mise.toml +3 -0
- data/package.json +9 -13
- data/pnpm-lock.yaml +600 -0
- data/skills/copy-tuner-to-t-migrate/SKILL.md +57 -8
- data/skills/copy-tuner-to-t-migrate/scripts/migrate_tt.rb +29 -2
- data/spec/copy_tuner_client/copyray_middleware_spec.rb +1 -2
- data/src/copyray-overlay.ts +125 -0
- data/src/copytuner-bar.ts +153 -0
- data/src/main.ts +29 -25
- data/src/{copyray.css → styles.ts} +104 -139
- data/src/util.ts +9 -1
- data/tsconfig.json +5 -10
- data/vite.config.ts +0 -1
- metadata +7 -9
- data/.babelrc +0 -18
- data/.eslintrc.js +0 -12
- data/app/assets/stylesheets/copytuner.css +0 -1
- data/src/copyray.ts +0 -111
- data/src/copytuner_bar.ts +0 -129
- data/src/specimen.ts +0 -94
- data/yarn.lock +0 -2540
data/src/specimen.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { computeBoundingBox } from './util'
|
|
2
|
-
|
|
3
|
-
const ZINDEX = 2_000_000_000
|
|
4
|
-
|
|
5
|
-
export default class Specimen {
|
|
6
|
-
// @ts-expect-error TS7006
|
|
7
|
-
constructor(element, keys, callback) {
|
|
8
|
-
// @ts-expect-error TS2339
|
|
9
|
-
this.element = element
|
|
10
|
-
// @ts-expect-error TS2339
|
|
11
|
-
this.keys = keys
|
|
12
|
-
// @ts-expect-error TS2339
|
|
13
|
-
this.callback = callback
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
show() {
|
|
17
|
-
// @ts-expect-error TS2339
|
|
18
|
-
this.box = this.makeBox()
|
|
19
|
-
// @ts-expect-error TS2339
|
|
20
|
-
if (this.box === null) return
|
|
21
|
-
|
|
22
|
-
// box 全体のクリックは先頭キーを開く(広いクリック領域を維持)。複数キー時は各ラベルから個別に開ける
|
|
23
|
-
// @ts-expect-error TS2339
|
|
24
|
-
this.box.addEventListener('click', () => {
|
|
25
|
-
// @ts-expect-error TS2339
|
|
26
|
-
this.callback(this.keys[0])
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
// @ts-expect-error TS2339
|
|
30
|
-
document.body.append(this.box)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
remove() {
|
|
34
|
-
// @ts-expect-error TS2339
|
|
35
|
-
if (!this.box) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
// @ts-expect-error TS2339
|
|
39
|
-
this.box.remove()
|
|
40
|
-
// @ts-expect-error TS2339
|
|
41
|
-
this.box = null
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
makeBox() {
|
|
45
|
-
const box = document.createElement('div')
|
|
46
|
-
box.classList.add('copyray-specimen')
|
|
47
|
-
box.classList.add('Specimen')
|
|
48
|
-
|
|
49
|
-
// @ts-expect-error TS2339
|
|
50
|
-
const bounds = computeBoundingBox(this.element)
|
|
51
|
-
if (bounds === null) return null
|
|
52
|
-
|
|
53
|
-
for (const key of Object.keys(bounds)) {
|
|
54
|
-
// @ts-expect-error TS7053
|
|
55
|
-
const value = bounds[key]
|
|
56
|
-
// @ts-expect-error TS7015
|
|
57
|
-
box.style[key] = `${value}px`
|
|
58
|
-
}
|
|
59
|
-
// @ts-expect-error TS2322
|
|
60
|
-
box.style.zIndex = ZINDEX
|
|
61
|
-
|
|
62
|
-
// @ts-expect-error TS2339
|
|
63
|
-
const { position, top, left } = getComputedStyle(this.element)
|
|
64
|
-
if (position === 'fixed') {
|
|
65
|
-
// @ts-expect-error TS2339
|
|
66
|
-
this.box.style.position = 'fixed'
|
|
67
|
-
// @ts-expect-error TS2339
|
|
68
|
-
this.box.style.top = `${top}px`
|
|
69
|
-
// @ts-expect-error TS2339
|
|
70
|
-
this.box.style.left = `${left}px`
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// @ts-expect-error TS2339
|
|
74
|
-
for (const key of this.keys) {
|
|
75
|
-
box.append(this.makeLabel(key))
|
|
76
|
-
}
|
|
77
|
-
return box
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// @ts-expect-error TS7006
|
|
81
|
-
makeLabel(key) {
|
|
82
|
-
const div = document.createElement('div')
|
|
83
|
-
div.classList.add('copyray-specimen-handle')
|
|
84
|
-
div.classList.add('Specimen')
|
|
85
|
-
div.textContent = key
|
|
86
|
-
// ラベルのクリックはそのキーを開く。box への伝播を止めて先頭キーとの二重発火を防ぐ
|
|
87
|
-
div.addEventListener('click', (event) => {
|
|
88
|
-
event.stopPropagation()
|
|
89
|
-
// @ts-expect-error TS2339
|
|
90
|
-
this.callback(key)
|
|
91
|
-
})
|
|
92
|
-
return div
|
|
93
|
-
}
|
|
94
|
-
}
|