mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-17 01:56:27 +08:00
69c2f09eba
## Description Fixes keyboard shortcuts for text formatting (Ctrl+B, Ctrl+I, Ctrl+U, etc.) not working inside table cells. ## Changes - **Modified `table-cell.ts`**: Updated the `_handleKeyDown` method to only prevent default behavior for Tab key and allow other keyboard events to propagate, enabling text formatting shortcuts to work properly - **Created `table-keymap.ts`**: New module that registers the `textKeymap` for table blocks, ensuring text formatting shortcuts are available in table cells - **Updated `view.ts`**: Registered the `TableKeymapExtension` in the table view extension setup - **Cleaned up `format.ts`**: Removed unnecessary `TextSelection` check that was preventing shortcuts from working in table contexts ## Closes Closes #13916 #12127 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved Tab key handling within table cells for more consistent keyboard navigation. * Simplified read-only detection for keyboard shortcuts to avoid unexpected behavior. * **Refactor** * Reworked table keyboard mapping and registration to streamline shortcut handling and event flow. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
32 lines
1020 B
TypeScript
32 lines
1020 B
TypeScript
import {
|
|
type ViewExtensionContext,
|
|
ViewExtensionProvider,
|
|
} from '@blocksuite/affine-ext-loader';
|
|
import { TableModelFlavour } from '@blocksuite/affine-model';
|
|
import { SlashMenuConfigExtension } from '@blocksuite/affine-widget-slash-menu';
|
|
import { BlockViewExtension, FlavourExtension } from '@blocksuite/std';
|
|
import { literal } from 'lit/static-html.js';
|
|
|
|
import { tableSlashMenuConfig } from './configs/slash-menu';
|
|
import { effects } from './effects';
|
|
import { TableKeymapExtension } from './table-keymap.js';
|
|
|
|
export class TableViewExtension extends ViewExtensionProvider {
|
|
override name = 'affine-table-block';
|
|
|
|
override effect(): void {
|
|
super.effect();
|
|
effects();
|
|
}
|
|
|
|
override setup(context: ViewExtensionContext) {
|
|
super.setup(context);
|
|
context.register([
|
|
FlavourExtension(TableModelFlavour),
|
|
TableKeymapExtension,
|
|
BlockViewExtension(TableModelFlavour, literal`affine-table`),
|
|
SlashMenuConfigExtension(TableModelFlavour, tableSlashMenuConfig),
|
|
]);
|
|
}
|
|
}
|