Skip to content

Commit 7740872

Browse files
committed
fix(links): heading links not handled correctly
1 parent 74aae3a commit 7740872

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/view/components/container/column/components/group/components/card/components/content/event-handlers/handle-links/heading-link/handle-local-heading-link.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,14 @@ import { LineageView } from 'src/view/view';
22
import { selectCard } from 'src/view/components/container/column/components/group/components/card/components/content/event-handlers/handle-links/helpers/select-card';
33

44
export const handleLocalHeadingLink = (view: LineageView, link: string) => {
5-
const match = /(#.+)$/.exec(link);
5+
const match = /#+(.*)$/.exec(link);
66
if (!match) return;
7-
const headingPart = match[1];
7+
const headingText = match[1].trimStart();
88
for (let level = 1; level <= 6; level++) {
99
const headings = Array.from(
1010
view.containerEl.querySelectorAll('h' + level),
1111
) as HTMLHeadingElement[];
12-
const heading = headings.find(
13-
(h) => '#' + h.dataset.heading === headingPart,
14-
);
12+
const heading = headings.find((h) => h.dataset.heading === headingText);
1513
if (heading) {
1614
const card = heading.closest('.lineage-card');
1715
if (card && card.id) {

0 commit comments

Comments
 (0)