scratch-blocks/core/block.js

1838 lines
56 KiB
JavaScript
Raw Normal View History

/**
* @license
* Visual Blocks Editor
*
* Copyright 2011 Google Inc.
2014-10-07 13:09:55 -07:00
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview The class representing one block.
* @author fraser@google.com (Neil Fraser)
*/
'use strict';
goog.provide('Blockly.Block');
goog.require('Blockly.Blocks');
goog.require('Blockly.Colours');
goog.require('Blockly.Comment');
2018-05-25 17:44:09 -04:00
goog.require('Blockly.ScratchBlockComment');
goog.require('Blockly.Connection');
2018-05-09 13:34:21 -07:00
goog.require('Blockly.Events.BlockChange');
goog.require('Blockly.Events.BlockCreate');
goog.require('Blockly.Events.BlockDelete');
goog.require('Blockly.Events.BlockMove');
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
goog.require('Blockly.Extensions');
goog.require('Blockly.FieldLabelSerializable');
2017-02-22 13:49:39 -08:00
goog.require('Blockly.FieldVariableGetter');
goog.require('Blockly.Input');
goog.require('Blockly.Mutator');
goog.require('Blockly.Warning');
goog.require('Blockly.Workspace');
goog.require('Blockly.Xml');
goog.require('goog.array');
goog.require('goog.asserts');
2014-12-23 11:22:02 -08:00
goog.require('goog.math.Coordinate');
goog.require('goog.string');
/**
* Class for one block.
* Not normally called directly, workspace.newBlock() is preferred.
* @param {!Blockly.Workspace} workspace The block's workspace.
* @param {?string} prototypeName Name of the language object containing
* type-specific functions for this block.
* @param {string=} opt_id Optional ID. Use this ID if provided, otherwise
2018-05-15 17:09:08 -07:00
* create a new ID. If the ID conflicts with an in-use ID, a new one will
* be generated.
* @constructor
*/
2015-12-09 10:02:42 +01:00
Blockly.Block = function(workspace, prototypeName, opt_id) {
var flyoutWorkspace = workspace && workspace.getFlyout && workspace.getFlyout() ?
workspace.getFlyout().getWorkspace() : null;
2015-09-22 13:27:32 -05:00
/** @type {string} */
this.id = (opt_id && !workspace.getBlockById(opt_id) &&
(!flyoutWorkspace || !flyoutWorkspace.getBlockById(opt_id))) ?
opt_id : Blockly.utils.genUid();
2016-04-05 18:43:39 -07:00
workspace.blockDB_[this.id] = this;
2015-07-13 15:03:22 -07:00
/** @type {Blockly.Connection} */
this.outputConnection = null;
2015-07-13 15:03:22 -07:00
/** @type {Blockly.Connection} */
this.nextConnection = null;
2015-07-13 15:03:22 -07:00
/** @type {Blockly.Connection} */
this.previousConnection = null;
2015-07-13 15:03:22 -07:00
/** @type {!Array.<!Blockly.Input>} */
this.inputList = [];
2015-07-13 15:03:22 -07:00
/** @type {boolean|undefined} */
2016-01-27 14:12:37 -05:00
this.inputsInline = true;
/** @type {boolean} */
this.disabled = false;
2015-07-13 15:03:22 -07:00
/** @type {string|!Function} */
this.tooltip = '';
/** @type {boolean} */
this.contextMenu = true;
2016-05-04 15:05:45 -07:00
/**
* @type {Blockly.Block}
* @protected
2016-05-04 15:05:45 -07:00
*/
this.parentBlock_ = null;
2016-05-04 15:05:45 -07:00
/**
* @type {!Array.<!Blockly.Block>}
* @protected
2016-05-04 15:05:45 -07:00
*/
this.childBlocks_ = [];
2016-05-04 15:05:45 -07:00
/**
* @type {boolean}
2016-05-04 15:05:45 -07:00
* @private
*/
this.deletable_ = true;
2016-05-04 15:05:45 -07:00
/**
* @type {boolean}
* @private
*/
this.movable_ = true;
2016-05-04 15:05:45 -07:00
/**
* @type {boolean}
* @private
*/
this.editable_ = true;
2016-05-04 15:05:45 -07:00
/**
* @type {boolean}
* @private
*/
2015-10-06 18:09:27 -07:00
this.isShadow_ = false;
2016-05-04 15:05:45 -07:00
/**
* @type {boolean}
* @protected
2016-05-04 15:05:45 -07:00
*/
this.collapsed_ = false;
/**
* @type {boolean}
* @private
*/
this.checkboxInFlyout_ = false;
2015-07-13 15:03:22 -07:00
/** @type {string|Blockly.Comment} */
2014-12-23 11:22:02 -08:00
this.comment = null;
/**
* @type {?number}
* @private
*/
this.outputShape_ = null;
/**
* @type {?string}
* @private
*/
this.category_ = null;
2016-05-04 15:05:45 -07:00
/**
* The block's position in workspace units. (0, 0) is at the workspace's
* origin; scale does not change this value.
2016-05-04 15:05:45 -07:00
* @type {!goog.math.Coordinate}
* @private
*/
2014-12-23 11:22:02 -08:00
this.xy_ = new goog.math.Coordinate(0, 0);
2015-07-13 15:03:22 -07:00
/** @type {!Blockly.Workspace} */
this.workspace = workspace;
/** @type {boolean} */
this.isInFlyout = workspace.isFlyout;
/** @type {boolean} */
this.isInMutator = workspace.isMutator;
/** @type {boolean} */
2015-04-28 13:51:25 -07:00
this.RTL = workspace.RTL;
2016-02-23 14:46:04 -08:00
/** @type {boolean} */
2016-04-06 14:42:12 -07:00
this.isInsertionMarker_ = false;
2016-02-23 14:46:04 -08:00
// Copy the type-specific functions and data from the prototype.
if (prototypeName) {
2015-07-13 15:03:22 -07:00
/** @type {string} */
this.type = prototypeName;
var prototype = Blockly.Blocks[prototypeName];
goog.asserts.assertObject(prototype,
'Error: Unknown block type "%s".', prototypeName);
goog.mixin(this, prototype);
}
workspace.addTopBlock(this);
// Call an initialization function, if it exists.
if (goog.isFunction(this.init)) {
this.init();
}
// Record initial inline state.
2015-07-13 15:03:22 -07:00
/** @type {boolean|undefined} */
this.inputsInlineDefault = this.inputsInline;
// Fire a create event.
2016-02-26 00:22:31 -08:00
if (Blockly.Events.isEnabled()) {
var existingGroup = Blockly.Events.getGroup();
if (!existingGroup) {
Blockly.Events.setGroup(true);
}
try {
Blockly.Events.fire(new Blockly.Events.BlockCreate(this));
} finally {
if (!existingGroup) {
Blockly.Events.setGroup(false);
}
}
}
// Bind an onchange function, if it exists.
if (goog.isFunction(this.onchange)) {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
this.setOnChange(this.onchange);
}
};
/**
* Optional text data that round-trips beween blocks and XML.
* Has no effect. May be used by 3rd parties for meta information.
* @type {?string}
*/
Blockly.Block.prototype.data = null;
2015-12-13 19:13:05 +01:00
/**
* Colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
2016-07-14 12:16:23 -03:00
Blockly.Block.prototype.colour_ = '#FF0000';
2015-12-13 19:13:05 +01:00
/**
* Secondary colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
2016-07-14 12:16:23 -03:00
Blockly.Block.prototype.colourSecondary_ = '#FF0000';
/**
* Tertiary colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
2016-07-14 12:16:23 -03:00
Blockly.Block.prototype.colourTertiary_ = '#FF0000';
/**
* Quaternary colour of the block in '#RRGGBB' format.
* @type {string}
* @private
*/
Blockly.Block.prototype.colourQuaternary = '#FF0000';
2018-10-23 13:55:28 -07:00
/**
* Fill colour used to override default shadow colour behaviour.
* @type {string}
* @private
*/
Blockly.Block.prototype.shadowColour_ = null;
/**
* Dispose of this block.
* @param {boolean} healStack If true, then try to heal any gap by connecting
* the next statement with the previous statement. Otherwise, dispose of
* all children of this block.
*/
2016-02-01 16:13:05 -08:00
Blockly.Block.prototype.dispose = function(healStack) {
if (!this.workspace) {
// Already deleted.
return;
}
// Terminate onchange event calls.
if (this.onchangeWrapper_) {
2016-03-18 15:19:26 -07:00
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
2016-02-01 16:13:05 -08:00
this.unplug(healStack);
2016-02-26 00:22:31 -08:00
if (Blockly.Events.isEnabled()) {
2017-06-22 10:38:20 -04:00
Blockly.Events.fire(new Blockly.Events.BlockDelete(this));
}
Blockly.Events.disable();
try {
// This block is now at the top of the workspace.
// Remove this block from the workspace's list of top-most blocks.
if (this.workspace) {
this.workspace.removeTopBlock(this);
// Remove from block database.
delete this.workspace.blockDB_[this.id];
this.workspace = null;
}
// Just deleting this block from the DOM would result in a memory leak as
// well as corruption of the connection database. Therefore we must
// methodically step through the blocks and carefully disassemble them.
if (Blockly.selected == this) {
Blockly.selected = null;
}
2014-09-08 14:26:52 -07:00
// First, dispose of all my children.
for (var i = this.childBlocks_.length - 1; i >= 0; i--) {
this.childBlocks_[i].dispose(false);
}
// Then dispose of myself.
// Dispose of all inputs and their fields.
for (var i = 0, input; input = this.inputList[i]; i++) {
input.dispose();
}
this.inputList.length = 0;
// Dispose of any remaining connections (next/previous/output).
var connections = this.getConnections_(true);
for (var i = 0; i < connections.length; i++) {
var connection = connections[i];
if (connection.isConnected()) {
connection.disconnect();
}
connections[i].dispose();
}
} finally {
Blockly.Events.enable();
}
};
/**
* Call initModel on all fields on the block.
* May be called more than once.
* Either initModel or initSvg must be called after creating a block and before
* the first interaction with it. Interactions include UI actions
* (e.g. clicking and dragging) and firing events (e.g. create, delete, and
* change).
* @public
*/
Blockly.Block.prototype.initModel = function() {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field.initModel) {
field.initModel();
}
}
}
};
/**
* Unplug this block from its superior block. If this block is a statement,
* optionally reconnect the block underneath with the block on top.
* @param {boolean=} opt_healStack Disconnect child statement and reconnect
* stack. Defaults to false.
*/
Blockly.Block.prototype.unplug = function(opt_healStack) {
if (this.outputConnection) {
2016-03-30 15:09:42 -07:00
if (this.outputConnection.isConnected()) {
// Disconnect from any superior block.
this.outputConnection.disconnect();
}
} else {
if (this.previousConnection) {
var previousTarget = null;
if (this.previousConnection.isConnected()) {
// Remember the connection that any next statements need to connect to.
previousTarget = this.previousConnection.targetConnection;
// Detach this block from the parent's tree.
this.previousConnection.disconnect();
}
}
2014-09-08 14:26:52 -07:00
var nextBlock = this.getNextBlock();
if (opt_healStack && nextBlock) {
// Disconnect the next statement.
var nextTarget = this.nextConnection.targetConnection;
nextTarget.disconnect();
if (previousTarget && previousTarget.checkType_(nextTarget)) {
// Attach the next statement to the previous statement.
previousTarget.connect(nextTarget);
}
}
}
};
/**
* Returns all connections originating from this block.
* @return {!Array.<!Blockly.Connection>} Array of connections.
* @private
*/
Blockly.Block.prototype.getConnections_ = function() {
var myConnections = [];
if (this.outputConnection) {
myConnections.push(this.outputConnection);
}
if (this.previousConnection) {
myConnections.push(this.previousConnection);
}
if (this.nextConnection) {
myConnections.push(this.nextConnection);
}
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection) {
myConnections.push(input.connection);
}
}
return myConnections;
};
/**
* Walks down a stack of blocks and finds the last next connection on the stack.
* @return {Blockly.Connection} The last next connection on the stack, or null.
* @package
*/
Blockly.Block.prototype.lastConnectionInStack = function() {
var nextConnection = this.nextConnection;
while (nextConnection) {
var nextBlock = nextConnection.targetBlock();
if (!nextBlock) {
// Found a next connection with nothing on the other side.
return nextConnection;
}
nextConnection = nextBlock.nextConnection;
}
// Ran out of next connections.
return null;
};
/**
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
* connected should not coincidentally line up on screen.
* @protected
*/
Blockly.Block.prototype.bumpNeighbours_ = function() {
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
console.warn('Not expected to reach this bumpNeighbours_ function. The ' +
'BlockSvg function for bumpNeighbours_ was expected to be called instead.');
};
/**
* Return the parent block or null if this block is at the top level.
* @return {Blockly.Block} The block that holds the current block.
*/
Blockly.Block.prototype.getParent = function() {
// Look at the DOM to see if we are nested in another block.
return this.parentBlock_;
};
/**
* Return the input that connects to the specified block.
2016-02-16 13:04:47 -08:00
* @param {!Blockly.Block} block A block connected to an input on this block.
* @return {Blockly.Input} The input that connects to the specified block.
*/
Blockly.Block.prototype.getInputWithBlock = function(block) {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection && input.connection.targetBlock() == block) {
2016-03-18 15:19:26 -07:00
return input;
}
}
return null;
};
/**
* Return the input that contains the specified connection
* @param {!Blockly.Connection} conn A connection on this block.
* @return {Blockly.Input} The input that contains the specified connection.
*/
Blockly.Block.prototype.getInputWithConnection = function(conn) {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection == conn) {
return input;
}
}
return null;
};
/**
* Return the parent block that surrounds the current block, or null if this
* block has no surrounding block. A parent block might just be the previous
* statement, whereas the surrounding block is an if statement, while loop, etc.
* @return {Blockly.Block} The block that surrounds the current block.
*/
Blockly.Block.prototype.getSurroundParent = function() {
var block = this;
2016-01-15 15:36:06 -08:00
do {
var prevBlock = block;
block = block.getParent();
if (!block) {
// Ran off the top.
return null;
}
} while (block.getNextBlock() == prevBlock);
// This block is an enclosing parent, not just a statement in a stack.
return block;
};
2014-09-08 14:26:52 -07:00
/**
* Return the next statement block directly connected to this block.
* @return {Blockly.Block} The next statement block or null.
*/
Blockly.Block.prototype.getNextBlock = function() {
return this.nextConnection && this.nextConnection.targetBlock();
};
2017-06-07 13:43:11 -07:00
/**
* Return the previous statement block directly connected to this block.
* @return {Blockly.Block} The previous statement block or null.
*/
Blockly.Block.prototype.getPreviousBlock = function() {
return this.previousConnection && this.previousConnection.targetBlock();
};
2016-03-14 17:10:15 -07:00
/**
* Return the connection on the first statement input on this block, or null if
* there are none.
* @return {Blockly.Connection} The first statement connection or null.
*/
Blockly.Block.prototype.getFirstStatementConnection = function() {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection && input.connection.type == Blockly.NEXT_STATEMENT) {
return input.connection;
}
}
return null;
};
/**
* Return the top-most block in this block's tree.
* This will return itself if this block is at the top level.
* @return {!Blockly.Block} The root block.
*/
Blockly.Block.prototype.getRootBlock = function() {
var rootBlock;
var block = this;
do {
rootBlock = block;
block = rootBlock.parentBlock_;
} while (block);
return rootBlock;
};
/**
* Find all the blocks that are directly nested inside this one.
* Includes value and statement inputs, as well as any following statement.
* Excludes any connection on an output tab or any preceding statement.
* Blocks are optionally sorted by position; top to bottom.
* @param {boolean} ordered Sort the list if true.
* @return {!Array.<!Blockly.Block>} Array of blocks.
*/
Blockly.Block.prototype.getChildren = function(ordered) {
if (!ordered) {
return this.childBlocks_;
}
var blocks = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection) {
var child = input.connection.targetBlock();
if (child) {
blocks.push(child);
}
}
}
var next = this.getNextBlock();
if (next) {
blocks.push(next);
}
return blocks;
};
/**
* Set parent of this block to be a new block or null.
* @param {Blockly.Block} newParent New parent block.
*/
Blockly.Block.prototype.setParent = function(newParent) {
if (newParent == this.parentBlock_) {
return;
2016-02-02 00:28:49 -08:00
}
if (this.parentBlock_) {
// Remove this block from the old parent's child list.
goog.array.remove(this.parentBlock_.childBlocks_, this);
// Disconnect from superior blocks.
2016-03-30 15:09:42 -07:00
if (this.previousConnection && this.previousConnection.isConnected()) {
throw 'Still connected to previous block.';
}
2016-03-30 15:09:42 -07:00
if (this.outputConnection && this.outputConnection.isConnected()) {
throw 'Still connected to parent block.';
}
this.parentBlock_ = null;
// This block hasn't actually moved on-screen, so there's no need to update
// its connection locations.
} else {
// Remove this block from the workspace's list of top-most blocks.
2016-02-02 00:28:49 -08:00
this.workspace.removeTopBlock(this);
}
this.parentBlock_ = newParent;
if (newParent) {
// Add this block to the new parent's child list.
newParent.childBlocks_.push(this);
} else {
this.workspace.addTopBlock(this);
}
};
/**
* Find all the blocks that are directly or indirectly nested inside this one.
* Includes this block in the list.
* Includes value and statement inputs, as well as any following statements.
* Excludes any connection on an output tab or any preceding statements.
* Blocks are optionally sorted by position, top to bottom.
* @param {boolean} ordered Sort the list if true.
* @param {boolean=} opt_ignoreShadows If set, don't include shadow blocks.
* @return {!Array.<!Blockly.Block>} Flattened array of blocks.
*/
Blockly.Block.prototype.getDescendants = function(ordered, opt_ignoreShadows) {
var blocks = [this];
var childBlocks = this.getChildren(ordered);
for (var child, i = 0; child = childBlocks[i]; i++) {
if (!opt_ignoreShadows || !child.isShadow_) {
blocks.push.apply(
blocks, child.getDescendants(ordered, opt_ignoreShadows));
}
}
return blocks;
};
/**
* Get whether this block is deletable or not.
* @return {boolean} True if deletable.
*/
Blockly.Block.prototype.isDeletable = function() {
return this.deletable_ && !this.isShadow_ &&
2015-04-28 13:51:25 -07:00
!(this.workspace && this.workspace.options.readOnly);
};
/**
* Set whether this block is deletable or not.
* @param {boolean} deletable True if deletable.
*/
Blockly.Block.prototype.setDeletable = function(deletable) {
this.deletable_ = deletable;
};
/**
* Get whether this block is movable or not.
* @return {boolean} True if movable.
*/
Blockly.Block.prototype.isMovable = function() {
2015-10-06 18:09:27 -07:00
return this.movable_ && !this.isShadow_ &&
!(this.workspace && this.workspace.options.readOnly);
};
/**
* Set whether this block is movable or not.
* @param {boolean} movable True if movable.
*/
Blockly.Block.prototype.setMovable = function(movable) {
this.movable_ = movable;
};
2015-10-06 18:09:27 -07:00
/**
* Get whether this block is a shadow block or not.
* @return {boolean} True if a shadow.
*/
Blockly.Block.prototype.isShadow = function() {
return this.isShadow_;
};
/**
* Set whether this block is a shadow block or not.
* @param {boolean} shadow True if a shadow.
*/
Blockly.Block.prototype.setShadow = function(shadow) {
this.isShadow_ = shadow;
};
2016-02-23 14:46:04 -08:00
/**
2016-04-06 14:42:12 -07:00
* Get whether this block is an insertion marker block or not.
* @return {boolean} True if an insertion marker.
2016-02-23 14:46:04 -08:00
*/
2016-04-06 14:42:12 -07:00
Blockly.Block.prototype.isInsertionMarker = function() {
return this.isInsertionMarker_;
2016-02-23 14:46:04 -08:00
};
/**
2016-04-06 14:42:12 -07:00
* Set whether this block is an insertion marker block or not.
* @param {boolean} insertionMarker True if an insertion marker.
2016-02-23 14:46:04 -08:00
*/
2016-04-06 14:42:12 -07:00
Blockly.Block.prototype.setInsertionMarker = function(insertionMarker) {
if (this.isInsertionMarker_ == insertionMarker) {
2016-02-23 14:46:04 -08:00
return; // No change.
}
2016-04-06 14:42:12 -07:00
this.isInsertionMarker_ = insertionMarker;
// TODO: handle removing insertion marker status.
2016-04-06 14:42:12 -07:00
if (this.isInsertionMarker_) {
this.setColour(Blockly.Colours.insertionMarker);
this.setOpacity(Blockly.Colours.insertionMarkerOpacity);
Blockly.utils.addClass(/** @type {!Element} */ (this.svgGroup_),
'blocklyInsertionMarker');
2016-02-23 14:46:04 -08:00
}
};
/**
* Get whether this block is editable or not.
* @return {boolean} True if editable.
*/
Blockly.Block.prototype.isEditable = function() {
2015-04-28 13:51:25 -07:00
return this.editable_ && !(this.workspace && this.workspace.options.readOnly);
};
/**
* Set whether this block is editable or not.
* @param {boolean} editable True if editable.
*/
Blockly.Block.prototype.setEditable = function(editable) {
this.editable_ = editable;
2015-01-01 14:30:37 -08:00
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
2013-12-20 16:25:26 -08:00
field.updateEditable();
}
}
};
2015-01-26 04:56:58 -08:00
/**
* Set whether the connections are hidden (not tracked in a database) or not.
* Recursively walk down all child blocks (except collapsed blocks).
2015-01-26 04:56:58 -08:00
* @param {boolean} hidden True if connections are hidden.
*/
Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
if (!hidden && this.isCollapsed()) {
if (this.outputConnection) {
this.outputConnection.setHidden(hidden);
}
if (this.previousConnection) {
this.previousConnection.setHidden(hidden);
}
if (this.nextConnection) {
this.nextConnection.setHidden(hidden);
var child = this.nextConnection.targetBlock();
if (child) {
child.setConnectionsHidden(hidden);
}
}
} else {
var myConnections = this.getConnections_(true);
for (var i = 0, connection; connection = myConnections[i]; i++) {
connection.setHidden(hidden);
if (connection.isSuperior()) {
var child = connection.targetBlock();
if (child) {
child.setConnectionsHidden(hidden);
}
}
}
2015-01-26 04:56:58 -08:00
}
};
2016-03-04 14:39:24 -08:00
/**
* Find the connection on this block that corresponds to the given connection
* on the other block.
2016-04-06 14:42:12 -07:00
* Used to match connections between a block and its insertion marker.
2016-03-04 14:39:24 -08:00
* @param {!Blockly.Block} otherBlock The other block to match against.
* @param {!Blockly.Connection} conn The other connection to match.
* @return {Blockly.Connection} the matching connection on this block, or null.
*/
Blockly.Block.prototype.getMatchingConnection = function(otherBlock, conn) {
var connections = this.getConnections_(true);
var otherConnections = otherBlock.getConnections_(true);
if (connections.length != otherConnections.length) {
throw "Connection lists did not match in length.";
}
for (var i = 0; i < otherConnections.length; i++) {
if (otherConnections[i] == conn) {
return connections[i];
}
}
return null;
};
/**
* Set the URL of this block's help page.
* @param {string|Function} url URL string for block help, or function that
* returns a URL. Null for no help.
*/
Blockly.Block.prototype.setHelpUrl = function(url) {
this.helpUrl = url;
};
/**
* Change the tooltip text for a block.
* @param {string|!Function} newTip Text for tooltip or a parent element to
* link to for its tooltip. May be a function that returns a string.
*/
Blockly.Block.prototype.setTooltip = function(newTip) {
this.tooltip = newTip;
};
/**
* Get the colour of a block.
2015-12-13 19:13:05 +01:00
* @return {string} #RRGGBB string.
*/
Blockly.Block.prototype.getColour = function() {
2015-12-13 19:13:05 +01:00
return this.colour_;
};
/**
* Get the secondary colour of a block.
* @return {string} #RRGGBB string.
*/
Blockly.Block.prototype.getColourSecondary = function() {
return this.colourSecondary_;
};
/**
* Get the tertiary colour of a block.
* @return {string} #RRGGBB string.
*/
Blockly.Block.prototype.getColourTertiary = function() {
return this.colourTertiary_;
};
/**
* Get the quaternary colour of a block.
* @return {string} #RRGGBB string.
*/
Blockly.Block.prototype.getColourQuaternary = function() {
return this.colourQuaternary_;
};
2018-10-23 13:55:28 -07:00
/**
* Get the shadow colour of a block.
* @return {string} #RRGGBB string.
*/
Blockly.Block.prototype.getShadowColour = function() {
return this.shadowColour_;
};
/**
* Set the shadow colour of a block.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
*/
Blockly.Block.prototype.setShadowColour = function(colour) {
this.shadowColour_ = this.makeColour_(colour);
if (this.rendered) {
this.updateColour();
}
};
/**
* Clear the shadow colour of a block.
*/
Blockly.Block.prototype.clearShadowColour = function() {
this.shadowColour_ = null;
if (this.rendered) {
this.updateColour();
}
};
/**
* Create an #RRGGBB string colour from a colour HSV hue value or #RRGGBB string.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @return {string} #RRGGBB string.
* @private
*/
Blockly.Block.prototype.makeColour_ = function(colour) {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
var hue = Number(colour);
2015-12-18 19:45:39 -08:00
if (!isNaN(hue)) {
return Blockly.hueToRgb(hue);
2015-12-13 19:13:05 +01:00
} else if (goog.isString(colour) && colour.match(/^#[0-9a-fA-F]{6}$/)) {
return colour;
2015-12-13 19:13:05 +01:00
} else {
throw 'Invalid colour: ' + colour;
}
2016-05-24 14:17:43 -07:00
};
/**
* Change the colour of a block, and optional secondary/teriarty colours.
* @param {number|string} colour HSV hue value, or #RRGGBB string.
* @param {number|string} colourSecondary HSV hue value, or #RRGGBB string.
* @param {number|string} colourTertiary HSV hue value, or #RRGGBB string.
* @param {number|string} colourQuaternary HSV hue value, or #RRGGBB string.
*/
Blockly.Block.prototype.setColour = function(colour, colourSecondary, colourTertiary,
colourQuaternary) {
this.colour_ = this.makeColour_(colour);
if (colourSecondary !== undefined) {
this.colourSecondary_ = this.makeColour_(colourSecondary);
} else {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
this.colourSecondary_ = goog.color.rgbArrayToHex(
2018-05-02 15:32:28 -07:00
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.1));
}
if (colourTertiary !== undefined) {
this.colourTertiary_ = this.makeColour_(colourTertiary);
} else {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
this.colourTertiary_ = goog.color.rgbArrayToHex(
2018-05-02 15:32:28 -07:00
goog.color.darken(goog.color.hexToRgb(this.colour_), 0.2));
}
if (colourQuaternary !== undefined) {
this.colourQuaternary_ = this.makeColour_(colourQuaternary);
} else {
this.colourQuaternary_ = this.colourTertiary_;
}
if (this.rendered) {
2014-12-23 11:22:02 -08:00
this.updateColour();
}
};
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
/**
* Sets a callback function to use whenever the block's parent workspace
* changes, replacing any prior onchange handler. This is usually only called
* from the constructor, the block type initializer function, or an extension
* initializer function.
* @param {function(Blockly.Events.Abstract)} onchangeFn The callback to call
* when the block's workspace changes.
* @throws {Error} if onchangeFn is not falsey or a function.
*/
Blockly.Block.prototype.setOnChange = function(onchangeFn) {
if (onchangeFn && !goog.isFunction(onchangeFn)) {
throw new Error("onchange must be a function.");
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
}
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
this.onchange = onchangeFn;
if (this.onchange) {
this.onchangeWrapper_ = onchangeFn.bind(this);
this.workspace.addChangeListener(this.onchangeWrapper_);
}
};
/**
2013-12-20 16:25:26 -08:00
* Returns the named field from a block.
* @param {string} name The name of the field.
* @return {Blockly.Field} Named field, or null if field does not exist.
*/
2015-07-02 16:14:10 -07:00
Blockly.Block.prototype.getField = function(name) {
2015-01-01 14:30:37 -08:00
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
2013-12-20 16:25:26 -08:00
if (field.name === name) {
return field;
}
}
}
return null;
};
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @package
*/
Blockly.Block.prototype.getVars = function() {
var vars = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field.referencesVariables()) {
vars.push(field.getValue());
}
}
}
return vars;
};
/**
* Return all variables referenced by this block.
* @return {!Array.<!Blockly.VariableModel>} List of variable models.
* @package
*/
Blockly.Block.prototype.getVarModels = function() {
var vars = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field.referencesVariables()) {
var model = this.workspace.getVariableById(field.getValue());
// Check if the variable actually exists (and isn't just a potential
// variable).
if (model) {
vars.push(model);
}
}
}
}
return vars;
};
/**
* Notification that a variable is renaming but keeping the same ID. If the
* variable is in use on this block, rerender to show the new name.
* @param {!Blockly.VariableModel} variable The variable being renamed.
* @package
*/
Blockly.Block.prototype.updateVarName = function(variable) {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field.referencesVariables() &&
variable.getId() == field.getValue()) {
field.setText(variable.name);
}
}
}
};
/**
* Notification that a variable is renaming.
* If the ID matches one of this block's variables, rename it.
* @param {string} oldId ID of variable to rename.
* @param {string} newId ID of new variable. May be the same as oldId, but with
* an updated name.
*/
Blockly.Block.prototype.renameVarById = function(oldId, newId) {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field.referencesVariables() &&
oldId == field.getValue()) {
field.setValue(newId);
}
}
}
};
/**
2013-12-20 16:25:26 -08:00
* Returns the language-neutral value from the field of a block.
* @param {string} name The name of the field.
* @return {?string} Value from the field or null if field does not exist.
*/
2013-12-20 16:25:26 -08:00
Blockly.Block.prototype.getFieldValue = function(name) {
2015-07-02 16:14:10 -07:00
var field = this.getField(name);
2013-12-20 16:25:26 -08:00
if (field) {
return field.getValue();
}
return null;
};
2013-12-20 16:25:26 -08:00
/**
* Change the field value for a block (e.g. 'CHOOSE' or 'REMOVE').
* @param {string} newValue Value to be the new field.
* @param {string} name The name of the field.
*/
Blockly.Block.prototype.setFieldValue = function(newValue, name) {
2015-07-02 16:14:10 -07:00
var field = this.getField(name);
goog.asserts.assertObject(field, 'Field "%s" not found.', name);
2013-12-20 16:25:26 -08:00
field.setValue(newValue);
};
/**
* Set whether this block can chain onto the bottom of another block.
* @param {boolean} newBoolean True if there can be a previous statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
2015-07-13 15:03:22 -07:00
* list of statement types. Null/undefined if any type could be connected.
*/
Blockly.Block.prototype.setPreviousStatement = function(newBoolean, opt_check) {
if (newBoolean) {
if (opt_check === undefined) {
opt_check = null;
}
if (!this.previousConnection) {
goog.asserts.assert(!this.outputConnection,
'Remove output connection prior to adding previous connection.');
2016-05-10 15:39:37 -07:00
this.previousConnection =
this.makeConnection_(Blockly.PREVIOUS_STATEMENT);
}
this.previousConnection.setCheck(opt_check);
} else {
if (this.previousConnection) {
goog.asserts.assert(!this.previousConnection.isConnected(),
'Must disconnect previous statement before removing connection.');
this.previousConnection.dispose();
this.previousConnection = null;
}
}
};
/**
* Set whether another block can chain onto the bottom of this block.
* @param {boolean} newBoolean True if there can be a next statement.
* @param {(string|Array.<string>|null)=} opt_check Statement type or
2015-07-13 15:03:22 -07:00
* list of statement types. Null/undefined if any type could be connected.
*/
Blockly.Block.prototype.setNextStatement = function(newBoolean, opt_check) {
if (newBoolean) {
if (opt_check === undefined) {
opt_check = null;
}
if (!this.nextConnection) {
2016-05-10 15:39:37 -07:00
this.nextConnection = this.makeConnection_(Blockly.NEXT_STATEMENT);
}
this.nextConnection.setCheck(opt_check);
} else {
if (this.nextConnection) {
goog.asserts.assert(!this.nextConnection.isConnected(),
'Must disconnect next statement before removing connection.');
this.nextConnection.dispose();
this.nextConnection = null;
}
}
};
/**
* Set whether this block returns a value.
* @param {boolean} newBoolean True if there is an output.
* @param {(string|Array.<string>|null)=} opt_check Returned type or list
2015-07-13 15:03:22 -07:00
* of returned types. Null or undefined if any type could be returned
* (e.g. variable get).
*/
Blockly.Block.prototype.setOutput = function(newBoolean, opt_check) {
if (newBoolean) {
if (opt_check === undefined) {
opt_check = null;
}
if (!this.outputConnection) {
goog.asserts.assert(!this.previousConnection,
'Remove previous connection prior to adding output connection.');
2016-05-10 15:39:37 -07:00
this.outputConnection = this.makeConnection_(Blockly.OUTPUT_VALUE);
}
this.outputConnection.setCheck(opt_check);
} else {
if (this.outputConnection) {
goog.asserts.assert(!this.outputConnection.isConnected(),
'Must disconnect output value before removing connection.');
this.outputConnection.dispose();
this.outputConnection = null;
}
}
};
/**
* Set whether value inputs are arranged horizontally or vertically.
* @param {boolean} newBoolean True if inputs are horizontal.
*/
Blockly.Block.prototype.setInputsInline = function(newBoolean) {
if (this.inputsInline != newBoolean) {
2017-06-22 10:38:20 -04:00
Blockly.Events.fire(new Blockly.Events.BlockChange(
this, 'inline', null, this.inputsInline, newBoolean));
this.inputsInline = newBoolean;
}
};
/**
* Get whether value inputs are arranged horizontally or vertically.
* @return {boolean} True if inputs are horizontal.
*/
Blockly.Block.prototype.getInputsInline = function() {
if (this.inputsInline != undefined) {
// Set explicitly.
return this.inputsInline;
}
// Not defined explicitly. Figure out what would look best.
for (var i = 1; i < this.inputList.length; i++) {
if (this.inputList[i - 1].type == Blockly.DUMMY_INPUT &&
this.inputList[i].type == Blockly.DUMMY_INPUT) {
// Two dummy inputs in a row. Don't inline them.
return false;
}
}
for (var i = 1; i < this.inputList.length; i++) {
if (this.inputList[i - 1].type == Blockly.INPUT_VALUE &&
this.inputList[i].type == Blockly.DUMMY_INPUT) {
// Dummy input after a value input. Inline them.
return true;
}
}
return false;
};
/**
* Set whether the block is disabled or not.
* @param {boolean} disabled True if disabled.
*/
Blockly.Block.prototype.setDisabled = function(disabled) {
if (this.disabled != disabled) {
2017-06-22 10:38:20 -04:00
Blockly.Events.fire(new Blockly.Events.BlockChange(
this, 'disabled', null, this.disabled, disabled));
this.disabled = disabled;
}
};
/**
* Get whether the block is disabled or not due to parents.
* The block's own disabled property is not considered.
* @return {boolean} True if disabled.
*/
Blockly.Block.prototype.getInheritedDisabled = function() {
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
var ancestor = this.getSurroundParent();
while (ancestor) {
if (ancestor.disabled) {
return true;
}
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
ancestor = ancestor.getSurroundParent();
}
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
// Ran off the top.
return false;
};
/**
* Get whether the block is collapsed or not.
* @return {boolean} True if collapsed.
*/
Blockly.Block.prototype.isCollapsed = function() {
return this.collapsed_;
};
/**
* Set whether the block is collapsed or not.
* @param {boolean} collapsed True if collapsed.
*/
Blockly.Block.prototype.setCollapsed = function(collapsed) {
2016-01-15 15:36:06 -08:00
if (this.collapsed_ != collapsed) {
2017-06-22 10:38:20 -04:00
Blockly.Events.fire(new Blockly.Events.BlockChange(
this, 'collapsed', null, this.collapsed_, collapsed));
2016-01-15 15:36:06 -08:00
this.collapsed_ = collapsed;
}
};
/**
* Create a human-readable text representation of this block and any children.
2015-07-13 15:03:22 -07:00
* @param {number=} opt_maxLength Truncate the string to this length.
* @param {string=} opt_emptyToken The placeholder string used to denote an
* empty field. If not specified, '?' is used.
* @return {string} Text of block.
*/
Blockly.Block.prototype.toString = function(opt_maxLength, opt_emptyToken) {
var text = [];
var emptyFieldPlaceholder = opt_emptyToken || '?';
if (this.collapsed_) {
2015-03-02 12:45:20 -05:00
text.push(this.getInput('_TEMP_COLLAPSED_INPUT').fieldRow[0].text_);
} else {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
if (field instanceof Blockly.FieldDropdown && !field.getValue()) {
text.push(emptyFieldPlaceholder);
} else {
text.push(field.getText());
}
2015-03-02 12:45:20 -05:00
}
if (input.connection) {
var child = input.connection.targetBlock();
if (child) {
text.push(child.toString(undefined, opt_emptyToken));
2015-03-02 12:45:20 -05:00
} else {
text.push(emptyFieldPlaceholder);
2015-03-02 12:45:20 -05:00
}
}
}
}
text = goog.string.trim(text.join(' ')) || '???';
if (opt_maxLength) {
// TODO: Improve truncation so that text from this block is given priority.
// E.g. "1+2+3+4+5+6+7+8+9=0" should be "...6+7+8+9=0", not "1+2+3+4+5...".
// E.g. "1+2+3+4+5=6+7+8+9+0" should be "...4+5=6+7...".
text = goog.string.truncate(text, opt_maxLength);
}
return text;
};
/**
* Shortcut for appending a value input row.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
Blockly.Block.prototype.appendValueInput = function(name) {
return this.appendInput_(Blockly.INPUT_VALUE, name);
};
/**
* Shortcut for appending a statement input row.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
Blockly.Block.prototype.appendStatementInput = function(name) {
return this.appendInput_(Blockly.NEXT_STATEMENT, name);
};
/**
* Shortcut for appending a dummy input row.
2015-07-13 15:03:22 -07:00
* @param {string=} opt_name Language-neutral identifier which may used to find
* this input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
*/
Blockly.Block.prototype.appendDummyInput = function(opt_name) {
return this.appendInput_(Blockly.DUMMY_INPUT, opt_name || '');
};
/**
* Initialize this block using a cross-platform, internationalization-friendly
* JSON description.
* @param {!Object} json Structured data describing the block.
*/
Blockly.Block.prototype.jsonInit = function(json) {
var warningPrefix = json['type'] ? 'Block "' + json['type'] + '": ' : '';
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
// Validate inputs.
goog.asserts.assert(
json['output'] == undefined || json['previousStatement'] == undefined,
warningPrefix + 'Must not have both an output and a previousStatement.');
// Set basic properties of block.
if (json['colour'] !== undefined) {
this.setColourFromJson_(json);
}
// Interpolate the message blocks.
var i = 0;
2015-07-01 22:49:44 -07:00
while (json['message' + i] !== undefined) {
this.interpolate_(json['message' + i], json['args' + i] || [],
json['lastDummyAlign' + i]);
i++;
}
if (json['inputsInline'] !== undefined) {
this.setInputsInline(json['inputsInline']);
}
// Set output and previous/next connections.
if (json['output'] !== undefined) {
this.setOutput(true, json['output']);
}
if (json['previousStatement'] !== undefined) {
this.setPreviousStatement(true, json['previousStatement']);
}
if (json['nextStatement'] !== undefined) {
this.setNextStatement(true, json['nextStatement']);
}
if (json['tooltip'] !== undefined) {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
var rawValue = json['tooltip'];
var localizedText = Blockly.utils.replaceMessageReferences(rawValue);
this.setTooltip(localizedText);
}
if (json['enableContextMenu'] !== undefined) {
var rawValue = json['enableContextMenu'];
this.contextMenu = !!rawValue;
}
if (json['helpUrl'] !== undefined) {
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
var rawValue = json['helpUrl'];
var localizedValue = Blockly.utils.replaceMessageReferences(rawValue);
this.setHelpUrl(localizedValue);
}
if (goog.isString(json['extensions'])) {
console.warn('JSON attribute \'extensions\' should be an array of ' +
'strings. Found raw string in JSON for \'' + json['type'] + '\' block.');
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
json['extensions'] = [json['extensions']]; // Correct and continue.
}
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
// Add the mutator to the block
if (json['mutator'] !== undefined) {
Blockly.Extensions.apply(json['mutator'], this, true);
}
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
if (Array.isArray(json['extensions'])) {
var extensionNames = json['extensions'];
for (var i = 0; i < extensionNames.length; ++i) {
var extensionName = extensionNames[i];
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
Blockly.Extensions.apply(extensionName, this, false);
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
}
}
if (json['outputShape'] !== undefined) {
this.setOutputShape(json['outputShape']);
}
if (json['checkboxInFlyout'] !== undefined) {
this.setCheckboxInFlyout(json['checkboxInFlyout']);
}
if (json['category'] !== undefined) {
this.setCategory(json['category']);
}
};
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
/**
* Add key/values from mixinObj to this block object. By default, this method
* will check that the keys in mixinObj will not overwrite existing values in
* the block, including prototype values. This provides some insurance against
* mixin / extension incompatibilities with future block features. This check
* can be disabled by passing true as the second argument.
* @param {!Object} mixinObj The key/values pairs to add to this block object.
* @param {boolean=} opt_disableCheck Option flag to disable overwrite checks.
*/
Blockly.Block.prototype.mixin = function(mixinObj, opt_disableCheck) {
if (goog.isDef(opt_disableCheck) && !goog.isBoolean(opt_disableCheck)) {
throw new Error("opt_disableCheck must be a boolean if provided");
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
}
if (!opt_disableCheck) {
var overwrites = [];
for (var key in mixinObj) {
if (this[key] !== undefined) {
overwrites.push(key);
}
}
if (overwrites.length) {
throw new Error('Mixin will overwrite block members: ' +
JSON.stringify(overwrites));
}
}
goog.mixin(this, mixinObj);
};
/**
* Set the colour of the block from strings or string table references.
* @param {string|?} primary Primary colour, which may be a string that contains
* string table references.
* @param {string|?} secondary Secondary colour, which may be a string that
* contains string table references.
* @param {string|?} tertiary Tertiary colour, which may be a string that
* contains string table references.
* @param {string|?} quaternary Quaternary colour, which may be a string that
* contains string table references.
* @private
*/
Blockly.Block.prototype.setColourFromRawValues_ = function(primary, secondary,
tertiary, quaternary) {
primary = goog.isString(primary) ?
Blockly.utils.replaceMessageReferences(primary) : primary;
secondary = goog.isString(secondary) ?
Blockly.utils.replaceMessageReferences(secondary) : secondary;
tertiary = goog.isString(tertiary) ?
Blockly.utils.replaceMessageReferences(tertiary) : tertiary;
quaternary = goog.isString(quaternary) ?
Blockly.utils.replaceMessageReferences(quaternary) : quaternary;
this.setColour(primary, secondary, tertiary, quaternary);
};
/**
* Set the colour of the block from JSON, replacing message references as
* needed.
* @param {!Object} json Structured data describing the block.
* @private
*/
Blockly.Block.prototype.setColourFromJson_ = function(json) {
this.setColourFromRawValues_(json['colour'], json['colourSecondary'],
json['colourTertiary'], json['colourQuaternary']);
};
/**
* Interpolate a message description onto the block.
2015-07-01 22:49:44 -07:00
* @param {string} message Text contains interpolation tokens (%1, %2, ...)
* that match with fields or inputs defined in the args array.
* @param {!Array} args Array of arguments to be interpolated.
* @param {string=} lastDummyAlign If a dummy input is added at the end,
* how should it be aligned?
* @private
*/
Blockly.Block.prototype.interpolate_ = function(message, args, lastDummyAlign) {
Merge google/develop June 22 (#441) * Localisation updates from https://translatewiki.net. * test page that creates random blocks and randomly drags them around the page * Localisation updates from https://translatewiki.net. * add missing return in fake drag * get rid of drag_tests file: * Generated JS helper functions should be camelCase. Complying with Google style guide. * Localisation updates from https://translatewiki.net. * Fix extra category error. Clean up code, rename variables, reduce line lengths, fix lint issues. * Remove claim that good.string.quote should be used. * Change the blockly workspace resizing strategy. (#386) * Add a new method to be called when the contents of the workspace change and the scrollbars need to be adjusted but the the chrome (trash, toolbox, etc) are expected to stay in the same place. Change a bunch of calls to svgResize to either be removed or call the new method instead. This is a nice performance win since the offsetHeight/Width call in svgResize can be expensive, especially when called as often as we do - there was some layout thrashing. This also paves the way for moving calls to recordDeleteAreas (which is also expensive) to a more cacheable spot than on every mouse down/touch event. of things (namely the scrollbars) * Fix size of graph demo when it first loads by calling svgResize. The graph starts with fixed width and was relying on a resize event to fire (which I believe was removed in commit 217c681b86b0f2df76c479c9efae62e6e). * Fix the resizing of the code demo. The demo's tab min-width used to match the toolbox's width was only being set on a resize event, but commit 217c681b86b0f2df76c479c9efae62e6e changed how that worked. * Fix up some comments. * Use specific workspaces rather than Blockly.getMainWorkspace(). * Make workspace required for resizeSvgContents and update some calls to send real workspaces rather than ones that are null. Remove the private tag on terminateDrag_ because it is only actually called from outside the BlockSvg object. * Remove a rogue period. * Recategorize BlockSvg.terminateDrag_ to @package instead of @private so that other developers don't use it, but it still can be used by other Blockly classes. * Add a TODO to fix issue #307. * Add @package to workspace resizeContents. * Routine recompile * Fix unit tests. * Fix inheritance on rendered connection. Closure compiler on maximum compression breaks badly due to lack of @extends attribute. * Add toolbox location and toolbox mode options to playground. * Increase commonality between playgrounds. * Properly deal with shadow statement blocks in stacks. * Localisation updates from https://translatewiki.net. * Use a comment block for function comments in generated JS, Python and Dart. * Fix typo in flyout.js (#403) * Fix typo in flyout.js (#402) * Line wrap comments in generated code. * Remove reference to undefined variable (#413) REASON_MUST_DISCONNECT was removed by a refactor in 2a1ffa1. * Fix airstrike by grabbing the correct toolbox element. (#411) Probably broken in 266e2ffa9a017d21d7ca2f151730d6ecfcecf173. * Localisation updates from https://translatewiki.net. * Fix issue #406 by calling resize from the keypress handler on text inputs. (#408) * Remove shadow blocks from Accessible Blockly demo. Update README. * Generate for loops on one line. * Introduce a common translation pipe; remove local stringMap attributes. Fix variable name error in paste functions. Minor linting. * Fix precedence on isIndex blocks. * Add indexing setting for JavaScript Generation (#419) Adding setting to allow for switching between zero and one based indexing for Blockly Blocks such that the generated code will use this flag to determine whether one based or zero based indexing should be used. One based indexing is enabled by default. * Remove unused functions and dependencies. * Remove the unnecessary construction of new services. * Fix sort block in JS to satisfy tests. * Trigger a contents resize in block's moveBy. (#422) This fixes #420 but and it also fixes some other similar problems with copy/paste and other users of moveBy. * Consolidate the usages of the 'blockly-disabled' label. * Fix error when undoing a shadow block replacement. Issue #415. * Unify setActiveDesc() and updateSelectedNode() in the TreeService. Move function calls made directly within the template to the correct hooks. * Standardize naming of components. * Prevent collisions between user functions and helper functions. * Localisation updates from https://translatewiki.net. * Fix #425. Attash the resize handler to the workspace so it can be removed (#429) when workspace.dispose() is called. * Change the TreeService to a singleton. * Remove unneeded generated parens around function calls in indexOf blocks. * Fix #423 by calling workspace's resize when the flyout reflows. (#430) * Updating URLs to reflect new docs. (#418) * Updating URLs to reflect new docs. Removing -blockly in URLs. * Rebuilt. * Routine recompile * Prevent selected block from ending up underneath a bumped block. * Fix undo on fields with validators with side effects. * Don't fire change event on fields that haven't been named yet. * Localisation updates from https://translatewiki.net. * Fix tree focus issues. * Fix remaining focus issues on block deletion. * cache delete areas instead of recalculating them onMouseDown * Cache screen CTM for performance improvement. * Call svgResizeContents from block_svg's dipose so that deleting blocks (#434) from the context menu (or anywhere really) causes the workspace to recalculate its size. Remove the call to svgResizeContents from onMouseUp's logic for determining whether the block is being dropped in the trash since it calls dispose. One side effect of this is that when you delete multiple blocks resize gets called for each of them and the scrollbars move during the operation. This is most obviously seen by doing an airstrike in the playground and then deleting all the blocks at once. * Allow terminal blocks to replace other terminal blocks (#433) * Allow terminal blocks to replace other terminal blocks * Updated test to allow replacing terminal blocks * Refactor how activeDescendant is set. Introduce helper functions to ensure that calls like pasteAbove() preserve the focus. * Localisation updates from https://translatewiki.net. * Remove unnecessary logging. * Reduce unneeded parentheses in JS and Python. * Start using field_number. * Make it easy to disable unconnected blocks. * Routine recompile. * Check if matrix is null in mouseToSvg * Remove js/ localizations pre-merge * Fix change to block_render_svg * Fix error in xml.js * Playground merge * Add simple toolboxes to playgrounds * Fix flyout reference in events listener * Move tokenizeIntepolation into Blockly.utils namespace. * Use simpler message interpolation in Code demo. * Create console stub for IE 9. * Don't output blockId if not set (e.g., toolbox category event). (#443) * Fix block in multi-playground * Increase commonality between playgrounds. # Conflicts: # tests/multi_playground.html # tests/playground.html * Remove "show flyouts" button * Recompile for merge June 22
2016-06-22 17:50:16 -04:00
var tokens = Blockly.utils.tokenizeInterpolation(message);
2015-07-10 16:08:27 -07:00
// Interpolate the arguments. Build a list of elements.
var indexDup = [];
var indexCount = 0;
var elements = [];
for (var i = 0; i < tokens.length; i++) {
var token = tokens[i];
2015-07-10 16:08:27 -07:00
if (typeof token == 'number') {
if (token <= 0 || token > args.length) {
throw new Error('Block "' + this.type + '": ' +
'Message index %' + token + ' out of range.');
}
if (indexDup[token]) {
throw new Error('Block "' + this.type + '": ' +
'Message index %' + token + ' duplicated.');
}
2015-07-10 16:08:27 -07:00
indexDup[token] = true;
indexCount++;
2015-07-10 16:08:27 -07:00
elements.push(args[token - 1]);
} else {
2015-07-10 16:08:27 -07:00
token = token.trim();
if (token) {
elements.push(token);
}
}
}
if (indexCount != args.length) {
throw new Error('Block "' + this.type + '": ' +
'Message does not reference all ' + args.length + ' arg(s).');
}
// Add last dummy input if needed.
2015-06-10 21:59:27 -07:00
if (elements.length && (typeof elements[elements.length - 1] == 'string' ||
goog.string.startsWith(
elements[elements.length - 1]['type'], 'field_'))) {
2016-05-04 15:05:45 -07:00
var dummyInput = {type: 'input_dummy'};
if (lastDummyAlign) {
2016-05-04 15:05:45 -07:00
dummyInput['align'] = lastDummyAlign;
}
2016-05-04 15:05:45 -07:00
elements.push(dummyInput);
}
// Lookup of alignment constants.
var alignmentLookup = {
'LEFT': Blockly.ALIGN_LEFT,
'RIGHT': Blockly.ALIGN_RIGHT,
'CENTRE': Blockly.ALIGN_CENTRE
};
// Populate block with inputs and fields.
var fieldStack = [];
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
if (typeof element == 'string') {
fieldStack.push([element, undefined]);
} else {
var field = null;
var input = null;
2015-07-01 22:49:44 -07:00
do {
var altRepeat = false;
if (typeof element == 'string') {
field = new Blockly.FieldLabel(element);
} else {
switch (element['type']) {
case 'input_value':
input = this.appendValueInput(element['name']);
break;
case 'input_statement':
input = this.appendStatementInput(element['name']);
break;
case 'input_dummy':
input = this.appendDummyInput(element['name']);
break;
default:
2018-04-17 14:15:18 -07:00
field = Blockly.Field.fromJson(element);
// Unknown field.
2018-04-17 14:15:18 -07:00
if (!field) {
if (element['alt']) {
element = element['alt'];
altRepeat = true;
} else {
console.warn('Blockly could not create a field of type ' +
element['type'] +
'. You may need to register your custom field. See ' +
'github.com/google/blockly/issues/1584');
}
}
}
2015-07-01 22:49:44 -07:00
}
} while (altRepeat);
if (field) {
fieldStack.push([field, element['name']]);
} else if (input) {
if (element['check']) {
input.setCheck(element['check']);
}
if (element['align']) {
input.setAlign(alignmentLookup[element['align']]);
}
for (var j = 0; j < fieldStack.length; j++) {
input.appendField(fieldStack[j][0], fieldStack[j][1]);
}
fieldStack.length = 0;
}
}
}
};
/**
* Add a value input, statement input or local variable to this block.
* @param {number} type Either Blockly.INPUT_VALUE or Blockly.NEXT_STATEMENT or
* Blockly.DUMMY_INPUT.
* @param {string} name Language-neutral identifier which may used to find this
* input again. Should be unique to this block.
* @return {!Blockly.Input} The input object created.
* @protected
*/
Blockly.Block.prototype.appendInput_ = function(type, name) {
var connection = null;
if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
2016-05-10 15:39:37 -07:00
connection = this.makeConnection_(type);
}
var input = new Blockly.Input(type, name, this, connection);
// Append input to list.
this.inputList.push(input);
return input;
};
/**
2013-12-03 16:10:37 -08:00
* Move a named input to a different location on this block.
* @param {string} name The name of the input to move.
2013-12-03 16:10:37 -08:00
* @param {?string} refName Name of input that should be after the moved input,
* or null to be the input at the end.
*/
Blockly.Block.prototype.moveInputBefore = function(name, refName) {
2013-12-03 16:10:37 -08:00
if (name == refName) {
return;
}
// Find both inputs.
var inputIndex = -1;
var refIndex = refName ? -1 : this.inputList.length;
2015-01-01 14:30:37 -08:00
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.name == name) {
2015-01-01 14:30:37 -08:00
inputIndex = i;
if (refIndex != -1) {
break;
}
} else if (refName && input.name == refName) {
2015-01-01 14:30:37 -08:00
refIndex = i;
if (inputIndex != -1) {
break;
}
}
}
goog.asserts.assert(inputIndex != -1, 'Named input "%s" not found.', name);
goog.asserts.assert(
refIndex != -1, 'Reference input "%s" not found.', refName);
2013-12-03 16:10:37 -08:00
this.moveNumberedInputBefore(inputIndex, refIndex);
};
/**
* Move a numbered input to a different location on this block.
* @param {number} inputIndex Index of the input to move.
* @param {number} refIndex Index of input that should be after the moved input.
*/
Blockly.Block.prototype.moveNumberedInputBefore = function(
inputIndex, refIndex) {
2013-12-03 16:10:37 -08:00
// Validate arguments.
goog.asserts.assert(inputIndex != refIndex, 'Can\'t move input to itself.');
goog.asserts.assert(inputIndex < this.inputList.length,
'Input index ' + inputIndex + ' out of bounds.');
goog.asserts.assert(refIndex <= this.inputList.length,
'Reference input ' + refIndex + ' out of bounds.');
// Remove input.
2013-12-03 16:10:37 -08:00
var input = this.inputList[inputIndex];
this.inputList.splice(inputIndex, 1);
if (inputIndex < refIndex) {
refIndex--;
}
// Reinsert input.
this.inputList.splice(refIndex, 0, input);
};
/**
* Remove an input from this block.
* @param {string} name The name of the input.
2015-07-13 15:03:22 -07:00
* @param {boolean=} opt_quiet True to prevent error if input is not present.
* @throws {goog.asserts.AssertionError} if the input is not present and
* opt_quiet is not true.
*/
Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
2015-01-01 14:30:37 -08:00
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.name == name) {
2016-03-30 15:09:42 -07:00
if (input.connection && input.connection.isConnected()) {
input.connection.setShadowDom(null);
var block = input.connection.targetBlock();
if (block.isShadow()) {
// Destroy any attached shadow block.
block.dispose();
} else {
// Disconnect any attached normal block.
block.unplug();
}
}
input.dispose();
2015-01-01 14:30:37 -08:00
this.inputList.splice(i, 1);
return;
}
}
if (!opt_quiet) {
goog.asserts.fail('Input "%s" not found.', name);
}
};
/**
* Fetches the named input object.
* @param {string} name The name of the input.
2016-03-18 15:19:26 -07:00
* @return {Blockly.Input} The input object, or null if input does not exist.
*/
Blockly.Block.prototype.getInput = function(name) {
2015-01-01 14:30:37 -08:00
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.name == name) {
return input;
}
}
// This input does not exist.
return null;
};
/**
* Fetches the block attached to the named input.
* @param {string} name The name of the input.
* @return {Blockly.Block} The attached value block, or null if the input is
* either disconnected or if the input does not exist.
*/
Blockly.Block.prototype.getInputTargetBlock = function(name) {
var input = this.getInput(name);
return input && input.connection && input.connection.targetBlock();
};
/**
* Returns the comment on this block (or '' if none).
* @return {string} Block's comment.
*/
Blockly.Block.prototype.getCommentText = function() {
2014-12-23 11:22:02 -08:00
return this.comment || '';
};
/**
* Set this block's comment text.
* @param {?string} text The text, or null to delete.
*/
Blockly.Block.prototype.setCommentText = function(text) {
2016-01-15 15:36:06 -08:00
if (this.comment != text) {
2017-06-22 10:38:20 -04:00
Blockly.Events.fire(new Blockly.Events.BlockChange(
this, 'comment', null, this.comment, text || ''));
2016-01-15 15:36:06 -08:00
this.comment = text;
}
};
/**
* Set this block's output shape.
* e.g., null, OUTPUT_SHAPE_HEXAGONAL, OUTPUT_SHAPE_ROUND, OUTPUT_SHAPE_SQUARE.
* @param {?number} outputShape Value representing output shape
* (see constants.js).
*/
Blockly.Block.prototype.setOutputShape = function(outputShape) {
this.outputShape_ = outputShape;
};
/**
* Get this block's output shape.
* @return {?number} Value representing output shape (see constants.js).
*/
Blockly.Block.prototype.getOutputShape = function() {
return this.outputShape_;
};
/**
* Set this block's category (for styling purposes)
* @param {?string} category The block's category (see constants.js).
*/
Blockly.Block.prototype.setCategory = function(category) {
this.category_ = category;
};
/**
* Get this block's category (for styling purposes)
* @return {?string} category The block's category (see constants.js).
*/
Blockly.Block.prototype.getCategory = function() {
return this.category_;
};
/**
* Set whether this block has a checkbox next to it in the flyout.
* @param {boolean} hasCheckbox True if this block should have a checkbox.
*/
Blockly.Block.prototype.setCheckboxInFlyout = function(hasCheckbox) {
this.checkboxInFlyout_ = hasCheckbox;
};
/**
* Get whether this block has a checkbox next to it in the flyout.
* @return {boolean} True if this block should have a checkbox.
*/
Blockly.Block.prototype.hasCheckboxInFlyout = function() {
return this.checkboxInFlyout_;
};
/**
* Set this block's warning text.
* @param {?string} text The text, or null to delete.
* @abstract
*/
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
Blockly.Block.prototype.setWarningText = function(/* text */) {
2014-12-23 11:22:02 -08:00
// NOP.
};
/**
2014-12-23 11:22:02 -08:00
* Give this block a mutator dialog.
* @param {Blockly.Mutator} mutator A mutator dialog instance or null to remove.
* @abstract
2014-12-23 11:22:02 -08:00
*/
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
Blockly.Block.prototype.setMutator = function(/* mutator */) {
2014-12-23 11:22:02 -08:00
// NOP.
};
/**
* Return the coordinates of the top-left corner of this block relative to the
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
* drawing surface's origin (0,0), in workspace units.
2014-12-23 11:22:02 -08:00
* @return {!goog.math.Coordinate} Object with .x and .y properties.
*/
2014-12-23 11:22:02 -08:00
Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
return this.xy_;
};
/**
* Move a block by a relative offset.
Merge google/blockly, May 2017 (#881) * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Option for moving one block from stack. See thread in support group before merging. * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Expand stack-drag modifier key to include alt and ctrl. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * Localisation updates from https://translatewiki.net. * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Localisation updates from https://translatewiki.net. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Temporary fix for broken text field validation. * rebuild * Add a block to reverse a list (#844) * Localisation updates from https://translatewiki.net. * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * Localisation updates from https://translatewiki.net. * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Localisation updates from https://translatewiki.net. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Localisation updates from https://translatewiki.net. * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * Potential bug fix for issue #661 * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Clarification update. Unraveling nested ternaries in Blockly.utils.tokenizeInterpolation_() * Code correction from previous commit. Moved style to css.js and set ROUNDING=15; * Fixing Enter so it properly propogates to dropdown selection. (#934) Fixing FieldSegment so it updates dropdowns when the underlying dropdown changes. * Localisation updates from https://translatewiki.net. * Make variable add set/get block in context menu obey block limits * Localisation updates from https://translatewiki.net. * Use mutator extension for controls_if block * Fix #946. Don't check for presence of constants.js * Fix #945 (annotations) and an eslint issue (constant condition) * Localisation updates from https://translatewiki.net. * Fix #950: BlockFactory typo and copypasta * Add safety checks for mutators and non-mutator extensions * Handle mutations with both mixins and functions * Adding warning on duplicate JSON block definition. * period * Make some functions private and add tests * Localisation updates from https://translatewiki.net. * Update help URL per #937. Replace URL usages of %28 and %29 with normal parenthesis characters. (They aren't replaced by JavaScript's encodeURIComponent() function, and seem to work just fine without them.) Added missing semicolon in build.py. * Typo in comment. * Make it easier to read the code that creates the variable category in the tolbox * Adding Blockly.Xml.appendDomToWorkspace() (#962) This is a copy (with additional comments) of PR #822 (and also #961) by @qnoirhomme with unrelated files removed. See #822 for full review. * Annotation fixes * Fix bug #904 by explicitly grabbing focus on the workspace svg element. (#964) * Potential fix for #888. Stops checking whether we are mid workspace drag since we do not always get mosue up events when blockly is in an iframe. (#899) * Adding new minimap demo * Basic code style changes. Adding a few more comments. Return early if disableScrollChange in onScrollChange listener. * `unction` to `function` corrects #962 (#970) * Cross browser friendly fix for #904. This calls blur and focus from … (#972) * Cross browser friendly fix for #904. This calls blur and focus from workspace.markFocused and removes the event listener on focus events. markFocused is called from all of our mouse down handlers, which triggers the focus event leading to an infinite loop of focus. As far as I can tell, there are no uses of the focus handler that actually did anything for us. * Localisation updates from https://translatewiki.net. * Another attempt to fix #904 to keep the page from jumping to the focused workspace in IE 11 (#974) * Adding horizontal scrolling. Changed scroll change callbacks from onScroll_ to setHandlePosition. onScroll_ is not challed when workspace is dragged. * set background color to lilac if opening the playground from file: * Registering mousemove and mouseup listener in mousedown event. Mousemove and Mouseup events are now listening over document. * Localisation updates from https://translatewiki.net. * Fix #967 by overriding the updateWidth method in FieldImage blocks to be a no-op. FieldImage fields should not change size after the width is set in init. The updateWidth and, therefore, getCachedWidth is now being called by BlockSvg renderFields_ (see commit d55d9cbd9ff308ff5e361cf77acabb61a4bf4695). IIUC, updateWidth/getCachedWidth was only called from render before which is overridden in FieldImage to be a no-op already. (#979) * Fix #969 * Localisation updates from https://translatewiki.net. * Fix #986. Looks like the original PR just forgot this block. (#992) * rebuild develop (#996) * Added the variable modal and component and implemented basic renaming functionality. (#991) * Fixing commenting from the last commit. (#1000) * Localisation updates from https://translatewiki.net. * RemoveAttribute doesn't work on SVG elements in IE 10. Use setAttribute to null instead. * Adding the remove variable modal and functionality to accessible Blockly. (#1011) * Minimap position bug fix for browsers other than chrome. Added touch support. * Adding an add variable modal to accessible Blockly. (#1015) * Adding the remove variable modal and functionality to accessible Blockly. * Adding the add variable modal for accessible Blockly. * Block browser context menu in the toolbox and flyout * Add links to the dev registration form and contributor guidelines * Miscellaneous comment cleanup * Adding the common modal class. (#1017) Centralizes accessible modal behavior. * - Changed error message referencing 'procedure' instead of 'function' (#1019) - Added iOS specific UI messages - Fixed bug with js_to_json.py script where it didn't recognize ' character * - Allows use of Blockly's messaging format for category name, colour,… (#1028) ...in toolbox XML. - Updated code editor demo to use this message format - Re-built blockly_compressed.js * Making text_count use a text color (like text_length, which also returns a number). (#1027) * Enable google/blockly with continuous build on travis ci (#1023) (#1035) * create .travis for ci job * initial checkin for blocky-web travis ci job * rename file to .travis.yaml for typo * remove after_script * added cache * rename .travis.yaml to .travis.yml * Update .travis.yml * include build script * fix yaml file format issue * debug install part * debug build issue * Update .travis.yml * remove cache for now * Update .travis.yml * Update .travis.yml * Update .travis.yml * more debug info * Update .travis.yml * Update .travis.yml * fix typo * installing chrome browser * remove chrome setting config * run build.py as part of npm install * Update .travis.yml * update karma dependency * use karma as test runner * fix typo * remove karma test for now * Update .travis.yml * Update package.json * add npm test target * add browserstack-runner depdendency * update browser support * fix typo for test target * fix chrome typo * added closure dependency * add google-closure-library * include blockly_uncompressed.js and core.js dependency * uncomment out core/*.js files * add kama job as part of install * remove browserstack add on for now * fix karma config typo * add karma-closure * add os support * remove typo config * include more closure files * change os back to linux * use closure-library from node_modules * change log level back to INFO * change npm test target to use open browser command instead of karma * change travis test target to use open command instead of karma * list current directory * find what's in current dir * typo command * Update .travis.yml * typo again * open right index.html * use right path for index.html * xdg-open to open default browser on travis * exit browser after 5s wait * change timeout to 1 min * exit after opening up browser * use browser only * use karma * remove un-needed dependency * clean up script section * fix typo * update build status on readme * initial commit for selenium integration tests * update selenium jar path * fix test_runner.js typo * add more debug info * check java version * add && instead of 9288 * fix java path * add logic to check if selenium is running or not * add some deugging info * initial commit to get chromedriver * add chromedriver flag * add get_chromedriver.sh to package.json and .travel * change browser to chrome for now * fix path issue * update chromdriver path * fix path issue again * more debugging * add debug msg * fix typo * minor fix for getting chromedriver * install latest chrome browser * clean up pakcage.json * use npm target for test run * remove removing trailing comma * fix another trailing comma * updated travis test target * clean up scripts * not sure nmp run preinstall * redirect selenium log to tmp file * revert writing console log to file * update test summary * more clean up * minor clean up before pull request * resolved closure-library conflict 1. add closure-library to dependencies instead of devDependencies. 2. add lint back in scripts block * fix typo (adding comma) in script section * Renames Blockly.workspaceDragSurface to Blockly.WorkspaceDragSurface. Fixes #880. * Ensure useDragSurface is a boolean. Fixed #988 * use pretest instead of preinstall in package.json (#1043) * cherry pick for pretest fix * put pretest target to test_setup.sh * fix conflict * cherry pick for get_chromedriver.sh * add some sleep to wait download to finish * use node.js stable * use npm test target * field_angle renders degree symbol consistently. Fixes #973 * bumpNeighbours_ function moved to block_svg. Fixed #1009 * Update RegEx in js-to-json to match windowi eol (#1050) The current regex only works with the "\n" line endings as it expects no characters after the optional ";" at the end of the line. In windows, if it adds the "\r" it counts as a characters and is not part of the line terminator so it doesn't match. * Fix French translation of "colour with rgb" block (#1053) "colorier", which is currently used, is a verb and proposed "couleur" is a noun: the block in question does not change colour of anything, it creates new colour instead, thus noun is more applicable. Also, noun is used in French translation of "random colour" block: "couleur aléatoire". * Enforcing non-empty names on value inputs and statement inputs. (#1054) * Correcting #1054 (#1056) single quotes. better logic. * Created a variable model with name, id, and type. Created a jsunit test file for variable model. * Change how blockly handles cursors. The old way was quite slow becau… (#1057) * Change how blockly handles cursors. The old way was quite slow because it changed the stylesheet directly. See issue #981 for more details on implementation and tradeoffs. This changes makes the following high level changes: deprecate Blockly.Css.setCursor, use built in open and closed hand cursor instead of custom .cur files, add css to draggable objects to set the open and closed hand cursors. * Rebuild blockly_uncompressed to pick up a testing change to make travis happy. Fix a build warning from a multi-line string in the process. (#1059) * Merge master into develop (#1063) - pick up translation changes - clean up trailing spaces * use goog.string.startswith instead of string.startswith (#1065) * New jsinterpreter demo includes wait block. Both demos have improved UI for clarity. (#1001) Refactor of interpreter demo * Renamed demos/interpreter/index.html as demos/interpreter/step-execution.html (including redirect), and added demos/interpreter/async-execution.html. * Refactored code to automatically generate/parse the blocks, eliminating the need for a "Parse JavaScript" button. Code is still shown in alert upon stepping to the first statement. Print statements now write to output <textarea> instead of modal dialogs. * Fix #1069 (#1073) * Fix cursor and mistaken css from merge * Comment out broken field angle merge * Fix broken merge with borders * Add back original package json (woops) * Remove render function for field angle, may not be the right way but it was broken... * Revert merge blocking variable shadow blocks * Add changes from built lang files * Add back travis and readme * Revert broken cleanup additions * Add notes for scratch-block specific functions * Revert change to css so blocks stay under the toolbox * Add back accidentally removed files * Use getFlyout_ instead of getFlyout everywhere * Satisfy the linter * Re-remove deprecated function * Remove duplicated code in block_svg * Add back flip_rtl option for images * Remove more duplicated functions from past merges * Fix flip_rtl code * Revert renaming of getFlyout
2017-05-11 15:58:18 -04:00
* @param {number} dx Horizontal offset, in workspace units.
* @param {number} dy Vertical offset, in workspace units.
2014-12-23 11:22:02 -08:00
*/
Blockly.Block.prototype.moveBy = function(dx, dy) {
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
2017-06-22 10:38:20 -04:00
var event = new Blockly.Events.BlockMove(this);
2014-12-23 11:22:02 -08:00
this.xy_.translate(dx, dy);
2016-02-02 00:28:49 -08:00
event.recordNew();
Blockly.Events.fire(event);
};
2015-12-09 10:02:42 +01:00
/**
2016-05-10 15:39:37 -07:00
* Create a connection of the specified type.
* @param {number} type The type of the connection to create.
* @return {!Blockly.Connection} A new connection of the specified type.
2015-12-09 10:02:42 +01:00
* @private
*/
2016-05-10 15:39:37 -07:00
Blockly.Block.prototype.makeConnection_ = function(type) {
return new Blockly.Connection(this, type);
2015-12-09 10:02:42 +01:00
};
Feature/merge feb 2017 (#791) * Revert "Rebuild nov 3 16" * Move injected css to start of head * simplification * lint * Remove copy/paste buttons. * Localisation updates from https://translatewiki.net. * Don't split dropdown text if there is an image. * Unblock push to master. * Revert "Revert "Rebuild nov 3 16"" This reverts commit c8ca24a0007b70e137417e843459c87185141a55. * rebuild * Remove ifelse block and messages' * Remove obsolete Gecko image hack. Apparently this has been fixed in Gecko. * Add correct focus behavior for the modal. Update boundary sounds. * Disallow clicks on disabled buttons. * add back metadata tag to qqq * revert qqq.json * Improve performance of block dragging. This is a backport of the blo… (#732) Improve performance of block dragging. This is a backport of the block drag surface from scratch-blocks. At the beginning of a block drag, blocks get moved to a drag surface which then translates using translate3d to avoid repainting the entire svg on every mouse move. At the end of the drag, the blocks are dropped back in the svg in their new position. * API-breaking cleanup. But doubtful anyone will be affected. (#748) * Make add/removeClass return whether they did anything. * Move more functions onto utils. * Move bind functions to Blockly. * Routine recompile. * String reference in JSON string messages (#741) * Adds message references to message string interpolation, in the form of %{BKY_STRING}. * Re-adding CONTROLS_IFELSE block using the new syntax, referencing to CONTROL_IF equivalents. * Fix compiler errors. * Break the sidebar out into its own individual component. * Hide notification messages after a short time interval. * Fix selection border on blocks that have been highlighted. * controls_ifelse: Remove right-align. Remove Boolean check on statements. (#749) * Move away from using a common modal service, since the block options and the toolbox modals are going to end up behaving fairly differently. * Fix conflict between 'utils' and 'image dropdown' merges. * Add a contextual modal for the toolbox. * Fix some bugs arising in the toolbox modal for the no-categories case. * Allow attaching blocks to a marked spot from the toolbox modal. This is the last prerequisite for removal of the existing on-screen toolbox. * Delete the on-screen toolbox. * Add warning sounds when the user reaches a boundary of the workspace. * Stop some blocks from throwing errors in headless workspaces. * Lint * Fix speling. * Fix broken highlighting when highlighted block is deleted. Issue 752. * When the workspace is empty, make it easy for the user to add a new group of blocks to it. * Handle the finer points for setting focus correctly after deleting blocks from the workspace. * When user edits text in a field, set text, not value. Existing text-editable fields don’t care (dropdown care, but are not text-editable). But a note picker needs to set its value to 60 if text is set to ‘C4’. * Set the text not the value when closing a text editor. Also rename variables for clarity. * Localisation updates from https://translatewiki.net. * Streamline the logic for block selection callbacks in the toolbox modal. * Do not show disabled actions in the block options modal. * Set focus correctly when toolbox modal is dismissed. * Add information regarding target screen reader and browser. * Rebuild Blockly. * Remove unavailable blocks from toolbox modal. Hide unnecessary category name in a toolbox without categories. * Do some refactoring and tidy-up. Pull some hardcoded strings out for i18n purposes; remove unused strings. * Update config options for sidebar buttons. * Minor refactoring. Remove unused dependencies. * Improve styling of sidebar buttons. * Remove clipboard functionality. * Refactor and simplify marked spot logic. * Change dropdowns to select fields instead of lists of buttons. * Add ability to specify a css class for labels and buttons * Don't make labels clickable * console.log -> console.warn * change 'class' to 'web-style' * createSvgElement is now in utils. fix two calls. * Improve comments. * lint * fix missing semicolon * When adding a new block group from the toolbox modal, only show blocks with no output connections. * Clean up the sidebar file and remove unneeded code. * Remove some functions from utilsService and consolidate code in workspace-tree.component.js. * Standardize indentation. * Remove premature focus on buttons in modal dialogs, since this prevents readout of the dialog text. * Localisation updates from https://translatewiki.net. * Don't get Toolbox element unless needed. * Associate flyout button callbacks directly with workspaces * Add colour block to the block factory base block initial state * Start getting helpurl and tooltip in * Generate helpURL and tooltip for Javascript block definition * Use Tab keys instead of arrow keys for dialog boxes. Set role=alertdialog and read out the header/text automatically. Ensure that Esc key actually closes dialogs and that all keystrokes are captured. * Add an aria-describedby to the 'create new block group...' button in the workspace to give more context. * Fix issue with aria-liveregion not speaking. Allow sufficient time for alert noise to play before speaking the notification. * Make zoom speed independent of event granularity Before, touchpads would give "smoother" scrolling by delivering lots of mousewheel events with small distance changes. Because the code only looked at the sign of deltaY, ten 5px scrolls would zoom 10x more than one 50px scroll. This change makes zooming with a touchpad more like zooming with a mousewheel. On my laptop, a full-scale zoom (fully out to fully in) was about a 5mm finger movement before, and is now about 3cm. Fixes #758. * Split the scrollbar and flyout out into their own SVG elements. They (#771) * Split the scrollbar and flyout out into their own SVG elements. They are siblings of the workpsace SVG. This paves the way to make performance improvements to workspace dragging. * remove overflow-y on the block exporter labels so scroll bars do not show upin firefox. Also fix up the styles on the labels so that they display better in firefox. (#699) * Fix #698 by adjusting the regex to not have \. Still not 100% sure w… (#700) * Fix #698 by adjusting the regex to not have \. Still not 100% sure why that was there. Also replaces bad names on input. There are probably more invalid names but this is a start. * update generator comments * Move the call to disable resize before placeNewBlock so that it is of… (#777) * Move the call to disable resize before placeNewBlock so that it is off when workspace resizeContents gets triggered by placeNewBlock. This fixes a bug in rtl mode where the workspace was being resized between when the block was added to the workspace and when it was moved to the proper location. * Disable workspace resizing while loading the flyout from XML * Localisation updates from https://translatewiki.net. * Add a workspace drag surface that blocks and bubble get moved to duri… (#778) * Add a workspace drag surface that blocks and bubble get moved to during a workspace drag. The surface is translated using translate3d instead of svg's translate attribute so that the browser does not have to repaint the entire workspace on every mouse move. This is very similar to the block drag surface. * Address code review comments * add back hasClass_ utility removed in #748 and stop using contains since it is not supported in IE * Fixes #786 by checking if getComputedStyle is null in is3dSupported. We do not cache the value in this case and try again later. is3dSupported is only called while users are interacting with blockly which they cannot do while hidden so the performance implications of running the check again are minimal. (#787) * Localisation updates from https://translatewiki.net. * Change the Python codegen for string quoting to match the behaviour of `repr` on a string in CPython. * Localisation updates from https://translatewiki.net. * Add an `allInputsConnected` method to `Block` and `Workspace` to test whether all trees in the block forest have their inputs filled. An optional argument controls whether or not shadow blocks are counted as being filled. Recommitting changes off `develop` instead of `master` as per discussion in PR #791. * Localisation updates from https://translatewiki.net. * Localisation updates from https://translatewiki.net. * Use the drag surface when scrolling using the scrollbars. #783 (#789) * End event groups when you finish editing a field * Fix #794 and make the workspace grid drag along with the workspace. (#801) There was some IE specific code that also applies to Edge so just updated a conditional to include Edge. * Now that text input's setText skips setValue, it needs to explicitly create a change event * Check if the text has changed before firing an event * Init procedure blocks with empty name, and set default name in xml in Blockly.Procedures.flyoutCategory * Routine rebuild * Move createDom call into the constructor of block drag surface. (#790) * Make cursor stay as a closed hand when dragging blocks around in the drag surface. Do this by applying the same style to text elements in the drag surface that we do in the main svg. (#805) * Don't connect to blocks under the flyout. * recompile again. (#806) * Fix german translation * Fix german translation of 'delete x blocks' * Adding unit tests for ifelse block. * Improvements to the generator test framework. * <field>, <value> reorder due to load/save. * Use the npm closure library instead of the same library installed at a parallel directory * Fix undo/redo for FieldCheckbox Thanks to PR #813 by ademenev * PR #818: Adding support for string table lookups in dropdown field labels Adding support for string table lookups in dropdown field labels specified in JSON. Adds Blockly.utils.replaceMessageReferences() method to handle string replacement without interpolation tokens. Effectively uses the same old code, now moved into tokenizeInterpolation_(), which takes a parseInterpolationTokens option. Replaces the direct JavaScript references (not pure JSON, and thus not portable). Demonstrating this behavior in the logic_boolean dropdown. * Integrating qqq.json changes into messages.json. (#820) From commits b77f8cbebc5cef247116d3df6a428df8addbe53d and 4ecdedec9f8a69f78abf246e7a5db1e1a0be6b85 * Naming changes in mirror demo * Adding support for untranslated messages. (#819) This will be used to define constants accessible in JSON block definitions. Messages with descriptions that include `{{Notranslate}}` will not be included in the translation files sent to TranslateWiki. Instead, they are written to `msg/json/constants.json`, and later merged back into the `.js` files, similar to synonyms. Template details: https://translatewiki.net/wiki/Template:Notranslate * JSON support for message lookup in colour, tooltip, and help URL. (#825) String replacement for the colour, tooltip text and help URL attributes of JSON defined blocks. Demonstrated in logic_boolean. * Fixes as per code review on PR. * Reduce number of Closure files in App Engine upload. * Python false is False. Issue #828. * Replace 'const' with 'var'. This unbreaks IE10 and advanced compiled apps such as Blockly Games. * Fix bug in audioService where attached event callbacks were not being cleared properly. * Rename workspace-tree to workspace-block. * Minor refactoring of the modal code (add comments, guard against invalid keystrokes, etc.). * FieldNumber & FieldAngle: Default value "0" (#832) FieldNumber and FieldAngle previously accepted "undefined" as values, if not defined in JSON. This catches these and uses "0" for any NaN value. The constructor value parameter is now optional. Includes tests. * Remove unnecessary check when attaching a new block to a marked connection. * Remove debug info. * Refactor and simplify field-segment.component.js. * Replace single quotes with double. (#836) Fixes commits in #832. * Adding extensions for JSON support of dynamic blocks. (#834) Adding support for extensions, functions that can assist with loading blocks, much like init functions, but that can be referenced from JSON definitions. This allows JSON definitions to define dynamic blocks such as onchange handlers and mutators. Rewrote math_number as an example pure JSON block. * Add ability to add a class to a scrollbar so that different types of … (#837) * Add ability to add a class to a scrollbar so that different types of scrollbars can be distinguished from each other. You used to be able to do this by looking at the parent element but now all the scrollbars are siblings in the dom. Also, use this new class to fix #816 so that layering of the flyout and workspace scrollbars are done correctly. * JSON definitions for colour blocks (#838) Replaces old colour block definitions with a Blockly.defineBlocksWithJsonArray(..) call. Generator unit tests continue to load and pass, signifying compatibility with prior block definitions. Replaces extension 'math_number_tooltip' with the reusable 'parent_tooltip_when_inline' extension, also used by colour_picker. Includes tests. * Rewrite tree.service.js. - Remove unnecessary code and functions. - Add documentation where needed. - Fix a bug arising when a block on the workspace is attached to an existing link. * Use setValue in fieldTextInput so that procedure renaming works * Further cleanup and removal of unnecessary functions. Pull some strings out for i18n. * Use bindEvent_ instead of bindEventWithChecks_ for longStop * Clean up workspace.component.js. When moving a block from one place to another, move all blocks after it too, and adjust the active descs accordingly. * Unit tests for JSON block definitions (just the start) (#850) * Beginnings of a JSON block definition unit test set. * Dispose of unit test workspaces and blocks in finally blocks. * Clarify JSON error message by echoing arg notation. * New blocks text_count, text_replace, and text_reverse (#830) Includes generators for all languages and units tests on those generators. * Fixing combo boxes getting out-of-sync with NVDA. Combo boxes need to be special cased like text input. Also, Escape is a reserved button in NVDA, so I added Enter as a way to "submit and move up a level" in addition to escape, so these boxes can be edited while NVDA is on. * Add a block to reverse a list (#844) * Porting math.js blocks to JSON (#846) Moving all `math.js` definitions into a single JSON array, complete with i18n syntax for all messages, dropdowns, and tooltips. Adding Blockly.Extensions.buildTooltipForDropdown(..) to facilitate the creation and error-checking of tooltips that update based on the value of a dropdown. Now warn on raw string in JSON 'extensions'. * Fixing JSON support for images in dropdowns. Adding tests. (#851) Fixes #848. * Update README.md Add a link to our forum. * Correcting math_change color * Enable custom flyout categories. * Add some safety * Update the set of reserved words in Python to reflect the current state of Python (2.7 and 3.6). (#861) * .getOptions_() to .getOptions() (#869) Fixes #867. * Blockly.Extensions.buildTooltipForDropdown(..): Deferred validation. (#870) Defer tooltip message string check until after load, when all Blockly.Msg should be loaded. Avoids validation in headless mode, due to lack of document.readyState. * annotation updates * jsdoc corrections (#874) * Remove use of Array.prototype.includes which is not implemented in IE or Edge < 14. Fixes google/blockly#876. * Attempt to work around the IE/Edge bug where `getComputedTextLength()` throws an exception when the SVG node is not visible. This workaround forces a re-render, which in turn, forces a re-calculation of the node width once a block is inserted into the workspace SVG. This workaround is only executed on IE and Edge. See https://groups.google.com/forum/#!topic/blockly/T8IR4t4xAIY for the initial discussion of this issue. * Change CSS transforms to work with older browsers (#879) * Change the setting of the CSS transform properties on SVG nodes to set both the unprefixed version and the `-webkit-` prefixed version so that Blockly correctly renders in order browsers, such as Safari < 9 and iOS Safari < 9.2. For discussion of this issue, see https://groups.google.com/forum/#!topic/blockly/o3pERaRQhSg * Correct the separation between the CSS transform property and the rest of the CSS that was in the variable misleadingly called "transform". * Don't try to get block position in a headless workspace * Stop bumping neighbours in headless blockly * Place context menu correctly on touch * Clear all active desc ids when the 'Erase Workspace' button is pressed. * Fix a bug where splicing a block between two linked blocks disconnects the group and messes up the focus. * Deleting a top-level block does not cause blocks after it to be deleted. Properly handle the active desc for this case. * Use the empty field placeholder for dropdowns that do not have a value selected. * Bugfix for #892. I incorrectly converted one CSS transform setting to use the cross-browser setting function in 40a063763c74b3f712c3057565966c25d5cfdb10. (#895) * Adding @namespace annotations for JSDoc. (#900) * Fix typo causing TypeError (#901) * Pinning the angular2 dependency, and including licenses. (#893) * Add skeleton for tests on rendered workspaces * Fix some lint errors * Correct changedState in setWarningText() (#908) When clearing warnings on blocks with IDs, the changedState variable should be true if the text changed. This will trigger the block being reshaped and remove the space for the notification icon (this.bumpNeighbours_). * Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). (#907) Adds Block.prototype.mixin() and Blockly.Extensions.registerMixin(). This adds support for a common use pattern in extensions, and adds error checking to avoid future incompatibilities. * Porting Logic blocks to JSON (#913) Extensions, mixins, mutators and constants now grouped under the new namespace Blockly.Constants.Logic. * Improving errors/warnings with Block.toDevString() and Connection.toString(). (#911) * Add isEditable to field, and add tests * Separate tests * Blockly.Constants.Math and Blockly.Constants.Colour extension constants (#916) Also, correcting quotes in logic.js. * Correction to logic_ternary type check (#920) * Porting Loop blocks to JSON (#919) * Improved documentation on `Blockly.Extensions.buildTooltipForDropdown` * Replaced incorrect uses of `@mixes` JSDoc annotation (on mixin extensions) with `@augments Blockly.Block`. * Added Blockly.Extensions.buildTooltipWithFieldValue() extension helper. * Workspace isDraggable * JSONify simple list blocks * JSONify variable blocks * Initial text block, with a mixin to generate quote image fields. (#923) Text block now uses the extension "text_quotes", supported by Blockly.Constants.Text.QUOTE_IMAGE_MIXIN.quoteField_(fieldName), so that each platform can use the best platform appropriate image (size, density, etc.) for the quotes. * Add no-op stub .neighbors() for headless Connection. * Adding tests for logic_ternary block in a new jsunit test framework. * Correcting output of the logic_null block. * extension controls_if => controls_if_mutator. * Renamed extension function constant, and moved variables into the mixin. * Dereference string table references when loading variable fields from JSON. * Moving FieldImage string dereferencing back into Block.interpolate_() (part of jsonInit()). This sets a clear boundary of where dereferencing should happen. Towards this, I've added message dereferencing for other field types here, as well. I've used a pattern of field-type specific helper functions. * Addressing comments. * .utils.replaceMessageReferences(..) now gracefully returns non-string arguments. * Fix a few small errors and rebuild * Call dynamic toolbox generators correctly * cleanup * Fix unit tests, and delete a few that relied on completely undefined behaviour * Fix RTL text inputs * eslintignore more tests * Fix insertion marker highlighting, I think * Make getFlyout public
2017-02-21 12:09:23 -08:00
/**
* Recursively checks whether all statement and value inputs are filled with
* blocks. Also checks all following statement blocks in this stack.
* @param {boolean=} opt_shadowBlocksAreFilled An optional argument controlling
* whether shadow blocks are counted as filled. Defaults to true.
* @return {boolean} True if all inputs are filled, false otherwise.
*/
Blockly.Block.prototype.allInputsFilled = function(opt_shadowBlocksAreFilled) {
// Account for the shadow block filledness toggle.
if (opt_shadowBlocksAreFilled === undefined) {
opt_shadowBlocksAreFilled = true;
}
if (!opt_shadowBlocksAreFilled && this.isShadow()) {
return false;
}
// Recursively check each input block of the current block.
for (var i = 0, input; input = this.inputList[i]; i++) {
if (!input.connection) {
continue;
}
var target = input.connection.targetBlock();
if (!target || !target.allInputsFilled(opt_shadowBlocksAreFilled)) {
return false;
}
}
// Recursively check the next block after the current block.
var next = this.getNextBlock();
if (next) {
return next.allInputsFilled(opt_shadowBlocksAreFilled);
}
return true;
};
/**
* This method returns a string describing this Block in developer terms (type
* name and ID; English only).
*
* Intended to on be used in console logs and errors. If you need a string that
* uses the user's native language (including block text, field values, and
* child blocks), use [toString()]{@link Blockly.Block#toString}.
* @return {string} The description.
*/
Blockly.Block.prototype.toDevString = function() {
var msg = this.type ? '"' + this.type + '" block' : 'Block';
if (this.id) {
msg += ' (id="' + this.id + '")';
}
return msg;
};