@fileverse-dev/fortune-core 1.0.10 → 1.0.11

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.
@@ -12,6 +12,7 @@ import _ from "lodash";
12
12
  import { mergeBorder } from "./cell";
13
13
  import { getFlowdata } from "../context";
14
14
  import { colLocation, rowLocation } from "./location";
15
+ import { isAllowEdit } from "../utils";
15
16
  export function getArrowCanvasSize(fromX, fromY, toX, toY) {
16
17
  var left = toX - 5;
17
18
  if (fromX < toX) {
@@ -195,6 +196,8 @@ export function removeEditingComment(ctx, globalCache) {
195
196
  }
196
197
  export function newComment(ctx, globalCache, r, c) {
197
198
  var _a, _b;
199
+ var allowEdit = isAllowEdit(ctx);
200
+ if (!allowEdit) return;
198
201
  if (((_b = (_a = ctx.hooks).beforeInsertComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
199
202
  return;
200
203
  }
@@ -228,6 +231,8 @@ export function newComment(ctx, globalCache, r, c) {
228
231
  }
229
232
  export function editComment(ctx, globalCache, r, c) {
230
233
  var _a;
234
+ var allowEdit = isAllowEdit(ctx);
235
+ if (!allowEdit) return;
231
236
  var flowdata = getFlowdata(ctx);
232
237
  removeEditingComment(ctx, globalCache);
233
238
  var comment = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
@@ -246,6 +251,8 @@ export function editComment(ctx, globalCache, r, c) {
246
251
  }
247
252
  export function deleteComment(ctx, globalCache, r, c) {
248
253
  var _a, _b;
254
+ var allowEdit = isAllowEdit(ctx);
255
+ if (!allowEdit) return;
249
256
  if (((_b = (_a = ctx.hooks).beforeDeleteComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
250
257
  return;
251
258
  }
@@ -443,6 +450,7 @@ export function onCommentBoxResizeStart(ctx, globalCache, e, _a, resizingId, res
443
450
  }
444
451
  }
445
452
  export function onCommentBoxResize(ctx, globalCache, e) {
453
+ if (ctx.allowEdit === false) return false;
446
454
  var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
447
455
  if ((commentBox === null || commentBox === void 0 ? void 0 : commentBox.resizingId) && commentBox.resizingSide) {
448
456
  var box = document.getElementById(commentBox.resizingId);
@@ -545,6 +553,8 @@ export function onCommentBoxMoveStart(ctx, globalCache, e, _a, movingId) {
545
553
  }
546
554
  }
547
555
  export function onCommentBoxMove(ctx, globalCache, e) {
556
+ var allowEdit = isAllowEdit(ctx);
557
+ if (!allowEdit) return false;
548
558
  var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
549
559
  if (commentBox === null || commentBox === void 0 ? void 0 : commentBox.movingId) {
550
560
  var box = document.getElementById(commentBox.movingId);
@@ -29,6 +29,7 @@ var _lodash = _interopRequireDefault(require("lodash"));
29
29
  var _cell = require("./cell");
30
30
  var _context = require("../context");
31
31
  var _location = require("./location");
32
+ var _utils = require("../utils");
32
33
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
33
34
  var __assign = void 0 && (void 0).__assign || function () {
34
35
  __assign = Object.assign || function (t) {
@@ -223,6 +224,8 @@ function removeEditingComment(ctx, globalCache) {
223
224
  }
224
225
  function newComment(ctx, globalCache, r, c) {
225
226
  var _a, _b;
227
+ var allowEdit = (0, _utils.isAllowEdit)(ctx);
228
+ if (!allowEdit) return;
226
229
  if (((_b = (_a = ctx.hooks).beforeInsertComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
227
230
  return;
228
231
  }
@@ -256,6 +259,8 @@ function newComment(ctx, globalCache, r, c) {
256
259
  }
257
260
  function editComment(ctx, globalCache, r, c) {
258
261
  var _a;
262
+ var allowEdit = (0, _utils.isAllowEdit)(ctx);
263
+ if (!allowEdit) return;
259
264
  var flowdata = (0, _context.getFlowdata)(ctx);
260
265
  removeEditingComment(ctx, globalCache);
261
266
  var comment = (_a = flowdata === null || flowdata === void 0 ? void 0 : flowdata[r][c]) === null || _a === void 0 ? void 0 : _a.ps;
@@ -274,6 +279,8 @@ function editComment(ctx, globalCache, r, c) {
274
279
  }
275
280
  function deleteComment(ctx, globalCache, r, c) {
276
281
  var _a, _b;
282
+ var allowEdit = (0, _utils.isAllowEdit)(ctx);
283
+ if (!allowEdit) return;
277
284
  if (((_b = (_a = ctx.hooks).beforeDeleteComment) === null || _b === void 0 ? void 0 : _b.call(_a, r, c)) === false) {
278
285
  return;
279
286
  }
@@ -471,6 +478,7 @@ function onCommentBoxResizeStart(ctx, globalCache, e, _a, resizingId, resizingSi
471
478
  }
472
479
  }
473
480
  function onCommentBoxResize(ctx, globalCache, e) {
481
+ if (ctx.allowEdit === false) return false;
474
482
  var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
475
483
  if ((commentBox === null || commentBox === void 0 ? void 0 : commentBox.resizingId) && commentBox.resizingSide) {
476
484
  var box = document.getElementById(commentBox.resizingId);
@@ -573,6 +581,8 @@ function onCommentBoxMoveStart(ctx, globalCache, e, _a, movingId) {
573
581
  }
574
582
  }
575
583
  function onCommentBoxMove(ctx, globalCache, e) {
584
+ var allowEdit = (0, _utils.isAllowEdit)(ctx);
585
+ if (!allowEdit) return false;
576
586
  var commentBox = globalCache === null || globalCache === void 0 ? void 0 : globalCache.commentBox;
577
587
  if (commentBox === null || commentBox === void 0 ? void 0 : commentBox.movingId) {
578
588
  var box = document.getElementById(commentBox.movingId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",