Skip to content

Commit

Permalink
style(extension/youtube): ✏️ change youtube typing
Browse files Browse the repository at this point in the history
  • Loading branch information
bdbch committed Jun 17, 2022
1 parent 6c302f2 commit 76c3d65
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
11 changes: 5 additions & 6 deletions demos/src/Experiments/Youtube/React/index.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import './styles.scss'

import React from 'react'

import YouTube from '@tiptap/extension-youtube'
import Youtube from '@tiptap/extension-youtube'
import { EditorContent, useEditor } from '@tiptap/react'
import StarterKit from '@tiptap/starter-kit'
import React from 'react'

const MenuBar = ({ editor }) => {
const widthRef = React.useRef(null)
Expand All @@ -21,7 +20,7 @@ const MenuBar = ({ editor }) => {
return null
}

const addYouTubeVideo = () => {
const addYoutubeVideo = () => {
const url = prompt('Enter YouTube URL')

editor.commands.setYoutubeVideo({
Expand All @@ -33,7 +32,7 @@ const MenuBar = ({ editor }) => {

return (
<>
<button id="add" onClick={addYouTubeVideo}>Add youtube video</button>
<button id="add" onClick={addYoutubeVideo}>Add youtube video</button>
<input id="width" type="number" min="320" max="1024" ref={widthRef} placeholder="width" />
<input id="height" type="number" min="180" max="720" ref={heightRef} placeholder="height" />
</>
Expand All @@ -44,7 +43,7 @@ export default () => {
const editor = useEditor({
extensions: [
StarterKit,
YouTube,
Youtube,
],
content: `
<p>Tiptap now supports youtube embeds! Awesome!</p>
Expand Down
6 changes: 3 additions & 3 deletions demos/src/Experiments/Youtube/Vue/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
</template>

<script>
import YouTube from '@tiptap/extension-youtube'
import { Editor, EditorContent } from '@tiptap/vue-3'
import Youtube from '@tiptap/extension-youtube'
import StarterKit from '@tiptap/starter-kit'
import { Editor, EditorContent } from '@tiptap/vue-3'
export default {
components: {
Expand All @@ -43,7 +43,7 @@ export default {
this.editor = new Editor({
extensions: [
StarterKit,
YouTube,
Youtube,
],
content: `
<p>Tiptap now supports youtube embeds! Awesome!</p>
Expand Down
12 changes: 6 additions & 6 deletions docs/api/extensions/youtube.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Controls if the node should be handled inline or as a block.
Default: `false`

```js
YouTube.configure({
Youtube.configure({
inline: false,
})
```
Expand All @@ -33,7 +33,7 @@ Controls the default width of added videos
Default: `640`

```js
YouTube.configure({
Youtube.configure({
width: 480,
})
```
Expand All @@ -44,7 +44,7 @@ Controls the default height of added videos
Default: `480`

```js
YouTube.configure({
Youtube.configure({
height: 320,
})
```
Expand All @@ -55,7 +55,7 @@ Enables or disables YouTube video controls
Default: `true`

```js
YouTube.configure({
Youtube.configure({
controls: false,
})
```
Expand All @@ -66,7 +66,7 @@ Enables the nocookie mode for YouTube embeds
Default: `false`

```js
YouTube.configure({
Youtube.configure({
nocookie: true,
})
```
Expand All @@ -77,7 +77,7 @@ Allows the iframe to be played in fullscreen
Default: `true`

```js
YouTube.configure({
Youtube.configure({
allowFullscreen: false,
})
```
Expand Down
4 changes: 2 additions & 2 deletions packages/extension-youtube/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { YouTube } from './youtube'
import { Youtube } from './youtube'

export * from './youtube'

export default YouTube
export default Youtube
4 changes: 2 additions & 2 deletions packages/extension-youtube/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const isValidYouTubeUrl = (url: string) => {
export const isValidYoutubeUrl = (url: string) => {
return url.match(/^(https?:\/\/)?(www\.|music\.)?(youtube\.com|youtu\.be)(.+)?$/)
}

Expand All @@ -13,7 +13,7 @@ export const getYoutubeEmbedUrl = (nocookie?: boolean) => {
return nocookie ? 'https://www.youtube-nocookie.com/embed/' : 'https://www.youtube.com/embed/'
}

export const getEmbedURLFromYouTubeURL = (options: GetEmbedUrlOptions) => {
export const getEmbedURLFromYoutubeURL = (options: GetEmbedUrlOptions) => {
const {
url,
controls,
Expand Down
10 changes: 5 additions & 5 deletions packages/extension-youtube/src/youtube.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Node, mergeAttributes } from '@tiptap/core'
import { mergeAttributes, Node } from '@tiptap/core'

import { getEmbedURLFromYouTubeURL, isValidYouTubeUrl } from './utils'
import { getEmbedURLFromYoutubeURL, isValidYoutubeUrl } from './utils'

export interface YoutubeOptions {
inline: boolean;
Expand All @@ -23,7 +23,7 @@ declare module '@tiptap/core' {
}
}

export const YouTube = Node.create<YoutubeOptions>({
export const Youtube = Node.create<YoutubeOptions>({
name: 'youtube',

addOptions() {
Expand Down Expand Up @@ -76,7 +76,7 @@ export const YouTube = Node.create<YoutubeOptions>({
addCommands() {
return {
setYoutubeVideo: options => ({ commands }) => {
if (!isValidYouTubeUrl(options.src)) {
if (!isValidYoutubeUrl(options.src)) {
return false
}

Expand All @@ -89,7 +89,7 @@ export const YouTube = Node.create<YoutubeOptions>({
},

renderHTML({ HTMLAttributes }) {
const embedUrl = getEmbedURLFromYouTubeURL({
const embedUrl = getEmbedURLFromYoutubeURL({
url: HTMLAttributes.src,
controls: this.options.controls,
nocookie: this.options.nocookie,
Expand Down

0 comments on commit 76c3d65

Please sign in to comment.