Use YMap for the Value of YKeyValue

I was looking for a way to optimize data management for each node in a collaborative drawing application and discovered YKeyValue.

However, when we tried to use YMap for the Value of YKeyValue, I ran into this problem.

const ydoc = new Y.Doc();
const yarr: YArray<{ key: string; val: YMap<any> }> = ydoc.getArray();
const ykv = new YKeyValue(yarr);

const ymap = new Y.Map();
ymap.set('key', 'val');

ykv.set('1', ymap);
ykv.get('1').toJSON(); // => {}, expected {'key', 'val'}

I am not sure if I am using the wrong approach or not. I’m not sure if I’m using it wrong or not. can I use a YMap for the value of a YKeyValue?

Maybe this is the reason:

Hm, could the value be a subdoc?