@inshapardaz/likhari-react 0.1.21-dev.206 → 0.1.22
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 -9
- package/dist/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +11 -12
- package/dist/components/Toolbar.d.ts +1 -4
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +2 -3
- package/dist/i18n/strings.d.ts +0 -14
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +5 -47
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/theme/editor.css +0 -58
- package/package.json +1 -1
- package/dist/autocorrect/AutoCorrectPlugin.d.ts +0 -27
- package/dist/autocorrect/AutoCorrectPlugin.d.ts.map +0 -1
- package/dist/autocorrect/AutoCorrectPlugin.js +0 -108
- package/dist/autocorrect/autoCorrectActions.d.ts +0 -35
- package/dist/autocorrect/autoCorrectActions.d.ts.map +0 -1
- package/dist/autocorrect/autoCorrectActions.js +0 -182
- package/dist/autocorrect/autoCorrectStores.d.ts +0 -52
- package/dist/autocorrect/autoCorrectStores.d.ts.map +0 -1
- package/dist/autocorrect/autoCorrectStores.js +0 -115
- package/dist/autocorrect/punctuationRules.d.ts +0 -26
- package/dist/autocorrect/punctuationRules.d.ts.map +0 -1
- package/dist/autocorrect/punctuationRules.js +0 -53
- package/dist/cleanup/textCleanupActions.d.ts +0 -8
- package/dist/cleanup/textCleanupActions.d.ts.map +0 -1
- package/dist/cleanup/textCleanupActions.js +0 -28
- package/dist/components/AutoCorrectPanel.d.ts +0 -15
- package/dist/components/AutoCorrectPanel.d.ts.map +0 -1
- package/dist/components/AutoCorrectPanel.js +0 -44
- package/dist/normalization/urduNormalize.d.ts +0 -24
- package/dist/normalization/urduNormalize.d.ts.map +0 -1
- package/dist/normalization/urduNormalize.js +0 -116
package/dist/EditorRoot.d.ts
CHANGED
|
@@ -4,9 +4,6 @@ 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';
|
|
8
|
-
import type { UrduNormalizationOptions } from './normalization/urduNormalize.js';
|
|
9
|
-
import type { PunctuationOptions } from './autocorrect/punctuationRules.js';
|
|
10
7
|
import { type Locale } from './i18n/index.js';
|
|
11
8
|
/** What happens when the user is about to leave with unsaved changes. */
|
|
12
9
|
export type NavigationGuardMode = 'confirm' | 'save-draft' | 'off';
|
|
@@ -16,12 +13,6 @@ export interface EditorInitialContent {
|
|
|
16
13
|
}
|
|
17
14
|
export interface EditorRootProps {
|
|
18
15
|
documentId?: string;
|
|
19
|
-
/** Where auto-corrections are loaded from and saved to, in priority order. Pass a stable array. */
|
|
20
|
-
autoCorrectStores?: AutoCorrectStore[];
|
|
21
|
-
/** Urdu normalisation applied as part of auto-correct. Diacritics are kept unless `removeDiacritics` is set. */
|
|
22
|
-
urduNormalization?: UrduNormalizationOptions;
|
|
23
|
-
/** Common punctuation fixes, and whether a straight " becomes ”. Both on by default. */
|
|
24
|
-
punctuation?: PunctuationOptions;
|
|
25
16
|
initialContent?: EditorInitialContent;
|
|
26
17
|
featureConfig?: EditorFeatureConfig;
|
|
27
18
|
featurePreset?: FeatureConfigPresetName;
|
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;AAE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rC,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,uGAwYrB,CAAC"}
|
package/dist/EditorRoot.js
CHANGED
|
@@ -27,9 +27,6 @@ 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';
|
|
33
30
|
import { SpellcheckPanel } from './components/SpellcheckPanel.js';
|
|
34
31
|
import { SpellHighlightPlugin } from './spellcheck/SpellHighlightPlugin.js';
|
|
35
32
|
import { LeaveDialog } from './components/LeaveDialog.js';
|
|
@@ -40,15 +37,13 @@ import { UiStringsContext, getStrings } from './i18n/index.js';
|
|
|
40
37
|
const DEFAULT_AUTOSAVE_DELAY_MS = 750;
|
|
41
38
|
const DEFAULT_AUTOSAVE_MAX_BYTES = 2000000;
|
|
42
39
|
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()];
|
|
45
40
|
function initialEditorStateJson(initialContent) {
|
|
46
41
|
if (!initialContent)
|
|
47
42
|
return undefined;
|
|
48
43
|
const state = defaultFormatRegistry.parse(initialContent.format, initialContent.value);
|
|
49
44
|
return JSON.stringify(state);
|
|
50
45
|
}
|
|
51
|
-
export const EditorRoot = forwardRef(function EditorRoot({ documentId,
|
|
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) {
|
|
52
47
|
const config = useMemo(() => resolveFeatureConfig(featureConfig, featurePreset), [featureConfig, featurePreset]);
|
|
53
48
|
const strings = useMemo(() => getStrings(locale), [locale]);
|
|
54
49
|
const resolvedPlaceholder = placeholder ?? strings.editor.placeholder;
|
|
@@ -75,10 +70,8 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorre
|
|
|
75
70
|
const editorStateRef = useRef(null);
|
|
76
71
|
const lastSavedJsonRef = useRef(null);
|
|
77
72
|
const [isDirty, setIsDirty] = useState(false);
|
|
78
|
-
const [
|
|
79
|
-
const [
|
|
80
|
-
const stores = autoCorrectStores ?? DEFAULT_AUTOCORRECT_STORES;
|
|
81
|
-
const togglePanel = (panel) => setOpenPanel((current) => (current === panel ? null : panel));
|
|
73
|
+
const [findOpen, setFindOpen] = useState(false);
|
|
74
|
+
const [spellOpen, setSpellOpen] = useState(false);
|
|
82
75
|
const isDirtyRef = useRef(isDirty);
|
|
83
76
|
isDirtyRef.current = isDirty;
|
|
84
77
|
const autosaveTimerRef = useRef(null);
|
|
@@ -291,9 +284,15 @@ export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorre
|
|
|
291
284
|
// rather than colliding on a shared one.
|
|
292
285
|
const portalTargetId = useId();
|
|
293
286
|
const portalTargetSelector = `#${CSS.escape(portalTargetId)}`;
|
|
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:
|
|
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
|
|
295
294
|
? { currentId: draftId, maxBytes: autosaveMaxBytes, adoptOnRestore: !documentId, onRestored: handleDraftRestored }
|
|
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 &&
|
|
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: () => {
|
|
297
296
|
handleSave();
|
|
298
297
|
settleLeave(true);
|
|
299
298
|
}, onSaveDraft: () => {
|
|
@@ -10,9 +10,6 @@ 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;
|
|
16
13
|
onSave?: () => void;
|
|
17
14
|
isDirty?: boolean;
|
|
18
15
|
showSave?: boolean;
|
|
@@ -25,5 +22,5 @@ export interface ToolbarProps {
|
|
|
25
22
|
/** Autosave drafts: when set, the toolbar offers a Drafts button that lists and restores them. */
|
|
26
23
|
drafts?: DraftsToolbarOptions;
|
|
27
24
|
}
|
|
28
|
-
export declare function Toolbar({ config, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell,
|
|
25
|
+
export declare function Toolbar({ config, onSave, isDirty, showSave, findOpen, onToggleFind, spellOpen, onToggleSpell, fontOptions, direction, locale, drafts }: ToolbarProps): import("react").JSX.Element;
|
|
29
26
|
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"
|
|
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,EAAE,MAAM,IAAI,CAAC;IAC3B,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,WAAkC,EAAE,SAAiB,EAAE,MAAa,EAAE,MAAM,EAAE,EAAE,YAAY,+BAwkC1N"}
|
|
@@ -8,7 +8,6 @@ import { $createParagraphNode } from 'lexical';
|
|
|
8
8
|
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';
|
|
9
9
|
import { $isListNode, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, } from '@lexical/list';
|
|
10
10
|
import { $findMatchingParent, $insertNodeToNearestRoot } from '@lexical/utils';
|
|
11
|
-
import { CORRECT_DOCUMENT_COMMAND } from '../autocorrect/AutoCorrectPlugin.js';
|
|
12
11
|
import { INSERT_HORIZONTAL_RULE_COMMAND } from '@lexical/react/LexicalHorizontalRuleNode';
|
|
13
12
|
import { ImageDialog } from '../image/ImageDialog.js';
|
|
14
13
|
import { $createImageNode } from '../image/ImageNode.js';
|
|
@@ -183,7 +182,7 @@ function PoetryMenuItems({ strings, layout, scale, centered, onAction, }) {
|
|
|
183
182
|
};
|
|
184
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')] }));
|
|
185
184
|
}
|
|
186
|
-
export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell,
|
|
185
|
+
export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, onToggleFind, spellOpen = false, onToggleSpell, fontOptions = DEFAULT_FONT_OPTIONS, direction = 'ltr', locale = 'en', drafts }) {
|
|
187
186
|
const [editor] = useLexicalComposerContext();
|
|
188
187
|
const [state, setState] = useState(INITIAL_STATE);
|
|
189
188
|
const strings = useStrings(locale);
|
|
@@ -812,7 +811,7 @@ export function Toolbar({ config, onSave, isDirty, showSave, findOpen = false, o
|
|
|
812
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")),
|
|
813
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")),
|
|
814
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")),
|
|
815
|
-
showLanguageGroup && (_jsxs("div", { className: "likhari-toolbar-group likhari-toolbar-group--collapse-tablet", children: [config.language.autocorrect &&
|
|
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")),
|
|
816
815
|
];
|
|
817
816
|
return (_jsxs("div", { className: "likhari-toolbar", role: "toolbar", "aria-label": strings.toolbar.ariaLabel, ref: toolbarContainerRef, children: [fixedGroups, movableGroups
|
|
818
817
|
.filter((group) => !overflowGroupKeys.has(group.key))
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -179,20 +179,6 @@ 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
|
-
correctDocument: string;
|
|
195
|
-
};
|
|
196
182
|
link: {
|
|
197
183
|
menuLabel: string;
|
|
198
184
|
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,CA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
|
163
163
|
noSuggestions: 'No suggestions',
|
|
164
164
|
},
|
|
165
|
-
autoCorrect: {
|
|
166
|
-
title: 'Auto-correct',
|
|
167
|
-
language: 'Language',
|
|
168
|
-
from: 'Typed word',
|
|
169
|
-
fromPlaceholder: 'Word as typed',
|
|
170
|
-
to: 'Corrected word',
|
|
171
|
-
toPlaceholder: 'Correct it to',
|
|
172
|
-
save: 'Save correction',
|
|
173
|
-
saved: 'Saved. It applies to the next word typed.',
|
|
174
|
-
noWritableStore: 'No store accepts new corrections',
|
|
175
|
-
failed: 'Could not save the correction',
|
|
176
|
-
close: 'Close',
|
|
177
|
-
correctDocument: 'Correct whole document',
|
|
178
|
-
},
|
|
179
165
|
link: {
|
|
180
166
|
menuLabel: 'Link',
|
|
181
167
|
noUrl: '(no URL)',
|
|
@@ -419,20 +405,6 @@ const ur = {
|
|
|
419
405
|
next: 'اگلا',
|
|
420
406
|
noSuggestions: 'کوئی تجویز نہیں',
|
|
421
407
|
},
|
|
422
|
-
autoCorrect: {
|
|
423
|
-
title: 'خودکار تصحیح',
|
|
424
|
-
language: 'زبان',
|
|
425
|
-
from: 'لکھا ہوا لفظ',
|
|
426
|
-
fromPlaceholder: 'جو لفظ لکھا جاتا ہے',
|
|
427
|
-
to: 'درست لفظ',
|
|
428
|
-
toPlaceholder: 'اسے درست کریں',
|
|
429
|
-
save: 'تصحیح محفوظ کریں',
|
|
430
|
-
saved: 'محفوظ ہو گئی۔ اگلے لفظ پر لاگو ہوگی۔',
|
|
431
|
-
noWritableStore: 'کوئی ذخیرہ نئی تصحیح قبول نہیں کرتا',
|
|
432
|
-
failed: 'تصحیح محفوظ نہیں ہو سکی',
|
|
433
|
-
close: 'بند کریں',
|
|
434
|
-
correctDocument: 'تمام متن کی تصحیح کریں',
|
|
435
|
-
},
|
|
436
408
|
link: {
|
|
437
409
|
menuLabel: 'لنک',
|
|
438
410
|
noUrl: '(کوئی یو آر ایل نہیں)',
|
|
@@ -655,16 +627,16 @@ const paShahmukhi = {
|
|
|
655
627
|
},
|
|
656
628
|
findReplace: {
|
|
657
629
|
toggle: 'لبھو تے بدلو',
|
|
658
|
-
find: '
|
|
659
|
-
replace: '
|
|
630
|
+
find: 'لبھo',
|
|
631
|
+
replace: 'بدلo',
|
|
660
632
|
findPlaceholder: 'جو لبھنا اے',
|
|
661
633
|
replacePlaceholder: 'بدلن والا متن',
|
|
662
634
|
previous: 'پچھلا',
|
|
663
635
|
next: 'اگلا',
|
|
664
|
-
replaceOne: '
|
|
665
|
-
replaceAll: 'سارے
|
|
636
|
+
replaceOne: 'بدلo',
|
|
637
|
+
replaceAll: 'سارے بدلo',
|
|
666
638
|
noMatches: 'کوئی ملدا نئیں',
|
|
667
|
-
close: 'بند
|
|
639
|
+
close: 'بند کرo',
|
|
668
640
|
},
|
|
669
641
|
spellcheck: {
|
|
670
642
|
title: 'ہجے دی جانچ',
|
|
@@ -676,20 +648,6 @@ const paShahmukhi = {
|
|
|
676
648
|
next: 'اگلا',
|
|
677
649
|
noSuggestions: 'کوئی تجویز نئیں',
|
|
678
650
|
},
|
|
679
|
-
autoCorrect: {
|
|
680
|
-
title: 'خودکار درستی',
|
|
681
|
-
language: 'بولی',
|
|
682
|
-
from: 'لکھیا ہویا لفظ',
|
|
683
|
-
fromPlaceholder: 'جو لفظ لکھیا جاندا اے',
|
|
684
|
-
to: 'ٹھیک لفظ',
|
|
685
|
-
toPlaceholder: 'ایس نوں ٹھیک کرو',
|
|
686
|
-
save: 'درستی سانبھو',
|
|
687
|
-
saved: 'سانبھ لیا۔ اگلے لفظ تے لاگو ہووے گی۔',
|
|
688
|
-
noWritableStore: 'کوئی ذخیرہ نویں درستی نئیں منّدا',
|
|
689
|
-
failed: 'درستی سانبھی نئیں جا سکی',
|
|
690
|
-
close: 'بند کرو',
|
|
691
|
-
correctDocument: 'پورے متن دی درستی کرو',
|
|
692
|
-
},
|
|
693
651
|
link: {
|
|
694
652
|
menuLabel: 'لنک',
|
|
695
653
|
noUrl: '(کوئی یو آر ایل نئیں)',
|
package/dist/index.d.ts
CHANGED
|
@@ -9,9 +9,4 @@ export type { FontOption } from './fonts/index.js';
|
|
|
9
9
|
export { STRINGS, getStrings, useStrings, useUiStrings, UiStringsContext } from './i18n/index.js';
|
|
10
10
|
export type { Locale, Strings } from './i18n/index.js';
|
|
11
11
|
export { registerSpellDictionary, hasSpellDictionary, type HunspellFiles, type SpellLanguage } from './spellcheck/spellDictionaries.js';
|
|
12
|
-
export { localStorageAutoCorrectStore, apiAutoCorrectStore, fileAutoCorrectStore } from './autocorrect/autoCorrectStores.js';
|
|
13
|
-
export type { AutoCorrectStore, AutoCorrectEntry } from './autocorrect/autoCorrectStores.js';
|
|
14
|
-
export { normalizeUrdu, normalizeUrduCharacters, removeUrduDiacritics, replaceUrduDigits } from './normalization/urduNormalize.js';
|
|
15
|
-
export type { UrduNormalizationOptions } from './normalization/urduNormalize.js';
|
|
16
|
-
export type { PunctuationOptions, PunctuationRule } from './autocorrect/punctuationRules.js';
|
|
17
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1G,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC9E,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC1F,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAA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+4,3 @@ 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';
|
|
8
|
-
export { normalizeUrdu, normalizeUrduCharacters, removeUrduDiacritics, replaceUrduDigits } from './normalization/urduNormalize.js';
|
package/dist/theme/editor.css
CHANGED
|
@@ -997,61 +997,3 @@
|
|
|
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,27 +0,0 @@
|
|
|
1
|
-
import { type LexicalCommand } from 'lexical';
|
|
2
|
-
import { type PunctuationOptions } from './punctuationRules.js';
|
|
3
|
-
import { type AutoCorrectStore } from './autoCorrectStores.js';
|
|
4
|
-
import { type UrduNormalizationOptions } from '../normalization/urduNormalize.js';
|
|
5
|
-
/** Keys that end a word: a space or punctuation, in Latin and Arabic-script forms. */
|
|
6
|
-
/** Corrects every word in the document, e.g. after pasting or loading content. */
|
|
7
|
-
export declare const CORRECT_DOCUMENT_COMMAND: LexicalCommand<void>;
|
|
8
|
-
/**
|
|
9
|
-
* Corrects typed words as the user finishes them, the way the reference editor
|
|
10
|
-
* does, but from any set of stores. Corrections are loaded once per change
|
|
11
|
-
* of `stores` or `version` (bump `version` after saving a new correction so
|
|
12
|
-
* the table reloads). The table used depends on the block's direction: RTL
|
|
13
|
-
* blocks use the Urdu and Shahmukhi tables, LTR blocks the English one.
|
|
14
|
-
*/
|
|
15
|
-
export declare function AutoCorrectPlugin({ stores, version, enabled, typing, urduNormalization, punctuation, }: {
|
|
16
|
-
stores: AutoCorrectStore[];
|
|
17
|
-
version: number;
|
|
18
|
-
/** Whether the tables and the whole-document command are active. */
|
|
19
|
-
enabled: boolean;
|
|
20
|
-
/** Whether corrections run as the user types (auto-correct), not only on demand. */
|
|
21
|
-
typing: boolean;
|
|
22
|
-
/** Urdu normalisation for right-to-left text; character mapping always applies. */
|
|
23
|
-
urduNormalization?: UrduNormalizationOptions;
|
|
24
|
-
/** Common punctuation fixes (from the bundled Urdu rule list). */
|
|
25
|
-
punctuation?: PunctuationOptions;
|
|
26
|
-
}): null;
|
|
27
|
-
//# sourceMappingURL=AutoCorrectPlugin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AutoCorrectPlugin.d.ts","sourceRoot":"","sources":["../../src/autocorrect/AutoCorrectPlugin.tsx"],"names":[],"mappings":"AAEA,OAAO,EAA4E,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAUxH,OAAO,EAA0B,KAAK,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACrF,OAAO,EAAuB,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAiB,KAAK,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAG9F,sFAAsF;AACtF,kFAAkF;AAClF,eAAO,MAAM,wBAAwB,EAAE,cAAc,CAAC,IAAI,CAA6C,CAAC;AAMxG;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,OAAO,EACP,OAAO,EACP,MAAM,EACN,iBAAiB,EACjB,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,OAAO,EAAE,OAAO,CAAC;IACjB,oFAAoF;IACpF,MAAM,EAAE,OAAO,CAAC;IAChB,mFAAmF;IACnF,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,kEAAkE;IAClE,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAClC,QA4FA"}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
|
-
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
4
|
-
import { $correctDocument, $correctPunctuationBeforeCaret, $correctPunctuationDocument, $correctWordBeforeCaret, $preservingSelection, $spacePunctuationDocument, } from './autoCorrectActions.js';
|
|
5
|
-
import { $cleanUpText } from '../cleanup/textCleanupActions.js';
|
|
6
|
-
import { activePunctuationRules } from './punctuationRules.js';
|
|
7
|
-
import { loadAutoCorrections } from './autoCorrectStores.js';
|
|
8
|
-
import { normalizeUrdu } from '../normalization/urduNormalize.js';
|
|
9
|
-
/** Keys that end a word: a space or punctuation, in Latin and Arabic-script forms. */
|
|
10
|
-
/** Corrects every word in the document, e.g. after pasting or loading content. */
|
|
11
|
-
export const CORRECT_DOCUMENT_COMMAND = createCommand('CORRECT_DOCUMENT_COMMAND');
|
|
12
|
-
const BOUNDARY_KEYS = new Set([' ', '.', ',', ';', ':', '!', '?', '،', '؛', '؟', '۔']);
|
|
13
|
-
const LANGUAGES = ['en', 'ur', 'pa-shahmukhi'];
|
|
14
|
-
const RTL_LANGUAGES = ['ur', 'pa-shahmukhi'];
|
|
15
|
-
/**
|
|
16
|
-
* Corrects typed words as the user finishes them, the way the reference editor
|
|
17
|
-
* does, but from any set of stores. Corrections are loaded once per change
|
|
18
|
-
* of `stores` or `version` (bump `version` after saving a new correction so
|
|
19
|
-
* the table reloads). The table used depends on the block's direction: RTL
|
|
20
|
-
* blocks use the Urdu and Shahmukhi tables, LTR blocks the English one.
|
|
21
|
-
*/
|
|
22
|
-
export function AutoCorrectPlugin({ stores, version, enabled, typing, urduNormalization, punctuation, }) {
|
|
23
|
-
const [editor] = useLexicalComposerContext();
|
|
24
|
-
// Effects below run once per editor, so they reach the latest options through this ref.
|
|
25
|
-
const normalizeOptions = useRef(urduNormalization);
|
|
26
|
-
normalizeOptions.current = urduNormalization;
|
|
27
|
-
const punctuationRules = useRef(activePunctuationRules(punctuation));
|
|
28
|
-
punctuationRules.current = activePunctuationRules(punctuation);
|
|
29
|
-
const normalizeRtl = (text) => normalizeUrdu(text, normalizeOptions.current);
|
|
30
|
-
const tables = useRef(new Map());
|
|
31
|
-
const rtlTable = useRef(new Map());
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
if (!enabled)
|
|
34
|
-
return;
|
|
35
|
-
let active = true;
|
|
36
|
-
Promise.all(LANGUAGES.map(async (language) => [language, await loadAutoCorrections(stores, language)])).then((loaded) => {
|
|
37
|
-
if (!active)
|
|
38
|
-
return;
|
|
39
|
-
tables.current = new Map(loaded);
|
|
40
|
-
// Urdu and Shahmukhi share right-to-left blocks, so both apply there; Urdu wins a clash.
|
|
41
|
-
const combined = new Map();
|
|
42
|
-
for (const language of RTL_LANGUAGES) {
|
|
43
|
-
for (const [from, to] of tables.current.get(language) ?? [])
|
|
44
|
-
if (!combined.has(from))
|
|
45
|
-
combined.set(from, to);
|
|
46
|
-
}
|
|
47
|
-
rtlTable.current = combined;
|
|
48
|
-
});
|
|
49
|
-
return () => {
|
|
50
|
-
active = false;
|
|
51
|
-
};
|
|
52
|
-
}, [stores, version, enabled]);
|
|
53
|
-
useEffect(() => {
|
|
54
|
-
if (!enabled)
|
|
55
|
-
return;
|
|
56
|
-
return editor.registerCommand(CORRECT_DOCUMENT_COMMAND, () => {
|
|
57
|
-
editor.update(() => {
|
|
58
|
-
$preservingSelection(() => {
|
|
59
|
-
$cleanUpText();
|
|
60
|
-
if (punctuation?.spacing)
|
|
61
|
-
$spacePunctuationDocument();
|
|
62
|
-
$correctPunctuationDocument(punctuationRules.current);
|
|
63
|
-
$correctDocument(tables.current.get('en') ?? new Map(), rtlTable.current, normalizeRtl);
|
|
64
|
-
});
|
|
65
|
-
}, { discrete: true });
|
|
66
|
-
return true;
|
|
67
|
-
}, COMMAND_PRIORITY_EDITOR);
|
|
68
|
-
}, [editor, enabled, punctuation?.spacing]);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (!enabled || !typing)
|
|
71
|
-
return;
|
|
72
|
-
const tableFor = (rtl) => (rtl ? rtlTable.current : tables.current.get('en'));
|
|
73
|
-
const onKeyDown = (event) => {
|
|
74
|
-
if (event.isComposing || event.key.length !== 1)
|
|
75
|
-
return;
|
|
76
|
-
const boundary = BOUNDARY_KEYS.has(event.key);
|
|
77
|
-
// The character is inserted after this event; correct once it is there.
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
editor.update(() => {
|
|
80
|
-
const selection = $getSelection();
|
|
81
|
-
if (!$isRangeSelection(selection))
|
|
82
|
-
return;
|
|
83
|
-
// Punctuation can end in any character (e.g. the letter ه), so every key is checked.
|
|
84
|
-
$correctPunctuationBeforeCaret(punctuationRules.current);
|
|
85
|
-
if (!boundary)
|
|
86
|
-
return;
|
|
87
|
-
const block = selection.anchor.getNode().getTopLevelElement();
|
|
88
|
-
const rtl = block?.getDirection() === 'rtl';
|
|
89
|
-
const table = tableFor(rtl);
|
|
90
|
-
if (table)
|
|
91
|
-
$correctWordBeforeCaret(table, rtl ? normalizeRtl : undefined);
|
|
92
|
-
}, { discrete: true });
|
|
93
|
-
}, 0);
|
|
94
|
-
};
|
|
95
|
-
let root = null;
|
|
96
|
-
const attach = (next) => {
|
|
97
|
-
root?.removeEventListener('keydown', onKeyDown);
|
|
98
|
-
root = next;
|
|
99
|
-
root?.addEventListener('keydown', onKeyDown);
|
|
100
|
-
};
|
|
101
|
-
const unregister = editor.registerRootListener((next) => attach(next));
|
|
102
|
-
return () => {
|
|
103
|
-
unregister();
|
|
104
|
-
attach(null);
|
|
105
|
-
};
|
|
106
|
-
}, [editor, enabled, typing]);
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type PunctuationRule } from './punctuationRules.js';
|
|
2
|
-
/**
|
|
3
|
-
* Corrects the word that ends just before the caret, when the character just
|
|
4
|
-
* typed (the word boundary: space or punctuation) is not a word character. The
|
|
5
|
-
* correction replaces only the word, and the caret stays right after the
|
|
6
|
-
* boundary. Returns true if a correction was made.
|
|
7
|
-
*/
|
|
8
|
-
export declare function $correctWordBeforeCaret(table: Map<string, string>, normalize?: (word: string) => string): boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Corrects every whole word in the document, for text that never went through
|
|
11
|
-
* typing (pasted or loaded content). Words are found per paragraph or cell, so a
|
|
12
|
-
* word split by formatting is still one word. Each block uses the table for its
|
|
13
|
-
* direction. Returns how many words were corrected.
|
|
14
|
-
*/
|
|
15
|
-
export declare function $correctDocument(ltr: Map<string, string>, rtl: Map<string, string>, normalizeRtl?: (text: string) => string): number;
|
|
16
|
-
/**
|
|
17
|
-
* Applies a punctuation rule to the text just before the caret, when that text
|
|
18
|
-
* ends with a rule's incorrect form. Longest match first. The caret ends after
|
|
19
|
-
* the replacement.
|
|
20
|
-
*/
|
|
21
|
-
export declare function $correctPunctuationBeforeCaret(rules: PunctuationRule[]): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Applies the punctuation rules to every paragraph and cell in the document.
|
|
24
|
-
* Where two matches overlap, the longer one wins. Returns how many were applied.
|
|
25
|
-
*/
|
|
26
|
-
export declare function $correctPunctuationDocument(rules: PunctuationRule[]): number;
|
|
27
|
-
/**
|
|
28
|
-
* Runs `change` and then puts the caret back where it was. Replacements move the
|
|
29
|
-
* selection onto each match they make, so a whole-document pass would otherwise
|
|
30
|
-
* leave the caret at the last match, or at the end of the document.
|
|
31
|
-
*/
|
|
32
|
-
export declare function $preservingSelection(change: () => void): void;
|
|
33
|
-
/** Applies urduhack-style punctuation spacing to every text node. Returns how many changed. */
|
|
34
|
-
export declare function $spacePunctuationDocument(): number;
|
|
35
|
-
//# sourceMappingURL=autoCorrectActions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"autoCorrectActions.d.ts","sourceRoot":"","sources":["../../src/autocorrect/autoCorrectActions.ts"],"names":[],"mappings":"AAWA,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAMhF;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAiCjH;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,GAAG,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACxB,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GACtC,MAAM,CA8BR;AAQD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO,CAqBhF;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,MAAM,CA2B5E;AAID;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,IAAI,GAAG,IAAI,CAoB7D;AAED,+FAA+F;AAC/F,wBAAgB,yBAAyB,IAAI,MAAM,CAWlD"}
|