UNPKG

@uiw/react-markdown-editor

Version:

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

45 lines (40 loc) 1.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.image = void 0; var _state = require("@codemirror/state"); var _jsxRuntime = require("react/jsx-runtime"); var image = { name: 'image', keyCommand: 'image', button: { 'aria-label': 'Add image text' }, icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 20 20", children: /*#__PURE__*/(0, _jsxRuntime.jsx)("path", { fill: "currentColor", d: "M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z" }) }), execute: function execute(_ref) { var state = _ref.state, view = _ref.view; 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 + 4, main.to + 4) // selection: { anchor: main.from + 4 }, }); } }; exports.image = image; //# sourceMappingURL=image.js.map