Commit Graph

1814 Commits

Author SHA1 Message Date
Ben Henning
0772a29824 feat!: Introduce new focus tree/node functions.
This introduces new callback methods for IFocusableTree and
IFocusableNode for providing a basis of synchronizing domain state with
focus changes. It also introduces support for implementations of
IFocusableTree to better manage initial state cases, especially when a
tree is focused using tab navigation.

FocusManager has also been updated to ensure functional parity between
tab-navigating to a tree and using focusTree() on that tree. This means
that tab navigating to a tree will actually restore focus back to that
tree's previous focused node rather than the root (unless the root is
navigated to from within the tree itself). This is meant to provide
better consistency between tab and non-tab keyboard navigation.

Note that these changes originally came from #8875 and are required for
later PRs that will introduce IFocusableNode and IFocusableTree
implementations.
2025-04-21 20:42:28 +00:00
RoboErikG
a2d76216b2 Feature: Add a dropdown options setter (#8833)
* Feature: Add a setOptions method to field_dropdown

* add test for changing droopdown options

* split out setOptions tests into their own test suite

* Add additional tests

* auto format files
2025-04-17 12:03:35 -07:00
Aaron Dodson
fd9263ac51 feat: Allow for HTML elements in dropdown field menus. (#8889)
* feat: Allow for HTML elements in dropdown field menus.

* refactor: Use dot access.
2025-04-15 14:34:38 -07:00
Rachel Fenichel
fac75043dd feat: add loopback in cursor navigation, and add tests (#8883)
* chore: tests for cursor getNextNode

* chore: add tests for getPreviousNode

* feat: add looping to getPreviousNode and getNextNode

* chore: inline returns

* chore: fix test that results in a stack node

* chore: fix annotations
2025-04-14 09:58:58 -07:00
Rachel Fenichel
3160e3d321 feat: add getFirstNode and getLastNode to cursor with tests (#8878)
* feat: add getFirstNode and getlastNode to line_cursor.ts

* chore: add simple tests for getFirstNode and getLastNode

* chore: broken tests for debugging

* chore: additional cursor tests

* chore: lint, format, reenable tasks
2025-04-11 10:13:10 -07:00
Maribeth Moffatt
89194b2ead fix: check potential variables for flyout variable fields (#8873)
* fix: check potential variables for flyout variable fields

* fix: format

* chore: move comment
2025-04-07 17:29:00 -07:00
Ben Henning
17171abf1c Merge pull request #8814 from BenHenning/introduce-focus-system-implementation
feat: Introduce FocusManager implementation
2025-04-03 16:20:49 -07:00
Ben Henning
c5404af82e chore: lint fixes. 2025-04-03 23:04:06 +00:00
Ben Henning
720e8dab2b chore: part 2 of addressing reviewer comments. 2025-04-03 22:55:35 +00:00
Ben Henning
902b26b1a1 chore: part 1 of addressing reviewer comments. 2025-04-03 22:25:50 +00:00
Aaron Dodson
ca362725ee refactor!: Backport LineCursor to core. (#8834)
* refactor: Backport LineCursor to core.

* fix: Fix instantiation of LineCursor.

* fix: Fix tests.

* chore: Assauge the linter.

* chore: Fix some typos.

* feat: Make padding configurable for scrollBoundsIntoView.

* chore: Merge in the latest changes from keyboard-experimentation.

* refactor: Clarify name and docs for findSiblingOrParentSibling().

* fix: Improve scrollBoundsIntoView() behavior.

* fix: Export CursorOptions.

* refactor: Further clarify second parameter of setCurNode().

* fix: Revert change that could prevent scrolling bounds into view.
2025-04-03 12:15:17 -07:00
Ben Henning
3dc4d17b30 Update tests/mocha/index.html 2025-03-27 16:54:19 -07:00
Ben Henning
9ab77cedff chore: fix formatting issues 2025-03-27 22:04:51 +00:00
Ben Henning
516e3af936 feat: finish core impl + tests
This adds new tests for the FocusableTreeTraverser and fixes a number of
issues with the original implementation (one of which required two new
API methods to be added to IFocusableTree). More tests have also been
added for FocusManager, and defocusing tracked nodes/trees has been
fully implemented in FocusManager.
2025-03-27 21:57:30 +00:00
Ben Henning
d9beacddb4 feat: add FocusManager
This is the bulk of the work for introducing the central logical unit
for managing and sychronizing focus as a first-class Blockly concept
with that of DOM focus.

There's a lot to do yet, including:
- Ensuring clicks within Blockly's scope correctly sync back to focus
  changes.
- Adding support for, and testing, cases when focus is lost from all
  registered trees.
- Testing nested tree propagation.
- Testing the traverser utility class.
- Adding implementations for IFocusableTree and IFocusableNode
  throughout Blockly.
2025-03-21 00:33:51 +00:00
Aaron Dodson
b8f71b83b7 Merge branch 'rc/v12.0.0' into develop-v12-merge 2025-03-11 09:42:25 -07:00
Aaron Dodson
34da1da061 fix: Fix flaky connection checker test. (#8754) 2025-01-31 08:10:33 -08:00
Aaron Dodson
343c2f51f3 feat: Add support for toggling readonly mode. (#8750)
* feat: Add methods for toggling and inspecting the readonly state of a workspace.

* refactor: Use the new readonly setters/getters in place of checking the injection options.

* fix: Fix bug that allowed dragging blocks from a flyout onto a readonly workspace.

* feat: Toggle a `blocklyReadOnly` class when readonly status is changed.

* chore: Placate the linter.

* chore: Placate the compiler.
2025-01-30 13:47:36 -08:00
Ben Henning
94794af02f Merge branch 'develop' into improve-workspace-svg-test-robustness 2025-01-16 22:16:01 +00:00
Aaron Dodson
7a23c8878f fix: Actually fix the browser tests. (#8736) 2025-01-16 11:02:49 -08:00
Aaron Dodson
a86ba15154 fix: Fix the browser tests. (#8735) 2025-01-16 10:37:24 -08:00
Aaron Dodson
bcdb65c623 release: Merge branch 'develop' into rc/v12.0.0 2025-01-10 10:53:09 -08:00
Aaron Dodson
80a6d85c26 refactor!: Use JSON instead of XML for defining dynamic toolbox categories. (#8658)
* refactor!: Use JSON instead of XML for defining dynamic toolbox categories.

* chore: Fix tests.

* chore: Remove unused import.

* chore: Update docstrings.

* chore: Revert removal of XML-based category functions.

* chore: Add deprecation notices.
2025-01-08 11:50:18 -08:00
Aaron Dodson
77c695a648 fix: Paste blocks copied from a mutator into the mutator. (#8719) 2025-01-06 11:19:23 -08:00
Aaron Dodson
bd7c86a909 chore: Improve code health of generator tests. (#8703) 2025-01-06 10:55:57 -08:00
Aaron Dodson
b8bb26f8fd fix: Fix serialization of the lists_split block. (#8702) 2025-01-06 10:54:33 -08:00
Ben Henning
9283c4e6e8 Improve the robustness of workspace SVG tests.
This largely reduces the dependence on direct value testing and instead
updates clean-up tests to verify logic based on relative positioning.
This guards against potential system-specific flakes that can occur when
there are subtle calculation differences on different systems.
2024-12-06 00:33:58 +00:00
Aaron Dodson
9fcd5a3037 release: Merge branch 'rc/v11.2.0' into rc/v12.0.0 2024-12-04 12:06:12 -08:00
Christopher Allen
4680b4b5c1 test: Disable failing tests (#8677)
See issue #8676.
2024-12-04 09:30:22 -08:00
Aaron Dodson
24ab50d49d fix: Fix bug that caused text to be selected when long-pressing in the workspace on a touch device. (#8670)
* fix: Fix bug that caused text to be selected when long-pressing in the workspace on a touch device.

* chore: Fix test failure.
2024-12-03 13:41:32 -08:00
Aaron Dodson
5870c66cf0 chore: Migrate ESLint configuration file to new flat format. (#8675)
* chore: rename .eslintrc.js to eslint.config.js

* chore: Rename eslint.config.js to eslint.config.mjs.

* refactor: Migrate ESLint config to new flat format.

* chore: Remove old per-directory and global ignore ESLint config files.

* fix: Allowlist JSDoc tag aliases.

* fix: Don't require @license in tests/*.

* fix: Add NodeJS globals to several files that run under Node.

* chore: Remove now-unneeded ESLint directives in core.

* chore: Remove invalid/unneeded ESLint directives.

* fix: Fix invalid use of `await` outside of an `async` function.

* fix: Improve screenshot error message.

* fix: Update ESLint config file to not warn on existing violations.

* chore: Remove suppressions of rules that weren't triggering.

* chore: Fix package-lock.json.
2024-12-03 12:40:48 -08:00
Aaron Dodson
61bbd7dbf6 chore: Remove underscores from private fields. (#8682)
* chore: Remove underscores from private fields.

* refactor: Use public APIs in tests where possible.
2024-12-02 11:33:05 -08:00
Aaron Dodson
ae2a140141 refactor!: Use one map for toolbox contents. (#8654) 2024-11-12 09:52:23 -08:00
Aaron Dodson
d804c1a3c4 refactor!: Improve ability to use CSS to style Blockly. (#8647)
* refactor!: Rename blocklyTreeIconClosed to blocklyToolboxCategoryIconClosed.

* refactor!: Rename blocklyTreeLabel to blocklyToolboxCategoryLabel

* refactor!: Rename blocklyToolboxDiv to blocklyToolbox.

* refactor: remove unreferenced CSS classes.

* refactor!: Remove the blocklyArrowTop and blocklyArrowBottom classes.

* feat: Add a blocklyTextInputField class to text fields.
2024-11-07 12:16:17 -08:00
Aaron Dodson
2523093cc9 refactor!: Remove the InsertionMarkerManager. (#8649)
* refactor!: Remove the InsertionMarkerManager.

* chore: Remove unused imports.

* chore: Remove import of insertion marker manager test.
2024-11-07 12:15:55 -08:00
Aaron Dodson
aedcfd6da5 fix: Use a readonly textarea for non-editable comments. (#8632)
* fix: Use a readonly textarea for non-editable comments.

* chore: Run formatter.

* chore: remove old function definition
2024-11-04 09:43:17 -08:00
Aaron Dodson
e777086f16 refactor!: Update flyouts to use inflaters. (#8601)
* refactor: Update flyouts to use inflaters.

* fix: Specify an axis when creating flyout separators.

* chore: Remove unused import.

* chore: Fix tests.

* chore: Update documentation.

* chore: Improve code readability.

* refactor: Use null instead of undefined.
2024-10-02 09:20:45 -07:00
Aaron Dodson
e5c1a89cdf fix: Fix bug that caused fields in the flyout to use the main workspace's scale. (#8607)
* fix: Fix bug that caused fields in the flyout to use the main workspace's scale.

* chore: remove errant param in docs.
2024-10-02 08:18:47 -07:00
John Nesky
8d44a4d93a fix: Group field validator changes with field value changes. (#8589) 2024-09-24 16:09:41 -07:00
Ben Henning
05795a06ea Rename 'tidyUp' back to 'cleanUp'. 2024-09-03 23:13:50 +00:00
Ben Henning
fbafda3e4c Merge branch 'develop' into ensure-immovable-blocks-are-considered-during-workspace-tidying 2024-09-03 23:02:37 +00:00
Christopher Allen
2409123d66 refactor: Omit unused exception arguments from catch blocks (#8559)
Fixes #1770.
2024-09-03 15:27:40 +01:00
Christopher Allen
724828f689 refactor: Use arrow functions when calling Array.prototype.filter (#8557) 2024-08-30 17:23:23 +01:00
Christopher Allen
a7afda8343 fix(events): Simplify filter function, add new enqueueEvent function (#8539)
* docs(events): JSDoc improvments

* fix(filter): Introduce enqueueEvent; don't reorder in filter

  Remove the broken BlockChange event reordering code from filter.
  Instead, do necessary event reordering (correctly, this time)
  in a new enqueueEvent function used by fireInternal.

* chore(events): Deprecate forward parameter of filter

  Since we don't filter in undo any more, and filtering in reverse
  order causes problems, prepare to remove this opportunity for
  error.

* fix(events): Only merge adjacent events

  Simplify filter by having it consider only adjacent events in the
  queue for merging.

  Previously any events in the queue could potentially be merged if
  they were of suitable (typically identical) .type, even if other
  events had occurred between them (with the sole exception of
  BlockMove events, which would only be merged with adjacent
  events).  This could potentially result in replay failures during
  undo/redo/mirroring, though it is unknown whether any such
  problems occurred in practice.

* refactor(events): Tweaks

  - Use for…of loop where appropriate.
  - Make filter reason-merging code more concise.
  - Use arrow functions when calling Array.prototype.filter.

* chore(events): Fix typos for PR #8539.
2024-08-29 17:41:54 +01:00
John Nesky
095f29e274 fix: Detect if deleting shadow block affects selection highlight (#8533)
* fix: Detect if deleting shadow block affects selection highlight

* Use contains instead of descendsFrom for html consistency.

* Added tests.

* Removing and manually inlining new contains function.
2024-08-26 12:22:37 -07:00
Ben Henning
348a5b33b8 Addressed self-review comment. 2024-08-22 18:00:22 +00:00
Ben Henning
0413021b7c Auto-fix formatting issues to address CI failure. 2024-08-21 21:02:07 +00:00
Ben Henning
ca42a4b4fd Merge branch 'develop' into ensure-immovable-blocks-are-considered-during-workspace-tidying 2024-08-21 17:44:37 +00:00
Ben Henning
3a3e83fe44 Fix workspace clean up not considering immovables.
At a high-level, this change ensures that cleaning up a workspace
doesn't move blocks in a way that overlaps with immovable blocks. It
also adds missing testing coverage for both Rect (used for bounding box
calculations during workspace cleanup) and WorkspaceSvg (for verifying
the updated clean up functionality).

This also renames the clean up function to be 'tidyUp' since that better
suits what's happening (as opposed to other clean-up routines which are
actually deinitializing objects).
2024-08-21 17:41:38 +00:00
Christopher Allen
7ccdcc5cef refactor(events): introduce EventType enum in separate module (#8530)
* refactor(events): Use "export ... from" where applicable

* refactor(events): Introduce EventType enum

  Introduce an enum for the event .type values.  We can't actually
  use it as the type of the .type property on Abstract events,
  because we want to allow developers to add their own custom
  event types inheriting from this type, but at least this way we
  can be reasonably sure that all of our own event subclasses have
  distinct .type values—plus consistent use of enum syntax
  (EventType.TYPE_NAME) is probably good for readability overall.

  Put it in a separate module from the rest of events/utils.ts
  because it would be helpful if event utils could use

      event instanceof SomeEventType

  for type narrowing but but at the moment most events are in
  modules that depend on events/utils.ts for their .type
  constant, and although circular ESM dependencies should work
  in principle there are various restrictions and this
  particular circularity causes issues at the moment.

  A few of the event classes also depend on utils.ts for fire()
  or other functions, which will be harder to deal with, but at
  least this commit is win in terms of reducing the complexity
  of our dependencies, making most of the Abstract event subclass
  module dependent on type.ts, which has no imports, rather than
  on utils.ts which has multiple imports.
2024-08-20 08:36:33 +01:00