forked from external/vscode-xml
commit
b09f732f50
@ -1,10 +1,12 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
let DOMParser = require('xmldom').DOMParser;
|
let DOMParser = require('xmldom').DOMParser;
|
||||||
|
let fs = require('fs');
|
||||||
|
|
||||||
export class XmlTreeService {
|
export class XmlTreeService {
|
||||||
static getXmlTreeHtml(xml: string): string {
|
static getXmlTreeHtml(xml: string): string {
|
||||||
let xdoc: Document = new DOMParser().parseFromString(xml, 'text/xml');
|
let xdoc: Document = new DOMParser().parseFromString(xml, 'text/xml');
|
||||||
|
let fontColor: string = XmlTreeService._getRecommendedTextColor();
|
||||||
let html: string =
|
let html: string =
|
||||||
`
|
`
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@ -22,7 +24,7 @@ export class XmlTreeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color: #ffffff;
|
color: ${fontColor};
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +76,7 @@ export class XmlTreeService {
|
|||||||
|
|
||||||
li.xml a {
|
li.xml a {
|
||||||
background: url(document.png) 0 0 no-repeat;
|
background: url(document.png) 0 0 no-repeat;
|
||||||
color: #000;
|
color: ${fontColor};
|
||||||
padding-left: 21px;
|
padding-left: 21px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
display: block;
|
display: block;
|
||||||
@ -114,6 +116,7 @@ export class XmlTreeService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
li label {
|
li label {
|
||||||
|
color: ${fontColor};
|
||||||
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAYJJREFUOBFjYBjygJGQD1SmfNb+w8Sw8g8js/uTTK6n6OqZ0AXs/HfKIov9ZWKIANoi+OQl53Mb7y2CDqH7eZDlUQywD9qSxcj056ZT6GZpJEXhQANWMTQw/mNiY1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ElFTkSuQmCC) 15px 1px no-repeat;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: block;
|
display: block;
|
||||||
@ -184,4 +187,36 @@ export class XmlTreeService {
|
|||||||
|
|
||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static _getRecommendedTextColor(): string {
|
||||||
|
let color = '#AAAAAA';
|
||||||
|
let path = '';
|
||||||
|
|
||||||
|
switch (process.platform) {
|
||||||
|
case 'darwin':
|
||||||
|
path = `${process.env.HOME}/Library/Application Support/Code/storage.json`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'win32':
|
||||||
|
path = `${process.env.APPDATA}\\Code\\storage.json`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
path = `${process.env.HOME}/.config/Code/storage.json`
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
fs.accessSync(path);
|
||||||
|
|
||||||
|
let json = fs.readFileSync(path, 'utf8');
|
||||||
|
let storage = JSON.parse(json);
|
||||||
|
|
||||||
|
color = (storage.theme.indexOf('vs-dark') > -1) ? '#FFFFFF' : '#000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
catch (error) { }
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user