editor: fix images from older version not rendering in outline list

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2025-10-29 11:24:05 +05:00
parent 17b14e0ac6
commit 78e4672871

View File

@@ -29,6 +29,7 @@ import {
import { OutlineList } from "../outline-list/outline-list.js";
import { keybindings, tiptapKeys } from "@notesnook/common";
import { Paragraph } from "../paragraph/paragraph.js";
import { DOMParser } from "@tiptap/pm/model";
export interface ListItemOptions {
HTMLAttributes: Record<string, unknown>;
@@ -64,7 +65,18 @@ export const OutlineListItem = Node.create<ListItemOptions>({
return [
{
priority: 100,
tag: `li[data-type="${this.name}"]`
tag: `li[data-type="${this.name}"]`,
getContent: (node, schema) => {
const parser = DOMParser.fromSchema(schema);
const fragment = parser.parse(node).content;
const firstNode = fragment.firstChild;
if (firstNode && firstNode.type.name !== "paragraph") {
const emptyParagraph = schema.nodes.paragraph.create();
return fragment.addToStart(emptyParagraph);
}
return fragment;
}
}
];
},