Draft: CodeMirror over Yjs prototype #1005
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a prototype of how to use Yjs in CryptPad to achieve local-first editing for the
codeapplication.This PR is to document and discuss the prototype, it is not meant to be merged.
Setup
To try out this prototype, you currently need to run two components:
the modified CryptPad instance and the Yjs backend that serves the websocket requests.
1.1. Clone and checkout this fork (
yjs)1.2.
npm i1.3.
npm run dev2.1. Clone https://github.com/theova/y-websocket and checkout the branch
crypto2.2.
npm i2.3.
npm startIn a later step, the Yjs backend should be integrated into the CryptPad server, so that only one component has to be started.
Bundle Yjs
Yjs cannot be installed straightforward via bundle and does not provide minified versions.
We therefore bundle Yjs and the required components (including y-websocket and y-codemirror 5).
The "factory" is in
scripts/yjs/yjs_bundle.js.To bundle this to a minified version (
www/lib/yjs_bundle.js) runnpm run bundle-yjs.Problems/Simplifications
This prototype is heavily simplifed, due to the complexity of the codebase, but not due to natural limitations.
The simplifications include:
codeapplication (e.g., cryptpad.fr/code/)localhost:3000/code, the resultingeditKeyStris not the same as the one coming from the generated URL hash. After a reload, this is fixed.