Skip to content

Commit dc8b8ac

Browse files
authored
Revert "Fix font-family not loading correctly"
1 parent 6bfbdde commit dc8b8ac

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

webview/index.js

+12-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
let target = 'container'
55
let transparentBackground = false
66
let backgroundColor = '#f2f2f2'
7-
let fontFamily
87

98
vscode.postMessage({
109
type: 'getAndUpdateCacheAndSettings'
@@ -15,15 +14,14 @@
1514
const obturateur = document.getElementById('save')
1615

1716
snippetContainerNode.style.opacity = '1'
18-
const oldState = vscode.getState()
17+
const oldState = vscode.getState();
1918
if (oldState && oldState.innerHTML) {
2019
snippetNode.innerHTML = oldState.innerHTML
2120
}
2221

23-
const getInitialHtml = ff => {
22+
const getInitialHtml = fontFamily => {
2423
const cameraWithFlashEmoji = String.fromCodePoint(128248)
25-
const monoFontStack = `${ff},SFMono-Regular,Consolas,DejaVu Sans Mono,Ubuntu Mono,Liberation Mono,Menlo,Courier,monospace`
26-
fontFamily = monoFontStack
24+
const monoFontStack = `${fontFamily},SFMono-Regular,Consolas,DejaVu Sans Mono,Ubuntu Mono,Liberation Mono,Menlo,Courier,monospace`
2725
return `<meta charset="utf-8"><div style="color: #d8dee9;background-color: #2e3440; font-family: ${monoFontStack};font-weight: normal;font-size: 12px;line-height: 18px;white-space: pre;"><div><span style="color: #8fbcbb;">console</span><span style="color: #eceff4;">.</span><span style="color: #88c0d0;">log</span><span style="color: #d8dee9;">(</span><span style="color: #eceff4;">'</span><span style="color: #a3be8c;">0. Run command \`Polacode ${cameraWithFlashEmoji}\`</span><span style="color: #eceff4;">'</span><span style="color: #d8dee9;">)</span></div><div><span style="color: #8fbcbb;">console</span><span style="color: #eceff4;">.</span><span style="color: #88c0d0;">log</span><span style="color: #d8dee9;">(</span><span style="color: #eceff4;">'</span><span style="color: #a3be8c;">1. Copy some code</span><span style="color: #eceff4;">'</span><span style="color: #d8dee9;">)</span></div><div><span style="color: #8fbcbb;">console</span><span style="color: #eceff4;">.</span><span style="color: #88c0d0;">log</span><span style="color: #d8dee9;">(</span><span style="color: #eceff4;">'</span><span style="color: #a3be8c;">2. Paste into Polacode view</span><span style="color: #eceff4;">'</span><span style="color: #d8dee9;">)</span></div><div><span style="color: #8fbcbb;">console</span><span style="color: #eceff4;">.</span><span style="color: #88c0d0;">log</span><span style="color: #d8dee9;">(</span><span style="color: #eceff4;">'</span><span style="color: #a3be8c;">3. Click the button ${cameraWithFlashEmoji}</span><span style="color: #eceff4;">'</span><span style="color: #d8dee9;">)</span></div></div></div>`
2826
}
2927

@@ -63,7 +61,7 @@
6361
}
6462
function getSnippetBgColor(html) {
6563
const match = html.match(/background-color: (#[a-fA-F0-9]+)/)
66-
return match ? match[1] : undefined
64+
return match ? match[1] : undefined;
6765
}
6866

6967
function updateEnvironment(snippetBgColor) {
@@ -104,10 +102,7 @@
104102
}
105103

106104
document.addEventListener('paste', e => {
107-
const div = document.createElement('div')
108-
div.innerHTML = e.clipboardData.getData('text/html')
109-
div.querySelector('div').style.fontFamily = fontFamily
110-
const innerHTML = div.innerHTML
105+
const innerHTML = e.clipboardData.getData('text/html')
111106

112107
const code = e.clipboardData.getData('text/plain')
113108
const minIndent = getMinIndent(code)
@@ -134,7 +129,7 @@
134129

135130
obturateur.addEventListener('click', () => {
136131
if (target === 'container') {
137-
shootAll()
132+
shootAll()
138133
} else {
139134
shootSnippet()
140135
}
@@ -233,6 +228,7 @@
233228
} else {
234229
snippetContainerNode.style.background = 'none'
235230
}
231+
236232
} else if (e.data.type === 'update') {
237233
document.execCommand('paste')
238234
} else if (e.data.type === 'restore') {
@@ -257,10 +253,10 @@
257253
})()
258254

259255
function getRgba(hex, transparentBackground) {
260-
const bigint = parseInt(hex.slice(1), 16)
261-
const r = (bigint >> 16) & 255
262-
const g = (bigint >> 8) & 255
263-
const b = bigint & 255
256+
const bigint = parseInt(hex.slice(1), 16);
257+
const r = (bigint >> 16) & 255;
258+
const g = (bigint >> 8) & 255;
259+
const b = bigint & 255;
264260
const a = transparentBackground ? 0 : 1
265261
return `rgba(${r}, ${g}, ${b}, ${a})`
266-
}
262+
}

0 commit comments

Comments
 (0)