feat: add copy table cell content option to contextmenu #307

This commit is contained in:
Hufe921
2023-10-30 21:18:43 +08:00
parent 7fba458d52
commit a94328fa95
3 changed files with 6 additions and 7 deletions
@@ -23,7 +23,7 @@ export const globalMenus: IRegisterContextMenu[] = [
i18nPath: 'contextmenu.global.copy',
shortCut: `${isApple ? '⌘' : 'Ctrl'} + C`,
when: payload => {
return payload.editorHasSelection
return payload.editorHasSelection || payload.isCrossRowCol
},
callback: (command: Command) => {
command.executeCopy()
+2 -2
View File
@@ -84,8 +84,8 @@ export class Control {
const startElement = elementList[startIndex]
const endElement = elementList[endIndex]
if (
(startElement.type === ElementType.CONTROL ||
endElement.type === ElementType.CONTROL) &&
(startElement?.type === ElementType.CONTROL ||
endElement?.type === ElementType.CONTROL) &&
startElement.controlId !== endElement.controlId
) {
return true
+3 -4
View File
@@ -24,10 +24,9 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
const isCollapsed = startIndex === endIndex
// 当前激活控件
const control = draw.getControl()
const isPartRangeInControlOutside = control.isPartRangeInControlOutside()
const activeControl = control.getActiveControl()
if (evt.key === KeyMap.Backspace) {
if (isReadonly || isPartRangeInControlOutside) return
if (isReadonly || control.isPartRangeInControlOutside()) return
let curIndex: number | null
if (activeControl) {
curIndex = control.keydown(evt)
@@ -62,7 +61,7 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
rangeManager.setRange(curIndex, curIndex)
draw.render({ curIndex })
} else if (evt.key === KeyMap.Delete) {
if (isReadonly || isPartRangeInControlOutside) return
if (isReadonly || control.isPartRangeInControlOutside()) return
let curIndex: number | null
if (activeControl) {
curIndex = control.keydown(evt)
@@ -84,7 +83,7 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
rangeManager.setRange(curIndex, curIndex)
draw.render({ curIndex })
} else if (evt.key === KeyMap.Enter) {
if (isReadonly || isPartRangeInControlOutside) return
if (isReadonly || control.isPartRangeInControlOutside()) return
const enterText: IElement = {
value: ZERO
}