Skip to content

Commit 9ea9a81

Browse files
committed
Feat: added support for location input placeholder
1 parent 2568dd7 commit 9ea9a81

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/components/operations/index.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useMemo } from "react";
12
import { Cog } from "lucide-react";
23
import { useSelector } from "react-redux";
34
import { twMerge } from "tailwind-merge";
@@ -13,21 +14,24 @@ import { default as GridSwitch } from "./grid-switch";
1314
const onCogClick = () => store.dispatch(toggleControls());
1415

1516
const Operations: React.FC<ISTKProps> = ({
16-
options: { showGridSwitch = true, exportButtonText, operationTriggerIcon } = {},
17+
options: { showGridSwitch = true, exportButtonText, operationTriggerIcon, locationInputPlaceholder } = {},
1718
events,
1819
...props
1920
}) => {
2021
const location = useSelector((state: any) => state.editor.location);
2122

23+
const inputPlaceholder = useMemo(() => locationInputPlaceholder ?? locationPlaceholder, [locationInputPlaceholder]);
24+
2225
const styles = props.styles?.operations;
2326

2427
const OperationTriggerIcon = operationTriggerIcon ?? Cog;
2528

2629
const onLocationChange = (e) => {
2730
const location = e.target.innerText;
31+
console.log(location);
2832
if (!location) {
29-
document.getElementById("stk-location-name").innerText = locationPlaceholder;
30-
return store.dispatch(setLocation(locationPlaceholder));
33+
document.getElementById(ids.location).innerText = inputPlaceholder;
34+
return store.dispatch(setLocation(inputPlaceholder));
3135
}
3236
store.dispatch(setLocation(location));
3337
};
@@ -58,13 +62,13 @@ const Operations: React.FC<ISTKProps> = ({
5862
suppressContentEditableWarning={true}
5963
className={twMerge(
6064
"text-xl font-bold outline-none",
61-
location === locationPlaceholder && "opacity-60",
65+
location === inputPlaceholder && "opacity-60",
6266
styles?.input?.className
6367
)}
6468
style={styles?.input?.properties}
6569
onInput={onLocationChange}
6670
>
67-
{locationPlaceholder}
71+
{inputPlaceholder}
6872
</Body>
6973
<div className="flex justify-between items-center gap-5">
7074
{showGridSwitch && <GridSwitch className="mr-2" />}

src/hooks/events/deletion.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const useDelete = () => {
1010
const handler = (e) => {
1111
if (e.key === "Backspace" || e.key === "Delete") {
1212
if (!document.querySelectorAll("input:focus").length) {
13-
e.preventDefault();
1413
store.dispatch(deleteElements(selectedElementIds));
1514
}
1615
}

src/types/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export interface ISTKProps {
8484
maxSeatSelectionCount?: number;
8585
/** Maximum size of an image which can be added to the workspace in bytes */
8686
maxImageSize?: number;
87+
/** Overrides the default input placeholder at the top left corner of the screen */
88+
locationInputPlaceholder?: string;
8789
};
8890
plugins?: IPlugins;
8991
}

0 commit comments

Comments
 (0)