@inshapardaz/likhari-react 0.1.44-dev.326 → 0.1.44
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 +0 -2
- package/dist/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +4 -4
- package/dist/components/SpellcheckPanel.d.ts +1 -3
- package/dist/components/SpellcheckPanel.d.ts.map +1 -1
- package/dist/components/SpellcheckPanel.js +2 -2
- package/dist/components/Toolbar.d.ts +1 -3
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +3 -3
- package/dist/spellcheck/SpellHighlightPlugin.d.ts +1 -6
- package/dist/spellcheck/SpellHighlightPlugin.d.ts.map +1 -1
- package/dist/spellcheck/SpellHighlightPlugin.js +13 -12
- package/package.json +1 -1
package/dist/EditorRoot.d.ts
CHANGED
|
@@ -31,8 +31,6 @@ export interface EditorRootProps {
|
|
|
31
31
|
thesaurusStores?: ThesaurusStore[];
|
|
32
32
|
/** The language autocomplete works in: 'auto' follows each block's direction (English for LTR, Urdu for RTL). */
|
|
33
33
|
autoCompleteLanguage?: SpellLanguage | 'auto';
|
|
34
|
-
/** Which dictionary spellcheck (underlining, right-click suggestions and "add to dictionary") uses: 'auto' (default) follows each block's/word's own direction (English for LTR, Urdu for RTL). */
|
|
35
|
-
spellCheckLanguage?: SpellLanguage | 'auto';
|
|
36
34
|
/** Urdu normalisation applied as part of auto-correct. Diacritics are kept unless `removeDiacritics` is set. */
|
|
37
35
|
urduNormalization?: UrduNormalizationOptions;
|
|
38
36
|
/** Common punctuation fixes, and whether a straight " becomes ”. Both on by default. */
|
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,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,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,uGAuhBrB,CAAC"}
|
package/dist/EditorRoot.js
CHANGED
|
@@ -59,7 +59,7 @@ function initialEditorStateJson(initialContent) {
|
|
|
59
59
|
const state = defaultFormatRegistry.parse(initialContent.format, initialContent.value);
|
|
60
60
|
return JSON.stringify(state);
|
|
61
61
|
}
|
|
62
|
-
export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorrectStores, dictionaryStores, completionStores, thesaurusStores, autoCompleteLanguage = 'auto',
|
|
62
|
+
export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorrectStores, dictionaryStores, completionStores, thesaurusStores, autoCompleteLanguage = 'auto', urduNormalization, punctuation, initialContent, featureConfig, featurePreset, theme, colorScheme, accentColor, toolbarStyle, helpUrl, locale = 'en', placeholder, height = '480px', onChange, onSave, showSave = Boolean(onSave), onImageUpload, fetchImage, fontOptions, fontMode = 'selective', fontFamily, zoom, onFontChange, autosave = true, restoreDraft = 'prompt', navigationGuard = 'confirm', onDraftRestored, autosaveDelayMs = DEFAULT_AUTOSAVE_DELAY_MS, autosaveMaxBytes = DEFAULT_AUTOSAVE_MAX_BYTES, autosaveMaxDrafts = DEFAULT_AUTOSAVE_MAX_DRAFTS, }, ref) {
|
|
63
63
|
const config = useMemo(() => resolveFeatureConfig(featureConfig, featurePreset), [featureConfig, featurePreset]);
|
|
64
64
|
const strings = useMemo(() => getStrings(locale), [locale]);
|
|
65
65
|
const resolvedPlaceholder = placeholder ?? strings.editor.placeholder;
|
|
@@ -379,11 +379,11 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorre
|
|
|
379
379
|
// rather than colliding on a shared one.
|
|
380
380
|
const portalTargetId = useId();
|
|
381
381
|
const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
|
|
382
|
-
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, toolbarStyle: toolbarStyle, helpUrl: helpUrl, dictionaryStores: wordStores, thesaurusStores: thesaurusStores ?? DEFAULT_THESAURUS_STORES, 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, fontMode: fontMode, uniformFontFamily: uniformFamily, zoom: uniformZoom, onUniformFontFamilyChange: handleUniformFamily, onZoomChange: handleUniformZoom, direction: dir, locale: locale,
|
|
382
|
+
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, toolbarStyle: toolbarStyle, helpUrl: helpUrl, dictionaryStores: wordStores, thesaurusStores: thesaurusStores ?? DEFAULT_THESAURUS_STORES, 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, fontMode: fontMode, uniformFontFamily: uniformFamily, zoom: uniformZoom, onUniformFontFamilyChange: handleUniformFamily, onZoomChange: handleUniformZoom, direction: dir, locale: locale, drafts: autosave
|
|
383
383
|
? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
|
|
384
|
-
: 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,
|
|
384
|
+
: 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, "data-font-mode": uniform ? 'uniform' : undefined, "data-uniform-font": uniform && uniformFamily ? '' : undefined, style: uniform
|
|
385
385
|
? { '--likhari-zoom': uniformZoom / 100, ...(uniformFamily && { '--likhari-uniform-font': uniformFamily }) }
|
|
386
|
-
: undefined }), 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, {
|
|
386
|
+
: undefined }), 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.autocomplete && (_jsx(AutocompletePlugin, { label: strings.autoComplete.label, stores: resolvedCompletionStores, language: autoCompleteLanguage })), (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, ignoreSelectionChange: true })] }) }), _jsx(LeaveDialog, { opened: leavePrompt !== null, canSave: Boolean(onSave), canSaveDraft: autosave || navigationGuard === 'save-draft', draftFailed: leavePrompt?.draftFailed ?? false, onSave: () => {
|
|
387
387
|
handleSave();
|
|
388
388
|
settleLeave(true);
|
|
389
389
|
}, onSaveDraft: () => {
|
|
@@ -7,13 +7,11 @@ import { type UserWordStore } from '../spellcheck/userWords.js';
|
|
|
7
7
|
* can replace it. Checking reads the document on demand, so it never flags
|
|
8
8
|
* words while the user is still typing.
|
|
9
9
|
*/
|
|
10
|
-
export declare function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect,
|
|
10
|
+
export declare function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect, onClose, }: {
|
|
11
11
|
strings: Strings;
|
|
12
12
|
dir: 'ltr' | 'rtl';
|
|
13
13
|
dictionaryStores: UserWordStore[];
|
|
14
14
|
onAddAutoCorrect?: (word: string, language: SpellLanguage) => void;
|
|
15
|
-
/** Pre-selects the language dropdown; the user can still switch it. Defaults to English. */
|
|
16
|
-
initialLanguage?: SpellLanguage;
|
|
17
15
|
onClose: () => void;
|
|
18
16
|
}): import("react").JSX.Element;
|
|
19
17
|
//# sourceMappingURL=SpellcheckPanel.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpellcheckPanel.d.ts","sourceRoot":"","sources":["../../src/components/SpellcheckPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgBtF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,GAAG,EACH,gBAAgB,EAChB,gBAAgB,EAChB,
|
|
1
|
+
{"version":3,"file":"SpellcheckPanel.d.ts","sourceRoot":"","sources":["../../src/components/SpellcheckPanel.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAkC,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACrG,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAgBtF;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,GAAG,EACH,gBAAgB,EAChB,gBAAgB,EAChB,OAAO,GACR,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;IACnB,gBAAgB,EAAE,aAAa,EAAE,CAAC;IAClC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;IACnE,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BAqKA"}
|
|
@@ -18,10 +18,10 @@ const SUGGESTIONS_PER_WORD = 3;
|
|
|
18
18
|
* can replace it. Checking reads the document on demand, so it never flags
|
|
19
19
|
* words while the user is still typing.
|
|
20
20
|
*/
|
|
21
|
-
export function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect,
|
|
21
|
+
export function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect, onClose, }) {
|
|
22
22
|
const [editor] = useLexicalComposerContext();
|
|
23
23
|
const t = strings.spellcheck;
|
|
24
|
-
const [language, setLanguage] = useState(
|
|
24
|
+
const [language, setLanguage] = useState('en');
|
|
25
25
|
const [items, setItems] = useState(null);
|
|
26
26
|
const [index, setIndex] = useState(0);
|
|
27
27
|
const [checking, setChecking] = useState(false);
|
|
@@ -57,8 +57,6 @@ export interface ToolbarProps {
|
|
|
57
57
|
direction?: 'ltr' | 'rtl';
|
|
58
58
|
/** UI locale — picks the translated strings for labels, tooltips and menu items. */
|
|
59
59
|
locale?: Locale;
|
|
60
|
-
/** Which dictionary the right-click spelling/thesaurus lookup uses: 'auto' follows the word's own direction (English for LTR, Urdu for RTL). */
|
|
61
|
-
spellCheckLanguage?: SpellLanguage | 'auto';
|
|
62
60
|
/** Autosave drafts: when set, the toolbar offers a Drafts button that lists and restores them. */
|
|
63
61
|
drafts?: DraftsToolbarOptions;
|
|
64
62
|
/**
|
|
@@ -71,5 +69,5 @@ export interface ToolbarProps {
|
|
|
71
69
|
/** `docs/markdown-dialect.md` at the repository's default branch — the Markdown
|
|
72
70
|
* format this editor reads and writes, including the poetry container syntax. */
|
|
73
71
|
export declare const DEFAULT_HELP_URL = "https://github.com/inshapardaz/likhari/blob/main/docs/markdown-dialect.md";
|
|
74
|
-
export declare function Toolbar({ config, toolbarStyle, dictionaryStores, thesaurusStores, onAddAutoCorrect, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell, autoCorrectOpen, onToggleAutoCorrect, fontOptions, fontMode, uniformFontFamily, zoom, onUniformFontFamilyChange, onZoomChange, direction, locale,
|
|
72
|
+
export declare function Toolbar({ config, toolbarStyle, dictionaryStores, thesaurusStores, onAddAutoCorrect, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell, autoCorrectOpen, onToggleAutoCorrect, fontOptions, fontMode, uniformFontFamily, zoom, onUniformFontFamilyChange, onZoomChange, direction, locale, drafts, helpUrl }: ToolbarProps):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AE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,wFAAwF;IACxF,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kGAAkG;IAClG,MAAM,CAAC,EAAE,oBAAoB,CAAC;IAC9B;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;CAC1B;AAED;iFACiF;AACjF,eAAO,MAAM,gBAAgB,8EAA8E,CAAC;AAE5G,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAqB,EAAE,eAAoB,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAgB,EAAE,YAAY,EAAE,SAAiB,EAAE,aAAa,EAAE,eAAuB,EAAE,mBAAmB,EAAE,WAAkC,EAAE,QAAsB,EAAE,iBAAiB,EAAE,IAAU,EAAE,yBAAyB,EAAE,YAAY,EAAE,SAAiB,EAAE,MAAa,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,+BAwzC9b"}
|
|
@@ -216,7 +216,7 @@ function PoetryMenuItems({ strings, layout, scale, centered, onAction, }) {
|
|
|
216
216
|
/** `docs/markdown-dialect.md` at the repository's default branch — the Markdown
|
|
217
217
|
* format this editor reads and writes, including the poetry container syntax. */
|
|
218
218
|
export const DEFAULT_HELP_URL = 'https://github.com/inshapardaz/likhari/blob/main/docs/markdown-dialect.md';
|
|
219
|
-
export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurusStores = [], onAddAutoCorrect, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell, autoCorrectOpen = false, onToggleAutoCorrect, fontOptions = DEFAULT_FONT_OPTIONS, fontMode = 'selective', uniformFontFamily, zoom = 100, onUniformFontFamilyChange, onZoomChange, direction = 'ltr', locale = 'en',
|
|
219
|
+
export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurusStores = [], onAddAutoCorrect, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell, autoCorrectOpen = false, onToggleAutoCorrect, fontOptions = DEFAULT_FONT_OPTIONS, fontMode = 'selective', uniformFontFamily, zoom = 100, onUniformFontFamilyChange, onZoomChange, direction = 'ltr', locale = 'en', drafts, helpUrl }) {
|
|
220
220
|
const bordered = toolbarStyle?.bordered ?? true;
|
|
221
221
|
const variant = toolbarStyle?.variant ?? 'light';
|
|
222
222
|
const overflowEnabled = toolbarStyle?.overflow ?? true;
|
|
@@ -609,7 +609,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
609
609
|
menu.canJoin = $canJoinLines();
|
|
610
610
|
}
|
|
611
611
|
}, { discrete: true });
|
|
612
|
-
const language =
|
|
612
|
+
const language = word?.direction === 'rtl' ? 'ur' : 'en';
|
|
613
613
|
if (word && config.language.thesaurus) {
|
|
614
614
|
menu.thesaurus = { language, word: word.word, match: word.match };
|
|
615
615
|
}
|
|
@@ -636,7 +636,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
636
636
|
previous?.removeEventListener('contextmenu', onContextMenu);
|
|
637
637
|
root?.addEventListener('contextmenu', onContextMenu);
|
|
638
638
|
});
|
|
639
|
-
}, [editor, config.links, config.tables, config.poetry.enabled, config.language.spellCheck, config.language.thesaurus, config.joinLines, thesaurusStores
|
|
639
|
+
}, [editor, config.links, config.tables, config.poetry.enabled, config.language.spellCheck, config.language.thesaurus, config.joinLines, thesaurusStores]);
|
|
640
640
|
// Cut and copy put the selected text on the clipboard as plain text.
|
|
641
641
|
const copyOrCut = (cut) => async () => {
|
|
642
642
|
restoreSelection();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type SpellLanguage } from './spellDictionaries.js';
|
|
2
1
|
/**
|
|
3
2
|
* Underlines misspelled words the way the browser does, without changing the
|
|
4
3
|
* document. Only blocks that are in view are checked, a block a few seconds after
|
|
@@ -7,9 +6,5 @@ import { type SpellLanguage } from './spellDictionaries.js';
|
|
|
7
6
|
* ranges set through the CSS Custom Highlight API. In browsers without it, nothing
|
|
8
7
|
* is underlined.
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
11
|
-
/** Which dictionary checks every block: 'auto' (default) follows each block's own direction (English for LTR, Urdu for RTL). */
|
|
12
|
-
language?: SpellLanguage | 'auto';
|
|
13
|
-
}
|
|
14
|
-
export declare function SpellHighlightPlugin({ language }?: SpellHighlightPluginProps): null;
|
|
9
|
+
export declare function SpellHighlightPlugin(): null;
|
|
15
10
|
//# sourceMappingURL=SpellHighlightPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpellHighlightPlugin.d.ts","sourceRoot":"","sources":["../../src/spellcheck/SpellHighlightPlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SpellHighlightPlugin.d.ts","sourceRoot":"","sources":["../../src/spellcheck/SpellHighlightPlugin.tsx"],"names":[],"mappings":"AAsBA;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,SAoJnC"}
|
|
@@ -18,7 +18,15 @@ function $topLevelKey(node) {
|
|
|
18
18
|
current = current.getParent();
|
|
19
19
|
return current.getParent() ? current.getKey() : null;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Underlines misspelled words the way the browser does, without changing the
|
|
23
|
+
* document. Only blocks that are in view are checked, a block a few seconds after
|
|
24
|
+
* it scrolls into view, and an edit is rechecked after typing pauses. Results are
|
|
25
|
+
* kept per block, so a change re-checks only the block it is in. Underlines are
|
|
26
|
+
* ranges set through the CSS Custom Highlight API. In browsers without it, nothing
|
|
27
|
+
* is underlined.
|
|
28
|
+
*/
|
|
29
|
+
export function SpellHighlightPlugin() {
|
|
22
30
|
const [editor] = useLexicalComposerContext();
|
|
23
31
|
useEffect(() => {
|
|
24
32
|
if (typeof CSS === 'undefined' || !('highlights' in CSS) || typeof IntersectionObserver === 'undefined')
|
|
@@ -156,18 +164,11 @@ export function SpellHighlightPlugin({ language = 'auto' } = {}) {
|
|
|
156
164
|
Promise.all([getSpeller('en'), getSpeller('ur')]).then(async ([en, ur]) => {
|
|
157
165
|
if (!active)
|
|
158
166
|
return;
|
|
159
|
-
|
|
160
|
-
const urSpeller = ur ? await ur : undefined;
|
|
161
|
-
checkers =
|
|
162
|
-
language === 'auto'
|
|
163
|
-
? { ltr: enSpeller, rtl: urSpeller }
|
|
164
|
-
: language === 'ur'
|
|
165
|
-
? { ltr: urSpeller, rtl: urSpeller }
|
|
166
|
-
: { ltr: enSpeller, rtl: enSpeller };
|
|
167
|
-
cache.clear();
|
|
167
|
+
checkers = { ltr: en ? await en : undefined, rtl: ur ? await ur : undefined };
|
|
168
168
|
syncBlocks();
|
|
169
169
|
for (const key of visible)
|
|
170
|
-
|
|
170
|
+
if (!cache.has(key))
|
|
171
|
+
schedule(key, 0);
|
|
171
172
|
});
|
|
172
173
|
return () => {
|
|
173
174
|
active = false;
|
|
@@ -178,7 +179,7 @@ export function SpellHighlightPlugin({ language = 'auto' } = {}) {
|
|
|
178
179
|
clearTimeout(timer);
|
|
179
180
|
CSS.highlights.delete(HIGHLIGHT);
|
|
180
181
|
};
|
|
181
|
-
}, [editor
|
|
182
|
+
}, [editor]);
|
|
182
183
|
return null;
|
|
183
184
|
}
|
|
184
185
|
/** The text nodes of a rendered block, with where each one starts in the block's text. */
|