copy_tuner_client 1.4.0 → 2.0.0
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/.gitattributes +2 -2
- data/.github/workflows/rspec.yml +1 -1
- data/CHANGELOG.md +27 -0
- data/CLAUDE.md +2 -3
- data/README.md +0 -25
- data/UPGRADING.md +201 -0
- data/app/assets/javascripts/copytuner.js +78 -73
- data/app/assets/stylesheets/copytuner.css +1 -1
- data/lib/copy_tuner_client/cache.rb +0 -2
- data/lib/copy_tuner_client/configuration.rb +23 -37
- data/lib/copy_tuner_client/copyray/marker.rb +24 -0
- data/lib/copy_tuner_client/copyray/rewriter.rb +113 -0
- data/lib/copy_tuner_client/copyray.rb +11 -4
- data/lib/copy_tuner_client/copyray_middleware.rb +10 -2
- data/lib/copy_tuner_client/helper_extension.rb +24 -3
- data/lib/copy_tuner_client/i18n_backend.rb +5 -12
- data/lib/copy_tuner_client/version.rb +1 -1
- data/skills/copy-tuner/SKILL.md +37 -6
- data/skills/copy-tuner-to-locales-cleanup/SKILL.md +4 -4
- data/skills/copy-tuner-to-locales-migrate-prefix/references/local-first-regexp.md +4 -9
- data/skills/copy-tuner-to-t-migrate/SKILL.md +131 -0
- data/skills/copy-tuner-to-t-migrate/scripts/migrate_tt.rb +189 -0
- data/spec/copy_tuner_client/cache_spec.rb +2 -10
- data/spec/copy_tuner_client/client_spec.rb +1 -0
- data/spec/copy_tuner_client/configuration_spec.rb +16 -16
- data/spec/copy_tuner_client/copyray/marker_spec.rb +41 -0
- data/spec/copy_tuner_client/copyray/rewriter_spec.rb +216 -0
- data/spec/copy_tuner_client/copyray_middleware_spec.rb +89 -0
- data/spec/copy_tuner_client/copyray_spec.rb +22 -39
- data/spec/copy_tuner_client/helper_extension_spec.rb +97 -5
- data/spec/copy_tuner_client/i18n_backend_spec.rb +8 -15
- data/spec/support/client_spec_helpers.rb +0 -1
- data/src/copyray.css +11 -0
- data/src/copyray.ts +10 -29
- data/src/copytuner_bar.ts +15 -1
- data/src/main.ts +5 -2
- data/src/specimen.ts +17 -7
- metadata +9 -1
data/src/copytuner_bar.ts
CHANGED
|
@@ -5,7 +5,7 @@ const HIDDEN_CLASS = 'copy-tuner-hidden'
|
|
|
5
5
|
|
|
6
6
|
export default class CopytunerBar {
|
|
7
7
|
// @ts-expect-error TS7006
|
|
8
|
-
constructor(element, data, callback) {
|
|
8
|
+
constructor(element, data, callback, keysSkipped = false) {
|
|
9
9
|
// @ts-expect-error TS2339
|
|
10
10
|
this.element = element
|
|
11
11
|
// @ts-expect-error TS2339
|
|
@@ -19,9 +19,23 @@ export default class CopytunerBar {
|
|
|
19
19
|
// @ts-expect-error TS2339
|
|
20
20
|
this.element.append(this.logMenuElement)
|
|
21
21
|
|
|
22
|
+
// 巨大DOM/Nokogiri例外でキー付与がスキップされた場合は、オーバーレイが使えないので
|
|
23
|
+
// ツールバー(Translations in this page)から編集する旨を案内する。
|
|
24
|
+
if (keysSkipped) {
|
|
25
|
+
this.appendSkippedNotice()
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
this.addHandler()
|
|
23
29
|
}
|
|
24
30
|
|
|
31
|
+
appendSkippedNotice() {
|
|
32
|
+
const notice = document.createElement('span')
|
|
33
|
+
notice.classList.add('copy-tuner-bar__notice')
|
|
34
|
+
notice.textContent = '⚠ This page is too large for the overlay. Use "Translations in this page" to edit.'
|
|
35
|
+
// @ts-expect-error TS2339
|
|
36
|
+
this.element.append(notice)
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
addHandler() {
|
|
26
40
|
// @ts-expect-error TS2339
|
|
27
41
|
const openLogButton = this.element.querySelector('.js-copy-tuner-bar-open-log')
|
data/src/main.ts
CHANGED
|
@@ -9,6 +9,9 @@ declare global {
|
|
|
9
9
|
toggle?: () => void
|
|
10
10
|
// TODO: type
|
|
11
11
|
data: object
|
|
12
|
+
// 巨大DOM/Nokogiri例外で data-copyray-key 付与をスキップしたか。
|
|
13
|
+
// true のときオーバーレイは使えないのでツールバーから編集する旨を案内する。
|
|
14
|
+
keysSkipped?: boolean
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
17
|
}
|
|
@@ -30,10 +33,10 @@ const appendCopyTunerBar = (url: string) => {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
const start = () => {
|
|
33
|
-
const { url, data } = window.CopyTuner
|
|
36
|
+
const { url, data, keysSkipped } = window.CopyTuner
|
|
34
37
|
|
|
35
38
|
appendCopyTunerBar(url)
|
|
36
|
-
const copyray = new Copyray(url, data)
|
|
39
|
+
const copyray = new Copyray(url, data, Boolean(keysSkipped))
|
|
37
40
|
window.CopyTuner.toggle = () => copyray.toggle()
|
|
38
41
|
|
|
39
42
|
document.addEventListener('keydown', (event) => {
|
data/src/specimen.ts
CHANGED
|
@@ -4,11 +4,11 @@ const ZINDEX = 2_000_000_000
|
|
|
4
4
|
|
|
5
5
|
export default class Specimen {
|
|
6
6
|
// @ts-expect-error TS7006
|
|
7
|
-
constructor(element,
|
|
7
|
+
constructor(element, keys, callback) {
|
|
8
8
|
// @ts-expect-error TS2339
|
|
9
9
|
this.element = element
|
|
10
10
|
// @ts-expect-error TS2339
|
|
11
|
-
this.
|
|
11
|
+
this.keys = keys
|
|
12
12
|
// @ts-expect-error TS2339
|
|
13
13
|
this.callback = callback
|
|
14
14
|
}
|
|
@@ -19,10 +19,11 @@ export default class Specimen {
|
|
|
19
19
|
// @ts-expect-error TS2339
|
|
20
20
|
if (this.box === null) return
|
|
21
21
|
|
|
22
|
+
// box 全体のクリックは先頭キーを開く(広いクリック領域を維持)。複数キー時は各ラベルから個別に開ける
|
|
22
23
|
// @ts-expect-error TS2339
|
|
23
24
|
this.box.addEventListener('click', () => {
|
|
24
25
|
// @ts-expect-error TS2339
|
|
25
|
-
this.callback(this.
|
|
26
|
+
this.callback(this.keys[0])
|
|
26
27
|
})
|
|
27
28
|
|
|
28
29
|
// @ts-expect-error TS2339
|
|
@@ -69,16 +70,25 @@ export default class Specimen {
|
|
|
69
70
|
this.box.style.left = `${left}px`
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
// @ts-expect-error TS2339
|
|
74
|
+
for (const key of this.keys) {
|
|
75
|
+
box.append(this.makeLabel(key))
|
|
76
|
+
}
|
|
73
77
|
return box
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
|
|
80
|
+
// @ts-expect-error TS7006
|
|
81
|
+
makeLabel(key) {
|
|
77
82
|
const div = document.createElement('div')
|
|
78
83
|
div.classList.add('copyray-specimen-handle')
|
|
79
84
|
div.classList.add('Specimen')
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
div.textContent = key
|
|
86
|
+
// ラベルのクリックはそのキーを開く。box への伝播を止めて先頭キーとの二重発火を防ぐ
|
|
87
|
+
div.addEventListener('click', (event) => {
|
|
88
|
+
event.stopPropagation()
|
|
89
|
+
// @ts-expect-error TS2339
|
|
90
|
+
this.callback(key)
|
|
91
|
+
})
|
|
82
92
|
return div
|
|
83
93
|
}
|
|
84
94
|
}
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: copy_tuner_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SonicGarden
|
|
@@ -198,6 +198,7 @@ files:
|
|
|
198
198
|
- LICENSE.txt
|
|
199
199
|
- README.md
|
|
200
200
|
- Rakefile
|
|
201
|
+
- UPGRADING.md
|
|
201
202
|
- app/assets/javascripts/copytuner.js
|
|
202
203
|
- app/assets/stylesheets/copytuner.css
|
|
203
204
|
- copy_tuner_client.gemspec
|
|
@@ -210,6 +211,8 @@ files:
|
|
|
210
211
|
- lib/copy_tuner_client/client.rb
|
|
211
212
|
- lib/copy_tuner_client/configuration.rb
|
|
212
213
|
- lib/copy_tuner_client/copyray.rb
|
|
214
|
+
- lib/copy_tuner_client/copyray/marker.rb
|
|
215
|
+
- lib/copy_tuner_client/copyray/rewriter.rb
|
|
213
216
|
- lib/copy_tuner_client/copyray_middleware.rb
|
|
214
217
|
- lib/copy_tuner_client/dotted_hash.rb
|
|
215
218
|
- lib/copy_tuner_client/engine.rb
|
|
@@ -237,10 +240,15 @@ files:
|
|
|
237
240
|
- skills/copy-tuner-to-locales-migrate-prefix/references/local-first-regexp.md
|
|
238
241
|
- skills/copy-tuner-to-locales-migrate-prefix/references/verification-per-prefix.md
|
|
239
242
|
- skills/copy-tuner-to-locales-migrate-prefix/scripts/migrate_prefix.rb
|
|
243
|
+
- skills/copy-tuner-to-t-migrate/SKILL.md
|
|
244
|
+
- skills/copy-tuner-to-t-migrate/scripts/migrate_tt.rb
|
|
240
245
|
- skills/copy-tuner/SKILL.md
|
|
241
246
|
- spec/copy_tuner_client/cache_spec.rb
|
|
242
247
|
- spec/copy_tuner_client/client_spec.rb
|
|
243
248
|
- spec/copy_tuner_client/configuration_spec.rb
|
|
249
|
+
- spec/copy_tuner_client/copyray/marker_spec.rb
|
|
250
|
+
- spec/copy_tuner_client/copyray/rewriter_spec.rb
|
|
251
|
+
- spec/copy_tuner_client/copyray_middleware_spec.rb
|
|
244
252
|
- spec/copy_tuner_client/copyray_spec.rb
|
|
245
253
|
- spec/copy_tuner_client/dotted_hash_spec.rb
|
|
246
254
|
- spec/copy_tuner_client/helper_extension_spec.rb
|