You've already forked vscode-1c-metadata-viewer
mirror of
https://github.com/zerobig/vscode-1c-metadata-viewer.git
synced 2025-07-17 01:32:19 +02:00
В продакшен!
This commit is contained in:
4
resources/dark/folder.svg
Normal file
4
resources/dark/folder.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48">
|
||||
<style type="text/css">.icon-canvas-transparent{opacity:0;fill:#F6F6F6;} .icon-vs-out{opacity:0;fill:#F6F6F6;} .icon-vs-bg{fill:#656565;} .icon-vs-fg{fill:#F0EFF1;}</style>
|
||||
<path class="icon-vs-fg" d="M7.05 40q-1.2 0-2.1-.925-.9-.925-.9-2.075V11q0-1.15.9-2.075Q5.85 8 7.05 8h14l3 3h17q1.15 0 2.075.925.925.925.925 2.075v23q0 1.15-.925 2.075Q42.2 40 41.05 40Zm0-29v26h34V14H22.8l-3-3H7.05Zm0 0v26Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 472 B |
4
resources/light/folder.svg
Normal file
4
resources/light/folder.svg
Normal file
@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48">
|
||||
<style>.icon-canvas-transparent{opacity:0;fill:#2d2d30}.icon-vs-out{fill:#2d2d30}.icon-vs-bg{fill:#c5c5c5}.icon-vs-fg{fill:#2b282e}</style>
|
||||
<path class="icon-vs-fg" d="M7.05 40q-1.2 0-2.1-.925-.9-.925-.9-2.075V11q0-1.15.9-2.075Q5.85 8 7.05 8h14l3 3h17q1.15 0 2.075.925.925.925.925 2.075v23q0 1.15-.925 2.075Q42.2 40 41.05 40Zm0-29v26h34V14H22.8l-3-3H7.05Zm0 0v26Z"/>
|
||||
</svg>
|
After Width: | Height: | Size: 439 B |
@ -6,7 +6,7 @@ export interface PredefinedData {
|
||||
Item: PredefinedDataItem[];
|
||||
}
|
||||
|
||||
interface PredefinedDataItem {
|
||||
export interface PredefinedDataItem {
|
||||
ChildItems: PredefinedData[];
|
||||
Code: string[];
|
||||
Description: string[];
|
||||
|
@ -1,8 +1,79 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { PredefinedData } from './predefinedDataInterfaces';
|
||||
import { PredefinedData, PredefinedDataItem } from './predefinedDataInterfaces';
|
||||
|
||||
export class PredefinedDataPanel {
|
||||
public static show(extensionUri: vscode.Uri, data: PredefinedData) {
|
||||
console.log(JSON.stringify(data));
|
||||
public static readonly viewType = 'metadataViewer.predefinedPanel';
|
||||
|
||||
public static show(extensionUri: vscode.Uri, data: PredefinedData) {
|
||||
const column = vscode.window.activeTextEditor
|
||||
? vscode.window.activeTextEditor.viewColumn
|
||||
: undefined;
|
||||
|
||||
const panel = vscode.window.createWebviewPanel(
|
||||
PredefinedDataPanel.viewType,
|
||||
"Предопределенные элементы",
|
||||
column || vscode.ViewColumn.One
|
||||
);
|
||||
|
||||
panel.webview.html = this._getHtmlForWebview(panel.webview, extensionUri, data);
|
||||
}
|
||||
}
|
||||
|
||||
private static _getHtmlForWebview(webview: vscode.Webview, extensionUri: vscode.Uri, data: PredefinedData) {
|
||||
const styleUri = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'media', 'predefined', 'styles.css'));
|
||||
|
||||
// TODO: иконка catalog.svg для других предопределенных элементов должна быть другой
|
||||
const isDark = vscode.window.activeColorTheme.kind === vscode.ColorThemeKind.Dark;
|
||||
|
||||
const rootImagePath = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'resources', isDark ? 'dark' : 'light', 'catalog.svg'));
|
||||
const folderImagePath = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'resources', isDark ? 'dark' : 'light', 'folder.svg'));
|
||||
const elementImagePath = webview.asWebviewUri(vscode.Uri.joinPath(extensionUri, 'resources', isDark ? 'dark' : 'light', 'attribute.svg'));
|
||||
|
||||
// TODO: разобраться с безопасностью ресурсов и переделать
|
||||
return `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title></title>
|
||||
<link href="${styleUri}" rel="stylesheet" />
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table rules="all">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Имя</th>
|
||||
<th>Код</th>
|
||||
<th>Наименование</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr><td colspan="3"><img src="${rootImagePath}" width="16px" height="16px" style="margin-bottom: 3px; vertical-align: middle;" /> Элементы</td></tr>
|
||||
${data.Item.map(i => CreateItem(i, [ folderImagePath, elementImagePath ], 1)).join('')}
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
}
|
||||
|
||||
function CreateItem(item: PredefinedDataItem, imageUri: vscode.Uri[], level: number): string {
|
||||
return `<tr>
|
||||
<td>${(() => {
|
||||
if (item.IsFolder[0] === 'true') {
|
||||
return `<img src="${imageUri[0]}" width="16px" height="16px" style="margin-left: ${16 * level}px; margin-bottom: 3px; vertical-align: middle;" />`;
|
||||
} else {
|
||||
return `<img src="${imageUri[1]}" width="16px" height="16px" style="margin-left: ${16 * level}px; margin-bottom: 3px; vertical-align: middle;" />`;
|
||||
}
|
||||
})()} ${item.Name}</td>
|
||||
<td>${item.Code}</td>
|
||||
<td>${item.Description}</td>
|
||||
</tr>
|
||||
${(() => {
|
||||
if (item.ChildItems) {
|
||||
return item.ChildItems[0].Item.map(i => CreateItem(i, imageUri, level + 1)).join('');
|
||||
}
|
||||
|
||||
return '';
|
||||
})()}`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user