mirror of
https://github.com/google/blockly.git
synced 2026-03-12 16:20:12 +01:00
@@ -4,6 +4,7 @@ gulpfile.js
|
||||
/msg/*
|
||||
/core/utils/global.js
|
||||
/tests/blocks/*
|
||||
/tests/themes/*
|
||||
/tests/compile/*
|
||||
/tests/jsunit/*
|
||||
/tests/generators/*
|
||||
@@ -16,3 +17,4 @@ gulpfile.js
|
||||
/appengine/*
|
||||
/externs/*
|
||||
/closure/*
|
||||
/scripts/gulpfiles/*
|
||||
|
||||
@@ -8,7 +8,7 @@ node_js:
|
||||
addons:
|
||||
chrome: stable
|
||||
firefox: latest
|
||||
# TODO (#2114): reenable osx build.
|
||||
# TODO (#2114): re-enable osx build.
|
||||
# - os: osx
|
||||
# node_js: stable
|
||||
# osx_image: xcode8.3
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
# Do not upload these files.
|
||||
.*
|
||||
deploy
|
||||
*.soy
|
||||
static/appengine/
|
||||
static/closure/
|
||||
static/demos/plane/soy/*.jar
|
||||
static/demos/plane/xlf/
|
||||
static/externs/
|
||||
static/i18n/
|
||||
static/msg/json/
|
||||
static/node_modules/
|
||||
static/package/
|
||||
static/theme_scripts/
|
||||
static/typings/
|
||||
*.komodoproject
|
||||
/deploy
|
||||
/static/appengine/
|
||||
/static/closure/
|
||||
/static/demos/plane/soy/*.jar
|
||||
/static/demos/plane/xlf/
|
||||
/static/externs/
|
||||
/static/i18n/
|
||||
/static/msg/json/
|
||||
/static/node_modules/
|
||||
/static/package/
|
||||
/static/theme_scripts/
|
||||
/static/typings/
|
||||
|
||||
static/build.py
|
||||
static/gulpfile.js
|
||||
static/jsconfig.json
|
||||
static/LICENSE
|
||||
static/package-lock.json
|
||||
static/package.json
|
||||
static/README.md
|
||||
/static/build.py
|
||||
/static/gulpfile.js
|
||||
/static/jsconfig.json
|
||||
/static/LICENSE
|
||||
/static/package-lock.json
|
||||
/static/package.json
|
||||
/static/README.md
|
||||
|
||||
@@ -11,12 +11,13 @@ structure:
|
||||
|
||||
blockly/
|
||||
|- app.yaml
|
||||
|- deploy
|
||||
|- index.yaml
|
||||
|- index_redirect.py
|
||||
|- main.py
|
||||
|- README.txt
|
||||
|- requirements.txt
|
||||
|- storage.js
|
||||
|- storage.py
|
||||
|- closure-library/ (Optional)
|
||||
`- static/
|
||||
|- blocks/
|
||||
|- core/
|
||||
@@ -26,7 +27,7 @@ blockly/
|
||||
|- msg/
|
||||
|- tests/
|
||||
|- blockly_compressed.js
|
||||
|- blockly_uncompressed.js (Optional)
|
||||
|- blockly_uncompressed.js
|
||||
|- blocks_compressed.js
|
||||
|- dart_compressed.js
|
||||
|- javascript_compressed.js
|
||||
@@ -34,11 +35,8 @@ blockly/
|
||||
|- php_compressed.js
|
||||
`- python_compressed.js
|
||||
|
||||
Instructions for fetching the optional Closure library may be found here:
|
||||
https://developers.google.com/blockly/guides/modify/web/closure
|
||||
|
||||
Go to https://appengine.google.com/ and create your App Engine application.
|
||||
Modify the 'application' name of app.yaml to your App Engine application name.
|
||||
Modify the 'PROJECT' name in the 'deploy' file to your App Engine application name.
|
||||
|
||||
Finally, upload this directory structure to your App Engine account,
|
||||
wait a minute, then go to http://YOURAPPNAME.appspot.com/
|
||||
then go to http://YOURAPPNAME.appspot.com/
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@ goog.addDependency('../../core/dropdowndiv.js', ['Blockly.DropDownDiv'], ['Block
|
||||
goog.addDependency('../../core/events.js', ['Blockly.Events'], ['Blockly.utils'], {});
|
||||
goog.addDependency('../../core/events_abstract.js', ['Blockly.Events.Abstract'], ['Blockly.Events'], {});
|
||||
goog.addDependency('../../core/extensions.js', ['Blockly.Extensions'], ['Blockly.utils'], {});
|
||||
goog.addDependency('../../core/field.js', ['Blockly.Field'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Gesture', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.style', 'Blockly.utils.userAgent'], {});
|
||||
goog.addDependency('../../core/field.js', ['Blockly.Field'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Gesture', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.style', 'Blockly.utils.userAgent'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/field_angle.js', ['Blockly.FieldAngle'], ['Blockly.Css', 'Blockly.DropDownDiv', 'Blockly.FieldTextInput', 'Blockly.fieldRegistry', 'Blockly.utils.dom', 'Blockly.utils.math', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {});
|
||||
goog.addDependency('../../core/field_checkbox.js', ['Blockly.FieldCheckbox'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.utils.Size', 'Blockly.utils.dom', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/field_colour.js', ['Blockly.FieldColour'], ['Blockly.Css', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.fieldRegistry', 'Blockly.navigation', 'Blockly.utils.IdGenerator', 'Blockly.utils.KeyCodes', 'Blockly.utils.Size', 'Blockly.utils.aria', 'Blockly.utils.colour', 'Blockly.utils.dom', 'Blockly.utils.object'], {});
|
||||
@@ -62,7 +62,7 @@ goog.addDependency('../../core/field_registry.js', ['Blockly.fieldRegistry'], []
|
||||
goog.addDependency('../../core/field_textinput.js', ['Blockly.FieldTextInput'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Field', 'Blockly.Msg', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.KeyCodes', 'Blockly.utils.Size', 'Blockly.utils.aria', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {});
|
||||
goog.addDependency('../../core/field_variable.js', ['Blockly.FieldVariable'], ['Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.FieldDropdown', 'Blockly.Msg', 'Blockly.VariableModel', 'Blockly.Variables', 'Blockly.Xml', 'Blockly.fieldRegistry', 'Blockly.utils', 'Blockly.utils.Size', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/flyout_base.js', ['Blockly.Flyout'], ['Blockly.Block', 'Blockly.Events', 'Blockly.Events.BlockCreate', 'Blockly.Events.VarCreate', 'Blockly.FlyoutCursor', 'Blockly.Gesture', 'Blockly.Marker', 'Blockly.Scrollbar', 'Blockly.Tooltip', 'Blockly.Touch', 'Blockly.WorkspaceSvg', 'Blockly.Xml', 'Blockly.blockRendering', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {});
|
||||
goog.addDependency('../../core/flyout_button.js', ['Blockly.FlyoutButton'], ['Blockly.Css', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {});
|
||||
goog.addDependency('../../core/flyout_button.js', ['Blockly.FlyoutButton'], ['Blockly.Css', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/flyout_dragger.js', ['Blockly.FlyoutDragger'], ['Blockly.WorkspaceDragger', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/flyout_horizontal.js', ['Blockly.HorizontalFlyout'], ['Blockly.Block', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/flyout_vertical.js', ['Blockly.VerticalFlyout'], ['Blockly.Block', 'Blockly.Flyout', 'Blockly.Scrollbar', 'Blockly.WidgetDiv', 'Blockly.utils', 'Blockly.utils.Rect', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {});
|
||||
@@ -72,7 +72,7 @@ goog.addDependency('../../core/grid.js', ['Blockly.Grid'], ['Blockly.utils.dom',
|
||||
goog.addDependency('../../core/icon.js', ['Blockly.Icon'], ['Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.dom'], {});
|
||||
goog.addDependency('../../core/inject.js', ['Blockly.inject'], ['Blockly.BlockDragSurfaceSvg', 'Blockly.Component', 'Blockly.Css', 'Blockly.DropDownDiv', 'Blockly.Events', 'Blockly.Grid', 'Blockly.Msg', 'Blockly.Options', 'Blockly.ScrollbarPair', 'Blockly.Tooltip', 'Blockly.WorkspaceDragSurfaceSvg', 'Blockly.WorkspaceSvg', 'Blockly.user.keyMap', 'Blockly.utils', 'Blockly.utils.dom', 'Blockly.utils.userAgent'], {});
|
||||
goog.addDependency('../../core/input.js', ['Blockly.Input'], ['Blockly.Connection', 'Blockly.FieldLabel'], {});
|
||||
goog.addDependency('../../core/insertion_marker_manager.js', ['Blockly.InsertionMarkerManager'], ['Blockly.Events', 'Blockly.blockAnimations'], {});
|
||||
goog.addDependency('../../core/insertion_marker_manager.js', ['Blockly.InsertionMarkerManager'], ['Blockly.Events', 'Blockly.blockAnimations'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/keyboard_nav/action.js', ['Blockly.Action'], [], {});
|
||||
goog.addDependency('../../core/keyboard_nav/ast_node.js', ['Blockly.ASTNode'], ['Blockly.utils.Coordinate'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/keyboard_nav/basic_cursor.js', ['Blockly.BasicCursor'], ['Blockly.ASTNode', 'Blockly.Cursor'], {'lang': 'es5'});
|
||||
@@ -97,8 +97,8 @@ goog.addDependency('../../core/renderers/common/i_path_object.js', ['Blockly.blo
|
||||
goog.addDependency('../../core/renderers/common/info.js', ['Blockly.blockRendering.RenderInfo'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.ExternalValueInput', 'Blockly.blockRendering.Hat', 'Blockly.blockRendering.InRowSpacer', 'Blockly.blockRendering.InlineInput', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.NextConnection', 'Blockly.blockRendering.OutputConnection', 'Blockly.blockRendering.PreviousConnection', 'Blockly.blockRendering.RoundCorner', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.SquareCorner', 'Blockly.blockRendering.StatementInput', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types'], {});
|
||||
goog.addDependency('../../core/renderers/common/marker_svg.js', ['Blockly.blockRendering.MarkerSvg'], ['Blockly.ASTNode'], {});
|
||||
goog.addDependency('../../core/renderers/common/path_object.js', ['Blockly.blockRendering.PathObject'], ['Blockly.Theme', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.IPathObject', 'Blockly.utils.dom'], {});
|
||||
goog.addDependency('../../core/renderers/common/renderer.js', ['Blockly.blockRendering.Renderer'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.IPathObject', 'Blockly.blockRendering.MarkerSvg', 'Blockly.blockRendering.PathObject', 'Blockly.blockRendering.RenderInfo'], {});
|
||||
goog.addDependency('../../core/renderers/geras/constants.js', ['Blockly.geras.ConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/renderers/common/renderer.js', ['Blockly.blockRendering.Renderer'], ['Blockly.InsertionMarkerManager', 'Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Drawer', 'Blockly.blockRendering.IPathObject', 'Blockly.blockRendering.MarkerSvg', 'Blockly.blockRendering.PathObject', 'Blockly.blockRendering.RenderInfo'], {});
|
||||
goog.addDependency('../../core/renderers/geras/constants.js', ['Blockly.geras.ConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.object'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/renderers/geras/drawer.js', ['Blockly.geras.Drawer'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.blockRendering.Drawer', 'Blockly.geras.Highlighter', 'Blockly.geras.RenderInfo', 'Blockly.utils.object', 'Blockly.utils.svgPaths'], {});
|
||||
goog.addDependency('../../core/renderers/geras/highlight_constants.js', ['Blockly.geras.HighlightConstantProvider'], ['Blockly.blockRendering.ConstantProvider', 'Blockly.utils.svgPaths'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/renderers/geras/highlighter.js', ['Blockly.geras.Highlighter'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.InputRow', 'Blockly.blockRendering.Measurable', 'Blockly.blockRendering.RenderInfo', 'Blockly.blockRendering.Row', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.blockRendering.Types', 'Blockly.utils.svgPaths'], {});
|
||||
@@ -126,12 +126,12 @@ goog.addDependency('../../core/renderers/zelos/measurables/inputs.js', ['Blockly
|
||||
goog.addDependency('../../core/renderers/zelos/measurables/row_elements.js', ['Blockly.zelos.RightConnectionShape'], ['Blockly.blockRendering.Measurable', 'Blockly.blockRendering.Types', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/renderers/zelos/measurables/rows.js', ['Blockly.zelos.BottomRow', 'Blockly.zelos.TopRow'], ['Blockly.blockRendering.BottomRow', 'Blockly.blockRendering.SpacerRow', 'Blockly.blockRendering.TopRow', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/renderers/zelos/path_object.js', ['Blockly.zelos.PathObject'], ['Blockly.blockRendering.PathObject', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider'], {});
|
||||
goog.addDependency('../../core/renderers/zelos/renderer.js', ['Blockly.zelos.Renderer'], ['Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider', 'Blockly.zelos.Drawer', 'Blockly.zelos.MarkerSvg', 'Blockly.zelos.PathObject', 'Blockly.zelos.RenderInfo'], {});
|
||||
goog.addDependency('../../core/renderers/zelos/renderer.js', ['Blockly.zelos.Renderer'], ['Blockly.InsertionMarkerManager', 'Blockly.blockRendering', 'Blockly.blockRendering.Renderer', 'Blockly.utils.object', 'Blockly.zelos.ConstantProvider', 'Blockly.zelos.Drawer', 'Blockly.zelos.MarkerSvg', 'Blockly.zelos.PathObject', 'Blockly.zelos.RenderInfo'], {});
|
||||
goog.addDependency('../../core/requires.js', ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldLabelSerializable', 'Blockly.FieldMultilineInput', 'Blockly.FieldNumber', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.FlyoutButton', 'Blockly.Generator', 'Blockly.HorizontalFlyout', 'Blockly.Mutator', 'Blockly.Themes.Classic', 'Blockly.Themes.Dark', 'Blockly.Themes.Deuteranopia', 'Blockly.Themes.HighContrast', 'Blockly.Themes.Tritanopia', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.VerticalFlyout', 'Blockly.Warning', 'Blockly.ZoomControls', 'Blockly.geras.Renderer', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer'], {});
|
||||
goog.addDependency('../../core/scrollbar.js', ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['Blockly.Touch', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.dom'], {});
|
||||
goog.addDependency('../../core/theme.js', ['Blockly.Theme'], ['Blockly.utils', 'Blockly.utils.colour'], {});
|
||||
goog.addDependency('../../core/theme.js', ['Blockly.Theme'], ['Blockly.utils', 'Blockly.utils.colour', 'Blockly.utils.object'], {});
|
||||
goog.addDependency('../../core/theme/classic.js', ['Blockly.Themes.Classic'], ['Blockly.Theme'], {});
|
||||
goog.addDependency('../../core/theme/dark.js', ['Blockly.Themes.Dark'], ['Blockly.Css', 'Blockly.Theme'], {'lang': 'es5'});
|
||||
goog.addDependency('../../core/theme/dark.js', ['Blockly.Themes.Dark'], ['Blockly.Theme'], {});
|
||||
goog.addDependency('../../core/theme/deuteranopia.js', ['Blockly.Themes.Deuteranopia'], ['Blockly.Theme'], {});
|
||||
goog.addDependency('../../core/theme/highcontrast.js', ['Blockly.Themes.HighContrast'], ['Blockly.Theme'], {});
|
||||
goog.addDependency('../../core/theme/modern.js', ['Blockly.Themes.Modern'], ['Blockly.Theme'], {});
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -237,7 +226,8 @@ Blockly.Blocks['lists_create_with'] = {
|
||||
// Add new inputs.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
if (!this.getInput('ADD' + i)) {
|
||||
var input = this.appendValueInput('ADD' + i);
|
||||
var input = this.appendValueInput('ADD' + i)
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
if (i == 0) {
|
||||
input.appendField(Blockly.Msg['LISTS_CREATE_WITH_INPUT_WITH']);
|
||||
}
|
||||
@@ -411,7 +401,7 @@ Blockly.Blocks['lists_getIndex'] = {
|
||||
/**
|
||||
* Create XML to represent whether the block is a statement or a value.
|
||||
* Also represent whether there is an 'AT' input.
|
||||
* @return {Element} XML storage element.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function() {
|
||||
@@ -575,7 +565,7 @@ Blockly.Blocks['lists_setIndex'] = {
|
||||
},
|
||||
/**
|
||||
* Create XML to represent whether there is an 'AT' input.
|
||||
* @return {Element} XML storage element.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function() {
|
||||
@@ -673,7 +663,7 @@ Blockly.Blocks['lists_getSublist'] = {
|
||||
},
|
||||
/**
|
||||
* Create XML to represent whether there are 'AT' inputs.
|
||||
* @return {Element} XML storage element.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function() {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -338,24 +327,28 @@ Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN = {
|
||||
/**
|
||||
* Called whenever anything on the workspace changes.
|
||||
* Add warning if this flow block is not nested inside a loop.
|
||||
* @param {!Blockly.Events.Abstract} _e Change event.
|
||||
* @param {!Blockly.Events.Abstract} e Change event.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
onchange: function(_e) {
|
||||
if (!this.workspace.isDragging || this.workspace.isDragging()) {
|
||||
return; // Don't change state at the start of a drag.
|
||||
onchange: function(e) {
|
||||
// Don't change state if:
|
||||
// * It's at the start of a drag.
|
||||
// * It's not a move event.
|
||||
// * Or the moving block is not this block.
|
||||
if (!this.workspace.isDragging || this.workspace.isDragging() ||
|
||||
e.type != Blockly.Events.BLOCK_MOVE || e.blockId != this.id) {
|
||||
return;
|
||||
}
|
||||
if (Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN
|
||||
.getSurroundLoop(this)) {
|
||||
this.setWarningText(null);
|
||||
if (!this.isInFlyout) {
|
||||
this.setEnabled(true);
|
||||
}
|
||||
} else {
|
||||
this.setWarningText(Blockly.Msg['CONTROLS_FLOW_STATEMENTS_WARNING']);
|
||||
if (!this.isInFlyout && !this.getInheritedDisabled()) {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
var enabled = Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN
|
||||
.getSurroundLoop(this);
|
||||
this.setWarningText(enabled ? null :
|
||||
Blockly.Msg['CONTROLS_FLOW_STATEMENTS_WARNING']);
|
||||
if (!this.isInFlyout) {
|
||||
var group = Blockly.Events.getGroup();
|
||||
// Makes it so the move and the disable event get undone together.
|
||||
Blockly.Events.setGroup(e.group);
|
||||
this.setEnabled(enabled);
|
||||
Blockly.Events.setGroup(group);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -457,7 +446,7 @@ Blockly.Extensions.register('math_op_tooltip',
|
||||
Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
|
||||
/**
|
||||
* Create XML to represent whether the 'divisorInput' should be present.
|
||||
* @return {Element} XML storage element.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function() {
|
||||
@@ -498,7 +487,7 @@ Blockly.Constants.Math.IS_DIVISIBLEBY_MUTATOR_MIXIN = {
|
||||
/**
|
||||
* 'math_is_divisibleby_mutator' extension to the 'math_property' block that
|
||||
* can update the block shape (add/remove divisor input) based on whether
|
||||
* property is "divisble by".
|
||||
* property is "divisible by".
|
||||
* @this {Blockly.Block}
|
||||
* @package
|
||||
*/
|
||||
@@ -542,7 +531,7 @@ Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN = {
|
||||
},
|
||||
/**
|
||||
* Create XML to represent the output type.
|
||||
* @return {Element} XML storage element.
|
||||
* @return {!Element} XML storage element.
|
||||
* @this {Blockly.Block}
|
||||
*/
|
||||
mutationToDom: function() {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -542,11 +531,14 @@ Blockly.Blocks['procedures_mutatorarg'] = {
|
||||
var workspace = sourceBlock.workspace.targetWorkspace ||
|
||||
sourceBlock.workspace;
|
||||
var blocks = workspace.getAllBlocks(false);
|
||||
var caselessName = varName.toLowerCase();
|
||||
for (var i = 0; i < blocks.length; i++) {
|
||||
if (blocks[i].id == this.getSourceBlock().id) {
|
||||
continue;
|
||||
}
|
||||
if (blocks[i].getFieldValue('NAME') == varName) {
|
||||
// Other blocks values may not be set yet when this is loaded.
|
||||
var otherVar = blocks[i].getFieldValue('NAME');
|
||||
if (otherVar && otherVar.toLowerCase() == caselessName) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -898,7 +890,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
|
||||
// in most cases the old group should be ''
|
||||
var oldGroup = Blockly.Events.getGroup();
|
||||
if (oldGroup) {
|
||||
// This should only be possible programatically and may indicate a problem
|
||||
// This should only be possible programmatically and may indicate a problem
|
||||
// with event grouping. If you see this message please investigate. If the
|
||||
// use ends up being valid we may need to reorder events in the undo stack.
|
||||
console.log('Saw an existing group while responding to a definition change');
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -296,7 +285,7 @@ Blockly.Blocks['text_getSubstring'] = {
|
||||
},
|
||||
/**
|
||||
* Create or delete an input for a numeric index.
|
||||
* This block has two such inputs, independant of each other.
|
||||
* This block has two such inputs, independent of each other.
|
||||
* @param {number} n Specify first or second input (1 or 2).
|
||||
* @param {boolean} isAt True if the input should exist.
|
||||
* @private
|
||||
@@ -784,7 +773,8 @@ Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN = {
|
||||
// Add new inputs.
|
||||
for (var i = 0; i < this.itemCount_; i++) {
|
||||
if (!this.getInput('ADD' + i)) {
|
||||
var input = this.appendValueInput('ADD' + i);
|
||||
var input = this.appendValueInput('ADD' + i)
|
||||
.setAlign(Blockly.ALIGN_RIGHT);
|
||||
if (i == 0) {
|
||||
input.appendField(Blockly.Msg['TEXT_JOIN_TITLE_CREATEWITH']);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,30 +10,30 @@ Blockly.defineBlocksWithJsonArray([{type:"lists_create_empty",message0:"%{BKY_LI
|
||||
message0:"%{BKY_LISTS_REVERSE_MESSAGE0}",args0:[{type:"input_value",name:"LIST",check:"Array"}],output:"Array",inputsInline:!0,style:"list_blocks",tooltip:"%{BKY_LISTS_REVERSE_TOOLTIP}",helpUrl:"%{BKY_LISTS_REVERSE_HELPURL}"},{type:"lists_isEmpty",message0:"%{BKY_LISTS_ISEMPTY_TITLE}",args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",style:"list_blocks",tooltip:"%{BKY_LISTS_ISEMPTY_TOOLTIP}",helpUrl:"%{BKY_LISTS_ISEMPTY_HELPURL}"},{type:"lists_length",message0:"%{BKY_LISTS_LENGTH_TITLE}",
|
||||
args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",style:"list_blocks",tooltip:"%{BKY_LISTS_LENGTH_TOOLTIP}",helpUrl:"%{BKY_LISTS_LENGTH_HELPURL}"}]);
|
||||
Blockly.Blocks.lists_create_with={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL);this.setStyle("list_blocks");this.itemCount_=3;this.updateShape_();this.setOutput(!0,"Array");this.setMutator(new Blockly.Mutator(["lists_create_with_item"]));this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),
|
||||
10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,e=0;e<this.itemCount_;e++){var d=a.newBlock("lists_create_with_item");d.initSvg();c.connect(d.previousConnection);c=d.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;
|
||||
10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;
|
||||
c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||
|
||||
this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++}};
|
||||
this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a).setAlign(Blockly.ALIGN_RIGHT);0==a&&b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++}};
|
||||
Blockly.Blocks.lists_create_with_container={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD);this.appendStatementInput("STACK");this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP);this.contextMenu=!1}};
|
||||
Blockly.Blocks.lists_create_with_item={init:function(){this.setStyle("list_blocks");this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP);this.contextMenu=!1}};
|
||||
Blockly.Blocks.lists_indexOf={init:function(){var a=[[Blockly.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[Blockly.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL);this.setStyle("list_blocks");this.setOutput(!0,"Number");this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST);this.appendValueInput("FIND").appendField(new Blockly.FieldDropdown(a),"END");this.setInputsInline(!0);var b=this;this.setTooltip(function(){return Blockly.Msg.LISTS_INDEX_OF_TOOLTIP.replace("%1",
|
||||
b.workspace.options.oneBasedIndex?"0":"-1")})}};
|
||||
Blockly.Blocks.lists_getIndex={init:function(){var a=[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"],[Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[Blockly.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL);this.setStyle("list_blocks");
|
||||
a=new Blockly.FieldDropdown(a,function(a){a="REMOVE"==a;this.getSourceBlock().updateStatement_(a)});this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST);this.appendDummyInput().appendField(a,"MODE").appendField("","SPACE");this.appendDummyInput("AT");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL);this.setInputsInline(!0);this.setOutput(!0);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=
|
||||
b.getFieldValue("MODE"),e=b.getFieldValue("WHERE"),d="";switch(a+" "+e){case "GET FROM_START":case "GET FROM_END":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case "GET FIRST":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case "GET LAST":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case "GET RANDOM":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case "GET_REMOVE FROM_START":case "GET_REMOVE FROM_END":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case "GET_REMOVE FIRST":d=
|
||||
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case "GET_REMOVE LAST":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case "GET_REMOVE RANDOM":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case "REMOVE FROM_START":case "REMOVE FROM_END":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case "REMOVE FIRST":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case "REMOVE LAST":d=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case "REMOVE RANDOM":d=
|
||||
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}if("FROM_START"==e||"FROM_END"==e)d+=" "+("FROM_START"==e?Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP:Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return d})},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("statement",!this.outputConnection);var b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){var b=
|
||||
b.getFieldValue("MODE"),d=b.getFieldValue("WHERE"),e="";switch(a+" "+d){case "GET FROM_START":case "GET FROM_END":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM;break;case "GET FIRST":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST;break;case "GET LAST":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST;break;case "GET RANDOM":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM;break;case "GET_REMOVE FROM_START":case "GET_REMOVE FROM_END":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM;break;case "GET_REMOVE FIRST":e=
|
||||
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST;break;case "GET_REMOVE LAST":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST;break;case "GET_REMOVE RANDOM":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM;break;case "REMOVE FROM_START":case "REMOVE FROM_END":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM;break;case "REMOVE FIRST":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST;break;case "REMOVE LAST":e=Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST;break;case "REMOVE RANDOM":e=
|
||||
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM}if("FROM_START"==d||"FROM_END"==d)e+=" "+("FROM_START"==d?Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP:Blockly.Msg.LISTS_INDEX_FROM_END_TOOLTIP).replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return e})},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("statement",!this.outputConnection);var b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){var b=
|
||||
"true"==a.getAttribute("statement");this.updateStatement_(b);a="false"!=a.getAttribute("at");this.updateAt_(a)},updateStatement_:function(a){a!=!this.outputConnection&&(this.unplug(!0,!0),a?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(a){this.removeInput("AT");this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&
|
||||
this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var c="FROM_START"==b||"FROM_END"==b;if(c!=a){var d=this.getSourceBlock();d.updateAt_(c);d.setFieldValue(b,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var c="FROM_START"==b||"FROM_END"==b;if(c!=a){var e=this.getSourceBlock();e.updateAt_(c);e.setFieldValue(b,"WHERE");return null}});this.getInput("AT").appendField(b,"WHERE");Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
Blockly.Blocks.lists_setIndex={init:function(){var a=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"],[Blockly.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]];this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL);this.setStyle("list_blocks");this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST);
|
||||
this.appendDummyInput().appendField(new Blockly.FieldDropdown(a),"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE"),e=b.getFieldValue("WHERE"),d="";switch(a+" "+e){case "SET FROM_START":case "SET FROM_END":d=
|
||||
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case "SET FIRST":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case "SET LAST":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case "SET RANDOM":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case "INSERT FROM_START":case "INSERT FROM_END":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case "INSERT FIRST":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case "INSERT LAST":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;
|
||||
break;case "INSERT RANDOM":d=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}if("FROM_START"==e||"FROM_END"==e)d+=" "+Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return d})},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation"),b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");
|
||||
this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var c="FROM_START"==b||"FROM_END"==b;if(c!=a){var d=this.getSourceBlock();d.updateAt_(c);d.setFieldValue(b,"WHERE");return null}});this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL",
|
||||
this.appendDummyInput().appendField(new Blockly.FieldDropdown(a),"MODE").appendField("","SPACE");this.appendDummyInput("AT");this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP);this.updateAt_(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE"),d=b.getFieldValue("WHERE"),e="";switch(a+" "+d){case "SET FROM_START":case "SET FROM_END":e=
|
||||
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM;break;case "SET FIRST":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FIRST;break;case "SET LAST":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST;break;case "SET RANDOM":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM;break;case "INSERT FROM_START":case "INSERT FROM_END":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FROM;break;case "INSERT FIRST":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_FIRST;break;case "INSERT LAST":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_LAST;
|
||||
break;case "INSERT RANDOM":e=Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_INSERT_RANDOM}if("FROM_START"==d||"FROM_END"==d)e+=" "+Blockly.Msg.LISTS_INDEX_FROM_START_TOOLTIP.replace("%1",b.workspace.options.oneBasedIndex?"#1":"#0");return e})},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation"),b=this.getInput("AT").type==Blockly.INPUT_VALUE;a.setAttribute("at",b);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT");
|
||||
this.removeInput("ORDINAL",!0);a?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var b=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(b){var c="FROM_START"==b||"FROM_END"==b;if(c!=a){var e=this.getSourceBlock();e.updateAt_(c);e.setFieldValue(b,"WHERE");return null}});this.moveInputBefore("AT","TO");this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL",
|
||||
"TO");this.getInput("AT").appendField(b,"WHERE")}};
|
||||
Blockly.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL);this.setStyle("list_blocks");
|
||||
this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL);this.setInputsInline(!0);this.setOutput(!0,"Array");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation"),
|
||||
b=this.getInput("AT1").type==Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):
|
||||
this.appendDummyInput("AT"+a);var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var d="FROM_START"==c||"FROM_END"==c;if(d!=b){var e=this.getSourceBlock();e.updateAt_(a,d);e.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"));Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
this.appendDummyInput("AT"+a);var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var d=this.getSourceBlock();d.updateAt_(a,e);d.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2"));Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}};
|
||||
Blockly.Blocks.lists_sort={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_SORT_TITLE,args0:[{type:"field_dropdown",name:"TYPE",options:[[Blockly.Msg.LISTS_SORT_TYPE_NUMERIC,"NUMERIC"],[Blockly.Msg.LISTS_SORT_TYPE_TEXT,"TEXT"],[Blockly.Msg.LISTS_SORT_TYPE_IGNORECASE,"IGNORE_CASE"]]},{type:"field_dropdown",name:"DIRECTION",options:[[Blockly.Msg.LISTS_SORT_ORDER_ASCENDING,"1"],[Blockly.Msg.LISTS_SORT_ORDER_DESCENDING,"-1"]]},{type:"input_value",name:"LIST",check:"Array"}],output:"Array",style:"list_blocks",
|
||||
tooltip:Blockly.Msg.LISTS_SORT_TOOLTIP,helpUrl:Blockly.Msg.LISTS_SORT_HELPURL})}};
|
||||
Blockly.Blocks.lists_split={init:function(){var a=this,b=new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(b){a.updateType_(b)});this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL);this.setStyle("list_blocks");this.appendValueInput("INPUT").setCheck("String").appendField(b,"MODE");this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER);this.setInputsInline(!0);this.setOutput(!0,
|
||||
@@ -49,16 +49,16 @@ Blockly.defineBlocksWithJsonArray([{type:"controls_if_if",message0:"%{BKY_CONTRO
|
||||
enableContextMenu:!1,style:"logic_blocks",tooltip:"%{BKY_CONTROLS_IF_ELSE_TOOLTIP}"}]);Blockly.Constants.Logic.TOOLTIPS_BY_OP={EQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}",NEQ:"%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}",LT:"%{BKY_LOGIC_COMPARE_TOOLTIP_LT}",LTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}",GT:"%{BKY_LOGIC_COMPARE_TOOLTIP_GT}",GTE:"%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}",AND:"%{BKY_LOGIC_OPERATION_TOOLTIP_AND}",OR:"%{BKY_LOGIC_OPERATION_TOOLTIP_OR}"};
|
||||
Blockly.Extensions.register("logic_op_tooltip",Blockly.Extensions.buildTooltipForDropdown("OP",Blockly.Constants.Logic.TOOLTIPS_BY_OP));
|
||||
Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN={elseifCount_:0,elseCount_:0,suppressPrefixSuffix:!0,mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=Blockly.utils.xml.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;this.rebuildShape_()},
|
||||
decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,e=1;e<=this.elseifCount_;e++){var d=a.newBlock("controls_if_elseif");d.initSvg();c.connect(d.previousConnection);c=d.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;for(var b=[null],c=[null],e=null;a;){switch(a.type){case "controls_if_elseif":this.elseifCount_++;
|
||||
b.push(a.valueConnection_);c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;e=a.statementConnection_;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,e)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),e=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;
|
||||
a.statementConnection_=e&&e.connection.targetConnection;b++;break;case "controls_if_else":e=this.getInput("ELSE");a.statementConnection_=e&&e.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}},rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(var e=1;this.getInput("IF"+e);){var d=this.getInput("IF"+e),f=this.getInput("DO"+
|
||||
e);a.push(d.connection.targetConnection);b.push(f.connection.targetConnection);e++}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
|
||||
this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(a,b,c){for(var e=1;e<=this.elseifCount_;e++)Blockly.Mutator.reconnect(a[e],this,"IF"+e),Blockly.Mutator.reconnect(b[e],this,"DO"+e);Blockly.Mutator.reconnect(c,this,"ELSE")}};Blockly.Extensions.registerMutator("controls_if_mutator",Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]);
|
||||
decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){a=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;for(var b=[null],c=[null],d=null;a;){switch(a.type){case "controls_if_elseif":this.elseifCount_++;
|
||||
b.push(a.valueConnection_);c.push(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=a.statementConnection_;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}this.updateShape_();this.reconnectChildBlocks_(b,c,d)},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;
|
||||
a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&d.connection.targetConnection;break;default:throw TypeError("Unknown block type: "+a.type);}a=a.nextConnection&&a.nextConnection.targetBlock()}},rebuildShape_:function(){var a=[null],b=[null],c=null;this.getInput("ELSE")&&(c=this.getInput("ELSE").connection.targetConnection);for(var d=1;this.getInput("IF"+d);){var e=this.getInput("IF"+d),f=this.getInput("DO"+
|
||||
d);a.push(e.connection.targetConnection);b.push(f.connection.targetConnection);d++}this.updateShape_();this.reconnectChildBlocks_(a,b,c)},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
|
||||
this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},reconnectChildBlocks_:function(a,b,c){for(var d=1;d<=this.elseifCount_;d++)Blockly.Mutator.reconnect(a[d],this,"IF"+d),Blockly.Mutator.reconnect(b[d],this,"DO"+d);Blockly.Mutator.reconnect(c,this,"ELSE")}};Blockly.Extensions.registerMutator("controls_if_mutator",Blockly.Constants.Logic.CONTROLS_IF_MUTATOR_MIXIN,null,["controls_if_elseif","controls_if_else"]);
|
||||
Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION=function(){this.setTooltip(function(){if(this.elseifCount_||this.elseCount_){if(!this.elseifCount_&&this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;if(this.elseifCount_&&!this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;if(this.elseifCount_&&this.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_4}else return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;return""}.bind(this))};Blockly.Extensions.register("controls_if_tooltip",Blockly.Constants.Logic.CONTROLS_IF_TOOLTIP_EXTENSION);
|
||||
Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN={onchange:function(a){this.prevBlocks_||(this.prevBlocks_=[null,null]);var b=this.getInputTargetBlock("A"),c=this.getInputTargetBlock("B");b&&c&&!b.outputConnection.checkType(c.outputConnection)&&(Blockly.Events.setGroup(a.group),a=this.prevBlocks_[0],a!==b&&(b.unplug(),!a||a.isDisposed()||a.isShadow()||this.getInput("A").connection.connect(a.outputConnection)),b=this.prevBlocks_[1],b!==c&&(c.unplug(),!b||b.isDisposed()||b.isShadow()||this.getInput("B").connection.connect(b.outputConnection)),
|
||||
this.bumpNeighbours(),Blockly.Events.setGroup(!1));this.prevBlocks_[0]=this.getInputTargetBlock("A");this.prevBlocks_[1]=this.getInputTargetBlock("B")}};Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION=function(){this.mixin(Blockly.Constants.Logic.LOGIC_COMPARE_ONCHANGE_MIXIN)};Blockly.Extensions.register("logic_compare",Blockly.Constants.Logic.LOGIC_COMPARE_EXTENSION);
|
||||
Blockly.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN={prevParentConnection_:null,onchange:function(a){var b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),e=this.outputConnection.targetConnection;if((b||c)&&e)for(var d=0;2>d;d++){var f=1==d?b:c;f&&!f.outputConnection.checkType(e)&&(Blockly.Events.setGroup(a.group),e===this.prevParentConnection_?(this.unplug(),e.getSourceBlock().bumpNeighbours()):(f.unplug(),f.bumpNeighbours()),Blockly.Events.setGroup(!1))}this.prevParentConnection_=
|
||||
e}};Blockly.Extensions.registerMixin("logic_ternary",Blockly.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN);Blockly.Blocks.loops={};Blockly.Constants.Loops={};Blockly.Constants.Loops.HUE=120;
|
||||
Blockly.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN={prevParentConnection_:null,onchange:function(a){var b=this.getInputTargetBlock("THEN"),c=this.getInputTargetBlock("ELSE"),d=this.outputConnection.targetConnection;if((b||c)&&d)for(var e=0;2>e;e++){var f=1==e?b:c;f&&!f.outputConnection.checkType(d)&&(Blockly.Events.setGroup(a.group),d===this.prevParentConnection_?(this.unplug(),d.getSourceBlock().bumpNeighbours()):(f.unplug(),f.bumpNeighbours()),Blockly.Events.setGroup(!1))}this.prevParentConnection_=
|
||||
d}};Blockly.Extensions.registerMixin("logic_ternary",Blockly.Constants.Logic.LOGIC_TERNARY_ONCHANGE_MIXIN);Blockly.Blocks.loops={};Blockly.Constants.Loops={};Blockly.Constants.Loops.HUE=120;
|
||||
Blockly.defineBlocksWithJsonArray([{type:"controls_repeat_ext",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"input_value",name:"TIMES",check:"Number"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_repeat",message0:"%{BKY_CONTROLS_REPEAT_TITLE}",args0:[{type:"field_number",name:"TIMES",value:10,
|
||||
min:0,precision:1}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",tooltip:"%{BKY_CONTROLS_REPEAT_TOOLTIP}",helpUrl:"%{BKY_CONTROLS_REPEAT_HELPURL}"},{type:"controls_whileUntil",message0:"%1 %2",args0:[{type:"field_dropdown",name:"MODE",options:[["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}","WHILE"],["%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}","UNTIL"]]},{type:"input_value",name:"BOOL",check:"Boolean"}],
|
||||
message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_WHILEUNTIL_HELPURL}",extensions:["controls_whileUntil_tooltip"]},{type:"controls_for",message0:"%{BKY_CONTROLS_FOR_TITLE}",args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",
|
||||
@@ -66,10 +66,10 @@ check:"Number",align:"RIGHT"}],message1:"%{BKY_CONTROLS_REPEAT_INPUT_DO} %1",arg
|
||||
args1:[{type:"input_statement",name:"DO"}],previousStatement:null,nextStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FOREACH_HELPURL}",extensions:["contextMenu_newGetVariableBlock","controls_forEach_tooltip"]},{type:"controls_flow_statements",message0:"%1",args0:[{type:"field_dropdown",name:"FLOW",options:[["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}","BREAK"],["%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}","CONTINUE"]]}],previousStatement:null,style:"loop_blocks",helpUrl:"%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}",
|
||||
extensions:["controls_flow_tooltip","controls_flow_in_loop_check"]}]);Blockly.Constants.Loops.WHILE_UNTIL_TOOLTIPS={WHILE:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}",UNTIL:"%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}"};Blockly.Extensions.register("controls_whileUntil_tooltip",Blockly.Extensions.buildTooltipForDropdown("MODE",Blockly.Constants.Loops.WHILE_UNTIL_TOOLTIPS));Blockly.Constants.Loops.BREAK_CONTINUE_TOOLTIPS={BREAK:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}",CONTINUE:"%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}"};
|
||||
Blockly.Extensions.register("controls_flow_tooltip",Blockly.Extensions.buildTooltipForDropdown("FLOW",Blockly.Constants.Loops.BREAK_CONTINUE_TOOLTIPS));
|
||||
Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!=c){var e={enabled:!0};e.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=Blockly.Variables.generateVariableFieldDom(b);c=Blockly.utils.xml.createElement("block");c.setAttribute("type","variables_get");c.appendChild(b);e.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(e)}}}};
|
||||
Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getField("VAR").getVariable(),c=b.name;if(!this.isCollapsed()&&null!=c){var d={enabled:!0};d.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);b=Blockly.Variables.generateVariableFieldDom(b);c=Blockly.utils.xml.createElement("block");c.setAttribute("type","variables_get");c.appendChild(b);d.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(d)}}}};
|
||||
Blockly.Extensions.registerMixin("contextMenu_newGetVariableBlock",Blockly.Constants.Loops.CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN);Blockly.Extensions.register("controls_for_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOR_TOOLTIP}","VAR"));Blockly.Extensions.register("controls_forEach_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_CONTROLS_FOREACH_TOOLTIP}","VAR"));
|
||||
Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"],suppressPrefixSuffix:!0,getSurroundLoop:function(a){do{if(-1!=Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.indexOf(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){this.workspace.isDragging&&!this.workspace.isDragging()&&(Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(this)?
|
||||
(this.setWarningText(null),this.isInFlyout||this.setEnabled(!0)):(this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING),this.isInFlyout||this.getInheritedDisabled()||this.setEnabled(!1)))}};Blockly.Extensions.registerMixin("controls_flow_in_loop_check",Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);Blockly.Blocks.math={};Blockly.Constants.Math={};Blockly.Constants.Math.HUE=230;
|
||||
Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN={LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"],suppressPrefixSuffix:!0,getSurroundLoop:function(a){do{if(-1!=Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.LOOP_TYPES.indexOf(a.type))return a;a=a.getSurroundParent()}while(a);return null},onchange:function(a){if(this.workspace.isDragging&&!this.workspace.isDragging()&&a.type==Blockly.Events.BLOCK_MOVE&&a.blockId==this.id){var b=
|
||||
Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN.getSurroundLoop(this);this.setWarningText(b?null:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING);if(!this.isInFlyout){var c=Blockly.Events.getGroup();Blockly.Events.setGroup(a.group);this.setEnabled(b);Blockly.Events.setGroup(c)}}}};Blockly.Extensions.registerMixin("controls_flow_in_loop_check",Blockly.Constants.Loops.CONTROL_FLOW_IN_LOOP_CHECK_MIXIN);Blockly.Blocks.math={};Blockly.Constants.Math={};Blockly.Constants.Math.HUE=230;
|
||||
Blockly.defineBlocksWithJsonArray([{type:"math_number",message0:"%1",args0:[{type:"field_number",name:"NUM",value:0}],output:"Number",helpUrl:"%{BKY_MATH_NUMBER_HELPURL}",style:"math_blocks",tooltip:"%{BKY_MATH_NUMBER_TOOLTIP}",extensions:["parent_tooltip_when_inline"]},{type:"math_arithmetic",message0:"%1 %2 %3",args0:[{type:"input_value",name:"A",check:"Number"},{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_ADDITION_SYMBOL}","ADD"],["%{BKY_MATH_SUBTRACTION_SYMBOL}","MINUS"],["%{BKY_MATH_MULTIPLICATION_SYMBOL}",
|
||||
"MULTIPLY"],["%{BKY_MATH_DIVISION_SYMBOL}","DIVIDE"],["%{BKY_MATH_POWER_SYMBOL}","POWER"]]},{type:"input_value",name:"B",check:"Number"}],inputsInline:!0,output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_ARITHMETIC_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_single",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_SINGLE_OP_ROOT}","ROOT"],["%{BKY_MATH_SINGLE_OP_ABSOLUTE}","ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]]},
|
||||
{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",helpUrl:"%{BKY_MATH_SINGLE_HELPURL}",extensions:["math_op_tooltip"]},{type:"math_trig",message0:"%1 %2",args0:[{type:"field_dropdown",name:"OP",options:[["%{BKY_MATH_TRIG_SIN}","SIN"],["%{BKY_MATH_TRIG_COS}","COS"],["%{BKY_MATH_TRIG_TAN}","TAN"],["%{BKY_MATH_TRIG_ASIN}","ASIN"],["%{BKY_MATH_TRIG_ACOS}","ACOS"],["%{BKY_MATH_TRIG_ATAN}","ATAN"]]},{type:"input_value",name:"NUM",check:"Number"}],output:"Number",style:"math_blocks",
|
||||
@@ -90,34 +90,34 @@ Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN={updateType_:function(a){"MODE"=
|
||||
Blockly.Extensions.registerMutator("math_modes_of_list_mutator",Blockly.Constants.Math.LIST_MODES_MUTATOR_MIXIN,Blockly.Constants.Math.LIST_MODES_MUTATOR_EXTENSION);Blockly.Blocks.procedures={};
|
||||
Blockly.Blocks.procedures_defnoreturn={init:function(){var a=new Blockly.FieldTextInput("",Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&this.workspace.options.parentWorkspace.options.comments)&&Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);
|
||||
this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=
|
||||
a)},updateParams_:function(){var a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));Blockly.Events.disable();try{this.setFieldValue(a,"PARAMS")}finally{Blockly.Events.enable()}},mutationToDom:function(a){var b=Blockly.utils.xml.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c<this.argumentVarModels_.length;c++){var e=Blockly.utils.xml.createElement("arg"),d=this.argumentVarModels_[c];e.setAttribute("name",
|
||||
d.name);e.setAttribute("varid",d.getId());a&&this.paramIds_&&e.setAttribute("paramId",this.paramIds_[c]);b.appendChild(e)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];this.argumentVarModels_=[];for(var b=0,c;c=a.childNodes[b];b++)if("arg"==c.nodeName.toLowerCase()){var e=c.getAttribute("name");c=c.getAttribute("varid")||c.getAttribute("varId");this.arguments_.push(e);c=Blockly.Variables.getOrCreateVariablePackage(this.workspace,c,
|
||||
e,"");null!=c?this.argumentVarModels_.push(c):console.log("Failed to create a variable with name "+e+", ignoring.")}this.updateParams_();Blockly.Procedures.mutateCallers(this);this.setStatements_("false"!==a.getAttribute("statements"))},decompose:function(a){var b=Blockly.utils.xml.createElement("block");b.setAttribute("type","procedures_mutatorcontainer");var c=Blockly.utils.xml.createElement("statement");c.setAttribute("name","STACK");b.appendChild(c);for(var e=0;e<this.arguments_.length;e++){var d=
|
||||
Blockly.utils.xml.createElement("block");d.setAttribute("type","procedures_mutatorarg");var f=Blockly.utils.xml.createElement("field");f.setAttribute("name","NAME");var g=Blockly.utils.xml.createTextNode(this.arguments_[e]);f.appendChild(g);d.appendChild(f);f=Blockly.utils.xml.createElement("next");d.appendChild(f);c.appendChild(d);c=f}a=Blockly.Xml.domToBlock(b,a);"procedures_defreturn"==this.type?a.setFieldValue(this.hasStatements_,"STATEMENTS"):a.removeInput("STATEMENT_INPUT");Blockly.Procedures.mutateCallers(this);
|
||||
a)},updateParams_:function(){var a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));Blockly.Events.disable();try{this.setFieldValue(a,"PARAMS")}finally{Blockly.Events.enable()}},mutationToDom:function(a){var b=Blockly.utils.xml.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c<this.argumentVarModels_.length;c++){var d=Blockly.utils.xml.createElement("arg"),e=this.argumentVarModels_[c];d.setAttribute("name",
|
||||
e.name);d.setAttribute("varid",e.getId());a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];this.argumentVarModels_=[];for(var b=0,c;c=a.childNodes[b];b++)if("arg"==c.nodeName.toLowerCase()){var d=c.getAttribute("name");c=c.getAttribute("varid")||c.getAttribute("varId");this.arguments_.push(d);c=Blockly.Variables.getOrCreateVariablePackage(this.workspace,c,
|
||||
d,"");null!=c?this.argumentVarModels_.push(c):console.log("Failed to create a variable with name "+d+", ignoring.")}this.updateParams_();Blockly.Procedures.mutateCallers(this);this.setStatements_("false"!==a.getAttribute("statements"))},decompose:function(a){var b=Blockly.utils.xml.createElement("block");b.setAttribute("type","procedures_mutatorcontainer");var c=Blockly.utils.xml.createElement("statement");c.setAttribute("name","STACK");b.appendChild(c);for(var d=0;d<this.arguments_.length;d++){var e=
|
||||
Blockly.utils.xml.createElement("block");e.setAttribute("type","procedures_mutatorarg");var f=Blockly.utils.xml.createElement("field");f.setAttribute("name","NAME");var g=Blockly.utils.xml.createTextNode(this.arguments_[d]);f.appendChild(g);e.appendChild(f);f=Blockly.utils.xml.createElement("next");e.appendChild(f);c.appendChild(e);c=f}a=Blockly.Xml.domToBlock(b,a);"procedures_defreturn"==this.type?a.setFieldValue(this.hasStatements_,"STATEMENTS"):a.removeInput("STATEMENT_INPUT");Blockly.Procedures.mutateCallers(this);
|
||||
return a},compose:function(a){this.arguments_=[];this.paramIds_=[];this.argumentVarModels_=[];for(var b=a.getInputTargetBlock("STACK");b;){var c=b.getFieldValue("NAME");this.arguments_.push(c);c=this.workspace.getVariable(c,"");this.argumentVarModels_.push(c);this.paramIds_.push(b.id);b=b.nextConnection&&b.nextConnection.targetBlock()}this.updateParams_();Blockly.Procedures.mutateCallers(this);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"==a,this.hasStatements_!=a))if(a)this.setStatements_(!0),
|
||||
Blockly.Mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null;else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.unplug(),a.bumpNeighbours();this.setStatements_(!1)}},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},getVars:function(){return this.arguments_},getVarModels:function(){return this.argumentVarModels_},renameVarById:function(a,b){var c=this.workspace.getVariableById(a);
|
||||
if(""==c.type){c=c.name;b=this.workspace.getVariableById(b);for(var e=!1,d=0;d<this.argumentVarModels_.length;d++)this.argumentVarModels_[d].getId()==a&&(this.arguments_[d]=b.name,this.argumentVarModels_[d]=b,e=!0);e&&(this.displayRenamedVar_(c,b.name),Blockly.Procedures.mutateCallers(this))}},updateVarName:function(a){for(var b=a.name,c=!1,e=0;e<this.argumentVarModels_.length;e++)if(this.argumentVarModels_[e].getId()==a.getId()){var d=this.arguments_[e];this.arguments_[e]=b;c=!0}c&&(this.displayRenamedVar_(d,
|
||||
b),Blockly.Procedures.mutateCallers(this))},displayRenamedVar_:function(a,b){this.updateParams_();if(this.mutator&&this.mutator.isVisible())for(var c=this.mutator.workspace_.getAllBlocks(!1),e=0,d;d=c[e];e++)"procedures_mutatorarg"==d.type&&Blockly.Names.equals(a,d.getFieldValue("NAME"))&&d.setFieldValue(b,"NAME")},customContextMenu:function(a){if(!this.isInFlyout){var b={enabled:!0},c=this.getFieldValue("NAME");b.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var e=Blockly.utils.xml.createElement("mutation");
|
||||
e.setAttribute("name",c);for(c=0;c<this.arguments_.length;c++){var d=Blockly.utils.xml.createElement("arg");d.setAttribute("name",this.arguments_[c]);e.appendChild(d)}c=Blockly.utils.xml.createElement("block");c.setAttribute("type",this.callType_);c.appendChild(e);b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b);if(!this.isCollapsed())for(c=0;c<this.argumentVarModels_.length;c++)b={enabled:!0},e=this.argumentVarModels_[c],b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",e.name),
|
||||
e=Blockly.Variables.generateVariableFieldDom(e),d=Blockly.utils.xml.createElement("block"),d.setAttribute("type","variables_get"),d.appendChild(e),b.callback=Blockly.ContextMenu.callbackFactory(this,d),a.push(b)}},callType_:"procedures_callnoreturn"};
|
||||
if(""==c.type){c=c.name;b=this.workspace.getVariableById(b);for(var d=!1,e=0;e<this.argumentVarModels_.length;e++)this.argumentVarModels_[e].getId()==a&&(this.arguments_[e]=b.name,this.argumentVarModels_[e]=b,d=!0);d&&(this.displayRenamedVar_(c,b.name),Blockly.Procedures.mutateCallers(this))}},updateVarName:function(a){for(var b=a.name,c=!1,d=0;d<this.argumentVarModels_.length;d++)if(this.argumentVarModels_[d].getId()==a.getId()){var e=this.arguments_[d];this.arguments_[d]=b;c=!0}c&&(this.displayRenamedVar_(e,
|
||||
b),Blockly.Procedures.mutateCallers(this))},displayRenamedVar_:function(a,b){this.updateParams_();if(this.mutator&&this.mutator.isVisible())for(var c=this.mutator.workspace_.getAllBlocks(!1),d=0,e;e=c[d];d++)"procedures_mutatorarg"==e.type&&Blockly.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")},customContextMenu:function(a){if(!this.isInFlyout){var b={enabled:!0},c=this.getFieldValue("NAME");b.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=Blockly.utils.xml.createElement("mutation");
|
||||
d.setAttribute("name",c);for(c=0;c<this.arguments_.length;c++){var e=Blockly.utils.xml.createElement("arg");e.setAttribute("name",this.arguments_[c]);d.appendChild(e)}c=Blockly.utils.xml.createElement("block");c.setAttribute("type",this.callType_);c.appendChild(d);b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b);if(!this.isCollapsed())for(c=0;c<this.argumentVarModels_.length;c++)b={enabled:!0},d=this.argumentVarModels_[c],b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",d.name),
|
||||
d=Blockly.Variables.generateVariableFieldDom(d),e=Blockly.utils.xml.createElement("block"),e.setAttribute("type","variables_get"),e.appendChild(d),b.callback=Blockly.ContextMenu.callbackFactory(this,e),a.push(b)}},callType_:"procedures_callnoreturn"};
|
||||
Blockly.Blocks.procedures_defreturn={init:function(){var a=new Blockly.FieldTextInput("",Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));(this.workspace.options.comments||this.workspace.options.parentWorkspace&&
|
||||
this.workspace.options.parentWorkspace.options.comments)&&Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT&&this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.setStatements_(!0);this.statementConnection_=null},setStatements_:Blockly.Blocks.procedures_defnoreturn.setStatements_,updateParams_:Blockly.Blocks.procedures_defnoreturn.updateParams_,
|
||||
mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},getVars:Blockly.Blocks.procedures_defnoreturn.getVars,getVarModels:Blockly.Blocks.procedures_defnoreturn.getVarModels,renameVarById:Blockly.Blocks.procedures_defnoreturn.renameVarById,
|
||||
updateVarName:Blockly.Blocks.procedures_defnoreturn.updateVarName,displayRenamedVar_:Blockly.Blocks.procedures_defnoreturn.displayRenamedVar_,customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,callType_:"procedures_callreturn"};
|
||||
Blockly.Blocks.procedures_mutatorcontainer={init:function(){this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);this.appendStatementInput("STACK");this.appendDummyInput("STATEMENT_INPUT").appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new Blockly.FieldCheckbox("TRUE"),"STATEMENTS");this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
|
||||
Blockly.Blocks.procedures_mutatorarg={init:function(){var a=new Blockly.FieldTextInput(Blockly.Procedures.DEFAULT_ARG,this.validator_);a.oldShowEditorFn_=a.showEditor_;a.showEditor_=function(){this.createdVariables_=[];this.oldShowEditorFn_()};this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(a,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=
|
||||
!1;a.onFinishEditing_=this.deleteIntermediateVars_;a.createdVariables_=[];a.onFinishEditing_("x")},validator_:function(a){var b=this.getSourceBlock(),c=Blockly.Mutator.findParentWs(b.workspace);a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"");if(!a)return null;for(var e=(b.workspace.targetWorkspace||b.workspace).getAllBlocks(!1),d=0;d<e.length;d++)if(e[d].id!=this.getSourceBlock().id&&e[d].getFieldValue("NAME")==a)return null;if(b.isInFlyout)return a;(b=c.getVariable(a,""))&&b.name!=a&&c.renameVariableById(b.getId(),
|
||||
a);b||(b=c.createVariable(a,""))&&this.createdVariables_&&this.createdVariables_.push(b);return a},deleteIntermediateVars_:function(a){var b=Blockly.Mutator.findParentWs(this.getSourceBlock().workspace);if(b)for(var c=0;c<this.createdVariables_.length;c++){var e=this.createdVariables_[c];e.name!=a&&b.deleteVariableById(e.getId())}}};
|
||||
!1;a.onFinishEditing_=this.deleteIntermediateVars_;a.createdVariables_=[];a.onFinishEditing_("x")},validator_:function(a){var b=this.getSourceBlock(),c=Blockly.Mutator.findParentWs(b.workspace);a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,"");if(!a)return null;for(var d=(b.workspace.targetWorkspace||b.workspace).getAllBlocks(!1),e=a.toLowerCase(),f=0;f<d.length;f++)if(d[f].id!=this.getSourceBlock().id){var g=d[f].getFieldValue("NAME");if(g&&g.toLowerCase()==e)return null}if(b.isInFlyout)return a;
|
||||
(b=c.getVariable(a,""))&&b.name!=a&&c.renameVariableById(b.getId(),a);b||(b=c.createVariable(a,""))&&this.createdVariables_&&this.createdVariables_.push(b);return a},deleteIntermediateVars_:function(a){var b=Blockly.Mutator.findParentWs(this.getSourceBlock().workspace);if(b)for(var c=0;c<this.createdVariables_.length;c++){var d=this.createdVariables_[c];d.name!=a&&b.deleteVariableById(d.getId())}}};
|
||||
Blockly.Blocks.procedures_callnoreturn={init:function(){this.appendDummyInput("TOPROW").appendField(this.id,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.argumentVarModels_=[];this.quarkConnections_={};this.quarkIds_=null;this.previousEnabledState_=!0},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,
|
||||
this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=Blockly.Procedures.getDefinition(this.getProcedureCall(),this.workspace),e=c&&c.mutator&&c.mutator.isVisible();e||(this.quarkConnections_={},this.quarkIds_=null);if(b)if(a.join("\n")==this.arguments_.join("\n"))this.quarkIds_=b;else{if(b.length!=a.length)throw RangeError("paramNames and paramIds must be the same length.");
|
||||
this.setCollapsed(!1);this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(var d=0;d<this.arguments_.length;d++){var f=this.getInput("ARG"+d);f&&(f=f.connection.targetConnection,this.quarkConnections_[this.quarkIds_[d]]=f,e&&f&&-1==b.indexOf(this.quarkIds_[d])&&(f.disconnect(),f.getSourceBlock().bumpNeighbours()))}this.arguments_=[].concat(a);this.argumentVarModels_=[];for(d=0;d<this.arguments_.length;d++)a=Blockly.Variables.getOrCreateVariablePackage(this.workspace,
|
||||
null,this.arguments_[d],""),this.argumentVarModels_.push(a);this.updateShape_();if(this.quarkIds_=b)for(d=0;d<this.arguments_.length;d++)b=this.quarkIds_[d],b in this.quarkConnections_&&(f=this.quarkConnections_[b],Blockly.Mutator.reconnect(f,this,"ARG"+d)||delete this.quarkConnections_[b]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);if(b){Blockly.Events.disable();try{b.setValue(this.arguments_[a])}finally{Blockly.Events.enable()}}else b=
|
||||
this.getProcedureCall())&&(this.setFieldValue(b,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=Blockly.Procedures.getDefinition(this.getProcedureCall(),this.workspace),d=c&&c.mutator&&c.mutator.isVisible();d||(this.quarkConnections_={},this.quarkIds_=null);if(b)if(a.join("\n")==this.arguments_.join("\n"))this.quarkIds_=b;else{if(b.length!=a.length)throw RangeError("paramNames and paramIds must be the same length.");
|
||||
this.setCollapsed(!1);this.quarkIds_||(this.quarkConnections_={},this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(var e=0;e<this.arguments_.length;e++){var f=this.getInput("ARG"+e);f&&(f=f.connection.targetConnection,this.quarkConnections_[this.quarkIds_[e]]=f,d&&f&&-1==b.indexOf(this.quarkIds_[e])&&(f.disconnect(),f.getSourceBlock().bumpNeighbours()))}this.arguments_=[].concat(a);this.argumentVarModels_=[];for(e=0;e<this.arguments_.length;e++)a=Blockly.Variables.getOrCreateVariablePackage(this.workspace,
|
||||
null,this.arguments_[e],""),this.argumentVarModels_.push(a);this.updateShape_();if(this.quarkIds_=b)for(e=0;e<this.arguments_.length;e++)b=this.quarkIds_[e],b in this.quarkConnections_&&(f=this.quarkConnections_[b],Blockly.Mutator.reconnect(f,this,"ARG"+e)||delete this.quarkConnections_[b]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);if(b){Blockly.Events.disable();try{b.setValue(this.arguments_[a])}finally{Blockly.Events.enable()}}else b=
|
||||
new Blockly.FieldLabel(this.arguments_[a]),this.appendValueInput("ARG"+a).setAlign(Blockly.ALIGN_RIGHT).appendField(b,"ARGNAME"+a).init()}for(;this.getInput("ARG"+a);)this.removeInput("ARG"+a),a++;if(a=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(a.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),a.init()):this.getField("WITH")&&a.removeField("WITH")},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("name",this.getProcedureCall());
|
||||
for(var b=0;b<this.arguments_.length;b++){var c=Blockly.utils.xml.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);b=[];for(var c=[],e=0,d;d=a.childNodes[e];e++)"arg"==d.nodeName.toLowerCase()&&(b.push(d.getAttribute("name")),c.push(d.getAttribute("paramId")));this.setProcedureParameters_(b,c)},getVarModels:function(){return this.argumentVarModels_},onchange:function(a){if(this.workspace&&
|
||||
!this.workspace.isFlyout&&a.recordUndo)if(a.type==Blockly.Events.BLOCK_CREATE&&-1!=a.ids.indexOf(this.id)){var b=this.getProcedureCall();b=Blockly.Procedures.getDefinition(b,this.workspace);!b||b.type==this.defType_&&JSON.stringify(b.arguments_)==JSON.stringify(this.arguments_)||(b=null);if(!b){Blockly.Events.setGroup(a.group);a=Blockly.utils.xml.createElement("xml");b=Blockly.utils.xml.createElement("block");b.setAttribute("type",this.defType_);var c=this.getRelativeToSurfaceXY(),e=c.y+2*Blockly.SNAP_RADIUS;
|
||||
b.setAttribute("x",c.x+Blockly.SNAP_RADIUS*(this.RTL?-1:1));b.setAttribute("y",e);c=this.mutationToDom();b.appendChild(c);c=Blockly.utils.xml.createElement("field");c.setAttribute("name","NAME");c.appendChild(Blockly.utils.xml.createTextNode(this.getProcedureCall()));b.appendChild(c);a.appendChild(b);Blockly.Xml.domToWorkspace(a,this.workspace);Blockly.Events.setGroup(!1)}}else a.type==Blockly.Events.BLOCK_DELETE?(b=this.getProcedureCall(),b=Blockly.Procedures.getDefinition(b,this.workspace),b||(Blockly.Events.setGroup(a.group),
|
||||
for(var b=0;b<this.arguments_.length;b++){var c=Blockly.utils.xml.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);b=[];for(var c=[],d=0,e;e=a.childNodes[d];d++)"arg"==e.nodeName.toLowerCase()&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,c)},getVarModels:function(){return this.argumentVarModels_},onchange:function(a){if(this.workspace&&
|
||||
!this.workspace.isFlyout&&a.recordUndo)if(a.type==Blockly.Events.BLOCK_CREATE&&-1!=a.ids.indexOf(this.id)){var b=this.getProcedureCall();b=Blockly.Procedures.getDefinition(b,this.workspace);!b||b.type==this.defType_&&JSON.stringify(b.arguments_)==JSON.stringify(this.arguments_)||(b=null);if(!b){Blockly.Events.setGroup(a.group);a=Blockly.utils.xml.createElement("xml");b=Blockly.utils.xml.createElement("block");b.setAttribute("type",this.defType_);var c=this.getRelativeToSurfaceXY(),d=c.y+2*Blockly.SNAP_RADIUS;
|
||||
b.setAttribute("x",c.x+Blockly.SNAP_RADIUS*(this.RTL?-1:1));b.setAttribute("y",d);c=this.mutationToDom();b.appendChild(c);c=Blockly.utils.xml.createElement("field");c.setAttribute("name","NAME");c.appendChild(Blockly.utils.xml.createTextNode(this.getProcedureCall()));b.appendChild(c);a.appendChild(b);Blockly.Xml.domToWorkspace(a,this.workspace);Blockly.Events.setGroup(!1)}}else a.type==Blockly.Events.BLOCK_DELETE?(b=this.getProcedureCall(),b=Blockly.Procedures.getDefinition(b,this.workspace),b||(Blockly.Events.setGroup(a.group),
|
||||
this.dispose(!0),Blockly.Events.setGroup(!1))):a.type==Blockly.Events.CHANGE&&"disabled"==a.element&&(b=this.getProcedureCall(),(b=Blockly.Procedures.getDefinition(b,this.workspace))&&b.id==a.blockId&&((b=Blockly.Events.getGroup())&&console.log("Saw an existing group while responding to a definition change"),Blockly.Events.setGroup(a.group),a.newValue?(this.previousEnabledState_=this.isEnabled(),this.setEnabled(!1)):this.setEnabled(this.previousEnabledState_),Blockly.Events.setGroup(b)))},customContextMenu:function(a){if(this.workspace.isMovable()){var b=
|
||||
{enabled:!0};b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),e=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,e);a&&(e.centerOnBlock(a.id),a.select())};a.push(b)}},defType_:"procedures_defnoreturn"};
|
||||
{enabled:!0};b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&(d.centerOnBlock(a.id),a.select())};a.push(b)}},defType_:"procedures_defnoreturn"};
|
||||
Blockly.Blocks.procedures_callreturn={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setStyle("procedure_blocks");this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkIds_=null;this.previousEnabledState_=!0},getProcedureCall:Blockly.Blocks.procedures_callnoreturn.getProcedureCall,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,setProcedureParameters_:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters_,
|
||||
updateShape_:Blockly.Blocks.procedures_callnoreturn.updateShape_,mutationToDom:Blockly.Blocks.procedures_callnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callnoreturn.domToMutation,getVarModels:Blockly.Blocks.procedures_callnoreturn.getVarModels,onchange:Blockly.Blocks.procedures_callnoreturn.onchange,customContextMenu:Blockly.Blocks.procedures_callnoreturn.customContextMenu,defType_:"procedures_defreturn"};
|
||||
Blockly.Blocks.procedures_ifreturn={init:function(){this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF);this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0);this.setStyle("procedure_blocks");this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},mutationToDom:function(){var a=
|
||||
@@ -133,7 +133,7 @@ args0:[{type:"input_value",name:"VALUE",check:"String"},{type:"field_dropdown",n
|
||||
Blockly.Blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]];this.WHERE_OPTIONS_2=[[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL);this.setStyle("text_blocks");
|
||||
this.appendValueInput("STRING").setCheck("String").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT);this.appendDummyInput("AT1");this.appendDummyInput("AT2");Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL);this.setInputsInline(!0);this.setOutput(!0,"String");this.updateAt_(1,!0);this.updateAt_(2,!0);this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation"),
|
||||
b=this.getInput("AT1").type==Blockly.INPUT_VALUE;a.setAttribute("at1",b);b=this.getInput("AT2").type==Blockly.INPUT_VALUE;a.setAttribute("at2",b);return a},domToMutation:function(a){var b="true"==a.getAttribute("at1");a="true"==a.getAttribute("at2");this.updateAt_(1,b);this.updateAt_(2,a)},updateAt_:function(a,b){this.removeInput("AT"+a);this.removeInput("ORDINAL"+a,!0);b?(this.appendValueInput("AT"+a).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+a).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):
|
||||
this.appendDummyInput("AT"+a);2==a&&Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var d="FROM_START"==c||"FROM_END"==c;if(d!=b){var e=this.getSourceBlock();e.updateAt_(a,d);e.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&
|
||||
this.appendDummyInput("AT"+a);2==a&&Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));var c=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+a],function(c){var e="FROM_START"==c||"FROM_END"==c;if(e!=b){var d=this.getSourceBlock();d.updateAt_(a,e);d.setFieldValue(c,"WHERE"+a);return null}});this.getInput("AT"+a).appendField(c,"WHERE"+a);1==a&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&
|
||||
this.moveInputBefore("ORDINAL1","AT2"))}};Blockly.Blocks.text_changeCase={init:function(){var a=[[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a),"CASE");this.setOutput(!0,"String");this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP)}};
|
||||
Blockly.Blocks.text_trim={init:function(){var a=[[Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL);this.setStyle("text_blocks");this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(a),"MODE");this.setOutput(!0,"String");this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)}};
|
||||
Blockly.Blocks.text_print={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,style:"text_blocks",tooltip:Blockly.Msg.TEXT_PRINT_TOOLTIP,helpUrl:Blockly.Msg.TEXT_PRINT_HELPURL})}};
|
||||
@@ -145,11 +145,11 @@ Blockly.Blocks.text_count={init:function(){this.jsonInit({message0:Blockly.Msg.T
|
||||
Blockly.Blocks.text_replace={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_REPLACE_MESSAGE0,args0:[{type:"input_value",name:"FROM",check:"String"},{type:"input_value",name:"TO",check:"String"},{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:Blockly.Msg.TEXT_REPLACE_TOOLTIP,helpUrl:Blockly.Msg.TEXT_REPLACE_HELPURL})}};
|
||||
Blockly.Blocks.text_reverse={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_REVERSE_MESSAGE0,args0:[{type:"input_value",name:"TEXT",check:"String"}],output:"String",inputsInline:!0,style:"text_blocks",tooltip:Blockly.Msg.TEXT_REVERSE_TOOLTIP,helpUrl:Blockly.Msg.TEXT_REVERSE_HELPURL})}};
|
||||
Blockly.Constants.Text.QUOTE_IMAGE_MIXIN={QUOTE_IMAGE_LEFT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",QUOTE_IMAGE_RIGHT_DATAURI:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==",
|
||||
QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(a){for(var b=0,c;c=this.inputList[b];b++)for(var e=0,d;d=c.fieldRow[e];e++)if(a==d.name){c.insertFieldAt(e,this.newQuote_(!0));c.insertFieldAt(e+2,this.newQuote_(!1));return}console.warn('field named "'+a+'" not found in '+this.toDevString())},newQuote_:function(a){a=this.RTL?!a:a;return new Blockly.FieldImage(a?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,this.QUOTE_IMAGE_WIDTH,this.QUOTE_IMAGE_HEIGHT,a?"\u201c":"\u201d")}};
|
||||
QUOTE_IMAGE_WIDTH:12,QUOTE_IMAGE_HEIGHT:12,quoteField_:function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)if(a==e.name){c.insertFieldAt(d,this.newQuote_(!0));c.insertFieldAt(d+2,this.newQuote_(!1));return}console.warn('field named "'+a+'" not found in '+this.toDevString())},newQuote_:function(a){a=this.RTL?!a:a;return new Blockly.FieldImage(a?this.QUOTE_IMAGE_LEFT_DATAURI:this.QUOTE_IMAGE_RIGHT_DATAURI,this.QUOTE_IMAGE_WIDTH,this.QUOTE_IMAGE_HEIGHT,a?"\u201c":"\u201d")}};
|
||||
Blockly.Constants.Text.TEXT_QUOTES_EXTENSION=function(){this.mixin(Blockly.Constants.Text.QUOTE_IMAGE_MIXIN);this.quoteField_("TEXT")};
|
||||
Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN={mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,e=0;e<this.itemCount_;e++){var d=a.newBlock("text_create_join_item");d.initSvg();c.connect(d.previousConnection);
|
||||
c=d.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=
|
||||
this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(;this.getInput("ADD"+
|
||||
Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN={mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);
|
||||
c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=
|
||||
this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a).setAlign(Blockly.ALIGN_RIGHT);0==a&&b.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(;this.getInput("ADD"+
|
||||
a);)this.removeInput("ADD"+a),a++}};Blockly.Constants.Text.TEXT_JOIN_EXTENSION=function(){this.mixin(Blockly.Constants.Text.QUOTE_IMAGE_MIXIN);this.itemCount_=2;this.updateShape_();this.setMutator(new Blockly.Mutator(["text_create_join_item"]))};Blockly.Extensions.register("text_append_tooltip",Blockly.Extensions.buildTooltipWithFieldText("%{BKY_TEXT_APPEND_TOOLTIP}","VAR"));
|
||||
Blockly.Constants.Text.TEXT_INDEXOF_TOOLTIP_EXTENSION=function(){var a=this;this.setTooltip(function(){return Blockly.Msg.TEXT_INDEXOF_TOOLTIP.replace("%1",a.workspace.options.oneBasedIndex?"0":"-1")})};
|
||||
Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN={mutationToDom:function(){var a=Blockly.utils.xml.createElement("mutation");a.setAttribute("at",!!this.isAt_);return a},domToMutation:function(a){a="false"!=a.getAttribute("at");this.updateAt_(a)},updateAt_:function(a){this.removeInput("AT",!0);this.removeInput("ORDINAL",!0);a&&(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX));Blockly.Msg.TEXT_CHARAT_TAIL&&
|
||||
@@ -158,12 +158,12 @@ Blockly.Constants.Text.TEXT_CHARAT_EXTENSION=function(){this.getField("WHERE").s
|
||||
"#1":"#0"));return c})};Blockly.Extensions.register("text_indexOf_tooltip",Blockly.Constants.Text.TEXT_INDEXOF_TOOLTIP_EXTENSION);Blockly.Extensions.register("text_quotes",Blockly.Constants.Text.TEXT_QUOTES_EXTENSION);Blockly.Extensions.registerMutator("text_join_mutator",Blockly.Constants.Text.TEXT_JOIN_MUTATOR_MIXIN,Blockly.Constants.Text.TEXT_JOIN_EXTENSION);Blockly.Extensions.registerMutator("text_charAt_mutator",Blockly.Constants.Text.TEXT_CHARAT_MUTATOR_MIXIN,Blockly.Constants.Text.TEXT_CHARAT_EXTENSION);Blockly.Blocks.variables={};Blockly.Constants.Variables={};Blockly.Constants.Variables.HUE=330;
|
||||
Blockly.defineBlocksWithJsonArray([{type:"variables_get",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableSetterGetter"]},{type:"variables_set",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",name:"VALUE"}],previousStatement:null,
|
||||
nextStatement:null,style:"variable_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableSetterGetter"]}]);
|
||||
Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){if("variables_get"==this.type)var b="variables_set",c=Blockly.Msg.VARIABLES_GET_CREATE_SET;else b="variables_get",c=Blockly.Msg.VARIABLES_SET_CREATE_GET;var e={enabled:0<this.workspace.remainingCapacity()},d=this.getField("VAR").getText();e.text=c.replace("%1",d);c=Blockly.utils.xml.createElement("field");c.setAttribute("name","VAR");c.appendChild(Blockly.utils.xml.createTextNode(d));
|
||||
d=Blockly.utils.xml.createElement("block");d.setAttribute("type",b);d.appendChild(c);e.callback=Blockly.ContextMenu.callbackFactory(this,d);a.push(e)}else if("variables_get"==this.type||"variables_get_reporter"==this.type)b={text:Blockly.Msg.RENAME_VARIABLE,enabled:!0,callback:Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)},d=this.getField("VAR").getText(),e={text:Blockly.Msg.DELETE_VARIABLE.replace("%1",d),enabled:!0,callback:Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)},
|
||||
a.unshift(b),a.unshift(e)}};Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();Blockly.Variables.renameVariable(b,c)}};Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};Blockly.Extensions.registerMixin("contextMenu_variableSetterGetter",Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);Blockly.Constants.VariablesDynamic={};Blockly.Constants.VariablesDynamic.HUE=310;
|
||||
Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){if("variables_get"==this.type)var b="variables_set",c=Blockly.Msg.VARIABLES_GET_CREATE_SET;else b="variables_get",c=Blockly.Msg.VARIABLES_SET_CREATE_GET;var d={enabled:0<this.workspace.remainingCapacity()},e=this.getField("VAR").getText();d.text=c.replace("%1",e);c=Blockly.utils.xml.createElement("field");c.setAttribute("name","VAR");c.appendChild(Blockly.utils.xml.createTextNode(e));
|
||||
e=Blockly.utils.xml.createElement("block");e.setAttribute("type",b);e.appendChild(c);d.callback=Blockly.ContextMenu.callbackFactory(this,e);a.push(d)}else if("variables_get"==this.type||"variables_get_reporter"==this.type)b={text:Blockly.Msg.RENAME_VARIABLE,enabled:!0,callback:Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)},e=this.getField("VAR").getText(),d={text:Blockly.Msg.DELETE_VARIABLE.replace("%1",e),enabled:!0,callback:Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)},
|
||||
a.unshift(b),a.unshift(d)}};Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();Blockly.Variables.renameVariable(b,c)}};Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};Blockly.Extensions.registerMixin("contextMenu_variableSetterGetter",Blockly.Constants.Variables.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);Blockly.Constants.VariablesDynamic={};Blockly.Constants.VariablesDynamic.HUE=310;
|
||||
Blockly.defineBlocksWithJsonArray([{type:"variables_get_dynamic",message0:"%1",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"}],output:null,style:"variable_dynamic_blocks",helpUrl:"%{BKY_VARIABLES_GET_HELPURL}",tooltip:"%{BKY_VARIABLES_GET_TOOLTIP}",extensions:["contextMenu_variableDynamicSetterGetter"]},{type:"variables_set_dynamic",message0:"%{BKY_VARIABLES_SET}",args0:[{type:"field_variable",name:"VAR",variable:"%{BKY_VARIABLES_DEFAULT_NAME}"},{type:"input_value",
|
||||
name:"VALUE"}],previousStatement:null,nextStatement:null,style:"variable_dynamic_blocks",tooltip:"%{BKY_VARIABLES_SET_TOOLTIP}",helpUrl:"%{BKY_VARIABLES_SET_HELPURL}",extensions:["contextMenu_variableDynamicSetterGetter"]}]);
|
||||
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getFieldValue("VAR");var c=this.workspace.getVariableById(b).type;if("variables_get_dynamic"==this.type){b="variables_set_dynamic";var e=Blockly.Msg.VARIABLES_GET_CREATE_SET}else b="variables_get_dynamic",e=Blockly.Msg.VARIABLES_SET_CREATE_GET;var d={enabled:0<this.workspace.remainingCapacity()},f=this.getField("VAR").getText();d.text=e.replace("%1",f);
|
||||
e=Blockly.utils.xml.createElement("field");e.setAttribute("name","VAR");e.setAttribute("variabletype",c);e.appendChild(Blockly.utils.xml.createTextNode(f));f=Blockly.utils.xml.createElement("block");f.setAttribute("type",b);f.appendChild(e);d.callback=Blockly.ContextMenu.callbackFactory(this,f);a.push(d)}else if("variables_get_dynamic"==this.type||"variables_get_reporter_dynamic"==this.type)b={text:Blockly.Msg.RENAME_VARIABLE,enabled:!0,callback:Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)},
|
||||
f=this.getField("VAR").getText(),d={text:Blockly.Msg.DELETE_VARIABLE.replace("%1",f),enabled:!0,callback:Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)},a.unshift(b),a.unshift(d)},onchange:function(a){a=this.getFieldValue("VAR");a=Blockly.Variables.getVariable(this.workspace,a);"variables_get_dynamic"==this.type?this.outputConnection.setCheck(a.type):this.getInput("VALUE").connection.setCheck(a.type)}};
|
||||
Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN={customContextMenu:function(a){if(!this.isInFlyout){var b=this.getFieldValue("VAR");var c=this.workspace.getVariableById(b).type;if("variables_get_dynamic"==this.type){b="variables_set_dynamic";var d=Blockly.Msg.VARIABLES_GET_CREATE_SET}else b="variables_get_dynamic",d=Blockly.Msg.VARIABLES_SET_CREATE_GET;var e={enabled:0<this.workspace.remainingCapacity()},f=this.getField("VAR").getText();e.text=d.replace("%1",f);
|
||||
d=Blockly.utils.xml.createElement("field");d.setAttribute("name","VAR");d.setAttribute("variabletype",c);d.appendChild(Blockly.utils.xml.createTextNode(f));f=Blockly.utils.xml.createElement("block");f.setAttribute("type",b);f.appendChild(d);e.callback=Blockly.ContextMenu.callbackFactory(this,f);a.push(e)}else if("variables_get_dynamic"==this.type||"variables_get_reporter_dynamic"==this.type)b={text:Blockly.Msg.RENAME_VARIABLE,enabled:!0,callback:Blockly.Constants.Variables.RENAME_OPTION_CALLBACK_FACTORY(this)},
|
||||
f=this.getField("VAR").getText(),e={text:Blockly.Msg.DELETE_VARIABLE.replace("%1",f),enabled:!0,callback:Blockly.Constants.Variables.DELETE_OPTION_CALLBACK_FACTORY(this)},a.unshift(b),a.unshift(e)},onchange:function(a){a=this.getFieldValue("VAR");a=Blockly.Variables.getVariable(this.workspace,a);"variables_get_dynamic"==this.type?this.outputConnection.setCheck(a.type):this.getInput("VALUE").connection.setCheck(a.type)}};
|
||||
Blockly.Constants.VariablesDynamic.RENAME_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();Blockly.Variables.renameVariable(b,c)}};Blockly.Constants.VariablesDynamic.DELETE_OPTION_CALLBACK_FACTORY=function(a){return function(){var b=a.workspace,c=a.getField("VAR").getVariable();b.deleteVariableById(c.getId());b.refreshToolboxSelection()}};Blockly.Extensions.registerMixin("contextMenu_variableDynamicSetterGetter",Blockly.Constants.VariablesDynamic.CUSTOM_CONTEXT_MENU_VARIABLE_GETTER_SETTER_MIXIN);
|
||||
|
||||
15
build.py
15
build.py
@@ -309,7 +309,7 @@ goog.provide('Blockly.utils.string');
|
||||
def file_lookup(name):
|
||||
if not name.startswith("Input_"):
|
||||
return "???"
|
||||
n = int(name[6:]) - 1
|
||||
n = int(name[6:])
|
||||
return filenames[n]
|
||||
|
||||
if "serverErrors" in json_data:
|
||||
@@ -384,18 +384,7 @@ goog.provide('Blockly.utils.string');
|
||||
|
||||
(Copyright \\d+ (Google LLC|Massachusetts Institute of Technology))
|
||||
( All rights reserved.
|
||||
)?
|
||||
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.
|
||||
)? SPDX-License-Identifier: Apache-2.0
|
||||
\\*/""")
|
||||
return re.sub(apache2, "", code)
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -181,6 +170,13 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
|
||||
*/
|
||||
this.hat = undefined;
|
||||
|
||||
/**
|
||||
* A count of statement inputs on the block.
|
||||
* @type {number}
|
||||
* @package
|
||||
*/
|
||||
this.statementInputCount = 0;
|
||||
|
||||
// Copy the type-specific functions and data from the prototype.
|
||||
if (prototypeName) {
|
||||
/** @type {string} */
|
||||
@@ -943,7 +939,7 @@ Blockly.Block.prototype.setStyle = function(blockStyleName) {
|
||||
* 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.
|
||||
* @throws {Error} if onchangeFn is not falsey and not a function.
|
||||
*/
|
||||
Blockly.Block.prototype.setOnChange = function(onchangeFn) {
|
||||
if (onchangeFn && typeof onchangeFn != 'function') {
|
||||
@@ -1646,6 +1642,9 @@ Blockly.Block.prototype.appendInput_ = function(type, name) {
|
||||
if (type == Blockly.INPUT_VALUE || type == Blockly.NEXT_STATEMENT) {
|
||||
connection = this.makeConnection_(type);
|
||||
}
|
||||
if (type == Blockly.NEXT_STATEMENT) {
|
||||
this.statementInputCount++;
|
||||
}
|
||||
var input = new Blockly.Input(type, name, this, connection);
|
||||
// Append input to list.
|
||||
this.inputList.push(input);
|
||||
@@ -1723,6 +1722,9 @@ Blockly.Block.prototype.moveNumberedInputBefore = function(
|
||||
Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
|
||||
for (var i = 0, input; (input = this.inputList[i]); i++) {
|
||||
if (input.name == name) {
|
||||
if (input.type == Blockly.NEXT_STATEMENT) {
|
||||
this.statementInputCount--;
|
||||
}
|
||||
input.dispose();
|
||||
this.inputList.splice(i, 1);
|
||||
return;
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -302,6 +291,7 @@ Blockly.BlockDragger.prototype.maybeDeleteBlock_ = function() {
|
||||
// Fire a move event, so we know where to go back to for an undo.
|
||||
this.fireMoveEvent_();
|
||||
this.draggingBlock_.dispose(false, true);
|
||||
Blockly.draggingConnections = [];
|
||||
} else if (trashcan) {
|
||||
// Make sure the trash can is closed.
|
||||
trashcan.close();
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -594,9 +583,12 @@ Blockly.BlockSvg.prototype.getBoundingRectangle = function() {
|
||||
|
||||
/**
|
||||
* Notify every input on this block to mark its fields as dirty.
|
||||
* A dirty field is a field that needs to be re-rendererd.
|
||||
* A dirty field is a field that needs to be re-rendered.
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.markDirty = function() {
|
||||
this.pathObject.constants =
|
||||
(/** @type {!Blockly.WorkspaceSvg} */ (this.workspace))
|
||||
.getRenderer().getConstants();
|
||||
for (var i = 0, input; (input = this.inputList[i]); i++) {
|
||||
input.markDirty();
|
||||
}
|
||||
@@ -684,6 +676,11 @@ Blockly.BlockSvg.prototype.tab = function(start, forward) {
|
||||
if (nextNode && nextNode !== currentNode) {
|
||||
var nextField = /** @type {!Blockly.Field} */ (nextNode.getLocation());
|
||||
nextField.showEditor();
|
||||
|
||||
// Also move the cursor if we're in keyboard nav mode.
|
||||
if (this.workspace.keyboardAccessibilityMode) {
|
||||
this.workspace.getCursor().setCurNode(nextNode);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -920,7 +917,8 @@ Blockly.BlockSvg.prototype.setInsertionMarker = function(insertionMarker) {
|
||||
}
|
||||
this.isInsertionMarker_ = insertionMarker;
|
||||
if (this.isInsertionMarker_) {
|
||||
this.setColour(Blockly.INSERTION_MARKER_COLOUR);
|
||||
this.setColour(this.workspace.getRenderer().getConstants().
|
||||
INSERTION_MARKER_COLOUR);
|
||||
this.pathObject.updateInsertionMarker(true);
|
||||
}
|
||||
};
|
||||
@@ -946,7 +944,8 @@ Blockly.BlockSvg.prototype.dispose = function(healStack, animate) {
|
||||
// The block has already been deleted.
|
||||
return;
|
||||
}
|
||||
Blockly.Tooltip.hide();
|
||||
Blockly.Tooltip.dispose();
|
||||
Blockly.Tooltip.unbindMouseEvents(this.pathObject.svgPath);
|
||||
Blockly.utils.dom.startTextWidthCache();
|
||||
// Save the block's workspace temporarily so we can resize the
|
||||
// contents once the block is disposed.
|
||||
@@ -1191,7 +1190,7 @@ Blockly.BlockSvg.prototype.setDisabled = function(disabled) {
|
||||
Blockly.BlockSvg.prototype.setEnabled = function(enabled) {
|
||||
if (this.isEnabled() != enabled) {
|
||||
Blockly.BlockSvg.superClass_.setEnabled.call(this, enabled);
|
||||
if (this.rendered) {
|
||||
if (this.rendered && !this.getInheritedDisabled()) {
|
||||
this.updateDisabled();
|
||||
}
|
||||
}
|
||||
@@ -1656,7 +1655,8 @@ Blockly.BlockSvg.prototype.getRootBlock = function() {
|
||||
Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||
Blockly.utils.dom.startTextWidthCache();
|
||||
this.rendered = true;
|
||||
(/** @type {!Blockly.WorkspaceSvg} */ (this.workspace)).getRenderer().render(this);
|
||||
(/** @type {!Blockly.WorkspaceSvg} */ (this.workspace))
|
||||
.getRenderer().render(this);
|
||||
// No matter how we rendered, connection locations should now be correct.
|
||||
this.updateConnectionLocations_();
|
||||
if (opt_bubble !== false) {
|
||||
@@ -1671,9 +1671,19 @@ Blockly.BlockSvg.prototype.render = function(opt_bubble) {
|
||||
}
|
||||
Blockly.utils.dom.stopTextWidthCache();
|
||||
|
||||
var cursor = this.workspace.getCursor();
|
||||
if (this.pathObject.cursorSvg_) {
|
||||
cursor.draw();
|
||||
this.updateMarkers_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Redraw any attached marker or cursor svgs if needed.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.updateMarkers_ = function() {
|
||||
if (this.workspace.keyboardAccessibilityMode && this.pathObject.cursorSvg) {
|
||||
this.workspace.getCursor().draw();
|
||||
}
|
||||
if (this.workspace.keyboardAccessibilityMode && this.pathObject.markerSvg) {
|
||||
this.workspace.getMarker(Blockly.navigation.MARKER_NAME).draw();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1760,8 +1770,8 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() {
|
||||
* @param {boolean} add True if highlighting should be added.
|
||||
* @package
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.highlightForReplacement = function(add) {
|
||||
this.pathObject.updateReplacementHighlight(add);
|
||||
Blockly.BlockSvg.prototype.fadeForReplacement = function(add) {
|
||||
this.pathObject.updateReplacementFade(add);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -101,6 +90,13 @@ Blockly.clipboardTypeCounts_ = null;
|
||||
*/
|
||||
Blockly.cache3dSupported_ = null;
|
||||
|
||||
/**
|
||||
* Container element to render the WidgetDiv, DropDownDiv and Tooltip.
|
||||
* @type {?Element}
|
||||
* @package
|
||||
*/
|
||||
Blockly.parentContainer = null;
|
||||
|
||||
/**
|
||||
* Blockly opaque event data used to unbind events when using
|
||||
* `Blockly.bindEvent_` and `Blockly.bindEventWithChecks_`.
|
||||
@@ -672,3 +668,14 @@ Blockly.checkBlockColourConstant_ = function(
|
||||
console.warn(warning);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the parent container. This is the container element that the WidgetDiv,
|
||||
* DropDownDiv, and Tooltip are rendered into the first time `Blockly.inject`
|
||||
* is called.
|
||||
* This method is a NOP if called after the first ``Blockly.inject``.
|
||||
* @param {!Element} container The container element.
|
||||
*/
|
||||
Blockly.setParentContainer = function(container) {
|
||||
Blockly.parentContainer = container;
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2013 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,7 +30,7 @@ Blockly.Component = function() {
|
||||
/**
|
||||
* Whether the component is rendered right-to-left.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
this.rightToLeft_ = Blockly.Component.defaultRightToLeft;
|
||||
|
||||
@@ -507,17 +496,6 @@ Blockly.Component.prototype.getContentElement = function() {
|
||||
return this.element_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns true if the component is rendered right-to-left, false otherwise.
|
||||
* The first time this function is invoked, the right-to-left rendering property
|
||||
* is set if it has not been already.
|
||||
* @return {boolean} Whether the control is rendered right-to-left.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Component.prototype.isRightToLeft = function() {
|
||||
return this.rightToLeft_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set is right-to-left. This function should be used if the component needs
|
||||
* to know the rendering direction during DOM creation (i.e. before
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -431,6 +420,8 @@ Blockly.Menu.prototype.handleMouseOver_ = function(e) {
|
||||
|
||||
this.unhighlightCurrent();
|
||||
this.setHighlighted(menuItem);
|
||||
} else {
|
||||
this.unhighlightCurrent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -78,7 +67,7 @@ Blockly.MenuItem.prototype.createDom = function() {
|
||||
element.className = 'goog-menuitem goog-option ' +
|
||||
(!this.enabled_ ? 'goog-menuitem-disabled ' : '') +
|
||||
(this.checked_ ? 'goog-option-selected ' : '') +
|
||||
(this.isRightToLeft() ? 'goog-menuitem-rtl ' : '');
|
||||
(this.rightToLeft_ ? 'goog-menuitem-rtl ' : '');
|
||||
|
||||
var content = this.getContentWrapperDom();
|
||||
element.appendChild(content);
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -44,31 +33,31 @@ goog.require('Blockly.utils.style');
|
||||
Blockly.tree.BaseNode = function(content, config) {
|
||||
Blockly.Component.call(this);
|
||||
|
||||
/**
|
||||
* The configuration for the tree.
|
||||
* @type {!Blockly.tree.BaseNode.Config}
|
||||
* @private
|
||||
*/
|
||||
this.config_ = config;
|
||||
|
||||
/**
|
||||
* Text content of the node label.
|
||||
* @type {string}
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
this.content_ = content;
|
||||
this.content = content;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
this.iconClass_;
|
||||
this.iconClass;
|
||||
|
||||
/**
|
||||
* @type {string}
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
this.expandedIconClass_;
|
||||
this.expandedIconClass;
|
||||
|
||||
/**
|
||||
* The configuration for the tree.
|
||||
* @type {!Blockly.tree.BaseNode.Config}
|
||||
* @protected
|
||||
*/
|
||||
this.config_ = config;
|
||||
|
||||
/**
|
||||
* @type {Blockly.tree.TreeControl}
|
||||
@@ -88,48 +77,29 @@ Blockly.tree.BaseNode = function(content, config) {
|
||||
*/
|
||||
this.nextSibling_;
|
||||
|
||||
/**
|
||||
* @type {Blockly.tree.BaseNode}
|
||||
* @private
|
||||
*/
|
||||
this.firstChild_;
|
||||
|
||||
/**
|
||||
* @type {Blockly.tree.BaseNode}
|
||||
* @private
|
||||
*/
|
||||
this.lastChild_;
|
||||
|
||||
/**
|
||||
* Whether the tree item is selected.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
this.selected_ = false;
|
||||
|
||||
/**
|
||||
* Whether the tree node is expanded.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
this.expanded_ = false;
|
||||
|
||||
/**
|
||||
* Tooltip for the tree item
|
||||
* @type {?string}
|
||||
* @private
|
||||
*/
|
||||
this.toolTip_ = null;
|
||||
|
||||
/**
|
||||
* Whether to allow user to collapse this node.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
* @protected
|
||||
*/
|
||||
this.isUserCollapsible_ = true;
|
||||
|
||||
/**
|
||||
* Nesting depth of this node; cached result of computeDepth_.
|
||||
* Nesting depth of this node; cached result of getDepth.
|
||||
* -1 if value has not been cached.
|
||||
* @type {number}
|
||||
* @private
|
||||
@@ -266,13 +236,9 @@ Blockly.tree.BaseNode.prototype.addChildAt = function(child, index) {
|
||||
|
||||
if (prevNode) {
|
||||
prevNode.nextSibling_ = child;
|
||||
} else {
|
||||
this.firstChild_ = child;
|
||||
}
|
||||
if (nextNode) {
|
||||
nextNode.previousSibling_ = child;
|
||||
} else {
|
||||
this.lastChild_ = child;
|
||||
}
|
||||
|
||||
var tree = this.getTree();
|
||||
@@ -286,8 +252,8 @@ Blockly.tree.BaseNode.prototype.addChildAt = function(child, index) {
|
||||
if (el) {
|
||||
this.updateExpandIcon();
|
||||
Blockly.utils.aria.setState(
|
||||
el, Blockly.utils.aria.State.EXPANDED, this.getExpanded());
|
||||
if (this.getExpanded()) {
|
||||
el, Blockly.utils.aria.State.EXPANDED, this.expanded_);
|
||||
if (this.expanded_) {
|
||||
var childrenEl = this.getChildrenElement();
|
||||
if (!child.getElement()) {
|
||||
child.createDom();
|
||||
@@ -305,7 +271,7 @@ Blockly.tree.BaseNode.prototype.addChildAt = function(child, index) {
|
||||
prevNode.updateExpandIcon();
|
||||
} else {
|
||||
Blockly.utils.style.setElementShown(childrenEl, true);
|
||||
this.setExpanded(this.getExpanded());
|
||||
this.setExpanded(this.expanded_);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -341,27 +307,17 @@ Blockly.tree.BaseNode.prototype.getTree = function() {
|
||||
Blockly.tree.BaseNode.prototype.getDepth = function() {
|
||||
var depth = this.depth_;
|
||||
if (depth < 0) {
|
||||
depth = this.computeDepth_();
|
||||
var parent = this.getParent();
|
||||
if (parent) {
|
||||
depth = parent.getDepth() + 1;
|
||||
} else {
|
||||
depth = 0;
|
||||
}
|
||||
this.setDepth_(depth);
|
||||
}
|
||||
return depth;
|
||||
};
|
||||
|
||||
/**
|
||||
* Computes the depth of the node in the tree.
|
||||
* Called only by getDepth, when the depth hasn't already been cached.
|
||||
* @return {number} The non-negative depth of this node (the root is zero).
|
||||
* @private
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.computeDepth_ = function() {
|
||||
var parent = this.getParent();
|
||||
if (parent) {
|
||||
return parent.getDepth() + 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the depth of a node (and all its descendants).
|
||||
* @param {number} depth The new nesting depth; must be non-negative.
|
||||
@@ -373,7 +329,7 @@ Blockly.tree.BaseNode.prototype.setDepth_ = function(depth) {
|
||||
var row = this.getRowElement();
|
||||
if (row) {
|
||||
var indent = this.getPixelIndent_() + 'px';
|
||||
if (this.isRightToLeft()) {
|
||||
if (this.rightToLeft_) {
|
||||
row.style.paddingRight = indent;
|
||||
} else {
|
||||
row.style.paddingLeft = indent;
|
||||
@@ -421,22 +377,6 @@ Blockly.tree.BaseNode.prototype.getChildren = function() {
|
||||
return children;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Blockly.tree.BaseNode} The first child of this node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getFirstChild = function() {
|
||||
return this.getChildAt(0);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Blockly.tree.BaseNode} The last child of this node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getLastChild = function() {
|
||||
return this.getChildAt(this.getChildCount() - 1);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {Blockly.tree.BaseNode} The previous sibling of this node.
|
||||
* @protected
|
||||
@@ -480,23 +420,12 @@ Blockly.tree.BaseNode.prototype.select = function() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Selects the first node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.selectFirst = function() {
|
||||
var tree = this.getTree();
|
||||
if (tree && this.firstChild_) {
|
||||
tree.setSelectedItem(this.firstChild_);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Called from the tree to instruct the node change its selection state.
|
||||
* @param {boolean} selected The new selection state.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setSelectedInternal = function(selected) {
|
||||
Blockly.tree.BaseNode.prototype.setSelected = function(selected) {
|
||||
if (this.selected_ == selected) {
|
||||
return;
|
||||
}
|
||||
@@ -515,23 +444,6 @@ Blockly.tree.BaseNode.prototype.setSelectedInternal = function(selected) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the node is expanded.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getExpanded = function() {
|
||||
return this.expanded_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the node to be expanded internally, without state change events.
|
||||
* @param {boolean} expanded Whether to expand or close the node.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setExpandedInternal = function(expanded) {
|
||||
this.expanded_ = expanded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the node to be expanded.
|
||||
* @param {boolean} expanded Whether to expand or close the node.
|
||||
@@ -586,7 +498,7 @@ Blockly.tree.BaseNode.prototype.setExpanded = function(expanded) {
|
||||
|
||||
/**
|
||||
* Used to notify a node of that we have expanded it.
|
||||
* Can be overidden by subclasses, see Blockly.tree.TreeNode.
|
||||
* Can be overridden by subclasses, see Blockly.tree.TreeNode.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.doNodeExpanded = function() {
|
||||
@@ -595,7 +507,7 @@ Blockly.tree.BaseNode.prototype.doNodeExpanded = function() {
|
||||
|
||||
/**
|
||||
* Used to notify a node that we have collapsed it.
|
||||
* Can be overidden by subclasses, see Blockly.tree.TreeNode.
|
||||
* Can be overridden by subclasses, see Blockly.tree.TreeNode.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.doNodeCollapsed = function() {
|
||||
@@ -607,15 +519,7 @@ Blockly.tree.BaseNode.prototype.doNodeCollapsed = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.toggle = function() {
|
||||
this.setExpanded(!this.getExpanded());
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the node is collapsible by user actions.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.isUserCollapsible = function() {
|
||||
return this.isUserCollapsible_;
|
||||
this.setExpanded(!this.expanded_);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -624,7 +528,7 @@ Blockly.tree.BaseNode.prototype.isUserCollapsible = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.toDom = function() {
|
||||
var nonEmptyAndExpanded = this.getExpanded() && this.hasChildren();
|
||||
var nonEmptyAndExpanded = this.expanded_ && this.hasChildren();
|
||||
|
||||
var children = document.createElement('div');
|
||||
children.style.backgroundPosition = this.getBackgroundPosition();
|
||||
@@ -661,7 +565,7 @@ Blockly.tree.BaseNode.prototype.getPixelIndent_ = function() {
|
||||
Blockly.tree.BaseNode.prototype.getRowDom = function() {
|
||||
var row = document.createElement('div');
|
||||
row.className = this.getRowClassName();
|
||||
row.style['padding-' + (this.isRightToLeft() ? 'right' : 'left')] =
|
||||
row.style['padding-' + (this.rightToLeft_ ? 'right' : 'left')] =
|
||||
this.getPixelIndent_() + 'px';
|
||||
|
||||
row.appendChild(this.getIconDom());
|
||||
@@ -689,7 +593,7 @@ Blockly.tree.BaseNode.prototype.getRowClassName = function() {
|
||||
Blockly.tree.BaseNode.prototype.getLabelDom = function() {
|
||||
var label = document.createElement('span');
|
||||
label.className = this.config_.cssItemLabel || '';
|
||||
label.textContent = this.getText();
|
||||
label.textContent = this.content;
|
||||
return label;
|
||||
};
|
||||
|
||||
@@ -773,43 +677,6 @@ Blockly.tree.BaseNode.prototype.getChildrenElement = function() {
|
||||
return el ? /** @type {Element} */ (el.lastChild) : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the icon class for the node.
|
||||
* @return {string} s The icon source.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getIconClass = function() {
|
||||
return this.iconClass_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the icon class for when the node is expanded.
|
||||
* @return {string} The class.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getExpandedIconClass = function() {
|
||||
return this.expandedIconClass_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the text of the label.
|
||||
* @param {string} s The plain text of the label.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.setText = function(s) {
|
||||
this.content_ = s;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the text of the label. If the text was originally set as HTML, the
|
||||
* return value is unspecified.
|
||||
* @return {string} The plain text of the label.
|
||||
* @package
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getText = function() {
|
||||
return this.content_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the row styles.
|
||||
* @protected
|
||||
@@ -944,7 +811,7 @@ Blockly.tree.BaseNode.prototype.selectPrevious = function() {
|
||||
* @package
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.selectParent = function() {
|
||||
if (this.hasChildren() && this.getExpanded() && this.isUserCollapsible_) {
|
||||
if (this.hasChildren() && this.expanded_ && this.isUserCollapsible_) {
|
||||
this.setExpanded(false);
|
||||
} else {
|
||||
var parent = this.getParent();
|
||||
@@ -965,10 +832,10 @@ Blockly.tree.BaseNode.prototype.selectParent = function() {
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.selectChild = function() {
|
||||
if (this.hasChildren()) {
|
||||
if (!this.getExpanded()) {
|
||||
if (!this.expanded_) {
|
||||
this.setExpanded(true);
|
||||
} else {
|
||||
this.getFirstChild().select();
|
||||
this.getChildAt(0).select();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -980,11 +847,11 @@ Blockly.tree.BaseNode.prototype.selectChild = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getLastShownDescendant = function() {
|
||||
if (!this.getExpanded() || !this.hasChildren()) {
|
||||
if (!this.expanded_ || !this.hasChildren()) {
|
||||
return this;
|
||||
}
|
||||
// we know there is at least 1 child
|
||||
return this.getLastChild().getLastShownDescendant();
|
||||
return this.getChildAt(this.getChildCount() - 1).getLastShownDescendant();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -993,8 +860,8 @@ Blockly.tree.BaseNode.prototype.getLastShownDescendant = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getNextShownNode = function() {
|
||||
if (this.hasChildren() && this.getExpanded()) {
|
||||
return this.getFirstChild();
|
||||
if (this.hasChildren() && this.expanded_) {
|
||||
return this.getChildAt(0);
|
||||
} else {
|
||||
var parent = this;
|
||||
var next;
|
||||
@@ -1030,14 +897,6 @@ Blockly.tree.BaseNode.prototype.getPreviousShownNode = function() {
|
||||
return /** @type {Blockly.tree.BaseNode} */ (parent);
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!Blockly.tree.BaseNode.Config} The configuration for the tree.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.tree.BaseNode.prototype.getConfig = function() {
|
||||
return this.config_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal method that is used to set the tree control on the node.
|
||||
* @param {Blockly.tree.TreeControl} tree The tree control.
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -75,9 +64,9 @@ Blockly.tree.TreeControl = function(toolbox, config) {
|
||||
Blockly.tree.BaseNode.call(this, '', config);
|
||||
|
||||
// The root is open and selected by default.
|
||||
this.setExpandedInternal(true);
|
||||
this.setSelectedInternal(true);
|
||||
|
||||
this.expanded_ = true;
|
||||
this.selected_ = true;
|
||||
|
||||
/**
|
||||
* Currently selected item.
|
||||
* @type {Blockly.tree.BaseNode}
|
||||
@@ -147,14 +136,9 @@ Blockly.tree.TreeControl.prototype.hasFocus = function() {
|
||||
return this.focused_;
|
||||
};
|
||||
|
||||
/** @override */
|
||||
Blockly.tree.TreeControl.prototype.getExpanded = function() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/** @override */
|
||||
Blockly.tree.TreeControl.prototype.setExpanded = function(expanded) {
|
||||
this.setExpandedInternal(expanded);
|
||||
this.expanded_ = expanded;
|
||||
};
|
||||
|
||||
/** @override */
|
||||
@@ -171,7 +155,7 @@ Blockly.tree.TreeControl.prototype.updateExpandIcon = function() {
|
||||
/** @override */
|
||||
Blockly.tree.TreeControl.prototype.getRowClassName = function() {
|
||||
return Blockly.tree.TreeControl.superClass_.getRowClassName.call(this) +
|
||||
' ' + this.getConfig().cssHideRoot;
|
||||
' ' + this.config_.cssHideRoot;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -180,20 +164,18 @@ Blockly.tree.TreeControl.prototype.getRowClassName = function() {
|
||||
* @override
|
||||
*/
|
||||
Blockly.tree.TreeControl.prototype.getCalculatedIconClass = function() {
|
||||
var expanded = this.getExpanded();
|
||||
var expandedIconClass = this.getExpandedIconClass();
|
||||
if (expanded && expandedIconClass) {
|
||||
return expandedIconClass;
|
||||
var expanded = this.expanded_;
|
||||
if (expanded && this.expandedIconClass) {
|
||||
return this.expandedIconClass;
|
||||
}
|
||||
var iconClass = this.getIconClass();
|
||||
var iconClass = this.iconClass;
|
||||
if (!expanded && iconClass) {
|
||||
return iconClass;
|
||||
}
|
||||
|
||||
// fall back on default icons
|
||||
var config = this.getConfig();
|
||||
if (expanded && config.cssExpandedRootIcon) {
|
||||
return config.cssTreeIcon + ' ' + config.cssExpandedRootIcon;
|
||||
if (expanded && this.config_.cssExpandedRootIcon) {
|
||||
return this.config_.cssTreeIcon + ' ' + this.config_.cssExpandedRootIcon;
|
||||
}
|
||||
return '';
|
||||
};
|
||||
@@ -216,13 +198,13 @@ Blockly.tree.TreeControl.prototype.setSelectedItem = function(node) {
|
||||
var oldNode = this.getSelectedItem();
|
||||
|
||||
if (this.selectedItem_) {
|
||||
this.selectedItem_.setSelectedInternal(false);
|
||||
this.selectedItem_.setSelected(false);
|
||||
}
|
||||
|
||||
this.selectedItem_ = node;
|
||||
|
||||
if (node) {
|
||||
node.setSelectedInternal(true);
|
||||
node.setSelected(true);
|
||||
}
|
||||
|
||||
if (this.onAfterSelected_) {
|
||||
@@ -276,7 +258,7 @@ Blockly.tree.TreeControl.prototype.initAccessibility = function() {
|
||||
Blockly.tree.TreeControl.prototype.enterDocument = function() {
|
||||
Blockly.tree.TreeControl.superClass_.enterDocument.call(this);
|
||||
var el = this.getElement();
|
||||
el.className = this.getConfig().cssRoot;
|
||||
el.className = this.config_.cssRoot;
|
||||
el.setAttribute('hideFocus', 'true');
|
||||
this.attachEvents_();
|
||||
this.initAccessibility();
|
||||
@@ -390,6 +372,10 @@ Blockly.tree.TreeControl.prototype.getNodeFromEvent_ = function(e) {
|
||||
if (target == this.getElement()) {
|
||||
break;
|
||||
}
|
||||
// Don't bubble if we hit a group. See issue #714.
|
||||
if (target.getAttribute('role') == Blockly.utils.aria.Role.GROUP) {
|
||||
return null;
|
||||
}
|
||||
target = target.parentNode;
|
||||
}
|
||||
return null;
|
||||
@@ -403,5 +389,5 @@ Blockly.tree.TreeControl.prototype.getNodeFromEvent_ = function(e) {
|
||||
*/
|
||||
Blockly.tree.TreeControl.prototype.createNode = function(opt_content) {
|
||||
return new Blockly.tree.TreeNode(
|
||||
this.toolbox_, opt_content || '', this.getConfig());
|
||||
this.toolbox_, opt_content || '', this.config_);
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -72,18 +61,17 @@ Blockly.tree.TreeNode.prototype.getTree = function() {
|
||||
* @override
|
||||
*/
|
||||
Blockly.tree.TreeNode.prototype.getCalculatedIconClass = function() {
|
||||
var expanded = this.getExpanded();
|
||||
var expandedIconClass = this.getExpandedIconClass();
|
||||
if (expanded && expandedIconClass) {
|
||||
return expandedIconClass;
|
||||
var expanded = this.expanded_;
|
||||
if (expanded && this.expandedIconClass) {
|
||||
return this.expandedIconClass;
|
||||
}
|
||||
var iconClass = this.getIconClass();
|
||||
var iconClass = this.iconClass;
|
||||
if (!expanded && iconClass) {
|
||||
return iconClass;
|
||||
}
|
||||
|
||||
// fall back on default icons
|
||||
var config = this.getConfig();
|
||||
var config = this.config_;
|
||||
if (this.hasChildren()) {
|
||||
if (expanded && config.cssExpandedFolderIcon) {
|
||||
return config.cssTreeIcon + ' ' + config.cssExpandedFolderIcon;
|
||||
@@ -105,7 +93,7 @@ Blockly.tree.TreeNode.prototype.getCalculatedIconClass = function() {
|
||||
*/
|
||||
Blockly.tree.TreeNode.prototype.onClick_ = function(_e) {
|
||||
// Expand icon.
|
||||
if (this.hasChildren() && this.isUserCollapsible()) {
|
||||
if (this.hasChildren() && this.isUserCollapsible_) {
|
||||
this.toggle();
|
||||
this.select();
|
||||
} else if (this.isSelected()) {
|
||||
@@ -139,8 +127,8 @@ Blockly.tree.TreeNode.prototype.onKeyDown = function(e) {
|
||||
var map = {};
|
||||
var next = Blockly.utils.KeyCodes.DOWN;
|
||||
var prev = Blockly.utils.KeyCodes.UP;
|
||||
map[Blockly.utils.KeyCodes.RIGHT] = this.isRightToLeft() ? prev : next;
|
||||
map[Blockly.utils.KeyCodes.LEFT] = this.isRightToLeft() ? next : prev;
|
||||
map[Blockly.utils.KeyCodes.RIGHT] = this.rightToLeft_ ? prev : next;
|
||||
map[Blockly.utils.KeyCodes.LEFT] = this.rightToLeft_ ? next : prev;
|
||||
map[Blockly.utils.KeyCodes.UP] = Blockly.utils.KeyCodes.LEFT;
|
||||
map[Blockly.utils.KeyCodes.DOWN] = Blockly.utils.KeyCodes.RIGHT;
|
||||
|
||||
@@ -179,7 +167,7 @@ Blockly.tree.TreeNode.prototype.doNodeExpanded =
|
||||
Blockly.tree.TreeNode.prototype.resizeToolbox_;
|
||||
|
||||
/**
|
||||
* Resize the toolbox when a node is collased.
|
||||
* Resize the toolbox when a node is collapsed.
|
||||
* @override
|
||||
*/
|
||||
Blockly.tree.TreeNode.prototype.doNodeCollapsed =
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -169,7 +158,7 @@ Blockly.Connection.prototype.connect_ = function(childConnection) {
|
||||
// Bump it off to the side after a moment.
|
||||
var group = Blockly.Events.getGroup();
|
||||
setTimeout(function() {
|
||||
// Verify orphan hasn't been deleted or reconnected (user on meth).
|
||||
// Verify orphan hasn't been deleted or reconnected.
|
||||
if (orphanBlock.workspace && !orphanBlock.getParent()) {
|
||||
Blockly.Events.setGroup(group);
|
||||
if (orphanBlock.outputConnection) {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -65,12 +54,6 @@ Blockly.CONNECTING_SNAP_RADIUS = Blockly.SNAP_RADIUS;
|
||||
*/
|
||||
Blockly.CURRENT_CONNECTION_PREFERENCE = 8;
|
||||
|
||||
/**
|
||||
* The main colour of insertion markers, in hex. The block is rendered a
|
||||
* transparent grey by changing the fill opacity in CSS.
|
||||
*/
|
||||
Blockly.INSERTION_MARKER_COLOUR = '#000000';
|
||||
|
||||
/**
|
||||
* Delay in ms between trigger and bumping unconnected block out of alignment.
|
||||
*/
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
18
core/css.js
18
core/css.js
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2013 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -331,10 +320,6 @@ Blockly.Css.CONTENT = [
|
||||
'pointer-events: none;',
|
||||
'}',
|
||||
|
||||
'.blocklyBubbleText {',
|
||||
'fill: #000;',
|
||||
'}',
|
||||
|
||||
'.blocklyFlyout {',
|
||||
'position: absolute;',
|
||||
'z-index: 20;',
|
||||
@@ -492,6 +477,7 @@ Blockly.Css.CONTENT = [
|
||||
'.blocklyVerticalMarker {',
|
||||
'stroke-width: 3px;',
|
||||
'fill: rgba(255,255,255,.5);',
|
||||
'pointer-events: none',
|
||||
'}',
|
||||
|
||||
'.blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,',
|
||||
|
||||
@@ -2,18 +2,7 @@
|
||||
* @license
|
||||
* Copyright 2016 Massachusetts Institute of Technology
|
||||
* All rights reserved.
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -116,17 +105,17 @@ Blockly.DropDownDiv.onHide_ = null;
|
||||
|
||||
/**
|
||||
* A class name representing the current owner's workspace renderer.
|
||||
* @type {?string}
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
Blockly.DropDownDiv.rendererClassName_ = null;
|
||||
Blockly.DropDownDiv.rendererClassName_ = '';
|
||||
|
||||
/**
|
||||
* A class name representing the current owner's workspace theme.
|
||||
* @type {?string}
|
||||
* @type {string}
|
||||
* @private
|
||||
*/
|
||||
Blockly.DropDownDiv.themeClassName_ = null;
|
||||
Blockly.DropDownDiv.themeClassName_ = '';
|
||||
|
||||
/**
|
||||
* Create and insert the DOM element for this div.
|
||||
@@ -138,7 +127,8 @@ Blockly.DropDownDiv.createDom = function() {
|
||||
}
|
||||
var div = document.createElement('div');
|
||||
div.className = 'blocklyDropDownDiv';
|
||||
document.body.appendChild(div);
|
||||
var container = Blockly.parentContainer || document.body;
|
||||
container.appendChild(div);
|
||||
/**
|
||||
* The div element.
|
||||
* @type {!Element}
|
||||
@@ -204,7 +194,7 @@ Blockly.DropDownDiv.getContentDiv = function() {
|
||||
* Clear the content of the drop-down.
|
||||
*/
|
||||
Blockly.DropDownDiv.clearContent = function() {
|
||||
Blockly.DropDownDiv.content_.innerHTML = '';
|
||||
Blockly.DropDownDiv.content_.textContent = '';
|
||||
Blockly.DropDownDiv.content_.style.width = '';
|
||||
};
|
||||
|
||||
@@ -351,9 +341,9 @@ Blockly.DropDownDiv.show = function(owner, rtl, primaryX, primaryY,
|
||||
div.style.direction = rtl ? 'rtl' : 'ltr';
|
||||
|
||||
Blockly.DropDownDiv.rendererClassName_ =
|
||||
Blockly.getMainWorkspace().getRenderer().name + '-renderer';
|
||||
Blockly.getMainWorkspace().getRenderer().getClassName();
|
||||
Blockly.DropDownDiv.themeClassName_ =
|
||||
Blockly.getMainWorkspace().getTheme().name + '-theme';
|
||||
Blockly.getMainWorkspace().getTheme().getClassName();
|
||||
Blockly.utils.dom.addClass(div, Blockly.DropDownDiv.rendererClassName_);
|
||||
Blockly.utils.dom.addClass(div, Blockly.DropDownDiv.themeClassName_);
|
||||
|
||||
@@ -653,11 +643,11 @@ Blockly.DropDownDiv.hideWithoutAnimation = function() {
|
||||
|
||||
if (Blockly.DropDownDiv.rendererClassName_) {
|
||||
Blockly.utils.dom.removeClass(div, Blockly.DropDownDiv.rendererClassName_);
|
||||
Blockly.DropDownDiv.rendererClassName_ = null;
|
||||
Blockly.DropDownDiv.rendererClassName_ = '';
|
||||
}
|
||||
if (Blockly.DropDownDiv.themeClassName_) {
|
||||
Blockly.utils.dom.removeClass(div, Blockly.DropDownDiv.themeClassName_);
|
||||
Blockly.DropDownDiv.themeClassName_ = null;
|
||||
Blockly.DropDownDiv.themeClassName_ = '';
|
||||
}
|
||||
Blockly.getMainWorkspace().markFocused();
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2018 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -328,7 +317,7 @@ Blockly.Extensions.mutatorPropertiesMatch_ = function(oldProperties, block) {
|
||||
* to the lookup table.
|
||||
* @param {!Object.<string, string>} lookupTable The table of field values to
|
||||
* tooltip text.
|
||||
* @return {Function} The extension function.
|
||||
* @return {!Function} The extension function.
|
||||
*/
|
||||
Blockly.Extensions.buildTooltipForDropdown = function(dropdownName,
|
||||
lookupTable) {
|
||||
@@ -412,7 +401,7 @@ Blockly.Extensions.checkDropdownOptionsInTable_ = function(block, dropdownName,
|
||||
* @param {string} msgTemplate The template form to of the message text, with
|
||||
* %1 placeholder.
|
||||
* @param {string} fieldName The field with the replacement text.
|
||||
* @return {Function} The extension function.
|
||||
* @return {!Function} The extension function.
|
||||
*/
|
||||
Blockly.Extensions.buildTooltipWithFieldText = function(msgTemplate,
|
||||
fieldName) {
|
||||
|
||||
145
core/field.js
145
core/field.js
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -205,7 +194,7 @@ Blockly.Field.prototype.getText_;
|
||||
* clicked. Blockly will automatically set the field as clickable if this
|
||||
* method is defined.
|
||||
* @param {Event=} opt_e Optional mouse event that triggered the field to open,
|
||||
* or undefined if triggered programatically.
|
||||
* or undefined if triggered programmatically.
|
||||
* @return {void}
|
||||
* @protected
|
||||
*/
|
||||
@@ -260,9 +249,19 @@ Blockly.Field.prototype.setSourceBlock = function(block) {
|
||||
throw Error('Field already bound to a block.');
|
||||
}
|
||||
this.sourceBlock_ = block;
|
||||
if (block.workspace.rendered) {
|
||||
this.constants_ = block.workspace.getRenderer().getConstants();
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the renderer constant provider.
|
||||
* @return {?Blockly.blockRendering.ConstantProvider} The renderer constant
|
||||
* provider.
|
||||
*/
|
||||
Blockly.Field.prototype.getConstants = function() {
|
||||
if (!this.constants_ && this.sourceBlock_ && this.sourceBlock_.workspace &&
|
||||
this.sourceBlock_.workspace.rendered) {
|
||||
this.constants_ = this.sourceBlock_.workspace.getRenderer().getConstants();
|
||||
}
|
||||
return this.constants_;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -321,15 +320,11 @@ Blockly.Field.prototype.initModel = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.createBorderRect_ = function() {
|
||||
this.size_.height =
|
||||
Math.max(this.size_.height, this.constants_.FIELD_BORDER_RECT_HEIGHT);
|
||||
this.size_.width =
|
||||
Math.max(this.size_.width, this.constants_.FIELD_BORDER_RECT_X_PADDING * 2);
|
||||
this.borderRect_ = /** @type {!SVGRectElement} **/
|
||||
(Blockly.utils.dom.createSvgElement('rect',
|
||||
{
|
||||
'rx': this.constants_.FIELD_BORDER_RECT_RADIUS,
|
||||
'ry': this.constants_.FIELD_BORDER_RECT_RADIUS,
|
||||
'rx': this.getConstants().FIELD_BORDER_RECT_RADIUS,
|
||||
'ry': this.getConstants().FIELD_BORDER_RECT_RADIUS,
|
||||
'x': 0,
|
||||
'y': 0,
|
||||
'height': this.size_.height,
|
||||
@@ -345,24 +340,12 @@ Blockly.Field.prototype.createBorderRect_ = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.createTextElement_ = function() {
|
||||
var xOffset = this.borderRect_ ?
|
||||
this.constants_.FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var baselineCenter = this.constants_.FIELD_TEXT_BASELINE_CENTER;
|
||||
var baselineY = this.constants_.FIELD_TEXT_BASELINE_Y;
|
||||
this.size_.height = Math.max(this.size_.height, baselineCenter ?
|
||||
this.constants_.FIELD_TEXT_HEIGHT : baselineY);
|
||||
if (this.size_.height > this.constants_.FIELD_TEXT_HEIGHT) {
|
||||
baselineY += (this.size_.height - baselineY) / 2;
|
||||
}
|
||||
this.textElement_ = /** @type {!SVGTextElement} **/
|
||||
(Blockly.utils.dom.createSvgElement('text',
|
||||
{
|
||||
'class': 'blocklyText',
|
||||
'y': baselineCenter ? this.size_.height / 2 : baselineY,
|
||||
'dy': this.constants_.FIELD_TEXT_Y_OFFSET,
|
||||
'x': xOffset
|
||||
}, this.fieldGroup_));
|
||||
if (baselineCenter) {
|
||||
if (this.getConstants().FIELD_TEXT_BASELINE_CENTER) {
|
||||
this.textElement_.setAttribute('dominant-baseline', 'central');
|
||||
}
|
||||
this.textContent_ = document.createTextNode('');
|
||||
@@ -411,6 +394,7 @@ Blockly.Field.prototype.toXml = function(fieldElement) {
|
||||
Blockly.Field.prototype.dispose = function() {
|
||||
Blockly.DropDownDiv.hideIfOwner(this);
|
||||
Blockly.WidgetDiv.hideIfOwner(this);
|
||||
Blockly.Tooltip.unbindMouseEvents(this.getClickTarget_());
|
||||
|
||||
if (this.mouseDownWrapper_) {
|
||||
Blockly.unbindEvent_(this.mouseDownWrapper_);
|
||||
@@ -598,14 +582,14 @@ Blockly.Field.prototype.applyColour = function() {
|
||||
Blockly.Field.prototype.render_ = function() {
|
||||
if (this.textContent_) {
|
||||
this.textContent_.nodeValue = this.getDisplayText_();
|
||||
this.updateSize_();
|
||||
}
|
||||
this.updateSize_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Show an editor when the field is clicked only if the field is clickable.
|
||||
* @param {Event=} opt_e Optional mouse event that triggered the field to open,
|
||||
* or undefined if triggered programatically.
|
||||
* or undefined if triggered programmatically.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Field.prototype.showEditor = function(opt_e) {
|
||||
@@ -630,22 +614,73 @@ Blockly.Field.prototype.updateWidth = function() {
|
||||
|
||||
/**
|
||||
* Updates the size of the field based on the text.
|
||||
* @param {number=} opt_margin margin to use when positioning the text element.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.updateSize_ = function() {
|
||||
var textWidth = Blockly.utils.dom.getFastTextWidth(
|
||||
/** @type {!SVGTextElement} */ (this.textElement_),
|
||||
this.constants_.FIELD_TEXT_FONTSIZE,
|
||||
this.constants_.FIELD_TEXT_FONTWEIGHT,
|
||||
this.constants_.FIELD_TEXT_FONTFAMILY);
|
||||
var totalWidth = textWidth;
|
||||
if (this.borderRect_) {
|
||||
totalWidth += this.constants_.FIELD_BORDER_RECT_X_PADDING * 2;
|
||||
this.borderRect_.setAttribute('width', totalWidth);
|
||||
Blockly.Field.prototype.updateSize_ = function(opt_margin) {
|
||||
var constants = this.getConstants();
|
||||
var xOffset = opt_margin != undefined ? opt_margin :
|
||||
(this.borderRect_ ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0);
|
||||
var totalWidth = xOffset * 2;
|
||||
var totalHeight = constants.FIELD_TEXT_HEIGHT;
|
||||
|
||||
var contentWidth = 0;
|
||||
if (this.textElement_) {
|
||||
contentWidth = Blockly.utils.dom.getFastTextWidth(this.textElement_,
|
||||
constants.FIELD_TEXT_FONTSIZE,
|
||||
constants.FIELD_TEXT_FONTWEIGHT,
|
||||
constants.FIELD_TEXT_FONTFAMILY);
|
||||
totalWidth += contentWidth;
|
||||
}
|
||||
if (this.borderRect_) {
|
||||
totalHeight = Math.max(totalHeight, constants.FIELD_BORDER_RECT_HEIGHT);
|
||||
}
|
||||
|
||||
this.size_.height = totalHeight;
|
||||
this.size_.width = totalWidth;
|
||||
|
||||
this.positionTextElement_(xOffset, contentWidth);
|
||||
this.positionBorderRect_();
|
||||
};
|
||||
|
||||
/**
|
||||
* Position a field's text element after a size change. This handles both LTR
|
||||
* and RTL positioning.
|
||||
* @param {number} xOffset x offset to use when positioning the text element.
|
||||
* @param {number} contentWidth The content width.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.positionTextElement_ = function(xOffset, contentWidth) {
|
||||
if (!this.textElement_) {
|
||||
return;
|
||||
}
|
||||
var constants = this.getConstants();
|
||||
var halfHeight = this.size_.height / 2;
|
||||
|
||||
this.textElement_.setAttribute('x', this.sourceBlock_.RTL ?
|
||||
this.size_.width - contentWidth - xOffset : xOffset);
|
||||
this.textElement_.setAttribute('y', constants.FIELD_TEXT_BASELINE_CENTER ?
|
||||
halfHeight : halfHeight - constants.FIELD_TEXT_HEIGHT / 2 +
|
||||
constants.FIELD_TEXT_BASELINE);
|
||||
};
|
||||
|
||||
/**
|
||||
* Position a field's border rect after a size change.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.positionBorderRect_ = function() {
|
||||
if (!this.borderRect_) {
|
||||
return;
|
||||
}
|
||||
this.borderRect_.setAttribute('width', this.size_.width);
|
||||
this.borderRect_.setAttribute('height', this.size_.height);
|
||||
this.borderRect_.setAttribute('rx',
|
||||
this.getConstants().FIELD_BORDER_RECT_RADIUS);
|
||||
this.borderRect_.setAttribute('ry',
|
||||
this.getConstants().FIELD_BORDER_RECT_RADIUS);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the height and width of the field.
|
||||
*
|
||||
@@ -772,6 +807,7 @@ Blockly.Field.prototype.setText = function(_newText) {
|
||||
*/
|
||||
Blockly.Field.prototype.markDirty = function() {
|
||||
this.isDirty_ = true;
|
||||
this.constants_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -786,6 +822,7 @@ Blockly.Field.prototype.forceRerender = function() {
|
||||
if (this.sourceBlock_ && this.sourceBlock_.rendered) {
|
||||
this.sourceBlock_.render();
|
||||
this.sourceBlock_.bumpNeighbours();
|
||||
this.updateMarkers_();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -898,7 +935,7 @@ Blockly.Field.prototype.doValueUpdate_ = function(newValue) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to notify the field an invalid value was input. Can be overidden by
|
||||
* Used to notify the field an invalid value was input. Can be overridden by
|
||||
* subclasses, see FieldTextInput.
|
||||
* No-op by default.
|
||||
* @param {*} _invalidValue The input value that was determined to be invalid.
|
||||
@@ -1058,3 +1095,17 @@ Blockly.Field.prototype.setMarkerSvg = function(markerSvg) {
|
||||
this.fieldGroup_.appendChild(markerSvg);
|
||||
this.markerSvg_ = markerSvg;
|
||||
};
|
||||
|
||||
/**
|
||||
* Redraw any attached marker or cursor svgs if needed.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.Field.prototype.updateMarkers_ = function() {
|
||||
var workspace = this.sourceBlock_.workspace;
|
||||
if (workspace.keyboardAccessibilityMode && this.cursorSvg_) {
|
||||
workspace.getCursor().draw();
|
||||
}
|
||||
if (workspace.keyboardAccessibilityMode && this.markerSvg_) {
|
||||
workspace.getMarker(Blockly.navigation.MARKER_NAME).draw();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2013 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -257,7 +246,7 @@ Blockly.FieldAngle.prototype.render_ = function() {
|
||||
/**
|
||||
* Create and show the angle field's editor.
|
||||
* @param {Event=} opt_e Optional mouse event that triggered the field to open,
|
||||
* or undefined if triggered programatically.
|
||||
* or undefined if triggered programmatically.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldAngle.prototype.showEditor_ = function(opt_e) {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -93,15 +82,6 @@ Blockly.FieldCheckbox.prototype.SERIALIZABLE = true;
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.CURSOR = 'default';
|
||||
|
||||
/**
|
||||
* Used to tell if the field needs to be rendered the next time the block is
|
||||
* rendered. Checkbox fields are statically sized, and only need to be
|
||||
* rendered at initialization.
|
||||
* @type {boolean}
|
||||
* @protected
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.isDirty_ = false;
|
||||
|
||||
/**
|
||||
* Configure the field based on the given map of options.
|
||||
* @param {!Object} config A map of options to configure the field based on.
|
||||
@@ -119,19 +99,30 @@ Blockly.FieldCheckbox.prototype.configure_ = function(config) {
|
||||
* @package
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.initView = function() {
|
||||
this.size_.width = this.constants_.FIELD_CHECKBOX_DEFAULT_WIDTH;
|
||||
Blockly.FieldCheckbox.superClass_.initView.call(this);
|
||||
|
||||
this.textElement_.setAttribute('x', this.constants_.FIELD_CHECKBOX_X_OFFSET);
|
||||
this.textElement_.setAttribute('y', this.constants_.FIELD_CHECKBOX_Y_OFFSET);
|
||||
this.textElement_.removeAttribute('dominant-baseline');
|
||||
Blockly.utils.dom.addClass(this.textElement_, 'blocklyCheckbox');
|
||||
|
||||
this.textContent_.nodeValue =
|
||||
this.checkChar_ || Blockly.FieldCheckbox.CHECK_CHAR;
|
||||
Blockly.utils.dom.addClass(
|
||||
/** @type {!SVGTextElement} **/ (this.textElement_), 'blocklyCheckbox');
|
||||
this.textElement_.style.display = this.value_ ? 'block' : 'none';
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.render_ = function() {
|
||||
if (this.textContent_) {
|
||||
this.textContent_.nodeValue = this.getDisplayText_();
|
||||
}
|
||||
this.updateSize_(this.getConstants().FIELD_CHECKBOX_X_OFFSET);
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.getDisplayText_ = function() {
|
||||
return this.checkChar_ || Blockly.FieldCheckbox.CHECK_CHAR;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the character used for the check mark.
|
||||
* @param {?string} character The character to use for the check mark, or
|
||||
@@ -139,9 +130,7 @@ Blockly.FieldCheckbox.prototype.initView = function() {
|
||||
*/
|
||||
Blockly.FieldCheckbox.prototype.setCheckCharacter = function(character) {
|
||||
this.checkChar_ = character;
|
||||
if (this.textContent_) {
|
||||
this.textContent_.nodeValue = character || Blockly.FieldCheckbox.CHECK_CHAR;
|
||||
}
|
||||
this.forceRerender();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -184,9 +173,9 @@ Blockly.FieldColour.prototype.configure_ = function(config) {
|
||||
*/
|
||||
Blockly.FieldColour.prototype.initView = function() {
|
||||
this.size_ = new Blockly.utils.Size(
|
||||
this.constants_.FIELD_COLOUR_DEFAULT_WIDTH,
|
||||
this.constants_.FIELD_COLOUR_DEFAULT_HEIGHT);
|
||||
if (!this.constants_.FIELD_COLOUR_FULL_BLOCK) {
|
||||
this.getConstants().FIELD_COLOUR_DEFAULT_WIDTH,
|
||||
this.getConstants().FIELD_COLOUR_DEFAULT_HEIGHT);
|
||||
if (!this.getConstants().FIELD_COLOUR_FULL_BLOCK) {
|
||||
this.createBorderRect_();
|
||||
this.borderRect_.style['fillOpacity'] = '1';
|
||||
} else {
|
||||
@@ -198,7 +187,7 @@ Blockly.FieldColour.prototype.initView = function() {
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldColour.prototype.applyColour = function() {
|
||||
if (!this.constants_.FIELD_COLOUR_FULL_BLOCK) {
|
||||
if (!this.getConstants().FIELD_COLOUR_FULL_BLOCK) {
|
||||
if (this.borderRect_) {
|
||||
this.borderRect_.style.fill = this.getValue();
|
||||
}
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2015 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -212,7 +201,7 @@ Blockly.FieldDropdown.prototype.initView = function() {
|
||||
this.imageElement_ = /** @type {!SVGImageElement} */
|
||||
(Blockly.utils.dom.createSvgElement('image', {}, this.fieldGroup_));
|
||||
|
||||
if (this.constants_.FIELD_DROPDOWN_SVG_ARROW) {
|
||||
if (this.getConstants().FIELD_DROPDOWN_SVG_ARROW) {
|
||||
this.createSVGArrow_();
|
||||
} else {
|
||||
this.createTextArrow_();
|
||||
@@ -229,8 +218,8 @@ Blockly.FieldDropdown.prototype.initView = function() {
|
||||
* @protected
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.shouldAddBorderRect_ = function() {
|
||||
return !this.constants_.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
|
||||
(this.constants_.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW &&
|
||||
return !this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
|
||||
(this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW &&
|
||||
!this.sourceBlock_.isShadow());
|
||||
};
|
||||
|
||||
@@ -258,17 +247,17 @@ Blockly.FieldDropdown.prototype.createTextArrow_ = function() {
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.createSVGArrow_ = function() {
|
||||
this.svgArrow_ = Blockly.utils.dom.createSvgElement('image', {
|
||||
'height': this.constants_.FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px',
|
||||
'width': this.constants_.FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px'
|
||||
'height': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px',
|
||||
'width': this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE + 'px'
|
||||
}, this.fieldGroup_);
|
||||
this.svgArrow_.setAttributeNS(Blockly.utils.dom.XLINK_NS, 'xlink:href',
|
||||
this.constants_.FIELD_DROPDOWN_SVG_ARROW_DATAURI);
|
||||
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_DATAURI);
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a dropdown menu under the text.
|
||||
* @param {Event=} opt_e Optional mouse event that triggered the field to open,
|
||||
* or undefined if triggered programatically.
|
||||
* or undefined if triggered programmatically.
|
||||
* @private
|
||||
*/
|
||||
Blockly.FieldDropdown.prototype.showEditor_ = function(opt_e) {
|
||||
@@ -284,7 +273,7 @@ Blockly.FieldDropdown.prototype.showEditor_ = function(opt_e) {
|
||||
Blockly.utils.dom.addClass(
|
||||
/** @type {!Element} */ (this.menu_.getElement()), 'blocklyDropdownMenu');
|
||||
|
||||
if (this.constants_.FIELD_DROPDOWN_COLOURED_DIV) {
|
||||
if (this.getConstants().FIELD_DROPDOWN_COLOURED_DIV) {
|
||||
var primaryColour = (this.sourceBlock_.isShadow()) ?
|
||||
this.sourceBlock_.getParent().getColour() :
|
||||
this.sourceBlock_.getColour();
|
||||
@@ -575,10 +564,8 @@ Blockly.FieldDropdown.prototype.render_ = function() {
|
||||
} else {
|
||||
this.renderSelectedText_();
|
||||
}
|
||||
if (this.borderRect_) {
|
||||
this.borderRect_.setAttribute('height', this.size_.height);
|
||||
this.borderRect_.setAttribute('width', this.size_.width);
|
||||
}
|
||||
|
||||
this.positionBorderRect_();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -599,36 +586,36 @@ Blockly.FieldDropdown.prototype.renderSelectedImage_ = function(imageJson) {
|
||||
|
||||
// Height and width include the border rect.
|
||||
var hasBorder = !!this.borderRect_;
|
||||
this.size_.height = Math.max(
|
||||
hasBorder ? this.constants_.FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
||||
var height = Math.max(
|
||||
hasBorder ? this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
||||
imageHeight + Blockly.FieldDropdown.IMAGE_Y_PADDING);
|
||||
var halfHeight = this.size_.height / 2;
|
||||
var xPadding = hasBorder ? this.constants_.FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var arrowWidth = 0;
|
||||
if (this.svgArrow_) {
|
||||
arrowWidth = this.positionSVGArrow_(imageWidth + xPadding, halfHeight -
|
||||
this.constants_.FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
||||
arrowWidth = this.positionSVGArrow_(imageWidth + xPadding, height / 2 -
|
||||
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
||||
} else {
|
||||
arrowWidth = Blockly.utils.dom.getFastTextWidth(
|
||||
/** @type {!SVGTSpanElement} */ (this.arrow_),
|
||||
this.constants_.FIELD_TEXT_FONTSIZE,
|
||||
this.constants_.FIELD_TEXT_FONTWEIGHT,
|
||||
this.constants_.FIELD_TEXT_FONTFAMILY);
|
||||
this.getConstants().FIELD_TEXT_FONTSIZE,
|
||||
this.getConstants().FIELD_TEXT_FONTWEIGHT,
|
||||
this.getConstants().FIELD_TEXT_FONTFAMILY);
|
||||
}
|
||||
this.size_.width = imageWidth + arrowWidth + xPadding * 2;
|
||||
this.size_.height = height;
|
||||
|
||||
var arrowX = 0;
|
||||
if (this.sourceBlock_.RTL) {
|
||||
var imageX = xPadding + arrowWidth;
|
||||
var arrowX = xPadding - 1;
|
||||
this.imageElement_.setAttribute('x', imageX);
|
||||
this.textElement_.setAttribute('x', arrowX);
|
||||
} else {
|
||||
var arrowX = imageWidth + arrowWidth + xPadding + 1;
|
||||
arrowX = imageWidth + arrowWidth;
|
||||
this.textElement_.setAttribute('text-anchor', 'end');
|
||||
this.textElement_.setAttribute('x', arrowX);
|
||||
this.imageElement_.setAttribute('x', xPadding);
|
||||
}
|
||||
this.imageElement_.setAttribute('y', halfHeight - imageHeight / 2);
|
||||
this.imageElement_.setAttribute('y', height / 2 - imageHeight / 2);
|
||||
|
||||
this.positionTextElement_(arrowX + xPadding, imageWidth + arrowWidth);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -644,31 +631,23 @@ Blockly.FieldDropdown.prototype.renderSelectedText_ = function() {
|
||||
|
||||
// Height and width include the border rect.
|
||||
var hasBorder = !!this.borderRect_;
|
||||
this.size_.height = Math.max(
|
||||
hasBorder ? this.constants_.FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
||||
this.constants_.FIELD_TEXT_HEIGHT);
|
||||
var halfHeight = this.size_.height / 2;
|
||||
var height = Math.max(
|
||||
hasBorder ? this.getConstants().FIELD_DROPDOWN_BORDER_RECT_HEIGHT : 0,
|
||||
this.getConstants().FIELD_TEXT_HEIGHT);
|
||||
var textWidth = Blockly.utils.dom.getFastTextWidth(this.textElement_,
|
||||
this.constants_.FIELD_TEXT_FONTSIZE,
|
||||
this.constants_.FIELD_TEXT_FONTWEIGHT,
|
||||
this.constants_.FIELD_TEXT_FONTFAMILY);
|
||||
var xPadding = hasBorder ? this.constants_.FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
this.getConstants().FIELD_TEXT_FONTSIZE,
|
||||
this.getConstants().FIELD_TEXT_FONTWEIGHT,
|
||||
this.getConstants().FIELD_TEXT_FONTFAMILY);
|
||||
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var arrowWidth = 0;
|
||||
if (this.svgArrow_) {
|
||||
arrowWidth = this.positionSVGArrow_(textWidth + xPadding, halfHeight -
|
||||
this.constants_.FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
||||
arrowWidth = this.positionSVGArrow_(textWidth + xPadding, height / 2 -
|
||||
this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE / 2);
|
||||
}
|
||||
this.size_.width = textWidth + arrowWidth + xPadding * 2;
|
||||
this.size_.height = height;
|
||||
|
||||
this.textElement_.setAttribute('x', this.sourceBlock_.RTL ?
|
||||
this.size_.width - textWidth - xPadding : xPadding);
|
||||
this.textElement_.setAttribute('y', halfHeight);
|
||||
if (!this.constants_.FIELD_TEXT_BASELINE_CENTER) {
|
||||
this.textElement_.setAttribute('dy',
|
||||
this.constants_.FIELD_TEXT_BASELINE_Y -
|
||||
this.constants_.FIELD_TEXT_HEIGHT / 2 +
|
||||
this.constants_.FIELD_TEXT_Y_OFFSET);
|
||||
}
|
||||
this.positionTextElement_(xPadding, textWidth);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -683,9 +662,9 @@ Blockly.FieldDropdown.prototype.positionSVGArrow_ = function(x, y) {
|
||||
return 0;
|
||||
}
|
||||
var hasBorder = !!this.borderRect_;
|
||||
var xPadding = hasBorder ? this.constants_.FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var textPadding = this.constants_.FIELD_DROPDOWN_SVG_ARROW_PADDING;
|
||||
var svgArrowSize = this.constants_.FIELD_DROPDOWN_SVG_ARROW_SIZE;
|
||||
var xPadding = hasBorder ? this.getConstants().FIELD_BORDER_RECT_X_PADDING : 0;
|
||||
var textPadding = this.getConstants().FIELD_DROPDOWN_SVG_ARROW_PADDING;
|
||||
var svgArrowSize = this.getConstants().FIELD_DROPDOWN_SVG_ARROW_SIZE;
|
||||
var arrowX = this.sourceBlock_.RTL ? xPadding : x + textPadding;
|
||||
this.svgArrow_.setAttribute('transform',
|
||||
'translate(' + arrowX + ',' + y + ')');
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -191,6 +180,17 @@ Blockly.FieldImage.prototype.initView = function() {
|
||||
this.fieldGroup_));
|
||||
this.imageElement_.setAttributeNS(Blockly.utils.dom.XLINK_NS,
|
||||
'xlink:href', /** @type {string} */ (this.value_));
|
||||
|
||||
if (this.clickHandler_) {
|
||||
this.imageElement_.style.cursor = 'pointer';
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldImage.prototype.updateSize_ = function() {
|
||||
// NOP
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -71,13 +60,6 @@ Blockly.utils.object.inherits(Blockly.FieldMultilineInput,
|
||||
Blockly.FieldTextInput);
|
||||
|
||||
|
||||
/**
|
||||
* The default height of a single line of text.
|
||||
* @type {number}
|
||||
* @const
|
||||
*/
|
||||
Blockly.FieldMultilineInput.LINE_HEIGHT = 20;
|
||||
|
||||
/**
|
||||
* Construct a FieldMultilineInput from a JSON arg object,
|
||||
* dereferencing any string table references.
|
||||
@@ -154,14 +136,16 @@ Blockly.FieldMultilineInput.prototype.render_ = function() {
|
||||
var lines = this.getDisplayText_().split('\n');
|
||||
var y = 0;
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var lineHeight = this.getConstants().FIELD_TEXT_HEIGHT +
|
||||
this.getConstants().FIELD_BORDER_RECT_Y_PADDING;
|
||||
var span = Blockly.utils.dom.createSvgElement('text', {
|
||||
'class': 'blocklyText blocklyMultilineText',
|
||||
x: this.constants_.FIELD_BORDER_RECT_X_PADDING,
|
||||
y: y + this.constants_.FIELD_BORDER_RECT_Y_PADDING,
|
||||
dy: Blockly.FieldMultilineInput.LINE_HEIGHT / 2
|
||||
x: this.getConstants().FIELD_BORDER_RECT_X_PADDING,
|
||||
y: y + this.getConstants().FIELD_BORDER_RECT_Y_PADDING,
|
||||
dy: this.getConstants().FIELD_TEXT_BASELINE
|
||||
}, this.textGroup_);
|
||||
span.appendChild(document.createTextNode(lines[i]));
|
||||
y += Blockly.FieldMultilineInput.LINE_HEIGHT;
|
||||
y += lineHeight;
|
||||
}
|
||||
|
||||
this.updateSize_();
|
||||
@@ -202,34 +186,19 @@ Blockly.FieldMultilineInput.prototype.updateSize_ = function() {
|
||||
if (textWidth > totalWidth) {
|
||||
totalWidth = textWidth;
|
||||
}
|
||||
totalHeight += Blockly.FieldMultilineInput.LINE_HEIGHT;
|
||||
totalHeight += this.getConstants().FIELD_TEXT_HEIGHT +
|
||||
(i > 0 ? this.getConstants().FIELD_BORDER_RECT_Y_PADDING : 0);
|
||||
}
|
||||
if (this.borderRect_) {
|
||||
totalWidth += this.constants_.FIELD_BORDER_RECT_X_PADDING * 2;
|
||||
totalHeight += this.getConstants().FIELD_BORDER_RECT_Y_PADDING * 2;
|
||||
totalWidth += this.getConstants().FIELD_BORDER_RECT_X_PADDING * 2;
|
||||
this.borderRect_.setAttribute('width', totalWidth);
|
||||
this.borderRect_.setAttribute('height', totalHeight);
|
||||
}
|
||||
this.size_.width = totalWidth;
|
||||
this.size_.height = totalHeight;
|
||||
};
|
||||
|
||||
/**
|
||||
* Resize the editor to fit the text.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.FieldMultilineInput.prototype.resizeEditor_ = function() {
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
var bBox = this.getScaledBBox();
|
||||
div.style.width = bBox.right - bBox.left + 'px';
|
||||
div.style.height = bBox.bottom - bBox.top + 'px';
|
||||
|
||||
// In RTL mode block fields and LTR input fields the left edge moves,
|
||||
// whereas the right edge is fixed. Reposition the editor.
|
||||
var x = this.sourceBlock_.RTL ? bBox.right - div.offsetWidth : bBox.left;
|
||||
var xy = new Blockly.utils.Coordinate(x, bBox.top);
|
||||
|
||||
div.style.left = xy.x + 'px';
|
||||
div.style.top = xy.y + 'px';
|
||||
this.positionBorderRect_();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -239,21 +208,24 @@ Blockly.FieldMultilineInput.prototype.resizeEditor_ = function() {
|
||||
*/
|
||||
Blockly.FieldMultilineInput.prototype.widgetCreate_ = function() {
|
||||
var div = Blockly.WidgetDiv.DIV;
|
||||
var scale = this.workspace_.scale;
|
||||
var scale = this.workspace_.getScale();
|
||||
|
||||
var htmlInput = /** @type {HTMLTextAreaElement} */ (document.createElement('textarea'));
|
||||
var htmlInput =
|
||||
/** @type {HTMLTextAreaElement} */ (document.createElement('textarea'));
|
||||
htmlInput.className = 'blocklyHtmlInput blocklyHtmlTextAreaInput';
|
||||
htmlInput.setAttribute('spellcheck', this.spellcheck_);
|
||||
var fontSize = (this.constants_.FIELD_TEXT_FONTSIZE * scale) + 'pt';
|
||||
var fontSize = (this.getConstants().FIELD_TEXT_FONTSIZE * scale) + 'pt';
|
||||
div.style.fontSize = fontSize;
|
||||
htmlInput.style.fontSize = fontSize;
|
||||
var borderRadius = (Blockly.FieldTextInput.BORDERRADIUS * scale) + 'px';
|
||||
htmlInput.style.borderRadius = borderRadius;
|
||||
var padding = this.constants_.FIELD_BORDER_RECT_X_PADDING * scale;
|
||||
htmlInput.style.paddingLeft = padding + 'px';
|
||||
htmlInput.style.width = 'calc(100% - ' + padding + 'px)';
|
||||
htmlInput.style.lineHeight =
|
||||
(Blockly.FieldMultilineInput.LINE_HEIGHT * scale) + 'px';
|
||||
var paddingX = this.getConstants().FIELD_BORDER_RECT_X_PADDING * scale;
|
||||
var paddingY = this.getConstants().FIELD_BORDER_RECT_Y_PADDING * scale / 2;
|
||||
htmlInput.style.padding = paddingY + 'px ' + paddingX + 'px ' + paddingY +
|
||||
'px ' + paddingX + 'px';
|
||||
var lineHeight = this.getConstants().FIELD_TEXT_HEIGHT +
|
||||
this.getConstants().FIELD_BORDER_RECT_Y_PADDING;
|
||||
htmlInput.style.lineHeight = (lineHeight * scale) + 'px';
|
||||
|
||||
div.appendChild(htmlInput);
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -139,7 +128,7 @@ Blockly.FieldTextInput.prototype.configure_ = function(config) {
|
||||
* @override
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.initView = function() {
|
||||
if (this.constants_.FULL_BLOCK_FIELDS) {
|
||||
if (this.getConstants().FULL_BLOCK_FIELDS) {
|
||||
// Step one: figure out if this is the only field on this block.
|
||||
// Rendering is quite different in that case.
|
||||
var nFields = 0;
|
||||
@@ -227,13 +216,13 @@ Blockly.FieldTextInput.prototype.doValueUpdate_ = function(newValue) {
|
||||
* @package
|
||||
*/
|
||||
Blockly.FieldTextInput.prototype.applyColour = function() {
|
||||
if (this.sourceBlock_ && this.constants_.FULL_BLOCK_FIELDS) {
|
||||
if (this.sourceBlock_ && this.getConstants().FULL_BLOCK_FIELDS) {
|
||||
if (this.borderRect_) {
|
||||
this.borderRect_.setAttribute('stroke',
|
||||
this.sourceBlock_.style.colourTertiary);
|
||||
} else {
|
||||
this.sourceBlock_.pathObject.svgPath.setAttribute('fill',
|
||||
this.constants_.FIELD_BORDER_RECT_COLOUR);
|
||||
this.getConstants().FIELD_BORDER_RECT_COLOUR);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -279,7 +268,7 @@ Blockly.FieldTextInput.prototype.setSpellcheck = function(check) {
|
||||
/**
|
||||
* Show the inline free-text editor on top of the text.
|
||||
* @param {Event=} _opt_e Optional mouse event that triggered the field to open,
|
||||
* or undefined if triggered programatically.
|
||||
* or undefined if triggered programmatically.
|
||||
* @param {boolean=} opt_quietInput True if editor should be created without
|
||||
* focus. Defaults to false.
|
||||
* @protected
|
||||
@@ -341,9 +330,9 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
var htmlInput = /** @type {HTMLInputElement} */ (document.createElement('input'));
|
||||
htmlInput.className = 'blocklyHtmlInput';
|
||||
htmlInput.setAttribute('spellcheck', this.spellcheck_);
|
||||
var scale = this.workspace_.scale;
|
||||
var scale = this.workspace_.getScale();
|
||||
var fontSize =
|
||||
(this.constants_.FIELD_TEXT_FONTSIZE * scale) + 'pt';
|
||||
(this.getConstants().FIELD_TEXT_FONTSIZE * scale) + 'pt';
|
||||
div.style.fontSize = fontSize;
|
||||
htmlInput.style.fontSize = fontSize;
|
||||
var borderRadius =
|
||||
@@ -361,7 +350,7 @@ Blockly.FieldTextInput.prototype.widgetCreate_ = function() {
|
||||
htmlInput.style.border = (1 * scale) + 'px solid ' + strokeColour;
|
||||
div.style.borderRadius = borderRadius;
|
||||
div.style.transition = 'box-shadow 0.25s ease 0s';
|
||||
if (this.constants_.FIELD_TEXTINPUT_BOX_SHADOW) {
|
||||
if (this.getConstants().FIELD_TEXTINPUT_BOX_SHADOW) {
|
||||
div.style.boxShadow = 'rgba(255, 255, 255, 0.3) 0px 0px 0px ' +
|
||||
4 * scale + 'px';
|
||||
}
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -156,7 +145,7 @@ Blockly.FieldVariable.prototype.initModel = function() {
|
||||
*/
|
||||
Blockly.FieldVariable.prototype.shouldAddBorderRect_ = function() {
|
||||
return Blockly.FieldVariable.superClass_.shouldAddBorderRect_.call(this) &&
|
||||
(!this.constants_.FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
|
||||
(!this.getConstants().FIELD_DROPDOWN_NO_BORDER_RECT_SHADOW ||
|
||||
this.sourceBlock_.type != 'variables_get');
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -57,6 +46,8 @@ Blockly.Flyout = function(workspaceOptions) {
|
||||
*/
|
||||
this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions);
|
||||
this.workspace_.isFlyout = true;
|
||||
// Keep the workspace visibility consistent with the flyout's visibility.
|
||||
this.workspace_.setVisible(this.isVisible_);
|
||||
|
||||
/**
|
||||
* Is RTL vs LTR.
|
||||
@@ -557,6 +548,7 @@ Blockly.Flyout.prototype.clearOldBlocks_ = function() {
|
||||
for (var j = 0; j < this.mats_.length; j++) {
|
||||
var rect = this.mats_[j];
|
||||
if (rect) {
|
||||
Blockly.Tooltip.unbindMouseEvents(rect);
|
||||
Blockly.utils.dom.removeNode(rect);
|
||||
}
|
||||
}
|
||||
@@ -638,8 +630,8 @@ Blockly.Flyout.prototype.isBlockCreatable_ = function(block) {
|
||||
/**
|
||||
* Create a copy of this block on the workspace.
|
||||
* @param {!Blockly.BlockSvg} originalBlock The block to copy from the flyout.
|
||||
* @return {Blockly.BlockSvg} The newly created block, or null if something
|
||||
* went wrong with deserialization.
|
||||
* @return {!Blockly.BlockSvg} The newly created block.
|
||||
* @throws {Error} if something went wrong with deserialization.
|
||||
* @package
|
||||
*/
|
||||
Blockly.Flyout.prototype.createBlock = function(originalBlock) {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -97,9 +86,14 @@ Blockly.FlyoutButton = function(workspace, targetWorkspace, xml, isLabel) {
|
||||
};
|
||||
|
||||
/**
|
||||
* The margin around the text in the button.
|
||||
* The horizontal margin around the text in the button.
|
||||
*/
|
||||
Blockly.FlyoutButton.MARGIN = 5;
|
||||
Blockly.FlyoutButton.MARGIN_X = 5;
|
||||
|
||||
/**
|
||||
* The vertical margin around the text in the button.
|
||||
*/
|
||||
Blockly.FlyoutButton.MARGIN_Y = 2;
|
||||
|
||||
/**
|
||||
* The width of the button's rect.
|
||||
@@ -164,11 +158,18 @@ Blockly.FlyoutButton.prototype.createDom = function() {
|
||||
'flyoutForegroundColour', 'fill');
|
||||
}
|
||||
|
||||
this.width = Blockly.utils.dom.getTextWidth(svgText);
|
||||
this.height = 20; // Can't compute it :(
|
||||
|
||||
var fontSize = Blockly.utils.style.getComputedStyle(svgText, 'fontSize');
|
||||
var fontWeight = Blockly.utils.style.getComputedStyle(svgText, 'fontWeight');
|
||||
var fontFamily = Blockly.utils.style.getComputedStyle(svgText, 'fontFamily');
|
||||
this.width = Blockly.utils.dom.getFastTextWidthWithSizeString(svgText,
|
||||
fontSize, fontWeight, fontFamily);
|
||||
var fontMetrics = Blockly.utils.dom.measureFontMetrics(text, fontSize,
|
||||
fontWeight, fontFamily);
|
||||
this.height = fontMetrics.height;
|
||||
|
||||
if (!this.isLabel_) {
|
||||
this.width += 2 * Blockly.FlyoutButton.MARGIN;
|
||||
this.width += 2 * Blockly.FlyoutButton.MARGIN_X;
|
||||
this.height += 2 * Blockly.FlyoutButton.MARGIN_Y;
|
||||
shadow.setAttribute('width', this.width);
|
||||
shadow.setAttribute('height', this.height);
|
||||
}
|
||||
@@ -176,7 +177,8 @@ Blockly.FlyoutButton.prototype.createDom = function() {
|
||||
rect.setAttribute('height', this.height);
|
||||
|
||||
svgText.setAttribute('x', this.width / 2);
|
||||
svgText.setAttribute('y', this.height - Blockly.FlyoutButton.MARGIN);
|
||||
svgText.setAttribute('y', this.height / 2 - fontMetrics.height / 2 +
|
||||
fontMetrics.baseline);
|
||||
|
||||
this.updateTransform_();
|
||||
|
||||
@@ -292,9 +294,5 @@ Blockly.Css.register([
|
||||
'.blocklyFlyoutLabelBackground {',
|
||||
'opacity: 0;',
|
||||
'}',
|
||||
|
||||
'.blocklyFlyoutLabelText {',
|
||||
'fill: #000;',
|
||||
'}'
|
||||
/* eslint-enable indent */
|
||||
]);
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
15
core/grid.js
15
core/grid.js
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -178,7 +167,7 @@ Blockly.Grid.prototype.setLineAttributes_ = function(line, width,
|
||||
* Move the grid to a new x and y position, and make sure that change is
|
||||
* visible.
|
||||
* @param {number} x The new x position of the grid (in px).
|
||||
* @param {number} y The new y position ofthe grid (in px).
|
||||
* @param {number} y The new y position of the grid (in px).
|
||||
* @package
|
||||
*/
|
||||
Blockly.Grid.prototype.moveTo = function(x, y) {
|
||||
|
||||
13
core/icon.js
13
core/icon.js
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2013 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2011 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -167,9 +156,9 @@ Blockly.createMainWorkspace_ = function(svg, options, blockDragSurface,
|
||||
|
||||
// Set the theme name and renderer name onto the injection div.
|
||||
Blockly.utils.dom.addClass(mainWorkspace.getInjectionDiv(),
|
||||
(wsOptions.renderer || 'geras') + '-renderer');
|
||||
mainWorkspace.getRenderer().getClassName());
|
||||
Blockly.utils.dom.addClass(mainWorkspace.getInjectionDiv(),
|
||||
mainWorkspace.getTheme().name + '-theme');
|
||||
mainWorkspace.getTheme().getClassName());
|
||||
|
||||
if (!wsOptions.hasCategories && wsOptions.languageTree) {
|
||||
// Add flyout as an <svg> that is a sibling of the workspace svg.
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2017 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -116,20 +105,19 @@ Blockly.InsertionMarkerManager = function(block) {
|
||||
this.markerConnection_ = null;
|
||||
|
||||
/**
|
||||
* Whether we are currently highlighting the block (shadow or real) that would
|
||||
* be replaced if the drag were released immediately.
|
||||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
this.highlightingBlock_ = false;
|
||||
|
||||
/**
|
||||
* The block that is being highlighted for replacement, or null.
|
||||
* The block that currently has an input being highlighted, or null.
|
||||
* @type {Blockly.BlockSvg}
|
||||
* @private
|
||||
*/
|
||||
this.highlightedBlock_ = null;
|
||||
|
||||
/**
|
||||
* The block being faded to indicate replacement, or null.
|
||||
* @type {Blockly.BlockSvg}
|
||||
* @private
|
||||
*/
|
||||
this.fadedBlock_ = null;
|
||||
|
||||
/**
|
||||
* The connections on the dragging blocks that are available to connect to
|
||||
* other blocks. This includes all open connections on the top block, as well
|
||||
@@ -141,6 +129,17 @@ Blockly.InsertionMarkerManager = function(block) {
|
||||
this.availableConnections_ = this.initAvailableConnections_();
|
||||
};
|
||||
|
||||
/**
|
||||
* An enum describing different kinds of previews the InsertionMarkerManager
|
||||
* could display.
|
||||
* @enum {number}
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.PREVIEW_TYPE = {
|
||||
INSERTION_MARKER: 0,
|
||||
INPUT_OUTLINE: 1,
|
||||
REPLACEMENT_FADE: 2,
|
||||
};
|
||||
|
||||
/**
|
||||
* Sever all links from this object.
|
||||
* @package
|
||||
@@ -210,7 +209,7 @@ Blockly.InsertionMarkerManager.prototype.applyConnections = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Update highlighted connections based on the most recent move location.
|
||||
* Update connections based on the most recent move location.
|
||||
* @param {!Blockly.utils.Coordinate} dxy Position relative to drag start,
|
||||
* in workspace units.
|
||||
* @param {?number} deleteArea One of {@link Blockly.DELETE_AREA_TRASH},
|
||||
@@ -255,16 +254,19 @@ Blockly.InsertionMarkerManager.prototype.createMarkerBlock_ = function(sourceBlo
|
||||
}
|
||||
}
|
||||
result.setCollapsed(sourceBlock.isCollapsed());
|
||||
// Copy field values from the other block. These values may impact the
|
||||
// rendered size of the insertion marker. Note that we do not care about
|
||||
// child blocks here.
|
||||
result.setInputsInline(sourceBlock.getInputsInline());
|
||||
// Copy visible field values from the other block. These values may impact
|
||||
// the rendered size of the insertion marker. Note that we do not care
|
||||
// about child blocks here.
|
||||
for (var i = 0; i < sourceBlock.inputList.length; i++) {
|
||||
var sourceInput = sourceBlock.inputList[i];
|
||||
var resultInput = result.inputList[i];
|
||||
for (var j = 0; j < sourceInput.fieldRow.length; j++) {
|
||||
var sourceField = sourceInput.fieldRow[j];
|
||||
var resultField = resultInput.fieldRow[j];
|
||||
resultField.setValue(sourceField.getValue());
|
||||
if (sourceInput.isVisible()) {
|
||||
var resultInput = result.inputList[i];
|
||||
for (var j = 0; j < sourceInput.fieldRow.length; j++) {
|
||||
var sourceField = sourceInput.fieldRow[j];
|
||||
var resultField = resultInput.fieldRow[j];
|
||||
resultField.setValue(sourceField.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -394,48 +396,6 @@ Blockly.InsertionMarkerManager.prototype.getStartRadius_ = function() {
|
||||
return Blockly.SNAP_RADIUS;
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether ending the drag would replace a block or insert a block.
|
||||
* @return {boolean} True if dropping the block immediately would replace
|
||||
* another block. False if dropping the block immediately would result in
|
||||
* the block being inserted in a block stack.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.shouldReplace_ = function() {
|
||||
var closest = this.closestConnection_;
|
||||
var local = this.localConnection_;
|
||||
|
||||
// Dragging a block over an existing block in an input.
|
||||
if (local.type == Blockly.OUTPUT_VALUE) {
|
||||
// Insert the dragged block into the stack if possible.
|
||||
if (closest &&
|
||||
this.workspace_.getRenderer()
|
||||
.shouldInsertDraggedBlock(this.topBlock_, closest)) {
|
||||
return false; // Insert.
|
||||
}
|
||||
// Otherwise replace the existing block and bump it out.
|
||||
return true; // Replace.
|
||||
}
|
||||
|
||||
// Connecting to a statement input of c-block is an insertion, even if that
|
||||
// c-block is terminal (e.g. forever).
|
||||
if (local == local.getSourceBlock().getFirstStatementConnection()) {
|
||||
return false; // Insert.
|
||||
}
|
||||
|
||||
// Dragging a terminal block over another (connected) terminal block will
|
||||
// replace, not insert.
|
||||
var isTerminalBlock = !this.topBlock_.nextConnection;
|
||||
var isConnectedTerminal = isTerminalBlock &&
|
||||
local.type == Blockly.PREVIOUS_STATEMENT && closest.isConnected();
|
||||
if (isConnectedTerminal) {
|
||||
return true; // Replace.
|
||||
}
|
||||
|
||||
// Otherwise it's an insertion.
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Whether ending the drag would delete the block.
|
||||
* @param {!Object} candidate An object containing a local connection, a closest
|
||||
@@ -498,16 +458,28 @@ Blockly.InsertionMarkerManager.prototype.maybeShowPreview_ = function(candidate)
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.showPreview_ = function() {
|
||||
if (this.shouldReplace_()) {
|
||||
this.highlightBlock_();
|
||||
} else { // Should insert
|
||||
this.connectMarker_();
|
||||
var closest = this.closestConnection_;
|
||||
var renderer = this.workspace_.getRenderer();
|
||||
var method = renderer.getConnectionPreviewMethod(
|
||||
/** @type {!Blockly.RenderedConnection} */ (closest),
|
||||
/** @type {!Blockly.RenderedConnection} */ (this.localConnection_),
|
||||
this.topBlock_);
|
||||
|
||||
switch (method) {
|
||||
case Blockly.InsertionMarkerManager.PREVIEW_TYPE.INPUT_OUTLINE:
|
||||
this.showInsertionInputOutline_();
|
||||
break;
|
||||
case Blockly.InsertionMarkerManager.PREVIEW_TYPE.INSERTION_MARKER:
|
||||
this.showInsertionMarker_();
|
||||
break;
|
||||
case Blockly.InsertionMarkerManager.PREVIEW_TYPE.REPLACEMENT_FADE:
|
||||
this.showReplacementFade_();
|
||||
break;
|
||||
}
|
||||
// Also highlight the actual connection, as a nod to previous behaviour.
|
||||
if (this.closestConnection_ && this.closestConnection_.targetBlock() &&
|
||||
this.workspace_.getRenderer()
|
||||
.shouldHighlightConnection(this.closestConnection_)) {
|
||||
this.closestConnection_.highlight();
|
||||
|
||||
// Optionally highlight the actual connection, as a nod to previous behaviour.
|
||||
if (closest && renderer.shouldHighlightConnection(closest)) {
|
||||
closest.highlight();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -555,53 +527,57 @@ Blockly.InsertionMarkerManager.prototype.hidePreview_ = function() {
|
||||
.shouldHighlightConnection(this.closestConnection_)) {
|
||||
this.closestConnection_.unhighlight();
|
||||
}
|
||||
if (this.highlightingBlock_) {
|
||||
this.unhighlightBlock_();
|
||||
if (this.fadedBlock_) {
|
||||
this.hideReplacementFade_();
|
||||
} else if (this.highlightedBlock_) {
|
||||
this.hideInsertionInputOutline_();
|
||||
} else if (this.markerConnection_) {
|
||||
this.disconnectMarker_();
|
||||
this.hideInsertionMarker_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Add highlighting showing which block will be replaced.
|
||||
* Shows an insertion marker connected to the appropriate blocks (based on
|
||||
* manager state).
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.highlightBlock_ = function() {
|
||||
var closest = this.closestConnection_;
|
||||
Blockly.InsertionMarkerManager.prototype.showInsertionMarker_ = function() {
|
||||
var local = this.localConnection_;
|
||||
if (closest.targetBlock()) {
|
||||
this.highlightedBlock_ = closest.targetBlock();
|
||||
closest.targetBlock().highlightForReplacement(true);
|
||||
} else if (local.type == Blockly.OUTPUT_VALUE) {
|
||||
this.highlightedBlock_ = closest.getSourceBlock();
|
||||
closest.getSourceBlock().highlightShapeForInput(closest, true);
|
||||
}
|
||||
this.highlightingBlock_ = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get rid of the highlighting marking the block that will be replaced.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.unhighlightBlock_ = function() {
|
||||
var closest = this.closestConnection_;
|
||||
// If there's no block in place, but we're still connecting to a value input,
|
||||
// then we must have been highlighting an input shape.
|
||||
if (closest.type == Blockly.INPUT_VALUE && !closest.isConnected()) {
|
||||
this.highlightedBlock_.highlightShapeForInput(closest, false);
|
||||
} else {
|
||||
this.highlightedBlock_.highlightForReplacement(false);
|
||||
|
||||
var isLastInStack = this.lastOnStack_ && local == this.lastOnStack_;
|
||||
var imBlock = isLastInStack ? this.lastMarker_ : this.firstMarker_;
|
||||
var imConn = imBlock.getMatchingConnection(local.getSourceBlock(), local);
|
||||
|
||||
if (imConn == this.markerConnection_) {
|
||||
throw Error('Made it to showInsertionMarker_ even though the marker isn\'t ' +
|
||||
'changing');
|
||||
}
|
||||
this.highlightedBlock_ = null;
|
||||
this.highlightingBlock_ = false;
|
||||
|
||||
// Render disconnected from everything else so that we have a valid
|
||||
// connection location.
|
||||
imBlock.render();
|
||||
imBlock.rendered = true;
|
||||
imBlock.getSvgRoot().setAttribute('visibility', 'visible');
|
||||
|
||||
if (imConn && closest) {
|
||||
// Position so that the existing block doesn't move.
|
||||
imBlock.positionNearConnection(imConn, closest);
|
||||
}
|
||||
if (closest) {
|
||||
// Connect() also renders the insertion marker.
|
||||
imConn.connect(closest);
|
||||
}
|
||||
|
||||
this.markerConnection_ = imConn;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disconnect the insertion marker block in a manner that returns the stack to
|
||||
* original state.
|
||||
* Disconnects and hides the current insertion marker. Should return the blocks
|
||||
* to their original state.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.disconnectMarker_ = function() {
|
||||
Blockly.InsertionMarkerManager.prototype.hideInsertionMarker_ = function() {
|
||||
if (!this.markerConnection_) {
|
||||
console.log('No insertion marker connection to disconnect');
|
||||
return;
|
||||
@@ -649,38 +625,41 @@ Blockly.InsertionMarkerManager.prototype.disconnectMarker_ = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an insertion marker connected to the appropriate blocks.
|
||||
* Shows an outline around the input the closest connection belongs to.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.connectMarker_ = function() {
|
||||
var local = this.localConnection_;
|
||||
Blockly.InsertionMarkerManager.prototype.showInsertionInputOutline_ = function() {
|
||||
var closest = this.closestConnection_;
|
||||
this.highlightedBlock_ = closest.getSourceBlock();
|
||||
this.highlightedBlock_.highlightShapeForInput(closest, true);
|
||||
};
|
||||
|
||||
var isLastInStack = this.lastOnStack_ && local == this.lastOnStack_;
|
||||
var imBlock = isLastInStack ? this.lastMarker_ : this.firstMarker_;
|
||||
var imConn = imBlock.getMatchingConnection(local.getSourceBlock(), local);
|
||||
/**
|
||||
* Hides any visible input outlines.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.hideInsertionInputOutline_ = function() {
|
||||
this.highlightedBlock_.highlightShapeForInput(this.closestConnection_, false);
|
||||
this.highlightedBlock_ = null;
|
||||
};
|
||||
|
||||
if (imConn == this.markerConnection_) {
|
||||
throw Error('Made it to connectMarker_ even though the marker isn\'t ' +
|
||||
'changing');
|
||||
}
|
||||
/**
|
||||
* Shows a replacement fade affect on the closest connection's target block
|
||||
* (the block that is currently connected to it).
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.showReplacementFade_ = function() {
|
||||
this.fadedBlock_ = this.closestConnection_.targetBlock();
|
||||
this.fadedBlock_.fadeForReplacement(true);
|
||||
};
|
||||
|
||||
// Render disconnected from everything else so that we have a valid
|
||||
// connection location.
|
||||
imBlock.render();
|
||||
imBlock.rendered = true;
|
||||
imBlock.getSvgRoot().setAttribute('visibility', 'visible');
|
||||
|
||||
if (imConn && closest) {
|
||||
// Position so that the existing block doesn't move.
|
||||
imBlock.positionNearConnection(imConn, closest);
|
||||
}
|
||||
if (closest) {
|
||||
// Connect() also renders the insertion marker.
|
||||
imConn.connect(closest);
|
||||
}
|
||||
|
||||
this.markerConnection_ = imConn;
|
||||
/**
|
||||
* Hides/Removes any visible fade affects.
|
||||
* @private
|
||||
*/
|
||||
Blockly.InsertionMarkerManager.prototype.hideReplacementFade_ = function() {
|
||||
this.fadedBlock_.fadeForReplacement(false);
|
||||
this.fadedBlock_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -31,7 +20,7 @@ goog.require('Blockly.utils.Coordinate');
|
||||
* It is recommended that you use one of the createNode methods instead of
|
||||
* creating a node directly.
|
||||
* @param {string} type The type of the location.
|
||||
* Must be in Bockly.ASTNode.types.
|
||||
* Must be in Blockly.ASTNode.types.
|
||||
* @param {!(Blockly.Block|Blockly.Connection|Blockly.Field|Blockly.Workspace)}
|
||||
* location The position in the AST.
|
||||
* @param {!Object=} opt_params Optional dictionary of options.
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -90,7 +79,7 @@ Blockly.BasicCursor.prototype.prev = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* For a basic cursor we only have the ability to go next and previou, so
|
||||
* For a basic cursor we only have the ability to go next and previous, so
|
||||
* out will allow the user to get to the previous node in the pre order traversal.
|
||||
* @return {Blockly.ASTNode} The previous node, or null if the current node is
|
||||
* not set or there is no previous value.
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -793,7 +782,7 @@ Blockly.navigation.onBlocklyAction = function(action) {
|
||||
} else if (Blockly.navigation.READONLY_ACTION_LIST.indexOf(action) > -1) {
|
||||
actionHandled = Blockly.navigation.handleActions_(action);
|
||||
}
|
||||
// If not in accessibility mode only hanlde turning on keyboard navigation.
|
||||
// If not in accessibility mode only handle turning on keyboard navigation.
|
||||
} else if (action.name === Blockly.navigation.actionNames.TOGGLE_KEYBOARD_NAV) {
|
||||
Blockly.navigation.enableKeyboardAccessibility();
|
||||
actionHandled = true;
|
||||
@@ -1042,7 +1031,7 @@ Blockly.navigation.ACTION_TOGGLE_KEYBOARD_NAV = new Blockly.Action(
|
||||
'Turns on and off keyboard navigation.');
|
||||
|
||||
/**
|
||||
* The action to move the cursor to the keft on a worksapce.
|
||||
* The action to move the cursor to the left on a workspace.
|
||||
* @type {!Blockly.Action}
|
||||
*/
|
||||
Blockly.navigation.ACTION_MOVE_WS_CURSOR_LEFT = new Blockly.Action(
|
||||
@@ -1050,7 +1039,7 @@ Blockly.navigation.ACTION_MOVE_WS_CURSOR_LEFT = new Blockly.Action(
|
||||
'Move the workspace cursor to the lefts.');
|
||||
|
||||
/**
|
||||
* The action to move the cursor to the right on a worksapce.
|
||||
* The action to move the cursor to the right on a workspace.
|
||||
* @type {!Blockly.Action}
|
||||
*/
|
||||
Blockly.navigation.ACTION_MOVE_WS_CURSOR_RIGHT = new Blockly.Action(
|
||||
@@ -1058,7 +1047,7 @@ Blockly.navigation.ACTION_MOVE_WS_CURSOR_RIGHT = new Blockly.Action(
|
||||
'Move the workspace cursor to the right.');
|
||||
|
||||
/**
|
||||
* The action to move the cursor up on a worksapce.
|
||||
* The action to move the cursor up on a workspace.
|
||||
* @type {!Blockly.Action}
|
||||
*/
|
||||
Blockly.navigation.ACTION_MOVE_WS_CURSOR_UP = new Blockly.Action(
|
||||
@@ -1066,7 +1055,7 @@ Blockly.navigation.ACTION_MOVE_WS_CURSOR_UP = new Blockly.Action(
|
||||
'Move the workspace cursor up.');
|
||||
|
||||
/**
|
||||
* The action to move the cursor down on a worksapce.
|
||||
* The action to move the cursor down on a workspace.
|
||||
* @type {!Blockly.Action}
|
||||
*/
|
||||
Blockly.navigation.ACTION_MOVE_WS_CURSOR_DOWN = new Blockly.Action(
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -165,6 +154,16 @@ Blockly.MarkerManager.prototype.setMarkerSvg = function(markerSvg) {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Redraw the attached cursor svg if needed.
|
||||
* @package
|
||||
*/
|
||||
Blockly.MarkerManager.prototype.updateMarkers = function() {
|
||||
if (this.workspace_.keyboardAccessibilityMode && this.cursorSvg_) {
|
||||
this.workspace_.getCursor().draw();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of the marker manager.
|
||||
* Go through and delete all markers associated with this marker manager.
|
||||
|
||||
13
core/msg.js
13
core/msg.js
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2013 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -171,7 +160,8 @@ Blockly.Mutator.prototype.createEditor_ = function() {
|
||||
'media': this.block_.workspace.options.pathToMedia,
|
||||
'rtl': this.block_.RTL,
|
||||
'horizontalLayout': false,
|
||||
'renderer': this.block_.workspace.options.renderer
|
||||
'renderer': this.block_.workspace.options.renderer,
|
||||
'rendererOverrides': this.block_.workspace.options.rendererOverrides
|
||||
}));
|
||||
workspaceOptions.toolboxPosition = this.block_.RTL ? Blockly.TOOLBOX_AT_RIGHT :
|
||||
Blockly.TOOLBOX_AT_LEFT;
|
||||
@@ -304,7 +294,7 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
|
||||
for (var i = 0, child; (child = blocks[i]); i++) {
|
||||
child.render();
|
||||
}
|
||||
// The root block should not be dragable or deletable.
|
||||
// The root block should not be draggable or deletable.
|
||||
this.rootBlock_.setMovable(false);
|
||||
this.rootBlock_.setDeletable(false);
|
||||
if (flyout) {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -93,7 +82,7 @@ Blockly.Names.prototype.setVariableMap = function(map) {
|
||||
Blockly.Names.prototype.getNameForUserVariable_ = function(id) {
|
||||
if (!this.variableMap_) {
|
||||
console.log('Deprecated call to Blockly.Names.prototype.getName without ' +
|
||||
'defining a variable map. To fix, add the folowing code in your ' +
|
||||
'defining a variable map. To fix, add the following code in your ' +
|
||||
'generator\'s init() function:\n' +
|
||||
'Blockly.YourGeneratorName.variableDB_.setVariableMap(' +
|
||||
'workspace.getVariableMap());');
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -142,6 +131,7 @@ Blockly.Options = function(options) {
|
||||
this.theme = Blockly.Options.parseThemeOptions_(options);
|
||||
this.keyMap = keyMap;
|
||||
this.renderer = renderer;
|
||||
this.rendererOverrides = options['rendererOverrides'];
|
||||
|
||||
/**
|
||||
* The SVG element for the grid pattern.
|
||||
@@ -160,7 +150,8 @@ Blockly.Options = function(options) {
|
||||
|
||||
/**
|
||||
* Blockly options.
|
||||
* This interface is further described in `typings/blockly-interfaces.d.ts`.
|
||||
* This interface is further described in
|
||||
* `typings/parts/blockly-interfaces.d.ts`.
|
||||
* @interface
|
||||
*/
|
||||
Blockly.BlocklyOptions = function() {};
|
||||
@@ -292,8 +283,7 @@ Blockly.Options.parseThemeOptions_ = function(options) {
|
||||
if (theme instanceof Blockly.Theme) {
|
||||
return /** @type {!Blockly.Theme} */ (theme);
|
||||
}
|
||||
return new Blockly.Theme('builtin',
|
||||
theme['blockStyles'], theme['categoryStyles'], theme['componentStyles']);
|
||||
return Blockly.Theme.defineTheme('builtin', theme);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2012 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2016 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -90,27 +79,18 @@ Blockly.blockRendering.stopDebugger = function() {
|
||||
/**
|
||||
* Initialize anything needed for rendering (constants, etc).
|
||||
* @param {!string} name Name of the renderer to initialize.
|
||||
* @param {!Blockly.Theme} theme The workspace theme object.
|
||||
* @param {Object=} opt_rendererOverrides Rendering constant overrides.
|
||||
* @return {!Blockly.blockRendering.Renderer} The new instance of a renderer.
|
||||
* Already initialized.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.init = function(name) {
|
||||
Blockly.blockRendering.init = function(name, theme, opt_rendererOverrides) {
|
||||
if (!Blockly.blockRendering.rendererMap_[name]) {
|
||||
throw Error('Renderer not registered: ', name);
|
||||
}
|
||||
/**
|
||||
* Wrap the renderer constructor into a temporary constructor
|
||||
* function so the closure compiler treats it as a constructor.
|
||||
* @param {string} name The renderer name.
|
||||
* @constructor
|
||||
* @extends {Blockly.blockRendering.Renderer}
|
||||
*/
|
||||
var rendererCtor = function(name) {
|
||||
rendererCtor.superClass_.constructor.call(this, name);
|
||||
};
|
||||
Blockly.utils.object.inherits(rendererCtor,
|
||||
Blockly.blockRendering.rendererMap_[name]);
|
||||
var renderer = new rendererCtor(name);
|
||||
renderer.init();
|
||||
var renderer = (/** @type {!Blockly.blockRendering.Renderer} */ (
|
||||
new Blockly.blockRendering.rendererMap_[name](name)));
|
||||
renderer.init(theme, opt_rendererOverrides);
|
||||
return renderer;
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,6 +18,8 @@ goog.require('Blockly.utils.dom');
|
||||
goog.require('Blockly.utils.svgPaths');
|
||||
goog.require('Blockly.utils.userAgent');
|
||||
|
||||
goog.requireType('Blockly.blockRendering.Debug');
|
||||
|
||||
|
||||
/**
|
||||
* An object that provides constants for rendering blocks.
|
||||
@@ -247,12 +238,6 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.FIELD_TEXT_FONTSIZE = 11;
|
||||
|
||||
/**
|
||||
* Height of text.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_TEXT_HEIGHT = 16;
|
||||
|
||||
/**
|
||||
* Text font weight.
|
||||
* @type {string}
|
||||
@@ -265,6 +250,20 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.FIELD_TEXT_FONTFAMILY = 'sans-serif';
|
||||
|
||||
/**
|
||||
* Height of text. This constant is dynamically set in ``setFontConstants_``
|
||||
* to be the height of the text based on the font used.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_TEXT_HEIGHT = -1; // Dynamically set
|
||||
|
||||
/**
|
||||
* Text baseline. This constant is dynamically set in ``setFontConstants_``
|
||||
* to be the baseline of the text based on the font used.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_TEXT_BASELINE = -1; // Dynamically set
|
||||
|
||||
/**
|
||||
* A field's border rect corner radius.
|
||||
* @type {number}
|
||||
@@ -296,19 +295,6 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.FIELD_BORDER_RECT_COLOUR = '#fff';
|
||||
|
||||
/**
|
||||
* Field text baseline.
|
||||
* This is only used if `FIELD_TEXT_BASELINE_CENTER` is false.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_TEXT_BASELINE_Y = Blockly.utils.userAgent.GECKO ? 12 : 13.09;
|
||||
|
||||
/**
|
||||
* An text offset adjusting the Y position of text after positioning.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_TEXT_Y_OFFSET = 0;
|
||||
|
||||
/**
|
||||
* A field's text element's dominant baseline.
|
||||
* @type {boolean}
|
||||
@@ -403,25 +389,13 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.FIELD_CHECKBOX_X_OFFSET = this.FIELD_BORDER_RECT_X_PADDING - 3;
|
||||
|
||||
/**
|
||||
* A checkbox field's Y offset.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_CHECKBOX_Y_OFFSET = 14;
|
||||
|
||||
/**
|
||||
* A checkbox field's default width.
|
||||
* @type {number}
|
||||
*/
|
||||
this.FIELD_CHECKBOX_DEFAULT_WIDTH = 15;
|
||||
|
||||
/**
|
||||
* A random identifier used to ensure a unique ID is used for each
|
||||
* filter/pattern for the case of multiple Blockly instances on a page.
|
||||
* @type {string}
|
||||
* @protected
|
||||
* @package
|
||||
*/
|
||||
this.randomIdentifier_ = String(Math.random()).substring(2);
|
||||
this.randomIdentifier = String(Math.random()).substring(2);
|
||||
|
||||
/**
|
||||
* The ID of the emboss filter, or the empty string if no filter is set.
|
||||
@@ -451,6 +425,27 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.disabledPattern_ = null;
|
||||
|
||||
/**
|
||||
* The ID of the debug filter, or the empty string if no pattern is set.
|
||||
* @type {string}
|
||||
* @package
|
||||
*/
|
||||
this.debugFilterId = '';
|
||||
|
||||
/**
|
||||
* The <filter> element to use for a debug highlight, or null if not set.
|
||||
* @type {SVGElement}
|
||||
* @private
|
||||
*/
|
||||
this.debugFilter_ = null;
|
||||
|
||||
/**
|
||||
* The <style> element to use for injecting renderer specific CSS.
|
||||
* @type {HTMLStyleElement}
|
||||
* @private
|
||||
*/
|
||||
this.cssNode_ = null;
|
||||
|
||||
/**
|
||||
* Cursor colour.
|
||||
* @type {string}
|
||||
@@ -507,6 +502,21 @@ Blockly.blockRendering.ConstantProvider = function() {
|
||||
*/
|
||||
this.FULL_BLOCK_FIELDS = false;
|
||||
|
||||
/**
|
||||
* The main colour of insertion markers, in hex. The block is rendered a
|
||||
* transparent grey by changing the fill opacity in CSS.
|
||||
* @type {string}
|
||||
* @package
|
||||
*/
|
||||
this.INSERTION_MARKER_COLOUR = '#000000';
|
||||
|
||||
/**
|
||||
* The insertion marker opacity.
|
||||
* @type {number}
|
||||
* @package
|
||||
*/
|
||||
this.INSERTION_MARKER_OPACITY = 0.2;
|
||||
|
||||
/**
|
||||
* Enum for connection shapes.
|
||||
* @enum {number}
|
||||
@@ -566,7 +576,7 @@ Blockly.blockRendering.ConstantProvider.prototype.init = function() {
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.refreshTheme = function(
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setTheme = function(
|
||||
theme) {
|
||||
|
||||
/**
|
||||
@@ -580,8 +590,71 @@ Blockly.blockRendering.ConstantProvider.prototype.refreshTheme = function(
|
||||
for (var key in blockStyles) {
|
||||
this.blockStyles[key] = this.validatedBlockStyle_(blockStyles[key]);
|
||||
}
|
||||
|
||||
this.setDynamicProperties_(theme);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets dynamic properties that depend on other values or theme properties.
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setDynamicProperties_ =
|
||||
function(theme) {
|
||||
/* eslint-disable indent */
|
||||
this.setFontConstants_(theme);
|
||||
this.setComponentConstants_(theme);
|
||||
|
||||
this.ADD_START_HATS = theme.startHats != null ? theme.startHats :
|
||||
this.ADD_START_HATS;
|
||||
}; /* eslint-enable indent */
|
||||
|
||||
/**
|
||||
* Set constants related to fonts.
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setFontConstants_ = function(
|
||||
theme) {
|
||||
this.FIELD_TEXT_FONTFAMILY =
|
||||
theme.fontStyle && theme.fontStyle['family'] != undefined ?
|
||||
theme.fontStyle['family'] : this.FIELD_TEXT_FONTFAMILY;
|
||||
this.FIELD_TEXT_FONTWEIGHT =
|
||||
theme.fontStyle && theme.fontStyle['weight'] != undefined ?
|
||||
theme.fontStyle['weight'] : this.FIELD_TEXT_FONTWEIGHT;
|
||||
this.FIELD_TEXT_FONTSIZE =
|
||||
theme.fontStyle && theme.fontStyle['size'] != undefined ?
|
||||
theme.fontStyle['size'] : this.FIELD_TEXT_FONTSIZE;
|
||||
|
||||
var fontMetrics = Blockly.utils.dom.measureFontMetrics('Hg',
|
||||
this.FIELD_TEXT_FONTSIZE + 'pt',
|
||||
this.FIELD_TEXT_FONTWEIGHT,
|
||||
this.FIELD_TEXT_FONTFAMILY);
|
||||
|
||||
this.FIELD_TEXT_HEIGHT = fontMetrics.height;
|
||||
this.FIELD_TEXT_BASELINE = fontMetrics.baseline;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set constants from a theme's component styles.
|
||||
* @param {!Blockly.Theme} theme The current workspace theme.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.setComponentConstants_ =
|
||||
function(theme) {
|
||||
/* eslint-disable indent */
|
||||
this.CURSOR_COLOUR = theme.getComponentStyle('cursorColour') ||
|
||||
this.CURSOR_COLOUR;
|
||||
this.MARKER_COLOUR = theme.getComponentStyle('markerColour') ||
|
||||
this.MARKER_COLOUR;
|
||||
this.INSERTION_MARKER_COLOUR =
|
||||
theme.getComponentStyle('insertionMarkerColour') ||
|
||||
this.INSERTION_MARKER_COLOUR;
|
||||
this.INSERTION_MARKER_OPACITY =
|
||||
Number(theme.getComponentStyle('insertionMarkerOpacity')) ||
|
||||
this.INSERTION_MARKER_OPACITY;
|
||||
}; /* eslint-enable indent */
|
||||
|
||||
/**
|
||||
* Get or create a block style based on a single colour value. Generate a name
|
||||
* for the style based on the colour.
|
||||
@@ -609,7 +682,9 @@ Blockly.blockRendering.ConstantProvider.prototype.getBlockStyleForColour =
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getBlockStyle = function(
|
||||
blockStyleName) {
|
||||
return this.blockStyles[blockStyleName || ''] ||
|
||||
this.createBlockStyle_('#000000');
|
||||
(blockStyleName && blockStyleName.indexOf('auto_') == 0 ?
|
||||
this.getBlockStyleForColour(blockStyleName.substring(5)).style :
|
||||
this.createBlockStyle_('#000000'));
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -700,6 +775,10 @@ Blockly.blockRendering.ConstantProvider.prototype.dispose = function() {
|
||||
if (this.disabledPattern_) {
|
||||
Blockly.utils.dom.removeNode(this.disabledPattern_);
|
||||
}
|
||||
if (this.debugFilter_) {
|
||||
Blockly.utils.dom.removeNode(this.debugFilter_);
|
||||
}
|
||||
this.cssNode_ = null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -926,9 +1005,15 @@ Blockly.blockRendering.ConstantProvider.prototype.shapeFor = function(
|
||||
/**
|
||||
* Create any DOM elements that this renderer needs (filters, patterns, etc).
|
||||
* @param {!SVGElement} svg The root of the workspace's SVG.
|
||||
* @param {string} tagName The name to use for the CSS style tag.
|
||||
* @param {string} selector The CSS selector to use.
|
||||
* @suppress {strictModuleDepCheck} Debug renderer only included in playground.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg) {
|
||||
Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg,
|
||||
tagName, selector) {
|
||||
this.injectCSS_(tagName, selector);
|
||||
|
||||
/*
|
||||
<defs>
|
||||
... filters go here ...
|
||||
@@ -950,7 +1035,7 @@ Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg) {
|
||||
</filter>
|
||||
*/
|
||||
var embossFilter = Blockly.utils.dom.createSvgElement('filter',
|
||||
{'id': 'blocklyEmbossFilter' + this.randomIdentifier_}, defs);
|
||||
{'id': 'blocklyEmbossFilter' + this.randomIdentifier}, defs);
|
||||
Blockly.utils.dom.createSvgElement('feGaussianBlur',
|
||||
{'in': 'SourceAlpha', 'stdDeviation': 1, 'result': 'blur'}, embossFilter);
|
||||
var feSpecularLighting = Blockly.utils.dom.createSvgElement('feSpecularLighting',
|
||||
@@ -994,7 +1079,7 @@ Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg) {
|
||||
*/
|
||||
var disabledPattern = Blockly.utils.dom.createSvgElement('pattern',
|
||||
{
|
||||
'id': 'blocklyDisabledPattern' + this.randomIdentifier_,
|
||||
'id': 'blocklyDisabledPattern' + this.randomIdentifier,
|
||||
'patternUnits': 'userSpaceOnUse',
|
||||
'width': 10,
|
||||
'height': 10
|
||||
@@ -1005,47 +1090,93 @@ Blockly.blockRendering.ConstantProvider.prototype.createDom = function(svg) {
|
||||
{'d': 'M 0 0 L 10 10 M 10 0 L 0 10', 'stroke': '#cc0'}, disabledPattern);
|
||||
this.disabledPatternId = disabledPattern.id;
|
||||
this.disabledPattern_ = disabledPattern;
|
||||
|
||||
if (Blockly.blockRendering.Debug) {
|
||||
var debugFilter = Blockly.utils.dom.createSvgElement('filter',
|
||||
{
|
||||
'id': 'blocklyDebugFilter' + this.randomIdentifier,
|
||||
'height': '160%',
|
||||
'width': '180%',
|
||||
y: '-30%',
|
||||
x: '-40%'
|
||||
},
|
||||
defs);
|
||||
// Set all gaussian blur pixels to 1 opacity before applying flood
|
||||
var debugComponentTransfer = Blockly.utils.dom.createSvgElement(
|
||||
'feComponentTransfer', {'result': 'outBlur'}, debugFilter);
|
||||
Blockly.utils.dom.createSvgElement('feFuncA',
|
||||
{
|
||||
'type': 'table', 'tableValues': '0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1'
|
||||
},
|
||||
debugComponentTransfer);
|
||||
// Color the highlight
|
||||
Blockly.utils.dom.createSvgElement('feFlood',
|
||||
{
|
||||
'flood-color': '#ff0000',
|
||||
'flood-opacity': 0.5,
|
||||
'result': 'outColor'
|
||||
},
|
||||
debugFilter);
|
||||
Blockly.utils.dom.createSvgElement('feComposite',
|
||||
{
|
||||
'in': 'outColor', 'in2': 'outBlur',
|
||||
'operator': 'in', 'result': 'outGlow'
|
||||
},
|
||||
debugFilter);
|
||||
this.debugFilterId = debugFilter.id;
|
||||
this.debugFilter_ = debugFilter;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Inject renderer specific CSS into the page.
|
||||
* @param {string} name Name of the renderer.
|
||||
* @package
|
||||
* @param {string} tagName The name of the style tag to use.
|
||||
* @param {string} selector The CSS selector to use.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.injectCSS = function(
|
||||
name) {
|
||||
var cssArray = this.getCSS_(name);
|
||||
var cssNodeId = 'blockly-renderer-style-' + name;
|
||||
if (document.getElementById(cssNodeId)) {
|
||||
// Already injected.
|
||||
Blockly.blockRendering.ConstantProvider.prototype.injectCSS_ = function(
|
||||
tagName, selector) {
|
||||
var cssArray = this.getCSS_(selector);
|
||||
var cssNodeId = 'blockly-renderer-style-' + tagName;
|
||||
this.cssNode_ =
|
||||
/** @type {!HTMLStyleElement} */ (document.getElementById(cssNodeId));
|
||||
var text = cssArray.join('\n');
|
||||
if (this.cssNode_) {
|
||||
// Already injected, update if the theme changed.
|
||||
this.cssNode_.firstChild.textContent = text;
|
||||
return;
|
||||
}
|
||||
var text = cssArray.join('\n');
|
||||
// Inject CSS tag at start of head.
|
||||
var cssNode = document.createElement('style');
|
||||
var cssNode =
|
||||
/** @type {!HTMLStyleElement} */ (document.createElement('style'));
|
||||
cssNode.id = cssNodeId;
|
||||
var cssTextNode = document.createTextNode(text);
|
||||
cssNode.appendChild(cssTextNode);
|
||||
document.head.insertBefore(cssNode, document.head.firstChild);
|
||||
this.cssNode_ = cssNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get any renderer specific CSS to inject when the renderer is initialized.
|
||||
* @param {string} name Name of the renderer.
|
||||
* @param {string} selector CSS selector to use.
|
||||
* @return {!Array.<string>} Array of CSS strings.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(name) {
|
||||
var selector = '.' + name + '-renderer';
|
||||
Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(selector) {
|
||||
return [
|
||||
/* eslint-disable indent */
|
||||
// Fields.
|
||||
selector + ' .blocklyText {',
|
||||
'fill: #fff;',
|
||||
// Text.
|
||||
selector + ' .blocklyText, ',
|
||||
selector + ' .blocklyFlyoutLabelText {',
|
||||
'font-family: ' + this.FIELD_TEXT_FONTFAMILY + ';',
|
||||
'font-size: ' + this.FIELD_TEXT_FONTSIZE + 'pt;',
|
||||
'font-weight: ' + this.FIELD_TEXT_FONTWEIGHT + ';',
|
||||
'}',
|
||||
|
||||
// Fields.
|
||||
selector + ' .blocklyText {',
|
||||
'fill: #fff;',
|
||||
'}',
|
||||
selector + ' .blocklyNonEditableText>rect,',
|
||||
selector + ' .blocklyEditableText>rect {',
|
||||
'fill: ' + this.FIELD_BORDER_RECT_COLOUR + ';',
|
||||
@@ -1057,6 +1188,16 @@ Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(name) {
|
||||
'fill: #000;',
|
||||
'}',
|
||||
|
||||
// Flyout labels.
|
||||
selector + ' .blocklyFlyoutLabelText {',
|
||||
'fill: #000;',
|
||||
'}',
|
||||
|
||||
// Bubbles.
|
||||
selector + ' .blocklyText.blocklyBubbleText {',
|
||||
'fill: #000;',
|
||||
'}',
|
||||
|
||||
// Editable field hover.
|
||||
selector + ' .blocklyEditableText:not(.editing):hover>rect {',
|
||||
'stroke: #fff;',
|
||||
@@ -1080,7 +1221,7 @@ Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(name) {
|
||||
'stroke: #fc3;',
|
||||
'}',
|
||||
|
||||
// Replacable highlight.
|
||||
// Replaceable highlight.
|
||||
selector + ' .blocklyReplaceable .blocklyPath {',
|
||||
'fill-opacity: .5;',
|
||||
'}',
|
||||
@@ -1088,6 +1229,12 @@ Blockly.blockRendering.ConstantProvider.prototype.getCSS_ = function(name) {
|
||||
selector + ' .blocklyReplaceable .blocklyPathDark {',
|
||||
'display: none;',
|
||||
'}',
|
||||
|
||||
// Insertion marker.
|
||||
selector + ' .blocklyInsertionMarker>.blocklyPath {',
|
||||
'fill-opacity: ' + this.INSERTION_MARKER_OPACITY + ';',
|
||||
'stroke: none',
|
||||
'}',
|
||||
/* eslint-enable indent */
|
||||
];
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -35,10 +24,12 @@ goog.require('Blockly.blockRendering.Types');
|
||||
|
||||
/**
|
||||
* An object that renders rectangles and dots for debugging rendering code.
|
||||
* @param {!Blockly.blockRendering.ConstantProvider} constants The renderer's
|
||||
* constants.
|
||||
* @package
|
||||
* @constructor
|
||||
*/
|
||||
Blockly.blockRendering.Debug = function() {
|
||||
Blockly.blockRendering.Debug = function(constants) {
|
||||
/**
|
||||
* An array of SVG elements that have been created by this object.
|
||||
* @type {Array.<!SVGElement>}
|
||||
@@ -53,6 +44,13 @@ Blockly.blockRendering.Debug = function() {
|
||||
* @private
|
||||
*/
|
||||
this.svgRoot_ = null;
|
||||
|
||||
/**
|
||||
* The renderer's constant provider.
|
||||
* @type {!Blockly.blockRendering.ConstantProvider}
|
||||
* @private
|
||||
*/
|
||||
this.constants_ = constants;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -67,7 +65,8 @@ Blockly.blockRendering.Debug.config = {
|
||||
elems: true,
|
||||
connections: true,
|
||||
blockBounds: true,
|
||||
connectedBlockBounds: true
|
||||
connectedBlockBounds: true,
|
||||
render: true
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -174,6 +173,23 @@ Blockly.blockRendering.Debug.prototype.drawRenderedElem = function(elem, isRtl)
|
||||
'stroke-width': '1px'
|
||||
},
|
||||
this.svgRoot_));
|
||||
|
||||
if (Blockly.blockRendering.Types.isField(elem) &&
|
||||
elem.field instanceof Blockly.FieldLabel) {
|
||||
var baseline = this.constants_.FIELD_TEXT_BASELINE;
|
||||
this.debugElements_.push(Blockly.utils.dom.createSvgElement('rect',
|
||||
{
|
||||
'class': 'rowRenderingRect blockRenderDebug',
|
||||
'x': xPos,
|
||||
'y': yPos + baseline,
|
||||
'width': elem.width,
|
||||
'height': '0.1px',
|
||||
'stroke': 'red',
|
||||
'fill': 'none',
|
||||
'stroke-width': '0.5px'
|
||||
},
|
||||
this.svgRoot_));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -382,4 +398,23 @@ Blockly.blockRendering.Debug.prototype.drawDebug = function(block, info) {
|
||||
}
|
||||
|
||||
this.drawBoundingBox(info);
|
||||
|
||||
this.drawRender(block.pathObject.svgPath);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Show a debug filter to highlight that a block has been rendered.
|
||||
* @param {!SVGElement} svgPath The block's svg path.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Debug.prototype.drawRender = function(svgPath) {
|
||||
if (!Blockly.blockRendering.Debug.config.render) {
|
||||
return;
|
||||
}
|
||||
svgPath.setAttribute('filter',
|
||||
'url(#' + this.constants_.debugFilterId + ')');
|
||||
setTimeout(function() {
|
||||
svgPath.setAttribute('filter', '');
|
||||
}, 100);
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -127,4 +116,4 @@ Blockly.blockRendering.IPathObject.prototype.updateMovable;
|
||||
* @param {boolean} enable True if styling should be added.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.IPathObject.prototype.updateReplacementHighlight;
|
||||
Blockly.blockRendering.IPathObject.prototype.updateReplacementFade;
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -139,11 +128,10 @@ Blockly.blockRendering.RenderInfo = function(renderer, block) {
|
||||
this.rows = [];
|
||||
|
||||
/**
|
||||
* The total number of input rows added onto the block.
|
||||
* @type {number}
|
||||
* @protected
|
||||
* An array of input rows on the block.
|
||||
* @type {!Array.<!Blockly.blockRendering.InputRow>}
|
||||
*/
|
||||
this.inputRowNum_ = 1;
|
||||
this.inputRows = [];
|
||||
|
||||
/**
|
||||
* An array of measurable objects containing hidden icons.
|
||||
@@ -206,6 +194,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
this.populateTopRow_();
|
||||
this.rows.push(this.topRow);
|
||||
var activeRow = new Blockly.blockRendering.InputRow(this.constants_);
|
||||
this.inputRows.push(activeRow);
|
||||
|
||||
// Icons always go on the first row, before anything else.
|
||||
var icons = this.block_.getIcons();
|
||||
@@ -231,7 +220,7 @@ Blockly.blockRendering.RenderInfo.prototype.createRows_ = function() {
|
||||
// Finish this row and create a new one.
|
||||
this.rows.push(activeRow);
|
||||
activeRow = new Blockly.blockRendering.InputRow(this.constants_);
|
||||
this.inputRowNum_ ++;
|
||||
this.inputRows.push(activeRow);
|
||||
}
|
||||
|
||||
// All of the fields in an input go on the same row.
|
||||
@@ -559,6 +548,9 @@ Blockly.blockRendering.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
if (missingSpace > 0) {
|
||||
this.addAlignmentPadding_(row, missingSpace);
|
||||
}
|
||||
if (Blockly.blockRendering.Types.isTopOrBottomRow(row)) {
|
||||
row.widthWithConnectedBlocks = row.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -775,8 +767,7 @@ Blockly.blockRendering.RenderInfo.prototype.finalize_ = function() {
|
||||
this.block_.nextConnection.targetBlock().getHeightWidth().width);
|
||||
}
|
||||
|
||||
this.widthWithChildren = Math.max(this.widthWithChildren,
|
||||
widestRowWithConnectedBlocks + this.startX);
|
||||
this.widthWithChildren = widestRowWithConnectedBlocks + this.startX;
|
||||
|
||||
this.height = yCursor;
|
||||
this.startY = this.topRow.capline;
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -134,6 +123,7 @@ Blockly.blockRendering.MarkerSvg.prototype.createDom = function() {
|
||||
}, null);
|
||||
|
||||
this.createDomInternal_();
|
||||
this.applyColour_();
|
||||
return this.svgGroup_;
|
||||
};
|
||||
|
||||
@@ -465,6 +455,13 @@ Blockly.blockRendering.MarkerSvg.prototype.draw = function(oldNode, curNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.constants_ = this.workspace_.getRenderer().getConstants();
|
||||
|
||||
var defaultColour = this.isCursor() ? this.constants_.CURSOR_COLOUR :
|
||||
this.constants_.MARKER_COLOUR;
|
||||
this.colour_ = this.marker_.colour || defaultColour;
|
||||
this.applyColour_();
|
||||
|
||||
this.showAtLocation_(curNode);
|
||||
|
||||
this.firemarkerEvent_(oldNode, curNode);
|
||||
@@ -561,7 +558,6 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
// A horizontal line used to represent a workspace coordinate or next connection.
|
||||
this.markerSvgLine_ = Blockly.utils.dom.createSvgElement('rect',
|
||||
{
|
||||
'fill': this.colour_,
|
||||
'width': this.constants_.CURSOR_WS_WIDTH,
|
||||
'height': this.constants_.WS_CURSOR_HEIGHT,
|
||||
'style': 'display: none'
|
||||
@@ -573,8 +569,7 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
{
|
||||
'class': 'blocklyVerticalMarker',
|
||||
'rx': 10, 'ry': 10,
|
||||
'style': 'display: none',
|
||||
'stroke': this.colour_
|
||||
'style': 'display: none'
|
||||
},
|
||||
this.markerSvg_);
|
||||
|
||||
@@ -582,8 +577,7 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
this.markerInput_ = Blockly.utils.dom.createSvgElement('path',
|
||||
{
|
||||
'transform': '',
|
||||
'style': 'display: none',
|
||||
'fill': this.colour_
|
||||
'style': 'display: none'
|
||||
},
|
||||
this.markerSvg_);
|
||||
|
||||
@@ -594,7 +588,6 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
'transform': '',
|
||||
'style': 'display: none',
|
||||
'fill': 'none',
|
||||
'stroke': this.colour_,
|
||||
'stroke-width': this.constants_.CURSOR_STROKE_WIDTH
|
||||
},
|
||||
this.markerSvg_);
|
||||
@@ -602,7 +595,7 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
// Markers and stack markers don't blink.
|
||||
if (this.isCursor()) {
|
||||
var blinkProperties = this.getBlinkProperties_();
|
||||
Blockly.utils.dom.createSvgElement('animate', this.getBlinkProperties_(),
|
||||
Blockly.utils.dom.createSvgElement('animate', blinkProperties,
|
||||
this.markerSvgLine_);
|
||||
Blockly.utils.dom.createSvgElement('animate', blinkProperties,
|
||||
this.markerInput_);
|
||||
@@ -614,6 +607,24 @@ Blockly.blockRendering.MarkerSvg.prototype.createDomInternal_ = function() {
|
||||
return this.markerSvg_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Apply the marker's colour.
|
||||
* @protected
|
||||
*/
|
||||
Blockly.blockRendering.MarkerSvg.prototype.applyColour_ = function() {
|
||||
this.markerSvgLine_.setAttribute('fill', this.colour_);
|
||||
this.markerSvgRect_.setAttribute('stroke', this.colour_);
|
||||
this.markerInput_.setAttribute('fill', this.colour_);
|
||||
this.markerBlock_.setAttribute('stroke', this.colour_);
|
||||
|
||||
if (this.isCursor()) {
|
||||
var values = this.colour_ + ';transparent;transparent;';
|
||||
this.markerSvgLine_.firstChild.setAttribute('values', values);
|
||||
this.markerInput_.firstChild.setAttribute('values', values);
|
||||
this.markerBlock_.firstChild.setAttribute('values', values);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of this marker.
|
||||
* @package
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -46,9 +35,9 @@ Blockly.blockRendering.PathObject = function(root, style, constants) {
|
||||
/**
|
||||
* The renderer's constant provider.
|
||||
* @type {!Blockly.blockRendering.ConstantProvider}
|
||||
* @protected
|
||||
* @package
|
||||
*/
|
||||
this.constants_ = constants;
|
||||
this.constants = constants;
|
||||
|
||||
this.svgRoot = root;
|
||||
|
||||
@@ -71,17 +60,17 @@ Blockly.blockRendering.PathObject = function(root, style, constants) {
|
||||
* Holds the cursors svg element when the cursor is attached to the block.
|
||||
* This is null if there is no cursor on the block.
|
||||
* @type {SVGElement}
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
this.cursorSvg_ = null;
|
||||
this.cursorSvg = null;
|
||||
|
||||
/**
|
||||
* Holds the markers svg element when the marker is attached to the block.
|
||||
* This is null if there is no marker on the block.
|
||||
* @type {SVGElement}
|
||||
* @private
|
||||
* @package
|
||||
*/
|
||||
this.markerSvg_ = null;
|
||||
this.markerSvg = null;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -110,12 +99,12 @@ Blockly.blockRendering.PathObject.prototype.flipRTL = function() {
|
||||
*/
|
||||
Blockly.blockRendering.PathObject.prototype.setCursorSvg = function(cursorSvg) {
|
||||
if (!cursorSvg) {
|
||||
this.cursorSvg_ = null;
|
||||
this.cursorSvg = null;
|
||||
return;
|
||||
}
|
||||
|
||||
this.svgRoot.appendChild(cursorSvg);
|
||||
this.cursorSvg_ = cursorSvg;
|
||||
this.cursorSvg = cursorSvg;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -126,16 +115,16 @@ Blockly.blockRendering.PathObject.prototype.setCursorSvg = function(cursorSvg) {
|
||||
*/
|
||||
Blockly.blockRendering.PathObject.prototype.setMarkerSvg = function(markerSvg) {
|
||||
if (!markerSvg) {
|
||||
this.markerSvg_ = null;
|
||||
this.markerSvg = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.cursorSvg_) {
|
||||
this.svgRoot.insertBefore(markerSvg, this.cursorSvg_);
|
||||
if (this.cursorSvg) {
|
||||
this.svgRoot.insertBefore(markerSvg, this.cursorSvg);
|
||||
} else {
|
||||
this.svgRoot.appendChild(markerSvg);
|
||||
}
|
||||
this.markerSvg_ = markerSvg;
|
||||
this.markerSvg = markerSvg;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -189,7 +178,7 @@ Blockly.blockRendering.PathObject.prototype.updateHighlighted = function(
|
||||
enable) {
|
||||
if (enable) {
|
||||
this.svgPath.setAttribute('filter',
|
||||
'url(#' + this.constants_.embossFilterId + ')');
|
||||
'url(#' + this.constants.embossFilterId + ')');
|
||||
} else {
|
||||
this.svgPath.setAttribute('filter', 'none');
|
||||
}
|
||||
@@ -217,7 +206,7 @@ Blockly.blockRendering.PathObject.prototype.updateDisabled_ = function(
|
||||
this.setClass_('blocklyDisabled', disabled);
|
||||
if (disabled) {
|
||||
this.svgPath.setAttribute('fill',
|
||||
'url(#' + this.constants_.disabledPatternId + ')');
|
||||
'url(#' + this.constants.disabledPatternId + ')');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -268,7 +257,7 @@ Blockly.blockRendering.PathObject.prototype.updateMovable = function(enable) {
|
||||
* @param {boolean} enable True if styling should be added.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.PathObject.prototype.updateReplacementHighlight =
|
||||
Blockly.blockRendering.PathObject.prototype.updateReplacementFade =
|
||||
function(enable) {
|
||||
/* eslint-disable indent */
|
||||
this.setClass_('blocklyReplaceable', enable);
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -29,6 +18,7 @@ goog.require('Blockly.blockRendering.Drawer');
|
||||
goog.require('Blockly.blockRendering.IPathObject');
|
||||
goog.require('Blockly.blockRendering.PathObject');
|
||||
goog.require('Blockly.blockRendering.RenderInfo');
|
||||
goog.require('Blockly.InsertionMarkerManager');
|
||||
|
||||
goog.requireType('Blockly.blockRendering.Debug');
|
||||
|
||||
@@ -54,17 +44,83 @@ Blockly.blockRendering.Renderer = function(name) {
|
||||
* @private
|
||||
*/
|
||||
this.constants_ = null;
|
||||
|
||||
/**
|
||||
* Rendering constant overrides, passed in through options.
|
||||
* @type {?Object}
|
||||
* @package
|
||||
*/
|
||||
this.overrides = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the class name that identifies this renderer.
|
||||
* @return {string} The CSS class name.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.getClassName = function() {
|
||||
return this.name + '-renderer';
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize the renderer.
|
||||
* @param {!Blockly.Theme} theme The workspace theme object.
|
||||
* @param {Object=} opt_rendererOverrides Rendering constant overrides.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.init = function() {
|
||||
Blockly.blockRendering.Renderer.prototype.init = function(theme,
|
||||
opt_rendererOverrides) {
|
||||
this.constants_ = this.makeConstants_();
|
||||
if (opt_rendererOverrides) {
|
||||
this.overrides = opt_rendererOverrides;
|
||||
Blockly.utils.object.mixin(this.constants_, opt_rendererOverrides);
|
||||
}
|
||||
this.constants_.setTheme(theme);
|
||||
this.constants_.init();
|
||||
};
|
||||
|
||||
/**
|
||||
* Create any DOM elements that this renderer needs.
|
||||
* @param {!SVGElement} svg The root of the workspace's SVG.
|
||||
* @param {!Blockly.Theme} theme The workspace theme object.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.createDom = function(svg, theme) {
|
||||
this.constants_.createDom(svg, this.name + '-' + theme.name,
|
||||
'.' + this.getClassName() + '.' + theme.getClassName());
|
||||
};
|
||||
|
||||
/**
|
||||
* Refresh the renderer after a theme change.
|
||||
* @param {!SVGElement} svg The root of the workspace's SVG.
|
||||
* @param {!Blockly.Theme} theme The workspace theme object.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.refreshDom = function(svg, theme) {
|
||||
var previousConstants = this.getConstants();
|
||||
previousConstants.dispose();
|
||||
this.constants_ = this.makeConstants_();
|
||||
if (this.overrides) {
|
||||
Blockly.utils.object.mixin(this.constants_, this.overrides);
|
||||
}
|
||||
// Ensure the constant provider's random identifier does not change.
|
||||
this.constants_.randomIdentifier = previousConstants.randomIdentifier;
|
||||
this.constants_.setTheme(theme);
|
||||
this.constants_.init();
|
||||
this.createDom(svg, theme);
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispose of this renderer.
|
||||
* Delete all DOM elements that this renderer and its constants created.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.dispose = function() {
|
||||
if (this.constants_) {
|
||||
this.constants_.dispose();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a new instance of the renderer's constant provider.
|
||||
* @return {!Blockly.blockRendering.ConstantProvider} The constant provider.
|
||||
@@ -106,7 +162,7 @@ Blockly.blockRendering.Renderer.prototype.makeDebugger_ = function() {
|
||||
if (!Blockly.blockRendering.Debug) {
|
||||
throw Error('Missing require for Blockly.blockRendering.Debug');
|
||||
}
|
||||
return new Blockly.blockRendering.Debug();
|
||||
return new Blockly.blockRendering.Debug(this.getConstants());
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -163,19 +219,69 @@ Blockly.blockRendering.Renderer.prototype.shouldHighlightConnection =
|
||||
}; /* eslint-enable indent */
|
||||
|
||||
/**
|
||||
* Determine whether or not to insert a dragged block into a stack.
|
||||
* @param {!Blockly.Block} block The target block.
|
||||
* @param {!Blockly.Connection} conn The closest connection.
|
||||
* @return {boolean} True if we should insert the dragged block into the stack.
|
||||
* Checks if an orphaned block can connect to the "end" of the topBlock's
|
||||
* block-clump. If the clump is a row the end is the last input. If the clump
|
||||
* is a stack, the end is the last next connection. If the clump is neither,
|
||||
* then this returns false.
|
||||
* @param {!Blockly.BlockSvg} topBlock The top block of the block clump we want to try and
|
||||
* connect to.
|
||||
* @param {!Blockly.BlockSvg} orphanBlock The orphan block that wants to find
|
||||
* a home.
|
||||
* @param {number} localType The type of the connection being dragged.
|
||||
* @return {boolean} Whether there is a home for the orphan or not.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.shouldInsertDraggedBlock =
|
||||
function(block, conn) {
|
||||
/* eslint-disable indent */
|
||||
return !conn.isConnected() ||
|
||||
!!Blockly.Connection.lastConnectionInRow(block,
|
||||
conn.targetConnection.getSourceBlock());
|
||||
}; /* eslint-enable indent */
|
||||
Blockly.blockRendering.Renderer.prototype.orphanCanConnectAtEnd =
|
||||
function(topBlock, orphanBlock, localType) {
|
||||
var orphanConnection = null;
|
||||
var lastConnection = null;
|
||||
if (localType == Blockly.OUTPUT_VALUE) { // We are replacing an output.
|
||||
orphanConnection = orphanBlock.outputConnection;
|
||||
// TODO: I don't think this function necessarily has the correct logic,
|
||||
// but for now it is being kept for behavioral backwards-compat.
|
||||
lastConnection = Blockly.Connection
|
||||
.lastConnectionInRow(
|
||||
/** @type {!Blockly.Block} **/ (topBlock), orphanBlock);
|
||||
} else { // We are replacing a previous.
|
||||
orphanConnection = orphanBlock.previousConnection;
|
||||
// TODO: This lives on the block while lastConnectionInRow lives on
|
||||
// on the connection. Something is fishy.
|
||||
lastConnection = topBlock.lastConnectionInStack();
|
||||
}
|
||||
|
||||
if (!lastConnection) {
|
||||
return false;
|
||||
}
|
||||
return orphanConnection.checkType(lastConnection);
|
||||
};
|
||||
|
||||
/**
|
||||
* Chooses a connection preview method based on the available connection, the
|
||||
* current dragged connection, and the block being dragged.
|
||||
* @param {!Blockly.RenderedConnection} closest The available connection.
|
||||
* @param {!Blockly.RenderedConnection} local The connection currently being
|
||||
* dragged.
|
||||
* @param {!Blockly.BlockSvg} topBlock The block currently being dragged.
|
||||
* @return {!Blockly.InsertionMarkerManager.PREVIEW_TYPE} The preview type
|
||||
* to display.
|
||||
* @package
|
||||
*/
|
||||
Blockly.blockRendering.Renderer.prototype.getConnectionPreviewMethod =
|
||||
function(closest, local, topBlock) {
|
||||
if (local.type == Blockly.OUTPUT_VALUE ||
|
||||
local.type == Blockly.PREVIOUS_STATEMENT) {
|
||||
if (!closest.isConnected() ||
|
||||
this.orphanCanConnectAtEnd(
|
||||
topBlock,
|
||||
/** @type {!Blockly.BlockSvg} */ (closest.targetBlock()),
|
||||
local.type)) {
|
||||
return Blockly.InsertionMarkerManager.PREVIEW_TYPE.INSERTION_MARKER;
|
||||
}
|
||||
return Blockly.InsertionMarkerManager.PREVIEW_TYPE.REPLACEMENT_FADE;
|
||||
}
|
||||
|
||||
return Blockly.InsertionMarkerManager.PREVIEW_TYPE.INSERTION_MARKER;
|
||||
};
|
||||
|
||||
/**
|
||||
* Render the block.
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -55,3 +44,21 @@ Blockly.geras.ConstantProvider = function() {
|
||||
};
|
||||
Blockly.utils.object.inherits(Blockly.geras.ConstantProvider,
|
||||
Blockly.blockRendering.ConstantProvider);
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.geras.ConstantProvider.prototype.getCSS_ = function(selector) {
|
||||
return Blockly.geras.ConstantProvider.superClass_.getCSS_.call(this, selector)
|
||||
.concat([
|
||||
/* eslint-disable indent */
|
||||
// Insertion marker.
|
||||
selector + ' .blocklyInsertionMarker>.blocklyPathLight,',
|
||||
selector + ' .blocklyInsertionMarker>.blocklyPathDark {',
|
||||
'fill-opacity: ' + this.INSERTION_MARKER_OPACITY + ';',
|
||||
'stroke: none',
|
||||
'}',
|
||||
/* eslint-enable indent */
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -57,6 +46,14 @@ Blockly.geras.HighlightConstantProvider = function(constants) {
|
||||
*/
|
||||
this.START_POINT = Blockly.utils.svgPaths.moveBy(this.OFFSET, this.OFFSET);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize shape objects based on the constants set in the constructor.
|
||||
* @package
|
||||
*/
|
||||
Blockly.geras.HighlightConstantProvider.prototype.init = function() {
|
||||
|
||||
/**
|
||||
* An object containing sizing and path information about inside corner
|
||||
* highlights.
|
||||
@@ -276,7 +273,9 @@ Blockly.geras.HighlightConstantProvider.prototype.makeJaggedTeeth = function() {
|
||||
Blockly.utils.svgPaths.moveBy(-10.2, 6.8) +
|
||||
Blockly.utils.svgPaths.lineTo(5.1, 2.6);
|
||||
return {
|
||||
pathLeft: pathLeft
|
||||
pathLeft: pathLeft,
|
||||
height: 12,
|
||||
width: 10.2
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -121,11 +110,10 @@ Blockly.geras.Highlighter.prototype.drawTopCorner = function(row) {
|
||||
|
||||
Blockly.geras.Highlighter.prototype.drawJaggedEdge_ = function(row) {
|
||||
if (this.info_.RTL) {
|
||||
this.steps_ += Blockly.utils.svgPaths.lineOnAxis('H', row.width - this.highlightOffset_);
|
||||
this.steps_ += this.jaggedTeethPaths_.pathLeft;
|
||||
var remainder =
|
||||
row.height - this.jaggedTeethPaths_.height - this.highlightOffset_;
|
||||
this.steps_ += Blockly.utils.svgPaths.lineOnAxis('v', remainder);
|
||||
this.steps_ += this.jaggedTeethPaths_.pathLeft +
|
||||
Blockly.utils.svgPaths.lineOnAxis('v', remainder);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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.
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user