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:
committed by
GitHub
parent
4a89504d54
commit
117962d473
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user