Update old version to become most recent version.
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6.5k
- Forks
- 456
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 5
Description
Hey folks,
I'm using fetchSnapshot so user can navigate between document versions, however when i edit old version it does not become last one, i'm assuming since @alecgibson said submitOp will always fetch most recent version in this issue - #293
What it does actually is, when i'm on previous version and start editing it's content, it only adds content i added when moved to previous version and assign it to most recent version.
So for example if my most recent version content is - 'SomeText' and previous version content is 'PreviousVersion', if i go back on that previous version and start editing and change it to 'PreviousVersionEdited', where 'Edited' is added to previous version content, most recent version is now 'SomeTextEdited' instead of my whole content of previous version which i want to be most recent.
So basically what i want to apply is that when user navigate to old version and change something, that whole content with old version content to become most recent version.
What i have tried, is to populate doc.data with snapshot data but i assume that submitOp is taking still most recent version content.
shareDbSubscription(){
this.doc.subscribe(err => {
if(err) throw err;
if (!this.doc.type) this.doc.create([], 'rich-text');
// update editor contents
this.quill.setContents(this.doc.data);
// local -> server
this.quill.on('text-change', (delta, oldDelta, source) => {
if (source === 'user') {
// Check if it's a formatting-only delta
const formattingDelta = delta.reduce((check, op) => {
return op.insert || op.delete ? false : check;
}, true);
// If it's not a formatting-only delta, collapse local selection
if (
!formattingDelta &&
this.cursors.localConnection.range &&
this.cursors.localConnection.range.length
) {
this.cursors.localConnection.range.index += this.cursors.localConnection.range.length;
this.cursors.localConnection.range.length = 0;
this.cursors.update();
} else
this.doc.submitOp(
delta,
{
source: this.quill
},
(error: any) => {
if (error) console.error('Submit OP returned an error:', error);
else console.log('submited', this.quill, delta);
}
);
if (this.inDraft) this.getDraftVersions();
this.updateUserListStatus();
}
});
this.doc.on('op', (op, source) => {
if (source !== this.quill) {
this.quill.updateContents(op);
this.updateUserListStatus();
}
});`
And here's where i'm fetching snapshot - https://pastebin.com/ABqq1q4L
Sorry if it's on pastebin but markdown here didn't format it correctly. If it's problem i'll try and format it here.
@alecgibson Hey, when you have time take a look :)
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
Start by reading the fetchSnapshot and submitOp usage in the shareDbSubscription example, then compare their behavior with the discussion in issue #293. Reproduce editing a fetched previous version and verify whether the newest version should contain the entire snapshot content rather than only the submitted delta.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100