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

RichTextAction subscription #129

Merged
merged 20 commits into from
Feb 3, 2024
Merged

RichTextAction subscription #129

merged 20 commits into from
Feb 3, 2024

Conversation

DominikBucher12
Copy link
Collaborator

@DominikBucher12 DominikBucher12 commented Jan 18, 2024

What this PR do:

  • Implements RichTextAction as main source of truth for Actions inside the richtextview. That means that setting isBold on RichTextContext no longer sets the style.
  • Properties on Context are now internal, meaning if you want to set some attributes from the outside, use userActionPublisher!
  • Fixes issue with sidebar focusing thus not setting typing attributes at given range.

How to test it

  • Run the test, try the app for yourself

TODO

  • Implement integration tests
  • Add Localizations for those user actions
  • Clean up a bit.

@DominikBucher12
Copy link
Collaborator Author

@danielsaidi Can you please take a look when you have some free time to ensure we are going correct direction?

This is breaking change, changing published properties to internal for them to reflect only and only be used with binding(for)...

@DominikBucher12 DominikBucher12 changed the title [WIP] RichTextAction RichTextAction subscription Jan 19, 2024
@DominikBucher12 DominikBucher12 marked this pull request as ready for review January 19, 2024 12:58
@DominikBucher12 DominikBucher12 marked this pull request as draft January 19, 2024 12:59
@DominikBucher12 DominikBucher12 marked this pull request as ready for review January 19, 2024 14:13
@DominikBucher12 DominikBucher12 added the adjustment Changes to existing functionality label Jan 19, 2024
Copy link
Owner

@danielsaidi danielsaidi left a comment

Choose a reason for hiding this comment

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

Great job! I have some comments that we need to fix though :)

Sources/RichTextKit/Actions/RichTextAction.swift Outdated Show resolved Hide resolved
Sources/RichTextKit/Actions/RichTextAction.swift Outdated Show resolved Hide resolved
Sources/RichTextKit/Actions/RichTextAction.swift Outdated Show resolved Hide resolved
Sources/RichTextKit/Actions/RichTextAction.swift Outdated Show resolved Hide resolved
Sources/RichTextKit/Actions/RichTextAction.swift Outdated Show resolved Hide resolved
@DominikBucher12 DominikBucher12 force-pushed the improvement/richtextaction branch 3 times, most recently from b4ccd3b to b4bd81d Compare January 23, 2024 15:09
case .setUnderlineColor: .underlineColor
case .setStrikethroughColor: .strikethroughColor
case .setStrokeColor: .strokeColor
case .setColor(_, let richTextColor):
Copy link
Owner

Choose a reason for hiding this comment

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

@DominikBucher12 I thiiiiink the rich text color has a title that you can return right away.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It actually does not :( I wouldn't implement it in there IMHO, but the icons can stay.

Copy link
Owner

Choose a reason for hiding this comment

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

I'll fix! :)

case .strikethrough: .strikethroughColor
case .stroke: .strokeColor
case .underline: .underlineColor
case .undefined: .strokeColor
Copy link
Owner

Choose a reason for hiding this comment

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

Is this correct for the undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You need to return something and this feels a lot better than exception or cascade of optionals. I would personally focus after 1.0 to get away from undefined...

Copy link
Owner

Choose a reason for hiding this comment

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

I love this so much!


/// Whether or not the latest undone change can be redone.
@Published
public var canRedoLatestChange = false
var canRedoLatestChange = false
Copy link
Owner

@danielsaidi danielsaidi Feb 3, 2024

Choose a reason for hiding this comment

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

But actually, removing public from these are breaking changes. I think we can do it if we don't release this PR as a 0.9 patch, but as a 1.0 bump.

I also don't understand how other parts of an app would be able to refresh if they can't listen to these published properties?? 🤔

@danielsaidi danielsaidi merged commit 697e073 into main Feb 3, 2024
1 check passed
@danielsaidi danielsaidi deleted the improvement/richtextaction branch February 3, 2024 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
adjustment Changes to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants