We would like to use BUEditor with this. We've created a submodule that integrates with a patch we made for bueditor.

See https://www.drupal.org/project/bueditor/issues/3065729.

I'll attach this submodule as a patch here.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damontgomery created an issue. See original summary.

damontgomery’s picture

Here is the submodule.

damontgomery’s picture

Status: Active » Needs review
kbentham’s picture

Thanks for creating this patch Dan!

a.dmitriiev’s picture

Thanks, very useful submodule.

I will review it tomorrow.

a.dmitriiev’s picture

What are the chances that the patch from the issue in description will go in?

damontgomery’s picture

Status: Needs review » Needs work

Thanks, a.dmitriiev.

I think it makes sense to move all the code into this submodule. I've described some of the reasoning in https://www.drupal.org/project/bueditor/issues/3065729#comment-13176005.

I should have some time later this week to try this.

Thanks again.

damontgomery’s picture

Status: Needs work » Needs review
FileSize
6.27 KB

I've attached a patch which moves all of this functionality into this sub module. This should make maintenance hopefully easier. As discussed, the token pattern is a little specific to this module, so I think the sub module makes sense.

I've used the general structure of the BUEditor functions, particularly those with the HTML Tag support, but removed a lot of the extra parts that were unused. I've also renamed some of the functions and tried to adhere to Drupal JS coding standards.

The structure of the JS is as follows:

A `tokenDialog` is created using the `createTokenDialog` function. This is then opened.

The `tokenDialog` contains a token form which is created with `createTokenForm`. The fields defined in `createTokenDialog` are processed into the form fields with `processTokenField`.

A submit function is created, `submitTokenForm` which converts the form to a string which is inserted into the editor. This uses `getTokenObjectFromTokenForm` and `getTokenStringFromTokenObject`.

We could probably combine a few of these steps, but this maintains most of the pattern from BUEditor.

damontgomery’s picture

Here is a new patch with clearer variable names and some of the weird for loop logic stated more explicitly.

a.dmitriiev’s picture

The patch was applied to latest dev branch. I would also like to know if it is possible to have the list of views in the dialog selectable? Because the filter supports restriction of the views that are allowed, would be nice to make the dialog more user friendly. Also, could you please find the icon for the button in the toolbar? Maybe use the same that is in the main module?

I also moved the module to modules/bueditor folder, to have the structure more clean.

Thank you very much for your contribution, I hope the changes described above would be also implemented.

a.dmitriiev’s picture

Status: Needs review » Fixed
damontgomery’s picture

Thanks, a.dmitriiev!

We're working on BUEditor for a bit and I'll keep those suggestions in mind. They are very helpful. We are currently trying to figure out how to implement autocomplete for nodes and blocks in BUEditor and I may be able to use something similar to provide dropdowns for the views.

a.dmitriiev’s picture

damontgomery, maybe before this is implemented, you can do a simple dropdown that will be populated with the values from drupalSettings object (the object itself will be populated from the module from filter settings)? I am willing to help to provide the data in drupalSettings, so you can take care of bueditor part. How does this sound to you?

damontgomery’s picture

Thanks. I'm working on this for the rest of the week and can provide an update on what I find. If you want to try a drupalSettings approach, that might work for this. That won't work for the autocomplete solution which might need a custom route. A custom route might be a good approach for this as well, essentially provide a public route that the JS can access that is safe enough and provides a list of views, etc to construct a dropdown.

damontgomery’s picture

TLDR: I have made progress on related work and may be able to revisit this next week.

I have been able to create a BUEditor plugin that uses Drupal fields.

The approach is to use a custom route / controller to generate a JSON response of the field markup. This JSON is pulled in with the BUEditor plugin JS and the fields are then prepended to the form element before it is added to the popup.

By including the libraries needed in the BUEditor plugin, I can use features like autocomplete.

In this situation, I can generate a select box with the various views and view modes and then use those results to generate the string. The submit handler has access to the form, so by adding classes, it's easy enough to process the form using JS / jQuery.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

damontgomery’s picture

I apologize for the long delay without any updates. I don't think I'll be able to update the approach in this module.

a.dmitriiev’s picture

No problem, I will try to use maybe drupalSettings and get the dropdowns as a start. I will create another issue.