Hi,
Is there plans to introduce D8 version of this module?
We (@InternetDevels team) would like to help you with development of this version.
Thanks, @ipo4ka704 and (@Rumato).

Comments

dragonwize’s picture

I have not had the time for a D8 version, nor do I know exactly when I will, so any help by those that like the features would be great.

ipo4ka704’s picture

Ok I will start. Later I will give a patch.

daylioti’s picture

Status: Active » Needs review
StatusFileSize
new24.37 KB

We (@InternetDevels team) have ported module and made a patch.
We plan to maintain this module in the future and want to get the maintainers.

dragonwize’s picture

Thanks daylioti. I would like to get some reviews before committing this.

As for maintainership, since you are new to the Drupal community and not yet an approved Drupal full projects (https://drupal.org/node/1011698), it would be best for you to see this patch through and help in the issue queue to learn about the community and the module more in depth before taking on the responsibility of a top 100 module. After that I can sponsor you to get your access and become a maintainer.

Thanks again for all your hard work. I hope this can turn into and awesome future for Better Formats.

berdir’s picture

Status: Needs review » Needs work

This is obviously quite out of date, but here's a quick review to get this started again if someone is interested in working on ths.

  1. +++ b/better_formats.info.yml
    @@ -0,0 +1,6 @@
    +version: VERSION
    

    this is reserved for core modules, just leave it out.

  2. +++ b/better_formats.install
    --- /dev/null
    +++ b/better_formats.local_tasks.yml
    

    File name has changed since then.

  3. +++ b/better_formats.module
    @@ -1,14 +1,10 @@
     function better_formats_permission() {
    

    hook_permission is now a yaml file + callback for dynamic stuff, which this will need.

  4. +++ b/better_formats.module
    @@ -21,47 +17,16 @@ function better_formats_permission() {
    +    if ($info->isFieldable()) {
    

    isFieldavble() is gone, what you want instead I think is check for FieldableEntityInterface of getClass()

  5. +++ b/better_formats.module
    @@ -112,12 +77,12 @@ function better_formats_filter_process_format($element) {
    -    $instance_info = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
    -    $bf = isset($instance_info['settings']['better_formats']) ? $instance_info['settings']['better_formats'] : NULL;
    +    $instance_info =  \Drupal\field\Field::fieldInfo()->getInstance($element['#entity_type'], $element['#bundle'], $element['#field_name']);
    +    $bf = $instance_info->getSetting('better_formats');
    

    This stuff will need to be updated for sure, the easiest way get the the field definition/settings is $entity->getFieldDefinition($name)->getSetting()

  6. +++ b/lib/Drupal/better_formats/Form/SettingsForm.php
    @@ -0,0 +1,33 @@
    +<?php
    +
    +namespace Drupal\better_formats\Form;
    +use Drupal\Core\Form\ConfigFormBase;
    +
    +class SettingsForm extends ConfigFormBase {
    +
    +  public function getFormId() {
    +    return 'better_formats_admin_settings_form';
    +  }
    +
    

    coding standards: missing documentation

    Needs a new method now that returns which config files are edited here.

colan’s picture

Does this overlap with Allowed Formats at all?

justachris’s picture

Yes, Allowed Formats seems to have a subset of the functionality of Better Formats. Basically the d7 version of the Better Formats module is allowed format selection + format ordering in the select box + hiding tips and help link. There's also an extra bit about updating the default format for entities where the field has not been set yet. fields without having the set a default value first.

Also there are a couple of issues in the queue for allowed formats that would provide further overlap if completed:
#2617982: Control "About text formats" link and inline text format guidelines
#2629618: Allow to hide text format help text for Text(formatted)

justachris’s picture

Status: Needs work » Needs review
StatusFileSize
new37.76 KB
new28.16 KB

Updated version of a D8 port addressing comments from #5 and changes in core since then. Should be functional with 8.0.0/8.0.1, matching functionality found in D7. The patch is off of the 7.x-1.x branch like the previous patch.

There is still plenty of testing and code updating to be done (noted a few @todo's in code). Adding some automated tests would also be helpful. Setting to Needs Review so others can look at and test this version.

dasjo’s picture

Title: Drupal 8 version » Drupal 8 version of Better Formats
krlucas’s picture

Status: Needs review » Needs work

Just a quick once-over of the patch in #8 with some very minor things. Awesome job! Hopefully I'll get to do some real testing in a bit.

  1. +++ b/better_formats.module
    @@ -203,12 +158,39 @@ function better_formats_filter_process_format($element) {
     function better_formats_text_format_sort($a, $b) {
    
    @@ -231,37 +215,38 @@ function better_formats_form_field_ui_field_edit_form_alter(&$form, &$form_state
    +  // Plain Text Format should not be an options, that is a separate field type.
    

    Typo. "option" not "options".

  2. +++ b/better_formats.module
    @@ -77,24 +25,36 @@ function better_formats_element_info_alter(&$type) {
       // user is not allowed to make any changes to this field. (This will happen
       // if the user does not have permission to use the currently-assigned text
    -  // format.)
    +  // format).
    

    It's grammatically correct for the period to be inside the parens because it's a complete sentence that started inside of them. That said I would just remove the parentheses.

  3. +++ b/better_formats.module
    @@ -107,34 +67,29 @@ function better_formats_filter_process_format($element) {
    +      $options = array();
    
    @@ -203,12 +158,39 @@ function better_formats_filter_process_format($element) {
    +  if (in_array($type, array('text', 'text_long', 'text_with_summary'), TRUE)) {
    
    @@ -231,37 +215,38 @@ function better_formats_form_field_ui_field_edit_form_alter(&$form, &$form_state
    +    $bf_settings = $entity->getThirdPartySettings('better_formats') != NULL ? $entity->getThirdPartySettings('better_formats') : array();
    

    We can use short array syntax now ([]) and while not an official coding standard or even a official "preference" I'm seeing it as a preference around D8. Definitely other instances.

  4. +++ b/better_formats.module
    @@ -107,34 +67,29 @@ function better_formats_filter_process_format($element) {
    +      dpm("A");
    

    Debug code.

justachris’s picture

StatusFileSize
new39.28 KB
new11.04 KB

@krlucas thanks for reviewing the code, updated from your comments.
The discussion on the array short syntax is here: #2135291: [Policy, no patch] PHP 5.4 short array syntax coding standards for Drupal 8, not an official preference yet, but I agree we can update these here. Updated the other instances of array() in this module port since I think we should at least be consistent. There were only a dozen or two instances, so not a big impact.

I did notice a bug with this implementation when using a formatted text field in Views. If you add an Global: Text Area for "No Results Behavior" for example, you will get an error similar to:
PHP Fatal error: Call to undefined method Drupal\views_ui\Form\Ajax\ConfigHandler::getEntity() in better_formats/better_formats.module on line 37

Will take a look at this soon, I'm pretty sure I know what is going on here.

dragonwize’s picture

Thanks for the hard work here everyone. When it is ready mark it Reviewed and Tested and I will commit it. Or if someone is interested in continuing with support I can add maintainers.

justachris’s picture

Status: Needs work » Needs review
StatusFileSize
new6.9 KB
new41.84 KB

Addressing a few things here in this port update:

  • Resolved above bug regarding the use of format selection in a Views UI config element.
  • Updated selection logic at top of process_format() function to reference the type of the form object. This also allowed resolution on the above Views issue since only format selection in ContentEntityForm and FieldConfigEditForm are modified.
  • Updated logic in hook_element_info_alter() to place our processing function directly following TextFormat::processFormat()
  • Updated logic surrounding default format selection. Default values during form build is handled differently than in D7, so additional functionality was needed.
  • Added a configuration schema file
  • Better handled configuration settings on SettingsForm::submitForm()

dragonwize’s picture

Status: Needs review » Fixed

Thanks to all for the work here. I created a 8.x branch and committed what the latest patch by justAChris. Let's continue the rest of the port in separate issues.

Status: Fixed » Closed (fixed)

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