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

refactor: support multiple-editors #5878

Merged
merged 17 commits into from
Jan 2, 2024

Conversation

AyushAgrawal-A2
Copy link
Contributor

@AyushAgrawal-A2 AyushAgrawal-A2 commented Dec 27, 2023

continuation of #5765

closes #5625
closes #5153

Changes:

  1. Completed pending cleanup global querySelectors and events

  2. UIEventDispatcher:
    I tried moving events from document to editorHost, but there were few events which will originate from the document only. In multiple editor scenario each editor needs to be aware whether it is active or not, and respond to events only is it active.

    I have added a static field on UIEventDispatcher, which stores which dispatcher and thus which editor is active. It will run event handlers only if it is active.

    • The editor gets activated when the selection changes to an element inside the editor or the user clicks inside the editor.
    • The editor gets deactivated If there is a selection change to an element outside the editor.
    • There are a few overlays appended to document.body. I have added class "blocksuite-overlay" to these elements. If the user interacts with any such element the state will not change, i.e. the previous active editor which created the overlay will remain active.
  3. For ease of testing of all three scenarios, added examples of independent multiple editors - doc-doc, doc-edgeless & edgeless-edgeless at

    • /examples/multiple-editors/doc-doc/
    • /examples/multiple-editors/doc-edgeless/
    • /examples/multiple-editors/edgeless-edgeless/

Copy link

vercel bot commented Dec 27, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 29, 2023 6:55pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
blocksuite-docs ⬜️ Ignored (Inspect) Visit Preview Dec 29, 2023 6:55pm

@AyushAgrawal-A2 AyushAgrawal-A2 marked this pull request as draft December 27, 2023 12:28
@AyushAgrawal-A2
Copy link
Contributor Author

AyushAgrawal-A2 commented Dec 29, 2023

The starter/init=multiple-editor works great! but here's my recording running the doc-doc one:

Screen.Recording.2023-12-30.at.02.13.12.mov

@doodlewind is the same issue occurring for doc-edgeless , edgeless-edgeless as well ?

Copy link
Member

@doodlewind doodlewind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AyushAgrawal-A2 I double checked and all examples work now, that's awesome!

Generally LGTM but for some updates in block-std, I'd require @Saul-Mirone for better review.

These entries are also great, I also plan to use similar entry in the newly added https://blocksuite.io/doc-editor.html and https://blocksuite.io/edgeless-editor.html doc pages.

Copy link
Member

@doodlewind doodlewind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should land this, happy new year!

@doodlewind doodlewind merged commit 0f0fa59 into toeverything:master Jan 2, 2024
19 checks passed
@AyushAgrawal-A2 AyushAgrawal-A2 deleted the ayush/5625 branch January 2, 2024 08:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
notable Major improvement worth emphasizing
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

multiple-editor Uncaught Error: val does not exist playground example "multiple-editor" not working
3 participants