mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Auto merge of #14565 - Veykril:view-crate-graph, r=Veykril
minor: Allow copying the graphviz source from the view crategraph webview
This commit is contained in:
commit
2c251a7e2b
1 changed files with 6 additions and 1 deletions
|
@ -667,17 +667,22 @@ function crateGraph(ctx: CtxInit, full: boolean): Cmd {
|
||||||
<script type="text/javascript" src="${uri}/d3-graphviz/build/d3-graphviz.min.js"></script>
|
<script type="text/javascript" src="${uri}/d3-graphviz/build/d3-graphviz.min.js"></script>
|
||||||
<div id="graph"></div>
|
<div id="graph"></div>
|
||||||
<script>
|
<script>
|
||||||
|
let dot = \`${dot}\`;
|
||||||
let graph = d3.select("#graph")
|
let graph = d3.select("#graph")
|
||||||
.graphviz({ useWorker: false, useSharedWorker: false })
|
.graphviz({ useWorker: false, useSharedWorker: false })
|
||||||
.fit(true)
|
.fit(true)
|
||||||
.zoomScaleExtent([0.1, Infinity])
|
.zoomScaleExtent([0.1, Infinity])
|
||||||
.renderDot(\`${dot}\`);
|
.renderDot(dot);
|
||||||
|
|
||||||
d3.select(window).on("click", (event) => {
|
d3.select(window).on("click", (event) => {
|
||||||
if (event.ctrlKey) {
|
if (event.ctrlKey) {
|
||||||
graph.resetZoom(d3.transition().duration(100));
|
graph.resetZoom(d3.transition().duration(100));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
d3.select(window).on("copy", (event) => {
|
||||||
|
event.clipboardData.setData("text/plain", dot);
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
`;
|
`;
|
||||||
|
|
Loading…
Reference in a new issue