Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
db9fb8a3
Commit
db9fb8a3
authored
Jun 21, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add default autocomplete config
parent
2bac2918
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
28 deletions
+39
-28
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+11
-8
app/assets/javascripts/gl_form.js
app/assets/javascripts/gl_form.js
+4
-11
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+8
-7
app/assets/javascripts/vue_shared/components/markdown/field.vue
...sets/javascripts/vue_shared/components/markdown/field.vue
+8
-1
app/helpers/notes_helper.rb
app/helpers/notes_helper.rb
+8
-1
No files found.
app/assets/javascripts/gfm_auto_complete.js
View file @
db9fb8a3
...
...
@@ -7,6 +7,16 @@ function sanitize(str) {
return
str
.
replace
(
/<
(?:
.|
\n)
*
?
>/gm
,
''
);
}
export
const
defaultAutocompleteConfig
=
{
emojis
:
true
,
members
:
true
,
issues
:
true
,
mergeRequests
:
true
,
epics
:
false
,
milestones
:
true
,
labels
:
true
,
};
class
GfmAutoComplete
{
constructor
(
dataSources
)
{
this
.
dataSources
=
dataSources
||
{};
...
...
@@ -14,14 +24,7 @@ class GfmAutoComplete {
this
.
isLoadingData
=
{};
}
setup
(
input
,
enableMap
=
{
emojis
:
true
,
members
:
true
,
issues
:
true
,
milestones
:
true
,
mergeRequests
:
true
,
labels
:
true
,
})
{
setup
(
input
,
enableMap
=
defaultAutocompleteConfig
)
{
// Add GFM auto-completion to all input fields, that accept GFM input.
this
.
input
=
input
||
$
(
'
.js-gfm-input
'
);
this
.
enableMap
=
enableMap
;
...
...
app/assets/javascripts/gl_form.js
View file @
db9fb8a3
import
$
from
'
jquery
'
;
import
autosize
from
'
autosize
'
;
import
GfmAutoComplete
from
'
./gfm_auto_complete
'
;
import
GfmAutoComplete
,
*
as
GFMConfig
from
'
./gfm_auto_complete
'
;
import
dropzoneInput
from
'
./dropzone_input
'
;
import
{
addMarkdownListeners
,
removeMarkdownListeners
}
from
'
./lib/utils/text_markdown
'
;
export
default
class
GLForm
{
constructor
(
form
,
enableGFM
=
false
)
{
constructor
(
form
,
enableGFM
=
{}
)
{
this
.
form
=
form
;
this
.
textarea
=
this
.
form
.
find
(
'
textarea.js-gfm-input
'
);
this
.
enableGFM
=
enableGFM
;
this
.
enableGFM
=
Object
.
assign
({},
GFMConfig
.
defaultAutocompleteConfig
,
enableGFM
)
;
// Before we start, we should clean up any previous data for this form
this
.
destroy
();
// Setup the form
...
...
@@ -34,14 +34,7 @@ export default class GLForm {
// remove notify commit author checkbox for non-commit notes
gl
.
utils
.
disableButtonIfEmptyField
(
this
.
form
.
find
(
'
.js-note-text
'
),
this
.
form
.
find
(
'
.js-comment-button, .js-note-new-discussion
'
));
this
.
autoComplete
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
this
.
autoComplete
.
setup
(
this
.
form
.
find
(
'
.js-gfm-input
'
),
{
emojis
:
true
,
members
:
this
.
enableGFM
,
issues
:
this
.
enableGFM
,
milestones
:
this
.
enableGFM
,
mergeRequests
:
this
.
enableGFM
,
labels
:
this
.
enableGFM
,
});
this
.
autoComplete
.
setup
(
this
.
form
.
find
(
'
.js-gfm-input
'
),
this
.
enableGFM
);
dropzoneInput
(
this
.
form
);
autosize
(
this
.
textarea
);
}
...
...
app/assets/javascripts/notes.js
View file @
db9fb8a3
...
...
@@ -20,6 +20,7 @@ import SkeletonLoadingContainer from '~/vue_shared/components/skeleton_loading_c
import
axios
from
'
./lib/utils/axios_utils
'
;
import
{
getLocationHash
}
from
'
./lib/utils/url_utility
'
;
import
Flash
from
'
./flash
'
;
import
{
defaultAutocompleteConfig
}
from
'
./gfm_auto_complete
'
;
import
CommentTypeToggle
from
'
./comment_type_toggle
'
;
import
GLForm
from
'
./gl_form
'
;
import
loadAwardsHandler
from
'
./awards_handler
'
;
...
...
@@ -45,7 +46,7 @@ const MAX_VISIBLE_COMMIT_LIST_COUNT = 3;
const
REGEX_QUICK_ACTIONS
=
/^
\/\w
+.*$/gm
;
export
default
class
Notes
{
static
initialize
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
=
true
)
{
static
initialize
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
)
{
if
(
!
this
.
instance
)
{
this
.
instance
=
new
Notes
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
);
}
...
...
@@ -55,7 +56,7 @@ export default class Notes {
return
this
.
instance
;
}
constructor
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
=
true
)
{
constructor
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
=
defaultAutocompleteConfig
)
{
this
.
updateTargetButtons
=
this
.
updateTargetButtons
.
bind
(
this
);
this
.
updateComment
=
this
.
updateComment
.
bind
(
this
);
this
.
visibilityChange
=
this
.
visibilityChange
.
bind
(
this
);
...
...
@@ -94,7 +95,7 @@ export default class Notes {
this
.
cleanBinding
();
this
.
addBinding
();
this
.
setPollingInterval
();
this
.
setupMainTargetNoteForm
();
this
.
setupMainTargetNoteForm
(
enableGFM
);
this
.
taskList
=
new
TaskList
({
dataType
:
'
note
'
,
fieldName
:
'
note
'
,
...
...
@@ -598,14 +599,14 @@ export default class Notes {
*
* Sets some hidden fields in the form.
*/
setupMainTargetNoteForm
()
{
setupMainTargetNoteForm
(
enableGFM
)
{
var
form
;
// find the form
form
=
$
(
'
.js-new-note-form
'
);
// Set a global clone of the form for later cloning
this
.
formClone
=
form
.
clone
();
// show the form
this
.
setupNoteForm
(
form
);
this
.
setupNoteForm
(
form
,
enableGFM
);
// fix classes
form
.
removeClass
(
'
js-new-note-form
'
);
form
.
addClass
(
'
js-main-target-form
'
);
...
...
@@ -633,9 +634,9 @@ export default class Notes {
* setup GFM auto complete
* show the form
*/
setupNoteForm
(
form
)
{
setupNoteForm
(
form
,
enableGFM
=
defaultAutocompleteConfig
)
{
var
textarea
,
key
;
this
.
glForm
=
new
GLForm
(
form
,
this
.
enableGFM
);
this
.
glForm
=
new
GLForm
(
form
,
enableGFM
);
textarea
=
form
.
find
(
'
.js-note-text
'
);
key
=
[
'
Note
'
,
...
...
app/assets/javascripts/vue_shared/components/markdown/field.vue
View file @
db9fb8a3
...
...
@@ -62,7 +62,14 @@
/*
GLForm class handles all the toolbar buttons
*/
return
new
GLForm
(
$
(
this
.
$refs
[
'
gl-form
'
]),
this
.
enableAutocomplete
);
return
new
GLForm
(
$
(
this
.
$refs
[
'
gl-form
'
]),
{
emojis
:
this
.
enableAutocomplete
,
members
:
this
.
enableAutocomplete
,
issues
:
this
.
enableAutocomplete
,
mergeRequests
:
this
.
enableAutocomplete
,
milestones
:
this
.
enableAutocomplete
,
labels
:
this
.
enableAutocomplete
,
});
},
beforeDestroy
()
{
const
glForm
=
$
(
this
.
$refs
[
'
gl-form
'
]).
data
(
'
glForm
'
);
...
...
app/helpers/notes_helper.rb
View file @
db9fb8a3
...
...
@@ -143,7 +143,14 @@ module NotesHelper
notesIds:
@notes
.
map
(
&
:id
),
now:
Time
.
now
.
to_i
,
diffView:
diff_view
,
autocomplete:
autocomplete
enableGFM:
{
emojis:
true
,
members:
autocomplete
,
issues:
autocomplete
,
mergeRequests:
autocomplete
,
milestones:
autocomplete
,
labels:
autocomplete
}
}
end
...
...
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