Skip to content
Open
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 @@ -227,7 +227,8 @@ function serializeBlock<

const elementFragment = doc.createDocumentFragment();

if ((ret.dom as HTMLElement).classList.contains("bn-block-content")) {
// Needs optional chaining for handling <ol> lists export
if ((ret.dom as HTMLElement).classList?.contains("bn-block-content")) {
const blockContentDataAttributes = [
...attrs,
...Array.from((ret.dom as HTMLElement).attributes),
Expand All @@ -242,13 +243,12 @@ function serializeBlock<
attr.name !== "data-editable",
);

// ret.dom = ret.dom.firstChild! as any;
for (const attr of blockContentDataAttributes) {
(ret.dom.firstChild! as HTMLElement).setAttribute(attr.name, attr.value);
}

addAttributesAndRemoveClasses(ret.dom.firstChild! as HTMLElement);
if (nestingLevel > 0) {
if (nestingLevel > 0 && typeof (ret.dom.firstChild as HTMLElement)?.setAttribute === 'function') {
(ret.dom.firstChild! as HTMLElement).setAttribute(
"data-nesting-level",
nestingLevel.toString(),
Expand All @@ -257,7 +257,7 @@ function serializeBlock<
elementFragment.append(...Array.from(ret.dom.childNodes));
} else {
elementFragment.append(ret.dom);
if (nestingLevel > 0) {
if (nestingLevel > 0 && typeof (ret.dom as HTMLElement).setAttribute === 'function') {
(ret.dom as HTMLElement).setAttribute(
"data-nesting-level",
nestingLevel.toString(),
Expand Down