mirror of https://github.com/astral-sh/ruff
Copy URL but don't update the hash (#1458)
This commit is contained in:
parent
9fafe16a55
commit
34cd22dfc1
|
|
@ -22,10 +22,13 @@ export function stringify(settings: Settings): string {
|
||||||
/**
|
/**
|
||||||
* Persist the configuration to a URL.
|
* Persist the configuration to a URL.
|
||||||
*/
|
*/
|
||||||
export function persist(settingsSource: string, pythonSource: string) {
|
export async function persist(settingsSource: string, pythonSource: string) {
|
||||||
window.location.hash = lzstring.compressToEncodedURIComponent(
|
const hash = lzstring.compressToEncodedURIComponent(
|
||||||
settingsSource + "$$$" + pythonSource,
|
settingsSource + "$$$" + pythonSource,
|
||||||
);
|
);
|
||||||
|
await navigator.clipboard.writeText(
|
||||||
|
window.location.href.split("#")[0] + "#" + hash,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
export async function copyTextToClipboard(text: string) {
|
||||||
|
if ("clipboard" in navigator) {
|
||||||
|
return await navigator.clipboard.writeText(text);
|
||||||
|
} else {
|
||||||
|
return document.execCommand("copy", true, text);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue