Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call link/image plugins on the correct tiny6 instance #1352

Merged
merged 2 commits into from
Oct 31, 2023

Conversation

petschki
Copy link
Member

@petschki petschki commented Oct 30, 2023

fixes #1351

@petschki
Copy link
Member Author

@mauritsvanrees I've tested this with collective.easyform edit schema ... there are 4 TinyMCE instances (default and "thank you page" tab). Now the Link and Image Modals behave correct.


// image plugin
// eslint-disable-next-line no-unused-vars
tinymce.PluginManager.add("ploneimage", (editor, url) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like that these plugins are added globally to the imported tinymce module.
But as long as it works this code is OK to me.

Copy link
Member Author

@petschki petschki Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in fact a restore of the original plugin registration from the 5.1.x branch here: https://github.com/plone/mockup/blob/5.1.x/src/pat/tinymce/js/links.js#L347 ... due to the fact, that in Tiny6 you cannot inject custom methods on initialization anymore, I changed the onAction caller to simply fetch the instantinated tinypattern from the DOM and call its add(Link|Image)Clicked method.

There might be a more "tinyish" way to use the new EditorOptions API and register a custom callable object for this (see https://www.tiny.cloud/docs/tinymce/6/apis/tinymce.editoroptions/) but I thought its also feasible to use patternslib API for now.

@thet
Copy link
Member

thet commented Oct 31, 2023

One remark though ^^

@petschki petschki merged commit ee29f33 into master Oct 31, 2023
3 checks passed
@petschki petschki deleted the petschki-fix-linkplugin branch October 31, 2023 13:40
@mauritsvanrees
Copy link
Sponsor Member

Sorry, I am slightly too late testing it.
Trying it with plone.staticresources master (which contains these mockup changes), I confirm it works again.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TinyMCE 6: image upload always goes to first rich text field
3 participants