Skip to content

Commit bbe2299

Browse files
committed
small fixes
1 parent 282a966 commit bbe2299

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

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

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function linkToNodes(
110110
* prosemirror text nodes with the appropriate marks
111111
*/
112112
function styledTextArrayToNodes<S extends StyleSchema>(
113+
// this is lenient to "partial" inline content. FIXME: let's simplify and remove support for `string` here
113114
content: string | StyledText<S>[],
114115
schema: Schema,
115116
styleSchema: S,
@@ -144,6 +145,7 @@ export function inlineContentToNodes<
144145
I extends InlineContentSchema,
145146
S extends StyleSchema,
146147
>(
148+
// this is lenient to "partial" inline content. FIXME: let's simplify and remove support for `string[]` here
147149
blockContent: string[] | InlineContent<I, S>[],
148150
schema: Schema,
149151
blockType?: string,
@@ -278,40 +280,34 @@ function blockOrInlineContentToContentNode(
278280
schema: Schema,
279281
styleSchema: StyleSchema,
280282
) {
283+
const type = block.type;
281284
let contentNode: Node;
282-
let type = block.type;
283-
284-
// TODO: needed? came from previous code
285-
if (type === undefined) {
286-
// TODO: remove
287-
type = "paragraph";
288-
}
289285

290286
if (!schema.nodes[type]) {
291287
throw new Error(`node type ${type} not found in schema`);
292288
}
293289

294290
if (!block.content) {
295-
contentNode = schema.nodes[type].createChecked(block.props as any);
291+
contentNode = schema.nodes[type].createChecked(block.props);
296292
} else if (typeof block.content === "string") {
297293
const nodes = inlineContentToNodes(
298294
[block.content],
299295
schema,
300296
type,
301297
styleSchema,
302298
);
303-
contentNode = schema.nodes[type].createChecked(block.props as any, nodes);
299+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
304300
} else if (Array.isArray(block.content)) {
305301
const nodes = inlineContentToNodes(
306302
block.content,
307303
schema,
308304
type,
309305
styleSchema,
310306
);
311-
contentNode = schema.nodes[type].createChecked(block.props as any, nodes);
307+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
312308
} else if (block.content.type === "tableContent") {
313309
const nodes = tableContentToNodes(block.content, schema, styleSchema);
314-
contentNode = schema.nodes[type].createChecked(block.props as any, nodes);
310+
contentNode = schema.nodes[type].createChecked(block.props, nodes);
315311
} else {
316312
throw new UnreachableCaseError(block.content.type);
317313
}

packages/core/src/schema/partialBlockToBlock.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ export function partialBlockToBlock<
218218
): Block<BSchema, I, S> {
219219
const id = partialBlock.id || UniqueID.options.generateID();
220220

221-
// TODO
221+
// Note: we might want to make "type" required for partial blocks and remove this default
222222
const type: string = partialBlock.type || "paragraph";
223223

224224
const props = partialPropsToProps(

0 commit comments

Comments
 (0)