@ai-matrx/context-menu 0.1.5 → 0.1.7
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/CHANGELOG.md +12 -0
- package/dist/engine.cjs +24 -3
- package/dist/engine.cjs.map +1 -1
- package/dist/engine.d.cts +3 -1
- package/dist/engine.d.ts +3 -1
- package/dist/engine.js +15 -3
- package/dist/engine.js.map +1 -1
- package/dist/menu-content.cjs +31 -7
- package/dist/menu-content.cjs.map +1 -1
- package/dist/menu-content.js +31 -7
- package/dist/menu-content.js.map +1 -1
- package/dist/react.cjs +73 -41
- package/dist/react.cjs.map +1 -1
- package/dist/react.js +72 -40
- package/dist/react.js.map +1 -1
- package/package.json +3 -3
package/dist/menu-content.cjs
CHANGED
|
@@ -156,6 +156,17 @@ function toast(props) {
|
|
|
156
156
|
else import_notify.toast.message(message, options);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// src/engine/utils/ensure-block-template.ts
|
|
160
|
+
var import_db = require("@ai-matrx/chat/host/db");
|
|
161
|
+
var import_ui_slots = require("@ai-matrx/chat/host/ui-slots");
|
|
162
|
+
async function ensureBlockTemplate(blockId, dispatch) {
|
|
163
|
+
const { data, error } = await import_db.supabase.schema("skill").from("render_definition").select("template").eq("id", blockId).single();
|
|
164
|
+
if (error) throw new Error(error.message);
|
|
165
|
+
const template = data?.template ?? "";
|
|
166
|
+
dispatch(import_ui_slots.sklActions.renderDefinitionsMerged([{ id: blockId, template }]));
|
|
167
|
+
return template;
|
|
168
|
+
}
|
|
169
|
+
|
|
159
170
|
// src/engine/host/port.ts
|
|
160
171
|
var import_confirm_opener = require("@ai-matrx/kit/confirm-opener");
|
|
161
172
|
function unwired(name) {
|
|
@@ -1422,12 +1433,25 @@ function useContextMenuActions(props) {
|
|
|
1422
1433
|
};
|
|
1423
1434
|
const insertTargets = { editorId, getTextarea, insertAtCaret, onTextReplace };
|
|
1424
1435
|
const handleContentBlockInsert = (entry) => {
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1436
|
+
void (async () => {
|
|
1437
|
+
let template = entry.template;
|
|
1438
|
+
if (!template) {
|
|
1439
|
+
try {
|
|
1440
|
+
template = await ensureBlockTemplate(entry.id, dispatch);
|
|
1441
|
+
} catch (error) {
|
|
1442
|
+
toast({
|
|
1443
|
+
title: "Couldn't load that block",
|
|
1444
|
+
description: error instanceof Error ? error.message : "Try again.",
|
|
1445
|
+
variant: "destructive"
|
|
1446
|
+
});
|
|
1447
|
+
return;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
if (insertIntoEditor(insertTargets, template)) {
|
|
1451
|
+
onContentInserted?.();
|
|
1452
|
+
return;
|
|
1453
|
+
}
|
|
1454
|
+
const copied = await (0, import_clipboard.copyText)(template);
|
|
1431
1455
|
if (copied) {
|
|
1432
1456
|
toast({
|
|
1433
1457
|
title: "Copied to clipboard",
|
|
@@ -1436,7 +1460,7 @@ function useContextMenuActions(props) {
|
|
|
1436
1460
|
} else {
|
|
1437
1461
|
getContextMenuHost().showManualCopy({ text: template });
|
|
1438
1462
|
}
|
|
1439
|
-
});
|
|
1463
|
+
})();
|
|
1440
1464
|
};
|
|
1441
1465
|
const handleEntrySelect = (entry) => {
|
|
1442
1466
|
if (entry.entryType === "agent_shortcut") void handleShortcutExecute(entry);
|