UNPKG

@uiw/react-markdown-editor

Version:

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

45 lines 1.17 kB
import { jsx as _jsx } from "react/jsx-runtime"; export var todo = { name: 'todo', keyCommand: 'todo', button: { 'aria-label': 'Add todo List' }, icon: /*#__PURE__*/_jsx("svg", { viewBox: "0 0 48 48", fill: "none", height: "15", width: "15", children: /*#__PURE__*/_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: _ref => { var { state, view } = _ref; 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: "" + mark + lineInfo.text }, // selection: EditorSelection.range(lineInfo.from + mark.length, lineInfo.to), selection: { anchor: view.state.selection.main.from + mark.length } }); } };