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

Getting wrong textContent and characterCounts when i press enter #1281

Closed
csainath07 opened this issue May 6, 2021 · 3 comments
Closed

Getting wrong textContent and characterCounts when i press enter #1281

csainath07 opened this issue May 6, 2021 · 3 comments
Labels
Type: Bug The issue or pullrequest is related to a bug

Comments

@csainath07
Copy link

csainath07 commented May 6, 2021

Description
I'm trying to calculate characters and word count but whenever I press Enter my last word and new word are concatenate which causes the wrong word counts and every time I press Enter my characterCount incremented by 2 which should be 1 (I think so)

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. write n number of words and press Enter
  2. start writing again

CodeSandbox
I created a CodeSandbox to help you debug the issue: Code Sand Box

Expected behavior
when I press Enter it should consider as space (the last word should not concatenate with the new word)

Screenshot, video, or GIF
image

Environment?

  • operating system: mac0s - big sur
  • browser: firefox
  • mobile/desktop: desktop
  • tiptap version: v2 beta

Additional context
I'm referring to this
@tiptap Doc

@csainath07 csainath07 added Type: Bug The issue or pullrequest is related to a bug v2 labels May 6, 2021
@atulmy
Copy link

atulmy commented May 18, 2021

Same here:
Screenshot 2021-05-18 at 4 13 41 PM

blocks should be appended in textContent beginning with a space.

@martinthenth
Copy link

I have the character count problem too, described in #1049

@philippkuehn
Copy link
Contributor

There is another way of getting text content

const from = 0
const to = editor.state.doc.content.size
const text = editor.state.doc.textBetween(from, to, ' ')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug The issue or pullrequest is related to a bug
Projects
None yet
Development

No branches or pull requests

4 participants