Skip to content

Commit 41d1449

Browse files
committed
build: finally get all the builds building
1 parent 95c493a commit 41d1449

File tree

8 files changed

+64
-49
lines changed

8 files changed

+64
-49
lines changed

examples/03-ui-components/13-custom-ui/src/MUIFormattingToolbar.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,24 @@ function MUITextAlignButton(props: {
266266
const editor = useBlockNoteEditor<TextBlockSchema>();
267267

268268
// The text alignment of the block currently containing the text cursor.
269-
const [activeTextAlignment, setActiveTextAlignment] = useState(
270-
() => editor.getTextCursorPosition().block.props.textAlignment,
271-
);
269+
const [activeTextAlignment, setActiveTextAlignment] = useState(() => {
270+
const props = editor.getTextCursorPosition().block.props;
271+
if ("textAlignment" in props) {
272+
return props.textAlignment;
273+
}
274+
return undefined;
275+
});
272276

273277
// Updates the text alignment when the editor content or selection changes.
274-
useEditorContentOrSelectionChange(
275-
() =>
276-
setActiveTextAlignment(
277-
editor.getTextCursorPosition().block.props.textAlignment,
278-
),
279-
editor,
280-
);
278+
useEditorContentOrSelectionChange(() => {
279+
setActiveTextAlignment(() => {
280+
const props = editor.getTextCursorPosition().block.props;
281+
if ("textAlignment" in props) {
282+
return props.textAlignment;
283+
}
284+
return undefined;
285+
});
286+
}, editor);
281287

282288
// Tooltip for the button.
283289
const tooltip = useMemo(

packages/core/src/blocks/BlockNoteSchema.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export class BlockNoteSchema<
2222
SSchema extends StyleSchema,
2323
> extends CustomBlockNoteSchema<BSchema, ISchema, SSchema> {
2424
public static create<
25-
BSpecs extends BlockSpecs = typeof defaultBlockSpecs,
26-
ISpecs extends InlineContentSpecs = typeof defaultInlineContentSpecs,
27-
SSpecs extends StyleSpecs = typeof defaultStyleSpecs,
25+
BSpecs extends BlockSpecs | undefined = undefined,
26+
ISpecs extends InlineContentSpecs | undefined = undefined,
27+
SSpecs extends StyleSpecs | undefined = undefined,
2828
>(options?: {
2929
/**
3030
* A list of custom block types that should be available in the editor.
@@ -38,12 +38,18 @@ export class BlockNoteSchema<
3838
* A list of custom Styles that should be available in the editor.
3939
*/
4040
styleSpecs?: SSpecs;
41-
}) {
42-
return new BlockNoteSchema<
43-
BlockSchemaFromSpecs<BSpecs>,
44-
InlineContentSchemaFromSpecs<ISpecs>,
45-
StyleSchemaFromSpecs<SSpecs>
46-
>({
41+
}): BlockNoteSchema<
42+
BSpecs extends undefined
43+
? BlockSchemaFromSpecs<typeof defaultBlockSpecs>
44+
: BlockSchemaFromSpecs<NonNullable<BSpecs>>,
45+
ISpecs extends undefined
46+
? InlineContentSchemaFromSpecs<typeof defaultInlineContentSpecs>
47+
: InlineContentSchemaFromSpecs<NonNullable<ISpecs>>,
48+
SSpecs extends undefined
49+
? StyleSchemaFromSpecs<typeof defaultStyleSpecs>
50+
: StyleSchemaFromSpecs<NonNullable<SSpecs>>
51+
> {
52+
return new BlockNoteSchema<any, any, any>({
4753
blockSpecs: options?.blockSpecs ?? defaultBlockSpecs,
4854
inlineContentSpecs:
4955
options?.inlineContentSpecs ?? defaultInlineContentSpecs,

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ import { createExternalHTMLExporter } from "../api/exporters/html/externalHTMLEx
5858
import { createInternalHTMLSerializer } from "../api/exporters/html/internalHTMLSerializer.js";
5959
import { blocksToMarkdown } from "../api/exporters/markdown/markdownExporter.js";
6060
import { getBlockInfoFromTransaction } from "../api/getBlockInfoFromPos.js";
61-
import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js";
62-
import { docToBlocks } from "../api/nodeConversions/nodeToBlock.js";
6361
import {
6462
BlocksChanged,
6563
getBlocksChangedByTransaction,
6664
} from "../api/getBlocksChangedByTransaction.js";
65+
import { inlineContentToNodes } from "../api/nodeConversions/blockToNode.js";
66+
import { docToBlocks } from "../api/nodeConversions/nodeToBlock.js";
6767
import { HTMLToBlocks } from "../api/parsers/html/parseHTML.js";
6868
import { nestedListsToBlockNoteStructure } from "../api/parsers/html/util/nestedLists.js";
6969
import {
@@ -570,11 +570,19 @@ export class BlockNoteEditor<
570570
};
571571

572572
public static create<
573-
BSchema extends BlockSchema = DefaultBlockSchema,
574-
ISchema extends InlineContentSchema = DefaultInlineContentSchema,
575-
SSchema extends StyleSchema = DefaultStyleSchema,
576-
>(options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>> = {}) {
577-
return new BlockNoteEditor<BSchema, ISchema, SSchema>(options);
573+
Options extends Partial<BlockNoteEditorOptions<any, any, any>> | undefined,
574+
>(
575+
options?: Options,
576+
): Options extends {
577+
schema: CustomBlockNoteSchema<infer BSchema, infer ISchema, infer SSchema>;
578+
}
579+
? BlockNoteEditor<BSchema, ISchema, SSchema>
580+
: BlockNoteEditor<
581+
DefaultBlockSchema,
582+
DefaultInlineContentSchema,
583+
DefaultStyleSchema
584+
> {
585+
return new BlockNoteEditor(options as any) as any;
578586
}
579587

580588
protected constructor(

packages/core/src/schema/propTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type PropSpec<PType extends boolean | number | string> =
99
| {
1010
// We infer the type of the prop from the default value
1111
default: PType;
12-
type?: "string" | "number" | "boolean";
12+
// type?: "string" | "number" | "boolean";
1313
// a list of possible values, for example for a string prop (this will then be used as a string union type)
1414
values?: readonly PType[];
1515
}

packages/core/src/schema/schema.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ import {
1010
InlineContentSpecs,
1111
LooseBlockSpec,
1212
PartialBlockNoDefaults,
13-
StyleConfig,
1413
StyleSchema,
15-
StyleSpec,
1614
StyleSpecs,
1715
addNodeAndExtensionsToSpec,
1816
getInlineContentSchemaFromSpecs,
@@ -161,10 +159,7 @@ export class CustomBlockNoteSchema<
161159
string,
162160
InlineContentSpec<InlineContentConfig>
163161
> = Record<string, never>,
164-
AdditionalStyleSpecs extends Record<
165-
string,
166-
StyleSpec<StyleConfig>
167-
> = Record<string, never>,
162+
AdditionalStyleSpecs extends StyleSpecs = Record<string, never>,
168163
>(opts: {
169164
blockSpecs?: AdditionalBlockSpecs;
170165
inlineContentSpecs?: AdditionalInlineContentSpecs;

packages/core/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"declarationDir": "types",
2020
"emitDeclarationOnly": true,
2121
"composite": true,
22-
"skipLibCheck": true
22+
"skipLibCheck": true,
23+
"noErrorTruncation": true
2324
},
2425
"include": ["src"]
2526
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
11
import {
22
BlockNoteEditor,
33
BlockNoteEditorOptions,
4-
BlockSchema,
4+
CustomBlockNoteSchema,
55
DefaultBlockSchema,
66
DefaultInlineContentSchema,
77
DefaultStyleSchema,
8-
InlineContentSchema,
9-
StyleSchema,
108
} from "@blocknote/core";
119
import { DependencyList, useMemo } from "react";
1210

1311
/**
1412
* Hook to instantiate a BlockNote Editor instance in React
1513
*/
1614
export const useCreateBlockNote = <
17-
BSchema extends BlockSchema = DefaultBlockSchema,
18-
ISchema extends InlineContentSchema = DefaultInlineContentSchema,
19-
SSchema extends StyleSchema = DefaultStyleSchema,
15+
Options extends Partial<BlockNoteEditorOptions<any, any, any>> | undefined,
2016
>(
21-
options: Partial<BlockNoteEditorOptions<BSchema, ISchema, SSchema>> = {},
17+
options: Options = {} as Options,
2218
deps: DependencyList = [],
23-
) => {
19+
): Options extends {
20+
schema: CustomBlockNoteSchema<infer BSchema, infer ISchema, infer SSchema>;
21+
}
22+
? BlockNoteEditor<BSchema, ISchema, SSchema>
23+
: BlockNoteEditor<
24+
DefaultBlockSchema,
25+
DefaultInlineContentSchema,
26+
DefaultStyleSchema
27+
> => {
2428
return useMemo(() => {
25-
const editor = BlockNoteEditor.create<BSchema, ISchema, SSchema>(options);
29+
const editor = BlockNoteEditor.create(options) as any;
2630
if (window) {
2731
// for testing / dev purposes
2832
(window as any).ProseMirror = editor._tiptapEditor;
2933
}
3034
return editor;
3135
}, deps); //eslint-disable-line react-hooks/exhaustive-deps
3236
};
33-
34-
/**
35-
* @deprecated use useCreateBlockNote instead
36-
*/
37-
export const useBlockNote = useCreateBlockNote;

packages/server-util/src/context/ServerBlockNoteEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export class ServerBlockNoteEditor<
9292
this.editor = BlockNoteEditor.create({
9393
...options,
9494
_headless: true,
95-
});
95+
}) as any;
9696
}
9797

9898
/** PROSEMIRROR / BLOCKNOTE conversions */

0 commit comments

Comments
 (0)