@inshapardaz/likhari-react 0.1.25-dev.224 → 0.1.25
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.map +1 -1
- package/dist/EditorRoot.js +1 -2
- package/dist/i18n/strings.d.ts +0 -3
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +0 -9
- package/dist/spellcheck/spellDictionaries.d.ts +0 -4
- package/dist/spellcheck/spellDictionaries.d.ts.map +1 -1
- package/dist/spellcheck/spellDictionaries.js +3 -29
- package/dist/spellcheck/userWords.d.ts +0 -2
- package/dist/spellcheck/userWords.d.ts.map +1 -1
- package/dist/spellcheck/userWords.js +0 -4
- package/dist/theme/editor.css +0 -22
- package/package.json +1 -1
- package/dist/autocomplete/AutocompletePlugin.d.ts +0 -11
- package/dist/autocomplete/AutocompletePlugin.d.ts.map +0 -1
- package/dist/autocomplete/AutocompletePlugin.js +0 -180
- package/dist/autocomplete/wordIndex.d.ts +0 -13
- package/dist/autocomplete/wordIndex.d.ts.map +0 -1
- package/dist/autocomplete/wordIndex.js +0 -37
package/dist/EditorRoot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorRoot.d.ts","sourceRoot":"","sources":["../src/EditorRoot.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAY1D,OAAO,KAAK,EAA8B,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEjF,OAAO,EAAyB,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AACvF,OAAO,EAAwB,KAAK,mBAAmB,EAAE,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAKzH,OAAO,EAAyB,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAOjE,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIhF,OAAO,E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AuG;IACvG,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IAC3E,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,UAAU,CAAC,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IACrC,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC;IAClD,iBAAiB,IAAI,OAAO,CAAC;IAC7B,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAQD,eAAO,MAAM,UAAU,uGAibrB,CAAC"}
|
package/dist/EditorRoot.js
CHANGED
|
@@ -32,7 +32,6 @@ import { AutoCorrectPlugin } from './autocorrect/AutoCorrectPlugin.js';
|
|
|
32
32
|
import { localStorageAutoCorrectStore } from './autocorrect/autoCorrectStores.js';
|
|
33
33
|
import { SpellcheckPanel } from './components/SpellcheckPanel.js';
|
|
34
34
|
import { SpellHighlightPlugin } from './spellcheck/SpellHighlightPlugin.js';
|
|
35
|
-
import { AutocompletePlugin } from './autocomplete/AutocompletePlugin.js';
|
|
36
35
|
import { loadUserWords, localStorageUserWordStore } from './spellcheck/userWords.js';
|
|
37
36
|
import { LeaveDialog } from './components/LeaveDialog.js';
|
|
38
37
|
import { clearDraft, createDraftId, hasDraftContent, pruneDrafts, writeDraft, } from './persistence/draftStorage.js';
|
|
@@ -306,7 +305,7 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorre
|
|
|
306
305
|
const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
|
|
307
306
|
return (_jsx(EditorThemeProvider, { theme: theme, colorScheme: colorScheme, accentColor: accentColor, scopeElementId: portalTargetId, children: _jsxs("div", { className: "likhari-root", dir: dir, ref: rootElementRef, "data-document-id": documentId, style: { height: typeof height === 'number' ? `${height}px` : height }, children: [_jsx("div", { id: portalTargetId, className: "likhari-portal-target" }), _jsx(PortalTargetContext.Provider, { value: portalTargetSelector, children: _jsxs(UiStringsContext.Provider, { value: strings, children: [_jsx(ImageOptionsContext.Provider, { value: imageOptions, children: _jsxs(LexicalComposer, { initialConfig: initialConfig, children: [_jsx(Toolbar, { config: config, dictionaryStores: wordStores, onAddAutoCorrect: config.language.autocorrect ? openAutoCorrectFor : undefined, onSave: handleSave, findOpen: openPanel === 'find', onToggleFind: () => togglePanel('find'), spellOpen: openPanel === 'spell', onToggleSpell: () => togglePanel('spell'), autoCorrectOpen: openPanel === 'autocorrect', onToggleAutoCorrect: () => togglePanel('autocorrect'), isDirty: isDirty, showSave: showSave, fontOptions: fontOptions, direction: dir, locale: locale, drafts: autosave
|
|
308
307
|
? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
|
|
309
|
-
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsxs("div", { className: "likhari-canvas-frame", children: [config.findReplace && openPanel === 'find' && _jsx(FindReplaceBar, { strings: strings, dir: dir, onClose: () => setOpenPanel(null) }), config.language.spellCheck && openPanel === 'spell' && (_jsx(SpellcheckPanel, { strings: strings, dir: dir, dictionaryStores: wordStores, onAddAutoCorrect: config.language.autocorrect ? openAutoCorrectFor : undefined, onClose: () => setOpenPanel(null) })), config.language.autocorrect && openPanel === 'autocorrect' && (_jsx(AutoCorrectPanel, { strings: strings, dir: dir, stores: stores, initialFrom: autoCorrectPrefill?.from, initialLanguage: autoCorrectPrefill?.language, onSaved: () => setAutoCorrectVersion((v) => v + 1), onClose: () => setOpenPanel(null) }, autoCorrectPrefill?.id ?? 0)), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, spellCheck: false, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) })] }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.blocks.pageBreak && _jsx(PageBreakPlugin, {}), config.language.spellCheck && _jsx(SpellHighlightPlugin, {}),
|
|
308
|
+
: undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsxs("div", { className: "likhari-canvas-frame", children: [config.findReplace && openPanel === 'find' && _jsx(FindReplaceBar, { strings: strings, dir: dir, onClose: () => setOpenPanel(null) }), config.language.spellCheck && openPanel === 'spell' && (_jsx(SpellcheckPanel, { strings: strings, dir: dir, dictionaryStores: wordStores, onAddAutoCorrect: config.language.autocorrect ? openAutoCorrectFor : undefined, onClose: () => setOpenPanel(null) })), config.language.autocorrect && openPanel === 'autocorrect' && (_jsx(AutoCorrectPanel, { strings: strings, dir: dir, stores: stores, initialFrom: autoCorrectPrefill?.from, initialLanguage: autoCorrectPrefill?.language, onSaved: () => setAutoCorrectVersion((v) => v + 1), onClose: () => setOpenPanel(null) }, autoCorrectPrefill?.id ?? 0)), _jsx("div", { className: "likhari-canvas", children: _jsx(RichTextPlugin, { contentEditable: _jsx(ContentEditable, { className: "likhari-content-editable", dir: dir, spellCheck: false, "aria-label": strings.editor.contentLabel }), placeholder: _jsx("div", { className: "likhari-placeholder", children: resolvedPlaceholder }), ErrorBoundary: LexicalErrorBoundary }) })] }), config.history && _jsx(HistoryPlugin, {}), (config.lists.bullet || config.lists.numbered || config.lists.check) && _jsx(ListPlugin, {}), config.lists.check && _jsx(CheckListPlugin, {}), config.links && _jsx(LinkPlugin, {}), config.links && _jsx(LinkPastePlugin, {}), config.blocks.pageBreak && _jsx(PageBreakPlugin, {}), config.language.spellCheck && _jsx(SpellHighlightPlugin, {}), (config.language.autocorrect || config.language.textCleanup) && _jsx(AutoCorrectPlugin, { stores: stores, version: autoCorrectVersion, enabled: true, typing: config.language.autocorrect, urduNormalization: urduNormalization, punctuation: punctuation }), config.columns && _jsx(LayoutPlugin, {}), config.footnotes && _jsx(FootnotePlugin, {}), config.poetry.enabled && _jsx(PoetryPlugin, {}), config.poetry.enabled && _jsx(PoetryResizer, {}), config.tables && _jsx(TablePlugin, { hasCellMerge: true, hasTabHandler: true }), config.blocks.horizontalRule && _jsx(HorizontalRulePlugin, {}), _jsx(EditorInstancePlugin, { instanceRef: editorInstanceRef }), _jsx(OnChangePlugin, { onChange: handleChange })] }) }), _jsx(LeaveDialog, { opened: leavePrompt !== null, canSave: Boolean(onSave), canSaveDraft: autosave || navigationGuard === 'save-draft', draftFailed: leavePrompt?.draftFailed ?? false, onSave: () => {
|
|
310
309
|
handleSave();
|
|
311
310
|
settleLeave(true);
|
|
312
311
|
}, onSaveDraft: () => {
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strings.d.ts","sourceRoot":"","sources":["../../src/i18n/strings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;+DAC+D;AAC/D,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,cAAc,CAAC;AAElD,MAAM,WAAW,OAAO;IACtB,MAAM,EAAE;QACN,mGAAmG;QACnG,WAAW,EAAE,MAAM,CAAC;QACpB,gDAAgD;QAChD,YAAY,EAAE,MAAM,CAAC;QACrB,sEAAsE;QACtE,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IACF,MAAM,EAAE;QACN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AE,MAAM,CAAC,MAAM,EAAE,OAAO,CAI3C,CAAC;AAEF;;sDAEsD;AACtD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD"}
|
package/dist/i18n/strings.js
CHANGED
|
@@ -187,9 +187,6 @@ const en = {
|
|
|
187
187
|
spelling: 'Spelling suggestions',
|
|
188
188
|
noSuggestions: 'No suggestions',
|
|
189
189
|
},
|
|
190
|
-
autoComplete: {
|
|
191
|
-
label: 'Suggestions',
|
|
192
|
-
},
|
|
193
190
|
link: {
|
|
194
191
|
menuLabel: 'Link',
|
|
195
192
|
noUrl: '(no URL)',
|
|
@@ -458,9 +455,6 @@ const ur = {
|
|
|
458
455
|
spelling: 'ہجے کی تجاویز',
|
|
459
456
|
noSuggestions: 'کوئی تجویز نہیں',
|
|
460
457
|
},
|
|
461
|
-
autoComplete: {
|
|
462
|
-
label: 'تجاویز',
|
|
463
|
-
},
|
|
464
458
|
link: {
|
|
465
459
|
menuLabel: 'لنک',
|
|
466
460
|
noUrl: '(کوئی یو آر ایل نہیں)',
|
|
@@ -729,9 +723,6 @@ const paShahmukhi = {
|
|
|
729
723
|
spelling: 'ہجے دیاں تجویزاں',
|
|
730
724
|
noSuggestions: 'کوئی تجویز نئیں',
|
|
731
725
|
},
|
|
732
|
-
autoComplete: {
|
|
733
|
-
label: 'تجویزاں',
|
|
734
|
-
},
|
|
735
726
|
link: {
|
|
736
727
|
menuLabel: 'لنک',
|
|
737
728
|
noUrl: '(کوئی یو آر ایل نئیں)',
|
|
@@ -27,10 +27,6 @@ export declare function hasSpellDictionary(language: SpellLanguage): boolean;
|
|
|
27
27
|
* can skip spellchecking that language rather than flag every word.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getSpeller(language: SpellLanguage): Promise<Speller> | null;
|
|
30
|
-
/** The dictionary's root words (its .dic entries without affix flags), for completion. */
|
|
31
|
-
export declare function dictionaryWords(dic: string): string[];
|
|
32
|
-
/** The language's dictionary words, or null when no dictionary is registered. */
|
|
33
|
-
export declare function getDictionaryWords(language: SpellLanguage): Promise<string[]> | null;
|
|
34
30
|
/** A word in a text, with its position as character offsets. */
|
|
35
31
|
export interface WordSpan {
|
|
36
32
|
word: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spellDictionaries.d.ts","sourceRoot":"","sources":["../../src/spellcheck/spellDictionaries.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,cAAc,CAAC;AAEzD,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACjC;AAED,KAAK,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"spellDictionaries.d.ts","sourceRoot":"","sources":["../../src/spellcheck/spellDictionaries.ts"],"names":[],"mappings":"AAGA,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,IAAI,GAAG,IAAI,GAAG,cAAc,CAAC;AAEzD,wFAAwF;AACxF,MAAM,WAAW,aAAa;IAC5B,uDAAuD;IACvD,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACjC;AAED,KAAK,MAAM,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;AAmB3C;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAGpG;AAED,2DAA2D;AAC3D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAe3E;AAED,gEAAgE;AAChE,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AASD,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,EAAE,CAMhD;AAED,0DAA0D;AAC1D,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,QAAQ,EAAE,CAEzE"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import nspell from 'nspell';
|
|
2
2
|
import { isAcceptedWord } from './userWords.js';
|
|
3
3
|
const loaders = new Map();
|
|
4
|
-
const loadedFiles = new Map();
|
|
5
4
|
const spellers = new Map();
|
|
6
5
|
async function fetchText(url) {
|
|
7
6
|
const response = await fetch(url);
|
|
@@ -24,7 +23,6 @@ loaders.set('en', englishLoader);
|
|
|
24
23
|
export function registerSpellDictionary(language, files) {
|
|
25
24
|
loaders.set(language, typeof files === 'function' ? files : async () => files);
|
|
26
25
|
spellers.delete(language);
|
|
27
|
-
loadedFiles.delete(language);
|
|
28
26
|
}
|
|
29
27
|
/** Whether a dictionary is registered for the language. */
|
|
30
28
|
export function hasSpellDictionary(language) {
|
|
@@ -36,11 +34,12 @@ export function hasSpellDictionary(language) {
|
|
|
36
34
|
* can skip spellchecking that language rather than flag every word.
|
|
37
35
|
*/
|
|
38
36
|
export function getSpeller(language) {
|
|
39
|
-
|
|
37
|
+
const loader = loaders.get(language);
|
|
38
|
+
if (!loader)
|
|
40
39
|
return null;
|
|
41
40
|
let speller = spellers.get(language);
|
|
42
41
|
if (!speller) {
|
|
43
|
-
speller =
|
|
42
|
+
speller = loader()
|
|
44
43
|
.then(({ aff, dic }) => nspell(aff, dic))
|
|
45
44
|
.then((base) => ({
|
|
46
45
|
// Words the user added or ignored count as correct, whatever the dictionary says.
|
|
@@ -51,31 +50,6 @@ export function getSpeller(language) {
|
|
|
51
50
|
}
|
|
52
51
|
return speller;
|
|
53
52
|
}
|
|
54
|
-
/** The dictionary's files, loaded once per language and shared by the speller and the word list. */
|
|
55
|
-
function filesFor(language) {
|
|
56
|
-
let loaded = loadedFiles.get(language);
|
|
57
|
-
if (!loaded) {
|
|
58
|
-
loaded = loaders.get(language)();
|
|
59
|
-
loadedFiles.set(language, loaded);
|
|
60
|
-
}
|
|
61
|
-
return loaded;
|
|
62
|
-
}
|
|
63
|
-
/** The dictionary's root words (its .dic entries without affix flags), for completion. */
|
|
64
|
-
export function dictionaryWords(dic) {
|
|
65
|
-
const words = new Set();
|
|
66
|
-
for (const line of dic.split(/\r?\n/).slice(1)) {
|
|
67
|
-
const word = line.split('/')[0].trim();
|
|
68
|
-
if (word)
|
|
69
|
-
words.add(word);
|
|
70
|
-
}
|
|
71
|
-
return [...words];
|
|
72
|
-
}
|
|
73
|
-
/** The language's dictionary words, or null when no dictionary is registered. */
|
|
74
|
-
export function getDictionaryWords(language) {
|
|
75
|
-
if (!loaders.has(language))
|
|
76
|
-
return null;
|
|
77
|
-
return filesFor(language).then(({ dic }) => dictionaryWords(dic));
|
|
78
|
-
}
|
|
79
53
|
/**
|
|
80
54
|
* Letters and combining marks, with apostrophes inside a word kept. The
|
|
81
55
|
* Unicode classes cover Arabic-script letters and their diacritics, so Urdu
|
|
@@ -24,8 +24,6 @@ export declare function apiUserWordStore(options: {
|
|
|
24
24
|
headers?: Record<string, string>;
|
|
25
25
|
fetch?: typeof fetch;
|
|
26
26
|
}): UserWordStore;
|
|
27
|
-
/** The words the user has added to the dictionary for a language. */
|
|
28
|
-
export declare function acceptedWords(language: SpellLanguage): string[];
|
|
29
27
|
/** Calls `listener` whenever accepted or ignored words change. Returns an unsubscribe function. */
|
|
30
28
|
export declare function onSpellWordsChange(listener: () => void): () => void;
|
|
31
29
|
/** Whether the speller should treat the word as correct: it is in the user's dictionary or ignored this session. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userWords.d.ts","sourceRoot":"","sources":["../../src/spellcheck/userWords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,IAAI,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,MAAM,CAAC,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAoBD,0EAA0E;AAC1E,wBAAgB,yBAAyB,CAAC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,aAAa,CAoBvF;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB,GAAG,aAAa,CAmBhB;AAWD,
|
|
1
|
+
{"version":3,"file":"userWords.d.ts","sourceRoot":"","sources":["../../src/spellcheck/userWords.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD;;;;GA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C,QAAQ,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAUtE"}
|
|
@@ -68,10 +68,6 @@ function notify() {
|
|
|
68
68
|
for (const listener of listeners)
|
|
69
69
|
listener();
|
|
70
70
|
}
|
|
71
|
-
/** The words the user has added to the dictionary for a language. */
|
|
72
|
-
export function acceptedWords(language) {
|
|
73
|
-
return [...(accepted.get(language) ?? [])];
|
|
74
|
-
}
|
|
75
71
|
/** Calls `listener` whenever accepted or ignored words change. Returns an unsubscribe function. */
|
|
76
72
|
export function onSpellWordsChange(listener) {
|
|
77
73
|
listeners.add(listener);
|
package/dist/theme/editor.css
CHANGED
|
@@ -1055,25 +1055,3 @@
|
|
|
1055
1055
|
cursor: default;
|
|
1056
1056
|
}
|
|
1057
1057
|
|
|
1058
|
-
/* Autocomplete suggestions, shown under the caret while typing. */
|
|
1059
|
-
.likhari-autocomplete {
|
|
1060
|
-
z-index: 20;
|
|
1061
|
-
min-width: 160px;
|
|
1062
|
-
max-width: 280px;
|
|
1063
|
-
padding: 4px 0;
|
|
1064
|
-
border: 1px solid var(--editor-line);
|
|
1065
|
-
border-radius: 6px;
|
|
1066
|
-
background: var(--editor-paper-dim);
|
|
1067
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.16);
|
|
1068
|
-
font-size: 14px;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
.likhari-autocomplete-item {
|
|
1072
|
-
padding: 3px 10px;
|
|
1073
|
-
cursor: pointer;
|
|
1074
|
-
}
|
|
1075
|
-
|
|
1076
|
-
.likhari-autocomplete-item--active {
|
|
1077
|
-
background: var(--editor-accent-soft);
|
|
1078
|
-
}
|
|
1079
|
-
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Suggests completions for the word being typed, from the dictionary's words and
|
|
3
|
-
* the user's own. Shown only while typing, at the caret. Tab or Enter accepts the
|
|
4
|
-
* highlighted suggestion, the arrow keys move through the list, and Escape (or
|
|
5
|
-
* moving the caret) dismisses it. Left-to-right text uses the English dictionary,
|
|
6
|
-
* right-to-left text the Urdu one.
|
|
7
|
-
*/
|
|
8
|
-
export declare function AutocompletePlugin({ label }: {
|
|
9
|
-
label: string;
|
|
10
|
-
}): import("react").JSX.Element | null;
|
|
11
|
-
//# sourceMappingURL=AutocompletePlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AutocompletePlugin.d.ts","sourceRoot":"","sources":["../../src/autocomplete/AutocompletePlugin.tsx"],"names":[],"mappings":"AAgCA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,sCA4J9D"}
|
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from 'react';
|
|
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';
|
|
5
|
-
import { $replaceMatch } from '../find/findReplaceActions.js';
|
|
6
|
-
import { getDictionaryWords } from '../spellcheck/spellDictionaries.js';
|
|
7
|
-
import { acceptedWords, onSpellWordsChange } from '../spellcheck/userWords.js';
|
|
8
|
-
import { WordIndex } from './wordIndex.js';
|
|
9
|
-
/** The letters at the end of the text before the caret. */
|
|
10
|
-
const WORD_END = /[\p{L}\p{M}]+$/u;
|
|
11
|
-
const LETTER = /[\p{L}\p{M}]/u;
|
|
12
|
-
/** Suggestions only appear once the typed part of a word is this long. */
|
|
13
|
-
const MIN_PREFIX = 2;
|
|
14
|
-
/**
|
|
15
|
-
* Suggests completions for the word being typed, from the dictionary's words and
|
|
16
|
-
* the user's own. Shown only while typing, at the caret. Tab or Enter accepts the
|
|
17
|
-
* highlighted suggestion, the arrow keys move through the list, and Escape (or
|
|
18
|
-
* moving the caret) dismisses it. Left-to-right text uses the English dictionary,
|
|
19
|
-
* right-to-left text the Urdu one.
|
|
20
|
-
*/
|
|
21
|
-
export function AutocompletePlugin({ label }) {
|
|
22
|
-
const [editor] = useLexicalComposerContext();
|
|
23
|
-
const [popup, setPopup] = useState(null);
|
|
24
|
-
const popupRef = useRef(null);
|
|
25
|
-
const typing = useRef(false);
|
|
26
|
-
const indexes = useRef(new Map());
|
|
27
|
-
const show = (next) => {
|
|
28
|
-
popupRef.current = next;
|
|
29
|
-
setPopup(next);
|
|
30
|
-
};
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
const indexFor = (language) => {
|
|
33
|
-
let index = indexes.current.get(language);
|
|
34
|
-
if (!index) {
|
|
35
|
-
const words = getDictionaryWords(language);
|
|
36
|
-
if (!words)
|
|
37
|
-
return null;
|
|
38
|
-
index = words.then((dictionary) => new WordIndex([...dictionary, ...acceptedWords(language)]));
|
|
39
|
-
indexes.current.set(language, index);
|
|
40
|
-
}
|
|
41
|
-
return index;
|
|
42
|
-
};
|
|
43
|
-
const hide = () => show(null);
|
|
44
|
-
const refresh = () => {
|
|
45
|
-
if (!typing.current)
|
|
46
|
-
return hide();
|
|
47
|
-
let target = null;
|
|
48
|
-
editor.getEditorState().read(() => {
|
|
49
|
-
const selection = $getSelection();
|
|
50
|
-
if (!$isRangeSelection(selection) || !selection.isCollapsed())
|
|
51
|
-
return;
|
|
52
|
-
const node = selection.anchor.getNode();
|
|
53
|
-
if (!$isTextNode(node))
|
|
54
|
-
return;
|
|
55
|
-
const text = node.getTextContent();
|
|
56
|
-
const before = text.slice(0, selection.anchor.offset);
|
|
57
|
-
const prefix = WORD_END.exec(before)?.[0];
|
|
58
|
-
const after = text.charAt(selection.anchor.offset);
|
|
59
|
-
if (!prefix || prefix.length < MIN_PREFIX || (after !== '' && LETTER.test(after)))
|
|
60
|
-
return;
|
|
61
|
-
const rtl = node.getParentOrThrow().getDirection() === 'rtl';
|
|
62
|
-
target = { prefix, language: rtl ? 'ur' : 'en', dir: rtl ? 'rtl' : 'ltr' };
|
|
63
|
-
});
|
|
64
|
-
if (target === null)
|
|
65
|
-
return hide();
|
|
66
|
-
const { prefix, language, dir } = target;
|
|
67
|
-
const index = indexFor(language);
|
|
68
|
-
if (!index)
|
|
69
|
-
return hide();
|
|
70
|
-
void index.then((loaded) => {
|
|
71
|
-
const items = loaded.complete(prefix);
|
|
72
|
-
if (items.length === 0)
|
|
73
|
-
return hide();
|
|
74
|
-
const rect = caretRect(editor);
|
|
75
|
-
show({ items, index: 0, x: rect.left, y: rect.bottom, dir });
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
const move = (delta) => {
|
|
79
|
-
const current = popupRef.current;
|
|
80
|
-
if (!current)
|
|
81
|
-
return false;
|
|
82
|
-
const count = current.items.length;
|
|
83
|
-
show({ ...current, index: (current.index + delta + count) % count });
|
|
84
|
-
return true;
|
|
85
|
-
};
|
|
86
|
-
const onKeyDown = (event) => {
|
|
87
|
-
if (event.key === 'Escape' && popupRef.current) {
|
|
88
|
-
event.preventDefault();
|
|
89
|
-
show(null);
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// Printable keys and Backspace are typing; any other key (arrows, Home, ...) moves the caret.
|
|
93
|
-
typing.current = (event.key.length === 1 && !event.ctrlKey && !event.metaKey) || event.key === 'Backspace';
|
|
94
|
-
if (!typing.current)
|
|
95
|
-
hide();
|
|
96
|
-
setTimeout(refresh, 0);
|
|
97
|
-
};
|
|
98
|
-
const onMouseDown = () => {
|
|
99
|
-
typing.current = false;
|
|
100
|
-
hide();
|
|
101
|
-
};
|
|
102
|
-
let root = null;
|
|
103
|
-
const attach = (next) => {
|
|
104
|
-
root?.removeEventListener('keydown', onKeyDown);
|
|
105
|
-
root?.removeEventListener('mousedown', onMouseDown);
|
|
106
|
-
root = next;
|
|
107
|
-
root?.addEventListener('keydown', onKeyDown);
|
|
108
|
-
root?.addEventListener('mousedown', onMouseDown);
|
|
109
|
-
};
|
|
110
|
-
const unregisterRoot = editor.registerRootListener((next) => attach(next));
|
|
111
|
-
const unregisterUpdate = editor.registerUpdateListener(() => {
|
|
112
|
-
// Keydown already schedules a refresh; this keeps the list right after the
|
|
113
|
-
// dictionary or user words change.
|
|
114
|
-
if (typing.current)
|
|
115
|
-
setTimeout(refresh, 0);
|
|
116
|
-
});
|
|
117
|
-
const unregisterWords = onSpellWordsChange(() => {
|
|
118
|
-
indexes.current.clear();
|
|
119
|
-
if (typing.current)
|
|
120
|
-
setTimeout(refresh, 0);
|
|
121
|
-
});
|
|
122
|
-
const unregisterCommands = [
|
|
123
|
-
editor.registerCommand(KEY_ARROW_DOWN_COMMAND, () => move(1), COMMAND_PRIORITY_HIGH),
|
|
124
|
-
editor.registerCommand(KEY_ARROW_UP_COMMAND, () => move(-1), COMMAND_PRIORITY_HIGH),
|
|
125
|
-
editor.registerCommand(KEY_TAB_COMMAND, (event) => acceptHighlighted(event), COMMAND_PRIORITY_HIGH),
|
|
126
|
-
editor.registerCommand(KEY_ENTER_COMMAND, (event) => acceptHighlighted(event), COMMAND_PRIORITY_HIGH),
|
|
127
|
-
];
|
|
128
|
-
function acceptHighlighted(event) {
|
|
129
|
-
const current = popupRef.current;
|
|
130
|
-
if (!current)
|
|
131
|
-
return false;
|
|
132
|
-
event?.preventDefault();
|
|
133
|
-
acceptItem(editor, current.items[current.index]);
|
|
134
|
-
show(null);
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
return () => {
|
|
138
|
-
unregisterRoot();
|
|
139
|
-
unregisterUpdate();
|
|
140
|
-
unregisterWords();
|
|
141
|
-
unregisterCommands.forEach((unregister) => unregister());
|
|
142
|
-
attach(null);
|
|
143
|
-
show(null);
|
|
144
|
-
};
|
|
145
|
-
}, [editor]);
|
|
146
|
-
if (!popup)
|
|
147
|
-
return null;
|
|
148
|
-
return (_jsx("div", { className: "likhari-autocomplete", role: "listbox", "aria-label": label, dir: popup.dir, style: { position: 'fixed', left: popup.x, top: popup.y + 4 }, children: popup.items.map((item, i) => (_jsx("div", { role: "option", "aria-selected": i === popup.index, className: i === popup.index ? 'likhari-autocomplete-item likhari-autocomplete-item--active' : 'likhari-autocomplete-item', onMouseDown: (event) => {
|
|
149
|
-
event.preventDefault();
|
|
150
|
-
acceptItem(editor, item);
|
|
151
|
-
}, children: item }, item))) }));
|
|
152
|
-
}
|
|
153
|
-
/** Where to put the popup: under the caret, or the editor's top-left if the caret has no position yet. */
|
|
154
|
-
function caretRect(editor) {
|
|
155
|
-
const selection = window.getSelection();
|
|
156
|
-
if (selection && selection.rangeCount > 0) {
|
|
157
|
-
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
158
|
-
if (rect.width > 0 || rect.height > 0)
|
|
159
|
-
return { left: rect.left, bottom: rect.bottom };
|
|
160
|
-
}
|
|
161
|
-
const root = editor.getRootElement()?.getBoundingClientRect();
|
|
162
|
-
return { left: root?.left ?? 0, bottom: root?.top ?? 0 };
|
|
163
|
-
}
|
|
164
|
-
function acceptItem(editor, item) {
|
|
165
|
-
editor.update(() => {
|
|
166
|
-
const selection = $getSelection();
|
|
167
|
-
if (!$isRangeSelection(selection) || !selection.isCollapsed())
|
|
168
|
-
return;
|
|
169
|
-
const node = selection.anchor.getNode();
|
|
170
|
-
if (!$isTextNode(node))
|
|
171
|
-
return;
|
|
172
|
-
const before = node.getTextContent().slice(0, selection.anchor.offset);
|
|
173
|
-
const prefix = WORD_END.exec(before)?.[0];
|
|
174
|
-
if (!prefix)
|
|
175
|
-
return;
|
|
176
|
-
const start = before.length - prefix.length;
|
|
177
|
-
$replaceMatch({ anchorKey: node.getKey(), anchorOffset: start, focusKey: node.getKey(), focusOffset: before.length }, item);
|
|
178
|
-
}, { discrete: true });
|
|
179
|
-
editor.focus();
|
|
180
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/** Words sorted once, so every prefix lookup is a binary search rather than a scan. */
|
|
2
|
-
export declare class WordIndex {
|
|
3
|
-
private readonly words;
|
|
4
|
-
constructor(words: Iterable<string>);
|
|
5
|
-
/**
|
|
6
|
-
* Completions for a prefix: words that start with it (other than the prefix
|
|
7
|
-
* itself), shortest first, then alphabetical. Only the first `scanLimit`
|
|
8
|
-
* matches are considered, so a one-letter prefix stays quick.
|
|
9
|
-
*/
|
|
10
|
-
complete(prefix: string, limit?: number, scanLimit?: number): string[];
|
|
11
|
-
private lowerBound;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=wordIndex.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"wordIndex.d.ts","sourceRoot":"","sources":["../../src/autocomplete/wordIndex.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAW;gBAErB,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC;IAInC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,EAAE,SAAS,SAAM,GAAG,MAAM,EAAE;IAY9D,OAAO,CAAC,UAAU;CAUnB"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** Words sorted once, so every prefix lookup is a binary search rather than a scan. */
|
|
2
|
-
export class WordIndex {
|
|
3
|
-
constructor(words) {
|
|
4
|
-
this.words = [...new Set(words)].sort((a, b) => (a < b ? -1 : a > b ? 1 : 0));
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Completions for a prefix: words that start with it (other than the prefix
|
|
8
|
-
* itself), shortest first, then alphabetical. Only the first `scanLimit`
|
|
9
|
-
* matches are considered, so a one-letter prefix stays quick.
|
|
10
|
-
*/
|
|
11
|
-
complete(prefix, limit = 5, scanLimit = 500) {
|
|
12
|
-
if (prefix === '')
|
|
13
|
-
return [];
|
|
14
|
-
const matches = [];
|
|
15
|
-
for (let i = this.lowerBound(prefix); i < this.words.length && matches.length < scanLimit; i++) {
|
|
16
|
-
const word = this.words[i];
|
|
17
|
-
if (!word.startsWith(prefix))
|
|
18
|
-
break;
|
|
19
|
-
if (word !== prefix)
|
|
20
|
-
matches.push(word);
|
|
21
|
-
}
|
|
22
|
-
matches.sort((a, b) => a.length - b.length || (a < b ? -1 : a > b ? 1 : 0));
|
|
23
|
-
return matches.slice(0, limit);
|
|
24
|
-
}
|
|
25
|
-
lowerBound(prefix) {
|
|
26
|
-
let low = 0;
|
|
27
|
-
let high = this.words.length;
|
|
28
|
-
while (low < high) {
|
|
29
|
-
const mid = (low + high) >>> 1;
|
|
30
|
-
if (this.words[mid] < prefix)
|
|
31
|
-
low = mid + 1;
|
|
32
|
-
else
|
|
33
|
-
high = mid;
|
|
34
|
-
}
|
|
35
|
-
return low;
|
|
36
|
-
}
|
|
37
|
-
}
|