@fileverse-dev/fortune-core 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/es/context.d.ts CHANGED
@@ -169,6 +169,7 @@ export type Context = {
169
169
  zoomRatio: number;
170
170
  showGridLines: boolean;
171
171
  allowEdit: boolean;
172
+ isFlvReadOnly: boolean;
172
173
  fontList: any[];
173
174
  defaultFontSize: number;
174
175
  luckysheetPaintModelOn: boolean;
package/es/context.js CHANGED
@@ -235,6 +235,7 @@ export function defaultContext(refs) {
235
235
  zoomRatio: 1,
236
236
  showGridLines: true,
237
237
  allowEdit: true,
238
+ isFlvReadOnly: false,
238
239
  fontList: [],
239
240
  defaultFontSize: 10,
240
241
  luckysheetPaintModelOn: false,
@@ -1,4 +1,4 @@
1
- import { colLocationByIndex, diff, getcellrange, getCellValue, getFlowdata, getRangeByTxt, getSheetIndex, isAllowEdit, iscelldata, isdatetime, isRealNull, isRealNum, jfrefreshgrid, mergeBorder, rowLocationByIndex, setCellValue } from "..";
1
+ import { colLocationByIndex, diff, getcellrange, getCellValue, getFlowdata, getRangeByTxt, getSheetIndex, isAllowEdit, isAllowEditReadOnly, iscelldata, isdatetime, isRealNull, isRealNum, jfrefreshgrid, mergeBorder, rowLocationByIndex, setCellValue } from "..";
2
2
  export function dataRangeSelection(ctx, cache, rangT, type, value) {
3
3
  var _a, _b;
4
4
  ctx.rangeDialog.show = true;
@@ -496,7 +496,8 @@ export function getHintText(ctx, item) {
496
496
  export function cellFocus(ctx, r, c, clickMode) {
497
497
  var _a, _b;
498
498
  var allowEdit = isAllowEdit(ctx);
499
- if (!allowEdit) return;
499
+ var isReadOnly = isAllowEditReadOnly(ctx);
500
+ if (!allowEdit || isReadOnly) return;
500
501
  var showHintBox = document.getElementById("luckysheet-dataVerification-showHintBox");
501
502
  var dropDownBtn = document.getElementById("luckysheet-dataVerification-dropdown-btn");
502
503
  ctx.dataVerificationDropDownList = false;
@@ -2,7 +2,7 @@ import _ from "lodash";
2
2
  import dayjs from "dayjs";
3
3
  import { getFlowdata } from "../context";
4
4
  import { colLocation, rowLocation } from "./location";
5
- import { getSheetIndex, isAllowEdit } from "../utils";
5
+ import { getSheetIndex, isAllowEdit, isAllowEditReadOnly } from "../utils";
6
6
  import { getBorderInfoCompute } from "./border";
7
7
  import { genarate, update } from "./format";
8
8
  import * as formula from "./formula";
@@ -1766,7 +1766,8 @@ export function updateDropCell(ctx) {
1766
1766
  var _e, _f, _g;
1767
1767
  var d = getFlowdata(ctx);
1768
1768
  var allowEdit = isAllowEdit(ctx);
1769
- if (allowEdit === false || d == null) {
1769
+ var isReadOnly = isAllowEditReadOnly(ctx);
1770
+ if (allowEdit === false || d == null || isReadOnly) {
1770
1771
  return;
1771
1772
  }
1772
1773
  var index = getSheetIndex(ctx, ctx.currentSheetId);
@@ -16,3 +16,4 @@ export declare function replaceHtml(temp: string, dataarry: any): string;
16
16
  export declare function getRegExpStr(str: string): string;
17
17
  export declare function chatatABC(n: number): string;
18
18
  export declare function isAllowEdit(ctx: Context, range?: Sheet["luckysheet_select_save"]): boolean;
19
+ export declare function isAllowEditReadOnly(ctx: Context, range?: Sheet["luckysheet_select_save"]): boolean;
package/es/utils/index.js CHANGED
@@ -170,4 +170,29 @@ export function isAllowEdit(ctx, range) {
170
170
  }
171
171
  return true;
172
172
  }) && (_.isUndefined(ctx.allowEdit) ? true : ctx.allowEdit);
173
+ }
174
+ export function isAllowEditReadOnly(ctx, range) {
175
+ var cfg = ctx.config;
176
+ var judgeRange = _.isUndefined(range) ? ctx.luckysheet_select_save : range;
177
+ return _.every(judgeRange, function (selection) {
178
+ var _a, _b;
179
+ for (var r = selection.row[0]; r <= selection.row[1]; r += 1) {
180
+ if ((_a = cfg.rowReadOnly) === null || _a === void 0 ? void 0 : _a[r]) {
181
+ return false;
182
+ }
183
+ }
184
+ for (var c = selection.column[0]; c <= selection.column[1]; c += 1) {
185
+ if ((_b = cfg.colReadOnly) === null || _b === void 0 ? void 0 : _b[c]) {
186
+ return false;
187
+ }
188
+ }
189
+ for (var r = selection.row[0]; r <= selection.row[1]; r += 1) {
190
+ for (var c = selection.column[0]; c <= selection.column[1]; c += 1) {
191
+ if (checkCellIsLocked(ctx, r, c, ctx.currentSheetId)) {
192
+ return false;
193
+ }
194
+ }
195
+ }
196
+ return true;
197
+ }) && (_.isUndefined(ctx.isFlvReadOnly) ? true : ctx.isFlvReadOnly);
173
198
  }
package/lib/context.d.ts CHANGED
@@ -169,6 +169,7 @@ export type Context = {
169
169
  zoomRatio: number;
170
170
  showGridLines: boolean;
171
171
  allowEdit: boolean;
172
+ isFlvReadOnly: boolean;
172
173
  fontList: any[];
173
174
  defaultFontSize: number;
174
175
  luckysheetPaintModelOn: boolean;
package/lib/context.js CHANGED
@@ -247,6 +247,7 @@ function defaultContext(refs) {
247
247
  zoomRatio: 1,
248
248
  showGridLines: true,
249
249
  allowEdit: true,
250
+ isFlvReadOnly: false,
250
251
  fontList: [],
251
252
  defaultFontSize: 10,
252
253
  luckysheetPaintModelOn: false,
@@ -511,7 +511,8 @@ function getHintText(ctx, item) {
511
511
  function cellFocus(ctx, r, c, clickMode) {
512
512
  var _a, _b;
513
513
  var allowEdit = (0, _.isAllowEdit)(ctx);
514
- if (!allowEdit) return;
514
+ var isReadOnly = (0, _.isAllowEditReadOnly)(ctx);
515
+ if (!allowEdit || isReadOnly) return;
515
516
  var showHintBox = document.getElementById("luckysheet-dataVerification-showHintBox");
516
517
  var dropDownBtn = document.getElementById("luckysheet-dataVerification-dropdown-btn");
517
518
  ctx.dataVerificationDropDownList = false;
@@ -1782,7 +1782,8 @@ function updateDropCell(ctx) {
1782
1782
  var _e, _f, _g;
1783
1783
  var d = (0, _context.getFlowdata)(ctx);
1784
1784
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1785
- if (allowEdit === false || d == null) {
1785
+ var isReadOnly = (0, _utils.isAllowEditReadOnly)(ctx);
1786
+ if (allowEdit === false || d == null || isReadOnly) {
1786
1787
  return;
1787
1788
  }
1788
1789
  var index = (0, _utils.getSheetIndex)(ctx, ctx.currentSheetId);
@@ -16,3 +16,4 @@ export declare function replaceHtml(temp: string, dataarry: any): string;
16
16
  export declare function getRegExpStr(str: string): string;
17
17
  export declare function chatatABC(n: number): string;
18
18
  export declare function isAllowEdit(ctx: Context, range?: Sheet["luckysheet_select_save"]): boolean;
19
+ export declare function isAllowEditReadOnly(ctx: Context, range?: Sheet["luckysheet_select_save"]): boolean;
@@ -17,7 +17,8 @@ var _exportNames = {
17
17
  replaceHtml: true,
18
18
  getRegExpStr: true,
19
19
  chatatABC: true,
20
- isAllowEdit: true
20
+ isAllowEdit: true,
21
+ isAllowEditReadOnly: true
21
22
  };
22
23
  exports.chatatABC = chatatABC;
23
24
  exports.columnCharToIndex = columnCharToIndex;
@@ -31,6 +32,7 @@ exports.getSheetIdByName = getSheetIdByName;
31
32
  exports.getSheetIndex = getSheetIndex;
32
33
  exports.indexToColumnChar = indexToColumnChar;
33
34
  exports.isAllowEdit = isAllowEdit;
35
+ exports.isAllowEditReadOnly = isAllowEditReadOnly;
34
36
  exports.replaceHtml = replaceHtml;
35
37
  exports.rgbToHex = rgbToHex;
36
38
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -228,4 +230,29 @@ function isAllowEdit(ctx, range) {
228
230
  }
229
231
  return true;
230
232
  }) && (_lodash.default.isUndefined(ctx.allowEdit) ? true : ctx.allowEdit);
233
+ }
234
+ function isAllowEditReadOnly(ctx, range) {
235
+ var cfg = ctx.config;
236
+ var judgeRange = _lodash.default.isUndefined(range) ? ctx.luckysheet_select_save : range;
237
+ return _lodash.default.every(judgeRange, function (selection) {
238
+ var _a, _b;
239
+ for (var r = selection.row[0]; r <= selection.row[1]; r += 1) {
240
+ if ((_a = cfg.rowReadOnly) === null || _a === void 0 ? void 0 : _a[r]) {
241
+ return false;
242
+ }
243
+ }
244
+ for (var c = selection.column[0]; c <= selection.column[1]; c += 1) {
245
+ if ((_b = cfg.colReadOnly) === null || _b === void 0 ? void 0 : _b[c]) {
246
+ return false;
247
+ }
248
+ }
249
+ for (var r = selection.row[0]; r <= selection.row[1]; r += 1) {
250
+ for (var c = selection.column[0]; c <= selection.column[1]; c += 1) {
251
+ if ((0, _modules.checkCellIsLocked)(ctx, r, c, ctx.currentSheetId)) {
252
+ return false;
253
+ }
254
+ }
255
+ }
256
+ return true;
257
+ }) && (_lodash.default.isUndefined(ctx.isFlvReadOnly) ? true : ctx.isFlvReadOnly);
231
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",