Update schema in collaborative editing

Hi,

How to send updated Schema on the client side to the (collab) server ?

My scenario is add some features in editor on load based on configuration, I have added nodes and marks according to my requirement and updated the local schema and its working fine, but it wont work in collab right? because the schema is not updated there, for this I have created a post method in server and able to send updated schema successfully using flatted, but then creating new schema in server fails due to OrderedMap issue. I am going in correct way? any other option available to meet my requirement?

If you’re asking how to send a Schema object over the wire—you can’t really do that. Schema specs can contain functions, so even if you have to original spec,

1 Like

Schemas generally need to be sent as Javascript code. Using a dynamic import (limited compatibility) or just loading the schema by dynamically inserting a <script/> tag might be your best option.

As said by folks above, you cannot send a schema. The server and the client must be sharing the schema generation code. There might be hacky workarounds, but I would ask why do you want to send a schema to the server? Is the schema dynamic, if yes, does it have to be? What is the root problem that you are trying to solve?

Yes my schema is dynamic, the use case is to add different type of plugins dynamically in editor( for example an Iframe to load pages), to work plugins collaborative we need to update the collab server schema right ?

I wonder if instead of sending a schema, you can keep two instances of Schema (generated by the same code) one on client side and other on server and add a plugin on both sides. This is possible since you need to anyway maintain an EditorState on the server side. With the reconfigure API, I am hoping most of your plugin state will be retained.

1 Like