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
355cfa0c
Commit
355cfa0c
authored
Sep 09, 2020
by
Tim Zallmann
Committed by
Mike Greiling
Sep 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made loading for GFM Inputs conditional
Double check if already initialised
parent
63124283
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
13 deletions
+34
-13
app/assets/javascripts/behaviors/index.js
app/assets/javascripts/behaviors/index.js
+20
-2
app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js
...ssets/javascripts/behaviors/markdown/gfm_auto_complete.js
+2
-2
app/assets/javascripts/gfm_auto_complete.js
app/assets/javascripts/gfm_auto_complete.js
+9
-6
app/assets/javascripts/notes/components/comment_form.vue
app/assets/javascripts/notes/components/comment_form.vue
+1
-1
app/assets/javascripts/notes/components/note_form.vue
app/assets/javascripts/notes/components/note_form.vue
+1
-1
spec/frontend/snippets/components/__snapshots__/snippet_description_edit_spec.js.snap
...nents/__snapshots__/snippet_description_edit_spec.js.snap
+1
-1
No files found.
app/assets/javascripts/behaviors/index.js
View file @
355cfa0c
import
$
from
'
jquery
'
;
import
'
./autosize
'
;
import
'
./autosize
'
;
import
'
./bind_in_out
'
;
import
'
./bind_in_out
'
;
import
'
./markdown/render_gfm
'
;
import
'
./markdown/render_gfm
'
;
import
initGFMInput
from
'
./markdown/gfm_auto_complete
'
;
import
initCopyAsGFM
from
'
./markdown/copy_as_gfm
'
;
import
initCopyAsGFM
from
'
./markdown/copy_as_gfm
'
;
import
initCopyToClipboard
from
'
./copy_to_clipboard
'
;
import
initCopyToClipboard
from
'
./copy_to_clipboard
'
;
import
'
./details_behavior
'
;
import
'
./details_behavior
'
;
...
@@ -15,9 +15,27 @@ import initCollapseSidebarOnWindowResize from './collapse_sidebar_on_window_resi
...
@@ -15,9 +15,27 @@ import initCollapseSidebarOnWindowResize from './collapse_sidebar_on_window_resi
import
initSelect2Dropdowns
from
'
./select2
'
;
import
initSelect2Dropdowns
from
'
./select2
'
;
installGlEmojiElement
();
installGlEmojiElement
();
initGFMInput
();
initCopyAsGFM
();
initCopyAsGFM
();
initCopyToClipboard
();
initCopyToClipboard
();
initPageShortcuts
();
initPageShortcuts
();
initCollapseSidebarOnWindowResize
();
initCollapseSidebarOnWindowResize
();
initSelect2Dropdowns
();
initSelect2Dropdowns
();
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
window
.
requestIdleCallback
(
()
=>
{
// Check if we have to Load GFM Input
const
$gfmInputs
=
$
(
'
.js-gfm-input:not(.js-gfm-input-initialized)
'
);
if
(
$gfmInputs
.
length
)
{
import
(
/* webpackChunkName: 'initGFMInput' */
'
./markdown/gfm_auto_complete
'
)
.
then
(({
default
:
initGFMInput
})
=>
{
initGFMInput
(
$gfmInputs
);
})
.
catch
(()
=>
{});
}
},
{
timeout
:
500
},
);
});
app/assets/javascripts/behaviors/markdown/gfm_auto_complete.js
View file @
355cfa0c
...
@@ -2,8 +2,8 @@ import $ from 'jquery';
...
@@ -2,8 +2,8 @@ import $ from 'jquery';
import
GfmAutoComplete
from
'
ee_else_ce/gfm_auto_complete
'
;
import
GfmAutoComplete
from
'
ee_else_ce/gfm_auto_complete
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
import
{
parseBoolean
}
from
'
~/lib/utils/common_utils
'
;
export
default
function
initGFMInput
()
{
export
default
function
initGFMInput
(
$els
)
{
$
(
'
.js-gfm-input:not(.js-vue-textarea)
'
)
.
each
((
i
,
el
)
=>
{
$
els
.
each
((
i
,
el
)
=>
{
const
gfm
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
const
gfm
=
new
GfmAutoComplete
(
gl
.
GfmAutoComplete
&&
gl
.
GfmAutoComplete
.
dataSources
);
const
enableGFM
=
parseBoolean
(
el
.
dataset
.
supportsAutocomplete
);
const
enableGFM
=
parseBoolean
(
el
.
dataset
.
supportsAutocomplete
);
...
...
app/assets/javascripts/gfm_auto_complete.js
View file @
355cfa0c
...
@@ -71,12 +71,15 @@ class GfmAutoComplete {
...
@@ -71,12 +71,15 @@ class GfmAutoComplete {
setupLifecycle
()
{
setupLifecycle
()
{
this
.
input
.
each
((
i
,
input
)
=>
{
this
.
input
.
each
((
i
,
input
)
=>
{
const
$input
=
$
(
input
);
const
$input
=
$
(
input
);
$input
.
off
(
'
focus.setupAtWho
'
).
on
(
'
focus.setupAtWho
'
,
this
.
setupAtWho
.
bind
(
this
,
$input
));
if
(
!
$input
.
hasClass
(
'
js-gfm-input-initialized
'
))
{
$input
.
on
(
'
change.atwho
'
,
()
=>
input
.
dispatchEvent
(
new
Event
(
'
input
'
)));
$input
.
off
(
'
focus.setupAtWho
'
).
on
(
'
focus.setupAtWho
'
,
this
.
setupAtWho
.
bind
(
this
,
$input
));
// This triggers at.js again
$input
.
on
(
'
change.atwho
'
,
()
=>
input
.
dispatchEvent
(
new
Event
(
'
input
'
)));
// Needed for quick actions with suffixes (ex: /label ~)
// This triggers at.js again
$input
.
on
(
'
inserted-commands.atwho
'
,
$input
.
trigger
.
bind
(
$input
,
'
keyup
'
));
// Needed for quick actions with suffixes (ex: /label ~)
$input
.
on
(
'
clear-commands-cache.atwho
'
,
()
=>
this
.
clearCache
());
$input
.
on
(
'
inserted-commands.atwho
'
,
$input
.
trigger
.
bind
(
$input
,
'
keyup
'
));
$input
.
on
(
'
clear-commands-cache.atwho
'
,
()
=>
this
.
clearCache
());
$input
.
addClass
(
'
js-gfm-input-initialized
'
);
}
});
});
}
}
...
...
app/assets/javascripts/notes/components/comment_form.vue
View file @
355cfa0c
...
@@ -380,7 +380,7 @@ export default {
...
@@ -380,7 +380,7 @@ export default {
dir=
"auto"
dir=
"auto"
:disabled=
"isSubmitting"
:disabled=
"isSubmitting"
name=
"note[note]"
name=
"note[note]"
class=
"note-textarea js-vue-comment-form js-note-text js-gfm-input js-autosize markdown-area
js-vue-textarea
qa-comment-input"
class=
"note-textarea js-vue-comment-form js-note-text js-gfm-input js-autosize markdown-area qa-comment-input"
data-supports-quick-actions=
"true"
data-supports-quick-actions=
"true"
:aria-label=
"__('Description')"
:aria-label=
"__('Description')"
:placeholder=
"__('Write a comment or drag your files here…')"
:placeholder=
"__('Write a comment or drag your files here…')"
...
...
app/assets/javascripts/notes/components/note_form.vue
View file @
355cfa0c
...
@@ -337,7 +337,7 @@ export default {
...
@@ -337,7 +337,7 @@ export default {
v-model=
"updatedNoteBody"
v-model=
"updatedNoteBody"
:data-supports-quick-actions=
"!isEditing"
:data-supports-quick-actions=
"!isEditing"
name=
"note[note]"
name=
"note[note]"
class=
"note-textarea js-gfm-input js-note-text js-autosize markdown-area js-vue-issue-note-form
js-vue-textarea
qa-reply-input"
class=
"note-textarea js-gfm-input js-note-text js-autosize markdown-area js-vue-issue-note-form qa-reply-input"
dir=
"auto"
dir=
"auto"
:aria-label=
"__('Description')"
:aria-label=
"__('Description')"
:placeholder=
"__('Write a comment or drag your files here…')"
:placeholder=
"__('Write a comment or drag your files here…')"
...
...
spec/frontend/snippets/components/__snapshots__/snippet_description_edit_spec.js.snap
View file @
355cfa0c
...
@@ -41,7 +41,7 @@ exports[`Snippet Description Edit component rendering matches the snapshot 1`] =
...
@@ -41,7 +41,7 @@ exports[`Snippet Description Edit component rendering matches the snapshot 1`] =
>
>
<textarea
<textarea
aria-label="Description"
aria-label="Description"
class="note-textarea js-gfm-input js-autosize markdown-area"
class="note-textarea js-gfm-input js-autosize markdown-area
js-gfm-input-initialized
"
data-qa-selector="snippet_description_field"
data-qa-selector="snippet_description_field"
data-supports-quick-actions="false"
data-supports-quick-actions="false"
dir="auto"
dir="auto"
...
...
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