-
-
Notifications
You must be signed in to change notification settings - Fork 621
Fix: video parsing and Markdown export issues #1955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
539dfa6
6c2c972
9a9f0fa
37b2d9e
d647bac
606c2c4
664aedc
4a2bc9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { visit } from "unist-util-visit"; | ||
|
||
// Originally, rehypeParse parses videos as links, which is incorrect. | ||
export function convertVideoToMarkdown() { | ||
return (tree: any) => { | ||
visit(tree, "element", (node, index, parent) => { | ||
if (node.tagName === "video") { | ||
const src = node.properties?.src || node.properties?.["data-url"] || ""; | ||
const name = | ||
node.properties?.title || node.properties?.["data-name"] || ""; | ||
parent.children[index!] = { | ||
type: "text", | ||
value: ``, | ||
}; | ||
} | ||
}); | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,24 @@ export function filenameFromURL(url: string): string { | |
} | ||
return parts[parts.length - 1]; | ||
} | ||
|
||
export function isVideoUrl(url: string) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @nperez0111 how do you feel about checking if a file is a video based on a hard coded list of file endings? The alternative would be to get it from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think hard-coding is fine for now, this is what the markdown parser would've done anyway. |
||
const videoExtensions = [ | ||
"mp4", | ||
"webm", | ||
"ogg", | ||
"mov", | ||
"mkv", | ||
"flv", | ||
"avi", | ||
"wmv", | ||
"m4v", | ||
]; | ||
try { | ||
const pathname = new URL(url).pathname; | ||
const ext = pathname.split(".").pop()?.toLowerCase() || ""; | ||
return videoExtensions.includes(ext); | ||
} catch (_) { | ||
return false; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="bn-block-group" data-node-type="blockGroup"> | ||
<div class="bn-block-outer" data-node-type="blockOuter" data-id="1"> | ||
<div class="bn-block" data-node-type="blockContainer" data-id="1"> | ||
<div | ||
class="bn-block-content" | ||
data-content-type="image" | ||
data-url="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" | ||
data-file-block="" | ||
> | ||
<div class="bn-file-block-content-wrapper" style="position: relative;"> | ||
<div class="bn-visual-media-wrapper"> | ||
<img | ||
class="bn-visual-media" | ||
src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" | ||
alt="BlockNote image" | ||
draggable="false" | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<div class="bn-block-group" data-node-type="blockGroup"> | ||
<div class="bn-block-outer" data-node-type="blockOuter" data-id="1"> | ||
<div class="bn-block" data-node-type="blockContainer" data-id="1"> | ||
<div | ||
class="bn-block-content" | ||
data-content-type="video" | ||
data-url="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" | ||
data-file-block="" | ||
> | ||
<div class="bn-file-block-content-wrapper" style="position: relative;"> | ||
<div class="bn-visual-media-wrapper"> | ||
<video | ||
class="bn-visual-media" | ||
src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" | ||
controls="" | ||
draggable="false" | ||
width="0" | ||
></video> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<img | ||
src="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" | ||
alt="BlockNote image" | ||
data-url="https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png" | ||
/> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<video | ||
src="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" | ||
data-url="https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm" | ||
></video> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"attrs": { | ||
"id": "1", | ||
}, | ||
"content": [ | ||
{ | ||
"attrs": { | ||
"backgroundColor": "default", | ||
"caption": "", | ||
"name": "", | ||
"previewWidth": undefined, | ||
"showPreview": true, | ||
"textAlignment": "left", | ||
"url": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", | ||
}, | ||
"type": "image", | ||
}, | ||
], | ||
"type": "blockContainer", | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[ | ||
{ | ||
"attrs": { | ||
"id": "1", | ||
}, | ||
"content": [ | ||
{ | ||
"attrs": { | ||
"backgroundColor": "default", | ||
"caption": "", | ||
"name": "", | ||
"previewWidth": undefined, | ||
"showPreview": true, | ||
"textAlignment": "left", | ||
"url": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm", | ||
}, | ||
"type": "video", | ||
}, | ||
], | ||
"type": "blockContainer", | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"children": [], | ||
"content": undefined, | ||
"id": "1", | ||
"props": { | ||
"backgroundColor": "default", | ||
"caption": "", | ||
"name": "Image", | ||
"showPreview": true, | ||
"textAlignment": "left", | ||
"url": "https://www.google.com/images/branding/googlelogo/1x/googlelogo_color_272x92dp.png", | ||
}, | ||
"type": "image", | ||
}, | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[ | ||
{ | ||
"children": [], | ||
"content": undefined, | ||
"id": "1", | ||
"props": { | ||
"backgroundColor": "default", | ||
"caption": "", | ||
"name": "", | ||
"showPreview": true, | ||
"textAlignment": "left", | ||
"url": "https://interactive-examples.mdn.mozilla.net/media/cc0-videos/flower.webm", | ||
}, | ||
"type": "video", | ||
}, | ||
] |
Uh oh!
There was an error while loading. Please reload this page.