@jhits/plugin-content 0.0.15 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/files.d.ts +27 -0
- package/dist/api/files.d.ts.map +1 -0
- package/dist/api/files.js +159 -0
- package/dist/api/handler.d.ts +4 -0
- package/dist/api/handler.d.ts.map +1 -1
- package/dist/api/links.d.ts +23 -0
- package/dist/api/links.d.ts.map +1 -0
- package/dist/api/links.js +75 -0
- package/dist/api/router.d.ts +6 -0
- package/dist/api/router.d.ts.map +1 -1
- package/dist/api/router.js +32 -4
- package/dist/components/DynamicLink.d.ts +28 -0
- package/dist/components/DynamicLink.d.ts.map +1 -0
- package/dist/components/DynamicLink.js +62 -0
- package/dist/components/LinkSettingsModal.d.ts +22 -0
- package/dist/components/LinkSettingsModal.d.ts.map +1 -0
- package/dist/components/LinkSettingsModal.js +172 -0
- package/dist/components/TranslationEditor.d.ts +3 -1
- package/dist/components/TranslationEditor.d.ts.map +1 -1
- package/dist/components/TranslationEditor.js +11 -5
- package/dist/hooks/useLinks.d.ts +23 -0
- package/dist/hooks/useLinks.d.ts.map +1 -0
- package/dist/hooks/useLinks.js +56 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -8
- package/dist/views/LinkManager/LinkManager.d.ts +9 -0
- package/dist/views/LinkManager/LinkManager.d.ts.map +1 -0
- package/dist/views/LinkManager/LinkManager.js +90 -0
- package/dist/views/MediaManager/MediaManager.d.ts +8 -0
- package/dist/views/MediaManager/MediaManager.d.ts.map +1 -0
- package/dist/views/MediaManager/MediaManager.js +93 -0
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.d.ts.map +1 -0
- package/dist/views/index.js +22 -0
- package/package.json +1 -1
- package/src/api/files.ts +192 -0
- package/src/api/handler.ts +2 -0
- package/src/api/links.ts +107 -0
- package/src/api/router.ts +37 -8
- package/src/components/DynamicLink.tsx +152 -0
- package/src/components/LinkSettingsModal.tsx +442 -0
- package/src/components/TranslationEditor.tsx +18 -7
- package/src/hooks/useLinks.ts +75 -0
- package/src/index.tsx +40 -9
package/src/index.tsx
CHANGED
|
@@ -16,12 +16,31 @@ export interface ContentPluginProps {
|
|
|
16
16
|
locale?: string;
|
|
17
17
|
/** Messages object - can be passed explicitly or will be fetched from context */
|
|
18
18
|
messages?: Record<string, any>;
|
|
19
|
+
/** API base URL for the dashboard */
|
|
20
|
+
apiBaseUrl?: string;
|
|
21
|
+
/** Site identifier for multi-tenant setups */
|
|
22
|
+
siteId?: string;
|
|
19
23
|
}
|
|
20
24
|
|
|
21
|
-
function ContentPluginWithIntl({
|
|
25
|
+
function ContentPluginWithIntl({
|
|
26
|
+
locale,
|
|
27
|
+
messages,
|
|
28
|
+
apiBaseUrl,
|
|
29
|
+
siteId
|
|
30
|
+
}: {
|
|
31
|
+
locale: string;
|
|
32
|
+
messages: Record<string, any>;
|
|
33
|
+
apiBaseUrl?: string;
|
|
34
|
+
siteId?: string;
|
|
35
|
+
}) {
|
|
22
36
|
return (
|
|
23
37
|
<Suspense fallback={null}>
|
|
24
|
-
<TranslationEditor
|
|
38
|
+
<TranslationEditor
|
|
39
|
+
messages={messages}
|
|
40
|
+
locale={locale}
|
|
41
|
+
apiBaseUrl={apiBaseUrl}
|
|
42
|
+
siteId={siteId}
|
|
43
|
+
/>
|
|
25
44
|
</Suspense>
|
|
26
45
|
);
|
|
27
46
|
}
|
|
@@ -40,28 +59,34 @@ function ClientOnly({ children }: { children: React.ReactNode }) {
|
|
|
40
59
|
* Content Plugin Component
|
|
41
60
|
* Renders the translation editor for editing website content
|
|
42
61
|
*/
|
|
43
|
-
export default function ContentPlugin(
|
|
62
|
+
export default function ContentPlugin(props: ContentPluginProps) {
|
|
63
|
+
const { enabled = true, locale, messages, apiBaseUrl, siteId = 'default' } = props;
|
|
64
|
+
|
|
44
65
|
if (!enabled) return null;
|
|
45
66
|
|
|
46
67
|
// If locale and messages are provided as props, use them directly
|
|
47
68
|
if (locale && messages) {
|
|
48
69
|
return (
|
|
49
70
|
<ClientOnly>
|
|
50
|
-
<ContentPluginWithIntl
|
|
71
|
+
<ContentPluginWithIntl
|
|
72
|
+
locale={locale}
|
|
73
|
+
messages={messages}
|
|
74
|
+
apiBaseUrl={apiBaseUrl}
|
|
75
|
+
siteId={siteId}
|
|
76
|
+
/>
|
|
51
77
|
</ClientOnly>
|
|
52
78
|
);
|
|
53
79
|
}
|
|
54
80
|
|
|
55
81
|
// Otherwise, try to use context (for backward compatibility)
|
|
56
|
-
// This path might have issues with context not being found
|
|
57
82
|
return (
|
|
58
83
|
<ClientOnly>
|
|
59
|
-
<ContentPluginWithIntlFallback />
|
|
84
|
+
<ContentPluginWithIntlFallback apiBaseUrl={apiBaseUrl} siteId={siteId} />
|
|
60
85
|
</ClientOnly>
|
|
61
86
|
);
|
|
62
87
|
}
|
|
63
88
|
|
|
64
|
-
function ContentPluginWithIntlFallback() {
|
|
89
|
+
function ContentPluginWithIntlFallback({ apiBaseUrl, siteId }: { apiBaseUrl?: string; siteId?: string }) {
|
|
65
90
|
// Dynamic import to avoid SSR issues with next-intl hooks
|
|
66
91
|
const { useMessages, useLocale, NextIntlClientProvider } = require('next-intl');
|
|
67
92
|
const messages = useMessages();
|
|
@@ -70,7 +95,12 @@ function ContentPluginWithIntlFallback() {
|
|
|
70
95
|
return (
|
|
71
96
|
<NextIntlClientProvider locale={locale} messages={messages}>
|
|
72
97
|
<Suspense fallback={null}>
|
|
73
|
-
<TranslationEditor
|
|
98
|
+
<TranslationEditor
|
|
99
|
+
messages={messages}
|
|
100
|
+
locale={locale}
|
|
101
|
+
apiBaseUrl={apiBaseUrl}
|
|
102
|
+
siteId={siteId}
|
|
103
|
+
/>
|
|
74
104
|
</Suspense>
|
|
75
105
|
</NextIntlClientProvider>
|
|
76
106
|
);
|
|
@@ -84,6 +114,7 @@ export { default as MultilineText } from './components/MultilineText';
|
|
|
84
114
|
export type { MultilineTextProps } from './components/MultilineText';
|
|
85
115
|
export { default as ParsedText } from './components/ParsedText';
|
|
86
116
|
export type { ParsedTextProps } from './components/ParsedText';
|
|
117
|
+
export { DynamicLink } from './components/DynamicLink';
|
|
87
118
|
export type { TranslationEditorProps } from './components/TranslationEditor';
|
|
88
119
|
|
|
89
120
|
// Export context
|
|
@@ -93,6 +124,7 @@ export type { ParserConfigProviderProps } from './context/ParserConfigContext';
|
|
|
93
124
|
// Export hooks
|
|
94
125
|
export { useParse } from './hooks/useParse';
|
|
95
126
|
export { useLocaleSync } from './hooks/useLocaleSync';
|
|
127
|
+
export { useLinks } from './hooks/useLinks';
|
|
96
128
|
|
|
97
129
|
// Export utilities
|
|
98
130
|
// Note: parse() is a client-only function. Use ParsedText component in server components.
|
|
@@ -104,4 +136,3 @@ export type { ParserConfig, FormatStyle } from './utils/parser-config';
|
|
|
104
136
|
|
|
105
137
|
// Note: API handlers are server-only and exported from ./index.ts (server entry point)
|
|
106
138
|
// They are NOT exported here to prevent client/server context mixing
|
|
107
|
-
|