Commit Graph

152 Commits

Author SHA1 Message Date
alschmiedt
f1498e7f07 Keyboard shortcuts (#4421)
* Adds shortcut registry and removes action and key map (#4398)

* Adds Shortcut tests and refactored navigation tests (#4412)

* Adds shortcut items (#4408)

* Add shortcuts for navigation (#4409)

* Add final keyboard shortcut cleanup (#4413)
2020-11-02 13:30:05 -08:00
Sam El-Husseini
db40e44b7c Move Blockly.utils.dom.SvgElementType to Blockly.utils.Svg (#4285)
* Move SVGElementType to its own file shaving off 2.7KB
2020-09-16 14:42:58 -07:00
Sam El-Husseini
0f3db47fa5 Use generics to derive SVG element type (#4036)
* Encapsulate type in a generic to automatically derive type of SVG element when using createSvgElement
2020-07-13 10:40:31 -07:00
Sam El-Husseini
1052f7548b Enable unusedPrivateMembers check (#3924)
* Add unusedPrivateMembers check
2020-05-28 17:44:16 -07:00
Sam El-Husseini
b84d25fe2d Strict types in input (#3912)
* Strict types in input.js
2020-05-21 17:57:13 -07:00
Sam El-Husseini
60a8eb63fe Fix contextmenu / dropdown field menu accessibility (#3892)
* Fix contextmenu and dropdown field accessibility
2020-05-08 09:22:28 -07:00
Neil Fraser
a65afdc189 Simplify Closure-sourced code for menus (#3880)
* Remove cargo-culted bloat from CSS

The `goog-menuitem-icon` and `goog-menuitem-noicon` classes are not present in Blockly.  Blockly doesn’t support the CSS compiler, so #noflip has no effect.  Shorten uncompressible warning string.

Also remove the “Copied from Closure” notes.  These were intended so that the CSS could be easily updated as the Closure Library evolved.  We are no longer linked to the Closure Library.

* Fix bug (in prod) where menu highlighting is lost

Previously, open playground.  Right-click on workspace.  Mouse-over “Add comment” (it highlights).  Mouse over “Download screenshot” (disabled option).  Mouse over “Add comment” (highlighting is lost).

Also remove `canHighlightItem` helper function.  In theory this helps abstract the concept of non-highlightable options.  But in practice it was only called in one of the several places that it should have been.  This was a false abstraction.

* Add support for Space/PgUp/PgDn/Home/End to menus

* Eliminate calls to clearHighlighted

The JSDoc for `setHighlightedIndex` specifically states, “If another item was previously highlighted, it is un-highlighted.”  This is not what was implemented, but it should be.  This commit adds the un-highlighting, and removes all the calls previously required to correct this bug.

* Stop wrapping at top or bottom of menu.

Real OS menus don’t wrap when one cursors off the top or bottom.

Also, replace the overly complicated helper function with a simple 1/-1 step value.

* Remove unused menu code

* Simplify menu roles

Remove unneeded sets to RTL on Menu (only MenuItem cares).

* Fix lack of disposal for context menus.

Context menus only disposed properly when an option was clicked.  If they were dismissed by clicking outside the menu there was no disposal.  This might result in a memory leak.
Also un-extract (inject?) several now trivial functions.

* Remove Component dependency from Menu & MenuItem

Component is now only used by the category tree.

* Remove unused functions in Component

These were used by Menu/MenuItem.

* Fix dependencies.

* Record highlighted menu item by object, not index

Less code, simpler.

* Rename CSS classes goog-menu* to blocklyMenu*

Old classes remain in DOM and are deprecated so that any custom CSS will continue to function.

* Remove unused focus tracker in tree.

* Add support for space/enter to toggle tree cats

* Delete unsettable .isUserCollapsible_ from tree

* Change visibility tags throughout menus.

The previous tags were inherited from Closure and don’t reflect current usage in the Blockly codebase.

The core/components/tree files are non-compliant in this regard, but I’m not going to update them since they need to be replaced and there’s no need to create an interim API change.

* Remove property on DOM element linking to JS obj

Performance is slower (O(n) rather than (O(1)), but ’n’ is the number of entries on the menu, so shouldn’t be more than a dozen or so.

* Fixes a compile error (node != element)

Usually we avoid parentElement in Blockly.  That’s because it has very spotty behaviour with SVG.  But in this case we are in pure HTML.
2020-05-06 23:55:17 -04:00
Sam El-Husseini
13ac939b91 Support passing renderer overrides in options (#3734)
* Support passing in renderer options through workspace options.
2020-03-10 18:36:29 -07:00
Sam El-Husseini
eb40ca44ba Dynamic fonts (#3698)
* Piping themes into the renderer and ensuring fields update their size information when constants change.
2020-02-20 17:16:01 -08:00
Neil Fraser
4e2f8e6e02 Use SPDX licences.
This is a followup to #3127.
At the time, SPDX licenses were pending approval by Google.
2020-02-11 13:27:20 -08:00
Monica Kozbial
e2b510662c Fixing typo on "programmatically". (#3654) 2020-01-24 15:10:22 -08:00
Sam El-Husseini
58b690728d Fix rtl placement of arrow in non-borderbox dropdown fields (#3629) 2020-01-22 11:07:59 -08:00
Sam El-Husseini
f8000e00dc Use selected option instead of selected index to cache current selected value in field. (#3602) 2020-01-16 13:33:45 -08:00
Sam El-Husseini
6a4251b11a Add constant for field dropdown arrow padding (#3581)
* Add constants for field dropdown arrow padding for more control over where the arrow shows up.
2020-01-14 13:27:47 -08:00
Sam El-Husseini
6bd6bdefbc Upgrade closure + support for closure-library dependency (#3554)
* Upgrade closure and include hints on how to include the closure library in the build.

* Revert build-uncomprssed.

* Sort uncompressed.

* nit: comment.
2020-01-14 12:59:43 -08:00
Sam El-Husseini
20e55b67d7 Fix bug with dropdown menu propagating the opening click event to a menu item (#3570)
* Prevent dropdown field menu from propagating a click event onto a menu item when the dropdown appears above the field
2020-01-09 18:08:29 -08:00
Sam El-Husseini
8d6ff39e64 [zelos] Support dropdown fields with no border rect (#3547)
* Dropdown fields without a border rect.
2020-01-06 13:16:59 -08:00
Sam El-Husseini
06c714d13b Fix dropdown field alignment in zelos when baseline is not centered (IE / Edge) (#3534) 2020-01-02 14:36:06 -08:00
Sam El-Husseini
63f7af115c [zelos] Set field rect background colour (#3500)
* More consistent field rect colour in zelos. Only overriding in full block fields. Fix disabled block colours.

* Use a better constant name and fix build.
2019-12-10 08:31:43 -08:00
Sam El-Husseini
b038c1cef5 [zelos] Set dropdown div colour to match block colour (#3462)
* Set dropdown div colour to match block colour
2019-11-27 09:30:29 -08:00
Sam El-Husseini
c868a86bdd Field dropdown with an SVG arrow (#3442)
* Add SVG arrow as an option on the dropdown field
2019-11-14 15:00:49 -08:00
Sam El-Husseini
2dea7038d5 Moves field layout constants into the renderer (#3437)
* Add field constants into renderer constants
2019-11-13 16:41:35 -08:00
Sam El-Husseini
95f2b232b9 Field constants (#3423)
* Move field text sizing constants to renderer constants
2019-11-11 16:13:50 -08:00
Sam El-Husseini
ee09aafd57 [zelos] Add input outlines on the path object. (#3410)
* Add input outlines on the path object.
2019-11-07 15:15:49 -08:00
Neil Fraser
123f436e04 Add parens around inline assignments (#3381) 2019-10-31 15:17:35 -07:00
Rachel Fenichel
5ef08fc0d4 Switch to using the style object in the path object. 2019-10-30 14:47:23 -07:00
Rachel Fenichel
ca1e49bf8e Fields now go through blockSvg for colours. 2019-10-30 14:43:42 -07:00
Rachel Fenichel
6f520335ea Cleanup of colouring code, and move it into path_object. 2019-10-30 14:42:13 -07:00
Rachel Fenichel
85c4db5a10 First pass at colourers 2019-10-30 14:42:13 -07:00
Sam El-Husseini
649dc116ed Using a HTML canvas for computing the text width (#3000)
* Use a helper HTML canvas element to measure text width for better performance
2019-10-24 13:02:32 -04:00
Neil Fraser
013f2714a3 Cleanup aria usage. (#3261)
Use enums instead of arbitrary strings.
Delete unused Aria properties
Add missing requires.
Delete unused code.
2019-10-15 22:43:23 -07:00
Sam El-Husseini
2224bb2a4e More field dispose (#3201)
* Dispose of element references in fields.
* Fewer warnings
2019-10-15 17:56:53 -05:00
Beka Westberg
f4f9a67903 Fixed field editor disposal (#3109)
* Fixed field editor disposal.
2019-10-08 16:48:31 -07:00
Sam El-Husseini
d0772ad496 Fix compiler warnings related to fields. (#3144)
* Fix compiler warnings related to fields.
2019-10-03 15:58:46 -07:00
Sam El-Husseini
fba98fca5b Move the dropdown field into the dropdown div. (#3122)
* Move the dropdown field into the dropdown div.
2019-10-03 14:35:28 -07:00
Neil Fraser
b46a4fe286 Bring our license format up to date (#3127)
* Google changed from an Inc to an LLC.

This happened back in 2017 but we didn’t notice.  Officially we should update files from Inc to LLC when they are changed as part of regular edits, but this is a nightmare to remember for the next decade.

* Remove project description/titles from licenses

This is no longer part of Google’s header requirements.  Our existing descriptions were useless (“Visual Blocks Editor”) or grossly obselete (“Visual Blocks Language”).

* License no longer requires URL.

* Fix license regexps.
2019-10-02 14:46:56 -07:00
Neil Fraser
76af463ec4 Removing require for Blockly.FlyoutButton
Should have been in the previous PR, since that’s the point.

Also, a recompile given all the recent dependency changes.
2019-09-24 12:15:03 -07:00
Beka Westberg
593383e18a Changed variable field to use configuration (#3065)
* Changed variable field to use new configuration.
2019-09-23 11:14:03 -07:00
alschmiedt
c16ea62b58 A bunch of small bug fixes (#3067) 2019-09-23 08:59:50 -07:00
Sam El-Husseini
9318c370f9 Handle blockly actions on the dropdown fields. (#3064)
* Handle blockly actions on the dropdown fields.
2019-09-20 15:07:35 -07:00
Beka Westberg
e053084621 Changed dropdown field to use new configuration. (#3061) 2019-09-20 13:35:13 -07:00
Sam El-Husseini
c524980f31 Cache dynamic dropdown options (#3036)
* Cache dynamic dropdown options and only re-generate on initialization and render.
2019-09-18 13:05:25 -07:00
Sam El-Husseini
f3f3329355 Fix configure method (#2915)
* Fix configure method.
2019-09-12 17:01:03 -07:00
Sam El-Husseini
8ab51c8639 Remove closure base file dependency (#2976)
* Trim down closure's base dependency even further by removing the dependency on closure's base file.
2019-09-11 17:30:51 -07:00
Sam El-Husseini
f23b659898 Remove this.text_ (#2910)
* Remove this.text_ and have every field handle its own properties.
2019-08-26 10:56:36 -07:00
mirandago
d9d234363c Dropdown scrolls to selected element (#2897)
* Dropdown scrolls to selected element
2019-08-26 10:23:41 -07:00
Sam El-Husseini
ff76ee5b0d Dropdown field with Blockly.Menu (#2832)
* Switch dropdown field from using goog.ui.Menu to Blockly.Menu
2019-08-16 18:22:05 -07:00
Beka Westberg
0872d022e1 Changed utils.fields -> fieldRegistry. Also removed useless tooltip requires. 2019-08-16 09:57:28 -07:00
Beka Westberg
84937a0ff6 Fixed lint error. 2019-08-16 09:57:27 -07:00
Beka Westberg
cdc90f4059 Refactored field utilities. 2019-08-16 09:57:27 -07:00