@alpaca-editor/core 1.0.3902 → 1.0.3904
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/components/ui/CardConnector.d.ts +2 -1
- package/dist/components/ui/CardConnector.js +3 -3
- package/dist/components/ui/CardConnector.js.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/card.d.ts +7 -1
- package/dist/components/ui/card.js +71 -3
- package/dist/components/ui/card.js.map +1 -1
- package/dist/config/config.js +4 -2
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +1 -0
- package/dist/editor/MobileLayout.js +1 -1
- package/dist/editor/MobileLayout.js.map +1 -1
- package/dist/editor/PictureEditor.js +13 -5
- package/dist/editor/PictureEditor.js.map +1 -1
- package/dist/editor/client/EditorClient.js +2 -2
- package/dist/editor/client/EditorClient.js.map +1 -1
- package/dist/editor/client/editContext.d.ts +14 -1
- package/dist/editor/client/editContext.js.map +1 -1
- package/dist/editor/client/operations.js +1 -1
- package/dist/editor/client/operations.js.map +1 -1
- package/dist/editor/page-editor-chrome/CommentHighlighting.js +4 -1
- package/dist/editor/page-editor-chrome/CommentHighlighting.js.map +1 -1
- package/dist/editor/ui/Splitter.js +3 -1
- package/dist/editor/ui/Splitter.js.map +1 -1
- package/dist/page-wizard/WizardBoxConnector.d.ts +2 -1
- package/dist/page-wizard/WizardBoxConnector.js +3 -3
- package/dist/page-wizard/WizardBoxConnector.js.map +1 -1
- package/dist/page-wizard/WizardSteps.js +63 -17
- package/dist/page-wizard/WizardSteps.js.map +1 -1
- package/dist/page-wizard/service.d.ts +1 -1
- package/dist/page-wizard/service.js +1 -1
- package/dist/page-wizard/service.js.map +1 -1
- package/dist/page-wizard/steps/CollectStep.js +11 -17
- package/dist/page-wizard/steps/CollectStep.js.map +1 -1
- package/dist/page-wizard/steps/ComponentTypesSelector.d.ts +1 -0
- package/dist/page-wizard/steps/ComponentTypesSelector.js +53 -78
- package/dist/page-wizard/steps/ComponentTypesSelector.js.map +1 -1
- package/dist/page-wizard/steps/ContentStep.d.ts +2 -0
- package/dist/page-wizard/steps/ContentStep.js +403 -0
- package/dist/page-wizard/steps/ContentStep.js.map +1 -0
- package/dist/page-wizard/steps/Generate.js +1 -1
- package/dist/page-wizard/steps/Generate.js.map +1 -1
- package/dist/page-wizard/steps/ImagesStep.js +16 -13
- package/dist/page-wizard/steps/ImagesStep.js.map +1 -1
- package/dist/page-wizard/steps/SelectStep.js +1 -1
- package/dist/page-wizard/steps/SelectStep.js.map +1 -1
- package/dist/page-wizard/steps/SetupPageStep.d.ts +2 -0
- package/dist/page-wizard/steps/SetupPageStep.js +152 -0
- package/dist/page-wizard/steps/SetupPageStep.js.map +1 -0
- package/dist/page-wizard/steps/usePageCreator.js +4 -4
- package/dist/page-wizard/steps/usePageCreator.js.map +1 -1
- package/dist/page-wizard/usePageWizard.d.ts +17 -3
- package/dist/page-wizard/usePageWizard.js +62 -2
- package/dist/page-wizard/usePageWizard.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/splash-screen/NewPage.js +10 -10
- package/dist/splash-screen/NewPage.js.map +1 -1
- package/dist/splash-screen/SplashScreen.js +3 -3
- package/dist/splash-screen/SplashScreen.js.map +1 -1
- package/dist/styles.css +184 -68
- package/package.json +1 -1
- package/src/components/ui/CardConnector.tsx +50 -15
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/card.tsx +331 -15
- package/src/config/config.tsx +4 -2
- package/src/config/types.ts +3 -0
- package/src/editor/MobileLayout.tsx +7 -9
- package/src/editor/PictureEditor.tsx +16 -10
- package/src/editor/client/EditorClient.tsx +3 -5
- package/src/editor/client/editContext.ts +23 -1
- package/src/editor/client/operations.ts +1 -1
- package/src/editor/page-editor-chrome/CommentHighlighting.tsx +6 -1
- package/src/editor/ui/Splitter.tsx +10 -1
- package/src/page-wizard/WizardBoxConnector.tsx +50 -15
- package/src/page-wizard/WizardSteps.tsx +163 -34
- package/src/page-wizard/service.ts +2 -2
- package/src/page-wizard/steps/CollectStep.tsx +95 -141
- package/src/page-wizard/steps/ComponentTypesSelector.tsx +225 -245
- package/src/page-wizard/steps/ContentStep.tsx +648 -0
- package/src/page-wizard/steps/Generate.tsx +3 -3
- package/src/page-wizard/steps/ImagesStep.tsx +20 -15
- package/src/page-wizard/steps/SelectStep.tsx +4 -4
- package/src/page-wizard/steps/SetupPageStep.tsx +329 -0
- package/src/page-wizard/steps/usePageCreator.ts +4 -4
- package/src/page-wizard/usePageWizard.ts +69 -4
- package/src/revision.ts +2 -2
- package/src/splash-screen/NewPage.tsx +22 -16
- package/src/splash-screen/SplashScreen.tsx +3 -1
- package/dist/page-wizard/steps/CreatePage.d.ts +0 -12
- package/dist/page-wizard/steps/CreatePage.js +0 -149
- package/dist/page-wizard/steps/CreatePage.js.map +0 -1
- package/dist/page-wizard/steps/CreatePageAndLayoutStep.d.ts +0 -2
- package/dist/page-wizard/steps/CreatePageAndLayoutStep.js +0 -235
- package/dist/page-wizard/steps/CreatePageAndLayoutStep.js.map +0 -1
- package/src/page-wizard/steps/CreatePage.tsx +0 -329
- package/src/page-wizard/steps/CreatePageAndLayoutStep.tsx +0 -430
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
import { ActionButton } from "../../components/ActionButton";
|
|
3
|
-
import { useDebouncedCallback } from "use-debounce";
|
|
4
|
-
import { FullItem, ItemDescriptor } from "../../editor/pageModel";
|
|
5
|
-
import { getChildren } from "../../editor/services/contentService";
|
|
6
|
-
import { Wizard, WizardData, WizardPageModel, WizardStep } from "../PageWizard";
|
|
7
|
-
import { executePrompt } from "../../editor/services/aiService";
|
|
8
|
-
import { createWizardAiContext } from "../service";
|
|
9
|
-
import { useEditContext } from "../../editor/client/editContext";
|
|
10
|
-
import { LanguageSelector } from "../../editor/menubar/LanguageSelector";
|
|
11
|
-
import { InputText } from "primereact/inputtext";
|
|
12
|
-
import { InputTextarea } from "primereact/inputtextarea";
|
|
13
|
-
import { getItemDescriptor } from "../../editor/utils";
|
|
14
|
-
import { WizardBox } from "../WizardBox";
|
|
15
|
-
import { WizardBoxConnector } from "../WizardBoxConnector";
|
|
16
|
-
import { Settings, FileText } from "lucide-react";
|
|
17
|
-
|
|
18
|
-
export function CreatePage({
|
|
19
|
-
wizard,
|
|
20
|
-
parentItem,
|
|
21
|
-
setPageItem,
|
|
22
|
-
pageItem,
|
|
23
|
-
pageModel,
|
|
24
|
-
setPageModel,
|
|
25
|
-
step,
|
|
26
|
-
data,
|
|
27
|
-
}: {
|
|
28
|
-
wizard: Wizard;
|
|
29
|
-
parentItem: ItemDescriptor;
|
|
30
|
-
setPageItem: (item: FullItem) => void;
|
|
31
|
-
pageItem?: FullItem;
|
|
32
|
-
pageModel: WizardPageModel;
|
|
33
|
-
setPageModel: (model: WizardPageModel) => void;
|
|
34
|
-
step: WizardStep;
|
|
35
|
-
data: WizardData;
|
|
36
|
-
}) {
|
|
37
|
-
const [validationMessage, setValidationMessage] = useState<string>();
|
|
38
|
-
const [isBuilding, setIsBuilding] = useState(false);
|
|
39
|
-
const [isGenerating, setIsGenerating] = useState(false);
|
|
40
|
-
const [language, setLanguage] = useState<string>(parentItem.language || "en");
|
|
41
|
-
const [previousLanguage, setPreviousLanguage] = useState<string>(language);
|
|
42
|
-
const [fullParentItem, setFullParentItem] = useState<FullItem>();
|
|
43
|
-
const editContext = useEditContext();
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!editContext) return;
|
|
47
|
-
|
|
48
|
-
if (editContext.mode !== "edit") {
|
|
49
|
-
editContext.setMode("edit");
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const generateNameAndMetaDescription = async () => {
|
|
53
|
-
const metaInstructions =
|
|
54
|
-
step["Instructions for generating item name and meta fields"];
|
|
55
|
-
|
|
56
|
-
setIsGenerating(true);
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
const abortController = new AbortController();
|
|
60
|
-
|
|
61
|
-
const result = await executePrompt(
|
|
62
|
-
[
|
|
63
|
-
{
|
|
64
|
-
content: `${metaInstructions?.trim()} Reply with a json object of type PageModel = { name: string; metaDescription: string; metaKeywords: string; };
|
|
65
|
-
The item name should be a valid sitecore item name. Spaces are allowed but no special characters or Umlaute.
|
|
66
|
-
The language of the page is ${language}.
|
|
67
|
-
Input data: ${JSON.stringify(data)}`,
|
|
68
|
-
name: "system",
|
|
69
|
-
role: "system",
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
editContext,
|
|
73
|
-
createWizardAiContext,
|
|
74
|
-
{},
|
|
75
|
-
{ signal: abortController.signal },
|
|
76
|
-
"o3-mini-low",
|
|
77
|
-
(response) => {
|
|
78
|
-
try {
|
|
79
|
-
const newLayout = JSON.parse(response.content) as WizardPageModel;
|
|
80
|
-
|
|
81
|
-
setPageModel({
|
|
82
|
-
...pageModel,
|
|
83
|
-
name: newLayout.name,
|
|
84
|
-
metaDescription: newLayout.metaDescription,
|
|
85
|
-
metaKeywords: newLayout.metaKeywords,
|
|
86
|
-
});
|
|
87
|
-
} catch (parseError: unknown) {}
|
|
88
|
-
},
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
const pageModel = JSON.parse(result.content) as WizardPageModel;
|
|
92
|
-
setPageModel({
|
|
93
|
-
...pageModel,
|
|
94
|
-
name: pageModel.name,
|
|
95
|
-
metaDescription: pageModel.metaDescription,
|
|
96
|
-
metaKeywords: pageModel.metaKeywords,
|
|
97
|
-
});
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error("Error generating name and meta description", error);
|
|
100
|
-
} finally {
|
|
101
|
-
setIsGenerating(false);
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
if (!pageModel.name || language !== previousLanguage) {
|
|
106
|
-
generateNameAndMetaDescription();
|
|
107
|
-
setPreviousLanguage(language);
|
|
108
|
-
}
|
|
109
|
-
}, [language, pageModel.name, previousLanguage, data, step, editContext]);
|
|
110
|
-
|
|
111
|
-
useEffect(() => {
|
|
112
|
-
const loadParentItem = async () => {
|
|
113
|
-
if (!parentItem) return;
|
|
114
|
-
const item = await editContext?.itemsRepository.getItem(parentItem);
|
|
115
|
-
setFullParentItem(item);
|
|
116
|
-
};
|
|
117
|
-
loadParentItem();
|
|
118
|
-
}, [parentItem]);
|
|
119
|
-
|
|
120
|
-
const checkName = async () => {
|
|
121
|
-
if (!parentItem) return;
|
|
122
|
-
let valid: boolean =
|
|
123
|
-
!!wizard.templateId && pageModel.name.trim().length >= 3;
|
|
124
|
-
if (valid) {
|
|
125
|
-
const children = await getChildren(
|
|
126
|
-
parentItem.id,
|
|
127
|
-
editContext?.sessionId ?? "",
|
|
128
|
-
[],
|
|
129
|
-
false,
|
|
130
|
-
editContext?.contentEditorItem?.language || "en",
|
|
131
|
-
);
|
|
132
|
-
if (
|
|
133
|
-
children.find(
|
|
134
|
-
(x) =>
|
|
135
|
-
x.name.toLocaleLowerCase() ===
|
|
136
|
-
pageModel.name.trim().toLocaleLowerCase(),
|
|
137
|
-
)
|
|
138
|
-
) {
|
|
139
|
-
valid = false;
|
|
140
|
-
setValidationMessage("A page with this name already exists.");
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
if (pageModel.name.trim().length > 0 && pageModel.name.trim().length < 3)
|
|
144
|
-
setValidationMessage("Name is too short.");
|
|
145
|
-
else setValidationMessage(undefined);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (valid) setValidationMessage(undefined);
|
|
149
|
-
return valid;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
const checkNameValidDebounced = useDebouncedCallback(
|
|
153
|
-
async () => checkName(),
|
|
154
|
-
500,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
checkNameValidDebounced();
|
|
159
|
-
}, [pageModel.name]);
|
|
160
|
-
|
|
161
|
-
const createPage = () => {
|
|
162
|
-
setTimeout(async () => {
|
|
163
|
-
if (!editContext || !parentItem) return;
|
|
164
|
-
try {
|
|
165
|
-
if (!(await checkName())) return;
|
|
166
|
-
setIsBuilding(true);
|
|
167
|
-
const result = await editContext.operations.createItem(
|
|
168
|
-
{ ...getItemDescriptor(parentItem), language },
|
|
169
|
-
wizard.templateId,
|
|
170
|
-
pageModel.name,
|
|
171
|
-
);
|
|
172
|
-
if (result) {
|
|
173
|
-
editContext?.loadItem(result, { addToBrowseHistory: true });
|
|
174
|
-
const item = await editContext?.itemsRepository.getItem(result);
|
|
175
|
-
if (item) setPageItem(item);
|
|
176
|
-
else console.error("Failed to load newly created item", result);
|
|
177
|
-
|
|
178
|
-
console.log("Page created", result, "Page model", pageModel);
|
|
179
|
-
}
|
|
180
|
-
} catch (error) {
|
|
181
|
-
console.error("Error creating page", error);
|
|
182
|
-
} finally {
|
|
183
|
-
setIsBuilding(false);
|
|
184
|
-
}
|
|
185
|
-
}, 1);
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
const handleInputChange = (field: keyof typeof pageModel, value: string) => {
|
|
189
|
-
const updatedPageModel = {
|
|
190
|
-
...pageModel,
|
|
191
|
-
[field]: value,
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
setPageModel(updatedPageModel);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<div className="flex h-full">
|
|
199
|
-
<WizardBox
|
|
200
|
-
title="Page Setup"
|
|
201
|
-
icon={<Settings />}
|
|
202
|
-
description="Configure the target location and language for your new page"
|
|
203
|
-
className="w-96"
|
|
204
|
-
>
|
|
205
|
-
<div className="flex h-full flex-col items-stretch">
|
|
206
|
-
<div className="relative flex-1">
|
|
207
|
-
<div className="absolute inset-0 overflow-y-auto pr-6">
|
|
208
|
-
<div className="mb-4">
|
|
209
|
-
<div className="mb-1 text-sm font-medium">
|
|
210
|
-
Target Parent Item
|
|
211
|
-
</div>
|
|
212
|
-
<div className="mb-4 break-after-all text-xs">
|
|
213
|
-
{fullParentItem?.path}
|
|
214
|
-
</div>
|
|
215
|
-
</div>
|
|
216
|
-
<div className="relative mb-4">
|
|
217
|
-
<label
|
|
218
|
-
htmlFor="language"
|
|
219
|
-
className="mb-1 block text-sm font-medium"
|
|
220
|
-
>
|
|
221
|
-
Language
|
|
222
|
-
</label>
|
|
223
|
-
<div className="w-fit">
|
|
224
|
-
<LanguageSelector
|
|
225
|
-
selectedLanguage={language}
|
|
226
|
-
darkMode={true}
|
|
227
|
-
disabled={isBuilding || isGenerating}
|
|
228
|
-
onLanguageSelected={(language) =>
|
|
229
|
-
setLanguage(language.languageCode)
|
|
230
|
-
}
|
|
231
|
-
showAllLanguages={true}
|
|
232
|
-
/>
|
|
233
|
-
</div>
|
|
234
|
-
</div>
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
</div>
|
|
238
|
-
</WizardBox>
|
|
239
|
-
<WizardBoxConnector className="mt-6" />
|
|
240
|
-
<WizardBox
|
|
241
|
-
title="Page Details"
|
|
242
|
-
icon={<FileText />}
|
|
243
|
-
description="Define the page name and meta information for SEO optimization"
|
|
244
|
-
className="flex-1"
|
|
245
|
-
>
|
|
246
|
-
<div className="flex h-full flex-col items-stretch">
|
|
247
|
-
<div className="relative flex-1">
|
|
248
|
-
<div className="absolute inset-0 overflow-y-auto pr-6">
|
|
249
|
-
<div className="mb-4">
|
|
250
|
-
<label
|
|
251
|
-
htmlFor="pageName"
|
|
252
|
-
className="mb-1 block text-sm font-medium"
|
|
253
|
-
>
|
|
254
|
-
Page Name
|
|
255
|
-
</label>
|
|
256
|
-
<InputText
|
|
257
|
-
id="pageName"
|
|
258
|
-
type="text"
|
|
259
|
-
disabled={!!pageItem || isBuilding || isGenerating}
|
|
260
|
-
className="w-full rounded border p-2 text-sm"
|
|
261
|
-
value={pageModel.name}
|
|
262
|
-
onChange={(e) => handleInputChange("name", e.target.value)}
|
|
263
|
-
placeholder="Enter page name"
|
|
264
|
-
/>
|
|
265
|
-
{validationMessage && (
|
|
266
|
-
<div className="mt-2 text-sm text-red-500">
|
|
267
|
-
{validationMessage}
|
|
268
|
-
</div>
|
|
269
|
-
)}
|
|
270
|
-
</div>
|
|
271
|
-
|
|
272
|
-
<div className="mb-4">
|
|
273
|
-
<label
|
|
274
|
-
htmlFor="metaDescription"
|
|
275
|
-
className="mb-1 block text-sm font-medium"
|
|
276
|
-
>
|
|
277
|
-
Meta Description
|
|
278
|
-
</label>
|
|
279
|
-
<InputTextarea
|
|
280
|
-
id="metaDescription"
|
|
281
|
-
disabled={!!pageItem || isBuilding || isGenerating}
|
|
282
|
-
className="min-h-[100px] w-full rounded border p-2 text-sm"
|
|
283
|
-
value={pageModel.metaDescription}
|
|
284
|
-
onChange={(e) =>
|
|
285
|
-
handleInputChange("metaDescription", e.target.value)
|
|
286
|
-
}
|
|
287
|
-
placeholder="Enter meta description"
|
|
288
|
-
/>
|
|
289
|
-
</div>
|
|
290
|
-
<div className="mb-4">
|
|
291
|
-
<label
|
|
292
|
-
htmlFor="metaKeywords"
|
|
293
|
-
className="mb-1 block text-sm font-medium"
|
|
294
|
-
>
|
|
295
|
-
Meta Keywords
|
|
296
|
-
</label>
|
|
297
|
-
<InputTextarea
|
|
298
|
-
id="metaKeywords"
|
|
299
|
-
disabled={!!pageItem || isBuilding || isGenerating}
|
|
300
|
-
className="min-h-[100px] w-full rounded border p-2 text-sm"
|
|
301
|
-
value={pageModel.metaKeywords}
|
|
302
|
-
onChange={(e) =>
|
|
303
|
-
handleInputChange("metaKeywords", e.target.value)
|
|
304
|
-
}
|
|
305
|
-
placeholder="Enter meta keywords"
|
|
306
|
-
/>
|
|
307
|
-
</div>
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
{!pageItem && (
|
|
311
|
-
<div className="py-2">
|
|
312
|
-
<ActionButton
|
|
313
|
-
disabled={isBuilding || isGenerating || !!validationMessage}
|
|
314
|
-
className="w-full"
|
|
315
|
-
onClick={() => {
|
|
316
|
-
createPage();
|
|
317
|
-
}}
|
|
318
|
-
isLoading={isBuilding || isGenerating}
|
|
319
|
-
loadingText={isGenerating ? "Generating..." : "Create Page"}
|
|
320
|
-
>
|
|
321
|
-
Create Page
|
|
322
|
-
</ActionButton>
|
|
323
|
-
</div>
|
|
324
|
-
)}
|
|
325
|
-
</div>
|
|
326
|
-
</WizardBox>
|
|
327
|
-
</div>
|
|
328
|
-
);
|
|
329
|
-
}
|