mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
⚙️ fix: resolve duplicate id display issue
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
import { cn } from '@/utils/cn';
|
||||
import { clipboard } from '@/utils/clipboard';
|
||||
import { copyToClipboard as figmaCopyToClipboard } from '@/figma/copy-to-clipboard';
|
||||
import { getPrefixFromSvgUrl, prefixSvgIds } from '@/utils/prefixSvgIds';
|
||||
|
||||
// Templates:
|
||||
import { getSource } from '@/templates/getSource';
|
||||
@@ -84,10 +85,14 @@
|
||||
const svgUrlToCopy = getSvgUrl();
|
||||
optionsOpen = false;
|
||||
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
if (isInFigma) {
|
||||
figmaCopyToClipboard(content);
|
||||
}
|
||||
@@ -125,9 +130,14 @@
|
||||
isLoading = true;
|
||||
|
||||
const title = svgInfo.title.split(' ').join('');
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
const dataComponent = { code: content, typescript: tsx, name: title };
|
||||
const { data, error } = await getReactCode(dataComponent);
|
||||
|
||||
@@ -156,10 +166,14 @@
|
||||
|
||||
optionsOpen = false;
|
||||
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
const copyCode = getVueCode({
|
||||
content: content,
|
||||
lang: ts ? 'ts' : 'js'
|
||||
@@ -189,10 +203,14 @@
|
||||
|
||||
optionsOpen = false;
|
||||
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
const copyCode = getSvelteCode({
|
||||
content: content,
|
||||
lang: ts ? 'ts' : 'js'
|
||||
@@ -222,10 +240,14 @@
|
||||
|
||||
const title = svgInfo.title.split(' ').join('');
|
||||
const svgUrlToCopy = getSvgUrl();
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
toast.error('Failed to fetch the SVG content', {
|
||||
duration: 5000
|
||||
@@ -255,10 +277,14 @@
|
||||
|
||||
const title = svgInfo.title.split(' ').join('');
|
||||
const svgUrlToCopy = getSvgUrl();
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
toast.error('Failed to fetch the SVG content', {
|
||||
duration: 5000
|
||||
@@ -287,10 +313,14 @@
|
||||
optionsOpen = false;
|
||||
|
||||
const svgUrlToCopy = getSvgUrl();
|
||||
const content = await getSource({
|
||||
let content = await getSource({
|
||||
url: svgUrlToCopy
|
||||
});
|
||||
|
||||
if (svgUrlToCopy) {
|
||||
content = prefixSvgIds(content, getPrefixFromSvgUrl(svgUrlToCopy));
|
||||
}
|
||||
|
||||
if (!content) {
|
||||
toast.error('Failed to fetch the SVG content', {
|
||||
duration: 5000
|
||||
|
||||
Reference in New Issue
Block a user