Skip to content

Commit

Permalink
fix: intellij webview keyBinding
Browse files Browse the repository at this point in the history
  • Loading branch information
dineug committed Jan 22, 2024
1 parent ea3cb72 commit 35d3b51
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 15 deletions.
22 changes: 22 additions & 0 deletions packages/erd-editor-intellij-webview/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,28 @@ const bridge = new Emitter();
const editor = document.createElement('erd-editor');
const sharedStore = editor.getSharedStore({ mouseTracker: false });

editor.setKeyBindingMap({
addTable: [{ shortcut: 'Alt+KeyN', preventDefault: true }],
addColumn: [{ shortcut: 'Alt+Enter', preventDefault: true }],
addMemo: [{ shortcut: 'Alt+KeyM', preventDefault: true }],
removeTable: [
{ shortcut: '$mod+Backspace', preventDefault: true },
{ shortcut: '$mod+Delete', preventDefault: true },
],
removeColumn: [
{ shortcut: 'Alt+Backspace', preventDefault: true },
{ shortcut: 'Alt+Delete', preventDefault: true },
],
primaryKey: [{ shortcut: 'Alt+KeyK', preventDefault: true }],
selectAllTable: [{ shortcut: '$mod+Alt+KeyA', preventDefault: true }],
selectAllColumn: [{ shortcut: 'Alt+KeyA', preventDefault: true }],
relationshipZeroOne: [{ shortcut: '$mod+Alt+Digit1', preventDefault: true }],
relationshipZeroN: [{ shortcut: '$mod+Alt+Digit2', preventDefault: true }],
relationshipOneOnly: [{ shortcut: '$mod+Alt+Digit3', preventDefault: true }],
relationshipOneN: [{ shortcut: '$mod+Alt+Digit4', preventDefault: true }],
tableProperties: [{ shortcut: 'Alt+Space', preventDefault: true }],
});

const dispatch = (action: AnyAction) => {
window.cefQuery({
request: JSON.stringify(action),
Expand Down
30 changes: 15 additions & 15 deletions packages/erd-editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,19 @@ type ShortcutOption = {
};

const defaultKeyBindingMap: KeyBindingMap = {
addTable: [{ shortcut: 'Alt+KeyN' }];
addColumn: [{ shortcut: 'Alt+Enter' }];
addMemo: [{ shortcut: 'Alt+KeyM' }];
removeTable: [{ shortcut: '$mod+Backspace' }, { shortcut: '$mod+Delete' }];
removeColumn: [{ shortcut: 'Alt+Backspace' }, { shortcut: 'Alt+Delete' }];
primaryKey: [{ shortcut: 'Alt+KeyK' }];
selectAllTable: [{ shortcut: '$mod+Alt+KeyA' }];
selectAllColumn: [{ shortcut: 'Alt+KeyA' }];
relationshipZeroOne: [{ shortcut: '$mod+Alt+Digit1' }];
relationshipZeroN: [{ shortcut: '$mod+Alt+Digit2' }];
relationshipOneOnly: [{ shortcut: '$mod+Alt+Digit3' }];
relationshipOneN: [{ shortcut: '$mod+Alt+Digit4' }];
tableProperties: [{ shortcut: 'Alt+Space' }];
addTable: [{ shortcut: 'Alt+KeyN' }],
addColumn: [{ shortcut: 'Alt+Enter' }],
addMemo: [{ shortcut: 'Alt+KeyM' }],
removeTable: [{ shortcut: '$mod+Backspace' }, { shortcut: '$mod+Delete' }],
removeColumn: [{ shortcut: 'Alt+Backspace' }, { shortcut: 'Alt+Delete' }],
primaryKey: [{ shortcut: 'Alt+KeyK' }],
selectAllTable: [{ shortcut: '$mod+Alt+KeyA' }],
selectAllColumn: [{ shortcut: 'Alt+KeyA' }],
relationshipZeroOne: [{ shortcut: '$mod+Alt+Digit1' }],
relationshipZeroN: [{ shortcut: '$mod+Alt+Digit2' }],
relationshipOneOnly: [{ shortcut: '$mod+Alt+Digit3' }],
relationshipOneN: [{ shortcut: '$mod+Alt+Digit4' }],
tableProperties: [{ shortcut: 'Alt+Space' }],
};

// example
Expand All @@ -229,7 +229,7 @@ Switches `Control` key depending on the environment.

### Shortcut Table

Uses keyboard event `key, code` properties.
Uses keyboard event `key, code` properties.
Use `code` for absolute positions and `key` for input values.

| Windows | macOS | `key` | `code` |
Expand Down Expand Up @@ -455,7 +455,7 @@ editor.setSchemaSQL('Schema SQL...');

## getSchemaSQL

Extracts the current editor state into a schema SQL.
Extracts the current editor state into a schema SQL.
If `databaseVendor` is not specified, it operates based on the currently set vendor.

```ts
Expand Down

0 comments on commit 35d3b51

Please sign in to comment.