Skip to content

Commit

Permalink
feat: add table dashed border #858
Browse files Browse the repository at this point in the history
  • Loading branch information
Hufe921 committed Oct 26, 2024
1 parent 8eabd07 commit dffac63
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/en/guide/contextmenu-internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- Table borders
- All borders
- Borderless
- Dashed border
- Outer border
- Td borders
- Top border
Expand Down
1 change: 1 addition & 0 deletions docs/en/guide/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface ILang {
border: string
borderAll: string
borderEmpty: string
borderDash: string
borderExternal: string
borderTd: string
borderTdTop: string
Expand Down
1 change: 1 addition & 0 deletions docs/guide/contextmenu-internal.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
- 表格边框
- 所有框线
- 无框线
- 虚框线
- 外侧框线
- 单元格边框
- 上边框
Expand Down
1 change: 1 addition & 0 deletions docs/guide/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ interface ILang {
border: string
borderAll: string
borderEmpty: string
borderDash: string
borderExternal: string
borderTd: string
borderTdTop: string
Expand Down
4 changes: 4 additions & 0 deletions src/editor/assets/css/contextmenu/contextmenu.css
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@
background-image: url(../../../assets/images/table-border-empty.svg);
}

.ce-contextmenu-border-dash {
background-image: url(../../../assets/images/table-border-dash.svg);
}

.ce-contextmenu-border-external {
background-image: url(../../../assets/images/table-border-external.svg);
}
Expand Down
1 change: 1 addition & 0 deletions src/editor/assets/images/table-border-dash.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/editor/core/contextmenu/menus/tableMenus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
BORDER,
BORDER_ALL,
BORDER_EMPTY,
BORDER_DASH,
BORDER_EXTERNAL,
BORDER_TD,
BORDER_TD_TOP,
Expand Down Expand Up @@ -73,6 +74,15 @@ export const tableMenus: IRegisterContextMenu[] = [
command.executeTableBorderType(TableBorder.EMPTY)
}
},
{
key: BORDER_DASH,
i18nPath: 'contextmenu.table.borderDash',
icon: 'border-dash',
when: () => true,
callback: (command: Command) => {
command.executeTableBorderType(TableBorder.DASH)
}
},
{
key: BORDER_EXTERNAL,
i18nPath: 'contextmenu.table.borderExternal',
Expand Down
4 changes: 4 additions & 0 deletions src/editor/core/draw/particle/table/TableParticle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export class TableParticle {
// 仅外边框
const isExternalBorderType = borderType === TableBorder.EXTERNAL
ctx.save()
// 虚线
if (borderType === TableBorder.DASH) {
ctx.setLineDash([3, 3])
}
ctx.lineWidth = scale
// 渲染边框
if (!isEmptyBorderType) {
Expand Down
1 change: 1 addition & 0 deletions src/editor/core/i18n/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"border": "Table border",
"borderAll": "All",
"borderEmpty": "Empty",
"borderDash": "Dash",
"borderExternal": "External",
"borderTd": "Table cell border",
"borderTdTop": "Top",
Expand Down
1 change: 1 addition & 0 deletions src/editor/core/i18n/lang/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"border": "表格边框",
"borderAll": "所有框线",
"borderEmpty": "无框线",
"borderDash": "虚框线",
"borderExternal": "外侧框线",
"borderTd": "单元格边框",
"borderTdTop": "上边框",
Expand Down
1 change: 1 addition & 0 deletions src/editor/dataset/constant/ContextMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const INTERNAL_CONTEXT_MENU_KEY = {
BORDER: 'border',
BORDER_ALL: 'tableBorderAll',
BORDER_EMPTY: 'tableBorderEmpty',
BORDER_DASH: 'tableBorderDash',
BORDER_EXTERNAL: 'tableBorderExternal',
BORDER_TD: 'tableBorderTd',
BORDER_TD_TOP: 'tableBorderTdTop',
Expand Down
3 changes: 2 additions & 1 deletion src/editor/dataset/enum/table/Table.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
export enum TableBorder {
ALL = 'all',
EMPTY = 'empty',
EXTERNAL = 'external'
EXTERNAL = 'external',
DASH = 'dash'
}

export enum TdBorder {
Expand Down

0 comments on commit dffac63

Please sign in to comment.