Merge pull request #12999 from vvlladd28/bug/js-editor/init-component
Fixed init js-func component
This commit is contained in:
commit
8baa86b1dc
@ -336,7 +336,7 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
}
|
}
|
||||||
|
|
||||||
private updatedScriptLanguage() {
|
private updatedScriptLanguage() {
|
||||||
this.jsEditor.session.setMode(`ace/mode/${ScriptLanguage.TBEL === this.scriptLanguage ? 'tbel' : 'javascript'}`);
|
this.jsEditor?.session?.setMode(`ace/mode/${ScriptLanguage.TBEL === this.scriptLanguage ? 'tbel' : 'javascript'}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
validateOnSubmit(): Observable<void> {
|
validateOnSubmit(): Observable<void> {
|
||||||
@ -582,7 +582,7 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
|
|
||||||
private updateHighlightRules(): void {
|
private updateHighlightRules(): void {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!!this.jsEditor.session.$mode) {
|
if (!!this.jsEditor?.session?.$mode) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const newMode = new this.jsEditor.session.$mode.constructor();
|
const newMode = new this.jsEditor.session.$mode.constructor();
|
||||||
newMode.$highlightRules = new newMode.HighlightRules();
|
newMode.$highlightRules = new newMode.HighlightRules();
|
||||||
@ -598,7 +598,7 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
if (this.scriptLanguage === ScriptLanguage.TBEL) {
|
if (this.scriptLanguage === ScriptLanguage.TBEL) {
|
||||||
newMode.$highlightRules.$rules.start = [...tbelUtilsFuncHighlightRules, ...newMode.$highlightRules.$rules.start];
|
newMode.$highlightRules.$rules.start = [...tbelUtilsFuncHighlightRules, ...newMode.$highlightRules.$rules.start];
|
||||||
}
|
}
|
||||||
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => rule.token?.includes('identifier'));
|
const identifierRule = newMode.$highlightRules.$rules.no_regex.find(rule => Array.isArray(rule.token) && rule.token.includes('identifier'));
|
||||||
if (identifierRule && identifierRule.next === 'no_regex') {
|
if (identifierRule && identifierRule.next === 'no_regex') {
|
||||||
identifierRule.next = 'start';
|
identifierRule.next = 'start';
|
||||||
}
|
}
|
||||||
@ -609,7 +609,7 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
|
|
||||||
private updateJsWorkerGlobals() {
|
private updateJsWorkerGlobals() {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
if (!!this.jsEditor.session.$worker) {
|
if (!!this.jsEditor?.session?.$worker) {
|
||||||
const jsWorkerOptions = {
|
const jsWorkerOptions = {
|
||||||
undef: !this.disableUndefinedCheck,
|
undef: !this.disableUndefinedCheck,
|
||||||
unused: true,
|
unused: true,
|
||||||
@ -638,6 +638,9 @@ export class JsFuncComponent implements OnInit, OnChanges, OnDestroy, ControlVal
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateCompleters() {
|
updateCompleters() {
|
||||||
|
if (!this.jsEditor) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let modulesCompleterObservable: Observable<TbEditorCompleter>;
|
let modulesCompleterObservable: Observable<TbEditorCompleter>;
|
||||||
if (this.withModules) {
|
if (this.withModules) {
|
||||||
modulesCompleterObservable = loadModulesCompleter(this.http, this.modules);
|
modulesCompleterObservable = loadModulesCompleter(this.http, this.modules);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user