@uiw/react-md-editor 4.1.3 → 4.1.4

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.
@@ -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* ';
@@ -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.4",
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",
@@ -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('*')) {