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

Resolve #254 #256

Merged
merged 27 commits into from
Apr 17, 2024
Merged

Resolve #254 #256

merged 27 commits into from
Apr 17, 2024

Conversation

T8RIN
Copy link
Contributor

@T8RIN T8RIN commented Apr 17, 2024

I've added this as parameters and config, but didn't know how to pass it to cinstructor from config

MohamedRejeb and others added 24 commits March 30, 2024 08:01
Fix Crash when setting maxLines in Text
Fix getBoundingBoxes returning emptyList when the last line is empty
Support add link to current selection
Support editing existing Link and deleting Link
@@ -186,13 +186,15 @@ class RichTextState internal constructor(
codeColor: Color = Color.Unspecified,
codeBackgroundColor: Color = Color.Unspecified,
codeStrokeColor: Color = Color.Unspecified,
listIndent: Int = 38
Copy link
Owner

Choose a reason for hiding this comment

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

Here we need to have a special value to ignore which can be -1 in the case of Int.
So the default value here should be changed to -1.

) {
richTextConfig = RichTextConfig(
linkColor = if (linkColor.isSpecified) linkColor else richTextConfig.linkColor,
linkTextDecoration = linkTextDecoration ?: richTextConfig.linkTextDecoration,
codeColor = if (codeColor.isSpecified) codeColor else richTextConfig.codeColor,
codeBackgroundColor = if (codeBackgroundColor.isSpecified) codeBackgroundColor else richTextConfig.codeBackgroundColor,
codeStrokeColor = if (codeStrokeColor.isSpecified) codeStrokeColor else richTextConfig.codeStrokeColor,
listIndent = listIndent
Copy link
Owner

Choose a reason for hiding this comment

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

Here we need to keep the same value if the listIndent is not changed.
So it's going to be something like this:
if (listIndent > -1) listIndent else richTextConfig .listIndent

@@ -11,6 +11,7 @@ import com.mohamedrejeb.richeditor.paragraph.RichParagraph

internal class OrderedList(
number: Int,
private val indent: Int = 38,
Copy link
Owner

Choose a reason for hiding this comment

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

The indent param here shouldn't have a default value. It should be passed by the state instead.

@@ -7,16 +7,18 @@ import com.mohamedrejeb.richeditor.annotation.ExperimentalRichTextApi
import com.mohamedrejeb.richeditor.model.RichSpan
import com.mohamedrejeb.richeditor.paragraph.RichParagraph

internal class UnorderedList : ParagraphType {
internal class UnorderedList(
private val indent: Int = 38
Copy link
Owner

Choose a reason for hiding this comment

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

The indent param here shouldn't have a default value. It should be passed by the state instead.

@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

Okay, then how i can pass value from config to constructors?

@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

I did the changes

@MohamedRejeb
Copy link
Owner

I think the build won't succeed. The indent is not passed to the lists on creation.

@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

I think the build won't succeed. The indent is not passed to the lists on creation.

Yes, that's what i asking for, i didn't know how to pass it 😢

@MohamedRejeb
Copy link
Owner

MohamedRejeb commented Apr 17, 2024

This is not going to be a funny thing to do haha, so here in the RichTextState there's a creation of lists in many places. If you are using the IDE you will see errors, but if you are editing with github it will be hard.
That's why I said before that I'm thinking about changing how this config works because now in order to pass the indent I need to go through each creation of a list which is not that good. Hopefully in the future custom styles like lists will have direct access to the config.

https://github.com/MohamedRejeb/Compose-Rich-Editor/blob/ecd2e01f041855f66a2f3e783a7448af9b9079cd/richeditor-compose/src/commonMain/kotlin/com/mohamedrejeb/richeditor/model/RichTextState.kt#L564

@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

I editing through github now because i didn't know if it builds on my pc, in cause of multiplatform, but how soon this future will be? 👀

I can try with AS later, but there also misunterstanding of passing this

@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

As a fast and stupid workaround, you can create const field with 38 value, and i can change it in my code through reflection 🤡

@MohamedRejeb
Copy link
Owner

MohamedRejeb commented Apr 17, 2024

No problem, I'll do it myself. Thanks for the contribution!
I'm not sure to be honest how soon this future is haha. Hopefully next week.

@MohamedRejeb MohamedRejeb changed the base branch from main to 1.x April 17, 2024 12:28
@MohamedRejeb MohamedRejeb self-requested a review April 17, 2024 12:29
@T8RIN
Copy link
Contributor Author

T8RIN commented Apr 17, 2024

Thanks!

@MohamedRejeb MohamedRejeb merged commit 2ebd03f into MohamedRejeb:1.x Apr 17, 2024
1 of 2 checks passed
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.

None yet

2 participants