Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/thirty-monkeys-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@builder.io/qwik': patch
---

FIX: fix up open in editor feature
26 changes: 20 additions & 6 deletions packages/qwik/src/optimizer/src/plugins/click-to-component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
cursor: pointer;
z-index: 999999;
}

#qwik-inspector-info-popup {
position: fixed;
bottom: 10px;
Expand All @@ -28,13 +29,16 @@
z-index: 999999;
contain: layout;
}

#qwik-inspector-info-popup p {
margin: 0px;
}

@-webkit-keyframes fadeOut {
0% {
opacity: 1;
}

100% {
opacity: 0;
}
Expand All @@ -44,6 +48,7 @@
0% {
opacity: 1;
}

100% {
opacity: 0;
visibility: hidden;
Expand Down Expand Up @@ -145,14 +150,23 @@
globalThis.qwikOpenInEditor = function (path) {
const isWindows = navigator.platform.includes('Win');
const resolvedURL = new URL(path, isWindows ? origin : srcDir);
if (resolvedURL.origin === origin) {
const params = new URLSearchParams();
const prefix = isWindows ? srcDir : '';
params.set('file', prefix + resolvedURL.pathname);
fetch('/__open-in-editor?' + params.toString());
const prefix = isWindows ? srcDir : srcDir.replace('http://local.local', '');
const params = new URLSearchParams();
const filePath =
resolvedURL.protocol === 'file:' && resolvedURL.pathname.startsWith('/')
? resolvedURL.pathname.slice(1)
: resolvedURL.pathname;
let finalPath;
if (filePath.startsWith(prefix)) {
finalPath = filePath;
} else {
location.href = resolvedURL.href;
// remove the extra src from filePath as prefix already contains it
const cleaned = filePath.replace(/^[/\\]?src[/\\]/, '');
const sep = isWindows ? '\\' : '/';
finalPath = prefix.endsWith(sep) ? prefix + cleaned : prefix + sep + cleaned;
}
params.set('file', finalPath);
fetch('/__open-in-editor?' + params.toString());
};
document.addEventListener(
'contextmenu',
Expand Down