Commit 1bd14b95 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '338380-wbr' into 'master'

Add support for wbr in content editor

See merge request gitlab-org/gitlab!69365
parents 10201c8a 772f061e
import { Node, mergeAttributes, nodeInputRule } from '@tiptap/core';
export const inputRegex = /^<wbr>$/;
export default Node.create({
name: 'wordBreak',
inline: true,
group: 'inline',
selectable: false,
atom: true,
defaultOptions: {
HTMLAttributes: {
class: 'gl-display-inline-flex gl-px-1 gl-bg-blue-100 gl-rounded-base gl-font-sm',
},
},
parseHTML() {
return [{ tag: 'wbr' }];
},
renderHTML({ HTMLAttributes }) {
return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), '-'];
},
addInputRules() {
return [nodeInputRule(inputRegex, this.type)];
},
});
...@@ -43,6 +43,7 @@ import TaskItem from '../extensions/task_item'; ...@@ -43,6 +43,7 @@ import TaskItem from '../extensions/task_item';
import TaskList from '../extensions/task_list'; import TaskList from '../extensions/task_list';
import Text from '../extensions/text'; import Text from '../extensions/text';
import Video from '../extensions/video'; import Video from '../extensions/video';
import WordBreak from '../extensions/word_break';
import { ContentEditor } from './content_editor'; import { ContentEditor } from './content_editor';
import createMarkdownSerializer from './markdown_serializer'; import createMarkdownSerializer from './markdown_serializer';
import trackInputRulesAndShortcuts from './track_input_rules_and_shortcuts'; import trackInputRulesAndShortcuts from './track_input_rules_and_shortcuts';
...@@ -112,6 +113,7 @@ export const createContentEditor = ({ ...@@ -112,6 +113,7 @@ export const createContentEditor = ({
TaskList, TaskList,
Text, Text,
Video, Video,
WordBreak,
]; ];
const allExtensions = [...builtInContentEditorExtensions, ...extensions]; const allExtensions = [...builtInContentEditorExtensions, ...extensions];
......
...@@ -39,6 +39,7 @@ import TaskItem from '../extensions/task_item'; ...@@ -39,6 +39,7 @@ import TaskItem from '../extensions/task_item';
import TaskList from '../extensions/task_list'; import TaskList from '../extensions/task_list';
import Text from '../extensions/text'; import Text from '../extensions/text';
import Video from '../extensions/video'; import Video from '../extensions/video';
import WordBreak from '../extensions/word_break';
import { import {
isPlainURL, isPlainURL,
renderHardBreak, renderHardBreak,
...@@ -166,6 +167,7 @@ const defaultSerializerConfig = { ...@@ -166,6 +167,7 @@ const defaultSerializerConfig = {
}, },
[Text.name]: defaultMarkdownSerializer.nodes.text, [Text.name]: defaultMarkdownSerializer.nodes.text,
[Video.name]: renderPlayable, [Video.name]: renderPlayable,
[WordBreak.name]: (state) => state.write('<wbr>'),
}, },
}; };
......
...@@ -219,3 +219,5 @@ ...@@ -219,3 +219,5 @@
# Sit amit # Sit amit
### I don't know ### I don't know
- name: word_break
markdown: Fernstraßen<wbr>bau<wbr>privat<wbr>finanzierungs<wbr>gesetz
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