Tinymce up - #74
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 25eaa399b6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| public function getParent(): string | ||
| { | ||
| $this->jsPath = $jsPath; | ||
| return TextareaType::class; | ||
| } |
There was a problem hiding this comment.
Restore the
tinymce form block prefix
Without a getBlockPrefix() override, Symfony derives tiny_mce from TinyMCEType, so it searches for tiny_mce_widget; the registered form theme only defines tinymce_widget. Consequently every TinyMCEType falls back to the parent textarea widget and never emits the configuration attributes or runtime script. Restore the previous tinymce prefix or rename the Twig block accordingly.
Useful? React with 👍 / 👎.
| composer require helios-ag/fm-tinymce-bundle | ||
| composer run copy-tinymce-assets |
There was a problem hiding this comment.
Register the copy script in consuming projects
After the documented composer require, this bundle is a dependency and its scripts section is not imported into the application's root package, so the next command fails with Script "copy-tinymce-assets" is not defined and no TinyMCE assets are installed. Composer's scripts documentation states that only scripts defined in the root package are executed; the installation instructions must have consumers register the callback in their root composer.json, or expose it through a mechanism available to dependencies.
Useful? React with 👍 / 👎.
|
|
||
| unset($options['file_picker_callback'], $options['license_key'], $options['selector']); | ||
|
|
||
| $options['base_url'] = $this->packages->getUrl($this->basePath); |
There was a problem hiding this comment.
Strip asset versions from TinyMCE's base URL
When the application's Symfony asset package uses a query-string version strategy, getUrl($this->basePath) returns a value such as /assets/tinymce?v=2. TinyMCE appends theme, icon, model, and plugin paths to base_url, producing invalid URLs with the query string in the middle of the path; the removed helper explicitly stripped this query component. Keep versioning on the script URL, but normalize base_url to the directory URL before passing it to TinyMCE.
Useful? React with 👍 / 👎.
|
|
||
| {% if tiny_mce_inline %} | ||
| <textarea {{ block('widget_attributes') }} hidden>{{ value }}</textarea> | ||
| <div id="{{ id }}_editor" contenteditable="true" data-fm-tinymce-inline-target="{{ id|e('html_attr') }}" data-fm-tinymce-options="{{ configuration|e('html_attr') }}" data-fm-tinymce-script="{{ script_path|e('html_attr') }}">{{ value }}</div> |
There was a problem hiding this comment.
Initialize inline content from the hidden value
For an inline profile whose existing value contains HTML, Twig auto-escapes that value inside the editable <div>, so TinyMCE starts with literal text such as <p>text</p> rather than the original paragraph markup. Once the editor changes, the synchronization code serializes those escaped tags back into the hidden textarea and corrupts the stored content. Keep the safe escaped rendering, but seed TinyMCE from the hidden textarea's decoded value during initialization.
Useful? React with 👍 / 👎.
| editor.on('change input', () => { | ||
| hiddenTarget.value = editor.getContent(); | ||
| }); |
There was a problem hiding this comment.
Synchronize inline content on form submission
Inline fields update their submitted textarea only for TinyMCE's change and input events. If content is changed through editor.setContent(), a plugin command, or another operation that does not emit either event before an immediate native submission, the hidden textarea retains its previous value and stale data is submitted. Attach a form-submit synchronization hook in addition to these incremental event handlers.
Useful? React with 👍 / 👎.
| if (isset(self::REMOVED_PLUGINS[$plugin])) { | ||
| throw new InvalidConfigurationException(sprintf('The "%s" plugin is not available in TinyMCE 8: %s.', $plugin, self::REMOVED_PLUGINS[$plugin])); | ||
| } |
There was a problem hiding this comment.
Reject the removed
modern theme
When a migrated configuration places theme: modern under options, this validator accepts it and the builder forwards it unchanged, but TinyMCE 8 no longer ships the modern theme; initialization then attempts to load a nonexistent theme and the editor fails. Reject this known legacy value during container compilation just as removed plugins are rejected, matching the upgrade guide's instruction to remove it.
Useful? React with 👍 / 👎.
No description provided.