Skip to content

Commit

Permalink
online editor: Support attribute grouping
Browse files Browse the repository at this point in the history
The LSP now groups attributes. Support that in the online editor
  • Loading branch information
hunger committed Oct 21, 2022
1 parent 96acd16 commit a0061bd
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/online_editor/src/lsp_integration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

import { Position, Range } from 'vscode-languageserver-types'
import { Position, Range } from "vscode-languageserver-types";

export interface DeclarationPosition {
uri: string;
Expand All @@ -15,6 +15,7 @@ export interface DefinitionPosition {

export interface Property {
name: string;
group: string;
type_name: string;
declared_at: DeclarationPosition | null;
defined_at: DefinitionPosition | null;
Expand Down
14 changes: 14 additions & 0 deletions tools/online_editor/src/properties_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,23 @@ export class PropertiesWidget extends Widget {
) {
const table = this.tableNode;

let current_group = "";

table.innerHTML = "";

for (const p of properties) {
if (p.group !== current_group) {
const group_header = document.createElement("tr");
group_header.className = "group-header";

const group_cell = document.createElement("td");
group_cell.innerText = p.group;
group_cell.setAttribute("colspan", "2");
current_group = p.group;

group_header.appendChild(group_cell);
table.appendChild(group_header);
}
const row = document.createElement("tr");
row.className = "property";
if (p.declared_at == null) {
Expand Down
6 changes: 6 additions & 0 deletions tools/online_editor/styles/content.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@
width: 100%;
}

.properties-editor .properties-table .group-header td {
background-color: #000000;
color: #ffffff;
font-weight: bold;
}

.properties-editor .properties-table .undefined {
background-color: #b0b0b0;
}
Expand Down

0 comments on commit a0061bd

Please sign in to comment.