-
Notifications
You must be signed in to change notification settings - Fork 0
BlockEditor driven by shared ObservableStore #1000
BlockEditor driven by shared ObservableStore #1000
Conversation
Fork of ObservableStore that allows creating custom Update types for models. This lets us publish a change description along with state changes. The controller can use the change description to perform appropriate updates.
...and update ObservableStore branch
...no longer use this class.
...also remove spacer from cells, since it was messing up constraint resolution in the collection view.
It's handled in its own store now.
...and replace delegate approach with send functions and enums. This lets us simply map between enums.
Not needed when we can use Self.
) | ||
} | ||
|
||
// TODO: re-implement |
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'm assuming these TODOs are out of scope for this PR since they're related to bulk selection.
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.
Yes, out of scope. The selection mode wasn't working properly. Removed commented-out code, and added issues to TODOs.
// TODO: serialize to nice Subtext whitespace | ||
blocks.compactMap(\.text).joined(separator: "\n\n") |
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.
Is this out of scope?
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.
@bfollington yes, it will require a modification to the Subtext parser to enable rendering a "pretty printed" string that places spaces between some lines and not others (e.g. list items can have blank lines between but probably shouldn't for readability purposes". This is purely an aesthetic enhancement.
I'll file a bug to follow up.
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.
Done
textStorage.delegate = self | ||
// !!!: Hack to trigger initial rendering of attributes | ||
// UITextView has a bug where a text view that has been created | ||
// with an empty string does not correctly render attributes until | ||
// given a non-empty string. This results in a jump triggered by | ||
// a change in intrinsic content size when the attributes are | ||
// first applied. | ||
// | ||
// After being rendered with a non-empty string, it works properly. | ||
// 2023-11-22 Gordon | ||
self.text = " " | ||
self.text = "" |
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.
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.
Nice work, this is a massive improvement to the existing code. Excited to try the editor out.
Fixes #987.
Depends on subconsciousnetwork/ObservableStore#43
This PR implements basic loading and saving of real data from database, including blocks and related notes. I've kept the scope to just saving and loading, and there is more work to be done wrt transcludes and loading states.
Approach
updates
publisher on storesupdates
publisher and performs updates to controller based on state transactions.@StateObject
on the enclosing SwiftUIView and passed down as an@ObservedObject
to the UIViewControllerRepresentable.The result is that we can share the same store between SwiftUI and UIKit land, as well as the same environment and side effects management.
Screenshots