@alpaca-editor/core 1.0.4018 → 1.0.4026

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.
Files changed (173) hide show
  1. package/dist/components/SimpleLanguageSelector.d.ts +2 -1
  2. package/dist/components/SimpleLanguageSelector.js +9 -2
  3. package/dist/components/SimpleLanguageSelector.js.map +1 -1
  4. package/dist/components/ui/input.js +1 -1
  5. package/dist/components/ui/input.js.map +1 -1
  6. package/dist/components/ui/tooltip.d.ts +3 -1
  7. package/dist/components/ui/tooltip.js +2 -2
  8. package/dist/components/ui/tooltip.js.map +1 -1
  9. package/dist/config/config.js +4 -0
  10. package/dist/config/config.js.map +1 -1
  11. package/dist/config/types.d.ts +2 -0
  12. package/dist/editor/ContentTree.js +1 -1
  13. package/dist/editor/ContentTree.js.map +1 -1
  14. package/dist/editor/ContextMenu.js +26 -0
  15. package/dist/editor/ContextMenu.js.map +1 -1
  16. package/dist/editor/FieldHistory.js +1 -1
  17. package/dist/editor/FieldHistory.js.map +1 -1
  18. package/dist/editor/FieldListField.js +2 -2
  19. package/dist/editor/FieldListField.js.map +1 -1
  20. package/dist/editor/Terminal.js +3 -1
  21. package/dist/editor/Terminal.js.map +1 -1
  22. package/dist/editor/ai/Agents.js +19 -10
  23. package/dist/editor/ai/Agents.js.map +1 -1
  24. package/dist/editor/ai/AiResponseMessage.js +63 -5
  25. package/dist/editor/ai/AiResponseMessage.js.map +1 -1
  26. package/dist/editor/ai/AiTerminal.js +7 -7
  27. package/dist/editor/ai/AiTerminal.js.map +1 -1
  28. package/dist/editor/ai/AiToolCall.js +3 -3
  29. package/dist/editor/ai/AiToolCall.js.map +1 -1
  30. package/dist/editor/client/EditorClient.js +5 -1
  31. package/dist/editor/client/EditorClient.js.map +1 -1
  32. package/dist/editor/client/editContext.d.ts +2 -0
  33. package/dist/editor/client/editContext.js.map +1 -1
  34. package/dist/editor/client/operations.d.ts +1 -0
  35. package/dist/editor/client/operations.js +7 -0
  36. package/dist/editor/client/operations.js.map +1 -1
  37. package/dist/editor/commands/componentCommands.js +1 -1
  38. package/dist/editor/commands/componentCommands.js.map +1 -1
  39. package/dist/editor/field-types/ImageFieldEditor.js +1 -1
  40. package/dist/editor/field-types/ImageFieldEditor.js.map +1 -1
  41. package/dist/editor/field-types/MultiLineText.js +1 -1
  42. package/dist/editor/field-types/MultiLineText.js.map +1 -1
  43. package/dist/editor/field-types/PictureFieldEditor.js +1 -1
  44. package/dist/editor/field-types/PictureFieldEditor.js.map +1 -1
  45. package/dist/editor/field-types/RawEditor.js +1 -1
  46. package/dist/editor/field-types/RawEditor.js.map +1 -1
  47. package/dist/editor/field-types/RichTextEditorComponent.js +16 -17
  48. package/dist/editor/field-types/RichTextEditorComponent.js.map +1 -1
  49. package/dist/editor/field-types/SingleLineText.js +1 -1
  50. package/dist/editor/field-types/SingleLineText.js.map +1 -1
  51. package/dist/editor/field-types/richtext/components/SimpleDropdown.d.ts +18 -0
  52. package/dist/editor/field-types/richtext/components/SimpleDropdown.js +71 -0
  53. package/dist/editor/field-types/richtext/components/SimpleDropdown.js.map +1 -0
  54. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.d.ts +5 -0
  55. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.js +359 -0
  56. package/dist/editor/field-types/richtext/components/SimpleRichTextEditor.js.map +1 -0
  57. package/dist/editor/field-types/richtext/components/SimpleToolbar.d.ts +16 -0
  58. package/dist/editor/field-types/richtext/components/SimpleToolbar.js +181 -0
  59. package/dist/editor/field-types/richtext/components/SimpleToolbar.js.map +1 -0
  60. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.d.ts +9 -0
  61. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.js +14 -0
  62. package/dist/editor/field-types/richtext/components/SimpleToolbarButton.js.map +1 -0
  63. package/dist/editor/field-types/richtext/contextMenuFactory.d.ts +4 -0
  64. package/dist/editor/field-types/richtext/contextMenuFactory.js +193 -0
  65. package/dist/editor/field-types/richtext/contextMenuFactory.js.map +1 -0
  66. package/dist/editor/field-types/richtext/index.d.ts +6 -5
  67. package/dist/editor/field-types/richtext/index.js +6 -5
  68. package/dist/editor/field-types/richtext/index.js.map +1 -1
  69. package/dist/editor/field-types/richtext/types.d.ts +16 -16
  70. package/dist/editor/field-types/richtext/types.js +84 -84
  71. package/dist/editor/field-types/richtext/types.js.map +1 -1
  72. package/dist/editor/page-editor-chrome/CommentHighlighting.js +1 -1
  73. package/dist/editor/page-editor-chrome/CommentHighlighting.js.map +1 -1
  74. package/dist/editor/page-editor-chrome/FrameMenu.js +5 -5
  75. package/dist/editor/page-editor-chrome/FrameMenu.js.map +1 -1
  76. package/dist/editor/page-editor-chrome/PlaceholderDropZone.js +1 -1
  77. package/dist/editor/page-viewer/PageViewerFrame.js +3 -2
  78. package/dist/editor/page-viewer/PageViewerFrame.js.map +1 -1
  79. package/dist/editor/services/agentService.d.ts +14 -4
  80. package/dist/editor/services/agentService.js.map +1 -1
  81. package/dist/editor/services/aiService.js +1 -0
  82. package/dist/editor/services/aiService.js.map +1 -1
  83. package/dist/page-wizard/PageWizard.d.ts +2 -0
  84. package/dist/page-wizard/PageWizard.js +6 -13
  85. package/dist/page-wizard/PageWizard.js.map +1 -1
  86. package/dist/page-wizard/WizardSteps.js +3 -1
  87. package/dist/page-wizard/WizardSteps.js.map +1 -1
  88. package/dist/page-wizard/service.d.ts +1 -0
  89. package/dist/page-wizard/service.js +7 -0
  90. package/dist/page-wizard/service.js.map +1 -1
  91. package/dist/page-wizard/steps/ContentStep.js +210 -33
  92. package/dist/page-wizard/steps/ContentStep.js.map +1 -1
  93. package/dist/page-wizard/steps/FindItemsStep.js +11 -3
  94. package/dist/page-wizard/steps/FindItemsStep.js.map +1 -1
  95. package/dist/page-wizard/steps/LayoutStep.js +1 -1
  96. package/dist/page-wizard/steps/LayoutStep.js.map +1 -1
  97. package/dist/page-wizard/steps/MetaDataStep.js +1 -1
  98. package/dist/page-wizard/steps/MetaDataStep.js.map +1 -1
  99. package/dist/page-wizard/steps/SchottSelectImagesStep.d.ts +2 -0
  100. package/dist/page-wizard/steps/SchottSelectImagesStep.js +55 -0
  101. package/dist/page-wizard/steps/SchottSelectImagesStep.js.map +1 -0
  102. package/dist/page-wizard/steps/StructureStep.js +20 -5
  103. package/dist/page-wizard/steps/StructureStep.js.map +1 -1
  104. package/dist/page-wizard/steps/TranslateStep.d.ts +2 -0
  105. package/dist/page-wizard/steps/TranslateStep.js +413 -0
  106. package/dist/page-wizard/steps/TranslateStep.js.map +1 -0
  107. package/dist/page-wizard/utils/dataAccessor.d.ts +7 -0
  108. package/dist/page-wizard/utils/dataAccessor.js +76 -0
  109. package/dist/page-wizard/utils/dataAccessor.js.map +1 -1
  110. package/dist/revision.d.ts +2 -2
  111. package/dist/revision.js +2 -2
  112. package/dist/splash-screen/NewPage.js +5 -4
  113. package/dist/splash-screen/NewPage.js.map +1 -1
  114. package/dist/splash-screen/OpenPage.js +2 -1
  115. package/dist/splash-screen/OpenPage.js.map +1 -1
  116. package/dist/splash-screen/RecentPages.js +3 -1
  117. package/dist/splash-screen/RecentPages.js.map +1 -1
  118. package/dist/styles.css +57 -0
  119. package/package.json +5 -4
  120. package/src/components/SimpleLanguageSelector.tsx +11 -1
  121. package/src/components/ui/input.tsx +1 -1
  122. package/src/components/ui/tooltip.tsx +3 -2
  123. package/src/config/config.tsx +4 -0
  124. package/src/config/types.ts +6 -0
  125. package/src/editor/ContentTree.tsx +1 -1
  126. package/src/editor/ContextMenu.tsx +39 -0
  127. package/src/editor/FieldHistory.tsx +1 -1
  128. package/src/editor/FieldListField.tsx +2 -6
  129. package/src/editor/Terminal.tsx +5 -1
  130. package/src/editor/ai/Agents.tsx +27 -16
  131. package/src/editor/ai/AiResponseMessage.tsx +138 -23
  132. package/src/editor/ai/AiTerminal.tsx +43 -29
  133. package/src/editor/ai/AiToolCall.tsx +14 -4
  134. package/src/editor/client/EditorClient.tsx +9 -1
  135. package/src/editor/client/editContext.ts +2 -0
  136. package/src/editor/client/operations.ts +9 -0
  137. package/src/editor/commands/componentCommands.tsx +1 -1
  138. package/src/editor/field-types/ImageFieldEditor.tsx +1 -0
  139. package/src/editor/field-types/MultiLineText.tsx +1 -0
  140. package/src/editor/field-types/PictureFieldEditor.tsx +1 -0
  141. package/src/editor/field-types/RawEditor.tsx +1 -0
  142. package/src/editor/field-types/RichTextEditorComponent.tsx +27 -25
  143. package/src/editor/field-types/SingleLineText.tsx +1 -0
  144. package/src/editor/field-types/richtext/components/SimpleDropdown.tsx +165 -0
  145. package/src/editor/field-types/richtext/components/SimpleRichTextEditor.css +261 -0
  146. package/src/editor/field-types/richtext/components/SimpleRichTextEditor.tsx +505 -0
  147. package/src/editor/field-types/richtext/components/SimpleToolbar.tsx +362 -0
  148. package/src/editor/field-types/richtext/components/SimpleToolbarButton.tsx +36 -0
  149. package/src/editor/field-types/richtext/contextMenuFactory.tsx +264 -0
  150. package/src/editor/field-types/richtext/index.ts +6 -5
  151. package/src/editor/field-types/richtext/types.ts +168 -148
  152. package/src/editor/page-editor-chrome/CommentHighlighting.tsx +1 -1
  153. package/src/editor/page-editor-chrome/FrameMenu.tsx +16 -11
  154. package/src/editor/page-editor-chrome/PlaceholderDropZone.tsx +1 -1
  155. package/src/editor/page-viewer/PageViewerFrame.tsx +4 -3
  156. package/src/editor/services/agentService.ts +16 -5
  157. package/src/editor/services/aiService.ts +2 -0
  158. package/src/page-wizard/PageWizard.tsx +10 -13
  159. package/src/page-wizard/WizardSteps.tsx +3 -1
  160. package/src/page-wizard/service.ts +11 -0
  161. package/src/page-wizard/steps/ContentStep.tsx +376 -43
  162. package/src/page-wizard/steps/FindItemsStep.tsx +23 -3
  163. package/src/page-wizard/steps/LayoutStep.tsx +1 -1
  164. package/src/page-wizard/steps/MetaDataStep.tsx +1 -1
  165. package/src/page-wizard/steps/SchottSelectImagesStep.tsx +141 -0
  166. package/src/page-wizard/steps/StructureStep.tsx +40 -5
  167. package/src/page-wizard/steps/TranslateStep.tsx +772 -0
  168. package/src/page-wizard/utils/dataAccessor.ts +85 -0
  169. package/src/revision.ts +2 -2
  170. package/src/splash-screen/NewPage.tsx +18 -3
  171. package/src/splash-screen/OpenPage.tsx +14 -1
  172. package/src/splash-screen/RecentPages.tsx +4 -2
  173. package/tsconfig.build.json +1 -0
@@ -299,3 +299,88 @@ export function getFilteredInputData(
299
299
 
300
300
  return result.value ?? data; // Return evaluated result or fall back to all data
301
301
  }
302
+
303
+ /**
304
+ * Processes a template string by replacing expressions wrapped in curly braces with their evaluated values
305
+ * @param template - The template string containing expressions like {data.items.map(x=>x.id)}
306
+ * @param data - The data object to evaluate expressions against
307
+ * @returns Object with the processed template and any errors encountered
308
+ */
309
+ export function processPromptTemplate(
310
+ template: string,
311
+ data: any,
312
+ ): DataAccessResult<string> {
313
+ if (!template) {
314
+ return { value: template };
315
+ }
316
+
317
+ try {
318
+ const errors: string[] = [];
319
+ let processedTemplate = template;
320
+
321
+ // Find all expressions wrapped in curly braces
322
+ const expressionRegex = /\{([^}]+)\}/g;
323
+ let match;
324
+ const replacements: { original: string; replacement: string }[] = [];
325
+
326
+ while ((match = expressionRegex.exec(template)) !== null) {
327
+ const fullMatch = match[0]; // The full match including braces: {expression}
328
+ const expression = match[1]?.trim(); // The expression inside braces
329
+
330
+ if (!expression) {
331
+ continue;
332
+ }
333
+
334
+ // Evaluate the expression
335
+ const evalResult = evaluateSingleExpression(expression, data);
336
+
337
+ if (evalResult.error) {
338
+ errors.push(`Expression "${expression}": ${evalResult.error}`);
339
+ continue;
340
+ }
341
+
342
+ // Convert the result to a string representation
343
+ let replacement: string;
344
+ try {
345
+ if (evalResult.value === undefined || evalResult.value === null) {
346
+ replacement = "";
347
+ } else if (typeof evalResult.value === "string") {
348
+ replacement = evalResult.value;
349
+ } else if (Array.isArray(evalResult.value)) {
350
+ replacement = JSON.stringify(evalResult.value);
351
+ } else if (typeof evalResult.value === "object") {
352
+ replacement = JSON.stringify(evalResult.value);
353
+ } else {
354
+ replacement = String(evalResult.value);
355
+ }
356
+ } catch (stringifyError) {
357
+ replacement = String(evalResult.value);
358
+ }
359
+
360
+ replacements.push({ original: fullMatch, replacement });
361
+ }
362
+
363
+ // If there are any errors, don't process the template at all
364
+ if (errors.length > 0) {
365
+ return {
366
+ value: undefined,
367
+ error: `Template processing failed:\n${errors.join("\n")}`,
368
+ };
369
+ }
370
+
371
+ // Apply all replacements
372
+ for (const { original, replacement } of replacements) {
373
+ processedTemplate = processedTemplate.replace(original, replacement);
374
+ }
375
+
376
+ return {
377
+ value: processedTemplate,
378
+ error: undefined,
379
+ };
380
+ } catch (error) {
381
+ return {
382
+ value: undefined,
383
+ error: `Failed to process template: ${error instanceof Error ? error.message : String(error)}`,
384
+ };
385
+ }
386
+ }
package/src/revision.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = "1.0.4018";
2
- export const buildDate = "2025-07-25 01:50:23";
1
+ export const version = "1.0.4026";
2
+ export const buildDate = "2025-07-31 15:29:01";
@@ -23,7 +23,7 @@ import { Card } from "../components/ui/card";
23
23
  import { CardConnector } from "../components/ui/CardConnector";
24
24
  import { Logo } from "../editor/ui/Icons";
25
25
  import { ActionButton } from "../components/ActionButton";
26
- import { FilePenLine, Palette } from "lucide-react";
26
+ import { FilePenLine, Palette, X } from "lucide-react";
27
27
  import { toast } from "sonner";
28
28
 
29
29
  export function NewPage({ selectedItemId }: { selectedItemId?: string }) {
@@ -70,6 +70,7 @@ export function NewPage({ selectedItemId }: { selectedItemId?: string }) {
70
70
  const loadItem = async () => {
71
71
  const itemId =
72
72
  selectedItemId ||
73
+ editContext?.contentEditorItem?.id ||
73
74
  editContext?.configuration.editor.dialogs.newPage.expandTreeNode;
74
75
  if (!itemId) return;
75
76
  const item = await editContext!.itemsRepository.getItem({
@@ -80,7 +81,7 @@ export function NewPage({ selectedItemId }: { selectedItemId?: string }) {
80
81
  if (item) setSelectedItem(item);
81
82
  };
82
83
  loadItem();
83
- }, [selectedItemId]);
84
+ }, [selectedItemId, editContext?.contentEditorItem?.id]);
84
85
 
85
86
  const isValidDebounced = useDebouncedCallback(async () => {
86
87
  if (!selectedItem) return;
@@ -159,10 +160,22 @@ export function NewPage({ selectedItemId }: { selectedItemId?: string }) {
159
160
  </div>
160
161
  </div>
161
162
 
162
- <div className="flex items-start">
163
+ <div className="flex items-start gap-2">
163
164
  <ActionButton onClick={() => editContext?.switchView("open-page")}>
164
165
  Open Existing
165
166
  </ActionButton>
167
+ <ActionButton
168
+ onClick={() =>
169
+ editContext?.switchView(
170
+ editContext.previousViewName || "splash-screen",
171
+ )
172
+ }
173
+ variant="ghost"
174
+ className="p-2"
175
+ aria-label="Close"
176
+ >
177
+ <X className="h-4 w-4" />
178
+ </ActionButton>
166
179
  </div>
167
180
  </div>
168
181
  <div className="flex flex-1 flex-col md:flex-row">
@@ -193,6 +206,8 @@ export function NewPage({ selectedItemId }: { selectedItemId?: string }) {
193
206
  >
194
207
  <ScrollingContentTree
195
208
  selectedItemId={selectedItem?.id || selectedItemId}
209
+ expandedItemId={selectedItem?.id || selectedItemId}
210
+ scrollToSelected={true}
196
211
  onSelectionChange={(selection) => {
197
212
  const selected = selection[0] as ItemTreeNodeData;
198
213
  if (selected) setSelectedItem(selected);
@@ -10,6 +10,7 @@ import { Card } from "../components/ui/card";
10
10
  import { Logo, MagicEditIcon } from "../editor/ui/Icons";
11
11
  import { ActionButton } from "../components/ActionButton";
12
12
  import { RecentPages } from "./RecentPages";
13
+ import { X } from "lucide-react";
13
14
 
14
15
  export function OpenPage() {
15
16
  const savedHistory =
@@ -63,13 +64,25 @@ export function OpenPage() {
63
64
  Browse your content structure or access recently viewed pages
64
65
  </div>
65
66
  </div>
66
- <div className="flex items-start">
67
+ <div className="flex items-start gap-2">
67
68
  <ActionButton
68
69
  onClick={() => editContext?.switchView("new-page")}
69
70
  isLoading={false}
70
71
  >
71
72
  Create New Page <MagicEditIcon />
72
73
  </ActionButton>
74
+ <ActionButton
75
+ onClick={() =>
76
+ editContext?.switchView(
77
+ editContext.previousViewName || "splash-screen",
78
+ )
79
+ }
80
+ variant="ghost"
81
+ className="p-2"
82
+ aria-label="Close"
83
+ >
84
+ <X className="h-4 w-4" />
85
+ </ActionButton>
73
86
  </div>
74
87
  </div>
75
88
 
@@ -24,7 +24,9 @@ export function RecentPages() {
24
24
 
25
25
  setIsLoading(true);
26
26
  try {
27
+ console.log("recentPages", recentPages);
27
28
  const pages = await editContext?.itemsRepository.getItems(recentPages);
29
+ console.log("pages", pages);
28
30
  setHistory(pages);
29
31
  } finally {
30
32
  setIsLoading(false);
@@ -119,13 +121,13 @@ export function RecentPages() {
119
121
  {isLoading && (
120
122
  <div className="flex h-full flex-col items-center justify-center p-6 text-center">
121
123
  <i className="pi pi-spin pi-spinner text-lg text-gray-400"></i>
122
- <div className="mt-2 text-sm text-gray-500">
124
+ <div className="mt-2 text-xs text-gray-500">
123
125
  Loading recent pages...
124
126
  </div>
125
127
  </div>
126
128
  )}
127
129
  {!isLoading && (!history || history.length === 0) && (
128
- <div className="p-6 text-center text-sm text-gray-500">
130
+ <div className="p-6 text-center text-xs text-gray-500">
129
131
  No recent pages found
130
132
  </div>
131
133
  )}
@@ -8,6 +8,7 @@
8
8
  "moduleResolution": "bundler",
9
9
  "jsx": "react-jsx",
10
10
  "declaration": true,
11
+ "rootDir": "./src",
11
12
  "outDir": "./dist",
12
13
  "strict": true,
13
14
  "esModuleInterop": true,