Files
Beka Westberg 9d5dcc6e46 fix: circular dependencies (#6281)
* chore: fix circular dependencies w/ static workspace funcs

* remove preserved imports that aren't currently necessary (probably)

* fix circular dependency with workspaces and block using stub

* fix dependency between variables and xml by moving function to utils

* add stub for trashcan as well

* fix line endings from rebase

* fix goog/base order

* add trashcan patch

* fix: types of compose and decompose in block

* fix: workspace naming in toolbox

* chore: add jsdoc

* chore: restore registry comments to better positions

* chore: remove implementations in goog.js

* chore: fix types of stubs

* chore: remove added AnyDuringMigration casts

* chore: remove modifications to xml and variables

* chore: format

* chore: remove event requirements in workspace comments

* chore: fix circular dependency with xml and workspace comments

* fixup remove ContextMenu import

* chore: fix dependency between mutator and workspace

* chore: break circular dependency between names and procedures

* chore: get tests to run?

* chore: pr comments'

* chore: fix stubbing field registry fromJson

* chore: fix spying on fire

* chore: fix stubbing parts of connection checker

* chore: fix stubbing dialog

* chore: fix stubbing style

* chore: fix spying on duplicate

* chore: fix stubbing variables

* chore: fix stubbing copy

* chore: fix stubbing in workspace

* chore: remove unnecessary stubs

* chore: fix formatting

* chore: fix other formatting

* chore: add backwards compatible static properties to workspace

* chore: move static type properties

* chore: move and comment stubs

* chore: add newlines at EOF

* chore: improve errors for monkey patched functions

* chore: update comment with a pointer to the doc

* chore: update comment with a pointer to the doc

* chore: format
2022-07-28 15:26:38 -07:00

184 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';
import type {WorkspaceSvg} from '../workspace_svg.js';
import type {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;
}