|
1 | 1 | <script lang="ts"> |
2 | 2 | import { RenderChildType } from 'packages/core/src/config/APIConfigs'; |
3 | | - import type { ButtonConfig } from 'packages/core/src/config/ButtonConfig'; |
| 3 | + import type { |
| 4 | + ButtonConfig, |
| 5 | + CommandButtonAction, |
| 6 | + CreateNoteButtonAction, |
| 7 | + InlineJSButtonAction, |
| 8 | + InputButtonAction, |
| 9 | + InsertIntoNoteButtonAction, |
| 10 | + JSButtonAction, |
| 11 | + OpenButtonAction, |
| 12 | + RegexpReplaceInNoteButtonAction, |
| 13 | + ReplaceInNoteButtonAction, |
| 14 | + ReplaceSelfButtonAction, |
| 15 | + RunTemplaterFileButtonAction, |
| 16 | + SleepButtonAction, |
| 17 | + TemplaterCreateNoteButtonAction, |
| 18 | + UpdateMetadataButtonAction, |
| 19 | + } from 'packages/core/src/config/ButtonConfig'; |
4 | 20 | import { ButtonActionType, ButtonStyleType } from 'packages/core/src/config/ButtonConfig'; |
5 | 21 | import { ButtonField } from 'packages/core/src/fields/button/ButtonField'; |
6 | 22 | import type { IPlugin } from 'packages/core/src/IPlugin'; |
@@ -196,72 +212,99 @@ Add action of type |
196 | 212 | </select> |
197 | 213 |
|
198 | 214 | <Button variant={ButtonStyleType.PRIMARY} onclick={() => addAction()}>Add Action</Button> |
199 | | - |
200 | | -{#each buttonConfig.actions ?? [] as action, i (i)} |
201 | | - <FlexRow> |
202 | | - <h5>{getActionLabel(action.type)}</h5> |
203 | | - <!-- eslint-disable-next-line @typescript-eslint/no-unsafe-argument --> |
204 | | - <Button variant={ButtonStyleType.PLAIN} onclick={e => openActionContextMenu(i, e)}> |
205 | | - <Icon iconName="more-vertical" plugin={plugin}></Icon> |
206 | | - </Button> |
207 | | - </FlexRow> |
208 | | - |
209 | | - {#if action.type === ButtonActionType.COMMAND} |
210 | | - <CommandActionSettings action={action} plugin={plugin}></CommandActionSettings> |
211 | | - {/if} |
212 | | - |
213 | | - {#if action.type === ButtonActionType.OPEN} |
214 | | - <OpenActionSettings action={action} plugin={plugin}></OpenActionSettings> |
215 | | - {/if} |
216 | | - |
217 | | - {#if action.type === ButtonActionType.JS} |
218 | | - <JSActionSettings action={action} plugin={plugin}></JSActionSettings> |
219 | | - {/if} |
220 | | - |
221 | | - {#if action.type === ButtonActionType.INPUT} |
222 | | - <InputActionSettings action={action} plugin={plugin}></InputActionSettings> |
223 | | - {/if} |
224 | | - |
225 | | - {#if action.type === ButtonActionType.SLEEP} |
226 | | - <SleepActionSettings action={action} plugin={plugin}></SleepActionSettings> |
227 | | - {/if} |
228 | | - |
229 | | - {#if action.type === ButtonActionType.TEMPLATER_CREATE_NOTE} |
230 | | - <TemplaterCreateNoteActionSettings action={action} plugin={plugin}></TemplaterCreateNoteActionSettings> |
231 | | - {/if} |
232 | | - |
233 | | - {#if action.type === ButtonActionType.UPDATE_METADATA} |
234 | | - <UpdateMetadataActionSettings action={action} plugin={plugin}></UpdateMetadataActionSettings> |
235 | | - {/if} |
236 | | - |
237 | | - {#if action.type === ButtonActionType.CREATE_NOTE} |
238 | | - <CreateNoteActionSettings action={action} plugin={plugin}></CreateNoteActionSettings> |
239 | | - {/if} |
240 | | - |
241 | | - {#if action.type === ButtonActionType.RUN_TEMPLATER_FILE} |
242 | | - <RunTemplaterFileActionSettings action={action} plugin={plugin}></RunTemplaterFileActionSettings> |
243 | | - {/if} |
244 | | - |
245 | | - {#if action.type === ButtonActionType.REPLACE_IN_NOTE} |
246 | | - <ReplaceInNoteActionSettings action={action} plugin={plugin}></ReplaceInNoteActionSettings> |
247 | | - {/if} |
248 | | - |
249 | | - {#if action.type === ButtonActionType.REGEXP_REPLACE_IN_NOTE} |
250 | | - <RegexpReplaceInNoteActionSettings action={action} plugin={plugin}></RegexpReplaceInNoteActionSettings> |
251 | | - {/if} |
252 | | - |
253 | | - {#if action.type === ButtonActionType.REPLACE_SELF} |
254 | | - <ReplaceSelfActionSettings action={action} plugin={plugin}></ReplaceSelfActionSettings> |
255 | | - {/if} |
256 | | - |
257 | | - {#if action.type === ButtonActionType.INSERT_INTO_NOTE} |
258 | | - <InsertIntoNoteActionSettings action={action} plugin={plugin}></InsertIntoNoteActionSettings> |
259 | | - {/if} |
260 | | - |
261 | | - {#if action.type === ButtonActionType.INLINE_JS} |
262 | | - <InlineJsActionSettings action={action} plugin={plugin}></InlineJsActionSettings> |
263 | | - {/if} |
264 | | -{/each} |
| 215 | +{#if buttonConfig.actions} |
| 216 | + {#each buttonConfig.actions ?? [] as action, i (i)} |
| 217 | + <FlexRow> |
| 218 | + <h5>{getActionLabel(action.type)}</h5> |
| 219 | + <!-- eslint-disable-next-line @typescript-eslint/no-unsafe-argument --> |
| 220 | + <Button variant={ButtonStyleType.PLAIN} onclick={e => openActionContextMenu(i, e)}> |
| 221 | + <Icon iconName="more-vertical" plugin={plugin}></Icon> |
| 222 | + </Button> |
| 223 | + </FlexRow> |
| 224 | + |
| 225 | + {#if action.type === ButtonActionType.COMMAND} |
| 226 | + <CommandActionSettings bind:action={buttonConfig.actions[i] as CommandButtonAction} plugin={plugin} |
| 227 | + ></CommandActionSettings> |
| 228 | + {/if} |
| 229 | + |
| 230 | + {#if action.type === ButtonActionType.OPEN} |
| 231 | + <OpenActionSettings bind:action={buttonConfig.actions[i] as OpenButtonAction} plugin={plugin} |
| 232 | + ></OpenActionSettings> |
| 233 | + {/if} |
| 234 | + |
| 235 | + {#if action.type === ButtonActionType.JS} |
| 236 | + <JSActionSettings bind:action={buttonConfig.actions[i] as JSButtonAction} plugin={plugin} |
| 237 | + ></JSActionSettings> |
| 238 | + {/if} |
| 239 | + |
| 240 | + {#if action.type === ButtonActionType.INPUT} |
| 241 | + <InputActionSettings bind:action={buttonConfig.actions[i] as InputButtonAction} plugin={plugin} |
| 242 | + ></InputActionSettings> |
| 243 | + {/if} |
| 244 | + |
| 245 | + {#if action.type === ButtonActionType.SLEEP} |
| 246 | + <SleepActionSettings bind:action={buttonConfig.actions[i] as SleepButtonAction} plugin={plugin} |
| 247 | + ></SleepActionSettings> |
| 248 | + {/if} |
| 249 | + |
| 250 | + {#if action.type === ButtonActionType.TEMPLATER_CREATE_NOTE} |
| 251 | + <TemplaterCreateNoteActionSettings |
| 252 | + bind:action={buttonConfig.actions[i] as TemplaterCreateNoteButtonAction} |
| 253 | + plugin={plugin} |
| 254 | + ></TemplaterCreateNoteActionSettings> |
| 255 | + {/if} |
| 256 | + |
| 257 | + {#if action.type === ButtonActionType.UPDATE_METADATA} |
| 258 | + <UpdateMetadataActionSettings |
| 259 | + bind:action={buttonConfig.actions[i] as UpdateMetadataButtonAction} |
| 260 | + plugin={plugin} |
| 261 | + ></UpdateMetadataActionSettings> |
| 262 | + {/if} |
| 263 | + |
| 264 | + {#if action.type === ButtonActionType.CREATE_NOTE} |
| 265 | + <CreateNoteActionSettings bind:action={buttonConfig.actions[i] as CreateNoteButtonAction} plugin={plugin} |
| 266 | + ></CreateNoteActionSettings> |
| 267 | + {/if} |
| 268 | + |
| 269 | + {#if action.type === ButtonActionType.RUN_TEMPLATER_FILE} |
| 270 | + <RunTemplaterFileActionSettings |
| 271 | + bind:action={buttonConfig.actions[i] as RunTemplaterFileButtonAction} |
| 272 | + plugin={plugin} |
| 273 | + ></RunTemplaterFileActionSettings> |
| 274 | + {/if} |
| 275 | + |
| 276 | + {#if action.type === ButtonActionType.REPLACE_IN_NOTE} |
| 277 | + <ReplaceInNoteActionSettings |
| 278 | + bind:action={buttonConfig.actions[i] as ReplaceInNoteButtonAction} |
| 279 | + plugin={plugin} |
| 280 | + ></ReplaceInNoteActionSettings> |
| 281 | + {/if} |
| 282 | + |
| 283 | + {#if action.type === ButtonActionType.REGEXP_REPLACE_IN_NOTE} |
| 284 | + <RegexpReplaceInNoteActionSettings |
| 285 | + bind:action={buttonConfig.actions[i] as RegexpReplaceInNoteButtonAction} |
| 286 | + plugin={plugin} |
| 287 | + ></RegexpReplaceInNoteActionSettings> |
| 288 | + {/if} |
| 289 | + |
| 290 | + {#if action.type === ButtonActionType.REPLACE_SELF} |
| 291 | + <ReplaceSelfActionSettings bind:action={buttonConfig.actions[i] as ReplaceSelfButtonAction} plugin={plugin} |
| 292 | + ></ReplaceSelfActionSettings> |
| 293 | + {/if} |
| 294 | + |
| 295 | + {#if action.type === ButtonActionType.INSERT_INTO_NOTE} |
| 296 | + <InsertIntoNoteActionSettings |
| 297 | + bind:action={buttonConfig.actions[i] as InsertIntoNoteButtonAction} |
| 298 | + plugin={plugin} |
| 299 | + ></InsertIntoNoteActionSettings> |
| 300 | + {/if} |
| 301 | + |
| 302 | + {#if action.type === ButtonActionType.INLINE_JS} |
| 303 | + <InlineJsActionSettings bind:action={buttonConfig.actions[i] as InlineJSButtonAction} plugin={plugin} |
| 304 | + ></InlineJsActionSettings> |
| 305 | + {/if} |
| 306 | + {/each} |
| 307 | +{/if} |
265 | 308 |
|
266 | 309 | <h4>Preview</h4> |
267 | 310 |
|
|
0 commit comments