| 104 | } |
| 105 | |
| 106 | function getWebviewContent() { |
| 107 | // baseline adjustment based on https://stackoverflow.com/a/27295528 |
| 108 | return `<!DOCTYPE html> |
| 109 | <html lang="en"> |
| 110 | <body> |
| 111 | <h1>Loading Cursorless...</h1> |
| 112 | <div id="container"> |
| 113 | <span id="letter" style="line-height: 0; visibility:hidden; font-size: 1000px; font-family: var(--vscode-editor-font-family); font-weight: var(--vscode-editor-font-weight);">A</span> |
| 114 | </div> |
| 115 | <script> |
| 116 | const letter = document.querySelector('#letter'); |
| 117 | const container = document.querySelector('#container'); |
| 118 | const baselineHeight = letter.offsetTop + letter.offsetHeight - container.offsetHeight - container.offsetTop; |
| 119 | const vscode = acquireVsCodeApi(); |
| 120 | vscode.postMessage({ |
| 121 | widthRatio: letter.offsetWidth / 1000, |
| 122 | heightRatio: (letter.offsetHeight - baselineHeight) / 1000 |
| 123 | }); |
| 124 | </script> |
| 125 | </body> |
| 126 | </html>`; |
| 127 | } |