feat: add copy table cell content option to contextmenu #307
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user