Skip to content

Commit c5237cd

Browse files
authored
Merge pull request #3552 from VisActor/feat/add_row_col_button
feat: add plugins
2 parents d8ea8e1 + e740a4e commit c5237cd

85 files changed

Lines changed: 4553 additions & 419 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/assets/demo/en/animation/carousel-animation.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
---
22
category: examples
33
group: Animation
4-
title: carousel animation
4+
title: Carousel Animation
55
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/carousel-animation.gif
66
link: animation/carousel_animation
77
---
88

99
# Carousel Animation
1010

11-
Carousel animation in VTable
11+
Table carousel animation display
1212

13-
## Key configuration
13+
## Key Configuration
1414

15-
- `CarouselAnimationPlugin` carousel animation plugin
16-
- `rowCount` scroll row count in a carousel animation
17-
- `colCount` scroll column count in a carousel animation
18-
- `animationDuration` The duration of a single carousel animation, in milliseconds
19-
- `animationDelay` The delay of a single carousel animation, in milliseconds
20-
- `animationEasing` The easing function of a single carousel animation
21-
- `replaceScrollAction` Whether to replace the scroll action, if true, the scroll action will be replaced by the carousel animation
15+
- `TableCarouselAnimationPlugin` Carousel animation plugin
16+
- `rowCount` Number of rows scrolled in one animation
17+
- `colCount` Number of columns scrolled in one animation
18+
- `animationDuration` Duration of a single scroll animation
19+
- `animationDelay` Time interval between animations
20+
- `animationEasing` Animation easing function
2221

23-
## Code demonstration
22+
## Code demo
2423

2524
```javascript livedemo template=vtable
2625
// use this for project
@@ -31,6 +30,10 @@ let tableInstance;
3130
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data100.json')
3231
.then(res => res.json())
3332
.then(data => {
33+
34+
const animationPlugin = new VTablePlugins.TableCarouselAnimationPlugin( {
35+
rowCount: 2,
36+
});
3437
const columns = [
3538
{
3639
field: 'Category',
@@ -92,16 +95,12 @@ fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American
9295
const option = {
9396
records: data.slice(0, 20),
9497
columns,
95-
widthMode: 'standard'
98+
widthMode: 'standard',
99+
plugins: [animationPlugin]
96100
};
97101
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
98102
window['tableInstance'] = tableInstance;
99103

100-
const ca = new VTablePlugins.CarouselAnimationPlugin(tableInstance, {
101-
rowCount: 2,
102-
replaceScrollAction: true
103-
});
104-
105-
ca.play();
104+
106105
});
107106
```

docs/assets/demo/en/interaction/head-highlight.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Highlight the header when selecting the cell.
1212

1313
## Key Configurations
1414

15-
- `HeaderHighlightPlugin` highlight plugin
15+
- `HighlightHeaderWhenSelectCellPlugin` highlight plugin
1616
- `columnHighlight` whether highlight the column
1717
- `rowHighlight` whether highlight the row
1818
- `colHighlightBGColor` the background color of the column highlight
@@ -90,14 +90,15 @@ const columns = [
9090
width: 100
9191
}
9292
];
93-
93+
const highlightPlugin = new VTablePlugins.HighlightHeaderWhenSelectCellPlugin();
9494
const option = {
9595
records,
9696
columns,
97-
rowSeriesNumber: {}
97+
rowSeriesNumber: {},
98+
plugins: [highlightPlugin]
9899
};
99100
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
100101
window['tableInstance'] = tableInstance;
101102

102-
const highlightPlugin = new VTablePlugins.HeaderHighlightPlugin(tableInstance, {});
103+
103104
```

docs/assets/demo/en/interaction/invert-highlight.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Show the highlight effect when set highlight range.
1212

1313
## Key Configurations
1414

15-
- `InvertHighlightPlugin` invert highlight plugin
15+
- `FocusHighlightPlugin` invert highlight plugin
1616
- `fill` invert highlight background color
1717
- `opacity` invert highlight opacity
1818
- `setInvertHighlightRange` set highlight range
@@ -87,25 +87,16 @@ const columns = [
8787
width: 100
8888
}
8989
];
90-
90+
const highlightPlugin = new VTablePlugins.FocusHighlightPlugin();
9191
const option = {
9292
records,
9393
columns,
94-
theme: VTable.themes.DARK
94+
theme: VTable.themes.DARK,
95+
plugins: [highlightPlugin]
9596
};
9697
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
9798
window['tableInstance'] = tableInstance;
9899

99-
const highlightPlugin = new VTablePlugins.InvertHighlightPlugin(tableInstance, {});
100100

101-
highlightPlugin.setInvertHighlightRange({
102-
start: {
103-
col: 0,
104-
row: 6
105-
},
106-
end: {
107-
col: 5,
108-
row: 6
109-
}
110-
});
101+
111102
```
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
---
2+
category: examples
3+
group: plugin
4+
title: Excel-like Online Editing
5+
cover: https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/preview/excel-online-editing.gif
6+
link: plugin/usage
7+
option: plugins
8+
---
9+
10+
# Excel-like Online Editing
11+
12+
Based on VTable's plugin mechanism, this example implements Excel-like online editing functionality.
13+
14+
In this example, we use the following plugins in combination:
15+
- `AddRowColumnPlugin`: Add rows and columns
16+
- `ColumnSeriesPlugin`: Column series plugin
17+
- `RowSeriesPlugin`: Row series plugin
18+
- `HighlightHeaderWhenSelectCellPlugin`: Highlight selected cells
19+
- `ExcelEditCellKeyboardPlugin`: Excel-style cell editing keyboard plugin
20+
21+
It's important to note that there are dependencies between plugins. For example, in the `AddRowColumnPlugin`, we call the `columnSeries.resetColumnCount` method to reset the column count, ensuring that after adding columns, the count remains consistent with the column count in the `ColumnSeriesPlugin`.
22+
23+
## Key Configuration
24+
25+
- `editCellTrigger`: Cell editing trigger method
26+
- `editor`: Editor type
27+
- `plugins`: Plugin list
28+
29+
30+
## Code Demo
31+
32+
```javascript livedemo template=vtable
33+
// import * as VTable from '@visactor/vtable';
34+
// 使用时需要引入插件包@visactor/vtable-plugins
35+
// import * as VTablePlugins from '@visactor/vtable-plugins';
36+
// 正常使用方式 const columnSeries = new VTable.plugins.ColumnSeriesPlugin({});
37+
// 官网编辑器中将 VTable.plugins重命名成了VTablePlugins
38+
39+
// 注册编辑器
40+
const input_editor = new VTable_editors.InputEditor();
41+
VTable.register.editor('input', input_editor);
42+
43+
// 注册插件
44+
const addRowColumn = new VTablePlugins.AddRowColumnPlugin({
45+
addColumnCallback: col => {
46+
// 新增列时,重置列数
47+
columnSeries.resetColumnCount(columnSeries.pluginOptions.columnCount + 1);
48+
// 将table实例中的数据源records每一个数组中新增一个空字符串,对应新增的列
49+
const newRecords = tableInstance.records.map(record => {
50+
if (Array.isArray(record)) {
51+
record.splice(col - 1, 0, '');
52+
}
53+
return record;
54+
});
55+
tableInstance.setRecords(newRecords);
56+
},
57+
addRowCallback: row => {
58+
// 新增行时,填充空行数据
59+
tableInstance.addRecord([], row - tableInstance.columnHeaderLevelCount);
60+
}
61+
});
62+
63+
const columnSeries = new VTablePlugins.ColumnSeriesPlugin({
64+
columnCount: 26
65+
});
66+
const rowSeries = new VTablePlugins.RowSeriesPlugin({
67+
rowCount: 100,
68+
//records数据以外 填充空行数据
69+
fillRowRecord: (index) => {
70+
return [];
71+
},
72+
rowSeriesNumber: {
73+
width: 'auto'
74+
}
75+
});
76+
const highlightPlugin = new VTablePlugins.HighlightHeaderWhenSelectCellPlugin({
77+
colHighlight: true,
78+
rowHighlight: true
79+
});
80+
const excelEditCellKeyboardPlugin = new VTablePlugins.ExcelEditCellKeyboardPlugin();
81+
const option = {
82+
// 二维数组的数据 和excel的行列一致
83+
records: [
84+
['姓名', '年龄', '地址'],
85+
['张三', 18, '北京'],
86+
['李四', 20, '上海'],
87+
['王五', 22, '广州'],
88+
['赵六', 24, '深圳'],
89+
['孙七', 26, '成都']
90+
],
91+
92+
padding: 30,
93+
editor: 'input',
94+
editCellTrigger: ['api', 'keydown', 'doubleclick'],// 编辑单元格触发方式
95+
select: {
96+
cornerHeaderSelectMode: 'body',
97+
headerSelectMode: 'body'
98+
},
99+
theme: VTable.themes.DEFAULT.extends({
100+
defaultStyle: {
101+
textAlign: 'left',
102+
padding: [2, 6, 2, 6]
103+
},
104+
headerStyle: {
105+
textAlign: 'center'
106+
}
107+
}),
108+
defaultRowHeight: 30,
109+
plugins: [addRowColumn, columnSeries, rowSeries, highlightPlugin, excelEditCellKeyboardPlugin]
110+
};
111+
const tableInstance = new VTable.ListTable( document.getElementById(CONTAINER_ID),option);
112+
window.tableInstance = tableInstance;
113+
114+
```

docs/assets/demo/menu.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,6 +1482,22 @@
14821482
}
14831483
]
14841484
},
1485+
{
1486+
"path": "plugin",
1487+
"title": {
1488+
"zh": "插件库",
1489+
"en": "plugin library"
1490+
},
1491+
"children": [
1492+
{
1493+
"path": "excel-online-editing",
1494+
"title": {
1495+
"zh": "类Excel在线编辑",
1496+
"en": "Excel online editing"
1497+
}
1498+
}
1499+
]
1500+
},
14851501
{
14861502
"path": "export",
14871503
"title": {

docs/assets/demo/zh/animation/carousel-animation.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@ link: animation/carousel_animation
1212

1313
## 关键配置
1414

15-
- `CarouselAnimationPlugin` 轮播动画插件
15+
- `TableCarouselAnimationPlugin` 轮播动画插件
1616
- `rowCount` 一次动画滚动的行数
1717
- `colCount` 一次动画滚动的列数
1818
- `animationDuration` 一次滚动动画的时间
1919
- `animationDelay` 动画间隔时间
2020
- `animationEasing` 动画缓动函数
21-
- `replaceScrollAction` 是否替换滚动行为,如果为 true ,每次滚动操作会移动对于的行数/列数
2221

2322
## 代码演示
2423

@@ -31,6 +30,10 @@ let tableInstance;
3130
fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American_Superstore_data100.json')
3231
.then(res => res.json())
3332
.then(data => {
33+
34+
const animationPlugin = new VTablePlugins.TableCarouselAnimationPlugin( {
35+
rowCount: 2,
36+
});
3437
const columns = [
3538
{
3639
field: 'Category',
@@ -92,16 +95,12 @@ fetch('https://lf9-dp-fe-cms-tos.byteorg.com/obj/bit-cloud/VTable/North_American
9295
const option = {
9396
records: data.slice(0, 20),
9497
columns,
95-
widthMode: 'standard'
98+
widthMode: 'standard',
99+
plugins: [animationPlugin]
96100
};
97101
tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
98102
window['tableInstance'] = tableInstance;
99103

100-
const ca = new VTablePlugins.CarouselAnimationPlugin(tableInstance, {
101-
rowCount: 2,
102-
replaceScrollAction: true
103-
});
104-
105-
ca.play();
104+
106105
});
107106
```

docs/assets/demo/zh/interaction/head-highlight.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ link: plugin/header-highlight
1212

1313
## 关键配置
1414

15-
- `HeaderHighlightPlugin` 高亮表头插件
15+
- `HighlightHeaderWhenSelectCellPlugin` 高亮表头插件
1616
- `columnHighlight` 是否高亮列头
1717
- `rowHighlight` 是否高亮行头
1818
- `colHighlightBGColor` 列头高亮背景色
@@ -90,14 +90,13 @@ const columns = [
9090
width: 100
9191
}
9292
];
93-
93+
const highlightPlugin = new VTablePlugins.HighlightHeaderWhenSelectCellPlugin();
9494
const option = {
9595
records,
9696
columns,
97-
rowSeriesNumber: {}
97+
rowSeriesNumber: {},
98+
plugins: [highlightPlugin]
9899
};
99100
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
100101
window['tableInstance'] = tableInstance;
101-
102-
const highlightPlugin = new VTablePlugins.HeaderHighlightPlugin(tableInstance, {});
103102
```

docs/assets/demo/zh/interaction/invert-highlight.md

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ link: plugin/invert-highlight
1212

1313
## 关键配置
1414

15-
- `InvertHighlightPlugin` 反选高亮插件
15+
- `FocusHighlightPlugin` 反选高亮插件
1616
- `fill` 反选高亮背景色
1717
- `opacity` 反选高亮透明度
1818
- `setInvertHighlightRange` 设置反选高亮范围
@@ -87,25 +87,16 @@ const columns = [
8787
width: 100
8888
}
8989
];
90-
90+
const highlightPlugin = new VTablePlugins.FocusHighlightPlugin();
9191
const option = {
9292
records,
9393
columns,
94-
theme: VTable.themes.DARK
94+
theme: VTable.themes.DARK,
95+
plugins: [highlightPlugin]
9596
};
9697
const tableInstance = new VTable.ListTable(document.getElementById(CONTAINER_ID), option);
9798
window['tableInstance'] = tableInstance;
9899

99-
const highlightPlugin = new VTablePlugins.InvertHighlightPlugin(tableInstance, {});
100100

101-
highlightPlugin.setInvertHighlightRange({
102-
start: {
103-
col: 0,
104-
row: 6
105-
},
106-
end: {
107-
col: 5,
108-
row: 6
109-
}
110-
});
101+
111102
```

0 commit comments

Comments
 (0)