Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: middle mouse click opens editor example instead of docs in new tab #9498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions site/static/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const loader = vega.loader({
});

const editorURL = 'https://vega.github.io/editor/';
const MIDDLE_MOUSE_CLICK = 1;

/* Anchors */
selectAll('h2, h3, h4, h5, h6').each(function (this: d3.BaseType) {
Expand Down Expand Up @@ -92,13 +93,16 @@ export function embedExample($target: any, spec: TopLevelSpec, actions = true, t
.append('a')
.text('Open in Vega Editor')
.attr('href', '#')
.on('click', event => {
post(window, editorURL, {
mode: 'vega-lite',
spec: compactStringify(spec),
config: vgSpec.config,
renderer: 'svg'
});
.on('click mouseup', event => {
// Check if it's a regular left click or middle mouse click
if (event.type === 'click' || (event.type === 'mouseup' && event.button === MIDDLE_MOUSE_CLICK)) {
post(window, editorURL, {
mode: 'vega-lite',
spec: compactStringify(spec),
config: vgSpec.config,
renderer: 'svg'
});
}
// remove as any when d3 typings are updated
(event as any).preventDefault();
});
Expand Down
Loading