@inshapardaz/likhari-react 0.1.43 → 0.1.44-dev.326
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 +2 -0
- package/dist/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +4 -4
- package/dist/components/SpellcheckPanel.d.ts +3 -1
- package/dist/components/SpellcheckPanel.d.ts.map +1 -1
- package/dist/components/SpellcheckPanel.js +2 -2
- package/dist/components/Toolbar.d.ts +3 -1
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +3 -3
- package/dist/join/joinLinesActions.d.ts.map +1 -1
- package/dist/join/joinLinesActions.js +23 -3
- package/dist/spellcheck/SpellHighlightPlugin.d.ts +6 -1
- package/dist/spellcheck/SpellHighlightPlugin.d.ts.map +1 -1
- package/dist/spellcheck/SpellHighlightPlugin.js +12 -13
- package/package.json +1 -1
package/dist/EditorRoot.d.ts
CHANGED
|
@@ -31,6 +31,8 @@ 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';
|
|
34
36
|
/** Urdu normalisation applied as part of auto-correct. Diacritics are kept unless `removeDiacritics` is set. */
|
|
35
37
|
urduNormalization?: UrduNormalizationOptions;
|
|
36
38
|
/** 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":"A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B,cAAc,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACnC,KAAK,IAAI,IAAI,CAAC;CACf;AAQD,eAAO,MAAM,UAAU,uGA0hBrB,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', 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) {
|
|
62
|
+
export const EditorRoot = forwardRef(function EditorRoot({ documentId, autoCorrectStores, dictionaryStores, completionStores, thesaurusStores, autoCompleteLanguage = 'auto', spellCheckLanguage = '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, drafts: autosave
|
|
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, spellCheckLanguage: spellCheckLanguage, 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, 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
|
|
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, initialLanguage: spellCheckLanguage !== 'auto' ? spellCheckLanguage : 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, {}), 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: () => {
|
|
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, { language: spellCheckLanguage }), 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,11 +7,13 @@ 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, onClose, }: {
|
|
10
|
+
export declare function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect, initialLanguage, 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;
|
|
15
17
|
onClose: () => void;
|
|
16
18
|
}): import("react").JSX.Element;
|
|
17
19
|
//# 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,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"}
|
|
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,eAAe,EACf,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,4FAA4F;IAC5F,eAAe,CAAC,EAAE,aAAa,CAAC;IAChC,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, onClose, }) {
|
|
21
|
+
export function SpellcheckPanel({ strings, dir, dictionaryStores, onAddAutoCorrect, initialLanguage, onClose, }) {
|
|
22
22
|
const [editor] = useLexicalComposerContext();
|
|
23
23
|
const t = strings.spellcheck;
|
|
24
|
-
const [language, setLanguage] = useState('en');
|
|
24
|
+
const [language, setLanguage] = useState(initialLanguage ?? 'en');
|
|
25
25
|
const [items, setItems] = useState(null);
|
|
26
26
|
const [index, setIndex] = useState(0);
|
|
27
27
|
const [checking, setChecking] = useState(false);
|
|
@@ -57,6 +57,8 @@ 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';
|
|
60
62
|
/** Autosave drafts: when set, the toolbar offers a Drafts button that lists and restores them. */
|
|
61
63
|
drafts?: DraftsToolbarOptions;
|
|
62
64
|
/**
|
|
@@ -69,5 +71,5 @@ export interface ToolbarProps {
|
|
|
69
71
|
/** `docs/markdown-dialect.md` at the repository's default branch — the Markdown
|
|
70
72
|
* format this editor reads and writes, including the poetry container syntax. */
|
|
71
73
|
export declare const DEFAULT_HELP_URL = "https://github.com/inshapardaz/likhari/blob/main/docs/markdown-dialect.md";
|
|
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): import("react").JSX.Element;
|
|
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, spellCheckLanguage, drafts, helpUrl }: ToolbarProps): import("react").JSX.Element;
|
|
73
75
|
//# sourceMappingURL=Toolbar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toolbar.d.ts","sourceRoot":"","sources":["../../src/components/Toolbar.tsx"],"names":[],"mappings":"AA2CA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,iCAAiC,CAAC;AACjF,OAAO,EAAkB,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnF,OAAO,EAA2B,KAAK,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAmDtF,OAAO,EAAgB,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEzE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAkF,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAI1I,OAAO,KAAK,EAAE,MAAM,EAAW,MAAM,iBAAiB,CAAC;AAujBvD,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,QAAQ,CA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CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gJAAgJ;IAChJ,kBAAkB,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;IAC5C,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,kBAA2B,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,YAAY,+BAwzC3d"}
|
|
@@ -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', drafts, helpUrl }) {
|
|
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', spellCheckLanguage = 'auto', 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 = word?.direction === 'rtl' ? 'ur' : 'en';
|
|
612
|
+
const language = spellCheckLanguage !== 'auto' ? spellCheckLanguage : 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, spellCheckLanguage]);
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinLinesActions.d.ts","sourceRoot":"","sources":["../../src/join/joinLinesActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"joinLinesActions.d.ts","sourceRoot":"","sources":["../../src/join/joinLinesActions.ts"],"names":[],"mappings":"AAoCA,wBAAgB,aAAa,IAAI,OAAO,CAKvC;AAiDD;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CA2B5C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $createTextNode, $getSelection, $isLineBreakNode, $isParagraphNode, $isRangeSelection, $createParagraphNode, } from 'lexical';
|
|
1
|
+
import { $createTextNode, $getSelection, $isLineBreakNode, $isParagraphNode, $isRangeSelection, $isTextNode, $createParagraphNode, } from 'lexical';
|
|
2
2
|
function $paragraphsInSelection(selection) {
|
|
3
3
|
const seen = new Set();
|
|
4
4
|
const paragraphs = [];
|
|
@@ -11,13 +11,30 @@ function $paragraphsInSelection(selection) {
|
|
|
11
11
|
}
|
|
12
12
|
return paragraphs;
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Text nodes in the selection that hold a literal newline. Lexical shows these
|
|
16
|
+
* as line breaks, but they are not line-break nodes: content loaded from
|
|
17
|
+
* plain text or a foreign Lexical document can be shaped this way.
|
|
18
|
+
*/
|
|
19
|
+
function $textNodesWithNewlines(selection) {
|
|
20
|
+
return selection.getNodes().filter((node) => $isTextNode(node) && node.getTextContent().includes('\n'));
|
|
21
|
+
}
|
|
14
22
|
export function $canJoinLines() {
|
|
15
23
|
const selection = $getSelection();
|
|
16
24
|
if (!$isRangeSelection(selection) || selection.isCollapsed())
|
|
17
25
|
return false;
|
|
18
26
|
if ($paragraphsInSelection(selection).length > 1)
|
|
19
27
|
return true;
|
|
20
|
-
return selection.getNodes().some($isLineBreakNode);
|
|
28
|
+
return selection.getNodes().some($isLineBreakNode) || $textNodesWithNewlines(selection).length > 0;
|
|
29
|
+
}
|
|
30
|
+
/** Replaces the newlines in the selected part of a text node, each by one space (none if one is already there). */
|
|
31
|
+
function $replaceNewlinesInText(node, selection) {
|
|
32
|
+
const [start, end] = selection.getStartEndPoints() ?? [];
|
|
33
|
+
const text = node.getTextContent();
|
|
34
|
+
const from = start && start.key === node.getKey() ? start.offset : 0;
|
|
35
|
+
const to = end && end.key === node.getKey() ? end.offset : text.length;
|
|
36
|
+
const joined = text.slice(from, to).replace(/[ \t]*\r?\n[ \t]*/g, ' ');
|
|
37
|
+
node.setTextContent(text.slice(0, from) + joined + text.slice(to));
|
|
21
38
|
}
|
|
22
39
|
/** A soft break becomes one space, unless the text either side already has a space there. */
|
|
23
40
|
function $replaceBreakWithSpace(lineBreak) {
|
|
@@ -67,13 +84,16 @@ export function $joinSelectedLines() {
|
|
|
67
84
|
const paragraphs = $paragraphsInSelection(selection);
|
|
68
85
|
const nodes = selection.getNodes();
|
|
69
86
|
const lineBreaks = nodes.filter($isLineBreakNode);
|
|
70
|
-
|
|
87
|
+
const textsWithNewlines = $textNodesWithNewlines(selection);
|
|
88
|
+
if (paragraphs.length < 2 && lineBreaks.length === 0 && textsWithNewlines.length === 0)
|
|
71
89
|
return false;
|
|
72
90
|
const last = nodes[nodes.length - 1];
|
|
73
91
|
const breakAfter = last?.getNextSibling();
|
|
74
92
|
const trailingBreak = $isLineBreakNode(breakAfter) ? breakAfter : null;
|
|
75
93
|
for (const lineBreak of lineBreaks)
|
|
76
94
|
$replaceBreakWithSpace(lineBreak);
|
|
95
|
+
for (const textNode of textsWithNewlines)
|
|
96
|
+
$replaceNewlinesInText(textNode, selection);
|
|
77
97
|
const [target, ...rest] = paragraphs;
|
|
78
98
|
if (!target)
|
|
79
99
|
return false;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type SpellLanguage } from './spellDictionaries.js';
|
|
1
2
|
/**
|
|
2
3
|
* Underlines misspelled words the way the browser does, without changing the
|
|
3
4
|
* document. Only blocks that are in view are checked, a block a few seconds after
|
|
@@ -6,5 +7,9 @@
|
|
|
6
7
|
* ranges set through the CSS Custom Highlight API. In browsers without it, nothing
|
|
7
8
|
* is underlined.
|
|
8
9
|
*/
|
|
9
|
-
export
|
|
10
|
+
export interface SpellHighlightPluginProps {
|
|
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;
|
|
10
15
|
//# 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":"AAIA,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAkBrE;;;;;;;GAOG;AACH,MAAM,WAAW,yBAAyB;IACxC,gIAAgI;IAChI,QAAQ,CAAC,EAAE,aAAa,GAAG,MAAM,CAAC;CACnC;AAED,wBAAgB,oBAAoB,CAAC,EAAE,QAAiB,EAAE,GAAE,yBAA8B,QA4JzF"}
|
|
@@ -18,15 +18,7 @@ function $topLevelKey(node) {
|
|
|
18
18
|
current = current.getParent();
|
|
19
19
|
return current.getParent() ? current.getKey() : null;
|
|
20
20
|
}
|
|
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() {
|
|
21
|
+
export function SpellHighlightPlugin({ language = 'auto' } = {}) {
|
|
30
22
|
const [editor] = useLexicalComposerContext();
|
|
31
23
|
useEffect(() => {
|
|
32
24
|
if (typeof CSS === 'undefined' || !('highlights' in CSS) || typeof IntersectionObserver === 'undefined')
|
|
@@ -164,11 +156,18 @@ export function SpellHighlightPlugin() {
|
|
|
164
156
|
Promise.all([getSpeller('en'), getSpeller('ur')]).then(async ([en, ur]) => {
|
|
165
157
|
if (!active)
|
|
166
158
|
return;
|
|
167
|
-
|
|
159
|
+
const enSpeller = en ? await en : undefined;
|
|
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();
|
|
168
168
|
syncBlocks();
|
|
169
169
|
for (const key of visible)
|
|
170
|
-
|
|
171
|
-
schedule(key, 0);
|
|
170
|
+
schedule(key, 0);
|
|
172
171
|
});
|
|
173
172
|
return () => {
|
|
174
173
|
active = false;
|
|
@@ -179,7 +178,7 @@ export function SpellHighlightPlugin() {
|
|
|
179
178
|
clearTimeout(timer);
|
|
180
179
|
CSS.highlights.delete(HIGHLIGHT);
|
|
181
180
|
};
|
|
182
|
-
}, [editor]);
|
|
181
|
+
}, [editor, language]);
|
|
183
182
|
return null;
|
|
184
183
|
}
|
|
185
184
|
/** The text nodes of a rendered block, with where each one starts in the block's text. */
|