Skip to content

Commit 36862de

Browse files
Merge branch 'main' into upgraded-nodejs-to-v22.13
2 parents e48119e + 94e0408 commit 36862de

File tree

5 files changed

+51
-38
lines changed

5 files changed

+51
-38
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bigbinary/neeto-editor",
3-
"version": "1.45.2",
3+
"version": "1.45.4",
44
"types": "./types.d.ts",
55
"description": "neetoEditor is the library that drives the rich text experience in all neeto products built at BigBinary",
66
"keywords": [

src/common/constants.js

+36
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,52 @@ export const LOOM_URL_REGEXP =
5252
export const NEETO_RECORD_URL_REGEXP =
5353
/((?:http|https):\/\/)?(www\.)?[a-zA-Z0-9-]+\.(neetorecord\.com)\/(watch)\/([0-9a-f]{20})/;
5454

55+
export const SUPA_DEMO_URL_REGEXP =
56+
/((?:http|https):\/\/)?(www\.)?([a-zA-Z0-9-]+)\.([a-zA-Z0-9-]+\.[a-zA-Z0-9-]+)\/(demo|embed)\/([0-9a-z]+)/;
57+
5558
export const COMBINED_REGEX = new RegExp(
5659
pluck("source", [
5760
YOUTUBE_URL_REGEXP,
5861
VIMEO_URL_REGEXP,
5962
LOOM_URL_REGEXP,
6063
NEETO_RECORD_URL_REGEXP,
64+
SUPA_DEMO_URL_REGEXP,
6165
]).join("|"),
6266
"g"
6367
);
6468

69+
export const URL_VALIDATORS = {
70+
youtube: url => {
71+
const match = url.match(YOUTUBE_URL_REGEXP);
72+
73+
return match && `https://www.youtube.com/embed/${match[5]}`;
74+
},
75+
vimeo: url => {
76+
const match = url.match(VIMEO_URL_REGEXP);
77+
78+
return match && `https://player.vimeo.com/video/${match[4]}?h=${match[5]}`;
79+
},
80+
loom: url => {
81+
const match = url.match(LOOM_URL_REGEXP);
82+
83+
return (
84+
match && `https://www.loom.com/embed/${match[4]}?t=${match[5] || ""}`
85+
);
86+
},
87+
neetoRecord: url => {
88+
const match = url.match(NEETO_RECORD_URL_REGEXP);
89+
90+
return match && url.replace("watch", "embeds");
91+
},
92+
supademo: url => {
93+
const match = url.match(SUPA_DEMO_URL_REGEXP);
94+
95+
return (
96+
match && `https://${match[3]}.${match[4]}/embed/${match[6]}?embed_v=2`
97+
);
98+
},
99+
};
100+
65101
export const EDITOR_SIZES = {
66102
MEDIUM: "medium",
67103
LARGE: "large",
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,12 @@
1-
import {
2-
YOUTUBE_URL_REGEXP,
3-
VIMEO_URL_REGEXP,
4-
LOOM_URL_REGEXP,
5-
NEETO_RECORD_URL_REGEXP,
6-
} from "common/constants";
1+
import { URL_VALIDATORS } from "common/constants";
72

8-
export const validateUrl = url =>
9-
url
10-
? validateNeetoRecordUrl(url) ||
11-
validateYouTubeUrl(url) ||
12-
validateLoomUrl(url) ||
13-
validateVimeoUrl(url)
14-
: false;
3+
export const validateUrl = url => {
4+
if (!url) return false;
155

16-
export const validateYouTubeUrl = url => {
17-
const match = url.match(YOUTUBE_URL_REGEXP);
6+
for (const validator of Object.values(URL_VALIDATORS)) {
7+
const result = validator(url);
8+
if (result) return result;
9+
}
1810

19-
return match && `https://www.youtube.com/embed/${match[5]}`;
20-
};
21-
22-
export const validateVimeoUrl = url => {
23-
const match = url.match(VIMEO_URL_REGEXP);
24-
25-
return match && `https://player.vimeo.com/video/${match[4]}?h=${match[5]}`;
26-
};
27-
28-
export const validateLoomUrl = url => {
29-
const match = url.match(LOOM_URL_REGEXP);
30-
31-
return match && `https://www.loom.com/embed/${match[4]}?t=${match[5] || ""}`;
32-
};
33-
34-
export const validateNeetoRecordUrl = url => {
35-
const match = url.match(NEETO_RECORD_URL_REGEXP);
36-
37-
return match && url.replace("watch", "embeds");
11+
return false;
3812
};

src/translations/en.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
},
3131
"error": {
3232
"invalidUrl": "Please enter a valid URL",
33-
"invalidEmbedUrl": "Supported sources: NeetoRecord, YouTube, Vimeo, Loom.",
33+
"invalidEmbedUrl": "Supported sources: NeetoRecord, YouTube, Vimeo, Loom, Supademo.",
3434
"cannotAddFiles": "Cannot add files",
3535
"onBeforeFileAddedReturn": "Cannot add the file because onBeforeFileAdded returned false.",
3636
"fileIsTooLarge": "File size is too large. Max size is {{maxFileSize, anyCase}}.",
@@ -103,7 +103,7 @@
103103
"emojiDescription": "Add an emoji.",
104104
"divider": "Divider",
105105
"dividerDescription": "Add an horizontal line to separate sections.",
106-
"embed": "Embed Youtube/Loom/Vimeo",
106+
"embed": "Embed Youtube/Loom/Vimeo/Supademo",
107107
"embedDescription": "Embed a video from major services.",
108108
"pasteUnformatted": "Paste Unformatted",
109109
"pasteUnformattedDescription": "Paste by removing all styles.",

stories/constants.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ 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 neetoRecord, YouTube, Loom and Vimeo."],
17+
[
18+
"video-embed",
19+
"Embed videos from neetoRecord, YouTube, Loom, Vimeo, and Supademo.",
20+
],
1821
["text-color", "Change the color of the text."],
1922
];
2023

0 commit comments

Comments
 (0)