| | import org.fxmisc.wellbehaved.event.EventHandlerHelper; |
| | import org.fxmisc.wellbehaved.event.EventPattern; |
| | +import org.markdownwriterfx.editor.MarkdownEditorPane; |
| | import org.markdownwriterfx.util.Action; |
| | import org.markdownwriterfx.util.ActionUtils; |
 |
| | |
| | // Edit actions |
| | - Action editUndoAction = new Action("Undo", "Shortcut+Z", UNDO, e -> editUndo(), |
| | + Action editUndoAction = new Action("Undo", "Shortcut+Z", UNDO, |
| | + e -> fileEditorTabPane.getActiveFileEditor().undo(), |
| | createActiveBooleanProperty(FileEditor::canUndoProperty).not()); |
| | - Action editRedoAction = new Action("Redo", "Shortcut+Y", REPEAT, e -> editRedo(), |
| | + Action editRedoAction = new Action("Redo", "Shortcut+Y", REPEAT, |
| | + e -> fileEditorTabPane.getActiveFileEditor().redo(), |
| | createActiveBooleanProperty(FileEditor::canRedoProperty).not()); |
| | |
| | // Insert actions |
| | - Action insertBoldAction = new Action("Bold", "Shortcut+B", BOLD, e -> insertBold(), activeFileEditorIsNull); |
| | - Action insertItalicAction = new Action("Italic", "Shortcut+I", ITALIC, e -> insertItalic(), activeFileEditorIsNull); |
| | + Action insertBoldAction = new Action("Bold", "Shortcut+B", BOLD, |
| | + e -> getActiveEditor().surroundSelection("**", "**"), |
| | + activeFileEditorIsNull); |
| | + Action insertItalicAction = new Action("Italic", "Shortcut+I", ITALIC, |
| | + e -> getActiveEditor().surroundSelection("*", "*"), |
| | + activeFileEditorIsNull); |
| | |
| | // Help actions |
 |
| | } |
| | |
| | + private MarkdownEditorPane getActiveEditor() { |
| | + return fileEditorTabPane.getActiveFileEditor().getEditor(); |
| | + } |
| | |
| | /** |
 |
| | Window window = scene.getWindow(); |
| | Event.fireEvent(window, new WindowEvent(window, WindowEvent.WINDOW_CLOSE_REQUEST)); |
| | - } |
| | - |
| | - //---- Edit actions ------------------------------------------------------- |
| | - |
| | - private void editUndo() { |
| | - fileEditorTabPane.getActiveFileEditor().undo(); |
| | - } |
| | - |
| | - private void editRedo() { |
| | - fileEditorTabPane.getActiveFileEditor().redo(); |
| | - } |
| | - |
| | - //---- Insert actions ----------------------------------------------------- |
| | - |
| | - private void insertBold() { |
| | - fileEditorTabPane.getActiveFileEditor().getEditor().surroundSelection("**", "**"); |
| | - } |
| | - |
| | - private void insertItalic() { |
| | - fileEditorTabPane.getActiveFileEditor().getEditor().surroundSelection("*", "*"); |
| | } |
| | |