-
Notifications
You must be signed in to change notification settings - Fork 23
Add mention insertion methods #698
Add mention insertion methods #698
Conversation
* Add Mention container node type and initial to markdown implementation * Make new container node kind correspond to link dom node * Add new_mention function * update all references to ContainerNodeType::Link with new mention type * add new_mention for dom node, add TODO comments for parsing * add TODO - app compiling, tests passing * add TODO for tree display
* change signature for set_link * update bindings * update tests * add TODO for deletion * remove unused parameters (web lib.rs) * change set_link and set_link_in_range signatures * update bindings * update tests * fix tests * rejig arguments for usability * rename to set_mention_from_suggestion * fix function calls, do not pass in contenteditable * fix mobile binding arguments * refactor to not pass attributes to new_links
This reverts commit cce8148.
…into jonny/distinct-mention-node-wip
…n-insertion-methods
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #698 +/- ##
============================================
+ Coverage 88.28% 88.38% +0.09%
+ Complexity 274 268 -6
============================================
Files 145 146 +1
Lines 16652 17003 +351
Branches 769 789 +20
============================================
+ Hits 14702 15028 +326
- Misses 1765 1785 +20
- Partials 185 190 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
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.
Looks good to me, but we'll need to update all platform code as part of this PR as it is a breaking change
suggestion: SuggestionPattern, | ||
attributes: Vec<(S, S)>, | ||
) -> ComposerUpdate<S> { | ||
// This function removes the text between the suggestion start and end points, updates the |
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.
We must self.push_state_to_history();
here, before we start making changes to the composer.
self.state.start = Location::from(suggestion.start); | ||
self.state.end = self.state.start; | ||
|
||
self.insert_mention(url, text, attributes) |
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 should really rather call the internal do_insert_mention
. If the test around being inside a link is required, it should be done before everything else (and be extracted to an util function run before push_state_to_history
)
let new_node = DomNode::new_mention(url, text, attributes); | ||
let new_cursor_index = start + new_node.text_len(); | ||
|
||
self.push_state_to_history(); |
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.
We should probably never push_state_to_history
inside inner variant do_...
in case of reuse somewhere else (since it creates an undo/redo state - it should always be called in the public API function)
self.state.start = Location::from(new_cursor_index); | ||
self.state.end = self.state.start; | ||
|
||
// add a trailing space in cases when we do not have a next sibling |
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.
Yeah this was already discussed at some point, the conversation lies somewhere in our Room history, but yeah adding a space after the inserted trailing function only is the way to go.
fn test_set_link_suggestion_ffi() { | ||
let model = Arc::new(ComposerModel::new()); | ||
fn test_replace_whole_suggestion_with_mention_ffi() { | ||
let mut model = Arc::new(ComposerModel::new()); | ||
let update = model.replace_text("@alic".into()); |
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.
update
is unused now
I've made those changes @aringenbach . Extracting the logic check to a util is probably a good move too as we're going to change that behaviour when issue #702 gets addressed anyway. |
Co-authored-by: aringenbach <[email protected]>
Co-authored-by: aringenbach <[email protected]>
Co-authored-by: aringenbach <[email protected]>
Co-authored-by: aringenbach <[email protected]>
* Update Android to new mention insertion API * Add issue link to todo
* [iOS] Handle selection offsets for mention node * [iOS] Rename `PermalinkReplacer` to `MentionReplacer` * Use insert_mention API and fix tests
SonarCloud Quality Gate failed. |
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.
LGTM ! I also triggered the mobile platforms tests that seem to be all green.
This change makes breaking changes to the API. This PR incorporates changes to web, iOS and Android to account for the selection logic changes required and the use of the new lib functions.
This PR:
set_mention_from_suggestion
and updates bindingsmentions.rs
file to handle the renamed functioninsert_node_at_cursor.rs
file to allow insertion of a node at a cursor with unit teststest_mentions.rs
- implements iOS changes
- implements Android changes