Beispiel #1
0
 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);
 }
Beispiel #2
0
 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();
   }
 }