From 5983cb015e092e2edc1d3f27dba2d585fb4db099 Mon Sep 17 00:00:00 2001 From: dushusir <1414556676@qq.com> Date: Tue, 22 Dec 2020 17:56:57 +0800 Subject: [PATCH] fix(feature): functionButton 1.fix functionButton 2.remove undefined request 3.add rangePasteBefore hook fix #336 fix #381 --- docs/guide/api.md | 10 ++++++++++ docs/zh/guide/api.md | 12 ++++++++++++ src/controllers/constant.js | 17 +++++++++-------- src/controllers/handler.js | 6 ++++++ src/css/luckysheet-core.css | 2 +- src/global/method.js | 3 +++ src/index.html | 6 +++++- 7 files changed, 46 insertions(+), 10 deletions(-) diff --git a/docs/guide/api.md b/docs/guide/api.md index f21dfe4..4a48752 100644 --- a/docs/guide/api.md +++ b/docs/guide/api.md @@ -319,6 +319,16 @@ Use note: Pay special attention to the setting of `range` in `setting` only when `isRange` is set to `true`, which is different from the general range format. + If you want to use this API to set the freeze after the workbook is initialized, you can execute it in the hook function after the workbook is created, such as: + ```js + luckysheet.create({ + hook:{ + workbookCreateAfter:function(){ + luckysheet.setBothFrozen(false); + } + } + }); + - **Usage**: - Frozen ranks diff --git a/docs/zh/guide/api.md b/docs/zh/guide/api.md index f20295c..6535c57 100644 --- a/docs/zh/guide/api.md +++ b/docs/zh/guide/api.md @@ -320,6 +320,18 @@ Luckysheet针对常用的数据操作需求,开放了主要功能的API,开 冻结行列操作 特别注意,只有在`isRange`设置为`true`的时候,才需要设置`setting`中的`range`,且与一般的range格式不同。 + + 如果想在工作簿初始化后使用此API设置冻结,可以在工作簿创建后的钩子函数中执行,比如: + ```js + luckysheet.create({ + hook:{ + workbookCreateAfter:function(){ + luckysheet.setBothFrozen(false); + } + } + }); + + ``` - **示例**: diff --git a/src/controllers/constant.js b/src/controllers/constant.js index aade632..67b6d9a 100644 --- a/src/controllers/constant.js +++ b/src/controllers/constant.js @@ -7,7 +7,7 @@ const gridHTML = function(){ const _locale = locale(); const locale_info = _locale.info; const locale_print = _locale.print; - const userInfo = luckysheetConfigsetting.userInfo === true ? ' Lucky' : luckysheetConfigsetting.userInfo; // When true, use the default HTML string + const userInfo = luckysheetConfigsetting.userInfo === true ? ' Lucky' : luckysheetConfigsetting.userInfo; // When true, use the default HTML string. The rendering of userInfo below uses nested template strings. Otherwise, when display is used and the image path is not passed in, there will be an undefined request return `
@@ -23,14 +23,15 @@ const gridHTML = function(){
${locale_info.detailUpdate}
${locale_info.wait}
-
\${functionButton} - ${userInfo} -
+ \${functionButton} + + ${getObjType(userInfo) === 'string' ? `
+ ${userInfo}
` : ''} -
\${functionButton} - - ${userInfo.userName} -
+ ${getObjType(userInfo) === 'object' ? `
+ + ${userInfo.userName} +
` : ''}
\${menu}
diff --git a/src/controllers/handler.js b/src/controllers/handler.js index 98d5885..dd983f6 100644 --- a/src/controllers/handler.js +++ b/src/controllers/handler.js @@ -5294,6 +5294,12 @@ export default function luckysheetHandler() { const locale_fontjson = locale().fontjson; + + // hook + if(!method.createHookFunction('rangePasteBefore',Store.luckysheet_select_save,txtdata)){ + return; + } + if (txtdata.indexOf("luckysheet_copy_action_table") > - 1 && Store.luckysheet_copy_save["copyRange"] != null && Store.luckysheet_copy_save["copyRange"].length > 0 && isEqual) { //剪切板内容 和 luckysheet本身复制的内容 一致 if (Store.luckysheet_paste_iscut) { diff --git a/src/css/luckysheet-core.css b/src/css/luckysheet-core.css index de50539..ee59f6f 100644 --- a/src/css/luckysheet-core.css +++ b/src/css/luckysheet-core.css @@ -122,7 +122,7 @@ .luckysheet_info_detail_save { color: #828282; font-size: 12px; - margin-left: 5px; + margin:0 5px; } .luckysheet-share-logo { diff --git a/src/global/method.js b/src/global/method.js index f576ba4..9d7eab8 100644 --- a/src/global/method.js +++ b/src/global/method.js @@ -491,6 +491,9 @@ const method = { dataVerificationCtrl[key] = defaultDataVerification[key]; } } + + // remove proxy + Store.asyncLoad = ['core']; }, editorChart:function(c){ let chart_selection_color = luckyColor[0]; diff --git a/src/index.html b/src/index.html index d463da7..a64c409 100644 --- a/src/index.html +++ b/src/index.html @@ -71,7 +71,7 @@ loadUrl: location.origin + "/luckysheet/api/load", loadSheetUrl: location.origin + "/luckysheet/api/loadsheet" } - }else{ + }else{ // http://localhost:3000/ options = { container: 'luckysheet', @@ -165,6 +165,10 @@ workbookCreateAfter:function(json){ // console.info(json) }, + rangePasteBefore:function(range,data){ + // console.info('rangePasteBefore',range,data) + // return false; //Can intercept paste + }, },