@glideapps/glide-data-grid
Advanced tools
Comparing version 2.2.4 to 2.2.5
@@ -102,3 +102,3 @@ "use strict"; | ||
onFinishEditing(undefined, [0, 0]); | ||
} else if (event.key === "Enter" && !event.ctrlKey) { | ||
} else if (event.key === "Enter") { | ||
onFinishEditing(tempValue, [0, event.shiftKey ? -1 : 1]); | ||
@@ -112,2 +112,16 @@ event.stopPropagation(); | ||
} | ||
}, [onFinishEditing, tempValue]); // The only difference is that `shift + enter` enters a newline | ||
var onKeyDownMultiline = React.useCallback(function (event) { | ||
if (event.key === "Escape") { | ||
onFinishEditing(undefined, [0, 0]); | ||
} else if (event.key === "Enter" && !event.shiftKey) { | ||
onFinishEditing(tempValue, [0, 1]); | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
} else if (event.key === "Tab") { | ||
onFinishEditing(tempValue, [event.shiftKey ? -1 : 1, 0]); | ||
event.stopPropagation(); | ||
event.preventDefault(); | ||
} | ||
}, [onFinishEditing, tempValue]); | ||
@@ -122,4 +136,3 @@ var ImageEditor = imageEditorOverride !== null && imageEditorOverride !== void 0 ? imageEditorOverride : _imageOverlayEditor.default; | ||
autoFocus: true, | ||
allowCtrlEnter: true, | ||
onKeyDown: onKeyDown, | ||
onKeyDown: onKeyDownMultiline, | ||
value: targetValue.data, | ||
@@ -178,3 +191,3 @@ onChange: onStringValueChange | ||
markdown: targetValue.data, | ||
onKeyDown: onKeyDown, | ||
onKeyDown: onKeyDownMultiline, | ||
onChange: onStringValueChange, | ||
@@ -189,7 +202,9 @@ forceEditMode: forceEditMode, | ||
ev.stopPropagation(); | ||
}; | ||
}; // Consider imperatively creating and adding the element to the dom? | ||
var portalElement = document.getElementById("portal"); | ||
if (portalElement === null) { | ||
// eslint-disable-next-line no-console | ||
console.error('Cannot open Data Grid overlay editor, because portal not found. Please add `<div id="portal" />` as the last child of your `<body>`.'); | ||
@@ -196,0 +211,0 @@ return null; |
@@ -31,6 +31,4 @@ "use strict"; | ||
value = props.value, | ||
ref = props.ref, | ||
onKeyDown = props.onKeyDown, | ||
allowCtrlEnter = props.allowCtrlEnter, | ||
rest = _objectWithoutProperties(props, ["placeholder", "value", "ref", "onKeyDown", "allowCtrlEnter"]); | ||
rest = _objectWithoutProperties(props, ["placeholder", "value", "onKeyDown"]); | ||
@@ -49,16 +47,2 @@ var onChange = rest.onChange, | ||
}, []); | ||
var onKeyDownImpl = React.useCallback(function (event) { | ||
if (event.ctrlKey && event.key === "Enter" && allowCtrlEnter === true && inputRef.current !== null) { | ||
var _Object$getOwnPropert; | ||
var newValue = inputRef.current.value + "\n"; | ||
var nativeInputValueSetter = (_Object$getOwnPropert = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value")) === null || _Object$getOwnPropert === void 0 ? void 0 : _Object$getOwnPropert.set; | ||
nativeInputValueSetter === null || nativeInputValueSetter === void 0 ? void 0 : nativeInputValueSetter.call(inputRef.current, newValue); | ||
inputRef.current.dispatchEvent(new Event("change", { | ||
bubbles: true | ||
})); | ||
} | ||
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(event); | ||
}, [onKeyDown, allowCtrlEnter]); | ||
return /*#__PURE__*/React.createElement(_growingEntryStyle.GrowingEntryStyle, null, /*#__PURE__*/React.createElement(_growingEntryStyle.ShadowBox, { | ||
@@ -68,3 +52,3 @@ className: className | ||
ref: inputRef, | ||
onKeyDown: onKeyDownImpl, | ||
onKeyDown: onKeyDown, | ||
value: useText, | ||
@@ -71,0 +55,0 @@ placeholder: placeholder, |
import * as React from "react"; | ||
interface Props extends React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement> { | ||
readonly placeholder?: string; | ||
readonly allowCtrlEnter?: boolean; | ||
} | ||
declare const GrowingEntry: React.NamedExoticComponent<Props>; | ||
export default GrowingEntry; |
{ | ||
"name": "@glideapps/glide-data-grid", | ||
"version": "2.2.4", | ||
"version": "2.2.5", | ||
"description": "Super fast, pure canvas Data Grid Editor", | ||
@@ -5,0 +5,0 @@ "main": "dist/js/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
344063
6045