mirror of
https://github.com/google/blockly.git
synced 2026-05-12 23:20:10 +02:00
29e1f0cb03
* fix: relative path for deprecation utils * fix: checking if properties exist in svg_math * fix: set all timeout PIDs to AnyDuringMigration * fix: make nullability errors explicity in block drag surface * fix: make null check in events_block_change explicit * fix: make getEventWorkspace_ internal so we can access it from CommentCreateDeleteHelper * fix: rename DIV -> containerDiv in tooltip * fix: ignore backwards compat check in category * fix: set block styles to AnyDuringMigration * fix: type typo in KeyboardShortcut * fix: constants name in row measurables * fix: typecast in mutator * fix: populateProcedures type of flattened array * fix: ignore errors related to workspace comment deserialization * chore: format files * fix: renaming imports missing file extensions * fix: remove check for sound.play * fix: temporarily remove bad requireType. All `export type` statements are stripped when tsc is run. This means that when we attempt to require BlockDefinition from the block files, we get an error because it does not exist. We decided to temporarily remove the require, because this will no longer be a problem when we conver the blocks to typescript, and everything gets compiled together. * fix: bad jsdoc in array * fix: silence missing property errors Closure was complaining about inexistant properties, but they actually do exist, they're just not being transpiled by tsc in a way that closure understands. I.E. if things are initialized in a function called by the constructor, rather than in a class field or in the custructor itself, closure would error. It would also error on enums, because they are transpiled to a weird IIFE. * fix: context menu action handler not knowing the type of this. this: TypeX information gets stripped when tsc is run, so closure could not know that this was not global. Fixed this by reorganizing to use the option object directly instead of passing it to onAction to be bound to this. * fix: readd getDeveloperVars checks (should not be part of migration) This was found because ALL_DEVELOPER_VARS_WARNINGS_BY_BLOCK_TYPE was no longer being accessed. * fix: silence closure errors about overriding supertype props We propertly define the overrides in typescript, but these get removed from the compiled output, so closure doesn't know they exist. * fix: silence globalThis errors this: TypeX annotations get stripped from the compiled output, so closure can't know that we're accessing the correct things. However, typescript makes sure that this always has the correct properties, so silencing this should be fine. * fix: bad jsdoc name * chore: attempt compiling with blockly.js * fix: attempt moving the import statement above the namespace line * chore: add todo comments to block def files * chore: remove todo from context menu * chore: add comments abotu disabled errors
186 lines
5.0 KiB
TypeScript
186 lines
5.0 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2020 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @fileoverview The interface for a flyout.
|
|
*/
|
|
|
|
/**
|
|
* The interface for a flyout.
|
|
* @namespace Blockly.IFlyout
|
|
*/
|
|
import * as goog from '../../closure/goog/goog.js';
|
|
goog.declareModuleId('Blockly.IFlyout');
|
|
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
// Unused import preserved for side-effects. Remove if unneeded.
|
|
import '../utils/toolbox.js';
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
// Unused import preserved for side-effects. Remove if unneeded.
|
|
import '../block_svg.js';
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
// Unused import preserved for side-effects. Remove if unneeded.
|
|
import '../utils/coordinate.js';
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
// Unused import preserved for side-effects. Remove if unneeded.
|
|
import '../utils/svg.js';
|
|
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
import {WorkspaceSvg} from '../workspace_svg.js';
|
|
|
|
/* eslint-disable-next-line no-unused-vars */
|
|
import {IRegistrable} from './i_registrable.js';
|
|
|
|
|
|
/**
|
|
* Interface for a flyout.
|
|
* @alias Blockly.IFlyout
|
|
*/
|
|
export interface IFlyout extends IRegistrable {
|
|
/** Whether the flyout is laid out horizontally or not. */
|
|
horizontalLayout: boolean;
|
|
|
|
/** Is RTL vs LTR. */
|
|
RTL: boolean;
|
|
|
|
/** The target workspace */
|
|
targetWorkspace: WorkspaceSvg|null;
|
|
|
|
/** Margin around the edges of the blocks in the flyout. */
|
|
readonly MARGIN: number;
|
|
|
|
/** Does the flyout automatically close when a block is created? */
|
|
autoClose: boolean;
|
|
|
|
/** Corner radius of the flyout background. */
|
|
readonly CORNER_RADIUS: number;
|
|
|
|
/**
|
|
* Creates the flyout's DOM. Only needs to be called once. The flyout can
|
|
* either exist as its own svg element or be a g element nested inside a
|
|
* separate svg element.
|
|
* @param tagName The type of tag to put the flyout in. This should be <svg>
|
|
* or <g>.
|
|
* @return The flyout's SVG group.
|
|
*/
|
|
createDom: AnyDuringMigration;
|
|
|
|
/**
|
|
* Initializes the flyout.
|
|
* @param targetWorkspace The workspace in which to create new blocks.
|
|
*/
|
|
init: AnyDuringMigration;
|
|
|
|
/**
|
|
* Dispose of this flyout.
|
|
* Unlink from all DOM elements to prevent memory leaks.
|
|
*/
|
|
dispose: () => void;
|
|
|
|
/**
|
|
* Get the width of the flyout.
|
|
* @return The width of the flyout.
|
|
*/
|
|
getWidth: AnyDuringMigration;
|
|
|
|
/**
|
|
* Get the height of the flyout.
|
|
* @return The width of the flyout.
|
|
*/
|
|
getHeight: AnyDuringMigration;
|
|
|
|
/**
|
|
* Get the workspace inside the flyout.
|
|
* @return The workspace inside the flyout.
|
|
*/
|
|
getWorkspace: AnyDuringMigration;
|
|
|
|
/**
|
|
* Is the flyout visible?
|
|
* @return True if visible.
|
|
*/
|
|
isVisible: AnyDuringMigration;
|
|
|
|
/**
|
|
* Set whether the flyout is visible. A value of true does not necessarily
|
|
* mean that the flyout is shown. It could be hidden because its container is
|
|
* hidden.
|
|
* @param visible True if visible.
|
|
*/
|
|
setVisible: AnyDuringMigration;
|
|
|
|
/**
|
|
* Set whether this flyout's container is visible.
|
|
* @param visible Whether the container is visible.
|
|
*/
|
|
setContainerVisible: AnyDuringMigration;
|
|
|
|
/** Hide and empty the flyout. */
|
|
hide: () => void;
|
|
|
|
/**
|
|
* Show and populate the flyout.
|
|
* @param flyoutDef Contents to display in the flyout. This is either an array
|
|
* of Nodes, a NodeList, a toolbox definition, or a string with the name
|
|
* of the dynamic category.
|
|
*/
|
|
show: AnyDuringMigration;
|
|
|
|
/**
|
|
* Create a copy of this block on the workspace.
|
|
* @param originalBlock The block to copy from the flyout.
|
|
* @return The newly created block.
|
|
* @throws {Error} if something went wrong with deserialization.
|
|
*/
|
|
createBlock: AnyDuringMigration;
|
|
|
|
/** Reflow blocks and their mats. */
|
|
reflow: () => void;
|
|
|
|
/**
|
|
* @return True if this flyout may be scrolled with a scrollbar or by
|
|
* dragging.
|
|
*/
|
|
isScrollable: AnyDuringMigration;
|
|
|
|
/**
|
|
* Calculates the x coordinate for the flyout position.
|
|
* @return X coordinate.
|
|
*/
|
|
getX: AnyDuringMigration;
|
|
|
|
/**
|
|
* Calculates the y coordinate for the flyout position.
|
|
* @return Y coordinate.
|
|
*/
|
|
getY: AnyDuringMigration;
|
|
|
|
/** Position the flyout. */
|
|
position: AnyDuringMigration;
|
|
|
|
/**
|
|
* Determine if a drag delta is toward the workspace, based on the position
|
|
* and orientation of the flyout. This is used in determineDragIntention_ to
|
|
* determine if a new block should be created or if the flyout should scroll.
|
|
* @param currentDragDeltaXY How far the pointer has moved from the position
|
|
* at mouse down, in pixel units.
|
|
* @return True if the drag is toward the workspace.
|
|
*/
|
|
isDragTowardWorkspace: AnyDuringMigration;
|
|
|
|
/**
|
|
* Does this flyout allow you to create a new instance of the given block?
|
|
* Used for deciding if a block can be "dragged out of" the flyout.
|
|
* @param block The block to copy from the flyout.
|
|
* @return True if you can create a new instance of the block, false
|
|
* otherwise.
|
|
*/
|
|
isBlockCreatable: AnyDuringMigration;
|
|
|
|
/** Scroll the flyout to the beginning of its contents. */
|
|
scrollToStart: () => void;
|
|
}
|