mirror of
https://github.com/docmost/docmost.git
synced 2026-08-24 17:22:15 +10:00
fix(editor-ext): stop persisting unfurl data on integration link nodes
This commit is contained in:
@@ -10,12 +10,12 @@ export interface IntegrationLinkOptions {
|
|||||||
export interface IntegrationLinkAttributes {
|
export interface IntegrationLinkAttributes {
|
||||||
url: string;
|
url: string;
|
||||||
provider: string;
|
provider: string;
|
||||||
unfurlData: Record<string, any> | null;
|
|
||||||
status: "pending" | "loaded" | "error";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shared by IntegrationLink (block) and IntegrationMention (inline) so both
|
// Shared by IntegrationLink (block) and IntegrationMention (inline) so both
|
||||||
// serialize the same attrs and stay convertible into each other.
|
// serialize the same attrs and stay convertible into each other. Unfurl data
|
||||||
|
// is intentionally NOT an attribute: it is fetched per viewer at render time
|
||||||
|
// so third-party permissions apply on every view.
|
||||||
export function createIntegrationAttributes() {
|
export function createIntegrationAttributes() {
|
||||||
return {
|
return {
|
||||||
url: {
|
url: {
|
||||||
@@ -35,31 +35,6 @@ export function createIntegrationAttributes() {
|
|||||||
"data-provider": attributes.provider,
|
"data-provider": attributes.provider,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
unfurlData: {
|
|
||||||
default: null,
|
|
||||||
parseHTML: (element: HTMLElement) => {
|
|
||||||
const data = element.getAttribute("data-unfurl");
|
|
||||||
if (!data) return null;
|
|
||||||
try {
|
|
||||||
return JSON.parse(data);
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
renderHTML: (attributes: IntegrationLinkAttributes) => ({
|
|
||||||
"data-unfurl": attributes.unfurlData
|
|
||||||
? JSON.stringify(attributes.unfurlData)
|
|
||||||
: null,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
status: {
|
|
||||||
default: "pending",
|
|
||||||
parseHTML: (element: HTMLElement) =>
|
|
||||||
element.getAttribute("data-status") ?? "pending",
|
|
||||||
renderHTML: (attributes: IntegrationLinkAttributes) => ({
|
|
||||||
"data-status": attributes.status,
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user