diff --git a/src/Components/Inputs/TextEditor/InsertVideoModal/InsertVideoModal.tsx b/src/Components/Inputs/TextEditor/InsertVideoModal/InsertVideoModal.tsx
index 7c211e7..5f4aeb9 100644
--- a/src/Components/Inputs/TextEditor/InsertVideoModal/InsertVideoModal.tsx
+++ b/src/Components/Inputs/TextEditor/InsertVideoModal/InsertVideoModal.tsx
@@ -10,18 +10,18 @@ interface Props extends ModalCard {
callbackAction: PayloadAction<{ src: string, alt?: string }>
}
+
export default function InsertVideoModal({ onClose, direction, callbackAction, ...props }: Props) {
- const [idInput, setIdInput] = useState("")
- const [altInput, setAltInput] = useState("")
+ const [urlInput, setUrlInput] = useState("")
const dispatch = useAppDispatch();
const handleSubmit = (e: FormEvent) => {
e.preventDefault()
- if (idInput.length > 10) {
- // onInsert({ src: idInput, alt: altInput })
+ const id = extractId(urlInput);
+ if (id) {
const action = Object.assign({}, callbackAction);
- action.payload = { src: idInput, alt: altInput }
+ action.payload = { src: id }
dispatch(action)
onClose?.();
}
@@ -42,15 +42,15 @@ export default function InsertVideoModal({ onClose, direction, callbackAction, .
@@ -68,3 +68,9 @@ export default function InsertVideoModal({ onClose, direction, callbackAction, .
)
}
+
+
+function extractId(url: string) {
+ const rgx = /^.*(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/;
+ return url.match(rgx)?.[1]
+}
\ No newline at end of file
diff --git a/src/features/Posts/pages/CreatePostPage/Components/BountyForm/BountyForm.stories.tsx b/src/features/Posts/pages/CreatePostPage/Components/BountyForm/BountyForm.stories.tsx
index 2203721..9bfc799 100644
--- a/src/features/Posts/pages/CreatePostPage/Components/BountyForm/BountyForm.stories.tsx
+++ b/src/features/Posts/pages/CreatePostPage/Components/BountyForm/BountyForm.stories.tsx
@@ -1,4 +1,5 @@
import { ComponentStory, ComponentMeta } from '@storybook/react';
+import { WithModals } from 'src/utils/storybook/decorators';
import BountyForm from './BountyForm';
@@ -8,6 +9,7 @@ export default {
argTypes: {
backgroundColor: { control: 'color' },
},
+ decorators: [WithModals]
} as ComponentMeta
;
diff --git a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx
index ed87321..223a0df 100644
--- a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx
+++ b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/ContentEditor.tsx
@@ -19,6 +19,7 @@ import {
NodeFormattingExtension,
OrderedListExtension,
PlaceholderExtension,
+ IframeExtension,
StrikeExtension,
TableExtension,
TrailingNodeExtension,
@@ -74,6 +75,7 @@ export default function ContentEditor({ placeholder, initialContent, name }: Pro
supportedLanguages: [javascript, typescript]
}),
new ImageExtension(),
+ new IframeExtension(),
// new TrailingNodeExtension(),
// new TableExtension(),
new MarkdownExtension({ copyAsMarkdown: false }),
diff --git a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/Toolbar.tsx b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/Toolbar.tsx
index cdf5a28..394a11b 100644
--- a/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/Toolbar.tsx
+++ b/src/features/Posts/pages/CreatePostPage/Components/ContentEditor/Toolbar.tsx
@@ -23,6 +23,7 @@ export default function Toolbar() {
+
diff --git a/src/features/Posts/pages/CreatePostPage/Components/QuestionForm/QuestionForm.stories.tsx b/src/features/Posts/pages/CreatePostPage/Components/QuestionForm/QuestionForm.stories.tsx
index 2d85f5a..e4da1db 100644
--- a/src/features/Posts/pages/CreatePostPage/Components/QuestionForm/QuestionForm.stories.tsx
+++ b/src/features/Posts/pages/CreatePostPage/Components/QuestionForm/QuestionForm.stories.tsx
@@ -1,4 +1,5 @@
import { ComponentStory, ComponentMeta } from '@storybook/react';
+import { WithModals } from 'src/utils/storybook/decorators';
import QuestionForm from './QuestionForm';
@@ -8,6 +9,7 @@ export default {
argTypes: {
backgroundColor: { control: 'color' },
},
+ decorators: [WithModals]
} as ComponentMeta;
diff --git a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.stories.tsx b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.stories.tsx
index 94e6776..6217b32 100644
--- a/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.stories.tsx
+++ b/src/features/Posts/pages/CreatePostPage/Components/StoryForm/StoryForm.stories.tsx
@@ -1,4 +1,5 @@
import { ComponentStory, ComponentMeta } from '@storybook/react';
+import { WithModals } from 'src/utils/storybook/decorators';
import StoryForm from './StoryForm';
@@ -8,6 +9,7 @@ export default {
argTypes: {
backgroundColor: { control: 'color' },
},
+ decorators: [WithModals]
} as ComponentMeta;
diff --git a/src/styles/vendors.scss b/src/styles/vendors.scss
index af1fd04..b969d29 100644
--- a/src/styles/vendors.scss
+++ b/src/styles/vendors.scss
@@ -19,7 +19,7 @@
.remirror-editor-wrapper iframe,
.remirror-theme iframe {
width: calc(min(100%, 550px));
- margin: 0 auto;
+ margin: 16px auto;
aspect-ratio: 16/9;
}