-
-
Notifications
You must be signed in to change notification settings - Fork 132
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
Paragraph fix #134
Conversation
} else { | ||
setRichTextAlignment(alignment, at: selectedRange) | ||
} | ||
setRichTextAlignment(alignment, at: selectedRange) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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...
@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.