Closed indigoxela closed 2 months ago
Additional benefit of the PR: mulitvalue fields now work properly (they actually didn't before). Downside: it's quite a change in logic.
But here we go: #6
Tested the PR. Able to apply the patch without difficulty. However, behaviour is unchanged from description in #3. Toggle still not working. No errors displayed. Only error in watchdog is
The imce/plugin.min.js is not present in the directory. This is was not a fresh install before patching. Can certainly do that to test.
Really no need to test a fresh install since there have been no new commits.
Is it possible that the last line of the tinymcebackport.api.php
file is interfering?
@izmeez hm. Are you using the Overlay? Never tested with that module, as that has always been the module I uninstalled first. :wink:
To be able to toggle you should enable multiple formats. An example for "foobar.module" (simplified):
function foobar_tinymcebackport_enabled_formats_alter(&$enabled_formats) {
$enabled_formats[] = 'full_html';
}
function foobar_tinymcebackport_options_alter(&$options, $format) {
if ($format == 'filtered_html') {
$options['plugins'] = 'autoresize image link lists';
$options['toolbar'] = 'bold italic blockquote bullist numlist outdent indent link unlink image';
}
elseif ($format == 'full_html') {
$options['plugins'] = 'accordion advlist autoresize charmap code codesample emoticons fullscreen help image imgalign imce link insertdatetime lists media searchreplace table visualblocks visualchars wordcount';
$options['toolbar'] = 'bold italic blockquote removeformat bullist numlist outdent indent alignleft aligncenter alignright link unlink image media accordion codesample fullscreen code';
$options['file_picker_types'] = 'file image media';
$options['menubar'] = TRUE;
}
}
Is it possible that the last line of the tinymcebackport.api.php file is interfering?
*api.php files are never executed nor even loaded. So, no that won't interfere.
Yes, I was using the overlay
module. Even with it off I have the same results.
When I try the suggestion in https://github.com/indigoxela/tinymcebackport/issues/5#issuecomment-2268223751 adding content opens with the filtered_html
option and fails to display a toolbar with full_html
option. On exit it shows Warning: Illegal offset type in _tinymcebackport_pre_render_text_format() (line 66 of /var/www/html/sites/all/modules/tinymcebackport/tinymcebackport.module).
The same appears when adding content, seeing the filtered_html
with toolbar and immediately exiting. This is with the patch applied to the tinymcebackport module.
Warning: Illegal offset type
Interesting, something on your setup seems to interfere. The weird thing is: there's no "type" in the code in line 66. Neither with, nor without the patch. My suspicion is, that something went wrong when applying the patch.
Can you revert all patches, then try to apply it cleanly? https://patch-diff.githubusercontent.com/raw/indigoxela/tinymcebackport/pull/6.diff
Reopening for possible feedback.
@izmeez to make testing easier, I merged the pull request. You can now just grab the latest dev, either via git or zip download, to test locally. Don't forget to flush caches, though, after replacing the module. :wink: And make sure, there's only one directory of "tinymcebackport".
@indigoxela Thank you. I have downloaded the latest zip. If my understanding is correct, the module as is does not provide two options to test the toggle. So with just the module as an admin selecting Filtered HTML
displays the small toolbar and selecting Full HTML
displays no toolbar.
When I enable my custom module the same behaviour is noticed and that is when the error shows up: Warning: Illegal offset type in _tinymcebackport_pre_render_text_format() (line 66 of /var/www/html/sites/all/modules/tinymcebackport/tinymcebackport.module).
Clearly, I must be doing something wrong. Here is the code in the module.
/**
* Implements hook_tinymcebackport_enabled_formats_alter().
*/
function fullformat_tinymcebackport_enabled_formats_alter(&$enabled_formats) {
$enabled_formats[] = array('full_html');
}
function fullformat_tinymcebackport_options_alter(&$options, $format) {
if ($format == 'filtered_html') {
$options['plugins'] = 'autoresize image link lists';
$options['toolbar'] = 'bold italic blockquote bullist numlist outdent indent link unlink image';
}
elseif ($format == 'full_html') {
$options['plugins'] = 'accordion advlist autoresize charmap code codesample emoticons fullscreen help image imgalign imce link insertdatetime lists media searchreplace table visualblocks visualchars wordcount';
$options['toolbar'] = 'bold italic blockquote removeformat bullist numlist outdent indent alignleft aligncenter alignright link unlink image media accordion codesample fullscreen code';
$options['file_picker_types'] = 'file image media';
$options['menubar'] = TRUE;
}
}
Any thoughts are welcome. Thank you.
I do wonder if it would be worth adding this functionality to the module itself and started to look at that as a possibility, but didn't have enough time to figure it out.
BTW, disabling the Overlay
module makes no difference.
@indigoxela Problem solved: The error was that the line: $enabled_formats[] = array('full_html');
should have been $enabled_formats[] = 'full_html';
as per your previous comment. So the toggle is working. Thank you.
@izmeez glad, you sorted things out with your setup. Many thanks for feedback, and especially for pointing me to the toggle problem in the first place. :+1:
New release is out! :tada:
@indigoxela Thank you for all your help and patience. I still think it would be a great feature to add the full editor option into the module itself.
If the TinyMCE editor's enabled on multiple formats, it's not possible to toggle between them. Or actually to toggle between different option sets, as only one (the default) is attached as js setting.
Additionally the logic relies on the element ID, which is quicksand when it comes to Drupal AJAX. :stuck_out_tongue_winking_eye: