From c624a0e75ed7464240539567bc6634ef16aab73d Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 17 May 2022 13:56:44 +0800 Subject: [PATCH] refactor: use jsepCurlyHook from nocodb-sdk --- .../components/editColumn/FormulaOptions.vue | 5 ++-- packages/nc-gui/helpers/formulaCurlyHook.js | 24 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) delete mode 100644 packages/nc-gui/helpers/formulaCurlyHook.js diff --git a/packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue b/packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue index 60aff9e658..429e335155 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editColumn/FormulaOptions.vue @@ -95,9 +95,8 @@ import debounce from 'debounce' import jsep from 'jsep' -import { UITypes } from 'nocodb-sdk' +import { UITypes, jsepCurlyHook } from 'nocodb-sdk' import formulaList, { validations } from '../../../../../helpers/formulaList' -import curly from '../../../../../helpers/formulaCurlyHook' import { getWordUntilCaret, insertAtCursor } from '@/helpers' import NcAutocompleteTree from '@/helpers/NcAutocompleteTree' @@ -162,7 +161,7 @@ export default { }, created() { this.formula = { value: this.value || '' } - jsep.plugins.register(curly) + jsep.plugins.register(jsepCurlyHook) }, methods: { async save() { diff --git a/packages/nc-gui/helpers/formulaCurlyHook.js b/packages/nc-gui/helpers/formulaCurlyHook.js deleted file mode 100644 index 3661b088f6..0000000000 --- a/packages/nc-gui/helpers/formulaCurlyHook.js +++ /dev/null @@ -1,24 +0,0 @@ -const OCURLY_CODE = 123; // { -const CCURLY_CODE = 125; // } - -export default { - name: 'curly', - init(jsep) { - jsep.hooks.add('gobble-token', function gobbleCurlyLiteral(env) { - const { context } = env - if (!jsep.isIdentifierStart(context.code) && context.code === OCURLY_CODE) { - context.index += 1 - let nodes = context.gobbleExpressions(CCURLY_CODE) - if (context.code === CCURLY_CODE) { - context.index += 1 - if (nodes.length > 0) { - env.node = nodes[0] - } - return env.node - } else { - context.throwError('Unclosed }') - } - } - }); - } -} \ No newline at end of file