Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 适配链接跳转的判断方式 #1983

Merged
merged 8 commits into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/s2-core/__tests__/spreadsheet/row-link-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ describe('Row Text Link Tests', () => {

expect(linkFieldJump).toBeCalledWith({
key: 'province',
cellData: rowNode,
record: {
province: '浙江',
type: '笔',
Expand Down Expand Up @@ -124,6 +125,7 @@ describe('Row Text Link Tests', () => {

expect(linkFieldJump).toBeCalledWith({
key: 'city',
cellData: rowNode,
record: {
province: '浙江',
city: '义乌1',
Expand Down Expand Up @@ -152,6 +154,7 @@ describe('Row Text Link Tests', () => {

expect(linkFieldJump).toBeCalledWith({
key: 'province',
cellData: rowNode,
record: {
province: '四川',
type: '笔',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ describe('Interaction Data Cell Click Tests', () => {

expect(linkFieldJump).toHaveBeenCalledWith({
key: mockCellData.valueField,
cellData: mockCellData,
record: mockCellData.data,
});
expect(s2.showTooltipWithInfo).not.toHaveBeenCalled();
Expand Down
6 changes: 4 additions & 2 deletions packages/s2-core/src/cell/row-cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,10 @@ export class RowCell extends HeaderCell {
protected drawLinkFieldShape() {
const { linkFields = [] } = this.headerConfig;
const { linkTextFill } = this.getTextStyle();

super.drawLinkFieldShape(linkFields.includes(this.meta.key), linkTextFill);
const isLinkField = linkFields.some(
lijinke666 marked this conversation as resolved.
Show resolved Hide resolved
(field) => field === this.meta.key || field === this.meta.id,
);
super.drawLinkFieldShape(isLinkField, linkTextFill);
}

protected drawRectBorder() {
Expand Down
1 change: 1 addition & 0 deletions packages/s2-core/src/common/interface/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export interface EmitterType {
/** ================ Cell ================ */
[S2Event.GLOBAL_LINK_FIELD_JUMP]: (data: {
key: string;
cellData: Node;
record: Data;
}) => void;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export class DataCellClick extends BaseEvent implements BaseEventImplement {

this.spreadsheet.emit(S2Event.GLOBAL_LINK_FIELD_JUMP, {
key,
cellData,
record: Object.assign({ rowIndex: cellData.rowIndex }, record),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class RowTextClick extends BaseEvent implements BaseEventImplement {

this.spreadsheet.emit(S2Event.GLOBAL_LINK_FIELD_JUMP, {
key,
cellData,
record: rowData,
});
});
Expand Down
4 changes: 2 additions & 2 deletions s2-site/docs/api/components/sheet-component.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ order: 0
| onMouseUp | 表格鼠标松开事件 | (event: CanvasEvent) => void | | |
| onSelected | 单元格选中事件 | (cells: ( [Cell](/docs/api/basic-class/base-cell)[] ) => void | | |
| onReset | 交互状态重置事件 | (event: KeyboardEvent) => void | | |
| onLinkFieldJump | 链接字段跳转事件 | (data: { key: string; record: [Data](/docs/api/general/S2DataConfig#data) }) => void | | |
| onLinkFieldJump | 链接字段跳转事件 (cellData: @antv/s2 1.37.0 新增) | (data: { key: string; cellData: [Node](/docs/api/basic-class/node); record: [Data](/docs/api/general/S2DataConfig#data) }) => void | | |
| onScroll | 单元格滚动事件 (含行头和数值单元格) | ({position: [CellScrollPosition](#cellscrollposition)} ) => void; | | |
| onColCellBrushSelection | 批量选中刷选范围内的列头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表) | (cells: [ColCell](/docs/api/basic-class/base-cell)[]) => void; | | |
| onRowCellBrushSelection | 批量选中刷选范围内的行头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表) | (cells: [RowCell](/docs/api/basic-class/base-cell)[]) => void; | | |
Expand Down Expand Up @@ -217,7 +217,7 @@ type SheetComponentOptions = S2Options<
| mouseUp | 表格鼠标松开事件 | (event: CanvasEvent) => void | | |
| selected | 单元格选中事件 | ( cells: ([Cell](/docs/api/basic-class/base-cell)[] ) => void | | |
| reset | 交互状态重置事件 | (event: KeyboardEvent) => void | | |
| linkFieldJump | 链接字段跳转事件 | (data: { key: string; record: [Data](/docs/api/general/S2DataConfig#data) }) => void | | |
| linkFieldJump | 链接字段跳转事件 (cellData: @antv/s2 1.37.0 新增) | (data: { key: string; cellData: [Node](/docs/api/basic-class/node); record: [Data](/docs/api/general/S2DataConfig#data) }) => void | | |
| scroll | 单元格滚动事件 (含行头和数值单元格) | ({position: [CellScrollPosition](#cellscrollposition)} ) => void; | | |
| colCellBrushSelection | 批量选中刷选范围内的列头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表) | (cells: ColCell[]) => void; | | |
| rowCellBrushSelection | 批量选中刷选范围内的行头单元格,刷选过程中,显示刷选范围提示蒙层,刷选完成后,弹出 tooltip, 展示被刷选单元格信息(仅支持透视表) | (cells: RowCell[]) => void; | | |
Expand Down