Skip to content

Commit 52c7075

Browse files
committed
build: get build working again
1 parent 6c0211a commit 52c7075

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

packages/core/src/api/exporters/html/util/serializeBlocksExternalHTML.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,12 @@ function serializeBlock<
222222
if (fragment.lastChild?.nodeName !== listType) {
223223
const list = doc.createElement(listType);
224224

225-
if (listType === "OL" && props?.start && props?.start !== 1) {
225+
if (
226+
listType === "OL" &&
227+
"start" in props &&
228+
props.start &&
229+
props?.start !== 1
230+
) {
226231
list.setAttribute("start", props.start + "");
227232
}
228233
fragment.append(list);

packages/core/src/blocks/defaultBlocks.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {
2020
import { BackgroundColor } from "../extensions/BackgroundColor/BackgroundColorMark.js";
2121
import { TextColor } from "../extensions/TextColor/TextColorMark.js";
2222
import {
23-
BlockConfig,
2423
BlockNoDefaults,
2524
BlockSchema,
2625
InlineContentSchema,
@@ -52,21 +51,8 @@ export const defaultBlockSpecs = {
5251

5352
// underscore is used that in case a user overrides DefaultBlockSchema,
5453
// they can still access the original default block schema
55-
export type _DefaultBlockSchema = Omit<
56-
{
57-
[K in keyof typeof defaultBlockSpecs]: (typeof defaultBlockSpecs)[K]["config"];
58-
},
59-
"table"
60-
> & {
61-
table: BlockConfig<
62-
"table",
63-
{
64-
textColor: {
65-
default: "default";
66-
};
67-
},
68-
"table"
69-
>;
54+
export type _DefaultBlockSchema = {
55+
[K in keyof typeof defaultBlockSpecs]: (typeof defaultBlockSpecs)[K]["config"];
7056
};
7157
export type DefaultBlockSchema = _DefaultBlockSchema;
7258

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,10 @@ export class BlockNoteEditor<
872872
? () => {
873873
return Object.fromEntries(
874874
Object.entries(ext.keyboardShortcuts!).map(
875-
([key, value]) => [key, () => value({ editor: this })],
875+
([key, value]) => [
876+
key,
877+
() => value({ editor: this as any }),
878+
],
876879
),
877880
);
878881
}

packages/core/src/editor/BlockNoteExtension.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Plugin } from "prosemirror-state";
22
import { EventEmitter } from "../util/EventEmitter.js";
33

4-
import { BlockNoteEditor } from "./BlockNoteEditor.js";
5-
import { PartialBlockNoDefaults } from "../schema/index.js";
64
import { AnyExtension } from "@tiptap/core";
5+
import {
6+
BlockSchema,
7+
InlineContentSchema,
8+
PartialBlockNoDefaults,
9+
StyleSchema,
10+
} from "../schema/index.js";
11+
import { BlockNoteEditor } from "./BlockNoteEditor.js";
712

813
export abstract class BlockNoteExtension<
914
TEvent extends Record<string, any> = any,
@@ -33,11 +38,32 @@ export abstract class BlockNoteExtension<
3338
*/
3439
public inputRules?: InputRule[];
3540

41+
/**
42+
* A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed
43+
*
44+
* The keys are in the format:
45+
* - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers
46+
* - Key identifiers are based on the strings that can appear in KeyEvent.key
47+
* - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)
48+
* - You may use `Space` as an alias for the " " name
49+
* - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)
50+
* - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly
51+
* - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms
52+
*
53+
* @example
54+
* ```typescript
55+
* keyboardShortcuts: {
56+
* "Mod-Enter": (ctx) => { return true; },
57+
* "Shift-Ctrl-Space": (ctx) => { return true; },
58+
* "a": (ctx) => { return true; },
59+
* "Space": (ctx) => { return true; }
60+
* }
61+
* ```
62+
*/
3663
public keyboardShortcuts?: Record<
3764
string,
3865
(ctx: {
39-
// TODO types
40-
editor: BlockNoteEditor<any, any, any>;
66+
editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>;
4167
}) => boolean
4268
>;
4369

0 commit comments

Comments
 (0)