Red Hat Bugzilla – Bug 838294
FEATURE: Wrap selection in tag
Last modified: 2014-10-19 19:01:01 EDT
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.
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
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.
Done, but hot key not implemented yet.
Hot key is Ctrl+Shift+D. Tested in Chrome, Firefox and Opera on Linux.