mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 16:21:25 +02:00
Variable value as title attr
This commit is contained in:
@@ -5,9 +5,11 @@ import { BetterMatchDecorator } from '../BetterMatchDecorator';
|
|||||||
class PlaceholderWidget extends WidgetType {
|
class PlaceholderWidget extends WidgetType {
|
||||||
constructor(
|
constructor(
|
||||||
readonly name: string,
|
readonly name: string,
|
||||||
|
readonly value: string,
|
||||||
readonly exists: boolean,
|
readonly exists: boolean,
|
||||||
readonly type: 'function' | 'variable' = 'variable',
|
readonly type: 'function' | 'variable' = 'variable',
|
||||||
) {
|
) {
|
||||||
|
console.log('PLACEHOLDER', { name, value });
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +26,7 @@ class PlaceholderWidget extends WidgetType {
|
|||||||
? 'x-theme-placeholder--primary'
|
? 'x-theme-placeholder--primary'
|
||||||
: 'x-theme-placeholder--info'
|
: 'x-theme-placeholder--info'
|
||||||
}`;
|
}`;
|
||||||
elt.title = !this.exists ? 'Variable not found in active environment' : '';
|
elt.title = !this.exists ? 'Variable not found in active environment' : this.value ?? '';
|
||||||
elt.textContent = this.name;
|
elt.textContent = this.name;
|
||||||
return elt;
|
return elt;
|
||||||
}
|
}
|
||||||
@@ -34,7 +36,7 @@ class PlaceholderWidget extends WidgetType {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const placeholders = function (variables: { name: string }[]) {
|
export const placeholders = function (variables: { name: string; value?: string }[]) {
|
||||||
const placeholderMatcher = new BetterMatchDecorator({
|
const placeholderMatcher = new BetterMatchDecorator({
|
||||||
regexp: /\$\{\[\s*([^\]\s]+)\s*]}/g,
|
regexp: /\$\{\[\s*([^\]\s]+)\s*]}/g,
|
||||||
decoration(match, view, matchStartPos) {
|
decoration(match, view, matchStartPos) {
|
||||||
@@ -59,6 +61,7 @@ export const placeholders = function (variables: { name: string }[]) {
|
|||||||
inclusive: true,
|
inclusive: true,
|
||||||
widget: new PlaceholderWidget(
|
widget: new PlaceholderWidget(
|
||||||
groupMatch,
|
groupMatch,
|
||||||
|
variables.find((v) => v.name === groupMatch)?.value ?? '',
|
||||||
isFunction ? true : variables.some((v) => v.name === groupMatch),
|
isFunction ? true : variables.some((v) => v.name === groupMatch),
|
||||||
isFunction ? 'function' : 'variable',
|
isFunction ? 'function' : 'variable',
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user