@fileverse-dev/fortune-core 1.0.76 → 1.0.78

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.
@@ -1,3 +1,4 @@
1
1
  import { Context } from "../context";
2
+ export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
2
3
  export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
3
4
  export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
@@ -990,8 +990,20 @@ function handleFormulaStringPaste(ctx, formulaStr) {
990
990
  afterUpdateCell(r, c, null, cellTemp);
991
991
  }
992
992
  }
993
+ export function parseAsLinkIfUrl(txtdata, ctx) {
994
+ var _a, _b, _c, _d, _e, _f, _g;
995
+ var urlRegex = /^(https?:\/\/[^\s]+)/;
996
+ if (urlRegex.test(txtdata)) {
997
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
998
+ if (last) {
999
+ var rowIndex = (_d = (_b = last.row_focus) !== null && _b !== void 0 ? _b : (_c = last.row) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0;
1000
+ var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
1001
+ saveHyperlink(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1002
+ }
1003
+ }
1004
+ }
993
1005
  export function handlePaste(ctx, e) {
994
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
1006
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
995
1007
  var allowEdit = isAllowEdit(ctx);
996
1008
  if (!allowEdit) return;
997
1009
  if (selectionCache.isPasteAction) {
@@ -1002,6 +1014,10 @@ export function handlePaste(ctx, e) {
1002
1014
  clipboardData = window.clipboardData;
1003
1015
  }
1004
1016
  if (!clipboardData) return;
1017
+ var text = clipboardData.getData("text/plain");
1018
+ if (text) {
1019
+ parseAsLinkIfUrl(text, ctx);
1020
+ }
1005
1021
  var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1006
1022
  var isEqual = true;
1007
1023
  if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0) {
@@ -1356,15 +1372,7 @@ export function handlePaste(ctx, e) {
1356
1372
  var text = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData("text/plain");
1357
1373
  if (text) {
1358
1374
  document.execCommand("insertText", false, text);
1359
- var urlRegex = /^(https?:\/\/[^\s]+)/;
1360
- if (urlRegex.test(text)) {
1361
- var last = (_y = ctx.luckysheet_select_save) === null || _y === void 0 ? void 0 : _y[ctx.luckysheet_select_save.length - 1];
1362
- if (last) {
1363
- var rowIndex = (_1 = (_z = last.row_focus) !== null && _z !== void 0 ? _z : (_0 = last.row) === null || _0 === void 0 ? void 0 : _0[0]) !== null && _1 !== void 0 ? _1 : 0;
1364
- var colIndex = (_4 = (_2 = last.column_focus) !== null && _2 !== void 0 ? _2 : (_3 = last.column) === null || _3 === void 0 ? void 0 : _3[0]) !== null && _4 !== void 0 ? _4 : 0;
1365
- saveHyperlink(ctx, rowIndex, colIndex, text, "webpage", text);
1366
- }
1367
- }
1375
+ parseAsLinkIfUrl(text, ctx);
1368
1376
  }
1369
1377
  }
1370
1378
  }
@@ -1,3 +1,4 @@
1
1
  import { Context } from "../context";
2
+ export declare function parseAsLinkIfUrl(txtdata: string, ctx: Context): void;
2
3
  export declare function handlePaste(ctx: Context, e: ClipboardEvent): void;
3
4
  export declare function handlePasteByClick(ctx: Context, clipboardData: string, triggerType?: string): void;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.handlePaste = handlePaste;
7
7
  exports.handlePasteByClick = handlePasteByClick;
8
+ exports.parseAsLinkIfUrl = parseAsLinkIfUrl;
8
9
  var _lodash = _interopRequireDefault(require("lodash"));
9
10
  var _context = require("../context");
10
11
  var _locale = require("../locale");
@@ -998,8 +999,20 @@ function handleFormulaStringPaste(ctx, formulaStr) {
998
999
  afterUpdateCell(r, c, null, cellTemp);
999
1000
  }
1000
1001
  }
1002
+ function parseAsLinkIfUrl(txtdata, ctx) {
1003
+ var _a, _b, _c, _d, _e, _f, _g;
1004
+ var urlRegex = /^(https?:\/\/[^\s]+)/;
1005
+ if (urlRegex.test(txtdata)) {
1006
+ var last = (_a = ctx.luckysheet_select_save) === null || _a === void 0 ? void 0 : _a[ctx.luckysheet_select_save.length - 1];
1007
+ if (last) {
1008
+ var rowIndex = (_d = (_b = last.row_focus) !== null && _b !== void 0 ? _b : (_c = last.row) === null || _c === void 0 ? void 0 : _c[0]) !== null && _d !== void 0 ? _d : 0;
1009
+ var colIndex = (_g = (_e = last.column_focus) !== null && _e !== void 0 ? _e : (_f = last.column) === null || _f === void 0 ? void 0 : _f[0]) !== null && _g !== void 0 ? _g : 0;
1010
+ (0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, txtdata, "webpage", txtdata);
1011
+ }
1012
+ }
1013
+ }
1001
1014
  function handlePaste(ctx, e) {
1002
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
1015
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
1003
1016
  var allowEdit = (0, _utils.isAllowEdit)(ctx);
1004
1017
  if (!allowEdit) return;
1005
1018
  if (_selection.selectionCache.isPasteAction) {
@@ -1010,6 +1023,10 @@ function handlePaste(ctx, e) {
1010
1023
  clipboardData = window.clipboardData;
1011
1024
  }
1012
1025
  if (!clipboardData) return;
1026
+ var text = clipboardData.getData("text/plain");
1027
+ if (text) {
1028
+ parseAsLinkIfUrl(text, ctx);
1029
+ }
1013
1030
  var txtdata = clipboardData.getData("text/html") || clipboardData.getData("text/plain");
1014
1031
  var isEqual = true;
1015
1032
  if (txtdata.indexOf("fortune-copy-action-table") > -1 && ((_a = ctx.luckysheet_copy_save) === null || _a === void 0 ? void 0 : _a.copyRange) != null && ctx.luckysheet_copy_save.copyRange.length > 0) {
@@ -1364,15 +1381,7 @@ function handlePaste(ctx, e) {
1364
1381
  var text = clipboardData === null || clipboardData === void 0 ? void 0 : clipboardData.getData("text/plain");
1365
1382
  if (text) {
1366
1383
  document.execCommand("insertText", false, text);
1367
- var urlRegex = /^(https?:\/\/[^\s]+)/;
1368
- if (urlRegex.test(text)) {
1369
- var last = (_y = ctx.luckysheet_select_save) === null || _y === void 0 ? void 0 : _y[ctx.luckysheet_select_save.length - 1];
1370
- if (last) {
1371
- var rowIndex = (_1 = (_z = last.row_focus) !== null && _z !== void 0 ? _z : (_0 = last.row) === null || _0 === void 0 ? void 0 : _0[0]) !== null && _1 !== void 0 ? _1 : 0;
1372
- var colIndex = (_4 = (_2 = last.column_focus) !== null && _2 !== void 0 ? _2 : (_3 = last.column) === null || _3 === void 0 ? void 0 : _3[0]) !== null && _4 !== void 0 ? _4 : 0;
1373
- (0, _modules.saveHyperlink)(ctx, rowIndex, colIndex, text, "webpage", text);
1374
- }
1375
- }
1384
+ parseAsLinkIfUrl(text, ctx);
1376
1385
  }
1377
1386
  }
1378
1387
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fileverse-dev/fortune-core",
3
- "version": "1.0.76",
3
+ "version": "1.0.78",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dev": "father-build --watch"
16
16
  },
17
17
  "dependencies": {
18
- "@fileverse-dev/formula-parser": "0.2.48",
18
+ "@fileverse-dev/formula-parser": "0.2.49",
19
19
  "dayjs": "^1.11.0",
20
20
  "immer": "^9.0.12",
21
21
  "lodash": "^4.17.21",