@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.
Files changed (85) hide show
  1. package/blockquote/createBlockquote.d.ts +1 -1
  2. package/blockquote/createBlockquote.js +33 -33
  3. package/blockquote/index.cjs.js +32 -34
  4. package/bold/createBold.d.ts +2 -1
  5. package/bold/createBold.js +6 -4
  6. package/bold/index.cjs.js +6 -6
  7. package/divider/createDivider.d.ts +1 -1
  8. package/divider/createDivider.js +29 -29
  9. package/divider/index.cjs.js +29 -31
  10. package/embed/createEmbed.js +40 -40
  11. package/embed/deserializeEmbedElementToData.js +6 -6
  12. package/embed/index.cjs.js +54 -56
  13. package/embed/serializeEmbedCode.js +8 -8
  14. package/embed/strategies/facebook/index.cjs.js +45 -47
  15. package/embed/strategies/facebook/index.d.ts +5 -5
  16. package/embed/strategies/facebook/index.js +45 -45
  17. package/embed/strategies/instagram/index.cjs.js +29 -31
  18. package/embed/strategies/instagram/index.d.ts +3 -3
  19. package/embed/strategies/instagram/index.js +29 -29
  20. package/embed/strategies/podcast-apple/index.cjs.js +16 -18
  21. package/embed/strategies/podcast-apple/index.d.ts +4 -4
  22. package/embed/strategies/podcast-apple/index.js +16 -16
  23. package/embed/strategies/spotify/index.cjs.js +14 -16
  24. package/embed/strategies/spotify/index.d.ts +4 -4
  25. package/embed/strategies/spotify/index.js +14 -14
  26. package/embed/strategies/twitter/index.cjs.js +41 -43
  27. package/embed/strategies/twitter/index.d.ts +4 -4
  28. package/embed/strategies/twitter/index.js +41 -41
  29. package/embed/strategies/vimeo/index.cjs.js +14 -16
  30. package/embed/strategies/vimeo/index.d.ts +3 -3
  31. package/embed/strategies/vimeo/index.js +14 -14
  32. package/embed/strategies/youtube/index.cjs.js +14 -16
  33. package/embed/strategies/youtube/index.d.ts +3 -3
  34. package/embed/strategies/youtube/index.js +14 -14
  35. package/embed/typings.d.ts +1 -1
  36. package/file-uploader/_virtual/_tslib.js +3 -1
  37. package/file-uploader/createFileUploader.js +76 -76
  38. package/file-uploader/getFilesFromInput.js +24 -24
  39. package/file-uploader/index.cjs.js +102 -102
  40. package/file-uploader/typings.d.ts +6 -6
  41. package/footnote/createFootnote.d.ts +1 -1
  42. package/footnote/createFootnote.js +65 -65
  43. package/footnote/index.cjs.js +65 -67
  44. package/footnote/typings.d.ts +1 -1
  45. package/heading/constants.js +1 -1
  46. package/heading/createHeading.d.ts +1 -1
  47. package/heading/createHeading.js +45 -45
  48. package/heading/index.cjs.js +46 -48
  49. package/heading/typings.d.ts +1 -1
  50. package/highlight/createHighlight.d.ts +2 -1
  51. package/highlight/createHighlight.js +6 -4
  52. package/highlight/index.cjs.js +6 -6
  53. package/image/constants.js +4 -4
  54. package/image/createImage.js +195 -195
  55. package/image/getImageElementCommonProps.js +6 -6
  56. package/image/getImageFigureElementCommonProps.js +5 -5
  57. package/image/index.cjs.js +211 -213
  58. package/image/isHostingNotRequired.js +2 -2
  59. package/image/typings.d.ts +8 -8
  60. package/input-block/createInputBlock.js +37 -37
  61. package/input-block/index.cjs.js +37 -39
  62. package/input-widget/typings.d.ts +1 -1
  63. package/italic/createItalic.d.ts +2 -1
  64. package/italic/createItalic.js +6 -4
  65. package/italic/index.cjs.js +6 -6
  66. package/link/createLink.js +147 -147
  67. package/link/index.cjs.js +146 -148
  68. package/link/typings.d.ts +2 -2
  69. package/list/constants.js +4 -4
  70. package/list/createList.js +185 -185
  71. package/list/index.cjs.js +188 -190
  72. package/list/typings.d.ts +4 -4
  73. package/package.json +4 -4
  74. package/read-more/createReadMore.d.ts +1 -1
  75. package/read-more/createReadMore.js +51 -51
  76. package/read-more/index.cjs.js +50 -52
  77. package/strikethrough/createStrikethrough.d.ts +2 -1
  78. package/strikethrough/createStrikethrough.js +6 -4
  79. package/strikethrough/index.cjs.js +6 -6
  80. package/toggle-mark/createToggleMarkCreator.d.ts +4 -4
  81. package/toggle-mark/createToggleMarkCreator.js +36 -36
  82. package/toggle-mark/index.cjs.js +36 -38
  83. package/underline/createUnderline.d.ts +2 -1
  84. package/underline/createUnderline.js +6 -4
  85. package/underline/index.cjs.js +6 -6
@@ -1,52 +1,50 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-redeclare
6
- const FacebookEmbedStrategy = {
7
- serialize: (html) => {
8
- var _a;
9
- const template = document.createElement('template');
10
- template.innerHTML = html;
11
- const { firstChild } = template.content;
12
- if (!firstChild || firstChild.nodeName !== 'IFRAME') {
13
- return undefined;
14
- }
15
- const iframe = firstChild;
16
- const parsedURL = new URL(iframe.src);
17
- const href = parsedURL.searchParams.get('href');
18
- if (!href) {
19
- return undefined;
20
- }
21
- const resourceURL = new URL(href);
22
- const embedType = (_a = /^\/plugins\/(comment_embed|post|video).php$/.exec(parsedURL.pathname)) === null || _a === void 0 ? void 0 : _a[1];
23
- if (!embedType) {
24
- return;
25
- }
26
- return {
27
- embedType,
28
- url: `${resourceURL.pathname}${resourceURL.search}`,
29
- width: Number(iframe.width),
30
- height: Number(iframe.height),
31
- };
32
- },
33
- deserialize: ({ embedType, url, width, height, }) => {
34
- const params = new URLSearchParams({
35
- href: `https://www.facebook.com${url}`,
36
- width: `${width}`,
37
- height: `${height}`,
38
- }).toString();
39
- return {
40
- url: `https://www.facebook.com/plugins/${embedType}.php?${params}`,
41
- width,
42
- height,
43
- };
44
- },
45
- isElementDataValid: ({ embedType, url, width, height, }) => typeof url === 'string'
46
- && !!url
47
- && ['comment_embed', 'post', 'video'].includes(embedType)
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 declare type FacebookEmbedType = 'comment_embed' | 'post' | 'video';
3
- export declare type FacebookEmbedData = {
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 declare type FacebookDeserializedEmbedData = Omit<FacebookEmbedData, 'embedType'>;
10
- export declare type FacebookEmbedElement = EmbedElement & FacebookEmbedData;
11
- export declare type FacebookEmbedStrategy = EmbedStrategy<FacebookEmbedData, FacebookDeserializedEmbedData>;
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
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function getInstagramUrlFromUrl(url) {
6
- var _a;
7
- return (_a = /^https:\/\/www.instagram.com\/([\w]*\/[\w-]*)\//i.exec(url)) === null || _a === void 0 ? void 0 : _a[1];
8
- }
9
- function getInstagramUrlFromBlockquote(embedCode) {
10
- const template = document.createElement('template');
11
- template.innerHTML = embedCode;
12
- const { firstChild } = template.content;
13
- if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
14
- return;
15
- }
16
- const blockquote = firstChild;
17
- const link = blockquote.firstChild.children[0];
18
- const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
19
- return url ? getInstagramUrlFromUrl(url) : undefined;
20
- }
21
- // eslint-disable-next-line @typescript-eslint/no-redeclare
22
- const InstagramEmbedStrategy = {
23
- serialize: (embedCode) => {
24
- const getter = embedCode.startsWith('<blockquote') ? getInstagramUrlFromBlockquote : getInstagramUrlFromUrl;
25
- const url = getter(embedCode);
26
- if (url) {
27
- return {
28
- url,
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 declare type InstagramEmbedElementData = {
2
+ export type InstagramEmbedElementData = {
3
3
  url: string;
4
4
  };
5
- export declare type InstagramEmbedElement = EmbedElement & InstagramEmbedElementData;
6
- export declare type InstagramEmbedStrategy = EmbedStrategy<InstagramEmbedElementData, string>;
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
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-redeclare
6
- const PodcastAppleEmbedStrategy = {
7
- serialize: (embedCode) => {
8
- var _a, _b;
9
- 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);
10
- if (result) {
11
- const [, language, contextId] = result;
12
- return {
13
- embedType: 'podcast-apple',
14
- language,
15
- contextId,
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 declare type PodcastAppleEmbedType = 'podcast-apple';
3
- export declare type PodcastAppleEmbedElementData = {
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 declare type PodcastAppleEmbedElement = EmbedElement & PodcastAppleEmbedElementData;
9
- export declare type PodcastAppleEmbedStrategy = EmbedStrategy<PodcastAppleEmbedElementData, string>;
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
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- // eslint-disable-next-line @typescript-eslint/no-redeclare
6
- const SpotifyEmbedStrategy = {
7
- serialize: (embedCode) => {
8
- const result = /^https:\/\/open.spotify.com\/([\S]*)/i.exec(embedCode);
9
- if (result) {
10
- const [, contextId] = result;
11
- return {
12
- embedType: 'spotify',
13
- contextId,
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 declare type SpotifyEmbedType = 'spotify';
3
- export declare type SpotifyEmbedElementData = {
2
+ export type SpotifyEmbedType = 'spotify';
3
+ export type SpotifyEmbedElementData = {
4
4
  embedType: SpotifyEmbedType;
5
5
  contextId: string;
6
6
  };
7
- export declare type SpotifyEmbedElement = EmbedElement & SpotifyEmbedElementData;
8
- export declare type SpotifyEmbedStrategy = EmbedStrategy<SpotifyEmbedElementData, string>;
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
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function getTwitterTweetDataFromUrl(url) {
6
- const result = /^https:\/\/twitter.com\/[\w]*\/status\/([\w-]*)/i.exec(url);
7
- if (result) {
8
- const [, tweetId] = result;
9
- return {
10
- embedType: 'tweet',
11
- tweetId,
12
- };
13
- }
14
- }
15
- function getTwitterTweetDataFromBlockquote(embedCode) {
16
- const template = document.createElement('template');
17
- template.innerHTML = embedCode;
18
- const { firstChild } = template.content;
19
- if (!firstChild || firstChild.nodeName !== 'BLOCKQUOTE') {
20
- return;
21
- }
22
- const blockquote = firstChild;
23
- const link = blockquote.lastChild;
24
- const url = link === null || link === void 0 ? void 0 : link.getAttribute('href');
25
- return url ? getTwitterTweetDataFromUrl(url) : undefined;
26
- }
27
- // eslint-disable-next-line @typescript-eslint/no-redeclare
28
- const TwitterEmbedStrategy = {
29
- serialize: (embedCode) => {
30
- const getter = embedCode.startsWith('<blockquote') ? getTwitterTweetDataFromBlockquote : getTwitterTweetDataFromUrl;
31
- return getter(embedCode);
32
- },
33
- deserialize: (data) => {
34
- if (data.embedType === 'tweet') {
35
- return data.tweetId;
36
- }
37
- return '';
38
- },
39
- isElementDataValid: (data) => {
40
- if (data.embedType === 'tweet') {
41
- const { tweetId } = data;
42
- return typeof tweetId === 'string' && !!tweetId;
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;