Skip to content

Commit 47b3db2

Browse files
committed
feat(website): fix editor playground load dictionary
1 parent 3e78fb3 commit 47b3db2

File tree

6 files changed

+43
-42
lines changed

6 files changed

+43
-42
lines changed

apps/website/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@intlayer/config": "workspace:*",
6060
"@intlayer/core": "workspace:*",
6161
"@intlayer/design-system": "workspace:*",
62+
"@intlayer/dictionaries-entry": "workspace:*",
6263
"@intlayer/docs": "workspace:*",
6364
"@intlayer/editor-react": "workspace:*",
6465
"@monaco-editor/react": "^4.7.0",
@@ -88,7 +89,6 @@
8889
},
8990
"devDependencies": {
9091
"@intlayer/backend": "workspace:*",
91-
"@intlayer/swc": "workspace:*",
9292
"@tailwindcss/postcss": "^4.0.14",
9393
"@types/next-pwa": "^5.6.9",
9494
"@types/node": "^22.13.10",

apps/website/src/components/Dashboard/Editor/DictionaryListDrawer/DictionaryListDrawer.tsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,20 @@
22

33
import type { Locales } from '@intlayer/config';
44
import {
5-
RightDrawer,
65
Button,
6+
RightDrawer,
77
useRightDrawerStore,
88
} from '@intlayer/design-system';
99
import { useGetAllDictionaries } from '@intlayer/design-system/hooks';
1010
import { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';
1111
import { ChevronRight } from 'lucide-react';
12-
import { type FC, useCallback, useMemo } from 'react';
12+
import { type FC } from 'react';
1313
import { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer';
1414
import { dictionaryListDrawerIdentifier } from './dictionaryListDrawerIdentifier';
1515

1616
export const DictionaryListDrawer: FC = () => {
1717
const { all: dictionaries } = useGetAllDictionaries();
18-
const dictionaryKeyList = useMemo(
19-
() => Object.keys(dictionaries) as Locales[],
20-
[dictionaries]
21-
);
18+
const dictionaryKeyList = Object.keys(dictionaries) as Locales[];
2219

2320
const { close: closeDrawer, open: openDrawer } = useRightDrawerStore();
2421

@@ -37,11 +34,8 @@ export const DictionaryListDrawer: FC = () => {
3734
openDrawer(getDrawerIdentifier(dictionaryKey));
3835
};
3936

40-
const isDictionaryEdited = useCallback(
41-
(dictionaryKey: string) =>
42-
Object.keys(editedContent ?? {}).includes(dictionaryKey),
43-
[editedContent]
44-
);
37+
const isDictionaryEdited = (dictionaryKey: string) =>
38+
Object.keys(editedContent ?? {}).includes(dictionaryKey);
4539

4640
return (
4741
<RightDrawer

apps/website/src/components/Dashboard/Editor/EditorLayout.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
'use client';
22

33
import { type Locales } from '@intlayer/config/client';
4-
import { useCrossFrameState } from '@intlayer/editor-react';
4+
import { Container } from '@intlayer/design-system';
5+
import dictionaries from '@intlayer/dictionaries-entry';
6+
import {
7+
useCrossFrameState,
8+
useDictionariesRecordActions,
9+
} from '@intlayer/editor-react';
510
import { useTheme } from 'next-themes';
6-
import type { FC, PropsWithChildren } from 'react';
11+
import { useEffect, type FC, type PropsWithChildren } from 'react';
712
import { DictionaryEditionDrawerController } from './DictionaryEditionDrawer';
813
import { DictionaryListDrawer } from './DictionaryListDrawer';
9-
import { Container } from '@intlayer/design-system';
1014

1115
export const EditorLayout: FC<PropsWithChildren> = ({ children }) => {
1216
const { resolvedTheme } = useTheme();
@@ -19,6 +23,12 @@ export const EditorLayout: FC<PropsWithChildren> = ({ children }) => {
1923
}
2024
);
2125

26+
const { setLocaleDictionaries } = useDictionariesRecordActions();
27+
28+
useEffect(() => {
29+
setLocaleDictionaries(dictionaries);
30+
}, []);
31+
2232
return (
2333
<>
2434
<Container
@@ -29,7 +39,6 @@ export const EditorLayout: FC<PropsWithChildren> = ({ children }) => {
2939
>
3040
{children}
3141
</Container>
32-
3342
<DictionaryEditionDrawerController
3443
locale={currentLocale}
3544
isDarkMode={resolvedTheme === 'dark'}

packages/intlayer-editor/client/src/components/Editor/DictionaryListDrawer/DictionaryListDrawer.tsx

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,17 @@ import {
66
RightDrawer,
77
useRightDrawerStore,
88
} from '@intlayer/design-system';
9-
import {
10-
useGetAllDictionaries,
11-
useGetEditorDictionaries,
12-
} from '@intlayer/design-system/hooks';
13-
import {
14-
useDictionariesRecordActions,
15-
useEditedContent,
16-
useFocusDictionary,
17-
} from '@intlayer/editor-react';
9+
import { useGetAllDictionaries } from '@intlayer/design-system/hooks';
10+
import { useEditedContent, useFocusDictionary } from '@intlayer/editor-react';
1811
import { ChevronRight } from 'lucide-react';
19-
import { type FC, useEffect } from 'react';
12+
import { type FC } from 'react';
2013
import { getDrawerIdentifier } from '../DictionaryEditionDrawer/useDictionaryEditionDrawer';
2114
import { dictionaryListDrawerIdentifier } from './dictionaryListDrawerIdentifier';
2215

2316
export const DictionaryListDrawer: FC = () => {
2417
const { all: dictionaries } = useGetAllDictionaries();
2518
const dictionaryKeyList = Object.keys(dictionaries) as Locales[];
2619

27-
const { setLocaleDictionaries } = useDictionariesRecordActions();
28-
const { data: localeDictionaries } = useGetEditorDictionaries({
29-
autoFetch: true,
30-
});
31-
32-
useEffect(() => {
33-
if (!localeDictionaries) return;
34-
35-
setLocaleDictionaries(localeDictionaries);
36-
}, [dictionaries]);
37-
3820
const { close: closeDrawer, open: openDrawer } = useRightDrawerStore();
3921

4022
const { editedContent } = useEditedContent();

packages/intlayer-editor/client/src/components/Editor/EditorLayout.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
'use client';
22

33
import { type Locales } from '@intlayer/config/client';
4-
import { MessageKey, useCrossFrameState } from '@intlayer/editor-react';
5-
import { type FC, type PropsWithChildren } from 'react';
4+
import { useGetEditorDictionaries } from '@intlayer/design-system/hooks';
5+
import {
6+
MessageKey,
7+
useCrossFrameState,
8+
useDictionariesRecordActions,
9+
} from '@intlayer/editor-react';
10+
import { useEffect, type FC, type PropsWithChildren } from 'react';
611
import { DictionaryEditionDrawerController } from './DictionaryEditionDrawer';
712
import { DictionaryListDrawer } from './DictionaryListDrawer';
813

@@ -15,6 +20,17 @@ export const EditorLayout: FC<PropsWithChildren> = ({ children }) => {
1520
emit: false,
1621
}
1722
);
23+
const { data: localeDictionaries } = useGetEditorDictionaries({
24+
autoFetch: true,
25+
});
26+
27+
const { setLocaleDictionaries } = useDictionariesRecordActions();
28+
29+
useEffect(() => {
30+
if (!localeDictionaries) return;
31+
32+
setLocaleDictionaries(localeDictionaries);
33+
}, [localeDictionaries]);
1834

1935
return (
2036
<div className="bg-card relative size-full p-3">

pnpm-lock.yaml

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)