Commit d78772ff authored by Savas Vedova's avatar Savas Vedova

Merge branch 'fix-formatting-bubble-menu-content-editor' into 'master'

Fix formatting bubble menu in Content Editor

See merge request gitlab-org/gitlab!69324
parents d1062c16 a9c73f18
...@@ -100,11 +100,13 @@ export default { ...@@ -100,11 +100,13 @@ export default {
:class="{ 'is-focused': focused }" :class="{ 'is-focused': focused }"
> >
<top-toolbar ref="toolbar" class="gl-mb-4" /> <top-toolbar ref="toolbar" class="gl-mb-4" />
<formatting-bubble-menu />
<div v-if="isLoadingContent" class="gl-w-full gl-display-flex gl-justify-content-center"> <div v-if="isLoadingContent" class="gl-w-full gl-display-flex gl-justify-content-center">
<gl-loading-icon size="sm" /> <gl-loading-icon size="sm" />
</div> </div>
<tiptap-editor-content v-else class="md" :editor="contentEditor.tiptapEditor" /> <template v-else>
<formatting-bubble-menu />
<tiptap-editor-content class="md" :editor="contentEditor.tiptapEditor" />
</template>
</div> </div>
</div> </div>
</content-editor-provider> </content-editor-provider>
......
...@@ -20,7 +20,11 @@ export default { ...@@ -20,7 +20,11 @@ export default {
}; };
</script> </script>
<template> <template>
<bubble-menu class="gl-shadow gl-rounded-base" :editor="tiptapEditor"> <bubble-menu
data-testid="formatting-bubble-menu"
class="gl-shadow gl-rounded-base"
:editor="tiptapEditor"
>
<gl-button-group> <gl-button-group>
<toolbar-button <toolbar-button
data-testid="bold" data-testid="bold"
......
...@@ -6,6 +6,7 @@ import ContentEditor from '~/content_editor/components/content_editor.vue'; ...@@ -6,6 +6,7 @@ import ContentEditor from '~/content_editor/components/content_editor.vue';
import ContentEditorError from '~/content_editor/components/content_editor_error.vue'; import ContentEditorError from '~/content_editor/components/content_editor_error.vue';
import ContentEditorProvider from '~/content_editor/components/content_editor_provider.vue'; import ContentEditorProvider from '~/content_editor/components/content_editor_provider.vue';
import EditorStateObserver from '~/content_editor/components/editor_state_observer.vue'; import EditorStateObserver from '~/content_editor/components/editor_state_observer.vue';
import FormattingBubbleMenu from '~/content_editor/components/formatting_bubble_menu.vue';
import TopToolbar from '~/content_editor/components/top_toolbar.vue'; import TopToolbar from '~/content_editor/components/top_toolbar.vue';
import { import {
LOADING_CONTENT_EVENT, LOADING_CONTENT_EVENT,
...@@ -25,6 +26,7 @@ describe('ContentEditor', () => { ...@@ -25,6 +26,7 @@ describe('ContentEditor', () => {
const findEditorElement = () => wrapper.findByTestId('content-editor'); const findEditorElement = () => wrapper.findByTestId('content-editor');
const findEditorContent = () => wrapper.findComponent(EditorContent); const findEditorContent = () => wrapper.findComponent(EditorContent);
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findBubbleMenu = () => wrapper.findComponent(FormattingBubbleMenu);
const createWrapper = (propsData = {}) => { const createWrapper = (propsData = {}) => {
renderMarkdown = jest.fn(); renderMarkdown = jest.fn();
...@@ -131,6 +133,10 @@ describe('ContentEditor', () => { ...@@ -131,6 +133,10 @@ describe('ContentEditor', () => {
it('hides EditorContent component', () => { it('hides EditorContent component', () => {
expect(findEditorContent().exists()).toBe(false); expect(findEditorContent().exists()).toBe(false);
}); });
it('hides formatting bubble menu', () => {
expect(findBubbleMenu().exists()).toBe(false);
});
}); });
describe('when loading content succeeds', () => { describe('when loading content succeeds', () => {
...@@ -171,5 +177,9 @@ describe('ContentEditor', () => { ...@@ -171,5 +177,9 @@ describe('ContentEditor', () => {
it('displays EditorContent component', () => { it('displays EditorContent component', () => {
expect(findEditorContent().exists()).toBe(true); expect(findEditorContent().exists()).toBe(true);
}); });
it('displays formatting bubble menu', () => {
expect(findBubbleMenu().exists()).toBe(true);
});
}); });
}); });
# frozen_string_literal: true
RSpec.shared_examples 'edits content using the content editor' do
it 'formats text as bold using bubble menu' do
content_editor_testid = '[data-testid="content-editor"] [contenteditable]'
expect(page).to have_css(content_editor_testid)
find(content_editor_testid).send_keys 'Typing text in the content editor'
find(content_editor_testid).send_keys [:shift, :left]
expect(page).to have_css('[data-testid="formatting-bubble-menu"]')
end
end
...@@ -136,6 +136,14 @@ RSpec.shared_examples 'User updates wiki page' do ...@@ -136,6 +136,14 @@ RSpec.shared_examples 'User updates wiki page' do
expect(find('textarea#wiki_content').value).to eq('Updated Wiki Content') expect(find('textarea#wiki_content').value).to eq('Updated Wiki Content')
end end
end end
context 'when using the content editor' do
before do
click_button 'Use the new editor'
end
it_behaves_like 'edits content using the content editor'
end
end end
context 'when the page is in a subdir', :js do context 'when the page is in a subdir', :js do
......
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