Skip to content

Commit 808f403

Browse files
committed
Editing sparks
1 parent a140ade commit 808f403

File tree

14 files changed

+515
-97
lines changed

14 files changed

+515
-97
lines changed

package-lock.json

Lines changed: 150 additions & 56 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"@astrojs/check": "^0.9.4",
1919
"@astrojs/react": "^3.6.2",
2020
"@astrojs/tailwind": "^5.1.2",
21+
"@radix-ui/react-alert-dialog": "^1.1.2",
2122
"@radix-ui/react-dialog": "^1.1.1",
2223
"@radix-ui/react-icons": "^1.3.0",
2324
"@radix-ui/react-select": "^2.1.2",

src/assets/icons/EditIcon.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
type IconProps = {
2+
className?: string;
3+
overrideDefaultClassName?: boolean;
4+
};
5+
6+
export const EditIcon = (props: IconProps) => {
7+
const { className, overrideDefaultClassName } = props;
8+
return (
9+
<svg
10+
xmlns="http://www.w3.org/2000/svg"
11+
fill="none"
12+
viewBox="0 0 24 24"
13+
strokeWidth={1.5}
14+
stroke="currentColor"
15+
className={
16+
overrideDefaultClassName ? className : `size-5 ${className}`
17+
}
18+
role="presentation"
19+
>
20+
<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" />
21+
<path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />
22+
</svg>
23+
);
24+
};

src/assets/icons/TrashIcon.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
type IconProps = {
2+
className?: string;
3+
overrideDefaultClassName?: boolean;
4+
};
5+
6+
export const TrashIcon = (props: IconProps) => {
7+
const { className, overrideDefaultClassName } = props;
8+
return (
9+
<svg
10+
xmlns="http://www.w3.org/2000/svg"
11+
fill="none"
12+
viewBox="0 0 24 24"
13+
strokeWidth={1.5}
14+
stroke="currentColor"
15+
className={
16+
overrideDefaultClassName ? className : `size-5 ${className}`
17+
}
18+
role="presentation"
19+
>
20+
<polyline points="3 6 5 6 21 6" />
21+
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />
22+
<line
23+
x1="10"
24+
y1="11"
25+
x2="10"
26+
y2="17"
27+
/>
28+
<line
29+
x1="14"
30+
y1="11"
31+
x2="14"
32+
y2="17"
33+
/>
34+
</svg>
35+
);
36+
};

src/common/components/TextInput/TextInput.config.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ export const getExtensions = (settings: Settings) => {
158158
},
159159

160160
onExit() {
161-
popup.destroy();
161+
if (!popup.state.isDestroyed) {
162+
popup.destroy();
163+
}
162164
component.destroy();
163165
},
164166
};
@@ -249,7 +251,9 @@ export const getExtensions = (settings: Settings) => {
249251
},
250252

251253
onExit() {
252-
popup.destroy();
254+
if (!popup.state.isDestroyed) {
255+
popup.destroy();
256+
}
253257
component.destroy();
254258
},
255259
};

src/common/components/TextInput/TextInput.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import "./TextInput.css";
44
import { parseSpark } from "../../../scripts/utils/stringUtils";
55
import { isUserSelectingTag } from "./TagList/TagList";
66
import { isUserSelectingExtension } from "./SparkExtensionList/SparkExtensionList";
7+
import { useEffect } from "react";
78

89
export type TextInputProps = {
910
onSubmit?: (plainText: string, html: string) => void;
@@ -12,6 +13,7 @@ export type TextInputProps = {
1213
onChange?: (htmlString: string) => void;
1314
style?: keyof typeof styleMap;
1415
placeholder?: string;
16+
content?: string;
1517
};
1618

1719
let editor: Editor | null = null;
@@ -28,9 +30,11 @@ export const TextInput = (props: TextInputProps) => {
2830
allowAddingTags = true,
2931
onChange,
3032
style = "spark",
33+
content,
3134
placeholder,
3235
} = props;
3336
editor = useEditor({
37+
content,
3438
extensions: getExtensions({
3539
parentWindow: parentWindow ?? window,
3640
allowAddingTags,

0 commit comments

Comments
 (0)