Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function insertBlocks<
// re-convert them into full `Block`s.
const insertedBlocks = nodesToInsert.map((node) =>
nodeToBlock(node, pmSchema),
);
) as Block<BSchema, I, S>[];

return insertedBlocks;
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export function removeAndInsertBlocks<
// Converts the nodes created from `blocksToInsert` into full `Block`s.
const insertedBlocks = nodesToInsert.map((node) =>
nodeToBlock(node, pmSchema),
);
) as Block<BSchema, I, S>[];

return { insertedBlocks, removedBlocks };
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function fragmentToExternalHTML<
);
externalHTML = externalHTMLExporter.exportInlineContent(ic, {});
} else {
const blocks = fragmentToBlocks(selectedFragment);
const blocks = fragmentToBlocks<BSchema, I, S>(selectedFragment);
externalHTML = externalHTMLExporter.exportBlocks(blocks, {});
}
return externalHTML;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,19 @@ function serializeBlock<
// we should change toExternalHTML so that this is not necessary
const attrs = Array.from(bc.dom.attributes);

const ret = editor.blockImplementations[
block.type as any
].implementation.toExternalHTML({ ...block, props } as any, editor as any);
const blockImplementation =
editor.blockImplementations[block.type as any].implementation;
const ret =
blockImplementation.toExternalHTML?.(
{ ...block, props } as any,
editor as any,
) || blockImplementation.render({ ...block, props } as any, editor as any);

const elementFragment = doc.createDocumentFragment();
if (ret.dom.classList.contains("bn-block-content")) {
if (
ret.dom instanceof HTMLElement &&
ret.dom.classList.contains("bn-block-content")
) {
const blockContentDataAttributes = [
...attrs,
...Array.from(ret.dom.attributes),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function serializeBlock<
}

const impl = editor.blockImplementations[block.type as any].implementation;
const ret = impl.toInternalHTML({ ...block, props } as any, editor as any);
const ret = impl.render({ ...block, props } as any, editor as any);

if (block.type === "numberedListItem") {
// This is a workaround to make sure there's a list index set.
Expand All @@ -83,7 +83,9 @@ function serializeBlock<
// - (a) this information is not available on the Blocks passed to the serializer. (we only have access to BlockNote Blocks)
// - (b) the NumberedListIndexingPlugin might not even have run, because we can manually call blocksToFullHTML
// with blocks that are not part of the active document
ret.dom.setAttribute("data-index", listIndex.toString());
if (ret.dom instanceof HTMLElement) {
ret.dom.setAttribute("data-index", listIndex.toString());
}
}

if (ret.contentDOM && block.content) {
Expand Down
135 changes: 0 additions & 135 deletions packages/core/src/blks/Audio/definition.ts

This file was deleted.

89 changes: 0 additions & 89 deletions packages/core/src/blks/File/definition.ts

This file was deleted.

Loading
Loading