[WIKI-785] refactor: editor markdown handler #8546
This commit is contained in:
parent
5af0f58aa9
commit
fc66fba5aa
2 changed files with 16 additions and 10 deletions
|
|
@ -35,13 +35,19 @@ export const parseCustomComponents = (args: TArgs): Record<string, Handle> => {
|
|||
},
|
||||
"mention-component": (_state, node) => {
|
||||
const properties = node.properties || {};
|
||||
const userId = String(properties.entity_identifier);
|
||||
const userDetails = metaData.user_mentions.find((user) => user.id === userId);
|
||||
if (!userDetails) return createTextNode("");
|
||||
return createTextNode(`[@${userDetails.display_name || "Unknown user"}](${userDetails.url || ""}) `);
|
||||
const mentionType = String(properties.entity_name);
|
||||
|
||||
let url: string = "";
|
||||
let tag: string = "@";
|
||||
if (mentionType === "user_mention") {
|
||||
const userId = String(properties.entity_identifier);
|
||||
const userDetails = metaData.user_mentions.find((user) => user.id === userId);
|
||||
if (!userDetails) return createTextNode("");
|
||||
url = userDetails.url || "";
|
||||
tag = `@${userDetails.display_name || "Unknown user"}`;
|
||||
}
|
||||
|
||||
return createTextNode(`[${tag}](${url}) `);
|
||||
},
|
||||
...parseExtendedCustomComponents({ metaData }),
|
||||
};
|
||||
};
|
||||
|
||||
export const parseExtendedCustomComponents = (_args: TArgs): Record<string, Handle> => ({});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue