Skip to content

Commit 57c6df5

Browse files
authored
fix(site): remove URL content sharing (#266)
1 parent 2ea1894 commit 57c6df5

4 files changed

Lines changed: 1 addition & 154 deletions

File tree

‎site/package.json‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"@codemirror/theme-one-dark": "^6.1.3",
3737
"@codemirror/view": "^6.39.7",
3838
"@radix-ui/react-context-menu": "^2.1.5",
39-
"@types/pako": "^2.0.4",
4039
"antd": "^5.24.7",
4140
"body-scroll-lock": "^3.1.3",
4241
"classnames": "^2.2.6",
@@ -47,7 +46,6 @@
4746
"lucide-react": "^0.554.0",
4847
"next": "^15.5.7",
4948
"next-remote-watch": "^1.0.0",
50-
"pako": "^2.1.0",
5149
"parse-numeric-range": "^1.2.0",
5250
"react": "^19.0.0",
5351
"react-collapsed": "4.2.0",

‎site/src/components/LiveEditor/EditorPanel.tsx‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import type {EditorView} from '@codemirror/view';
1010
import {Select} from 'antd';
1111
import {TEMPLATES} from 'components/Gallery/templates';
1212
import {IconClose} from 'components/Icon/IconClose';
13-
import {IconLink} from 'components/Icon/IconLink';
1413
import {IconRestart} from 'components/Icon/IconRestart';
1514
import {CodeEditor} from 'components/MDX/CodeEditor';
1615
import {useLocaleBundle} from 'hooks/useTranslation';
@@ -326,7 +325,6 @@ const TRANSLATIONS = {
326325
themeLabel: '主题',
327326
paletteLabel: '配色',
328327
resetButton: '重置',
329-
shareButton: '分享',
330328
clearButton: '清空',
331329
searchPlaceholder: '搜索',
332330
noResults: '无匹配选项',
@@ -339,7 +337,6 @@ const TRANSLATIONS = {
339337
themeLabel: 'Theme',
340338
paletteLabel: 'Palette',
341339
resetButton: 'Reset',
342-
shareButton: 'Share',
343340
clearButton: 'Clear',
344341
searchPlaceholder: 'Search',
345342
noResults: 'No results',
@@ -368,12 +365,10 @@ const CUSTOM_PALETTES = [
368365
export function EditorPanel({
369366
value,
370367
onChange,
371-
onShare,
372368
onReset,
373369
}: {
374370
value: string;
375371
onChange: (value: string) => void;
376-
onShare: () => void;
377372
onReset: () => void;
378373
}) {
379374
const texts = useLocaleBundle(TRANSLATIONS);
@@ -612,13 +607,6 @@ export function EditorPanel({
612607
aria-label={texts.resetButton}>
613608
<IconRestart className="w-4 h-4" />
614609
</button>
615-
<div className="w-[1px] h-5 bg-border dark:bg-border-dark self-center mx-1" />
616-
<button
617-
onClick={onShare}
618-
className="inline-flex items-center gap-2 px-4 py-2 text-sm font-semibold text-white rounded-full bg-gradient-to-r from-link to-link/80 dark:from-link-dark dark:to-link-dark/90 shadow-sm hover:shadow-md transition">
619-
<IconLink className="w-4 h-4" />
620-
{texts.shareButton}
621-
</button>
622610
</div>
623611
</div>
624612
<div className="flex-1 relative group overflow-auto">

‎site/src/components/LiveEditor/index.tsx‎

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import {CopyToast, useCopyToast} from 'components/CopyToast';
22
import {motion} from 'framer-motion';
33
import {useLocaleBundle} from 'hooks/useTranslation';
4-
import {useRouter} from 'next/router';
54
import {useEffect, useState} from 'react';
65
import {DEFAULT_SYNTAX} from './defaultSyntax';
76
import {EditorPanel} from './EditorPanel';
87
import {PreviewPanel} from './PreviewPanel';
9-
import {extractContentFromUrl, generateShareUrl} from './utils';
108

119
const STORAGE_KEY = 'live-editor-syntax';
1210

@@ -15,43 +13,28 @@ const TRANSLATIONS = {
1513
title: 'Live Editor',
1614
description: '编辑 AntV Infographic Syntax 并查看实时预览',
1715
resetButton: '重置为默认',
18-
shareButton: '分享',
1916
imageCopied: '图片已复制到剪贴板',
20-
linkCopied: '分享链接已复制到剪贴板',
21-
shareFailed: '生成分享链接失败',
2217
},
2318
'en-US': {
2419
title: 'Live Editor',
2520
description: 'Edit AntV Infographic Syntax and see real-time preview',
2621
resetButton: 'Reset to Default',
27-
shareButton: 'Share',
2822
imageCopied: 'Image copied to clipboard',
29-
linkCopied: 'Share link copied to clipboard',
30-
shareFailed: 'Failed to generate share link',
3123
},
3224
};
3325

3426
export function EditorContent() {
35-
const router = useRouter();
3627
const [syntax, setSyntax] = useState(DEFAULT_SYNTAX);
3728
const [error, setError] = useState<string | null>(null);
3829
const [mounted, setMounted] = useState(false);
3930
const {message: copyHint, show: showCopyHint} = useCopyToast(2500);
4031
const texts = useLocaleBundle(TRANSLATIONS);
4132

42-
// Load from URL or localStorage on mount
33+
// Load from localStorage on mount
4334
useEffect(() => {
4435
setMounted(true);
4536
if (typeof window === 'undefined') return;
4637

47-
// Try URL first
48-
const urlContent = extractContentFromUrl();
49-
if (urlContent) {
50-
setSyntax(urlContent);
51-
return;
52-
}
53-
54-
// Fall back to localStorage
5538
const saved = localStorage.getItem(STORAGE_KEY);
5639
if (saved) {
5740
setSyntax(saved);
@@ -66,53 +49,11 @@ export function EditorContent() {
6649
localStorage.setItem(STORAGE_KEY, syntax);
6750
}, [syntax, mounted]);
6851

69-
// Debounced URL update when content is edited (if URL has content param)
70-
useEffect(() => {
71-
if (!mounted) return;
72-
if (typeof window === 'undefined') return;
73-
74-
// Check if current URL has content parameter
75-
const hasContentParam = window.location.search.includes('content=');
76-
if (!hasContentParam) return;
77-
78-
// Debounce URL update (same delay as preview: 300ms)
79-
const timer = setTimeout(() => {
80-
const shareUrl = generateShareUrl(syntax);
81-
if (shareUrl) {
82-
window.history.replaceState(null, '', shareUrl);
83-
}
84-
}, 300);
85-
86-
return () => clearTimeout(timer);
87-
}, [syntax, mounted]);
88-
8952
const handleReset = () => {
9053
setSyntax(DEFAULT_SYNTAX);
9154
if (typeof window !== 'undefined') {
9255
localStorage.removeItem(STORAGE_KEY);
9356
}
94-
// Clear URL params
95-
router.replace('/editor', undefined, {shallow: true});
96-
};
97-
98-
const handleShare = async () => {
99-
const shareUrl = generateShareUrl(syntax);
100-
if (!shareUrl) {
101-
showCopyHint(texts.shareFailed);
102-
return;
103-
}
104-
105-
try {
106-
await navigator.clipboard.writeText(shareUrl);
107-
showCopyHint(texts.linkCopied);
108-
// Use native history API to update URL without triggering re-render
109-
if (typeof window !== 'undefined') {
110-
window.history.replaceState(null, '', shareUrl);
111-
}
112-
} catch (e) {
113-
console.error('Failed to copy share link:', e);
114-
showCopyHint(texts.shareFailed);
115-
}
11657
};
11758

11859
return (
@@ -142,7 +83,6 @@ export function EditorContent() {
14283
<EditorPanel
14384
value={syntax}
14485
onChange={setSyntax}
145-
onShare={handleShare}
14686
onReset={handleReset}
14787
/>
14888
<PreviewPanel

‎site/src/components/LiveEditor/utils.ts‎

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)