@uiw/react-md-editor
Version:
A markdown editor with preview, implemented with React.js and TypeScript.
31 lines (26 loc) • 957 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.comment = void 0;
var _markdownUtils = require("../utils/markdownUtils");
var comment = {
name: 'comment',
keyCommand: 'comment',
shortcuts: 'ctrlcmd+/',
execute: function execute(state, api) {
// Adjust the selection to encompass the whole word if the caret is inside one
var newSelectionRange = (0, _markdownUtils.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("<!-- ".concat(state1.selectedText, " -->")); // Adjust the selection to not contain the **
api.setSelectionRange({
start: state2.selection.end - 4 - state1.selectedText.length,
end: state2.selection.end - 4
});
}
};
exports.comment = comment;
//# sourceMappingURL=comment.js.map