diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-28 09:10:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-28 09:10:17 +0300 |
commit | cf73ed7d11fdf517c230038fe8c88c96b7e3d6f0 (patch) | |
tree | 2bff9cfe778217ae462963ff4c22bb80bd274969 /app/assets/javascripts/behaviors | |
parent | c01895daab6ec8bffc5466a8330fc154fd47a726 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/behaviors')
-rw-r--r-- | app/assets/javascripts/behaviors/markdown/nodes/playable.js | 43 |
1 files changed, 20 insertions, 23 deletions
diff --git a/app/assets/javascripts/behaviors/markdown/nodes/playable.js b/app/assets/javascripts/behaviors/markdown/nodes/playable.js index 33bb6e0c31c..64bc30e1fe7 100644 --- a/app/assets/javascripts/behaviors/markdown/nodes/playable.js +++ b/app/assets/javascripts/behaviors/markdown/nodes/playable.js @@ -1,9 +1,7 @@ /* eslint-disable class-methods-use-this */ -/* eslint-disable @gitlab/require-i18n-strings */ import { defaultMarkdownSerializer } from 'prosemirror-markdown'; import { Node } from 'tiptap'; -import { HIGHER_PARSE_RULE_PRIORITY } from '../constants'; /** * Abstract base class for playable media, like video and audio. @@ -32,34 +30,34 @@ export default class Playable extends Node { const parseDOM = [ { - tag: `.${this.mediaType}-container`, - skip: true, - }, - { - tag: `.${this.mediaType}-container p`, - priority: HIGHER_PARSE_RULE_PRIORITY, - ignore: true, - }, - { - tag: `${this.mediaType}[src]`, - getAttrs: (el) => ({ src: el.src, alt: el.dataset.title }), + tag: `.media-container`, + getAttrs: (el) => ({ + src: el.querySelector('audio,video').src, + alt: el.querySelector('audio,video').dataset.title, + }), }, ]; const toDOM = (node) => [ - this.mediaType, - { - src: node.attrs.src, - controls: true, - 'data-setup': '{}', - 'data-title': node.attrs.alt, - ...this.extraElementAttrs, - }, + 'span', + { class: 'media-container' }, + [ + this.options.mediaType, + { + src: node.attrs.src, + controls: true, + 'data-setup': '{}', + 'data-title': node.attrs.alt, + ...this.extraElementAttrs, + }, + ], + ['a', { href: node.attrs.src }, node.attrs.alt], ]; return { attrs, - group: 'block', + group: 'inline', + inline: true, draggable: true, parseDOM, toDOM, @@ -68,6 +66,5 @@ export default class Playable extends Node { toMarkdown(state, node) { defaultMarkdownSerializer.nodes.image(state, node); - state.closeBlock(node); } } |