ProseMirror as generic XML editor

Has anyone tried to make ProseMirror into a generic XML editor? I’m working in a project where there are quite a number of different XSD schemas. We can convert these to ProseMirror schemas but then the editing actions still need to be defined manually. Also, ProseMirror prefers HTML5 tags, so the XML document would need to convert its tags to that in Schema.parse() and back again when saving. Part of this can be done in the schema.

mytag: {
  parseDOM: [{tag: "div", attrs: {"data-tag": "mytag"}}],
  toDOM: () => { return ["div", {"data-tag": "mytag"}, 0] }
}

With some CSS magic this can give an editor view like this:

Writing helper functions to make this user-friendly and generic is possible. If someone else has already started on this, collaboration might be nice.

This idea could work for LwDITA (Lightweight DITA), which is a stripped-down version of the OASIS DITA standard for structured authoring. If you haven’t heard of DITA, it’s sort of like Docbook except that it’s more oriented towards small reusable topics - and documents assembled from them - rather than long monolithic documents. What’s nice about LwDITA is that it can be edited and stored as XML, HTML5, or Markdown, and there are transformations among the three of them. The point here is simply that LwDITA can be edited as HTML5 content, which is what ProseMirror prefers, according to your post. In order to store additional information about document nodes, the HTML5 flavor of LwDITA uses custom attributes. If ProseMirror can add custom attributes to HTML5 tags, and preserve those custom attributes across transformations (some of them are used by DITA CSS when generating output), then it might work as an LwDITA editor.

Hi @vandenoever. Can you share your schema and saving function please ?

The schema is here https://gitlab.com/omgevingswet/maaksoftware/-/blob/master/pr04schemas/schema.json and save function here: https://gitlab.com/omgevingswet/maaksoftware/-/blob/master/src/app/save.ts

Thank you !