mirror of
https://github.com/enso-org/enso.git
synced 2024-12-24 05:12:31 +03:00
Allow vector widget only on vector expressions. (#9596)
Fixes #9593 <img width="426" alt="image" src="https://github.com/enso-org/enso/assets/919491/a794a023-420d-4358-8068-252d8d136a57">
This commit is contained in:
parent
9db264231e
commit
84c8535587
@ -44,7 +44,7 @@ const navigator = injectGraphNavigator(true)
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export const widgetDefinition = defineWidget(WidgetInput.isAstOrPlaceholder, {
|
||||
export const widgetDefinition = defineWidget(WidgetInput.placeholderOrAstMatcher(Ast.Vector), {
|
||||
priority: 500,
|
||||
score: (props) =>
|
||||
props.input.dynamicConfig?.kind === 'Vector_Editor' ? Score.Perfect
|
||||
|
@ -36,6 +36,12 @@ export namespace WidgetInput {
|
||||
input.value instanceof nodeType
|
||||
}
|
||||
|
||||
/** Match input against a placeholder or specific AST node type. */
|
||||
export function placeholderOrAstMatcher<T extends Ast.Ast>(nodeType: new (...args: any[]) => T) {
|
||||
return (input: WidgetInput): input is WidgetInput & { value: T } =>
|
||||
isPlaceholder(input) || input.value instanceof nodeType
|
||||
}
|
||||
|
||||
export function isAst(input: WidgetInput): input is WidgetInput & { value: Ast.Ast } {
|
||||
return input.value instanceof Ast.Ast
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user