feat: add table cell border type #389

This commit is contained in:
Hufe921
2024-01-08 21:28:35 +08:00
parent 981e4582f9
commit 3253f3708e
15 changed files with 98 additions and 5 deletions
@@ -14,7 +14,10 @@ const {
BORDER_EMPTY,
BORDER_EXTERNAL,
BORDER_TD,
BORDER_TD_TOP,
BORDER_TD_LEFT,
BORDER_TD_BOTTOM,
BORDER_TD_RIGHT,
BORDER_TD_BACK,
BORDER_TD_FORWARD,
VERTICAL_ALIGN,
@@ -80,6 +83,24 @@ export const tableMenus: IRegisterContextMenu[] = [
icon: 'border-td',
when: () => true,
childMenus: [
{
key: BORDER_TD_TOP,
i18nPath: 'contextmenu.table.borderTdTop',
icon: 'border-td-top',
when: () => true,
callback: (command: Command) => {
command.executeTableTdBorderType(TdBorder.TOP)
}
},
{
key: BORDER_TD_RIGHT,
i18nPath: 'contextmenu.table.borderTdRight',
icon: 'border-td-right',
when: () => true,
callback: (command: Command) => {
command.executeTableTdBorderType(TdBorder.RIGHT)
}
},
{
key: BORDER_TD_BOTTOM,
i18nPath: 'contextmenu.table.borderTdBottom',
@@ -89,6 +110,15 @@ export const tableMenus: IRegisterContextMenu[] = [
command.executeTableTdBorderType(TdBorder.BOTTOM)
}
},
{
key: BORDER_TD_LEFT,
i18nPath: 'contextmenu.table.borderTdLeft',
icon: 'border-td-left',
when: () => true,
callback: (command: Command) => {
command.executeTableTdBorderType(TdBorder.LEFT)
}
},
{
key: BORDER_TD_FORWARD,
i18nPath: 'contextmenu.table.borderTdForward',
@@ -189,13 +189,29 @@ export class TableParticle {
ctx.translate(0.5, 0.5)
// 绘制线条
ctx.beginPath()
// 单元格边框
if (td.borderType === TdBorder.TOP) {
ctx.moveTo(x - width, y)
ctx.lineTo(x, y)
ctx.stroke()
}
if (td.borderType === TdBorder.RIGHT) {
ctx.moveTo(x, y)
ctx.lineTo(x, y + height)
ctx.stroke()
}
if (td.borderType === TdBorder.BOTTOM) {
ctx.moveTo(x, y + height)
ctx.lineTo(x - width, y + height)
ctx.stroke()
}
if (td.borderType === TdBorder.LEFT) {
ctx.moveTo(x - width, y)
ctx.lineTo(x - width, y + height)
ctx.stroke()
}
// 表格线
if (!isEmptyBorderType && !isExternalBorderType) {
ctx.moveTo(x, y + height)
ctx.moveTo(x, y)
ctx.lineTo(x, y + height)
ctx.lineTo(x - width, y + height)
+5 -2
View File
@@ -45,9 +45,12 @@
"borderEmpty": "Empty",
"borderExternal": "External",
"borderTd": "Table cell border",
"borderTdTop": "Top",
"borderTdRight": "Right",
"borderTdBottom": "Bottom",
"borderTdForward": "forward",
"borderTdBack": "back"
"borderTdLeft": "Left",
"borderTdForward": "Forward",
"borderTdBack": "Back"
}
},
"datePicker": {
+3
View File
@@ -45,7 +45,10 @@
"borderEmpty": "无框线",
"borderExternal": "外侧框线",
"borderTd": "单元格边框",
"borderTdTop": "上边框",
"borderTdRight": "右边框",
"borderTdBottom": "下边框",
"borderTdLeft": "左边框",
"borderTdForward": "正斜线",
"borderTdBack": "反斜线"
}