diff options
Diffstat (limited to 'app/assets/javascripts')
3 files changed, 22 insertions, 4 deletions
diff --git a/app/assets/javascripts/content_editor/components/top_toolbar.vue b/app/assets/javascripts/content_editor/components/top_toolbar.vue index d3363ce092b..398a9610fb5 100644 --- a/app/assets/javascripts/content_editor/components/top_toolbar.vue +++ b/app/assets/javascripts/content_editor/components/top_toolbar.vue @@ -123,5 +123,14 @@ export default { :tiptap-editor="contentEditor.tiptapEditor" @execute="trackToolbarControlExecution" /> + <toolbar-button + data-testid="horizontal-rule" + content-type="horizontalRule" + icon-name="dash" + editor-command="setHorizontalRule" + :label="__('Add a horizontal rule')" + :tiptap-editor="contentEditor.tiptapEditor" + @execute="trackToolbarControlExecution" + /> </div> </template> diff --git a/app/assets/javascripts/content_editor/extensions/horizontal_rule.js b/app/assets/javascripts/content_editor/extensions/horizontal_rule.js index dcc59476518..c287938af5c 100644 --- a/app/assets/javascripts/content_editor/extensions/horizontal_rule.js +++ b/app/assets/javascripts/content_editor/extensions/horizontal_rule.js @@ -1,5 +1,12 @@ +import { nodeInputRule } from '@tiptap/core'; import { HorizontalRule } from '@tiptap/extension-horizontal-rule'; import { defaultMarkdownSerializer } from 'prosemirror-markdown/src/to_markdown'; -export const tiptapExtension = HorizontalRule; +export const hrInputRuleRegExp = /^---$/; + +export const tiptapExtension = HorizontalRule.extend({ + addInputRules() { + return [nodeInputRule(hrInputRuleRegExp, this.type)]; + }, +}); export const serializer = defaultMarkdownSerializer.nodes.horizontal_rule; diff --git a/app/assets/javascripts/search/topbar/components/searchable_dropdown_item.vue b/app/assets/javascripts/search/topbar/components/searchable_dropdown_item.vue index 498d4af59b4..42d6444e690 100644 --- a/app/assets/javascripts/search/topbar/components/searchable_dropdown_item.vue +++ b/app/assets/javascripts/search/topbar/components/searchable_dropdown_item.vue @@ -1,5 +1,5 @@ <script> -import { GlDropdownItem, GlAvatar } from '@gitlab/ui'; +import { GlDropdownItem, GlAvatar, GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui'; import highlight from '~/lib/utils/highlight'; import { truncateNamespace } from '~/lib/utils/text_utility'; @@ -9,6 +9,9 @@ export default { GlDropdownItem, GlAvatar, }, + directives: { + SafeHtml, + }, props: { item: { type: Object, @@ -62,8 +65,7 @@ export default { :size="32" /> <div class="gl-display-flex gl-flex-direction-column"> - <!-- eslint-disable-next-line vue/no-v-html --> - <span data-testid="item-title" v-html="highlightedItemName">{{ item[name] }}</span> + <span v-safe-html="highlightedItemName" data-testid="item-title"></span> <span class="gl-font-sm gl-text-gray-700" data-testid="item-namespace">{{ truncatedNamespace }}</span> |