rimelight-components 2.1.10 → 2.1.12
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/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/components/page/PageEditor.d.vue.ts +5 -1
- package/dist/runtime/components/page/PageEditor.vue +178 -72
- package/dist/runtime/components/page/PageEditor.vue.d.ts +5 -1
- package/dist/runtime/components/page/PagePropertiesEditor.vue +163 -81
- package/dist/runtime/components/page/PagePropertiesRenderer.vue +1 -1
- package/dist/runtime/components/page/PageRenderer.vue +1 -1
- package/dist/runtime/components/page/PageTOC.vue +1 -1
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/runtime/composables/index.mjs +1 -0
- package/dist/runtime/composables/useInfobox.d.ts +8 -0
- package/dist/runtime/composables/useInfobox.js +31 -0
- package/dist/runtime/composables/useInfobox.mjs +31 -0
- package/dist/runtime/composables/usePageEditor.js +2 -4
- package/dist/runtime/composables/usePageEditor.mjs +2 -4
- package/dist/runtime/types/pages.d.ts +1 -0
- package/package.json +2 -1
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { readdirSync } from 'node:fs';
|
|
|
4
4
|
import { basename } from 'node:path';
|
|
5
5
|
|
|
6
6
|
const name = "rimelight-components";
|
|
7
|
-
const version = "2.1.
|
|
7
|
+
const version = "2.1.12";
|
|
8
8
|
const homepage = "https://rimelight.com/tools/rimelight-components";
|
|
9
9
|
|
|
10
10
|
const defaultOptions = {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { Page } from "../../types/index.js";
|
|
1
|
+
import type { Page, PageSurround } from "../../types/index.js";
|
|
2
2
|
interface PageEditorProps {
|
|
3
3
|
isSaving: boolean;
|
|
4
|
+
useSurround?: boolean;
|
|
5
|
+
surround?: PageSurround | null;
|
|
6
|
+
surroundStatus?: 'idle' | 'pending' | 'success' | 'error';
|
|
7
|
+
resolvePage?: (id: string) => Promise<Pick<Page, 'title' | 'icon' | 'slug'>>;
|
|
4
8
|
}
|
|
5
9
|
type __VLS_Props = PageEditorProps;
|
|
6
10
|
type __VLS_ModelProps = {
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, computed, useTemplateRef } from "vue";
|
|
3
|
-
import { usePageEditor } from "../../composables";
|
|
2
|
+
import { ref, computed, useTemplateRef, provide } from "vue";
|
|
3
|
+
import { usePageEditor, usePageRegistry } from "../../composables";
|
|
4
4
|
import { getLocalizedContent } from "../../utils";
|
|
5
|
+
import { useI18n } from "vue-i18n";
|
|
6
|
+
const { getTypeLabelKey } = usePageRegistry();
|
|
7
|
+
const { t, locale } = useI18n();
|
|
5
8
|
const page = defineModel({ type: null, ...{ required: true } });
|
|
6
9
|
const { undo, redo, canUndo, canRedo, captureSnapshot } = usePageEditor(page);
|
|
7
|
-
const { isSaving } = defineProps({
|
|
8
|
-
isSaving: { type: Boolean, required: true }
|
|
10
|
+
const { isSaving, useSurround = false, surroundStatus = "idle", surround = null, resolvePage } = defineProps({
|
|
11
|
+
isSaving: { type: Boolean, required: true },
|
|
12
|
+
useSurround: { type: Boolean, required: false },
|
|
13
|
+
surround: { type: [Object, null], required: false },
|
|
14
|
+
surroundStatus: { type: String, required: false },
|
|
15
|
+
resolvePage: { type: Function, required: false }
|
|
9
16
|
});
|
|
10
17
|
const emit = defineEmits(["save"]);
|
|
11
18
|
const handleSave = () => {
|
|
@@ -20,12 +27,43 @@ defineExpose({
|
|
|
20
27
|
});
|
|
21
28
|
const editorRef = useTemplateRef("editor");
|
|
22
29
|
const showPreview = ref(false);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
30
|
+
provide("page-resolver", resolvePage);
|
|
31
|
+
const previousPage = computed(() => surround?.previous);
|
|
32
|
+
const nextPage = computed(() => surround?.next);
|
|
33
|
+
const hasSurround = computed(() => !!(surround?.previous || surround?.next));
|
|
34
|
+
const containerRef = useTemplateRef("split-container");
|
|
35
|
+
const editorWidth = ref(50);
|
|
36
|
+
const isResizing = ref(false);
|
|
37
|
+
const SNAP_THRESHOLD = 1.5;
|
|
38
|
+
const handleMouseMove = (e) => {
|
|
39
|
+
if (!isResizing.value || !containerRef.value) return;
|
|
40
|
+
const containerRect = containerRef.value.getBoundingClientRect();
|
|
41
|
+
let newWidth = (e.clientX - containerRect.left) / containerRect.width * 100;
|
|
42
|
+
newWidth = Math.min(Math.max(newWidth, 20), 80);
|
|
43
|
+
if (Math.abs(newWidth - 50) < SNAP_THRESHOLD) {
|
|
44
|
+
editorWidth.value = 50;
|
|
45
|
+
} else {
|
|
46
|
+
editorWidth.value = newWidth;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const cursorClass = computed(() => {
|
|
50
|
+
if (isResizing.value) return "cursor-grabbing";
|
|
51
|
+
return "cursor-grab";
|
|
52
|
+
});
|
|
53
|
+
const startResizing = (e) => {
|
|
54
|
+
isResizing.value = true;
|
|
55
|
+
window.addEventListener("mousemove", handleMouseMove);
|
|
56
|
+
window.addEventListener("mouseup", stopResizing);
|
|
57
|
+
document.body.style.cursor = "col-resize";
|
|
58
|
+
document.body.style.userSelect = "none";
|
|
59
|
+
};
|
|
60
|
+
const stopResizing = () => {
|
|
61
|
+
isResizing.value = false;
|
|
62
|
+
window.removeEventListener("mousemove", handleMouseMove);
|
|
63
|
+
window.removeEventListener("mouseup", stopResizing);
|
|
64
|
+
document.body.style.cursor = "";
|
|
65
|
+
document.body.style.userSelect = "";
|
|
66
|
+
};
|
|
29
67
|
</script>
|
|
30
68
|
|
|
31
69
|
<template>
|
|
@@ -72,70 +110,138 @@ const editorPanelClass = computed(() => ({
|
|
|
72
110
|
</div>
|
|
73
111
|
</template>
|
|
74
112
|
</UHeader>
|
|
75
|
-
<
|
|
76
|
-
|
|
77
|
-
|
|
113
|
+
<main
|
|
114
|
+
ref="split-container"
|
|
115
|
+
class="flex w-full overflow-hidden"
|
|
78
116
|
>
|
|
79
|
-
<div
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
>
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
117
|
+
<div
|
|
118
|
+
class="h-full overflow-y-auto"
|
|
119
|
+
:style="{ width: showPreview ? `${editorWidth}%` : '100%' }"
|
|
120
|
+
>
|
|
121
|
+
<UContainer class="flex flex-col py-16">
|
|
122
|
+
<div class="grid grid-cols-1 lg:grid-cols-24 gap-xl items-start">
|
|
123
|
+
<RCPageTOC
|
|
124
|
+
:page-blocks="page.blocks"
|
|
125
|
+
:levels="[2, 3, 4]"
|
|
126
|
+
class="hidden lg:flex lg:col-span-4 sticky top-20 self-start"
|
|
127
|
+
>
|
|
128
|
+
<template #bottom> </template>
|
|
129
|
+
</RCPageTOC>
|
|
130
|
+
<RCPagePropertiesEditor v-model="page" class="order-1 lg:order-2 lg:col-span-6" />
|
|
131
|
+
<div class="order-2 lg:order-1 lg:col-span-14 flex flex-col gap-xl">
|
|
132
|
+
<NuxtImg
|
|
133
|
+
v-if="page.banner?.src"
|
|
134
|
+
:src="page.banner?.src"
|
|
135
|
+
:alt="page.banner?.alt"
|
|
136
|
+
class="rounded-xl w-full object-cover"
|
|
137
|
+
/>
|
|
138
|
+
<UPageHeader
|
|
139
|
+
:headline="t(getTypeLabelKey(page.type))"
|
|
140
|
+
:description="getLocalizedContent(page.description, 'en') ?? ''"
|
|
141
|
+
:ui="{ root: 'pt-0' }"
|
|
142
|
+
>
|
|
143
|
+
<template #title>
|
|
144
|
+
<div class="flex flex-row gap-sm">
|
|
145
|
+
<NuxtImg
|
|
146
|
+
v-if="page.icon?.src"
|
|
147
|
+
:src="page.icon?.src"
|
|
148
|
+
:alt="page.icon?.alt"
|
|
149
|
+
class="rounded-full w-12 h-12 object-cover"
|
|
150
|
+
/>
|
|
151
|
+
<h1>{{ getLocalizedContent(page.title, locale) }}</h1>
|
|
152
|
+
</div>
|
|
153
|
+
</template>
|
|
154
|
+
</UPageHeader>
|
|
155
|
+
<RCBlockEditor
|
|
156
|
+
ref="editor"
|
|
157
|
+
v-model="page.blocks"
|
|
158
|
+
@mutation="captureSnapshot"
|
|
159
|
+
/>
|
|
160
|
+
<template v-if="useSurround">
|
|
161
|
+
<div v-if="surroundStatus === 'pending'" class="grid grid-cols-1 gap-md sm:grid-cols-2">
|
|
162
|
+
<USkeleton class="h-48 w-full rounded-xl" />
|
|
163
|
+
<USkeleton class="h-48 w-full rounded-xl" />
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<LazyRCPageSurround
|
|
167
|
+
v-else-if="surroundStatus === 'success' && hasSurround"
|
|
168
|
+
hydrate-on-visible
|
|
169
|
+
:pageType="getTypeLabelKey(page.type)"
|
|
170
|
+
:previousTitle="getLocalizedContent(previousPage?.title, locale)"
|
|
171
|
+
:previousDescription="getLocalizedContent(previousPage?.description, locale)"
|
|
172
|
+
:previousTo="`/${previousPage?.slug}`"
|
|
173
|
+
:nextTitle="getLocalizedContent(nextPage?.title, locale)"
|
|
174
|
+
:nextDescription="getLocalizedContent(nextPage?.description, locale)"
|
|
175
|
+
:nextTo="`/${nextPage?.slug}`"
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
<USeparator />
|
|
179
|
+
|
|
180
|
+
<div class="flex flex-col gap-xs text-xs text-dimmed p-xl">
|
|
181
|
+
<h6>Metadata</h6>
|
|
182
|
+
<span>Page ID: {{ page.id }}</span>
|
|
183
|
+
<span
|
|
184
|
+
>Created At:
|
|
185
|
+
<NuxtTime
|
|
186
|
+
:datetime="page.created_at ?? ''"
|
|
187
|
+
year="numeric"
|
|
188
|
+
month="numeric"
|
|
189
|
+
day="numeric"
|
|
190
|
+
hour="numeric"
|
|
191
|
+
minute="numeric"
|
|
192
|
+
second="numeric"
|
|
193
|
+
time-zone-name="short"
|
|
194
|
+
/></span>
|
|
195
|
+
<span
|
|
196
|
+
>Posted At:
|
|
197
|
+
<NuxtTime
|
|
198
|
+
:datetime="page.created_at ?? ''"
|
|
199
|
+
year="numeric"
|
|
200
|
+
month="numeric"
|
|
201
|
+
day="numeric"
|
|
202
|
+
hour="numeric"
|
|
203
|
+
minute="numeric"
|
|
204
|
+
second="numeric"
|
|
205
|
+
time-zone-name="short"
|
|
206
|
+
/></span>
|
|
207
|
+
<span
|
|
208
|
+
>Updated At:
|
|
209
|
+
<NuxtTime
|
|
210
|
+
:datetime="page.created_at ?? ''"
|
|
211
|
+
year="numeric"
|
|
212
|
+
month="numeric"
|
|
213
|
+
day="numeric"
|
|
214
|
+
hour="numeric"
|
|
215
|
+
minute="numeric"
|
|
216
|
+
second="numeric"
|
|
217
|
+
time-zone-name="short"
|
|
218
|
+
/></span>
|
|
219
|
+
</div>
|
|
220
|
+
</template>
|
|
221
|
+
</div>
|
|
133
222
|
</div>
|
|
134
|
-
</
|
|
223
|
+
</UContainer>
|
|
135
224
|
</div>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
225
|
+
|
|
226
|
+
<div
|
|
227
|
+
v-if="showPreview"
|
|
228
|
+
:class="cursorClass"
|
|
229
|
+
class="relative flex flex-col items-center justify-center w-6 cursor-col-resize group px-1 py-16"
|
|
230
|
+
@mousedown="startResizing"
|
|
231
|
+
@dblclick="editorWidth = 50"
|
|
232
|
+
>
|
|
233
|
+
<USeparator
|
|
234
|
+
orientation="vertical"
|
|
235
|
+
:ui="{}"
|
|
236
|
+
/>
|
|
237
|
+
</div>
|
|
238
|
+
|
|
239
|
+
<div
|
|
240
|
+
v-if="showPreview"
|
|
241
|
+
class="h-full overflow-y-auto"
|
|
242
|
+
:style="{ width: `${100 - editorWidth}%` }"
|
|
243
|
+
>
|
|
244
|
+
<RCPageRenderer v-model="page" />
|
|
139
245
|
</div>
|
|
140
|
-
</
|
|
246
|
+
</main>
|
|
141
247
|
</template>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import type { Page } from "../../types/index.js";
|
|
1
|
+
import type { Page, PageSurround } from "../../types/index.js";
|
|
2
2
|
interface PageEditorProps {
|
|
3
3
|
isSaving: boolean;
|
|
4
|
+
useSurround?: boolean;
|
|
5
|
+
surround?: PageSurround | null;
|
|
6
|
+
surroundStatus?: 'idle' | 'pending' | 'success' | 'error';
|
|
7
|
+
resolvePage?: (id: string) => Promise<Pick<Page, 'title' | 'icon' | 'slug'>>;
|
|
4
8
|
}
|
|
5
9
|
type __VLS_Props = PageEditorProps;
|
|
6
10
|
type __VLS_ModelProps = {
|
|
@@ -1,101 +1,183 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
+
import { computed } from "vue";
|
|
2
3
|
import { useI18n } from "vue-i18n";
|
|
3
|
-
import { usePageRegistry } from "../../composables";
|
|
4
|
+
import { usePageRegistry, useInfobox } from "../../composables";
|
|
4
5
|
import { getLocalizedContent } from "../../utils";
|
|
6
|
+
import {} from "@nuxt/ui/components/Tabs.vue";
|
|
5
7
|
import {} from "../../types";
|
|
6
|
-
const { getTypeLabelKey } = usePageRegistry();
|
|
7
8
|
const page = defineModel({ type: null, ...{ required: true } });
|
|
9
|
+
const { getTypeLabelKey } = usePageRegistry();
|
|
10
|
+
const { isFieldVisible, shouldRenderGroup, getSortedFields, getSortedGroups } = useInfobox(page.value.properties);
|
|
8
11
|
const { locale, t } = useI18n();
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
11
|
-
return
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const imageTabs = computed(() => {
|
|
13
|
+
if (!page.value.images?.length) return [];
|
|
14
|
+
return page.value.images.map((img, index) => {
|
|
15
|
+
const localizedName = getLocalizedContent(img.name, locale.value);
|
|
16
|
+
return {
|
|
17
|
+
label: localizedName || `${t("label_image")} ${index + 1}`,
|
|
18
|
+
value: `image-${index}`,
|
|
19
|
+
img
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
const updateTextArray = (schema, vals) => {
|
|
24
|
+
schema.value = vals.map((str) => ({
|
|
25
|
+
...schema.value.find((i) => i.en === str),
|
|
26
|
+
// Preserve other locales if they exist
|
|
27
|
+
en: str
|
|
28
|
+
}));
|
|
15
29
|
};
|
|
16
30
|
</script>
|
|
17
31
|
|
|
18
32
|
<template>
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
<aside class="flex flex-col gap-md">
|
|
34
|
+
<UCard
|
|
35
|
+
variant="soft"
|
|
36
|
+
:ui="{ root: 'divide-none', header: 'bg-accented text-center', body: 'p-0 sm:p-0 bg-muted' }"
|
|
37
|
+
>
|
|
38
|
+
<template #header>
|
|
39
|
+
<div class="flex flex-col gap-xs items-center">
|
|
40
|
+
<NuxtImg
|
|
41
|
+
v-if="page.icon?.src"
|
|
42
|
+
:src="page.icon?.src"
|
|
43
|
+
:alt="page.icon?.alt"
|
|
44
|
+
class="rounded-full w-12 h-12 object-cover"
|
|
45
|
+
/>
|
|
29
46
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{{ group.label[locale] }}
|
|
34
|
-
</span>
|
|
35
|
-
<div class="h-px flex-1 bg-border/50"></div>
|
|
36
|
-
</div>
|
|
47
|
+
<h3>
|
|
48
|
+
{{ getLocalizedContent(page.title, locale) }}
|
|
49
|
+
</h3>
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
<template v-for="[fieldKey, schema] in getSortedFields(group.fields)" :key="fieldKey">
|
|
40
|
-
<UFormField
|
|
41
|
-
v-if="isFieldVisible(schema)"
|
|
42
|
-
:label="getLocalizedContent(schema.label, locale)"
|
|
43
|
-
:name="fieldKey"
|
|
44
|
-
>
|
|
45
|
-
<UInput
|
|
46
|
-
v-if="schema.type === 'text'"
|
|
47
|
-
v-model="schema.value[locale]"
|
|
48
|
-
variant="subtle"
|
|
49
|
-
placeholder="..."
|
|
50
|
-
/>
|
|
51
|
+
<span class="text-sm">{{ t(getTypeLabelKey(page.type)) }}</span>
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
v-
|
|
55
|
-
|
|
56
|
-
variant="
|
|
57
|
-
|
|
53
|
+
<div v-if="page.tags?.length" class="flex flex-row flex-wrap gap-xs">
|
|
54
|
+
<UBadge
|
|
55
|
+
v-for="tag in page.tags"
|
|
56
|
+
:key="tag[locale]"
|
|
57
|
+
variant="soft"
|
|
58
|
+
size="xs"
|
|
59
|
+
color="neutral"
|
|
60
|
+
>
|
|
61
|
+
{{ tag[locale] }}
|
|
62
|
+
</UBadge>
|
|
63
|
+
</div>
|
|
58
64
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
v-
|
|
62
|
-
:items="
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
<div v-if="page.images?.length" class="w-full">
|
|
66
|
+
<UTabs
|
|
67
|
+
v-if="page.images.length > 1"
|
|
68
|
+
:items="imageTabs"
|
|
69
|
+
default-value="image-0"
|
|
70
|
+
variant="link"
|
|
71
|
+
size="xs"
|
|
72
|
+
color="neutral"
|
|
73
|
+
class="w-full"
|
|
74
|
+
>
|
|
75
|
+
<template #content="{ item }">
|
|
76
|
+
<NuxtImg :src="item.img.src" :alt="item.img.alt" class="w-full object-cover" />
|
|
77
|
+
</template>
|
|
78
|
+
</UTabs>
|
|
65
79
|
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
80
|
+
<div v-else-if="page.images[0]">
|
|
81
|
+
<NuxtImg
|
|
82
|
+
:src="page.images[0].src"
|
|
83
|
+
:alt="page.images[0].alt"
|
|
84
|
+
class="w-full object-cover"
|
|
85
|
+
/>
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</template>
|
|
75
90
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
<template #default>
|
|
92
|
+
<template v-for="[groupId, group] in getSortedGroups(page.properties)" :key="groupId">
|
|
93
|
+
<UCollapsible v-if="shouldRenderGroup(group, false)" :default-open="group.defaultOpen">
|
|
94
|
+
<template #default>
|
|
95
|
+
<UButton
|
|
96
|
+
:label="getLocalizedContent(group.label, locale)"
|
|
97
|
+
variant="soft"
|
|
98
|
+
trailing-icon="lucide:chevron-down"
|
|
99
|
+
:ui="{
|
|
100
|
+
trailingIcon: 'group-data-[state=open]:rotate-180 transition-transform duration-200'
|
|
101
|
+
}"
|
|
102
|
+
block
|
|
103
|
+
class="group rounded-none bg-elevated text-default"
|
|
104
|
+
/>
|
|
105
|
+
</template>
|
|
87
106
|
|
|
88
|
-
|
|
107
|
+
<template #content>
|
|
108
|
+
<dl class="p-sm flex flex-col gap-xs">
|
|
109
|
+
<template v-for="[fieldKey, schema] in getSortedFields(group.fields)" :key="fieldKey">
|
|
110
|
+
<UFormField
|
|
111
|
+
v-if="isFieldVisible(schema, false)"
|
|
112
|
+
:label="getLocalizedContent(schema.label, locale)"
|
|
113
|
+
:name="fieldKey"
|
|
114
|
+
>
|
|
115
|
+
<UInput
|
|
116
|
+
v-if="schema.type === 'text'"
|
|
117
|
+
v-model="schema.value.en"
|
|
118
|
+
variant="subtle"
|
|
119
|
+
placeholder="Type here..."
|
|
120
|
+
class="w-full"
|
|
121
|
+
/>
|
|
89
122
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
123
|
+
<UInput
|
|
124
|
+
v-else-if="schema.type === 'number'"
|
|
125
|
+
v-model.number="schema.value"
|
|
126
|
+
type="number"
|
|
127
|
+
variant="subtle"
|
|
128
|
+
class="w-full"
|
|
129
|
+
/>
|
|
130
|
+
|
|
131
|
+
<USelect
|
|
132
|
+
v-else-if="schema.type === 'enum'"
|
|
133
|
+
v-model="schema.value"
|
|
134
|
+
:items="schema.options || []"
|
|
135
|
+
variant="subtle"
|
|
136
|
+
class="w-full"
|
|
137
|
+
/>
|
|
138
|
+
|
|
139
|
+
<UInputMenu
|
|
140
|
+
v-else-if="schema.type === 'text-array'"
|
|
141
|
+
:model-value="schema.value.map((v) => v.en)"
|
|
142
|
+
@update:model-value="(vals) => updateTextArray(schema, vals)"
|
|
143
|
+
multiple
|
|
144
|
+
creatable
|
|
145
|
+
variant="subtle"
|
|
146
|
+
placeholder="Add item..."
|
|
147
|
+
class="w-full"
|
|
148
|
+
/>
|
|
149
|
+
|
|
150
|
+
<UInput
|
|
151
|
+
v-else-if="schema.type === 'page'"
|
|
152
|
+
v-model="schema.value"
|
|
153
|
+
icon="lucide:link-2"
|
|
154
|
+
variant="subtle"
|
|
155
|
+
:placeholder="`Select ${schema.allowedPageTypes?.join('/')}`"
|
|
156
|
+
class="w-full"
|
|
157
|
+
/>
|
|
158
|
+
</UFormField>
|
|
159
|
+
</template>
|
|
160
|
+
</dl>
|
|
161
|
+
</template>
|
|
162
|
+
</UCollapsible>
|
|
163
|
+
</template>
|
|
164
|
+
</template>
|
|
165
|
+
</UCard>
|
|
166
|
+
<div class="flex flex-col gap-xs">
|
|
167
|
+
<h6>Links</h6>
|
|
168
|
+
<UButton
|
|
169
|
+
v-for="(link, index) in page.links"
|
|
170
|
+
:key="index"
|
|
171
|
+
:label="link.label"
|
|
172
|
+
:icon="link.icon"
|
|
173
|
+
:to="link.to"
|
|
174
|
+
:target="link.to ? '_blank' : void 0"
|
|
175
|
+
:external="!!link.to"
|
|
176
|
+
:variant="link.variant || 'link'"
|
|
177
|
+
:color="link.color || 'neutral'"
|
|
178
|
+
size="sm"
|
|
179
|
+
:ui="{ base: 'pl-0' }"
|
|
98
180
|
/>
|
|
99
|
-
</
|
|
100
|
-
</
|
|
181
|
+
</div>
|
|
182
|
+
</aside>
|
|
101
183
|
</template>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
3
|
import { getLocalizedContent } from "../../utils";
|
|
4
|
-
import { usePageRegistry } from "../../composables";
|
|
4
|
+
import { usePageRegistry, useInfobox } from "../../composables";
|
|
5
5
|
import { useToast } from "@nuxt/ui/composables";
|
|
6
6
|
import {} from "@nuxt/ui/components/Tabs.vue";
|
|
7
7
|
import { useI18n } from "vue-i18n";
|
|
@@ -26,7 +26,7 @@ const hasSurround = computed(() => !!(surround?.previous || surround?.next));
|
|
|
26
26
|
<RCPageTOC
|
|
27
27
|
:page-blocks="page.blocks"
|
|
28
28
|
:levels="[2, 3, 4]"
|
|
29
|
-
class="hidden lg:flex lg:col-span-4 sticky top-
|
|
29
|
+
class="hidden lg:flex lg:col-span-4 sticky top-16"
|
|
30
30
|
>
|
|
31
31
|
<template #bottom> </template>
|
|
32
32
|
</RCPageTOC>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Property, PropertyGroup, BasePageProperties } from '../types/index.js';
|
|
2
|
+
export declare const useInfobox: (properties: BasePageProperties) => {
|
|
3
|
+
isFieldVisible: (schema: Property, isReadOnly: boolean) => boolean;
|
|
4
|
+
shouldRenderGroup: (group: PropertyGroup, isReadOnly: boolean) => boolean;
|
|
5
|
+
getSortedFields: (fields: Record<string, Property>) => [string, Property<any>][];
|
|
6
|
+
getSortedGroups: (props: BasePageProperties) => [string, PropertyGroup][];
|
|
7
|
+
locale: import("vue").WritableComputedRef<string, string>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useI18n } from "vue-i18n";
|
|
2
|
+
export const useInfobox = (properties) => {
|
|
3
|
+
const { locale } = useI18n();
|
|
4
|
+
const isFieldVisible = (schema, isReadOnly) => {
|
|
5
|
+
const passesLogic = !schema.visibleIf || schema.visibleIf(properties);
|
|
6
|
+
if (!passesLogic) return false;
|
|
7
|
+
if (isReadOnly) {
|
|
8
|
+
const val = schema.value;
|
|
9
|
+
if (schema.type === "text") return !!val?.[locale.value];
|
|
10
|
+
if (schema.type === "text-array") return Array.isArray(val) && val.length > 0;
|
|
11
|
+
return val !== void 0 && val !== null && val !== "";
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
const shouldRenderGroup = (group, isReadOnly) => {
|
|
16
|
+
return Object.values(group.fields).some((schema) => isFieldVisible(schema, isReadOnly));
|
|
17
|
+
};
|
|
18
|
+
const getSortedFields = (fields) => {
|
|
19
|
+
return Object.entries(fields).sort(([, a], [, b]) => (a.order ?? 0) - (b.order ?? 0));
|
|
20
|
+
};
|
|
21
|
+
const getSortedGroups = (props) => {
|
|
22
|
+
return Object.entries(props).sort(([, a], [, b]) => (a.order ?? 0) - (b.order ?? 0));
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
isFieldVisible,
|
|
26
|
+
shouldRenderGroup,
|
|
27
|
+
getSortedFields,
|
|
28
|
+
getSortedGroups,
|
|
29
|
+
locale
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useI18n } from "vue-i18n";
|
|
2
|
+
export const useInfobox = (properties) => {
|
|
3
|
+
const { locale } = useI18n();
|
|
4
|
+
const isFieldVisible = (schema, isReadOnly) => {
|
|
5
|
+
const passesLogic = !schema.visibleIf || schema.visibleIf(properties);
|
|
6
|
+
if (!passesLogic) return false;
|
|
7
|
+
if (isReadOnly) {
|
|
8
|
+
const val = schema.value;
|
|
9
|
+
if (schema.type === "text") return !!val?.[locale.value];
|
|
10
|
+
if (schema.type === "text-array") return Array.isArray(val) && val.length > 0;
|
|
11
|
+
return val !== void 0 && val !== null && val !== "";
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
15
|
+
const shouldRenderGroup = (group, isReadOnly) => {
|
|
16
|
+
return Object.values(group.fields).some((schema) => isFieldVisible(schema, isReadOnly));
|
|
17
|
+
};
|
|
18
|
+
const getSortedFields = (fields) => {
|
|
19
|
+
return Object.entries(fields).sort(([, a], [, b]) => (a.order ?? 0) - (b.order ?? 0));
|
|
20
|
+
};
|
|
21
|
+
const getSortedGroups = (props) => {
|
|
22
|
+
return Object.entries(props).sort(([, a], [, b]) => (a.order ?? 0) - (b.order ?? 0));
|
|
23
|
+
};
|
|
24
|
+
return {
|
|
25
|
+
isFieldVisible,
|
|
26
|
+
shouldRenderGroup,
|
|
27
|
+
getSortedFields,
|
|
28
|
+
getSortedGroups,
|
|
29
|
+
locale
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -13,14 +13,12 @@ export function usePageEditor(page, maxHistorySize = 100) {
|
|
|
13
13
|
const undo = () => {
|
|
14
14
|
if (history.value.length === 0) return;
|
|
15
15
|
future.value = [JSON.stringify(page.value), ...future.value];
|
|
16
|
-
|
|
17
|
-
page.value = previous;
|
|
16
|
+
page.value = JSON.parse(history.value.pop());
|
|
18
17
|
};
|
|
19
18
|
const redo = () => {
|
|
20
19
|
if (future.value.length === 0) return;
|
|
21
20
|
history.value = [...history.value, JSON.stringify(page.value)];
|
|
22
|
-
|
|
23
|
-
page.value = next;
|
|
21
|
+
page.value = JSON.parse(future.value.shift());
|
|
24
22
|
};
|
|
25
23
|
const canUndo = computed(() => history.value.length > 0);
|
|
26
24
|
const canRedo = computed(() => future.value.length > 0);
|
|
@@ -13,14 +13,12 @@ export function usePageEditor(page, maxHistorySize = 100) {
|
|
|
13
13
|
const undo = () => {
|
|
14
14
|
if (history.value.length === 0) return;
|
|
15
15
|
future.value = [JSON.stringify(page.value), ...future.value];
|
|
16
|
-
|
|
17
|
-
page.value = previous;
|
|
16
|
+
page.value = JSON.parse(history.value.pop());
|
|
18
17
|
};
|
|
19
18
|
const redo = () => {
|
|
20
19
|
if (future.value.length === 0) return;
|
|
21
20
|
history.value = [...history.value, JSON.stringify(page.value)];
|
|
22
|
-
|
|
23
|
-
page.value = next;
|
|
21
|
+
page.value = JSON.parse(future.value.shift());
|
|
24
22
|
};
|
|
25
23
|
const canUndo = computed(() => history.value.length > 0);
|
|
26
24
|
const canRedo = computed(() => future.value.length > 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rimelight-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.12",
|
|
4
4
|
"description": "A component library by Rimelight Entertainment.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nuxt",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"exports": {
|
|
24
24
|
".": "./dist/module.mjs",
|
|
25
|
+
"./components/*": "./dist/runtime/components/*",
|
|
25
26
|
"./composables": {
|
|
26
27
|
"types": "./dist/runtime/composables/index.d.ts",
|
|
27
28
|
"import": "./dist/runtime/composables/index.mjs"
|