@rowsncolumns/ui 16.1.0 → 16.1.2
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/cjs/dialog/index.d.ts.map +1 -1
- package/dist/cjs/dialog/index.js +4 -1
- package/dist/cjs/editor-pm/helpers.d.ts +8 -1
- package/dist/cjs/editor-pm/helpers.d.ts.map +1 -1
- package/dist/cjs/editor-pm/helpers.js +17 -0
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts +39 -0
- package/dist/cjs/editor-pm/prosemirror-editor.d.ts.map +1 -1
- package/dist/cjs/editor-pm/prosemirror-editor.js +77 -4
- package/dist/cjs/editor-pm/use-editor-keydown-pm.d.ts +13 -1
- package/dist/cjs/editor-pm/use-editor-keydown-pm.d.ts.map +1 -1
- package/dist/cjs/editor-pm/use-editor-keydown-pm.js +38 -2
- package/dist/esm/dialog/index.d.ts.map +1 -1
- package/dist/esm/dialog/index.js +4 -1
- package/dist/esm/editor-pm/helpers.d.ts +8 -1
- package/dist/esm/editor-pm/helpers.d.ts.map +1 -1
- package/dist/esm/editor-pm/helpers.js +17 -0
- package/dist/esm/editor-pm/prosemirror-editor.d.ts +39 -0
- package/dist/esm/editor-pm/prosemirror-editor.d.ts.map +1 -1
- package/dist/esm/editor-pm/prosemirror-editor.js +76 -4
- package/dist/esm/editor-pm/use-editor-keydown-pm.d.ts +13 -1
- package/dist/esm/editor-pm/use-editor-keydown-pm.d.ts.map +1 -1
- package/dist/esm/editor-pm/use-editor-keydown-pm.js +38 -2
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,eAAO,MAAM,YAAY;mDAKtB,eAAe,CAAC,iBAAiB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;CAc5D,CAAC;AAGF,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAGH,eAAO,MAAM,iBAAiB,8KAY5B,CAAC;AAkBH,eAAO,MAAM,aAAa;sBAGJ,MAAM;gBACZ,WAAW,GAAG,IAAI;wCA8ChC,CAAC;AAGH,eAAO,MAAM,MAAM,uCAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,8GAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,4GAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,eAAO,MAAM,YAAY;mDAKtB,eAAe,CAAC,iBAAiB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;CAc5D,CAAC;AAGF,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAGH,eAAO,MAAM,iBAAiB,8KAY5B,CAAC;AAkBH,eAAO,MAAM,aAAa;sBAGJ,MAAM;gBACZ,WAAW,GAAG,IAAI;wCA8ChC,CAAC;AAGH,eAAO,MAAM,MAAM,uCAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,8GAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,4GAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,4KAY5B,CAAC;AAGH,eAAO,MAAM,UAAU,GAAI,0BAGxB;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,sBAEA,CAAC"}
|
package/dist/cjs/dialog/index.js
CHANGED
|
@@ -85,7 +85,10 @@ export var DialogTrigger = DialogPrimitive.Trigger;
|
|
|
85
85
|
export var DialogClose = DialogPrimitive.Close;
|
|
86
86
|
export var DialogCloseButton = React.forwardRef(function (_a, ref) {
|
|
87
87
|
var className = _a.className, props = __rest(_a, ["className"]);
|
|
88
|
-
return (
|
|
88
|
+
return (
|
|
89
|
+
// Icon-only: without a name a screen reader announces just "button" (axe `button-name`). A
|
|
90
|
+
// caller's own `aria-label` still wins.
|
|
91
|
+
React.createElement(IconButton, __assign({ ref: ref, "aria-label": "Close", className: cn("absolute top-2 right-2", className) }, props)));
|
|
89
92
|
});
|
|
90
93
|
DialogCloseButton.displayName = "DialogCloseButton";
|
|
91
94
|
export var DialogBody = function (_a) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ParsedToken } from "@rowsncolumns/calculator";
|
|
2
2
|
import { Node, Schema } from "prosemirror-model";
|
|
3
|
-
import { EditorState } from "prosemirror-state";
|
|
3
|
+
import { EditorState, type Transaction } from "prosemirror-state";
|
|
4
4
|
import { EditorView } from "prosemirror-view";
|
|
5
5
|
import { TextFormatRun } from "./types";
|
|
6
6
|
export type LeafDecorator = {
|
|
@@ -210,5 +210,12 @@ export declare const getTokenizationContent: (state: EditorState, cursorPos: num
|
|
|
210
210
|
* @param text
|
|
211
211
|
*/
|
|
212
212
|
export declare const cleanFunctionToken: (text: string) => string;
|
|
213
|
+
/**
|
|
214
|
+
* Overtype (Excel's Insert key while editing): typed text replaces as many
|
|
215
|
+
* characters after the caret as it holds, within the caret's line, instead of
|
|
216
|
+
* pushing them along. A selection, the end of a line or an empty insert leave
|
|
217
|
+
* the ordinary insert to ProseMirror (`null`).
|
|
218
|
+
*/
|
|
219
|
+
export declare const overtypeTransaction: (state: EditorState, from: number, to: number, text: string) => Transaction | null;
|
|
213
220
|
export {};
|
|
214
221
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../editor-pm/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,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AC5B,UAAU,WAAW,GAAG,SAAS,EACjC,eAAe,WAAW,GAAG,SAAS,EACtC,QAAQ,WAAW,EAAE,WAwCtB,CAAC;AAEF,eAAO,MAAM,qBAAqB,GAChC,OAAO,MAAM,EACb,eAAe,WAAW,GAAG,SAAS;AACtC,wFAAwF;AACxF,0BAAuB,KACtB;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAyFlE,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,WAAW,EAClB,WAAW,MAAM;;;CA6ElB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,MAAM,MAAM,WAE9C,CAAC;AA0CF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,WAAW,EAClB,MAAM,MAAM,EACZ,IAAI,MAAM,EACV,MAAM,MAAM,KACX,WAAW,GAAG,IAOhB,CAAC"}
|
|
@@ -1202,3 +1202,20 @@ function getWordAtPosition(editorState, pos) {
|
|
|
1202
1202
|
text: wordText,
|
|
1203
1203
|
};
|
|
1204
1204
|
}
|
|
1205
|
+
/**
|
|
1206
|
+
* Overtype (Excel's Insert key while editing): typed text replaces as many
|
|
1207
|
+
* characters after the caret as it holds, within the caret's line, instead of
|
|
1208
|
+
* pushing them along. A selection, the end of a line or an empty insert leave
|
|
1209
|
+
* the ordinary insert to ProseMirror (`null`).
|
|
1210
|
+
*/
|
|
1211
|
+
export var overtypeTransaction = function (state, from, to, text) {
|
|
1212
|
+
if (from !== to || !text)
|
|
1213
|
+
return null;
|
|
1214
|
+
var $from = state.doc.resolve(from);
|
|
1215
|
+
if (!$from.parent.isTextblock)
|
|
1216
|
+
return null;
|
|
1217
|
+
var overwriteTo = Math.min(from + text.length, $from.end());
|
|
1218
|
+
if (overwriteTo <= from)
|
|
1219
|
+
return null;
|
|
1220
|
+
return state.tr.insertText(text, from, overwriteTo);
|
|
1221
|
+
};
|
|
@@ -53,6 +53,11 @@ export type ProseMirrorEditorProps<M extends Mention = Mention> = RichTextEditor
|
|
|
53
53
|
* in the same locale. Canonical syntax when omitted.
|
|
54
54
|
*/
|
|
55
55
|
formulaLocale?: FormulaLocale;
|
|
56
|
+
/**
|
|
57
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
58
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
59
|
+
*/
|
|
60
|
+
locale?: string;
|
|
56
61
|
showDropdown?: boolean;
|
|
57
62
|
dropdownStyles?: React.CSSProperties;
|
|
58
63
|
stickyEditor?: boolean;
|
|
@@ -175,6 +180,14 @@ export type ProseMirrorEditorProps<M extends Mention = Mention> = RichTextEditor
|
|
|
175
180
|
* instead of inheriting whatever the paste sandbox sees.
|
|
176
181
|
*/
|
|
177
182
|
cellFontFamily?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
185
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
186
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
187
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
188
|
+
* replaces it. Ignored in formula mode.
|
|
189
|
+
*/
|
|
190
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
178
191
|
};
|
|
179
192
|
type SelectionMode = "clear" | "modify" | "append";
|
|
180
193
|
export type TextEditorRef = {
|
|
@@ -249,6 +262,11 @@ export declare const ProseMirrorEditorThatMayError: React.NamedExoticComponent<R
|
|
|
249
262
|
* in the same locale. Canonical syntax when omitted.
|
|
250
263
|
*/
|
|
251
264
|
formulaLocale?: FormulaLocale;
|
|
265
|
+
/**
|
|
266
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
267
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
268
|
+
*/
|
|
269
|
+
locale?: string;
|
|
252
270
|
showDropdown?: boolean;
|
|
253
271
|
dropdownStyles?: React.CSSProperties;
|
|
254
272
|
stickyEditor?: boolean;
|
|
@@ -366,6 +384,14 @@ export declare const ProseMirrorEditorThatMayError: React.NamedExoticComponent<R
|
|
|
366
384
|
* instead of inheriting whatever the paste sandbox sees.
|
|
367
385
|
*/
|
|
368
386
|
cellFontFamily?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
389
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
390
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
391
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
392
|
+
* replaces it. Ignored in formula mode.
|
|
393
|
+
*/
|
|
394
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
369
395
|
} & ProseMirrorEditorRef>;
|
|
370
396
|
export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<RichTextEditorAttribues & {
|
|
371
397
|
value: string;
|
|
@@ -397,6 +423,11 @@ export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<Ric
|
|
|
397
423
|
* in the same locale. Canonical syntax when omitted.
|
|
398
424
|
*/
|
|
399
425
|
formulaLocale?: FormulaLocale;
|
|
426
|
+
/**
|
|
427
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
428
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
429
|
+
*/
|
|
430
|
+
locale?: string;
|
|
400
431
|
showDropdown?: boolean;
|
|
401
432
|
dropdownStyles?: React.CSSProperties;
|
|
402
433
|
stickyEditor?: boolean;
|
|
@@ -514,5 +545,13 @@ export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<Ric
|
|
|
514
545
|
* instead of inheriting whatever the paste sandbox sees.
|
|
515
546
|
*/
|
|
516
547
|
cellFontFamily?: string;
|
|
548
|
+
/**
|
|
549
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
550
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
551
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
552
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
553
|
+
* replaces it. Ignored in formula mode.
|
|
554
|
+
*/
|
|
555
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
517
556
|
} & ProseMirrorEditorRef, "ref"> & React.RefAttributes<any>>;
|
|
518
557
|
//# sourceMappingURL=prosemirror-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAK9E,OAAO,EAGL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAK9E,OAAO,EAGL,KAAK,aAAa,EAGnB,MAAM,qBAAqB,CAAC;AAY7B,OAAO,KAAK,EAAE,OAAO,EAAC,MAAM,mBAAmB,CAAC;AAIhD,OAAO,KAQN,MAAM,OAAO,CAAC;AAOf,OAAO,KAAK,EACV,wBAAwB,EAAC,MAAM,gCAAgC,CAAC;AAUlE,OAAO,EAQL,KAAK,gBAAgB,EAEtB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAA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AEG;2BACoB,kBAAkB,EAAE,GAAG,IAAI;IAClD;;OAEG;sCAC+B,CAChC,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,MAAM,EACtB,UAAU,EAAE,MAAM,EAAE,KAElB,UAAU,EAAE,GACZ,SAAS,GACT,OAAO,CAAC,UAAU,EAAE,GAAG,SAAS,CAAC,GACjC,OAAO,CAAC,UAAU,EAAE,CAAC;IACzB;;OAEG;sBACe,UAAU,EAAE,GAAG,SAAS;IAC1C;;;OAGG;oCAEU,MAAM,GAAG,SAAS,GAC5B,UAAU,EAAE,GAAG,SAAS;IAC3B;;;;;OAKG;wCAEU,MAAM,GAAG,SAAS,YACnB,MAAM,eACH,MAAM,GAClB,UAAU,EAAE,GAAG,SAAS;IAC3B;;;OAGG;wBACiB,OAAO;IAC3B;;OAEG;0BACmB,KAAK,CAAC,WAAW,CAAC,wBAAwB,CAAC;IACjE;;;OAGG;wBAEM,MAAM,GAAG,SAAS,GAAG,IAAI,GAC/B,OAAO,CAAC,OAAO,EAAE,GAAG,SAAS,GAAG,IAAI,CAAC;IACxC;;OAEG;iDAEa,MAAM,kBACJ,MAAM,cACV,MAAM,EAAE,GACnB,OAAO;IACV;;OAEG;;IAEH;;OAEG;;;;IAEH;;;OAGG;qBACc,OAAO;IACxB;;;OAGG;gCACyB,OAAO;IACnC;;;;OAIG;qBACc,MAAM;IACvB;;;;;;OAMG;4BACqB,MAAM,GAAG,MAAM,GAAG,SAAS;4DA2tDtD,CAAC"}
|
|
@@ -5,7 +5,7 @@ import { tokenVocabulary } from "@rowsncolumns/fast-formula-parser";
|
|
|
5
5
|
import { useCallbackRef } from "@rowsncolumns/grid";
|
|
6
6
|
import { LoadingIcon, QuestionMarkIcon } from "@rowsncolumns/icons";
|
|
7
7
|
import { DEFAULT_ARRAY } from "@rowsncolumns/spreadsheet";
|
|
8
|
-
import { canonicalizeFunctionName, clipboardHtmlToRichText, } from "@rowsncolumns/utils";
|
|
8
|
+
import { canonicalizeFunctionName, clipboardHtmlToRichText, formatInsertedDateTime, } from "@rowsncolumns/utils";
|
|
9
9
|
import { addressToCell, getHotkeyKey, isAFormula, isNil, log, } from "@rowsncolumns/utils";
|
|
10
10
|
import { baseKeymap, joinBackward, toggleMark } from "prosemirror-commands";
|
|
11
11
|
import { history, redo, undo } from "prosemirror-history";
|
|
@@ -27,7 +27,7 @@ import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect
|
|
|
27
27
|
import { usePortalContainer } from "../portal-container";
|
|
28
28
|
import { cn } from "../utils";
|
|
29
29
|
import { createDecorationPlugin } from "./decoration-plugin";
|
|
30
|
-
import { applyTextFormatRuns, applyTextFormatToSelection, deserializeString, getPropertyStartIndex, getSelectionFontSize, isCellToken, serializeEditorValue, } from "./helpers";
|
|
30
|
+
import { applyTextFormatRuns, applyTextFormatToSelection, deserializeString, getPropertyStartIndex, getSelectionFontSize, isCellToken, overtypeTransaction, serializeEditorValue, } from "./helpers";
|
|
31
31
|
import { MentionNodeView } from "./mention-nodeview";
|
|
32
32
|
import { MentionsDropdown } from "./mentions-dropdown";
|
|
33
33
|
import { createMentionsPlugin } from "./mentions-plugin";
|
|
@@ -65,13 +65,14 @@ export var deleteAll = function (state, dispatch) {
|
|
|
65
65
|
*/
|
|
66
66
|
export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forwardedRef) {
|
|
67
67
|
var _b;
|
|
68
|
-
var _c = _a.value, value = _c === void 0 ? "" : _c, isNewValue = _a.isNewValue, formulaMode = _a.formulaMode, onChange = _a.onChange, autoFocus = _a.autoFocus, className = _a.className, onKeyDown = _a.onKeyDown, disabled = _a.disabled, _d = _a.showDropdown, showDropdown = _d === void 0 ? true : _d, _e = _a.persistFocus, persistFocus = _e === void 0 ? true : _e, editorZeroOutline = _a.editorZeroOutline, showFormulaHelp = _a.showFormulaHelp, onHideFormulaHelp = _a.onHideFormulaHelp, onShowFormulaHelp = _a.onShowFormulaHelp, tokenizer = _a.tokenizer, onCancel = _a.onCancel, onSubmit = _a.onSubmit, onFormulaStateChange = _a.onFormulaStateChange, dropdownStyles = _a.dropdownStyles, options = _a.options, isOptionSelected = _a.isOptionSelected, functionDescriptions = _a.functionDescriptions, shouldFetchFunctionParametersProp = _a.shouldFetchFunctionParameters, getFunctionParameterSuggestionsProp = _a.getFunctionParameterSuggestions, formulaLocale = _a.formulaLocale, getMentions = _a.getMentions, getNamedRanges = _a.getNamedRanges, getTableNames = _a.getTableNames, getTableColumnNames = _a.getTableColumnNames, getStructuredProperties = _a.getStructuredProperties, onTeardown = _a.onTeardown, _f = _a.SuggestionsDropdown, SuggestionsDropdown = _f === void 0 ? DefaultSuggestionsDropdown : _f, MentionTagComponent = _a.MentionTagComponent, MentionDropdownItemComponent = _a.MentionDropdownItemComponent, isActive = _a.isActive, _g = _a.stickyEditor, stickyEditor = _g === void 0 ? true : _g, onFocus = _a.onFocus, onBlur = _a.onBlur, onCopy = _a.onCopy, onCut = _a.onCut, onPaste = _a.onPaste, placeholder = _a.placeholder, textFormatRuns = _a.textFormatRuns, resolveRunColor = _a.resolveRunColor, navigationMode = _a.navigationMode, enableContinuousSelection = _a.enableContinuousSelection, cellFontFamily = _a.cellFontFamily, props = __rest(_a, ["value", "isNewValue", "formulaMode", "onChange", "autoFocus", "className", "onKeyDown", "disabled", "showDropdown", "persistFocus", "editorZeroOutline", "showFormulaHelp", "onHideFormulaHelp", "onShowFormulaHelp", "tokenizer", "onCancel", "onSubmit", "onFormulaStateChange", "dropdownStyles", "options", "isOptionSelected", "functionDescriptions", "shouldFetchFunctionParameters", "getFunctionParameterSuggestions", "formulaLocale", "getMentions", "getNamedRanges", "getTableNames", "getTableColumnNames", "getStructuredProperties", "onTeardown", "SuggestionsDropdown", "MentionTagComponent", "MentionDropdownItemComponent", "isActive", "stickyEditor", "onFocus", "onBlur", "onCopy", "onCut", "onPaste", "placeholder", "textFormatRuns", "resolveRunColor", "navigationMode", "enableContinuousSelection", "cellFontFamily"]);
|
|
68
|
+
var _c = _a.value, value = _c === void 0 ? "" : _c, isNewValue = _a.isNewValue, formulaMode = _a.formulaMode, onChange = _a.onChange, autoFocus = _a.autoFocus, className = _a.className, onKeyDown = _a.onKeyDown, disabled = _a.disabled, _d = _a.showDropdown, showDropdown = _d === void 0 ? true : _d, _e = _a.persistFocus, persistFocus = _e === void 0 ? true : _e, editorZeroOutline = _a.editorZeroOutline, showFormulaHelp = _a.showFormulaHelp, onHideFormulaHelp = _a.onHideFormulaHelp, onShowFormulaHelp = _a.onShowFormulaHelp, tokenizer = _a.tokenizer, onCancel = _a.onCancel, onSubmit = _a.onSubmit, onFormulaStateChange = _a.onFormulaStateChange, dropdownStyles = _a.dropdownStyles, options = _a.options, isOptionSelected = _a.isOptionSelected, functionDescriptions = _a.functionDescriptions, shouldFetchFunctionParametersProp = _a.shouldFetchFunctionParameters, getFunctionParameterSuggestionsProp = _a.getFunctionParameterSuggestions, formulaLocale = _a.formulaLocale, locale = _a.locale, getMentions = _a.getMentions, getNamedRanges = _a.getNamedRanges, getTableNames = _a.getTableNames, getTableColumnNames = _a.getTableColumnNames, getStructuredProperties = _a.getStructuredProperties, onTeardown = _a.onTeardown, _f = _a.SuggestionsDropdown, SuggestionsDropdown = _f === void 0 ? DefaultSuggestionsDropdown : _f, MentionTagComponent = _a.MentionTagComponent, MentionDropdownItemComponent = _a.MentionDropdownItemComponent, isActive = _a.isActive, _g = _a.stickyEditor, stickyEditor = _g === void 0 ? true : _g, onFocus = _a.onFocus, onBlur = _a.onBlur, onCopy = _a.onCopy, onCut = _a.onCut, onPaste = _a.onPaste, placeholder = _a.placeholder, textFormatRuns = _a.textFormatRuns, resolveRunColor = _a.resolveRunColor, navigationMode = _a.navigationMode, enableContinuousSelection = _a.enableContinuousSelection, cellFontFamily = _a.cellFontFamily, getAutoComplete = _a.getAutoComplete, props = __rest(_a, ["value", "isNewValue", "formulaMode", "onChange", "autoFocus", "className", "onKeyDown", "disabled", "showDropdown", "persistFocus", "editorZeroOutline", "showFormulaHelp", "onHideFormulaHelp", "onShowFormulaHelp", "tokenizer", "onCancel", "onSubmit", "onFormulaStateChange", "dropdownStyles", "options", "isOptionSelected", "functionDescriptions", "shouldFetchFunctionParameters", "getFunctionParameterSuggestions", "formulaLocale", "locale", "getMentions", "getNamedRanges", "getTableNames", "getTableColumnNames", "getStructuredProperties", "onTeardown", "SuggestionsDropdown", "MentionTagComponent", "MentionDropdownItemComponent", "isActive", "stickyEditor", "onFocus", "onBlur", "onCopy", "onCut", "onPaste", "placeholder", "textFormatRuns", "resolveRunColor", "navigationMode", "enableContinuousSelection", "cellFontFamily", "getAutoComplete"]);
|
|
69
69
|
var editorRef = useRef(null);
|
|
70
70
|
var viewRef = useRef(null);
|
|
71
71
|
var portalContainer = usePortalContainer();
|
|
72
72
|
/** The `history()` plugin instance the view was created with — see `resetUndoHistory`. */
|
|
73
73
|
var historyPluginRef = useRef(null);
|
|
74
74
|
var cellFontFamilyRef = useRef(cellFontFamily);
|
|
75
|
+
var getAutoCompleteRef = useRef(getAutoComplete);
|
|
75
76
|
// The function token is in the editor's locale (`СУММ(`); hosts are asked about the canonical
|
|
76
77
|
// name (`SUM(`) so parameter providers keyed on English names work in every locale.
|
|
77
78
|
var canonicalFunctionImage = useCallback(function (image) {
|
|
@@ -169,10 +170,31 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
169
170
|
useIsomorphicLayoutEffect(function () {
|
|
170
171
|
cellFontFamilyRef.current = cellFontFamily;
|
|
171
172
|
}, [cellFontFamily]);
|
|
173
|
+
// Overtype (Insert), for the edit under way: every edit starts in insert mode, as in Excel.
|
|
174
|
+
var overtypeRef = useRef(false);
|
|
175
|
+
var setOvertype = useCallback(function (on) {
|
|
176
|
+
var _a;
|
|
177
|
+
overtypeRef.current = on;
|
|
178
|
+
var dom = (_a = viewRef.current) === null || _a === void 0 ? void 0 : _a.dom;
|
|
179
|
+
if (!dom)
|
|
180
|
+
return;
|
|
181
|
+
if (on) {
|
|
182
|
+
dom.setAttribute("data-overtype", "true");
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
dom.removeAttribute("data-overtype");
|
|
186
|
+
}
|
|
187
|
+
}, []);
|
|
188
|
+
useIsomorphicLayoutEffect(function () {
|
|
189
|
+
getAutoCompleteRef.current = getAutoComplete;
|
|
190
|
+
}, [getAutoComplete]);
|
|
172
191
|
useIsomorphicLayoutEffect(function () {
|
|
173
192
|
var _a;
|
|
174
193
|
var previousMode = navigationModeRef.current;
|
|
175
194
|
navigationModeRef.current = navigationMode;
|
|
195
|
+
if (navigationMode && overtypeRef.current) {
|
|
196
|
+
setOvertype(false);
|
|
197
|
+
}
|
|
176
198
|
// Reset formula-related states when entering navigation mode (and mode has changed)
|
|
177
199
|
if (navigationMode && previousMode !== navigationMode) {
|
|
178
200
|
setCursorPosition(undefined);
|
|
@@ -527,6 +549,40 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
527
549
|
tabindex: "0",
|
|
528
550
|
},
|
|
529
551
|
editable: function () { return !disabled; },
|
|
552
|
+
// Overtype (Insert): a typed character replaces the one after the caret.
|
|
553
|
+
// Otherwise AutoComplete for cell values: type the character, then write
|
|
554
|
+
// the rest of the one matching entry after the caret, selected.
|
|
555
|
+
handleTextInput: function (view, from, to, text) {
|
|
556
|
+
if (overtypeRef.current && !view.composing) {
|
|
557
|
+
var overtype = overtypeTransaction(view.state, from, to, text);
|
|
558
|
+
if (overtype) {
|
|
559
|
+
view.dispatch(overtype.scrollIntoView());
|
|
560
|
+
return true;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
var complete = getAutoCompleteRef.current;
|
|
564
|
+
if (!complete || formulaModeRef.current)
|
|
565
|
+
return false;
|
|
566
|
+
var doc = view.state.doc;
|
|
567
|
+
if (doc.childCount !== 1 || to !== doc.content.size - 1) {
|
|
568
|
+
return false;
|
|
569
|
+
}
|
|
570
|
+
var tr = view.state.tr.insertText(text, from, to);
|
|
571
|
+
var typed = serializeEditorValue(tr.doc);
|
|
572
|
+
if (isAFormula(typed))
|
|
573
|
+
return false;
|
|
574
|
+
var entry = complete(typed);
|
|
575
|
+
if (!entry ||
|
|
576
|
+
entry.length <= typed.length ||
|
|
577
|
+
!entry.toLowerCase().startsWith(typed.toLowerCase())) {
|
|
578
|
+
return false;
|
|
579
|
+
}
|
|
580
|
+
var caret = tr.selection.to;
|
|
581
|
+
tr.insertText(entry.slice(typed.length), caret);
|
|
582
|
+
tr.setSelection(TextSelection.create(tr.doc, caret, tr.doc.content.size - 1));
|
|
583
|
+
view.dispatch(tr.scrollIntoView());
|
|
584
|
+
return true;
|
|
585
|
+
},
|
|
530
586
|
// Rich text from Google Sheets / Excel: convert the clipboard's
|
|
531
587
|
// `text/html` with the shared converter and insert it as marks —
|
|
532
588
|
// the same runs the grid paste commits, so the formula bar, the
|
|
@@ -564,6 +620,10 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
564
620
|
},
|
|
565
621
|
blur: function (_, event) {
|
|
566
622
|
var _a;
|
|
623
|
+
// Leaving the editor ends overtype, as leaving an entry does in Excel (the formula
|
|
624
|
+
// bar's editor outlives its edits and never goes into navigation mode).
|
|
625
|
+
if (overtypeRef.current)
|
|
626
|
+
setOvertype(false);
|
|
567
627
|
(_a = onBlurRef.current) === null || _a === void 0 ? void 0 : _a.call(onBlurRef, event);
|
|
568
628
|
return false; // Let ProseMirror handle the blur as well
|
|
569
629
|
},
|
|
@@ -1057,6 +1117,15 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
1057
1117
|
}
|
|
1058
1118
|
}
|
|
1059
1119
|
}, []);
|
|
1120
|
+
// Ctrl+; / Ctrl+Shift+;: the date or the time at the caret, replacing a selection; the edit stays open.
|
|
1121
|
+
var handleInsertDateTime = useCallback(function (kind) {
|
|
1122
|
+
var view = viewRef.current;
|
|
1123
|
+
if (!view)
|
|
1124
|
+
return;
|
|
1125
|
+
var text = formatInsertedDateTime({ kind: kind, locale: locale });
|
|
1126
|
+
view.dispatch(view.state.tr.insertText(text).scrollIntoView());
|
|
1127
|
+
}, [locale]);
|
|
1128
|
+
var handleToggleOvertype = useCallback(function () { return setOvertype(!overtypeRef.current); }, [setOvertype]);
|
|
1060
1129
|
var canSubmitInDropdown = function () {
|
|
1061
1130
|
var token = suggestionTokenRef.current;
|
|
1062
1131
|
var item = items[highlightedIndex];
|
|
@@ -1082,6 +1151,10 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
1082
1151
|
onCancel: !navigationMode ? onCancel : undefined,
|
|
1083
1152
|
onSubmit: !navigationMode ? onSubmit : undefined,
|
|
1084
1153
|
onInsertBreak: handleInsertBreak,
|
|
1154
|
+
// The sticky editor buffers keys while the grid navigates: there the grid owns Ctrl+; (it
|
|
1155
|
+
// inserts the date into the cell) and Insert does nothing.
|
|
1156
|
+
onInsertDateTime: !navigationMode && !disabled ? handleInsertDateTime : undefined,
|
|
1157
|
+
onToggleOvertype: !navigationMode && !disabled ? handleToggleOvertype : undefined,
|
|
1085
1158
|
onKeyDown: handleKeyDown,
|
|
1086
1159
|
canSubmit: canSubmit,
|
|
1087
1160
|
canCancel: !isOpen && !showMentionDropdownEffective,
|
|
@@ -1286,7 +1359,7 @@ export var ProseMirrorEditorThatMayError = memo(forwardRef(function (_a, forward
|
|
|
1286
1359
|
React.createElement("div", { className: "h-full overflow-auto [&_div]:outline-none" },
|
|
1287
1360
|
React.createElement("div", __assign({ ref: editorRef, className: cn(className, "whitespace-pre-wrap"), onKeyDownCapture: handleKeyDownCapture, onKeyDown: onKeyDownEditor }, props))),
|
|
1288
1361
|
React.createElement(Popper.Anchor, { asChild: true },
|
|
1289
|
-
React.createElement("button", { tabIndex: -1, className: cn("absolute left-0 top-0 w-0 h-full overflow-hidden m-0 p-0 border-none bg-transparent shadow-none"), style: {
|
|
1362
|
+
React.createElement("button", { type: "button", "aria-hidden": "true", tabIndex: -1, className: cn("absolute left-0 top-0 w-0 h-full overflow-hidden m-0 p-0 border-none bg-transparent shadow-none"), style: {
|
|
1290
1363
|
left: showMentionDropdownEffective ? mentionPositionLeft : 0,
|
|
1291
1364
|
} })),
|
|
1292
1365
|
showDropdownEffective && isDropdownOpen && (React.createElement(ConditionalWrapper, { condition: stickyEditor, wrapper: function (children) { return (React.createElement(Portal, { asChild: true, container: portalContainer }, children)); } },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type InsertedDateTimeKind } from "@rowsncolumns/utils";
|
|
1
2
|
import { EditorView } from "prosemirror-view";
|
|
2
3
|
import { TextFormatRun } from "./types.js";
|
|
3
4
|
type UseEditorKeyDownPMProps = {
|
|
@@ -6,6 +7,10 @@ type UseEditorKeyDownPMProps = {
|
|
|
6
7
|
isNewValue?: boolean;
|
|
7
8
|
isCursorAtEnd(): boolean;
|
|
8
9
|
onInsertBreak(): void;
|
|
10
|
+
/** Ctrl+; and Ctrl+Shift+;: today's date or the time typed at the caret (`insertedDateTimeKind`). */
|
|
11
|
+
onInsertDateTime?(kind: InsertedDateTimeKind): void;
|
|
12
|
+
/** Insert: overtype on or off for the rest of the edit. */
|
|
13
|
+
onToggleOvertype?(): void;
|
|
9
14
|
onSubmit?(value: string, textFormatRuns: TextFormatRun[] | undefined | null, e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
10
15
|
onCancel?(e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
11
16
|
onKeyDown?(e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
@@ -16,6 +21,13 @@ type UseEditorKeyDownPMProps = {
|
|
|
16
21
|
isMentionDropdownOpen?: boolean;
|
|
17
22
|
getView(): EditorView | null;
|
|
18
23
|
};
|
|
19
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Excel's keys that type the current date or time into the entry being edited: Ctrl+; the date and
|
|
26
|
+
* Ctrl+Shift+; (Ctrl+:) the time ("Keyboard shortcuts in Excel", support.microsoft.com). Read off
|
|
27
|
+
* the physical key so a layout that puts `;` and `:` elsewhere still has them, as the grid's chords
|
|
28
|
+
* do. Excel for Mac's ⌘; (the time) arrives from a host's key map as Ctrl+Shift+;.
|
|
29
|
+
*/
|
|
30
|
+
export declare const insertedDateTimeKind: (e: Pick<KeyboardEvent, "code" | "key" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey">) => InsertedDateTimeKind | undefined;
|
|
31
|
+
export declare const useEditorKeyDownPM: ({ formulaMode, isNewValue, isCursorAtEnd, onInsertBreak, onInsertDateTime, onToggleOvertype, onSubmit, onCancel, onKeyDown, getView, isActive, value, canSubmit, canCancel, isDropdownOpen, }: UseEditorKeyDownPMProps) => (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
20
32
|
export {};
|
|
21
33
|
//# sourceMappingURL=use-editor-keydown-pm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor-keydown-pm.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-editor-keydown-pm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-editor-keydown-pm.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-editor-keydown-pm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAgB,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,IAAI,OAAO,CAAC;IACzB,aAAa,IAAI,IAAI,CAAC;IACtB,qGAAqG;IACrG,gBAAgB,CAAC,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACpD,2DAA2D;IAC3D,gBAAgB,CAAC,IAAI,IAAI,CAAC;IAC1B,QAAQ,CAAC,CACP,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI,EAClD,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GACrC,IAAI,CAAC;IACR,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACxD,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,IAAI,UAAU,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC,KACrF,oBAAoB,GAAG,SAMzB,CAAC;AAOF,eAAO,MAAM,kBAAkB,GAAI,+LAgBhC,uBAAuB,SASlB,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,SA0H1C,CAAC"}
|
|
@@ -2,8 +2,24 @@ import { isAnArrowKey } from "@rowsncolumns/utils";
|
|
|
2
2
|
import { useCallback, useRef } from "react";
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect.ts";
|
|
4
4
|
import { extractTextFormatRuns, serializeEditorValue } from "./helpers.js";
|
|
5
|
+
/**
|
|
6
|
+
* Excel's keys that type the current date or time into the entry being edited: Ctrl+; the date and
|
|
7
|
+
* Ctrl+Shift+; (Ctrl+:) the time ("Keyboard shortcuts in Excel", support.microsoft.com). Read off
|
|
8
|
+
* the physical key so a layout that puts `;` and `:` elsewhere still has them, as the grid's chords
|
|
9
|
+
* do. Excel for Mac's ⌘; (the time) arrives from a host's key map as Ctrl+Shift+;.
|
|
10
|
+
*/
|
|
11
|
+
export var insertedDateTimeKind = function (e) {
|
|
12
|
+
if (!e.ctrlKey || e.metaKey || e.altKey)
|
|
13
|
+
return undefined;
|
|
14
|
+
var isSemicolonKey = e.code === "Semicolon" || e.key === ";" || e.key === ":";
|
|
15
|
+
if (!isSemicolonKey)
|
|
16
|
+
return undefined;
|
|
17
|
+
return e.shiftKey || e.key === ":" ? "time" : "date";
|
|
18
|
+
};
|
|
19
|
+
/** Insert alone, which Excel's editor takes for overtype. */
|
|
20
|
+
var isOvertypeToggle = function (e) { return e.key === "Insert" && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey; };
|
|
5
21
|
export var useEditorKeyDownPM = function (_a) {
|
|
6
|
-
var formulaMode = _a.formulaMode, isNewValue = _a.isNewValue, isCursorAtEnd = _a.isCursorAtEnd, onInsertBreak = _a.onInsertBreak, onSubmit = _a.onSubmit, onCancel = _a.onCancel, onKeyDown = _a.onKeyDown, getView = _a.getView, isActive = _a.isActive, value = _a.value, _b = _a.canSubmit, canSubmit = _b === void 0 ? true : _b, _c = _a.canCancel, canCancel = _c === void 0 ? true : _c, isDropdownOpen = _a.isDropdownOpen;
|
|
22
|
+
var formulaMode = _a.formulaMode, isNewValue = _a.isNewValue, isCursorAtEnd = _a.isCursorAtEnd, onInsertBreak = _a.onInsertBreak, onInsertDateTime = _a.onInsertDateTime, onToggleOvertype = _a.onToggleOvertype, onSubmit = _a.onSubmit, onCancel = _a.onCancel, onKeyDown = _a.onKeyDown, getView = _a.getView, isActive = _a.isActive, value = _a.value, _b = _a.canSubmit, canSubmit = _b === void 0 ? true : _b, _c = _a.canCancel, canCancel = _c === void 0 ? true : _c, isDropdownOpen = _a.isDropdownOpen;
|
|
7
23
|
var valueRef = useRef(undefined);
|
|
8
24
|
// Used in keydown handler, closure
|
|
9
25
|
useIsomorphicLayoutEffect(function () {
|
|
@@ -24,6 +40,22 @@ export var useEditorKeyDownPM = function (_a) {
|
|
|
24
40
|
isAnArrowKey(e.key))) {
|
|
25
41
|
return;
|
|
26
42
|
}
|
|
43
|
+
if (!isComposing) {
|
|
44
|
+
var dateTimeKind = onInsertDateTime
|
|
45
|
+
? insertedDateTimeKind(nativeEvent)
|
|
46
|
+
: undefined;
|
|
47
|
+
if (dateTimeKind) {
|
|
48
|
+
// The entry stays open: Excel types the text at the caret and keeps editing.
|
|
49
|
+
onInsertDateTime === null || onInsertDateTime === void 0 ? void 0 : onInsertDateTime(dateTimeKind);
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (onToggleOvertype && isOvertypeToggle(nativeEvent)) {
|
|
54
|
+
onToggleOvertype();
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
27
59
|
// Handle line breaks
|
|
28
60
|
var key = e.key;
|
|
29
61
|
var isEnter = key === "Enter";
|
|
@@ -44,7 +76,9 @@ export var useEditorKeyDownPM = function (_a) {
|
|
|
44
76
|
// uses Ctrl+Return for the fill-selection commit, so nothing is lost.
|
|
45
77
|
// Previously this fired on metaKey||ctrlKey, so Alt+Enter fell through
|
|
46
78
|
// to the submit path and destructively committed instead of newlining.
|
|
47
|
-
|
|
79
|
+
// ⇧⌘Return is Excel for Mac's array-formula entry (as Ctrl+Shift+Enter is on Windows):
|
|
80
|
+
// it commits, so the cell editor can enter the formula over the selection.
|
|
81
|
+
if (isEnter && (e.altKey || (e.metaKey && !e.shiftKey))) {
|
|
48
82
|
onInsertBreak();
|
|
49
83
|
e.preventDefault();
|
|
50
84
|
return;
|
|
@@ -93,6 +127,8 @@ export var useEditorKeyDownPM = function (_a) {
|
|
|
93
127
|
formulaMode,
|
|
94
128
|
isDropdownOpen,
|
|
95
129
|
onInsertBreak,
|
|
130
|
+
onInsertDateTime,
|
|
131
|
+
onToggleOvertype,
|
|
96
132
|
canSubmit,
|
|
97
133
|
canCancel,
|
|
98
134
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,eAAO,MAAM,YAAY;mDAKtB,eAAe,CAAC,iBAAiB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;CAc5D,CAAC;AAGF,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAGH,eAAO,MAAM,iBAAiB,8KAY5B,CAAC;AAkBH,eAAO,MAAM,aAAa;sBAGJ,MAAM;gBACZ,WAAW,GAAG,IAAI;wCA8ChC,CAAC;AAGH,eAAO,MAAM,MAAM,uCAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,8GAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,4GAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../dialog/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,MAAM,OAAO,CAAC;AA2B1B,eAAO,MAAM,YAAY;mDAKtB,eAAe,CAAC,iBAAiB,GAAG;QAAE,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;;CAc5D,CAAC;AAGF,eAAO,MAAM,WAAW,oKAYtB,CAAC;AAGH,eAAO,MAAM,iBAAiB,8KAY5B,CAAC;AAkBH,eAAO,MAAM,aAAa;sBAGJ,MAAM;gBACZ,WAAW,GAAG,IAAI;wCA8ChC,CAAC;AAGH,eAAO,MAAM,MAAM,uCAAuB,CAAC;AAC3C,eAAO,MAAM,aAAa,8GAA0B,CAAC;AACrD,eAAO,MAAM,WAAW,4GAAwB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,4KAY5B,CAAC;AAGH,eAAO,MAAM,UAAU,GAAI,0BAGxB;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,sBAEA,CAAC"}
|
package/dist/esm/dialog/index.js
CHANGED
|
@@ -60,6 +60,9 @@ export const DialogContent = React.forwardRef(({ className, portalClassName, con
|
|
|
60
60
|
export const Dialog = DialogPrimitive.Root;
|
|
61
61
|
export const DialogTrigger = DialogPrimitive.Trigger;
|
|
62
62
|
export const DialogClose = DialogPrimitive.Close;
|
|
63
|
-
export const DialogCloseButton = React.forwardRef(({ className, ...props }, ref) => (
|
|
63
|
+
export const DialogCloseButton = React.forwardRef(({ className, ...props }, ref) => (
|
|
64
|
+
// Icon-only: without a name a screen reader announces just "button" (axe `button-name`). A
|
|
65
|
+
// caller's own `aria-label` still wins.
|
|
66
|
+
React.createElement(IconButton, { ref: ref, "aria-label": "Close", className: cn("absolute top-2 right-2", className), ...props })));
|
|
64
67
|
DialogCloseButton.displayName = "DialogCloseButton";
|
|
65
68
|
export const DialogBody = ({ className, children, }) => (React.createElement("div", { className: cn("p-4 overflow-auto max-h-svh", className) }, children));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ParsedToken } from "@rowsncolumns/calculator";
|
|
2
2
|
import { Node, Schema } from "prosemirror-model";
|
|
3
|
-
import { EditorState } from "prosemirror-state";
|
|
3
|
+
import { EditorState, type Transaction } from "prosemirror-state";
|
|
4
4
|
import { EditorView } from "prosemirror-view";
|
|
5
5
|
import { TextFormatRun } from "./types";
|
|
6
6
|
export type LeafDecorator = {
|
|
@@ -210,5 +210,12 @@ export declare const getTokenizationContent: (state: EditorState, cursorPos: num
|
|
|
210
210
|
* @param text
|
|
211
211
|
*/
|
|
212
212
|
export declare const cleanFunctionToken: (text: string) => string;
|
|
213
|
+
/**
|
|
214
|
+
* Overtype (Excel's Insert key while editing): typed text replaces as many
|
|
215
|
+
* characters after the caret as it holds, within the caret's line, instead of
|
|
216
|
+
* pushing them along. A selection, the end of a line or an empty insert leave
|
|
217
|
+
* the ordinary insert to ProseMirror (`null`).
|
|
218
|
+
*/
|
|
219
|
+
export declare const overtypeTransaction: (state: EditorState, from: number, to: number, text: string) => Transaction | null;
|
|
213
220
|
export {};
|
|
214
221
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../editor-pm/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAQ,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../editor-pm/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,EAAQ,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,OAAO,EAAW,aAAa,EAAE,MAAM,SAAS,CAAC;AAOjD,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,KAAK,MAAM,EAAE,QAAQ,GAAG,QA8BzD,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,KAAK,GAAG,QAQxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,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(Excel's Insert key while editing): typed text replaces as many
|
|
1145
|
+
* characters after the caret as it holds, within the caret's line, instead of
|
|
1146
|
+
* pushing them along. A selection, the end of a line or an empty insert leave
|
|
1147
|
+
* the ordinary insert to ProseMirror (`null`).
|
|
1148
|
+
*/
|
|
1149
|
+
export const overtypeTransaction = (state, from, to, text) => {
|
|
1150
|
+
if (from !== to || !text)
|
|
1151
|
+
return null;
|
|
1152
|
+
const $from = state.doc.resolve(from);
|
|
1153
|
+
if (!$from.parent.isTextblock)
|
|
1154
|
+
return null;
|
|
1155
|
+
const overwriteTo = Math.min(from + text.length, $from.end());
|
|
1156
|
+
if (overwriteTo <= from)
|
|
1157
|
+
return null;
|
|
1158
|
+
return state.tr.insertText(text, from, overwriteTo);
|
|
1159
|
+
};
|
|
@@ -53,6 +53,11 @@ export type ProseMirrorEditorProps<M extends Mention = Mention> = RichTextEditor
|
|
|
53
53
|
* in the same locale. Canonical syntax when omitted.
|
|
54
54
|
*/
|
|
55
55
|
formulaLocale?: FormulaLocale;
|
|
56
|
+
/**
|
|
57
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
58
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
59
|
+
*/
|
|
60
|
+
locale?: string;
|
|
56
61
|
showDropdown?: boolean;
|
|
57
62
|
dropdownStyles?: React.CSSProperties;
|
|
58
63
|
stickyEditor?: boolean;
|
|
@@ -175,6 +180,14 @@ export type ProseMirrorEditorProps<M extends Mention = Mention> = RichTextEditor
|
|
|
175
180
|
* instead of inheriting whatever the paste sandbox sees.
|
|
176
181
|
*/
|
|
177
182
|
cellFontFamily?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
185
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
186
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
187
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
188
|
+
* replaces it. Ignored in formula mode.
|
|
189
|
+
*/
|
|
190
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
178
191
|
};
|
|
179
192
|
type SelectionMode = "clear" | "modify" | "append";
|
|
180
193
|
export type TextEditorRef = {
|
|
@@ -249,6 +262,11 @@ export declare const ProseMirrorEditorThatMayError: React.NamedExoticComponent<R
|
|
|
249
262
|
* in the same locale. Canonical syntax when omitted.
|
|
250
263
|
*/
|
|
251
264
|
formulaLocale?: FormulaLocale;
|
|
265
|
+
/**
|
|
266
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
267
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
268
|
+
*/
|
|
269
|
+
locale?: string;
|
|
252
270
|
showDropdown?: boolean;
|
|
253
271
|
dropdownStyles?: React.CSSProperties;
|
|
254
272
|
stickyEditor?: boolean;
|
|
@@ -366,6 +384,14 @@ export declare const ProseMirrorEditorThatMayError: React.NamedExoticComponent<R
|
|
|
366
384
|
* instead of inheriting whatever the paste sandbox sees.
|
|
367
385
|
*/
|
|
368
386
|
cellFontFamily?: string;
|
|
387
|
+
/**
|
|
388
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
389
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
390
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
391
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
392
|
+
* replaces it. Ignored in formula mode.
|
|
393
|
+
*/
|
|
394
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
369
395
|
} & ProseMirrorEditorRef>;
|
|
370
396
|
export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<RichTextEditorAttribues & {
|
|
371
397
|
value: string;
|
|
@@ -397,6 +423,11 @@ export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<Ric
|
|
|
397
423
|
* in the same locale. Canonical syntax when omitted.
|
|
398
424
|
*/
|
|
399
425
|
formulaLocale?: FormulaLocale;
|
|
426
|
+
/**
|
|
427
|
+
* The locale Ctrl+; and Ctrl+Shift+; write today's date and the time in (`formatInsertedDateTime`):
|
|
428
|
+
* the locale's short date (`11/3/2026`) and time (`2:05 PM`). The browser's when omitted.
|
|
429
|
+
*/
|
|
430
|
+
locale?: string;
|
|
400
431
|
showDropdown?: boolean;
|
|
401
432
|
dropdownStyles?: React.CSSProperties;
|
|
402
433
|
stickyEditor?: boolean;
|
|
@@ -514,5 +545,13 @@ export declare const ProseMirrorEditor: React.ForwardRefExoticComponent<Omit<Ric
|
|
|
514
545
|
* instead of inheriting whatever the paste sandbox sees.
|
|
515
546
|
*/
|
|
516
547
|
cellFontFamily?: string;
|
|
548
|
+
/**
|
|
549
|
+
* Excel's AutoComplete for cell values: called with the editor's text
|
|
550
|
+
* after a character is typed at the end of a one-line entry; a returned
|
|
551
|
+
* entry that extends it (case-insensitively) is written in after the caret
|
|
552
|
+
* and selected, so Enter accepts it, Backspace removes it and typing on
|
|
553
|
+
* replaces it. Ignored in formula mode.
|
|
554
|
+
*/
|
|
555
|
+
getAutoComplete?(typed: string): string | undefined;
|
|
517
556
|
} & ProseMirrorEditorRef, "ref"> & React.RefAttributes<any>>;
|
|
518
557
|
//# sourceMappingURL=prosemirror-editor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAK9E,OAAO,EAGL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"prosemirror-editor.d.ts","sourceRoot":"","sources":["../../../editor-pm/prosemirror-editor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,M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AAO;IACnC;;;;OAIG;qBACc,MAAM;IACvB;;;;;;OAMG;4BACqB,MAAM,GAAG,MAAM,GAAG,SAAS;4DA2tDtD,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { tokenVocabulary } from "@rowsncolumns/fast-formula-parser";
|
|
|
4
4
|
import { useCallbackRef } from "@rowsncolumns/grid";
|
|
5
5
|
import { LoadingIcon, QuestionMarkIcon } from "@rowsncolumns/icons";
|
|
6
6
|
import { DEFAULT_ARRAY } from "@rowsncolumns/spreadsheet";
|
|
7
|
-
import { canonicalizeFunctionName, clipboardHtmlToRichText, } from "@rowsncolumns/utils";
|
|
7
|
+
import { canonicalizeFunctionName, clipboardHtmlToRichText, formatInsertedDateTime, } from "@rowsncolumns/utils";
|
|
8
8
|
import { addressToCell, getHotkeyKey, isAFormula, isNil, log, } from "@rowsncolumns/utils";
|
|
9
9
|
import { baseKeymap, joinBackward, toggleMark } from "prosemirror-commands";
|
|
10
10
|
import { history, redo, undo } from "prosemirror-history";
|
|
@@ -26,7 +26,7 @@ import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect
|
|
|
26
26
|
import { usePortalContainer } from "../portal-container";
|
|
27
27
|
import { cn } from "../utils";
|
|
28
28
|
import { createDecorationPlugin } from "./decoration-plugin";
|
|
29
|
-
import { applyTextFormatRuns, applyTextFormatToSelection, deserializeString, getPropertyStartIndex, getSelectionFontSize, isCellToken, serializeEditorValue, } from "./helpers";
|
|
29
|
+
import { applyTextFormatRuns, applyTextFormatToSelection, deserializeString, getPropertyStartIndex, getSelectionFontSize, isCellToken, overtypeTransaction, serializeEditorValue, } from "./helpers";
|
|
30
30
|
import { MentionNodeView } from "./mention-nodeview";
|
|
31
31
|
import { MentionsDropdown } from "./mentions-dropdown";
|
|
32
32
|
import { createMentionsPlugin } from "./mentions-plugin";
|
|
@@ -62,13 +62,14 @@ export const deleteAll = (state, dispatch) => {
|
|
|
62
62
|
* ProseMirror editor component for rich text and formula editing.
|
|
63
63
|
* Supports syntax highlighting, autocomplete, and keyboard shortcuts.
|
|
64
64
|
*/
|
|
65
|
-
export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNewValue, formulaMode, onChange, autoFocus, className, onKeyDown, disabled, showDropdown = true, persistFocus = true, editorZeroOutline, showFormulaHelp, onHideFormulaHelp, onShowFormulaHelp, tokenizer, onCancel, onSubmit, onFormulaStateChange, dropdownStyles, options, isOptionSelected, functionDescriptions, shouldFetchFunctionParameters: shouldFetchFunctionParametersProp, getFunctionParameterSuggestions: getFunctionParameterSuggestionsProp, formulaLocale, getMentions, getNamedRanges, getTableNames, getTableColumnNames, getStructuredProperties, onTeardown, SuggestionsDropdown = DefaultSuggestionsDropdown, MentionTagComponent, MentionDropdownItemComponent, isActive, stickyEditor = true, onFocus, onBlur, onCopy, onCut, onPaste, placeholder, textFormatRuns, resolveRunColor, navigationMode, enableContinuousSelection, cellFontFamily, ...props }, forwardedRef) => {
|
|
65
|
+
export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNewValue, formulaMode, onChange, autoFocus, className, onKeyDown, disabled, showDropdown = true, persistFocus = true, editorZeroOutline, showFormulaHelp, onHideFormulaHelp, onShowFormulaHelp, tokenizer, onCancel, onSubmit, onFormulaStateChange, dropdownStyles, options, isOptionSelected, functionDescriptions, shouldFetchFunctionParameters: shouldFetchFunctionParametersProp, getFunctionParameterSuggestions: getFunctionParameterSuggestionsProp, formulaLocale, locale, getMentions, getNamedRanges, getTableNames, getTableColumnNames, getStructuredProperties, onTeardown, SuggestionsDropdown = DefaultSuggestionsDropdown, MentionTagComponent, MentionDropdownItemComponent, isActive, stickyEditor = true, onFocus, onBlur, onCopy, onCut, onPaste, placeholder, textFormatRuns, resolveRunColor, navigationMode, enableContinuousSelection, cellFontFamily, getAutoComplete, ...props }, forwardedRef) => {
|
|
66
66
|
const editorRef = useRef(null);
|
|
67
67
|
const viewRef = useRef(null);
|
|
68
68
|
const portalContainer = usePortalContainer();
|
|
69
69
|
/** The `history()` plugin instance the view was created with — see `resetUndoHistory`. */
|
|
70
70
|
const historyPluginRef = useRef(null);
|
|
71
71
|
const cellFontFamilyRef = useRef(cellFontFamily);
|
|
72
|
+
const getAutoCompleteRef = useRef(getAutoComplete);
|
|
72
73
|
// The function token is in the editor's locale (`СУММ(`); hosts are asked about the canonical
|
|
73
74
|
// name (`SUM(`) so parameter providers keyed on English names work in every locale.
|
|
74
75
|
const canonicalFunctionImage = useCallback((image) => {
|
|
@@ -157,9 +158,29 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
157
158
|
useIsomorphicLayoutEffect(() => {
|
|
158
159
|
cellFontFamilyRef.current = cellFontFamily;
|
|
159
160
|
}, [cellFontFamily]);
|
|
161
|
+
// Overtype (Insert), for the edit under way: every edit starts in insert mode, as in Excel.
|
|
162
|
+
const overtypeRef = useRef(false);
|
|
163
|
+
const setOvertype = useCallback((on) => {
|
|
164
|
+
overtypeRef.current = on;
|
|
165
|
+
const dom = viewRef.current?.dom;
|
|
166
|
+
if (!dom)
|
|
167
|
+
return;
|
|
168
|
+
if (on) {
|
|
169
|
+
dom.setAttribute("data-overtype", "true");
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
dom.removeAttribute("data-overtype");
|
|
173
|
+
}
|
|
174
|
+
}, []);
|
|
175
|
+
useIsomorphicLayoutEffect(() => {
|
|
176
|
+
getAutoCompleteRef.current = getAutoComplete;
|
|
177
|
+
}, [getAutoComplete]);
|
|
160
178
|
useIsomorphicLayoutEffect(() => {
|
|
161
179
|
const previousMode = navigationModeRef.current;
|
|
162
180
|
navigationModeRef.current = navigationMode;
|
|
181
|
+
if (navigationMode && overtypeRef.current) {
|
|
182
|
+
setOvertype(false);
|
|
183
|
+
}
|
|
163
184
|
// Reset formula-related states when entering navigation mode (and mode has changed)
|
|
164
185
|
if (navigationMode && previousMode !== navigationMode) {
|
|
165
186
|
setCursorPosition(undefined);
|
|
@@ -511,6 +532,40 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
511
532
|
tabindex: "0",
|
|
512
533
|
},
|
|
513
534
|
editable: () => !disabled,
|
|
535
|
+
// Overtype (Insert): a typed character replaces the one after the caret.
|
|
536
|
+
// Otherwise AutoComplete for cell values: type the character, then write
|
|
537
|
+
// the rest of the one matching entry after the caret, selected.
|
|
538
|
+
handleTextInput: (view, from, to, text) => {
|
|
539
|
+
if (overtypeRef.current && !view.composing) {
|
|
540
|
+
const overtype = overtypeTransaction(view.state, from, to, text);
|
|
541
|
+
if (overtype) {
|
|
542
|
+
view.dispatch(overtype.scrollIntoView());
|
|
543
|
+
return true;
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
const complete = getAutoCompleteRef.current;
|
|
547
|
+
if (!complete || formulaModeRef.current)
|
|
548
|
+
return false;
|
|
549
|
+
const { doc } = view.state;
|
|
550
|
+
if (doc.childCount !== 1 || to !== doc.content.size - 1) {
|
|
551
|
+
return false;
|
|
552
|
+
}
|
|
553
|
+
const tr = view.state.tr.insertText(text, from, to);
|
|
554
|
+
const typed = serializeEditorValue(tr.doc);
|
|
555
|
+
if (isAFormula(typed))
|
|
556
|
+
return false;
|
|
557
|
+
const entry = complete(typed);
|
|
558
|
+
if (!entry ||
|
|
559
|
+
entry.length <= typed.length ||
|
|
560
|
+
!entry.toLowerCase().startsWith(typed.toLowerCase())) {
|
|
561
|
+
return false;
|
|
562
|
+
}
|
|
563
|
+
const caret = tr.selection.to;
|
|
564
|
+
tr.insertText(entry.slice(typed.length), caret);
|
|
565
|
+
tr.setSelection(TextSelection.create(tr.doc, caret, tr.doc.content.size - 1));
|
|
566
|
+
view.dispatch(tr.scrollIntoView());
|
|
567
|
+
return true;
|
|
568
|
+
},
|
|
514
569
|
// Rich text from Google Sheets / Excel: convert the clipboard's
|
|
515
570
|
// `text/html` with the shared converter and insert it as marks —
|
|
516
571
|
// the same runs the grid paste commits, so the formula bar, the
|
|
@@ -545,6 +600,10 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
545
600
|
return false; // Let ProseMirror handle the focus as well
|
|
546
601
|
},
|
|
547
602
|
blur: (_, event) => {
|
|
603
|
+
// Leaving the editor ends overtype, as leaving an entry does in Excel (the formula
|
|
604
|
+
// bar's editor outlives its edits and never goes into navigation mode).
|
|
605
|
+
if (overtypeRef.current)
|
|
606
|
+
setOvertype(false);
|
|
548
607
|
onBlurRef.current?.(event);
|
|
549
608
|
return false; // Let ProseMirror handle the blur as well
|
|
550
609
|
},
|
|
@@ -1044,6 +1103,15 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
1044
1103
|
}
|
|
1045
1104
|
}
|
|
1046
1105
|
}, []);
|
|
1106
|
+
// Ctrl+; / Ctrl+Shift+;: the date or the time at the caret, replacing a selection; the edit stays open.
|
|
1107
|
+
const handleInsertDateTime = useCallback((kind) => {
|
|
1108
|
+
const view = viewRef.current;
|
|
1109
|
+
if (!view)
|
|
1110
|
+
return;
|
|
1111
|
+
const text = formatInsertedDateTime({ kind, locale });
|
|
1112
|
+
view.dispatch(view.state.tr.insertText(text).scrollIntoView());
|
|
1113
|
+
}, [locale]);
|
|
1114
|
+
const handleToggleOvertype = useCallback(() => setOvertype(!overtypeRef.current), [setOvertype]);
|
|
1047
1115
|
const canSubmitInDropdown = () => {
|
|
1048
1116
|
const token = suggestionTokenRef.current;
|
|
1049
1117
|
const item = items[highlightedIndex];
|
|
@@ -1069,6 +1137,10 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
1069
1137
|
onCancel: !navigationMode ? onCancel : undefined,
|
|
1070
1138
|
onSubmit: !navigationMode ? onSubmit : undefined,
|
|
1071
1139
|
onInsertBreak: handleInsertBreak,
|
|
1140
|
+
// The sticky editor buffers keys while the grid navigates: there the grid owns Ctrl+; (it
|
|
1141
|
+
// inserts the date into the cell) and Insert does nothing.
|
|
1142
|
+
onInsertDateTime: !navigationMode && !disabled ? handleInsertDateTime : undefined,
|
|
1143
|
+
onToggleOvertype: !navigationMode && !disabled ? handleToggleOvertype : undefined,
|
|
1072
1144
|
onKeyDown: handleKeyDown,
|
|
1073
1145
|
canSubmit,
|
|
1074
1146
|
canCancel: !isOpen && !showMentionDropdownEffective,
|
|
@@ -1259,7 +1331,7 @@ export const ProseMirrorEditorThatMayError = memo(forwardRef(({ value = "", isNe
|
|
|
1259
1331
|
React.createElement("div", { className: "h-full overflow-auto [&_div]:outline-none" },
|
|
1260
1332
|
React.createElement("div", { ref: editorRef, className: cn(className, "whitespace-pre-wrap"), onKeyDownCapture: handleKeyDownCapture, onKeyDown: onKeyDownEditor, ...props })),
|
|
1261
1333
|
React.createElement(Popper.Anchor, { asChild: true },
|
|
1262
|
-
React.createElement("button", { tabIndex: -1, className: cn("absolute left-0 top-0 w-0 h-full overflow-hidden m-0 p-0 border-none bg-transparent shadow-none"), style: {
|
|
1334
|
+
React.createElement("button", { type: "button", "aria-hidden": "true", tabIndex: -1, className: cn("absolute left-0 top-0 w-0 h-full overflow-hidden m-0 p-0 border-none bg-transparent shadow-none"), style: {
|
|
1263
1335
|
left: showMentionDropdownEffective ? mentionPositionLeft : 0,
|
|
1264
1336
|
} })),
|
|
1265
1337
|
showDropdownEffective && isDropdownOpen && (React.createElement(ConditionalWrapper, { condition: stickyEditor, wrapper: (children) => (React.createElement(Portal, { asChild: true, container: portalContainer }, children)) },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type InsertedDateTimeKind } from "@rowsncolumns/utils";
|
|
1
2
|
import { EditorView } from "prosemirror-view";
|
|
2
3
|
import { TextFormatRun } from "./types.js";
|
|
3
4
|
type UseEditorKeyDownPMProps = {
|
|
@@ -6,6 +7,10 @@ type UseEditorKeyDownPMProps = {
|
|
|
6
7
|
isNewValue?: boolean;
|
|
7
8
|
isCursorAtEnd(): boolean;
|
|
8
9
|
onInsertBreak(): void;
|
|
10
|
+
/** Ctrl+; and Ctrl+Shift+;: today's date or the time typed at the caret (`insertedDateTimeKind`). */
|
|
11
|
+
onInsertDateTime?(kind: InsertedDateTimeKind): void;
|
|
12
|
+
/** Insert: overtype on or off for the rest of the edit. */
|
|
13
|
+
onToggleOvertype?(): void;
|
|
9
14
|
onSubmit?(value: string, textFormatRuns: TextFormatRun[] | undefined | null, e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
10
15
|
onCancel?(e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
11
16
|
onKeyDown?(e: React.KeyboardEvent<HTMLDivElement>): void;
|
|
@@ -16,6 +21,13 @@ type UseEditorKeyDownPMProps = {
|
|
|
16
21
|
isMentionDropdownOpen?: boolean;
|
|
17
22
|
getView(): EditorView | null;
|
|
18
23
|
};
|
|
19
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Excel's keys that type the current date or time into the entry being edited: Ctrl+; the date and
|
|
26
|
+
* Ctrl+Shift+; (Ctrl+:) the time ("Keyboard shortcuts in Excel", support.microsoft.com). Read off
|
|
27
|
+
* the physical key so a layout that puts `;` and `:` elsewhere still has them, as the grid's chords
|
|
28
|
+
* do. Excel for Mac's ⌘; (the time) arrives from a host's key map as Ctrl+Shift+;.
|
|
29
|
+
*/
|
|
30
|
+
export declare const insertedDateTimeKind: (e: Pick<KeyboardEvent, "code" | "key" | "ctrlKey" | "metaKey" | "altKey" | "shiftKey">) => InsertedDateTimeKind | undefined;
|
|
31
|
+
export declare const useEditorKeyDownPM: ({ formulaMode, isNewValue, isCursorAtEnd, onInsertBreak, onInsertDateTime, onToggleOvertype, onSubmit, onCancel, onKeyDown, getView, isActive, value, canSubmit, canCancel, isDropdownOpen, }: UseEditorKeyDownPMProps) => (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
20
32
|
export {};
|
|
21
33
|
//# sourceMappingURL=use-editor-keydown-pm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-editor-keydown-pm.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-editor-keydown-pm.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-editor-keydown-pm.d.ts","sourceRoot":"","sources":["../../../editor-pm/use-editor-keydown-pm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAgB,MAAM,qBAAqB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,KAAK,uBAAuB,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,IAAI,OAAO,CAAC;IACzB,aAAa,IAAI,IAAI,CAAC;IACtB,qGAAqG;IACrG,gBAAgB,CAAC,CAAC,IAAI,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACpD,2DAA2D;IAC3D,gBAAgB,CAAC,IAAI,IAAI,CAAC;IAC1B,QAAQ,CAAC,CACP,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,aAAa,EAAE,GAAG,SAAS,GAAG,IAAI,EAClD,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GACrC,IAAI,CAAC;IACR,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACxD,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC;IACzD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,IAAI,UAAU,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC/B,GAAG,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC,KACrF,oBAAoB,GAAG,SAMzB,CAAC;AAOF,eAAO,MAAM,kBAAkB,GAAI,+LAgBhC,uBAAuB,SASlB,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,SA0H1C,CAAC"}
|
|
@@ -2,7 +2,23 @@ import { isAnArrowKey } from "@rowsncolumns/utils";
|
|
|
2
2
|
import { useCallback, useRef } from "react";
|
|
3
3
|
import { useIsomorphicLayoutEffect } from "../hooks/use-isomorphic-layout-effect.ts";
|
|
4
4
|
import { extractTextFormatRuns, serializeEditorValue } from "./helpers.js";
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Excel's keys that type the current date or time into the entry being edited: Ctrl+; the date and
|
|
7
|
+
* Ctrl+Shift+; (Ctrl+:) the time ("Keyboard shortcuts in Excel", support.microsoft.com). Read off
|
|
8
|
+
* the physical key so a layout that puts `;` and `:` elsewhere still has them, as the grid's chords
|
|
9
|
+
* do. Excel for Mac's ⌘; (the time) arrives from a host's key map as Ctrl+Shift+;.
|
|
10
|
+
*/
|
|
11
|
+
export const insertedDateTimeKind = (e) => {
|
|
12
|
+
if (!e.ctrlKey || e.metaKey || e.altKey)
|
|
13
|
+
return undefined;
|
|
14
|
+
const isSemicolonKey = e.code === "Semicolon" || e.key === ";" || e.key === ":";
|
|
15
|
+
if (!isSemicolonKey)
|
|
16
|
+
return undefined;
|
|
17
|
+
return e.shiftKey || e.key === ":" ? "time" : "date";
|
|
18
|
+
};
|
|
19
|
+
/** Insert alone, which Excel's editor takes for overtype. */
|
|
20
|
+
const isOvertypeToggle = (e) => e.key === "Insert" && !e.ctrlKey && !e.metaKey && !e.altKey && !e.shiftKey;
|
|
21
|
+
export const useEditorKeyDownPM = ({ formulaMode, isNewValue, isCursorAtEnd, onInsertBreak, onInsertDateTime, onToggleOvertype, onSubmit, onCancel, onKeyDown, getView, isActive, value, canSubmit = true, canCancel = true, isDropdownOpen, }) => {
|
|
6
22
|
const valueRef = useRef(undefined);
|
|
7
23
|
// Used in keydown handler, closure
|
|
8
24
|
useIsomorphicLayoutEffect(() => {
|
|
@@ -22,6 +38,22 @@ export const useEditorKeyDownPM = ({ formulaMode, isNewValue, isCursorAtEnd, onI
|
|
|
22
38
|
isAnArrowKey(e.key))) {
|
|
23
39
|
return;
|
|
24
40
|
}
|
|
41
|
+
if (!isComposing) {
|
|
42
|
+
const dateTimeKind = onInsertDateTime
|
|
43
|
+
? insertedDateTimeKind(nativeEvent)
|
|
44
|
+
: undefined;
|
|
45
|
+
if (dateTimeKind) {
|
|
46
|
+
// The entry stays open: Excel types the text at the caret and keeps editing.
|
|
47
|
+
onInsertDateTime?.(dateTimeKind);
|
|
48
|
+
e.preventDefault();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (onToggleOvertype && isOvertypeToggle(nativeEvent)) {
|
|
52
|
+
onToggleOvertype();
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
25
57
|
// Handle line breaks
|
|
26
58
|
const key = e.key;
|
|
27
59
|
const isEnter = key === "Enter";
|
|
@@ -42,7 +74,9 @@ export const useEditorKeyDownPM = ({ formulaMode, isNewValue, isCursorAtEnd, onI
|
|
|
42
74
|
// uses Ctrl+Return for the fill-selection commit, so nothing is lost.
|
|
43
75
|
// Previously this fired on metaKey||ctrlKey, so Alt+Enter fell through
|
|
44
76
|
// to the submit path and destructively committed instead of newlining.
|
|
45
|
-
|
|
77
|
+
// ⇧⌘Return is Excel for Mac's array-formula entry (as Ctrl+Shift+Enter is on Windows):
|
|
78
|
+
// it commits, so the cell editor can enter the formula over the selection.
|
|
79
|
+
if (isEnter && (e.altKey || (e.metaKey && !e.shiftKey))) {
|
|
46
80
|
onInsertBreak();
|
|
47
81
|
e.preventDefault();
|
|
48
82
|
return;
|
|
@@ -91,6 +125,8 @@ export const useEditorKeyDownPM = ({ formulaMode, isNewValue, isCursorAtEnd, onI
|
|
|
91
125
|
formulaMode,
|
|
92
126
|
isDropdownOpen,
|
|
93
127
|
onInsertBreak,
|
|
128
|
+
onInsertDateTime,
|
|
129
|
+
onToggleOvertype,
|
|
94
130
|
canSubmit,
|
|
95
131
|
canCancel,
|
|
96
132
|
]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rowsncolumns/ui",
|
|
3
|
-
"version": "16.1.
|
|
3
|
+
"version": "16.1.2",
|
|
4
4
|
"author": "Vinay M",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -58,12 +58,12 @@
|
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@rowsncolumns/calculator": ">=7.3.2",
|
|
61
|
-
"@rowsncolumns/common-types": ">=5.3.
|
|
61
|
+
"@rowsncolumns/common-types": ">=5.3.6",
|
|
62
62
|
"@rowsncolumns/fast-formula-parser": ">=6.2.43",
|
|
63
|
-
"@rowsncolumns/functions": ">=15.1.
|
|
63
|
+
"@rowsncolumns/functions": ">=15.1.1",
|
|
64
64
|
"@rowsncolumns/grid": ">=13.2.36",
|
|
65
65
|
"@rowsncolumns/icons": ">=7.2.33",
|
|
66
|
-
"@rowsncolumns/utils": ">=9.
|
|
66
|
+
"@rowsncolumns/utils": ">=9.6.3",
|
|
67
67
|
"@types/lodash": "^4.17.17",
|
|
68
68
|
"react": "^19.1.0",
|
|
69
69
|
"react-dom": "^19.1.0"
|