Repository navigation
Expand file tree
/
Copy pathfriendly-ui.js
More file actions
51 lines (46 loc) · 1.68 KB
/
Copy pathfriendly-ui.js
File metadata and controls
51 lines (46 loc) · 1.68 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
const basePath = '../../../../'
const loadJsFile = async (path, callback, isImport) => {
const resp = await fetch(
(path.startsWith('./') ? path : basePath + path) + '.js'
)
const respText = await resp.text()
const newText = callback ? await callback(respText) : respText
const blob = new Blob([newText], { type: 'application/javascript' })
const url = URL.createObjectURL(blob)
return isImport ? await import(url) : url
}
const replaceCommandPannelHeight = (text) => {
const commandPannelHeight = 36
// command panel item height
// getHeight(i){return i instanceof iO?30:i.saneDetail?44:22}
text = text.replace(
/(44:)22(?=})/g,
(_, prefix) => `${prefix}${commandPannelHeight}`
)
return text
}
const replaceItemHeight = (text) => {
const itemHeight = 30
// item height
let replaceItemH = (_, prefix) => `${prefix}${itemHeight}`
text = text.replace(/(eight\([^)]*?\)\{return )22(?!\d)/g, replaceItemH)
text = text.replace(/(ITEM_HEIGHT=)22(?!\d)/g, replaceItemH)
text = text.replace(/(\*)22(?!\d)/g, replaceItemH)
text = text.replace(/(:)22(?=})/g, replaceItemH)
return text
}
; (async function () {
const mainJsPath = 'vs/workbench/workbench.desktop.main'
await loadJsFile(
'./workbench',
async (text) => {
const mainJsUrl = await loadJsFile(mainJsPath, (text) => {
text = replaceCommandPannelHeight(text)
text = replaceItemHeight(text)
return text
})
return text.replace(mainJsPath, mainJsUrl + '#')
},
true
)
})()