@inshapardaz/likhari-react 0.1.29-dev.265 → 0.1.29
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/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +4 -19
- package/dist/i18n/strings.d.ts +0 -3
- package/dist/i18n/strings.d.ts.map +1 -1
- package/dist/i18n/strings.js +0 -6
- package/package.json +1 -1
- package/dist/join/joinLinesActions.d.ts +0 -9
- package/dist/join/joinLinesActions.d.ts.map +0 -1
- package/dist/join/joinLinesActions.js +0 -89
|
@@ -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":"AA0CA,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;AAgDtF,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;AAggBvD,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2FAA2F;IAC3F,OAAO,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,2BAA2B,CAAC;IACpC,YAAY,CAAC,EAAE,YAAY,CAAC;I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|
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
11
|
import { CORRECT_DOCUMENT_COMMAND } from '../autocorrect/AutoCorrectPlugin.js';
|
|
12
|
-
import { $canJoinLines, $joinSelectedLines } from '../join/joinLinesActions.js';
|
|
13
12
|
import { $replaceMatch } from '../find/findReplaceActions.js';
|
|
14
13
|
import { getSpeller } from '../spellcheck/spellDictionaries.js';
|
|
15
14
|
import { lookupSynonyms } from '../thesaurus/thesaurusStores.js';
|
|
@@ -36,13 +35,12 @@ import { CANVAS_FONT_DEFAULTS, DEFAULT_FONT_OPTIONS, FONT_SIZES_PX } from '../fo
|
|
|
36
35
|
import { setStyleProperty } from '../utils/style.js';
|
|
37
36
|
import { useStrings } from '../i18n/useStrings.js';
|
|
38
37
|
import { usePortalTarget } from '../PortalTargetContext.js';
|
|
39
|
-
import { IconAbc, IconAlignCenter, IconAlignJustified, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowForwardUp,
|
|
38
|
+
import { IconAbc, IconAlignCenter, IconAlignJustified, IconAlignLeft, IconAlignRight, IconArrowBackUp, IconArrowForwardUp, IconBold, IconClearFormatting, IconDeviceFloppy, IconDots, IconHistory, IconExternalLink, IconFeather, IconH1, IconH2, IconH3, IconH4, IconH5, IconH6, IconIndentDecrease, IconIndentIncrease, IconItalic, IconLetterCase, IconLetterCaseLower, IconLetterCaseUpper, IconLink, IconLinkOff, IconList, IconListCheck, IconListNumbers, IconPageBreak, IconPencil, IconPhoto, IconPilcrow, IconQuote, IconSeparatorHorizontal, IconSparkles, IconStrikethrough, IconSubscript, IconSuperscript, IconArrowMergeBoth, IconArrowsSplit2, IconColumnInsertLeft, IconColumnInsertRight, IconColumnRemove, IconColumns, IconClipboard, IconCopy, IconCut, IconSearch, IconSelectAll, IconColumns1, IconColumns2, IconNumber1Small, IconRowInsertBottom, IconRowInsertTop, IconRowRemove, IconArrowsMaximize, IconArrowsMinimize, IconArrowsShuffle, IconTable, IconTableMinus, IconTrash, IconTableOptions, IconTextSize, IconTypography, IconUnderline, IconWand, } from '@tabler/icons-react';
|
|
40
39
|
/** Sentinel for "no inline style": Lexical returns the default it is given when
|
|
41
40
|
* the selection has none, so this tells "unstyled" (show the canvas default)
|
|
42
41
|
* apart from "styled with a value the dropdown doesn't list" (show nothing). */
|
|
43
42
|
const UNSET_STYLE = '__unset__';
|
|
44
43
|
const INITIAL_STATE = {
|
|
45
|
-
canJoinLines: false,
|
|
46
44
|
blockType: 'paragraph',
|
|
47
45
|
activeFormats: new Set(),
|
|
48
46
|
elementFormat: 'start',
|
|
@@ -228,7 +226,6 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
228
226
|
// Lexical's read/update context has already closed, so any $-prefixed
|
|
229
227
|
// node method (getFormatType() included) must not be deferred into it.
|
|
230
228
|
const elementFormat = ($isElementNode(element) ? element.getFormatType() : 'start') || 'start';
|
|
231
|
-
const canJoinLines = $canJoinLines();
|
|
232
229
|
const poetryLayout = poetryBlock?.getLayout();
|
|
233
230
|
const poetryCentered = $getCoupletCenteredFromSelection();
|
|
234
231
|
const poetryScale = poetryBlock
|
|
@@ -236,7 +233,6 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
236
233
|
: null;
|
|
237
234
|
setState((s) => ({
|
|
238
235
|
...s,
|
|
239
|
-
canJoinLines,
|
|
240
236
|
blockType,
|
|
241
237
|
activeFormats,
|
|
242
238
|
elementFormat,
|
|
@@ -506,10 +502,6 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
506
502
|
}
|
|
507
503
|
if (point)
|
|
508
504
|
word = $wordAtDomPoint(point.node, point.offset);
|
|
509
|
-
if (!cell && !couplet) {
|
|
510
|
-
menu.text = true;
|
|
511
|
-
menu.canJoin = $canJoinLines();
|
|
512
|
-
}
|
|
513
505
|
}, { discrete: true });
|
|
514
506
|
const language = word?.direction === 'rtl' ? 'ur' : 'en';
|
|
515
507
|
if (word && config.language.thesaurus) {
|
|
@@ -647,6 +639,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
647
639
|
(config.poetry.enabled && locale !== 'en') ||
|
|
648
640
|
(config.tables && state.inTable) ||
|
|
649
641
|
(config.poetry.enabled && state.inPoetry);
|
|
642
|
+
const showLanguageGroup = config.language.autocorrect || config.language.textCleanup || config.language.spellCheck;
|
|
650
643
|
const moreItems = [];
|
|
651
644
|
if (fmt.superscript) {
|
|
652
645
|
moreItems.push({
|
|
@@ -740,13 +733,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
740
733
|
restoreSelection();
|
|
741
734
|
openLinkDialog();
|
|
742
735
|
}, onRemove: removeLink, strings: strings }) })] })) : (_jsx(ToolbarButton, { icon: IconLink, title: strings.toolbar.insertLink, onClick: openLinkDialog }))), (config.images.linked || config.images.embedded) && (_jsx(ToolbarButton, { icon: IconPhoto, title: strings.toolbar.insertImage, onClick: openImageDialog })), config.blocks.horizontalRule && (_jsx(ToolbarButton, { icon: IconSeparatorHorizontal, title: strings.toolbar.insertHorizontalRule, onClick: () => editor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, undefined) })), config.tables && _jsx(ToolbarButton, { icon: IconTable, title: strings.toolbar.insertTable, onClick: openTableDialog }), config.tables && state.inTable && (_jsxs(Menu, { position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 240, onOpen: snapshotSelection, children: [_jsx(Menu.Target, { children: _jsx(ToolbarButton, { icon: IconTableOptions, title: strings.toolbar.tableOptions, active: true, "aria-haspopup": "menu" }) }), _jsx(Menu.Dropdown, { children: _jsx(TableMenuItems, { strings: strings, direction: direction, rows: state.tableRows, columns: state.tableColumns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }) })] })), 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.pageBreak && (_jsx(ToolbarButton, { icon: IconPageBreak, title: strings.toolbar.insertPageBreak, onClick: () => editor.dispatchCommand(INSERT_PAGE_BREAK_COMMAND, undefined) })), config.poetry.enabled && locale !== 'en' && (_jsx(ToolbarButton, { icon: IconFeather, title: strings.toolbar.insertPoetryCouplet, onClick: () => editor.dispatchCommand(INSERT_POETRY_COUPLET_COMMAND, { layout: config.poetry.defaultLayout }) })), config.poetry.enabled && state.inPoetry && (_jsxs(Menu, { position: "bottom-start", withinPortal: true, portalProps: { target: portalTarget }, shadow: "sm", width: 200, onOpen: snapshotSelection, children: [_jsx(Menu.Target, { children: _jsx(ToolbarButton, { icon: IconFeather, title: strings.toolbar.poetryOptions, active: true, "aria-haspopup": "menu" }) }), _jsx(Menu.Dropdown, { children: _jsx(PoetryMenuItems, { strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction }) })] }))] }, "insert"));
|
|
743
|
-
const
|
|
744
|
-
editor.update(() => {
|
|
745
|
-
$joinSelectedLines();
|
|
746
|
-
}, { discrete: true });
|
|
747
|
-
editor.focus();
|
|
748
|
-
};
|
|
749
|
-
const toolsSection = (_jsxs(MantineToolbar.Group, { className: "likhari-toolbar-cluster", children: [config.language.autocorrect && (_jsx(ToolbarButton, { icon: IconWand, title: strings.toolbar.autocorrect, active: autoCorrectOpen, onClick: onToggleAutoCorrect })), config.language.textCleanup && (_jsx(ToolbarButton, { icon: IconSparkles, title: strings.autoCorrect.correctDocument, onClick: () => editor.dispatchCommand(CORRECT_DOCUMENT_COMMAND, undefined) })), config.language.spellCheck && (_jsx(ToolbarButton, { icon: IconAbc, title: strings.toolbar.spellChecker, active: spellOpen, onClick: onToggleSpell })), _jsx(ToolbarButton, { icon: IconArrowsJoin, title: strings.toolbar.joinLines, disabled: !state.canJoinLines, onClick: joinLines })] }, "tools"));
|
|
736
|
+
const toolsSection = showLanguageGroup && (_jsxs(MantineToolbar.Group, { className: "likhari-toolbar-cluster", children: [config.language.autocorrect && (_jsx(ToolbarButton, { icon: IconWand, title: strings.toolbar.autocorrect, active: autoCorrectOpen, onClick: onToggleAutoCorrect })), config.language.textCleanup && (_jsx(ToolbarButton, { icon: IconSparkles, title: strings.autoCorrect.correctDocument, onClick: () => editor.dispatchCommand(CORRECT_DOCUMENT_COMMAND, undefined) })), config.language.spellCheck && (_jsx(ToolbarButton, { icon: IconAbc, title: strings.toolbar.spellChecker, active: spellOpen, onClick: onToggleSpell }))] }, "tools"));
|
|
750
737
|
const endSection = (drafts || config.findReplace) && (_jsxs(MantineToolbar.Group, { className: "likhari-toolbar-cluster", style: { marginInlineStart: 'auto' }, children: [drafts && _jsx(ToolbarButton, { icon: IconHistory, title: strings.toolbar.drafts, onClick: () => setDraftsOpen(true) }), config.findReplace && (_jsx(ToolbarButton, { icon: IconSearch, title: strings.findReplace.toggle, active: findOpen, onClick: onToggleFind }))] }, "end"));
|
|
751
738
|
const startSections = [
|
|
752
739
|
showSave && (_jsx(MantineToolbar.Group, { className: "likhari-toolbar-cluster", children: _jsx(ToolbarButton, { icon: IconDeviceFloppy, title: strings.toolbar.save, dirty: Boolean(isDirty), onClick: onSave }) }, "save")),
|
|
@@ -785,7 +772,5 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
785
772
|
}, children: synonym }, synonym))), _jsx(Menu.Divider, {})] })), contextMenu?.link !== undefined && (_jsxs(_Fragment, { children: [_jsx(LinkMenuItems, { url: contextMenu.link, onEdit: () => {
|
|
786
773
|
restoreSelection();
|
|
787
774
|
openLinkDialog();
|
|
788
|
-
}, onRemove: removeLink, strings: strings }), _jsx(Menu.Divider, {})] })), contextMenu?.table && (_jsxs(_Fragment, { children: [_jsx(TableMenuItems, { strings: strings, direction: direction, rows: contextMenu.table.rows, columns: contextMenu.table.columns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }), _jsx(Menu.Divider, {})] })), contextMenu?.poetry && (_jsxs(_Fragment, { children: [_jsx(PoetryMenuItems, { strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction }), _jsx(Menu.Divider, {})] })), contextMenu
|
|
789
|
-
$joinSelectedLines();
|
|
790
|
-
}), children: strings.contextMenu.joinLines }), _jsx(Menu.Divider, {})] })), _jsx(Menu.Item, { leftSection: _jsx(IconCut, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void copyOrCut(true)(), children: strings.contextMenu.cut }), _jsx(Menu.Item, { leftSection: _jsx(IconCopy, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void copyOrCut(false)(), children: strings.contextMenu.copy }), _jsx(Menu.Item, { leftSection: _jsx(IconClipboard, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void paste(), children: strings.contextMenu.paste }), _jsx(Menu.Item, { leftSection: _jsx(IconSelectAll, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: runMenuAction(() => $selectAll()), children: strings.contextMenu.selectAll })] })] }), (config.images.linked || config.images.embedded) && (_jsx(ImageDialog, { mode: "insert", opened: imageDialogOpen, onSubmit: insertImage, onClose: closeImageDialog })), config.tables && _jsx(TableDialog, { opened: tableDialogOpen, onSubmit: insertTable, onClose: closeTableDialog }), config.columns && _jsx(LayoutDialog, { opened: layoutDialogOpen, onSubmit: insertLayout, onClose: closeLayoutDialog }), config.links && (_jsx(LinkDialog, { opened: linkDialogOpen, initialUrl: state.linkUrl, showTextField: linkNeedsText, onSubmit: applyLink, onRemove: state.isLink ? removeLink : undefined, onClose: closeLinkDialog })), drafts && _jsx(DraftsDialog, { opened: draftsOpen, locale: locale, onClose: () => setDraftsOpen(false), ...drafts })] }));
|
|
775
|
+
}, onRemove: removeLink, strings: strings }), _jsx(Menu.Divider, {})] })), contextMenu?.table && (_jsxs(_Fragment, { children: [_jsx(TableMenuItems, { strings: strings, direction: direction, rows: contextMenu.table.rows, columns: contextMenu.table.columns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction }), _jsx(Menu.Divider, {})] })), contextMenu?.poetry && (_jsxs(_Fragment, { children: [_jsx(PoetryMenuItems, { strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction }), _jsx(Menu.Divider, {})] })), _jsx(Menu.Item, { leftSection: _jsx(IconCut, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void copyOrCut(true)(), children: strings.contextMenu.cut }), _jsx(Menu.Item, { leftSection: _jsx(IconCopy, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void copyOrCut(false)(), children: strings.contextMenu.copy }), _jsx(Menu.Item, { leftSection: _jsx(IconClipboard, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: () => void paste(), children: strings.contextMenu.paste }), _jsx(Menu.Item, { leftSection: _jsx(IconSelectAll, { size: ICON_SIZE, stroke: ICON_STROKE }), onClick: runMenuAction(() => $selectAll()), children: strings.contextMenu.selectAll })] })] }), (config.images.linked || config.images.embedded) && (_jsx(ImageDialog, { mode: "insert", opened: imageDialogOpen, onSubmit: insertImage, onClose: closeImageDialog })), config.tables && _jsx(TableDialog, { opened: tableDialogOpen, onSubmit: insertTable, onClose: closeTableDialog }), config.columns && _jsx(LayoutDialog, { opened: layoutDialogOpen, onSubmit: insertLayout, onClose: closeLayoutDialog }), config.links && (_jsx(LinkDialog, { opened: linkDialogOpen, initialUrl: state.linkUrl, showTextField: linkNeedsText, onSubmit: applyLink, onRemove: state.isLink ? removeLink : undefined, onClose: closeLinkDialog })), drafts && _jsx(DraftsDialog, { opened: draftsOpen, locale: locale, onClose: () => setDraftsOpen(false), ...drafts })] }));
|
|
791
776
|
}
|
package/dist/i18n/strings.d.ts
CHANGED
|
@@ -56,8 +56,6 @@ export interface Strings {
|
|
|
56
56
|
autocorrect: string;
|
|
57
57
|
textCleanup: string;
|
|
58
58
|
spellChecker: string;
|
|
59
|
-
/** Joins the selected lines into one paragraph. */
|
|
60
|
-
joinLines: string;
|
|
61
59
|
moreFormatting: string;
|
|
62
60
|
strikethrough: string;
|
|
63
61
|
superscript: string;
|
|
@@ -197,7 +195,6 @@ export interface Strings {
|
|
|
197
195
|
};
|
|
198
196
|
contextMenu: {
|
|
199
197
|
cut: string;
|
|
200
|
-
joinLines: string;
|
|
201
198
|
copy: string;
|
|
202
199
|
paste: string;
|
|
203
200
|
selectAll: 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,MA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AAO,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;AAo0BD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAI3C,CAAC;AAEF;;sDAEsD;AACtD,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAElD"}
|
package/dist/i18n/strings.js
CHANGED
|
@@ -46,7 +46,6 @@ const en = {
|
|
|
46
46
|
autocorrect: 'Auto-correct',
|
|
47
47
|
textCleanup: 'Text cleanup',
|
|
48
48
|
spellChecker: 'Spell-checker',
|
|
49
|
-
joinLines: 'Join lines',
|
|
50
49
|
moreFormatting: 'More formatting',
|
|
51
50
|
strikethrough: 'Strikethrough',
|
|
52
51
|
superscript: 'Superscript',
|
|
@@ -179,7 +178,6 @@ const en = {
|
|
|
179
178
|
},
|
|
180
179
|
contextMenu: {
|
|
181
180
|
cut: 'Cut',
|
|
182
|
-
joinLines: 'Join lines',
|
|
183
181
|
copy: 'Copy',
|
|
184
182
|
paste: 'Paste',
|
|
185
183
|
selectAll: 'Select all',
|
|
@@ -324,7 +322,6 @@ const ur = {
|
|
|
324
322
|
autocorrect: 'خودکار تصحیح',
|
|
325
323
|
textCleanup: 'متن کی صفائی',
|
|
326
324
|
spellChecker: 'ہجے چیک کرنے والا',
|
|
327
|
-
joinLines: 'سطریں ملائیں',
|
|
328
325
|
moreFormatting: 'مزید فارمیٹنگ',
|
|
329
326
|
strikethrough: 'خط زدہ',
|
|
330
327
|
superscript: 'بالا نویس',
|
|
@@ -457,7 +454,6 @@ const ur = {
|
|
|
457
454
|
},
|
|
458
455
|
contextMenu: {
|
|
459
456
|
cut: 'کاٹیں',
|
|
460
|
-
joinLines: 'سطریں ملائیں',
|
|
461
457
|
copy: 'کاپی کریں',
|
|
462
458
|
paste: 'چسپاں کریں',
|
|
463
459
|
selectAll: 'سب منتخب کریں',
|
|
@@ -602,7 +598,6 @@ const paShahmukhi = {
|
|
|
602
598
|
autocorrect: 'خودکار درستی',
|
|
603
599
|
textCleanup: 'متن دی صفائی',
|
|
604
600
|
spellChecker: 'ہجے چیکر',
|
|
605
|
-
joinLines: 'سطراں ملاؤ',
|
|
606
601
|
moreFormatting: 'ہور فارمیٹنگ',
|
|
607
602
|
strikethrough: 'کٹی لکیر',
|
|
608
603
|
superscript: 'اُتلا لکھت',
|
|
@@ -735,7 +730,6 @@ const paShahmukhi = {
|
|
|
735
730
|
},
|
|
736
731
|
contextMenu: {
|
|
737
732
|
cut: 'کٹو',
|
|
738
|
-
joinLines: 'سطراں ملاؤ',
|
|
739
733
|
copy: 'کاپی کرو',
|
|
740
734
|
paste: 'چسپاں کرو',
|
|
741
735
|
selectAll: 'سارا چنو',
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export declare function $canJoinLines(): boolean;
|
|
2
|
-
/**
|
|
3
|
-
* Joins the lines in the selection into one paragraph. Soft breaks and the
|
|
4
|
-
* paragraph breaks between selected paragraphs become a single space each,
|
|
5
|
-
* unless there is already a space at that point. A soft break right after the
|
|
6
|
-
* selection becomes a paragraph break, so the joined text stands on its own.
|
|
7
|
-
*/
|
|
8
|
-
export declare function $joinSelectedLines(): boolean;
|
|
9
|
-
//# sourceMappingURL=joinLinesActions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"joinLinesActions.d.ts","sourceRoot":"","sources":["../../src/join/joinLinesActions.ts"],"names":[],"mappings":"AAyBA,wBAAgB,aAAa,IAAI,OAAO,CAKvC;AAuCD;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAyB5C"}
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { $createTextNode, $getSelection, $isLineBreakNode, $isParagraphNode, $isRangeSelection, $createParagraphNode, } from 'lexical';
|
|
2
|
-
function $paragraphsInSelection(selection) {
|
|
3
|
-
const seen = new Set();
|
|
4
|
-
const paragraphs = [];
|
|
5
|
-
for (const node of selection.getNodes()) {
|
|
6
|
-
const block = node.getTopLevelElement();
|
|
7
|
-
if (!block || !$isParagraphNode(block) || seen.has(block.getKey()))
|
|
8
|
-
continue;
|
|
9
|
-
seen.add(block.getKey());
|
|
10
|
-
paragraphs.push(block);
|
|
11
|
-
}
|
|
12
|
-
return paragraphs;
|
|
13
|
-
}
|
|
14
|
-
export function $canJoinLines() {
|
|
15
|
-
const selection = $getSelection();
|
|
16
|
-
if (!$isRangeSelection(selection) || selection.isCollapsed())
|
|
17
|
-
return false;
|
|
18
|
-
if ($paragraphsInSelection(selection).length > 1)
|
|
19
|
-
return true;
|
|
20
|
-
return selection.getNodes().some($isLineBreakNode);
|
|
21
|
-
}
|
|
22
|
-
/** A soft break becomes one space, unless the text either side already has a space there. */
|
|
23
|
-
function $replaceBreakWithSpace(lineBreak) {
|
|
24
|
-
const before = lineBreak.getPreviousSibling()?.getTextContent() ?? '';
|
|
25
|
-
const after = lineBreak.getNextSibling()?.getTextContent() ?? '';
|
|
26
|
-
if (before === '' || after === '' || /\s$/.test(before) || /^\s/.test(after)) {
|
|
27
|
-
lineBreak.remove();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
lineBreak.replace($createTextNode(' '));
|
|
31
|
-
}
|
|
32
|
-
/** Moves a paragraph's content onto the end of the target, with a space between when needed. */
|
|
33
|
-
function $appendParagraph(target, paragraph) {
|
|
34
|
-
const content = paragraph.getTextContent();
|
|
35
|
-
if (content !== '') {
|
|
36
|
-
const targetText = target.getTextContent();
|
|
37
|
-
if (targetText !== '' && !/\s$/.test(targetText) && !/^\s/.test(content)) {
|
|
38
|
-
target.append($createTextNode(' '));
|
|
39
|
-
}
|
|
40
|
-
for (const child of paragraph.getChildren())
|
|
41
|
-
target.append(child);
|
|
42
|
-
}
|
|
43
|
-
paragraph.remove();
|
|
44
|
-
}
|
|
45
|
-
/** Turns a soft break into a paragraph break: the content after it moves to a new paragraph. */
|
|
46
|
-
function $splitParagraphAt(lineBreak, paragraph) {
|
|
47
|
-
const rest = $createParagraphNode();
|
|
48
|
-
let sibling = lineBreak.getNextSibling();
|
|
49
|
-
while (sibling) {
|
|
50
|
-
const next = sibling.getNextSibling();
|
|
51
|
-
rest.append(sibling);
|
|
52
|
-
sibling = next;
|
|
53
|
-
}
|
|
54
|
-
lineBreak.remove();
|
|
55
|
-
paragraph.insertAfter(rest);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Joins the lines in the selection into one paragraph. Soft breaks and the
|
|
59
|
-
* paragraph breaks between selected paragraphs become a single space each,
|
|
60
|
-
* unless there is already a space at that point. A soft break right after the
|
|
61
|
-
* selection becomes a paragraph break, so the joined text stands on its own.
|
|
62
|
-
*/
|
|
63
|
-
export function $joinSelectedLines() {
|
|
64
|
-
const selection = $getSelection();
|
|
65
|
-
if (!$isRangeSelection(selection) || selection.isCollapsed())
|
|
66
|
-
return false;
|
|
67
|
-
const paragraphs = $paragraphsInSelection(selection);
|
|
68
|
-
const nodes = selection.getNodes();
|
|
69
|
-
const lineBreaks = nodes.filter($isLineBreakNode);
|
|
70
|
-
if (paragraphs.length < 2 && lineBreaks.length === 0)
|
|
71
|
-
return false;
|
|
72
|
-
const last = nodes[nodes.length - 1];
|
|
73
|
-
const breakAfter = last?.getNextSibling();
|
|
74
|
-
const trailingBreak = $isLineBreakNode(breakAfter) ? breakAfter : null;
|
|
75
|
-
for (const lineBreak of lineBreaks)
|
|
76
|
-
$replaceBreakWithSpace(lineBreak);
|
|
77
|
-
const [target, ...rest] = paragraphs;
|
|
78
|
-
if (!target)
|
|
79
|
-
return false;
|
|
80
|
-
for (const paragraph of rest)
|
|
81
|
-
$appendParagraph(target, paragraph);
|
|
82
|
-
if (trailingBreak?.isAttached()) {
|
|
83
|
-
const paragraph = trailingBreak.getParent();
|
|
84
|
-
if ($isParagraphNode(paragraph))
|
|
85
|
-
$splitParagraphAt(trailingBreak, paragraph);
|
|
86
|
-
}
|
|
87
|
-
target.selectEnd();
|
|
88
|
-
return true;
|
|
89
|
-
}
|