@inshapardaz/likhari-react 0.1.49 → 0.1.50
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.
|
@@ -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;
|
|
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;AA0sBvD,0FAA0F;AAC1F,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IAC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YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,wFAAwF;IACxF,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,oFAAoF;IACpF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,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,+BAksD3d"}
|
|
@@ -691,8 +691,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
691
691
|
word = atPoint;
|
|
692
692
|
}
|
|
693
693
|
if (!cell && !couplet && config.joinLines) {
|
|
694
|
-
menu.text =
|
|
695
|
-
menu.canJoin = $canJoinLines();
|
|
694
|
+
menu.text = $canJoinLines();
|
|
696
695
|
}
|
|
697
696
|
}, { discrete: true });
|
|
698
697
|
const language = spellCheckLanguage !== 'auto' ? spellCheckLanguage : word?.direction === 'rtl' ? 'ur' : 'en';
|
|
@@ -991,9 +990,8 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
991
990
|
void wordActionAtCaret((language, word) => onAddAutoCorrect(word, language));
|
|
992
991
|
};
|
|
993
992
|
// Keyboard shortcuts mirroring the right-click menu: Ctrl/Cmd+Alt+J joins the
|
|
994
|
-
// selected lines
|
|
995
|
-
//
|
|
996
|
-
// way the menu's Ignore / Add to dictionary / Add to auto-correct items do.
|
|
993
|
+
// selected lines, and Ctrl/Cmd+Alt+I/D/A act on the misspelled word at the caret
|
|
994
|
+
// the way the menu's Ignore / Add to dictionary / Add to auto-correct items do.
|
|
997
995
|
// Matched on event.code (the physical key), not event.key, so they still fire
|
|
998
996
|
// while typing in Urdu or another non-Latin layout, where event.key would be
|
|
999
997
|
// whatever character that layout produces rather than "j"/"i"/"d"/"a".
|
|
@@ -1033,7 +1031,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
1033
1031
|
});
|
|
1034
1032
|
// The tools group is always built, even when every command in it is off, so the ribbon asks first.
|
|
1035
1033
|
const hasToolsGroup = config.language.autocorrect || config.language.textCleanup || config.language.spellCheck || config.joinLines;
|
|
1036
|
-
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 })), config.joinLines && (_jsx(ToolbarButton, { icon: IconArrowsJoin, title: strings.toolbar.joinLines,
|
|
1034
|
+
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 })), config.joinLines && state.canJoinLines && (_jsx(ToolbarButton, { icon: IconArrowsJoin, title: strings.toolbar.joinLines, onClick: joinLines }))] }, "tools"));
|
|
1037
1035
|
// Uniform mode's zoom: [-] 100% [+], stepping through the preset levels; the
|
|
1038
1036
|
// percentage resets to 100%. Always laid out left-to-right, like a number.
|
|
1039
1037
|
const showZoom = uniform && config.font.size;
|
|
@@ -1162,7 +1160,7 @@ export function Toolbar({ config, toolbarStyle, dictionaryStores = [], thesaurus
|
|
|
1162
1160
|
}, children: synonym }, synonym)))] })] })), contextMenu?.link !== undefined && (_jsxs(Menu.Sub, { ...CONTEXT_SUBMENU_PROPS, children: [_jsx(Menu.Sub.Target, { children: _jsx(Menu.Sub.Item, { leftSection: _jsx(IconLink, { size: ICON_SIZE, stroke: ICON_STROKE }), children: strings.link.menuLabel }) }), _jsx(Menu.Sub.Dropdown, { children: _jsx(LinkMenuItems, { mode: "submenu", url: contextMenu.link, onEdit: () => {
|
|
1163
1161
|
restoreSelection();
|
|
1164
1162
|
openLinkDialog();
|
|
1165
|
-
}, onRemove: removeLink, strings: strings }) })] })), contextMenu?.table && (_jsx(TableMenuItems, { mode: "icons", strings: strings, direction: direction, rows: contextMenu.table.rows, columns: contextMenu.table.columns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction })), contextMenu?.poetry && (_jsx(PoetryMenuItems, { mode: "icons", strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction })), contextMenu?.text && (_jsx(Menu.Item, { leftSection: _jsx(IconArrowsJoin, { size: ICON_SIZE, stroke: ICON_STROKE }), rightSection: _jsx(ShortcutHint, { keys: "Ctrl+Alt+J" }), "aria-keyshortcuts": "Control+Alt+J",
|
|
1163
|
+
}, onRemove: removeLink, strings: strings }) })] })), contextMenu?.table && (_jsx(TableMenuItems, { mode: "icons", strings: strings, direction: direction, rows: contextMenu.table.rows, columns: contextMenu.table.columns, canMergeCells: state.canMergeCells, canUnmergeCell: state.canUnmergeCell, onAction: runMenuAction })), contextMenu?.poetry && (_jsx(PoetryMenuItems, { mode: "icons", strings: strings, layout: state.poetryLayout, scale: state.poetryScale, centered: state.poetryCentered, onAction: runMenuAction })), contextMenu?.text && (_jsx(Menu.Item, { leftSection: _jsx(IconArrowsJoin, { size: ICON_SIZE, stroke: ICON_STROKE }), rightSection: _jsx(ShortcutHint, { keys: "Ctrl+Alt+J" }), "aria-keyshortcuts": "Control+Alt+J", onClick: runMenuAction(() => {
|
|
1166
1164
|
$joinSelectedLines();
|
|
1167
1165
|
}), children: strings.contextMenu.joinLines })), ((contextMenu?.thesaurus && contextMenu.thesaurus.items?.length !== 0) ||
|
|
1168
1166
|
contextMenu?.link !== undefined ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joinLinesActions.d.ts","sourceRoot":"","sources":["../../src/join/joinLinesActions.ts"],"names":[],"mappings":"AAqCA,wBAAgB,aAAa,IAAI,OAAO,CAKvC;
|
|
1
|
+
{"version":3,"file":"joinLinesActions.d.ts","sourceRoot":"","sources":["../../src/join/joinLinesActions.ts"],"names":[],"mappings":"AAqCA,wBAAgB,aAAa,IAAI,OAAO,CAKvC;AAgFD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,IAAI,OAAO,CAgC5C"}
|
|
@@ -28,11 +28,10 @@ export function $canJoinLines() {
|
|
|
28
28
|
return selection.getNodes().some($isLineBreakNode) || $textNodesWithNewlines(selection).length > 0;
|
|
29
29
|
}
|
|
30
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,
|
|
32
|
-
const [start, end] = selection.getStartEndPoints() ?? [];
|
|
31
|
+
function $replaceNewlinesInText(node, start, end) {
|
|
33
32
|
const text = node.getTextContent();
|
|
34
|
-
const from = start
|
|
35
|
-
const to = end
|
|
33
|
+
const from = start.key === node.getKey() ? start.offset : 0;
|
|
34
|
+
const to = end.key === node.getKey() ? end.offset : text.length;
|
|
36
35
|
const joined = text.slice(from, to).replace(/[ \t]*\r?\n[ \t]*/g, ' ');
|
|
37
36
|
node.setTextContent(text.slice(0, from) + joined + text.slice(to));
|
|
38
37
|
}
|
|
@@ -126,27 +125,26 @@ export function $joinSelectedLines() {
|
|
|
126
125
|
const textsWithNewlines = $textNodesWithNewlines(selection);
|
|
127
126
|
if (paragraphs.length < 2 && lineBreaks.length === 0 && textsWithNewlines.length === 0)
|
|
128
127
|
return false;
|
|
129
|
-
|
|
128
|
+
// RangeSelection's anchor/focus track drag direction, not document order (and
|
|
129
|
+
// getStartEndPoints() returns them as-is, anchor first) — reorder them so "start"/"end"
|
|
130
|
+
// below always mean "earlier"/"later" in the document, regardless of which way the user
|
|
131
|
+
// dragged, or Shift+arrow'd, the selection. Getting this wrong silently skips the tail
|
|
132
|
+
// split below (sweeping unselected content into the join) for any backward selection.
|
|
133
|
+
const [start, end] = selection.isBackward() ? [selection.focus, selection.anchor] : [selection.anchor, selection.focus];
|
|
130
134
|
for (const lineBreak of lineBreaks)
|
|
131
135
|
$replaceBreakWithSpace(lineBreak);
|
|
132
136
|
for (const textNode of textsWithNewlines)
|
|
133
|
-
$replaceNewlinesInText(textNode,
|
|
137
|
+
$replaceNewlinesInText(textNode, start, end);
|
|
134
138
|
const [target, ...rest] = paragraphs;
|
|
135
139
|
if (!target)
|
|
136
140
|
return false;
|
|
137
141
|
const lastParagraph = paragraphs[paragraphs.length - 1];
|
|
138
|
-
|
|
139
|
-
$splitUnselectedTail(lastParagraph, end);
|
|
142
|
+
$splitUnselectedTail(lastParagraph, end);
|
|
140
143
|
for (const paragraph of rest)
|
|
141
144
|
$appendParagraph(target, paragraph);
|
|
142
145
|
// Keep the caret where the selection began, rather than at the end of everything
|
|
143
146
|
// just joined — useful on its own, and essential when many lines were joined at
|
|
144
147
|
// once, where "the end" could otherwise land far past where the user was working.
|
|
145
|
-
|
|
146
|
-
start.getNode().select(start.offset, start.offset);
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
target.selectEnd();
|
|
150
|
-
}
|
|
148
|
+
start.getNode().select(start.offset, start.offset);
|
|
151
149
|
return true;
|
|
152
150
|
}
|