UNPKG

@uiw/react-md-editor

Version:

A markdown editor with preview, implemented with React.js and TypeScript.

22 lines (20 loc) 788 B
import { selectWord } from '../utils/markdownUtils'; export var comment = { name: 'comment', keyCommand: 'comment', shortcuts: 'ctrlcmd+/', execute: (state, api) => { // Adjust the selection to encompass the whole word if the caret is inside one var newSelectionRange = selectWord({ text: state.text, selection: state.selection }); var state1 = api.setSelectionRange(newSelectionRange); // Replaces the current selection with the bold mark up var state2 = api.replaceSelection("<!-- " + state1.selectedText + " -->"); // Adjust the selection to not contain the ** api.setSelectionRange({ start: state2.selection.end - 4 - state1.selectedText.length, end: state2.selection.end - 4 }); } }; //# sourceMappingURL=comment.js.map