@uiw/react-md-editor 4.1.3 → 4.1.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.
@@ -83,7 +83,6 @@ export default function Textarea(props) {
83
83
  }, []);
84
84
  return /*#__PURE__*/_jsx("textarea", _extends({
85
85
  autoComplete: "off",
86
- autoCorrect: "off",
87
86
  autoCapitalize: "off",
88
87
  spellCheck: false
89
88
  }, other, {
@@ -68,7 +68,6 @@ export function createTextArea(options) {
68
68
  children: renderTextarea ? (/*#__PURE__*/React.cloneElement(renderTextarea(_extends({}, otherProps, {
69
69
  value: markdown,
70
70
  autoComplete: 'off',
71
- autoCorrect: 'off',
72
71
  spellCheck: 'false',
73
72
  autoCapitalize: 'off',
74
73
  className: prefixCls + "-text-input",
@@ -118,6 +118,15 @@ export default function handleKeyDown(e, tabSize, defaultTabEnable) {
118
118
  * `13` - `Enter`
119
119
  */
120
120
  stopPropagation(e);
121
+ var atEndOfLine = target.selectionEnd === target.value.length || target.value[target.selectionEnd] === '\n';
122
+ var emptyListItem = /^(?:[-*]|\d+\.)\s+$/.test(currentLineStr) || /^- \[[ xX]\]\s*$/.test(currentLineStr);
123
+ if (target.selectionStart === target.selectionEnd && atEndOfLine && emptyListItem) {
124
+ textArea.setSelectionRange({
125
+ start: target.selectionStart - currentLineStr.length,
126
+ end: target.selectionEnd
127
+ });
128
+ return insertTextAtPosition(target, '');
129
+ }
121
130
  var startStr = '\n- ';
122
131
  if (currentLineStr.startsWith('*')) {
123
132
  startStr = '\n* ';
@@ -91,7 +91,6 @@ function Textarea(props) {
91
91
  }, []);
92
92
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
93
93
  autoComplete: "off",
94
- autoCorrect: "off",
95
94
  autoCapitalize: "off",
96
95
  spellCheck: false
97
96
  }, other), {}, {
@@ -75,7 +75,6 @@ function createTextArea(options) {
75
75
  children: renderTextarea ? (/*#__PURE__*/_react["default"].cloneElement(renderTextarea((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, otherProps), {}, {
76
76
  value: markdown,
77
77
  autoComplete: 'off',
78
- autoCorrect: 'off',
79
78
  spellCheck: 'false',
80
79
  autoCapitalize: 'off',
81
80
  className: "".concat(prefixCls, "-text-input"),
@@ -122,6 +122,15 @@ function handleKeyDown(e) {
122
122
  * `13` - `Enter`
123
123
  */
124
124
  stopPropagation(e);
125
+ var atEndOfLine = target.selectionEnd === target.value.length || target.value[target.selectionEnd] === '\n';
126
+ var emptyListItem = /^(?:[-*]|\d+\.)\s+$/.test(currentLineStr) || /^- \[[ xX]\]\s*$/.test(currentLineStr);
127
+ if (target.selectionStart === target.selectionEnd && atEndOfLine && emptyListItem) {
128
+ textArea.setSelectionRange({
129
+ start: target.selectionStart - currentLineStr.length,
130
+ end: target.selectionEnd
131
+ });
132
+ return (0, _InsertTextAtPosition.insertTextAtPosition)(target, '');
133
+ }
125
134
  var startStr = '\n- ';
126
135
  if (currentLineStr.startsWith('*')) {
127
136
  startStr = '\n* ';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uiw/react-md-editor",
3
- "version": "4.1.3",
3
+ "version": "4.1.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
  "funding": "https://jaywcjlove.github.io/#/sponsor",
@@ -77,7 +77,6 @@ export default function Textarea(props: TextAreaProps) {
77
77
  return (
78
78
  <textarea
79
79
  autoComplete="off"
80
- autoCorrect="off"
81
80
  autoCapitalize="off"
82
81
  spellCheck={false}
83
82
  {...other}
@@ -87,7 +87,6 @@ export function createTextArea(options?: { Markdown?: MarkdownComponent; useMinH
87
87
  ...otherProps,
88
88
  value: markdown,
89
89
  autoComplete: 'off',
90
- autoCorrect: 'off',
91
90
  spellCheck: 'false',
92
91
  autoCapitalize: 'off',
93
92
  className: `${prefixCls}-text-input`,
@@ -109,6 +109,16 @@ export default function handleKeyDown(
109
109
  * `13` - `Enter`
110
110
  */
111
111
  stopPropagation(e);
112
+ const atEndOfLine = target.selectionEnd === target.value.length || target.value[target.selectionEnd] === '\n';
113
+ const emptyListItem =
114
+ /^(?:[-*]|\d+\.)\s+$/.test(currentLineStr) || /^- \[[ xX]\]\s*$/.test(currentLineStr);
115
+ if (target.selectionStart === target.selectionEnd && atEndOfLine && emptyListItem) {
116
+ textArea.setSelectionRange({
117
+ start: target.selectionStart - currentLineStr.length,
118
+ end: target.selectionEnd,
119
+ });
120
+ return insertTextAtPosition(target, '');
121
+ }
112
122
  let startStr = '\n- ';
113
123
 
114
124
  if (currentLineStr.startsWith('*')) {