Skip to content

Commit

Permalink
chore: replace webview-ui-toolkit in abbreviationview
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuisi committed Nov 5, 2024
1 parent cdd9fbb commit 1c39a21
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions vscode-lean4/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
!dist/lean4-infoview/codicon.ttf
!dist/loogleview/static
!dist/moogleview/static
!dist/abbreviationview/static
!media
!manual
!images
Expand Down
25 changes: 12 additions & 13 deletions vscode-lean4/abbreviationview/index.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import {
DataGrid,
provideVSCodeDesignSystem,
vsCodeDataGrid,
vsCodeDataGridCell,
vsCodeDataGridRow,
} from '@vscode/webview-ui-toolkit'

provideVSCodeDesignSystem().register(vsCodeDataGrid(), vsCodeDataGridRow(), vsCodeDataGridCell())

const abbreviations: { Abbreviation: string; 'Unicode symbol': string } = JSON.parse(
const abbreviations: { Abbreviation: string; 'Unicode symbol': string }[] = JSON.parse(
document.querySelector('script[data-id="abbreviationview-script"]')!.getAttribute('abbreviations')!,
)

const grid = document.getElementById('abbreviation-grid')! as DataGrid
const tableBody = document.getElementById('abbreviation-table')!

grid.rowsData = abbreviations as any
for (const { Abbreviation: abbr, 'Unicode symbol': symb } of abbreviations) {
const row = document.createElement('vscode-table-row')
const abbrCell = document.createElement('vscode-table-cell')
abbrCell.innerText = abbr
row.appendChild(abbrCell)
const symbCell = document.createElement('vscode-table-cell')
symbCell.innerText = symb
row.appendChild(symbCell)
tableBody.appendChild(row)
}
1 change: 0 additions & 1 deletion vscode-lean4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@
"@leanprover/unicode-input": "~0.1.0",
"@leanprover/unicode-input-component": "~0.1.0",
"@vscode/codicons": "^0.0.36",
"@vscode/webview-ui-toolkit": "^1.4.0",
"@vscode-elements/elements": "^1.7.1",
"markdown-it": "^14.1.0",
"markdown-it-anchor": "^9.0.1",
Expand Down
13 changes: 12 additions & 1 deletion vscode-lean4/src/abbreviationview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,21 @@ export class AbbreviationView implements Disposable {
<meta charset="UTF-8" />
<meta http-equiv="Content-type" content="text/html;charset=utf-8">
<title>AbbreviationView</title>
<script
src="${this.webviewUri(this.webviewPanel, 'dist', 'abbreviationview', 'static', 'elements', 'bundled.js')}"
type="module"
></script>
<script defer data-id="abbreviationview-script" src="${this.webviewUri(this.webviewPanel, 'dist/abbreviationview.js')}" abbreviations="${escapeHtml(JSON.stringify(abbreviations))}"></script>
</head>
<body>
<vscode-data-grid id="abbreviation-grid" aria-label="Abbreviations" grid-template-columns="20em 1fr"></vscode-data-grid>
<vscode-table aria-label="Abbreviations" responsive resizable bordered zebra>
<vscode-table-header slot="header">
<vscode-table-header-cell>Abbreviation</vscode-table-header-cell>
<vscode-table-header-cell>Unicode symbol</vscode-table-header-cell>
</vscode-table-header>
<vscode-table-body id="abbreviation-table" slot="body">
</vscode-table-body>
</vscode-table>
</body>
</html>`
this.webviewPanel.reveal()
Expand Down
10 changes: 10 additions & 0 deletions vscode-lean4/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ const getAbbreviationViewConfig = env => ({
filename: 'abbreviationview.js',
path: path.resolve(__dirname, 'dist'),
},
plugins: [
new CopyPlugin({
patterns: [
{
from: '../node_modules/@vscode-elements/elements/dist',
to: path.resolve(__dirname, 'dist', 'abbreviationview', 'static', 'elements'),
},
],
}),
],
})

/** @type {(env: Env) => import('webpack').Configuration} */
Expand Down

0 comments on commit 1c39a21

Please sign in to comment.