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
ea267796
Commit
ea267796
authored
Aug 09, 2021
by
Jarek Ostrowski
Committed by
Enrique Alcántara
Aug 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate md header buttons to gl-buttons
Changelog: changed
parent
64f3d893
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
132 additions
and
161 deletions
+132
-161
app/assets/javascripts/vue_shared/components/markdown/header.vue
...ets/javascripts/vue_shared/components/markdown/header.vue
+117
-118
app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue
...scripts/vue_shared/components/markdown/toolbar_button.vue
+8
-7
app/assets/stylesheets/framework/markdown_area.scss
app/assets/stylesheets/framework/markdown_area.scss
+3
-32
app/assets/stylesheets/framework/secondary_navigation_elements.scss
.../stylesheets/framework/secondary_navigation_elements.scss
+0
-1
app/assets/stylesheets/pages/note_form.scss
app/assets/stylesheets/pages/note_form.scss
+2
-2
spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js
...end/vue_shared/components/markdown/toolbar_button_spec.js
+2
-1
No files found.
app/assets/javascripts/vue_shared/components/markdown/header.vue
View file @
ea267796
<
script
>
<
script
>
import
{
GlPopover
,
GlButton
,
GlTooltipDirective
,
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
GlPopover
,
GlButton
,
GlTooltipDirective
}
from
'
@gitlab/ui
'
;
import
$
from
'
jquery
'
;
import
$
from
'
jquery
'
;
import
{
keysFor
,
BOLD_TEXT
,
ITALIC_TEXT
,
LINK_TEXT
}
from
'
~/behaviors/shortcuts/keybindings
'
;
import
{
keysFor
,
BOLD_TEXT
,
ITALIC_TEXT
,
LINK_TEXT
}
from
'
~/behaviors/shortcuts/keybindings
'
;
import
{
getSelectedFragment
}
from
'
~/lib/utils/common_utils
'
;
import
{
getSelectedFragment
}
from
'
~/lib/utils/common_utils
'
;
...
@@ -10,7 +10,6 @@ import ToolbarButton from './toolbar_button.vue';
...
@@ -10,7 +10,6 @@ import ToolbarButton from './toolbar_button.vue';
export
default
{
export
default
{
components
:
{
components
:
{
ToolbarButton
,
ToolbarButton
,
GlIcon
,
GlPopover
,
GlPopover
,
GlButton
,
GlButton
,
},
},
...
@@ -46,6 +45,7 @@ export default {
...
@@ -46,6 +45,7 @@ export default {
data
()
{
data
()
{
return
{
return
{
tag
:
'
>
'
,
tag
:
'
>
'
,
suggestPopoverVisible
:
false
,
};
};
},
},
computed
:
{
computed
:
{
...
@@ -76,15 +76,27 @@ export default {
...
@@ -76,15 +76,27 @@ export default {
return
this
.
isMac
?
'
⌘
'
:
s__
(
'
KeyboardKey|Ctrl+
'
);
return
this
.
isMac
?
'
⌘
'
:
s__
(
'
KeyboardKey|Ctrl+
'
);
},
},
},
},
watch
:
{
showSuggestPopover
()
{
this
.
updateSuggestPopoverVisibility
();
},
},
mounted
()
{
mounted
()
{
$
(
document
).
on
(
'
markdown-preview:show.vue
'
,
this
.
previewMarkdownTab
);
$
(
document
).
on
(
'
markdown-preview:show.vue
'
,
this
.
previewMarkdownTab
);
$
(
document
).
on
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
$
(
document
).
on
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
this
.
updateSuggestPopoverVisibility
();
},
},
beforeDestroy
()
{
beforeDestroy
()
{
$
(
document
).
off
(
'
markdown-preview:show.vue
'
,
this
.
previewMarkdownTab
);
$
(
document
).
off
(
'
markdown-preview:show.vue
'
,
this
.
previewMarkdownTab
);
$
(
document
).
off
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
$
(
document
).
off
(
'
markdown-preview:hide.vue
'
,
this
.
writeMarkdownTab
);
},
},
methods
:
{
methods
:
{
async
updateSuggestPopoverVisibility
()
{
await
this
.
$nextTick
();
this
.
suggestPopoverVisible
=
this
.
showSuggestPopover
&&
this
.
canSuggest
;
},
isValid
(
form
)
{
isValid
(
form
)
{
return
(
return
(
!
form
||
!
form
||
...
@@ -153,127 +165,114 @@ export default {
...
@@ -153,127 +165,114 @@ export default {
</button>
</button>
</li>
</li>
<li
:class=
"
{ active: !previewMarkdown }" class="md-header-toolbar">
<li
:class=
"
{ active: !previewMarkdown }" class="md-header-toolbar">
<div
class=
"d-inline-block"
>
<toolbar-button
<toolbar-button
tag=
"**"
tag=
"**"
:button-title=
"
:button-title=
"
sprintf(s__('MarkdownEditor|Add bold text (%
{modifierKey}B)'), { modifierKey })
sprintf(s__('MarkdownEditor|Add bold text (%
{modifierKey}B)'), { modifierKey })
"
"
:shortcuts="$options.shortcuts.bold"
:shortcuts="$options.shortcuts.bold"
icon="bold"
icon="bold"
/>
/>
<toolbar-button
<toolbar-button
tag=
"_"
tag=
"_"
:button-title=
"
:button-title=
"
sprintf(s__('MarkdownEditor|Add italic text (%
{modifierKey}I)'), { modifierKey })
sprintf(s__('MarkdownEditor|Add italic text (%
{modifierKey}I)'), { modifierKey })
"
"
:shortcuts="$options.shortcuts.italic"
:shortcuts="$options.shortcuts.italic"
icon="italic"
icon="italic"
/>
/>
<toolbar-button
:prepend=
"true"
:tag=
"tag"
:button-title=
"__('Insert a quote')"
icon=
"quote"
@
click=
"handleQuote"
/>
<template
v-if=
"canSuggest"
>
<toolbar-button
<toolbar-button
ref=
"suggestButton"
:tag=
"mdSuggestion"
:prepend=
"true"
:prepend=
"true"
:tag=
"tag"
:button-title=
"__('Insert suggestion')"
:button-title=
"__('Insert a quote')"
:cursor-offset=
"4"
icon=
"quote"
:tag-content=
"lineContent"
@
click=
"handleQuote"
icon=
"doc-code"
data-qa-selector=
"suggestion_button"
class=
"js-suggestion-btn"
@
click=
"handleSuggestDismissed"
/>
/>
</div>
<gl-popover
<div
class=
"d-inline-block ml-md-2 ml-0"
>
v-if=
"suggestPopoverVisible"
<template
v-if=
"canSuggest"
>
:target=
"$refs.suggestButton.$el"
<toolbar-button
:css-classes=
"['diff-suggest-popover']"
ref=
"suggestButton"
placement=
"bottom"
:tag=
"mdSuggestion"
:show=
"suggestPopoverVisible"
:prepend=
"true"
>
:button-title=
"__('Insert suggestion')"
<strong>
{{
__
(
'
New! Suggest changes directly
'
)
}}
</strong>
:cursor-offset=
"4"
<p
class=
"mb-2"
>
:tag-content=
"lineContent"
{{
icon=
"doc-code"
__
(
data-qa-selector=
"suggestion_button"
'
Suggest code changes which can be immediately applied in one click. Try it out!
'
,
class=
"js-suggestion-btn"
)
}}
</p>
<gl-button
variant=
"info"
category=
"primary"
size=
"small"
@
click=
"handleSuggestDismissed"
@
click=
"handleSuggestDismissed"
/>
<gl-popover
v-if=
"showSuggestPopover && $refs.suggestButton"
:target=
"$refs.suggestButton"
:css-classes=
"['diff-suggest-popover']"
placement=
"bottom"
:show=
"showSuggestPopover"
>
>
<strong>
{{
__
(
'
New! Suggest changes directly
'
)
}}
</strong>
{{
__
(
'
Got it
'
)
}}
<p
class=
"mb-2"
>
</gl-button>
{{
</gl-popover>
__
(
</
template
>
'
Suggest code changes which can be immediately applied in one click. Try it out!
'
,
<toolbar-button
tag=
"`"
tag-block=
"```"
:button-title=
"__('Insert code')"
icon=
"code"
/>
)
<toolbar-button
}}
tag=
"[{text}](url)"
</p>
tag-select=
"url"
<gl-button
:button-title=
"
variant=
"info"
sprintf(s__('MarkdownEditor|Add a link (%{modifierKey}K)'), { modifierKey })
category=
"primary"
"
size=
"sm"
:shortcuts=
"$options.shortcuts.link"
@
click=
"handleSuggestDismissed"
icon=
"link"
>
/>
{{
__
(
'
Got it
'
)
}}
<toolbar-button
</gl-button>
:prepend=
"true"
</gl-popover>
tag=
"- "
</
template
>
:button-title=
"__('Add a bullet list')"
<toolbar-button
tag=
"`"
tag-block=
"```"
:button-title=
"__('Insert code')"
icon=
"code"
/>
icon=
"list-bulleted"
<toolbar-button
/>
tag=
"[{text}](url)"
<toolbar-button
tag-select=
"url"
:prepend=
"true"
:button-title=
"
tag=
"1. "
sprintf(s__('MarkdownEditor|Add a link (%{modifierKey}K)'), { modifierKey })
:button-title=
"__('Add a numbered list')"
"
icon=
"list-numbered"
:shortcuts=
"$options.shortcuts.link"
/>
icon=
"link"
<toolbar-button
/>
:prepend=
"true"
</div>
tag=
"- [ ] "
<div
class=
"d-inline-block ml-md-2 ml-0"
>
:button-title=
"__('Add a task list')"
<toolbar-button
icon=
"list-task"
:prepend=
"true"
/>
tag=
"- "
<toolbar-button
:button-title=
"__('Add a bullet list')"
:tag=
"mdCollapsibleSection"
icon=
"list-bulleted"
:prepend=
"true"
/>
tag-select=
"Click to expand"
<toolbar-button
:button-title=
"__('Add a collapsible section')"
:prepend=
"true"
icon=
"details-block"
tag=
"1. "
/>
:button-title=
"__('Add a numbered list')"
<toolbar-button
icon=
"list-numbered"
:tag=
"mdTable"
/>
:prepend=
"true"
<toolbar-button
:button-title=
"__('Add a table')"
:prepend=
"true"
icon=
"table"
tag=
"- [ ] "
/>
:button-title=
"__('Add a task list')"
<toolbar-button
icon=
"list-task"
class=
"js-zen-enter"
/>
:prepend=
"true"
<toolbar-button
:button-title=
"__('Go full screen')"
:tag=
"mdCollapsibleSection"
icon=
"maximize"
:prepend=
"true"
/>
tag-select=
"Click to expand"
:button-title=
"__('Add a collapsible section')"
icon=
"details-block"
/>
<toolbar-button
:tag=
"mdTable"
:prepend=
"true"
:button-title=
"__('Add a table')"
icon=
"table"
/>
</div>
<div
class=
"d-inline-block ml-md-2 ml-0"
>
<button
v-gl-tooltip
:aria-label=
"__('Go full screen')"
class=
"toolbar-btn toolbar-fullscreen-btn js-zen-enter"
data-container=
"body"
tabindex=
"-1"
:title=
"__('Go full screen')"
type=
"button"
>
<gl-icon
name=
"maximize"
/>
</button>
</div>
</li>
</li>
</ul>
</ul>
</div>
</div>
...
...
app/assets/javascripts/vue_shared/components/markdown/toolbar_button.vue
View file @
ea267796
<
script
>
<
script
>
import
{
GlTooltipDirective
,
Gl
Ic
on
}
from
'
@gitlab/ui
'
;
import
{
GlTooltipDirective
,
Gl
Butt
on
}
from
'
@gitlab/ui
'
;
export
default
{
export
default
{
components
:
{
components
:
{
Gl
Ic
on
,
Gl
Butt
on
,
},
},
directives
:
{
directives
:
{
GlTooltip
:
GlTooltipDirective
,
GlTooltip
:
GlTooltipDirective
,
...
@@ -19,7 +19,8 @@ export default {
...
@@ -19,7 +19,8 @@ export default {
},
},
tag
:
{
tag
:
{
type
:
String
,
type
:
String
,
required
:
true
,
required
:
false
,
default
:
''
,
},
},
tagBlock
:
{
tagBlock
:
{
type
:
String
,
type
:
String
,
...
@@ -71,7 +72,7 @@ export default {
...
@@ -71,7 +72,7 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<button
<
gl-
button
v-gl-tooltip
v-gl-tooltip
:data-md-tag=
"tag"
:data-md-tag=
"tag"
:data-md-cursor-offset=
"cursorOffset"
:data-md-cursor-offset=
"cursorOffset"
...
@@ -82,11 +83,11 @@ export default {
...
@@ -82,11 +83,11 @@ export default {
:data-md-shortcuts=
"shortcutsString"
:data-md-shortcuts=
"shortcutsString"
:title=
"buttonTitle"
:title=
"buttonTitle"
:aria-label=
"buttonTitle"
:aria-label=
"buttonTitle"
:icon=
"icon"
type=
"button"
type=
"button"
category=
"tertiary"
class=
"toolbar-btn js-md"
class=
"toolbar-btn js-md"
data-container=
"body"
data-container=
"body"
@
click=
"() => $emit('click')"
@
click=
"() => $emit('click')"
>
/>
<gl-icon
:name=
"icon"
/>
</button>
</
template
>
</
template
>
app/assets/stylesheets/framework/markdown_area.scss
View file @
ea267796
...
@@ -83,6 +83,7 @@
...
@@ -83,6 +83,7 @@
li
.md-header-toolbar
{
li
.md-header-toolbar
{
margin-left
:
auto
;
margin-left
:
auto
;
display
:
none
;
display
:
none
;
padding-bottom
:
$gl-padding-8
;
&
.active
{
&
.active
{
display
:
block
;
display
:
block
;
...
@@ -91,9 +92,9 @@
...
@@ -91,9 +92,9 @@
flex
:
none
;
flex
:
none
;
display
:
flex
;
display
:
flex
;
justify-content
:
center
;
justify-content
:
center
;
flex-wrap
:
wrap
;
margin-top
:
$gl-padding-8
;
width
:
100%
;
width
:
100%
;
padding-top
:
$gl-padding-top
;
padding-bottom
:
$gl-padding-top
;
}
}
}
}
}
}
...
@@ -131,36 +132,6 @@
...
@@ -131,36 +132,6 @@
width
:
100%
;
width
:
100%
;
}
}
.toolbar-btn
{
float
:
left
;
padding
:
0
7px
;
background
:
transparent
;
border
:
0
;
outline
:
0
;
svg
{
width
:
14px
;
height
:
14px
;
vertical-align
:
middle
;
fill
:
$gl-text-color-secondary
;
}
&
:hover
,
&
:focus
{
svg
{
fill
:
$blue-600
;
}
}
}
.toolbar-fullscreen-btn
{
margin-right
:
-5px
;
@include
media-breakpoint-down
(
xs
)
{
margin-right
:
0
;
}
}
.md-suggestion-diff
{
.md-suggestion-diff
{
display
:
table
!
important
;
display
:
table
!
important
;
border
:
1px
solid
$border-color
!
important
;
border
:
1px
solid
$border-color
!
important
;
...
...
app/assets/stylesheets/framework/secondary_navigation_elements.scss
View file @
ea267796
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
a
,
a
,
button
{
button
{
padding
:
$gl-padding-8
;
padding
:
$gl-padding-8
;
padding-bottom
:
$gl-padding-8
+
1
;
font-size
:
14px
;
font-size
:
14px
;
line-height
:
28px
;
line-height
:
28px
;
color
:
$gl-text-color-secondary
;
color
:
$gl-text-color-secondary
;
...
...
app/assets/stylesheets/pages/note_form.scss
View file @
ea267796
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
.common-note-form
{
.common-note-form
{
.md-area
{
.md-area
{
padding
:
$gl-padding-
top
$gl-padding
;
padding
:
$gl-padding-
8
$gl-padding
;
border
:
1px
solid
$border-color
;
border
:
1px
solid
$border-color
;
border-radius
:
$border-radius-base
;
border-radius
:
$border-radius-base
;
transition
:
border-color
ease-in-out
0
.15s
,
transition
:
border-color
ease-in-out
0
.15s
,
...
@@ -323,7 +323,7 @@ table {
...
@@ -323,7 +323,7 @@ table {
}
}
.comment-toolbar
{
.comment-toolbar
{
padding-top
:
$gl-padding-
top
;
padding-top
:
$gl-padding-
8
;
color
:
$gl-text-color-secondary
;
color
:
$gl-text-color-secondary
;
border-top
:
1px
solid
$border-color
;
border-top
:
1px
solid
$border-color
;
}
}
...
...
spec/frontend/vue_shared/components/markdown/toolbar_button_spec.js
View file @
ea267796
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
ToolbarButton
from
'
~/vue_shared/components/markdown/toolbar_button.vue
'
;
import
ToolbarButton
from
'
~/vue_shared/components/markdown/toolbar_button.vue
'
;
...
@@ -25,7 +26,7 @@ describe('toolbar_button', () => {
...
@@ -25,7 +26,7 @@ describe('toolbar_button', () => {
});
});
const
getButtonShortcutsAttr
=
()
=>
{
const
getButtonShortcutsAttr
=
()
=>
{
return
wrapper
.
find
(
'
button
'
).
attributes
(
'
data-md-shortcuts
'
);
return
wrapper
.
find
(
GlButton
).
attributes
(
'
data-md-shortcuts
'
);
};
};
describe
(
'
keyboard shortcuts
'
,
()
=>
{
describe
(
'
keyboard shortcuts
'
,
()
=>
{
...
...
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