@fileverse-dev/fortune-core 1.0.81 → 1.0.82
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/events/keyboard.js +23 -2
- package/es/modules/selection.d.ts +2 -0
- package/es/modules/selection.js +99 -0
- package/lib/events/keyboard.js +21 -0
- package/lib/modules/selection.d.ts +2 -0
- package/lib/modules/selection.js +101 -0
- package/package.json +1 -1
package/es/events/keyboard.js
CHANGED
|
@@ -3,8 +3,8 @@ import { hideCRCount, removeActiveImage } from "..";
|
|
|
3
3
|
import { getFlowdata } from "../context";
|
|
4
4
|
import { updateCell, cancelNormalSelected } from "../modules/cell";
|
|
5
5
|
import { handleFormulaInput } from "../modules/formula";
|
|
6
|
-
import { copy, deleteSelectedCellText, moveHighlightCell, moveHighlightRange, selectAll, selectionCache } from "../modules/selection";
|
|
7
|
-
import { cancelPaintModel, handleBold } from "../modules/toolbar";
|
|
6
|
+
import { copy, deleteSelectedCellText, deleteSelectedCellFormat, textFormat, moveHighlightCell, moveHighlightRange, selectAll, selectionCache } from "../modules/selection";
|
|
7
|
+
import { cancelPaintModel, handleBold, handleItalic, handleUnderline } from "../modules/toolbar";
|
|
8
8
|
import { hasPartMC } from "../modules/validation";
|
|
9
9
|
import { getNowDateTime, getSheetIndex, isAllowEdit } from "../utils";
|
|
10
10
|
import { handleCopy } from "./copy";
|
|
@@ -119,6 +119,7 @@ function handleControlPlusArrowKey(ctx, e, shiftPressed) {
|
|
|
119
119
|
}
|
|
120
120
|
export function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo) {
|
|
121
121
|
var _a, _b, _c, _d;
|
|
122
|
+
console.log(e.key, e.code);
|
|
122
123
|
var flowdata = getFlowdata(ctx);
|
|
123
124
|
if (!flowdata) return;
|
|
124
125
|
if (e.shiftKey) {
|
|
@@ -146,6 +147,12 @@ export function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handl
|
|
|
146
147
|
handleControlPlusArrowKey(ctx, e, false);
|
|
147
148
|
} else if (e.code === "KeyB") {
|
|
148
149
|
handleBold(ctx, cellInput);
|
|
150
|
+
} else if (e.code === "KeyI") {
|
|
151
|
+
handleItalic(ctx, cellInput);
|
|
152
|
+
} else if (e.code === "KeyU") {
|
|
153
|
+
handleUnderline(ctx, cellInput);
|
|
154
|
+
} else if (e.code === 'Backslash') {
|
|
155
|
+
deleteSelectedCellFormat(ctx);
|
|
149
156
|
} else if (e.code === "KeyC") {
|
|
150
157
|
handleCopy(ctx);
|
|
151
158
|
e.stopPropagation();
|
|
@@ -250,6 +257,19 @@ export function handleArrowKey(ctx, e) {
|
|
|
250
257
|
}
|
|
251
258
|
export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
|
|
252
259
|
var _a;
|
|
260
|
+
if (e.shiftKey && e.code === 'Space') {
|
|
261
|
+
e.stopImmediatePropagation();
|
|
262
|
+
e.stopPropagation();
|
|
263
|
+
e.preventDefault();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
|
|
267
|
+
textFormat(ctx, 'center');
|
|
268
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
|
|
269
|
+
textFormat(ctx, 'left');
|
|
270
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
|
|
271
|
+
textFormat(ctx, 'right');
|
|
272
|
+
}
|
|
253
273
|
ctx.luckysheet_select_status = false;
|
|
254
274
|
var kcode = e.keyCode;
|
|
255
275
|
var kstr = e.key;
|
|
@@ -325,6 +345,7 @@ export function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUnd
|
|
|
325
345
|
}
|
|
326
346
|
}
|
|
327
347
|
}
|
|
348
|
+
console.log('kkkk');
|
|
328
349
|
if (cellInput !== document.activeElement) {
|
|
329
350
|
cellInput === null || cellInput === void 0 ? void 0 : cellInput.focus();
|
|
330
351
|
}
|
|
@@ -24,6 +24,8 @@ export declare function moveHighlightRange(ctx: Context, postion: "down" | "righ
|
|
|
24
24
|
export declare function rangeValueToHtml(ctx: Context, sheetId: string, ranges?: Range): string | null;
|
|
25
25
|
export declare function copy(ctx: Context): void;
|
|
26
26
|
export declare function deleteSelectedCellText(ctx: Context): string;
|
|
27
|
+
export declare function deleteSelectedCellFormat(ctx: Context): string;
|
|
28
|
+
export declare function textFormat(ctx: Context, type: 'left' | 'center' | 'right'): string;
|
|
27
29
|
export declare function selectIsOverlap(ctx: Context, range?: any): boolean;
|
|
28
30
|
export declare function selectAll(ctx: Context): void;
|
|
29
31
|
export declare function fixRowStyleOverflowInFreeze(ctx: Context, r1: number, r2: number, freeze: Freezen | undefined): {
|
package/es/modules/selection.js
CHANGED
|
@@ -1538,6 +1538,105 @@ export function deleteSelectedCellText(ctx) {
|
|
|
1538
1538
|
}
|
|
1539
1539
|
return "success";
|
|
1540
1540
|
}
|
|
1541
|
+
export function deleteSelectedCellFormat(ctx) {
|
|
1542
|
+
var allowEdit = isAllowEdit(ctx);
|
|
1543
|
+
if (allowEdit === false) {
|
|
1544
|
+
return "allowEdit";
|
|
1545
|
+
}
|
|
1546
|
+
var selection = ctx.luckysheet_select_save;
|
|
1547
|
+
if (selection && !_.isEmpty(selection)) {
|
|
1548
|
+
var d = getFlowdata(ctx);
|
|
1549
|
+
if (!d) return "dataNullError";
|
|
1550
|
+
var has_PartMC = false;
|
|
1551
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1552
|
+
var r1 = selection[s].row[0];
|
|
1553
|
+
var r2 = selection[s].row[1];
|
|
1554
|
+
var c1 = selection[s].column[0];
|
|
1555
|
+
var c2 = selection[s].column[1];
|
|
1556
|
+
if (hasPartMC(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1557
|
+
has_PartMC = true;
|
|
1558
|
+
break;
|
|
1559
|
+
}
|
|
1560
|
+
}
|
|
1561
|
+
if (has_PartMC) {
|
|
1562
|
+
return "partMC";
|
|
1563
|
+
}
|
|
1564
|
+
var hyperlinkMap = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink;
|
|
1565
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1566
|
+
var r1 = selection[s].row[0];
|
|
1567
|
+
var r2 = selection[s].row[1];
|
|
1568
|
+
var c1 = selection[s].column[0];
|
|
1569
|
+
var c2 = selection[s].column[1];
|
|
1570
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1571
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1572
|
+
if (_.isPlainObject(d[r][c])) {
|
|
1573
|
+
var cell = d[r][c];
|
|
1574
|
+
if (cell.ct) {
|
|
1575
|
+
delete cell.ct;
|
|
1576
|
+
delete cell.ff;
|
|
1577
|
+
delete cell.fs;
|
|
1578
|
+
delete cell.bl;
|
|
1579
|
+
delete cell.fc;
|
|
1580
|
+
delete cell.bg;
|
|
1581
|
+
delete cell.tb;
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
return "success";
|
|
1589
|
+
}
|
|
1590
|
+
export function textFormat(ctx, type) {
|
|
1591
|
+
var allowEdit = isAllowEdit(ctx);
|
|
1592
|
+
if (allowEdit === false) {
|
|
1593
|
+
return "allowEdit";
|
|
1594
|
+
}
|
|
1595
|
+
var selection = ctx.luckysheet_select_save;
|
|
1596
|
+
if (selection && !_.isEmpty(selection)) {
|
|
1597
|
+
var d = getFlowdata(ctx);
|
|
1598
|
+
if (!d) return "dataNullError";
|
|
1599
|
+
var has_PartMC = false;
|
|
1600
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1601
|
+
var r1 = selection[s].row[0];
|
|
1602
|
+
var r2 = selection[s].row[1];
|
|
1603
|
+
var c1 = selection[s].column[0];
|
|
1604
|
+
var c2 = selection[s].column[1];
|
|
1605
|
+
if (hasPartMC(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1606
|
+
has_PartMC = true;
|
|
1607
|
+
break;
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
if (has_PartMC) {
|
|
1611
|
+
return "partMC";
|
|
1612
|
+
}
|
|
1613
|
+
var hyperlinkMap = ctx.luckysheetfile[getSheetIndex(ctx, ctx.currentSheetId)].hyperlink;
|
|
1614
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1615
|
+
var r1 = selection[s].row[0];
|
|
1616
|
+
var r2 = selection[s].row[1];
|
|
1617
|
+
var c1 = selection[s].column[0];
|
|
1618
|
+
var c2 = selection[s].column[1];
|
|
1619
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1620
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1621
|
+
if (_.isPlainObject(d[r][c])) {
|
|
1622
|
+
var cell = d[r][c];
|
|
1623
|
+
if (type === 'left') {
|
|
1624
|
+
cell.tb = "2";
|
|
1625
|
+
cell.ht = 1;
|
|
1626
|
+
} else if (type === "center") {
|
|
1627
|
+
cell.tb = "2";
|
|
1628
|
+
cell.ht = 0;
|
|
1629
|
+
} else if (type === 'right') {
|
|
1630
|
+
cell.tb = "2";
|
|
1631
|
+
cell.ht = 2;
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
return "success";
|
|
1639
|
+
}
|
|
1541
1640
|
export function selectIsOverlap(ctx, range) {
|
|
1542
1641
|
return false;
|
|
1543
1642
|
}
|
package/lib/events/keyboard.js
CHANGED
|
@@ -129,6 +129,7 @@ function handleControlPlusArrowKey(ctx, e, shiftPressed) {
|
|
|
129
129
|
}
|
|
130
130
|
function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo, handleRedo) {
|
|
131
131
|
var _a, _b, _c, _d;
|
|
132
|
+
console.log(e.key, e.code);
|
|
132
133
|
var flowdata = (0, _context.getFlowdata)(ctx);
|
|
133
134
|
if (!flowdata) return;
|
|
134
135
|
if (e.shiftKey) {
|
|
@@ -156,6 +157,12 @@ function handleWithCtrlOrMetaKey(ctx, cache, e, cellInput, fxInput, handleUndo,
|
|
|
156
157
|
handleControlPlusArrowKey(ctx, e, false);
|
|
157
158
|
} else if (e.code === "KeyB") {
|
|
158
159
|
(0, _toolbar.handleBold)(ctx, cellInput);
|
|
160
|
+
} else if (e.code === "KeyI") {
|
|
161
|
+
(0, _toolbar.handleItalic)(ctx, cellInput);
|
|
162
|
+
} else if (e.code === "KeyU") {
|
|
163
|
+
(0, _toolbar.handleUnderline)(ctx, cellInput);
|
|
164
|
+
} else if (e.code === 'Backslash') {
|
|
165
|
+
(0, _selection.deleteSelectedCellFormat)(ctx);
|
|
159
166
|
} else if (e.code === "KeyC") {
|
|
160
167
|
(0, _copy.handleCopy)(ctx);
|
|
161
168
|
e.stopPropagation();
|
|
@@ -260,6 +267,19 @@ function handleArrowKey(ctx, e) {
|
|
|
260
267
|
}
|
|
261
268
|
function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, handleRedo, canvas) {
|
|
262
269
|
var _a;
|
|
270
|
+
if (e.shiftKey && e.code === 'Space') {
|
|
271
|
+
e.stopImmediatePropagation();
|
|
272
|
+
e.stopPropagation();
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyE") {
|
|
277
|
+
(0, _selection.textFormat)(ctx, 'center');
|
|
278
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyL") {
|
|
279
|
+
(0, _selection.textFormat)(ctx, 'left');
|
|
280
|
+
} else if ((e.ctrlKey || e.metaKey && e.shiftKey) && e.code === "KeyR") {
|
|
281
|
+
(0, _selection.textFormat)(ctx, 'right');
|
|
282
|
+
}
|
|
263
283
|
ctx.luckysheet_select_status = false;
|
|
264
284
|
var kcode = e.keyCode;
|
|
265
285
|
var kstr = e.key;
|
|
@@ -335,6 +355,7 @@ function handleGlobalKeyDown(ctx, cellInput, fxInput, e, cache, handleUndo, hand
|
|
|
335
355
|
}
|
|
336
356
|
}
|
|
337
357
|
}
|
|
358
|
+
console.log('kkkk');
|
|
338
359
|
if (cellInput !== document.activeElement) {
|
|
339
360
|
cellInput === null || cellInput === void 0 ? void 0 : cellInput.focus();
|
|
340
361
|
}
|
|
@@ -24,6 +24,8 @@ export declare function moveHighlightRange(ctx: Context, postion: "down" | "righ
|
|
|
24
24
|
export declare function rangeValueToHtml(ctx: Context, sheetId: string, ranges?: Range): string | null;
|
|
25
25
|
export declare function copy(ctx: Context): void;
|
|
26
26
|
export declare function deleteSelectedCellText(ctx: Context): string;
|
|
27
|
+
export declare function deleteSelectedCellFormat(ctx: Context): string;
|
|
28
|
+
export declare function textFormat(ctx: Context, type: 'left' | 'center' | 'right'): string;
|
|
27
29
|
export declare function selectIsOverlap(ctx: Context, range?: any): boolean;
|
|
28
30
|
export declare function selectAll(ctx: Context): void;
|
|
29
31
|
export declare function fixRowStyleOverflowInFreeze(ctx: Context, r1: number, r2: number, freeze: Freezen | undefined): {
|
package/lib/modules/selection.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.calcSelectionInfo = calcSelectionInfo;
|
|
7
7
|
exports.colHasMerged = colHasMerged;
|
|
8
8
|
exports.copy = copy;
|
|
9
|
+
exports.deleteSelectedCellFormat = deleteSelectedCellFormat;
|
|
9
10
|
exports.deleteSelectedCellText = deleteSelectedCellText;
|
|
10
11
|
exports.fixColumnStyleOverflowInFreeze = fixColumnStyleOverflowInFreeze;
|
|
11
12
|
exports.fixRowStyleOverflowInFreeze = fixRowStyleOverflowInFreeze;
|
|
@@ -25,6 +26,7 @@ exports.selectTitlesRange = selectTitlesRange;
|
|
|
25
26
|
exports.selectionCache = void 0;
|
|
26
27
|
exports.selectionCopyShow = selectionCopyShow;
|
|
27
28
|
exports.seletedHighlistByindex = seletedHighlistByindex;
|
|
29
|
+
exports.textFormat = textFormat;
|
|
28
30
|
var _lodash = _interopRequireWildcard(require("lodash"));
|
|
29
31
|
var _context = require("../context");
|
|
30
32
|
var _cell = require("./cell");
|
|
@@ -1567,6 +1569,105 @@ function deleteSelectedCellText(ctx) {
|
|
|
1567
1569
|
}
|
|
1568
1570
|
return "success";
|
|
1569
1571
|
}
|
|
1572
|
+
function deleteSelectedCellFormat(ctx) {
|
|
1573
|
+
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1574
|
+
if (allowEdit === false) {
|
|
1575
|
+
return "allowEdit";
|
|
1576
|
+
}
|
|
1577
|
+
var selection = ctx.luckysheet_select_save;
|
|
1578
|
+
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
1579
|
+
var d = (0, _context.getFlowdata)(ctx);
|
|
1580
|
+
if (!d) return "dataNullError";
|
|
1581
|
+
var has_PartMC = false;
|
|
1582
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1583
|
+
var r1 = selection[s].row[0];
|
|
1584
|
+
var r2 = selection[s].row[1];
|
|
1585
|
+
var c1 = selection[s].column[0];
|
|
1586
|
+
var c2 = selection[s].column[1];
|
|
1587
|
+
if ((0, _validation.hasPartMC)(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1588
|
+
has_PartMC = true;
|
|
1589
|
+
break;
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
if (has_PartMC) {
|
|
1593
|
+
return "partMC";
|
|
1594
|
+
}
|
|
1595
|
+
var hyperlinkMap = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].hyperlink;
|
|
1596
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1597
|
+
var r1 = selection[s].row[0];
|
|
1598
|
+
var r2 = selection[s].row[1];
|
|
1599
|
+
var c1 = selection[s].column[0];
|
|
1600
|
+
var c2 = selection[s].column[1];
|
|
1601
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1602
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1603
|
+
if (_lodash.default.isPlainObject(d[r][c])) {
|
|
1604
|
+
var cell = d[r][c];
|
|
1605
|
+
if (cell.ct) {
|
|
1606
|
+
delete cell.ct;
|
|
1607
|
+
delete cell.ff;
|
|
1608
|
+
delete cell.fs;
|
|
1609
|
+
delete cell.bl;
|
|
1610
|
+
delete cell.fc;
|
|
1611
|
+
delete cell.bg;
|
|
1612
|
+
delete cell.tb;
|
|
1613
|
+
}
|
|
1614
|
+
}
|
|
1615
|
+
}
|
|
1616
|
+
}
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
return "success";
|
|
1620
|
+
}
|
|
1621
|
+
function textFormat(ctx, type) {
|
|
1622
|
+
var allowEdit = (0, _utils.isAllowEdit)(ctx);
|
|
1623
|
+
if (allowEdit === false) {
|
|
1624
|
+
return "allowEdit";
|
|
1625
|
+
}
|
|
1626
|
+
var selection = ctx.luckysheet_select_save;
|
|
1627
|
+
if (selection && !_lodash.default.isEmpty(selection)) {
|
|
1628
|
+
var d = (0, _context.getFlowdata)(ctx);
|
|
1629
|
+
if (!d) return "dataNullError";
|
|
1630
|
+
var has_PartMC = false;
|
|
1631
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1632
|
+
var r1 = selection[s].row[0];
|
|
1633
|
+
var r2 = selection[s].row[1];
|
|
1634
|
+
var c1 = selection[s].column[0];
|
|
1635
|
+
var c2 = selection[s].column[1];
|
|
1636
|
+
if ((0, _validation.hasPartMC)(ctx, ctx.config, r1, r2, c1, c2)) {
|
|
1637
|
+
has_PartMC = true;
|
|
1638
|
+
break;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
if (has_PartMC) {
|
|
1642
|
+
return "partMC";
|
|
1643
|
+
}
|
|
1644
|
+
var hyperlinkMap = ctx.luckysheetfile[(0, _utils.getSheetIndex)(ctx, ctx.currentSheetId)].hyperlink;
|
|
1645
|
+
for (var s = 0; s < selection.length; s += 1) {
|
|
1646
|
+
var r1 = selection[s].row[0];
|
|
1647
|
+
var r2 = selection[s].row[1];
|
|
1648
|
+
var c1 = selection[s].column[0];
|
|
1649
|
+
var c2 = selection[s].column[1];
|
|
1650
|
+
for (var r = r1; r <= r2; r += 1) {
|
|
1651
|
+
for (var c = c1; c <= c2; c += 1) {
|
|
1652
|
+
if (_lodash.default.isPlainObject(d[r][c])) {
|
|
1653
|
+
var cell = d[r][c];
|
|
1654
|
+
if (type === 'left') {
|
|
1655
|
+
cell.tb = "2";
|
|
1656
|
+
cell.ht = 1;
|
|
1657
|
+
} else if (type === "center") {
|
|
1658
|
+
cell.tb = "2";
|
|
1659
|
+
cell.ht = 0;
|
|
1660
|
+
} else if (type === 'right') {
|
|
1661
|
+
cell.tb = "2";
|
|
1662
|
+
cell.ht = 2;
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
}
|
|
1669
|
+
return "success";
|
|
1670
|
+
}
|
|
1570
1671
|
function selectIsOverlap(ctx, range) {
|
|
1571
1672
|
return false;
|
|
1572
1673
|
}
|