Skip to content

HAR-9736 - fix link export (and url field)#532

Merged
harbournick merged 1 commit intomainfrom
artem-HAR-9736
May 28, 2025
Merged

HAR-9736 - fix link export (and url field)#532
harbournick merged 1 commit intomainfrom
artem-HAR-9736

Conversation

@artem-harbour
Copy link
Copy Markdown
Contributor

@artem-harbour artem-harbour commented May 28, 2025

Added comments in the code (more details in the ticket).

@artem-harbour artem-harbour self-assigned this May 28, 2025
@artem-harbour artem-harbour added the don't merge Don't merge yet label May 28, 2025

// Update the ID. If we've assigned a long ID (ie: images) we leave it alone
// Update the ID. If we've assigned a long ID (ie: images, links) we leave it alone
rel.attributes.Id = existingId.length > 6 ? existingId : `rId${++largestId}`;
Copy link
Copy Markdown
Contributor Author

@artem-harbour artem-harbour May 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the main issue why the links did not work when exporting. We create a new id for the link node every time, but we don't create a new relationship for this id.

Note:

  • Previous relationships are not deleted, but this does not seem to be an issue. It can also be quite risky to delete prev relationships by checking the value. In any case, we can consider this later.

return newNode;
}

function processLinkContentNode(node) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add default properties and color to the link node so it looks like a link in a document.

const newId = addNewLinkRelationship(params, attrs.linkUrl);

const linkTextNode = getTextNodeForExport(attrs.linkUrl, marks, params);
const contentNode = processLinkContentNode(linkTextNode);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for url annotation.

@artem-harbour artem-harbour added ready for review and removed don't merge Don't merge yet labels May 28, 2025
@artem-harbour artem-harbour marked this pull request as ready for review May 28, 2025 17:28
@artem-harbour artem-harbour requested a review from harbournick May 28, 2025 17:28
Copy link
Copy Markdown
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@harbournick harbournick merged commit 448937f into main May 28, 2025
5 of 6 checks passed
@harbournick harbournick deleted the artem-HAR-9736 branch May 28, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants