diff --git a/src/controllers/selection.js b/src/controllers/selection.js index e4d5164..d0045a8 100644 --- a/src/controllers/selection.js +++ b/src/controllers/selection.js @@ -514,26 +514,26 @@ const selection = { Store.iscopyself = true; if (!clipboardData) { - // let textarea = $("#luckysheet-copy-content"); - // textarea.html(cpdata); - // textarea.focus(); - // textarea.select(); - // document.execCommand("selectAll"); - // document.execCommand("Copy"); + let textarea = $("#luckysheet-copy-content"); + textarea.html(cpdata); + textarea.focus(); + textarea.select(); + document.execCommand("selectAll"); + document.execCommand("Copy"); // 等50毫秒,keyPress事件发生了再去处理数据 - // setTimeout(function () { - // $("#luckysheet-copy-content").blur(); - // }, 10); - - var oInput = document.createElement('input'); - oInput.setAttribute('readonly', 'readonly'); - oInput.value = cpdata; - document.body.appendChild(oInput); - oInput.select(); // 选择对象 - document.execCommand("Copy"); - oInput.style.display='none'; - document.body.removeChild(oInput); + setTimeout(function () { + $("#luckysheet-copy-content").blur(); + }, 10); + + // var oInput = document.createElement('input'); + // oInput.setAttribute('readonly', 'readonly'); + // oInput.value = cpdata; + // document.body.appendChild(oInput); + // oInput.select(); // 选择对象 + // document.execCommand("Copy"); + // oInput.style.display='none'; + // document.body.removeChild(oInput); } else { clipboardData.setData('Text', cpdata); diff --git a/src/global/extend.js b/src/global/extend.js index 087415e..b2475db 100644 --- a/src/global/extend.js +++ b/src/global/extend.js @@ -13,6 +13,7 @@ import Store from '../store'; //增加行列 function luckysheetextendtable(type, index, value, direction, sheetIndex) { + console.log(type, index, value, direction, sheetIndex) sheetIndex = sheetIndex || Store.currentSheetIndex; if(type=='row' && !checkProtectionAuthorityNormal(sheetIndex, "insertRows")){ @@ -627,9 +628,12 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { } //空行模板 - let row = []; + let row = [], + curRow = [...d][index] for(let c = 0; c < d[0].length; c++){ - row.push(null); + let cell = curRow[c], + templateCell = cell ? {...cell, v: '', m: ''} : Store.defaultCell; + row.push(templateCell); } //边框 @@ -779,9 +783,12 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { } //空列模板 - let col = []; + let col = [], + curd= [...d]; for(let r = 0; r < d.length; r++){ - col.push(null); + let cell = curd[r][index], + templateCell = cell ? {...cell, v: '', m: ''} : Store.defaultCell; + col.push(templateCell); } //边框 @@ -892,6 +899,7 @@ function luckysheetextendtable(type, index, value, direction, sheetIndex) { newDataVerification, newHyperlink ); + } else{ file.data = d; diff --git a/src/store/index.js b/src/store/index.js index d057a6a..27d1ec2 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -150,6 +150,20 @@ const Store = { // Resources that currently need to be loaded asynchronously, especially plugins. 'Core' marks the core rendering process. asyncLoad:['core'], + // 默认单元格 + defaultCell: { + bg: null, + bl: 0, + ct: {fa: "General", t: "n"}, + fc: "rgb(51, 51, 51)", + ff: 0, + fs: 11, + ht: 1, + it: 0, + vt: 1, + m: '', + v: '' + } }