I recently discovered this awesome plugin:
https://github.com/google/blockly-samples/tree/master/plugins/cross-tab-copy-paste
and I immediately jumped on it and integrated it into our application (openHAB).
However, there is a bit of an issue: it turns out that this plugin must be loaded ONLY ONCE. Even when recreating a new workspace it must not be loaded again, otherwise it throws an exception complaining that it already exists.
While for example the Zoom-Control-Plugin links to the workspace like so
const zoomToFit = new ZoomToFitControl(this.workspace)
zoomToFit.init()
it seems that I have to use a GLOBAL variable make sure that the plugin is not yet loaded like so
if (!copyPastePluginInitialized) {
const copyAndPasteOptions = { ... }
const copyAndPastePlugin = new CrossTabCopyPaste()
copyAndPastePlugin.init(copyAndPasteOptions, () => {
console.log('There has been a block type error during copying and pasting')
})
copyPastePluginInitialized = true
}
but even then sometimes it seems that this doesn't really prevent it.
I wonder if there is a better of doing it to make it fail-save or why the plugin was created that way?
TIA
Stefan
PS: As a sidenote, I upgraded from 6.x to 9.2 and the migration was amazingly smooth! Well done, team!