Skip to content

Commit 760be84

Browse files
committed
Merge branch 'default-blocks-type-guards' into default-blocks
2 parents dba7321 + a0fc6e2 commit 760be84

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

packages/core/src/blocks/defaultBlockTypeGuards.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import { CellSelection } from "prosemirror-tables";
22
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
3-
import {
4-
BlockConfig,
5-
BlockSchema,
6-
PropSchema,
7-
PropSpec,
8-
StyleSchema,
9-
} from "../schema/index.js";
10-
import {
11-
Block,
12-
DefaultInlineContentSchema,
13-
defaultInlineContentSchema,
14-
} from "./defaultBlocks.js";
3+
import { BlockConfig, PropSchema, PropSpec } from "../schema/index.js";
4+
import { Block } from "./defaultBlocks.js";
155
import { Selection } from "prosemirror-state";
166

177
export function editorHasBlockWithType<
@@ -174,27 +164,6 @@ export function blockHasType<
174164
);
175165
}
176166

177-
// TODO: Only used once in the emoji picker - is it even needed? If so, should
178-
// be changed to be like the block type guards.
179-
export function checkDefaultInlineContentTypeInSchema<
180-
InlineContentType extends keyof DefaultInlineContentSchema,
181-
B extends BlockSchema,
182-
S extends StyleSchema,
183-
>(
184-
inlineContentType: InlineContentType,
185-
editor: BlockNoteEditor<B, any, S>,
186-
): editor is BlockNoteEditor<
187-
B,
188-
{ [K in InlineContentType]: DefaultInlineContentSchema[InlineContentType] },
189-
S
190-
> {
191-
return (
192-
inlineContentType in editor.schema.inlineContentSchema &&
193-
editor.schema.inlineContentSchema[inlineContentType] ===
194-
defaultInlineContentSchema[inlineContentType]
195-
);
196-
}
197-
198167
export function isTableCellSelection(
199168
selection: Selection,
200169
): selection is CellSelection {

packages/core/src/extensions/SuggestionMenu/getDefaultEmojiPickerItems.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Emoji, EmojiMartData } from "@emoji-mart/data";
22

3-
import { checkDefaultInlineContentTypeInSchema } from "../../blocks/defaultBlockTypeGuards.js";
3+
import { defaultInlineContentSchema } from "../../blocks/defaultBlocks.js";
44
import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
55
import {
66
BlockSchema,
@@ -54,7 +54,11 @@ export async function getDefaultEmojiPickerItems<
5454
editor: BlockNoteEditor<BSchema, I, S>,
5555
query: string,
5656
): Promise<DefaultGridSuggestionItem[]> {
57-
if (!checkDefaultInlineContentTypeInSchema("text", editor)) {
57+
if (
58+
!("text" in editor.schema.inlineContentSchema) ||
59+
editor.schema.inlineContentSchema["text"] !==
60+
defaultInlineContentSchema["text"]
61+
) {
5862
return [];
5963
}
6064

0 commit comments

Comments
 (0)