Skip to content

Commit 1051f70

Browse files
committed
use escape-key to cancel (and store) contenteditable nodes
1 parent 7de60d0 commit 1051f70

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

apps/vps-web/src/app/custom-nodes/classes/rect-node-class.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ w-min h-min
5757
}px ${nodeInfo?.strokeColor ?? 'white'} solid;color:${
5858
nodeInfo?.strokeColor ?? 'white'
5959
}`}
60+
spellcheck="false"
6061
blur={() => {
6162
console.log('blur', this.rectElement?.textContent);
6263
if (this.node?.nodeInfo) {

libs/app-canvas/src/app/app.element.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@ export class AppElement<T extends BaseNodeInfo> {
461461
['A', 'BUTTON', 'INPUT', 'SELECT', 'TEXTAREA'].indexOf(
462462
(event.target as HTMLElement)?.tagName
463463
) >= 0;
464+
if (
465+
key === 'escape' &&
466+
!inInputControle &&
467+
(event.target as HTMLElement)?.isContentEditable
468+
) {
469+
if (document.activeElement) {
470+
(document.activeElement as HTMLElement).blur();
471+
}
472+
return;
473+
}
464474
if (key === 'backspace' || key === 'delete' || key === 'enter') {
465475
if (inInputControle || (event.target as HTMLElement)?.isContentEditable) {
466476
return;

0 commit comments

Comments
 (0)