Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Rectangle selection #5778

Closed
wants to merge 1 commit into from
Closed

Feature: Rectangle selection #5778

wants to merge 1 commit into from

Conversation

ezatsepin
Copy link

This PR contains implementation of the component rectangle selection that allows to select multiple components quickly with the mouse:

rect-selection

You can see demo of the selection logic here: https://jsfiddle.net/eugene23/z35kygc7/

Code example:

editor.on('load', function() {
  initDragSelector(editor);
});

const initDragSelector = (editor) => {
  const canvasFrame = editor.Canvas.getFrameEl();
  const target = editor.getWrapper();

  if (target && canvasFrame) {
    new editor.Utils.DragSelector(editor, target);
  }
}

@artf
Copy link
Member

artf commented Apr 1, 2024

Thanks for the nice PR @ezatsepin but, at the moment, I'm not accepting anything outside of the API changes (eg. UI additions).
The rule of thumb to follow here is, that if you can make it as a plugin, it should be added as a plugin and not part of the core.

As all your code logic is contained in a simple class, you're close to releasing a nice plugin. All you need to do is to create a command for your functionality.

commands.add('area-selector', {
  run(editor) {
    // ...
    this.dragSelector =  new DragSelector(editor, editor.getWrapper());
  },
  stop(editor) {
    this.dragSelector?.destroy();
  },
});

and this is how the consumer can enable/disable it.

editor.runCommand('area-selector');
editor.stopCommand('area-selector');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants