Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
c1db1597
Commit
c1db1597
authored
Feb 05, 2024
by
Alejandro Celaya
Committed by
Alejandro Celaya
Feb 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add placeholder to MarkdownEditor with different value for replies
parent
7341fac3
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
6 deletions
+24
-6
AnnotationEditor.tsx
src/sidebar/components/Annotation/AnnotationEditor.tsx
+5
-4
AnnotationEditor-test.js
...debar/components/Annotation/test/AnnotationEditor-test.js
+15
-0
MarkdownEditor.tsx
src/sidebar/components/MarkdownEditor.tsx
+1
-0
MarkdownEditor-test.js
src/sidebar/components/test/MarkdownEditor-test.js
+3
-2
No files found.
src/sidebar/components/Annotation/AnnotationEditor.tsx
View file @
c1db1597
import
{
useCallback
,
useState
}
from
'preact/hooks'
;
import
{
useCallback
,
use
Memo
,
use
State
}
from
'preact/hooks'
;
import
type
{
Annotation
}
from
'../../../types/api'
;
import
type
{
Annotation
}
from
'../../../types/api'
;
import
type
{
SidebarSettings
}
from
'../../../types/config'
;
import
type
{
SidebarSettings
}
from
'../../../types/config'
;
...
@@ -48,6 +48,7 @@ function AnnotationEditor({
...
@@ -48,6 +48,7 @@ function AnnotationEditor({
const
store
=
useSidebarStore
();
const
store
=
useSidebarStore
();
const
group
=
store
.
getGroup
(
annotation
.
group
);
const
group
=
store
.
getGroup
(
annotation
.
group
);
const
isReplyAnno
=
useMemo
(()
=>
isReply
(
annotation
),
[
annotation
]);
const
shouldShowLicense
=
const
shouldShowLicense
=
!
draft
.
isPrivate
&&
group
&&
group
.
type
!==
'private'
;
!
draft
.
isPrivate
&&
group
&&
group
.
type
!==
'private'
;
...
@@ -118,11 +119,11 @@ function AnnotationEditor({
...
@@ -118,11 +119,11 @@ function AnnotationEditor({
isPrivate
,
isPrivate
,
});
});
// Persist this as privacy default for future annotations unless this is a reply
// Persist this as privacy default for future annotations unless this is a reply
if
(
!
isReply
(
annotation
)
)
{
if
(
!
isReply
Anno
)
{
store
.
setDefault
(
'annotationPrivacy'
,
isPrivate
?
'private'
:
'shared'
);
store
.
setDefault
(
'annotationPrivacy'
,
isPrivate
?
'private'
:
'shared'
);
}
}
},
},
[
annotation
,
draft
,
store
],
[
annotation
,
draft
,
isReplyAnno
,
store
],
);
);
const
onSave
=
async
()
=>
{
const
onSave
=
async
()
=>
{
...
@@ -175,7 +176,7 @@ function AnnotationEditor({
...
@@ -175,7 +176,7 @@ function AnnotationEditor({
>
>
<
MarkdownEditor
<
MarkdownEditor
textStyle=
{
textStyle
}
textStyle=
{
textStyle
}
label=
"Annotation body"
label=
{
isReplyAnno
?
'Enter reply'
:
'Enter comment'
}
text=
{
text
}
text=
{
text
}
onEditText=
{
onEditText
}
onEditText=
{
onEditText
}
/>
/>
...
...
src/sidebar/components/Annotation/test/AnnotationEditor-test.js
View file @
c1db1597
...
@@ -106,6 +106,21 @@ describe('AnnotationEditor', () => {
...
@@ -106,6 +106,21 @@ describe('AnnotationEditor', () => {
assert
.
calledOnce
(
fakeStore
.
createDraft
);
assert
.
calledOnce
(
fakeStore
.
createDraft
);
assert
.
equal
(
call
.
args
[
1
].
text
,
'updated text'
);
assert
.
equal
(
call
.
args
[
1
].
text
,
'updated text'
);
});
});
[
{
annotation
:
fixtures
.
newReply
(),
expectedLabel
:
'Enter reply'
},
{
annotation
:
fixtures
.
defaultAnnotation
(),
expectedLabel
:
'Enter comment'
,
},
].
forEach
(({
annotation
,
expectedLabel
})
=>
{
it
(
'sets proper label'
,
()
=>
{
const
wrapper
=
createComponent
({
annotation
});
const
editor
=
wrapper
.
find
(
'MarkdownEditor'
);
assert
.
equal
(
editor
.
prop
(
'label'
),
expectedLabel
);
});
});
});
});
describe
(
'editing tags'
,
()
=>
{
describe
(
'editing tags'
,
()
=>
{
...
...
src/sidebar/components/MarkdownEditor.tsx
View file @
c1db1597
...
@@ -394,6 +394,7 @@ export default function MarkdownEditor({
...
@@ -394,6 +394,7 @@ export default function MarkdownEditor({
)
:
(
)
:
(
<
TextArea
<
TextArea
aria
-
label=
{
label
}
aria
-
label=
{
label
}
placeholder=
{
label
}
dir=
"auto"
dir=
"auto"
classes=
{
classnames
(
classes=
{
classnames
(
'w-full min-h-[8em] resize-y'
,
'w-full min-h-[8em] resize-y'
,
...
...
src/sidebar/components/test/MarkdownEditor-test.js
View file @
c1db1597
...
@@ -291,9 +291,10 @@ describe('MarkdownEditor', () => {
...
@@ -291,9 +291,10 @@ describe('MarkdownEditor', () => {
});
});
it
(
'sets accessible label for input field'
,
()
=>
{
it
(
'sets accessible label for input field'
,
()
=>
{
const
wrapper
=
createComponent
({
label
:
'
Annotation body
'
});
const
wrapper
=
createComponent
({
label
:
'
Enter comment
'
});
const
inputField
=
wrapper
.
find
(
'textarea'
);
const
inputField
=
wrapper
.
find
(
'textarea'
);
assert
.
equal
(
inputField
.
prop
(
'aria-label'
),
'Annotation body'
);
assert
.
equal
(
inputField
.
prop
(
'aria-label'
),
'Enter comment'
);
assert
.
equal
(
inputField
.
prop
(
'placeholder'
),
'Enter comment'
);
});
});
describe
(
'keyboard navigation'
,
()
=>
{
describe
(
'keyboard navigation'
,
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment