diff --git a/bundles/org.openhab.ui/web/src/components/app.vue b/bundles/org.openhab.ui/web/src/components/app.vue index f5e6f38dda..05e6af11af 100644 --- a/bundles/org.openhab.ui/web/src/components/app.vue +++ b/bundles/org.openhab.ui/web/src/components/app.vue @@ -600,6 +600,7 @@ export default { this.visibleBreakpointDisabled = true this.$nextTick(() => this.$f7.panel.get('left').disableVisibleBreakpoint()) } + this.themeOptions.blocklyRenderer = localStorage.getItem('openhab.ui:blockly.renderer') }, toggleDeveloperDock () { if (!this.$store.getters.isAdmin) return diff --git a/bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue b/bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue index 813d7cffaa..28afe9ac7b 100644 --- a/bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue +++ b/bundles/org.openhab.ui/web/src/components/config/controls/blockly-editor.vue @@ -1127,6 +1127,7 @@ export default { }, mounted () { this.load() + this.$emit('mounted') }, methods: { load () { @@ -1201,7 +1202,8 @@ export default { pinch: true }, trashcan: false, - showLabels: false + showLabels: false, + renderer: this.getCurrentRenderer() }) this.workspace.addChangeListener(shadowBlockConversionChangeListener) const workspaceSearch = new WorkspaceSearch(this.workspace) @@ -1268,6 +1270,27 @@ export default { getCode () { return javascriptGenerator.workspaceToCode(this.workspace) }, + getRenderers () { + const excludedRenderers = ['minimalist'] + const renderers = Object.keys(Blockly.registry.getAllItems('renderer')) + .filter(r => !excludedRenderers.includes(r)) + .sort() + return renderers + }, + getCurrentRenderer () { + return this.$f7.data.themeOptions.blocklyRenderer + }, + changeRenderer (newRenderer) { + this.$f7.data.themeOptions.blocklyRenderer = newRenderer + localStorage.setItem('openhab.ui:blockly.renderer', newRenderer) + + const dom = Blockly.Xml.workspaceToDom(this.workspace) + this.workspace.dispose() + this.initBlockly(this.blockLibraries) + this.workspace.clear() + Blockly.Xml.domToWorkspace(dom, this.workspace) + this.workspace.refreshToolboxSelection() + }, onChange (event) { if (event.type === Blockly.Events.FINISHED_LOADING) { this.loading = false diff --git a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue index ee988bbc13..430c8e3808 100644 --- a/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue +++ b/bundles/org.openhab.ui/web/src/pages/settings/rules/script/script-edit.vue @@ -30,6 +30,11 @@ :tooltip="rule.status.description" /> + + + @@ -42,7 +47,7 @@ - + @@ -166,7 +171,9 @@ export default { keyHandler: null, detailsOpened: false, blocklyCodePreview: false, - blocklyShowLabels: false + blocklyShowLabels: false, + blocklyRenderer: 'default', + blocklyRenderers: [] } }, computed: { @@ -530,6 +537,14 @@ export default { } ) }, + onBlocklyMounted () { + this.blocklyRenderer = this.$refs.blocklyEditor.getCurrentRenderer() + this.blocklyRenderers = this.$refs.blocklyEditor.getRenderers() + }, + setBlocklyRenderer (event) { + this.blocklyRenderer = event.target.value + this.$refs.blocklyEditor.changeRenderer(this.blocklyRenderer) + }, toggleBlocklyItemLabelId () { this.blocklyShowLabels = !this.blocklyShowLabels this.$refs.blocklyEditor.showHideLabels(this.blocklyShowLabels)