@uiw/react-markdown-editor
Version:
A markdown editor with preview, implemented with React.js and TypeScript.
50 lines (49 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.todo = void 0;
var _jsxRuntime = require("react/jsx-runtime");
var todo = {
name: 'todo',
keyCommand: 'todo',
button: {
'aria-label': 'Add todo List'
},
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
viewBox: "0 0 48 48",
fill: "none",
height: "15",
width: "15",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
d: "m5 10 3 3 6-6M5 24l3 3 6-6M5 38l3 3 6-6m7-11h22M21 38h22M21 10h22",
stroke: "currentColor",
strokeWidth: "5",
strokeLinecap: "round",
strokeLinejoin: "round"
})
}),
execute: function execute(_ref) {
var state = _ref.state,
view = _ref.view;
if (!state || !view) return;
var lineInfo = view.state.doc.lineAt(view.state.selection.main.from);
var mark = '- [ ] ';
var matchMark = lineInfo.text.match(/^-\s\[\s\]\s/);
if (matchMark && matchMark[0]) {
mark = '';
}
view.dispatch({
changes: {
from: lineInfo.from,
to: lineInfo.to,
insert: "".concat(mark).concat(lineInfo.text)
},
// selection: EditorSelection.range(lineInfo.from + mark.length, lineInfo.to),
selection: {
anchor: view.state.selection.main.from + mark.length
}
});
}
};
exports.todo = todo;