From cf5f9414362de7c56a75c3f850be2d2acb0bbb9a Mon Sep 17 00:00:00 2001 From: Dalia Date: Fri, 26 Sep 2025 13:23:55 +0200 Subject: [PATCH 1/2] #27220 refactor form events to use new form API --- CHANGELOG.md | 4 ++++ plugin-manifest.json | 2 +- plugins/index.js | 21 ++++++++++++--------- plugins/panelPlugin/panelPlugin.js | 25 +++++++++---------------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8670ba..fde899a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.1.1] +### Changed +* refactor form events to use new form API #27220 + ## [1.1.0] ### Added * Changelog diff --git a/plugin-manifest.json b/plugin-manifest.json index 451c25e..951cb73 100644 --- a/plugin-manifest.json +++ b/plugin-manifest.json @@ -1,7 +1,7 @@ { "id": "flotiq.custom-links", "name": "Custom Links", - "version": "1.1.0", + "version": "1.1.1", "description": "This plugin will display a button with a link in the edit content object. The link will be supplemented with data from the currently edited object. Thanks to this link, you will be able to get easy access to the preview of where the content is used.", "repository": "https://github.com/flotiq/flotiq-ui-plugins-custom-links", "url": "https://localhost:3053/index.js", diff --git a/plugins/index.js b/plugins/index.js index 13481a8..5853e49 100644 --- a/plugins/index.js +++ b/plugins/index.js @@ -15,16 +15,19 @@ const loadStyles = () => { } }; -registerFn(pluginInfo, (handler, _client, { getLanguage }) => { - loadStyles(); +registerFn( + pluginInfo, + (handler, _client, { getLanguage, getPluginSettings }) => { + loadStyles(); - handler.on('flotiq.plugins.manage::form-schema', (data) => - handleManagePlugin(data, pluginInfo, getLanguage), - ); - handler.on('flotiq.form.sidebar-panel::add', (data) => - handlePanelPlugin(data, pluginInfo), - ); -}); + handler.on('flotiq.plugins.manage::form-schema', (data) => + handleManagePlugin(data, pluginInfo, getLanguage), + ); + handler.on('flotiq.form.sidebar-panel::add', (data) => + handlePanelPlugin(data, pluginInfo, getPluginSettings), + ); + }, +); const pluginManagePreviewRoot = document.getElementById('manage-preview-root'); const pluginPanelPreviewRoot = document.getElementById('panel-preview-root'); diff --git a/plugins/panelPlugin/panelPlugin.js b/plugins/panelPlugin/panelPlugin.js index 952ac4d..908497d 100644 --- a/plugins/panelPlugin/panelPlugin.js +++ b/plugins/panelPlugin/panelPlugin.js @@ -1,7 +1,7 @@ import { addElementToCache, getCachedElement, - deepReadKeyValue + deepReadKeyValue, } from '../../common/plugin-helpers'; const onClick = (e) => { @@ -11,23 +11,21 @@ const onClick = (e) => { }; export const handlePanelPlugin = ( - { contentType, contentObject, duplicate, create, userPlugins }, + { contentType, contentObject, duplicate, create }, pluginInfo, + getPluginSettings, ) => { - const customLinksSettings = userPlugins?.find( - ({ id }) => id === pluginInfo.id, - )?.settings; - + const pluginSettings = getPluginSettings(); if ( !contentObject || !contentType?.name || create || duplicate || - !customLinksSettings + !pluginSettings ) return null; - const settingsForCtd = JSON.parse(customLinksSettings)?.settings?.filter( + const settingsForCtd = JSON.parse(pluginSettings)?.settings?.filter( (plugin) => plugin.content_types.length === 0 || plugin.content_types.find((ctd) => ctd === contentType.name), @@ -93,16 +91,11 @@ export const loadPanelPlugin = (pluginPanelPreviewRoot) => { contentObject: { id: 'id', name: 'co name' }, duplicate: false, create: false, - userPlugins: [ - { - id: 'plugin-id', - settings: - // eslint-disable-next-line max-len - '{"settings":[{"url_template":"example.com","link_template":"Link","content_types":[]}, {"url_template":"example.com","link_template":"Link to {name}","content_types":[]}]}', - }, - ], }, { id: 'plugin-id' }, + () => + // eslint-disable-next-line max-len + '{"settings":[{"url_template":"example.com","link_template":"Link","content_types":[]}, {"url_template":"example.com","link_template":"Link to {name}","content_types":[]}]}', ); element.style.border = '1px solid #DAE3F2'; From 319dd0c53b67892ef78a08f8d881ac8f70f15373 Mon Sep 17 00:00:00 2001 From: Dalia Date: Fri, 26 Sep 2025 18:52:18 +0200 Subject: [PATCH 2/2] bump version in package json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 62f7687..9287948 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "type": "module", "license": "MIT", - "version": "1.1.0", + "version": "1.1.1", "scripts": { "build": "node esbuild.config.js", "start": "node esbuild.config.js --watch"