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

fix textarea newline handle #32966

Merged
merged 7 commits into from
Dec 25, 2024
Merged

fix textarea newline handle #32966

merged 7 commits into from
Dec 25, 2024

Conversation

metiftikci
Copy link
Member

@metiftikci metiftikci commented Dec 23, 2024

  • Fix cursor position if input newline on middle of lines
  • Increment number if numbered list

image

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Dec 23, 2024
@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Dec 23, 2024
} else {
// start a new line with the same indention and prefix
let newPrefix = prefix;
// a simple approach, otherwise it needs to parse the lines after the current line
if (/^\d+\./.test(prefix)) newPrefix = `1. ${newPrefix.slice(newPrefix.indexOf('.') + 2)}`;
Copy link
Member Author

@metiftikci metiftikci Dec 23, 2024

Choose a reason for hiding this comment

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

not sure what old code does

got it

Copy link
Contributor

Choose a reason for hiding this comment

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

Comment above // a simple approach, otherwise it needs to parse the lines after the current line

@techknowlogick techknowlogick added the topic/ui Change the appearance of the Gitea UI label Dec 23, 2024
@wxiaoguang
Copy link
Contributor

wxiaoguang commented Dec 24, 2024

I guess it's not right for this case:

1. a
2. b <---  enter here
3. c

Your result might be

1. a
2. b
3. 
3. c

?

I didn't do that (auto-increase) because it needs a complex algorithm to make it right. And for most cases only using 1. seems clearer and easier when editing, and it doesn't affect the rendering.


I added a new test: testInput({value: '1. a\n2. b\n3. c', pos: 4}, {value: '1. a\n2. \n2. b\n3. c', pos: 8});, there are two 2., not sure whether it is what you want.

@pull-request-size pull-request-size bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Dec 24, 2024
@metiftikci
Copy link
Member Author

@wxiaoguang should i revert the increase number code or try to implement increasing numbers below?

@wxiaoguang
Copy link
Contributor

@wxiaoguang should i revert the increase number code or try to implement increasing numbers below?

Either is fine, but there are many edge cases, even GitHub doesn't get it completely right, and it would be quite complex, maybe at least hundreds lines of code in my mind.

So at the moment, I would prefer to revert "the increase number"

@pull-request-size pull-request-size bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 24, 2024
@metiftikci
Copy link
Member Author

@wxiaoguang done

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 25, 2024
@wxiaoguang wxiaoguang added type/bug backport/v1.23 This PR should be backported to Gitea 1.23 labels Dec 25, 2024
@wxiaoguang wxiaoguang added this to the 1.24.0 milestone Dec 25, 2024
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Dec 25, 2024
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Dec 25, 2024
@lunny lunny merged commit 1a7591d into go-gitea:main Dec 25, 2024
26 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Dec 25, 2024
- Fix cursor position if input newline on middle of lines
- ~Increment number if numbered list~


![image](https://github.com/user-attachments/assets/bcfe2625-11a8-4ea4-9a71-b7ecfe81b2e0)

---------

Co-authored-by: wxiaoguang <[email protected]>
@GiteaBot GiteaBot added backport/done All backports for this PR have been created and removed reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. labels Dec 25, 2024
wxiaoguang added a commit that referenced this pull request Dec 25, 2024
Backport #32966 by metiftikci

Co-authored-by: metiftikci <[email protected]>
Co-authored-by: wxiaoguang <[email protected]>
zjjhot added a commit to zjjhot/gitea that referenced this pull request Dec 25, 2024
* giteaofficial/main:
  demilestone should not include milestone (go-gitea#32923)
  fix textarea newline handle (go-gitea#32966)
  Fix Azure blob object `Seek`  (go-gitea#32974)
  Fix maven pom inheritance (go-gitea#32943)
  Refactor arch route handlers (go-gitea#32972)
  [skip ci] Updated translations via Crowdin
  Refactor tmpl and blob_excerpt (go-gitea#32967)
  Clarify path param naming (go-gitea#32969)
  Refactor getpatch/getdiff functions and remove unnecessary fallback (go-gitea#32817)
  Refactor request context (go-gitea#32956)
@wxiaoguang
Copy link
Contributor

@wxiaoguang should i revert the increase number code or try to implement increasing numbers below?

I have made a complete fix : Fix editor markdown not incrementing in a numbered list #33187

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/done All backports for this PR have been created backport/v1.23 This PR should be backported to Gitea 1.23 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend size/S Denotes a PR that changes 10-29 lines, ignoring generated files. topic/ui Change the appearance of the Gitea UI type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants