Skip to content

Commit

Permalink
Fix heading plugin crash if slugs are not calculated
Browse files Browse the repository at this point in the history
  • Loading branch information
retronav committed Jun 30, 2022
1 parent ff5429f commit 64acd12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-plants-confess.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@retronav/ixora': patch
---

Fix heading plugin crash if slugs are not calculated
4 changes: 2 additions & 2 deletions src/plugins/heading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ class HeadingDecorationsPlugin {
if (!name.includes('Heading')) return;
const slug = view.state
.field(headingSlugField)
.find((s) => s.pos === from).slug;
.find((s) => s.pos === from)?.slug;
const level = parseInt(/[1-6]$/.exec(name)[0]);
const dec = Decoration.line({
class: [
classes.heading,
classes.level(level),
classes.slug(slug)
slug ? classes.slug(slug) : ''
].join(' ')
});
widgets.push(dec.range(view.state.doc.lineAt(from).from));
Expand Down

1 comment on commit 64acd12

@vercel
Copy link

@vercel vercel bot commented on 64acd12 Jun 30, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

ixora – ./

ixora-retronav.vercel.app
ixora-git-main-retronav.vercel.app
ixora.karawale.in
ixora.vercel.app

Please sign in to comment.