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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
242820e2
Commit
242820e2
authored
Apr 11, 2018
by
Simon Knox
Committed by
Fatih Acet
Apr 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "When editing a comment in an issue, the preview mode is toggled in the main textarea"
parent
2a7d011a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
19 deletions
+29
-19
app/assets/javascripts/vue_shared/components/markdown/header.vue
...ets/javascripts/vue_shared/components/markdown/header.vue
+6
-4
changelogs/unreleased/44697-prevue.yml
changelogs/unreleased/44697-prevue.yml
+5
-0
spec/javascripts/vue_shared/components/markdown/header_spec.js
...javascripts/vue_shared/components/markdown/header_spec.js
+18
-15
No files found.
app/assets/javascripts/vue_shared/components/markdown/header.vue
View file @
242820e2
...
...
@@ -27,20 +27,22 @@
$
(
document
).
off
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
},
methods
:
{
isMarkdownForm
(
form
)
{
return
form
&&
!
form
.
find
(
'
.js-vue-markdown-field
'
).
length
;
isValid
(
form
)
{
return
!
form
||
form
.
find
(
'
.js-vue-markdown-field
'
).
length
||
$
(
this
.
$el
).
closest
(
'
form
'
)
===
form
[
0
];
},
previewMarkdownTab
(
event
,
form
)
{
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
this
.
isMarkdownForm
(
form
))
return
;
if
(
!
this
.
isValid
(
form
))
return
;
this
.
$emit
(
'
preview-markdown
'
);
},
writeMarkdownTab
(
event
,
form
)
{
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
this
.
isMarkdownForm
(
form
))
return
;
if
(
!
this
.
isValid
(
form
))
return
;
this
.
$emit
(
'
write-markdown
'
);
},
...
...
changelogs/unreleased/44697-prevue.yml
0 → 100644
View file @
242820e2
---
title
:
Make toggle markdown preview shortcut only toggle selected field
merge_request
:
author
:
type
:
fixed
spec/javascripts/vue_shared/components/markdown/header_spec.js
View file @
242820e2
import
Vue
from
'
vue
'
;
import
$
from
'
jquery
'
;
import
headerComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
describe
(
'
Markdown field header component
'
,
()
=>
{
let
vm
;
beforeEach
(
(
done
)
=>
{
beforeEach
(
done
=>
{
const
Component
=
Vue
.
extend
(
headerComponent
);
vm
=
new
Component
({
...
...
@@ -17,24 +18,18 @@ describe('Markdown field header component', () => {
});
it
(
'
renders markdown buttons
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-md
'
).
length
,
).
toBe
(
7
);
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-md
'
).
length
).
toBe
(
7
);
});
it
(
'
renders `write` link as active when previewMarkdown is false
'
,
()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(1)
'
).
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(1)
'
).
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
});
it
(
'
renders `preview` link as active when previewMarkdown is true
'
,
(
done
)
=>
{
it
(
'
renders `preview` link as active when previewMarkdown is true
'
,
done
=>
{
vm
.
previewMarkdown
=
true
;
Vue
.
nextTick
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(2)
'
).
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(2)
'
).
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
done
();
});
...
...
@@ -52,16 +47,24 @@ describe('Markdown field header component', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
write-markdown
'
);
});
it
(
'
blurs preview link after click
'
,
(
done
)
=>
{
it
(
'
does not emit toggle markdown event when triggered from another form
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
$
(
document
).
triggerHandler
(
'
markdown-preview:show
'
,
[
$
(
'
<form><textarea class="markdown-area"></textarea></textarea></form>
'
),
]);
expect
(
vm
.
$emit
).
not
.
toHaveBeenCalled
();
});
it
(
'
blurs preview link after click
'
,
done
=>
{
const
link
=
vm
.
$el
.
querySelector
(
'
li:nth-child(2) a
'
);
spyOn
(
HTMLElement
.
prototype
,
'
blur
'
);
link
.
click
();
setTimeout
(()
=>
{
expect
(
link
.
blur
,
).
toHaveBeenCalled
();
expect
(
link
.
blur
).
toHaveBeenCalled
();
done
();
});
...
...
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