@inshapardaz/likhari-react 0.1.22 → 0.1.23
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/dist/EditorRoot.d.ts +9 -0
- package/dist/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +12 -11
- package/dist/autocorrect/AutoCorrectPlugin.d.ts +27 -0
- package/dist/autocorrect/AutoCorrectPlugin.d.ts.map +1 -0
- package/dist/autocorrect/AutoCorrectPlugin.js +108 -0
- package/dist/autocorrect/autoCorrectActions.d.ts +35 -0
- package/dist/autocorrect/autoCorrectActions.d.ts.map +1 -0
- package/dist/autocorrect/autoCorrectActions.js +182 -0
- package/dist/autocorrect/autoCorrectStores.d.ts +52 -0
- package/dist/autocorrect/autoCorrectStores.d.ts.map +1 -0
- package/dist/autocorrect/autoCorrectStores.js +115 -0
- package/dist/autocorrect/punctuationRules.d.ts +26 -0
- package/dist/autocorrect/punctuationRules.d.ts.map +1 -0
- package/dist/autocorrect/punctuationRules.js +53 -0
- package/dist/cleanup/textCleanupActions.d.ts +8 -0
- package/dist/cleanup/textCleanupActions.d.ts.map +1 -0
- package/dist/cleanup/textCleanupActions.js +28 -0
- package/dist/components/AutoCorrectPanel.d.ts +15 -0
- package/dist/components/AutoCorrectPanel.d.ts.map +1 -0
- package/dist/components/AutoCorrectPanel.js +44 -0
- package/dist/components/Toolbar.d.ts +4 -1
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +112 -109
- package/dist/i18n/strings.d.ts +22 -0
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +71 -5
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/normalization/urduNormalize.d.ts +24 -0
- package/dist/normalization/urduNormalize.d.ts.map +1 -0
- package/dist/normalization/urduNormalize.js +116 -0
- package/dist/spellcheck/spellingMenu.d.ts +15 -0
- package/dist/spellcheck/spellingMenu.d.ts.map +1 -0
- package/dist/spellcheck/spellingMenu.js +27 -0
- package/dist/theme/editor.css +58 -0
- package/package.json +1 -1
package/dist/i18n/strings.js
CHANGED
|
@@ -162,6 +162,28 @@ const en = {
|
|
|
162
162
|
next: 'Next',
|
|
163
163
|
noSuggestions: 'No suggestions',
|
|
164
164
|
},
|
|
165
|
+
autoCorrect: {
|
|
166
|
+
title: 'Auto-correct',
|
|
167
|
+
language: 'Language',
|
|
168
|
+
from: 'Typed word',
|
|
169
|
+
fromPlaceholder: 'Word as typed',
|
|
170
|
+
to: 'Corrected word',
|
|
171
|
+
toPlaceholder: 'Correct it to',
|
|
172
|
+
save: 'Save correction',
|
|
173
|
+
saved: 'Saved. It applies to the next word typed.',
|
|
174
|
+
noWritableStore: 'No store accepts new corrections',
|
|
175
|
+
failed: 'Could not save the correction',
|
|
176
|
+
close: 'Close',
|
|
177
|
+
correctDocument: 'Correct whole document',
|
|
178
|
+
},
|
|
179
|
+
contextMenu: {
|
|
180
|
+
cut: 'Cut',
|
|
181
|
+
copy: 'Copy',
|
|
182
|
+
paste: 'Paste',
|
|
183
|
+
selectAll: 'Select all',
|
|
184
|
+
spelling: 'Spelling suggestions',
|
|
185
|
+
noSuggestions: 'No suggestions',
|
|
186
|
+
},
|
|
165
187
|
link: {
|
|
166
188
|
menuLabel: 'Link',
|
|
167
189
|
noUrl: '(no URL)',
|
|
@@ -405,6 +427,28 @@ const ur = {
|
|
|
405
427
|
next: 'اگلا',
|
|
406
428
|
noSuggestions: 'کوئی تجویز نہیں',
|
|
407
429
|
},
|
|
430
|
+
autoCorrect: {
|
|
431
|
+
title: 'خودکار تصحیح',
|
|
432
|
+
language: 'زبان',
|
|
433
|
+
from: 'لکھا ہوا لفظ',
|
|
434
|
+
fromPlaceholder: 'جو لفظ لکھا جاتا ہے',
|
|
435
|
+
to: 'درست لفظ',
|
|
436
|
+
toPlaceholder: 'اسے درست کریں',
|
|
437
|
+
save: 'تصحیح محفوظ کریں',
|
|
438
|
+
saved: 'محفوظ ہو گئی۔ اگلے لفظ پر لاگو ہوگی۔',
|
|
439
|
+
noWritableStore: 'کوئی ذخیرہ نئی تصحیح قبول نہیں کرتا',
|
|
440
|
+
failed: 'تصحیح محفوظ نہیں ہو سکی',
|
|
441
|
+
close: 'بند کریں',
|
|
442
|
+
correctDocument: 'تمام متن کی تصحیح کریں',
|
|
443
|
+
},
|
|
444
|
+
contextMenu: {
|
|
445
|
+
cut: 'کاٹیں',
|
|
446
|
+
copy: 'کاپی کریں',
|
|
447
|
+
paste: 'چسپاں کریں',
|
|
448
|
+
selectAll: 'سب منتخب کریں',
|
|
449
|
+
spelling: 'ہجے کی تجاویز',
|
|
450
|
+
noSuggestions: 'کوئی تجویز نہیں',
|
|
451
|
+
},
|
|
408
452
|
link: {
|
|
409
453
|
menuLabel: 'لنک',
|
|
410
454
|
noUrl: '(کوئی یو آر ایل نہیں)',
|
|
@@ -627,16 +671,16 @@ const paShahmukhi = {
|
|
|
627
671
|
},
|
|
628
672
|
findReplace: {
|
|
629
673
|
toggle: 'لبھو تے بدلو',
|
|
630
|
-
find: '
|
|
631
|
-
replace: '
|
|
674
|
+
find: 'لبھو',
|
|
675
|
+
replace: 'بدلو',
|
|
632
676
|
findPlaceholder: 'جو لبھنا اے',
|
|
633
677
|
replacePlaceholder: 'بدلن والا متن',
|
|
634
678
|
previous: 'پچھلا',
|
|
635
679
|
next: 'اگلا',
|
|
636
|
-
replaceOne: '
|
|
637
|
-
replaceAll: 'سارے
|
|
680
|
+
replaceOne: 'بدلو',
|
|
681
|
+
replaceAll: 'سارے بدلو',
|
|
638
682
|
noMatches: 'کوئی ملدا نئیں',
|
|
639
|
-
close: 'بند
|
|
683
|
+
close: 'بند کرو',
|
|
640
684
|
},
|
|
641
685
|
spellcheck: {
|
|
642
686
|
title: 'ہجے دی جانچ',
|
|
@@ -648,6 +692,28 @@ const paShahmukhi = {
|
|
|
648
692
|
next: 'اگلا',
|
|
649
693
|
noSuggestions: 'کوئی تجویز نئیں',
|
|
650
694
|
},
|
|
695
|
+
autoCorrect: {
|
|
696
|
+
title: 'خودکار درستی',
|
|
697
|
+
language: 'بولی',
|
|
698
|
+
from: 'لکھیا ہویا لفظ',
|
|
699
|
+
fromPlaceholder: 'جو لفظ لکھیا جاندا اے',
|
|
700
|
+
to: 'ٹھیک لفظ',
|
|
701
|
+
toPlaceholder: 'ایس نوں ٹھیک کرو',
|
|
702
|
+
save: 'درستی سانبھو',
|
|
703
|
+
saved: 'سانبھ لیا۔ اگلے لفظ تے لاگو ہووے گی۔',
|
|
704
|
+
noWritableStore: 'کوئی ذخیرہ نویں درستی نئیں منّدا',
|
|
705
|
+
failed: 'درستی سانبھی نئیں جا سکی',
|
|
706
|
+
close: 'بند کرو',
|
|
707
|
+
correctDocument: 'پورے متن دی درستی کرو',
|
|
708
|
+
},
|
|
709
|
+
contextMenu: {
|
|
710
|
+
cut: 'کٹو',
|
|
711
|
+
copy: 'کاپی کرو',
|
|
712
|
+
paste: 'چسپاں کرو',
|
|
713
|
+
selectAll: 'سارا چنو',
|
|
714
|
+
spelling: 'ہجے دیاں تجویزاں',
|
|
715
|
+
noSuggestions: 'کوئی تجویز نئیں',
|
|
716
|
+
},
|
|
651
717
|
link: {
|
|
652
718
|
menuLabel: 'لنک',
|
|
653
719
|
noUrl: '(کوئی یو آر ایل نئیں)',
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,9 @@ export type { FontOption } from './fonts/index.js';
|
|
|
9
9
|
export { STRINGS, getStrings, useStrings, useUiStrings, UiStringsContext } from './i18n/index.js';
|
|
10
10
|
export type { Locale, Strings } from './i18n/index.js';
|
|
11
11
|
export { registerSpellDictionary, hasSpellDictionary, type HunspellFiles, type SpellLanguage } from './spellcheck/spellDictionaries.js';
|
|
12
|
+
export { localStorageAutoCorrectStore, apiAutoCorrectStore, fileAutoCorrectStore } from './autocorrect/autoCorrectStores.js';
|
|
13
|
+
export type { AutoCorrectStore, AutoCorrectEntry } from './autocorrect/autoCorrectStores.js';
|
|
14
|
+
export { normalizeUrdu, normalizeUrduCharacters, removeUrduDiacritics, replaceUrduDigits } from './normalization/urduNormalize.js';
|
|
15
|
+
export type { UrduNormalizationOptions } from './normalization/urduNormalize.js';
|
|
16
|
+
export type { PunctuationOptions, PunctuationRule } from './autocorrect/punctuationRules.js';
|
|
12
17
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1G,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrF,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AACzF,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAE,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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ageNode.js'
|
|
|
4
4
|
export { DEFAULT_FONT_OPTIONS, URDU_WEB_FONT_OPTIONS, FONT_SIZES_PX } from './fonts/index.js';
|
|
5
5
|
export { STRINGS, getStrings, useStrings, useUiStrings, UiStringsContext } from './i18n/index.js';
|
|
6
6
|
export { registerSpellDictionary, hasSpellDictionary } from './spellcheck/spellDictionaries.js';
|
|
7
|
+
export { localStorageAutoCorrectStore, apiAutoCorrectStore, fileAutoCorrectStore } from './autocorrect/autoCorrectStores.js';
|
|
8
|
+
export { normalizeUrdu, normalizeUrduCharacters, removeUrduDiacritics, replaceUrduDigits } from './normalization/urduNormalize.js';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Urdu character normalisation, ported from urduhack's `normalization/character.py`
|
|
3
|
+
* (MIT licence, https://github.com/urduhack/urduhack). The mapping replaces
|
|
4
|
+
* Arabic and presentation-form letters with the standard Urdu letter, and
|
|
5
|
+
* the tables below keep the same entries and order as the original, so the
|
|
6
|
+
* output matches it character for character.
|
|
7
|
+
*/
|
|
8
|
+
/** Replaces Arabic and presentation-form letters with standard Urdu letters, character by character. */
|
|
9
|
+
export declare function normalizeUrduCharacters(text: string): string;
|
|
10
|
+
export declare function removeUrduDiacritics(text: string): string;
|
|
11
|
+
/** Converts Urdu digits to English digits, or the reverse. */
|
|
12
|
+
export declare function replaceUrduDigits(text: string, to: 'english' | 'urdu'): string;
|
|
13
|
+
export interface UrduNormalizationOptions {
|
|
14
|
+
/** Remove harakat. Off by default, since they are meaningful in poetry and religious text. */
|
|
15
|
+
removeDiacritics?: boolean;
|
|
16
|
+
/** Digit style to convert to; 'keep' (the default) leaves digits as they are. */
|
|
17
|
+
digits?: 'keep' | 'english' | 'urdu';
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The normalisation urduhack's `normalize` applies, with the diacritic and
|
|
21
|
+
* digit steps made optional. Character mapping always runs.
|
|
22
|
+
*/
|
|
23
|
+
export declare function normalizeUrdu(text: string, options?: UrduNormalizationOptions): string;
|
|
24
|
+
//# sourceMappingURL=urduNormalize.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"urduNormalize.d.ts","sourceRoot":"","sources":["../../src/normalization/urduNormalize.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8EH,wGAAwG;AACxG,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAI5D;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAIzD;AAED,8DAA8D;AAC9D,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAS9E;AAED,MAAM,WAAW,wBAAwB;IACvC,8FAA8F;IAC9F,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iFAAiF;IACjF,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAAC;CACtC;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,MAAM,CAK1F"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Urdu character normalisation, ported from urduhack's `normalization/character.py`
|
|
3
|
+
* (MIT licence, https://github.com/urduhack/urduhack). The mapping replaces
|
|
4
|
+
* Arabic and presentation-form letters with the standard Urdu letter, and
|
|
5
|
+
* the tables below keep the same entries and order as the original, so the
|
|
6
|
+
* output matches it character for character.
|
|
7
|
+
*/
|
|
8
|
+
const CORRECT_URDU_CHARACTERS = {
|
|
9
|
+
"آ": ["ﺁ", "ﺂ"],
|
|
10
|
+
"أ": ["ﺃ"],
|
|
11
|
+
"ا": ["ﺍ", "ﺎ"],
|
|
12
|
+
"ب": ["ﺏ", "ﺐ", "ﺑ", "ﺒ"],
|
|
13
|
+
"پ": ["ﭖ", "ﭘ", "ﭙ"],
|
|
14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": ["ﮍ", "ﮌ"],
|
|
40
|
+
"ژ": ["ﮋ"],
|
|
41
|
+
"ک": ["ﮎ", "ﮏ", "ﮐ", "ﮑ", "ﻛ", "ك"],
|
|
42
|
+
"گ": ["ﮒ", "ﮓ", "ﮔ", "ﮕ"],
|
|
43
|
+
"ں": ["ﮞ", "ﮟ"],
|
|
44
|
+
"و": ["ﻮ", "ﻭ", "ﻮ"],
|
|
45
|
+
"ؤ": ["ﺅ"],
|
|
46
|
+
"ھ": ["ﮪ", "ﮬ", "ﮭ", "ﻬ", "ﻫ", "ﮫ"],
|
|
47
|
+
"ہ": ["ﻩ", "ﮦ", "ﻪ", "ﮧ", "ﮩ", "ﮨ", "ه"],
|
|
48
|
+
"ۂ": [],
|
|
49
|
+
"ۃ": ["ة"],
|
|
50
|
+
"ء": ["ﺀ"],
|
|
51
|
+
"ی": ["ﯼ", "ى", "ﯽ", "ﻰ", "ﻱ", "ﻲ", "ﯾ", "ﯿ", "ي"],
|
|
52
|
+
"ئ": ["ﺋ", "ﺌ"],
|
|
53
|
+
"ے": ["ﮮ", "ﮯ", "ﻳ", "ﻴ"],
|
|
54
|
+
"ۓ": [],
|
|
55
|
+
"۰": ["٠"],
|
|
56
|
+
"۱": ["١"],
|
|
57
|
+
"۲": ["٢"],
|
|
58
|
+
"۳": ["٣"],
|
|
59
|
+
"۴": ["٤"],
|
|
60
|
+
"۵": ["٥"],
|
|
61
|
+
"۶": ["٦"],
|
|
62
|
+
"۷": ["٧"],
|
|
63
|
+
"۸": ["٨"],
|
|
64
|
+
"۹": ["٩"],
|
|
65
|
+
"۔": [],
|
|
66
|
+
"؟": [],
|
|
67
|
+
"٫": [],
|
|
68
|
+
"،": [],
|
|
69
|
+
"لا": ["ﻻ", "ﻼ"],
|
|
70
|
+
"": ["ـ"],
|
|
71
|
+
};
|
|
72
|
+
const TRANSLATOR = new Map();
|
|
73
|
+
for (const [key, values] of Object.entries(CORRECT_URDU_CHARACTERS)) {
|
|
74
|
+
for (const value of values)
|
|
75
|
+
TRANSLATOR.set(value, key);
|
|
76
|
+
}
|
|
77
|
+
/** Combining diacritics (harakat and similar), as urduhack's URDU_DIACRITICS. */
|
|
78
|
+
const DIACRITICS = new Set(['َ', 'ً', 'ٰ', 'ِ', 'ُ', 'ٍ']);
|
|
79
|
+
const ENGLISH_DIGITS = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
|
|
80
|
+
const URDU_DIGITS = ['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'];
|
|
81
|
+
/** Replaces Arabic and presentation-form letters with standard Urdu letters, character by character. */
|
|
82
|
+
export function normalizeUrduCharacters(text) {
|
|
83
|
+
let out = '';
|
|
84
|
+
for (const char of text)
|
|
85
|
+
out += TRANSLATOR.get(char) ?? char;
|
|
86
|
+
return out;
|
|
87
|
+
}
|
|
88
|
+
export function removeUrduDiacritics(text) {
|
|
89
|
+
let out = '';
|
|
90
|
+
for (const char of text)
|
|
91
|
+
if (!DIACRITICS.has(char))
|
|
92
|
+
out += char;
|
|
93
|
+
return out;
|
|
94
|
+
}
|
|
95
|
+
/** Converts Urdu digits to English digits, or the reverse. */
|
|
96
|
+
export function replaceUrduDigits(text, to) {
|
|
97
|
+
const from = to === 'english' ? URDU_DIGITS : ENGLISH_DIGITS;
|
|
98
|
+
const target = to === 'english' ? ENGLISH_DIGITS : URDU_DIGITS;
|
|
99
|
+
let out = '';
|
|
100
|
+
for (const char of text) {
|
|
101
|
+
const index = from.indexOf(char);
|
|
102
|
+
out += index === -1 ? char : target[index];
|
|
103
|
+
}
|
|
104
|
+
return out;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The normalisation urduhack's `normalize` applies, with the diacritic and
|
|
108
|
+
* digit steps made optional. Character mapping always runs.
|
|
109
|
+
*/
|
|
110
|
+
export function normalizeUrdu(text, options = {}) {
|
|
111
|
+
let out = options.removeDiacritics ? removeUrduDiacritics(text) : text;
|
|
112
|
+
out = normalizeUrduCharacters(out);
|
|
113
|
+
if (options.digits === 'english' || options.digits === 'urdu')
|
|
114
|
+
out = replaceUrduDigits(out, options.digits);
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FindMatch } from '../find/findReplaceActions.js';
|
|
2
|
+
/** A word under the pointer, as a Lexical range, with the direction of its block. */
|
|
3
|
+
export interface WordAtPoint {
|
|
4
|
+
word: string;
|
|
5
|
+
direction: 'ltr' | 'rtl';
|
|
6
|
+
match: FindMatch;
|
|
7
|
+
}
|
|
8
|
+
/** The DOM text node and offset under a viewport point, or null if the point is not on text. */
|
|
9
|
+
export declare function textPointAt(x: number, y: number): {
|
|
10
|
+
node: Node;
|
|
11
|
+
offset: number;
|
|
12
|
+
} | null;
|
|
13
|
+
/** The whole word around an offset in a Lexical text node. Must run inside an editor read or update. */
|
|
14
|
+
export declare function $wordAtDomPoint(domText: Node, offset: number): WordAtPoint | null;
|
|
15
|
+
//# sourceMappingURL=spellingMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spellingMenu.d.ts","sourceRoot":"","sources":["../../src/spellcheck/spellingMenu.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAG5D,qFAAqF;AACrF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,KAAK,GAAG,KAAK,CAAC;IACzB,KAAK,EAAE,SAAS,CAAC;CAClB;AAED,gGAAgG;AAChG,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAUvF;AAED,wGAAwG;AACxG,wBAAgB,eAAe,CAAC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAWjF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { $getNearestNodeFromDOMNode, $isTextNode } from 'lexical';
|
|
2
|
+
import { wordsIn } from './spellDictionaries.js';
|
|
3
|
+
/** The DOM text node and offset under a viewport point, or null if the point is not on text. */
|
|
4
|
+
export function textPointAt(x, y) {
|
|
5
|
+
const doc = document;
|
|
6
|
+
if (doc.caretPositionFromPoint) {
|
|
7
|
+
const position = doc.caretPositionFromPoint(x, y);
|
|
8
|
+
return position && position.offsetNode.nodeType === Node.TEXT_NODE ? { node: position.offsetNode, offset: position.offset } : null;
|
|
9
|
+
}
|
|
10
|
+
const range = doc.caretRangeFromPoint?.(x, y);
|
|
11
|
+
return range && range.startContainer.nodeType === Node.TEXT_NODE ? { node: range.startContainer, offset: range.startOffset } : null;
|
|
12
|
+
}
|
|
13
|
+
/** The whole word around an offset in a Lexical text node. Must run inside an editor read or update. */
|
|
14
|
+
export function $wordAtDomPoint(domText, offset) {
|
|
15
|
+
const node = $getNearestNodeFromDOMNode(domText);
|
|
16
|
+
if (!$isTextNode(node))
|
|
17
|
+
return null;
|
|
18
|
+
const text = node.getTextContent();
|
|
19
|
+
const span = wordsIn(text).find((s) => offset >= s.start && offset <= s.end);
|
|
20
|
+
if (!span)
|
|
21
|
+
return null;
|
|
22
|
+
return {
|
|
23
|
+
word: span.word,
|
|
24
|
+
direction: node.getParentOrThrow().getDirection() === 'rtl' ? 'rtl' : 'ltr',
|
|
25
|
+
match: { anchorKey: node.getKey(), anchorOffset: span.start, focusKey: node.getKey(), focusOffset: span.end },
|
|
26
|
+
};
|
|
27
|
+
}
|
package/dist/theme/editor.css
CHANGED
|
@@ -997,3 +997,61 @@
|
|
|
997
997
|
gap: 4px;
|
|
998
998
|
}
|
|
999
999
|
|
|
1000
|
+
/* Auto-correct panel: the same floating spot as the spellcheck panel. */
|
|
1001
|
+
.likhari-autocorrect-panel {
|
|
1002
|
+
position: absolute;
|
|
1003
|
+
z-index: 5;
|
|
1004
|
+
top: 8px;
|
|
1005
|
+
right: 16px;
|
|
1006
|
+
width: 260px;
|
|
1007
|
+
max-width: calc(100% - 32px);
|
|
1008
|
+
padding: 8px;
|
|
1009
|
+
border: 1px solid var(--editor-line);
|
|
1010
|
+
border-radius: 6px;
|
|
1011
|
+
background: var(--editor-paper-dim);
|
|
1012
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
|
|
1013
|
+
font-size: 13px;
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
.likhari-autocorrect-panel[dir='rtl'] {
|
|
1017
|
+
right: auto;
|
|
1018
|
+
left: 16px;
|
|
1019
|
+
}
|
|
1020
|
+
|
|
1021
|
+
.likhari-autocorrect-field {
|
|
1022
|
+
display: flex;
|
|
1023
|
+
flex-direction: column;
|
|
1024
|
+
gap: 2px;
|
|
1025
|
+
margin-bottom: 6px;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
.likhari-autocorrect-field input,
|
|
1029
|
+
.likhari-autocorrect-field select {
|
|
1030
|
+
padding: 3px 6px;
|
|
1031
|
+
border: 1px solid var(--editor-line);
|
|
1032
|
+
border-radius: 4px;
|
|
1033
|
+
background: var(--editor-paper);
|
|
1034
|
+
color: inherit;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
.likhari-autocorrect-actions {
|
|
1038
|
+
display: flex;
|
|
1039
|
+
flex-direction: column;
|
|
1040
|
+
gap: 6px;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
.likhari-autocorrect-actions button {
|
|
1044
|
+
align-self: flex-start;
|
|
1045
|
+
padding: 2px 8px;
|
|
1046
|
+
border: 1px solid var(--editor-line);
|
|
1047
|
+
border-radius: 4px;
|
|
1048
|
+
background: transparent;
|
|
1049
|
+
color: inherit;
|
|
1050
|
+
cursor: pointer;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
.likhari-autocorrect-actions button:disabled {
|
|
1054
|
+
opacity: 0.5;
|
|
1055
|
+
cursor: default;
|
|
1056
|
+
}
|
|
1057
|
+
|