Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7fedc5e0
Commit
7fedc5e0
authored
Aug 28, 2021
by
Lee Tickett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render video in content editor
Changelog: added
parent
6b6e344e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
11 deletions
+31
-11
app/assets/javascripts/behaviors/markdown/nodes/playable.js
app/assets/javascripts/behaviors/markdown/nodes/playable.js
+6
-5
app/assets/javascripts/content_editor/extensions/audio.js
app/assets/javascripts/content_editor/extensions/audio.js
+1
-0
app/assets/javascripts/content_editor/extensions/playable.js
app/assets/javascripts/content_editor/extensions/playable.js
+4
-3
app/assets/javascripts/content_editor/extensions/video.js
app/assets/javascripts/content_editor/extensions/video.js
+10
-0
app/assets/javascripts/content_editor/services/create_content_editor.js
...ascripts/content_editor/services/create_content_editor.js
+2
-0
app/assets/javascripts/content_editor/services/markdown_serializer.js
...avascripts/content_editor/services/markdown_serializer.js
+2
-0
spec/frontend/fixtures/api_markdown.yml
spec/frontend/fixtures/api_markdown.yml
+6
-3
No files found.
app/assets/javascripts/behaviors/markdown/nodes/playable.js
View file @
7fedc5e0
/* eslint-disable class-methods-use-this */
/* eslint-disable class-methods-use-this */
/* eslint-disable @gitlab/require-i18n-strings */
import
{
defaultMarkdownSerializer
}
from
'
prosemirror-markdown
'
;
import
{
defaultMarkdownSerializer
}
from
'
prosemirror-markdown
'
;
import
{
Node
}
from
'
tiptap
'
;
import
{
Node
}
from
'
tiptap
'
;
...
@@ -30,19 +31,19 @@ export default class Playable extends Node {
...
@@ -30,19 +31,19 @@ export default class Playable extends Node {
const
parseDOM
=
[
const
parseDOM
=
[
{
{
tag
:
`.
media
-container`
,
tag
:
`.
${
this
.
mediaType
}
-container`
,
getAttrs
:
(
el
)
=>
({
getAttrs
:
(
el
)
=>
({
src
:
el
.
querySelector
(
'
audio,video
'
).
src
,
src
:
el
.
querySelector
(
this
.
mediaType
).
src
,
alt
:
el
.
querySelector
(
'
audio,video
'
).
dataset
.
title
,
alt
:
el
.
querySelector
(
this
.
mediaType
).
dataset
.
title
,
}),
}),
},
},
];
];
const
toDOM
=
(
node
)
=>
[
const
toDOM
=
(
node
)
=>
[
'
span
'
,
'
span
'
,
{
class
:
'
media-container
'
},
{
class
:
`media-container
${
this
.
mediaType
}
-container`
},
[
[
this
.
options
.
mediaType
,
this
.
mediaType
,
{
{
src
:
node
.
attrs
.
src
,
src
:
node
.
attrs
.
src
,
controls
:
true
,
controls
:
true
,
...
...
app/assets/javascripts/content_editor/extensions/audio.js
View file @
7fedc5e0
import
Playable
from
'
./playable
'
;
import
Playable
from
'
./playable
'
;
export
default
Playable
.
extend
({
export
default
Playable
.
extend
({
name
:
'
audio
'
,
defaultOptions
:
{
defaultOptions
:
{
...
Playable
.
options
,
...
Playable
.
options
,
mediaType
:
'
audio
'
,
mediaType
:
'
audio
'
,
...
...
app/assets/javascripts/content_editor/extensions/playable.js
View file @
7fedc5e0
/* eslint-disable @gitlab/require-i18n-strings */
import
{
Node
}
from
'
@tiptap/core
'
;
import
{
Node
}
from
'
@tiptap/core
'
;
const
queryPlayableElement
=
(
element
,
mediaType
)
=>
element
.
querySelector
(
mediaType
);
const
queryPlayableElement
=
(
element
,
mediaType
)
=>
element
.
querySelector
(
mediaType
);
export
default
Node
.
create
({
export
default
Node
.
create
({
name
:
'
playable
'
,
group
:
'
inline
'
,
group
:
'
inline
'
,
inline
:
true
,
inline
:
true
,
draggable
:
true
,
draggable
:
true
,
...
@@ -46,7 +47,7 @@ export default Node.create({
...
@@ -46,7 +47,7 @@ export default Node.create({
parseHTML
()
{
parseHTML
()
{
return
[
return
[
{
{
tag
:
'
.media-container
'
,
tag
:
`.
${
this
.
options
.
mediaType
}
-container`
,
},
},
];
];
},
},
...
@@ -54,7 +55,7 @@ export default Node.create({
...
@@ -54,7 +55,7 @@ export default Node.create({
renderHTML
({
node
})
{
renderHTML
({
node
})
{
return
[
return
[
'
span
'
,
'
span
'
,
{
class
:
'
media-container
'
},
{
class
:
`media-container
${
this
.
options
.
mediaType
}
-container`
},
[
[
this
.
options
.
mediaType
,
this
.
options
.
mediaType
,
{
{
...
...
app/assets/javascripts/content_editor/extensions/video.js
0 → 100644
View file @
7fedc5e0
import
Playable
from
'
./playable
'
;
export
default
Playable
.
extend
({
name
:
'
video
'
,
defaultOptions
:
{
...
Playable
.
options
,
mediaType
:
'
video
'
,
extraElementAttrs
:
{
width
:
'
400
'
},
},
});
app/assets/javascripts/content_editor/services/create_content_editor.js
View file @
7fedc5e0
...
@@ -36,6 +36,7 @@ import TableRow from '../extensions/table_row';
...
@@ -36,6 +36,7 @@ import TableRow from '../extensions/table_row';
import
TaskItem
from
'
../extensions/task_item
'
;
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
{
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
'
;
...
@@ -98,6 +99,7 @@ export const createContentEditor = ({
...
@@ -98,6 +99,7 @@ export const createContentEditor = ({
TaskItem
,
TaskItem
,
TaskList
,
TaskList
,
Text
,
Text
,
Video
,
];
];
const
allExtensions
=
[...
builtInContentEditorExtensions
,
...
extensions
];
const
allExtensions
=
[...
builtInContentEditorExtensions
,
...
extensions
];
...
...
app/assets/javascripts/content_editor/services/markdown_serializer.js
View file @
7fedc5e0
...
@@ -32,6 +32,7 @@ import TableRow from '../extensions/table_row';
...
@@ -32,6 +32,7 @@ import TableRow from '../extensions/table_row';
import
TaskItem
from
'
../extensions/task_item
'
;
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
{
import
{
isPlainURL
,
isPlainURL
,
renderHardBreak
,
renderHardBreak
,
...
@@ -144,6 +145,7 @@ const defaultSerializerConfig = {
...
@@ -144,6 +145,7 @@ const defaultSerializerConfig = {
else
defaultMarkdownSerializer
.
nodes
.
bullet_list
(
state
,
node
);
else
defaultMarkdownSerializer
.
nodes
.
bullet_list
(
state
,
node
);
},
},
[
Text
.
name
]:
defaultMarkdownSerializer
.
nodes
.
text
,
[
Text
.
name
]:
defaultMarkdownSerializer
.
nodes
.
text
,
[
Video
.
name
]:
renderPlayable
,
},
},
};
};
...
...
spec/frontend/fixtures/api_markdown.yml
View file @
7fedc5e0
...
@@ -147,13 +147,16 @@
...
@@ -147,13 +147,16 @@
Hi @gitlab - thank you for reporting this ~bug (#1) we hope to fix it in %1.1 as part of !1
Hi @gitlab - thank you for reporting this ~bug (#1) we hope to fix it in %1.1 as part of !1
-
name
:
audio
-
name
:
audio
markdown
:
'
![Sample
Audio](https://gitlab.com/gitlab.mp3)'
markdown
:
'
![Sample
Audio](https://gitlab.com/gitlab.mp3)'
-
name
:
audio_in_lists
-
name
:
video
markdown
:
'
![Sample
Video](https://gitlab.com/gitlab.mp4)'
-
name
:
audio_and_video_in_lists
markdown
:
|-
markdown
:
|-
* ![Sample Audio](https://gitlab.com/1.mp3)
* ![Sample Audio](https://gitlab.com/1.mp3)
* ![Sample
Audio](https://gitlab.com/2.mp3
)
* ![Sample
Video](https://gitlab.com/2.mp4
)
1. ![Sample
Audio](https://gitlab.com/1.mp3
)
1. ![Sample
Video](https://gitlab.com/1.mp4
)
2. ![Sample Audio](https://gitlab.com/2.mp3)
2. ![Sample Audio](https://gitlab.com/2.mp3)
* [x] ![Sample Audio](https://gitlab.com/1.mp3)
* [x] ![Sample Audio](https://gitlab.com/1.mp3)
* [x] ![Sample Audio](https://gitlab.com/2.mp3)
* [x] ![Sample Audio](https://gitlab.com/2.mp3)
* [x] ![Sample Video](https://gitlab.com/3.mp4)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment