Commit 0112a50b authored by Enrique Alcantara's avatar Enrique Alcantara

Code review feedback

- Add inline comment about padding in contenteditable
element
- Use icon button instead of icon inside a button
- Consolidate labels
- Validate that ContentEditor is provided a valid
TipTap Editor instance
parent cc2b5e1a
<script> <script>
import { EditorContent } from 'tiptap'; import { EditorContent, Editor } from 'tiptap';
import TopToolbar from './top_toolbar.vue'; import TopToolbar from './top_toolbar.vue';
export default { export default {
...@@ -11,6 +11,7 @@ export default { ...@@ -11,6 +11,7 @@ export default {
editor: { editor: {
type: Object, type: Object,
required: true, required: true,
validator: (editor) => editor instanceof Editor,
}, },
}, },
}; };
......
<script> <script>
import { GlButton, GlIcon, GlTooltipDirective as GlTooltip } from '@gitlab/ui'; import { GlButton, GlTooltipDirective as GlTooltip } from '@gitlab/ui';
export default { export default {
components: { components: {
GlButton, GlButton,
GlIcon,
}, },
directives: { directives: {
GlTooltip, GlTooltip,
...@@ -55,11 +54,11 @@ export default { ...@@ -55,11 +54,11 @@ export default {
v-gl-tooltip v-gl-tooltip
category="tertiary" category="tertiary"
size="small" size="small"
class="gl-mx-2"
:class="{ active: isActive }" :class="{ active: isActive }"
:aria-label="label" :aria-label="label"
:title="label" :title="label"
:icon="iconName"
@click="execute" @click="execute"
> />
<gl-icon :name="iconName" :size="16" />
</gl-button>
</template> </template>
...@@ -23,14 +23,14 @@ export default { ...@@ -23,14 +23,14 @@ export default {
data-testid="bold" data-testid="bold"
content-type="bold" content-type="bold"
icon-name="bold" icon-name="bold"
:label="__('Bold')" :label="__('Bold text')"
:editor="editor" :editor="editor"
/> />
<toolbar-button <toolbar-button
data-testid="italic" data-testid="italic"
content-type="italic" content-type="italic"
icon-name="italic" icon-name="italic"
:label="__('Italic')" :label="__('Italic text')"
:editor="editor" :editor="editor"
/> />
<toolbar-button <toolbar-button
......
...@@ -39,6 +39,11 @@ const createEditor = async ({ content, renderMarkdown, serializer: customSeriali ...@@ -39,6 +39,11 @@ const createEditor = async ({ content, renderMarkdown, serializer: customSeriali
], ],
editorProps: { editorProps: {
attributes: { attributes: {
/*
* Adds some padding to the contenteditable element where the user types.
* Otherwise, the text cursor is not visible when its position is at the
* beginning of a line.
*/
class: 'gl-py-4 gl-px-5', class: 'gl-py-4 gl-px-5',
}, },
}, },
......
...@@ -5229,9 +5229,6 @@ msgstr "" ...@@ -5229,9 +5229,6 @@ msgstr ""
msgid "Board|Load more issues" msgid "Board|Load more issues"
msgstr "" msgstr ""
msgid "Bold"
msgstr ""
msgid "Bold text" msgid "Bold text"
msgstr "" msgstr ""
...@@ -17902,9 +17899,6 @@ msgstr "" ...@@ -17902,9 +17899,6 @@ msgstr ""
msgid "It's you" msgid "It's you"
msgstr "" msgstr ""
msgid "Italic"
msgstr ""
msgid "Italic text" msgid "Italic text"
msgstr "" msgstr ""
......
// Jest Snapshot v1, https://goo.gl/fbAQLP // Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`content_editor/components/toolbar_button displays tertiary, small button with a provided label and icon 1`] = ` exports[`content_editor/components/toolbar_button displays tertiary, small button with a provided label and icon 1`] = `
"<b-button-stub event=\\"click\\" routertag=\\"a\\" size=\\"sm\\" variant=\\"default\\" type=\\"button\\" tag=\\"button\\" aria-label=\\"Bold\\" title=\\"Bold\\" class=\\"gl-button btn-default-tertiary\\"> "<b-button-stub event=\\"click\\" routertag=\\"a\\" size=\\"sm\\" variant=\\"default\\" type=\\"button\\" tag=\\"button\\" aria-label=\\"Bold\\" title=\\"Bold\\" class=\\"gl-mx-2 gl-button btn-default-tertiary btn-icon\\">
<!----> <!---->
<!----> <span class=\\"gl-button-text\\"><gl-icon-stub name=\\"bold\\" size=\\"16\\"></gl-icon-stub></span></b-button-stub>" <gl-icon-stub name=\\"bold\\" size=\\"16\\" class=\\"gl-button-icon\\"></gl-icon-stub>
<!---->
</b-button-stub>"
`; `;
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