Skip to content

Generate blockly code when workspace is first displayed #35

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions python-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,17 +503,18 @@ function web_editor(config) {
editor.ACE.setReadOnly(true);
$("#command-snippet").off('click');
$("#command-snippet").click(function () {
alert(config.translate.alerts.snippets);
alert(config.translate.alerts.snippets);
});
blockly.show();
blockly.css('width', '33%');
blockly.css('height', '100%');
if(blockly.find('div.injectionDiv').length === 0) {
var workspace = null;
if (blockly.find('div.injectionDiv').length === 0) {
// Calculate initial zoom level
var zoomScaleSteps = 0.2;
var fontSteps = (getFontSize() - EDITOR.initialFontSize) / EDITOR.fontSizeStep;
var zoomLevel = (fontSteps * zoomScaleSteps) + 1.0;
var workspace = Blockly.inject('blockly', {
workspace = Blockly.inject('blockly', {
toolbox: document.getElementById('blockly-toolbox'),
zoom: {
controls: false,
Expand All @@ -528,6 +529,11 @@ function web_editor(config) {
}
workspace.addChangeListener(myUpdateFunction);
}
// When blocks are displayed ensure code is generated by firing the change listener
workspace = workspace || Blockly.getMainWorkspace();
if (workspace) {
workspace.fireChangeListener({});
}
};
}

Expand Down