|
1 | 1 | import { Node } from "@xyflow/react"; |
2 | 2 | import { Plus, Trash2 } from "lucide-react"; |
3 | | -import { NodeData } from "./types"; |
| 3 | +import { NodeData, Resource } from "./types"; |
4 | 4 | import { getTranslations } from "./translations"; |
5 | 5 |
|
6 | 6 | interface Props { |
@@ -93,6 +93,17 @@ export function EditorDrawerTaskContent({ |
93 | 93 | placeholder={t.placeholderNodeLabel} |
94 | 94 | /> |
95 | 95 | </div> |
| 96 | + <div className="form-group"> |
| 97 | + <label>Font Size (px)</label> |
| 98 | + <input |
| 99 | + type="number" |
| 100 | + value={localNode.data.fontSize || 14} |
| 101 | + onChange={(e) => handleFieldChange("fontSize", parseInt(e.target.value) || 14)} |
| 102 | + placeholder="14" |
| 103 | + min="8" |
| 104 | + max="72" |
| 105 | + /> |
| 106 | + </div> |
96 | 107 | <div className="form-group"> |
97 | 108 | <label>{t.summary}</label> |
98 | 109 | <input |
@@ -131,27 +142,59 @@ export function EditorDrawerTaskContent({ |
131 | 142 | </div> |
132 | 143 | <div className="form-group"> |
133 | 144 | <label>{t.resources}</label> |
134 | | - {(localNode.data.resources || []).map((resource: { label: string; url: string }, idx: number) => ( |
135 | | - <div key={idx} style={{ display: "flex", gap: "8px", marginBottom: "8px" }}> |
136 | | - <input |
137 | | - type="text" |
138 | | - value={resource.label || ""} |
139 | | - onChange={(e) => handleResourceChange(idx, "label", e.target.value)} |
140 | | - placeholder={t.placeholderLabel} |
141 | | - style={{ flex: 1 }} |
142 | | - /> |
143 | | - <input |
144 | | - type="text" |
145 | | - value={resource.url || ""} |
146 | | - onChange={(e) => handleResourceChange(idx, "url", e.target.value)} |
147 | | - placeholder={t.placeholderURL} |
148 | | - style={{ flex: 2 }} |
149 | | - /> |
150 | | - <button onClick={() => removeResource(idx)} className="icon-button"> |
151 | | - <Trash2 size={16} /> |
152 | | - </button> |
153 | | - </div> |
154 | | - ))} |
| 145 | + {(localNode.data.resources || []).map((resource: Resource, idx: number) => { |
| 146 | + const isBook = resource.type === "book"; |
| 147 | + return ( |
| 148 | + <div key={idx} style={{ marginBottom: "16px", padding: "12px", border: "1px solid #e5e7eb", borderRadius: "6px" }}> |
| 149 | + <div style={{ display: "flex", gap: "8px", marginBottom: "8px" }}> |
| 150 | + <select |
| 151 | + value={resource.type || "url"} |
| 152 | + onChange={(e) => handleResourceChange(idx, "type", e.target.value)} |
| 153 | + style={{ flex: 0.5 }} |
| 154 | + > |
| 155 | + <option value="url">URL</option> |
| 156 | + <option value="book">Book</option> |
| 157 | + </select> |
| 158 | + <input |
| 159 | + type="text" |
| 160 | + value={resource.label || ""} |
| 161 | + onChange={(e) => handleResourceChange(idx, "label", e.target.value)} |
| 162 | + placeholder={t.placeholderLabel} |
| 163 | + style={{ flex: 1 }} |
| 164 | + /> |
| 165 | + <button onClick={() => removeResource(idx)} className="icon-button"> |
| 166 | + <Trash2 size={16} /> |
| 167 | + </button> |
| 168 | + </div> |
| 169 | + {isBook ? ( |
| 170 | + <> |
| 171 | + <input |
| 172 | + type="text" |
| 173 | + value={resource.bookName || ""} |
| 174 | + onChange={(e) => handleResourceChange(idx, "bookName", e.target.value)} |
| 175 | + placeholder="Book name (e.g., Lambacher Schweitzer GK)" |
| 176 | + style={{ width: "100%", marginBottom: "8px" }} |
| 177 | + /> |
| 178 | + <input |
| 179 | + type="text" |
| 180 | + value={resource.bookLocation || ""} |
| 181 | + onChange={(e) => handleResourceChange(idx, "bookLocation", e.target.value)} |
| 182 | + placeholder="Location (e.g., S. 223 Nr. 5)" |
| 183 | + style={{ width: "100%" }} |
| 184 | + /> |
| 185 | + </> |
| 186 | + ) : ( |
| 187 | + <input |
| 188 | + type="text" |
| 189 | + value={resource.url || ""} |
| 190 | + onChange={(e) => handleResourceChange(idx, "url", e.target.value)} |
| 191 | + placeholder={t.placeholderURL} |
| 192 | + style={{ width: "100%" }} |
| 193 | + /> |
| 194 | + )} |
| 195 | + </div> |
| 196 | + ); |
| 197 | + })} |
155 | 198 | <button onClick={addResource} className="secondary-button"> |
156 | 199 | <Plus size={16} /> {t.addResource} |
157 | 200 | </button> |
|
0 commit comments