How to Create a Plugin with Modal-based Marks?

Iā€™m developing a DatoCMS plugin to enhance multilingual accessibility in structured text fields using customMarksForStructuredTextField. The plugin needs to implement a custom mark that, similar to the native ā€˜Add Linkā€™ functionality, opens a modal dialog for capturing language-specific metadata. Specifically, Iā€™m looking to:

  • Create a custom mark that triggers a modal interface

  • Capture language attributes and accessibility metadata through the modal

  • Persist these attributes within the structured text fieldā€™s mark system

  • Implement a UI pattern similar to DatoCMSā€™s native link handling

Could you provide guidance on implementing this?

Hey @jessie.morin,

Welcome to the forum!

Unfortunately, I donā€™t think our structured text customizations allow quite this level of functionality inside our editor :frowning: It could be a feature request here on the forum.

However, maybe you can get similar enough functionality by linking to another record first instead of a URL, and then putting that other metadata inside the other record? For example, Iā€™ve made a new model called ā€œLocalized Links with Metadataā€:

Allow it as a link in the structured text field of the first model:

Then when you add a link in the structured text field:

And you can set different data for different locales:

Then you get back as a GraphQL response:
(English)

(Spanish)

Would that work for you?

1 Like

Thank you for the suggestion. While this approach could serve as an interim solution, Iā€™m specifically focused on optimizing the content management workflow for our editorial team by minimizing direct code intervention.

To clarify my requirements: Iā€™m looking to implement functionality similar to the native ā€˜Add Linkā€™ markā€™s modal interface, but with a different purpose. Rather than managing hyperlinks, this implementation would facilitate language attribution for multilingual content elements (such as business names or culturally-specific terms) within our content. Ideally, the modal would present a select interface populated with our siteā€™s supported languages, allowing editors to efficiently tag content segments with appropriate language metadata.

I recognize this specific functionality isnā€™t currently available. Iā€™ll be submitting a feature request to address this use case, as it would benefit organizations managing multilingual content through DatoCMS.

I appreciate your assistance in exploring potential solutions.

1 Like

Thank you for the detailed response! I really appreciate the thoughtfulness.

I see the feature request nowā€¦ and thank you for voting on it too :slight_smile: Modal Support for Custom Marks in Structured Text Fields - #2 by christine.daneau.pelletier