@inshapardaz/likhari-react 0.1.21-dev.212 → 0.1.21-dev.213
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":"AutoCorrectPlugin.d.ts","sourceRoot":"","sources":["../../src/autocorrect/AutoCorrectPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"AutoCorrectPlugin.d.ts","sourceRoot":"","sources":["../../src/autocorrect/AutoCorrectPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAWjB,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAiB,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG9F,sFAAsF;AACtF,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,IAAI,CAA6C,CAAC;AAMxG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,kEAAkE;IAClE,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,QA0GA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useRef } from 'react';
|
|
2
2
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_HIGH, KEY_ENTER_COMMAND, createCommand, } from 'lexical';
|
|
3
|
+
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, BLUR_COMMAND, COMMAND_PRIORITY_HIGH, KEY_ENTER_COMMAND, createCommand, } from 'lexical';
|
|
4
4
|
import { $correctDocument, $correctPunctuationBeforeCaret, $correctPunctuationDocument, $correctWordBeforeCaret, $correctWordEndingAtCaret, $preservingSelection, $spacePunctuationDocument, } from './autoCorrectActions.js';
|
|
5
5
|
import { $cleanUpText } from '../cleanup/textCleanupActions.js';
|
|
6
6
|
import { activePunctuationRules } from './punctuationRules.js';
|
|
@@ -99,8 +99,9 @@ export function AutoCorrectPlugin({ stores, version, enabled, typing, urduNormal
|
|
|
99
99
|
root?.addEventListener('keydown', onKeyDown);
|
|
100
100
|
};
|
|
101
101
|
const unregister = editor.registerRootListener((next) => attach(next));
|
|
102
|
-
//
|
|
103
|
-
|
|
102
|
+
// A word with nothing after it (end of line or document) is corrected when the
|
|
103
|
+
// caret leaves it: Enter splits the line, and blur means the user has moved on.
|
|
104
|
+
const correctEndingWord = () => {
|
|
104
105
|
const selection = $getSelection();
|
|
105
106
|
if (!$isRangeSelection(selection))
|
|
106
107
|
return false;
|
|
@@ -109,10 +110,13 @@ export function AutoCorrectPlugin({ stores, version, enabled, typing, urduNormal
|
|
|
109
110
|
if (table)
|
|
110
111
|
$correctWordEndingAtCaret(table, rtl ? normalizeRtl : undefined);
|
|
111
112
|
return false;
|
|
112
|
-
}
|
|
113
|
+
};
|
|
114
|
+
const unregisterEnter = editor.registerCommand(KEY_ENTER_COMMAND, correctEndingWord, COMMAND_PRIORITY_HIGH);
|
|
115
|
+
const unregisterBlur = editor.registerCommand(BLUR_COMMAND, correctEndingWord, COMMAND_PRIORITY_EDITOR);
|
|
113
116
|
return () => {
|
|
114
117
|
unregister();
|
|
115
118
|
unregisterEnter();
|
|
119
|
+
unregisterBlur();
|
|
116
120
|
attach(null);
|
|
117
121
|
};
|
|
118
122
|
}, [editor, enabled, typing]);
|