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

pr675
Hufe921 2 years ago
parent 7fba458d52
commit a94328fa95

@ -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()

@ -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

@ -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
}

Loading…
Cancel
Save