@svadmin/ui 0.21.0 → 0.22.0
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/package.json
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import ArrayField from './fields/ArrayField.svelte';
|
|
19
19
|
import { Plus, X } from 'lucide-svelte';
|
|
20
20
|
import type { Snippet } from 'svelte';
|
|
21
|
+
import { getRichTextEditor } from '../editor-config.svelte.js';
|
|
21
22
|
|
|
22
23
|
let { field, value, onchange, children } = $props<{
|
|
23
24
|
field: FieldDefinition;
|
|
@@ -164,25 +165,16 @@
|
|
|
164
165
|
/>
|
|
165
166
|
|
|
166
167
|
{:else if field.type === 'richtext'}
|
|
167
|
-
{
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
value={strVal}
|
|
171
|
-
oninput={(e) => onchange((e.target as HTMLTextAreaElement).value)}
|
|
172
|
-
required={field.required}
|
|
173
|
-
rows={10}
|
|
174
|
-
placeholder={t('field.enterValue', { label: field.label })}
|
|
175
|
-
class="resize-y"
|
|
176
|
-
/>
|
|
177
|
-
{:then editorMod}
|
|
178
|
-
<editorMod.Editor
|
|
168
|
+
{@const EditorComp = getRichTextEditor()}
|
|
169
|
+
{#if EditorComp}
|
|
170
|
+
<EditorComp
|
|
179
171
|
id={field.key}
|
|
180
172
|
value={strVal}
|
|
181
173
|
placeholder={t('field.enterValue', { label: field.label })}
|
|
182
174
|
preset="full"
|
|
183
175
|
onchange={(html: string) => onchange(html)}
|
|
184
176
|
/>
|
|
185
|
-
{:
|
|
177
|
+
{:else}
|
|
186
178
|
<Textarea
|
|
187
179
|
id={field.key}
|
|
188
180
|
value={strVal}
|
|
@@ -192,7 +184,7 @@
|
|
|
192
184
|
placeholder={t('field.enterValue', { label: field.label })}
|
|
193
185
|
class="resize-y"
|
|
194
186
|
/>
|
|
195
|
-
{/
|
|
187
|
+
{/if}
|
|
196
188
|
|
|
197
189
|
{:else if field.type === 'textarea'}
|
|
198
190
|
<Textarea
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Component } from 'svelte';
|
|
2
|
+
|
|
3
|
+
let registeredEditor: Component<any> | undefined = $state(undefined);
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Register a global Rich Text Editor component.
|
|
7
|
+
* This decouples @svadmin/ui from @svadmin/editor, making the editor completely optional.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Editor } from '@svadmin/editor';
|
|
12
|
+
* import { setRichTextEditor } from '@svadmin/ui';
|
|
13
|
+
*
|
|
14
|
+
* setRichTextEditor(Editor);
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export function setRichTextEditor(editorComponent: Component<any>): void {
|
|
18
|
+
registeredEditor = editorComponent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function getRichTextEditor(): Component<any> | undefined {
|
|
22
|
+
return registeredEditor;
|
|
23
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -61,6 +61,11 @@ export { default as InlineEdit } from "./components/InlineEdit.svelte";
|
|
|
61
61
|
export { default as VirtualTable } from "./components/VirtualTable.svelte";
|
|
62
62
|
export { default as DraggableHeader } from "./components/DraggableHeader.svelte";
|
|
63
63
|
export { default as SettingsPage } from "./components/SettingsPage.svelte";
|
|
64
|
+
|
|
65
|
+
// Editor Registry
|
|
66
|
+
export { setRichTextEditor, getRichTextEditor } from "./editor-config.svelte.js";
|
|
67
|
+
|
|
68
|
+
// Settings & Preferences
|
|
64
69
|
export { default as AppearanceSettings } from "./components/AppearanceSettings.svelte";
|
|
65
70
|
export { default as AboutSettings } from "./components/AboutSettings.svelte";
|
|
66
71
|
export { default as PermissionMatrix } from "./components/PermissionMatrix.svelte";
|