blockly 12.5.1 → 13.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockly.min.js +1541 -700
- package/blockly.mjs +13 -5
- package/blockly_compressed.js +1449 -674
- package/blockly_compressed.js.map +1 -1
- package/blocks_compressed.js +16 -16
- package/blocks_compressed.js.map +1 -1
- package/core/block.d.ts +1 -1
- package/core/block_aria_composer.d.ts +119 -0
- package/core/block_svg.d.ts +59 -16
- package/core/blockly.d.ts +21 -16
- package/core/bubbles/bubble.d.ts +17 -2
- package/core/bubbles/mini_workspace_bubble.d.ts +9 -1
- package/core/bubbles/text_bubble.d.ts +4 -1
- package/core/bubbles/textinput_bubble.d.ts +5 -0
- package/core/comments/comment_editor.d.ts +2 -2
- package/core/comments/rendered_workspace_comment.d.ts +6 -1
- package/core/common.d.ts +1 -1
- package/core/css.d.ts +2 -1
- package/core/dragging/block_drag_strategy.d.ts +126 -14
- package/core/dragging/bubble_drag_strategy.d.ts +5 -4
- package/core/dragging/comment_drag_strategy.d.ts +4 -4
- package/core/dragging/dragger.d.ts +13 -14
- package/core/events/events_block_create.d.ts +0 -3
- package/core/events/events_block_delete.d.ts +0 -3
- package/core/events/events_comment_create.d.ts +0 -3
- package/core/events/events_comment_delete.d.ts +0 -3
- package/core/field.d.ts +69 -2
- package/core/field_input.d.ts +23 -0
- package/core/flyout_base.d.ts +1 -125
- package/core/flyout_button.d.ts +9 -0
- package/core/flyout_horizontal.d.ts +0 -11
- package/core/flyout_vertical.d.ts +0 -11
- package/core/focus_manager.d.ts +47 -2
- package/core/gesture.d.ts +0 -12
- package/core/hints.d.ts +44 -0
- package/core/icons/icon.d.ts +6 -0
- package/core/inputs/input.d.ts +22 -1
- package/core/interfaces/i_bounded_element.d.ts +7 -0
- package/core/interfaces/i_bubble.d.ts +3 -2
- package/core/interfaces/i_collapsible_toolbox_item.d.ts +5 -1
- package/core/interfaces/i_draggable.d.ts +22 -17
- package/core/interfaces/i_dragger.d.ts +19 -10
- package/core/interfaces/i_flyout.d.ts +1 -31
- package/core/interfaces/i_focusable_node.d.ts +8 -0
- package/core/interfaces/i_focusable_tree.d.ts +8 -0
- package/core/interfaces/i_json_block_definition.d.ts +102 -0
- package/core/interfaces/i_navigation_policy.d.ts +12 -0
- package/core/interfaces/i_selectable.d.ts +2 -2
- package/core/interfaces/i_selectable_toolbox_item.d.ts +3 -3
- package/core/interfaces/i_toolbox.d.ts +4 -0
- package/core/interfaces/i_toolbox_item.d.ts +6 -0
- package/core/keyboard_nav/keyboard_mover.d.ts +149 -0
- package/core/keyboard_nav/move_indicator.d.ts +35 -0
- package/core/keyboard_nav/{block_navigation_policy.d.ts → navigation_policies/block_navigation_policy.d.ts} +17 -25
- package/core/keyboard_nav/navigation_policies/bubble_navigation_policy.d.ts +63 -0
- package/core/keyboard_nav/{comment_bar_button_navigation_policy.d.ts → navigation_policies/comment_bar_button_navigation_policy.d.ts} +10 -3
- package/core/keyboard_nav/{comment_editor_navigation_policy.d.ts → navigation_policies/comment_editor_navigation_policy.d.ts} +10 -3
- package/core/keyboard_nav/{connection_navigation_policy.d.ts → navigation_policies/connection_navigation_policy.d.ts} +11 -16
- package/core/keyboard_nav/{field_navigation_policy.d.ts → navigation_policies/field_navigation_policy.d.ts} +10 -3
- package/core/keyboard_nav/{flyout_button_navigation_policy.d.ts → navigation_policies/flyout_button_navigation_policy.d.ts} +10 -3
- package/core/keyboard_nav/{flyout_separator_navigation_policy.d.ts → navigation_policies/flyout_separator_navigation_policy.d.ts} +9 -3
- package/core/keyboard_nav/{icon_navigation_policy.d.ts → navigation_policies/icon_navigation_policy.d.ts} +12 -5
- package/core/keyboard_nav/navigation_policies/toolbox_item_navigation_policy.d.ts +64 -0
- package/core/keyboard_nav/{workspace_comment_navigation_policy.d.ts → navigation_policies/workspace_comment_navigation_policy.d.ts} +14 -9
- package/core/keyboard_nav/{workspace_navigation_policy.d.ts → navigation_policies/workspace_navigation_policy.d.ts} +10 -3
- package/core/keyboard_nav/navigators/flyout_navigator.d.ts +63 -0
- package/core/keyboard_nav/navigators/navigator.d.ts +225 -0
- package/core/keyboard_nav/navigators/toolbox_navigator.d.ts +70 -0
- package/core/registry.d.ts +0 -2
- package/core/renderers/common/constants.d.ts +4 -7
- package/core/renderers/common/i_path_object.d.ts +8 -0
- package/core/renderers/common/path_object.d.ts +5 -14
- package/core/renderers/common/renderer.d.ts +3 -3
- package/core/renderers/zelos/constants.d.ts +1 -14
- package/core/renderers/zelos/measurables/bottom_row.d.ts +1 -1
- package/core/renderers/zelos/measurables/top_row.d.ts +1 -1
- package/core/renderers/zelos/path_object.d.ts +0 -3
- package/core/renderers/zelos/renderer.d.ts +8 -0
- package/core/shortcut_items.d.ts +73 -1
- package/core/shortcut_registry.d.ts +6 -0
- package/core/theme.d.ts +0 -2
- package/core/toast.d.ts +2 -11
- package/core/toolbox/category.d.ts +5 -0
- package/core/toolbox/separator.d.ts +4 -0
- package/core/toolbox/toolbox.d.ts +17 -33
- package/core/toolbox/toolbox_item.d.ts +4 -0
- package/core/utils/aria.d.ts +245 -28
- package/core/utils/dom.d.ts +1 -1
- package/core/utils/shortcut_formatting.d.ts +22 -0
- package/core/utils/useragent.d.ts +1 -0
- package/core/variables.d.ts +1 -1
- package/core/workspace_audio.d.ts +23 -0
- package/core/workspace_svg.d.ts +8 -50
- package/dart_compressed.js +9 -9
- package/dart_compressed.js.map +1 -1
- package/index.mjs +13 -5
- package/javascript_compressed.js +11 -10
- package/javascript_compressed.js.map +1 -1
- package/lua_compressed.js +7 -7
- package/lua_compressed.js.map +1 -1
- package/msg/ab.js +65 -0
- package/msg/ab.mjs +65 -0
- package/msg/ace.js +65 -0
- package/msg/ace.mjs +65 -0
- package/msg/af.js +65 -0
- package/msg/af.mjs +65 -0
- package/msg/am.js +65 -0
- package/msg/am.mjs +65 -0
- package/msg/ar.js +65 -0
- package/msg/ar.mjs +65 -0
- package/msg/ast.js +65 -0
- package/msg/ast.mjs +65 -0
- package/msg/az.js +65 -0
- package/msg/az.mjs +65 -0
- package/msg/ba.js +65 -0
- package/msg/ba.mjs +65 -0
- package/msg/bcc.js +65 -0
- package/msg/bcc.mjs +65 -0
- package/msg/be-tarask.js +65 -0
- package/msg/be-tarask.mjs +65 -0
- package/msg/be.js +65 -0
- package/msg/be.mjs +65 -0
- package/msg/bg.js +65 -0
- package/msg/bg.mjs +65 -0
- package/msg/bn.js +65 -0
- package/msg/bn.mjs +65 -0
- package/msg/br.js +65 -0
- package/msg/br.mjs +65 -0
- package/msg/bs.js +65 -0
- package/msg/bs.mjs +65 -0
- package/msg/ca.js +65 -0
- package/msg/ca.mjs +65 -0
- package/msg/cdo.js +65 -0
- package/msg/cdo.mjs +65 -0
- package/msg/ce.js +65 -0
- package/msg/ce.mjs +65 -0
- package/msg/cs.js +65 -0
- package/msg/cs.mjs +65 -0
- package/msg/da.js +65 -0
- package/msg/da.mjs +65 -0
- package/msg/de.js +65 -0
- package/msg/de.mjs +65 -0
- package/msg/diq.js +65 -0
- package/msg/diq.mjs +65 -0
- package/msg/dtp.js +65 -0
- package/msg/dtp.mjs +65 -0
- package/msg/dty.js +65 -0
- package/msg/dty.mjs +65 -0
- package/msg/ee.js +65 -0
- package/msg/ee.mjs +65 -0
- package/msg/el.js +65 -0
- package/msg/el.mjs +65 -0
- package/msg/en-gb.js +65 -0
- package/msg/en-gb.mjs +65 -0
- package/msg/en.js +65 -0
- package/msg/en.mjs +65 -0
- package/msg/eo.js +65 -0
- package/msg/eo.mjs +65 -0
- package/msg/es.js +65 -0
- package/msg/es.mjs +65 -0
- package/msg/et.js +65 -0
- package/msg/et.mjs +65 -0
- package/msg/eu.js +65 -0
- package/msg/eu.mjs +65 -0
- package/msg/fa.js +65 -0
- package/msg/fa.mjs +65 -0
- package/msg/fi.js +65 -0
- package/msg/fi.mjs +65 -0
- package/msg/fo.js +65 -0
- package/msg/fo.mjs +65 -0
- package/msg/fr.js +65 -0
- package/msg/fr.mjs +65 -0
- package/msg/frr.js +65 -0
- package/msg/frr.mjs +65 -0
- package/msg/gl.js +65 -0
- package/msg/gl.mjs +65 -0
- package/msg/gn.js +65 -0
- package/msg/gn.mjs +65 -0
- package/msg/gor.js +65 -0
- package/msg/gor.mjs +65 -0
- package/msg/ha.js +65 -0
- package/msg/ha.mjs +65 -0
- package/msg/hak.js +65 -0
- package/msg/hak.mjs +65 -0
- package/msg/he.js +65 -0
- package/msg/he.mjs +65 -0
- package/msg/hi.js +65 -0
- package/msg/hi.mjs +65 -0
- package/msg/hr.js +65 -0
- package/msg/hr.mjs +65 -0
- package/msg/hrx.js +65 -0
- package/msg/hrx.mjs +65 -0
- package/msg/hsb.js +65 -0
- package/msg/hsb.mjs +65 -0
- package/msg/hu.js +65 -0
- package/msg/hu.mjs +65 -0
- package/msg/hy.js +65 -0
- package/msg/hy.mjs +65 -0
- package/msg/ia.js +65 -0
- package/msg/ia.mjs +65 -0
- package/msg/id.js +65 -0
- package/msg/id.mjs +65 -0
- package/msg/ig.js +65 -0
- package/msg/ig.mjs +65 -0
- package/msg/inh.js +65 -0
- package/msg/inh.mjs +65 -0
- package/msg/is.js +65 -0
- package/msg/is.mjs +65 -0
- package/msg/it.js +65 -0
- package/msg/it.mjs +65 -0
- package/msg/ja.js +65 -0
- package/msg/ja.mjs +65 -0
- package/msg/ka.js +65 -0
- package/msg/ka.mjs +65 -0
- package/msg/kab.js +65 -0
- package/msg/kab.mjs +65 -0
- package/msg/kbd-cyrl.js +65 -0
- package/msg/kbd-cyrl.mjs +65 -0
- package/msg/km.js +65 -0
- package/msg/km.mjs +65 -0
- package/msg/kn.js +65 -0
- package/msg/kn.mjs +65 -0
- package/msg/ko.js +65 -0
- package/msg/ko.mjs +65 -0
- package/msg/ksh.js +65 -0
- package/msg/ksh.mjs +65 -0
- package/msg/ku-latn.js +65 -0
- package/msg/ku-latn.mjs +65 -0
- package/msg/ky.js +65 -0
- package/msg/ky.mjs +65 -0
- package/msg/la.js +65 -0
- package/msg/la.mjs +65 -0
- package/msg/lb.js +65 -0
- package/msg/lb.mjs +65 -0
- package/msg/lki.js +65 -0
- package/msg/lki.mjs +65 -0
- package/msg/lo.js +65 -0
- package/msg/lo.mjs +65 -0
- package/msg/lrc.js +65 -0
- package/msg/lrc.mjs +65 -0
- package/msg/lt.js +65 -0
- package/msg/lt.mjs +65 -0
- package/msg/lv.js +65 -0
- package/msg/lv.mjs +65 -0
- package/msg/mg.js +65 -0
- package/msg/mg.mjs +65 -0
- package/msg/mk.js +65 -0
- package/msg/mk.mjs +65 -0
- package/msg/ml.js +65 -0
- package/msg/ml.mjs +65 -0
- package/msg/mnw.js +65 -0
- package/msg/mnw.mjs +65 -0
- package/msg/ms.js +65 -0
- package/msg/ms.mjs +65 -0
- package/msg/my.js +65 -0
- package/msg/my.mjs +65 -0
- package/msg/mzn.js +65 -0
- package/msg/mzn.mjs +65 -0
- package/msg/nb.js +65 -0
- package/msg/nb.mjs +65 -0
- package/msg/ne.js +65 -0
- package/msg/ne.mjs +65 -0
- package/msg/nl.js +65 -0
- package/msg/nl.mjs +65 -0
- package/msg/oc.js +65 -0
- package/msg/oc.mjs +65 -0
- package/msg/olo.js +65 -0
- package/msg/olo.mjs +65 -0
- package/msg/pa.js +65 -0
- package/msg/pa.mjs +65 -0
- package/msg/pl.js +65 -0
- package/msg/pl.mjs +65 -0
- package/msg/pms.js +65 -0
- package/msg/pms.mjs +65 -0
- package/msg/ps.js +65 -0
- package/msg/ps.mjs +65 -0
- package/msg/pt-br.js +65 -0
- package/msg/pt-br.mjs +65 -0
- package/msg/pt.js +65 -0
- package/msg/pt.mjs +65 -0
- package/msg/ro.js +65 -0
- package/msg/ro.mjs +65 -0
- package/msg/ru.js +65 -0
- package/msg/ru.mjs +65 -0
- package/msg/sc.js +65 -0
- package/msg/sc.mjs +65 -0
- package/msg/sco.js +65 -0
- package/msg/sco.mjs +65 -0
- package/msg/sd.js +65 -0
- package/msg/sd.mjs +65 -0
- package/msg/shn.js +65 -0
- package/msg/shn.mjs +65 -0
- package/msg/si.js +65 -0
- package/msg/si.mjs +65 -0
- package/msg/sk.js +65 -0
- package/msg/sk.mjs +65 -0
- package/msg/skr-arab.js +65 -0
- package/msg/skr-arab.mjs +65 -0
- package/msg/sl.js +65 -0
- package/msg/sl.mjs +65 -0
- package/msg/smn.js +65 -0
- package/msg/smn.mjs +65 -0
- package/msg/sq.js +65 -0
- package/msg/sq.mjs +65 -0
- package/msg/sr-latn.js +65 -0
- package/msg/sr-latn.mjs +65 -0
- package/msg/sr.js +65 -0
- package/msg/sr.mjs +65 -0
- package/msg/sv.js +65 -0
- package/msg/sv.mjs +65 -0
- package/msg/sw.js +65 -0
- package/msg/sw.mjs +65 -0
- package/msg/ta.js +65 -0
- package/msg/ta.mjs +65 -0
- package/msg/tcy.js +65 -0
- package/msg/tcy.mjs +65 -0
- package/msg/tdd.js +65 -0
- package/msg/tdd.mjs +65 -0
- package/msg/te.js +65 -0
- package/msg/te.mjs +65 -0
- package/msg/th.js +65 -0
- package/msg/th.mjs +65 -0
- package/msg/ti.js +65 -0
- package/msg/ti.mjs +65 -0
- package/msg/tl.js +65 -0
- package/msg/tl.mjs +65 -0
- package/msg/tlh.js +65 -0
- package/msg/tlh.mjs +65 -0
- package/msg/tr.js +65 -0
- package/msg/tr.mjs +65 -0
- package/msg/ug-arab.js +65 -0
- package/msg/ug-arab.mjs +65 -0
- package/msg/uk.js +65 -0
- package/msg/uk.mjs +65 -0
- package/msg/ur.js +65 -0
- package/msg/ur.mjs +65 -0
- package/msg/uz.js +65 -0
- package/msg/uz.mjs +65 -0
- package/msg/vi.js +65 -0
- package/msg/vi.mjs +65 -0
- package/msg/xmf.js +65 -0
- package/msg/xmf.mjs +65 -0
- package/msg/yo.js +65 -0
- package/msg/yo.mjs +65 -0
- package/msg/zgh.js +65 -0
- package/msg/zgh.mjs +65 -0
- package/msg/zh-hans.js +65 -0
- package/msg/zh-hans.mjs +65 -0
- package/msg/zh-hant.js +65 -0
- package/msg/zh-hant.mjs +65 -0
- package/package.json +11 -11
- package/php_compressed.js +2 -2
- package/php_compressed.js.map +1 -1
- package/python_compressed.js +2 -2
- package/python_compressed.js.map +1 -1
- package/core/flyout_navigator.d.ts +0 -11
- package/core/keyboard_nav/block_comment_navigation_policy.d.ts +0 -56
- package/core/keyboard_nav/flyout_navigation_policy.d.ts +0 -65
- package/core/keyboard_nav/line_cursor.d.ts +0 -187
- package/core/keyboard_nav/marker.d.ts +0 -53
- package/core/marker_manager.d.ts +0 -72
- package/core/navigator.d.ts +0 -65
- package/media/sprites.png +0 -0
|
@@ -3,9 +3,23 @@
|
|
|
3
3
|
* Copyright 2024 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { BlockSvg } from '../block_svg.js';
|
|
7
|
-
import { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
6
|
+
import type { BlockSvg } from '../block_svg.js';
|
|
7
|
+
import type { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
8
|
+
import { DragDisposition } from '../interfaces/i_draggable.js';
|
|
9
|
+
import type { RenderedConnection } from '../rendered_connection.js';
|
|
8
10
|
import { Coordinate } from '../utils.js';
|
|
11
|
+
/** Represents a valid pair of connections between the dragging block and a block on the workspace. */
|
|
12
|
+
interface ConnectionPair {
|
|
13
|
+
/** A connection on the dragging stack that is compatible with neighbour. */
|
|
14
|
+
local: RenderedConnection;
|
|
15
|
+
/** A nearby connection that is compatible with local. */
|
|
16
|
+
neighbour: RenderedConnection;
|
|
17
|
+
}
|
|
18
|
+
/** Represents a nearby valid connection. */
|
|
19
|
+
interface ConnectionCandidate extends ConnectionPair {
|
|
20
|
+
/** The distance between the local connection and the neighbour connection. */
|
|
21
|
+
distance: number;
|
|
22
|
+
}
|
|
9
23
|
export declare class BlockDragStrategy implements IDragStrategy {
|
|
10
24
|
private block;
|
|
11
25
|
private workspace;
|
|
@@ -20,21 +34,53 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
20
34
|
private connectionCandidate;
|
|
21
35
|
private connectionPreviewer;
|
|
22
36
|
private dragging;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
private dragOffset;
|
|
37
|
+
/** List of all connections available on the workspace. */
|
|
38
|
+
private allConnectionPairs;
|
|
39
|
+
/** The current movement mode. */
|
|
40
|
+
private moveMode;
|
|
28
41
|
/** Used to persist an event group when snapping is done async. */
|
|
29
42
|
private originalEventGroup;
|
|
43
|
+
protected readonly BLOCK_CONNECTION_OFFSET = 10;
|
|
30
44
|
constructor(block: BlockSvg);
|
|
31
45
|
/** Returns true if the block is currently movable. False otherwise. */
|
|
32
46
|
isMovable(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Positions a cloned block on its new workspace.
|
|
49
|
+
*
|
|
50
|
+
* @param oldBlock The flyout block that was cloned.
|
|
51
|
+
* @param newBlock The new block to position.
|
|
52
|
+
*/
|
|
53
|
+
private positionNewBlock;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the block to use for the current drag operation. This may create
|
|
56
|
+
* and return a newly instantiated block when e.g. dragging from a flyout.
|
|
57
|
+
*/
|
|
58
|
+
protected getTargetBlock(): BlockSvg;
|
|
59
|
+
/**
|
|
60
|
+
* Announces a move on the ARIA live region for assistive technologies.
|
|
61
|
+
*
|
|
62
|
+
* @param isMoveStart Whether this announcement is for the start of a move. If false,
|
|
63
|
+
* skip announcing the block label since it should have already been announced at the
|
|
64
|
+
* start of the move.
|
|
65
|
+
*/
|
|
66
|
+
private announceMove;
|
|
67
|
+
/**
|
|
68
|
+
* Checks if there are multiple compatible connections for the specified side of the pair.
|
|
69
|
+
*
|
|
70
|
+
* @param forLocal Whether we are considering the local or neighbour side of the pair
|
|
71
|
+
* @returns True if there are multiple compatible connections, false otherwise
|
|
72
|
+
*/
|
|
73
|
+
private hasMultipleCompatibleConnections;
|
|
33
74
|
/**
|
|
34
75
|
* Handles any setup for starting the drag, including disconnecting the block
|
|
35
76
|
* from any parent blocks.
|
|
36
77
|
*/
|
|
37
|
-
startDrag(e?: PointerEvent):
|
|
78
|
+
startDrag(e?: PointerEvent | KeyboardEvent): import("../interfaces/i_draggable.js").IDraggable;
|
|
79
|
+
/**
|
|
80
|
+
* Handles any setup for starting the drag, including disconnecting the block
|
|
81
|
+
* from any parent blocks.
|
|
82
|
+
*/
|
|
83
|
+
private cacheAllConnectionPairs;
|
|
38
84
|
/**
|
|
39
85
|
* Returns an array of visible bubbles attached to the given block or its
|
|
40
86
|
* descendants.
|
|
@@ -47,13 +93,11 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
47
93
|
/**
|
|
48
94
|
* Get whether the drag should act on a single block or a block stack.
|
|
49
95
|
*
|
|
50
|
-
* @param e The instigating pointer event, if any.
|
|
96
|
+
* @param e The instigating pointer or keyboard event, if any.
|
|
51
97
|
* @returns True if just the initial block should be dragged out, false
|
|
52
98
|
* if all following blocks should also be dragged.
|
|
53
99
|
*/
|
|
54
|
-
protected shouldHealStack(e: PointerEvent | undefined): boolean;
|
|
55
|
-
/** Starts a drag on a shadow, recording the drag offset. */
|
|
56
|
-
private startDraggingShadow;
|
|
100
|
+
protected shouldHealStack(e: PointerEvent | KeyboardEvent | undefined): boolean;
|
|
57
101
|
/**
|
|
58
102
|
* Whether or not we should disconnect the block when a drag is started.
|
|
59
103
|
*
|
|
@@ -69,6 +113,12 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
69
113
|
* @param healStack Whether or not to heal the stack after disconnecting.
|
|
70
114
|
*/
|
|
71
115
|
private disconnectBlock;
|
|
116
|
+
/**
|
|
117
|
+
* Stores the dragging block's current parent or child connection before
|
|
118
|
+
* unplugging. This allows us to revert the drag cleanly. In keyboard move mode,
|
|
119
|
+
* the initial connection pair is also used as the first connection candidate.
|
|
120
|
+
*/
|
|
121
|
+
private storeInitialConnections;
|
|
72
122
|
/** Fire a UI event at the start of a block drag. */
|
|
73
123
|
private fireDragStartEvent;
|
|
74
124
|
/** Fire a UI event at the end of a block drag. */
|
|
@@ -76,11 +126,15 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
76
126
|
/** Fire a move event at the end of a block drag. */
|
|
77
127
|
private fireMoveEvent;
|
|
78
128
|
/** Moves the block and updates any connection previews. */
|
|
79
|
-
drag(newLoc: Coordinate): void;
|
|
129
|
+
drag(newLoc: Coordinate, e?: PointerEvent | KeyboardEvent): void;
|
|
80
130
|
/**
|
|
131
|
+
* Renders the connection preview indicator.
|
|
132
|
+
*
|
|
81
133
|
* @param draggingBlock The block being dragged.
|
|
82
134
|
* @param delta How far the pointer has moved from the position
|
|
83
135
|
* at the start of the drag, in workspace units.
|
|
136
|
+
* @returns The neighbouring connection to which the connection preview will
|
|
137
|
+
* be attached.
|
|
84
138
|
*/
|
|
85
139
|
private updateConnectionPreview;
|
|
86
140
|
/**
|
|
@@ -101,6 +155,14 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
101
155
|
* compatible type (input, output, etc) and connection check.
|
|
102
156
|
*/
|
|
103
157
|
private getConnectionCandidate;
|
|
158
|
+
/**
|
|
159
|
+
* Returns the closest connection candidate for the given block.
|
|
160
|
+
*
|
|
161
|
+
* @param block The block to find a connection for.
|
|
162
|
+
* @param delta The distance the block has traveled since dragging began.
|
|
163
|
+
* @returns The closest available connection candidate, if any.
|
|
164
|
+
*/
|
|
165
|
+
private getClosestCandidate;
|
|
104
166
|
/**
|
|
105
167
|
* Get the radius to use when searching for a nearby valid connection.
|
|
106
168
|
*/
|
|
@@ -116,7 +178,7 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
116
178
|
* Cleans up any state at the end of the drag. Applies any pending
|
|
117
179
|
* connections.
|
|
118
180
|
*/
|
|
119
|
-
endDrag(
|
|
181
|
+
endDrag(_e: PointerEvent | KeyboardEvent | undefined, disposition: DragDisposition): void;
|
|
120
182
|
/** Disposes of any state at the end of the drag. */
|
|
121
183
|
private disposeStep;
|
|
122
184
|
/** Connects the given candidate connections. */
|
|
@@ -126,5 +188,55 @@ export declare class BlockDragStrategy implements IDragStrategy {
|
|
|
126
188
|
* including reconnecting connections.
|
|
127
189
|
*/
|
|
128
190
|
revertDrag(): void;
|
|
191
|
+
/**
|
|
192
|
+
* Get the nearest valid candidate connection in traversal order.
|
|
193
|
+
*
|
|
194
|
+
* @param delta The distance the block has moved since this drag began.
|
|
195
|
+
* @returns A candidate connection and radius, or null if none was found.
|
|
196
|
+
*/
|
|
197
|
+
findTraversalCandidate(delta: Coordinate): ConnectionCandidate | null;
|
|
198
|
+
/**
|
|
199
|
+
* Returns whether or not the given block is at a terminal position (start or
|
|
200
|
+
* end) of the blocks on the workspace. This helps distinguish between a block
|
|
201
|
+
* that is at the end of the line because all valid connections have been
|
|
202
|
+
* visited and the proposed constrained move destination is now to drop it on
|
|
203
|
+
* the workspace as a top-level block (in which case it will be in a terminal
|
|
204
|
+
* position), and a block that just entered move mode as a top-level block,
|
|
205
|
+
* and should therefore still be able to move to another connection point
|
|
206
|
+
* even if looping is disabled.
|
|
207
|
+
*
|
|
208
|
+
* @param block The block to check.
|
|
209
|
+
* @param direction The current dragging direction.
|
|
210
|
+
* @returns True if the block is at the start or end of its possible positions
|
|
211
|
+
* on the workspace.
|
|
212
|
+
*/
|
|
213
|
+
private isInTerminalPosition;
|
|
214
|
+
/**
|
|
215
|
+
* Converts a connection pair to a connection candidate with a default
|
|
216
|
+
* distance of 0.
|
|
217
|
+
*/
|
|
218
|
+
private pairToCandidate;
|
|
219
|
+
/**
|
|
220
|
+
* Returns the cardinal direction that the block being dragged would have to
|
|
221
|
+
* move in to reach the given location.
|
|
222
|
+
* The given coordinate should differ from the current location on only one
|
|
223
|
+
* axis.
|
|
224
|
+
*
|
|
225
|
+
* @param newLocation The intended destination for the block.
|
|
226
|
+
* @returns The direction the block would need to travel to reach the new
|
|
227
|
+
* location.
|
|
228
|
+
*/
|
|
229
|
+
private getDirectionToNewLocation;
|
|
230
|
+
/**
|
|
231
|
+
* Returns all navigable connections on the given block and its children.
|
|
232
|
+
* Omits connections on shadow blocks, collapsed blocks, or those that are
|
|
233
|
+
* associated with a hidden input.
|
|
234
|
+
*
|
|
235
|
+
* @param block The block to use as a starting point for retrieving
|
|
236
|
+
* connections.
|
|
237
|
+
* @returns All connections on the block and its children.
|
|
238
|
+
*/
|
|
239
|
+
private getAllConnections;
|
|
129
240
|
}
|
|
241
|
+
export {};
|
|
130
242
|
//# sourceMappingURL=block_drag_strategy.d.ts.map
|
|
@@ -3,16 +3,17 @@
|
|
|
3
3
|
* Copyright 2024 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { IBubble
|
|
7
|
-
import { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
8
|
-
import { Coordinate } from '../utils.js';
|
|
6
|
+
import type { IBubble } from '../interfaces/i_bubble.js';
|
|
7
|
+
import type { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
8
|
+
import type { Coordinate } from '../utils.js';
|
|
9
|
+
import type { WorkspaceSvg } from '../workspace_svg.js';
|
|
9
10
|
export declare class BubbleDragStrategy implements IDragStrategy {
|
|
10
11
|
private bubble;
|
|
11
12
|
private workspace;
|
|
12
13
|
private startLoc;
|
|
13
14
|
constructor(bubble: IBubble, workspace: WorkspaceSvg);
|
|
14
15
|
isMovable(): boolean;
|
|
15
|
-
startDrag():
|
|
16
|
+
startDrag(): IBubble;
|
|
16
17
|
drag(newLoc: Coordinate): void;
|
|
17
18
|
endDrag(): void;
|
|
18
19
|
revertDrag(): void;
|
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
* Copyright 2024 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { RenderedWorkspaceComment } from '../comments.js';
|
|
7
|
-
import { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
8
|
-
import { Coordinate } from '../utils.js';
|
|
6
|
+
import type { RenderedWorkspaceComment } from '../comments.js';
|
|
7
|
+
import type { IDragStrategy } from '../interfaces/i_draggable.js';
|
|
8
|
+
import type { Coordinate } from '../utils.js';
|
|
9
9
|
export declare class CommentDragStrategy implements IDragStrategy {
|
|
10
10
|
private comment;
|
|
11
11
|
private startLoc;
|
|
12
12
|
private workspace;
|
|
13
13
|
constructor(comment: RenderedWorkspaceComment);
|
|
14
14
|
isMovable(): boolean;
|
|
15
|
-
startDrag():
|
|
15
|
+
startDrag(): RenderedWorkspaceComment;
|
|
16
16
|
drag(newLoc: Coordinate): void;
|
|
17
17
|
endDrag(): void;
|
|
18
18
|
/** Fire a UI event at the start of a comment drag. */
|
|
@@ -3,29 +3,27 @@
|
|
|
3
3
|
* Copyright 2024 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
*/
|
|
6
|
-
import { IDeletable } from '../interfaces/i_deletable.js';
|
|
7
|
-
import { IDragTarget } from '../interfaces/i_drag_target.js';
|
|
8
|
-
import { IDraggable } from '../interfaces/i_draggable.js';
|
|
9
|
-
import { IDragger } from '../interfaces/i_dragger.js';
|
|
6
|
+
import type { IDeletable } from '../interfaces/i_deletable.js';
|
|
7
|
+
import type { IDragTarget } from '../interfaces/i_drag_target.js';
|
|
8
|
+
import { type IDraggable } from '../interfaces/i_draggable.js';
|
|
9
|
+
import type { IDragger } from '../interfaces/i_dragger.js';
|
|
10
10
|
import { Coordinate } from '../utils/coordinate.js';
|
|
11
|
-
import { WorkspaceSvg } from '../workspace_svg.js';
|
|
12
11
|
export declare class Dragger implements IDragger {
|
|
13
12
|
protected draggable: IDraggable;
|
|
14
|
-
protected workspace: WorkspaceSvg;
|
|
15
13
|
protected startLoc: Coordinate;
|
|
16
14
|
protected dragTarget: IDragTarget | null;
|
|
17
|
-
constructor(draggable: IDraggable
|
|
15
|
+
constructor(draggable: IDraggable);
|
|
18
16
|
/** Handles any drag startup. */
|
|
19
|
-
onDragStart(e
|
|
17
|
+
onDragStart(e?: PointerEvent | KeyboardEvent): IDraggable;
|
|
20
18
|
/**
|
|
21
19
|
* Handles calculating where the element should actually be moved to.
|
|
22
20
|
*
|
|
23
21
|
* @param totalDelta The total amount in pixel coordinates the mouse has moved
|
|
24
22
|
* since the start of the drag.
|
|
25
23
|
*/
|
|
26
|
-
onDrag(e: PointerEvent, totalDelta: Coordinate): void;
|
|
24
|
+
onDrag(e: PointerEvent | KeyboardEvent | undefined, totalDelta: Coordinate): void;
|
|
27
25
|
/** Updates the drag target under the pointer (if there is one). */
|
|
28
|
-
protected updateDragTarget(
|
|
26
|
+
protected updateDragTarget(coordinate: Coordinate): void;
|
|
29
27
|
/**
|
|
30
28
|
* Calculates the correct workspace coordinate for the movable and tells
|
|
31
29
|
* the draggable to go to that location.
|
|
@@ -35,15 +33,16 @@ export declare class Dragger implements IDragger {
|
|
|
35
33
|
* Returns true if we would delete the draggable if it was dropped
|
|
36
34
|
* at the current location.
|
|
37
35
|
*/
|
|
38
|
-
protected wouldDeleteDraggable(
|
|
36
|
+
protected wouldDeleteDraggable(coordinate: Coordinate, rootDraggable: IDraggable & IDeletable): boolean;
|
|
39
37
|
/** Handles any drag cleanup. */
|
|
40
|
-
onDragEnd(e
|
|
41
|
-
|
|
38
|
+
onDragEnd(e?: PointerEvent | KeyboardEvent): void;
|
|
39
|
+
/** Handles a drag being reverted. */
|
|
40
|
+
onDragRevert(): void;
|
|
42
41
|
/**
|
|
43
42
|
* Returns true if we should return the draggable to its original location
|
|
44
43
|
* at the end of the drag.
|
|
45
44
|
*/
|
|
46
|
-
protected shouldReturnToStart(
|
|
45
|
+
protected shouldReturnToStart(coordinate: Coordinate, rootDraggable: IDraggable): boolean;
|
|
47
46
|
protected pixelsToWorkspaceUnits(pixelCoord: Coordinate): Coordinate;
|
|
48
47
|
}
|
|
49
48
|
//# sourceMappingURL=dragger.d.ts.map
|
|
@@ -19,8 +19,6 @@ import { EventType } from './type.js';
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class BlockCreate extends BlockBase {
|
|
21
21
|
type: EventType;
|
|
22
|
-
/** The XML representation of the created block(s). */
|
|
23
|
-
xml?: Element | DocumentFragment;
|
|
24
22
|
/** The JSON respresentation of the created block(s). */
|
|
25
23
|
json?: blocks.State;
|
|
26
24
|
/** All of the IDs of created blocks. */
|
|
@@ -51,7 +49,6 @@ export declare class BlockCreate extends BlockBase {
|
|
|
51
49
|
run(forward: boolean): void;
|
|
52
50
|
}
|
|
53
51
|
export interface BlockCreateJson extends BlockBaseJson {
|
|
54
|
-
xml: string;
|
|
55
52
|
ids: string[];
|
|
56
53
|
json: object;
|
|
57
54
|
recordUndo?: boolean;
|
|
@@ -18,8 +18,6 @@ import { EventType } from './type.js';
|
|
|
18
18
|
* deleted.
|
|
19
19
|
*/
|
|
20
20
|
export declare class BlockDelete extends BlockBase {
|
|
21
|
-
/** The XML representation of the deleted block(s). */
|
|
22
|
-
oldXml?: Element | DocumentFragment;
|
|
23
21
|
/** The JSON respresentation of the deleted block(s). */
|
|
24
22
|
oldJson?: blocks.State;
|
|
25
23
|
/** All of the IDs of deleted blocks. */
|
|
@@ -53,7 +51,6 @@ export declare class BlockDelete extends BlockBase {
|
|
|
53
51
|
run(forward: boolean): void;
|
|
54
52
|
}
|
|
55
53
|
export interface BlockDeleteJson extends BlockBaseJson {
|
|
56
|
-
oldXml: string;
|
|
57
54
|
ids: string[];
|
|
58
55
|
wasShadow: boolean;
|
|
59
56
|
oldJson: blocks.State;
|
|
@@ -18,8 +18,6 @@ import { EventType } from './type.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class CommentCreate extends CommentBase {
|
|
20
20
|
type: EventType;
|
|
21
|
-
/** The XML representation of the created workspace comment. */
|
|
22
|
-
xml?: Element | DocumentFragment;
|
|
23
21
|
/** The JSON representation of the created workspace comment. */
|
|
24
22
|
json?: comments.State;
|
|
25
23
|
/**
|
|
@@ -51,7 +49,6 @@ export declare class CommentCreate extends CommentBase {
|
|
|
51
49
|
run(forward: boolean): void;
|
|
52
50
|
}
|
|
53
51
|
export interface CommentCreateJson extends CommentBaseJson {
|
|
54
|
-
xml: string;
|
|
55
52
|
json: object;
|
|
56
53
|
}
|
|
57
54
|
//# sourceMappingURL=events_comment_create.d.ts.map
|
|
@@ -18,8 +18,6 @@ import { EventType } from './type.js';
|
|
|
18
18
|
*/
|
|
19
19
|
export declare class CommentDelete extends CommentBase {
|
|
20
20
|
type: EventType;
|
|
21
|
-
/** The XML representation of the deleted workspace comment. */
|
|
22
|
-
xml?: Element;
|
|
23
21
|
/** The JSON representation of the created workspace comment. */
|
|
24
22
|
json?: comments.State;
|
|
25
23
|
/**
|
|
@@ -51,7 +49,6 @@ export declare class CommentDelete extends CommentBase {
|
|
|
51
49
|
static fromJson(json: CommentDeleteJson, workspace: Workspace, event?: any): CommentDelete;
|
|
52
50
|
}
|
|
53
51
|
export interface CommentDeleteJson extends CommentBaseJson {
|
|
54
|
-
xml: string;
|
|
55
52
|
json: object;
|
|
56
53
|
}
|
|
57
54
|
//# sourceMappingURL=events_comment_delete.d.ts.map
|
package/core/field.d.ts
CHANGED
|
@@ -70,6 +70,8 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
|
|
|
70
70
|
protected value_: T | null;
|
|
71
71
|
/** Validation function called when user edits an editable field. */
|
|
72
72
|
protected validator_: FieldValidator<T> | null;
|
|
73
|
+
/** The ARIA-friendly label representation of this field's type. */
|
|
74
|
+
protected ariaTypeName: string | null;
|
|
73
75
|
/**
|
|
74
76
|
* Used to cache the field's tooltip value if setTooltip is called when the
|
|
75
77
|
* field is not yet initialized. Is *not* guaranteed to be accurate.
|
|
@@ -184,6 +186,63 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
|
|
|
184
186
|
* @throws An error if the source block is not defined.
|
|
185
187
|
*/
|
|
186
188
|
getSourceBlock(): Block | null;
|
|
189
|
+
/**
|
|
190
|
+
* Gets an ARIA-friendly label representation of this field's type.
|
|
191
|
+
*
|
|
192
|
+
* Implementations are responsible for, and encouraged to, return a localized
|
|
193
|
+
* version of the ARIA representation of the field's type.
|
|
194
|
+
*
|
|
195
|
+
* @returns An ARIA representation of the field's type or null if it is
|
|
196
|
+
* unspecified.
|
|
197
|
+
*/
|
|
198
|
+
getAriaTypeName(): string | null;
|
|
199
|
+
/**
|
|
200
|
+
* Gets an ARIA-friendly label representation of this field's value.
|
|
201
|
+
*
|
|
202
|
+
* Note that implementations should generally always override this value to
|
|
203
|
+
* ensure a non-null value is returned. The default implementation relies on
|
|
204
|
+
* 'getText' which may return an empty string. A null return value from this
|
|
205
|
+
* function will prompt ARIA label generation to skip the field's value
|
|
206
|
+
* entirely when there may be a better contextual placeholder to use isstead.
|
|
207
|
+
*
|
|
208
|
+
* For example, to avoid hiding an empty text input field from screen reader,
|
|
209
|
+
* implementations should ensure that if the text is an empty string, this
|
|
210
|
+
* function would return an appropriate, localized value such as "empty text".
|
|
211
|
+
*
|
|
212
|
+
* Implementations are responsible for, and encouraged to, return a localized
|
|
213
|
+
* version of the ARIA representation of the field's value.
|
|
214
|
+
*
|
|
215
|
+
* @returns An ARIA representation of the field's text, or null if no text is
|
|
216
|
+
* currently defined or known for the field.
|
|
217
|
+
*/
|
|
218
|
+
getAriaValue(): string | null;
|
|
219
|
+
/**
|
|
220
|
+
* Computes a descriptive ARIA label to represent this field with configurable
|
|
221
|
+
* verbosity.
|
|
222
|
+
*
|
|
223
|
+
* A 'verbose' label includes type information, if available, whereas a
|
|
224
|
+
* non-verbose label only contains the field's value.
|
|
225
|
+
*
|
|
226
|
+
* Note that this will always return the latest representation of the field's
|
|
227
|
+
* label which may differ from any previously set ARIA label for the field
|
|
228
|
+
* itself. Implementations are largely responsible for ensuring that the
|
|
229
|
+
* field's ARIA label is set correctly at relevant moments in the field's
|
|
230
|
+
* lifecycle (such as when its value changes).
|
|
231
|
+
*
|
|
232
|
+
* Finally, it is never guaranteed that implementations use the label returned
|
|
233
|
+
* by this method for their actual ARIA label. Some implementations may rely
|
|
234
|
+
* on other contexts to convey information like the field's value. Example:
|
|
235
|
+
* checkboxes represent their checked/non-checked status (i.e. value) through
|
|
236
|
+
* a separate ARIA property.
|
|
237
|
+
*
|
|
238
|
+
* It's not expected that this method, under normal operations, returns an empty
|
|
239
|
+
* string. If the field's value is empty then it will return a localized
|
|
240
|
+
* placeholder indicating that its value is empty.
|
|
241
|
+
*
|
|
242
|
+
* @param includeTypeInfo Whether to include the field's type information in
|
|
243
|
+
* the returned label, if available.
|
|
244
|
+
*/
|
|
245
|
+
computeAriaLabel(includeTypeInfo?: boolean): string;
|
|
187
246
|
/**
|
|
188
247
|
* Initialize everything to render this field. Override
|
|
189
248
|
* methods initModel and initView rather than this method.
|
|
@@ -219,9 +278,11 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
|
|
|
219
278
|
*/
|
|
220
279
|
protected createBorderRect_(): void;
|
|
221
280
|
/**
|
|
222
|
-
* Create a field text element. Not to be overridden by subclasses. Instead
|
|
281
|
+
* Create a field text element. Not to be overridden by subclasses. Instead,
|
|
223
282
|
* modify the result of the function inside initView, or create a separate
|
|
224
|
-
* function to call.
|
|
283
|
+
* function to call. Aria state is hidden; use the aria label for the field
|
|
284
|
+
* and/or containing block to expose content to screen readers. Text content
|
|
285
|
+
* for custom blocks can be set after creation.
|
|
225
286
|
*/
|
|
226
287
|
protected createTextElement_(): void;
|
|
227
288
|
/**
|
|
@@ -684,6 +745,11 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
|
|
|
684
745
|
onNodeBlur(): void;
|
|
685
746
|
/** See IFocusableNode.canBeFocused. */
|
|
686
747
|
canBeFocused(): boolean;
|
|
748
|
+
/**
|
|
749
|
+
* Handles the user acting on this field via keyboard navigation.
|
|
750
|
+
* Shows and focuses the field editor.
|
|
751
|
+
*/
|
|
752
|
+
performAction(): void;
|
|
687
753
|
/**
|
|
688
754
|
* Subclasses should reimplement this method to construct their Field
|
|
689
755
|
* subclass from a JSON arg object.
|
|
@@ -701,6 +767,7 @@ export declare abstract class Field<T = any> implements IKeyboardAccessible, IRe
|
|
|
701
767
|
*/
|
|
702
768
|
export interface FieldConfig {
|
|
703
769
|
tooltip?: string;
|
|
770
|
+
ariaTypeName?: string;
|
|
704
771
|
}
|
|
705
772
|
/**
|
|
706
773
|
* Represents an object that has all the prototype properties of the `Field`
|
package/core/field_input.d.ts
CHANGED
|
@@ -263,6 +263,29 @@ export declare abstract class FieldInput<T extends InputTypes> extends Field<str
|
|
|
263
263
|
* @returns The value to store.
|
|
264
264
|
*/
|
|
265
265
|
protected getValueFromEditorText_(text: string): any;
|
|
266
|
+
/**
|
|
267
|
+
* Gets an ARIA-friendly label representation of this field's type.
|
|
268
|
+
*
|
|
269
|
+
* Implementations are responsible for, and encouraged to, return a localized
|
|
270
|
+
* version of the ARIA representation of the field's type.
|
|
271
|
+
*
|
|
272
|
+
* @returns An ARIA representation of the field's type or a default if it is
|
|
273
|
+
* unspecified.
|
|
274
|
+
*/
|
|
275
|
+
getAriaTypeName(): string | null;
|
|
276
|
+
/**
|
|
277
|
+
* Gets an ARIA-friendly label representation of this field's value.
|
|
278
|
+
*
|
|
279
|
+
* Implementations are responsible for, and encouraged to, return a localized
|
|
280
|
+
* version of the ARIA representation of the field's value.
|
|
281
|
+
*
|
|
282
|
+
* @returns An ARIA representation of the field's text.
|
|
283
|
+
*/
|
|
284
|
+
getAriaValue(): string | null;
|
|
285
|
+
/**
|
|
286
|
+
* Recomputes the ARIA role and label for this field.
|
|
287
|
+
*/
|
|
288
|
+
private recomputeAriaContext;
|
|
266
289
|
}
|
|
267
290
|
/**
|
|
268
291
|
* Config options for the input field.
|