mirror of
https://github.com/google/blockly.git
synced 2026-01-07 09:00:11 +01:00
chore: use prettier instead of clang-format (#7014)
* chore: add and configure prettier * chore: remove clang-format * chore: remove clang-format config * chore: lint additional ts files * chore: fix lint errors in blocks * chore: add prettier-ignore where needed * chore: ignore js blocks when formatting * chore: fix playground html syntax * chore: fix yaml spacing from merge * chore: convert text blocks to use arrow functions * chore: format everything with prettier * chore: fix lint unused imports in blocks
This commit is contained in:
committed by
GitHub
parent
af991f5e1b
commit
88ff901a72
@@ -11,7 +11,6 @@ import * as Touch from './touch.js';
|
||||
import * as deprecation from './utils/deprecation.js';
|
||||
import * as userAgent from './utils/useragent.js';
|
||||
|
||||
|
||||
/**
|
||||
* Blockly opaque event data used to unbind events when using
|
||||
* `bind` and `conditionalBind`.
|
||||
@@ -49,12 +48,19 @@ const PAGE_MODE_MULTIPLIER = 125;
|
||||
* @returns Opaque data that can be passed to unbindEvent_.
|
||||
*/
|
||||
export function conditionalBind(
|
||||
node: EventTarget, name: string, thisObject: Object|null, func: Function,
|
||||
opt_noCaptureIdentifier?: boolean, opt_noPreventDefault?: boolean): Data {
|
||||
node: EventTarget,
|
||||
name: string,
|
||||
thisObject: Object | null,
|
||||
func: Function,
|
||||
opt_noCaptureIdentifier?: boolean,
|
||||
opt_noPreventDefault?: boolean
|
||||
): Data {
|
||||
if (opt_noPreventDefault !== undefined) {
|
||||
deprecation.warn(
|
||||
'The opt_noPreventDefault argument of conditionalBind', 'version 9',
|
||||
'version 10');
|
||||
'The opt_noPreventDefault argument of conditionalBind',
|
||||
'version 9',
|
||||
'version 10'
|
||||
);
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -99,8 +105,11 @@ export function conditionalBind(
|
||||
* @returns Opaque data that can be passed to unbindEvent_.
|
||||
*/
|
||||
export function bind(
|
||||
node: EventTarget, name: string, thisObject: Object|null,
|
||||
func: Function): Data {
|
||||
node: EventTarget,
|
||||
name: string,
|
||||
thisObject: Object | null,
|
||||
func: Function
|
||||
): Data {
|
||||
/**
|
||||
*
|
||||
* @param e
|
||||
@@ -154,17 +163,24 @@ export function unbind(bindData: Data): (e: Event) => void {
|
||||
*/
|
||||
export function isTargetInput(e: Event): boolean {
|
||||
if (e.target instanceof HTMLElement) {
|
||||
if (e.target.isContentEditable ||
|
||||
e.target.getAttribute('data-is-text-input') === 'true') {
|
||||
if (
|
||||
e.target.isContentEditable ||
|
||||
e.target.getAttribute('data-is-text-input') === 'true'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.target instanceof HTMLInputElement) {
|
||||
const target = e.target;
|
||||
return target.type === 'text' || target.type === 'number' ||
|
||||
target.type === 'email' || target.type === 'password' ||
|
||||
target.type === 'search' || target.type === 'tel' ||
|
||||
target.type === 'url';
|
||||
return (
|
||||
target.type === 'text' ||
|
||||
target.type === 'number' ||
|
||||
target.type === 'email' ||
|
||||
target.type === 'password' ||
|
||||
target.type === 'search' ||
|
||||
target.type === 'tel' ||
|
||||
target.type === 'url'
|
||||
);
|
||||
}
|
||||
|
||||
if (e.target instanceof HTMLTextAreaElement) {
|
||||
@@ -200,7 +216,10 @@ export function isRightButton(e: MouseEvent): boolean {
|
||||
* @returns Object with .x and .y properties.
|
||||
*/
|
||||
export function mouseToSvg(
|
||||
e: MouseEvent, svg: SVGSVGElement, matrix: SVGMatrix|null): SVGPoint {
|
||||
e: MouseEvent,
|
||||
svg: SVGSVGElement,
|
||||
matrix: SVGMatrix | null
|
||||
): SVGPoint {
|
||||
const svgPoint = svg.createSVGPoint();
|
||||
svgPoint.x = e.clientX;
|
||||
svgPoint.y = e.clientY;
|
||||
@@ -217,17 +236,17 @@ export function mouseToSvg(
|
||||
* @param e Mouse event.
|
||||
* @returns Scroll delta object with .x and .y properties.
|
||||
*/
|
||||
export function getScrollDeltaPixels(e: WheelEvent): {x: number, y: number} {
|
||||
export function getScrollDeltaPixels(e: WheelEvent): {x: number; y: number} {
|
||||
switch (e.deltaMode) {
|
||||
case 0x00: // Pixel mode.
|
||||
case 0x00: // Pixel mode.
|
||||
default:
|
||||
return {x: e.deltaX, y: e.deltaY};
|
||||
case 0x01: // Line mode.
|
||||
case 0x01: // Line mode.
|
||||
return {
|
||||
x: e.deltaX * LINE_MODE_MULTIPLIER,
|
||||
y: e.deltaY * LINE_MODE_MULTIPLIER,
|
||||
};
|
||||
case 0x02: // Page mode.
|
||||
case 0x02: // Page mode.
|
||||
return {
|
||||
x: e.deltaX * PAGE_MODE_MULTIPLIER,
|
||||
y: e.deltaY * PAGE_MODE_MULTIPLIER,
|
||||
|
||||
Reference in New Issue
Block a user