Bike 2.0 Preview Extensions API Questions

I think that should work.

1 Like

( I guess for many cases, it may suffice to filter for targets of links in the document )


We can list the HTML source of rows containing links with an expression like:

bike.frontmostDocument.outline
.query("//*/run::@a/..").value.map(x => x.text.toHTML())

and I think perhaps we should be able to return runs, rather than rows, with a slightly shorter query:

//*/run::@a

but I haven’t yet figured out how to read the link text from the array of RowRun objects returned by a run query like that.

/** RowRuns are returned by OutlinePaths that query the `run` axis. */
export interface RowRun {
  /** Row that contains this run. */
  readonly row: Row
  /** Start index of this run in row's text. */
  readonly runStart: number
  /** Substring contained by this run. */
  readonly runString: string
  /** Run's text attributes. */
  readonly runAttributes: Record<TextAttributeName, string>
}

(I seem to be getting undefined when I try to read these properties, so I’m probably missing something – possibly an import :slight_smile: )

Nope, I defined the API, but forgot to implement the swift side. Will fix!

1 Like

Forgot to mention in release notes, but I believe this is fixed in 276.

1 Like

Thanks ! It’s working well …

(Using that API here to retrieve a list of locally defined relative links – for jumping back from footnotes – and opening #ROWID links works perfectly too now … really helpful and much appreciated )

1 Like