Skip to content

Commit 55f169d

Browse files
committed
fix: copy code block
1 parent 87ed64c commit 55f169d

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
# Changelog
44

5+
## 0.10.1
6+
7+
- Fixed the copy button for code blocks.
8+
- Improved error handling when fetching live rules.
9+
510
## 0.10.0
611

712
- Variables in code panels are now copyable.

components/Code.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ const highlighted = computed(() => {
5454
const code = computed(() => props.code)
5555
const copy = useCopy(code)
5656
57+
function handleCopy() {
58+
copy()
59+
}
60+
5761
function handleClick(event: MouseEvent) {
5862
const target = event.target as HTMLElement
5963
if (target.closest('.token.copyable')) {
@@ -68,7 +72,7 @@ function handleClick(event: MouseEvent) {
6872
{{ title }}
6973
<div class="tp-row tp-gap">
7074
<slot name="actions" />
71-
<IconButton variant="secondary" title="Copy" @click="copy">
75+
<IconButton variant="secondary" title="Copy" @click="handleCopy">
7276
<Copy />
7377
</IconButton>
7478
</div>

entrypoints/background.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@ const SYNC_ALARM = 'sync-rules'
55
const SYNC_INTERVAL_MINUTES = 10
66

77
async function fetchRules() {
8-
const res = await fetch(RULE_URL, { cache: 'no-store' })
9-
if (!res.ok) {
10-
console.error('[tempad-dev] Failed to fetch rules:', res.statusText)
11-
}
12-
13-
const newRules = await res.json()
14-
const oldIds = (await browser.declarativeNetRequest.getDynamicRules()).map(({ id }) => id)
8+
try {
9+
const res = await fetch(RULE_URL, { cache: 'no-store' })
10+
if (!res.ok) {
11+
console.error('[tempad-dev] Failed to fetch rules:', res.statusText)
12+
return
13+
}
1514

16-
await browser.declarativeNetRequest.updateEnabledRulesets({
17-
disableRulesetIds: ['figma']
18-
})
15+
const newRules = await res.json()
16+
const oldIds = (await browser.declarativeNetRequest.getDynamicRules()).map(({ id }) => id)
1917

20-
await browser.declarativeNetRequest.updateDynamicRules({
21-
removeRuleIds: oldIds,
22-
addRules: newRules
23-
})
18+
await browser.declarativeNetRequest.updateEnabledRulesets({
19+
disableRulesetIds: ['figma']
20+
})
2421

25-
console.log(`[tempad-dev] Updated ${newRules.length} rule${newRules.length === 1 ? '' : 's'}.`)
22+
await browser.declarativeNetRequest.updateDynamicRules({
23+
removeRuleIds: oldIds,
24+
addRules: newRules
25+
})
26+
console.log(`[tempad-dev] Updated ${newRules.length} rule${newRules.length === 1 ? '' : 's'}.`)
27+
} catch (error) {
28+
console.error('[tempad-dev] Error fetching rules:', error)
29+
}
2630
}
2731

2832
export default defineBackground(() => {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "tempad-dev",
33
"description": "Inspect panel on Figma, for everyone.",
44
"private": true,
5-
"version": "0.10.0",
5+
"version": "0.10.1",
66
"type": "module",
77
"scripts": {
88
"dev": "wxt",

0 commit comments

Comments
 (0)