Skip to content
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

editor: count chars and words in textarea #370

Merged
merged 1 commit into from
Apr 13, 2021
Merged

editor: count chars and words in textarea #370

merged 1 commit into from
Apr 13, 2021

Conversation

sebdeleze
Copy link

  • Adds counters in textarea for chars and words, depending on the configuration.
  • Avoids to exceed the counts when typing.
  • Checks for new resource context to avoid pid to be set in model.

Co-Authored-by: Sébastien Délèze sebastien.deleze@rero.ch

@sebdeleze sebdeleze marked this pull request as ready for review March 26, 2021 12:10
Copy link
Contributor

@Garfield-fr Garfield-fr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reformat the html part template

Comment on lines 51 to 43
<ng-container
*ngIf="
field.templateOptions.limitChars || field.templateOptions.displayChars
"
>
<span class="small text-muted d-inline-block"
>{{ 'Number of chars' | translate }}: {{ countChars
}}<ng-container *ngIf="field.templateOptions.limitChars">
/ {{ field.templateOptions.limitChars }}</ng-container
></span
>
</ng-container>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you don't use ng-template with a parameter display only with values word or char

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand, could you be more precise, please?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I changed the way to handle this.

@sebdeleze
Copy link
Author

@zannkukai, @Garfield-fr I use prettier for formatting with printWidth configuration to 80 (default value). And that's the result... Which formatter are you using?

@zannkukai
Copy link
Contributor

zannkukai commented Mar 30, 2021

@zannkukai, @Garfield-fr I use prettier for formatting with printWidth configuration to 80 (default value). And that's the result... Which formatter are you using?

@sebastiendeleze We don't use a 80 characters line limit in angular projects. Isn't it ?
For me this code isn't readable for an human

      <span class="small text-muted d-inline-block"
        >{{ 'Number of chars' | translate }}: {{ countChars
        }}<ng-container *ngIf="field.templateOptions.limitChars">
          / {{ field.templateOptions.limitChars }}</ng-container
        ></span
      >

It seems (always for me) better to write

<span class="small text-muted d-inline-block">
    {{ 'Number of chars' | translate }}: {{ countChars }}
    <ng-container *ngIf="field.templateOptions.limitChars">
         / {{ field.templateOptions.limitChars }}
    </ng-container>
</span>

At least have the > on the same line than the tag

@sebdeleze sebdeleze requested a review from Garfield-fr April 12, 2021 06:25
@Component({
selector: 'ng-core-editor-formly-field-textarea',
template: `
<textarea
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be in a separate file.

* Adds counters in textarea for chars and words, depending on the configuration.
* Avoids to exceed the counts when typing.
* Checks for new resource context to avoid `pid` to be set in model.

Co-Authored-by: Sébastien Délèze <sebastien.deleze@rero.ch>
@sebdeleze sebdeleze merged commit dfb9a27 into rero:dev Apr 13, 2021
@sebdeleze sebdeleze deleted the sed-textarea-count-chars branch April 13, 2021 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants