private void insertClip(Clip clip) { CodeEditor editor = currentEditor.getValue(); EditorRange selectedRange = editor.getSelection(); String insertedClip = selectedRange.getSelection().replaceAll("^(.*)$", clip.getContent()); editor.replaceSelection(insertedClip); book.setBookIsChanged(true); }
public void surroundSelectionWithTag(String tagName) { if (currentEditor.getValue().getMediaType().equals(MediaType.XHTML)) { XHTMLCodeEditor xhtmlCodeEditor = (XHTMLCodeEditor) currentEditor.getValue(); EditorRange range = xhtmlCodeEditor.getSelection(); xhtmlCodeEditor.replaceRange( "<" + tagName + ">" + range.getSelection() + "</" + tagName + ">", range.getFrom(), range.getTo()); refreshPreview(); xhtmlCodeEditor.requestFocus(); } }