@uiw/react-md-editor 3.25.3 → 3.25.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/Editor.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["prefixCls", "className", "value", "commands", "commandsFilter", "direction", "extraCommands", "height", "enableScroll", "visibleDragbar", "highlightEnable", "preview", "fullscreen", "overflow", "previewOptions", "textareaProps", "maxHeight", "minHeight", "autoFocus", "tabSize", "defaultTabEnable", "onChange", "onStatistics", "onHeightChange", "hideToolbar", "toolbarBottom", "components", "renderTextarea"];
4
- import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle, Fragment } from 'react';
4
+ import React, { useEffect, useReducer, useMemo, useRef, useImperativeHandle } from 'react';
5
5
  import MarkdownPreview from '@uiw/react-markdown-preview';
6
6
  import TextArea from './components/TextArea';
7
7
  import { ToolbarVisibility } from './components/Toolbar';
@@ -212,17 +212,6 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
212
212
  }));
213
213
  }
214
214
  };
215
- var contentView = /(live|preview)/.test(state.preview || '') && /*#__PURE__*/_jsxs(Fragment, {
216
- children: [/*#__PURE__*/_jsx(TextArea, _extends({
217
- className: prefixCls + "-input",
218
- prefixCls: prefixCls,
219
- autoFocus: autoFocus
220
- }, textareaProps, {
221
- onChange: changeHandle,
222
- renderTextarea: (components == null ? void 0 : components.textarea) || renderTextarea,
223
- onScroll: e => handleScroll(e, 'text')
224
- })), mdPreview]
225
- });
226
215
  return /*#__PURE__*/_jsx(EditorContext.Provider, {
227
216
  value: _extends({}, state, {
228
217
  dispatch
@@ -239,9 +228,17 @@ var InternalMDEditor = /*#__PURE__*/React.forwardRef((props, ref) => {
239
228
  prefixCls: prefixCls,
240
229
  overflow: overflow,
241
230
  placement: "top"
242
- }), /*#__PURE__*/_jsx("div", {
231
+ }), /*#__PURE__*/_jsxs("div", {
243
232
  className: prefixCls + "-content",
244
- children: contentView
233
+ children: [/(edit|live)/.test(state.preview || '') && /*#__PURE__*/_jsx(TextArea, _extends({
234
+ className: prefixCls + "-input",
235
+ prefixCls: prefixCls,
236
+ autoFocus: autoFocus
237
+ }, textareaProps, {
238
+ onChange: changeHandle,
239
+ renderTextarea: (components == null ? void 0 : components.textarea) || renderTextarea,
240
+ onScroll: e => handleScroll(e, 'text')
241
+ })), /(live|preview)/.test(state.preview || '') && mdPreview]
245
242
  }), visibleDragbar && !state.fullscreen && /*#__PURE__*/_jsx(DragBar, {
246
243
  prefixCls: prefixCls,
247
244
  height: state.height,
package/lib/Editor.js CHANGED
@@ -271,19 +271,6 @@ var InternalMDEditor = /*#__PURE__*/_react["default"].forwardRef(function (props
271
271
  }));
272
272
  }
273
273
  };
274
- var contentView = /(live|preview)/.test(state.preview || '') && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_react.Fragment, {
275
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextArea["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
276
- className: "".concat(prefixCls, "-input"),
277
- prefixCls: prefixCls,
278
- autoFocus: autoFocus
279
- }, textareaProps), {}, {
280
- onChange: changeHandle,
281
- renderTextarea: (components === null || components === void 0 ? void 0 : components.textarea) || renderTextarea,
282
- onScroll: function onScroll(e) {
283
- return handleScroll(e, 'text');
284
- }
285
- })), mdPreview]
286
- });
287
274
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Context.EditorContext.Provider, {
288
275
  value: (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, state), {}, {
289
276
  dispatch: dispatch
@@ -300,9 +287,19 @@ var InternalMDEditor = /*#__PURE__*/_react["default"].forwardRef(function (props
300
287
  prefixCls: prefixCls,
301
288
  overflow: overflow,
302
289
  placement: "top"
303
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
290
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
304
291
  className: "".concat(prefixCls, "-content"),
305
- children: contentView
292
+ children: [/(edit|live)/.test(state.preview || '') && /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextArea["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
293
+ className: "".concat(prefixCls, "-input"),
294
+ prefixCls: prefixCls,
295
+ autoFocus: autoFocus
296
+ }, textareaProps), {}, {
297
+ onChange: changeHandle,
298
+ renderTextarea: (components === null || components === void 0 ? void 0 : components.textarea) || renderTextarea,
299
+ onScroll: function onScroll(e) {
300
+ return handleScroll(e, 'text');
301
+ }
302
+ })), /(live|preview)/.test(state.preview || '') && mdPreview]
306
303
  }), visibleDragbar && !state.fullscreen && /*#__PURE__*/(0, _jsxRuntime.jsx)(_DragBar["default"], {
307
304
  prefixCls: prefixCls,
308
305
  height: state.height,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "3.25.3",
3
+ "version": "3.25.5",
4
4
  "description": "A markdown editor with preview, implemented with React.js and TypeScript.",
5
5
  "homepage": "https://uiwjs.github.io/react-md-editor/",
6
6
  "author": "kenny wang <wowohoo@qq.com>",
@@ -19,6 +19,11 @@
19
19
  "import": "./esm/index.nohighlight.js",
20
20
  "types": "./lib/index.nohighlight.d.ts",
21
21
  "require": "./lib/index.nohighlight.js"
22
+ },
23
+ "./commands": {
24
+ "import": "./esm/commands/index.js",
25
+ "types": "./lib/commands/index.d.ts",
26
+ "require": "./lib/commands/index.js"
22
27
  }
23
28
  },
24
29
  "repository": {
package/src/Editor.tsx CHANGED
@@ -217,20 +217,6 @@ const InternalMDEditor = React.forwardRef<RefMDEditor, MDEditorProps>(
217
217
  });
218
218
  }
219
219
  };
220
- const contentView = /(live|preview)/.test(state.preview || '') && (
221
- <Fragment>
222
- <TextArea
223
- className={`${prefixCls}-input`}
224
- prefixCls={prefixCls}
225
- autoFocus={autoFocus}
226
- {...textareaProps}
227
- onChange={changeHandle}
228
- renderTextarea={components?.textarea || renderTextarea}
229
- onScroll={(e) => handleScroll(e, 'text')}
230
- />
231
- {mdPreview}
232
- </Fragment>
233
- );
234
220
  return (
235
221
  <EditorContext.Provider value={{ ...state, dispatch }}>
236
222
  <div ref={container} className={cls} {...other} onClick={containerClick} style={containerStyle}>
@@ -241,7 +227,20 @@ const InternalMDEditor = React.forwardRef<RefMDEditor, MDEditorProps>(
241
227
  overflow={overflow}
242
228
  placement="top"
243
229
  />
244
- <div className={`${prefixCls}-content`}>{contentView}</div>
230
+ <div className={`${prefixCls}-content`}>
231
+ {/(edit|live)/.test(state.preview || '') && (
232
+ <TextArea
233
+ className={`${prefixCls}-input`}
234
+ prefixCls={prefixCls}
235
+ autoFocus={autoFocus}
236
+ {...textareaProps}
237
+ onChange={changeHandle}
238
+ renderTextarea={components?.textarea || renderTextarea}
239
+ onScroll={(e) => handleScroll(e, 'text')}
240
+ />
241
+ )}
242
+ {/(live|preview)/.test(state.preview || '') && mdPreview}
243
+ </div>
245
244
  {visibleDragbar && !state.fullscreen && (
246
245
  <DragBar
247
246
  prefixCls={prefixCls}