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

[Suggestions for collaborative editing scenario] Reconstruct read-only mode logic #2265

Closed
lijie1129 opened this issue Feb 4, 2023 · 1 comment

Comments

@lijie1129
Copy link

lijie1129 commented Feb 4, 2023

Current situation

When the editor switches the read-only mode, it will perform the following two sub-actions:

  1. Clear all blocks
  2. Render the blocks you just cleared again

This is very unfriendly to the experience of collaborative editing scenes

Impact on the data layer

Whether the data layer of the collaborative editing scenario listens for data changes through onchange or DOM Mutation API, when the editor performs the first sub-action of switching read-only mode, the data layer will immediately send a message to clear all blocks to the back-end service, which will also cause the back-end service to immediately clear all blocks data; When the editor completes the second sub-action of switching read-only mode, it will cause the data layer to immediately send the message of all blocks before adding to the back-end service, which will cause the back-end service to add the blocks data just cleared back to the database.

What problems will this cause?

  1. Lost history details

In the collaboration scenario, we need to know which user added what content, for example, user x added hello and user y added world. We can easily distinguish this information in the collaborative data layer.
However, after the editor has performed at least one read-only mode switch, the above information will be lost.

  1. Unnecessary network data transmission

When the editor switches to the read-only mode, it is unnecessary to waste performance and resources by clearing all blocks data and adding back all blocks data to the back-end service.

Solution

  1. Open a new mandatory API for all plug-ins, requiring plug-ins to implement read-only mode by themselves
  2. The editor reconstructs the current logic of switching to read-only mode. Only when the plug-in does not implement the API of switching read-only mode by itself, it only performs the default action of switching read-only mode for specific blocks: try to remove the contenteditable attribute in the default container
@lijie1129
Copy link
Author

The current issue is duplicated with #2467, please refer to #2467 for details.

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

No branches or pull requests

1 participant