mirror of
https://github.com/google/blockly.git
synced 2026-01-06 16:40:07 +01:00
Add serializing shadows as JSOs for the JSO system (#5246)
* Move existing tests into new suite * Add tests for setShadowState * Add assertions for serialization * Unskip serialization tests * Add logic to handle shadows in both systems * Uncomment tests * fix: add access modifiers to new comment funcs * fix: fixup types * fix: remove addNextBlocks = true * feat: add real child of shadow errors * fix: types
This commit is contained in:
committed by
alschmiedt
parent
1b47953c58
commit
1d4cbd1ab6
@@ -23,6 +23,7 @@ const IConnectionChecker = goog.requireType('Blockly.IConnectionChecker');
|
||||
/* eslint-disable-next-line no-unused-vars */
|
||||
const Input = goog.requireType('Blockly.Input');
|
||||
const Xml = goog.require('Blockly.Xml');
|
||||
const blocks = goog.require('Blockly.serialization.blocks');
|
||||
const connectionTypes = goog.require('Blockly.connectionTypes');
|
||||
const deprecation = goog.require('Blockly.utils.deprecation');
|
||||
/** @suppress {extraRequire} */
|
||||
@@ -121,16 +122,15 @@ Connection.prototype.connect_ = function(childConnection) {
|
||||
// Make sure the parentConnection is available.
|
||||
let orphan;
|
||||
if (parentConnection.isConnected()) {
|
||||
const shadowDom = parentConnection.getShadowDom(true);
|
||||
parentConnection.shadowDom_ = null; // Set to null so it doesn't respawn.
|
||||
const target = parentConnection.targetBlock();
|
||||
let shadowState = parentConnection.stashShadowState_();
|
||||
var target = parentConnection.targetBlock();
|
||||
if (target.isShadow()) {
|
||||
target.dispose(false);
|
||||
} else {
|
||||
parentConnection.disconnect();
|
||||
orphan = target;
|
||||
}
|
||||
parentConnection.shadowDom_ = shadowDom;
|
||||
parentConnection.applyShadowState_(shadowState);
|
||||
}
|
||||
|
||||
// Connect the new connection to the parent.
|
||||
@@ -169,7 +169,7 @@ Connection.prototype.dispose = function() {
|
||||
// isConnected returns true for shadows and non-shadows.
|
||||
if (this.isConnected()) {
|
||||
// Destroy the attached shadow block & its children (if it exists).
|
||||
this.setShadowDom(null);
|
||||
this.setShadowStateInternal_();
|
||||
|
||||
const targetBlock = this.targetBlock();
|
||||
if (targetBlock) {
|
||||
@@ -464,18 +464,8 @@ Connection.prototype.disconnectInternal_ = function(parentBlock, childBlock) {
|
||||
* @protected
|
||||
*/
|
||||
Connection.prototype.respawnShadow_ = function() {
|
||||
const parentBlock = this.getSourceBlock();
|
||||
const shadow = this.getShadowDom();
|
||||
if (parentBlock.workspace && shadow) {
|
||||
const blockShadow = Xml.domToBlock(shadow, parentBlock.workspace);
|
||||
if (blockShadow.outputConnection) {
|
||||
this.connect(blockShadow.outputConnection);
|
||||
} else if (blockShadow.previousConnection) {
|
||||
this.connect(blockShadow.previousConnection);
|
||||
} else {
|
||||
throw Error('Child block does not have output or previous statement.');
|
||||
}
|
||||
}
|
||||
// Have to keep respawnShadow_ for backwards compatibility.
|
||||
this.createShadowBlock_(true);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -569,18 +559,10 @@ Connection.prototype.getCheck = function() {
|
||||
|
||||
/**
|
||||
* Changes the connection's shadow block.
|
||||
* @param {?Element} shadow DOM representation of a block or null.
|
||||
* @param {?Element} shadowDom DOM representation of a block or null.
|
||||
*/
|
||||
Connection.prototype.setShadowDom = function(shadow) {
|
||||
this.shadowDom_ = shadow;
|
||||
const target = this.targetBlock();
|
||||
if (!target) {
|
||||
this.respawnShadow_();
|
||||
} else if (target.isShadow()) {
|
||||
// The disconnect from dispose will automatically generate the new shadow.
|
||||
target.dispose(false);
|
||||
this.respawnShadow_();
|
||||
}
|
||||
Connection.prototype.setShadowDom = function(shadowDom) {
|
||||
this.setShadowStateInternal_({shadowDom: shadowDom});
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -598,6 +580,32 @@ Connection.prototype.getShadowDom = function(returnCurrent) {
|
||||
this.shadowDom_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the connection's shadow block.
|
||||
* @param {?blocks.State} shadowState An state represetation of the block or
|
||||
* null.
|
||||
*/
|
||||
Connection.prototype.setShadowState = function(shadowState) {
|
||||
this.setShadowStateInternal_({shadowState: shadowState});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the serialized object representation of the connection's shadow
|
||||
* block.
|
||||
* @param {boolean=} returnCurrent If true, and the shadow block is currently
|
||||
* attached to this connection, this serializes the state of that block
|
||||
* and returns it (so that field values are correct). Otherwise the saved
|
||||
* state is just returned.
|
||||
* @return {?blocks.State} Serialized object representation of the block, or
|
||||
* null.
|
||||
*/
|
||||
Connection.prototype.getShadowState = function(returnCurrent) {
|
||||
if (returnCurrent && this.targetBlock() && this.targetBlock().isShadow()) {
|
||||
return blocks.save(/** @type {!Block} */ (this.targetBlock()));
|
||||
}
|
||||
return this.shadowState_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find all nearby compatible connections to this connection.
|
||||
* Type checking does not apply, since this function is used for bumping.
|
||||
@@ -667,4 +675,123 @@ Connection.prototype.toString = function() {
|
||||
return msg + block.toDevString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the state of the shadowDom_ and shadowState_ properties, then
|
||||
* temporarily sets those properties to null so no shadow respawns.
|
||||
* @return {{shadowDom: ?Element, shadowState: ?blocks.State}} The state of both
|
||||
* the shadowDom_ and shadowState_ properties.
|
||||
* @private
|
||||
*/
|
||||
Connection.prototype.stashShadowState_ = function() {
|
||||
const shadowDom = this.getShadowDom(true);
|
||||
const shadowState = this.getShadowState(true);
|
||||
// Set to null so it doesn't respawn.
|
||||
this.shadowDom_ = null;
|
||||
this.shadowState_ = null;
|
||||
return {shadowDom, shadowState};
|
||||
};
|
||||
|
||||
/**
|
||||
* Reapplies the stashed state of the shadowDom_ and shadowState_ properties.
|
||||
* @param {{shadowDom: ?Element, shadowState: ?blocks.State}} param0 The state
|
||||
* to reapply to the shadowDom_ and shadowState_ properties.
|
||||
* @private
|
||||
*/
|
||||
Connection.prototype.applyShadowState_ =
|
||||
function({shadowDom, shadowState}) {
|
||||
this.shadowDom_ = shadowDom;
|
||||
this.shadowState_ = shadowState;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the state of the shadow of this connection.
|
||||
* @param {{shadowDom: (?Element|undefined), shadowState:
|
||||
* (?blocks.State|undefined)}=} param0 The state to set the shadow of this
|
||||
* connection to.
|
||||
* @private
|
||||
*/
|
||||
Connection.prototype.setShadowStateInternal_ =
|
||||
function({shadowDom = null, shadowState = null} = {}) {
|
||||
// One or both of these should always be null.
|
||||
// If neither is null, the shadowState will get priority.
|
||||
this.shadowDom_ = shadowDom;
|
||||
this.shadowState_ = shadowState;
|
||||
|
||||
var target = this.targetBlock();
|
||||
if (!target) {
|
||||
this.respawnShadow_();
|
||||
if (this.targetBlock() && this.targetBlock().isShadow()) {
|
||||
this.serializeShadow_(this.targetBlock());
|
||||
}
|
||||
} else if (target.isShadow()) {
|
||||
target.dispose(false);
|
||||
this.respawnShadow_();
|
||||
if (this.targetBlock() && this.targetBlock().isShadow()) {
|
||||
this.serializeShadow_(this.targetBlock());
|
||||
}
|
||||
} else {
|
||||
var shadow = this.createShadowBlock_(false);
|
||||
this.serializeShadow_(shadow);
|
||||
if (shadow) {
|
||||
shadow.dispose(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a shadow block based on the current shadowState_ or shadowDom_.
|
||||
* shadowState_ gets priority.
|
||||
* @param {boolean} attemptToConnect Whether to try to connect the shadow block
|
||||
* to this connection or not.
|
||||
* @return {?Block} The shadow block that was created, or null if both the
|
||||
* shadowState_ and shadowDom_ are null.
|
||||
* @private
|
||||
*/
|
||||
Connection.prototype.createShadowBlock_ = function(attemptToConnect) {
|
||||
var parentBlock = this.getSourceBlock();
|
||||
var shadowState = this.getShadowState();
|
||||
var shadowDom = this.getShadowDom();
|
||||
if (!parentBlock.workspace || (!shadowState && !shadowDom)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (shadowState) {
|
||||
var blockShadow = blocks.loadInternal(
|
||||
shadowState,
|
||||
parentBlock.workspace,
|
||||
attemptToConnect ? this : undefined,
|
||||
true);
|
||||
return blockShadow;
|
||||
}
|
||||
|
||||
if (shadowDom) {
|
||||
blockShadow = Xml.domToBlock(shadowDom, parentBlock.workspace);
|
||||
if (attemptToConnect) {
|
||||
if (blockShadow.outputConnection) {
|
||||
this.connect(blockShadow.outputConnection);
|
||||
} else if (blockShadow.previousConnection) {
|
||||
this.connect(blockShadow.previousConnection);
|
||||
} else {
|
||||
throw Error('Shadow block does not have output or previous statement.');
|
||||
}
|
||||
}
|
||||
return blockShadow;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Saves the given shadow block to both the shadowDom_ and shadowState_
|
||||
* properties, in their respective serialized forms.
|
||||
* @param {?Block} shadow The shadow to serialize, or null.
|
||||
* @private
|
||||
*/
|
||||
Connection.prototype.serializeShadow_ = function(shadow) {
|
||||
if (!shadow) {
|
||||
return;
|
||||
}
|
||||
this.shadowDom_ = /** @type {!Element} */ (Xml.blockToDom(shadow));
|
||||
this.shadowState_ = blocks.save(shadow);
|
||||
};
|
||||
|
||||
exports = Connection;
|
||||
|
||||
@@ -506,7 +506,6 @@ RenderedConnection.prototype.respawnShadow_ = function() {
|
||||
RenderedConnection.superClass_.respawnShadow_.call(this);
|
||||
const blockShadow = this.targetBlock();
|
||||
if (!blockShadow) {
|
||||
// This connection must not have a shadowDom_.
|
||||
return;
|
||||
}
|
||||
blockShadow.initSvg();
|
||||
|
||||
@@ -13,17 +13,15 @@
|
||||
goog.module('Blockly.serialization.blocks');
|
||||
goog.module.declareLegacyNamespace();
|
||||
|
||||
const {BadConnectionCheck, MissingBlockType, MissingConnection, RealChildOfShadow} = goog.require('Blockly.serialization.exceptions');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Block = goog.requireType('Blockly.Block');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Connection = goog.requireType('Blockly.Connection');
|
||||
const Events = goog.require('Blockly.Events');
|
||||
const {MissingBlockType, MissingConnection, BadConnectionCheck} =
|
||||
goog.require('Blockly.serialization.exceptions');
|
||||
const Size = goog.require('Blockly.utils.Size');
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const Workspace = goog.requireType('Blockly.Workspace');
|
||||
const Xml = goog.require('Blockly.Xml');
|
||||
const inputTypes = goog.require('Blockly.inputTypes');
|
||||
|
||||
|
||||
@@ -266,15 +264,14 @@ const saveNextBlocks = function(block, state) {
|
||||
* shadow block, or any connected real block.
|
||||
*/
|
||||
const saveConnection = function(connection) {
|
||||
const shadow = connection.getShadowDom();
|
||||
const shadow = connection.getShadowState();
|
||||
const child = connection.targetBlock();
|
||||
if (!shadow && !child) {
|
||||
return null;
|
||||
}
|
||||
var state = Object.create(null);
|
||||
if (shadow) {
|
||||
state['shadow'] = Xml.domToText(shadow)
|
||||
.replace('xmlns="https://developers.google.com/blockly/xml"', '');
|
||||
state['shadow'] = shadow;
|
||||
}
|
||||
if (child && !child.isShadow()) {
|
||||
state['block'] = save(child);
|
||||
@@ -332,14 +329,18 @@ exports.load = load;
|
||||
* @param {!Workspace} workspace The workspace to add the block to.
|
||||
* @param {!Connection=} parentConnection The optional parent connection to
|
||||
* attach the block to.
|
||||
* @param {boolean} isShadow Whether the block we are loading is a shadow block
|
||||
* or not.
|
||||
* @return {!Block} The block that was just loaded.
|
||||
*/
|
||||
const loadInternal = function(state, workspace, parentConnection = undefined) {
|
||||
const loadInternal = function(
|
||||
state, workspace, parentConnection = undefined, isShadow = false) {
|
||||
if (!state['type']) {
|
||||
throw new MissingBlockType(state);
|
||||
}
|
||||
|
||||
const block = workspace.newBlock(state['type'], state['id']);
|
||||
block.setShadow(isShadow);
|
||||
loadCoords(block, state);
|
||||
loadAttributes(block, state);
|
||||
loadExtraState(block, state);
|
||||
@@ -351,6 +352,8 @@ const loadInternal = function(state, workspace, parentConnection = undefined) {
|
||||
initBlock(block, workspace.rendered);
|
||||
return block;
|
||||
};
|
||||
/** @package */
|
||||
exports.loadInternal = loadInternal;
|
||||
|
||||
/**
|
||||
* Applies any coordinate information available on the state object to the
|
||||
@@ -417,6 +420,10 @@ const tryToConnectParent = function(parentConnection, child, state) {
|
||||
if (!parentConnection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (parentConnection.getSourceBlock().isShadow() && !child.isShadow()) {
|
||||
throw new RealChildOfShadow(state);
|
||||
}
|
||||
|
||||
let connected = false;
|
||||
let childConnection;
|
||||
@@ -542,7 +549,7 @@ const loadNextBlocks = function(block, state) {
|
||||
*/
|
||||
const loadConnection = function(connection, connectionState) {
|
||||
if (connectionState['shadow']) {
|
||||
connection.setShadowDom(Blockly.Xml.textToDom(connectionState['shadow']));
|
||||
connection.setShadowState(connectionState['shadow']);
|
||||
}
|
||||
if (connectionState['block']) {
|
||||
loadInternal(
|
||||
|
||||
@@ -23,7 +23,7 @@ goog.addDependency('../../core/clipboard.js', ['Blockly.clipboard'], ['Blockly.E
|
||||
goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/common.js', ['Blockly.common'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.serialization.blocks', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.internalConstants', 'Blockly.registry'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.connectionTypes', 'Blockly.constants'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_types.js', ['Blockly.connectionTypes'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -196,7 +196,7 @@ goog.addDependency('../../core/renderers/zelos/renderer.js', ['Blockly.zelos.Ren
|
||||
goog.addDependency('../../core/requires.js', ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.ContextMenuItems', '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.ShortcutItems', 'Blockly.Themes.Classic', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.VerticalFlyout', 'Blockly.Warning', 'Blockly.ZoomControls', 'Blockly.geras.Renderer', 'Blockly.serialization.workspaces', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer']);
|
||||
goog.addDependency('../../core/scrollbar.js', ['Blockly.Scrollbar'], ['Blockly.Touch', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/scrollbar_pair.js', ['Blockly.ScrollbarPair'], ['Blockly.Events', 'Blockly.Scrollbar', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/blocks.js', ['Blockly.serialization.blocks'], ['Blockly.Events', 'Blockly.Xml', 'Blockly.inputTypes', 'Blockly.serialization.exceptions', 'Blockly.utils.Size'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/blocks.js', ['Blockly.serialization.blocks'], ['Blockly.Events', 'Blockly.inputTypes', 'Blockly.serialization.exceptions', 'Blockly.utils.Size'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/exceptions.js', ['Blockly.serialization.exceptions'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/variables.js', ['Blockly.serialization.variables'], ['Blockly.Events'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/workspaces.js', ['Blockly.serialization.workspaces'], ['Blockly.Events', 'Blockly.Workspace', 'Blockly.serialization.blocks', 'Blockly.serialization.variables', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
goog.addDependency('../../blocks/colour.js', ['Blockly.Blocks.colour', 'Blockly.Constants.Colour'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldColour', 'Blockly.FieldLabel']);
|
||||
goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator']);
|
||||
goog.addDependency('../../blocks/lists.js', ['Blockly.Constants.Lists'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator'], {'lang': 'es5'});
|
||||
goog.addDependency('../../blocks/logic.js', ['Blockly.Blocks.logic', 'Blockly.Constants.Logic'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.Mutator']);
|
||||
goog.addDependency('../../blocks/loops.js', ['Blockly.Blocks.loops', 'Blockly.Constants.Loops'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable', 'Blockly.Warning']);
|
||||
goog.addDependency('../../blocks/math.js', ['Blockly.Blocks.math', 'Blockly.Constants.Math'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable']);
|
||||
goog.addDependency('../../blocks/procedures.js', ['Blockly.Blocks.procedures'], ['Blockly', 'Blockly.Blocks', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning'], {'lang': 'es5'});
|
||||
goog.addDependency('../../blocks/text.js', ['Blockly.Blocks.texts', 'Blockly.Constants.Text'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator']);
|
||||
goog.addDependency('../../blocks/math.js', ['Blockly.Blocks.math', 'Blockly.Constants.Math'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldLabel', 'Blockly.FieldNumber', 'Blockly.FieldVariable'], {'lang': 'es5'});
|
||||
goog.addDependency('../../blocks/procedures.js', ['Blockly.Blocks.procedures'], ['Blockly', 'Blockly.Blocks', 'Blockly.Comment', 'Blockly.FieldCheckbox', 'Blockly.FieldLabel', 'Blockly.FieldTextInput', 'Blockly.Mutator', 'Blockly.Warning'], {'lang': 'es6'});
|
||||
goog.addDependency('../../blocks/text.js', ['Blockly.Blocks.texts', 'Blockly.Constants.Text'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldMultilineInput', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Mutator'], {'lang': 'es5'});
|
||||
goog.addDependency('../../blocks/variables.js', ['Blockly.Blocks.variables', 'Blockly.Constants.Variables'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldLabel', 'Blockly.FieldVariable']);
|
||||
goog.addDependency('../../blocks/variables_dynamic.js', ['Blockly.Constants.VariablesDynamic'], ['Blockly', 'Blockly.Blocks', 'Blockly.FieldLabel', 'Blockly.FieldVariable']);
|
||||
goog.addDependency('../../core/block.js', ['Blockly.Block'], ['Blockly.ASTNode', 'Blockly.Blocks', 'Blockly.Connection', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BlockCreate', 'Blockly.Events.BlockDelete', 'Blockly.Events.BlockMove', 'Blockly.Extensions', 'Blockly.Input', 'Blockly.Tooltip', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.fieldRegistry', 'Blockly.inputTypes', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Size', 'Blockly.utils.idGenerator', 'Blockly.utils.object'], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -23,7 +23,7 @@ goog.addDependency('../../core/clipboard.js', ['Blockly.clipboard'], ['Blockly.E
|
||||
goog.addDependency('../../core/comment.js', ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Css', 'Blockly.Events', 'Blockly.Events.BlockChange', 'Blockly.Events.BubbleOpen', 'Blockly.Icon', 'Blockly.Warning', 'Blockly.browserEvents', 'Blockly.utils.Svg', 'Blockly.utils.dom', 'Blockly.utils.object', 'Blockly.utils.userAgent'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/common.js', ['Blockly.common'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/component_manager.js', ['Blockly.ComponentManager'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection.js', ['Blockly.Connection'], ['Blockly.Events', 'Blockly.Events.BlockMove', 'Blockly.Xml', 'Blockly.connectionTypes', 'Blockly.constants', 'Blockly.serialization.blocks', 'Blockly.utils.deprecation'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_checker.js', ['Blockly.ConnectionChecker'], ['Blockly.Connection', 'Blockly.common', 'Blockly.connectionTypes', 'Blockly.internalConstants', 'Blockly.registry'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_db.js', ['Blockly.ConnectionDB'], ['Blockly.connectionTypes', 'Blockly.constants'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/connection_types.js', ['Blockly.connectionTypes'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -196,7 +196,8 @@ goog.addDependency('../../core/renderers/zelos/renderer.js', ['Blockly.zelos.Ren
|
||||
goog.addDependency('../../core/requires.js', ['Blockly.requires'], ['Blockly', 'Blockly.Comment', 'Blockly.ContextMenuItems', '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.ShortcutItems', 'Blockly.Themes.Classic', 'Blockly.Toolbox', 'Blockly.Trashcan', 'Blockly.VariablesDynamic', 'Blockly.VerticalFlyout', 'Blockly.Warning', 'Blockly.ZoomControls', 'Blockly.geras.Renderer', 'Blockly.serialization.workspaces', 'Blockly.thrasos.Renderer', 'Blockly.zelos.Renderer']);
|
||||
goog.addDependency('../../core/scrollbar.js', ['Blockly.Scrollbar'], ['Blockly.Touch', 'Blockly.browserEvents', 'Blockly.utils', 'Blockly.utils.Coordinate', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/scrollbar_pair.js', ['Blockly.ScrollbarPair'], ['Blockly.Events', 'Blockly.Scrollbar', 'Blockly.utils.Svg', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/blocks.js', ['Blockly.serialization.blocks'], ['Blockly.Events', 'Blockly.Xml', 'Blockly.inputTypes'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/blocks.js', ['Blockly.serialization.blocks'], ['Blockly.Events', 'Blockly.inputTypes', 'Blockly.serialization.exceptions', 'Blockly.utils.Size'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/exceptions.js', ['Blockly.serialization.exceptions'], [], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/variables.js', ['Blockly.serialization.variables'], ['Blockly.Events'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/serialization/workspaces.js', ['Blockly.serialization.workspaces'], ['Blockly.Events', 'Blockly.Workspace', 'Blockly.serialization.blocks', 'Blockly.serialization.variables', 'Blockly.utils.dom'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../core/shortcut_items.js', ['Blockly.ShortcutItems'], ['Blockly.Gesture', 'Blockly.ShortcutRegistry', 'Blockly.clipboard', 'Blockly.common', 'Blockly.utils.KeyCodes'], {'lang': 'es6', 'module': 'goog'});
|
||||
@@ -332,7 +333,7 @@ goog.addDependency('../../tests/mocha/gesture_test.js', ['Blockly.test.gesture']
|
||||
goog.addDependency('../../tests/mocha/input_test.js', ['Blockly.test.input'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/insertion_marker_test.js', ['Blockly.test.insertionMarker'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/jso_deserialization_test.js', ['Blockly.test.jsoDeserialization'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/jso_serialization_test.js', ['Blockly.test.jsoSerialization'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/jso_serialization_test.js', ['Blockly.test.jsoSerialization'], ['Blockly.test.helpers'], {'lang': 'es8', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/json_test.js', ['Blockly.test.json'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/keydown_test.js', ['Blockly.test.keydown'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
goog.addDependency('../../tests/mocha/logic_ternary_test.js', ['Blockly.test.logicTernary'], ['Blockly.test.helpers'], {'lang': 'es6', 'module': 'goog'});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -627,7 +627,7 @@ suite('JSO Deserialization', function() {
|
||||
});
|
||||
});
|
||||
|
||||
suite.skip('Real child of shadow', function() {
|
||||
suite('Real child of shadow', function() {
|
||||
test('Input', function() {
|
||||
const state = {
|
||||
'blocks': {
|
||||
@@ -664,10 +664,10 @@ suite('JSO Deserialization', function() {
|
||||
'type': 'text_print',
|
||||
'next': {
|
||||
'shadow': {
|
||||
'type': 'text_input',
|
||||
'type': 'text_print',
|
||||
'next': {
|
||||
'block': {
|
||||
'type': 'text_input',
|
||||
'type': 'text_print',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -424,7 +424,7 @@ suite('JSO Serialization', function() {
|
||||
const block = this.workspace.newBlock(blockType);
|
||||
block.getInput(inputName).connection.setShadowDom(
|
||||
Blockly.Xml.textToDom(
|
||||
'<block type="' + blockType + '" id="test"></block>'));
|
||||
'<shadow type="' + blockType + '" id="test"></shadow>'));
|
||||
return block;
|
||||
};
|
||||
|
||||
@@ -435,7 +435,7 @@ suite('JSO Serialization', function() {
|
||||
childBlock.outputConnection || childBlock.previousConnection);
|
||||
block.getInput(inputName).connection.setShadowDom(
|
||||
Blockly.Xml.textToDom(
|
||||
'<block type="' + blockType + '" id="test"></block>'));
|
||||
'<shadow type="' + blockType + '" id="test"></shadow>'));
|
||||
return block;
|
||||
};
|
||||
|
||||
@@ -501,11 +501,11 @@ suite('JSO Serialization', function() {
|
||||
this.assertChild('row_block', 'INPUT');
|
||||
});
|
||||
|
||||
test.skip('Shadow', function() {
|
||||
test('Shadow', function() {
|
||||
this.assertShadow('row_block', 'INPUT');
|
||||
});
|
||||
|
||||
test.skip('Overwritten shadow', function() {
|
||||
test('Overwritten shadow', function() {
|
||||
this.assertOverwrittenShadow('row_block', 'INPUT');
|
||||
});
|
||||
});
|
||||
@@ -531,11 +531,11 @@ suite('JSO Serialization', function() {
|
||||
this.assertChild('statement_block', 'NAME');
|
||||
});
|
||||
|
||||
test.skip('Shadow', function() {
|
||||
test('Shadow', function() {
|
||||
this.assertShadow('statement_block', 'NAME');
|
||||
});
|
||||
|
||||
test.skip('Overwritten shadow', function() {
|
||||
test('Overwritten shadow', function() {
|
||||
this.assertOverwrittenShadow('statement_block', 'NAME');
|
||||
});
|
||||
|
||||
@@ -595,7 +595,7 @@ suite('JSO Serialization', function() {
|
||||
const block = this.workspace.newBlock('stack_block');
|
||||
block.nextConnection.setShadowDom(
|
||||
Blockly.Xml.textToDom(
|
||||
'<block type="stack_block" id="test"></block>'));
|
||||
'<shadow type="stack_block" id="test"></shadow>'));
|
||||
return block;
|
||||
};
|
||||
|
||||
@@ -605,7 +605,7 @@ suite('JSO Serialization', function() {
|
||||
block.nextConnection.connect(childBlock.previousConnection);
|
||||
block.nextConnection.setShadowDom(
|
||||
Blockly.Xml.textToDom(
|
||||
'<block type="stack_block" id="test"></block>'));
|
||||
'<shadow type="stack_block" id="test"></shadow>'));
|
||||
return block;
|
||||
};
|
||||
});
|
||||
@@ -619,14 +619,14 @@ suite('JSO Serialization', function() {
|
||||
jso['next'], {'block': { 'type': 'stack_block', 'id': 'id2'}});
|
||||
});
|
||||
|
||||
test.skip('Shadow', function() {
|
||||
test('Shadow', function() {
|
||||
const block = this.createNextWithShadow();
|
||||
const jso = Blockly.serialization.blocks.save(block);
|
||||
chai.assert.deepInclude(
|
||||
jso['next'], {'shadow': { 'type': 'stack_block', 'id': 'test'}});
|
||||
});
|
||||
|
||||
test.skip('Overwritten shadow', function() {
|
||||
test('Overwritten shadow', function() {
|
||||
const block = this.createNextWithShadowAndChild();
|
||||
const jso = Blockly.serialization.blocks.save(block);
|
||||
chai.assert.deepInclude(
|
||||
|
||||
Reference in New Issue
Block a user