Skip to content

Commit

Permalink
RELEASE: v.2.0.1
Browse files Browse the repository at this point in the history
- fixed: support all syntax for embedding local videos (addresses #8)
  • Loading branch information
vyleung committed Jun 3, 2022
1 parent 36bc0f6 commit 772338a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logseq-helium-plugin",
"version": "2.0.0",
"version": "2.0.1",
"description": "Float videos for an improved note-taking experience",
"main": "dist/index.html",
"targets": {
Expand Down
17 changes: 7 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ let video_embed_iframe;
let video_embed_legacy;
let video_embed_iframe_legacy;
let local_video_embed;
let local_video;
let youtube_embed;

let video_iframe_increase_h;
Expand Down Expand Up @@ -106,7 +105,7 @@ function startFloat(e) {
let block_content = block.content;
video_embed_legacy = (block_content.match(/({{youtube [\s\S]*?}})/gm)) || (block_content.match(/({{vimeo [\s\S]*?}})/gm));
video_embed = block_content.match(/({{video [\s\S]*?}})/gm);
local_video_embed = block_content.match(/(![[\s\S]*?\))/gm);
local_video_embed = parent_block.querySelector("video");

// iframes
if (video_embed) {
Expand All @@ -120,13 +119,11 @@ function startFloat(e) {
}
// local videos
else if ((!video_embed) && (local_video_embed)) {
local_video = parent_block.querySelector("video");

if ((local_video) && (local_video.id == "")) {
local_video.id = `helium-localVideo-${block_uuid_start}`;
if ((local_video_embed) && (local_video_embed.id == "")) {
local_video_embed.id = `helium-localVideo-${block_uuid_start}`;
}
video_id = local_video.id;
local_video.addEventListener("click", playPauseControls);
video_id = local_video_embed.id;
local_video_embed.addEventListener("click", playPauseControls);
}
// iframes using the legacy {{youtube URL}} or {{vimeo URL}} macros
else if ((!video_embed) && (video_embed_legacy)) {
Expand Down Expand Up @@ -330,8 +327,8 @@ function startFloat(e) {
}

function stopFloat(e) {
if (local_video) {
local_video.removeEventListener("click", playPauseControls);
if (local_video_embed) {
local_video_embed.removeEventListener("click", playPauseControls);
}

let block_uuid_stop = (e.uuid == undefined) ? e.dataset.heliumId : e.uuid;
Expand Down

0 comments on commit 772338a

Please sign in to comment.