UNPKG

@uiw/react-markdown-editor

Version:

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

43 lines (42 loc) 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.link = void 0; var _state = require("@codemirror/state"); var _jsxRuntime = require("react/jsx-runtime"); var link = { name: 'link', keyCommand: 'link', button: { 'aria-label': 'Add link text' }, icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", { fill: "currentColor", viewBox: "0 0 640 512", height: "16", width: "16", children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", { d: "M172.5 131.1c55.6-55.59 148-55.59 203.6 0 50 50 57.4 129.7 16.3 187.2l-1.1 1.6c-10.3 14.3-30.3 17.7-44.6 7.4-14.4-10.3-17.8-30.3-7.5-44.6l1.1-1.6c22.9-32.1 19.3-76-8.6-103.9-31.4-31.4-82.5-31.4-114 0L105.5 289.5c-31.51 30.6-31.51 82.5 0 114 27.8 27.9 71.8 31.5 103.8 8.6l1.6-2c14.4-9.4 34.4-6.1 44.6 8.3 10.3 14.4 7 34.4-7.4 44.7l-1.6 1.1c-58.4 41.1-136.3 34.5-186.29-15.4-56.469-56.5-56.469-148.1 0-204.5L172.5 131.1zm295 248.9c-56.5 56.5-148 56.5-204.5 0-50-50-56.5-128.8-15.4-186.3l1.1-1.6c9.4-14.3 29.4-17.7 44.6-7.4 14.4 9.4 17.8 29.4 7.5 44.6l-1.1 1.6c-22.9 31.2-19.3 76 8.6 103.9 31.4 31.4 82.5 31.4 114 0l112.2-112.3c31.5-31.5 31.5-83.4 0-114-27.8-27.87-71.8-31.51-103.8-8.6l-1.6 1.1c-14.4 10.3-34.4 6.1-44.6-7.42-10.3-14.38-7-34.37 7.4-44.64l1.6-1.12C451 6.731 529.8 13.25 579.8 63.24c56.5 56.46 56.5 148.06 0 204.46L467.5 380z" }) }), execute: function execute(_ref) { var state = _ref.state, view = _ref.view; if (!state || !view) return; if (!state || !view) return; var main = view.state.selection.main; var txt = view.state.sliceDoc(view.state.selection.main.from, view.state.selection.main.to); view.dispatch({ changes: { from: main.from, to: main.to, insert: "[".concat(txt, "]()") }, selection: _state.EditorSelection.range(main.from + 3 + txt.length, main.to + 3) // selection: { anchor: main.from + 4 }, }); } }; exports.link = link; //# sourceMappingURL=link.js.map