mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
];
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user