Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: some keydown handlers not trigger when multiple editors #8114

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class EdgelessMindmapToolButton extends EdgelessToolbarToolMixin(
},
});

const dispose = this.edgeless.bindHotKey(
this.edgeless.bindHotKey(
{
m: () => {
const service = this.edgeless.service;
Expand Down Expand Up @@ -229,7 +229,6 @@ export class EdgelessMindmapToolButton extends EdgelessToolbarToolMixin(
},
{ global: true }
);
this.disposables.add(dispose);
}

override render() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,39 +203,37 @@ export class EdgelessToolbarShapeDraggable extends EdgelessToolbarToolMixin(
},
});

this._disposables.add(
this.edgeless.bindHotKey(
{
s: ctx => {
// `page.keyboard.press('Shift+s')` in playwright will also trigger this 's' key event
if (ctx.get('keyboardState').raw.shiftKey) return;
this.edgeless.bindHotKey(
{
s: ctx => {
// `page.keyboard.press('Shift+s')` in playwright will also trigger this 's' key event
if (ctx.get('keyboardState').raw.shiftKey) return;

const service = this.edgeless.service;
if (service.locked || service.selection.editing) return;
const service = this.edgeless.service;
if (service.locked || service.selection.editing) return;

if (this.readyToDrop) {
const activeIndex = shapes.findIndex(
s => s.name === this.draggingShape
);
const nextIndex = (activeIndex + 1) % shapes.length;
const next = shapes[nextIndex];
this.draggingShape = next.name;
if (this.readyToDrop) {
const activeIndex = shapes.findIndex(
s => s.name === this.draggingShape
);
const nextIndex = (activeIndex + 1) % shapes.length;
const next = shapes[nextIndex];
this.draggingShape = next.name;

this.draggableController.cancelWithoutAnimation();
}
this.draggableController.cancelWithoutAnimation();
}

const el = this.shapeContainer.querySelector(
`.shape.${this.draggingShape}`
) as HTMLElement;
assertExists(el, 'Edgeless toolbar Shape element not found');
const { x, y } = service.tool.lastMousePos;
const { left, top } = this.edgeless.viewport;
const clientPos = { x: x + left, y: y + top };
this.draggableController.clickToDrag(el, clientPos);
},
const el = this.shapeContainer.querySelector(
`.shape.${this.draggingShape}`
) as HTMLElement;
assertExists(el, 'Edgeless toolbar Shape element not found');
const { x, y } = service.tool.lastMousePos;
const { left, top } = this.edgeless.viewport;
const clientPos = { x: x + left, y: y + top };
this.draggableController.clickToDrag(el, clientPos);
},
{ global: true }
)
},
{ global: true }
);
}

Expand Down
Loading