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', i18nPath: 'contextmenu.global.copy',
shortCut: `${isApple ? '⌘' : 'Ctrl'} + C`, shortCut: `${isApple ? '⌘' : 'Ctrl'} + C`,
when: payload => { when: payload => {
return payload.editorHasSelection return payload.editorHasSelection || payload.isCrossRowCol
}, },
callback: (command: Command) => { callback: (command: Command) => {
command.executeCopy() command.executeCopy()

@ -84,8 +84,8 @@ export class Control {
const startElement = elementList[startIndex] const startElement = elementList[startIndex]
const endElement = elementList[endIndex] const endElement = elementList[endIndex]
if ( if (
(startElement.type === ElementType.CONTROL || (startElement?.type === ElementType.CONTROL ||
endElement.type === ElementType.CONTROL) && endElement?.type === ElementType.CONTROL) &&
startElement.controlId !== endElement.controlId startElement.controlId !== endElement.controlId
) { ) {
return true return true

@ -24,10 +24,9 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
const isCollapsed = startIndex === endIndex const isCollapsed = startIndex === endIndex
// 当前激活控件 // 当前激活控件
const control = draw.getControl() const control = draw.getControl()
const isPartRangeInControlOutside = control.isPartRangeInControlOutside()
const activeControl = control.getActiveControl() const activeControl = control.getActiveControl()
if (evt.key === KeyMap.Backspace) { if (evt.key === KeyMap.Backspace) {
if (isReadonly || isPartRangeInControlOutside) return if (isReadonly || control.isPartRangeInControlOutside()) return
let curIndex: number | null let curIndex: number | null
if (activeControl) { if (activeControl) {
curIndex = control.keydown(evt) curIndex = control.keydown(evt)
@ -62,7 +61,7 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
rangeManager.setRange(curIndex, curIndex) rangeManager.setRange(curIndex, curIndex)
draw.render({ curIndex }) draw.render({ curIndex })
} else if (evt.key === KeyMap.Delete) { } else if (evt.key === KeyMap.Delete) {
if (isReadonly || isPartRangeInControlOutside) return if (isReadonly || control.isPartRangeInControlOutside()) return
let curIndex: number | null let curIndex: number | null
if (activeControl) { if (activeControl) {
curIndex = control.keydown(evt) curIndex = control.keydown(evt)
@ -84,7 +83,7 @@ export function keydown(evt: KeyboardEvent, host: CanvasEvent) {
rangeManager.setRange(curIndex, curIndex) rangeManager.setRange(curIndex, curIndex)
draw.render({ curIndex }) draw.render({ curIndex })
} else if (evt.key === KeyMap.Enter) { } else if (evt.key === KeyMap.Enter) {
if (isReadonly || isPartRangeInControlOutside) return if (isReadonly || control.isPartRangeInControlOutside()) return
const enterText: IElement = { const enterText: IElement = {
value: ZERO value: ZERO
} }

Loading…
Cancel
Save