@teleporthq/teleport-shared 0.43.68 → 0.43.69
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/__tests__/_helpers/embed-runtime-emitter.ts +197 -0
- package/__tests__/utils/rich-text-embeds-runtime-module.ts +34 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/rich-text-embeds-codegen.d.ts +13 -0
- package/dist/cjs/utils/rich-text-embeds-codegen.d.ts.map +1 -1
- package/dist/cjs/utils/rich-text-embeds-codegen.js +15 -104
- package/dist/cjs/utils/rich-text-embeds-codegen.js.map +1 -1
- package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts +2 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.js +409 -0
- package/dist/cjs/utils/rich-text-embeds-runtime-source.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/rich-text-embeds-codegen.d.ts +13 -0
- package/dist/esm/utils/rich-text-embeds-codegen.d.ts.map +1 -1
- package/dist/esm/utils/rich-text-embeds-codegen.js +16 -105
- package/dist/esm/utils/rich-text-embeds-codegen.js.map +1 -1
- package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts +2 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.d.ts.map +1 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.js +406 -0
- package/dist/esm/utils/rich-text-embeds-runtime-source.js.map +1 -0
- package/package.json +2 -2
- package/src/utils/rich-text-embeds-codegen.ts +16 -183
- package/src/utils/rich-text-embeds-runtime-source.ts +405 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-embeds-codegen.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-codegen.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-codegen.ts"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACH,uDAAoD;AACpD,qFAA+E;AAE/E;;;;;GAKG;AACH,SAAgB,iCAAiC;IAC/C,IAAM,OAAO,GAAG,kCAAe,CAAC,GAAG,CAAC,UAAC,QAAQ;QAC3C,IAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ;aAC/B,GAAG,CACF,UAAC,OAAO;YACN,OAAA,qBAAc,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,eAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,MAAG;QAAjF,CAAiF,CACpF;aACA,IAAI,CAAC,IAAI,CAAC,CAAA;QACb,OAAO,CACL,gBAAS,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC,sBAAY,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAI;YAClF,qBAAc,QAAQ,0BAAgB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAI;YAC3E,iBAAU,QAAQ,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAI,CACxE,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,eAAQ,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAK,CAAA;AAC3C,CAAC;AAfD,8EAeC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,gCAAgC;IAC9C,OAAO,6DAA2B,CAAA;AACpC,CAAC;AAFD,4EAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-runtime-source.d.ts","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-runtime-source.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,2BAA2B,QAgZ5B,CAAA"}
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EMBED_RUNTIME_MODULE_SOURCE = void 0;
|
|
4
|
+
// GENERATED from src/utils/rich-text-embeds.ts — do not edit by hand. Regenerate with
|
|
5
|
+
// UPDATE_EMBED_RUNTIME=1 npx jest packages/teleport-shared/__tests__/utils/rich-text-embeds-runtime-module.ts
|
|
6
|
+
// (see generateEmbedRuntimeModuleSource for why this is a string).
|
|
7
|
+
/* tslint:disable:no-invalid-template-strings -- the lines are JavaScript source */
|
|
8
|
+
exports.EMBED_RUNTIME_MODULE_SOURCE = [
|
|
9
|
+
'/**',
|
|
10
|
+
' * Code embeds inside rich-text content — the shape the editor writes and the',
|
|
11
|
+
' * page reads back. Generated from @teleporthq/teleport-shared; edit it there.',
|
|
12
|
+
' *',
|
|
13
|
+
' * An embed is stored inside the content HTML as a <figure class="tq-embed">.',
|
|
14
|
+
' * Passive markup (a provider iframe) lives in the figure as real children, so',
|
|
15
|
+
' * it renders server-side with no JavaScript. Markup that can execute — a',
|
|
16
|
+
' * <script>, an on* handler, a javascript: URL — is base64-encoded onto the',
|
|
17
|
+
' * element instead, and mounted at runtime inside a sandboxed iframe so it can',
|
|
18
|
+
' * never reach this page.',
|
|
19
|
+
' */',
|
|
20
|
+
'',
|
|
21
|
+
'export var EMBED_CLASS_NAME = "tq-embed"',
|
|
22
|
+
'',
|
|
23
|
+
'export var EMBED_FRAME_CLASS_NAME = "tq-embed-frame"',
|
|
24
|
+
'',
|
|
25
|
+
'export var EMBED_CAPTION_CLASS_NAME = "tq-embed-caption"',
|
|
26
|
+
'',
|
|
27
|
+
'export var EMBED_BLOT_NAME = "tq-embed"',
|
|
28
|
+
'',
|
|
29
|
+
'export var EMBED_ATTR = {',
|
|
30
|
+
' "MARKER": "data-tq-embed",',
|
|
31
|
+
' "PROVIDER": "data-tq-embed-provider",',
|
|
32
|
+
' "URL": "data-tq-embed-url",',
|
|
33
|
+
' "MODE": "data-tq-embed-mode",',
|
|
34
|
+
' "CODE": "data-tq-embed-code",',
|
|
35
|
+
' "RATIO": "data-tq-embed-ratio",',
|
|
36
|
+
' "WIDTH": "data-tq-embed-width",',
|
|
37
|
+
' "ALIGN": "data-tq-embed-align",',
|
|
38
|
+
' "CAPTION": "data-tq-embed-caption",',
|
|
39
|
+
' "SANDBOX": "data-tq-embed-sandbox",',
|
|
40
|
+
' "ACTIVATED": "data-tq-embed-activated",',
|
|
41
|
+
' "PREVIEW": "data-tq-embed-preview"',
|
|
42
|
+
'}',
|
|
43
|
+
'',
|
|
44
|
+
'export var EMBED_ALIGNMENTS = ["center","float-left","float-right"]',
|
|
45
|
+
'',
|
|
46
|
+
'export var CUSTOM_EMBED_PROVIDER_ID = "custom"',
|
|
47
|
+
'',
|
|
48
|
+
'export var GENERIC_EMBED_PROVIDER_ID = "iframe-url"',
|
|
49
|
+
'',
|
|
50
|
+
'export var DEFAULT_EMBED_WIDTH = 100',
|
|
51
|
+
'',
|
|
52
|
+
'export var DEFAULT_EMBED_ALIGN = "center"',
|
|
53
|
+
'',
|
|
54
|
+
'export var DEFAULT_EMBED_SANDBOX_LEVEL = "strict"',
|
|
55
|
+
'',
|
|
56
|
+
'export var WIDESCREEN_EMBED_RATIO = 56.25',
|
|
57
|
+
'',
|
|
58
|
+
'export var EMBED_CAPTION_STYLE = "margin-top:8px;font-size:0.875em;line-height:1.5;opacity:0.75;text-align:center"',
|
|
59
|
+
'',
|
|
60
|
+
'export var EMBED_PROVIDERS = [',
|
|
61
|
+
' { id: "youtube", label: "YouTube", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.|m\\\\.)?youtube\\\\.com\\\\/watch\\\\?(?:[^#]*&)?v=([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/youtu\\\\.be\\\\/([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?youtube\\\\.com\\\\/shorts\\\\/([A-Za-z0-9_-]{6,})", "i"), new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?youtube(?:-nocookie)?\\\\.com\\\\/embed\\\\/([A-Za-z0-9_-]{6,})", "i")], template: "<iframe src=\\"https://www.youtube.com/embed/$1\\" title=\\"YouTube video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
62
|
+
' { id: "vimeo", label: "Vimeo", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?vimeo\\\\.com\\\\/(\\\\d+)", "i"), new RegExp("^https?:\\\\/\\\\/player\\\\.vimeo\\\\.com\\\\/video\\\\/(\\\\d+)", "i")], template: "<iframe src=\\"https://player.vimeo.com/video/$1\\" title=\\"Vimeo video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
63
|
+
' { id: "loom", label: "Loom", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?loom\\\\.com\\\\/(?:share|embed)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://www.loom.com/embed/$1\\" title=\\"Loom video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
64
|
+
' { id: "dailymotion", label: "Dailymotion", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?dailymotion\\\\.com\\\\/video\\\\/([A-Za-z0-9]+)", "i"), new RegExp("^https?:\\\\/\\\\/dai\\\\.ly\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://www.dailymotion.com/embed/video/$1\\" title=\\"Dailymotion video\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
65
|
+
' { id: "spotify", label: "Spotify", patterns: [new RegExp("^https?:\\\\/\\\\/open\\\\.spotify\\\\.com\\\\/(?:embed\\\\/)?(track|album|playlist|episode|show|artist)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://open.spotify.com/embed/$1/$2\\" title=\\"Spotify player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:352px\\"></iframe>", ratio: null },',
|
|
66
|
+
' { id: "soundcloud", label: "SoundCloud", patterns: [new RegExp("^https?:\\\\/\\\\/soundcloud\\\\.com\\\\/[^?#]+", "i")], template: "<iframe src=\\"https://w.soundcloud.com/player/?url=$E&&color=%23ff5500&auto_play=false&show_teaser=false\\" title=\\"SoundCloud player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:166px\\"></iframe>", ratio: null },',
|
|
67
|
+
' { id: "apple-podcasts", label: "Apple Podcasts", patterns: [new RegExp("^https?:\\\\/\\\\/podcasts\\\\.apple\\\\.com\\\\/(.+)$", "i")], template: "<iframe src=\\"https://embed.podcasts.apple.com/$1\\" title=\\"Apple Podcasts player\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:175px\\"></iframe>", ratio: null },',
|
|
68
|
+
' { id: "twitter", label: "X (Twitter)", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?(?:twitter|x)\\\\.com\\\\/[^/]+\\\\/status\\\\/(\\\\d+)", "i")], template: "<blockquote class=\\"twitter-tweet\\"><a href=\\"$&\\"></a></blockquote><script async src=\\"https://platform.twitter.com/widgets.js\\" charset=\\"utf-8\\"></script>", ratio: null },',
|
|
69
|
+
' { id: "instagram", label: "Instagram", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?instagram\\\\.com\\\\/(?:p|reel|tv)\\\\/([A-Za-z0-9_-]+)", "i")], template: "<blockquote class=\\"instagram-media\\" data-instgrm-permalink=\\"https://www.instagram.com/p/$1/\\" data-instgrm-version=\\"14\\"></blockquote><script async src=\\"https://www.instagram.com/embed.js\\"></script>", ratio: null },',
|
|
70
|
+
' { id: "tiktok", label: "TikTok", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?tiktok\\\\.com\\\\/@[^/]+\\\\/video\\\\/(\\\\d+)", "i")], template: "<blockquote class=\\"tiktok-embed\\" cite=\\"$&\\" data-video-id=\\"$1\\"><section></section></blockquote><script async src=\\"https://www.tiktok.com/embed.js\\"></script>", ratio: null },',
|
|
71
|
+
' { id: "reddit", label: "Reddit", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?reddit\\\\.com\\\\/r\\\\/[^/]+\\\\/comments\\\\/.+", "i")], template: "<blockquote class=\\"reddit-embed-bq\\"><a href=\\"$&\\"></a></blockquote><script async src=\\"https://embed.reddit.com/widgets.js\\" charset=\\"UTF-8\\"></script>", ratio: null },',
|
|
72
|
+
' { id: "pinterest", label: "Pinterest", patterns: [new RegExp("^https?:\\\\/\\\\/(?:[a-z]{2}\\\\.)?pinterest\\\\.[a-z.]+\\\\/pin\\\\/[0-9]+", "i")], template: "<a data-pin-do=\\"embedPin\\" href=\\"$&\\"></a><script async defer src=\\"https://assets.pinterest.com/js/pinit.js\\"></script>", ratio: null },',
|
|
73
|
+
' { id: "facebook", label: "Facebook", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.|web\\\\.)?facebook\\\\.com\\\\/.+\\\\/(?:posts|videos)\\\\/.+", "i")], template: "<iframe src=\\"https://www.facebook.com/plugins/post.php?href=$E&&show_text=true\\" title=\\"Facebook post\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
|
|
74
|
+
' { id: "github-gist", label: "GitHub Gist", patterns: [new RegExp("^https?:\\\\/\\\\/gist\\\\.github\\\\.com\\\\/([^/]+\\\\/[a-f0-9]+)", "i")], template: "<script src=\\"https://gist.github.com/$1.js\\"></script>", ratio: null },',
|
|
75
|
+
' { id: "codepen", label: "CodePen", patterns: [new RegExp("^https?:\\\\/\\\\/codepen\\\\.io\\\\/([^/]+)\\\\/(?:pen|embed|details|full)\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://codepen.io/$1/embed/$2?default-tab=result\\" title=\\"CodePen\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:400px\\"></iframe>", ratio: null },',
|
|
76
|
+
' { id: "codesandbox", label: "CodeSandbox", patterns: [new RegExp("^https?:\\\\/\\\\/codesandbox\\\\.io\\\\/(?:s|embed)\\\\/([A-Za-z0-9_-]+)", "i"), new RegExp("^https?:\\\\/\\\\/codesandbox\\\\.io\\\\/p\\\\/(?:sandbox|devbox)\\\\/([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://codesandbox.io/embed/$1\\" title=\\"CodeSandbox\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
|
|
77
|
+
' { id: "jsfiddle", label: "JSFiddle", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?jsfiddle\\\\.net\\\\/((?:[^/]+\\\\/)?[A-Za-z0-9]+)\\\\/?", "i")], template: "<iframe src=\\"https://jsfiddle.net/$1/embedded/\\" title=\\"JSFiddle\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:400px\\"></iframe>", ratio: null },',
|
|
78
|
+
' { id: "figma", label: "Figma", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?figma\\\\.com\\\\/(?:file|design|proto|board|slides)\\\\/.+", "i")], template: "<iframe src=\\"https://www.figma.com/embed?embed_host=share&url=$E&\\" title=\\"Figma\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
79
|
+
' { id: "canva", label: "Canva", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?canva\\\\.com\\\\/design\\\\/([A-Za-z0-9_-]+)\\\\/([A-Za-z0-9_-]+)\\\\/(?:view|watch)", "i")], template: "<iframe src=\\"https://www.canva.com/design/$1/$2/view?embed\\" title=\\"Canva design\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
80
|
+
' { id: "miro", label: "Miro", patterns: [new RegExp("^https?:\\\\/\\\\/miro\\\\.com\\\\/app\\\\/(?:board|live-embed)\\\\/([A-Za-z0-9_=-]+)", "i")], template: "<iframe src=\\"https://miro.com/app/live-embed/$1/\\" title=\\"Miro board\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
81
|
+
' { id: "google-maps", label: "Google Maps", patterns: [new RegExp("^https?:\\\\/\\\\/(?:www\\\\.)?google\\\\.[a-z.]+\\\\/maps\\\\/embed\\\\?(.+)$", "i")], template: "<iframe src=\\"https://www.google.com/maps/embed?$1\\" title=\\"Google Maps\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
82
|
+
' { id: "google-maps-place", label: "Google Maps", patterns: [new RegExp("^https?:\\\\/\\\\/(?:(?:www\\\\.)?google\\\\.[a-z.]+\\\\/maps|maps\\\\.app\\\\.goo\\\\.gl)\\\\/.+", "i")], template: "<iframe src=\\"https://maps.google.com/maps?q=$E&&output=embed\\" title=\\"Google Maps\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 },',
|
|
83
|
+
' { id: "google-forms", label: "Google Forms", patterns: [new RegExp("^https?:\\\\/\\\\/docs\\\\.google\\\\.com\\\\/forms\\\\/d\\\\/(?:e\\\\/)?([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://docs.google.com/forms/d/e/$1/viewform?embedded=true\\" title=\\"Google Form\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:700px\\"></iframe>", ratio: null },',
|
|
84
|
+
' { id: "google-docs", label: "Google Docs", patterns: [new RegExp("^https?:\\\\/\\\\/docs\\\\.google\\\\.com\\\\/(document|spreadsheets|presentation)\\\\/d\\\\/([A-Za-z0-9_-]+)", "i")], template: "<iframe src=\\"https://docs.google.com/$1/d/$2/preview\\" title=\\"Google Docs\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:600px\\"></iframe>", ratio: null },',
|
|
85
|
+
' { id: "airtable", label: "Airtable", patterns: [new RegExp("^https?:\\\\/\\\\/airtable\\\\.com\\\\/(?:embed\\\\/)?(app[A-Za-z0-9/?=&_-]+)", "i")], template: "<iframe src=\\"https://airtable.com/embed/$1\\" title=\\"Airtable\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:533px\\"></iframe>", ratio: null },',
|
|
86
|
+
' { id: "typeform", label: "Typeform", patterns: [new RegExp("^https?:\\\\/\\\\/(?:[A-Za-z0-9-]+\\\\.)?typeform\\\\.com\\\\/to\\\\/([A-Za-z0-9]+)", "i")], template: "<iframe src=\\"https://form.typeform.com/to/$1\\" title=\\"Typeform\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:500px\\"></iframe>", ratio: null },',
|
|
87
|
+
' { id: "calendly", label: "Calendly", patterns: [new RegExp("^https?:\\\\/\\\\/calendly\\\\.com\\\\/(.+)$", "i")], template: "<iframe src=\\"https://calendly.com/$1\\" title=\\"Calendly\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"display:block;width:100%;border:0;border-radius:inherit;height:700px\\"></iframe>", ratio: null },',
|
|
88
|
+
' { id: "iframe-url", label: "Web page", patterns: [new RegExp("^https:\\\\/\\\\/[^\\\\s\\"\'<>]+$", "i")], template: "<iframe src=\\"$&\\" title=\\"Embedded page\\" loading=\\"lazy\\" frameborder=\\"0\\" referrerpolicy=\\"strict-origin-when-cross-origin\\" allow=\\"accelerometer; autoplay; clipboard-write; encrypted-media; fullscreen; gyroscope; picture-in-picture; web-share\\" allowfullscreen style=\\"position:absolute;top:0;left:0;width:100%;height:100%;border:0;border-radius:inherit\\"></iframe>", ratio: 56.25 }',
|
|
89
|
+
']',
|
|
90
|
+
'',
|
|
91
|
+
'export var EMBED_SANDBOX_FLAGS_STRICT = "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation"',
|
|
92
|
+
'',
|
|
93
|
+
'export var EMBED_SANDBOX_FLAGS_TRUSTED = "allow-scripts allow-popups allow-popups-to-escape-sandbox allow-forms allow-presentation allow-same-origin"',
|
|
94
|
+
'',
|
|
95
|
+
'export var EMBED_HEIGHT_MESSAGE_TYPE = "tq-embed-height"',
|
|
96
|
+
'',
|
|
97
|
+
'export var EMBED_TOKEN_PLACEHOLDER = "__TQ_EMBED_TOKEN__"',
|
|
98
|
+
'',
|
|
99
|
+
'export var EMBED_MIN_HEIGHT = 80',
|
|
100
|
+
'',
|
|
101
|
+
'export var EMBED_MAX_HEIGHT = 6000',
|
|
102
|
+
'',
|
|
103
|
+
'export var EMBED_INITIAL_HEIGHT = 320',
|
|
104
|
+
'',
|
|
105
|
+
'export var EMBED_SANDBOX_DOC_HEAD = "<!doctype html><html><head><meta charset=\\"utf-8\\"><meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1\\"><base target=\\"_blank\\"><style>html,body{margin:0;padding:0;background:transparent}img,iframe,video,blockquote{max-width:100%}</style><script>(function(){var token=\\"__TQ_EMBED_TOKEN__\\";var last=0;function report(){try{var doc=document.documentElement;var body=document.body;var height=Math.max(doc?doc.scrollHeight:0,doc?doc.offsetHeight:0,body?body.scrollHeight:0,body?body.offsetHeight:0);if(!height||height===last){return;}last=height;parent.postMessage({type:\\"tq-embed-height\\",token:token,height:height},\\"*\\");}catch(e){}}function watch(){report();if(typeof ResizeObserver===\\"function\\"&&document.documentElement){new ResizeObserver(report).observe(document.documentElement);}if(typeof MutationObserver===\\"function\\"&&document.body){new MutationObserver(report).observe(document.body,{childList:true,subtree:true,attributes:true});}var delays=[150,400,900,1800,3500];for(var i=0;i<delays.length;i++){setTimeout(report,delays[i]);}}if(document.readyState===\\"loading\\"){document.addEventListener(\\"DOMContentLoaded\\",watch);}else{watch();}window.addEventListener(\\"load\\",report);})();</script></head><body>"',
|
|
106
|
+
'',
|
|
107
|
+
'export var EMBED_SANDBOX_DOC_TAIL = "</body></html>"',
|
|
108
|
+
'',
|
|
109
|
+
'export var embedTokenCounter = 0',
|
|
110
|
+
'',
|
|
111
|
+
'export function isSafeEmbedUrl(url) {',
|
|
112
|
+
" return /^https?:\\/\\/[^\\s\"'<>]+$/i.test((url || '').trim());",
|
|
113
|
+
'}',
|
|
114
|
+
'',
|
|
115
|
+
'export function resolveEmbedProvider(url) {',
|
|
116
|
+
" const trimmed = (url || '').trim();",
|
|
117
|
+
' if (!isSafeEmbedUrl(trimmed)) {',
|
|
118
|
+
' return null;',
|
|
119
|
+
' }',
|
|
120
|
+
' for (const provider of EMBED_PROVIDERS) {',
|
|
121
|
+
' for (const pattern of provider.patterns) {',
|
|
122
|
+
' const match = trimmed.match(pattern);',
|
|
123
|
+
' if (match) {',
|
|
124
|
+
' return { provider, match };',
|
|
125
|
+
' }',
|
|
126
|
+
' }',
|
|
127
|
+
' }',
|
|
128
|
+
' return null;',
|
|
129
|
+
'}',
|
|
130
|
+
'',
|
|
131
|
+
'export function applyEmbedTemplate(template, match, url) {',
|
|
132
|
+
' return template.replace(/\\$(\\$|E?(?:[1-9]|&))/g, (_token, spec) => {',
|
|
133
|
+
' var _a;',
|
|
134
|
+
" if (spec === '$') {",
|
|
135
|
+
" return '$';",
|
|
136
|
+
' }',
|
|
137
|
+
" const encoded = spec.charAt(0) === 'E';",
|
|
138
|
+
' const key = encoded ? spec.slice(1) : spec;',
|
|
139
|
+
" const raw = key === '&' ? url : (_a = match[Number(key)]) !== null && _a !== void 0 ? _a : '';",
|
|
140
|
+
' return encoded ? encodeURIComponent(raw) : raw;',
|
|
141
|
+
' });',
|
|
142
|
+
'}',
|
|
143
|
+
'',
|
|
144
|
+
'export function buildEmbedHtmlFromUrl(url) {',
|
|
145
|
+
' const resolved = resolveEmbedProvider(url);',
|
|
146
|
+
' if (!resolved) {',
|
|
147
|
+
' return null;',
|
|
148
|
+
' }',
|
|
149
|
+
' return {',
|
|
150
|
+
' provider: resolved.provider,',
|
|
151
|
+
' html: applyEmbedTemplate(resolved.provider.template, resolved.match, url.trim()),',
|
|
152
|
+
' };',
|
|
153
|
+
'}',
|
|
154
|
+
'',
|
|
155
|
+
'export function resolveEmbedMode(html) {',
|
|
156
|
+
" const markup = html || '';",
|
|
157
|
+
' const executes = /<script[\\s/>]/i.test(markup) ||',
|
|
158
|
+
' /\\son[a-z]+\\s*=/i.test(markup) ||',
|
|
159
|
+
' /(?:href|src|action|formaction)\\s*=\\s*["\']?\\s*javascript:/i.test(markup);',
|
|
160
|
+
" return executes ? 'sandbox' : 'inline';",
|
|
161
|
+
'}',
|
|
162
|
+
'',
|
|
163
|
+
'export function clampEmbedWidth(width) {',
|
|
164
|
+
' if (!isFinite(width)) {',
|
|
165
|
+
' return DEFAULT_EMBED_WIDTH;',
|
|
166
|
+
' }',
|
|
167
|
+
' return Math.max(10, Math.min(100, Math.round(width)));',
|
|
168
|
+
'}',
|
|
169
|
+
'',
|
|
170
|
+
'export function normalizeEmbedAlign(align) {',
|
|
171
|
+
' return EMBED_ALIGNMENTS.indexOf(align) !== -1',
|
|
172
|
+
' ? align',
|
|
173
|
+
' : DEFAULT_EMBED_ALIGN;',
|
|
174
|
+
'}',
|
|
175
|
+
'',
|
|
176
|
+
'export function escapeEmbedAttribute(value) {',
|
|
177
|
+
" return String(value !== null && value !== void 0 ? value : '')",
|
|
178
|
+
" .replace(/&/g, '&')",
|
|
179
|
+
" .replace(/\"/g, '"')",
|
|
180
|
+
" .replace(/</g, '<')",
|
|
181
|
+
" .replace(/>/g, '>');",
|
|
182
|
+
'}',
|
|
183
|
+
'',
|
|
184
|
+
'export function escapeEmbedText(value) {',
|
|
185
|
+
" return String(value !== null && value !== void 0 ? value : '')",
|
|
186
|
+
" .replace(/&/g, '&')",
|
|
187
|
+
" .replace(/</g, '<')",
|
|
188
|
+
" .replace(/>/g, '>');",
|
|
189
|
+
'}',
|
|
190
|
+
'',
|
|
191
|
+
'export function encodeEmbedCode(code) {',
|
|
192
|
+
' const binary = encodeURIComponent(code).replace(/%([0-9A-F]{2})/gi, (_m, hex) => String.fromCharCode(parseInt(hex, 16)));',
|
|
193
|
+
" if (typeof btoa === 'function') {",
|
|
194
|
+
' return btoa(binary);',
|
|
195
|
+
' }',
|
|
196
|
+
" if (typeof Buffer !== 'undefined') {",
|
|
197
|
+
" return Buffer.from(binary, 'binary').toString('base64');",
|
|
198
|
+
' }',
|
|
199
|
+
" throw new Error('No base64 encoder available');",
|
|
200
|
+
'}',
|
|
201
|
+
'',
|
|
202
|
+
'export function decodeEmbedCode(encoded) {',
|
|
203
|
+
' let binary;',
|
|
204
|
+
" if (typeof atob === 'function') {",
|
|
205
|
+
' binary = atob(encoded);',
|
|
206
|
+
' }',
|
|
207
|
+
" else if (typeof Buffer !== 'undefined') {",
|
|
208
|
+
" binary = Buffer.from(encoded, 'base64').toString('binary');",
|
|
209
|
+
' }',
|
|
210
|
+
' else {',
|
|
211
|
+
" throw new Error('No base64 decoder available');",
|
|
212
|
+
' }',
|
|
213
|
+
" let percent = '';",
|
|
214
|
+
' for (let index = 0; index < binary.length; index += 1) {',
|
|
215
|
+
' percent += `%${`00${binary.charCodeAt(index).toString(16)}`.slice(-2)}`;',
|
|
216
|
+
' }',
|
|
217
|
+
' return decodeURIComponent(percent);',
|
|
218
|
+
'}',
|
|
219
|
+
'',
|
|
220
|
+
'export function createEmbedValue(params) {',
|
|
221
|
+
' var _a, _b, _c;',
|
|
222
|
+
" const code = params.code || '';",
|
|
223
|
+
' return {',
|
|
224
|
+
' provider: params.provider || CUSTOM_EMBED_PROVIDER_ID,',
|
|
225
|
+
" url: params.url || '',",
|
|
226
|
+
' code,',
|
|
227
|
+
' mode: resolveEmbedMode(code),',
|
|
228
|
+
' ratio: (_a = params.ratio) !== null && _a !== void 0 ? _a : null,',
|
|
229
|
+
' width: clampEmbedWidth((_b = params.width) !== null && _b !== void 0 ? _b : DEFAULT_EMBED_WIDTH),',
|
|
230
|
+
' align: normalizeEmbedAlign((_c = params.align) !== null && _c !== void 0 ? _c : DEFAULT_EMBED_ALIGN),',
|
|
231
|
+
" caption: params.caption || '',",
|
|
232
|
+
" sandboxLevel: params.sandboxLevel === 'trusted' ? 'trusted' : DEFAULT_EMBED_SANDBOX_LEVEL,",
|
|
233
|
+
' };',
|
|
234
|
+
'}',
|
|
235
|
+
'',
|
|
236
|
+
'export function embedBlockStyle(value) {',
|
|
237
|
+
' const declarations = [',
|
|
238
|
+
" 'position:relative',",
|
|
239
|
+
' `width:${clampEmbedWidth(value.width)}%`,',
|
|
240
|
+
" 'max-width:100%',",
|
|
241
|
+
" 'margin:16px 0',",
|
|
242
|
+
' ];',
|
|
243
|
+
" if (value.align === 'center') {",
|
|
244
|
+
" declarations.push('margin-left:auto', 'margin-right:auto');",
|
|
245
|
+
' }',
|
|
246
|
+
" else if (value.align === 'float-left') {",
|
|
247
|
+
" declarations.push('float:left', 'margin-right:16px', 'margin-bottom:8px');",
|
|
248
|
+
' }',
|
|
249
|
+
" else if (value.align === 'float-right') {",
|
|
250
|
+
" declarations.push('float:right', 'margin-left:16px', 'margin-bottom:8px');",
|
|
251
|
+
' }',
|
|
252
|
+
" return declarations.join(';');",
|
|
253
|
+
'}',
|
|
254
|
+
'',
|
|
255
|
+
'export function embedFrameStyle(ratio) {',
|
|
256
|
+
' if (ratio === null || !isFinite(ratio) || ratio <= 0) {',
|
|
257
|
+
" return 'position:relative;width:100%';",
|
|
258
|
+
' }',
|
|
259
|
+
' return `position:relative;width:100%;padding-top:${ratio}%`;',
|
|
260
|
+
'}',
|
|
261
|
+
'',
|
|
262
|
+
'export function buildEmbedElementHtml(value) {',
|
|
263
|
+
' const attrs = [',
|
|
264
|
+
' `class="${EMBED_CLASS_NAME}"`,',
|
|
265
|
+
' `${EMBED_ATTR.MARKER}="1"`,',
|
|
266
|
+
' `${EMBED_ATTR.PROVIDER}="${escapeEmbedAttribute(value.provider)}"`,',
|
|
267
|
+
' `${EMBED_ATTR.MODE}="${value.mode}"`,',
|
|
268
|
+
' `${EMBED_ATTR.WIDTH}="${clampEmbedWidth(value.width)}"`,',
|
|
269
|
+
' `${EMBED_ATTR.ALIGN}="${value.align}"`,',
|
|
270
|
+
' `${EMBED_ATTR.SANDBOX}="${value.sandboxLevel}"`,',
|
|
271
|
+
' ];',
|
|
272
|
+
' if (value.url) {',
|
|
273
|
+
' attrs.push(`${EMBED_ATTR.URL}="${escapeEmbedAttribute(value.url)}"`);',
|
|
274
|
+
' }',
|
|
275
|
+
' if (value.ratio !== null) {',
|
|
276
|
+
' attrs.push(`${EMBED_ATTR.RATIO}="${value.ratio}"`);',
|
|
277
|
+
' }',
|
|
278
|
+
' if (value.caption) {',
|
|
279
|
+
' attrs.push(`${EMBED_ATTR.CAPTION}="${escapeEmbedAttribute(value.caption)}"`);',
|
|
280
|
+
' }',
|
|
281
|
+
" if (value.mode === 'sandbox') {",
|
|
282
|
+
' attrs.push(`${EMBED_ATTR.CODE}="${escapeEmbedAttribute(encodeEmbedCode(value.code))}"`);',
|
|
283
|
+
' }',
|
|
284
|
+
' attrs.push(\'contenteditable="false"\');',
|
|
285
|
+
' attrs.push(`style="${embedBlockStyle(value)}"`);',
|
|
286
|
+
' const caption = value.caption',
|
|
287
|
+
' ? `<figcaption class="${EMBED_CAPTION_CLASS_NAME}" style="${EMBED_CAPTION_STYLE}">${escapeEmbedText(value.caption)}</figcaption>`',
|
|
288
|
+
" : '';",
|
|
289
|
+
" return (`<figure ${attrs.join(' ')}>` +",
|
|
290
|
+
' `<div class="${EMBED_FRAME_CLASS_NAME}" style="${embedFrameStyle(value.ratio)}">` +',
|
|
291
|
+
' `${buildEmbedFrameChildren(value)}</div>${caption}</figure>`);',
|
|
292
|
+
'}',
|
|
293
|
+
'',
|
|
294
|
+
'export function buildEmbedFrameChildren(value) {',
|
|
295
|
+
" if (value.mode === 'inline') {",
|
|
296
|
+
' return value.code;',
|
|
297
|
+
' }',
|
|
298
|
+
' if (!value.url) {',
|
|
299
|
+
" return '';",
|
|
300
|
+
' }',
|
|
301
|
+
' return (`<noscript><a href="${escapeEmbedAttribute(value.url)}" rel="noopener noreferrer" ` +',
|
|
302
|
+
' `target="_blank">${escapeEmbedText(value.url)}</a></noscript>`);',
|
|
303
|
+
'}',
|
|
304
|
+
'',
|
|
305
|
+
'export function findEmbedFrame(element) {',
|
|
306
|
+
' return element.querySelector(`.${EMBED_FRAME_CLASS_NAME}`);',
|
|
307
|
+
'}',
|
|
308
|
+
'',
|
|
309
|
+
'export function readEmbedValueFromElement(element) {',
|
|
310
|
+
" const mode = element.getAttribute(EMBED_ATTR.MODE) === 'sandbox' ? 'sandbox' : 'inline';",
|
|
311
|
+
' const frame = findEmbedFrame(element);',
|
|
312
|
+
' const rawRatio = element.getAttribute(EMBED_ATTR.RATIO);',
|
|
313
|
+
' const parsedRatio = rawRatio === null ? NaN : parseFloat(rawRatio);',
|
|
314
|
+
" let code = '';",
|
|
315
|
+
" if (mode === 'sandbox') {",
|
|
316
|
+
' code = readEncodedEmbedCode(element);',
|
|
317
|
+
' }',
|
|
318
|
+
' else if (frame) {',
|
|
319
|
+
' code = frame.innerHTML;',
|
|
320
|
+
' }',
|
|
321
|
+
' return {',
|
|
322
|
+
' provider: element.getAttribute(EMBED_ATTR.PROVIDER) || CUSTOM_EMBED_PROVIDER_ID,',
|
|
323
|
+
" url: element.getAttribute(EMBED_ATTR.URL) || '',",
|
|
324
|
+
' code,',
|
|
325
|
+
' mode,',
|
|
326
|
+
' ratio: isFinite(parsedRatio) ? parsedRatio : null,',
|
|
327
|
+
" width: clampEmbedWidth(parseFloat(element.getAttribute(EMBED_ATTR.WIDTH) || '')),",
|
|
328
|
+
" align: normalizeEmbedAlign(element.getAttribute(EMBED_ATTR.ALIGN) || ''),",
|
|
329
|
+
" caption: element.getAttribute(EMBED_ATTR.CAPTION) || '',",
|
|
330
|
+
" sandboxLevel: element.getAttribute(EMBED_ATTR.SANDBOX) === 'trusted'",
|
|
331
|
+
" ? 'trusted'",
|
|
332
|
+
' : DEFAULT_EMBED_SANDBOX_LEVEL,',
|
|
333
|
+
' };',
|
|
334
|
+
'}',
|
|
335
|
+
'',
|
|
336
|
+
'export function readEncodedEmbedCode(element) {',
|
|
337
|
+
' const encoded = element.getAttribute(EMBED_ATTR.CODE);',
|
|
338
|
+
' if (!encoded) {',
|
|
339
|
+
" return '';",
|
|
340
|
+
' }',
|
|
341
|
+
' try {',
|
|
342
|
+
' return decodeEmbedCode(encoded);',
|
|
343
|
+
' }',
|
|
344
|
+
' catch (_a) {',
|
|
345
|
+
" return '';",
|
|
346
|
+
' }',
|
|
347
|
+
'}',
|
|
348
|
+
'',
|
|
349
|
+
'export function normalizeEmbedsForStorage(root) {',
|
|
350
|
+
' const previews = root.querySelectorAll(`[${EMBED_ATTR.PREVIEW}]`);',
|
|
351
|
+
' for (let index = previews.length - 1; index >= 0; index -= 1) {',
|
|
352
|
+
' const preview = previews[index];',
|
|
353
|
+
' if (preview.parentNode) {',
|
|
354
|
+
' preview.parentNode.removeChild(preview);',
|
|
355
|
+
' }',
|
|
356
|
+
' }',
|
|
357
|
+
' const blocks = root.querySelectorAll(`[${EMBED_ATTR.MARKER}]`);',
|
|
358
|
+
' for (let index = 0; index < blocks.length; index += 1) {',
|
|
359
|
+
' const block = blocks[index];',
|
|
360
|
+
' block.removeAttribute(EMBED_ATTR.ACTIVATED);',
|
|
361
|
+
' const frame = findEmbedFrame(block);',
|
|
362
|
+
' if (!frame) {',
|
|
363
|
+
' continue;',
|
|
364
|
+
' }',
|
|
365
|
+
' const value = readEmbedValueFromElement(block);',
|
|
366
|
+
" if (value.mode !== 'sandbox') {",
|
|
367
|
+
' continue;',
|
|
368
|
+
' }',
|
|
369
|
+
' frame.innerHTML = buildEmbedFrameChildren(value);',
|
|
370
|
+
' }',
|
|
371
|
+
'}',
|
|
372
|
+
'',
|
|
373
|
+
'export function resolveEmbedSandboxFlags(level) {',
|
|
374
|
+
" return level === 'trusted' ? EMBED_SANDBOX_FLAGS_TRUSTED : EMBED_SANDBOX_FLAGS_STRICT;",
|
|
375
|
+
'}',
|
|
376
|
+
'',
|
|
377
|
+
'export function buildEmbedSandboxDocument(code, token) {',
|
|
378
|
+
' return (EMBED_SANDBOX_DOC_HEAD.replace(EMBED_TOKEN_PLACEHOLDER, token) +',
|
|
379
|
+
" (code || '') +",
|
|
380
|
+
' EMBED_SANDBOX_DOC_TAIL);',
|
|
381
|
+
'}',
|
|
382
|
+
'',
|
|
383
|
+
'export function parseEmbedHeightMessage(data) {',
|
|
384
|
+
" if (!data || typeof data !== 'object') {",
|
|
385
|
+
' return null;',
|
|
386
|
+
' }',
|
|
387
|
+
' const message = data;',
|
|
388
|
+
" if (message.type !== EMBED_HEIGHT_MESSAGE_TYPE || typeof message.token !== 'string') {",
|
|
389
|
+
' return null;',
|
|
390
|
+
' }',
|
|
391
|
+
' const height = Number(message.height);',
|
|
392
|
+
' if (!isFinite(height) || height <= 0) {',
|
|
393
|
+
' return null;',
|
|
394
|
+
' }',
|
|
395
|
+
' return {',
|
|
396
|
+
' token: message.token,',
|
|
397
|
+
' height: Math.min(Math.max(Math.round(height), EMBED_MIN_HEIGHT), EMBED_MAX_HEIGHT),',
|
|
398
|
+
' };',
|
|
399
|
+
'}',
|
|
400
|
+
'',
|
|
401
|
+
'export function createEmbedToken() {',
|
|
402
|
+
' embedTokenCounter += 1;',
|
|
403
|
+
' return `tqe-${Date.now().toString(36)}-${embedTokenCounter.toString(36)}-${Math.random()',
|
|
404
|
+
' .toString(36)',
|
|
405
|
+
' .slice(2, 8)}`;',
|
|
406
|
+
'}',
|
|
407
|
+
'',
|
|
408
|
+
].join('\n');
|
|
409
|
+
//# sourceMappingURL=rich-text-embeds-runtime-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rich-text-embeds-runtime-source.js","sourceRoot":"","sources":["../../../src/utils/rich-text-embeds-runtime-source.ts"],"names":[],"mappings":";;;AAAA,sFAAsF;AACtF,8GAA8G;AAC9G,mEAAmE;AACnE,mFAAmF;AACtE,QAAA,2BAA2B,GAAG;IACzC,KAAK;IACL,+EAA+E;IAC/E,gFAAgF;IAChF,IAAI;IACJ,+EAA+E;IAC/E,gFAAgF;IAChF,2EAA2E;IAC3E,6EAA6E;IAC7E,gFAAgF;IAChF,2BAA2B;IAC3B,KAAK;IACL,EAAE;IACF,0CAA0C;IAC1C,EAAE;IACF,sDAAsD;IACtD,EAAE;IACF,0DAA0D;IAC1D,EAAE;IACF,yCAAyC;IACzC,EAAE;IACF,2BAA2B;IAC3B,8BAA8B;IAC9B,yCAAyC;IACzC,+BAA+B;IAC/B,iCAAiC;IACjC,iCAAiC;IACjC,mCAAmC;IACnC,mCAAmC;IACnC,mCAAmC;IACnC,uCAAuC;IACvC,uCAAuC;IACvC,2CAA2C;IAC3C,sCAAsC;IACtC,GAAG;IACH,EAAE;IACF,qEAAqE;IACrE,EAAE;IACF,gDAAgD;IAChD,EAAE;IACF,qDAAqD;IACrD,EAAE;IACF,sCAAsC;IACtC,EAAE;IACF,2CAA2C;IAC3C,EAAE;IACF,mDAAmD;IACnD,EAAE;IACF,2CAA2C;IAC3C,EAAE;IACF,oHAAoH;IACpH,EAAE;IACF,gCAAgC;IAChC,44BAA44B;IAC54B,8oBAA8oB;IAC9oB,0kBAA0kB;IAC1kB,6qBAA6qB;IAC7qB,mnBAAmnB;I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