@quadrats/common 0.6.7 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blockquote/createBlockquote.d.ts +1 -1
- package/blockquote/createBlockquote.js +33 -33
- package/blockquote/index.cjs.js +32 -34
- package/bold/createBold.d.ts +2 -1
- package/bold/createBold.js +6 -4
- package/bold/index.cjs.js +6 -6
- package/divider/createDivider.d.ts +1 -1
- package/divider/createDivider.js +29 -29
- package/divider/index.cjs.js +29 -31
- package/embed/createEmbed.js +40 -40
- package/embed/deserializeEmbedElementToData.js +6 -6
- package/embed/index.cjs.js +54 -56
- package/embed/serializeEmbedCode.js +8 -8
- package/embed/strategies/facebook/index.cjs.js +45 -47
- package/embed/strategies/facebook/index.d.ts +5 -5
- package/embed/strategies/facebook/index.js +45 -45
- package/embed/strategies/instagram/index.cjs.js +29 -31
- package/embed/strategies/instagram/index.d.ts +3 -3
- package/embed/strategies/instagram/index.js +29 -29
- package/embed/strategies/podcast-apple/index.cjs.js +16 -18
- package/embed/strategies/podcast-apple/index.d.ts +4 -4
- package/embed/strategies/podcast-apple/index.js +16 -16
- package/embed/strategies/spotify/index.cjs.js +14 -16
- package/embed/strategies/spotify/index.d.ts +4 -4
- package/embed/strategies/spotify/index.js +14 -14
- package/embed/strategies/twitter/index.cjs.js +41 -43
- package/embed/strategies/twitter/index.d.ts +4 -4
- package/embed/strategies/twitter/index.js +41 -41
- package/embed/strategies/vimeo/index.cjs.js +14 -16
- package/embed/strategies/vimeo/index.d.ts +3 -3
- package/embed/strategies/vimeo/index.js +14 -14
- package/embed/strategies/youtube/index.cjs.js +14 -16
- package/embed/strategies/youtube/index.d.ts +3 -3
- package/embed/strategies/youtube/index.js +14 -14
- package/embed/typings.d.ts +1 -1
- package/file-uploader/_virtual/_tslib.js +3 -1
- package/file-uploader/createFileUploader.js +76 -76
- package/file-uploader/getFilesFromInput.js +24 -24
- package/file-uploader/index.cjs.js +102 -102
- package/file-uploader/typings.d.ts +6 -6
- package/footnote/createFootnote.d.ts +1 -1
- package/footnote/createFootnote.js +65 -65
- package/footnote/index.cjs.js +65 -67
- package/footnote/typings.d.ts +1 -1
- package/heading/constants.js +1 -1
- package/heading/createHeading.d.ts +1 -1
- package/heading/createHeading.js +45 -45
- package/heading/index.cjs.js +46 -48
- package/heading/typings.d.ts +1 -1
- package/highlight/createHighlight.d.ts +2 -1
- package/highlight/createHighlight.js +6 -4
- package/highlight/index.cjs.js +6 -6
- package/image/constants.js +4 -4
- package/image/createImage.js +195 -195
- package/image/getImageElementCommonProps.js +6 -6
- package/image/getImageFigureElementCommonProps.js +5 -5
- package/image/index.cjs.js +211 -213
- package/image/isHostingNotRequired.js +2 -2
- package/image/typings.d.ts +8 -8
- package/input-block/createInputBlock.js +37 -37
- package/input-block/index.cjs.js +37 -39
- package/input-widget/typings.d.ts +1 -1
- package/italic/createItalic.d.ts +2 -1
- package/italic/createItalic.js +6 -4
- package/italic/index.cjs.js +6 -6
- package/link/createLink.js +147 -147
- package/link/index.cjs.js +146 -148
- package/link/typings.d.ts +2 -2
- package/list/constants.js +4 -4
- package/list/createList.js +185 -185
- package/list/index.cjs.js +188 -190
- package/list/typings.d.ts +4 -4
- package/package.json +4 -4
- package/read-more/createReadMore.d.ts +1 -1
- package/read-more/createReadMore.js +51 -51
- package/read-more/index.cjs.js +50 -52
- package/strikethrough/createStrikethrough.d.ts +2 -1
- package/strikethrough/createStrikethrough.js +6 -4
- package/strikethrough/index.cjs.js +6 -6
- package/toggle-mark/createToggleMarkCreator.d.ts +4 -4
- package/toggle-mark/createToggleMarkCreator.js +36 -36
- package/toggle-mark/index.cjs.js +36 -38
- package/underline/createUnderline.d.ts +2 -1
- package/underline/createUnderline.js +6 -4
- package/underline/index.cjs.js +6 -6
|
@@ -1,52 +1,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
&&
|
|
47
|
-
&&
|
|
48
|
-
&& (typeof width === 'number' || typeof width === 'undefined')
|
|
49
|
-
&& (typeof height === 'number' || typeof height === 'undefined'),
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
4
|
+
const FacebookEmbedStrategy = {
|
|
5
|
+
serialize: (html) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const template = document.createElement('template');
|
|
8
|
+
template.innerHTML = html;
|
|
9
|
+
const { firstChild } = template.content;
|
|
10
|
+
if (!firstChild || firstChild.nodeName !== 'IFRAME') {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
const iframe = firstChild;
|
|
14
|
+
const parsedURL = new URL(iframe.src);
|
|
15
|
+
const href = parsedURL.searchParams.get('href');
|
|
16
|
+
if (!href) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
const resourceURL = new URL(href);
|
|
20
|
+
const embedType = (_a = /^\/plugins\/(comment_embed|post|video).php$/.exec(parsedURL.pathname)) === null || _a === void 0 ? void 0 : _a[1];
|
|
21
|
+
if (!embedType) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
embedType,
|
|
26
|
+
url: `${resourceURL.pathname}${resourceURL.search}`,
|
|
27
|
+
width: Number(iframe.width),
|
|
28
|
+
height: Number(iframe.height),
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
deserialize: ({ embedType, url, width, height, }) => {
|
|
32
|
+
const params = new URLSearchParams({
|
|
33
|
+
href: `https://www.facebook.com${url}`,
|
|
34
|
+
width: `${width}`,
|
|
35
|
+
height: `${height}`,
|
|
36
|
+
}).toString();
|
|
37
|
+
return {
|
|
38
|
+
url: `https://www.facebook.com/plugins/${embedType}.php?${params}`,
|
|
39
|
+
width,
|
|
40
|
+
height,
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
isElementDataValid: ({ embedType, url, width, height, }) => typeof url === 'string'
|
|
44
|
+
&& !!url
|
|
45
|
+
&& ['comment_embed', 'post', 'video'].includes(embedType)
|
|
46
|
+
&& (typeof width === 'number' || typeof width === 'undefined')
|
|
47
|
+
&& (typeof height === 'number' || typeof height === 'undefined'),
|
|
50
48
|
};
|
|
51
49
|
|
|
52
50
|
exports.FacebookEmbedStrategy = FacebookEmbedStrategy;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { EmbedElement, EmbedStrategy } from '@quadrats/common/embed';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type FacebookEmbedType = 'comment_embed' | 'post' | 'video';
|
|
3
|
+
export type FacebookEmbedData = {
|
|
4
4
|
embedType: FacebookEmbedType;
|
|
5
5
|
url: string;
|
|
6
6
|
width?: number;
|
|
7
7
|
height?: number;
|
|
8
8
|
};
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
9
|
+
export type FacebookDeserializedEmbedData = Omit<FacebookEmbedData, 'embedType'>;
|
|
10
|
+
export type FacebookEmbedElement = EmbedElement & FacebookEmbedData;
|
|
11
|
+
export type FacebookEmbedStrategy = EmbedStrategy<FacebookEmbedData, FacebookDeserializedEmbedData>;
|
|
12
12
|
export declare const FacebookEmbedStrategy: FacebookEmbedStrategy;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
-
const FacebookEmbedStrategy = {
|
|
3
|
-
serialize: (html) => {
|
|
4
|
-
var _a;
|
|
5
|
-
const template = document.createElement('template');
|
|
6
|
-
template.innerHTML = html;
|
|
7
|
-
const { firstChild } = template.content;
|
|
8
|
-
if (!firstChild || firstChild.nodeName !== 'IFRAME') {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
11
|
-
const iframe = firstChild;
|
|
12
|
-
const parsedURL = new URL(iframe.src);
|
|
13
|
-
const href = parsedURL.searchParams.get('href');
|
|
14
|
-
if (!href) {
|
|
15
|
-
return undefined;
|
|
16
|
-
}
|
|
17
|
-
const resourceURL = new URL(href);
|
|
18
|
-
const embedType = (_a = /^\/plugins\/(comment_embed|post|video).php$/.exec(parsedURL.pathname)) === null || _a === void 0 ? void 0 : _a[1];
|
|
19
|
-
if (!embedType) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
embedType,
|
|
24
|
-
url: `${resourceURL.pathname}${resourceURL.search}`,
|
|
25
|
-
width: Number(iframe.width),
|
|
26
|
-
height: Number(iframe.height),
|
|
27
|
-
};
|
|
28
|
-
},
|
|
29
|
-
deserialize: ({ embedType, url, width, height, }) => {
|
|
30
|
-
const params = new URLSearchParams({
|
|
31
|
-
href: `https://www.facebook.com${url}`,
|
|
32
|
-
width: `${width}`,
|
|
33
|
-
height: `${height}`,
|
|
34
|
-
}).toString();
|
|
35
|
-
return {
|
|
36
|
-
url: `https://www.facebook.com/plugins/${embedType}.php?${params}`,
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
isElementDataValid: ({ embedType, url, width, height, }) => typeof url === 'string'
|
|
42
|
-
&& !!url
|
|
43
|
-
&& ['comment_embed', 'post', 'video'].includes(embedType)
|
|
44
|
-
&& (typeof width === 'number' || typeof width === 'undefined')
|
|
45
|
-
&& (typeof height === 'number' || typeof height === 'undefined'),
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
+
const FacebookEmbedStrategy = {
|
|
3
|
+
serialize: (html) => {
|
|
4
|
+
var _a;
|
|
5
|
+
const template = document.createElement('template');
|
|
6
|
+
template.innerHTML = html;
|
|
7
|
+
const { firstChild } = template.content;
|
|
8
|
+
if (!firstChild || firstChild.nodeName !== 'IFRAME') {
|
|
9
|
+
return undefined;
|
|
10
|
+
}
|
|
11
|
+
const iframe = firstChild;
|
|
12
|
+
const parsedURL = new URL(iframe.src);
|
|
13
|
+
const href = parsedURL.searchParams.get('href');
|
|
14
|
+
if (!href) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const resourceURL = new URL(href);
|
|
18
|
+
const embedType = (_a = /^\/plugins\/(comment_embed|post|video).php$/.exec(parsedURL.pathname)) === null || _a === void 0 ? void 0 : _a[1];
|
|
19
|
+
if (!embedType) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return {
|
|
23
|
+
embedType,
|
|
24
|
+
url: `${resourceURL.pathname}${resourceURL.search}`,
|
|
25
|
+
width: Number(iframe.width),
|
|
26
|
+
height: Number(iframe.height),
|
|
27
|
+
};
|
|
28
|
+
},
|
|
29
|
+
deserialize: ({ embedType, url, width, height, }) => {
|
|
30
|
+
const params = new URLSearchParams({
|
|
31
|
+
href: `https://www.facebook.com${url}`,
|
|
32
|
+
width: `${width}`,
|
|
33
|
+
height: `${height}`,
|
|
34
|
+
}).toString();
|
|
35
|
+
return {
|
|
36
|
+
url: `https://www.facebook.com/plugins/${embedType}.php?${params}`,
|
|
37
|
+
width,
|
|
38
|
+
height,
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
isElementDataValid: ({ embedType, url, width, height, }) => typeof url === 'string'
|
|
42
|
+
&& !!url
|
|
43
|
+
&& ['comment_embed', 'post', 'video'].includes(embedType)
|
|
44
|
+
&& (typeof width === 'number' || typeof width === 'undefined')
|
|
45
|
+
&& (typeof height === 'number' || typeof height === 'undefined'),
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
export { FacebookEmbedStrategy };
|
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
deserialize: ({ url }) => `https://www.instagram.com/${url}/`,
|
|
33
|
-
isElementDataValid: ({ url }) => typeof url === 'string' && !!url,
|
|
3
|
+
function getInstagramUrlFromUrl(url) {
|
|
4
|
+
var _a;
|
|
5
|
+
return (_a = /^https:\/\/www.instagram.com\/([\w]*\/[\w-]*)\//i.exec(url)) === null || _a === void 0 ? void 0 : _a[1];
|
|
6
|
+
}
|
|
7
|
+
function getInstagramUrlFromBlockquote(embedCode) {
|
|
8
|
+
const template = document.createElement('template');
|
|
9
|
+
template.innerHTML = embedCode;
|
|
10
|
+
const { firstChild } = template.content;
|
|
11
|
+
if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const blockquote = firstChild;
|
|
15
|
+
const link = blockquote.firstChild.children[0];
|
|
16
|
+
const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
|
|
17
|
+
return url ? getInstagramUrlFromUrl(url) : undefined;
|
|
18
|
+
}
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
20
|
+
const InstagramEmbedStrategy = {
|
|
21
|
+
serialize: (embedCode) => {
|
|
22
|
+
const getter = embedCode.startsWith('<blockquote') ? getInstagramUrlFromBlockquote : getInstagramUrlFromUrl;
|
|
23
|
+
const url = getter(embedCode);
|
|
24
|
+
if (url) {
|
|
25
|
+
return {
|
|
26
|
+
url,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
deserialize: ({ url }) => `https://www.instagram.com/${url}/`,
|
|
31
|
+
isElementDataValid: ({ url }) => typeof url === 'string' && !!url,
|
|
34
32
|
};
|
|
35
33
|
|
|
36
34
|
exports.InstagramEmbedStrategy = InstagramEmbedStrategy;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EmbedElement, EmbedStrategy } from '@quadrats/common/embed';
|
|
2
|
-
export
|
|
2
|
+
export type InstagramEmbedElementData = {
|
|
3
3
|
url: string;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
5
|
+
export type InstagramEmbedElement = EmbedElement & InstagramEmbedElementData;
|
|
6
|
+
export type InstagramEmbedStrategy = EmbedStrategy<InstagramEmbedElementData, string>;
|
|
7
7
|
export declare function getInstagramUrlFromUrl(url: string): string | undefined;
|
|
8
8
|
export declare function getInstagramUrlFromBlockquote(embedCode: string): string | undefined;
|
|
9
9
|
export declare const InstagramEmbedStrategy: InstagramEmbedStrategy;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
function getInstagramUrlFromUrl(url) {
|
|
2
|
-
var _a;
|
|
3
|
-
return (_a = /^https:\/\/www.instagram.com\/([\w]*\/[\w-]*)\//i.exec(url)) === null || _a === void 0 ? void 0 : _a[1];
|
|
4
|
-
}
|
|
5
|
-
function getInstagramUrlFromBlockquote(embedCode) {
|
|
6
|
-
const template = document.createElement('template');
|
|
7
|
-
template.innerHTML = embedCode;
|
|
8
|
-
const { firstChild } = template.content;
|
|
9
|
-
if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
const blockquote = firstChild;
|
|
13
|
-
const link = blockquote.firstChild.children[0];
|
|
14
|
-
const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
|
|
15
|
-
return url ? getInstagramUrlFromUrl(url) : undefined;
|
|
16
|
-
}
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
18
|
-
const InstagramEmbedStrategy = {
|
|
19
|
-
serialize: (embedCode) => {
|
|
20
|
-
const getter = embedCode.startsWith('<blockquote') ? getInstagramUrlFromBlockquote : getInstagramUrlFromUrl;
|
|
21
|
-
const url = getter(embedCode);
|
|
22
|
-
if (url) {
|
|
23
|
-
return {
|
|
24
|
-
url,
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
deserialize: ({ url }) => `https://www.instagram.com/${url}/`,
|
|
29
|
-
isElementDataValid: ({ url }) => typeof url === 'string' && !!url,
|
|
1
|
+
function getInstagramUrlFromUrl(url) {
|
|
2
|
+
var _a;
|
|
3
|
+
return (_a = /^https:\/\/www.instagram.com\/([\w]*\/[\w-]*)\//i.exec(url)) === null || _a === void 0 ? void 0 : _a[1];
|
|
4
|
+
}
|
|
5
|
+
function getInstagramUrlFromBlockquote(embedCode) {
|
|
6
|
+
const template = document.createElement('template');
|
|
7
|
+
template.innerHTML = embedCode;
|
|
8
|
+
const { firstChild } = template.content;
|
|
9
|
+
if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const blockquote = firstChild;
|
|
13
|
+
const link = blockquote.firstChild.children[0];
|
|
14
|
+
const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
|
|
15
|
+
return url ? getInstagramUrlFromUrl(url) : undefined;
|
|
16
|
+
}
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
18
|
+
const InstagramEmbedStrategy = {
|
|
19
|
+
serialize: (embedCode) => {
|
|
20
|
+
const getter = embedCode.startsWith('<blockquote') ? getInstagramUrlFromBlockquote : getInstagramUrlFromUrl;
|
|
21
|
+
const url = getter(embedCode);
|
|
22
|
+
if (url) {
|
|
23
|
+
return {
|
|
24
|
+
url,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
deserialize: ({ url }) => `https://www.instagram.com/${url}/`,
|
|
29
|
+
isElementDataValid: ({ url }) => typeof url === 'string' && !!url,
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
export { InstagramEmbedStrategy, getInstagramUrlFromBlockquote, getInstagramUrlFromUrl };
|
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
20
|
-
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
4
|
+
const PodcastAppleEmbedStrategy = {
|
|
5
|
+
serialize: (embedCode) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode)) !== null && _a !== void 0 ? _a : /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/id([\d]*)/i.exec(embedCode)) !== null && _b !== void 0 ? _b : /^https:\/\/podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode);
|
|
8
|
+
if (result) {
|
|
9
|
+
const [, language, contextId] = result;
|
|
10
|
+
return {
|
|
11
|
+
embedType: 'podcast-apple',
|
|
12
|
+
language,
|
|
13
|
+
contextId,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
18
|
+
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
exports.PodcastAppleEmbedStrategy = PodcastAppleEmbedStrategy;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EmbedElement, EmbedStrategy } from '@quadrats/common/embed';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type PodcastAppleEmbedType = 'podcast-apple';
|
|
3
|
+
export type PodcastAppleEmbedElementData = {
|
|
4
4
|
embedType: PodcastAppleEmbedType;
|
|
5
5
|
language?: string;
|
|
6
6
|
contextId: string;
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type PodcastAppleEmbedElement = EmbedElement & PodcastAppleEmbedElementData;
|
|
9
|
+
export type PodcastAppleEmbedStrategy = EmbedStrategy<PodcastAppleEmbedElementData, string>;
|
|
10
10
|
export declare const PodcastAppleEmbedStrategy: PodcastAppleEmbedStrategy;
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
-
const PodcastAppleEmbedStrategy = {
|
|
3
|
-
serialize: (embedCode) => {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode)) !== null && _a !== void 0 ? _a : /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/id([\d]*)/i.exec(embedCode)) !== null && _b !== void 0 ? _b : /^https:\/\/podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode);
|
|
6
|
-
if (result) {
|
|
7
|
-
const [, language, contextId] = result;
|
|
8
|
-
return {
|
|
9
|
-
embedType: 'podcast-apple',
|
|
10
|
-
language,
|
|
11
|
-
contextId,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
16
|
-
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
+
const PodcastAppleEmbedStrategy = {
|
|
3
|
+
serialize: (embedCode) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const result = (_b = (_a = /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode)) !== null && _a !== void 0 ? _a : /^https:\/\/embed.podcasts.apple.com\/([\w-]*)\/podcast\/id([\d]*)/i.exec(embedCode)) !== null && _b !== void 0 ? _b : /^https:\/\/podcasts.apple.com\/([\w-]*)\/podcast\/[\S]*\/id([\d]*)/i.exec(embedCode);
|
|
6
|
+
if (result) {
|
|
7
|
+
const [, language, contextId] = result;
|
|
8
|
+
return {
|
|
9
|
+
embedType: 'podcast-apple',
|
|
10
|
+
language,
|
|
11
|
+
contextId,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
deserialize: data => { var _a; return `https://embed.podcasts.apple.com/${(_a = data.language) !== null && _a !== void 0 ? _a : 'us'}/podcast/id${data.contextId}`; },
|
|
16
|
+
isElementDataValid: data => typeof data.contextId === 'string' && !!(data.contextId),
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export { PodcastAppleEmbedStrategy };
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
deserialize: (data) => `https://open.spotify.com/embed/${data.contextId}?utm_source=generator`,
|
|
18
|
-
isElementDataValid: (data) => typeof data.contextId === 'string' && !!(data.contextId),
|
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
4
|
+
const SpotifyEmbedStrategy = {
|
|
5
|
+
serialize: (embedCode) => {
|
|
6
|
+
const result = /^https:\/\/open.spotify.com\/([\S]*)/i.exec(embedCode);
|
|
7
|
+
if (result) {
|
|
8
|
+
const [, contextId] = result;
|
|
9
|
+
return {
|
|
10
|
+
embedType: 'spotify',
|
|
11
|
+
contextId,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
deserialize: (data) => `https://open.spotify.com/embed/${data.contextId}?utm_source=generator`,
|
|
16
|
+
isElementDataValid: (data) => typeof data.contextId === 'string' && !!(data.contextId),
|
|
19
17
|
};
|
|
20
18
|
|
|
21
19
|
exports.SpotifyEmbedStrategy = SpotifyEmbedStrategy;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EmbedElement, EmbedStrategy } from '@quadrats/common/embed';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export type SpotifyEmbedType = 'spotify';
|
|
3
|
+
export type SpotifyEmbedElementData = {
|
|
4
4
|
embedType: SpotifyEmbedType;
|
|
5
5
|
contextId: string;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
8
|
-
export
|
|
7
|
+
export type SpotifyEmbedElement = EmbedElement & SpotifyEmbedElementData;
|
|
8
|
+
export type SpotifyEmbedStrategy = EmbedStrategy<SpotifyEmbedElementData, string>;
|
|
9
9
|
export declare const SpotifyEmbedStrategy: SpotifyEmbedStrategy;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
-
const SpotifyEmbedStrategy = {
|
|
3
|
-
serialize: (embedCode) => {
|
|
4
|
-
const result = /^https:\/\/open.spotify.com\/([\S]*)/i.exec(embedCode);
|
|
5
|
-
if (result) {
|
|
6
|
-
const [, contextId] = result;
|
|
7
|
-
return {
|
|
8
|
-
embedType: 'spotify',
|
|
9
|
-
contextId,
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
deserialize: (data) => `https://open.spotify.com/embed/${data.contextId}?utm_source=generator`,
|
|
14
|
-
isElementDataValid: (data) => typeof data.contextId === 'string' && !!(data.contextId),
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
2
|
+
const SpotifyEmbedStrategy = {
|
|
3
|
+
serialize: (embedCode) => {
|
|
4
|
+
const result = /^https:\/\/open.spotify.com\/([\S]*)/i.exec(embedCode);
|
|
5
|
+
if (result) {
|
|
6
|
+
const [, contextId] = result;
|
|
7
|
+
return {
|
|
8
|
+
embedType: 'spotify',
|
|
9
|
+
contextId,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
deserialize: (data) => `https://open.spotify.com/embed/${data.contextId}?utm_source=generator`,
|
|
14
|
+
isElementDataValid: (data) => typeof data.contextId === 'string' && !!(data.contextId),
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
export { SpotifyEmbedStrategy };
|
|
@@ -1,48 +1,46 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return true;
|
|
45
|
-
},
|
|
3
|
+
function getTwitterTweetDataFromUrl(url) {
|
|
4
|
+
const result = /^https:\/\/twitter.com\/[\w]*\/status\/([\w-]*)/i.exec(url);
|
|
5
|
+
if (result) {
|
|
6
|
+
const [, tweetId] = result;
|
|
7
|
+
return {
|
|
8
|
+
embedType: 'tweet',
|
|
9
|
+
tweetId,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function getTwitterTweetDataFromBlockquote(embedCode) {
|
|
14
|
+
const template = document.createElement('template');
|
|
15
|
+
template.innerHTML = embedCode;
|
|
16
|
+
const { firstChild } = template.content;
|
|
17
|
+
if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const blockquote = firstChild;
|
|
21
|
+
const link = blockquote.lastChild;
|
|
22
|
+
const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
|
|
23
|
+
return url ? getTwitterTweetDataFromUrl(url) : undefined;
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
26
|
+
const TwitterEmbedStrategy = {
|
|
27
|
+
serialize: (embedCode) => {
|
|
28
|
+
const getter = embedCode.startsWith('<blockquote') ? getTwitterTweetDataFromBlockquote : getTwitterTweetDataFromUrl;
|
|
29
|
+
return getter(embedCode);
|
|
30
|
+
},
|
|
31
|
+
deserialize: (data) => {
|
|
32
|
+
if (data.embedType === 'tweet') {
|
|
33
|
+
return data.tweetId;
|
|
34
|
+
}
|
|
35
|
+
return '';
|
|
36
|
+
},
|
|
37
|
+
isElementDataValid: (data) => {
|
|
38
|
+
if (data.embedType === 'tweet') {
|
|
39
|
+
const { tweetId } = data;
|
|
40
|
+
return typeof tweetId === 'string' && !!tweetId;
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
},
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
exports.TwitterEmbedStrategy = TwitterEmbedStrategy;
|