Forum Replies Created
-
AuthorPosts
-
Grzegorz Sidor
ParticipantGrzegorz Sidor
ParticipantOctober 25, 2024 at 7:29 PM in reply to: ✅WYISWG editor do not work inside nested group on some instances #46766Grzegorz Sidor
ParticipantNo one will even reply to this unique ID name solution? When can we expect an update? This is a critical bug for me and more and more customers are reporting this issue to me.
October 17, 2024 at 10:33 PM in reply to: ✅WYISWG editor do not work inside nested group on some instances #46715Grzegorz Sidor
ParticipantI found a much better solution. In the file /meta-box-aio/vendor/meta-box/meta-box-group/group-field.php just add uniqid() to the return of the static function child_field_id().
This will give each field a unique id even before the wysiwyg is called.
/** * Change child field attribute id to from 'id' to 'parent_id'. * * @param array $parent Parent field. * @param array $child Child field. * * @return string */ protected static function child_field_id( $parent, $child ) { if ( isset( $child['attributes']['id'] ) && false === $child['attributes']['id'] ) { return false; } $parent = isset( $parent['attributes']['id'] ) ? $parent['attributes']['id'] : $parent['id']; $child = isset( $child['attributes']['id'] ) ? $child['attributes']['id'] : $child['id']; return "{$parent}_{$child}_".uniqid(); }And there are no such delays by re-rendering wysiwyg.
This should also solve the problem with other field types.
October 17, 2024 at 7:57 PM in reply to: ✅WYISWG editor do not work inside nested group on some instances #46713Grzegorz Sidor
ParticipantI found a temporary solution, but it slows down the editing page. It turns out that the ids for texarea for wysiwig are not created correctly.
<textarea class="rwmb-wysiwyg wp-editor-area valid" rows="20" autocomplete="off" cols="40" name="sw_c_row[6][sw_c_col][1][sw_c_content]" id="sw_c_col_sw_c_content" aria-invalid="false"><div class="h-4 h-lg-1">34 lata wyzwań nauczyły nas, jak być lepszą organizacją, budować silną markę i wspierać naszych partnerów. Poznaj nasza historię.</div></textarea>In this case I have a clonable group in a clonable group. The textarea gets an id without the name of the parent group and without its sequence number. This creates multiple textarea with the same id, from which wysiwyg is called. Since multiple textarea have the same id, wysiwyg does not start fully for them.
I solved this problem by modifying the wysiwyg.js script for the meta-box.
/meta-box/js/wysiwyg.js
In the file for the transform() function I added a line so that the isInBlock variable always has the value true, which changes the id to unique.function transform() { var $this = $( this ), $wrapper = $this.closest( '.wp-editor-wrap' ), id = $this.attr( 'id' ), isInBlock = $this.closest( '.wp-block, .components-panel' ).length > 0; isInBlock=true; // Update the ID attribute if the editor is in a new block. if ( isInBlock ) { id = id + '_' + rwmb.uniqid(); $this.attr( 'id', id ); } ...and in the load function I changed the re-render condition to fire not only for Gutenberg
// Force re-render editors in Gutenberg. Use setTimeOut to run after all other code. Bug occurs in WP 5.6. if ( rwmb.isGutenberg ) { setTimeout( () => $editors.each( transform ), 200 ); }else{ setTimeout( () => $editors.each( transform ), 20 ); }unfortunately this forces a re-render for each wysiwyg, which increases the time it takes to load them. But at least it works until a better solution is found.
Grzegorz Sidor
ParticipantHas anyone solved this problem? Because I have one that works in one clonable group, but when I want to add another clonable group to the clonable group, then wysiwig doesn't start in it. You can only click the text tab and refresh the page. Only then can you edit the content, but no buttons appear anyway.
-
AuthorPosts