Commit ef6c614e authored by Enrique Alcantara's avatar Enrique Alcantara

Add top toolbar to content editor

parent 83b869ac
<script> <script>
import { EditorContent } from 'tiptap'; import { EditorContent } from 'tiptap';
import createEditor from '../services/create_editor'; import TopToolbar from './top_toolbar.vue';
export default { export default {
components: { components: {
EditorContent, EditorContent,
TopToolbar,
},
props: {
editor: {
type: Object,
required: true,
}, },
data() {
return {
editor: createEditor(),
};
}, },
}; };
</script> </script>
<template> <template>
<editor-content :editor="editor" /> <div
class="gl-display-flex gl-flex-direction-column gl-p-3 gl-border-solid gl-border-1 gl-border-gray-200 gl-rounded-base"
>
<top-toolbar class="gl-mb-3" :editor="editor" />
<editor-content class="md" :editor="editor" />
</div>
</template> </template>
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { EditorContent } from 'tiptap'; import { EditorContent } from 'tiptap';
import ContentEditor from '~/content_editor/components/content_editor.vue'; import ContentEditor from '~/content_editor/components/content_editor.vue';
import TopToolbar from '~/content_editor/components/top_toolbar.vue';
import createEditor from '~/content_editor/services/create_editor'; import createEditor from '~/content_editor/services/create_editor';
import createMarkdownSerializer from '~/content_editor/services/markdown_serializer';
jest.mock('~/content_editor/services/create_editor');
describe('ContentEditor', () => { describe('ContentEditor', () => {
let wrapper; let wrapper;
let editor;
const buildWrapper = () => { const buildWrapper = async () => {
wrapper = shallowMount(ContentEditor); editor = await createEditor({ serializer: createMarkdownSerializer({ toHTML: () => '' }) });
wrapper = shallowMount(ContentEditor, {
propsData: {
editor,
},
});
}; };
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
}); });
it('renders editor content component and attaches editor instance', () => { it('renders editor content component and attaches editor instance', async () => {
const editor = {}; await buildWrapper();
createEditor.mockReturnValueOnce(editor);
buildWrapper();
expect(wrapper.findComponent(EditorContent).props().editor).toBe(editor); expect(wrapper.findComponent(EditorContent).props().editor).toBe(editor);
}); });
it('renders top toolbar component and attaches editor instance', async () => {
await buildWrapper();
expect(wrapper.findComponent(TopToolbar).props().editor).toBe(editor);
});
}); });
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import ToolbarButton from '~/content_editor/components/toolbar_button.vue';
import TopToolbar from '~/content_editor/components/top_toolbar.vue'; import TopToolbar from '~/content_editor/components/top_toolbar.vue';
describe('content_editor/components/top_toolbar', () => { describe('content_editor/components/top_toolbar', () => {
......
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