Challenge with shared nodes and copy/cut + paste
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 675
- Forks
- 18
- Avg merge
- 5h 11m
- Merged PRs (30d)
- 1
Description
I just fixed cut/copy+pasting nodes that have references. The solution was to always create a "deep copy" of the whole subgraph(tree), so we make the paste independent of the current state of the document.
However, this approach will not work once we introduce "shared nodes" e.g. a navigation that is stored globally and used in multiple documents. Here we want to make sure that the id of that navigation stays the same even if you move the navigation around with cut&paste.
There's a bunch of things to consider:
- when you copy a shared node so you have multiple instances in the document, always the same shared node should be referenced, so no deep copy of the node, just creating a new reference elsewhere
- for cut+paste it's basically the same: we should never generate new ids here, we don't want to touch the shared node.
- Edge case (there are probably more)
- Imagine deleting the last occurence of that shared node (e.g. navigation)
- now do undo to bring it back
- now make some changes to the navigation (add some nav items)
- now paste the navigation (as it's still in the clipboard) - what should happen?
- "garbage collection" on the server: as you manipulate the navigation (add remove nav items), we need to update them on the server on each save. this is where we need to find the entry point (navigation node) and delete all the nodes that are no longer referenced, otherwise the database will grow a huge number of orphaned nodes.
Need to think through this whole implementation for storing each node in a global space on the server. There's benefits to just storing independent documents as just one blob of JSON. The good thing here is that garbage collection already happens within the Svedit Document, so we don't need all these global node management infrastructure. Need to think about which route to go for editable.website, and how much resources to budget to implement the fully interlinked graph thing.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are named. Begin by mapping the current document clipboard/deep-copy behavior, the server save path, and the navigation-node entry point mentioned in the issue. A complete result would define the shared-node storage model, copy/cut and undo behavior, and server-side removal of unreferenced nodes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100