Skip to content

Commit 5d8e9c1

Browse files
authored
Added support for embedding neetoRecord video links (#1056)
* Added support for embedding neetoRecord links * Updated documentation
1 parent 8b862c1 commit 5d8e9c1

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

src/common/constants.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ export const VIMEO_URL_REGEXP =
4949
export const LOOM_URL_REGEXP =
5050
/((?:http|https):\/\/)?(www\.)?loom\.com\/(share|embed)\/([a-f0-9]{32})(?:\?sid=([a-f0-9-]{36}))?(?:\?t=(\d+))?(\?[^#]*)?/;
5151

52+
export const NEETO_RECORD_URL_REGEXP =
53+
/((?:http|https):\/\/)?(www\.)?[a-zA-Z0-9-]+\.(neetorecord\.com)\/(watch)\/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/;
54+
5255
export const COMBINED_REGEX = new RegExp(
53-
pluck("source", [YOUTUBE_URL_REGEXP, VIMEO_URL_REGEXP, LOOM_URL_REGEXP]).join(
54-
"|"
55-
),
56+
pluck("source", [
57+
YOUTUBE_URL_REGEXP,
58+
VIMEO_URL_REGEXP,
59+
LOOM_URL_REGEXP,
60+
NEETO_RECORD_URL_REGEXP,
61+
]).join("|"),
5662
"g"
5763
);

src/components/Editor/CustomExtensions/Embeds/index.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ const EmbedOption = ({ isEmbedModalOpen, setIsEmbedModalOpen, editor }) => {
6868
onClose={handleClose}
6969
>
7070
<Modal.Header>
71-
<Typography style="h2">Embed Video</Typography>
71+
<Typography style="h2">{t("neetoEditor.menu.embedVideo")}</Typography>
7272
</Modal.Header>
7373
<Modal.Body className="ne-embed-modal space-y-2">
7474
<Input
7575
data-cy="neeto-editor-embed-input"
76-
error={error && "Please enter a valid URL"}
76+
error={error && t("neetoEditor.error.invalidEmbedUrl")}
7777
label={t("neetoEditor.common.videoUrl")}
7878
ref={inputRef}
7979
size="medium"

src/components/Editor/CustomExtensions/Embeds/utils.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import {
22
YOUTUBE_URL_REGEXP,
33
VIMEO_URL_REGEXP,
44
LOOM_URL_REGEXP,
5+
NEETO_RECORD_URL_REGEXP,
56
} from "common/constants";
67

7-
export const validateUrl = url => {
8-
const validatedUrl = url
9-
? validateYouTubeUrl(url) || validateLoomUrl(url) || validateVimeoUrl(url)
8+
export const validateUrl = url =>
9+
url
10+
? validateNeetoRecordUrl(url) ||
11+
validateYouTubeUrl(url) ||
12+
validateLoomUrl(url) ||
13+
validateVimeoUrl(url)
1014
: false;
1115

12-
return validatedUrl;
13-
};
14-
1516
export const validateYouTubeUrl = url => {
1617
const match = url.match(YOUTUBE_URL_REGEXP);
1718

@@ -29,3 +30,9 @@ export const validateLoomUrl = url => {
2930

3031
return match && `https://www.loom.com/embed/${match[4]}?t=${match[5] || ""}`;
3132
};
33+
34+
export const validateNeetoRecordUrl = url => {
35+
const match = url.match(NEETO_RECORD_URL_REGEXP);
36+
37+
return match && url.replace("watch", "embeds");
38+
};

src/translations/en.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"error": {
3030
"invalidUrl": "Please enter a valid URL",
31+
"invalidEmbedUrl": "Supported sources: NeetoRecord, YouTube, Vimeo, Loom.",
3132
"cannotAddFiles": "Cannot add files",
3233
"onBeforeFileAddedReturn": "Cannot add the file because onBeforeFileAdded returned false.",
3334
"fileIsTooLarge": "File size is too large. Max size is {{maxFileSize, anyCase}}.",
@@ -64,7 +65,8 @@
6465
"alignLeft": "Align left",
6566
"alignCenter": "Align center",
6667
"alignRight": "Align right",
67-
"delete": "Delete"
68+
"delete": "Delete",
69+
"embedVideo": "Embed video"
6870
},
6971
"placeholders": {
7072
"columns": "Enter columns",

stories/constants.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const EDITOR_ADDONS_TABLE_ROWS = [
1414
["table", "Add a table to the editor."],
1515
["undo", "Undo last performed action."],
1616
["video-upload", "Upload videos to the editor."],
17-
["video-embed", "Embed videos from YouTube, Loom and Vimeo."],
17+
["video-embed", "Embed videos from neetoRecord, YouTube, Loom and Vimeo."],
1818
["text-color", "Change the color of the text."],
1919
];
2020

0 commit comments

Comments
 (0)