Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[blockly] Add multi-select feature #2419

Merged
merged 4 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
51 changes: 33 additions & 18 deletions bundles/org.openhab.ui/web/package-lock.json

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

2 changes: 1 addition & 1 deletion bundles/org.openhab.ui/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@
],
"dependencies": {
"@blockly/field-slider": "^6.1.4",
"@blockly/plugin-cross-tab-copy-paste": "^5.0.5",
"@blockly/plugin-workspace-search": "^8.1.2",
"@blockly/shadow-block-converter": "^5.0.0",
"@blockly/theme-dark": "^6.0.5",
"@blockly/zoom-to-fit": "^5.0.11",
"@mit-app-inventor/blockly-plugin-workspace-multiselect": "^0.1.12",
"@jsep-plugin/arrow": "^1.0.5",
"@jsep-plugin/object": "^1.2.1",
"@jsep-plugin/regex": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,9 +1077,9 @@ import Blockly from 'blockly'
import { WorkspaceSearch } from '@blockly/plugin-workspace-search'
import { javascriptGenerator } from 'blockly/javascript.js'
import DarkTheme from '@blockly/theme-dark'
import { CrossTabCopyPaste } from '@blockly/plugin-cross-tab-copy-paste'
import { ZoomToFitControl } from '@blockly/zoom-to-fit'
import { shadowBlockConversionChangeListener } from '@blockly/shadow-block-converter'
import { Multiselect, MultiselectBlockDragger } from '@mit-app-inventor/blockly-plugin-workspace-multiselect'

import Vue from 'vue'

Expand Down Expand Up @@ -1187,24 +1187,42 @@ export default {
}, this.isGraalJs)
this.addLibraryToToolbox(libraryDefinitions || [])

this.workspace = Blockly.inject(this.$refs.blocklyEditor, {
const options = {
toolbox: this.$refs.toolbox,
plugins: {
'blockDragger': MultiselectBlockDragger
},
horizontalLayout: !this.$device.desktop,
theme: this.$f7.data.themeOptions.dark === 'dark' ? DarkTheme : undefined,
zoom:
{
controls: true,
wheel: true,
startScale: 1.0,
maxScale: 3,
minScale: 0.3,
scaleSpeed: 1.2,
pinch: true
},
zoom: {
controls: true,
wheel: true,
startScale: 1.0,
maxScale: 3,
minScale: 0.3,
scaleSpeed: 1.2,
pinch: true
},
move: {
drag: true,
wheel: true
},
trashcan: false,
showLabels: false,

// Multi-select-options
multiselectCopyPaste: {
crossTab: true,
menu: true
},
multiselectIcon: {
hideIcon: true // hide it because it doesn't work in v0.1.11
},
multiFieldUpdate: true,

renderer: this.getCurrentRenderer()
})
}
this.workspace = Blockly.inject(this.$refs.blocklyEditor, options)
this.workspace.addChangeListener(shadowBlockConversionChangeListener)
const workspaceSearch = new WorkspaceSearch(this.workspace)
workspaceSearch.init()
Expand All @@ -1215,19 +1233,8 @@ export default {
const zoomToFit = new ZoomToFitControl(this.workspace)
zoomToFit.init()

if (!Blockly.ContextMenuRegistry.registry.getItem('blockCopyToStorage')) {
const copyAndPasteOptions = {
contextMenu: true,
shortcut: true
}
const copyAndPastePlugin = new CrossTabCopyPaste()
copyAndPastePlugin.init(copyAndPasteOptions, () => {
console.log('There has been a block type error during copying and pasting')
})

Blockly.Msg['CROSS_TAB_COPY'] = 'Cross-Rule-Copy'
Blockly.Msg['CROSS_TAB_PASTE'] = 'Cross-Rule-Paste'
}
const multiselectPlugin = new Multiselect(this.workspace)
multiselectPlugin.init(options)

this.registerLibraryCallbacks(libraryDefinitions)
const xml = Blockly.utils.xml.textToDom(this.blocks)
Expand Down