Skip to content

Commit 4989ba5

Browse files
committed
feat: change language. refactor core
1 parent c5a1fc4 commit 4989ba5

21 files changed

Lines changed: 770 additions & 279 deletions

apps/playground/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ export function App() {
7070
<div className="playground-shell relative mx-auto flex min-h-[calc(100vh-2rem)] max-w-[1400px] flex-col gap-4">
7171
<header className="playground-header">
7272
<div className="playground-header__copy">
73-
<div className="playground-header__eyebrow">mxm-editor Playground</div>
73+
<div className="playground-header__eyebrow">mxm-editor 演示场</div>
7474
<h1>{route.label}</h1>
7575
<p>{route.description}</p>
7676
</div>
7777

7878
<div className="playground-header__actions">
79-
<nav className="playground-route-nav" aria-label="Playground Routes">
79+
<nav className="playground-route-nav" aria-label="演示页导航">
8080
{routes.map((routeItem) => (
8181
<a
8282
key={routeItem.id}
@@ -108,7 +108,7 @@ export function App() {
108108
</nav>
109109

110110
<button
111-
aria-label={theme === "dark" ? "Switch to light mode" : "Switch to dark mode"}
111+
aria-label={theme === "dark" ? "切换到浅色模式" : "切换到深色模式"}
112112
className="playground-theme-toggle"
113113
onClick={() => {
114114
setTheme((currentTheme) =>

apps/playground/src/playground/components/CollaborationSection.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function PresenceChips({ editor }: { editor: Editor | null }) {
3232
color: user.color ?? "#ffb870",
3333
}}
3434
>
35-
{user.name ?? `User ${user.clientId}`}
35+
{user.name ?? `用户 ${user.clientId}`}
3636
</span>
3737
))}
3838
</div>
@@ -62,23 +62,23 @@ function ActiveCollaborationSection() {
6262
<section className="collaboration-card">
6363
<div className="panel-heading">
6464
<div>
65-
<div className="panel-eyebrow">Collaboration</div>
66-
<h2>Shared Doc + Remote Carets</h2>
65+
<div className="panel-eyebrow">协同</div>
66+
<h2>共享文档与远端光标</h2>
6767
</div>
6868
<p>
69-
左右编辑器通过独立 Doc Awareness 桥接同步内容与光标,支持
70-
slash 命令、列表块和各自本地撤销/重做。
69+
左右编辑器通过独立 Doc Awareness 桥接同步内容和光标,支持
70+
slash 命令、列表块,以及各自本地撤销 / 重做。
7171
</p>
7272
</div>
7373

7474
<div className="collaboration-grid">
7575
<CollaborationEditorPanel
7676
editor={leftEditor}
77-
label="Editor A"
77+
label="编辑器 A"
7878
/>
7979
<CollaborationEditorPanel
8080
editor={rightEditor}
81-
label="Editor B"
81+
label="编辑器 B"
8282
/>
8383
</div>
8484
</section>
@@ -96,8 +96,8 @@ export function CollaborationSection() {
9696
<section className="collaboration-card collaboration-card--standby">
9797
<div className="panel-heading">
9898
<div>
99-
<div className="panel-eyebrow">Collaboration</div>
100-
<h2>Collaboration Demo On Demand</h2>
99+
<div className="panel-eyebrow">协同</div>
100+
<h2>按需启动的协同演示</h2>
101101
</div>
102102
<p>
103103
协同区包含 `Y.Doc + Awareness + remote caret`,为了避免开发态初始化把整页拖慢,默认按需启动。

apps/playground/src/playground/components/CommentsSection.tsx

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ function getThreadAuthor(thread: CommentsThread) {
4545
(comment) => typeof comment.data?.author === "string",
4646
)?.data?.author;
4747

48-
return threadAuthor ?? commentAuthor ?? "Reviewer";
48+
return threadAuthor ?? commentAuthor ?? "审阅者";
4949
}
5050

5151
function getThreadQuote(thread: CommentsThread) {
5252
return typeof thread.data?.quote === "string"
5353
? thread.data.quote
54-
: "No quote stored";
54+
: "暂无摘录";
5555
}
5656

5757
function useCommentsThreads(
@@ -103,10 +103,10 @@ export function CommentsSection() {
103103
createInMemoryCommentsProvider(commentsDemoThreads),
104104
);
105105
const [newThreadDraft, setNewThreadDraft] = useState(
106-
"This is a great anchor point. Can we make the user outcome even more explicit?",
106+
"这句话已经很接近核心价值了,能不能把用户收益再说得更明确一点?",
107107
);
108108
const [replyDraft, setReplyDraft] = useState(
109-
"Let's keep this as-is for the demo, but call out the overlap behavior.",
109+
"这个示例里先保留当前写法,但要把重叠锚点的行为说清楚。",
110110
);
111111
const editor = useEditor({
112112
extensions: [
@@ -190,12 +190,12 @@ export function CommentsSection() {
190190
content: draft,
191191
data: {
192192
author: "Mika",
193-
label: selectedText.slice(0, 42) || "New thread",
193+
label: selectedText.slice(0, 42) || "新讨论串",
194194
quote: selectedText,
195195
},
196196
commentData: {
197197
author: "Mika",
198-
role: "Design Review",
198+
role: "设计评审",
199199
},
200200
})) {
201201
return;
@@ -216,7 +216,7 @@ export function CommentsSection() {
216216
content: draft,
217217
data: {
218218
author: "Noah",
219-
role: "Product",
219+
role: "产品",
220220
},
221221
})) {
222222
return;
@@ -229,10 +229,10 @@ export function CommentsSection() {
229229
resetCommentsProvider(provider);
230230
editor.commands.setContent(commentsDemoContent);
231231
setNewThreadDraft(
232-
"This is a great anchor point. Can we make the user outcome even more explicit?",
232+
"这句话已经很接近核心价值了,能不能把用户收益再说得更明确一点?",
233233
);
234234
setReplyDraft(
235-
"Let's keep this as-is for the demo, but call out the overlap behavior.",
235+
"这个示例里先保留当前写法,但要把重叠锚点的行为说清楚。",
236236
);
237237

238238
queueMicrotask(() => {
@@ -267,22 +267,22 @@ export function CommentsSection() {
267267
<div className="ui-shell comments-editor-card border border-[var(--panel-border)]">
268268
<div className="comments-card__header">
269269
<div>
270-
<div className="panel-eyebrow">Comments</div>
271-
<h2>Inline review threads with overlapping anchors</h2>
270+
<div className="panel-eyebrow">评论</div>
271+
<h2>支持重叠锚点的行内审阅讨论</h2>
272272
<p>
273-
选中文本创建 thread,侧栏直接回复、resolve 或归档。文档里的高亮和右侧线程面板保持双向联动
273+
选中文本创建讨论串,侧栏直接回复、标记解决或归档。文档里的高亮与右侧讨论面板保持双向联动
274274
</p>
275275
</div>
276276
<div className="comments-stat-strip">
277-
<span>{activeThreads.filter((thread) => !thread.resolved).length} open</span>
278-
<span>{activeThreads.filter((thread) => thread.resolved).length} resolved</span>
277+
<span>{activeThreads.filter((thread) => !thread.resolved).length} 个未解决</span>
278+
<span>{activeThreads.filter((thread) => thread.resolved).length} 个已解决</span>
279279
<button
280280
className="comments-ghost-button"
281281
onClick={resetDemo}
282282
type="button"
283283
>
284284
<RotateCcw size={15} strokeWidth={2} />
285-
<span>Reset demo</span>
285+
<span>重置演示</span>
286286
</button>
287287
</div>
288288
</div>
@@ -294,7 +294,7 @@ export function CommentsSection() {
294294
{" "}
295295
{editorMeta.hasSelection
296296
? `“${editorMeta.selectedText.trim()}”`
297-
: "先在正文里选一段文字,再创建 thread"}
297+
: "先在正文里选一段文字,再创建讨论串"}
298298
</span>
299299
</div>
300300

@@ -308,21 +308,21 @@ export function CommentsSection() {
308308
<section className="ui-shell comments-panel border border-[var(--panel-border)]">
309309
<div className="comments-panel__header">
310310
<div>
311-
<div className="panel-eyebrow">Selection Composer</div>
312-
<h3>Start a new thread</h3>
311+
<div className="panel-eyebrow">选区发起</div>
312+
<h3>新建讨论串</h3>
313313
</div>
314314
</div>
315315

316316
<div className="comments-selection-quote">
317317
{editorMeta.hasSelection
318318
? `“${editorMeta.selectedText.trim()}”`
319-
: "Select text in the editor to create a new discussion thread."}
319+
: "在编辑器中选中文本后,就可以为这段内容发起新讨论。"}
320320
</div>
321321

322322
<textarea
323323
className="comments-textarea"
324324
onChange={(event) => setNewThreadDraft(event.target.value)}
325-
placeholder="Write the opening note for this selection..."
325+
placeholder="为这段选区写下第一条评论..."
326326
rows={4}
327327
value={newThreadDraft}
328328
/>
@@ -334,18 +334,18 @@ export function CommentsSection() {
334334
type="button"
335335
>
336336
<MessageSquarePlus size={16} strokeWidth={2} />
337-
<span>Create thread</span>
337+
<span>创建讨论串</span>
338338
</button>
339339
</section>
340340

341341
<section className="ui-shell comments-panel border border-[var(--panel-border)]">
342342
<div className="comments-panel__header">
343343
<div>
344-
<div className="panel-eyebrow">Thread List</div>
345-
<h3>Live discussion map</h3>
344+
<div className="panel-eyebrow">讨论列表</div>
345+
<h3>实时讨论概览</h3>
346346
</div>
347347
<span className="comments-panel__meta">
348-
{activeThreads.length} active
348+
{activeThreads.length} 个进行中
349349
</span>
350350
</div>
351351

@@ -369,33 +369,33 @@ export function CommentsSection() {
369369
thread.resolved ? " is-resolved" : " is-open"
370370
}`}
371371
>
372-
{thread.resolved ? "Resolved" : "Open"}
372+
{thread.resolved ? "已解决" : "未解决"}
373373
</span>
374374
</div>
375375
<p>{getThreadQuote(thread)}</p>
376376
<div className="comments-thread-card__meta">
377377
<span>{getThreadAuthor(thread)}</span>
378-
<span>{thread.comments.length} comments</span>
378+
<span>{thread.comments.length} 条评论</span>
379379
</div>
380380
</button>
381381
))}
382382

383383
{!activeThreads.length && (
384384
<div className="comments-empty-state">
385-
No active threads yet.
385+
还没有进行中的讨论。
386386
</div>
387387
)}
388388
</div>
389389

390390
{archivedThreads.length > 0 && (
391391
<div className="comments-archived-list">
392392
<div className="comments-archived-list__title">
393-
Archived
393+
已归档
394394
</div>
395395
{archivedThreads.map((thread) => (
396396
<div key={thread.id} className="comments-archived-item">
397397
<strong>{thread.data?.label ?? thread.id}</strong>
398-
<span>{thread.comments.length} comments</span>
398+
<span>{thread.comments.length} 条评论</span>
399399
</div>
400400
))}
401401
</div>
@@ -405,13 +405,12 @@ export function CommentsSection() {
405405
<section className="ui-shell comments-panel border border-[var(--panel-border)]">
406406
<div className="comments-panel__header">
407407
<div>
408-
<div className="panel-eyebrow">Selected Thread</div>
409-
<h3>{selectedThread?.data?.label ?? "Inspect discussion state"}</h3>
408+
<div className="panel-eyebrow">当前讨论</div>
409+
<h3>{selectedThread?.data?.label ?? "查看讨论详情"}</h3>
410410
</div>
411411
{selectedThread && (
412412
<span className="comments-panel__meta">
413-
{selectedThreadOccurrences} anchor
414-
{selectedThreadOccurrences === 1 ? "" : "s"}
413+
{selectedThreadOccurrences} 个锚点
415414
</span>
416415
)}
417416
</div>
@@ -423,7 +422,7 @@ export function CommentsSection() {
423422
selectedThread.resolved ? " is-resolved" : " is-open"
424423
}`}
425424
>
426-
{selectedThread.resolved ? "Resolved" : "Open"}
425+
{selectedThread.resolved ? "已解决" : "未解决"}
427426
</span>
428427
<span>{formatTimestamp(selectedThread.updatedAt)}</span>
429428
</div>
@@ -451,7 +450,7 @@ export function CommentsSection() {
451450
<textarea
452451
className="comments-textarea"
453452
onChange={(event) => setReplyDraft(event.target.value)}
454-
placeholder="Reply to the selected thread..."
453+
placeholder="回复当前讨论..."
455454
rows={3}
456455
value={replyDraft}
457456
/>
@@ -464,7 +463,7 @@ export function CommentsSection() {
464463
type="button"
465464
>
466465
<MessageCircleReply size={16} strokeWidth={2} />
467-
<span>Reply</span>
466+
<span>回复</span>
468467
</button>
469468

470469
<button
@@ -482,7 +481,7 @@ export function CommentsSection() {
482481
<CheckCheck size={16} strokeWidth={2} />
483482
)}
484483
<span>
485-
{selectedThread.resolved ? "Reopen" : "Resolve"}
484+
{selectedThread.resolved ? "重新打开" : "标记已解决"}
486485
</span>
487486
</button>
488487

@@ -492,13 +491,13 @@ export function CommentsSection() {
492491
type="button"
493492
>
494493
<Archive size={16} strokeWidth={2} />
495-
<span>Archive</span>
494+
<span>归档</span>
496495
</button>
497496
</div>
498497
</div>
499498
) : (
500499
<div className="comments-empty-state comments-empty-state--detail">
501-
Click a highlighted range or choose a thread from the list to inspect its discussion.
500+
点击正文中的高亮范围,或从列表里选择一个讨论,即可查看详细内容。
502501
</div>
503502
)}
504503
</section>

apps/playground/src/playground/components/HeroCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { heroCopy } from "../constants";
33
export function HeroCard() {
44
return (
55
<section className="hero-card">
6-
<div className="eyebrow">Monorepo + Vite + TypeScript</div>
7-
<h1>mxm-editor Playground</h1>
6+
<div className="eyebrow">工程栈:Monorepo + Vite + TypeScript</div>
7+
<h1>mxm-editor 演示场</h1>
88
<p className="hero-copy">{heroCopy}</p>
99
</section>
1010
);

apps/playground/src/playground/components/InspectorPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ export function InspectorPanel({ editor }: InspectorPanelProps) {
1010

1111
return (
1212
<aside className="inspector-panel">
13-
<h2>HTML Output</h2>
13+
<h2>HTML 输出</h2>
1414
<pre>{html}</pre>
15-
<h2 className="secondary-heading">Markdown Output</h2>
15+
<h2 className="secondary-heading">Markdown 输出</h2>
1616
<pre>{markdown}</pre>
1717
</aside>
1818
);

0 commit comments

Comments
 (0)