@inshapardaz/likhari-react 0.1.21-dev.197 → 0.1.21-dev.200

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.
@@ -4,6 +4,7 @@ import { type FormatId } from '@inshapardaz/likhari-converters';
4
4
  import { type EditorFeatureConfig, type FeatureConfigPresetName } from '@inshapardaz/likhari-core';
5
5
  import { type FontOption } from './fonts/index.js';
6
6
  import { type DraftRestoreMode } from './components/DraftRestore.js';
7
+ import { type AutoCorrectStore } from './autocorrect/autoCorrectStores.js';
7
8
  import { type Locale } from './i18n/index.js';
8
9
  /** What happens when the user is about to leave with unsaved changes. */
9
10
  export type NavigationGuardMode = 'confirm' | 'save-draft' | 'off';
@@ -13,6 +14,8 @@ export interface EditorInitialContent {
13
14
  }
14
15
  export interface EditorRootProps {
15
16
  documentId?: string;
17
+ /** Where auto-corrections are loaded from and saved to, in priority order. Pass a stable array. */
18
+ autoCorrectStores?: AutoCorrectStore[];
16
19
  initialContent?: EditorInitialContent;
17
20
  featureConfig?: EditorFeatureConfig;
18
21
  featurePreset?: FeatureConfigPresetName;
@@ -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;AAehF,OAAO,EAAgC,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAMnE,yEAAy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AAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;;;;;;;;;;;;;;OAeG;IACH,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,uGAAuG;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,uGAmZrB,CAAC"}
@@ -27,6 +27,9 @@ import { PoetryPlugin } from './plugins/PoetryPlugin.js';
27
27
  import { PoetryResizer } from './blocks/PoetryResizer.js';
28
28
  import { DraftRestore } from './components/DraftRestore.js';
29
29
  import { FindReplaceBar } from './components/FindReplaceBar.js';
30
+ import { AutoCorrectPanel } from './components/AutoCorrectPanel.js';
31
+ import { AutoCorrectPlugin } from './autocorrect/AutoCorrectPlugin.js';
32
+ import { localStorageAutoCorrectStore } from './autocorrect/autoCorrectStores.js';
30
33
  import { SpellcheckPanel } from './components/SpellcheckPanel.js';
31
34
  import { SpellHighlightPlugin } from './spellcheck/SpellHighlightPlugin.js';
32
35
  import { LeaveDialog } from './components/LeaveDialog.js';
@@ -37,13 +40,15 @@ import { UiStringsContext, getStrings } from './i18n/index.js';
37
40
  const DEFAULT_AUTOSAVE_DELAY_MS = 750;
38
41
  const DEFAULT_AUTOSAVE_MAX_BYTES = 2000000;
39
42
  const DEFAULT_AUTOSAVE_MAX_DRAFTS = 20;
43
+ /** Used when the host passes no stores: corrections are kept in this browser. */
44
+ const DEFAULT_AUTOCORRECT_STORES = [localStorageAutoCorrectStore()];
40
45
  function initialEditorStateJson(initialContent) {
41
46
  if (!initialContent)
42
47
  return undefined;
43
48
  const state = defaultFormatRegistry.parse(initialContent.format, initialContent.value);
44
49
  return JSON.stringify(state);
45
50
  }
46
- export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialContent, featureConfig, featurePreset, theme, colorScheme, accentColor, locale = 'en', placeholder, height = '480px', onChange, onSave, showSave = Boolean(onSave), onImageUpload, fetchImage, fontOptions, autosave = true, restoreDraft = 'prompt', navigationGuard = 'confirm', onDraftRestored, autosaveDelayMs = DEFAULT_AUTOSAVE_DELAY_MS, autosaveMaxBytes = DEFAULT_AUTOSAVE_MAX_BYTES, autosaveMaxDrafts = DEFAULT_AUTOSAVE_MAX_DRAFTS, }, ref) {
51
+ export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorrectStores, initialContent, featureConfig, featurePreset, theme, colorScheme, accentColor, locale = 'en', placeholder, height = '480px', onChange, onSave, showSave = Boolean(onSave), onImageUpload, fetchImage, fontOptions, autosave = true, restoreDraft = 'prompt', navigationGuard = 'confirm', onDraftRestored, autosaveDelayMs = DEFAULT_AUTOSAVE_DELAY_MS, autosaveMaxBytes = DEFAULT_AUTOSAVE_MAX_BYTES, autosaveMaxDrafts = DEFAULT_AUTOSAVE_MAX_DRAFTS, }, ref) {
47
52
  const config = useMemo(() => resolveFeatureConfig(featureConfig, featurePreset), [featureConfig, featurePreset]);
48
53
  const strings = useMemo(() => getStrings(locale), [locale]);
49
54
  const resolvedPlaceholder = placeholder ?? strings.editor.placeholder;
@@ -70,8 +75,10 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
70
75
  const editorStateRef = useRef(null);
71
76
  const lastSavedJsonRef = useRef(null);
72
77
  const [isDirty, setIsDirty] = useState(false);
73
- const [findOpen, setFindOpen] = useState(false);
74
- const [spellOpen, setSpellOpen] = useState(false);
78
+ const [openPanel, setOpenPanel] = useState(null);
79
+ const [autoCorrectVersion, setAutoCorrectVersion] = useState(0);
80
+ const stores = autoCorrectStores ?? DEFAULT_AUTOCORRECT_STORES;
81
+ const togglePanel = (panel) => setOpenPanel((current) => (current === panel ? null : panel));
75
82
  const isDirtyRef = useRef(isDirty);
76
83
  isDirtyRef.current = isDirty;
77
84
  const autosaveTimerRef = useRef(null);
@@ -284,15 +291,9 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, initialCo
284
291
  // rather than colliding on a shared one.
285
292
  const portalTargetId = useId();
286
293
  const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
287
- 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, onSave: handleSave, findOpen: findOpen, onToggleFind: () => {
288
- setFindOpen((v) => !v);
289
- setSpellOpen(false);
290
- }, spellOpen: spellOpen, onToggleSpell: () => {
291
- setSpellOpen((v) => !v);
292
- setFindOpen(false);
293
- }, isDirty: isDirty, showSave: showSave, fontOptions: fontOptions, direction: dir, locale: locale, drafts: autosave
294
+ 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, 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
294
295
  ? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
295
- : undefined }), documentId && (_jsx(DraftRestore, { draftId: documentId, mode: restoreDraft, initialJson: initialContentJsonRef.current, locale: locale, onRestored: handleDraftRestored })), _jsxs("div", { className: "likhari-canvas-frame", children: [config.findReplace && findOpen && _jsx(FindReplaceBar, { strings: strings, dir: dir, onClose: () => setFindOpen(false) }), config.language.spellCheck && spellOpen && _jsx(SpellcheckPanel, { strings: strings, dir: dir, onClose: () => setSpellOpen(false) }), _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.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: () => {
296
+ : 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, onClose: () => setOpenPanel(null) })), config.language.autocorrect && openPanel === 'autocorrect' && (_jsx(AutoCorrectPanel, { strings: strings, dir: dir, stores: stores, onSaved: () => setAutoCorrectVersion((v) => v + 1), onClose: () => setOpenPanel(null) })), _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 && _jsx(AutoCorrectPlugin, { stores: stores, version: autoCorrectVersion, enabled: true }), 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: () => {
296
297
  handleSave();
297
298
  settleLeave(true);
298
299
  }, onSaveDraft: () => {
@@ -0,0 +1,14 @@
1
+ import { type AutoCorrectStore } from './autoCorrectStores.js';
2
+ /**
3
+ * Corrects typed words as the user finishes them, the way the reference editor
4
+ * does, but from any set of stores. Corrections are loaded once per change
5
+ * of `stores` or `version` (bump `version` after saving a new correction so
6
+ * the table reloads). The table used depends on the block's direction: RTL
7
+ * blocks use the Urdu and Shahmukhi tables, LTR blocks the English one.
8
+ */
9
+ export declare function AutoCorrectPlugin({ stores, version, enabled }: {
10
+ stores: AutoCorrectStore[];
11
+ version: number;
12
+ enabled: boolean;
13
+ }): null;
14
+ //# sourceMappingURL=AutoCorrectPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoCorrectPlugin.d.ts","sourceRoot":"","sources":["../../src/autocorrect/AutoCorrectPlugin.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAQjF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAAE,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,QA2DhI"}
@@ -0,0 +1,75 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
+ import { $getSelection, $isRangeSelection } from 'lexical';
4
+ import { $correctWordBeforeCaret } from './autoCorrectActions.js';
5
+ import { loadAutoCorrections } from './autoCorrectStores.js';
6
+ /** Keys that end a word: a space or punctuation, in Latin and Arabic-script forms. */
7
+ const BOUNDARY_KEYS = new Set([' ', '.', ',', ';', ':', '!', '?', '،', '؛', '؟', '۔']);
8
+ const LANGUAGES = ['en', 'ur', 'pa-shahmukhi'];
9
+ const RTL_LANGUAGES = ['ur', 'pa-shahmukhi'];
10
+ /**
11
+ * Corrects typed words as the user finishes them, the way the reference editor
12
+ * does, but from any set of stores. Corrections are loaded once per change
13
+ * of `stores` or `version` (bump `version` after saving a new correction so
14
+ * the table reloads). The table used depends on the block's direction: RTL
15
+ * blocks use the Urdu and Shahmukhi tables, LTR blocks the English one.
16
+ */
17
+ export function AutoCorrectPlugin({ stores, version, enabled }) {
18
+ const [editor] = useLexicalComposerContext();
19
+ const tables = useRef(new Map());
20
+ const rtlTable = useRef(new Map());
21
+ useEffect(() => {
22
+ if (!enabled)
23
+ return;
24
+ let active = true;
25
+ Promise.all(LANGUAGES.map(async (language) => [language, await loadAutoCorrections(stores, language)])).then((loaded) => {
26
+ if (!active)
27
+ return;
28
+ tables.current = new Map(loaded);
29
+ // Urdu and Shahmukhi share right-to-left blocks, so both apply there; Urdu wins a clash.
30
+ const combined = new Map();
31
+ for (const language of RTL_LANGUAGES) {
32
+ for (const [from, to] of tables.current.get(language) ?? [])
33
+ if (!combined.has(from))
34
+ combined.set(from, to);
35
+ }
36
+ rtlTable.current = combined;
37
+ });
38
+ return () => {
39
+ active = false;
40
+ };
41
+ }, [stores, version, enabled]);
42
+ useEffect(() => {
43
+ if (!enabled)
44
+ return;
45
+ const tableFor = (rtl) => (rtl ? rtlTable.current : tables.current.get('en'));
46
+ const onKeyDown = (event) => {
47
+ if (event.isComposing || !BOUNDARY_KEYS.has(event.key))
48
+ return;
49
+ // The character is inserted after this event; correct the word once it is there.
50
+ setTimeout(() => {
51
+ editor.update(() => {
52
+ const selection = $getSelection();
53
+ if (!$isRangeSelection(selection))
54
+ return;
55
+ const block = selection.anchor.getNode().getTopLevelElement();
56
+ const table = tableFor(block?.getDirection() === 'rtl');
57
+ if (table)
58
+ $correctWordBeforeCaret(table);
59
+ }, { discrete: true });
60
+ }, 0);
61
+ };
62
+ let root = null;
63
+ const attach = (next) => {
64
+ root?.removeEventListener('keydown', onKeyDown);
65
+ root = next;
66
+ root?.addEventListener('keydown', onKeyDown);
67
+ };
68
+ const unregister = editor.registerRootListener((next) => attach(next));
69
+ return () => {
70
+ unregister();
71
+ attach(null);
72
+ };
73
+ }, [editor, enabled]);
74
+ return null;
75
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Corrects the word that ends just before the caret, when the character just
3
+ * typed (the word boundary: space or punctuation) is not a word character. The
4
+ * correction replaces only the word, and the caret stays right after the
5
+ * boundary. Returns true if a correction was made.
6
+ */
7
+ export declare function $correctWordBeforeCaret(table: Map<string, string>): boolean;
8
+ //# sourceMappingURL=autoCorrectActions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoCorrectActions.d.ts","sourceRoot":"","sources":["../../src/autocorrect/autoCorrectActions.ts"],"names":[],"mappings":"AAOA;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAiC3E"}
@@ -0,0 +1,42 @@
1
+ import { $getSelection, $isRangeSelection, $isTextNode } from 'lexical';
2
+ import { $replaceMatch } from '../find/findReplaceActions.js';
3
+ /** The part of a word that counts as word characters at its end. */
4
+ const WORD_END = /[\p{L}\p{M}'’]+$/u;
5
+ const WORD_CHAR = /[\p{L}\p{M}'’]/u;
6
+ /**
7
+ * Corrects the word that ends just before the caret, when the character just
8
+ * typed (the word boundary: space or punctuation) is not a word character. The
9
+ * correction replaces only the word, and the caret stays right after the
10
+ * boundary. Returns true if a correction was made.
11
+ */
12
+ export function $correctWordBeforeCaret(table) {
13
+ const selection = $getSelection();
14
+ if (!$isRangeSelection(selection) || !selection.isCollapsed())
15
+ return false;
16
+ const anchor = selection.anchor;
17
+ const node = anchor.getNode();
18
+ if (!$isTextNode(node))
19
+ return false;
20
+ const before = node.getTextContent().slice(0, anchor.offset);
21
+ const boundary = before.slice(-1);
22
+ if (boundary === '' || WORD_CHAR.test(boundary))
23
+ return false;
24
+ const body = before.slice(0, -1);
25
+ const word = WORD_END.exec(body)?.[0];
26
+ if (!word)
27
+ return false;
28
+ const replacement = table.get(word);
29
+ if (replacement === undefined || replacement === word)
30
+ return false;
31
+ const start = body.length - word.length;
32
+ $replaceMatch({ anchorKey: node.getKey(), anchorOffset: start, focusKey: node.getKey(), focusOffset: body.length }, replacement);
33
+ // Put the caret back after the boundary the user typed, not at the end of the replacement.
34
+ const after = $getSelection();
35
+ if ($isRangeSelection(after)) {
36
+ const focusNode = after.focus.getNode();
37
+ const caret = after.focus.offset + boundary.length;
38
+ after.anchor.set(focusNode.getKey(), caret, 'text');
39
+ after.focus.set(focusNode.getKey(), caret, 'text');
40
+ }
41
+ return true;
42
+ }
@@ -0,0 +1,52 @@
1
+ import type { SpellLanguage } from '../spellcheck/spellDictionaries.js';
2
+ /** One correction: a typed word and what it should become. */
3
+ export interface AutoCorrectEntry {
4
+ from: string;
5
+ to: string;
6
+ }
7
+ /**
8
+ * Where auto-corrections come from and go. The host supplies any number of
9
+ * stores; corrections from all of them are merged, and when two stores
10
+ * correct the same word, the one listed first wins. New corrections are
11
+ * appended to the first store that accepts writes.
12
+ */
13
+ export interface AutoCorrectStore {
14
+ readonly id: string;
15
+ /** A store without `append` (or with `readOnly`) is never written to. */
16
+ readonly readOnly?: boolean;
17
+ load(language: SpellLanguage): Promise<AutoCorrectEntry[]>;
18
+ append?(language: SpellLanguage, entry: AutoCorrectEntry): Promise<void>;
19
+ }
20
+ /**
21
+ * Corrections kept in this browser's localStorage. Storage can be disabled or
22
+ * full, so every access is guarded: a failure means "no corrections", never a
23
+ * broken editor.
24
+ */
25
+ export declare function localStorageAutoCorrectStore(options?: {
26
+ key?: string;
27
+ }): AutoCorrectStore;
28
+ /**
29
+ * Corrections served by an API. `load` calls `GET {url}?language=xx` and expects
30
+ * a JSON array of `{ from, to }`; `append` calls `POST {url}` with
31
+ * `{ language, from, to }`. Credentials and headers belong to the host.
32
+ */
33
+ export declare function apiAutoCorrectStore(options: {
34
+ id?: string;
35
+ url: string;
36
+ headers?: Record<string, string>;
37
+ fetch?: typeof fetch;
38
+ }): AutoCorrectStore;
39
+ /**
40
+ * Corrections from a JSON file the host publishes — a list of `{ language, from, to }`.
41
+ * Read-only: it has no way to write back to a static file.
42
+ */
43
+ export declare function fileAutoCorrectStore(options: {
44
+ id?: string;
45
+ url: string;
46
+ fetch?: typeof fetch;
47
+ }): AutoCorrectStore;
48
+ /** Corrections for one language, merged across stores. Failing stores are skipped. */
49
+ export declare function loadAutoCorrections(stores: AutoCorrectStore[], language: SpellLanguage): Promise<Map<string, string>>;
50
+ /** Saves a correction to the first store that accepts writes. Returns false if none does. */
51
+ export declare function appendAutoCorrection(stores: AutoCorrectStore[], language: SpellLanguage, entry: AutoCorrectEntry): Promise<boolean>;
52
+ //# sourceMappingURL=autoCorrectStores.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autoCorrectStores.d.ts","sourceRoot":"","sources":["../../src/autocorrect/autoCorrectStores.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAErE,8DAA8D;AAC9D,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,C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AAO,CAAC,CAKzI"}
@@ -0,0 +1,115 @@
1
+ const STORAGE_KEY = 'likhari-autocorrect';
2
+ function isEntry(value) {
3
+ return (typeof value === 'object' &&
4
+ value !== null &&
5
+ typeof value.from === 'string' &&
6
+ typeof value.to === 'string' &&
7
+ value.from !== '');
8
+ }
9
+ /**
10
+ * Corrections kept in this browser's localStorage. Storage can be disabled or
11
+ * full, so every access is guarded: a failure means "no corrections", never a
12
+ * broken editor.
13
+ */
14
+ export function localStorageAutoCorrectStore(options = {}) {
15
+ const key = options.key ?? STORAGE_KEY;
16
+ function readAll() {
17
+ try {
18
+ const parsed = JSON.parse(localStorage.getItem(key) ?? '[]');
19
+ return Array.isArray(parsed) ? parsed.filter((e) => isEntry(e) && 'language' in e) : [];
20
+ }
21
+ catch {
22
+ return [];
23
+ }
24
+ }
25
+ return {
26
+ id: 'local-storage',
27
+ async load(language) {
28
+ return readAll()
29
+ .filter((e) => e.language === language)
30
+ .map(({ from, to }) => ({ from, to }));
31
+ },
32
+ async append(language, entry) {
33
+ const all = readAll().filter((e) => !(e.language === language && e.from === entry.from));
34
+ all.push({ language, from: entry.from, to: entry.to });
35
+ try {
36
+ localStorage.setItem(key, JSON.stringify(all));
37
+ }
38
+ catch {
39
+ // Quota exceeded or storage disabled: the correction is kept for this session only.
40
+ }
41
+ },
42
+ };
43
+ }
44
+ /**
45
+ * Corrections served by an API. `load` calls `GET {url}?language=xx` and expects
46
+ * a JSON array of `{ from, to }`; `append` calls `POST {url}` with
47
+ * `{ language, from, to }`. Credentials and headers belong to the host.
48
+ */
49
+ export function apiAutoCorrectStore(options) {
50
+ const doFetch = options.fetch ?? fetch;
51
+ return {
52
+ id: options.id ?? 'api',
53
+ async load(language) {
54
+ const response = await doFetch(`${options.url}?language=${encodeURIComponent(language)}`, { headers: options.headers });
55
+ if (!response.ok)
56
+ throw new Error(`Auto-correct API failed: ${response.status}`);
57
+ const data = await response.json();
58
+ return Array.isArray(data) ? data.filter(isEntry).map(({ from, to }) => ({ from, to })) : [];
59
+ },
60
+ async append(language, entry) {
61
+ const response = await doFetch(options.url, {
62
+ method: 'POST',
63
+ headers: { 'Content-Type': 'application/json', ...options.headers },
64
+ body: JSON.stringify({ language, from: entry.from, to: entry.to }),
65
+ });
66
+ if (!response.ok)
67
+ throw new Error(`Auto-correct API rejected the entry: ${response.status}`);
68
+ },
69
+ };
70
+ }
71
+ /**
72
+ * Corrections from a JSON file the host publishes — a list of `{ language, from, to }`.
73
+ * Read-only: it has no way to write back to a static file.
74
+ */
75
+ export function fileAutoCorrectStore(options) {
76
+ const doFetch = options.fetch ?? fetch;
77
+ let cached = null;
78
+ const all = () => {
79
+ cached ?? (cached = doFetch(options.url).then(async (response) => {
80
+ if (!response.ok)
81
+ throw new Error(`Auto-correct file failed: ${response.status}`);
82
+ const data = await response.json();
83
+ return Array.isArray(data) ? data.filter((e) => isEntry(e) && 'language' in e) : [];
84
+ }));
85
+ return cached;
86
+ };
87
+ return {
88
+ id: options.id ?? 'file',
89
+ readOnly: true,
90
+ async load(language) {
91
+ return (await all()).filter((e) => e.language === language).map(({ from, to }) => ({ from, to }));
92
+ },
93
+ };
94
+ }
95
+ /** Corrections for one language, merged across stores. Failing stores are skipped. */
96
+ export async function loadAutoCorrections(stores, language) {
97
+ const table = new Map();
98
+ const results = await Promise.allSettled(stores.map((store) => store.load(language)));
99
+ results.forEach((result) => {
100
+ if (result.status !== 'fulfilled')
101
+ return;
102
+ for (const entry of result.value)
103
+ if (!table.has(entry.from))
104
+ table.set(entry.from, entry.to);
105
+ });
106
+ return table;
107
+ }
108
+ /** Saves a correction to the first store that accepts writes. Returns false if none does. */
109
+ export async function appendAutoCorrection(stores, language, entry) {
110
+ const writable = stores.find((store) => !store.readOnly && store.append);
111
+ if (!writable?.append)
112
+ return false;
113
+ await writable.append(language, entry);
114
+ return true;
115
+ }
@@ -0,0 +1,15 @@
1
+ import type { Strings } from '../i18n/strings.js';
2
+ import { type AutoCorrectStore } from '../autocorrect/autoCorrectStores.js';
3
+ /**
4
+ * Adds one correction (a typed word and its replacement) to the first store
5
+ * that accepts writes. Saving bumps the editor's correction version, so the new
6
+ * entry applies to the next word the user types.
7
+ */
8
+ export declare function AutoCorrectPanel({ strings, dir, stores, onSaved, onClose, }: {
9
+ strings: Strings;
10
+ dir: 'ltr' | 'rtl';
11
+ stores: AutoCorrectStore[];
12
+ onSaved: () => void;
13
+ onClose: () => void;
14
+ }): import("react").JSX.Element;
15
+ //# sourceMappingURL=AutoCorrectPanel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AutoCorrectPanel.d.ts","sourceRoot":"","sources":["../../src/components/AutoCorrectPanel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAwB,KAAK,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAS/F;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,GAAG,EACH,MAAM,EACN,OAAO,EACP,OAAO,GACR,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,KAAK,GAAG,KAAK,CAAC;IACnB,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,+BAqEA"}
@@ -0,0 +1,44 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { IconX } from '@tabler/icons-react';
4
+ import { appendAutoCorrection } from '../autocorrect/autoCorrectStores.js';
5
+ const LANGUAGES = [
6
+ { value: 'en', label: 'English' },
7
+ { value: 'ur', label: 'اردو' },
8
+ { value: 'pa-shahmukhi', label: 'پنجابی (شاہ مکھی)' },
9
+ ];
10
+ /**
11
+ * Adds one correction (a typed word and its replacement) to the first store
12
+ * that accepts writes. Saving bumps the editor's correction version, so the new
13
+ * entry applies to the next word the user types.
14
+ */
15
+ export function AutoCorrectPanel({ strings, dir, stores, onSaved, onClose, }) {
16
+ const t = strings.autoCorrect;
17
+ const [language, setLanguage] = useState('en');
18
+ const [from, setFrom] = useState('');
19
+ const [to, setTo] = useState('');
20
+ const [status, setStatus] = useState('idle');
21
+ const save = async () => {
22
+ const entry = { from: from.trim(), to: to.trim() };
23
+ if (entry.from === '' || entry.to === '' || entry.from === entry.to)
24
+ return;
25
+ try {
26
+ const written = await appendAutoCorrection(stores, language, entry);
27
+ if (!written) {
28
+ setStatus('nowhere');
29
+ return;
30
+ }
31
+ setStatus('saved');
32
+ setFrom('');
33
+ setTo('');
34
+ onSaved();
35
+ }
36
+ catch {
37
+ setStatus('failed');
38
+ }
39
+ };
40
+ return (_jsxs("div", { className: "likhari-autocorrect-panel", role: "region", "aria-label": t.title, dir: dir, children: [_jsxs("div", { className: "likhari-spell-header", children: [_jsx("strong", { children: t.title }), _jsx("button", { type: "button", className: "likhari-spell-icon", onClick: onClose, "aria-label": t.close, title: t.close, children: _jsx(IconX, { size: 14, stroke: 1.75 }) })] }), _jsxs("label", { className: "likhari-autocorrect-field", children: [t.language, _jsx("select", { value: language, onChange: (e) => {
41
+ setLanguage(e.target.value);
42
+ setStatus('idle');
43
+ }, children: LANGUAGES.map((l) => (_jsx("option", { value: l.value, children: l.label }, l.value))) })] }), _jsxs("label", { className: "likhari-autocorrect-field", children: [t.from, _jsx("input", { value: from, onChange: (e) => setFrom(e.target.value), placeholder: t.fromPlaceholder })] }), _jsxs("label", { className: "likhari-autocorrect-field", children: [t.to, _jsx("input", { value: to, onChange: (e) => setTo(e.target.value), placeholder: t.toPlaceholder })] }), _jsxs("div", { className: "likhari-autocorrect-actions", children: [_jsx("button", { type: "button", onClick: save, disabled: from.trim() === '' || to.trim() === '', children: t.save }), _jsxs("span", { className: "likhari-spell-note", "aria-live": "polite", children: [status === 'saved' && t.saved, status === 'nowhere' && t.noWritableStore, status === 'failed' && t.failed] })] })] }));
44
+ }
@@ -10,6 +10,9 @@ export interface ToolbarProps {
10
10
  /** Whether the spellcheck panel is open, and how to toggle it (owned by EditorRoot). */
11
11
  spellOpen?: boolean;
12
12
  onToggleSpell?: () => void;
13
+ /** Whether the add-auto-correction panel is open, and how to toggle it (owned by EditorRoot). */
14
+ autoCorrectOpen?: boolean;
15
+ onToggleAutoCorrect?: () => void;
13
16
  onSave?: () => void;
14
17
  isDirty?: boolean;
15
18
  showSave?: boolean;
@@ -22,5 +25,5 @@ export interface ToolbarProps {
22
25
  /** Autosave drafts: when set, the toolbar offers a Drafts button that lists and restores them. */
23
26
  drafts?: DraftsToolbarOptions;
24
27
  }
25
- export declare function Toolbar({ config, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell, fontOptions, direction, locale, drafts }: ToolbarProps): import("react").JSX.Element;
28
+ export declare function Toolbar({ config, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell, autoCorrectOpen, onToggleAutoCorrect, fontOptions, direction, locale, drafts }: ToolbarProps): import("react").JSX.Element;
26
29
  //# sourceMappingURL=Toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AAqFA,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAA6D,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAItG,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AA+gBvD,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,2BAA2B,CAAC;IACpC,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,wFAAwF;IACxF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,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AI,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sEAAsE;IACtE,WAAW,CAAC,EAAE,UAAU,EAAE,CAAC;IAC3B,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;CAC/B;AAED,wBAAgB,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAgB,EAAE,YAAY,EAAE,SAAiB,EAAE,aAAa,EAAE,eAAuB,EAAE,mBAAmB,EAAE,WAAkC,EAAE,SAAiB,EAAE,MAAa,EAAE,MAAM,EAAE,EAAE,YAAY,+BA0kCxQ"}
@@ -182,7 +182,7 @@ function PoetryMenuItems({ strings, layout, scale, centered, onAction, }) {
182
182
  };
183
183
  return (_jsxs(_Fragment, { children: [_jsx(Menu.Label, { children: t.menuLabel }), item(IconColumns1, t.singleColumn, setLayout('single'), layout === 'single'), item(IconColumns2, t.twoColumn, setLayout('two-column'), layout === 'two-column'), item(IconArrowsShuffle, t.staggered, setLayout('staggered'), layout === 'staggered'), _jsx(Menu.Divider, {}), _jsx(Menu.Divider, {}), item(IconRowInsertTop, t.insertCoupletBefore, () => $insertCoupletRelativeToSelection('before')), item(IconRowInsertBottom, t.insertCoupletAfter, () => $insertCoupletRelativeToSelection('after')), item(IconArrowsMinimize, t.tighterSpacing, () => $adjustPoetrySpacing(-1), !canStep(POETRY_SPACINGS, scale.spacing, -1)), item(IconArrowsMaximize, t.looserSpacing, () => $adjustPoetrySpacing(1), !canStep(POETRY_SPACINGS, scale.spacing, 1)), layout === 'staggered' && (_jsxs(_Fragment, { children: [item(IconArrowsMinimize, t.narrowerCouplets, () => $adjustPoetryStagger(-1), !canStep(POETRY_STAGGERS, scale.stagger, -1)), item(IconArrowsMaximize, t.widerCouplets, () => $adjustPoetryStagger(1), !canStep(POETRY_STAGGERS, scale.stagger, 1))] })), layout === 'two-column' && (_jsxs(_Fragment, { children: [item(IconAlignCenter, centered ? t.uncenterCouplet : t.centerCouplet, () => $setCoupletCentered(!centered)), item(IconColumns2, t.narrowerGutter, () => $adjustPoetryGutter(-1), !canStep(POETRY_GUTTERS, scale.gutter, -1)), item(IconColumns2, t.widerGutter, () => $adjustPoetryGutter(1), !canStep(POETRY_GUTTERS, scale.gutter, 1))] })), item(IconTrash, t.deleteCouplet, $deletePoetryCouplet, false, 'red'), item(IconTrash, t.deletePoetry, $deletePoetryBlock, false, 'red')] }));
184
184
  }
185
- export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell, fontOptions = DEFAULT_FONT_OPTIONS, direction = 'ltr', locale = 'en', drafts }) {
185
+ export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell, autoCorrectOpen = false, onToggleAutoCorrect, fontOptions = DEFAULT_FONT_OPTIONS, direction = 'ltr', locale = 'en', drafts }) {
186
186
  const [editor] = useLexicalComposerContext();
187
187
  const [state, setState] = useState(INITIAL_STATE);
188
188
  const strings = useStrings(locale);
@@ -811,7 +811,7 @@ export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, o
811
811
  showStubInsertGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [(config.images.linked || config.images.embedded) && (_jsx(ToolbarButton, { icon: IconPhoto, title: strings.toolbar.insertImage, onClick: openImageDialog })), config.blocks.pageBreak && (_jsx(ToolbarButton, { icon: IconPageBreak, title: strings.toolbar.insertPageBreak, onClick: () => editor.dispatchCommand(INSERT_PAGE_BREAK_COMMAND, undefined) })), config.tables && _jsx(ToolbarButton, { icon: IconTable, title: strings.toolbar.insertTable, onClick: openTableDialog }), config.columns && _jsx(ToolbarButton, { icon: IconColumns, title: strings.toolbar.insertColumns, onClick: openLayoutDialog }), config.footnotes && (_jsx(ToolbarButton, { icon: IconNumber1Small, title: strings.toolbar.insertFootnote, onClick: () => editor.dispatchCommand(INSERT_FOOTNOTE_COMMAND, undefined) })), config.blocks.horizontalRule && (_jsx(ToolbarButton, { icon: IconSeparatorHorizontal, title: strings.toolbar.insertHorizontalRule, onClick: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined) })), config.findReplace && (_jsx(ToolbarButton, { icon: IconSearch, title: strings.findReplace.toggle, active: findOpen, onClick: onToggleFind })), config.poetry.enabled && locale !== 'en' && (_jsx(ToolbarButton, { icon: IconFeather, title: strings.toolbar.insertPoetryCouplet, onClick: () => editor.dispatchCommand(INSERT_POETRY_COUPLET_COMMAND, { layout: config.poetry.defaultLayout }) }))] }, "stubInsert")),
812
812
  config.tables && state.inTable && (_jsx("div", { className: "likhari-toolbar-group", children: _jsxs(Menu, { position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 240, onOpen: snapshotSelection, children: [_jsx(Menu.Target, { children: _jsx("button", { type: "button", className: "likhari-toolbar-button", "data-active": "true", "aria-pressed": "true", "aria-haspopup": "menu", "aria-label": strings.toolbar.tableOptions, title: strings.toolbar.tableOptions, onMouseDown: (e) => e.preventDefault(), children: _jsx(IconTableOptions, { size: ICON_SIZE, stroke: ICON_STROKE }) }) }), _jsx(Menu.Dropdown, { children: _jsx(TableMenuItems, { strings: strings, direction: direction, rows: state.tableRows, columns: state.tableColumns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }) })] }) }, "tableActions")),
813
813
  config.poetry.enabled && state.inPoetry && (_jsx("div", { className: "likhari-toolbar-group", children: _jsxs(Menu, { position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 200, onOpen: snapshotSelection, children: [_jsx(Menu.Target, { children: _jsx("button", { type: "button", className: "likhari-toolbar-button", "data-active": "true", "aria-pressed": "true", "aria-haspopup": "menu", "aria-label": strings.toolbar.poetryOptions, title: strings.toolbar.poetryOptions, onMouseDown: (e) => e.preventDefault(), children: _jsx(IconFeather, { size: ICON_SIZE, stroke: ICON_STROKE }) }) }), _jsx(Menu.Dropdown, { children: _jsx(PoetryMenuItems, { strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction }) })] }) }, "poetryActions")),
814
- showLanguageGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [config.language.autocorrect && _jsx(StubButton, { icon: IconWand, title: strings.toolbar.autocorrect, comingSoon: strings.toolbar.comingSoon }), config.language.textCleanup && _jsx(StubButton, { icon: IconSparkles, title: strings.toolbar.textCleanup, comingSoon: strings.toolbar.comingSoon }), config.language.spellCheck && (_jsx(ToolbarButton, { icon: IconAbc, title: strings.toolbar.spellChecker, active: spellOpen, onClick: onToggleSpell }))] }, "language")),
814
+ showLanguageGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [config.language.autocorrect && (_jsx(ToolbarButton, { icon: IconWand, title: strings.toolbar.autocorrect, active: autoCorrectOpen, onClick: onToggleAutoCorrect })), config.language.textCleanup && _jsx(StubButton, { icon: IconSparkles, title: strings.toolbar.textCleanup, comingSoon: strings.toolbar.comingSoon }), config.language.spellCheck && (_jsx(ToolbarButton, { icon: IconAbc, title: strings.toolbar.spellChecker, active: spellOpen, onClick: onToggleSpell }))] }, "language")),
815
815
  ];
816
816
  return (_jsxs("div", { className: "likhari-toolbar", role: "toolbar", "aria-label": strings.toolbar.ariaLabel, ref: toolbarContainerRef, children: [fixedGroups, movableGroups
817
817
  .filter((group) => !overflowGroupKeys.has(group.key))
@@ -179,6 +179,19 @@ export interface Strings {
179
179
  next: string;
180
180
  noSuggestions: string;
181
181
  };
182
+ autoCorrect: {
183
+ title: string;
184
+ language: string;
185
+ from: string;
186
+ fromPlaceholder: string;
187
+ to: string;
188
+ toPlaceholder: string;
189
+ save: string;
190
+ saved: string;
191
+ noWritableStore: string;
192
+ failed: string;
193
+ close: string;
194
+ };
182
195
  link: {
183
196
  menuLabel: string;
184
197
  noUrl: string;
@@ -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,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,EAAE;QACP,gEAAgE;QAChE,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,0CAA0C;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;QACb,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,QAAQ,EAAE,MAAM,CAAC;QACjB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,8FAA8F;QAC9F,YAAY,EAAE,MAAM,CAAC;QACrB,0GAA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YACrB,eAAe,EAAE,MAAM,CAAC;YACxB,gBAAgB,EAAE,MAAM,CAAC;YACzB,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;SAC3C,CAAC;KACH,CAAC;IACF,eAAe,EAAE;QACf,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,eAAe,EAAE,MAAM,CAAC;QACxB,eAAe,EAAE,MAAM,CAAC;QACxB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,CAAC,OAAO,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE,MAAM,CAAA;SAAE,GAAG,IAAI,KAAK,MAAM,CAAC;QACxE,MAAM,EAAE;YACN,cAAc,EAAE,MAAM,CAAC;YACvB,YAAY,EAAE,MAAM,CAAC;YACrB,UAAU,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;SAC3C,CAAC;KACH,CAAC;IACF,SAAS,EAAE;QACT,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAwwBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAI3C,CAAC;AAEF;;sDAEsD;AACtD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD"}
@@ -162,6 +162,19 @@ 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
+ },
165
178
  link: {
166
179
  menuLabel: 'Link',
167
180
  noUrl: '(no URL)',
@@ -405,6 +418,19 @@ const ur = {
405
418
  next: 'اگلا',
406
419
  noSuggestions: 'کوئی تجویز نہیں',
407
420
  },
421
+ autoCorrect: {
422
+ title: 'خودکار تصحیح',
423
+ language: 'زبان',
424
+ from: 'لکھا ہوا لفظ',
425
+ fromPlaceholder: 'جو لفظ لکھا جاتا ہے',
426
+ to: 'درست لفظ',
427
+ toPlaceholder: 'اسے درست کریں',
428
+ save: 'تصحیح محفوظ کریں',
429
+ saved: 'محفوظ ہو گئی۔ اگلے لفظ پر لاگو ہوگی۔',
430
+ noWritableStore: 'کوئی ذخیرہ نئی تصحیح قبول نہیں کرتا',
431
+ failed: 'تصحیح محفوظ نہیں ہو سکی',
432
+ close: 'بند کریں',
433
+ },
408
434
  link: {
409
435
  menuLabel: 'لنک',
410
436
  noUrl: '(کوئی یو آر ایل نہیں)',
@@ -627,16 +653,16 @@ const paShahmukhi = {
627
653
  },
628
654
  findReplace: {
629
655
  toggle: 'لبھو تے بدلو',
630
- find: 'لبھo',
631
- replace: 'بدلo',
656
+ find: 'لبھو',
657
+ replace: 'بدلو',
632
658
  findPlaceholder: 'جو لبھنا اے',
633
659
  replacePlaceholder: 'بدلن والا متن',
634
660
  previous: 'پچھلا',
635
661
  next: 'اگلا',
636
- replaceOne: 'بدلo',
637
- replaceAll: 'سارے بدلo',
662
+ replaceOne: 'بدلو',
663
+ replaceAll: 'سارے بدلو',
638
664
  noMatches: 'کوئی ملدا نئیں',
639
- close: 'بند کرo',
665
+ close: 'بند کرو',
640
666
  },
641
667
  spellcheck: {
642
668
  title: 'ہجے دی جانچ',
@@ -648,6 +674,19 @@ const paShahmukhi = {
648
674
  next: 'اگلا',
649
675
  noSuggestions: 'کوئی تجویز نئیں',
650
676
  },
677
+ autoCorrect: {
678
+ title: 'خودکار درستی',
679
+ language: 'بولی',
680
+ from: 'لکھیا ہویا لفظ',
681
+ fromPlaceholder: 'جو لفظ لکھیا جاندا اے',
682
+ to: 'ٹھیک لفظ',
683
+ toPlaceholder: 'ایس نوں ٹھیک کرو',
684
+ save: 'درستی سانبھو',
685
+ saved: 'سانبھ لیا۔ اگلے لفظ تے لاگو ہووے گی۔',
686
+ noWritableStore: 'کوئی ذخیرہ نویں درستی نئیں منّدا',
687
+ failed: 'درستی سانبھی نئیں جا سکی',
688
+ close: 'بند کرو',
689
+ },
651
690
  link: {
652
691
  menuLabel: 'لنک',
653
692
  noUrl: '(کوئی یو آر ایل نئیں)',
package/dist/index.d.ts CHANGED
@@ -9,4 +9,6 @@ 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';
12
14
  //# sourceMappingURL=index.d.ts.map
@@ -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,s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B,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;AACrI,OAAO,EAAE,4BAA4B,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAC1H,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export { ImageNode, $createImageNode, $isImageNode } from './image/ImageNode.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';
@@ -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
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inshapardaz/likhari-react",
3
- "version": "0.1.21-dev.197",
3
+ "version": "0.1.21-dev.200",
4
4
  "description": "React implementation of the Likhari editor, built on @lexical/react.",
5
5
  "license": "MIT",
6
6
  "repository": {