diff --git a/packages/s2-core/__tests__/spreadsheet/row-link-spec.ts b/packages/s2-core/__tests__/spreadsheet/row-link-spec.ts index f3fb2e488d..e71ac8785b 100644 --- a/packages/s2-core/__tests__/spreadsheet/row-link-spec.ts +++ b/packages/s2-core/__tests__/spreadsheet/row-link-spec.ts @@ -96,6 +96,7 @@ describe('Row Text Link Tests', () => { expect(linkFieldJump).toBeCalledWith({ key: 'province', + cellData: rowNode, record: { province: '浙江', type: '笔', @@ -124,6 +125,7 @@ describe('Row Text Link Tests', () => { expect(linkFieldJump).toBeCalledWith({ key: 'city', + cellData: rowNode, record: { province: '浙江', city: '义乌1', @@ -152,6 +154,7 @@ describe('Row Text Link Tests', () => { expect(linkFieldJump).toBeCalledWith({ key: 'province', + cellData: rowNode, record: { province: '四川', type: '笔', diff --git a/packages/s2-core/__tests__/unit/interaction/base-interaction/click/data-cell-click-spec.ts b/packages/s2-core/__tests__/unit/interaction/base-interaction/click/data-cell-click-spec.ts index 0c183b563c..c2a64b7cc6 100644 --- a/packages/s2-core/__tests__/unit/interaction/base-interaction/click/data-cell-click-spec.ts +++ b/packages/s2-core/__tests__/unit/interaction/base-interaction/click/data-cell-click-spec.ts @@ -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(); diff --git a/packages/s2-core/src/cell/row-cell.ts b/packages/s2-core/src/cell/row-cell.ts index e5c87ad76f..c8e9c22983 100644 --- a/packages/s2-core/src/cell/row-cell.ts +++ b/packages/s2-core/src/cell/row-cell.ts @@ -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( + (field) => field === this.meta.key || field === this.meta.id, + ); + super.drawLinkFieldShape(isLinkField, linkTextFill); } protected drawRectBorder() { diff --git a/packages/s2-core/src/common/interface/emitter.ts b/packages/s2-core/src/common/interface/emitter.ts index dd045ccd75..cdc3d84a6a 100644 --- a/packages/s2-core/src/common/interface/emitter.ts +++ b/packages/s2-core/src/common/interface/emitter.ts @@ -77,6 +77,7 @@ export interface EmitterType { /** ================ Cell ================ */ [S2Event.GLOBAL_LINK_FIELD_JUMP]: (data: { key: string; + cellData: Node; record: Data; }) => void; diff --git a/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts b/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts index 55cd55a0f7..c4d080fa08 100644 --- a/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts +++ b/packages/s2-core/src/interaction/base-interaction/click/data-cell-click.ts @@ -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), }); } diff --git a/packages/s2-core/src/interaction/base-interaction/click/row-text-click.ts b/packages/s2-core/src/interaction/base-interaction/click/row-text-click.ts index 0f5d601ec0..58a8fa9435 100644 --- a/packages/s2-core/src/interaction/base-interaction/click/row-text-click.ts +++ b/packages/s2-core/src/interaction/base-interaction/click/row-text-click.ts @@ -28,6 +28,7 @@ export class RowTextClick extends BaseEvent implements BaseEventImplement { this.spreadsheet.emit(S2Event.GLOBAL_LINK_FIELD_JUMP, { key, + cellData, record: rowData, }); }); diff --git a/s2-site/docs/api/components/sheet-component.zh.md b/s2-site/docs/api/components/sheet-component.zh.md index 8309e22e9e..c299396f10 100644 --- a/s2-site/docs/api/components/sheet-component.zh.md +++ b/s2-site/docs/api/components/sheet-component.zh.md @@ -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; | | | @@ -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; | | |