You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In order to initially create and populate my Y.Doc in my server (Before sharing it with my frontend) I want to use y-prosemirror utility fonctions.
The final goal is to have my Tiptap Wysiwyg nicely displayed with the already existing data in my DataBase (HTML stored as String).
I already have my Y.Doc, and I only want to create a new Y.XmlFragment populated with my existing HTML.
So the utility function prosemirrorJSONToYXmlFragment(schema, state) looks perfect for my usage.
But it seems that the method cannot return a populated Y.XmlFragment, without giving an existing one already linked to an existing Y.Doc
To Reproduce
I think the best thing I can do is to provide a real exemple of what I am trying to do :
import*asYfrom"yjs";import{generateJSON}from"@tiptap/html";import{prosemirrorJSONToYXmlFragment}from"y-prosemirror";import{getSchema}from"@tiptap/core";consthtmlFromDataBase="<p>Hello !</p>";constyDoc=newY.Doc();// import from tiptap are omitted (but theses are only tiptap extensions).consttiptapExtensions=[Document,Paragraph,Text,Link,BulletList,ListItem,OrderedList,Bold,Italic,Underline,Strike];constschema=getSchema(tiptapExtensions);conststate=generateJSON(htmlFromDataBase,tiptapExtensions);constxmlFragment=yDoc.getXmlFragment('myFragment');// Here xmlFragment and yFragment are correctly populated with my given HTML. Working exemple !constyFragment=prosemirrorJSONToYXmlFragment(schema,state,xmlFragment);// If I would have done that, newFragment would have been empty (without Y.XmlElements) constnewFragment=prosemirrorJSONToYXmlFragment(schema,state);// Same I gave and existing fragment ! updateFragment is witout any elements.constupdateFragment=prosemirrorJSONToYXmlFragment(schema,state,newY.XmlFragment());// So i guess it only work if the given Y.XmlFragment is already linked to and existing Y.Doc !
Expected behavior
I expect that if i use the method prosemirrorJSONToYXmlFragment(schema, state) with valid schema and json, it should create me a populated Y.XmlFragment
This makes it very difficult to restore a XmlFragment from the output of XmlFragment.toJSON(). Especially, because the XmlFragment cannot be properly cloned to be inserted in another yDoc.
Describe the bug
In order to initially create and populate my Y.Doc in my server (Before sharing it with my frontend) I want to use y-prosemirror utility fonctions.
The final goal is to have my Tiptap Wysiwyg nicely displayed with the already existing data in my DataBase (HTML stored as String).
I already have my Y.Doc, and I only want to create a new Y.XmlFragment populated with my existing HTML.
So the utility function
prosemirrorJSONToYXmlFragment(schema, state)
looks perfect for my usage.But it seems that the method cannot return a populated Y.XmlFragment, without giving an existing one already linked to an existing Y.Doc
To Reproduce
I think the best thing I can do is to provide a real exemple of what I am trying to do :
Expected behavior
I expect that if i use the method
prosemirrorJSONToYXmlFragment(schema, state)
with valid schema and json, it should create me a populated Y.XmlFragmentEnvironment Information
The text was updated successfully, but these errors were encountered: