fixed highlight bug

This commit is contained in:
mpetrov 2025-02-24 11:00:12 +02:00
parent 353459aa90
commit 25f5027135
4 changed files with 29 additions and 16 deletions

View File

@ -139,7 +139,7 @@ export class CalculatedFieldTestArgumentsComponent extends PageComponent impleme
private getValue(): CalculatedFieldEventArguments { private getValue(): CalculatedFieldEventArguments {
return this.argumentsFormArray.getRawValue().reduce((acc, rowItem) => { return this.argumentsFormArray.getRawValue().reduce((acc, rowItem) => {
const { argumentName, rollingJson = {}, ...value } = rowItem; const { argumentName, rollingJson = {}, ...value } = rowItem;
acc[argumentName] = { ...rollingJson, ...value}; acc[argumentName] = { ...rollingJson, ...value };
return acc; return acc;
}, {}); }, {});
} }

View File

@ -31,7 +31,12 @@ import {
} from '@home/components/widget/lib/scada/scada-symbol.models'; } from '@home/components/widget/lib/scada/scada-symbol.models';
import { TbEditorCompletion, TbEditorCompletions } from '@shared/models/ace/completion.models'; import { TbEditorCompletion, TbEditorCompletions } from '@shared/models/ace/completion.models';
import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe'; import { CustomTranslatePipe } from '@shared/pipe/custom-translate.pipe';
import { AceHighlightRule, AceHighlightRules } from '@shared/models/ace/ace.models'; import {
AceHighlightRule,
AceHighlightRules,
dotOperatorHighlightRule,
endGroupHighlightRule
} from '@shared/models/ace/ace.models';
import { HelpLinks, ValueType } from '@shared/models/constants'; import { HelpLinks, ValueType } from '@shared/models/constants';
import { formPropertyCompletions } from '@shared/models/dynamic-form.models'; import { formPropertyCompletions } from '@shared/models/dynamic-form.models';
import ITooltipsterInstance = JQueryTooltipster.ITooltipsterInstance; import ITooltipsterInstance = JQueryTooltipster.ITooltipsterInstance;
@ -921,17 +926,6 @@ export class ScadaSymbolElement {
const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/; const identifierRe = /[a-zA-Z$_\u00a1-\uffff][a-zA-Z\d$_\u00a1-\uffff]*/;
const dotOperatorHighlightRule: AceHighlightRule = {
token: 'punctuation.operator',
regex: /[.](?![.])/,
};
const endGroupHighlightRule: AceHighlightRule = {
regex: '',
token: 'empty',
next: 'no_regex'
};
const scadaSymbolCtxObjectHighlightRule: AceHighlightRule = { const scadaSymbolCtxObjectHighlightRule: AceHighlightRule = {
token: 'tb.scada-symbol-ctx', token: 'tb.scada-symbol-ctx',
regex: /\bctx\b/, regex: /\bctx\b/,

View File

@ -365,5 +365,16 @@ export interface AceHighlightRule {
next?: string; next?: string;
} }
export const dotOperatorHighlightRule: AceHighlightRule = {
token: 'punctuation.operator',
regex: /[.](?![.])/,
};
export const endGroupHighlightRule: AceHighlightRule = {
regex: '',
token: 'empty',
next: 'no_regex'
};

View File

@ -28,7 +28,11 @@ import { EntityType } from '@shared/models/entity-type.models';
import { AliasFilterType } from '@shared/models/alias.models'; import { AliasFilterType } from '@shared/models/alias.models';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { TbEditorCompleter } from '@shared/models/ace/completion.models'; import { TbEditorCompleter } from '@shared/models/ace/completion.models';
import { AceHighlightRules } from '@shared/models/ace/ace.models'; import {
AceHighlightRules,
dotOperatorHighlightRule,
endGroupHighlightRule
} from '@shared/models/ace/ace.models';
export interface CalculatedField extends Omit<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasTenantId, ExportableEntity<CalculatedFieldId> { export interface CalculatedField extends Omit<BaseData<CalculatedFieldId>, 'label'>, HasVersion, HasTenantId, ExportableEntity<CalculatedFieldId> {
debugSettings?: EntityDebugSettings; debugSettings?: EntityDebugSettings;
@ -337,6 +341,7 @@ export const getCalculatedFieldArgumentsHighlights = (
const calculatedFieldSingleArgumentValueHighlightRules: AceHighlightRules = { const calculatedFieldSingleArgumentValueHighlightRules: AceHighlightRules = {
calculatedFieldSingleArgumentValue: [ calculatedFieldSingleArgumentValue: [
dotOperatorHighlightRule,
{ {
token: 'tb.calculated-field-value', token: 'tb.calculated-field-value',
regex: /value/, regex: /value/,
@ -346,12 +351,14 @@ const calculatedFieldSingleArgumentValueHighlightRules: AceHighlightRules = {
token: 'tb.calculated-field-ts', token: 'tb.calculated-field-ts',
regex: /ts/, regex: /ts/,
next: 'no_regex' next: 'no_regex'
} },
endGroupHighlightRule
], ],
} }
const calculatedFieldRollingArgumentValueHighlightRules: AceHighlightRules = { const calculatedFieldRollingArgumentValueHighlightRules: AceHighlightRules = {
calculatedFieldRollingArgumentValue: [ calculatedFieldRollingArgumentValue: [
dotOperatorHighlightRule,
{ {
token: 'tb.calculated-field-values', token: 'tb.calculated-field-values',
regex: /values/, regex: /values/,
@ -361,7 +368,8 @@ const calculatedFieldRollingArgumentValueHighlightRules: AceHighlightRules = {
token: 'tb.calculated-field-time-window', token: 'tb.calculated-field-time-window',
regex: /timeWindow/, regex: /timeWindow/,
next: 'calculatedFieldRollingArgumentTimeWindow' next: 'calculatedFieldRollingArgumentTimeWindow'
} },
endGroupHighlightRule
], ],
} }