Skip to content

Commit 7ed2b0f

Browse files
hermanwiknerskogsmaskin
andauthoredMar 1, 2024
feat(comments): introduce inline commenting (#5606)
* feat(comments): add inline comments Co-Authored-By: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com> * feat(comments): enhance optimistic updates by tracking the transaction ID Co-Authored-By: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com> * fix(comments): clean up, remove unused code * fix(comments): remove unneccesary memoization, fix broken query * fix(comments): enable check * fix(comments): disable comments for ai assist and when in upsell mode * feat(comments): use DMP to track commented ranges across edits * test(comments): update test and workshop * feat(comments): add optional throttle option to update operation * fix(comments): boundary element for inline commenting popovers * fix(comments): only patch comment document when range decorators are moved by local changes * fix(comments): throttled updates * fix(comments): recalculate ranges when `rangeDecorationMove` is triggered but only proceed with updating the comment document if the current user made changes * feat(comments): add `contentSnapshot` fix(comments): type * feat(comments): inline decorator color * feat(comments): omit inline comments without referenced value (#5760) * feat(comments): re-calculate range decoration for individual changed comment Co-Authored-By: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com> * fix(comments): clean up throttle id map in update operation * refactor(comments): add selection type, correct variable names * refactor(comments): disable logic that omit inline comments without any referenced value * feat(comments): store document revision id + add design when inline comment do not have a referenced value * dev(test-studio): add `commentsCI` document type * test(comments): add test ids * test(comments): add e2e test for inline comment creation * test(comments): add missing property in range decoration test fix fix * test(comments): update inline comment creation e2e * feat(comments): include optimistic update in throttled function * feat(comments): add `CommentDisabledIcon` * feat(comments): improve perf when editing content with comments * feat(comments): implement UI when inline comment creation is disabled * dev(comments): add `CommentsListItemLayout` story * dev(comments): update `CommentsListItemReferencedValue` story * feat(comments): add UI when inline comment is referencing a deleted value * fix(comments): fix some issues with the range tracking algo * Fixes an issue where adding text inside single word ranges didn't expand correctly * Fixes an issue where bolding partially inside a range expanded the range incorrectly * Replaces child and comment range start/end indicators with unused utf-8 chars to avoid conflicts with user content * test(comments): break apart inline comment range tests Have each test in it's own file to make them easier to write and read. Ditch snapshot testing and test against hard coded values that makes it easier to undstand what is going on. * test(comments): temporarily only run tests in Chromium due to flakiness * refactor(comments): refactor buildRangeDecorationSelectionsFromComments Improve invalidation of range decorations when text is edited * refactor(comments): refactor CommentsPortableTextInput Improve how we move and update range decorations when content is edited * test(comments): update workshop story for CommentInlineHighlightDebug * test(comments): add new tests (skipped for now) * fix(comments): check if selection overlaps with added comments * fix(comments): referenced value UI * feat(comments): update referenced value design * test(comments): use test over it * feat(comments): localize strings * feat(comments): preserve local dirty flags when receiving comments from the server * fix(comments): improve performance on finding text ranges in side panel * feat(comments): show comment button on mouse up * chore(comments): temporarily disable inline comments * fix(comments): remove `console.log` in `CommentsPortableTextInput` --------- Co-authored-by: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com>
1 parent fa330a0 commit 7ed2b0f

File tree

70 files changed

+3988
-598
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+3988
-598
lines changed
 

‎dev/test-studio/schema/ci/comments.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import {defineField, type PortableTextBlock} from 'sanity'
2+
3+
const INITIAL_VALUE: PortableTextBlock[] = [
4+
{
5+
_key: 'ROOT_KEY',
6+
children: [
7+
{
8+
_type: 'span',
9+
marks: [],
10+
text: 'This is some text in the body field',
11+
_key: 'CHILD_KEY',
12+
},
13+
],
14+
markDefs: [],
15+
_type: 'block',
16+
style: 'normal',
17+
},
18+
]
19+
20+
export const commentsCI = defineField({
21+
type: 'document',
22+
name: 'commentsCI',
23+
title: 'Comments CI',
24+
fields: [
25+
{
26+
name: 'body',
27+
type: 'array',
28+
initialValue: INITIAL_VALUE,
29+
of: [
30+
{
31+
type: 'block',
32+
},
33+
],
34+
},
35+
],
36+
})

‎dev/test-studio/schema/debug/comments.ts

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export const commentsDebug = defineType({
1212
type: 'string',
1313
title: 'String title',
1414
},
15+
{
16+
type: 'array',
17+
name: 'body',
18+
of: [{type: 'block'}],
19+
},
1520
{
1621
name: 'hideFields',
1722
type: 'boolean',

0 commit comments

Comments
 (0)