sheetkeys icon indicating copy to clipboard operation
sheetkeys copied to clipboard

Implement hashmark link support for `openCellAsUrl` in calls to `HYPERLINK`

Open jparoz opened this issue 1 year ago • 0 comments

If the URL argument to a call to HYPERLINK begins with a hash (#), then change the current page's hash to equal the given hash; otherwise open the link in a new tab as normal.

I changed the regex (used for functionMatch) to be more permissive, because the link_label argument to HYPERLINK is optional. This is a bug, which causes the behaviour shown in #34 (should have opened the sheet in a new tab, with the new hash); but also caused links with any label other than a string literal (i.e. any links with indirect references) to not be openable with the ;o action. Possibly the regex is now too permissive, as it will work on some malformed formulae; but this seems like a small issue or non-issue to me.

Also, I'm not 100% sure why I have to call this.commitCellChanges() twice? I haven't read that function in great detail though, and it's probable that it's dependent on some state which is changed by assigning window.location.hash = functionMatch[1] above. The extra call should probably be removable with some further investigation.

Fixes #34

jparoz avatar Jan 03 '24 06:01 jparoz