Skip to content

Commit 0920bf9

Browse files
committed
address feedback
1 parent 53bd6d7 commit 0920bf9

File tree

19 files changed

+48
-58
lines changed

19 files changed

+48
-58
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
BlockIdentifier,
77
BlockSchema,
88
InlineContentSchema,
9-
partialBlockToFullBlock,
9+
partialBlockToBlock,
1010
StyleSchema,
1111
} from "../../../../schema/index.js";
1212
import { blockToNode } from "../../../nodeConversions/blockToNode.js";
@@ -20,7 +20,6 @@ export function insertBlocks<
2020
S extends StyleSchema,
2121
>(
2222
tr: Transaction,
23-
// TBD: allow PartialBlock here?
2423
blocksToInsert: PartialBlock<BSchema, I, S>[],
2524
referenceBlock: BlockIdentifier,
2625
placement: "before" | "after" = "before",
@@ -30,7 +29,7 @@ export function insertBlocks<
3029
const pmSchema = getPmSchema(tr);
3130
const nodesToInsert = blocksToInsert.map((block) =>
3231
blockToNode(
33-
partialBlockToFullBlock(getBlockNoteSchema(pmSchema), block),
32+
partialBlockToBlock(getBlockNoteSchema(pmSchema), block),
3433
pmSchema,
3534
),
3635
);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Node } from "prosemirror-model";
22
import type { Transaction } from "prosemirror-state";
33
import type { Block, PartialBlock } from "../../../../blocks/defaultBlocks.js";
44
import {
5-
partialBlockToFullBlock,
5+
partialBlockToBlock,
66
type BlockIdentifier,
77
type BlockSchema,
88
type InlineContentSchema,
@@ -30,7 +30,7 @@ export function removeAndInsertBlocks<
3030
// document.
3131
const nodesToInsert: Node[] = blocksToInsert.map((block) =>
3232
blockToNode(
33-
partialBlockToFullBlock(getBlockNoteSchema(pmSchema), block),
33+
partialBlockToBlock(getBlockNoteSchema(pmSchema), block),
3434
pmSchema,
3535
),
3636
);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ import type {
1515
} from "../../../../schema/blocks/types.js";
1616
import type { InlineContentSchema } from "../../../../schema/inlineContent/types.js";
1717
import {
18-
partialBlockToFullBlock,
18+
partialBlockToBlock,
1919
partialInlineContentToInlineContent,
2020
partialTableContentToTableContent,
21-
} from "../../../../schema/partialBlockToFullBlock.js";
21+
} from "../../../../schema/partialBlockToBlock.js";
2222
import type { StyleSchema } from "../../../../schema/styles/types.js";
2323
import { UnreachableCaseError } from "../../../../util/typescript.js";
2424
import {
@@ -132,7 +132,7 @@ export function updateBlockTr<
132132
// currently, we calculate the new node and replace the entire node with the desired new node.
133133
// for this, we do a nodeToBlock on the existing block to get the children.
134134
// it would be cleaner to use a ReplaceAroundStep, but this is a bit simpler and it's quite an edge case
135-
const newFullBlock = partialBlockToFullBlock(schema, block);
135+
const newFullBlock = partialBlockToBlock(schema, block);
136136
if (block.children === undefined) {
137137
// if no children are passed in, use existing children
138138
const existingBlock = nodeToBlock<BSchema, I, S>(
@@ -300,7 +300,7 @@ function updateChildren<
300300
const schema = getBlockNoteSchema<BSchema, I, S>(pmSchema);
301301
if (block.children !== undefined && block.children.length > 0) {
302302
const childNodes = block.children.map((child) => {
303-
return blockToNode(partialBlockToFullBlock(schema, child), pmSchema);
303+
return blockToNode(partialBlockToBlock(schema, child), pmSchema);
304304
});
305305

306306
// Checks if a blockGroup node already exists.

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ function blockOrInlineContentToContentNode(
282282

283283
// TODO: needed? came from previous code
284284
if (type === undefined) {
285+
// TODO: remove
285286
type = "paragraph";
286287
}
287288

packages/core/src/editor/BlockNoteEditor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { UniqueID } from "../extensions/UniqueID/UniqueID.js";
3838
import type { Dictionary } from "../i18n/dictionary.js";
3939
import { en } from "../i18n/locales/index.js";
4040
import {
41-
partialBlockToFullBlock,
41+
partialBlockToBlock,
4242
type BlockIdentifier,
4343
type BlockNoteDOMAttributes,
4444
type BlockSchema,
@@ -891,7 +891,7 @@ export class BlockNoteEditor<
891891
const schema = getSchema(tiptapOptions.extensions!);
892892
const pmNodes = initialContent.map((b) =>
893893
blockToNode(
894-
partialBlockToFullBlock(this.schema, b),
894+
partialBlockToBlock(this.schema, b),
895895
schema,
896896
this.schema.styleSchema,
897897
).toJSON(),

packages/core/src/extensions/TableHandles/TableHandlesPlugin.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,7 @@ export class TableHandlesView<
282282
this.editor.schema.styleSchema,
283283
);
284284

285-
if (
286-
blockHasType(
287-
block,
288-
this.editor,
289-
"table",
290-
defaultBlockSpecs.table.config.propSchema,
291-
)
292-
) {
285+
if (blockHasType(block, this.editor, "table")) {
293286
this.tablePos = pmNodeInfo.posBeforeNode + 1;
294287
tableBlock = block;
295288
}

packages/core/src/schema/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export * from "./CustomBlockNoteSchema.js";
66
export * from "./inlineContent/createSpec.js";
77
export * from "./inlineContent/internal.js";
88
export * from "./inlineContent/types.js";
9-
export * from "./partialBlockToFullBlock.js";
9+
export * from "./partialBlockToBlock.js";
1010
export * from "./propTypes.js";
1111
export * from "./styles/createSpec.js";
1212
export * from "./styles/internal.js";

packages/core/src/schema/inlineContent/createSpec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { inlineContentToNodes } from "../../api/nodeConversions/blockToNode.js";
55
import { nodeToCustomInlineContent } from "../../api/nodeConversions/nodeToBlock.js";
66
import type { BlockNoteEditor } from "../../editor/BlockNoteEditor.js";
77
import { propsToAttributes } from "../blocks/internal.js";
8-
import { partialInlineContentToInlineContent } from "../partialBlockToFullBlock.js";
8+
import { partialInlineContentToInlineContent } from "../partialBlockToBlock.js";
99
import { Props } from "../propTypes.js";
1010
import { StyleSchema } from "../styles/types.js";
1111
import {

packages/core/src/schema/partialBlockToFullBlock.ts renamed to packages/core/src/schema/partialBlockToBlock.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as z from "zod/v4/core";
2-
import type { Block, BlockNoteSchema, PartialBlock } from "../blocks/index.js";
2+
import type { Block, PartialBlock } from "../blocks/index.js";
33
import { UniqueID } from "../extensions/UniqueID/UniqueID.js";
44
import { mapTableCell } from "../util/table.js";
55
import { UnreachableCaseError } from "../util/typescript.js";
@@ -204,7 +204,7 @@ function partialBlockContentToBlockContent(
204204
}
205205
}
206206

207-
export function partialBlockToFullBlock<
207+
export function partialBlockToBlock<
208208
BSchema extends BlockSchema,
209209
I extends InlineContentSchema,
210210
S extends StyleSchema,
@@ -229,9 +229,8 @@ export function partialBlockToFullBlock<
229229
);
230230

231231
const children =
232-
partialBlock.children?.map((child) =>
233-
partialBlockToFullBlock(schema, child),
234-
) || [];
232+
partialBlock.children?.map((child) => partialBlockToBlock(schema, child)) ||
233+
[];
235234

236235
return {
237236
id,
@@ -242,17 +241,15 @@ export function partialBlockToFullBlock<
242241
} as Block<BSchema, I, S>;
243242
}
244243

245-
export function partialBlocksToFullBlocks<
244+
export function partialBlocksToBlocks<
246245
BSchema extends BlockSchema,
247246
I extends InlineContentSchema,
248247
S extends StyleSchema,
249248
>(
250-
// TODO: I think this should be a CustomBlockNoteSchema,
251-
// but that breaks docxExporter etc
252-
schema: BlockNoteSchema<BSchema, I, S>,
249+
schema: CustomBlockNoteSchema<BSchema, I, S>,
253250
partialBlocks: PartialBlock<BSchema, I, S>[],
254251
): Block<BSchema, I, S>[] {
255252
return partialBlocks.map((partialBlock) =>
256-
partialBlockToFullBlock(schema, partialBlock),
253+
partialBlockToBlock(schema, partialBlock),
257254
);
258255
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
createExternalHTMLExporter,
1616
createInternalHTMLSerializer,
1717
nodeToBlock,
18-
partialBlockToFullBlock,
18+
partialBlockToBlock,
1919
} from "@blocknote/core";
2020

2121
import { BlockNoteViewRaw } from "@blocknote/react";
@@ -140,7 +140,7 @@ export class ServerBlockNoteEditor<
140140
) {
141141
const pmSchema = this.editor.pmSchema;
142142
const pmNodes = blocks.map((b) =>
143-
blockToNode(partialBlockToFullBlock(this.editor.schema, b), pmSchema),
143+
blockToNode(partialBlockToBlock(this.editor.schema, b), pmSchema),
144144
);
145145

146146
const doc = pmSchema.topNodeType.create(

0 commit comments

Comments
 (0)