Skip to content

fix: Use video player only for embedded videos (#60) #67

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

Merged
merged 1 commit into from
Aug 11, 2023

Conversation

andrew-polk
Copy link
Contributor

@andrew-polk andrew-polk commented Aug 9, 2023

#60


This change is Reviewable

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Member

@hatton hatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 8 files reviewed, 3 unresolved discussions (waiting on @andrew-polk)


src/transform.ts line 147 at r1 (raw file):

          // add any library imports
          if (!context.imports) context.imports = [];
          mod.imports?.forEach(imp => context.imports!.push(imp));

To avoid the Forbidden non-null assertion, you could do

 context.imports?.push(...mod.imports || []);


src/plugins/VideoTransformer.ts line 9 at r1 (raw file):

      type: "video",
      getStringFromBlock: async (context, block) => {
        const blockAsAny = block as any;

You can avoid any here, something like this:

        const video = (block as VideoBlockObjectResponse).video;

        if (video.type === "external") {

          context.imports = [`import ReactPlayer from "react-player";`];

          return `<ReactPlayer controls url="${video.external.url}" />`;
 else {

          error(`Docunotion cannot handle this video type: ${video.type}`);
           ...

src/plugins/VideoTransformer.ts line 11 at r1 (raw file):

        const blockAsAny = block as any;
        if (blockAsAny?.video?.external?.url) {
          context.imports = [`import ReactPlayer from "react-player";`];

Should this be something like

context.imports += `import ReactPlayer from "react-player";`

So that it doesn't collide with imports from other plugins?

@andrew-polk andrew-polk force-pushed the 60-change-video-embed branch from f6b1b7b to 7390e98 Compare August 9, 2023 20:44
Copy link
Contributor Author

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 8 files reviewed, 3 unresolved discussions (waiting on @hatton)


src/transform.ts line 147 at r1 (raw file):

Previously, hatton (John Hatton) wrote…

To avoid the Forbidden non-null assertion, you could do

 context.imports?.push(...mod.imports || []);

Done. Thanks.


src/plugins/VideoTransformer.ts line 9 at r1 (raw file):

Previously, hatton (John Hatton) wrote…

You can avoid any here, something like this:

        const video = (block as VideoBlockObjectResponse).video;

        if (video.type === "external") {

          context.imports = [`import ReactPlayer from "react-player";`];

          return `<ReactPlayer controls url="${video.external.url}" />`;
 else {

          error(`Docunotion cannot handle this video type: ${video.type}`);
           ...

Done. Thanks.


src/plugins/VideoTransformer.ts line 11 at r1 (raw file):

Previously, hatton (John Hatton) wrote…

Should this be something like

context.imports += `import ReactPlayer from "react-player";`

So that it doesn't collide with imports from other plugins?

Yep!
Good catch.

Copy link
Member

@hatton hatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 8 files reviewed, 4 unresolved discussions (waiting on @andrew-polk)


src/plugins/pluginTypes.ts line 78 at r2 (raw file):

  counts: ICounts;

  // If the output is creating things like react elements, you can import their definitions here

Let's set the comment to emphasize that you should append to this

@andrew-polk andrew-polk force-pushed the 60-change-video-embed branch from 7390e98 to 047bafd Compare August 11, 2023 20:35
Copy link
Contributor Author

@andrew-polk andrew-polk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 8 files reviewed, 4 unresolved discussions (waiting on @hatton)


src/plugins/pluginTypes.ts line 78 at r2 (raw file):

Previously, hatton (John Hatton) wrote…

Let's set the comment to emphasize that you should append to this

Done.

Copy link
Member

@hatton hatton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5 of 8 files at r1, 2 of 2 files at r2, 1 of 1 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @andrew-polk)

@andrew-polk andrew-polk merged commit 4606aff into main Aug 11, 2023
@andrew-polk andrew-polk deleted the 60-change-video-embed branch August 11, 2023 21:44
@github-actions
Copy link

🎉 This PR is included in version 0.13.2-alpha.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link

🎉 This PR is included in version 0.14.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants