diff --git a/packages/editor/patches/@tiptap+core+2.1.12.patch b/packages/editor/patches/@tiptap+core+2.1.12.patch index 92ebbd892..89f8ede1a 100644 --- a/packages/editor/patches/@tiptap+core+2.1.12.patch +++ b/packages/editor/patches/@tiptap+core+2.1.12.patch @@ -1,3 +1,33 @@ +diff --git a/node_modules/@tiptap/core/dist/index.cjs b/node_modules/@tiptap/core/dist/index.cjs +index d61da68..31ceb87 100644 +--- a/node_modules/@tiptap/core/dist/index.cjs ++++ b/node_modules/@tiptap/core/dist/index.cjs +@@ -1880,8 +1880,23 @@ const lift = (typeOrName, attributes = {}) => ({ state, dispatch }) => { + return commands$1.lift(state, dispatch); + }; + +-const liftEmptyBlock = () => ({ state, dispatch }) => { +- return commands$1.liftEmptyBlock(state, dispatch); ++const liftEmptyBlock = () => ({ state, dispatch, editor }) => { ++ return commands$1.liftEmptyBlock$1(state, (tr) => { ++ if (!dispatch) return true; ++ ++ const { selection, storedMarks } = state; ++ const marks = storedMarks || (selection.$to.parentOffset && selection.$from.marks()); ++ ++ if (!marks) return dispatch(tr); ++ ++ const { splittableMarks } = editor.extensionManager; ++ const filteredMarks = marks.filter((mark) => ++ splittableMarks.includes(mark.type.name) ++ ); ++ tr.ensureMarks(filteredMarks) ++ ++ return dispatch(tr); ++ }); + }; + + const liftListItem = typeOrName => ({ state, dispatch }) => { diff --git a/node_modules/@tiptap/core/dist/index.js b/node_modules/@tiptap/core/dist/index.js index 38c9884..4a9e10c 100644 --- a/node_modules/@tiptap/core/dist/index.js diff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsx index cd0376fad..9ba8cb011 100644 --- a/packages/editor/src/extensions/image/component.tsx +++ b/packages/editor/src/extensions/image/component.tsx @@ -97,12 +97,21 @@ export function ImageComponent( if (!inView) return; if (src || !hash || bloburl) return; (async function () { - const data = await editor.storage - .getAttachmentData?.(node.attrs) - .catch(() => null); - if (typeof data !== "string" || !data) return; // TODO: show error + const { hash, filename, mime, size } = node.attrs; + if (!!hash && !!filename && !!mime && !!size) { + const data = await editor.storage + .getAttachmentData?.({ + type: "image", + hash, + filename, + mime, + size + }) + .catch(() => null); + if (typeof data !== "string" || !data) return; // TODO: show error - setBloburl(toBlobURL(data, "image", node.attrs.mime, hash)); + setBloburl(toBlobURL(data, "image", node.attrs.mime, hash)); + } })(); }, [inView]); diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts index 3afe9c9be..7296d4c39 100644 --- a/packages/editor/src/index.ts +++ b/packages/editor/src/index.ts @@ -101,7 +101,9 @@ interface TiptapStorage { createInternalLink?: ( attributes?: LinkAttributes ) => Promise; - getAttachmentData: (attachment: Attachment) => Promise; + getAttachmentData: + | ((attachment: Attachment) => Promise) + | undefined; } declare module "@tiptap/core" {