Skip to content

Commit 8b9d83b

Browse files
authored
Merge pull request #70 from chanhyokpark/next
feat: add dedicated strings file
2 parents 8b4516f + 85f989f commit 8b9d83b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+546
-264
lines changed

src/lib/edra/commands/toolbar-commands.ts

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@ import Video from '@lucide/svelte/icons/video';
3131
import { isTextSelection } from '@tiptap/core';
3232
import { isMac } from '../utils.js';
3333
import type { EdraToolBarCommands } from './types.js';
34+
import strings from '../strings.js';
3435

3536
const commands: Record<string, EdraToolBarCommands[]> = {
3637
'undo-redo': [
3738
{
3839
icon: Undo,
3940
name: 'undo',
40-
tooltip: 'Undo',
41+
tooltip: strings.command.undo,
4142
shortCut: `${isMac ? '⌘' : 'Ctrl+'}Z`,
4243
onClick: (editor) => {
4344
editor.chain().focus().undo().run();
@@ -49,7 +50,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
4950
{
5051
icon: Redo,
5152
name: 'redo',
52-
tooltip: 'Redo',
53+
tooltip: strings.command.redo,
5354
shortCut: `${isMac ? '⌘' : 'Ctrl+'}Y`,
5455
onClick: (editor) => {
5556
editor.chain().focus().redo().run();
@@ -63,7 +64,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
6364
{
6465
icon: Heading1,
6566
name: 'h1',
66-
tooltip: 'Heading 1',
67+
tooltip: strings.command.h1,
6768
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}1`,
6869
onClick: (editor) => {
6970
editor.chain().focus().toggleHeading({ level: 1 }).run();
@@ -81,7 +82,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
8182
{
8283
icon: Heading2,
8384
name: 'h2',
84-
tooltip: 'Heading 2',
85+
tooltip: strings.command.h2,
8586
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}2`,
8687
onClick: (editor) => {
8788
editor.chain().focus().toggleHeading({ level: 2 }).run();
@@ -99,7 +100,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
99100
{
100101
icon: Heading3,
101102
name: 'h3',
102-
tooltip: 'Heading 3',
103+
tooltip: strings.command.h3,
103104
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}3`,
104105
onClick: (editor) => {
105106
editor.chain().focus().toggleHeading({ level: 3 }).run();
@@ -117,7 +118,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
117118
{
118119
icon: Heading4,
119120
name: 'h4',
120-
tooltip: 'Heading 4',
121+
tooltip: strings.command.h4,
121122
shortCut: `${isMac ? '⌘⌥' : 'Ctrl+Alt+'}4`,
122123
onClick: (editor) => {
123124
editor.chain().focus().toggleHeading({ level: 4 }).run();
@@ -137,7 +138,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
137138
{
138139
icon: Link,
139140
name: 'link',
140-
tooltip: 'Link',
141+
tooltip: strings.command.link,
141142
onClick: (editor) => {
142143
if (editor.isActive('link')) {
143144
editor.chain().focus().unsetLink().run();
@@ -173,7 +174,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
173174
{
174175
icon: Bold,
175176
name: 'bold',
176-
tooltip: 'Bold',
177+
tooltip: strings.command.bold,
177178
shortCut: `${isMac ? '⌘' : 'Ctrl+'}B`,
178179
onClick: (editor) => {
179180
editor.chain().focus().toggleBold().run();
@@ -191,7 +192,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
191192
{
192193
icon: Italic,
193194
name: 'italic',
194-
tooltip: 'Italic',
195+
tooltip: strings.command.italic,
195196
shortCut: `${isMac ? '⌘' : 'Ctrl+'}I`,
196197
onClick: (editor) => {
197198
editor.chain().focus().toggleItalic().run();
@@ -209,7 +210,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
209210
{
210211
icon: Underline,
211212
name: 'underline',
212-
tooltip: 'Underline',
213+
tooltip: strings.command.underline,
213214
shortCut: `${isMac ? '⌘' : 'Ctrl+'}U`,
214215
onClick: (editor) => {
215216
editor.chain().focus().toggleUnderline().run();
@@ -227,7 +228,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
227228
{
228229
icon: StrikeThrough,
229230
name: 'strikethrough',
230-
tooltip: 'Strikethrough',
231+
tooltip: strings.command.strikethrough,
231232
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}S`,
232233
onClick: (editor) => {
233234
editor.chain().focus().toggleStrike().run();
@@ -245,7 +246,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
245246
{
246247
icon: Quote,
247248
name: 'blockQuote',
248-
tooltip: 'BlockQuote',
249+
tooltip: strings.command.blockQuote,
249250
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}B`,
250251
onClick: (editor) => {
251252
editor.chain().focus().toggleBlockquote().run();
@@ -263,7 +264,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
263264
{
264265
icon: Code,
265266
name: 'code',
266-
tooltip: 'Inline Code',
267+
tooltip: strings.command.code,
267268
shortCut: `${isMac ? '⌘' : 'Ctrl+'}E`,
268269
onClick: (editor) => {
269270
editor.chain().focus().toggleCode().run();
@@ -281,7 +282,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
281282
{
282283
icon: Superscript,
283284
name: 'superscript',
284-
tooltip: 'Superscript',
285+
tooltip: strings.command.superscript,
285286
shortCut: `${isMac ? '⌘' : 'Ctrl+'}.`,
286287
onClick: (editor) => {
287288
editor.chain().focus().toggleSuperscript().run();
@@ -296,7 +297,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
296297
{
297298
icon: Subscript,
298299
name: 'subscript',
299-
tooltip: 'Subscript',
300+
tooltip: strings.command.subscript,
300301
shortCut: `${isMac ? '⌘' : 'Ctrl+'},`,
301302
onClick: (editor) => {
302303
editor.chain().focus().toggleSubscript().run();
@@ -313,7 +314,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
313314
{
314315
icon: AlignLeft,
315316
name: 'align-left',
316-
tooltip: 'Align Left',
317+
tooltip: strings.command.alignLeft,
317318
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}L`,
318319
onClick: (editor) => {
319320
editor.chain().focus().toggleTextAlign('left').run();
@@ -329,7 +330,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
329330
{
330331
icon: AlignCenter,
331332
name: 'align-center',
332-
tooltip: 'Align Center',
333+
tooltip: strings.command.alignCenter,
333334
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}E`,
334335
onClick: (editor) => {
335336
editor.chain().focus().toggleTextAlign('center').run();
@@ -345,7 +346,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
345346
{
346347
icon: AlignRight,
347348
name: 'align-right',
348-
tooltip: 'Align Right',
349+
tooltip: strings.command.alignRight,
349350
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}R`,
350351
onClick: (editor) => {
351352
editor.chain().focus().toggleTextAlign('right').run();
@@ -361,7 +362,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
361362
{
362363
icon: AlighJustify,
363364
name: 'align-justify',
364-
tooltip: 'Align Justify',
365+
tooltip: strings.command.alignJustify,
365366
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}J`,
366367
onClick: (editor) => {
367368
editor.chain().focus().toggleTextAlign('justify').run();
@@ -379,7 +380,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
379380
{
380381
icon: List,
381382
name: 'bulletList',
382-
tooltip: 'Bullet List',
383+
tooltip: strings.command.bulletList,
383384
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}8`,
384385
onClick: (editor) => {
385386
editor.chain().focus().toggleBulletList().run();
@@ -392,7 +393,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
392393
{
393394
icon: ListOrdered,
394395
name: 'orderedList',
395-
tooltip: 'Ordered List',
396+
tooltip: strings.command.orderedList,
396397
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}7`,
397398
onClick: (editor) => {
398399
editor.chain().focus().toggleOrderedList().run();
@@ -410,7 +411,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
410411
{
411412
icon: ListChecks,
412413
name: 'taskList',
413-
tooltip: 'Task List',
414+
tooltip: strings.command.taskList,
414415
shortCut: `${isMac ? '⌘⇧' : 'Ctrl+Shift+'}9`,
415416
onClick: (editor) => {
416417
editor.chain().focus().toggleTaskList().run();
@@ -430,7 +431,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
430431
{
431432
icon: Image,
432433
name: 'image-placeholder',
433-
tooltip: 'Image Placeholder',
434+
tooltip: strings.command.imagePlaceholder,
434435
onClick: (editor) => {
435436
editor.chain().focus().insertImagePlaceholder().run();
436437
},
@@ -439,7 +440,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
439440
{
440441
icon: Video,
441442
name: 'video-placeholder',
442-
tooltip: 'Video Placeholder',
443+
tooltip: strings.command.videoPlaceholder,
443444
onClick: (editor) => {
444445
editor.chain().focus().insertVideoPlaceholder().run();
445446
},
@@ -448,7 +449,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
448449
{
449450
icon: Audio,
450451
name: 'audio-placeholder',
451-
tooltip: 'Audio Placeholder',
452+
tooltip: strings.command.audioPlaceholder,
452453
onClick: (editor) => {
453454
editor.chain().focus().insertAudioPlaceholder().run();
454455
},
@@ -457,7 +458,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
457458
{
458459
icon: IFrame,
459460
name: 'iframe-placeholder',
460-
tooltip: 'IFrame Placeholder',
461+
tooltip: strings.command.iframePlaceholder,
461462
onClick: (editor) => {
462463
editor.chain().focus().insertIFramePlaceholder().run();
463464
},
@@ -468,7 +469,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
468469
{
469470
icon: Table,
470471
name: 'table',
471-
tooltip: 'Table',
472+
tooltip: strings.command.table,
472473
onClick: (editor) => {
473474
if (editor.isActive('table')) {
474475
const del = confirm('Do you really want to delete this table??');
@@ -486,7 +487,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
486487
{
487488
icon: Radical,
488489
name: 'mathematics',
489-
tooltip: 'Inline Expression',
490+
tooltip: strings.command.inlineExpression,
490491
onClick: (editor) => {
491492
let latex = 'a^2 + b^2 = c^2';
492493
const chain = editor.chain().focus();
@@ -502,7 +503,7 @@ const commands: Record<string, EdraToolBarCommands[]> = {
502503
{
503504
icon: SquareRadical,
504505
name: 'mathematics',
505-
tooltip: 'Block Expression',
506+
tooltip: strings.command.blockExpression,
506507
onClick: (editor) => {
507508
const latex = 'a^2 + b^2 = c^2';
508509
editor.chain().focus().insertBlockMath({ latex }).run();

src/lib/edra/editor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { Table, TableCell, TableHeader, TableRow } from './extensions/table/inde
1515
import 'katex/dist/katex.min.css';
1616
import { Markdown } from '@tiptap/markdown';
1717
import { InlineMathReplacer } from './extensions/InlineMathReplacer.js';
18+
import strings from './strings.js';
1819

1920
export default (
2021
element?: HTMLElement,
@@ -61,10 +62,10 @@ export default (
6162
// Use different placeholders depending on the node type:
6263
placeholder: ({ node }) => {
6364
if (node.type.name === 'heading') {
64-
return 'What’s the title?';
65+
return strings.editor.headingPlaceholder;
6566
}
6667
if (node.type.name === 'paragraph') {
67-
return 'Write, press space for AI or / for commands';
68+
return strings.editor.paragraphPlaceholder;
6869
}
6970
return '';
7071
}

src/lib/edra/extensions/audio/AudioExtension.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Node, nodeInputRule } from '@tiptap/core';
22
import { Plugin, PluginKey } from '@tiptap/pm/state';
33
import { toast } from 'svelte-sonner';
4+
import strings from '../../strings.js';
45

56
export interface AudioOptions {
67
HTMLAttributes: Record<string, unknown>;
@@ -124,14 +125,13 @@ export const Audio = (onDrop?: (file: File) => Promise<string>) =>
124125
event.preventDefault();
125126

126127
if (audios.length > 1) {
127-
toast.warning('Can not paste multple files at once!', {
128-
description:
129-
'You can only paste one file at a time. Only the first file will be pasted.'
128+
toast.warning(strings.extension.audio.multiplePasteWarningTitle, {
129+
description: strings.extension.audio.multiplePasteWarningDescription
130130
});
131131
}
132132

133133
const audio = audios[0];
134-
const id = toast.loading('Processing Pasted Audio');
134+
const id = toast.loading(strings.extension.audio.pasteProcessing);
135135
onDrop?.(audio)
136136
.then((src) => {
137137
const node = schema.nodes.audio.create({ src });
@@ -141,7 +141,7 @@ export const Audio = (onDrop?: (file: File) => Promise<string>) =>
141141
})
142142
.catch((err) => {
143143
console.error(err);
144-
toast.error('Could not paste audio', { id });
144+
toast.error(strings.extension.audio.pasteError, { id });
145145
});
146146

147147
return true;
@@ -167,14 +167,13 @@ export const Audio = (onDrop?: (file: File) => Promise<string>) =>
167167
const coordinates = view.posAtCoords({ left: event.clientX, top: event.clientY });
168168

169169
if (audios.length > 1) {
170-
toast.warning('Can not drop multple files at once!', {
171-
description:
172-
'You can only drop one file at a time. Only the first file will be processed.'
170+
toast.warning(strings.extension.audio.multipleDropWarningTitle, {
171+
description: strings.extension.audio.multipleDropWarningDescription
173172
});
174173
}
175174

176175
const audio = audios[0];
177-
const id = toast.loading('Processing Dropped Audio');
176+
const id = toast.loading(strings.extension.audio.dropProcessing);
178177
onDrop?.(audio)
179178
.then((src) => {
180179
if (coordinates && typeof coordinates.pos === 'number') {
@@ -186,7 +185,7 @@ export const Audio = (onDrop?: (file: File) => Promise<string>) =>
186185
})
187186
.catch((err) => {
188187
console.error(err);
189-
toast.error('Could not upload audio', { id });
188+
toast.error(strings.extension.audio.dropError, { id });
190189
});
191190

192191
return true;

0 commit comments

Comments
 (0)