@blokkli/editor 2.0.0-alpha.59 → 2.0.0-alpha.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/module.json +1 -1
- package/dist/module.mjs +28 -11
- package/dist/modules/agent/runtime/app/tools/auto_translate_paragraphs/Component.d.vue.ts +29 -0
- package/dist/modules/agent/runtime/app/tools/auto_translate_paragraphs/Component.vue +172 -0
- package/dist/modules/agent/runtime/app/tools/auto_translate_paragraphs/Component.vue.d.ts +29 -0
- package/dist/modules/agent/runtime/app/tools/auto_translate_paragraphs/index.d.ts +19 -0
- package/dist/modules/agent/runtime/app/tools/auto_translate_paragraphs/index.js +80 -0
- package/dist/modules/agent/runtime/app/tools/delegate_text_rewrite/Component.vue +16 -0
- package/dist/modules/agent/runtime/app/tools/get_all_page_content/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/get_content_fields/index.js +12 -9
- package/dist/modules/agent/runtime/app/tools/get_page_text/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/get_page_text/index.js +65 -0
- package/dist/modules/agent/runtime/app/tools/get_referenced_entities/index.d.ts +2 -0
- package/dist/modules/agent/runtime/app/tools/get_referenced_entities/index.js +62 -0
- package/dist/modules/agent/runtime/app/tools/helpers.d.ts +8 -2
- package/dist/modules/agent/runtime/app/tools/helpers.js +9 -9
- package/dist/modules/agent/runtime/app/tools/schemas.d.ts +12 -0
- package/dist/modules/agent/runtime/app/tools/schemas.js +20 -0
- package/dist/modules/agent/runtime/app/tools/search_media/index.js +1 -1
- package/dist/modules/agent/runtime/app/tools/select_media/Component.vue +1 -1
- package/dist/modules/agent/runtime/server/agent.js +0 -1
- package/dist/modules/agent/runtime/server/classes/Session/index.js +4 -0
- package/dist/modules/agent/runtime/shared/toolResult.d.ts +4 -0
- package/dist/modules/agent/runtime/shared/toolResult.js +5 -0
- package/dist/modules/drupal/graphql/features/notifications.graphql +39 -0
- package/dist/modules/drupal/index.mjs +6 -1
- package/dist/modules/drupal/runtime/adapter/index.js +38 -0
- package/dist/runtime/editor/components/Actions/ItemDropdown/Item.vue +0 -1
- package/dist/runtime/editor/components/Actions/ScrollArrow/index.d.vue.ts +13 -0
- package/dist/runtime/editor/components/Actions/ScrollArrow/index.vue +52 -0
- package/dist/runtime/editor/components/Actions/ScrollArrow/index.vue.d.ts +13 -0
- package/dist/runtime/editor/components/Actions/Title/index.vue +2 -2
- package/dist/runtime/editor/components/Actions/index.vue +47 -7
- package/dist/runtime/editor/components/Actions/useToolbarScroll.d.ts +25 -0
- package/dist/runtime/editor/components/Actions/useToolbarScroll.js +125 -0
- package/dist/runtime/editor/components/AddListItem/index.vue +0 -2
- package/dist/runtime/editor/components/AppMenu/MenuButton.vue +1 -3
- package/dist/runtime/editor/components/ArtboardTooltip/index.vue +4 -1
- package/dist/runtime/editor/components/Avatar/index.vue +0 -1
- package/dist/runtime/editor/components/BlockPreviewRenderer/index.d.vue.ts +1 -1
- package/dist/runtime/editor/components/BlockPreviewRenderer/index.vue.d.ts +1 -1
- package/dist/runtime/editor/components/BundleSelector/index.vue +0 -4
- package/dist/runtime/editor/components/Dialog/index.d.vue.ts +2 -2
- package/dist/runtime/editor/components/Dialog/index.vue +1 -3
- package/dist/runtime/editor/components/Dialog/index.vue.d.ts +2 -2
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.d.vue.ts +8 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue +12 -2
- package/dist/runtime/editor/components/DiffApproval/Highlight/Item.vue.d.ts +8 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.d.vue.ts +8 -0
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue +14 -2
- package/dist/runtime/editor/components/DiffApproval/Highlight/index.vue.d.ts +8 -0
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.d.vue.ts +2 -2
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue +0 -2
- package/dist/runtime/editor/components/DiffApproval/Toolbar/index.vue.d.ts +2 -2
- package/dist/runtime/editor/components/DiffApproval/index.vue +1 -0
- package/dist/runtime/editor/components/Form/Datepicker/index.vue +0 -1
- package/dist/runtime/editor/components/Form/TextDark/index.vue +0 -1
- package/dist/runtime/editor/components/Form/Textarea/index.vue +0 -1
- package/dist/runtime/editor/components/Form/Toggle/index.d.vue.ts +1 -0
- package/dist/runtime/editor/components/Form/Toggle/index.vue +9 -2
- package/dist/runtime/editor/components/Form/Toggle/index.vue.d.ts +1 -0
- package/dist/runtime/editor/components/FormOverlay/index.vue +0 -1
- package/dist/runtime/editor/components/Icon/index.vue +0 -2
- package/dist/runtime/editor/components/Messages/Item/index.vue +4 -1
- package/dist/runtime/editor/components/Messages/index.vue +3 -0
- package/dist/runtime/editor/components/Panel/Sheet/index.vue +1 -1
- package/dist/runtime/editor/components/Popup/index.vue +0 -2
- package/dist/runtime/editor/components/RichText/Editor/index.d.vue.ts +1 -1
- package/dist/runtime/editor/components/RichText/Editor/index.vue.d.ts +1 -1
- package/dist/runtime/editor/components/ScheduleDate/index.vue +1 -3
- package/dist/runtime/editor/components/SearchOverlay/index.d.vue.ts +1 -1
- package/dist/runtime/editor/components/SearchOverlay/index.vue.d.ts +1 -1
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/Button/index.d.vue.ts +3 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/Button/index.vue +74 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/Button/index.vue.d.ts +3 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/index.d.vue.ts +7 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/index.vue +16 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/List/index.vue.d.ts +7 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/index.d.vue.ts +3 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/index.vue +57 -0
- package/dist/runtime/editor/components/Toolbar/ViewOptions/index.vue.d.ts +3 -0
- package/dist/runtime/editor/components/Toolbar/index.vue +3 -56
- package/dist/runtime/editor/components/ToolbarDropdown/index.d.vue.ts +21 -0
- package/dist/runtime/editor/components/ToolbarDropdown/index.vue +36 -0
- package/dist/runtime/editor/components/ToolbarDropdown/index.vue.d.ts +21 -0
- package/dist/runtime/editor/components/Tooltip/Context.vue +3 -1
- package/dist/runtime/editor/components/Tooltip/index.d.vue.ts +1 -1
- package/dist/runtime/editor/components/Tooltip/index.vue +4 -1
- package/dist/runtime/editor/components/Tooltip/index.vue.d.ts +1 -1
- package/dist/runtime/editor/components/index.d.ts +1 -0
- package/dist/runtime/editor/components/index.js +1 -0
- package/dist/runtime/editor/composables/defineViewOption.d.ts +5 -0
- package/dist/runtime/editor/composables/defineViewOption.js +10 -0
- package/dist/runtime/editor/composables/index.d.ts +3 -0
- package/dist/runtime/editor/composables/index.js +2 -0
- package/dist/runtime/editor/composables/useDismiss.d.ts +30 -0
- package/dist/runtime/editor/composables/useDismiss.js +43 -0
- package/dist/runtime/editor/composables/useGlobalBlokkliObject.d.ts +3 -3
- package/dist/runtime/editor/css/output.css +1 -1
- package/dist/runtime/editor/events/index.d.ts +23 -0
- package/dist/runtime/editor/features/add-list/Actions/index.vue +0 -1
- package/dist/runtime/editor/features/add-list/Blocks/index.vue +0 -1
- package/dist/runtime/editor/features/add-list/Help/Item.vue +2 -7
- package/dist/runtime/editor/features/add-list/Help/index.vue +1 -1
- package/dist/runtime/editor/features/add-list/index.vue +0 -2
- package/dist/runtime/editor/features/anchors/index.vue +11 -11
- package/dist/runtime/editor/features/anchors/types.d.ts +1 -0
- package/dist/runtime/editor/features/anchors/types.js +1 -0
- package/dist/runtime/editor/features/artboard/Renderer.vue +30 -28
- package/dist/runtime/editor/features/block-scheduler/Dialog/ScheduleSection.vue +0 -3
- package/dist/runtime/editor/features/block-scheduler/index.vue +0 -1
- package/dist/runtime/editor/features/block-transfer/SummaryDialog/index.vue +0 -4
- package/dist/runtime/editor/features/breadcrumbs/Crumb/index.vue +0 -5
- package/dist/runtime/editor/features/changelog/changelog.json +8 -0
- package/dist/runtime/editor/features/command-palette/Palette/Item/index.vue +0 -3
- package/dist/runtime/editor/features/command-palette/Palette/index.vue +0 -1
- package/dist/runtime/editor/features/comments/AddForm/index.vue +0 -1
- package/dist/runtime/editor/features/comments/Comment/Actions/index.vue +0 -4
- package/dist/runtime/editor/features/comments/Comment/index.d.vue.ts +14 -0
- package/dist/runtime/editor/features/comments/Comment/index.vue +29 -8
- package/dist/runtime/editor/features/comments/Comment/index.vue.d.ts +14 -0
- package/dist/runtime/editor/features/comments/CommentInput/index.d.vue.ts +1 -1
- package/dist/runtime/editor/features/comments/CommentInput/index.vue +0 -3
- package/dist/runtime/editor/features/comments/CommentInput/index.vue.d.ts +1 -1
- package/dist/runtime/editor/features/comments/Sidebar/AddForm/index.vue +0 -1
- package/dist/runtime/editor/features/comments/Sidebar/index.d.vue.ts +16 -0
- package/dist/runtime/editor/features/comments/Sidebar/index.vue +13 -8
- package/dist/runtime/editor/features/comments/Sidebar/index.vue.d.ts +16 -0
- package/dist/runtime/editor/features/comments/Thread/ReplyForm/index.vue +0 -1
- package/dist/runtime/editor/features/comments/Thread/index.d.vue.ts +16 -0
- package/dist/runtime/editor/features/comments/Thread/index.vue +26 -6
- package/dist/runtime/editor/features/comments/Thread/index.vue.d.ts +16 -0
- package/dist/runtime/editor/features/comments/index.vue +28 -3
- package/dist/runtime/editor/features/delete/types.d.ts +1 -0
- package/dist/runtime/editor/features/delete/types.js +1 -0
- package/dist/runtime/editor/features/dev-mode/index.vue +17 -15
- package/dist/runtime/editor/features/dragging-overlay/DragItems/index.vue +1 -0
- package/dist/runtime/editor/features/duplicate/types.d.ts +1 -0
- package/dist/runtime/editor/features/duplicate/types.js +1 -0
- package/dist/runtime/editor/features/editable-field/Overlay/Frame/index.vue +0 -2
- package/dist/runtime/editor/features/editable-field/Overlay/Plaintext/index.vue +0 -1
- package/dist/runtime/editor/features/editable-field/Overlay/ReadabilityIndicator/index.vue +0 -5
- package/dist/runtime/editor/features/editable-field/Overlay/index.vue +0 -5
- package/dist/runtime/editor/features/editable-mask/index.vue +21 -20
- package/dist/runtime/editor/features/entity-title/index.vue +0 -4
- package/dist/runtime/editor/features/fragments/Dialog/index.vue +0 -4
- package/dist/runtime/editor/features/grid/index.vue +16 -15
- package/dist/runtime/editor/features/grid/types.d.ts +1 -0
- package/dist/runtime/editor/features/grid/types.js +1 -0
- package/dist/runtime/editor/features/help/Dialog/index.d.vue.ts +7 -0
- package/dist/runtime/editor/features/help/Dialog/index.vue +57 -0
- package/dist/runtime/editor/features/help/Dialog/index.vue.d.ts +7 -0
- package/dist/runtime/editor/features/help/index.vue +52 -47
- package/dist/runtime/editor/features/history/List/index.vue +2 -9
- package/dist/runtime/editor/features/history/types.d.ts +1 -0
- package/dist/runtime/editor/features/history/types.js +1 -0
- package/dist/runtime/editor/features/notifications/Item/index.d.vue.ts +4 -0
- package/dist/runtime/editor/features/notifications/Item/index.vue +96 -0
- package/dist/runtime/editor/features/notifications/Item/index.vue.d.ts +4 -0
- package/dist/runtime/editor/features/notifications/List/index.d.vue.ts +11 -0
- package/dist/runtime/editor/features/notifications/List/index.vue +126 -0
- package/dist/runtime/editor/features/notifications/List/index.vue.d.ts +11 -0
- package/dist/runtime/editor/features/notifications/docs.md +12 -0
- package/dist/runtime/editor/features/notifications/index.d.vue.ts +3 -0
- package/dist/runtime/editor/features/notifications/index.vue +123 -0
- package/dist/runtime/editor/features/notifications/index.vue.d.ts +3 -0
- package/dist/runtime/editor/features/notifications/types.d.ts +132 -0
- package/dist/runtime/editor/features/notifications/types.js +20 -0
- package/dist/runtime/editor/features/options/Form/Checkbox/index.vue +6 -2
- package/dist/runtime/editor/features/options/Form/Checkboxes/index.vue +14 -4
- package/dist/runtime/editor/features/options/Form/Color/index.vue +1 -1
- package/dist/runtime/editor/features/options/Form/ComplexType/index.vue +0 -1
- package/dist/runtime/editor/features/options/Form/DateTimeLocal/index.vue +0 -1
- package/dist/runtime/editor/features/options/Form/Group.vue +3 -1
- package/dist/runtime/editor/features/options/Form/Item.vue +1 -2
- package/dist/runtime/editor/features/options/Form/Number/index.vue +9 -3
- package/dist/runtime/editor/features/options/Form/Radios/index.vue +3 -2
- package/dist/runtime/editor/features/options/Form/Range/index.vue +8 -2
- package/dist/runtime/editor/features/options/Form/Text/index.vue +6 -2
- package/dist/runtime/editor/features/options/index.vue +7 -1
- package/dist/runtime/editor/features/ownership/Banner/index.vue +3 -1
- package/dist/runtime/editor/features/ownership/types.d.ts +1 -0
- package/dist/runtime/editor/features/ownership/types.js +1 -0
- package/dist/runtime/editor/features/preview-grant/types.d.ts +1 -0
- package/dist/runtime/editor/features/preview-grant/types.js +1 -0
- package/dist/runtime/editor/features/proxy-view/index.vue +24 -21
- package/dist/runtime/editor/features/publish/Dialog/PublishOption.vue +0 -2
- package/dist/runtime/editor/features/publish/Dialog/index.vue +1 -2
- package/dist/runtime/editor/features/responsive-preview/Frame/index.vue +0 -1
- package/dist/runtime/editor/features/revert/types.d.ts +1 -0
- package/dist/runtime/editor/features/revert/types.js +1 -0
- package/dist/runtime/editor/features/settings/Dialog/FeatureSetting/index.vue +18 -8
- package/dist/runtime/editor/features/swap/types.d.ts +1 -0
- package/dist/runtime/editor/features/swap/types.js +1 -0
- package/dist/runtime/editor/features/translations/Banner/index.vue +4 -1
- package/dist/runtime/editor/features/translations/CsvDialog/Import/index.vue +4 -1
- package/dist/runtime/editor/features/translations/TranslateDialog/index.vue +7 -2
- package/dist/runtime/editor/plugins/BlockIndicator/index.vue +0 -2
- package/dist/runtime/editor/plugins/ContextMenu/Menu/index.vue +4 -36
- package/dist/runtime/editor/plugins/ItemAction/index.vue +0 -1
- package/dist/runtime/editor/plugins/Sidebar/index.vue +7 -50
- package/dist/runtime/editor/plugins/ToolbarButton/index.d.vue.ts +8 -2
- package/dist/runtime/editor/plugins/ToolbarButton/index.vue +122 -28
- package/dist/runtime/editor/plugins/ToolbarButton/index.vue.d.ts +8 -2
- package/dist/runtime/editor/plugins/index.d.ts +1 -2
- package/dist/runtime/editor/plugins/index.js +1 -3
- package/dist/runtime/editor/providers/fieldValue.js +11 -13
- package/dist/runtime/editor/providers/plugin.d.ts +12 -0
- package/dist/runtime/editor/providers/plugin.js +9 -0
- package/dist/runtime/editor/translations/de.json +51 -19
- package/dist/runtime/editor/translations/fr.json +16 -4
- package/dist/runtime/editor/translations/gsw_CH.json +44 -19
- package/dist/runtime/editor/translations/it.json +16 -4
- package/package.json +4 -5
- package/dist/runtime/editor/plugins/ViewOption/index.d.vue.ts +0 -139
- package/dist/runtime/editor/plugins/ViewOption/index.vue +0 -99
- package/dist/runtime/editor/plugins/ViewOption/index.vue.d.ts +0 -139
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import 'typescript';
|
|
|
19
19
|
import 'oxc-walker';
|
|
20
20
|
|
|
21
21
|
const name = "@blokkli/editor";
|
|
22
|
-
const version = "2.0.0-alpha.
|
|
22
|
+
const version = "2.0.0-alpha.60";
|
|
23
23
|
|
|
24
24
|
function validateOption(optionKey, option, icons) {
|
|
25
25
|
const errors = [];
|
|
@@ -1512,6 +1512,7 @@ const USED_MATERIAL_ICONS = [
|
|
|
1512
1512
|
"bk_mdi_add_column_right",
|
|
1513
1513
|
"bk_mdi_add_comment",
|
|
1514
1514
|
"bk_mdi_add_row_below",
|
|
1515
|
+
"bk_mdi_alternate_email",
|
|
1515
1516
|
"bk_mdi_anchor",
|
|
1516
1517
|
"bk_mdi_architecture",
|
|
1517
1518
|
"bk_mdi_area_chart",
|
|
@@ -1552,6 +1553,7 @@ const USED_MATERIAL_ICONS = [
|
|
|
1552
1553
|
"bk_mdi_construction",
|
|
1553
1554
|
"bk_mdi_content_copy",
|
|
1554
1555
|
"bk_mdi_content_paste",
|
|
1556
|
+
"bk_mdi_crop_9_16",
|
|
1555
1557
|
"bk_mdi_csv",
|
|
1556
1558
|
"bk_mdi_dashboard",
|
|
1557
1559
|
"bk_mdi_data_object",
|
|
@@ -1569,6 +1571,7 @@ const USED_MATERIAL_ICONS = [
|
|
|
1569
1571
|
"bk_mdi_exit_to_app",
|
|
1570
1572
|
"bk_mdi_expand_all",
|
|
1571
1573
|
"bk_mdi_extension",
|
|
1574
|
+
"bk_mdi_eye_tracking",
|
|
1572
1575
|
"bk_mdi_feature_search",
|
|
1573
1576
|
"bk_mdi_fit_screen",
|
|
1574
1577
|
"bk_mdi_format_bold",
|
|
@@ -1601,11 +1604,13 @@ const USED_MATERIAL_ICONS = [
|
|
|
1601
1604
|
"bk_mdi_lists",
|
|
1602
1605
|
"bk_mdi_lock",
|
|
1603
1606
|
"bk_mdi_logo_dev",
|
|
1607
|
+
"bk_mdi_mark_chat_read",
|
|
1604
1608
|
"bk_mdi_menu",
|
|
1605
1609
|
"bk_mdi_mobile",
|
|
1606
1610
|
"bk_mdi_mobile_rotate",
|
|
1607
1611
|
"bk_mdi_monitor",
|
|
1608
1612
|
"bk_mdi_newspaper",
|
|
1613
|
+
"bk_mdi_notifications",
|
|
1609
1614
|
"bk_mdi_open_in_new",
|
|
1610
1615
|
"bk_mdi_palette",
|
|
1611
1616
|
"bk_mdi_person",
|
|
@@ -1658,6 +1663,7 @@ const USED_MATERIAL_ICONS = [
|
|
|
1658
1663
|
"bk_mdi_undo",
|
|
1659
1664
|
"bk_mdi_unpublished",
|
|
1660
1665
|
"bk_mdi_upload",
|
|
1666
|
+
"bk_mdi_verified",
|
|
1661
1667
|
"bk_mdi_video_camera_back",
|
|
1662
1668
|
"bk_mdi_visibility",
|
|
1663
1669
|
"bk_mdi_visibility_off",
|
|
@@ -1921,7 +1927,9 @@ export default adapterExtensions
|
|
|
1921
1927
|
}
|
|
1922
1928
|
);
|
|
1923
1929
|
|
|
1930
|
+
const logger$2 = useLogger("@blokkli/editor");
|
|
1924
1931
|
let processor = null;
|
|
1932
|
+
let processorUnavailable = false;
|
|
1925
1933
|
function postcssMangleClasses(selectorParser) {
|
|
1926
1934
|
const plugin = () => ({
|
|
1927
1935
|
postcssPlugin: "postcss-mangle-blokkli-classes",
|
|
@@ -1963,12 +1971,16 @@ function postcssMangleClasses(selectorParser) {
|
|
|
1963
1971
|
plugin.postcss = true;
|
|
1964
1972
|
return plugin;
|
|
1965
1973
|
}
|
|
1974
|
+
async function ensureProcessor() {
|
|
1975
|
+
if (processor || processorUnavailable) return processor;
|
|
1976
|
+
processor = await createProcessor();
|
|
1977
|
+
return processor;
|
|
1978
|
+
}
|
|
1966
1979
|
async function processCSS(css, from, contentPaths) {
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
}
|
|
1980
|
+
const proc = await ensureProcessor();
|
|
1981
|
+
if (!proc) return css;
|
|
1970
1982
|
const sourceDirectives = contentPaths?.length ? "\n" + contentPaths.map((dir) => `@source "${dir}/**/*.vue";`).join("\n") : "";
|
|
1971
|
-
const result = await
|
|
1983
|
+
const result = await proc.process(css + sourceDirectives, {
|
|
1972
1984
|
from: from || "module.css"
|
|
1973
1985
|
});
|
|
1974
1986
|
return result.css;
|
|
@@ -2006,12 +2018,13 @@ async function createProcessor() {
|
|
|
2006
2018
|
return postcss(plugins);
|
|
2007
2019
|
} catch (e) {
|
|
2008
2020
|
if (e.code === "MODULE_NOT_FOUND") {
|
|
2021
|
+
processorUnavailable = true;
|
|
2009
2022
|
const missing = e.message.match(/Cannot find module '([^']+)'/)?.[1] || "unknown";
|
|
2010
|
-
|
|
2011
|
-
`
|
|
2012
|
-
|
|
2013
|
-
npm install -D postcss tailwindcss @tailwindcss/postcss postcss-import postcss-nesting postcss-replace @thedutchcoder/postcss-rem-to-px`
|
|
2023
|
+
logger$2.warn(
|
|
2024
|
+
`bl\xF6kkli's PostCSS pipeline is disabled \u2014 missing dependency "${missing}". This is only required if you author custom bl\xF6kkli modules or features that use Tailwind v4 \`@apply\` / \`theme()\` in their <style> blocks. To enable it, install:
|
|
2025
|
+
npm install -D postcss tailwindcss @tailwindcss/postcss postcss-import postcss-nesting postcss-replace @thedutchcoder/postcss-rem-to-px`
|
|
2014
2026
|
);
|
|
2027
|
+
return null;
|
|
2015
2028
|
}
|
|
2016
2029
|
throw e;
|
|
2017
2030
|
}
|
|
@@ -2174,6 +2187,7 @@ async function stripDistBoilerplate(css) {
|
|
|
2174
2187
|
return result.css;
|
|
2175
2188
|
}
|
|
2176
2189
|
async function processStyleBlocks(code, filePath, tailwindConfigPath) {
|
|
2190
|
+
if (!await ensureProcessor()) return code;
|
|
2177
2191
|
const styleRegex = /<style([^>]*)>([\s\S]*?)<\/style>/g;
|
|
2178
2192
|
let result = code;
|
|
2179
2193
|
let styleMatch;
|
|
@@ -4378,8 +4392,11 @@ const module$1 = defineNuxtModule({
|
|
|
4378
4392
|
blockCollector,
|
|
4379
4393
|
theme
|
|
4380
4394
|
);
|
|
4381
|
-
const
|
|
4382
|
-
|
|
4395
|
+
const distMarker = helper.resolvers.module.resolve(
|
|
4396
|
+
"./modules/tailwind/index.mjs"
|
|
4397
|
+
);
|
|
4398
|
+
const isRunningFromDist = helper.fileCache.fileExists(distMarker);
|
|
4399
|
+
if (!isRunningFromDist) {
|
|
4383
4400
|
context.addContentPath(helper.resolvers.module.resolve("./runtime"));
|
|
4384
4401
|
context.addContentPath(helper.resolvers.module.resolve("./modules"));
|
|
4385
4402
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { McpToolContext } from '#blokkli/agent/app/types';
|
|
2
|
+
import type { ComponentParams } from './index.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
context: McpToolContext;
|
|
5
|
+
params: ComponentParams;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
8
|
+
done: (result: ComponentToolResult<{
|
|
9
|
+
acceptedCount: number;
|
|
10
|
+
rejectedByUser: Record<string, Record<string, {
|
|
11
|
+
reasonForRejection: string;
|
|
12
|
+
}>>;
|
|
13
|
+
label: string;
|
|
14
|
+
agentMessage?: string | undefined;
|
|
15
|
+
historyIndex?: number | undefined;
|
|
16
|
+
}>) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
onDone?: ((result: ComponentToolResult<{
|
|
19
|
+
acceptedCount: number;
|
|
20
|
+
rejectedByUser: Record<string, Record<string, {
|
|
21
|
+
reasonForRejection: string;
|
|
22
|
+
}>>;
|
|
23
|
+
label: string;
|
|
24
|
+
agentMessage?: string | undefined;
|
|
25
|
+
historyIndex?: number | undefined;
|
|
26
|
+
}>) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DiffApproval
|
|
3
|
+
v-if="phase === 'approving' && approvalItems.length > 0"
|
|
4
|
+
:items="approvalItems"
|
|
5
|
+
insertions-only
|
|
6
|
+
show-reason
|
|
7
|
+
@apply="onApply"
|
|
8
|
+
@cancel="onCancel"
|
|
9
|
+
/>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { useBlokkli, ref, onMounted } from "#imports";
|
|
14
|
+
import { DiffApproval } from "#blokkli/editor/components";
|
|
15
|
+
import {
|
|
16
|
+
skippedFieldsMessage,
|
|
17
|
+
appendAgentNote,
|
|
18
|
+
rejectedWithoutReasonMessage
|
|
19
|
+
} from "../fieldDiffApproval";
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
context: { type: null, required: true },
|
|
22
|
+
params: { type: Object, required: true }
|
|
23
|
+
});
|
|
24
|
+
const emit = defineEmits(["done"]);
|
|
25
|
+
const blokkli = useBlokkli();
|
|
26
|
+
const { $t, state, context: entityContext, types } = blokkli;
|
|
27
|
+
const phase = ref("loading");
|
|
28
|
+
const approvalItems = ref([]);
|
|
29
|
+
const adapter = props.context.adapter;
|
|
30
|
+
const skippedNote = skippedFieldsMessage(props.params.skipped);
|
|
31
|
+
function emitDone(result) {
|
|
32
|
+
emit("done", {
|
|
33
|
+
...result,
|
|
34
|
+
agentMessage: appendAgentNote(result.agentMessage, skippedNote)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function resolveFieldLabel(entityType, bundle, fieldName) {
|
|
38
|
+
const config = types.editableFieldConfig.forName(
|
|
39
|
+
entityType,
|
|
40
|
+
bundle,
|
|
41
|
+
fieldName
|
|
42
|
+
);
|
|
43
|
+
return config?.label || fieldName;
|
|
44
|
+
}
|
|
45
|
+
onMounted(async () => {
|
|
46
|
+
const sourceLanguage = state.translation.value.sourceLanguage || "";
|
|
47
|
+
const targetLanguage = entityContext.value.language;
|
|
48
|
+
if (!sourceLanguage) {
|
|
49
|
+
emitDone({
|
|
50
|
+
acceptedCount: 0,
|
|
51
|
+
rejectedByUser: {},
|
|
52
|
+
label: $t("aiAgentAutoTranslateNoSource", "No source language available"),
|
|
53
|
+
agentMessage: "The host entity has no source language configured, so there is nothing to auto-translate from."
|
|
54
|
+
});
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const requestedUuids = new Set(props.params.uuids);
|
|
58
|
+
const sourceValues = await adapter.loadTextFieldValuesForLanguage(sourceLanguage);
|
|
59
|
+
const toTranslate = sourceValues.filter(
|
|
60
|
+
(v) => requestedUuids.has(v.uuid) && v.value.trim().length > 0
|
|
61
|
+
);
|
|
62
|
+
if (!toTranslate.length) {
|
|
63
|
+
emitDone({
|
|
64
|
+
acceptedCount: 0,
|
|
65
|
+
rejectedByUser: {},
|
|
66
|
+
label: $t("aiAgentAutoTranslateNoFields", "No text fields to translate"),
|
|
67
|
+
agentMessage: "No text fields were found on the requested paragraphs in the source language. Use get_page_structure or get_content_fields to inspect what is editable."
|
|
68
|
+
});
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const byKey = new Map(
|
|
72
|
+
toTranslate.map((v) => [`${v.uuid}:${v.fieldName}`, v])
|
|
73
|
+
);
|
|
74
|
+
const response = await adapter.requestTranslation(
|
|
75
|
+
toTranslate.map((v) => ({
|
|
76
|
+
key: `${v.uuid}:${v.fieldName}`,
|
|
77
|
+
text: v.value,
|
|
78
|
+
isHtml: v.fieldType === "markup",
|
|
79
|
+
sourceLanguage,
|
|
80
|
+
targetLanguage
|
|
81
|
+
}))
|
|
82
|
+
);
|
|
83
|
+
if (!response.success || !response.data.length) {
|
|
84
|
+
emitDone({
|
|
85
|
+
acceptedCount: 0,
|
|
86
|
+
rejectedByUser: {},
|
|
87
|
+
label: $t("aiAgentAutoTranslateFailed", "Translation request failed"),
|
|
88
|
+
agentMessage: 'The backend translation service returned no results. Inform the user \u2014 they may need to retry, or use delegate_text_rewrite with template "translate" instead.'
|
|
89
|
+
});
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
let id = 0;
|
|
93
|
+
approvalItems.value = response.data.map((result) => {
|
|
94
|
+
const separatorIndex = result.key.indexOf(":");
|
|
95
|
+
const uuid = result.key.substring(0, separatorIndex);
|
|
96
|
+
const fieldName = result.key.substring(separatorIndex + 1);
|
|
97
|
+
const source = byKey.get(result.key);
|
|
98
|
+
return {
|
|
99
|
+
id: id++,
|
|
100
|
+
uuid,
|
|
101
|
+
fieldName,
|
|
102
|
+
fieldLabel: source ? resolveFieldLabel(source.entityType, source.entityBundle, fieldName) : fieldName,
|
|
103
|
+
value: result.translatedText
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
phase.value = "approving";
|
|
107
|
+
});
|
|
108
|
+
async function onApply(data) {
|
|
109
|
+
const targetLanguage = entityContext.value.language;
|
|
110
|
+
const items = approvalItems.value;
|
|
111
|
+
const rejectedByUser = {};
|
|
112
|
+
const accepted = [];
|
|
113
|
+
for (const item of items) {
|
|
114
|
+
if (data.selected[item.id]) {
|
|
115
|
+
accepted.push(item);
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const fields = rejectedByUser[item.uuid] ?? {};
|
|
119
|
+
fields[item.fieldName] = {
|
|
120
|
+
reasonForRejection: data.reasons[item.id] || ""
|
|
121
|
+
};
|
|
122
|
+
rejectedByUser[item.uuid] = fields;
|
|
123
|
+
}
|
|
124
|
+
if (accepted.length) {
|
|
125
|
+
await state.mutateWithLoadingState(
|
|
126
|
+
() => adapter.importTranslationsBatched({
|
|
127
|
+
items: accepted.map((item) => ({
|
|
128
|
+
langcode: targetLanguage,
|
|
129
|
+
uuid: item.uuid,
|
|
130
|
+
fieldName: item.fieldName,
|
|
131
|
+
fieldValue: item.value
|
|
132
|
+
}))
|
|
133
|
+
})
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
const acceptedCount = accepted.length;
|
|
137
|
+
const label = acceptedCount === items.length ? $t(
|
|
138
|
+
"aiAgentAutoTranslateAllApplied",
|
|
139
|
+
"All @count translations applied"
|
|
140
|
+
).replace("@count", String(acceptedCount)) : $t(
|
|
141
|
+
"aiAgentAutoTranslateSomeApplied",
|
|
142
|
+
"@applied of @total translations applied"
|
|
143
|
+
).replace("@applied", String(acceptedCount)).replace("@total", String(items.length));
|
|
144
|
+
const _details = accepted.map((item) => ({
|
|
145
|
+
fieldLabel: item.fieldLabel,
|
|
146
|
+
before: "",
|
|
147
|
+
after: item.value
|
|
148
|
+
}));
|
|
149
|
+
emitDone({
|
|
150
|
+
acceptedCount,
|
|
151
|
+
rejectedByUser,
|
|
152
|
+
label,
|
|
153
|
+
agentMessage: rejectedWithoutReasonMessage(rejectedByUser),
|
|
154
|
+
historyIndex: state.currentMutationIndex.value,
|
|
155
|
+
_details
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
function onCancel() {
|
|
159
|
+
const rejectedByUser = {};
|
|
160
|
+
for (const item of approvalItems.value) {
|
|
161
|
+
const fields = rejectedByUser[item.uuid] ?? {};
|
|
162
|
+
fields[item.fieldName] = { reasonForRejection: "" };
|
|
163
|
+
rejectedByUser[item.uuid] = fields;
|
|
164
|
+
}
|
|
165
|
+
emitDone({
|
|
166
|
+
acceptedCount: 0,
|
|
167
|
+
rejectedByUser,
|
|
168
|
+
label: $t("aiAgentAutoTranslateAllRejected", "All translations rejected"),
|
|
169
|
+
agentMessage: "All translations were rejected by the user. Ask what they would like instead before retrying."
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { McpToolContext } from '#blokkli/agent/app/types';
|
|
2
|
+
import type { ComponentParams } from './index.js';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
context: McpToolContext;
|
|
5
|
+
params: ComponentParams;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
8
|
+
done: (result: ComponentToolResult<{
|
|
9
|
+
acceptedCount: number;
|
|
10
|
+
rejectedByUser: Record<string, Record<string, {
|
|
11
|
+
reasonForRejection: string;
|
|
12
|
+
}>>;
|
|
13
|
+
label: string;
|
|
14
|
+
agentMessage?: string | undefined;
|
|
15
|
+
historyIndex?: number | undefined;
|
|
16
|
+
}>) => any;
|
|
17
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
18
|
+
onDone?: ((result: ComponentToolResult<{
|
|
19
|
+
acceptedCount: number;
|
|
20
|
+
rejectedByUser: Record<string, Record<string, {
|
|
21
|
+
reasonForRejection: string;
|
|
22
|
+
}>>;
|
|
23
|
+
label: string;
|
|
24
|
+
agentMessage?: string | undefined;
|
|
25
|
+
historyIndex?: number | undefined;
|
|
26
|
+
}>) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { fieldDiffResultSchema } from '../schemas.js';
|
|
3
|
+
import { type SkippedField } from '../fieldDiffApproval.js';
|
|
4
|
+
declare const paramsSchema: z.ZodObject<{
|
|
5
|
+
uuids: z.ZodPipe<z.ZodTransform<unknown, unknown>, z.ZodArray<z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export type AutoTranslateParams = z.infer<typeof paramsSchema>;
|
|
8
|
+
export type AutoTranslateResult = z.infer<typeof fieldDiffResultSchema>;
|
|
9
|
+
/**
|
|
10
|
+
* Resolved params handed to the Component after `execute` has validated the
|
|
11
|
+
* UUIDs. `uuids` only contains paragraphs that exist; `skipped` lists the
|
|
12
|
+
* dropped references so the Component can report them back to the agent.
|
|
13
|
+
*/
|
|
14
|
+
export type ComponentParams = {
|
|
15
|
+
uuids: string[];
|
|
16
|
+
skipped: SkippedField[];
|
|
17
|
+
};
|
|
18
|
+
declare const _default: any;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import {
|
|
4
|
+
requireBundlePermission,
|
|
5
|
+
requireNoRestrictedAncestor
|
|
6
|
+
} from "../../helpers/validation.js";
|
|
7
|
+
import { onlyUnique } from "#blokkli/helpers";
|
|
8
|
+
import { fieldDiffResultSchema } from "../schemas.js";
|
|
9
|
+
import { stringArrayParam } from "../schemas.js";
|
|
10
|
+
import { resolveHost } from "../helpers.js";
|
|
11
|
+
import { skippedFieldsMessage } from "../fieldDiffApproval.js";
|
|
12
|
+
import Component from "./Component.vue";
|
|
13
|
+
import DetailsComponent from "../../components/FieldDiffDetails/index.vue";
|
|
14
|
+
const paramsSchema = z.object({
|
|
15
|
+
uuids: stringArrayParam(
|
|
16
|
+
"UUIDs of paragraphs to auto-translate. Every editable text field on each paragraph is sent to the backend's translation service. The user reviews and accepts/rejects each translation before it is applied. The source language is always the host entity's source language; the target language is the currently-edited language."
|
|
17
|
+
)
|
|
18
|
+
});
|
|
19
|
+
export default defineBlokkliAgentTool({
|
|
20
|
+
name: "auto_translate_paragraphs",
|
|
21
|
+
description: "Translate every editable text field of one or more paragraphs into the currently-edited language using the backend's configured translation service (e.g. DeepL via Drupal) \u2014 not the agent's own LLM. The user reviews each translation in a diff approval UI before it is applied. Only available in translating mode and only when the adapter exposes a translation service. Prefer this when the user asks for an automatic translation; use `delegate_text_rewrite` with `template: 'translate'` only when the user specifically wants the agent to do the translation, or when no backend translation service is configured.",
|
|
22
|
+
category: "mutation",
|
|
23
|
+
lazy: false,
|
|
24
|
+
modes: ["translating"],
|
|
25
|
+
prunedSummary: (r) => `${r.acceptedCount || 0} accepted, ${Object.keys(r.rejectedByUser || {}).length} rejected`,
|
|
26
|
+
label($t) {
|
|
27
|
+
return $t("aiAgentAutoTranslateRunning", "Auto-translating", {
|
|
28
|
+
more: true
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
paramsSchema,
|
|
32
|
+
resultSchema: fieldDiffResultSchema,
|
|
33
|
+
requiredAdapterMethods: [
|
|
34
|
+
"loadTextFieldValuesForLanguage",
|
|
35
|
+
"requestTranslation",
|
|
36
|
+
"importTranslationsBatched"
|
|
37
|
+
],
|
|
38
|
+
component: Component,
|
|
39
|
+
detailsComponent: DetailsComponent,
|
|
40
|
+
buildDetails: (result) => result,
|
|
41
|
+
execute(ctx, params) {
|
|
42
|
+
if (ctx.app.state.editMode.value !== "translating") {
|
|
43
|
+
return {
|
|
44
|
+
error: "auto_translate_paragraphs is only available when the editor is in translating mode."
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const skipped = [];
|
|
48
|
+
const keptUuids = [];
|
|
49
|
+
for (const uuid of params.uuids) {
|
|
50
|
+
const host = resolveHost(ctx.app, uuid);
|
|
51
|
+
if (!host) {
|
|
52
|
+
skipped.push({ uuid, fieldName: "*", reason: "paragraph not found" });
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
keptUuids.push(uuid);
|
|
56
|
+
}
|
|
57
|
+
if (!keptUuids.length) {
|
|
58
|
+
return {
|
|
59
|
+
error: skippedFieldsMessage(skipped) ?? "No paragraph UUIDs were provided."
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
const bundles = keptUuids.map((uuid) => ctx.app.blocks.getBlock(uuid)?.bundle).filter((b) => !!b).filter(onlyUnique);
|
|
63
|
+
if (bundles.length) {
|
|
64
|
+
const denied = requireBundlePermission(ctx.app, bundles, "edit");
|
|
65
|
+
if (denied) return denied;
|
|
66
|
+
}
|
|
67
|
+
const ancestorDenied = requireNoRestrictedAncestor(ctx.app, keptUuids);
|
|
68
|
+
if (ancestorDenied) return ancestorDenied;
|
|
69
|
+
return {
|
|
70
|
+
uuids: keptUuids,
|
|
71
|
+
skipped
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
mockParams: () => ({
|
|
75
|
+
uuids: [
|
|
76
|
+
"4526d2d0-f122-4093-902f-e2f00a433981",
|
|
77
|
+
"9485812c-0ecd-4699-85b2-3a031d47a0a1"
|
|
78
|
+
]
|
|
79
|
+
})
|
|
80
|
+
});
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
:items="completedItems"
|
|
37
37
|
show-reason
|
|
38
38
|
@apply="applySelected"
|
|
39
|
+
@cancel="rejectAllFromApproval"
|
|
39
40
|
/>
|
|
40
41
|
|
|
41
42
|
<ToolCard
|
|
@@ -154,6 +155,21 @@ function finishWithError() {
|
|
|
154
155
|
_usage: streamUsage.value
|
|
155
156
|
});
|
|
156
157
|
}
|
|
158
|
+
function rejectAllFromApproval() {
|
|
159
|
+
const rejectedByUser = {};
|
|
160
|
+
for (const item of completedItems.value) {
|
|
161
|
+
const fields = rejectedByUser[item.uuid] ?? {};
|
|
162
|
+
fields[item.fieldName] = { reasonForRejection: "" };
|
|
163
|
+
rejectedByUser[item.uuid] = fields;
|
|
164
|
+
}
|
|
165
|
+
emitDone({
|
|
166
|
+
acceptedCount: 0,
|
|
167
|
+
rejectedByUser,
|
|
168
|
+
label: $t("aiAgentDelegateRewriteAllRejected", "All changes rejected"),
|
|
169
|
+
agentMessage: "All proposed changes were rejected by the user. Ask the user what they would like to change instead.",
|
|
170
|
+
_usage: streamUsage.value
|
|
171
|
+
});
|
|
172
|
+
}
|
|
157
173
|
async function applySelected(data) {
|
|
158
174
|
const { selected, reasons } = data;
|
|
159
175
|
const { acceptedCount, rejectedByUser, label } = await applyFieldDiffs(
|
|
@@ -15,7 +15,7 @@ const resultSchema = z.object({
|
|
|
15
15
|
});
|
|
16
16
|
export default defineBlokkliAgentTool({
|
|
17
17
|
name: "get_all_page_content",
|
|
18
|
-
description: "Get
|
|
18
|
+
description: "Get a flat list of every paragraph on the page with its uuid, bundle, and the concatenated text of its OWN editable fields (does NOT follow references \u2014 a teaser appears with empty text). Use this when you need per-block uuids to act on specific blocks (translate, rewrite, delete). For any question about what the page SAYS \u2014 summarising, writing an intro that matches the content, translating the page, reviewing meaning \u2014 call `get_page_text` instead; it reads the actual rendered DOM (so teaser/referenced content is included) and returns Markdown the LLM can reason about directly.",
|
|
19
19
|
category: "query",
|
|
20
20
|
lazy: true,
|
|
21
21
|
volatile: true,
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
3
|
import { readBlockContentFields } from "../helpers.js";
|
|
4
|
-
import { stringArrayParam } from "../schemas.js";
|
|
4
|
+
import { stringArrayParam, tolerantSingularKeys } from "../schemas.js";
|
|
5
5
|
import { booleanParam } from "#blokkli/agent/shared/toolParams";
|
|
6
|
-
const paramsSchema =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
const paramsSchema = tolerantSingularKeys(
|
|
7
|
+
z.object({
|
|
8
|
+
uuids: stringArrayParam(
|
|
9
|
+
"Array of paragraph UUIDs. To get page-level fields, pass the page UUID in this array."
|
|
10
|
+
),
|
|
11
|
+
includeNested: booleanParam(
|
|
12
|
+
"Recursively include content fields from all nested child paragraphs (default: true). Set to false to only get direct fields."
|
|
13
|
+
).optional().default(true)
|
|
14
|
+
}),
|
|
15
|
+
{ uuid: "uuids" }
|
|
16
|
+
);
|
|
14
17
|
const fieldSchema = z.discriminatedUnion("type", [
|
|
15
18
|
z.object({
|
|
16
19
|
type: z.literal("plain").describe("Plain text field"),
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
const paramsSchema = z.object({});
|
|
4
|
+
const resultSchema = z.object({
|
|
5
|
+
text: z.string().describe(
|
|
6
|
+
"The page rendered as Markdown \u2014 exactly what the user sees, in reading order"
|
|
7
|
+
),
|
|
8
|
+
truncated: z.boolean().optional().describe("True when the Markdown exceeded the size cap and was cut off")
|
|
9
|
+
});
|
|
10
|
+
const MAX_LENGTH = 5e4;
|
|
11
|
+
const STRIP_SELECTOR = [
|
|
12
|
+
"[hidden]",
|
|
13
|
+
'[aria-hidden="true"]',
|
|
14
|
+
'[data-bk-is-muted="true"]',
|
|
15
|
+
"style",
|
|
16
|
+
"script"
|
|
17
|
+
].join(", ");
|
|
18
|
+
export default defineBlokkliAgentTool({
|
|
19
|
+
name: "get_page_text",
|
|
20
|
+
description: 'Get the rendered page as Markdown \u2014 exactly what the user sees, in reading order, with headings/lists/tables preserved and content from referenced entities (teasers, etc.) included because it reads from the actual DOM. ALWAYS PREFER this over `get_all_page_content` for any question about page meaning or content ("what does this page say", "summarize the page", "write an intro that matches the content", "translate the page"). Reach for `get_all_page_content` only when you need per-block UUIDs to act on specific blocks.',
|
|
21
|
+
category: "query",
|
|
22
|
+
lazy: true,
|
|
23
|
+
volatile: true,
|
|
24
|
+
prunedSummary: (r) => `${r.text?.length ?? 0} chars of page text`,
|
|
25
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
26
|
+
label($t) {
|
|
27
|
+
return $t("aiAgentGetPageTextRunning", "Reading page content", {
|
|
28
|
+
more: true
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
paramsSchema,
|
|
32
|
+
resultSchema,
|
|
33
|
+
async execute(ctx) {
|
|
34
|
+
const { ui, $t } = ctx.app;
|
|
35
|
+
const clone = ui.providerElement.cloneNode(true);
|
|
36
|
+
for (const el of Array.from(clone.querySelectorAll(STRIP_SELECTOR))) {
|
|
37
|
+
el.remove();
|
|
38
|
+
}
|
|
39
|
+
const { default: TurndownService } = await import("turndown");
|
|
40
|
+
const turndown = new TurndownService({
|
|
41
|
+
headingStyle: "atx",
|
|
42
|
+
codeBlockStyle: "fenced",
|
|
43
|
+
bulletListMarker: "-"
|
|
44
|
+
});
|
|
45
|
+
const REMOVED_TAGS = /* @__PURE__ */ new Set([
|
|
46
|
+
"SVG",
|
|
47
|
+
"IFRAME",
|
|
48
|
+
"PICTURE",
|
|
49
|
+
"VIDEO",
|
|
50
|
+
"AUDIO",
|
|
51
|
+
"CANVAS"
|
|
52
|
+
]);
|
|
53
|
+
turndown.remove((node) => REMOVED_TAGS.has(node.nodeName));
|
|
54
|
+
let text = turndown.turndown(clone.innerHTML).trim();
|
|
55
|
+
let truncated = false;
|
|
56
|
+
if (text.length > MAX_LENGTH) {
|
|
57
|
+
text = text.slice(0, MAX_LENGTH) + "\n\n[TRUNCATED]";
|
|
58
|
+
truncated = true;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
label: $t("aiAgentGetPageTextDone", "Read page content"),
|
|
62
|
+
result: truncated ? { text, truncated } : { text }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { defineBlokkliAgentTool } from "#blokkli/agent/app/composables";
|
|
3
|
+
import { stringArrayParam } from "../schemas.js";
|
|
4
|
+
const paramsSchema = z.object({
|
|
5
|
+
uuids: stringArrayParam(
|
|
6
|
+
"Paragraph UUIDs to resolve references for. Returns the entities (media, nodes, taxonomy terms, ...) currently referenced by these paragraphs via any of their reference fields."
|
|
7
|
+
)
|
|
8
|
+
});
|
|
9
|
+
const resultSchema = z.object({
|
|
10
|
+
entities: z.array(
|
|
11
|
+
z.object({
|
|
12
|
+
entityUuid: z.string().describe(
|
|
13
|
+
'UUID of the referenced entity. Pass this as `mediaId` to replace_media_field when the entityType is "media".'
|
|
14
|
+
),
|
|
15
|
+
entityType: z.string().describe('e.g. "media", "node", "taxonomy_term"'),
|
|
16
|
+
entityBundle: z.string().describe(
|
|
17
|
+
'e.g. "image", "canto". Pass this as `mediaBundle` to replace_media_field when the entityType is "media".'
|
|
18
|
+
),
|
|
19
|
+
label: z.string().describe("Human-readable label of the entity"),
|
|
20
|
+
editUrl: z.string().describe("Backend edit URL of the entity"),
|
|
21
|
+
referencedBy: z.array(z.string()).describe(
|
|
22
|
+
"Paragraph UUIDs (from the input) that reference this entity"
|
|
23
|
+
)
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
});
|
|
27
|
+
export default defineBlokkliAgentTool({
|
|
28
|
+
name: "get_referenced_entities",
|
|
29
|
+
description: "Resolve which entities (media items, referenced nodes, taxonomy terms, etc.) are currently referenced by one or more paragraphs. Use this when get_content_fields shows a paragraph has a reference field but you need the actual referenced entity ID \u2014 for example, to copy a media reference from one paragraph into another field via replace_media_field.",
|
|
30
|
+
category: "query",
|
|
31
|
+
lazy: false,
|
|
32
|
+
volatile: true,
|
|
33
|
+
prunedSummary: (r) => `${r.entities?.length ?? 0} referenced entities`,
|
|
34
|
+
modes: ["readonly", "editing", "translating", "review"],
|
|
35
|
+
requiredAdapterMethods: ["getReferencedEntities"],
|
|
36
|
+
label($t) {
|
|
37
|
+
return $t("aiAgentGetReferencedEntitiesRunning", "Resolving references", {
|
|
38
|
+
more: true
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
paramsSchema,
|
|
42
|
+
resultSchema,
|
|
43
|
+
async execute(ctx, params) {
|
|
44
|
+
const { $t } = ctx.app;
|
|
45
|
+
const raw = await ctx.adapter.getReferencedEntities(params.uuids);
|
|
46
|
+
const result = {
|
|
47
|
+
entities: raw.map((e) => ({
|
|
48
|
+
entityUuid: e.entityUuid,
|
|
49
|
+
entityType: e.entityType,
|
|
50
|
+
entityBundle: e.entityBundle,
|
|
51
|
+
label: e.label,
|
|
52
|
+
editUrl: e.editUrl,
|
|
53
|
+
referencedBy: e.uuids
|
|
54
|
+
}))
|
|
55
|
+
};
|
|
56
|
+
const label = $t(
|
|
57
|
+
"aiAgentGetReferencedEntitiesDone",
|
|
58
|
+
"Resolved @count referenced entities"
|
|
59
|
+
).replace("@count", String(result.entities.length));
|
|
60
|
+
return { label, result, affectedUuids: params.uuids };
|
|
61
|
+
}
|
|
62
|
+
});
|