Skip to content

Commit

Permalink
feat: focus & copy command
Browse files Browse the repository at this point in the history
  • Loading branch information
WindRunnerMax committed Jun 24, 2024
1 parent 497675d commit ef6a339
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/core/src/canvas/paint/mask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export class Mask {
return this;
}

public focus() {
this.canvas.focus();
}

public isActive() {
return this.canvas === document.activeElement;
}
Expand Down
9 changes: 8 additions & 1 deletion packages/react/src/components/context-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ export const ContextMenu: FC = () => {
e.preventDefault();
};

const onCopy = (e: React.MouseEvent) => {
editor.canvas.mask.focus();
document.execCommand("copy");
e.preventDefault();
};

const onClipBoard = (e: React.MouseEvent) => {
Message.info("请使用快捷键的方式操作");
e.preventDefault();
};

const onSelectAll = (e: React.MouseEvent) => {
editor.canvas.mask.focus();
editor.selection.selectAll();
e.preventDefault();
};
Expand All @@ -66,7 +73,7 @@ export const ContextMenu: FC = () => {
<Portal>
<div className={styles.container} onClick={onClickProxy} style={{ top, left }}>
{active.length !== 0 && (
<div className={styles.item} onClick={onClipBoard}>
<div className={styles.item} onClick={onCopy}>
<div>复制</div>
<div className={styles.shortcut}>Ctrl+C</div>
</div>
Expand Down

0 comments on commit ef6a339

Please sign in to comment.