Skip to content

Commit d15becc

Browse files
committed
merge and build
1 parent 56f4245 commit d15becc

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

packages/core/src/api/blockManipulation/commands/insertBlocks/insertBlocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function insertBlocks<
2929
const pmSchema = getPmSchema(tr);
3030
const nodesToInsert = blocksToInsert.map((block) =>
3131
blockToNode(
32-
partialBlockToBlock(getBlockNoteSchema(pmSchema), block),
32+
partialBlockToBlock<BSchema, I, S>(getBlockNoteSchema(pmSchema), block),
3333
pmSchema,
3434
),
3535
);

packages/core/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function removeAndInsertBlocks<
3030
// document.
3131
const nodesToInsert: Node[] = blocksToInsert.map((block) =>
3232
blockToNode(
33-
partialBlockToBlock(getBlockNoteSchema(pmSchema), block),
33+
partialBlockToBlock<BSchema, I, S>(getBlockNoteSchema(pmSchema), block),
3434
pmSchema,
3535
),
3636
);

packages/core/src/api/nodeConversions/blockToNode.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Attrs, Fragment, Mark, Node, Schema } from "@tiptap/pm/model";
22

33
import type {
4+
BlockSchema,
45
CustomInlineContentFromConfig,
56
InlineContent,
67
InlineContentSchema,
@@ -320,10 +321,14 @@ function blockOrInlineContentToContentNode(
320321
/**
321322
* Converts a BlockNote block to a Prosemirror node.
322323
*/
323-
export function blockToNode(
324-
block: Block<any, any, any>,
324+
export function blockToNode<
325+
BSchema extends BlockSchema,
326+
I extends InlineContentSchema,
327+
S extends StyleSchema,
328+
>(
329+
block: Block<BSchema, I, S>,
325330
schema: Schema,
326-
styleSchema: StyleSchema = getStyleSchema(schema),
331+
styleSchema: S = getStyleSchema(schema),
327332
) {
328333
const children: Node[] = [];
329334

packages/core/src/api/pmUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Node, Schema } from "prosemirror-model";
22
import { Transform } from "prosemirror-transform";
33
import type { BlockNoteEditor } from "../editor/BlockNoteEditor.js";
4-
import { CustomBlockNoteSchema } from "../schema/schema.js";
54
import type { BlockSchema } from "../schema/blocks/types.js";
5+
import { CustomBlockNoteSchema } from "../schema/CustomBlockNoteSchema.js";
66
import type { InlineContentSchema } from "../schema/inlineContent/types.js";
77
import type { StyleSchema } from "../schema/styles/types.js";
88

packages/core/src/schema/partialBlockToBlock.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,18 @@ function partialPropsToProps(
3131
): Props<PropSchema> {
3232
const props: Props<PropSchema> = partialProps || {};
3333

34-
Object.entries(propSchema._zod.def.shape).forEach(([propKey, propValue]) => {
35-
if (props[propKey] === undefined) {
36-
if (propValue instanceof z.$ZodDefault) {
37-
props[propKey] = propValue._zod.def.defaultValue;
34+
Object.entries(propSchema._zodSource._zod.def.shape).forEach(
35+
([propKey, propValue]) => {
36+
if (props[propKey] === undefined) {
37+
if (propValue instanceof z.$ZodDefault) {
38+
props[propKey] = propValue._zod.def.defaultValue;
39+
}
40+
if (propValue instanceof z.$ZodOptional) {
41+
props[propKey] = undefined;
42+
}
3843
}
39-
if (propValue instanceof z.$ZodOptional) {
40-
props[propKey] = undefined;
41-
}
42-
}
43-
});
44+
},
45+
);
4446
return props;
4547
}
4648

@@ -64,7 +66,9 @@ function partialLinkToLink(partialLink: PartialLink<StyleSchema>): Link<any> {
6466
}
6567

6668
export function partialInlineContentToInlineContent(
67-
partialInlineContent: PartialInlineContent<any, any> | undefined,
69+
partialInlineContent:
70+
| PartialInlineContent<InlineContentSchema, StyleSchema>
71+
| undefined,
6872
inlineContentSchema: InlineContentSchema,
6973
): InlineContent<any, any>[] {
7074
if (partialInlineContent === undefined) {

0 commit comments

Comments
 (0)