mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
minor: Allow copying the graphviz source from the view crategraph webview
This commit is contained in:
parent
7a6d5c680c
commit
34177d8552
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