Commit fa424e62 authored by Enrique Alcantara's avatar Enrique Alcantara

Include text styles dropdown in top toolbar

parent 81be441f
...@@ -4,6 +4,7 @@ import { CONTENT_EDITOR_TRACKING_LABEL, TOOLBAR_CONTROL_TRACKING_ACTION } from ' ...@@ -4,6 +4,7 @@ import { CONTENT_EDITOR_TRACKING_LABEL, TOOLBAR_CONTROL_TRACKING_ACTION } from '
import { ContentEditor } from '../services/content_editor'; import { ContentEditor } from '../services/content_editor';
import Divider from './divider.vue'; import Divider from './divider.vue';
import ToolbarButton from './toolbar_button.vue'; import ToolbarButton from './toolbar_button.vue';
import ToolbarTextStyleDropdown from './toolbar_text_style_dropdown.vue';
const trackingMixin = Tracking.mixin({ const trackingMixin = Tracking.mixin({
label: CONTENT_EDITOR_TRACKING_LABEL, label: CONTENT_EDITOR_TRACKING_LABEL,
...@@ -12,6 +13,7 @@ const trackingMixin = Tracking.mixin({ ...@@ -12,6 +13,7 @@ const trackingMixin = Tracking.mixin({
export default { export default {
components: { components: {
ToolbarButton, ToolbarButton,
ToolbarTextStyleDropdown,
Divider, Divider,
}, },
mixins: [trackingMixin], mixins: [trackingMixin],
...@@ -35,6 +37,12 @@ export default { ...@@ -35,6 +37,12 @@ export default {
<div <div
class="gl-display-flex gl-justify-content-end gl-pb-3 gl-pt-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-200" class="gl-display-flex gl-justify-content-end gl-pb-3 gl-pt-0 gl-border-b-solid gl-border-b-1 gl-border-b-gray-200"
> >
<toolbar-text-style-dropdown
data-testid="text-styles"
:tiptap-editor="contentEditor.tiptapEditor"
@execute="trackToolbarControlExecution"
/>
<divider />
<toolbar-button <toolbar-button
data-testid="bold" data-testid="bold"
content-type="bold" content-type="bold"
......
...@@ -39,32 +39,33 @@ describe('content_editor/components/top_toolbar', () => { ...@@ -39,32 +39,33 @@ describe('content_editor/components/top_toolbar', () => {
}); });
describe.each` describe.each`
testId | buttonProps testId | controlProps
${'bold'} | ${{ contentType: 'bold', iconName: 'bold', label: 'Bold text', editorCommand: 'toggleBold' }} ${'bold'} | ${{ contentType: 'bold', iconName: 'bold', label: 'Bold text', editorCommand: 'toggleBold' }}
${'italic'} | ${{ contentType: 'italic', iconName: 'italic', label: 'Italic text', editorCommand: 'toggleItalic' }} ${'italic'} | ${{ contentType: 'italic', iconName: 'italic', label: 'Italic text', editorCommand: 'toggleItalic' }}
${'code'} | ${{ contentType: 'code', iconName: 'code', label: 'Code', editorCommand: 'toggleCode' }} ${'code'} | ${{ contentType: 'code', iconName: 'code', label: 'Code', editorCommand: 'toggleCode' }}
${'blockquote'} | ${{ contentType: 'blockquote', iconName: 'quote', label: 'Insert a quote', editorCommand: 'toggleBlockquote' }} ${'blockquote'} | ${{ contentType: 'blockquote', iconName: 'quote', label: 'Insert a quote', editorCommand: 'toggleBlockquote' }}
${'bullet-list'} | ${{ contentType: 'bulletList', iconName: 'list-bulleted', label: 'Add a bullet list', editorCommand: 'toggleBulletList' }} ${'bullet-list'} | ${{ contentType: 'bulletList', iconName: 'list-bulleted', label: 'Add a bullet list', editorCommand: 'toggleBulletList' }}
${'ordered-list'} | ${{ contentType: 'orderedList', iconName: 'list-numbered', label: 'Add a numbered list', editorCommand: 'toggleOrderedList' }} ${'ordered-list'} | ${{ contentType: 'orderedList', iconName: 'list-numbered', label: 'Add a numbered list', editorCommand: 'toggleOrderedList' }}
`('given a $testId toolbar control', ({ testId, buttonProps }) => { ${'text-styles'} | ${{}}
`('given a $testId toolbar control', ({ testId, controlProps }) => {
beforeEach(() => { beforeEach(() => {
buildWrapper(); buildWrapper();
}); });
it('renders the toolbar control with the provided properties', () => { it('renders the toolbar control with the provided properties', () => {
expect(wrapper.findByTestId(testId).props()).toEqual({ expect(wrapper.findByTestId(testId).props()).toEqual({
...buttonProps, ...controlProps,
tiptapEditor: contentEditor.tiptapEditor, tiptapEditor: contentEditor.tiptapEditor,
}); });
}); });
it.each` it.each`
control | eventData eventData
${'bold'} | ${{ contentType: 'bold' }} ${{ contentType: 'bold' }}
${'blockquote'} | ${{ contentType: 'blockquote', value: 1 }} ${{ contentType: 'blockquote', value: 1 }}
`('tracks the execution of toolbar controls', ({ control, eventData }) => { `('tracks the execution of toolbar controls', ({ eventData }) => {
const { contentType, value } = eventData; const { contentType, value } = eventData;
wrapper.findByTestId(control).vm.$emit('execute', eventData); wrapper.findByTestId(testId).vm.$emit('execute', eventData);
expect(trackingSpy).toHaveBeenCalledWith(undefined, TOOLBAR_CONTROL_TRACKING_ACTION, { expect(trackingSpy).toHaveBeenCalledWith(undefined, TOOLBAR_CONTROL_TRACKING_ACTION, {
label: CONTENT_EDITOR_TRACKING_LABEL, label: CONTENT_EDITOR_TRACKING_LABEL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment