feat(core): Update LLM applications building support (no-changelog) (#7710)

extracted out of #7336

---------

Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
Co-authored-by: Oleg Ivaniv <me@olegivaniv.com>
Co-authored-by: Alex Grozav <alex@grozav.com>
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-11-28 16:47:28 +01:00
committed by GitHub
parent 4a89504d54
commit 117962d473
58 changed files with 1135 additions and 183 deletions

View File

@@ -17,6 +17,18 @@ export default () => {
const { [key]: _, ...rest } = state.customActions;
state.customActions = rest;
}
function getElementAttributes(element: Element) {
const attributesObject: Record<string, string> = {};
for (let i = 0; i < element.attributes.length; i++) {
const attr = element.attributes[i];
if (attr.name.startsWith('data-action-parameter-')) {
attributesObject[attr.name.replace('data-action-parameter-', '')] = attr.value;
}
}
return attributesObject;
}
function delegateClick(e: MouseEvent) {
const clickedElement = e.target;
if (!(clickedElement instanceof Element) || clickedElement.tagName !== 'A') return;
@@ -24,7 +36,9 @@ export default () => {
const actionAttribute = clickedElement.getAttribute('data-action');
if (actionAttribute && typeof availableActions.value[actionAttribute] === 'function') {
e.preventDefault();
availableActions.value[actionAttribute]();
// Extract and parse `data-action-parameter-` attributes and pass them to the action
const elementAttributes = getElementAttributes(clickedElement);
availableActions.value[actionAttribute](elementAttributes);
}
}