Commit Graph

84 Commits

Author SHA1 Message Date
Neil Fraser
90b3f75d82 Remove @author tags (#5601)
Our files are up to a decade old, and have churned so much, that the initial author of the file no longer has much meaning.

Furthermore, this will encourage developers to post to the developer group, rather than emailing Googlers (usually me) directly.
2021-10-15 09:50:46 -07:00
Neil Fraser
c929b3015b chore: Convert == to === and != to !== where possible. (#5599) 2021-10-15 09:17:04 -07:00
Rachel Fenichel
b25e24fd02 chore: Run clang-format on core/*.js (#5589)
* Run clang-format on core/*.js

* Revert changes for css formatting
2021-10-07 10:32:02 -07:00
Christopher Allen
d2d5dc4b71 fix: Use require instead of requireType for interfaces (#5568)
But only if the interface is used in an @implements or @extends
declaration.

Fixes #5450
2021-09-29 17:44:21 +01:00
Monica Kozbial
49bc2b1ae4 Replace namespace annotation with class annotation in files that define a class (#5566) 2021-09-28 15:57:09 -07:00
Monica Kozbial
d8fbe1b05b Add namespace and alias annotations to jsdoc (#5550)
* Add annotations to files under core/events

* Add annotations to files under core/interfaces

* Add annotations to files under core/keyboard_nav

* Add annotations to files under core/renderers

* Add annotations to files under core/serialization

* Add annotations to files under core/theme

* Add annotations to files under core/toolbox

* Add annotations to files under core/utils

* Add annotations to files under core
2021-09-27 14:42:54 -07:00
alschmiedt
2b34748e0e chore: remove declareLegacyNamespace from events (#5532)
- Adds an extra events/utils.js file to hold helper methods related to events.
2021-09-24 14:20:32 -07:00
Rachel Fenichel
3adfaaf6d9 chore: named exports for block* files (#5512)
* chore: named export for block.js

* chore: named export for block_drag_surface.js

* chore: named export for block_dragger.js

* chore: named export for block_svg.js

* Fix import ordering

* chore: fix imports using requireType

* Remove extra require
2021-09-22 08:46:19 -07:00
Aaron Dodson
d6c9423bdf Remove declareLegacyNamespace from block-related files. 2021-09-21 13:18:07 -07:00
Rachel Fenichel
f4430e9e47 Move bump objects function into a separate module (#5453)
* Move bump objects function into a separate module

* Fix types

* Update core/bump_objects.js

Fix missing newline.

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>

Co-authored-by: Christopher Allen <cpcallen+github@gmail.com>
2021-09-14 10:02:38 -07:00
Christopher Allen
4c40378b9a Use goog.requireType when importing interfaces (etc.) (#5343)
* Use goog.requireType when importing I* interfaces

Interfaces have no code, so should never be referred to outside of
(JSDoc) comments, and so the modules that define only interfaces never
need to be goog.require'd - goog.requireType is always sufficient.

This commit fixes imports of all modules whose name matches
/(.*\.)?I[A-Z]*/ - i.e., the hungarian-notation named ones in
core/interfaces/.

* Use goog.requireType when only using import for type specifications

Where a module is imported only to used in JSDoc comments it can
(and should) be goog.requireType'd instead of goog.require'd.

* Remove spurious eslint-disable no-unused-vars

There were a few cases where modules were being imported with
goog.require (because they are referred to in code, not just JSDoc
comments) but were prefaced by a spurious eslint suppress.

Remove these, restoring the invariant that an import gets an eslint
if and only if it is a requireType.

* Remove obsolete Closure Compiler error group

stricterMissingRequire has been superceded by missingRequire, and now
causes a Java null pointer exception if supplied.
2021-08-11 18:50:45 +01:00
Rachel Fenichel
7bc461ea83 polish: export draggingConnections directly 2021-08-04 17:17:24 -07:00
Rachel Fenichel
d5a6d7d3db Move draggingConnections to common 2021-08-04 15:59:41 -07:00
alschmiedt
f88320770c Remove unnecessary require 2021-07-23 12:16:00 -07:00
alschmiedt
2688329aef Fix imports 2021-07-23 12:12:59 -07:00
alschmiedt
c838b0e27c Reorder requires 2021-07-23 12:00:35 -07:00
alschmiedt
848ec34a0a clang-format core/block_dragger.js 2021-07-23 12:00:35 -07:00
alschmiedt
873b75e58a Migrate core/block_dragger.js named requires 2021-07-23 12:00:35 -07:00
alschmiedt
4850ad0300 Migrate core/block_dragger.js to goog.module 2021-07-23 12:00:35 -07:00
alschmiedt
fc10f9e625 Migrate core/block_dragger.js to ES6 const/let 2021-07-23 12:00:35 -07:00
Monica Kozbial
34fce2c1cb Moves toolbox cursor styling out of block_dragger (#4896) 2021-06-11 18:02:40 -07:00
Maribeth Bottorff
5a1533d1b0 Creates getLocationAfterMove in BlockDragger (#4905)
* Add getLocationAfterMove method to block dragger

* Renames and addresses comments
2021-06-11 17:32:27 -07:00
Monica Kozbial
a17cb7f12e Adding parameter to dragEnter and dragExit (#4890)
* introduce IDraggable interface
* Add parameter to drag methods in IDragTarget
* combines bubble/drag methods on IDragTarget and IDeleteArea to take an IDraggable element
2021-06-11 12:58:26 -07:00
Monica Kozbial
8aeb78eff3 Revert bubble dragger logic change and helper name change (#4897)
* Revert accidental change in bubble drag logic

* Revert name change
2021-06-11 11:10:39 -07:00
alschmiedt
566b14e15f Fixes block dragger after merge (#4895) 2021-06-10 16:54:33 -07:00
Monica Kozbial
2005576036 Add onDragOver and wouldDelete_ to DeleteArea (#4888)
* keep track of state for whether the block or bubble would be deleted for use with drag enter exit

* Check if block and bubble is deletable in IDeleteArea

* Add to jsdoc of IDeleteArea
2021-06-10 16:27:04 -07:00
Monica Kozbial
e40093dc23 Add API to IDragTarget to prevent block move (#4886) 2021-06-10 16:17:07 -07:00
alschmiedt
9eaca6a1e1 Adds necessary methods for scroll-options plugin (#4893) 2021-06-10 15:50:42 -07:00
Monica Kozbial
77dddca02e Fix bug with updating cursor style in draggers (#4889) 2021-06-10 10:57:09 -07:00
Monica Kozbial
d2c61d5735 Prevent uncessary add/remove class calls on cursor during drag (#4885) 2021-06-09 19:20:47 -07:00
Monica Kozbial
11390341b1 Adding IDragTarget support. (#4852) 2021-06-09 13:59:22 -07:00
Neil Fraser
d919b0af21 Update JSDoc from Array.<> to Array<>
Same with Object.
2021-05-27 21:30:26 -07:00
Sam El-Husseini
63d26dc186 Add extra requires check (#4677)
* Add extra requires check
2021-03-05 09:50:51 -08:00
Sam El-Husseini
f97730e83c Sort requires (#4658)
* Cleanup gulp method to sort requires
2021-02-25 17:17:42 -08:00
Sam El-Husseini
ab8a11784d Fix event related missing requires (#4656)
* Fix event related missing requires
2021-02-25 14:28:11 -08:00
Rachel Fenichel
40928634e5 Add some missing requires and requireTypes 2021-01-08 15:03:55 -08:00
Monica Kozbial
637497148d Renaming ui event properties and updating documentation for consistency (#4432)
* Renaming properties and updating documentation for consistency

* Update more properties

* fix tests
2020-11-05 11:40:17 -08:00
Monica Kozbial
40ef586260 Refactoring Ui events in core (#4418)
* Ui events base (#4370)

* Add constants for new ui event types

* Add property to indicate an event as UI event

* Click events (#4372)

* Creating new ui base class.

* Refactor theme event (#4391)

* Add themeName property to theme event

* Refactor marker move events. (#4389)

* Refactor trashcan open event (#4392)

* Refactor selected event (#4387)

* Refactor toolbox item change event (#4394)

* Refactor bubble open events (#4390)

* Refactor block drag event (#4388)

* Viewport events (#4395)

* Fix event filtering for ui events (#4401)

* Move events to new directory and rename Ui events base (#4400)

* Move events to new directory and rename Ui events base

* Add missing fromJson implementation for click event (#4410)

* Adding serialization tests for events

* Zoom controls event (#4407)

* Refactor zoom event

* Rename IS_UI_EVENT to isUiEvent
2020-11-04 14:43:54 -08:00
Sam El-Husseini
fba35d342c Add missing require Blockly.constants (#4366) 2020-10-12 17:56:42 -04:00
Monica Kozbial
12b5658109 Rename trashcan api calls for open/close lid. (#4110)
* Rename trashcan api calls for open/close lid.

* Update comments.
2020-08-05 12:25:35 -07:00
alschmiedt
b2650e6cef Update availble connections when we have unplugged a block (#3954)
* Update availble connections when we have unplugged a block
2020-06-11 10:50:23 -07:00
alschmiedt
14479fd7e2 Update Toolbox Interface (#3934)
* Update toolbox interface
2020-06-08 09:17:38 -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
14428a0da4 Fix two memory leaks (#3747)
* Fix two memory leaks
2020-03-13 14:49:08 -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
Neil Fraser
123f436e04 Add parens around inline assignments (#3381) 2019-10-31 15:17:35 -07:00
Sam El-Husseini
d387841db2 Resolve remaining compiler warnings with visibility issues (#3335) 2019-10-24 19:13:51 -04:00
Sam El-Husseini
52bef4463c Fix warnings related to connections. (#3306)
* Fix warnings related to connections.
2019-10-23 17:56:52 -04:00
Sam El-Husseini
270781113d Fix warnings related to gestures and drag. (#3307)
* Fix warnings related to gestures and drag.
2019-10-22 14:21:00 -04:00
Navil Perez
c0784a61e7 Linting Fix 2019-10-17 15:23:10 -07:00