- Issue created by @mortona2k
- First commit to issue fork.
I get the same error, but only in combination with the CKEditor 5 Plugin Pack β module.
- πΊπΈUnited States swirt Florida
I am seeing this same issue and not related to CKEditor5_plugin_pack
- πΊπΈUnited States swirt Florida
Our current config prior to 10.3 has this
shortcode: id: shortcode provider: shortcode status: true weight: -50 settings: nhd: '1' irf: '1' ltch: '1'
The complaint is that
'nhd' is not a supported key. 'irf' is not a supported key. 'ltch' is not a supported key.
What I am not clear on is what the new structure of the config should be.
- πΊπΈUnited States swirt Florida
I tried commenting out the validation to see if I could save the form and export the config to see if the config would take on a different structure. It did not.
The problem seems to be that the file
/Drupal/Core/Validation/Plugin/Validation/Constraint/ValidKeysConstraintValidator.php validate()
went through significant refactoring in 10.3 and broke it for shortcode. - πΊπΈUnited States swirt Florida
The problem is that this line
$dynamically_valid_keys = $mapping->getDynamicallyValidKeys();
is not grabbing the dynamic keys that are in the settings. So they are not present.
- πΊπΈUnited States swirt Florida
I believe the shortcode module needs to declare a schema for the settings similar to the way other filter plugins declare them.
https://api.drupal.org/api/drupal/core%21modules%21filter%21config%21sch... We are using the shortcode module without the base tags, but we have a custom module that uses the shortcode API.
I am trying to implement the configuration scheme as follows:
filter_settings.shortcode_plugin: type: mapping label: 'Shortcode Plugin' mapping: shortcode_plugin: type: boolean label: 'Provides a shortcode plugin.'
It's not enough to implement the schema. We have to edit the plugin file (*Shortcode.php), because of the configuration section.
use Drupal\Core\Language\Language; use Drupal\shortcode\Plugin\ShortcodeBase; /** * The image shortcode. * * @Shortcode( * id = "button", * title = @Translation("Button"), * description = @Translation("Insert a link formatted like a button.") * ) */ class ButtonShortcode extends ShortcodeBase { ...
- π«π·France jverneaut
Like #10, I'm using the shortcode module without the basic tags. After some trial and error, I was able to get the provided shortcode_example module to work by adding the following minimal configuration at
shortcode_example/config/schema/shortcode_example.schema.yml
wherecol
is the name of its defined shortcode:filter_settings.shortcode: type: mapping mapping: col: type: boolean
It is therefore possible to add configuration mappings to the base shortcode module from custom shortcode modules which was a sufficient fix in my case to be able to save the text formats.
- πΊπΈUnited States mortona2k Seattle
@jverneaut I think the issue is needing to determine the schema dynamically, or populating default values for unused parameters.
All the shortcode plugins have their own parameters. Are we able to add all the optional parts to the main schema, or does it only work when you explicitly match the schema file with the plugins in use?
It seems like we need a way to dynamically alter schema?
- πΊπΈUnited States swirt Florida
When I was xdebugging some of this I noticed there support for a pattern that is 'settings.*' that other plugins were using. I interpreted that as being essentially allow any settings. Which I think, like mortana2k is suggesting, it a bit more dynamic. I had to step away from this for a bit, so I did not chase that farther.
- π«π·France jverneaut
I dug a little deeper and found in the configuration schema docs β that the appropriate type for configuration objects with unknown keys is actually
sequence
, I then tried to create a configuration file at/config/schema/shortcode.schema.yml
at the root of the base shortcode module with this content and I can then save text formats successfully and the config gets correctly exported.filter_settings.shortcode: type: sequence sequence: type: boolean
- πΊπΈUnited States swirt Florida
Sadly I am away from my machine and can't test this but it seems like the right fix. Nice digging jverneaut.
- Status changed to RTBC
about 2 months ago 1:42am 13 July 2024 - πΊπΈUnited States swirt Florida
I was able to test this using simplytest.me and applying the patch
- simplytest.me using 10.3.1 and shortcode 2.2 plus patch 14
- enabled shortcode basics
- went to full html filter
- enabled all shortcodes
- was able to save the settings without errors
Nicely done jverneaut. Thank you. Changing to RTBC
- πΊπΈUnited States swirt Florida
And on a side note, Welcome to Drupal jverneaut. You've been on Drupal.org for less than 15 hours and already have a successful patch submitted. That is pretty impressive. Cheers.
Thank you jverneaut. The patch is working like a charm. I was able to save the settings without errors, and the shortcodes are working as expected.
- First commit to issue fork.
- πΊπΈUnited States nicxvan
I had to apply this patch and add this file:
web/modules/custom/custom_shortcode/config/schema/custom_shortcode.schema.yml
Then for each custom shortcode I need the following:
filter_settings.shortcode: type: mapping mapping: custom-shortcode: type: boolean
- π©π°Denmark Steven Snedker
I'm very impressed with the solution in #14. Repaired the upcoming version of Wayback Filter β as well. Thank you, Julien.
-
Denes.Szabo β
committed 01c7023a on 2.0.x
Issue #3457731 by nicxvan, jverneaut, swirt, mortona2k, vincent.hoehn,...
-
Denes.Szabo β
committed 01c7023a on 2.0.x
- Assigned to Denes.Szabo
- Status changed to Fixed
about 1 month ago 11:49am 29 July 2024 - ππΊHungary Denes.Szabo Hungary
Thank you guys, nice improvement! Merged.
- Status changed to Fixed
about 1 month ago 11:49am 29 July 2024