Hello,

I'd like to add a functionnality for the TextTrimmedFormatter to be able to add an ellipsis and / or word boundaries trim options.

Patch attached.

Issue fork drupal-2959924

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

B2F created an issue. See original summary.

b2f’s picture

StatusFileSize
new2.23 KB
new11.87 KB
b2f’s picture

b2f’s picture

Version: 8.5.1 » 8.5.x-dev
b2f’s picture

b2f’s picture

Patch updated with schema data.

b2f’s picture

b2f’s picture

StatusFileSize
new6.45 KB
b2f’s picture

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

anfor’s picture

Title: Adds elipsis and word boundaries (wordsafe) options to TrimmedText Formatter » Ellipsis and wordsafe options to TrimmedTextFormatter
Version: 8.6.x-dev » 8.7.x-dev
Issue summary: View changes
Status: Active » Needs work
StatusFileSize
new6.29 KB
new6.97 KB

I rerolled the patch on 8.7.x branch and made some changes.

I put back the issue to "Needs work", since tests coverage isn't done.
And more importantly, I think it might be best to create a custom Formatter.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

aporie’s picture

Subscribed.

Don't think it's best to create a new custom formatter. This option could ship with the default core TextTrimmedFormatter as I don't see any cases where you want to trim your content without having the possibility to add ellipsis. (You see what I m...).

Just tested #12 on 8.9.8, works well.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

alexandre.todorov’s picture

Hi,

Here is a rerolled patch for branch 9.1.x with the following improvements :

  • The text_summary() function uses "breakpoints" trim which will remove the ellipsis. So append the ellipsis after the "breakpoints" trim.
  • The "breakpoints" trim already include word boundary as it is a trim on "end of" paragraph, line or sentence. There is no effect if the "wordsafe" option is set or not. So add settings to choose if we want to trim on breakpoints or not.
  • Add also a "Form API" states as "user helper" to choose only one of the "breakpoints" or "wordsafe" trims.
alexandre.todorov’s picture

Add the ellipsis (if needed) when using the delimiter

alexandre.todorov’s picture

FYI the same patch as #20, but without indentation for simpler reading

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

karltud123’s picture

+1

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

chike’s picture

How different is this from what Smart Trim offers?

fskreuz’s picture

_utsavsharma’s picture

StatusFileSize
new3.34 KB
new13.35 KB

Tried to fix CCF for #27.
Please review.

_utsavsharma’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 28: 2959924-28.patch, failed testing. View results

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

fskreuz’s picture

Reroll of #21 for 10.2.x.

Added both indent and no-indent versions, since the files involved are frequently modified by updates. The indented version is the one meant to be merged, while the no-indent version is for easy composer patching.

nod_’s picture

Can we have an MR for this?

immaculatexavier made their first commit to this issue’s fork.

nod_’s picture

Status: Needs work » Needs review

thx

nod_’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

fskreuz’s picture

Rebased to latest main branch. Hiding the older patches. Probably needs tests, leaving as Needs Work.