At the moment if I want to wrap existing text in a tag, I have to type the tag, get the autoclosure, then cut and paste either the ending tag or the text. In the oXygenXML editor there is a hot key and a pop-up. You make a selection, then you hit the hot key, put the tag name into the pop-up, and get the wrapping. Implement.
Here's the pseudo-code: Add an onKeyEvent handler for the hot-key combination to the Codemirror create code in the editor page. In the handler, get the current selected text in the editor. Pop-up a modal dialog and allow the user to enter a tag. Parse the tag to the first space, and use that as the tag name. Assume the rest is attributes. If the user input looks like this: XXXX then do: <XXXX>SELECTED-TEXT</XXXX> if it looks like: XXXX YYY ZZZ then do: <XXXX YYY ZZZ>SELECTED-TEXT</XXXX>
Another thing to do would be to make a hot key that will delete the last inserted tag. This allows you to close the tag on the other side of the text you want to wrap, and get the autoclosure. So, the pseudo code: 1. Trap the hot key. 2. When it fires, check the text at the cursor. Parse around it for the open and closed tag. If found, delete the closed tag part.
https://github.com/jwulf/fudcon-docs-hack/blob/feature-admin/source/topicindex-server/WebContent/Books/editor/scripts/topiceditor.js#L604 Done, but hot key not implemented yet.
Hot key is Ctrl+Shift+D. Tested in Chrome, Firefox and Opera on Linux.