Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
23 changes: 6 additions & 17 deletions common/plugin-element-cache.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,24 @@
const appRoots = {};

export const onElementRemoved = (element, callback) => {
new MutationObserver(function () {
if (!document.contains(element)) {
callback();
this.disconnect();
}
}).observe(element.parentElement, { childList: true });
};

export const addElementToCache = (element, key, data = {}) => {
appRoots[key] = {
element,
data,
};

element.addEventListener(
'flotiq.attached',
() => onElementRemoved(element, () => delete appRoots[key]),
true,
setTimeout(
() =>
element.addEventListener('flotiq.detached', () => {
delete appRoots[key];
}),
50,
);
};

export const getCachedElement = (key) => {
return appRoots[key];
};

export const removeCachedElement = (key) => {
delete appRoots[key];
};

export const registerFn = (pluginInfo, callback) => {
if (window.FlotiqPlugins?.add) {
window.FlotiqPlugins.add(pluginInfo, callback);
Expand Down
2 changes: 1 addition & 1 deletion plugin-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "flotiq.deploy-netlify",
"name": "Deploy Netlify",
"description": "Integration with Netlify deploy. With this plugin, you can easily trigger Netlify builds within Content Object changes on form submission. You will also be able to quickly navigate to your Netlify pages from the Flotiq content editor.",
"version": "1.1.1",
"version": "1.1.2",
"repository": "https://github.com/flotiq/flotiq-ui-plugin-deploy-netlify",
"url": "https://localhost:3053/index.js",
"permissions": []
Expand Down