Skip to content
This repository has been archived by the owner on Sep 26, 2022. It is now read-only.

paperclip-editor #1030

Open
8 tasks
crcn opened this issue Jan 12, 2022 · 1 comment
Open
8 tasks

paperclip-editor #1030

crcn opened this issue Jan 12, 2022 · 1 comment

Comments

@crcn
Copy link
Collaborator

crcn commented Jan 12, 2022

Need to create paperclip editor package which handles all of the funcitonality around editing Paperclip source code. This includes:

  • providing a data format to UI editors that allows them to display editable information
    • style inspections
    • canvas information
  • CRDT document syncing and such. This is high prio.
  • handling various editing behavior
    • dragging & dropping elements to a slot
    • displaying slots in a canvas
    • updating PC files to include imports

This should basically be the engine for editors. Emitted data from this engine should be immutable so that it can be connected to a deterministic UI.

@crcn
Copy link
Collaborator Author

crcn commented Jan 13, 2022

Some thoughts on the CRDT. We can establish a few things:

  1. text document will need to be synchronized between clients
  2. Clients will only have access to AST ids
  3. FE state will become out of date with the BE
  4. I think this is okay. If FE makes a change to an AST that doesn't exist anymore, then it will be a no-op
  5. BE will need to keep a record of what state FE has in order to make edits

Possible high-level solutions:

Store AST as CRDT documents

  • will need to diff text & patch AST documents with new IDs
  • When edits are coming from the FE, we can just modify the node associated with the ID in the tree

Store virtual elements as CRDT documents

  • Diffing already occurs here
  • virtual objects can contain additional information about source ASTs that's stored locally. Edits to virtual elements can be redirected to AST / element
  • virtual objects are basically a 1:1 map with AST. for cases where they're not, we can include additional metadata about original AST and how things were computed to arrive at virtual object.
  • If FE deletes a virtual object that's missing, that results in a no-op
  • virtual objects (and their IDs) are sent to the front-end
  • (problem) If a child is inserted somewhere in the document, all proceeding siblings will have new IDs. This should be okay.

☝️ I think editing virtual objects is the winner

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

No branches or pull requests

1 participant