Skip to content

Commit

Permalink
update generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
jogibear9988 committed May 16, 2024
1 parent 5997ad1 commit 207bc09
Show file tree
Hide file tree
Showing 235 changed files with 20,929 additions and 1,437 deletions.
3 changes: 2 additions & 1 deletion src/frontend/generated/Properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"definitions": {
"BindingTarget": {
"enum": [
"explicitProperty",
"property",
"attribute",
"class",
Expand Down Expand Up @@ -37,7 +38,7 @@
"arguments",
"caller",
"name",
"__@hasInstance@5377"
"__@hasInstance@5421"
],
"type": "object"
},
Expand Down
1 change: 1 addition & 0 deletions www/assets/icons/control.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions www/assets/icons/grid.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions www/assets/icons/play.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions www/dist/frontend/config/CommandHandling.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class CommandHandling {
style += `\n\n:host {
box-sizing: border-box;
display: grid;
grid-template-columns: ${'1fr '.repeat(columns).trim()};
grid-template-rows: ${'1fr '.repeat(rows).trim()};
grid-template-columns: repeat(${columns}, 1fr);
grid-template-rows: repeat(${rows}, 1fr);
gap: 10px;
padding: 10px;
}`;
Expand Down
4 changes: 4 additions & 0 deletions www/dist/frontend/config/ConfigureWebcomponentDesigner.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { IobrokerWebuiCustomElementContextMenu } from "../services/IobrokerWebui
import { IobrokerWebuiRefactorService } from "../services/IobrokerWebuiRefactorService.js";
import { IobrokerWebuiSpecialPropertiesService } from "../services/IobrokerWebuiSpecialPropertiesService.js";
import { iobrokerHandler } from "../common/IobrokerHandler.js";
import { ExpandCollapseContextMenu } from "@node-projects/web-component-designer-widgets-wunderbaum";
import { IobrokerWebuiScreenContextMenu } from "../services/IobrokerWebuiScreenContextMenu.js";
export function configureDesigner(bindingsHelper) {
const serviceContainer = createDefaultServiceContainer();
serviceContainer.register("bindingService", new BaseCustomWebcomponentBindingsService());
Expand All @@ -41,6 +43,8 @@ export function configureDesigner(bindingsHelper) {
serviceContainer.designViewConfigButtons.push(new IobrokerWebuiConfigButtonProvider());
serviceContainer.designerContextMenuExtensions.push(new SeperatorContextMenu());
serviceContainer.designerContextMenuExtensions.push(new IobrokerWebuiCustomElementContextMenu());
serviceContainer.designerContextMenuExtensions.push(new IobrokerWebuiScreenContextMenu());
serviceContainer.designerContextMenuExtensions.push(new ExpandCollapseContextMenu());
for (let l of customElementsObserver.getElements()) {
if (l[1].length > 0) {
const elementsCfg = {
Expand Down
74 changes: 72 additions & 2 deletions www/dist/frontend/config/IobrokerWebuiAppShell.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@ const scriptSystem = new IobrokerWebuiScriptSystem(iobrokerHandler);
const bindingsHelper = new BindingsHelper(iobrokerHandler);
LazyLoader.LoadJavascript('./node_modules/monaco-editor/min/vs/loader.js');
import '@node-projects/web-component-designer';
import { ValueType } from '@node-projects/web-component-designer';
import { PanelContainer } from 'dock-spawn-ts/lib/js/PanelContainer.js';
import { PanelType } from 'dock-spawn-ts/lib/js/enums/PanelType.js';
import { configureDesigner } from './ConfigureWebcomponentDesigner.js';
const serviceContainer = configureDesigner(bindingsHelper);
import { DockSpawnTsWebcomponent } from 'dock-spawn-ts/lib/js/webcomponent/DockSpawnTsWebcomponent.js';
import { BaseCustomWebComponentConstructorAppend, LazyLoader, css, html } from '@node-projects/base-custom-webcomponent';
import { CommandHandling } from './CommandHandling.js';
import propertiesTypeInfo from "../generated/Properties.json" with { type: 'json' };
DockSpawnTsWebcomponent.cssRootDirectory = "./node_modules/dock-spawn-ts/lib/css/";
import "../runtime/controls.js";
import "./IobrokerWebuiSolutionExplorer.js";
import "./IobrokerWebuiMonacoEditor.js";
Expand Down Expand Up @@ -147,6 +146,7 @@ export class IobrokerWebuiAppShell extends BaseCustomWebComponentConstructorAppe
this._dockManager.activeDocument.setHeight(prp.newValue);
}
});
await customElements.whenDefined('dock-spawn-ts');
const linkElement = document.createElement("link");
linkElement.rel = "stylesheet";
linkElement.href = "./assets/dockspawn.css";
Expand Down Expand Up @@ -186,6 +186,36 @@ export class IobrokerWebuiAppShell extends BaseCustomWebComponentConstructorAppe
this.npmState = state.val;
stateElement.innerText = state.val;
});
//@ts-ignore
this.propertyGrid.propertyGrid.propertyGroupHover = (group) => group.properties?.[0]?.styleDeclaration;
this.propertyGrid.propertyGrid.propertyContextMenuProvider = (designItems, property) => {
const ctxMenuItems = property.service.getContextMenu(designItems, property);
if (property.service.isSet(designItems, property) == ValueType.fromStylesheet) {
ctxMenuItems.push(...[
{ title: '-' },
{
title: 'jump to declaration', action: () => {
//@ts-ignore
let styleDeclaration = property.styleDeclaration;
if (!styleDeclaration)
styleDeclaration = designItems[0].getAllStyles().filter(x => x.selector != null).flatMap(x => x.declarations).find(x => x.name == property.name);
if (styleDeclaration)
//@ts-ignore
this.jumpToCss(styleDeclaration.ast, styleDeclaration.stylesheet);
}
}
]);
}
;
return ctxMenuItems;
};
this.propertyGrid.propertyGrid.propertyGroupClick = (group, mode) => {
//@ts-ignore
if (group.properties?.[0]?.styleDeclaration?.ast?.parent)
//@ts-ignore
this.jumpToCss(group.properties?.[0]?.styleDeclaration?.ast?.parent, group.properties?.[0]?.styleDeclaration?.stylesheet);
//}
};
setTimeout(() => {
this.activateDockById('attributeDock');
this.activateDockById('eventsDock');
Expand All @@ -194,6 +224,46 @@ export class IobrokerWebuiAppShell extends BaseCustomWebComponentConstructorAppe
this._getDomElement('styleDock').title = '';
}, 150);
}
jumpToCss(styleDeclaration, stylesheet) {
//@ts-ignore
const line = styleDeclaration.position?.start?.line;
//@ts-ignore
const column = styleDeclaration.position?.start?.column;
//@ts-ignore
const lineEnd = styleDeclaration.position?.end?.line;
//@ts-ignore
const columnEnd = styleDeclaration.position?.end?.column;
//@ts-ignore
if (stylesheet?.designItem) {
//@ts-ignore
const di = stylesheet?.designItem;
let switched = false;
if (di.instanceServiceContainer.documentContainer.currentView != 'code' &&
di.instanceServiceContainer.documentContainer.currentView != 'split') {
switched = true;
di.instanceServiceContainer.documentContainer.currentView = 'split';
}
setTimeout(() => {
let startPos = column;
let endPos = columnEnd;
//@ts-ignore
const cssCode = stylesheet?.content;
const lines = cssCode.split('\n');
for (let n = 0; n < lineEnd - 1; n++) {
if (n < line - 1)
startPos += lines[n].length + 1;
endPos += lines[n].length + 1;
}
const selectionPosition = di.instanceServiceContainer.designItemDocumentPositionService.getPosition(di);
//TODO: style tag could contain attributes
const styleLength = '<style>'.length;
di.instanceServiceContainer.documentContainer.codeView.setSelection({ start: startPos + styleLength + selectionPosition.start - 1, length: endPos - startPos });
}, switched ? 250 : 0);
}
else {
this.styleEditor.showLine(line, column, lineEnd, columnEnd);
}
}
async _setupServiceContainer() {
this._solutionExplorer.initialize(serviceContainer);
this.propertyGrid.serviceContainer = serviceContainer;
Expand Down
5 changes: 5 additions & 0 deletions www/dist/frontend/config/IobrokerWebuiMonacoEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,10 @@ export class IobrokerWebuiMonacoEditor extends BaseCustomWebComponentConstructor
this._editor.revealRangeInCenterIfOutsideViewport(new monaco.Range(lineStart, columnStart, lineEnd, columnEnd), 1);
}, 50);
}
showLine(line, column, lineEnd, columnEnd) {
this._editor.setSelection({ startLineNumber: line, startColumn: column, endLineNumber: lineEnd, endColumn: columnEnd });
//@ts-ignore
this._editor.revealRangeAtTop(new monaco.Range(line, column, lineEnd, columnEnd), 1);
}
}
customElements.define('iobroker-webui-monaco-editor', IobrokerWebuiMonacoEditor);
3 changes: 2 additions & 1 deletion www/dist/frontend/generated/Properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"definitions": {
"BindingTarget": {
"enum": [
"explicitProperty",
"property",
"attribute",
"class",
Expand Down Expand Up @@ -37,7 +38,7 @@
"arguments",
"caller",
"name",
"__@hasInstance@5377"
"__@hasInstance@5421"
],
"type": "object"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BaseCustomControl, webuiCustomControlSymbol } from '../runtime/CustomCo
import { iobrokerHandler } from '../common/IobrokerHandler.js';
export class IobrokerWebuiCustomElementContextMenu {
shouldProvideContextmenu(event, designerView, designItem, initiator) {
return !designItem.isRootItem && designItem.element instanceof BaseCustomControl;
return designItem && !designItem.isRootItem && designItem.element instanceof BaseCustomControl;
}
provideContextMenuItems(event, designerView, designItem) {
return [
Expand Down
19 changes: 19 additions & 0 deletions www/dist/frontend/services/IobrokerWebuiScreenContextMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { iobrokerHandler } from '../common/IobrokerHandler.js';
import { ScreenViewer } from '../runtime/ScreenViewer.js';
export class IobrokerWebuiScreenContextMenu {
shouldProvideContextmenu(event, designerView, designItem, initiator) {
return designItem && !designItem.isRootItem && designItem.element instanceof ScreenViewer;
}
provideContextMenuItems(event, designerView, designItem) {
return [
{
title: 'edit screen', action: () => {
let nm = designItem.element.screenName;
iobrokerHandler.getWebuiObject('screen', nm).then(s => {
window.appShell.openScreenEditor(nm, 'screen', s.html, s.style, s.script, s.settings, null);
});
}, shortCut: 'Ctrl + E'
},
];
}
}

0 comments on commit 207bc09

Please sign in to comment.