@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
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
const paramsSchema = z.object({
|
|
10
|
-
itemId: z.string().describe("Content item ID from
|
|
6
|
+
itemId: z.string().describe("Content item ID from search_content results"),
|
|
11
7
|
itemEntityType: z.string().describe("Entity type of the content item"),
|
|
12
8
|
itemEntityBundle: z.string().describe("Entity bundle of the content item"),
|
|
13
9
|
targetBundle: z.string().describe(
|
|
14
|
-
"Paragraph bundle to create (from targetBundles in
|
|
10
|
+
"Paragraph bundle to create (from targetBundles in search_content results)"
|
|
15
11
|
),
|
|
16
12
|
parent: parentSchema.describe("The parent entity to add the paragraph to"),
|
|
17
13
|
position: positionSchema
|
|
18
14
|
});
|
|
19
15
|
export default defineBlokkliAgentTool({
|
|
20
16
|
name: "add_content_search_paragraphs",
|
|
21
|
-
description: "Add a paragraph using a content item from search results. Use
|
|
17
|
+
description: "Add a paragraph using a content item from search results. Use search_content first to find content items, then use this tool to add one to the page. Requires user approval.",
|
|
22
18
|
category: "mutation",
|
|
23
19
|
prunedSummary: (r) => r.success ? "added content paragraph" : "rejected",
|
|
24
20
|
modes: ["editing"],
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
const paramsSchema = z.object({
|
|
10
6
|
name: z.string().describe("The fragment name to add"),
|
|
11
7
|
parent: parentSchema.describe("The parent entity to add the fragment to"),
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
const paramsSchema = z.object({
|
|
10
6
|
mediaId: z.string().describe("Media item ID from search_media results"),
|
|
11
7
|
mediaBundle: z.string().describe('Media bundle type (e.g., "image")'),
|
|
@@ -5,10 +5,9 @@ import {
|
|
|
5
5
|
mutationResultSchema,
|
|
6
6
|
parentSchema,
|
|
7
7
|
positionSchema,
|
|
8
|
-
|
|
9
|
-
optionValueSchema,
|
|
10
|
-
validateOptionValue
|
|
8
|
+
optionValueSchema
|
|
11
9
|
} from "../schemas.js";
|
|
10
|
+
import { resolvePosition, validateOptionValue } from "../helpers.js";
|
|
12
11
|
import { itemEntityType } from "#blokkli-build/config";
|
|
13
12
|
import {
|
|
14
13
|
getAvailableOptions,
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
import { fromLibraryBlockBundle, itemEntityType } from "#blokkli-build/config";
|
|
10
6
|
const paramsSchema = z.object({
|
|
11
7
|
libraryItemUuid: z.string().describe(
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
const paramsSchema = z.object({
|
|
10
6
|
templateUuid: z.string().describe(
|
|
11
7
|
"The UUID of the template to add (from search_templates results)"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
const issueSchema = z.object({
|
|
4
|
+
text: z.string(),
|
|
5
|
+
impact: z.string().optional(),
|
|
6
|
+
scores: z.record(z.string(), z.number()).optional()
|
|
7
|
+
});
|
|
8
|
+
const fieldResultSchema = z.object({
|
|
9
|
+
fieldValue: z.string().optional(),
|
|
10
|
+
issues: z.array(issueSchema)
|
|
11
|
+
});
|
|
12
|
+
const paramsSchema = z.object({});
|
|
13
|
+
const resultSchema = z.record(
|
|
14
|
+
z.string(),
|
|
15
|
+
z.record(z.string(), fieldResultSchema)
|
|
16
|
+
);
|
|
17
|
+
function resolveTargetInfo(target) {
|
|
18
|
+
const blockEl = target.closest("[data-bk-uuid]");
|
|
19
|
+
const paragraphUuid = blockEl?.getAttribute("data-bk-uuid") ?? void 0;
|
|
20
|
+
let fieldName;
|
|
21
|
+
let fieldEl;
|
|
22
|
+
let el = target;
|
|
23
|
+
while (el && el !== blockEl) {
|
|
24
|
+
if (el.dataset.blokkliEditableField) {
|
|
25
|
+
fieldName = el.dataset.blokkliEditableField;
|
|
26
|
+
fieldEl = el;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
el = el.parentElement;
|
|
30
|
+
}
|
|
31
|
+
const fieldText = fieldEl?.textContent?.trim() || void 0;
|
|
32
|
+
return { paragraphUuid, fieldName, fieldText };
|
|
33
|
+
}
|
|
34
|
+
export default defineBlokkliAgentTool({
|
|
35
|
+
name: "get_readability_issues",
|
|
36
|
+
description: "Run all readability analyzers against the full page. Returns an object keyed by paragraph UUID and field name, with the current field value and a list of issues. Each issue contains the flagged text segment, impact, and scores. Use the result to call batch_rewrite_text directly.",
|
|
37
|
+
category: "query",
|
|
38
|
+
volatile: true,
|
|
39
|
+
lazy: true,
|
|
40
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
41
|
+
requiredAdapterMethods: ["getAnalyzers"],
|
|
42
|
+
label($t) {
|
|
43
|
+
return $t("aiAgentAnalyzeContentRunning", "Analyzing content...");
|
|
44
|
+
},
|
|
45
|
+
prunedSummary: (r) => {
|
|
46
|
+
let count = 0;
|
|
47
|
+
for (const fields of Object.values(r)) {
|
|
48
|
+
for (const field of Object.values(fields)) {
|
|
49
|
+
count += field.issues.length;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return `found ${count} issues`;
|
|
53
|
+
},
|
|
54
|
+
paramsSchema,
|
|
55
|
+
resultSchema,
|
|
56
|
+
async execute(ctx) {
|
|
57
|
+
const { analyze, ui, $t } = ctx.app;
|
|
58
|
+
await analyze.ensureInitialized();
|
|
59
|
+
const readabilityAnalyzers = analyze.analyzers.value.filter(
|
|
60
|
+
(a) => a.type === "readability" && !a.requireRawPage
|
|
61
|
+
);
|
|
62
|
+
if (readabilityAnalyzers.length === 0) {
|
|
63
|
+
return {
|
|
64
|
+
label: $t(
|
|
65
|
+
"aiAgentAnalyzeContentDone",
|
|
66
|
+
"Analyzed @count results"
|
|
67
|
+
).replace("@count", "0"),
|
|
68
|
+
result: {}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const analyzerCtx = analyze.createContext(ui.providerElement);
|
|
72
|
+
const result = {};
|
|
73
|
+
for (const analyzer of readabilityAnalyzers) {
|
|
74
|
+
const rawResults = await analyze.runAnalyzer(analyzer, analyzerCtx);
|
|
75
|
+
for (const r of rawResults) {
|
|
76
|
+
const rawNodes = Array.isArray(r.nodes) ? r.nodes : [r.nodes];
|
|
77
|
+
for (const node of rawNodes) {
|
|
78
|
+
const targets = Array.isArray(node.targets) ? node.targets : [node.targets];
|
|
79
|
+
for (const target of targets) {
|
|
80
|
+
if (!(target instanceof HTMLElement)) continue;
|
|
81
|
+
const info = resolveTargetInfo(target);
|
|
82
|
+
if (!info.paragraphUuid || !info.fieldName) continue;
|
|
83
|
+
const targetText = target.textContent?.trim();
|
|
84
|
+
if (!targetText) continue;
|
|
85
|
+
const uuid = info.paragraphUuid;
|
|
86
|
+
const field = info.fieldName;
|
|
87
|
+
if (!result[uuid]) {
|
|
88
|
+
result[uuid] = {};
|
|
89
|
+
}
|
|
90
|
+
if (!result[uuid][field]) {
|
|
91
|
+
result[uuid][field] = {
|
|
92
|
+
fieldValue: info.fieldText,
|
|
93
|
+
issues: []
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
result[uuid][field].issues.push({
|
|
97
|
+
text: targetText,
|
|
98
|
+
impact: node.impact,
|
|
99
|
+
scores: node.scores
|
|
100
|
+
});
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let issueCount = 0;
|
|
107
|
+
for (const fields of Object.values(result)) {
|
|
108
|
+
for (const field of Object.values(fields)) {
|
|
109
|
+
issueCount += field.issues.length;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
label: $t("aiAgentAnalyzeContentDone", "Analyzed @count results").replace(
|
|
114
|
+
"@count",
|
|
115
|
+
String(issueCount)
|
|
116
|
+
),
|
|
117
|
+
result
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
const nodeSchema = z.object({
|
|
4
|
+
description: z.string().optional(),
|
|
5
|
+
impact: z.string().optional(),
|
|
6
|
+
scores: z.record(z.string(), z.number()).optional()
|
|
7
|
+
});
|
|
8
|
+
const textResultSchema = z.object({
|
|
9
|
+
text: z.string(),
|
|
10
|
+
nodes: z.array(nodeSchema)
|
|
11
|
+
});
|
|
12
|
+
const paramsSchema = z.object({
|
|
13
|
+
texts: z.array(z.string()).describe(
|
|
14
|
+
"Text strings to check for readability. Each string is analyzed independently."
|
|
15
|
+
)
|
|
16
|
+
});
|
|
17
|
+
const resultSchema = z.object({
|
|
18
|
+
results: z.array(textResultSchema)
|
|
19
|
+
});
|
|
20
|
+
export default defineBlokkliAgentTool({
|
|
21
|
+
name: "check_readability_for_texts",
|
|
22
|
+
description: "Check readability scores for one or more text strings. Returns readability metrics (LIX, CLI, ARI) for each text. Use this to evaluate whether a rewritten text has better readability before applying it.",
|
|
23
|
+
category: "query",
|
|
24
|
+
lazy: true,
|
|
25
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
26
|
+
requiredAdapterMethods: ["getAnalyzers"],
|
|
27
|
+
label($t) {
|
|
28
|
+
return $t("aiAgentCheckReadabilityRunning", "Checking readability...");
|
|
29
|
+
},
|
|
30
|
+
prunedSummary: (r) => {
|
|
31
|
+
return `checked readability for ${r.results.length} texts`;
|
|
32
|
+
},
|
|
33
|
+
paramsSchema,
|
|
34
|
+
resultSchema,
|
|
35
|
+
async execute(ctx, params) {
|
|
36
|
+
const { analyze, $t } = ctx.app;
|
|
37
|
+
await analyze.ensureInitialized();
|
|
38
|
+
const rawResults = await analyze.runOnTexts(params.texts, "readability");
|
|
39
|
+
const results = rawResults.map(
|
|
40
|
+
(tr) => ({
|
|
41
|
+
text: tr.text,
|
|
42
|
+
nodes: tr.nodes.map((node) => ({
|
|
43
|
+
description: node.description,
|
|
44
|
+
impact: node.impact,
|
|
45
|
+
scores: node.scores
|
|
46
|
+
}))
|
|
47
|
+
})
|
|
48
|
+
);
|
|
49
|
+
return {
|
|
50
|
+
label: $t(
|
|
51
|
+
"aiAgentCheckReadabilityDone",
|
|
52
|
+
"Checked readability for @count texts"
|
|
53
|
+
).replace("@count", String(results.length)),
|
|
54
|
+
result: { results }
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
});
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
import {
|
|
10
6
|
validateBlocksExist,
|
|
11
7
|
validateSameField,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import { getFieldType, getEditableValue } from "../
|
|
3
|
+
import { getFieldType, getEditableValue } from "../helpers.js";
|
|
4
4
|
const paramsSchema = z.object({});
|
|
5
5
|
const blockContentSchema = z.object({
|
|
6
6
|
uuid: z.string().describe("The paragraph UUID"),
|
|
@@ -2,7 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
3
|
import { getAvailableOptions } from "#blokkli/editor/helpers/options";
|
|
4
4
|
import { getRuntimeOptionValue } from "#blokkli/runtime-helpers";
|
|
5
|
-
import { blockOptionsMapSchema
|
|
5
|
+
import { blockOptionsMapSchema } from "../schemas.js";
|
|
6
|
+
import { extractOptionLabels } from "../helpers.js";
|
|
6
7
|
const paramsSchema = z.object({
|
|
7
8
|
parentUuid: z.string().describe("The parent entity UUID"),
|
|
8
9
|
field: z.string().describe("The field name"),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import { getFieldType, getEditableValue } from "../
|
|
3
|
+
import { getFieldType, getEditableValue } from "../helpers.js";
|
|
4
4
|
const paramsSchema = z.object({
|
|
5
5
|
uuids: z.array(z.string()).describe(
|
|
6
6
|
"One or more paragraph UUIDs (or the page UUID to get page-level fields)"
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
blockOptionsMapSchema,
|
|
6
|
-
buildBlockOptionsMap
|
|
7
|
-
} from "../schemas.js";
|
|
3
|
+
import { parentSchema, blockOptionsMapSchema } from "../schemas.js";
|
|
4
|
+
import { buildBlockOptionsMap } from "../helpers.js";
|
|
8
5
|
import { getAvailableOptions } from "#blokkli/editor/helpers/options";
|
|
9
6
|
import { fragmentBlockBundle } from "#blokkli-build/config";
|
|
10
7
|
const paramsSchema = z.object({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
3
|
import { getAvailableOptions } from "#blokkli/editor/helpers/options";
|
|
4
|
-
import { blockOptionsMapSchema
|
|
4
|
+
import { blockOptionsMapSchema } from "../schemas.js";
|
|
5
|
+
import { buildBlockOptionsMap } from "../helpers.js";
|
|
5
6
|
const paramsSchema = z.object({
|
|
6
7
|
uuids: z.array(z.string()).describe("The paragraph UUIDs to get options for")
|
|
7
8
|
});
|
|
@@ -23,11 +23,10 @@ export default defineBlokkliAgentTool({
|
|
|
23
23
|
resultSchema,
|
|
24
24
|
execute(ctx) {
|
|
25
25
|
const { selection, types, $t } = ctx.app;
|
|
26
|
-
const paragraphs = selection.
|
|
27
|
-
const item = selection.items.value.find((v) => v.uuid === uuid);
|
|
26
|
+
const paragraphs = selection.items.value.map((item) => {
|
|
28
27
|
const bundle = item?.bundle ?? "unknown";
|
|
29
28
|
return {
|
|
30
|
-
uuid,
|
|
29
|
+
uuid: item.uuid,
|
|
31
30
|
bundle,
|
|
32
31
|
label: types.getBlockLabel(bundle)
|
|
33
32
|
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { OptionItem } from '#blokkli/editor/helpers/options';
|
|
2
|
+
import type { BlokkliApp } from '#blokkli/editor/types/app';
|
|
3
|
+
import type { BlockOptionsMap } from './schemas.js';
|
|
4
|
+
/**
|
|
5
|
+
* Extract a simple key→label map from the various radios/checkboxes option formats.
|
|
6
|
+
* Handles plain strings, icon objects, color objects, grid objects, etc.
|
|
7
|
+
*/
|
|
8
|
+
export declare function extractOptionLabels(option: Record<string, unknown>): Record<string, string> | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Build a block options map from available options and mutated state.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildBlockOptionsMap(availableOptions: OptionItem[], mutatedOptions: Record<string, Record<string, string>>, uuid: string): BlockOptionsMap;
|
|
13
|
+
/**
|
|
14
|
+
* Build a block options map from option definitions, using defaults as current values.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildBlockOptionsMapFromDefinitions(options: Record<string, Record<string, unknown>>): BlockOptionsMap;
|
|
17
|
+
/**
|
|
18
|
+
* Validate a single option value against its definition.
|
|
19
|
+
* Returns an error string or undefined if valid.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateOptionValue(key: string, value: string | boolean | number | string[], optionDef: OptionItem): string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Resolve an editable field config to its simplified type.
|
|
24
|
+
* Returns 'plain' for text fields, 'markup' for rich text/frame fields, null for unsupported.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getFieldType(app: BlokkliApp, entityType: string, bundle: string, fieldName: string): 'plain' | 'markup' | null;
|
|
27
|
+
/**
|
|
28
|
+
* Read the current value of an editable field on a block or entity.
|
|
29
|
+
* Tries the registered getValue() callback first, falls back to DOM element reading.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getEditableValue(app: BlokkliApp, entityType: string, uuid: string, bundle: string, fieldName: string, fieldType: 'plain' | 'markup'): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get all child fields and their paragraphs for a given entity UUID.
|
|
34
|
+
* Walks mutatedFields to find fields belonging to the entity.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getParagraphChildren(app: BlokkliApp, uuid: string): {
|
|
37
|
+
fieldName: string;
|
|
38
|
+
paragraphs: {
|
|
39
|
+
uuid: string;
|
|
40
|
+
bundle: string;
|
|
41
|
+
}[];
|
|
42
|
+
}[];
|
|
43
|
+
/**
|
|
44
|
+
* Resolve a `position` string to the `afterUuid` value expected by adapter methods.
|
|
45
|
+
*
|
|
46
|
+
* Returns `{ afterUuid: string | null }` on success, or `{ error: string }` if
|
|
47
|
+
* the referenced UUID is not found in the target field.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolvePosition(app: BlokkliApp, parentUuid: string, fieldName: string, position?: string): {
|
|
50
|
+
afterUuid: string | null;
|
|
51
|
+
} | {
|
|
52
|
+
error: string;
|
|
53
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import { getMutatedOptionValue } from "#blokkli/editor/helpers/options";
|
|
2
|
+
import { getRuntimeOptionValue } from "#blokkli/runtime-helpers";
|
|
3
|
+
export function extractOptionLabels(option) {
|
|
4
|
+
if (!("options" in option) || !option.options) return void 0;
|
|
5
|
+
const raw = option.options;
|
|
6
|
+
const labels = {};
|
|
7
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
8
|
+
if (typeof value === "string") {
|
|
9
|
+
labels[key] = value;
|
|
10
|
+
} else if (typeof value === "object" && value !== null && "label" in value) {
|
|
11
|
+
labels[key] = String(value.label);
|
|
12
|
+
} else {
|
|
13
|
+
labels[key] = key;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return labels;
|
|
17
|
+
}
|
|
18
|
+
export function buildBlockOptionsMap(availableOptions, mutatedOptions, uuid) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (const opt of availableOptions) {
|
|
21
|
+
const rawValue = getMutatedOptionValue(
|
|
22
|
+
mutatedOptions,
|
|
23
|
+
uuid,
|
|
24
|
+
opt.property,
|
|
25
|
+
opt.option.default
|
|
26
|
+
);
|
|
27
|
+
const currentValue = getRuntimeOptionValue(opt.option, rawValue);
|
|
28
|
+
result[opt.property] = buildBlockOptionEntry(opt.option, currentValue);
|
|
29
|
+
}
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
export function buildBlockOptionsMapFromDefinitions(options) {
|
|
33
|
+
const result = {};
|
|
34
|
+
for (const [key, opt] of Object.entries(options)) {
|
|
35
|
+
result[key] = buildBlockOptionEntry(
|
|
36
|
+
opt,
|
|
37
|
+
opt.default
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
function buildBlockOptionEntry(opt, currentValue) {
|
|
43
|
+
const entry = {
|
|
44
|
+
type: opt.type,
|
|
45
|
+
label: opt.label,
|
|
46
|
+
currentValue
|
|
47
|
+
};
|
|
48
|
+
if (opt.description) {
|
|
49
|
+
entry.description = opt.description;
|
|
50
|
+
}
|
|
51
|
+
const labels = extractOptionLabels(opt);
|
|
52
|
+
if (labels) {
|
|
53
|
+
entry.options = labels;
|
|
54
|
+
}
|
|
55
|
+
if ("min" in opt) {
|
|
56
|
+
entry.min = opt.min;
|
|
57
|
+
}
|
|
58
|
+
if ("max" in opt) {
|
|
59
|
+
entry.max = opt.max;
|
|
60
|
+
}
|
|
61
|
+
if ("step" in opt && opt.type === "range") {
|
|
62
|
+
entry.step = opt.step;
|
|
63
|
+
}
|
|
64
|
+
return entry;
|
|
65
|
+
}
|
|
66
|
+
export function validateOptionValue(key, value, optionDef) {
|
|
67
|
+
const optionType = optionDef.option.type;
|
|
68
|
+
if (optionType === "checkbox") {
|
|
69
|
+
if (typeof value !== "boolean" && value !== "1" && value !== "0" && value !== "true" && value !== "false") {
|
|
70
|
+
return `Option "${key}" expects a boolean value`;
|
|
71
|
+
}
|
|
72
|
+
} else if (optionType === "radios") {
|
|
73
|
+
if (typeof value !== "string") {
|
|
74
|
+
return `Option "${key}" expects a string value`;
|
|
75
|
+
}
|
|
76
|
+
if ("options" in optionDef.option && optionDef.option.options) {
|
|
77
|
+
const allowedKeys = Object.keys(optionDef.option.options);
|
|
78
|
+
if (!allowedKeys.includes(value)) {
|
|
79
|
+
return `Option "${key}" value must be one of: ${allowedKeys.join(", ")}`;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} else if (optionType === "checkboxes") {
|
|
83
|
+
if (!Array.isArray(value) && typeof value !== "string") {
|
|
84
|
+
return `Option "${key}" expects an array of strings or comma-separated string`;
|
|
85
|
+
}
|
|
86
|
+
if ("options" in optionDef.option && optionDef.option.options) {
|
|
87
|
+
const allowedKeys = Object.keys(optionDef.option.options);
|
|
88
|
+
const values = Array.isArray(value) ? value : value.split(",");
|
|
89
|
+
for (const v of values) {
|
|
90
|
+
if (!allowedKeys.includes(v)) {
|
|
91
|
+
return `Option "${key}" value "${v}" is not allowed. Must be one of: ${allowedKeys.join(", ")}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else if (optionType === "number" || optionType === "range") {
|
|
96
|
+
const numValue = typeof value === "number" ? value : Number.parseFloat(String(value));
|
|
97
|
+
if (Number.isNaN(numValue)) {
|
|
98
|
+
return `Option "${key}" expects a numeric value`;
|
|
99
|
+
}
|
|
100
|
+
if ("min" in optionDef.option && numValue < optionDef.option.min) {
|
|
101
|
+
return `Option "${key}" value must be >= ${optionDef.option.min}`;
|
|
102
|
+
}
|
|
103
|
+
if ("max" in optionDef.option && numValue > optionDef.option.max) {
|
|
104
|
+
return `Option "${key}" value must be <= ${optionDef.option.max}`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return void 0;
|
|
108
|
+
}
|
|
109
|
+
export function getFieldType(app, entityType, bundle, fieldName) {
|
|
110
|
+
const config = app.types.editableFieldConfig.forName(
|
|
111
|
+
entityType,
|
|
112
|
+
bundle,
|
|
113
|
+
fieldName
|
|
114
|
+
);
|
|
115
|
+
if (!config) return null;
|
|
116
|
+
if (config.type === "table") return null;
|
|
117
|
+
if (config.type === "frame" || config.type === "markup") return "markup";
|
|
118
|
+
return "plain";
|
|
119
|
+
}
|
|
120
|
+
export function getEditableValue(app, entityType, uuid, bundle, fieldName, fieldType) {
|
|
121
|
+
const editables = app.directive.getEditablesForBlock(uuid);
|
|
122
|
+
const editable = editables.find((e) => e.fieldName === fieldName);
|
|
123
|
+
if (editable?.getValue) {
|
|
124
|
+
return editable.getValue();
|
|
125
|
+
}
|
|
126
|
+
const element = app.directive.findEditableElement(fieldName, {
|
|
127
|
+
type: entityType,
|
|
128
|
+
uuid,
|
|
129
|
+
bundle
|
|
130
|
+
});
|
|
131
|
+
if (element) {
|
|
132
|
+
return fieldType === "markup" ? element.innerHTML || "" : element.textContent || "";
|
|
133
|
+
}
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
export function getParagraphChildren(app, uuid) {
|
|
137
|
+
const result = [];
|
|
138
|
+
for (const field of app.state.mutatedFields.value) {
|
|
139
|
+
if (field.entityUuid === uuid && field.list.length > 0) {
|
|
140
|
+
result.push({
|
|
141
|
+
fieldName: field.name,
|
|
142
|
+
paragraphs: field.list.map((item) => ({
|
|
143
|
+
uuid: item.uuid,
|
|
144
|
+
bundle: item.bundle
|
|
145
|
+
}))
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return result;
|
|
150
|
+
}
|
|
151
|
+
export function resolvePosition(app, parentUuid, fieldName, position) {
|
|
152
|
+
const fieldList = app.state.mutatedFields.value.find(
|
|
153
|
+
(f) => f.entityUuid === parentUuid && f.name === fieldName
|
|
154
|
+
);
|
|
155
|
+
const list = fieldList?.list ?? [];
|
|
156
|
+
if (position === void 0 || position === "end") {
|
|
157
|
+
const lastBlock = list.at(-1);
|
|
158
|
+
return { afterUuid: lastBlock?.uuid ?? null };
|
|
159
|
+
}
|
|
160
|
+
if (position === "start") {
|
|
161
|
+
return { afterUuid: null };
|
|
162
|
+
}
|
|
163
|
+
if (position.startsWith("after:")) {
|
|
164
|
+
const uuid = position.slice(6);
|
|
165
|
+
const found = list.find((b) => b.uuid === uuid);
|
|
166
|
+
if (!found) {
|
|
167
|
+
return {
|
|
168
|
+
error: `Position "after:${uuid}": paragraph not found in field "${fieldName}".`
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
return { afterUuid: uuid };
|
|
172
|
+
}
|
|
173
|
+
if (position.startsWith("before:")) {
|
|
174
|
+
const uuid = position.slice(7);
|
|
175
|
+
const index = list.findIndex((b) => b.uuid === uuid);
|
|
176
|
+
if (index === -1) {
|
|
177
|
+
return {
|
|
178
|
+
error: `Position "before:${uuid}": paragraph not found in field "${fieldName}".`
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
const preceding = index > 0 ? list[index - 1] : void 0;
|
|
182
|
+
return { afterUuid: preceding?.uuid ?? null };
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
error: `Invalid position value: "${position}". Use "start", "end", "after:<UUID>", or "before:<UUID>".`
|
|
186
|
+
};
|
|
187
|
+
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
parentSchema,
|
|
6
|
-
positionSchema,
|
|
7
|
-
resolvePosition
|
|
8
|
-
} from "../schemas.js";
|
|
3
|
+
import { mutationResultSchema, parentSchema, positionSchema } from "../schemas.js";
|
|
4
|
+
import { resolvePosition } from "../helpers.js";
|
|
9
5
|
const paramsSchema = z.object({
|
|
10
6
|
uuids: z.array(z.string()).describe("The UUIDs of the paragraphs to move"),
|
|
11
7
|
parent: parentSchema.describe("The target parent entity"),
|