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

Paragraph fix #134

Closed
wants to merge 5 commits into from
Closed

Paragraph fix #134

wants to merge 5 commits into from

Conversation

danielsaidi
Copy link
Owner

@DominikBucher12

After merging your branch, which still didn't work for me, I returned to the alignment code and cleaned it up a bit.

It's still not working perfectly, but given how little code it now has, perhaps it's worth merging just to reduce complexity?

Have a look at this PR and give it a try. I will not merge until we see that it works better or the same with less code.

} else {
setRichTextAlignment(alignment, at: selectedRange)
}
setRichTextAlignment(alignment, at: selectedRange)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the issue in here is that I am testing on iOS and you on macOS. :D

This will work on macOS but not on iOS because it doesnt set the typing attributes and the behaviour of text is quite different. What I suggest is to platform-check this and use set typing attributes on non-mac platform, that way we can actually ensure it works properly and test those under both platforms.

Copy link
Owner Author

Choose a reason for hiding this comment

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

I actually tested continuously in both iOS and macOS. :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Currently not setting typing attributes causes obviously this:
https://github.com/danielsaidi/RichTextKit/assets/17381941/00fa4f8f-ce12-4992-9627-e09151c0e96c

I am on it, hopefully I can fix this today so lets see.

// The cursor is somewhere within a paragraph
let location = UInt(range.location)
let index = text.findIndexOfCurrentParagraph(from: location)
return setAlignment(alignment, atIndex: index)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is IMHO needed for proper functionality but it probably needs to tweak a bit with some symbols. I am still wrapping my head around why setting alignment on a new line separated by newLineSeparator changes alignment of previous line as well...

@danielsaidi danielsaidi closed this Feb 3, 2024
@danielsaidi danielsaidi deleted the paragraph-fix branch February 3, 2024 11:51
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.

2 participants