@inshapardaz/likhari-react 0.1.25-dev.230 → 0.1.25-dev.232
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompletePlugin.d.ts","sourceRoot":"","sources":["../../src/autocomplete/AutocompletePlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AutocompletePlugin.d.ts","sourceRoot":"","sources":["../../src/autocomplete/AutocompletePlugin.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAGrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAsB1D;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,MAAM,EACN,QAAQ,EAAE,cAAc,GACzB,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,8EAA8E;IAC9E,QAAQ,EAAE,aAAa,GAAG,MAAM,CAAC;CAClC,sCAqNA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
4
|
-
import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_HIGH, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_TAB_COMMAND, } from 'lexical';
|
|
4
|
+
import { $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_HIGH, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, KEY_ENTER_COMMAND, KEY_ESCAPE_COMMAND, KEY_TAB_COMMAND, } from 'lexical';
|
|
5
5
|
import { $replaceMatch } from '../find/findReplaceActions.js';
|
|
6
6
|
import { onSpellWordsChange } from '../spellcheck/userWords.js';
|
|
7
7
|
import { WordIndex } from './wordIndex.js';
|
|
@@ -123,11 +123,6 @@ export function AutocompletePlugin({ label, stores, language: chosenLanguage, })
|
|
|
123
123
|
return;
|
|
124
124
|
if ((event.key === 'ArrowUp' || event.key === 'ArrowDown') && (current || prefixAtCaret(editor) !== null))
|
|
125
125
|
return;
|
|
126
|
-
if (event.key === 'Escape' && popupRef.current) {
|
|
127
|
-
event.preventDefault();
|
|
128
|
-
show(null);
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
126
|
// Left, Right, Home and End move the caret away from the word, so the list closes.
|
|
132
127
|
if (MOVEMENT_KEYS.has(event.key)) {
|
|
133
128
|
typing.current = false;
|
|
@@ -166,6 +161,13 @@ export function AutocompletePlugin({ label, stores, language: chosenLanguage, })
|
|
|
166
161
|
const unregisterCommands = [
|
|
167
162
|
editor.registerCommand(KEY_ARROW_DOWN_COMMAND, (event) => move(1, event), COMMAND_PRIORITY_HIGH),
|
|
168
163
|
editor.registerCommand(KEY_ARROW_UP_COMMAND, (event) => move(-1, event), COMMAND_PRIORITY_HIGH),
|
|
164
|
+
// While the list is open, Escape only closes it. Lexical would otherwise blur the editor.
|
|
165
|
+
editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
|
|
166
|
+
if (!popupRef.current)
|
|
167
|
+
return false;
|
|
168
|
+
show(null);
|
|
169
|
+
return true;
|
|
170
|
+
}, COMMAND_PRIORITY_HIGH),
|
|
169
171
|
editor.registerCommand(KEY_TAB_COMMAND, (event) => acceptHighlighted(event), COMMAND_PRIORITY_HIGH),
|
|
170
172
|
editor.registerCommand(KEY_ENTER_COMMAND, (event) => (popupRef.current?.selected ? acceptHighlighted(event) : false), COMMAND_PRIORITY_HIGH),
|
|
171
173
|
];
|