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
3fc05267
Commit
3fc05267
authored
Nov 01, 2017
by
Luke "Jared" Bennett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let field.vue handle the changing of preview
parent
ce22977f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
13 deletions
+13
-13
app/assets/javascripts/vue_shared/components/markdown/field.vue
...sets/javascripts/vue_shared/components/markdown/field.vue
+4
-2
app/assets/javascripts/vue_shared/components/markdown/header.vue
...ets/javascripts/vue_shared/components/markdown/header.vue
+7
-9
spec/javascripts/vue_shared/components/markdown/field_spec.js
.../javascripts/vue_shared/components/markdown/field_spec.js
+2
-2
No files found.
app/assets/javascripts/vue_shared/components/markdown/field.vue
View file @
3fc05267
...
...
@@ -45,8 +45,10 @@
},
},
methods
:
{
toggleMarkdownPreview
()
{
this
.
previewMarkdown
=
!
this
.
previewMarkdown
;
toggleMarkdownPreview
(
isPreview
)
{
if
(
isPreview
===
this
.
previewMarkdown
)
return
;
this
.
previewMarkdown
=
isPreview
;
/*
Can't use `$refs` as the component is technically in the parent component
...
...
app/assets/javascripts/vue_shared/components/markdown/header.vue
View file @
3fc05267
...
...
@@ -20,16 +20,12 @@
return
form
&&
!
form
.
find
(
'
.js-vue-markdown-field
'
).
length
;
},
isActiveTarget
(
target
)
{
return
target
.
closest
(
'
li
'
).
classList
.
contains
(
'
active
'
);
},
toggleMarkdownPreview
(
e
,
form
)
{
toggleMarkdownPreview
(
e
,
isPreview
,
form
)
{
if
(
e
.
target
.
blur
)
e
.
target
.
blur
();
if
(
this
.
isMarkdownForm
(
form
)
||
this
.
isActiveTarget
(
e
.
target
)
)
return
;
if
(
this
.
isMarkdownForm
(
form
))
return
;
this
.
$emit
(
'
toggle-markdown
'
);
this
.
$emit
(
'
toggle-markdown
'
,
isPreview
);
},
},
mounted
()
{
...
...
@@ -48,17 +44,19 @@
<ul
class=
"nav-links clearfix"
>
<li
:class=
"
{ active: !previewMarkdown }">
<a
class=
"js-write-link"
href=
"#md-write-holder"
tabindex=
"-1"
@
click.prevent=
"toggleMarkdownPreview($event)"
>
@
click.prevent=
"toggleMarkdownPreview($event
, false
)"
>
Write
</a>
</li>
<li
:class=
"
{ active: previewMarkdown }">
<a
class=
"js-preview-link"
href=
"#md-preview-holder"
tabindex=
"-1"
@
click.prevent=
"toggleMarkdownPreview($event)"
>
@
click.prevent=
"toggleMarkdownPreview($event
, true
)"
>
Preview
</a>
</li>
...
...
spec/javascripts/vue_shared/components/markdown/field_spec.js
View file @
3fc05267
...
...
@@ -53,8 +53,8 @@ describe('Markdown field component', () => {
});
}));
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links
li:nth-child(2) a
'
);
writeLink
=
vm
.
$el
.
querySelector
(
'
.nav-links
li:nth-child(1) a
'
);
previewLink
=
vm
.
$el
.
querySelector
(
'
.nav-links
.js-preview-link
'
);
writeLink
=
vm
.
$el
.
querySelector
(
'
.nav-links
js-write-link
'
);
});
it
(
'
sets preview link as active
'
,
(
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