Add a static fromChanges method to ChangeSet class #24

Closed
maitysubhasis wants to merge 1 commit from add-static-method-to-change-set into master
maitysubhasis commented 2026-02-10 17:28:17 +01:00 (Migrated from github.com)

If we want to create a ChangeSet from a deserialized Change list we need to have a way to pass the changes to the constructor.

Currently the constructor is marked @internal So adding this method.

If we want to create a ChangeSet from a deserialized Change list we need to have a way to pass the changes to the constructor. Currently the constructor is marked @internal So adding this method.
marijnh commented 2026-02-10 20:28:51 +01:00 (Migrated from github.com)

What's wrong with calling ChangeSet.create(...).addSteps(...)?

What's wrong with calling `ChangeSet.create(...).addSteps(...)`?
maitysubhasis commented 2026-02-11 17:40:27 +01:00 (Migrated from github.com)

For a large document there can be too many steps. To avoid fetching all those steps we decided to save the Change[] in db. This way we can load the the list and create ChangeSet and apply the recent Step[] on top.

For a large document there can be too many steps. To avoid fetching all those steps we decided to save the `Change[]` in db. This way we can load the the list and create `ChangeSet` and apply the recent `Step[]` on top.
marijnh commented 2026-02-12 11:27:05 +01:00 (Migrated from github.com)

Ah, I see, you're asking for a direct serialization format. But it appears Span and Change also don't export their constructors. Could you take a look at attached patch and let me know whether it'd solve your problem?

Ah, I see, you're asking for a direct serialization format. But it appears `Span` and `Change` also don't export their constructors. Could you take a look at attached patch and let me know whether it'd solve your problem?
sch commented 2026-02-12 15:21:19 +01:00 (Migrated from github.com)

I like the symmetry in your patch with serializing Nodes and Steps. This would serve our use case nicely and avoid needing to extend the types with declaration merging in our app.

I like the symmetry in your patch with serializing Nodes and Steps. This would serve our use case nicely and avoid needing to extend the types with declaration merging in our app.
maitysubhasis commented 2026-02-12 15:31:11 +01:00 (Migrated from github.com)

I made a comment for the patch. In summary the question is: how should we pass the optional parameters?

I made a comment for the [patch](https://github.com/ProseMirror/prosemirror-changeset/commit/fabfe3b23e96284d62742958191fdb4164ab9780#r177036658). In summary the question is: how should we pass the optional parameters?
marijnh commented 2026-02-12 15:32:04 +01:00 (Migrated from github.com)

Pass undefined if you don't want to pass a non-default value.

Pass `undefined` if you don't want to pass a non-default value.
maitysubhasis commented 2026-02-12 17:14:47 +01:00 (Migrated from github.com)

Thanks you. That would do!

Thanks you. That would do!
sch commented 2026-02-13 17:26:24 +01:00 (Migrated from github.com)

I can confirm these changes work well with a vendored copy of this patch in our codebase.

I can confirm these changes work well with a vendored copy of [this patch](https://github.com/ProseMirror/prosemirror-changeset/commit/fabfe3b23e96284d62742958191fdb4164ab9780) in our codebase.
marijnh commented 2026-02-14 11:56:22 +01:00 (Migrated from github.com)

I've published a version 2.4.0

I've published a version 2.4.0

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-changeset!24
No description provided.