diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue')
-rw-r--r-- | app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue b/app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue index 2bf32a70cd1..9c1d1faca48 100644 --- a/app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue +++ b/app/assets/javascripts/content_editor/components/toolbar_text_style_dropdown.vue @@ -1,13 +1,12 @@ <script> -import { GlDropdown, GlDropdownItem, GlTooltipDirective as GlTooltip } from '@gitlab/ui'; +import { GlTooltipDirective as GlTooltip, GlCollapsibleListbox } from '@gitlab/ui'; import { __ } from '~/locale'; import { TEXT_STYLE_DROPDOWN_ITEMS } from '../constants'; import EditorStateObserver from './editor_state_observer.vue'; export default { components: { - GlDropdown, - GlDropdownItem, + GlCollapsibleListbox, EditorStateObserver, }, directives: { @@ -25,15 +24,26 @@ export default { return activeItem ? activeItem.label : this.$options.i18n.placeholder; }, + listboxItems() { + return this.$options.items.map((item) => { + return { + value: item.label, + text: item.label, + }; + }); + }, }, methods: { + mapDropdownItemToCommand(dropdownItem) { + return this.$options.items.find((option) => option.label === dropdownItem); + }, updateActiveItem({ editor }) { this.activeItem = TEXT_STYLE_DROPDOWN_ITEMS.find((item) => editor.isActive(item.contentType, item.commandParams), ); }, execute(item) { - const { editorCommand, contentType, commandParams } = item; + const { editorCommand, contentType, commandParams } = this.mapDropdownItemToCommand(item); const value = commandParams?.level; if (editorCommand) { @@ -46,8 +56,8 @@ export default { this.$emit('execute', { contentType, value }); }, - isActive(item) { - return this.tiptapEditor.isActive(item.contentType, item.commandParams); + isActive(dropdownItem) { + return this.tiptapEditor.isActive(dropdownItem.contentType, dropdownItem.commandParams); }, }, items: TEXT_STYLE_DROPDOWN_ITEMS, @@ -58,25 +68,15 @@ export default { </script> <template> <editor-state-observer @transaction="updateActiveItem"> - <gl-dropdown - v-gl-tooltip="$options.i18n.placeholder" - size="small" - data-qa-selector="text_style_dropdown" + <gl-collapsible-listbox + v-gl-tooltip.hover="$options.i18n.placeholder" + :items="listboxItems" + :toggle-text="activeItemLabel" + :selected="activeItemLabel" :disabled="!activeItem" - :text="activeItemLabel" - lazy - > - <gl-dropdown-item - v-for="(item, index) in $options.items" - :key="index" - is-check-item - :is-checked="isActive(item)" - data-qa-selector="text_style_menu_item" - :data-qa-text-style="item.label" - @click="execute(item)" - > - {{ item.label }} - </gl-dropdown-item> - </gl-dropdown> + :data-qa-text-style="activeItemLabel" + data-qa-selector="text_style_dropdown" + @select="execute" + /> </editor-state-observer> </template> |