-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (34 loc) · 917 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const template = document.createElement('template');
template.innerHTML = `
<style>
.dot {
display: none;
background: blue;
height: 20px;
width: 20px;
border-radius: 20px;
top: 0px;
left: 0px;
position: absolute;
}
</style>
<a id="dot" class="dot"></a>`;
class FileOpener extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.shadowRoot.appendChild(template.content.cloneNode(true));
const workstacePath = localStorage.getItem('DEV_WORKSPACE_PATH');
if (workstacePath !== null) {
const dot = this.shadowRoot.getElementById('dot');
dot.setAttribute(
'href',
`vscode://file/${workstacePath}${this.getAttribute('src')}`
);
dot.style.display = 'block';
}
}
}
window.customElements.define('file-open-in-editor', FileOpener);