Skip to content

Commit

Permalink
fix: can not show slash menu if insert "/" before select block (#2999)
Browse files Browse the repository at this point in the history
  • Loading branch information
QiShaoXuan committed Jun 6, 2023
1 parent d845d49 commit b5aba84
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/blocks/src/page-block/utils/container-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
focusBlockByModel,
getBlockElementByModel,
getClosestBlockElementByElement,
getCurrentNativeRange,
getDefaultPage,
getVirgoByModel,
handleNativeRangeDblClick,
Expand All @@ -40,6 +41,7 @@ import {
import { asyncFocusRichText } from '../../__internal__/utils/common-operations.js';
import { clearMarksOnDiscontinuousInput } from '../../__internal__/utils/virgo.js';
import { showFormatQuickBar } from '../../components/format-quick-bar/index.js';
import { showSlashMenu } from '../../components/slash-menu/index.js';
import type { BlockSchemas } from '../../models.js';
import type {
DefaultSelectionManager,
Expand Down Expand Up @@ -537,6 +539,14 @@ export function handleKeydownAfterSelectBlocks({
const newBlock = page.getBlockById(id) as BaseBlockModel;
defaultPage?.selection.clear();
focusBlockByModel(newBlock, 'end');

// XXX: slash menu trigger probably shouldn't be here
if (key === '/') {
const curRange = getCurrentNativeRange();
const model = page.getBlockById(id);
assertExists(model);
showSlashMenu({ model, range: curRange });
}
});
}
export async function onModelTextUpdated(
Expand Down

2 comments on commit b5aba84

@vercel
Copy link

@vercel vercel bot commented on b5aba84 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blocksuite – ./packages/playground

blocksuite-git-master-toeverything.vercel.app
blocksuite-five.vercel.app
blocksuite-toeverything.vercel.app

@vercel
Copy link

@vercel vercel bot commented on b5aba84 Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.