Browse Source
Merge pull request #1075 from salmoro/add-custom-functions
Allow to dynamically add custom functions at runtime
master
mengshukeji
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
9 additions and
4 deletions
-
src/core.js
-
src/function/functionlist.js
|
|
@ -126,6 +126,7 @@ luckysheet.create = function (setting) { |
|
|
|
luckysheetConfigsetting.workbookCreateBefore = extendsetting.workbookCreateBefore; |
|
|
|
luckysheetConfigsetting.workbookCreateAfter = extendsetting.workbookCreateAfter; |
|
|
|
luckysheetConfigsetting.remoteFunction = extendsetting.remoteFunction; |
|
|
|
luckysheetConfigsetting.customFunctions = extendsetting.customFunctions; |
|
|
|
|
|
|
|
luckysheetConfigsetting.fireMousedown = extendsetting.fireMousedown; |
|
|
|
luckysheetConfigsetting.forceCalculation = extendsetting.forceCalculation; |
|
|
@ -156,7 +157,7 @@ luckysheet.create = function (setting) { |
|
|
|
initPlugins(extendsetting.plugins , extendsetting.data); |
|
|
|
|
|
|
|
// Store formula information, including internationalization
|
|
|
|
functionlist(); |
|
|
|
functionlist(extendsetting.customFunctions); |
|
|
|
|
|
|
|
let devicePixelRatio = extendsetting.devicePixelRatio; |
|
|
|
if(devicePixelRatio == null){ |
|
|
|
|
|
@ -3,10 +3,10 @@ import Store from '../store/index' |
|
|
|
import locale from '../locale/locale'; |
|
|
|
//{"0":"数学","1":"统计","2":"查找","3":"Luckysheet内置","4":"数据挖掘","5":"数据源","6":"日期","7":"过滤器","8":"财务","9":"工程计算","10":"逻辑","11":"运算符","12":"文本","13":"转换工具","14":"数组"}
|
|
|
|
|
|
|
|
const functionlist = function(){ |
|
|
|
const functionlist = function(customFunctions){ |
|
|
|
let _locale = locale(); |
|
|
|
// internationalization,get function list
|
|
|
|
let functionListOrigin = _locale.functionlist; |
|
|
|
let functionListOrigin = [..._locale.functionlist]; |
|
|
|
|
|
|
|
// add new property f
|
|
|
|
for (let i = 0; i < functionListOrigin.length; i++) { |
|
|
@ -14,6 +14,10 @@ const functionlist = function(){ |
|
|
|
func.f = functionImplementation[func.n]; |
|
|
|
} |
|
|
|
|
|
|
|
if (customFunctions) { |
|
|
|
functionListOrigin.push(...customFunctions); |
|
|
|
} |
|
|
|
|
|
|
|
Store.functionlist = functionListOrigin; |
|
|
|
|
|
|
|
// get n property
|
|
|
|