Commit Graph

188 Commits

Author SHA1 Message Date
Beka Westberg
111b47980d Fix toolbox sizes not being updated properly (#4139)
* Fix toolbox changing size

* Fix flyout changing size

* Fix mutator bumping blocks

* Fix accessing .flyout_
2020-08-13 08:19:40 -07:00
alschmiedt
0f00f42580 Adds Ability to Add a Flyout as a Plugin (#4059) 2020-07-22 17:13:19 -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
Monica Kozbial
bd887665b8 Handle undefined colour (#3997) 2020-06-29 10:47:24 -07:00
Sam El-Husseini
9e7f3b07e9 Advanced compilation fixes (#3995)
* Advanced compilation fixes
2020-06-25 11:59:03 -07:00
alschmiedt
d91b5038c3 Revert not closing the flyout for a tree separator (#3944) 2020-06-09 10:27:06 -07:00
alschmiedt
14479fd7e2 Update Toolbox Interface (#3934)
* Update toolbox interface
2020-06-08 09:17:38 -07:00
alschmiedt
00df97a59d Add plugin options (#3922)
* Adds a plugin through options

* Fix requires

* Fix pr comments
2020-05-29 13:22:25 -07:00
Sam El-Husseini
1052f7548b Enable unusedPrivateMembers check (#3924)
* Add unusedPrivateMembers check
2020-05-28 17:44:16 -07:00
alschmiedt
6bc60894db Toolbox interface (#3918)
* Add toolbox interface
2020-05-27 10:06:18 -07:00
Sam El-Husseini
317834ff59 Add accessibility interfaces and fix navigation types (#3908)
* Add accessibility interfaces and fix navigation types
2020-05-21 11:18:10 -07:00
alschmiedt
d0e91a15a2 Toolbox definition (#3891)
* Add support for creating a toolbox with JSON
2020-05-13 08:16:53 -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
alschmiedt
16e6735748 Cleanup (#3848)
* General Toolbox Cleanup
2020-04-22 09:57:19 -07:00
Sam El-Husseini
eb07793ba8 Cleanup Blockly UI components. (#3723)
* Cleanup Blockly UI components. Remove unnecessary getters
2020-03-11 10:40:16 -07: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
a9e10807ca Support extending themes with a base theme property. (#3731)
* Support extending themes with a base theme property.
2020-03-10 10:30:13 -07: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
alschmiedt
ee9a55ec79 Fix flyouts (#3645)
* Set toolboxPosition after options have been parsed

* Final toolbox position update
2020-01-23 14:23:25 -08:00
Sam El-Husseini
70f42b3395 Fix parsing and passing of workspace options around Blockly (#3616) 2020-01-21 13:29:03 -08:00
Monica Kozbial
c84ee46a89 Setting default options in workspace constructor. (#3592)
* Setting default options in workspace constructor.

* Changing logic for parsing workspace options.

* Adding gridPattern declaration to options and updating options handling for workspace.

* Addressing PR comments.

* Moving objects to constructor.

* Using constructor instead of casting for Blockly.Options.

* fix eslint

* Adding types.

* Change in type.

* eslint fix.

* Fix typings.
2020-01-17 15:16:20 -08:00
alschmiedt
a1ed9ab791 Update component names (#3549) 2020-01-06 13:18:15 -08:00
Sam El-Husseini
55997784ca Move blockStyles into constants (#3485)
* Move blockStyles into constants.
2019-12-06 10:51:36 -08:00
Rachel Fenichel
13e4d671c3 Moved setHighlighted and setDisabled into the path object. 2019-11-01 14:28:51 -07:00
Neil Fraser
123f436e04 Add parens around inline assignments (#3381) 2019-10-31 15:17:35 -07:00
alschmiedt
cbf867f441 Add keyboard navigation support for multiple workspaces (#3352)
* Add keyboard navigation support for multiple workspaces
2019-10-28 12:53:51 -07:00
Sam El-Husseini
4f02ceeba0 Make Blockly options an interface (#3312)
* Make workspace options an interface so it can be extended in the d.ts.
2019-10-22 14:20:26 -04:00
Sam El-Husseini
3c2c4677df Fix 55 warnings related to flyouts. (#3211)
* Fix 55 warnings related to flyouts.
2019-10-16 12:13:37 -05:00
Sam El-Husseini
986e965be8 Private/protected visibility cleanup (#3263)
* Fix a number of private visibility issues
2019-10-16 11:48:09 -05: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
alschmiedt
468b673b73 Fix bugs (#3108)
* Fix various bugs around keyboard nav
2019-09-27 14:34:28 -07:00
Sam El-Husseini
870824bc3e Workspace theme (#3093)
* Move the theme object so it's on the workspace.

* Add support for subscribing UI elements to theme component styles and changes.
2019-09-26 16:52:17 -07:00
Neil Fraser
75cf614104 Break CSS into modules. (#3084)
* Break CSS into modules.

Drops the compile test by 3 KB.
Remove obsolete .blocklyDraggable class stub (it used to be dynamically changed).
Remove unused menuseparator CSS.
2019-09-25 18:01:19 -07:00
Rachel Fenichel
269f0dc381 Enable eslint rule spaced-comment
Fix up all remaining violations and turn the rule on.
2019-09-25 16:04:05 -07:00
Neil Fraser
a03660243e Code cleanup, drop some CSS.
Random improvements to require statements.

Removal of some obviously dead CSS.

.blocklyDropDownDiv no longer supresses text selection (see comment in PR).

This PR drops the compiled size by 4 KB, which is larger than I was expecting.
2019-09-25 10:34:34 -07:00
Neil Fraser
ddb8e46b87 Make flyouts be optional modules.
No Blockly instances need both Horizontal and Vertical flyouts.  Dropping one of these saves 2 KB.  Some don’t need flyouts at all (e.g. Blockly Games Puzzle or readonly documentation blocks).
2019-09-23 22:02:59 -07:00
Neil Fraser
b84cda2c76 Strip out more bloat from toolbox (#3068)
Also removes three private accesses from workspaceSvg into toolbox tree.

The strategy for workspace.updateToolbox is no longer to clear and repopulate the toolbox, but rather to throw away the old toolbox and rebuild a new one.  This is simpler and more reliable.

This commit trims off another KB from the compiled code.
2019-09-23 15:18:32 -07:00
alschmiedt
f3b4fc0732 Fix interaction between mouse and keyboard (#3070) 2019-09-23 11:07:59 -07:00
Neil Fraser
fb17b0276d Remove unused CSS classes. 2019-09-20 10:36:06 -07:00
Sam El-Husseini
cb564053b3 Merge toolbox navigation (#3054)
* Merge both types of keyboard navigation (with and without accessibility mode).
2019-09-19 16:36:39 -07:00
Sam El-Husseini
e339ae26bc Move the rendering object to live on the workspace_svg (#3016)
* Move the rendering object onto the workspace allowing the various workspaces to have different renderers.
2019-09-13 14:20:34 -07:00
Sam El-Husseini
fc420b7037 Support for registering renderers and switching between them (#3013)
* Added support for registering renderers and for choosing which renderer the workspace wants to use.
2019-09-13 10:30:20 -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
Neil Fraser
096959fde9 Cleanup of last fortnight’s commits. (#2865)
No functional changes.
2019-08-19 14:07:48 -07:00
Sam El-Husseini
f118d6de88 No closure toolbox (#2819)
* Update the toolbox to not rely on closure and instead use the built in Blockly.tree component
2019-08-14 13:48:21 -07:00
Neil Fraser
aca1a43ec8 Fix regular expressions.
1) Simplifications.
2) Enable toolbox category colours to be specified using the full range of CSS formats (not just hue or #rrggbb).
3) Fix bug where `Blockly.utils.checkMessageReferences('%{BKY_today}  %{BKY_xxx}')` returns true.
2019-06-10 11:03:22 -07:00
Neil Fraser
6947010c49 Change Rect to use top/bottom/left/right
Instead of top/left/height/width.  Given our uses of Rect, it makes the math slightly simpler.

This is a setup for using Rect in other places.  Currently it is only used to describe delete areas.
2019-06-07 10:32:57 -07:00
Neil Fraser
d1a29739d8 Move utilities into own directory.
TODO: There are more functions which may be migrated into dom and string.
2019-06-07 10:32:57 -07:00
Neil Fraser
f2c57dea1b Remove goog.math.Rect dependency 2019-06-07 10:32:57 -07:00
Neil Fraser
e8d8798ecf Remove goog.events.BrowserFeature dependency. 2019-06-07 10:32:57 -07:00