Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

editor: fix images from older version not rendering in outline list Signed-off-by: 01zulfi <[email protected]>

01zulfi78e467287199
diff --git a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts b/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
index 499fddb89..9b0801dfb 100644
--- a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
+++ b/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
@@ -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;
+ }
}
];
},