Problems when binding with codemirror6

I also meet some problem when bind the codemirror with prosemirror, and figure out another solution about the selection recover, the key point is record the codemirror selection in the code_block node attribute, and then reload it when we need, this solution can support multiple selection inside the codemirror

solution-demo-2