|
1 |
| -<style> |
2 |
| - #qwik-inspector-overlay { |
3 |
| - position: fixed; |
4 |
| - background: rgba(24, 182, 246, 0.27); |
5 |
| - pointer-events: none; |
6 |
| - box-sizing: border-box; |
7 |
| - border: 2px solid rgba(172, 126, 244, 0.46); |
8 |
| - border-radius: 4px; |
9 |
| - contain: strict; |
10 |
| - cursor: pointer; |
11 |
| - z-index: 999999; |
12 |
| - } |
13 |
| - |
14 |
| - #qwik-inspector-info-popup { |
15 |
| - position: fixed; |
16 |
| - bottom: 10px; |
17 |
| - right: 10px; |
18 |
| - font-family: monospace; |
19 |
| - background: #000000c2; |
20 |
| - color: white; |
21 |
| - padding: 10px 20px; |
22 |
| - border-radius: 8px; |
23 |
| - box-shadow: |
24 |
| - 0 20px 25px -5px rgb(0 0 0 / 34%), |
25 |
| - 0 8px 10px -6px rgb(0 0 0 / 24%); |
26 |
| - backdrop-filter: blur(4px); |
27 |
| - -webkit-animation: fadeOut 0.3s 3s ease-in-out forwards; |
28 |
| - animation: fadeOut 0.3s 3s ease-in-out forwards; |
29 |
| - z-index: 999999; |
30 |
| - contain: layout; |
31 |
| - } |
32 |
| - |
33 |
| - #qwik-inspector-info-popup p { |
34 |
| - margin: 0px; |
35 |
| - } |
36 |
| - |
37 |
| - @-webkit-keyframes fadeOut { |
38 |
| - 0% { |
39 |
| - opacity: 1; |
40 |
| - } |
41 |
| - |
42 |
| - 100% { |
43 |
| - opacity: 0; |
44 |
| - } |
45 |
| - } |
46 |
| - |
47 |
| - @keyframes fadeOut { |
48 |
| - 0% { |
49 |
| - opacity: 1; |
50 |
| - } |
51 |
| - |
52 |
| - 100% { |
53 |
| - opacity: 0; |
54 |
| - visibility: hidden; |
55 |
| - } |
56 |
| - } |
57 |
| -</style> |
58 |
| -<div id="qwik-inspector-info-popup" aria-hidden="true">Click-to-Source</div> |
59 |
| -<script> |
60 |
| - (function () { |
| 1 | +if (typeof document !== 'undefined') { |
| 2 | + const register = () => { |
61 | 3 | const inspectAttribute = 'data-qwik-inspector';
|
62 |
| - const hotKeys = globalThis.qwikdevtools.hotKeys; |
63 |
| - const srcDir = globalThis.qwikdevtools.srcDir; |
64 |
| - document.querySelector('#qwik-inspector-info-popup').textContent = |
65 |
| - `Click-to-Source: ${hotKeys.join(' + ')}`; |
| 4 | + const hotKeys = globalThis.__HOTKEYS__; |
| 5 | + const srcDir = globalThis.__SRC_DIR__; |
| 6 | + let popup = document.querySelector('#qwik-inspector-info-popup'); |
| 7 | + if (!popup) { |
| 8 | + popup = document.createElement('div'); |
| 9 | + popup.id = 'qwik-inspector-info-popup'; |
| 10 | + popup['aria-hidden'] = 'true'; |
| 11 | + document.body.appendChild(popup); |
| 12 | + } |
| 13 | + popup.textContent = `Click-to-Source: ${hotKeys.join(' + ')}`; |
| 14 | + // eslint-disable-next-line no-console |
66 | 15 | console.debug(
|
67 | 16 | '%c🔍 Qwik Click-To-Source',
|
68 | 17 | 'background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;',
|
|
107 | 56 |
|
108 | 57 | window.addEventListener(
|
109 | 58 | 'blur',
|
110 |
| - (event) => { |
| 59 | + () => { |
111 | 60 | window.__qwik_inspector_state.pressedKeys.clear();
|
112 | 61 | updateOverlay();
|
113 | 62 | },
|
|
139 | 88 | const inspectUrl = target.getAttribute(inspectAttribute);
|
140 | 89 | if (inspectUrl !== 'false') {
|
141 | 90 | body.style.setProperty('cursor', 'progress');
|
142 |
| - qwikOpenInEditor(inspectUrl); |
| 91 | + globalThis.qwikOpenInEditor(inspectUrl); |
143 | 92 | }
|
144 | 93 | }
|
145 | 94 | }
|
146 | 95 | },
|
147 | 96 | { capture: true }
|
148 | 97 | );
|
149 | 98 |
|
| 99 | + // TODO use the vite dev URLs and translate in resolveId + use launch-editor from NPM |
150 | 100 | globalThis.qwikOpenInEditor = function (path) {
|
151 | 101 | const isWindows = navigator.platform.includes('Win');
|
152 | 102 | const resolvedURL = new URL(path, isWindows ? origin : srcDir);
|
|
208 | 158 | }
|
209 | 159 | window.addEventListener('resize', updateOverlay);
|
210 | 160 | document.addEventListener('scroll', updateOverlay);
|
211 |
| - })(); |
212 |
| -</script> |
| 161 | + }; |
| 162 | + |
| 163 | + document.addEventListener('DOMContentLoaded', register); |
| 164 | +} |
0 commit comments