-
Notifications
You must be signed in to change notification settings - Fork 572
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
Make WYSIWYG / TinyMCE / Editor field repeatable? #264
Comments
We haven't given up and we/I get asked very frequently. It's just a matter of getting the time. CMB2 is a (heavily used) side project for us, so we work on it when we can, and repeatable wysiwyg is at the top of the feature list roadmap. |
Thanks a lot for taking the time to answer! |
Just in case this helps, I have a repeatable group with a WYSIWYG editor as a field within that group and it works perfectly.
|
@adchsm does your new editor instantiate ok when you add it? I get a blank If I save the post and refresh it works fine, however. But ideally the tinyMCE instance would work immediately after duplicating. (Edit: I see it does work fine if you are in Text mode instead of Visual.) |
Yeah it works all ok for me. I can add multiple editors without the need to save/update. This is on WordPress 4.0 + 4.1 |
@adchsm Interesting. I wonder if it has to do with using Bedrock/Sage and/or using CMB2 as a plugin? It works fine if I'm editing in Text mode, but if it's set to Visual, the freshly-added editor is always broken. |
Are you using it as a plugin? I've built it into the theme. |
@adchsm yeah, I have CMB2 in mu-plugins using Bedrock's composer.json so I can easily keep it updated. Well, as long as I know it works for you duplicating editors in Visual mode, then it's something I need to track down on my own install. Thanks for the feedback. |
Fwiw, I downloaded a fresh Wordpress 4.1.1 install, copied CMB2 into the twentyfifteen theme directory, and just added this to functions.php:
...and it still behaves the same. I also realized that the Text mode isn't actually working, it was just showing the textarea, but the quickbar buttons don't work. |
I've seen this feature work in other frameworks (but they weren't as good as CMB2). I hope CMB2 will be maintained in the future (I'm going to poke the author again and he's going to think that I'm a really annoying person, sorry for that). @jtsternberg we need you. |
👍 |
@adchsm @natebeaty - did you manage to get anything working. I wonder if there is a way to get this to work (or any other plugin with repeatable wysiwyg) |
+1 for this feature, it would be very useful. |
I wasn't able to get it fully working. Right now you have to add a new block with some content (either switching to Text and typing in the wysiwyg area, or adding some content to another field in the new repeatable block) and save, then you can edit with the fully instantiated tinymce area in the new block. I also ran into a problem with the move-up and move-down buttons, as they don't support swapping wysiwyg areas. |
@natebeaty do you have a patch or code for your fixes ? what you have sounds much better than anything else. |
@sandys I am using default code. You can do basic repeatable wysiwyg fields, but the post just has to be saved before tinymce inits properly for editing in Visual mode. I looked into adjusting cmb.js to support the up/down arrows w/ wysiwyg areas, but my quick fixes didn't work and I don't have much time to work on this right now. |
@sandys You can take a look at C7 Form Builder. Being able to repeat any field (including editor and group field) is one of the features available. And, if anyone willing to implement repeatable editor fields in CMB, feel free to borrow code from my plugin. |
I started to debug this but ran out of time. The issue seems to reside in cmb2.js. Here's what I determined:
So this seems very fixable. Wish I could keep at it. Cheers and long live CMB2! Thanks a lot. |
I needed to hove a reapeatable group with a wisiwig field too, and all my custom field were already managed by cmb2 so I coulnd't change to something else without changing everything, so I manage something (not really clean i agree) with an other jquery plugin for wisiwig textarea. I post it here so maybe it can help until the feature exist in cmb2. |
@dnsJunior cool workaround, I was looking to fix this for a while now, would it be possible to have a look at your code. Thanks, |
Thanks for the amazing plugin @jtsternberg but in the meantime it would be great for me to implement @dnsJunior temporary fix. Thanks in advance. |
Where WYSIWYG tinyMCE doesn't initialize properly when added to the end of a repeater Group. Event works with tinyMCE enhancements like TinyMCE Advanced plugin for WordPress Changes in cmb2.js and cmb2.min.js
I've been having a look at this today to see if I can manage to at least get the editors working in groups. I implemented the steps that @wilrevehl talked about and fixed the tinymce.init call. The settings were being passed through to the 'id' element but I think that's incorrect (I'm by no means a TinyMCE expert though - so correct me if I'm wrong). Anyway, this has got me as far as the TinyMCE area now initialising but for some reason it is hidden so it looks as though it hasn't initialised even though that isn't the case. If you run this code, you'll notice that the element with a class of This change has also caused the tabs from letting you switch editors. I forked the repository and you can find the changes I made at: https://github.com/0Neji/CMB2/commit/0ad6616786ebbb8ed1206a413b02c5b16e1de7a4 Obviously, still miles away from an actual fix but I thought it might be a good idea to post it to see if it gives anyone else more ideas etc. I'll try to find more time to look again but hopefully this helps someone! |
You all might try testing this branch: https://github.com/WebDevStudios/CMB2/tree/repeat-wysiwyg wysiwyg is working in repeat groups, but only when adding groups. Removing groups is not working yet. |
Ah, interesting - I'll check that out. Thanks! |
Yeah, this is still a problem for me. I often need to have wysiwyg in repeatable group field, but I don't want to limit cmb2 to the branch mentioned in this thread. I would definitely vote to have it as a feature. |
I have submitted a pull request that fixes this issue. |
@johnsonpaul1014 thanks. |
Hi, not sure it’s the best to write here or open a new ticket… |
@synthview I noticed that also: #264 (comment) ... just told client to switch to text mode before sorting, but that's obviously not a great solution. |
@synthview WYSIWYG in repeatable groups is not supported. That's why this thread exists. Or are you referring to a different branch? |
well, in my case it seems to almost work, just I have to create a new group & save the (custom) post to make it load. BTW I’ve disabled the main content (the_content) form my posts |
I've got a new PR that could use testing, but should make wysiwyg in repeatable groups work as expected. For all interested, please review/test! |
Just found this patched version of the included .js which worked perfectly for me: |
@madebymartin Thanks, working perfectly for me, too. |
@madebymartin Thanks, it works, but only for init and saving. Sorting doesn't work. |
@slaFFik yes, it is now part of the trunk branch. |
@jtsternberg Tested, seems to be working fine. |
I'm working on finalizing some bits for the REST API, so once that's good to go, I'll be pushing an update. |
Just use trunk as is and carry on :) |
Already changed in |
Thank you all for your input and contributions. wywiwyg field-types should now work correctly in repeatable groups. From the changelog: |
This works smoothly but any pre code disappears in the CMB2 wysiwyg editor. In the visual editor, I add the html with > etc., and put a pre around it, just like in the regular visual editor and save then it's gone. If I do the same in just the text editor, it is fine as long as I don't switch back. Very odd. |
@carasmo I would suggest adding your own |
Hi, all. While the functionality of a repeating group with a WYSIWYG field works, has anybody solved the problem with it becoming very laggy when there are numerous editors in the page? Some people reported that it's laggy when you have 5 editors. Our team can have upwards of 15 or 20 or more groups, which causes there to be that many editors in the page. I've been trying to figure out a way to get the editors to lazy load, but haven't had a lot of success. Any ideas on how to solve the lagginess issue? |
@cooms13 your dilemma is exactly why it took so long for me to implement this feature. But we had a generous PR come in, so we got it in. I think if you're looking to do something like you are, unfortunately your best bet is going to be something custom-made until we have a better solution in core. You can also look through the available resources to see if there is anything that could help. |
@jtsternberg Thanks for your response. Are you saying that the PR that you integrated solves the problem of the page getting laggy when there are lots of editors? |
I believe the PR was already merged, and composed what we have now. However, that means that your usecase is still a bit on the heavy side for the topic. |
@cooms13 @tw2113 is right. I meant, I didn't want to necessarily tackle the problem by throwing a ton of editor instances on the page, but the solution that came in is better than not being able to use wysiwyg fields in groups at all, so this is what we have for now. One possible solution, we switch to a single editor instance when over X number of groups, and have an edit button next to the textarea which opens the content in a modal w/ that editor instance. |
Hi there,
I know this has been asked a couple of times, I just hope you didn't give up on this. I think it's very important for CMB2. To me it's pretty much the only thing that's missing. Apart from this, being a CMB2 user and having tried many other frameworks, you da best.
Keep up the great work.
NB: I'd be willing to pay for this feature. A lot.
The text was updated successfully, but these errors were encountered: