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
Boxiang Sun
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 @@
...
@@ -27,20 +27,22 @@
$
(
document
).
off
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
$
(
document
).
off
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
},
},
methods
:
{
methods
:
{
isMarkdownForm
(
form
)
{
isValid
(
form
)
{
return
form
&&
!
form
.
find
(
'
.js-vue-markdown-field
'
).
length
;
return
!
form
||
form
.
find
(
'
.js-vue-markdown-field
'
).
length
||
$
(
this
.
$el
).
closest
(
'
form
'
)
===
form
[
0
];
},
},
previewMarkdownTab
(
event
,
form
)
{
previewMarkdownTab
(
event
,
form
)
{
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
this
.
isMarkdownForm
(
form
))
return
;
if
(
!
this
.
isValid
(
form
))
return
;
this
.
$emit
(
'
preview-markdown
'
);
this
.
$emit
(
'
preview-markdown
'
);
},
},
writeMarkdownTab
(
event
,
form
)
{
writeMarkdownTab
(
event
,
form
)
{
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
event
.
target
.
blur
)
event
.
target
.
blur
();
if
(
this
.
isMarkdownForm
(
form
))
return
;
if
(
!
this
.
isValid
(
form
))
return
;
this
.
$emit
(
'
write-markdown
'
);
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
Vue
from
'
vue
'
;
import
$
from
'
jquery
'
;
import
headerComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
import
headerComponent
from
'
~/vue_shared/components/markdown/header.vue
'
;
describe
(
'
Markdown field header component
'
,
()
=>
{
describe
(
'
Markdown field header component
'
,
()
=>
{
let
vm
;
let
vm
;
beforeEach
(
(
done
)
=>
{
beforeEach
(
done
=>
{
const
Component
=
Vue
.
extend
(
headerComponent
);
const
Component
=
Vue
.
extend
(
headerComponent
);
vm
=
new
Component
({
vm
=
new
Component
({
...
@@ -17,24 +18,18 @@ describe('Markdown field header component', () => {
...
@@ -17,24 +18,18 @@ describe('Markdown field header component', () => {
});
});
it
(
'
renders markdown buttons
'
,
()
=>
{
it
(
'
renders markdown buttons
'
,
()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelectorAll
(
'
.js-md
'
).
length
).
toBe
(
7
);
vm
.
$el
.
querySelectorAll
(
'
.js-md
'
).
length
,
).
toBe
(
7
);
});
});
it
(
'
renders `write` link as active when previewMarkdown is false
'
,
()
=>
{
it
(
'
renders `write` link as active when previewMarkdown is false
'
,
()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(1)
'
).
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
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
;
vm
.
previewMarkdown
=
true
;
Vue
.
nextTick
(()
=>
{
Vue
.
nextTick
(()
=>
{
expect
(
expect
(
vm
.
$el
.
querySelector
(
'
li:nth-child(2)
'
).
classList
.
contains
(
'
active
'
)).
toBeTruthy
();
vm
.
$el
.
querySelector
(
'
li:nth-child(2)
'
).
classList
.
contains
(
'
active
'
),
).
toBeTruthy
();
done
();
done
();
});
});
...
@@ -52,16 +47,24 @@ describe('Markdown field header component', () => {
...
@@ -52,16 +47,24 @@ describe('Markdown field header component', () => {
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
write-markdown
'
);
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
'
);
const
link
=
vm
.
$el
.
querySelector
(
'
li:nth-child(2) a
'
);
spyOn
(
HTMLElement
.
prototype
,
'
blur
'
);
spyOn
(
HTMLElement
.
prototype
,
'
blur
'
);
link
.
click
();
link
.
click
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
expect
(
link
.
blur
).
toHaveBeenCalled
();
link
.
blur
,
).
toHaveBeenCalled
();
done
();
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