@uiw/react-markdown-editor
Version:
A markdown editor with preview, implemented with React.js and TypeScript.
48 lines (47 loc) • 1.69 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.quote = void 0;
var _react = _interopRequireDefault(require("react"));
var _jsxRuntime = require("react/jsx-runtime");
var quote = {
name: 'quote',
keyCommand: 'quote',
button: {
'aria-label': 'Add quote text'
},
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", {
fill: "currentColor",
viewBox: "0 0 448 512",
height: "15",
width: "15",
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", {
d: "M96 96c-53.02 0-96 42.1-96 96s42.98 96 96 96c11.28 0 21.95-2.305 32-5.879V288c0 35.3-28.7 64-64 64-17.67 0-32 14.33-32 32s14.33 32 32 32c70.58 0 128-57.42 128-128v-96c0-53.9-43-96-96-96zm352 96c0-53.02-42.98-96-96-96s-96 42.98-96 96 42.98 96 96 96c11.28 0 21.95-2.305 32-5.879V288c0 35.3-28.7 64-64 64-17.67 0-32 14.33-32 32s14.33 32 32 32c70.58 0 128-57.42 128-128v-96z"
})
}),
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/);
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.quote = quote;