mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
chore: remove alias comments (#6816)
* chore: remove alias comments * chore: format * chore: remove extra newlines * chore: fix bad replaces
This commit is contained in:
@@ -24,8 +24,6 @@ const ROLE_ATTRIBUTE = 'role';
|
||||
/**
|
||||
* ARIA role values.
|
||||
* Copied from Closure's goog.a11y.aria.Role
|
||||
*
|
||||
* @alias Blockly.utils.aria.Role
|
||||
*/
|
||||
export enum Role {
|
||||
// ARIA role for an interactive control of tabular data.
|
||||
@@ -64,8 +62,6 @@ export enum Role {
|
||||
/**
|
||||
* ARIA states and properties.
|
||||
* Copied from Closure's goog.a11y.aria.State
|
||||
*
|
||||
* @alias Blockly.utils.aria.State
|
||||
*/
|
||||
export enum State {
|
||||
// ARIA property for setting the currently active descendant of an element,
|
||||
@@ -129,7 +125,6 @@ export enum State {
|
||||
*
|
||||
* @param element DOM node to set role of.
|
||||
* @param roleName Role name.
|
||||
* @alias Blockly.utils.aria.setRole
|
||||
*/
|
||||
export function setRole(element: Element, roleName: Role) {
|
||||
element.setAttribute(ROLE_ATTRIBUTE, roleName);
|
||||
@@ -144,7 +139,6 @@ export function setRole(element: Element, roleName: Role) {
|
||||
* Automatically adds prefix 'aria-' to the state name if the attribute is
|
||||
* not an extra attribute.
|
||||
* @param value Value for the state attribute.
|
||||
* @alias Blockly.utils.aria.setState
|
||||
*/
|
||||
export function setState(
|
||||
element: Element, stateName: State, value: string|boolean|number|string[]) {
|
||||
|
||||
@@ -15,7 +15,6 @@ goog.declareModuleId('Blockly.utils.array');
|
||||
* @param arr Array from which to remove value.
|
||||
* @param value Value to remove.
|
||||
* @returns True if an element was removed.
|
||||
* @alias Blockly.array.removeElem
|
||||
* @internal
|
||||
*/
|
||||
export function removeElem<T>(arr: Array<T>, value: T): boolean {
|
||||
|
||||
@@ -16,15 +16,12 @@ goog.declareModuleId('Blockly.utils.colour');
|
||||
/**
|
||||
* The richness of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*
|
||||
* @alias Blockly.utils.colour.hsvSaturation
|
||||
*/
|
||||
let hsvSaturation = 0.45;
|
||||
|
||||
/**
|
||||
* Get the richness of block colours, regardless of the hue.
|
||||
*
|
||||
* @alias Blockly.utils.colour.getHsvSaturation
|
||||
* @returns The current richness.
|
||||
* @internal
|
||||
*/
|
||||
@@ -37,7 +34,6 @@ export function getHsvSaturation(): number {
|
||||
*
|
||||
* @param newSaturation The new richness, in the range of 0 (inclusive) to 1
|
||||
* (exclusive)
|
||||
* @alias Blockly.utils.colour.setHsvSaturation
|
||||
* @internal
|
||||
*/
|
||||
export function setHsvSaturation(newSaturation: number) {
|
||||
@@ -47,15 +43,12 @@ export function setHsvSaturation(newSaturation: number) {
|
||||
/**
|
||||
* The intensity of block colours, regardless of the hue.
|
||||
* Must be in the range of 0 (inclusive) to 1 (exclusive).
|
||||
*
|
||||
* @alias Blockly.utils.colour.hsvValue
|
||||
*/
|
||||
let hsvValue = 0.65;
|
||||
|
||||
/**
|
||||
* Get the intensity of block colours, regardless of the hue.
|
||||
*
|
||||
* @alias Blockly.utils.colour.getHsvValue
|
||||
* @returns The current intensity.
|
||||
* @internal
|
||||
*/
|
||||
@@ -68,7 +61,6 @@ export function getHsvValue(): number {
|
||||
*
|
||||
* @param newValue The new intensity, in the range of 0 (inclusive) to 1
|
||||
* (exclusive)
|
||||
* @alias Blockly.utils.colour.setHsvValue
|
||||
* @internal
|
||||
*/
|
||||
export function setHsvValue(newValue: number) {
|
||||
@@ -86,7 +78,6 @@ export function setHsvValue(newValue: number) {
|
||||
* @param str Colour in some CSS format.
|
||||
* @returns A string containing a hex representation of the colour, or null if
|
||||
* can't be parsed.
|
||||
* @alias Blockly.utils.colour.parse
|
||||
*/
|
||||
export function parse(str: string|number): string|null {
|
||||
str = String(str).toLowerCase().trim();
|
||||
@@ -125,7 +116,6 @@ export function parse(str: string|number): string|null {
|
||||
* @param g Amount of green, int between 0 and 255.
|
||||
* @param b Amount of blue, int between 0 and 255.
|
||||
* @returns Hex representation of the colour.
|
||||
* @alias Blockly.utils.colour.rgbToHex
|
||||
*/
|
||||
export function rgbToHex(r: number, g: number, b: number): string {
|
||||
const rgb = r << 16 | g << 8 | b;
|
||||
@@ -141,7 +131,6 @@ export function rgbToHex(r: number, g: number, b: number): string {
|
||||
* @param colour String representing colour in any colour format ('#ff0000',
|
||||
* 'red', '0xff000', etc).
|
||||
* @returns RGB representation of the colour.
|
||||
* @alias Blockly.utils.colour.hexToRgb
|
||||
*/
|
||||
export function hexToRgb(colour: string): number[] {
|
||||
const hex = parse(colour);
|
||||
@@ -164,7 +153,6 @@ export function hexToRgb(colour: string): number[] {
|
||||
* @param s Saturation value in [0, 1].
|
||||
* @param v Brightness in [0, 255].
|
||||
* @returns Hex representation of the colour.
|
||||
* @alias Blockly.utils.colour.hsvToHex
|
||||
*/
|
||||
export function hsvToHex(h: number, s: number, v: number): string {
|
||||
let red = 0;
|
||||
@@ -226,7 +214,6 @@ export function hsvToHex(h: number, s: number, v: number): string {
|
||||
* @param factor The weight to be given to colour1 over colour2.
|
||||
* Values should be in the range [0, 1].
|
||||
* @returns Combined colour represented in hex.
|
||||
* @alias Blockly.utils.colour.blend
|
||||
*/
|
||||
export function blend(colour1: string, colour2: string, factor: number): string|
|
||||
null {
|
||||
@@ -251,8 +238,6 @@ export function blend(colour1: string, colour2: string, factor: number): string|
|
||||
* https://www.w3.org/TR/2018/REC-css-color-3-20180619/#html4
|
||||
* The keys of this map are the lowercase "readable" names of the colours,
|
||||
* while the values are the "hex" values.
|
||||
*
|
||||
* @alias Blockly.utils.colour.names
|
||||
*/
|
||||
export const names: {[key: string]: string} = {
|
||||
'aqua': '#00ffff',
|
||||
@@ -278,7 +263,6 @@ export const names: {[key: string]: string} = {
|
||||
*
|
||||
* @param hue Hue on a colour wheel (0-360).
|
||||
* @returns RGB code, e.g. '#5ba65b'.
|
||||
* @alias Blockly.utils.colour.hueToHex
|
||||
*/
|
||||
export function hueToHex(hue: number): string {
|
||||
return hsvToHex(hue, hsvSaturation, hsvValue * 255);
|
||||
|
||||
@@ -17,8 +17,6 @@ goog.declareModuleId('Blockly.utils.Coordinate');
|
||||
|
||||
/**
|
||||
* Class for representing coordinates and positions.
|
||||
*
|
||||
* @alias Blockly.utils.Coordinate
|
||||
*/
|
||||
export class Coordinate {
|
||||
/**
|
||||
|
||||
@@ -23,7 +23,6 @@ goog.declareModuleId('Blockly.utils.deprecation');
|
||||
* @param deletionDate The date of deletion. Prefer 'version n.0.0'
|
||||
* format, and fall back to 'month yyyy' or 'quarter yyyy' format.
|
||||
* @param opt_use The name of a function or property to use instead, if any.
|
||||
* @alias Blockly.utils.deprecation.warn
|
||||
* @internal
|
||||
*/
|
||||
export function warn(
|
||||
|
||||
@@ -19,30 +19,22 @@ import type {Svg} from './svg.js';
|
||||
|
||||
/**
|
||||
* Required name space for SVG elements.
|
||||
*
|
||||
* @alias Blockly.utils.dom.SVG_NS
|
||||
*/
|
||||
export const SVG_NS = 'http://www.w3.org/2000/svg';
|
||||
|
||||
/**
|
||||
* Required name space for HTML elements.
|
||||
*
|
||||
* @alias Blockly.utils.dom.HTML_NS
|
||||
*/
|
||||
export const HTML_NS = 'http://www.w3.org/1999/xhtml';
|
||||
|
||||
/**
|
||||
* Required name space for XLINK elements.
|
||||
*
|
||||
* @alias Blockly.utils.dom.XLINK_NS
|
||||
*/
|
||||
export const XLINK_NS = 'http://www.w3.org/1999/xlink';
|
||||
|
||||
/**
|
||||
* Node type constants.
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
||||
*
|
||||
* @alias Blockly.utils.dom.NodeType
|
||||
*/
|
||||
export enum NodeType {
|
||||
ELEMENT_NODE = 1,
|
||||
@@ -67,7 +59,6 @@ let canvasContext: CanvasRenderingContext2D|null = null;
|
||||
* @param attrs Dictionary of attribute names and values.
|
||||
* @param opt_parent Optional parent on which to append the element.
|
||||
* @returns if name is a string or a more specific type if it a member of Svg.
|
||||
* @alias Blockly.utils.dom.createSvgElement
|
||||
*/
|
||||
export function createSvgElement<T extends SVGElement>(
|
||||
name: string|Svg<T>, attrs: {[key: string]: string|number},
|
||||
@@ -90,7 +81,6 @@ export function createSvgElement<T extends SVGElement>(
|
||||
* @param element DOM element to add class to.
|
||||
* @param className Name of class to add.
|
||||
* @returns True if class was added, false if already present.
|
||||
* @alias Blockly.utils.dom.addClass
|
||||
*/
|
||||
export function addClass(element: Element, className: string): boolean {
|
||||
const classNames = className.split(' ');
|
||||
@@ -106,7 +96,6 @@ export function addClass(element: Element, className: string): boolean {
|
||||
*
|
||||
* @param element DOM element to remove classes from.
|
||||
* @param classNames A string of one or multiple class names for an element.
|
||||
* @alias Blockly.utils.dom.removeClasses
|
||||
*/
|
||||
export function removeClasses(element: Element, classNames: string) {
|
||||
element.classList.remove(...classNames.split(' '));
|
||||
@@ -120,7 +109,6 @@ export function removeClasses(element: Element, classNames: string) {
|
||||
* @param element DOM element to remove class from.
|
||||
* @param className Name of class to remove.
|
||||
* @returns True if class was removed, false if never present.
|
||||
* @alias Blockly.utils.dom.removeClass
|
||||
*/
|
||||
export function removeClass(element: Element, className: string): boolean {
|
||||
const classNames = className.split(' ');
|
||||
@@ -137,7 +125,6 @@ export function removeClass(element: Element, className: string): boolean {
|
||||
* @param element DOM element to check.
|
||||
* @param className Name of class to check.
|
||||
* @returns True if class exists, false otherwise.
|
||||
* @alias Blockly.utils.dom.hasClass
|
||||
*/
|
||||
export function hasClass(element: Element, className: string): boolean {
|
||||
return element.classList.contains(className);
|
||||
@@ -148,7 +135,6 @@ export function hasClass(element: Element, className: string): boolean {
|
||||
*
|
||||
* @param node The node to remove.
|
||||
* @returns The node removed if removed; else, null.
|
||||
* @alias Blockly.utils.dom.removeNode
|
||||
*/
|
||||
// Copied from Closure goog.dom.removeNode
|
||||
export function removeNode(node: Node|null): Node|null {
|
||||
@@ -161,7 +147,6 @@ export function removeNode(node: Node|null): Node|null {
|
||||
*
|
||||
* @param newNode New element to insert.
|
||||
* @param refNode Existing element to precede new node.
|
||||
* @alias Blockly.utils.dom.insertAfter
|
||||
*/
|
||||
export function insertAfter(newNode: Element, refNode: Element) {
|
||||
const siblingNode = refNode.nextSibling;
|
||||
@@ -182,7 +167,6 @@ export function insertAfter(newNode: Element, refNode: Element) {
|
||||
* @param parent The node that should contain the other node.
|
||||
* @param descendant The node to test presence of.
|
||||
* @returns Whether the parent node contains the descendant node.
|
||||
* @alias Blockly.utils.dom.containsNode
|
||||
*/
|
||||
export function containsNode(parent: Node, descendant: Node): boolean {
|
||||
return !!(
|
||||
@@ -197,7 +181,6 @@ export function containsNode(parent: Node, descendant: Node): boolean {
|
||||
*
|
||||
* @param element Element to which the CSS transform will be applied.
|
||||
* @param transform The value of the CSS `transform` property.
|
||||
* @alias Blockly.utils.dom.setCssTransform
|
||||
*/
|
||||
export function setCssTransform(
|
||||
element: HTMLElement|SVGElement, transform: string) {
|
||||
@@ -208,8 +191,6 @@ export function setCssTransform(
|
||||
/**
|
||||
* Start caching text widths. Every call to this function MUST also call
|
||||
* stopTextWidthCache. Caches must not survive between execution threads.
|
||||
*
|
||||
* @alias Blockly.utils.dom.startTextWidthCache
|
||||
*/
|
||||
export function startTextWidthCache() {
|
||||
cacheReference++;
|
||||
@@ -221,8 +202,6 @@ export function startTextWidthCache() {
|
||||
/**
|
||||
* Stop caching field widths. Unless caching was already on when the
|
||||
* corresponding call to startTextWidthCache was made.
|
||||
*
|
||||
* @alias Blockly.utils.dom.stopTextWidthCache
|
||||
*/
|
||||
export function stopTextWidthCache() {
|
||||
cacheReference--;
|
||||
@@ -236,7 +215,6 @@ export function stopTextWidthCache() {
|
||||
*
|
||||
* @param textElement An SVG 'text' element.
|
||||
* @returns Width of element.
|
||||
* @alias Blockly.utils.dom.getTextWidth
|
||||
*/
|
||||
export function getTextWidth(textElement: SVGTextElement): number {
|
||||
const key = textElement.textContent + '\n' + textElement.className.baseVal;
|
||||
@@ -277,7 +255,6 @@ export function getTextWidth(textElement: SVGTextElement): number {
|
||||
* @param fontWeight The font weight to use.
|
||||
* @param fontFamily The font family to use.
|
||||
* @returns Width of element.
|
||||
* @alias Blockly.utils.dom.getFastTextWidth
|
||||
*/
|
||||
export function getFastTextWidth(
|
||||
textElement: SVGTextElement, fontSize: number, fontWeight: string,
|
||||
@@ -298,7 +275,6 @@ export function getFastTextWidth(
|
||||
* @param fontWeight The font weight to use.
|
||||
* @param fontFamily The font family to use.
|
||||
* @returns Width of element.
|
||||
* @alias Blockly.utils.dom.getFastTextWidthWithSizeString
|
||||
*/
|
||||
export function getFastTextWidthWithSizeString(
|
||||
textElement: SVGTextElement, fontSize: string, fontWeight: string,
|
||||
@@ -351,7 +327,6 @@ export function getFastTextWidthWithSizeString(
|
||||
* @param fontWeight The font weight to use.
|
||||
* @param fontFamily The font family to use.
|
||||
* @returns Font measurements.
|
||||
* @alias Blockly.utils.dom.measureFontMetrics
|
||||
*/
|
||||
export function measureFontMetrics(
|
||||
text: string, fontSize: string, fontWeight: string,
|
||||
|
||||
@@ -59,7 +59,6 @@ let nextId = 0;
|
||||
* primarily be used for IDs that end up in the DOM.
|
||||
*
|
||||
* @returns The next unique identifier.
|
||||
* @alias Blockly.utils.idGenerator.getNextUniqueId
|
||||
*/
|
||||
export function getNextUniqueId(): string {
|
||||
return 'blockly-' + (nextId++).toString(36);
|
||||
@@ -70,7 +69,6 @@ export function getNextUniqueId(): string {
|
||||
*
|
||||
* @see internal.genUid
|
||||
* @returns A globally unique ID string.
|
||||
* @alias Blockly.utils.idGenerator.genUid
|
||||
*/
|
||||
export function genUid(): string {
|
||||
return internal.genUid();
|
||||
|
||||
@@ -22,8 +22,6 @@ goog.declareModuleId('Blockly.utils.KeyCodes');
|
||||
*
|
||||
* This list is not localized and therefore some of the key codes are not
|
||||
* correct for non US keyboard layouts. See comments below.
|
||||
*
|
||||
* @alias Blockly.utils.KeyCodes
|
||||
*/
|
||||
export enum KeyCodes {
|
||||
WIN_KEY_FF_LINUX = 0,
|
||||
|
||||
@@ -21,7 +21,6 @@ goog.declareModuleId('Blockly.utils.math');
|
||||
*
|
||||
* @param angleDegrees Angle in degrees.
|
||||
* @returns Angle in radians.
|
||||
* @alias Blockly.utils.math.toRadians
|
||||
*/
|
||||
export function toRadians(angleDegrees: number): number {
|
||||
return angleDegrees * Math.PI / 180;
|
||||
@@ -33,7 +32,6 @@ export function toRadians(angleDegrees: number): number {
|
||||
*
|
||||
* @param angleRadians Angle in radians.
|
||||
* @returns Angle in degrees.
|
||||
* @alias Blockly.utils.math.toDegrees
|
||||
*/
|
||||
export function toDegrees(angleRadians: number): number {
|
||||
return angleRadians * 180 / Math.PI;
|
||||
@@ -46,7 +44,6 @@ export function toDegrees(angleRadians: number): number {
|
||||
* @param number The number to clamp.
|
||||
* @param upperBound The desired upper bound.
|
||||
* @returns The clamped number.
|
||||
* @alias Blockly.utils.math.clamp
|
||||
*/
|
||||
export function clamp(
|
||||
lowerBound: number, number: number, upperBound: number): number {
|
||||
|
||||
@@ -13,7 +13,6 @@ import * as goog from '../../closure/goog/goog.js';
|
||||
goog.declareModuleId('Blockly.utils.Metrics');
|
||||
|
||||
|
||||
/** @alias Blockly.utils.Metrics */
|
||||
export interface Metrics {
|
||||
/** Height of the visible portion of the workspace. */
|
||||
viewHeight: number;
|
||||
|
||||
@@ -22,7 +22,6 @@ import * as deprecation from './deprecation.js';
|
||||
* @param parentCtor Parent class.
|
||||
* @suppress {strictMissingProperties} superClass_ is not defined on Function.
|
||||
* @deprecated No longer provided by Blockly.
|
||||
* @alias Blockly.utils.object.inherits
|
||||
*/
|
||||
export function inherits(childCtor: Function, parentCtor: Function) {
|
||||
deprecation.warn('Blockly.utils.object.inherits', 'version 9', 'version 10');
|
||||
@@ -50,7 +49,6 @@ export function inherits(childCtor: Function, parentCtor: Function) {
|
||||
* @param target Target.
|
||||
* @param source Source.
|
||||
* @deprecated Use the built-in **Object.assign** instead.
|
||||
* @alias Blockly.utils.object.mixin
|
||||
*/
|
||||
export function mixin(target: AnyDuringMigration, source: AnyDuringMigration) {
|
||||
deprecation.warn(
|
||||
@@ -66,7 +64,6 @@ export function mixin(target: AnyDuringMigration, source: AnyDuringMigration) {
|
||||
* @param target Target.
|
||||
* @param source Source.
|
||||
* @returns The resulting object.
|
||||
* @alias Blockly.utils.object.deepMerge
|
||||
*/
|
||||
export function deepMerge(
|
||||
target: AnyDuringMigration,
|
||||
@@ -87,7 +84,6 @@ export function deepMerge(
|
||||
* @param obj Object containing values.
|
||||
* @returns Array of values.
|
||||
* @deprecated Use the built-in **Object.values** instead.
|
||||
* @alias Blockly.utils.object.values
|
||||
*/
|
||||
export function values(obj: AnyDuringMigration): AnyDuringMigration[] {
|
||||
deprecation.warn(
|
||||
|
||||
@@ -166,7 +166,6 @@ function tokenizeInterpolationInternal(
|
||||
* @param message Text which might contain string table references and
|
||||
* interpolation tokens.
|
||||
* @returns Array of strings and numbers.
|
||||
* @alias Blockly.utils.parsing.tokenizeInterpolation
|
||||
*/
|
||||
export function tokenizeInterpolation(message: string): (string|number)[] {
|
||||
return tokenizeInterpolationInternal(message, true);
|
||||
@@ -180,7 +179,6 @@ export function tokenizeInterpolation(message: string): (string|number)[] {
|
||||
* @param message Message, which may be a string that contains
|
||||
* string table references.
|
||||
* @returns String with message references replaced.
|
||||
* @alias Blockly.utils.parsing.replaceMessageReferences
|
||||
*/
|
||||
export function replaceMessageReferences(message: string|any): string {
|
||||
if (typeof message !== 'string') {
|
||||
@@ -199,7 +197,6 @@ export function replaceMessageReferences(message: string|any): string {
|
||||
* @param message Text which might contain string table references.
|
||||
* @returns True if all message references have matching values.
|
||||
* Otherwise, false.
|
||||
* @alias Blockly.utils.parsing.checkMessageReferences
|
||||
*/
|
||||
export function checkMessageReferences(message: string): boolean {
|
||||
let validSoFar = true;
|
||||
@@ -230,7 +227,6 @@ export function checkMessageReferences(message: string): boolean {
|
||||
* @returns An object containing the colour as
|
||||
* a #RRGGBB string, and the hue if the input was an HSV hue value.
|
||||
* @throws {Error} If the colour cannot be parsed.
|
||||
* @alias Blockly.utils.parsing.parseBlockColour
|
||||
*/
|
||||
export function parseBlockColour(colour: number|
|
||||
string): {hue: number|null, hex: string} {
|
||||
|
||||
@@ -17,8 +17,6 @@ goog.declareModuleId('Blockly.utils.Rect');
|
||||
|
||||
/**
|
||||
* Class for representing rectangular regions.
|
||||
*
|
||||
* @alias Blockly.utils.Rect
|
||||
*/
|
||||
export class Rect {
|
||||
/**
|
||||
|
||||
@@ -15,8 +15,6 @@ goog.declareModuleId('Blockly.utils.Sentinel');
|
||||
|
||||
/**
|
||||
* A type used to create flag values.
|
||||
*
|
||||
* @alias Blockly.utils.Sentinel
|
||||
*/
|
||||
export class Sentinel {
|
||||
/**
|
||||
|
||||
@@ -17,8 +17,6 @@ goog.declareModuleId('Blockly.utils.Size');
|
||||
|
||||
/**
|
||||
* Class for representing sizes consisting of a width and height.
|
||||
*
|
||||
* @alias Blockly.utils.Size
|
||||
*/
|
||||
export class Size {
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,6 @@ import * as deprecation from './deprecation.js';
|
||||
* @param str The string to check.
|
||||
* @param prefix A string to look for at the start of `str`.
|
||||
* @returns True if `str` begins with `prefix`.
|
||||
* @alias Blockly.utils.string.startsWith
|
||||
* @deprecated Use built-in **string.startsWith** instead.
|
||||
*/
|
||||
export function startsWith(str: string, prefix: string): boolean {
|
||||
@@ -39,7 +38,6 @@ export function startsWith(str: string, prefix: string): boolean {
|
||||
*
|
||||
* @param array Array of strings.
|
||||
* @returns Length of shortest string.
|
||||
* @alias Blockly.utils.string.shortestStringLength
|
||||
*/
|
||||
export function shortestStringLength(array: string[]): number {
|
||||
if (!array.length) {
|
||||
@@ -59,7 +57,6 @@ export function shortestStringLength(array: string[]): number {
|
||||
* @param array Array of strings.
|
||||
* @param opt_shortest Length of shortest string.
|
||||
* @returns Length of common prefix.
|
||||
* @alias Blockly.utils.string.commonWordPrefix
|
||||
*/
|
||||
export function commonWordPrefix(
|
||||
array: string[], opt_shortest?: number): number {
|
||||
@@ -98,7 +95,6 @@ export function commonWordPrefix(
|
||||
* @param array Array of strings.
|
||||
* @param opt_shortest Length of shortest string.
|
||||
* @returns Length of common suffix.
|
||||
* @alias Blockly.utils.string.commonWordSuffix
|
||||
*/
|
||||
export function commonWordSuffix(
|
||||
array: string[], opt_shortest?: number): number {
|
||||
@@ -136,7 +132,6 @@ export function commonWordSuffix(
|
||||
* @param text Text to wrap.
|
||||
* @param limit Width to wrap each line.
|
||||
* @returns Wrapped text.
|
||||
* @alias Blockly.utils.string.wrap
|
||||
*/
|
||||
export function wrap(text: string, limit: number): string {
|
||||
const lines = text.split('\n');
|
||||
@@ -306,7 +301,6 @@ function wrapToText(words: string[], wordBreaks: boolean[]): string {
|
||||
*
|
||||
* @param str Input string.
|
||||
* @returns True if number, false otherwise.
|
||||
* @alias Blockly.utils.string.isNumber
|
||||
*/
|
||||
export function isNumber(str: string): boolean {
|
||||
return /^\s*-?\d+(\.\d+)?\s*$/.test(str);
|
||||
|
||||
@@ -26,7 +26,6 @@ import {Size} from './size.js';
|
||||
*
|
||||
* @param element Element to get size of.
|
||||
* @returns Object with width/height properties.
|
||||
* @alias Blockly.utils.style.getSize
|
||||
*/
|
||||
export function getSize(element: Element): Size {
|
||||
return TEST_ONLY.getSizeInternal(element);
|
||||
@@ -84,7 +83,6 @@ function getSizeWithDisplay(element: Element): Size {
|
||||
* @param element Element to get style of.
|
||||
* @param property Property to get (camel-case).
|
||||
* @returns Style value.
|
||||
* @alias Blockly.utils.style.getComputedStyle
|
||||
*/
|
||||
export function getComputedStyle(element: Element, property: string): string {
|
||||
const styles = window.getComputedStyle(element);
|
||||
@@ -104,7 +102,6 @@ export function getComputedStyle(element: Element, property: string): string {
|
||||
* @param style Property to get (camel-case).
|
||||
* @returns Style value.
|
||||
* @deprecated No longer provided by Blockly.
|
||||
* @alias Blockly.utils.style.getCascadedStyle
|
||||
*/
|
||||
export function getCascadedStyle(element: Element, style: string): string {
|
||||
deprecation.warn(
|
||||
@@ -123,7 +120,6 @@ export function getCascadedStyle(element: Element, style: string): string {
|
||||
*
|
||||
* @param el Element to get the page offset for.
|
||||
* @returns The page offset.
|
||||
* @alias Blockly.utils.style.getPageOffset
|
||||
*/
|
||||
export function getPageOffset(el: Element): Coordinate {
|
||||
const pos = new Coordinate(0, 0);
|
||||
@@ -146,7 +142,6 @@ export function getPageOffset(el: Element): Coordinate {
|
||||
* Similar to Closure's goog.style.getViewportPageOffset
|
||||
*
|
||||
* @returns The page offset of the viewport.
|
||||
* @alias Blockly.utils.style.getViewportPageOffset
|
||||
*/
|
||||
export function getViewportPageOffset(): Coordinate {
|
||||
const body = document.body;
|
||||
@@ -162,7 +157,6 @@ export function getViewportPageOffset(): Coordinate {
|
||||
*
|
||||
* @param element The element to get the border widths for.
|
||||
* @returns The computed border widths.
|
||||
* @alias Blockly.utils.style.getBorderBox
|
||||
*/
|
||||
export function getBorderBox(element: Element): Rect {
|
||||
const left = parseFloat(getComputedStyle(element, 'borderLeftWidth'));
|
||||
@@ -185,7 +179,6 @@ export function getBorderBox(element: Element): Rect {
|
||||
* scroll element will be used.
|
||||
* @param opt_center Whether to center the element in the container.
|
||||
* Defaults to false.
|
||||
* @alias Blockly.utils.style.scrollIntoContainerView
|
||||
*/
|
||||
export function scrollIntoContainerView(
|
||||
element: Element, container: Element, opt_center?: boolean) {
|
||||
@@ -207,7 +200,6 @@ export function scrollIntoContainerView(
|
||||
* @param opt_center Whether to center the element in the container.
|
||||
* Defaults to false.
|
||||
* @returns The new scroll position of the container.
|
||||
* @alias Blockly.utils.style.getContainerOffsetToScrollInto
|
||||
*/
|
||||
export function getContainerOffsetToScrollInto(
|
||||
element: Element, container: Element, opt_center?: boolean): Coordinate {
|
||||
|
||||
@@ -16,8 +16,6 @@ goog.declareModuleId('Blockly.utils.Svg');
|
||||
|
||||
/**
|
||||
* A name with the type of the SVG element stored in the generic.
|
||||
*
|
||||
* @alias Blockly.utils.Svg
|
||||
*/
|
||||
export class Svg<_T> {
|
||||
/** @internal */
|
||||
|
||||
@@ -43,7 +43,6 @@ const XY_STYLE_REGEX =
|
||||
*
|
||||
* @param element SVG element to find the coordinates of.
|
||||
* @returns Object with .x and .y properties.
|
||||
* @alias Blockly.utils.svgMath.getRelativeXY
|
||||
*/
|
||||
export function getRelativeXY(element: Element): Coordinate {
|
||||
const xy = new Coordinate(0, 0);
|
||||
@@ -90,7 +89,6 @@ export function getRelativeXY(element: Element): Coordinate {
|
||||
* @param element SVG element to find the coordinates of. If this is not a child
|
||||
* of the div Blockly was injected into, the behaviour is undefined.
|
||||
* @returns Object with .x and .y properties.
|
||||
* @alias Blockly.utils.svgMath.getInjectionDivXY
|
||||
*/
|
||||
export function getInjectionDivXY(element: Element): Coordinate {
|
||||
let x = 0;
|
||||
@@ -114,7 +112,6 @@ export function getInjectionDivXY(element: Element): Coordinate {
|
||||
*
|
||||
* @returns True if 3D transforms are supported.
|
||||
* @deprecated No longer provided by Blockly.
|
||||
* @alias Blockly.utils.svgMath.is3dSupported
|
||||
*/
|
||||
export function is3dSupported(): boolean {
|
||||
// All browsers support translate3d in 2022.
|
||||
@@ -129,7 +126,6 @@ export function is3dSupported(): boolean {
|
||||
*
|
||||
* @returns An object containing window width, height, and scroll position in
|
||||
* window coordinates.
|
||||
* @alias Blockly.utils.svgMath.getViewportBBox
|
||||
* @internal
|
||||
*/
|
||||
export function getViewportBBox(): Rect {
|
||||
@@ -145,7 +141,6 @@ export function getViewportBBox(): Rect {
|
||||
* Copied from Closure's goog.dom.getDocumentScroll.
|
||||
*
|
||||
* @returns Object with values 'x' and 'y'.
|
||||
* @alias Blockly.utils.svgMath.getDocumentScroll
|
||||
*/
|
||||
export function getDocumentScroll(): Coordinate {
|
||||
const el = document.documentElement;
|
||||
@@ -161,7 +156,6 @@ export function getDocumentScroll(): Coordinate {
|
||||
* @param screenCoordinates The screen coordinates to be converted to workspace
|
||||
* coordinates
|
||||
* @returns The workspace coordinates.
|
||||
* @alias Blockly.utils.svgMath.screenToWsCoordinates
|
||||
*/
|
||||
export function screenToWsCoordinates(
|
||||
ws: WorkspaceSvg, screenCoordinates: Coordinate): Coordinate {
|
||||
|
||||
@@ -22,7 +22,6 @@ goog.declareModuleId('Blockly.utils.svgPaths');
|
||||
* @param x The x coordinate.
|
||||
* @param y The y coordinate.
|
||||
* @returns A string of the format ' x,y '
|
||||
* @alias Blockly.utils.svgPaths.point
|
||||
*/
|
||||
export function point(x: number, y: number): string {
|
||||
return ' ' + x + ',' + y + ' ';
|
||||
@@ -40,7 +39,6 @@ export function point(x: number, y: number): string {
|
||||
* x, y '.
|
||||
* @returns A string defining one or more Bezier curves. See the MDN
|
||||
* documentation for exact format.
|
||||
* @alias Blockly.utils.svgPaths.curve
|
||||
*/
|
||||
export function curve(command: string, points: string[]): string {
|
||||
return ' ' + command + points.join('');
|
||||
@@ -55,7 +53,6 @@ export function curve(command: string, points: string[]): string {
|
||||
* @param x The absolute x coordinate.
|
||||
* @param y The absolute y coordinate.
|
||||
* @returns A string of the format ' M x,y '
|
||||
* @alias Blockly.utils.svgPaths.moveTo
|
||||
*/
|
||||
export function moveTo(x: number, y: number): string {
|
||||
return ' M ' + x + ',' + y + ' ';
|
||||
@@ -70,7 +67,6 @@ export function moveTo(x: number, y: number): string {
|
||||
* @param dx The relative x coordinate.
|
||||
* @param dy The relative y coordinate.
|
||||
* @returns A string of the format ' m dx,dy '
|
||||
* @alias Blockly.utils.svgPaths.moveBy
|
||||
*/
|
||||
export function moveBy(dx: number, dy: number): string {
|
||||
return ' m ' + dx + ',' + dy + ' ';
|
||||
@@ -85,7 +81,6 @@ export function moveBy(dx: number, dy: number): string {
|
||||
* @param dx The relative x coordinate.
|
||||
* @param dy The relative y coordinate.
|
||||
* @returns A string of the format ' l dx,dy '
|
||||
* @alias Blockly.utils.svgPaths.lineTo
|
||||
*/
|
||||
export function lineTo(dx: number, dy: number): string {
|
||||
return ' l ' + dx + ',' + dy + ' ';
|
||||
@@ -100,7 +95,6 @@ export function lineTo(dx: number, dy: number): string {
|
||||
* @param points An array containing all of the points to draw lines to, in
|
||||
* order. The points are represented as strings of the format ' dx,dy '.
|
||||
* @returns A string of the format ' l (dx,dy)+ '
|
||||
* @alias Blockly.utils.svgPaths.line
|
||||
*/
|
||||
export function line(points: string[]): string {
|
||||
return ' l' + points.join('');
|
||||
@@ -118,7 +112,6 @@ export function line(points: string[]): string {
|
||||
* @param val The coordinate to pass to the command. It may be absolute or
|
||||
* relative.
|
||||
* @returns A string of the format ' command val '
|
||||
* @alias Blockly.utils.svgPaths.lineOnAxis
|
||||
*/
|
||||
export function lineOnAxis(command: string, val: number): string {
|
||||
return ' ' + command + ' ' + val + ' ';
|
||||
@@ -136,7 +129,6 @@ export function lineOnAxis(command: string, val: number): string {
|
||||
* @param point The point to move the cursor to after drawing the arc, specified
|
||||
* either in absolute or relative coordinates depending on the command.
|
||||
* @returns A string of the format 'command radius radius flags point'
|
||||
* @alias Blockly.utils.svgPaths.arc
|
||||
*/
|
||||
export function arc(
|
||||
command: string, flags: string, radius: number, point: string): string {
|
||||
|
||||
@@ -21,8 +21,6 @@ import * as Xml from '../xml.js';
|
||||
/**
|
||||
* The information needed to create a block in the toolbox.
|
||||
* Note that disabled has a different type for backwards compatibility.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.BlockInfo
|
||||
*/
|
||||
export interface BlockInfo {
|
||||
kind: string;
|
||||
@@ -46,8 +44,6 @@ export interface BlockInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create a separator in the toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.SeparatorInfo
|
||||
*/
|
||||
export interface SeparatorInfo {
|
||||
kind: string;
|
||||
@@ -58,8 +54,6 @@ export interface SeparatorInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create a button in the toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.ButtonInfo
|
||||
*/
|
||||
export interface ButtonInfo {
|
||||
kind: string;
|
||||
@@ -69,8 +63,6 @@ export interface ButtonInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create a label in the toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.LabelInfo
|
||||
*/
|
||||
export interface LabelInfo {
|
||||
kind: string;
|
||||
@@ -80,15 +72,11 @@ export interface LabelInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create either a button or a label in the flyout.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.ButtonOrLabelInfo
|
||||
*/
|
||||
export type ButtonOrLabelInfo = ButtonInfo|LabelInfo;
|
||||
|
||||
/**
|
||||
* The information needed to create a category in the toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.StaticCategoryInfo
|
||||
*/
|
||||
export interface StaticCategoryInfo {
|
||||
kind: string;
|
||||
@@ -104,8 +92,6 @@ export interface StaticCategoryInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create a custom category.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.DynamicCategoryInfo
|
||||
*/
|
||||
export interface DynamicCategoryInfo {
|
||||
kind: string;
|
||||
@@ -120,30 +106,22 @@ export interface DynamicCategoryInfo {
|
||||
|
||||
/**
|
||||
* The information needed to create either a dynamic or static category.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.CategoryInfo
|
||||
*/
|
||||
export type CategoryInfo = StaticCategoryInfo|DynamicCategoryInfo;
|
||||
|
||||
/**
|
||||
* Any information that can be used to create an item in the toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.ToolboxItemInfo
|
||||
*/
|
||||
export type ToolboxItemInfo = FlyoutItemInfo|StaticCategoryInfo;
|
||||
|
||||
/**
|
||||
* All the different types that can be displayed in a flyout.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.FlyoutItemInfo
|
||||
*/
|
||||
export type FlyoutItemInfo =
|
||||
BlockInfo|SeparatorInfo|ButtonInfo|LabelInfo|DynamicCategoryInfo;
|
||||
|
||||
/**
|
||||
* The JSON definition of a toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.ToolboxInfo
|
||||
*/
|
||||
export interface ToolboxInfo {
|
||||
kind?: string;
|
||||
@@ -152,22 +130,16 @@ export interface ToolboxInfo {
|
||||
|
||||
/**
|
||||
* An array holding flyout items.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.FlyoutItemInfoArray
|
||||
*/
|
||||
export type FlyoutItemInfoArray = FlyoutItemInfo[];
|
||||
|
||||
/**
|
||||
* All of the different types that can create a toolbox.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.ToolboxDefinition
|
||||
*/
|
||||
export type ToolboxDefinition = Node|ToolboxInfo|string;
|
||||
|
||||
/**
|
||||
* All of the different types that can be used to show items in a flyout.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.FlyoutDefinition
|
||||
*/
|
||||
export type FlyoutDefinition = FlyoutItemInfoArray|NodeList|ToolboxInfo|Node[];
|
||||
|
||||
@@ -187,8 +159,6 @@ const FLYOUT_TOOLBOX_KIND = 'flyoutToolbox';
|
||||
|
||||
/**
|
||||
* Position of the toolbox and/or flyout relative to the workspace.
|
||||
*
|
||||
* @alias Blockly.utils.toolbox.Position
|
||||
*/
|
||||
export enum Position {
|
||||
TOP,
|
||||
@@ -202,7 +172,6 @@ export enum Position {
|
||||
*
|
||||
* @param toolboxDef The definition of the toolbox in one of its many forms.
|
||||
* @returns Object holding information for creating a toolbox.
|
||||
* @alias Blockly.utils.toolbox.convertToolboxDefToJson
|
||||
* @internal
|
||||
*/
|
||||
export function convertToolboxDefToJson(toolboxDef: ToolboxDefinition|
|
||||
@@ -252,7 +221,6 @@ function validateToolbox(toolboxJson: ToolboxInfo) {
|
||||
*
|
||||
* @param flyoutDef The definition of the flyout in one of its many forms.
|
||||
* @returns A list of flyout items.
|
||||
* @alias Blockly.utils.toolbox.convertFlyoutDefToJsonArray
|
||||
* @internal
|
||||
*/
|
||||
export function convertFlyoutDefToJsonArray(flyoutDef: FlyoutDefinition|
|
||||
@@ -284,7 +252,6 @@ export function convertFlyoutDefToJsonArray(flyoutDef: FlyoutDefinition|
|
||||
*
|
||||
* @param toolboxJson Object holding information for creating a toolbox.
|
||||
* @returns True if the toolbox has categories.
|
||||
* @alias Blockly.utils.toolbox.hasCategories
|
||||
* @internal
|
||||
*/
|
||||
export function hasCategories(toolboxJson: ToolboxInfo|null): boolean {
|
||||
@@ -315,7 +282,6 @@ function hasCategoriesInternal(toolboxJson: ToolboxInfo|null): boolean {
|
||||
*
|
||||
* @param categoryInfo Object holing information for creating a category.
|
||||
* @returns True if the category has subcategories.
|
||||
* @alias Blockly.utils.toolbox.isCategoryCollapsible
|
||||
* @internal
|
||||
*/
|
||||
export function isCategoryCollapsible(categoryInfo: CategoryInfo): boolean {
|
||||
@@ -415,7 +381,6 @@ function addAttributes(node: Node, obj: AnyDuringMigration) {
|
||||
*
|
||||
* @param toolboxDef DOM tree of blocks, or text representation of same.
|
||||
* @returns DOM tree of blocks, or null.
|
||||
* @alias Blockly.utils.toolbox.parseToolboxTree
|
||||
*/
|
||||
export function parseToolboxTree(toolboxDef: Element|null|string): Element|
|
||||
null {
|
||||
|
||||
@@ -78,26 +78,18 @@ isTablet = isIPad || isAndroid && !has('Mobile') || has('Silk');
|
||||
isMobile = !isTablet && (isIPhone || isAndroid);
|
||||
})(globalThis['navigator'] && globalThis['navigator']['userAgent'] || '');
|
||||
|
||||
/** @alias Blockly.utils.userAgent.raw */
|
||||
export const raw: string = rawUserAgent;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.JavaFx */
|
||||
export const JavaFx: boolean = isJavaFx;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.GECKO */
|
||||
export const GECKO: boolean = isGecko;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.ANDROID */
|
||||
export const ANDROID: boolean = isAndroid;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.IPAD */
|
||||
export const IPAD: boolean = isIPad;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.IPHONE */
|
||||
export const IPHONE: boolean = isIPhone;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.MAC */
|
||||
export const MAC: boolean = isMac;
|
||||
|
||||
/** @alias Blockly.utils.userAgent.MOBILE */
|
||||
export const MOBILE: boolean = isMobile;
|
||||
|
||||
@@ -61,8 +61,6 @@ export function injectDependencies(dependencies: {
|
||||
|
||||
/**
|
||||
* Namespace for Blockly's XML.
|
||||
*
|
||||
* @alias Blockly.utils.xml.NAME_SPACE
|
||||
*/
|
||||
export const NAME_SPACE = 'https://developers.google.com/blockly/xml';
|
||||
|
||||
@@ -71,7 +69,6 @@ export const NAME_SPACE = 'https://developers.google.com/blockly/xml';
|
||||
*
|
||||
* @returns The document object.
|
||||
* @deprecated No longer provided by Blockly.
|
||||
* @alias Blockly.utils.xml.getDocument
|
||||
*/
|
||||
export function getDocument(): Document {
|
||||
deprecation.warn('Blockly.utils.xml.getDocument', 'version 9', 'version 10');
|
||||
@@ -83,7 +80,6 @@ export function getDocument(): Document {
|
||||
*
|
||||
* @param xmlDocument The document object to use.
|
||||
* @deprecated No longer provided by Blockly.
|
||||
* @alias Blockly.utils.xml.setDocument
|
||||
*/
|
||||
export function setDocument(xmlDocument: Document) {
|
||||
deprecation.warn('Blockly.utils.xml.setDocument', 'version 9', 'version 10');
|
||||
@@ -95,7 +91,6 @@ export function setDocument(xmlDocument: Document) {
|
||||
*
|
||||
* @param tagName Name of DOM element.
|
||||
* @returns New DOM element.
|
||||
* @alias Blockly.utils.xml.createElement
|
||||
*/
|
||||
export function createElement(tagName: string): Element {
|
||||
return document.createElementNS(NAME_SPACE, tagName);
|
||||
@@ -106,7 +101,6 @@ export function createElement(tagName: string): Element {
|
||||
*
|
||||
* @param text Text content.
|
||||
* @returns New DOM text node.
|
||||
* @alias Blockly.utils.xml.createTextNode
|
||||
*/
|
||||
export function createTextNode(text: string): Text {
|
||||
return document.createTextNode(text);
|
||||
@@ -118,7 +112,6 @@ export function createTextNode(text: string): Text {
|
||||
* @param text XML string.
|
||||
* @returns The DOM document.
|
||||
* @throws if XML doesn't parse.
|
||||
* @alias Blockly.utils.xml.textToDomDocument
|
||||
*/
|
||||
export function textToDomDocument(text: string): Document {
|
||||
const oParser = new DOMParser();
|
||||
@@ -131,7 +124,6 @@ export function textToDomDocument(text: string): Document {
|
||||
*
|
||||
* @param dom A tree of XML nodes.
|
||||
* @returns Text representation.
|
||||
* @alias Blockly.utils.xml.domToText
|
||||
*/
|
||||
export function domToText(dom: Node): string {
|
||||
const oSerializer = new XMLSerializer();
|
||||
|
||||
Reference in New Issue
Block a user