@blokkli/editor 2.0.0-alpha.36 → 2.0.0-alpha.38
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/global/types/blockOptions.d.ts +4 -3
- package/dist/module.d.mts +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +71 -4
- package/dist/modules/agent/index.d.mts +1 -1
- package/dist/modules/agent/index.mjs +276 -6
- package/dist/modules/agent/runtime/app/composables/agentProvider.js +31 -14
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.d.ts +2 -20
- package/dist/modules/agent/runtime/app/composables/defineBlokkliAgentTool.js +0 -3
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/Assistant/index.vue +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Conversation/Item/User/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/DebugGallery/index.vue +1 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.d.vue.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue +66 -59
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/Actions/index.vue.d.ts +1 -0
- package/dist/modules/agent/runtime/app/features/agent/Panel/Input/index.vue +10 -12
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/de.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/Welcome/en.md +2 -2
- package/dist/modules/agent/runtime/app/features/agent/Panel/index.vue +1 -5
- package/dist/modules/agent/runtime/app/features/agent/index.vue +89 -37
- package/dist/modules/agent/runtime/app/helpers/index.d.ts +16 -19
- package/dist/modules/agent/runtime/app/helpers/index.js +22 -46
- package/dist/modules/agent/runtime/app/helpers/pageStructure.js +1 -1
- package/dist/modules/agent/runtime/app/tools/add_content_search_paragraph/index.js +5 -9
- package/dist/modules/agent/runtime/app/tools/add_fragment/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_media_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/add_reusable_paragraph/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/add_template/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/analyze_content/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/analyze_content/index.js +120 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/check_readability/index.js +57 -0
- package/dist/modules/agent/runtime/app/tools/duplicate_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_bundle_info/index.js +2 -1
- package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_paragraph_context/index.js +2 -5
- package/dist/modules/agent/runtime/app/tools/get_paragraph_options/index.js +2 -1
- package/dist/modules/agent/runtime/app/tools/get_selected_paragraphs/index.js +2 -3
- package/dist/modules/agent/runtime/app/tools/helpers.d.ts +53 -0
- package/dist/modules/agent/runtime/app/tools/helpers.js +187 -0
- package/dist/modules/agent/runtime/app/tools/move_paragraphs/index.js +2 -6
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +0 -52
- package/dist/modules/agent/runtime/app/tools/schemas.js +0 -187
- package/dist/modules/agent/runtime/app/tools/search_content/index.js +40 -47
- package/dist/modules/agent/runtime/app/tools/set_paragraph_options/index.js +2 -5
- package/dist/modules/agent/runtime/app/types/index.d.ts +0 -61
- package/dist/modules/agent/runtime/server/Session.d.ts +25 -6
- package/dist/modules/agent/runtime/server/Session.js +109 -30
- package/dist/modules/agent/runtime/server/SessionManager.d.ts +3 -0
- package/dist/modules/agent/runtime/server/SessionManager.js +4 -1
- package/dist/modules/agent/runtime/server/agent.js +3 -2
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.d.ts +2 -0
- package/dist/modules/agent/runtime/server/default-skills/fixReadability.js +69 -0
- package/dist/modules/agent/runtime/server/default-system-prompts/page-context.js +28 -0
- package/dist/modules/agent/runtime/server/server-tools/index.d.ts +10 -2
- package/dist/modules/agent/runtime/server/server-tools/index.js +1 -1
- package/dist/modules/agent/runtime/server/server-tools/load_tools/index.js +1 -1
- package/dist/modules/agent/runtime/shared/types.d.ts +46 -11
- package/dist/modules/agent/runtime/shared/types.js +22 -10
- package/dist/modules/charts/index.d.mts +1 -1
- package/dist/modules/charts/index.mjs +21 -7
- package/dist/modules/charts/runtime/blokkli/skills/charts.js +6 -6
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.d.ts +25 -2
- package/dist/modules/charts/runtime/blokkli/tools/chart_schemas.js +39 -1
- package/dist/modules/charts/runtime/blokkli/tools/create_chart/index.js +24 -17
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_data/index.js +11 -19
- package/dist/modules/charts/runtime/blokkli/tools/get_chart_type_options/index.js +2 -4
- package/dist/modules/charts/runtime/blokkli/tools/update_chart/index.js +8 -20
- package/dist/modules/charts/runtime/chartTypes/area.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/bar.d.ts +7 -1
- package/dist/modules/charts/runtime/chartTypes/define.d.ts +1 -1
- package/dist/modules/charts/runtime/chartTypes/donut.d.ts +5 -1
- package/dist/modules/charts/runtime/chartTypes/heatmap.d.ts +3 -1
- package/dist/modules/charts/runtime/chartTypes/index.d.ts +18 -0
- package/dist/modules/charts/runtime/chartTypes/line.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/pie.d.ts +4 -1
- package/dist/modules/charts/runtime/chartTypes/radar.d.ts +6 -1
- package/dist/modules/charts/runtime/chartTypes/radialBar.d.ts +5 -1
- package/dist/modules/charts/runtime/chartTypes/shared.d.ts +20 -5
- package/dist/modules/charts/runtime/chartTypes/types.d.ts +6 -6
- package/dist/modules/charts/runtime/components/ChartRenderer/index.d.vue.ts +145 -2
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue +2 -2
- package/dist/modules/charts/runtime/components/ChartRenderer/index.vue.d.ts +145 -2
- package/dist/modules/charts/runtime/components/index.d.ts +1 -0
- package/dist/modules/charts/runtime/components/index.js +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.d.vue.ts +3 -2
- package/dist/modules/charts/runtime/features/charts/Editor/ChartTypeOptions/index.vue.d.ts +3 -2
- package/dist/modules/charts/runtime/features/charts/Editor/CsvImport/index.vue +1 -2
- package/dist/modules/charts/runtime/features/charts/Editor/FootnoteEditor/index.vue +1 -1
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.d.vue.ts +2 -0
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue +35 -13
- package/dist/modules/charts/runtime/features/charts/Editor/Preview/index.vue.d.ts +2 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.d.vue.ts +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue +9 -3
- package/dist/modules/charts/runtime/features/charts/Editor/index.vue.d.ts +1 -0
- package/dist/modules/charts/runtime/features/charts/Editor/useChartEditorState.js +1 -1
- package/dist/modules/charts/runtime/features/charts/index.vue +6 -6
- package/dist/modules/charts/runtime/helpers/index.d.ts +25 -0
- package/dist/modules/charts/runtime/helpers/index.js +63 -0
- package/dist/modules/charts/runtime/types.d.ts +10 -28
- package/dist/modules/charts/runtime/types.js +0 -64
- package/dist/modules/drupal/index.d.mts +1 -1
- package/dist/modules/drupal/runtime/adapter/index.d.ts +3 -1
- package/dist/modules/drupal/runtime/adapter/index.js +4 -4
- package/dist/modules/table-of-contents/index.d.mts +1 -1
- package/dist/runtime/components/BlokkliItem.vue +1 -1
- package/dist/runtime/composables/defineBlokkli.js +1 -1
- package/dist/runtime/editor/components/AnimationCanvas/index.vue +13 -7
- package/dist/runtime/editor/components/Banner/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/Banner/index.vue +1 -1
- package/dist/runtime/editor/components/Banner/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/DropdownItem/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/DropdownItem/index.vue +3 -2
- package/dist/runtime/editor/components/DropdownItem/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/EditProvider.vue +7 -4
- package/dist/runtime/editor/components/FlexTextarea/index.d.vue.ts +4 -0
- package/dist/runtime/editor/components/FlexTextarea/index.vue +24 -101
- package/dist/runtime/editor/components/FlexTextarea/index.vue.d.ts +4 -0
- package/dist/runtime/editor/components/NestedEditorOverlay/index.vue +28 -9
- package/dist/runtime/editor/components/Popup/index.d.vue.ts +30 -0
- package/dist/runtime/editor/components/Popup/index.vue +82 -0
- package/dist/runtime/editor/components/Popup/index.vue.d.ts +30 -0
- package/dist/runtime/editor/components/Resizable/index.vue +4 -1
- package/dist/runtime/editor/components/Toolbar/index.vue +107 -6
- package/dist/runtime/editor/components/index.d.ts +4 -3
- package/dist/runtime/editor/components/index.js +6 -4
- package/dist/runtime/editor/composables/defineDropAreas.js +3 -3
- package/dist/runtime/editor/composables/defineDropHandler.d.ts +3 -0
- package/dist/runtime/editor/composables/defineDropHandler.js +10 -0
- package/dist/runtime/editor/composables/index.d.ts +1 -0
- package/dist/runtime/editor/composables/index.js +1 -0
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +9 -0
- package/dist/runtime/editor/features/add-list/index.vue +58 -1
- package/dist/runtime/editor/features/analyze/Main.d.vue.ts +3 -2
- package/dist/runtime/editor/features/analyze/Main.vue +28 -44
- package/dist/runtime/editor/features/analyze/Main.vue.d.ts +3 -2
- package/dist/runtime/editor/features/analyze/analyzers/readability.js +65 -0
- package/dist/runtime/editor/features/analyze/analyzers/types.d.ts +19 -0
- package/dist/runtime/editor/features/analyze/index.vue +18 -15
- package/dist/runtime/editor/features/clipboard/DropElement/Video.d.vue.ts +8 -0
- package/dist/runtime/editor/features/clipboard/{List/Item → DropElement}/Video.vue +1 -5
- package/dist/runtime/editor/features/clipboard/DropElement/Video.vue.d.ts +8 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.d.ts +1 -0
- package/dist/runtime/editor/features/clipboard/DropElement/helpers.js +14 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.d.vue.ts +16 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue +97 -0
- package/dist/runtime/editor/features/clipboard/DropElement/index.vue.d.ts +16 -0
- package/dist/runtime/editor/features/clipboard/helpers.d.ts +15 -0
- package/dist/runtime/editor/features/clipboard/helpers.js +62 -0
- package/dist/runtime/editor/features/clipboard/index.vue +585 -337
- package/dist/runtime/editor/features/clipboard/types.d.ts +14 -2
- package/dist/runtime/editor/features/dragging-overlay/DragItems/index.vue +17 -5
- package/dist/runtime/editor/features/dragging-overlay/Renderer/index.vue +2 -2
- package/dist/runtime/editor/features/dragging-overlay/index.vue +125 -219
- package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue +4 -4
- package/dist/runtime/editor/features/editable-field/Overlay/index.vue +6 -0
- package/dist/runtime/editor/features/library/index.vue +14 -0
- package/dist/runtime/editor/features/media-library/index.vue +32 -1
- package/dist/runtime/editor/features/options/Form/ComplexType/index.d.vue.ts +11 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue +36 -0
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue.d.ts +11 -0
- package/dist/runtime/editor/features/options/Form/Item.d.vue.ts +3 -2
- package/dist/runtime/editor/features/options/Form/Item.vue +10 -2
- package/dist/runtime/editor/features/options/Form/Item.vue.d.ts +3 -2
- package/dist/runtime/editor/features/options/Form/index.vue +5 -0
- package/dist/runtime/editor/features/search/index.vue +25 -1
- package/dist/runtime/editor/features/structure/index.vue +25 -1
- package/dist/runtime/editor/features/tour/index.vue +22 -12
- package/dist/runtime/editor/helpers/clipboardData/index.d.ts +11 -0
- package/dist/runtime/editor/helpers/clipboardData/index.js +157 -0
- package/dist/runtime/editor/helpers/options/index.js +5 -0
- package/dist/runtime/editor/icons/svg/stars.svg +5 -1
- package/dist/runtime/editor/plugins/Sidebar/index.d.vue.ts +13 -2
- package/dist/runtime/editor/plugins/Sidebar/index.vue +4 -2
- package/dist/runtime/editor/plugins/Sidebar/index.vue.d.ts +13 -2
- package/dist/runtime/editor/providers/analyze.d.ts +43 -0
- package/dist/runtime/editor/providers/analyze.js +78 -0
- package/dist/runtime/editor/providers/animation.d.ts +4 -0
- package/dist/runtime/editor/providers/animation.js +6 -0
- package/dist/runtime/editor/providers/dragdrop.d.ts +55 -0
- package/dist/runtime/editor/providers/dragdrop.js +37 -0
- package/dist/runtime/editor/providers/storage.js +15 -0
- package/dist/runtime/editor/providers/ui.d.ts +6 -0
- package/dist/runtime/editor/providers/ui.js +19 -0
- package/dist/runtime/editor/translations/de.json +73 -61
- package/dist/runtime/editor/translations/fr.json +67 -55
- package/dist/runtime/editor/translations/gsw_CH.json +71 -59
- package/dist/runtime/editor/translations/it.json +67 -55
- package/dist/runtime/editor/types/app.d.ts +4 -2
- package/dist/runtime/editor/types/draggable.d.ts +1 -0
- package/dist/runtime/editor/types/ui.d.ts +1 -1
- package/dist/runtime/helpers/injections.d.ts +1 -1
- package/dist/runtime/types/blockOptions.d.ts +2 -1
- package/dist/runtime/types/definitions.d.ts +4 -0
- package/dist/shared/{editor.CWQIFIEQ.d.mts → editor.BdBm1Z7C.d.mts} +12 -0
- package/dist/types.d.mts +1 -1
- package/package.json +5 -3
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.d.vue.ts +0 -3
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue +0 -29
- package/dist/modules/charts/runtime/components/Fragment/BlokkliChart.vue.d.ts +0 -3
- package/dist/runtime/editor/features/clipboard/List/Item/File.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue +0 -60
- package/dist/runtime/editor/features/clipboard/List/Item/File.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.d.vue.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/Item/Video.vue.d.ts +0 -4
- package/dist/runtime/editor/features/clipboard/List/index.d.vue.ts +0 -11
- package/dist/runtime/editor/features/clipboard/List/index.vue +0 -72
- package/dist/runtime/editor/features/clipboard/List/index.vue.d.ts +0 -11
- package/dist/runtime/editor/features/tour/Popup/index.d.vue.ts +0 -9
- package/dist/runtime/editor/features/tour/Popup/index.vue +0 -34
- package/dist/runtime/editor/features/tour/Popup/index.vue.d.ts +0 -9
- package/dist/runtime/editor/providers/dropArea.d.ts +0 -48
- package/dist/runtime/editor/providers/dropArea.js +0 -22
|
@@ -2,27 +2,27 @@ import { defineBlokkliAgentSkill } from "#blokkli/agent/server/skills";
|
|
|
2
2
|
export default defineBlokkliAgentSkill({
|
|
3
3
|
name: "charts",
|
|
4
4
|
label: { en: "Working with charts", de: "Arbeiten mit Diagrammen" },
|
|
5
|
-
description: "How charts work in bl\xF6kkli. LOAD THIS when the user asks about charts or when you need to create or update a chart!
|
|
5
|
+
description: "How charts work in bl\xF6kkli. LOAD THIS when the user asks about charts or when you need to create or update a chart!",
|
|
6
6
|
getContents: () => `
|
|
7
7
|
# Charts
|
|
8
8
|
|
|
9
|
-
Charts are
|
|
9
|
+
Charts are NOT a specific block bundle. Instead, charts are a **complex option type**: any block can have a JSON option with \`dataType: 'chart'\`. The chart data is stored as a JSON string in that option. The option key can be anything (e.g. "data", "chart", etc.) \u2014 the tools detect it automatically.
|
|
10
10
|
|
|
11
11
|
## Key concept
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
A "chart block" is any block whose definition has a JSON option with \`dataType: 'chart'\`. The chart tools automatically detect which option holds chart data, so you don't need to know the option key or bundle name.
|
|
14
14
|
|
|
15
15
|
## Available tools
|
|
16
16
|
|
|
17
17
|
- **get_chart_data**: Read the current chart data (type, categories, series, colors, typeOptions). Always call this first when modifying an existing chart!
|
|
18
|
-
- **create_chart**: Create a new chart. Requires chart data (type, categories, series).
|
|
19
|
-
- **update_chart**: Update an existing chart. Pass the
|
|
18
|
+
- **create_chart**: Create a new chart. Requires chart data (type, categories, series). The tool automatically finds which bundle in the target field has a chart option.
|
|
19
|
+
- **update_chart**: Update an existing chart. Pass the block's UUID and only the properties you want to change (title, type, categories, series, categoryColors, footnotes, typeOptions).
|
|
20
20
|
- **get_chart_type_options**: Get available typeOptions for a chart type. Call this to discover which rendering options exist (e.g. stacked, horizontal for bar charts) before setting typeOptions.
|
|
21
21
|
|
|
22
22
|
## Workflow
|
|
23
23
|
|
|
24
24
|
1. To **read** a chart's current state: use get_chart_data with the paragraph UUID.
|
|
25
|
-
2. To **create** a chart: use create_chart with the data.
|
|
25
|
+
2. To **create** a chart: use create_chart with the data. The tool finds the right bundle automatically from the target field's allowed bundles.
|
|
26
26
|
3. To **modify** a chart: first call get_chart_data to see the current state, then use update_chart with only the properties you want to change.
|
|
27
27
|
4. To **change rendering options** (e.g. stacked bars, smooth lines, grid lines): first call get_chart_type_options with the chart type to see available options, then use update_chart with the typeOptions property.
|
|
28
28
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import type { BlokkliChartData, ChartColor } from '#blokkli/charts/types';
|
|
3
|
+
import type { McpToolContext } from '#blokkli/agent/app/types';
|
|
3
4
|
export declare const chartTypeEnum: z.ZodEnum<{
|
|
4
5
|
bar: "bar";
|
|
5
6
|
line: "line";
|
|
6
|
-
pie: "pie";
|
|
7
7
|
area: "area";
|
|
8
|
+
pie: "pie";
|
|
8
9
|
donut: "donut";
|
|
9
10
|
heatmap: "heatmap";
|
|
10
11
|
radialBar: "radialBar";
|
|
@@ -25,8 +26,8 @@ export declare const chartDataSchema: z.ZodObject<{
|
|
|
25
26
|
type: z.ZodEnum<{
|
|
26
27
|
bar: "bar";
|
|
27
28
|
line: "line";
|
|
28
|
-
pie: "pie";
|
|
29
29
|
area: "area";
|
|
30
|
+
pie: "pie";
|
|
30
31
|
donut: "donut";
|
|
31
32
|
heatmap: "heatmap";
|
|
32
33
|
radialBar: "radialBar";
|
|
@@ -61,3 +62,25 @@ export declare function validateChartData(data: BlokkliChartData, colors: Record
|
|
|
61
62
|
} | {
|
|
62
63
|
data: BlokkliChartData;
|
|
63
64
|
};
|
|
65
|
+
/**
|
|
66
|
+
* Find the option key for a chart option on a block.
|
|
67
|
+
*
|
|
68
|
+
* Charts are stored as a JSON option with `dataType: 'chart'` on any block.
|
|
69
|
+
* This helper looks up the block's definition and returns the option key.
|
|
70
|
+
*/
|
|
71
|
+
export declare function findChartOptionKey(ctx: McpToolContext, uuid: string): {
|
|
72
|
+
key: string;
|
|
73
|
+
} | {
|
|
74
|
+
error: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Find a bundle that has a chart option among a field's allowed bundles.
|
|
78
|
+
*
|
|
79
|
+
* Returns the bundle name and the option key for the chart data.
|
|
80
|
+
*/
|
|
81
|
+
export declare function findChartBundle(ctx: McpToolContext, allowedBundles: string[]): {
|
|
82
|
+
bundle: string;
|
|
83
|
+
key: string;
|
|
84
|
+
} | {
|
|
85
|
+
error: string;
|
|
86
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { getColorIdAtIndex } from "
|
|
2
|
+
import { getColorIdAtIndex } from "../../helpers/index.js";
|
|
3
3
|
import { getChartTypeRuntime, getDefaultTypeOptions } from "../../chartTypes/index.js";
|
|
4
4
|
import { COLORS } from "#blokkli-build/charts-config";
|
|
5
5
|
const SINGLE_SERIES_TYPES = ["pie", "donut", "radialBar"];
|
|
@@ -96,3 +96,41 @@ export function validateChartData(data, colors) {
|
|
|
96
96
|
}
|
|
97
97
|
return { data };
|
|
98
98
|
}
|
|
99
|
+
export function findChartOptionKey(ctx, uuid) {
|
|
100
|
+
const { blocks, definitions, selection } = ctx.app;
|
|
101
|
+
const block = blocks.getBlock(uuid);
|
|
102
|
+
if (!block) return { error: `Paragraph not found: ${uuid}` };
|
|
103
|
+
const bundle = block.library?.reusableBundle || block.bundle;
|
|
104
|
+
const selectionItem = selection.items.value.find((v) => v.uuid === uuid);
|
|
105
|
+
const definition = definitions.getBlockDefinition(
|
|
106
|
+
bundle,
|
|
107
|
+
selectionItem?.fieldListType ?? "default",
|
|
108
|
+
selectionItem?.parentBlockBundle
|
|
109
|
+
);
|
|
110
|
+
if (!definition?.options) {
|
|
111
|
+
return { error: `Paragraph "${uuid}" (${bundle}) has no chart option.` };
|
|
112
|
+
}
|
|
113
|
+
const chartEntry = Object.entries(definition.options).find(
|
|
114
|
+
([_, opt]) => opt.type === "json" && "dataType" in opt && opt.dataType === "chart"
|
|
115
|
+
);
|
|
116
|
+
if (!chartEntry) {
|
|
117
|
+
return { error: `Paragraph "${uuid}" (${bundle}) has no chart option.` };
|
|
118
|
+
}
|
|
119
|
+
return { key: chartEntry[0] };
|
|
120
|
+
}
|
|
121
|
+
export function findChartBundle(ctx, allowedBundles) {
|
|
122
|
+
const { definitions } = ctx.app;
|
|
123
|
+
for (const bundle of allowedBundles) {
|
|
124
|
+
const def = definitions.getDefaultDefinition(bundle);
|
|
125
|
+
if (!def?.options) continue;
|
|
126
|
+
const entry = Object.entries(def.options).find(
|
|
127
|
+
([_, opt]) => opt.type === "json" && "dataType" in opt && opt.dataType === "chart"
|
|
128
|
+
);
|
|
129
|
+
if (entry) {
|
|
130
|
+
return { bundle, key: entry[0] };
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
error: `No block type with a chart option is allowed in this field.`
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -3,10 +3,14 @@ import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
|
3
3
|
import {
|
|
4
4
|
mutationResultSchema,
|
|
5
5
|
parentSchema,
|
|
6
|
-
positionSchema
|
|
7
|
-
resolvePosition
|
|
6
|
+
positionSchema
|
|
8
7
|
} from "#blokkli/agent/app/tools/schemas";
|
|
9
|
-
import {
|
|
8
|
+
import { resolvePosition } from "#blokkli/agent/app/tools/helpers";
|
|
9
|
+
import {
|
|
10
|
+
chartDataSchema,
|
|
11
|
+
validateChartData,
|
|
12
|
+
findChartBundle
|
|
13
|
+
} from "../chart_schemas.js";
|
|
10
14
|
import { COLORS } from "#blokkli-build/charts-config";
|
|
11
15
|
const paramsSchema = z.object({
|
|
12
16
|
chart: chartDataSchema,
|
|
@@ -25,24 +29,19 @@ export default defineBlokkliAgentTool({
|
|
|
25
29
|
},
|
|
26
30
|
paramsSchema,
|
|
27
31
|
resultSchema: mutationResultSchema,
|
|
28
|
-
requiredAdapterMethods: ["
|
|
32
|
+
requiredAdapterMethods: ["addNewBlocks"],
|
|
29
33
|
execute(ctx, params) {
|
|
30
|
-
const { fields
|
|
31
|
-
const fragment = definitions.fragmentDefinitions.value.find(
|
|
32
|
-
(f) => f.name === "blokkli_chart"
|
|
33
|
-
);
|
|
34
|
-
if (!fragment) {
|
|
35
|
-
return { error: 'Chart fragment "blokkli_chart" is not available.' };
|
|
36
|
-
}
|
|
34
|
+
const { fields } = ctx.app;
|
|
37
35
|
const field = fields.find(params.parent.uuid, params.parent.field);
|
|
38
36
|
if (!field) {
|
|
39
37
|
return {
|
|
40
38
|
error: `Field not found: ${params.parent.field} on entity ${params.parent.uuid}`
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
|
-
|
|
41
|
+
const chartBundle = findChartBundle(ctx, field.allowedBundles);
|
|
42
|
+
if ("error" in chartBundle) {
|
|
44
43
|
return {
|
|
45
|
-
error: `
|
|
44
|
+
error: `No block type with a chart option is allowed in field "${params.parent.field}". Allowed bundles: ${field.allowedBundles.length ? field.allowedBundles.join(", ") : "none"}`
|
|
46
45
|
};
|
|
47
46
|
}
|
|
48
47
|
const chartData = {
|
|
@@ -68,18 +67,26 @@ export default defineBlokkliAgentTool({
|
|
|
68
67
|
);
|
|
69
68
|
if ("error" in resolved) return resolved;
|
|
70
69
|
const { $t } = ctx.app;
|
|
70
|
+
const blockUuid = crypto.randomUUID();
|
|
71
71
|
return {
|
|
72
72
|
type: "add",
|
|
73
73
|
label: $t("aiAgentCreateChartDone", "Added chart"),
|
|
74
|
-
apply: (adapter) => adapter.
|
|
75
|
-
|
|
74
|
+
apply: (adapter) => adapter.addNewBlocks({
|
|
75
|
+
blocks: [
|
|
76
|
+
{
|
|
77
|
+
bundle: chartBundle.bundle,
|
|
78
|
+
blockUuid,
|
|
79
|
+
options: {
|
|
80
|
+
[chartBundle.key]: JSON.stringify(result.data)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
],
|
|
76
84
|
host: {
|
|
77
85
|
type: params.parent.type,
|
|
78
86
|
uuid: params.parent.uuid,
|
|
79
87
|
fieldName: params.parent.field
|
|
80
88
|
},
|
|
81
|
-
|
|
82
|
-
options: { data: JSON.stringify(result.data) }
|
|
89
|
+
afterUuid: resolved.afterUuid
|
|
83
90
|
})
|
|
84
91
|
};
|
|
85
92
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
chartTypeEnum,
|
|
5
|
+
chartColorEnum,
|
|
6
|
+
chartSeriesSchema,
|
|
7
|
+
findChartOptionKey
|
|
8
|
+
} from "../chart_schemas.js";
|
|
4
9
|
import { COLORS } from "#blokkli-build/charts-config";
|
|
5
|
-
import { getDefaultChartData } from "
|
|
6
|
-
import { fragmentBlockBundle } from "#blokkli-build/config";
|
|
10
|
+
import { getDefaultChartData } from "../../../helpers/index.js";
|
|
7
11
|
const paramsSchema = z.object({
|
|
8
12
|
uuid: z.string().describe("UUID of the chart paragraph")
|
|
9
13
|
});
|
|
@@ -30,23 +34,11 @@ export default defineBlokkliAgentTool({
|
|
|
30
34
|
paramsSchema,
|
|
31
35
|
resultSchema,
|
|
32
36
|
execute(ctx, params) {
|
|
33
|
-
const {
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
return { error: `Paragraph not found: ${params.uuid}` };
|
|
37
|
-
}
|
|
38
|
-
if (block.bundle !== fragmentBlockBundle) {
|
|
39
|
-
return {
|
|
40
|
-
error: `Paragraph "${params.uuid}" is a "${block.bundle}", not a fragment.`
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (block.fragment?.name !== "blokkli_chart") {
|
|
44
|
-
return {
|
|
45
|
-
error: `Fragment "${params.uuid}" is a "${block.fragment?.name}", not a "blokkli_chart".`
|
|
46
|
-
};
|
|
47
|
-
}
|
|
37
|
+
const { state, $t } = ctx.app;
|
|
38
|
+
const chartOption = findChartOptionKey(ctx, params.uuid);
|
|
39
|
+
if ("error" in chartOption) return chartOption;
|
|
48
40
|
const item = state.getFieldListItem(params.uuid);
|
|
49
|
-
const rawData = item?.options?.
|
|
41
|
+
const rawData = item?.options?.[chartOption.key];
|
|
50
42
|
let data;
|
|
51
43
|
if (rawData) {
|
|
52
44
|
try {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
buildBlockOptionsMapFromDefinitions
|
|
6
|
-
} from "#blokkli/agent/app/tools/schemas";
|
|
3
|
+
import { blockOptionsMapSchema } from "#blokkli/agent/app/tools/schemas";
|
|
4
|
+
import { buildBlockOptionsMapFromDefinitions } from "#blokkli/agent/app/tools/helpers";
|
|
7
5
|
import { getChartTypeRuntime } from "../../../chartTypes/index.js";
|
|
8
6
|
import { chartTypeEnum } from "../chart_schemas.js";
|
|
9
7
|
const paramsSchema = z.object({
|
|
@@ -5,11 +5,11 @@ import {
|
|
|
5
5
|
chartTypeEnum,
|
|
6
6
|
chartColorEnum,
|
|
7
7
|
chartSeriesSchema,
|
|
8
|
-
validateChartData
|
|
8
|
+
validateChartData,
|
|
9
|
+
findChartOptionKey
|
|
9
10
|
} from "../chart_schemas.js";
|
|
10
11
|
import { COLORS } from "#blokkli-build/charts-config";
|
|
11
|
-
import { getDefaultChartData } from "
|
|
12
|
-
import { fragmentBlockBundle } from "#blokkli-build/config";
|
|
12
|
+
import { getDefaultChartData } from "../../../helpers/index.js";
|
|
13
13
|
const paramsSchema = z.object({
|
|
14
14
|
uuid: z.string().describe("UUID of the chart paragraph to update"),
|
|
15
15
|
title: z.string().optional().describe("Chart title"),
|
|
@@ -42,24 +42,12 @@ export default defineBlokkliAgentTool({
|
|
|
42
42
|
resultSchema: mutationResultSchema,
|
|
43
43
|
requiredAdapterMethods: ["updateOptions"],
|
|
44
44
|
execute(ctx, params) {
|
|
45
|
-
const {
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
return { error: `Paragraph not found: ${params.uuid}` };
|
|
49
|
-
}
|
|
50
|
-
if (block.bundle !== fragmentBlockBundle) {
|
|
51
|
-
return {
|
|
52
|
-
error: `Paragraph "${params.uuid}" is a "${block.bundle}", not a "${fragmentBlockBundle}".`
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (block.fragment?.name !== "blokkli_chart") {
|
|
56
|
-
return {
|
|
57
|
-
error: `Fragment "${params.uuid}" is a "${block.fragment?.name}", not a "blokkli_chart".`
|
|
58
|
-
};
|
|
59
|
-
}
|
|
45
|
+
const { state } = ctx.app;
|
|
46
|
+
const chartOption = findChartOptionKey(ctx, params.uuid);
|
|
47
|
+
if ("error" in chartOption) return chartOption;
|
|
60
48
|
let current;
|
|
61
49
|
const item = state.getFieldListItem(params.uuid);
|
|
62
|
-
const rawData = item?.options?.
|
|
50
|
+
const rawData = item?.options?.[chartOption.key];
|
|
63
51
|
if (rawData) {
|
|
64
52
|
try {
|
|
65
53
|
current = JSON.parse(rawData);
|
|
@@ -92,7 +80,7 @@ export default defineBlokkliAgentTool({
|
|
|
92
80
|
apply: (adapter) => adapter.updateOptions([
|
|
93
81
|
{
|
|
94
82
|
uuid: params.uuid,
|
|
95
|
-
key:
|
|
83
|
+
key: chartOption.key,
|
|
96
84
|
value: JSON.stringify(result.data)
|
|
97
85
|
}
|
|
98
86
|
])
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { XAxisTypeOptions, DataLabelsTypeOptions, LegendTypeOptions, GridTypeOptions, StrokeWidthTypeOptions } from './shared.js';
|
|
2
|
+
export type TypeOptions = {
|
|
3
|
+
curved: boolean;
|
|
4
|
+
markers: boolean;
|
|
5
|
+
} & XAxisTypeOptions & DataLabelsTypeOptions & LegendTypeOptions & GridTypeOptions & StrokeWidthTypeOptions;
|
|
6
|
+
declare const _default: import("./types.js").ChartTypeFactory<TypeOptions>;
|
|
2
7
|
export default _default;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import type { XAxisTypeOptions, DataLabelsTypeOptions, LegendTypeOptions, GridTypeOptions } from './shared.js';
|
|
2
|
+
export type TypeOptions = {
|
|
3
|
+
stacked: boolean;
|
|
4
|
+
horizontal: boolean;
|
|
5
|
+
borderRadius: string;
|
|
6
|
+
} & XAxisTypeOptions & DataLabelsTypeOptions & LegendTypeOptions & GridTypeOptions;
|
|
7
|
+
declare const _default: import("./types.js").ChartTypeFactory<TypeOptions>;
|
|
2
8
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { ChartTypeFactory } from './types.js';
|
|
2
|
-
export declare function defineChartType(factory: ChartTypeFactory): ChartTypeFactory
|
|
2
|
+
export declare function defineChartType<T extends Record<string, unknown>>(factory: ChartTypeFactory<T>): ChartTypeFactory<T>;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { XAxisTypeOptions, LegendTypeOptions, GridTypeOptions } from './shared.js';
|
|
2
|
+
export type TypeOptions = XAxisTypeOptions & LegendTypeOptions & GridTypeOptions;
|
|
3
|
+
declare const _default: import("./types.js").ChartTypeFactory<TypeOptions>;
|
|
2
4
|
export default _default;
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import type { TranslateFunction, ChartTypeDefinition } from './types.js';
|
|
2
|
+
import type { TypeOptions as BarTypeOptions } from './bar.js';
|
|
3
|
+
import type { TypeOptions as LineTypeOptions } from './line.js';
|
|
4
|
+
import type { TypeOptions as AreaTypeOptions } from './area.js';
|
|
5
|
+
import type { TypeOptions as PieTypeOptions } from './pie.js';
|
|
6
|
+
import type { TypeOptions as DonutTypeOptions } from './donut.js';
|
|
7
|
+
import type { TypeOptions as HeatmapTypeOptions } from './heatmap.js';
|
|
8
|
+
import type { TypeOptions as RadialBarTypeOptions } from './radialBar.js';
|
|
9
|
+
import type { TypeOptions as RadarTypeOptions } from './radar.js';
|
|
10
|
+
export type ChartTypeOptionsMap = {
|
|
11
|
+
bar: BarTypeOptions;
|
|
12
|
+
line: LineTypeOptions;
|
|
13
|
+
area: AreaTypeOptions;
|
|
14
|
+
pie: PieTypeOptions;
|
|
15
|
+
donut: DonutTypeOptions;
|
|
16
|
+
heatmap: HeatmapTypeOptions;
|
|
17
|
+
radialBar: RadialBarTypeOptions;
|
|
18
|
+
radar: RadarTypeOptions;
|
|
19
|
+
};
|
|
2
20
|
/**
|
|
3
21
|
* Get a chart type definition using fallback labels (no real translations).
|
|
4
22
|
* Used by ChartRenderer which runs in both edit mode and production.
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { XAxisTypeOptions, DataLabelsTypeOptions, LegendTypeOptions, GridTypeOptions, StrokeWidthTypeOptions } from './shared.js';
|
|
2
|
+
export type TypeOptions = {
|
|
3
|
+
curved: boolean;
|
|
4
|
+
markers: boolean;
|
|
5
|
+
} & XAxisTypeOptions & DataLabelsTypeOptions & LegendTypeOptions & GridTypeOptions & StrokeWidthTypeOptions;
|
|
6
|
+
declare const _default: import("./types.js").ChartTypeFactory<TypeOptions>;
|
|
2
7
|
export default _default;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DataLabelsTypeOptions, LegendTypeOptions } from './shared.js';
|
|
2
|
+
export type TypeOptions = {
|
|
3
|
+
markers: boolean;
|
|
4
|
+
fillOpacity: string;
|
|
5
|
+
} & DataLabelsTypeOptions & LegendTypeOptions;
|
|
6
|
+
declare const _default: import("./types.js").ChartTypeFactory<TypeOptions>;
|
|
2
7
|
export default _default;
|
|
@@ -4,6 +4,21 @@ import type { TranslateFunction } from './types.js';
|
|
|
4
4
|
type SharedOptions = {
|
|
5
5
|
options: Record<string, BlockOptionDefinitionBase<BlokkliIcon>>;
|
|
6
6
|
};
|
|
7
|
+
export type XAxisTypeOptions = {
|
|
8
|
+
xaxisRotation: string;
|
|
9
|
+
};
|
|
10
|
+
export type DataLabelsTypeOptions = {
|
|
11
|
+
dataLabels: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type LegendTypeOptions = {
|
|
14
|
+
legendPosition: string;
|
|
15
|
+
};
|
|
16
|
+
export type GridTypeOptions = {
|
|
17
|
+
gridLines: boolean;
|
|
18
|
+
};
|
|
19
|
+
export type StrokeWidthTypeOptions = {
|
|
20
|
+
strokeWidth: string;
|
|
21
|
+
};
|
|
7
22
|
/**
|
|
8
23
|
* Shared x-axis label options for chart types that display an x-axis.
|
|
9
24
|
*/
|
|
@@ -12,7 +27,7 @@ export declare function xAxisOptions($t: TranslateFunction): SharedOptions;
|
|
|
12
27
|
* Build x-axis label config from type options.
|
|
13
28
|
* Returns properties to merge into the xaxis config object.
|
|
14
29
|
*/
|
|
15
|
-
export declare function buildXAxisLabelOptions(typeOptions:
|
|
30
|
+
export declare function buildXAxisLabelOptions(typeOptions: XAxisTypeOptions): Record<string, any>;
|
|
16
31
|
/**
|
|
17
32
|
* Data labels option — show values directly on chart elements.
|
|
18
33
|
*/
|
|
@@ -20,7 +35,7 @@ export declare function dataLabelsOptions($t: TranslateFunction): SharedOptions;
|
|
|
20
35
|
/**
|
|
21
36
|
* Build data labels config from type options.
|
|
22
37
|
*/
|
|
23
|
-
export declare function buildDataLabelsOptions(typeOptions:
|
|
38
|
+
export declare function buildDataLabelsOptions(typeOptions: DataLabelsTypeOptions): Record<string, any>;
|
|
24
39
|
/**
|
|
25
40
|
* Legend position option for multi-series chart types.
|
|
26
41
|
*/
|
|
@@ -28,7 +43,7 @@ export declare function legendOptions($t: TranslateFunction): SharedOptions;
|
|
|
28
43
|
/**
|
|
29
44
|
* Build legend config from type options.
|
|
30
45
|
*/
|
|
31
|
-
export declare function buildLegendOptions(typeOptions:
|
|
46
|
+
export declare function buildLegendOptions(typeOptions: LegendTypeOptions): Record<string, any>;
|
|
32
47
|
/**
|
|
33
48
|
* Grid lines option for chart types with axes.
|
|
34
49
|
*/
|
|
@@ -36,7 +51,7 @@ export declare function gridOptions($t: TranslateFunction): SharedOptions;
|
|
|
36
51
|
/**
|
|
37
52
|
* Build grid config from type options.
|
|
38
53
|
*/
|
|
39
|
-
export declare function buildGridOptions(typeOptions:
|
|
54
|
+
export declare function buildGridOptions(typeOptions: GridTypeOptions): Record<string, any>;
|
|
40
55
|
/**
|
|
41
56
|
* Stroke width option for line-based chart types.
|
|
42
57
|
*/
|
|
@@ -44,7 +59,7 @@ export declare function strokeWidthOptions($t: TranslateFunction): SharedOptions
|
|
|
44
59
|
/**
|
|
45
60
|
* Build stroke width config from type options.
|
|
46
61
|
*/
|
|
47
|
-
export declare function buildStrokeWidthOptions(typeOptions:
|
|
62
|
+
export declare function buildStrokeWidthOptions(typeOptions: StrokeWidthTypeOptions): Record<string, any>;
|
|
48
63
|
/**
|
|
49
64
|
* Merge multiple shared option sets into one.
|
|
50
65
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BlokkliIcon } from '#blokkli-build/icons';
|
|
2
2
|
import type { BlockOptionDefinitionBase } from '../../../../global/types/blockOptions.js';
|
|
3
3
|
export type TranslateFunction = (key: string, fallback: string) => string;
|
|
4
|
-
export type ChartBuildContext = {
|
|
4
|
+
export type ChartBuildContext<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
5
5
|
title: string;
|
|
6
6
|
categories: string[];
|
|
7
7
|
series: Array<{
|
|
@@ -11,19 +11,19 @@ export type ChartBuildContext = {
|
|
|
11
11
|
}>;
|
|
12
12
|
seriesColors: string[];
|
|
13
13
|
categoryColors: string[];
|
|
14
|
-
typeOptions:
|
|
14
|
+
typeOptions: T;
|
|
15
15
|
};
|
|
16
|
-
export type ChartTypeDefinition = {
|
|
16
|
+
export type ChartTypeDefinition<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
17
17
|
id: string;
|
|
18
18
|
hasMultipleSeries: boolean;
|
|
19
19
|
hasSeriesColors: boolean;
|
|
20
20
|
hasCategoryColors: boolean;
|
|
21
|
-
buildChartOptions: (ctx: ChartBuildContext) => Record<string, any>;
|
|
22
|
-
buildSeries: (ctx: ChartBuildContext) => any;
|
|
21
|
+
buildChartOptions: (ctx: ChartBuildContext<T>) => Record<string, any>;
|
|
22
|
+
buildSeries: (ctx: ChartBuildContext<T>) => any;
|
|
23
23
|
editor: {
|
|
24
24
|
label: string;
|
|
25
25
|
icon: BlokkliIcon;
|
|
26
26
|
options: Record<string, BlockOptionDefinitionBase<BlokkliIcon>>;
|
|
27
27
|
};
|
|
28
28
|
};
|
|
29
|
-
export type ChartTypeFactory = ($t: TranslateFunction) => ChartTypeDefinition
|
|
29
|
+
export type ChartTypeFactory<T extends Record<string, unknown> = Record<string, unknown>> = ($t: TranslateFunction) => ChartTypeDefinition<T>;
|