Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
oEmbed VvvebJs components
givanza9411139dbc1
diff --git a/public/js/libs/oembed.js b/public/js/libs/oembed.jsnew file mode 100644index 0000000..102103a--- /dev/null+++ b/public/js/libs/oembed.js@@ -0,0 +1,330 @@+const oEmbedProviders = [+ {+ regex: /^(https:\/\/(.*).youtube.com\/watch(.*)|https:\/\/(.*).youtube.com\/v\/(.*)|https:\/\/youtu.be\/(.*)|https:\/\/(.*).youtube.com\/playlist?list=(.*))/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /https?:\/\/((m|www)\.)?youtube\.com\/watch.*/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /https?:\/\/((m|www)\.)?youtube\.com\/playlist.*/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /https?:\/\/((m|www)\.)?youtube\.com\/shorts\/*/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /https?:\/\/((m|www)\.)?youtube\.com\/live\/*/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /https?:\/\/youtu\.be\/.*/,+ url: "https://www.youtube.com/oembed"+ },+ {+ regex: /^(https:\/\/vimeo.com\/(.*)|https:\/\/vimeo.com\/album\/(.*)\/video\/(.*)|https:\/\/vimeo.com\/channels\/(.*)\/(.*)|https:\/\/vimeo.com\/groups\/(.*)\/videos\/(.*)|https:\/\/vimeo.com\/ondemand\/(.*)\/(.*)|https:\/\/player.vimeo.com\/video\/(.*))/,+ url: "https://vimeo.com/api/oembed.json"+ },+ {+ regex: /https?:\/\/(.+\.)?vimeo\.com\/.*/,+ url: "https://vimeo.com/api/oembed.json"+ },+ {+ regex: /https?:\/\/(www\.)?dailymotion\.com\/.*/,+ url: "https://www.dailymotion.com/services/oembed"+ },+ {+ regex: /https?:\/\/dai\.ly\/.*/,+ url: "https://www.dailymotion.com/services/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?flickr\.com\/.*/,+ url: "https://www.flickr.com/services/oembed/"+ },+ {+ regex: /https?:\/\/flic\.kr\/.*/,+ url: "https://www.flickr.com/services/oembed/"+ },+ {+ regex: /https?:\/\/(.+\.)?smugmug\.com\/.*/,+ url: "https://api.smugmug.com/services/oembed/"+ },+ {+ regex: /https?:\/\/(www\.)?scribd\.com\/(doc|document)\/.*/,+ url: "https://www.scribd.com/services/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/\w{1,15}\/status(es)?\/.*/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/\w{1,15}$/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/\w{1,15}\/likes$/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/\w{1,15}\/lists\/.*/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/\w{1,15}\/timelines\/.*/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?twitter\.com\/i\/moments\/.*/,+ url: "https://publish.twitter.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?soundcloud\.com\/.*/,+ url: "https://soundcloud.com/oembed"+ },+ {+ regex: /https?:\/\/(.+?\.)?slideshare\.net\/.*/,+ url: "https://www.slideshare.net/api/oembed/2"+ },+ {+ regex: /https?:\/\/(open|play)\.spotify\.com\/.*/,+ url: "https://embed.spotify.com/oembed/"+ },+ {+ regex: /https?:\/\/(.+\.)?imgur\.com\/.*/,+ url: "https://api.imgur.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?issuu\.com\/.+\/docs\/.+/,+ url: "https://issuu.com/oembed_wp"+ },+ {+ regex: /https?:\/\/(www\.)?mixcloud\.com\/.*/,+ url: "https://app.mixcloud.com/oembed/"+ },+ {+ regex: /https?:\/\/(www\.|embed\.)?ted\.com\/talks\/.*/,+ url: "https://www.ted.com/services/v1/oembed.json"+ },+ {+ regex: /https?:\/\/(www\.)?(animoto|video214)\.com\/play\/.*/,+ url: "https://animoto.com/oembeds/create"+ },+ {+ regex: /https?:\/\/(.+)\.tumblr\.com\/.*/,+ url: "https://www.tumblr.com/oembed/1.0"+ },+ {+ regex: /https?:\/\/(www\.)?kickstarter\.com\/projects\/.*/,+ url: "https://www.kickstarter.com/services/oembed"+ },+ {+ regex: /https?:\/\/kck\.st\/.*/,+ url: "https://www.kickstarter.com/services/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?reverbnation\.com\/.*/,+ url: "https://www.reverbnation.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?reddit\.com\/r\/[^\/]+\/comments\/.*/,+ url: "https://www.reddit.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?speakerdeck\.com\/.*/,+ url: "https://speakerdeck.com/oembed.json"+ },+ {+ regex: /https?:\/\/(www\.)?screencast\.com\/.*/,+ url: "https://api.screencast.com/external/oembed"+ },+ {+ regex: /https?:\/\/([a-z0-9-]+\.)?amazon\.(com|com\.mx|com\.br|ca)\/.*/,+ url: "https://read.amazon.com/kp/api/oembed"+ },+ {+ regex: /https?:\/\/([a-z0-9-]+\.)?amazon\.(co\.uk|de|fr|it|es|in|nl|ru)\/.*/,+ url: "https://read.amazon.co.uk/kp/api/oembed"+ },+ {+ regex: /https?:\/\/([a-z0-9-]+\.)?amazon\.(co\.jp|com\.au)\/.*/,+ url: "https://read.amazon.com.au/kp/api/oembed"+ },+ {+ regex: /https?:\/\/([a-z0-9-]+\.)?amazon\.cn\/.*/,+ url: "https://read.amazon.cn/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?a\.co\/.*/,+ url: "https://read.amazon.com/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?amzn\.to\/.*/,+ url: "https://read.amazon.com/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?amzn\.eu\/.*/,+ url: "https://read.amazon.co.uk/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?amzn\.in\/.*/,+ url: "https://read.amazon.in/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?amzn\.asia\/.*/,+ url: "https://read.amazon.com.au/kp/api/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?z\.cn\/.*/,+ url: "https://read.amazon.cn/kp/api/oembed"+ },+ {+ regex: /https?:\/\/www\.someecards\.com\/.+-cards\/.+/,+ url: "https://www.someecards.com/v2/oembed/"+ },+ {+ regex: /https?:\/\/www\.someecards\.com\/usercards\/viewcard\/.+/,+ url: "https://www.someecards.com/v2/oembed/"+ },+ {+ regex: /https?:\/\/some\.ly\/.+/,+ url: "https://www.someecards.com/v2/oembed/"+ },+ {+ regex: /https?:\/\/(www\.)?tiktok\.com\/.*\/video\/.*/,+ url: "https://www.tiktok.com/oembed"+ },+ {+ regex: /https?:\/\/(www\.)?tiktok\.com\/\/.*/,+ url: "https://www.tiktok.com/oembed"+ },+ {+ regex: /https?:\/\/([a-z]{2}|www)\.pinterest\.com(\.(au|mx))?\/.*/,+ url: "https://www.pinterest.com/oembed.json"+ },+ {+ regex: /https?:\/\/(www\.)?wolframcloud\.com\/obj\/.+/,+ url: "https://www.wolframcloud.com/oembed"+ },+ {+ regex: /https?:\/\/((play|www)\.)?anghami\.com\/.*/,+ url: "https://api.anghami.com/rest/v1/oembed.view"+ }+];++const urlTransforms = [+ {+ regex: /youtu\.be\/([\w\-_\?&=.]+)/i,+ url: 'www.youtube.com/embed/$1',+ },+ {+ regex: /youtube\.com(.+)v=([^&]+)(&([a-z0-9&=\-_]+))?/i,+ url: 'www.youtube.com/embed/$2?$4',+ },+ {+ regex: /youtube.com\/embed\/([a-z0-9\?&=\-_]+)/i,+ url: 'www.youtube.com/embed/$1',+ },+ {+ regex: /vimeo\.com\/([0-9]+)\?h=(\w+)/,+ url: 'player.vimeo.com/video/$1?h=$2&title=0&byline=0&portrait=0&color=8dc7dc',+ },+ {+ regex: /vimeo\.com\/(.*)\/([0-9]+)\?h=(\w+)/,+ url: 'player.vimeo.com/video/$2?h=$3&title=0&byline=0',+ },+ {+ regex: /vimeo\.com\/([0-9]+)/,+ url: 'player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc',+ },+ {+ regex: /vimeo\.com\/(.*)\/([0-9]+)/,+ url: 'player.vimeo.com/video/$2?title=0&byline=0',+ },+ {+ regex: /(maps|www)\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/,+ url: '$2.google.com/maps/ms?msid=$3&output=embed"',+ },+ {+ regex: /(maps|www)\.google\.([a-z]{2,3})\/maps\/@(.+)/,+ url: '$1.google.com/maps/embed?center=$3"',+ },+ {+ regex: /dailymotion\.com\/video\/([^_]+)/,+ url: 'www.dailymotion.com/embed/video/$1',+ },+ {+ regex: /dai\.ly\/([^_]+)/,+ url: 'www.dailymotion.com/embed/video/$1',+ }+];++async function getOembed(url, maxwidth = 800, maxheight = 600) {+ let oembedUrl;++ for (const service of oEmbedProviders) {+ if (service.regex.exec(url)) {+ oembedUrl = service.url + `?url=${url}&maxwidth=${maxwidth}&maxheight=${maxheight}&format=json`;+ }+ }++ if (oembedUrl === undefined) {++ const matchTransform = (url, maxwidth, maxheight) => {+ for (const transforms of urlTransforms) {+ let matches = transforms.regex.exec(url);+ if (matches) {+ let newUrl = transforms.url;+ for (let i = 0; i < matches.length; i++) {+ newUrl = newUrl.replace('$' + i, () => matches[i] ? matches[i] : '');+ }+ return `<iframe src="https://${newUrl}" width="${maxwidth}" height="${maxheight}" style="border:0;" loading="lazy" ></iframe>`;+ }+ }+ };++ let transform = matchTransform(url, maxwidth, maxheight);+ if (transform) {+ return {html: transform};+ }++ let message = 'Embed error: URL did not match any provider.';+ displayToast("bg-danger", "Error", message);++ return;+ }++ let remoteResponse;+ //try to fetch directly, if CORS error use proxy+ for (url of [oembedUrl,oEmbedProxyUrl + "&url=" + encodeURIComponent(oembedUrl)]) {++ try {+ remoteResponse = await window.fetch(url);++ if (remoteResponse && remoteResponse.status == 200) {+ break;+ }+ } catch (error) {+ console.log(error);+ }+ }++ if (!remoteResponse || remoteResponse.status !== 200) {+ let message = `Embed error: Could not fetch embed URL.`;+ displayToast("bg-danger", "Error", message);+ }++ const json = await remoteResponse.json();++ if (json.html === undefined) {+ const message = `Eembed error: ${message}`;+ displayToast("bg-danger", "Error", message);+ return;+ }++ //response = { url: url, html: json.html, poster: json.thumbnail_url };+ response = json;++ return response;+}diff --git a/public/js/libs/tinymce-embed.js b/public/js/libs/tinymce-embed.jsnew file mode 100755index 0000000..ffc6598--- /dev/null+++ b/public/js/libs/tinymce-embed.js@@ -0,0 +1,26 @@+$(window).on("vvveb.tinymce.options", function (e, tinyMceOptions) {+ tinyMceOptions.quickbars_insert_toolbar += '| Embed';+ tinyMceOptions.toolbar += '| Embed';++ return tinyMceOptions;+});++$(window).on("vvveb.tinymce.setup", function (e, editor) {++ editor.ui.registry.addButton('Embed', {+ text: "Embed",+ icon: 'browse',+ tooltip: 'Insert oEmbed Url',+ //enabled: true,+ onAction: (_) => {++ const url = prompt('Enter embed URL');++ if (url) {+ getOembed(url).then(response => {+ editor.insertContent(response.html);+ }).catch(error => console.log(error));+ }+ }+ });+});diff --git a/public/js/libs/tinymce-options.js b/public/js/libs/tinymce-options.jsindex bc16bf2..733fd11 100755--- a/public/js/libs/tinymce-options.js+++ b/public/js/libs/tinymce-options.js@@ -98,11 +98,11 @@ var tinyMceOptions = {$(window).trigger("vvveb.tinymce.setup", editor);},- plugins: 'preview importcss searchreplace autolink autosave autoresize save directionality code visualblocks visualchars fullscreen image link template codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help quickbars emoticons table',+ plugins: 'preview importcss searchreplace autolink autosave autoresize save directionality code visualblocks visualchars fullscreen image media link codesample table charmap pagebreak nonbreaking anchor insertdatetime advlist lists wordcount help quickbars emoticons table accordion',//valid_children : '-p[img],h1[img],h2[img],h3[img],h4[img],+body[img],div[img],div[h1],div[h2],div[h3]',//editimage_cors_hosts: ['picsum.photos'],menubar: false,//'file edit view insert format tools table help',- toolbar: 'undo redo | bold italic underline strikethrough | fontfamily fontsize blocks | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | insertfile image media link anchor codesample | fullscreen preview save print| ltr rtl | code template | charmap emoticons table',+ toolbar: 'undo redo | bold italic underline strikethrough | fontfamily fontsize blocks | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | insertfile image media link anchor codesample | fullscreen preview save print| ltr rtl | code | charmap emoticons table accordion',toolbar_sticky: true,//toolbar_sticky_offset: isSmallScreen ? 102 : 108,autosave_ask_before_unload: true,@@ -111,6 +111,7 @@ var tinyMceOptions = {autosave_restore_when_empty: false,autosave_retention: '2m',image_advtab: true,+ /*link_list: [{ title: 'My page 1', value: 'https://www.tiny.cloud' },{ title: 'My page 2', value: 'http://www.moxiecode.com' }@@ -119,9 +120,10 @@ var tinyMceOptions = {{ title: 'My page 1', value: 'https://www.tiny.cloud' },{ title: 'My page 2', value: 'http://www.moxiecode.com' }],+ */image_class_list: [{ title: 'None', value: '' },- { title: 'Some class', value: 'class-name' }+ { title: 'Fluid', value: 'img-fluid' }],importcss_append: true,relative_urls : false,@@ -154,7 +156,7 @@ var tinyMceOptions = {poster: 'https://www.google.com/logos/google.jpg'});}- },+ },/*templates: [{title: 'New Table',description: 'creates a new table',@@ -167,7 +169,7 @@ var tinyMceOptions = {title: 'New list with dates',description: 'New List with dates',content: '<div class="mceTmpl"><span class="cdate">cdate</span><br /><span class="mdate">mdate</span><h2>My List</h2><ul><li></li><li></li></ul></div>'- }],+ }],*/template_cdate_format: '[Date Created (CDATE): %m/%d/%Y : %H:%M:%S]',template_mdate_format: '[Date Modified (MDATE): %m/%d/%Y : %H:%M:%S]',height: 600,@@ -213,7 +215,7 @@ var tinyMceOptions = {textAlign: "left"}}, {- selector: "img,table,video,audio,dl.caption",+ selector: "img,figure,table,video,audio,dl.caption,iframe",classes: "align-left"}],aligncenter: [{@@ -222,7 +224,7 @@ var tinyMceOptions = {textAlign: "center"}}, {- selector: "img,table,video,audio,dl.caption",+ selector: "img,figure,table,video,audio,dl.caption,iframe",classes: "align-center"}],alignright: [{@@ -231,7 +233,7 @@ var tinyMceOptions = {textAlign: "right"}}, {- selector: "img,table,video,audio,dl.caption",+ selector: "img,figure,table,video,audio,dl.caption,iframe",classes: "align-right"}],strikethrough: {@@ -244,7 +246,7 @@ var tinyMceOptions = {//'test': '../tinymce-plugins/test/plugin.js',},branding:false,- media_live_embeds:false,+ media_live_embeds:true,media_filter_html:false,visual_table_class:"table mce-item-table",table_default_attributes: {diff --git a/public/js/vvvebjs/components-embeds.js b/public/js/vvvebjs/components-embeds.jsindex 45b08c2..ec94863 100755--- a/public/js/vvvebjs/components-embeds.js+++ b/public/js/vvvebjs/components-embeds.js@@ -16,569 +16,72 @@ limitations under the License.https://github.com/givanz/VvvebJs*/-Vvveb.ComponentsGroup['Widgets'] = ["widgets/googlemaps", "widgets/video", "widgets/chartjs", "widgets/facebookpage", "widgets/paypal", "widgets/instagram", "widgets/twitter"/*, "widgets/facebookcomments"*/];-Vvveb.Components.extend("_base", "widgets/googlemaps", {- name: "Google Maps",- attributes: ["data-component-maps"],- image: "icons/map.svg",- dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/maps.png">',- html: '<div data-component-maps style="min-height:240px;min-width:240px;position:relative"><iframe frameborder="0" src="https://maps.google.com/maps?&z=1&t=q&output=embed" width="100" height="100" style="width:100%;height:100%;left:0px;pointer-events:none"></iframe></div>',- resizable:true,//show select box resize handlers- resizeMode:"css",--- //url parameters- z:3, //zoom- q:'Paris',//location- t: 'q', //map type q = roadmap, w = satellite-- onChange: function (node, property, value)- {- map_iframe = jQuery('iframe', node);-- this[property.key] = value;-- mapurl = 'https://maps.google.com/maps?&q=' + this.q + '&z=' + this.z + '&t=' + this.t + '&output=embed';-- map_iframe.attr("src",mapurl);-- return node;- },+Vvveb.ComponentsGroup['Embeds'] = ["embeds/embed"];- properties: [{- name: "Address",- key: "q",- inputtype: TextInput- },- {- name: "Map type",- key: "t",- inputtype: SelectInput,- data:{- options: [{- value: "q",- text: "Roadmap"- }, {- value: "w",- text: "Satellite"- }]- },- },- {- name: "Zoom",- key: "z",- inputtype: RangeInput,- data:{- max: 20, //max zoom level- min:1,- step:1- },- }]-});--Vvveb.Components.extend("_base", "widgets/video", {- name: "Video",- attributes: ["data-component-video"],- image: "icons/video.svg",- dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/video.svg" width="100" height="100">', //use image for drag and swap with iframe on drop for drag performance- html: '<div data-component-video style="min-height:320px;min-width:240px;position:relative"><iframe frameborder="0" src="https://www.youtube.com/embed/M7lc1UVf-VE" style="width:100%;height:100%;"></iframe></div>',--- //url parameters set with onChange- t:'y',//video type- video_id:'',//video id- url: '', //html5 video src- autoplay: false,- controls: false,- loop: false,-- init: function (node)- {- iframe = jQuery('iframe', node);- video = jQuery('video', node);-- $("#right-panel [data-key=url]").hide();-- //check if html5- if (video.length)- {- this.url = video.src;- } else if (iframe.length) //vimeo or youtube- {- src = iframe.attr("src");+Vvveb.Components.extend("_base", "embeds/embed", {+ name: "Embed",+ attributes: ["data-component-oembed"],+ image: "icons/code.svg",+ //dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/maps.png">',+ html: `<div data-component-oembed data-url="">+ <div class="alert alert-light m-5" role="alert">+ <img width="64" src="${Vvveb.baseUrl}icons/code.svg">+ <h6>Enter url to embed</h6>+ </div></div>`,- if (src && src.indexOf("youtube"))//youtube- {- this.video_id = src.match(/youtube.com\/embed\/([^$\?]*)/)[1];- } else if (src && src.indexOf("vimeo"))//youtube- {- this.video_id = src.match(/vimeo.com\/video\/([^$\?]*)/)[1];- }- }-- $("#right-panel input[name=video_id]").val(this.video_id);- $("#right-panel input[name=url]").val(this.url);- },-- onChange: function (node, property, value)- {- this[property.key] = value;- //if (property.key == "t")- {- switch (this.t)- {- case 'y':- $("#right-panel [data-key=video_id]").show();- $("#right-panel [data-key=url]").hide();- newnode = $(`<div data-component-video>- <iframe- src="https://www.youtube.com/embed/${this.video_id}?&autoplay=${this.autoplay}&controls=${this.controls}&loop=${this.loop}" allowfullscreen="true"- style="height: 100%; width: 100%;" frameborder="0">- </iframe>- </div>`);- break;- case 'v':- $("#right-panel [data-key=video_id]").show();- $("#right-panel [data-key=url]").hide();- newnode = $(`<div data-component-video>- <iframe- src="https://player.vimeo.com/video/${this.video_id}?&autoplay=${this.autoplay}&controls=${this.controls}&loop=${this.loop}" allowfullscreen="true"- style="height: 100%; width: 100%;" frameborder="0">- </iframe>- </div>`);- break;- case 'h':- $("#right-panel [data-key=video_id]").hide();- $("#right-panel [data-key=url]").show();- newnode = $('<div data-component-video><video src="' + this.url + '" ' + (this.autoplay?' autoplay ':'') + (this.controls?' controls ':'') + (this.loop?' loop ':'') + ' style="height: 100%; width: 100%;"></video></div>');- break;- }-- node.replaceWith(newnode);- return newnode;- }- return node;- },-properties: [{- name: "Provider",- key: "t",- inputtype: SelectInput,- data:{- options: [{- text: "Youtube",- value: "y"- }, {- text: "Vimeo",- value: "v"- },{- text: "HTML5",- value: "h"- }]- },- },- {- name: "Video id",- key: "video_id",- inputtype: TextInput,- },{name: "Url",key: "url",- inputtype: TextInput- },{- name: "Autoplay",- key: "autoplay",- inputtype: ToggleInput,- data: {- on: "true",- off: "false"- },- inline:true,- col:4,- },{- name: "Controls",- key: "controls",- inputtype: ToggleInput,- data: {- on: "true",- off: "false"- },- inline:true,- col:4,- },{- name: "Loop",- key: "loop",- inputtype: ToggleInput,- data: {- on: "true",- off: "false"- },- inline:true,- col:4,- }]-});----Vvveb.Components.extend("_base", "widgets/facebookcomments", {- name: "Facebook Comments",- attributes: ["data-component-facebookcomments"],- image: "icons/facebook.svg",- dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/facebook.svg">',- html: '<div data-component-facebookcomments><script>(function(d, s, id) {\- var js, fjs = d.getElementsByTagName(s)[0];\- if (d.getElementById(id)) return;\- js = d.createElement(s); js.id = id;\- js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.6&appId=";\- fjs.parentNode.insertBefore(js, fjs);\- }(document, \'script\', \'facebook-jssdk\'));</script>\- <div class="fb-comments" \- data-href="' + window.location.href + '" \- data-numposts="5" \- data-colorscheme="light" \- data-mobile="" \- data-order-by="social" \- data-width="100%" \- ></div></div>',- properties: [{- name: "Href",- key: "business",- htmlAttr: "data-href",- child:".fb-comments",- inputtype: TextInput- },{- name: "Item name",- key: "item_name",- htmlAttr: "data-numposts",- child:".fb-comments",- inputtype: TextInput- },{- name: "Color scheme",- key: "colorscheme",- htmlAttr: "data-colorscheme",- child:".fb-comments",- inputtype: TextInput- },{- name: "Order by",- key: "order-by",- htmlAttr: "data-order-by",- child:".fb-comments",- inputtype: TextInput- },{- name: "Currency code",+ htmlAttr: "data-url",+ inputtype: TextInput,+ onChange: function(node, value) {+ let element = node[0];++ element.innerHTML = `<div class="alert alert-light d-flex justify-content-center">+ <div class="spinner-border m-5" role="status">+ <span class="visually-hidden">Loading...</span>+ </div>+ </div>`;++ getOembed(value).then(response => {+ element.innerHTML = response.html;+ let containerW = node.width();+ let iframe = $("iframe", element);+ let ratio = containerW / iframe.width();++ iframe.attr("width",(i, width) => width * ratio);+ iframe.attr("height", (i, height) => height * ratio);++ }).catch(error => console.log(error));++ return node;+ },+ }, {+ name: "Width",key: "width",- htmlAttr: "data-width",- child:".fb-comments",- inputtype: TextInput+ child:"iframe",+ htmlAttr: "width",+ inputtype: CssUnitInput+ }, {+ name: "Height",+ key: "height",+ child:"iframe",+ htmlAttr: "height",+ inputtype: CssUnitInput}]});-Vvveb.Components.extend("_base", "widgets/instagram", {- name: "Instagram",- attributes: ["data-component-instagram"],- image: "icons/instagram.svg",- drophtml: '<img src="' + Vvveb.baseUrl + 'icons/instagram.png">',- html: '<div align=center data-component-instagram>\- <blockquote class="instagram-media" data-instgrm-captioned data-instgrm-permalink="https://www.instagram.com/p/tsxp1hhQTG/" data-instgrm-version="8" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);"><div style="padding:8px;"> <div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding:50% 0; text-align:center; width:100%;"> <div style=" background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5/P8/t9FuRVCRmU73JWlzosgSIIZURCjo/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;"></div></div> <p style=" margin:8px 0 0 0; padding:0 4px;"> <a href="https://www.instagram.com/p/tsxp1hhQTG/" style=" color:#000; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none; word-wrap:break-word;" target="_blank">Text</a></p> <p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;">A post shared by <a href="https://www.instagram.com/instagram/" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px;" target="_blank"> Instagram</a> (@instagram) on <time style=" font-family:Arial,sans-serif; font-size:14px; line-height:17px;" datetime="-">-</time></p></div></blockquote>\- <script async defer src="//www.instagram.com/embed.js"></script>\- </div>',- properties: [{- name: "Widget id",- key: "instgrm-permalink",- htmlAttr: "data-instgrm-permalink",- child: ".instagram-media",- inputtype: TextInput- }],-});--Vvveb.Components.extend("_base", "widgets/twitter", {- name: "Twitter",- attributes: ["data-component-twitter"],- image: "icons/twitter.svg",- dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/twitter.svg">',- html: '<div data-component-twitter><a class="twitter-timeline" data-dnt="true" data-chrome="nofooter noborders noscrollbar noheader transparent" href="https://twitter.com/twitterapi" href="https://twitter.com/twitterapi" data-widget-id="243046062967885824" ></a>\- <script>window.twttr = (function(d, s, id) {\- var js, fjs = d.getElementsByTagName(s)[0],\- t = window.twttr || {};\- if (d.getElementById(id)) return t;\- js = d.createElement(s);\- js.id = id;\- js.src = "https://platform.twitter.com/widgets.js";\- fjs.parentNode.insertBefore(js, fjs);\- t._e = [];\- t.ready = function(f) {\- t._e.push(f);\- };\- return t;\- }(document, "script", "twitter-wjs"));</script></div>',- properties: [{- name: "Widget id",- key: "widget-id",- htmlAttr: "data-widget-id",- child: " > a, > iframe",- inputtype: TextInput- }],-});--Vvveb.Components.extend("_base", "widgets/paypal", {- name: "Paypal",- attributes: ["data-component-paypal"],- image: "icons/paypal.svg",- html: '<form action="https://www.paypal.com/cgi-bin/webscr" method="post" data-component-paypal>\-\- <!-- Identify your business so that you can collect the payments. -->\- <input type="hidden" name="business"\- value="[email protected]">\-\- <!-- Specify a Donate button. -->\- <input type="hidden" name="cmd" value="_donations">\-\- <!-- Specify details about the contribution -->\- <input type="hidden" name="item_name" value="VvvebJs">\- <input type="hidden" name="item_number" value="Support">\- <input type="hidden" name="currency_code" value="USD">\-\- <!-- Display the payment button. -->\- <input type="image" name="submit"\- src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif"\- alt="Donate">\- <img alt="" width="1" height="1"\- src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" >\-\- </form>',- properties: [{- name: "Email",- key: "business",- htmlAttr: "value",- child:"input[name='business']",- inputtype: TextInput- },{- name: "Item name",- key: "item_name",- htmlAttr: "value",- child:"input[name='item_name']",- inputtype: TextInput- },{- name: "Item number",- key: "item_number",- htmlAttr: "value",- child:"input[name='item_number']",- inputtype: TextInput- },{- name: "Currency code",- key: "currency_code",- htmlAttr: "value",- child:"input[name='currency_code']",- inputtype: TextInput- }],-});--Vvveb.Components.extend("_base", "widgets/facebookpage", {- name: "Facebook Page Plugin",- attributes: ["data-component-facebookpage"],- image: "icons/facebook.svg",- dropHtml: '<img src="' + Vvveb.baseUrl + 'icons/facebook.png">',- html: '<div data-component-facebookpage><div class="fb-page" data-href="https://www.facebook.com/facebook" data-appId="100526183620976" data-tabs="timeline" data-small-header="true" data-adapt-container-width="true" data-hide-cover="false" data-show-facepile="true"><blockquote cite="https://www.facebook.com/facebook" class="fb-xfbml-parse-ignore"><a href="https://www.facebook.com/facebook">Facebook</a></blockquote></div>\- <div id="fb-root"></div>\- <script>(function(d, s, id) {\- var appId = document.getElementsByClassName("fb-page")[0].dataset.appid;\- var js, fjs = d.getElementsByTagName(s)[0];\- js.nonce = "5YzD1JaS";\- js.crossorigin = "anonymous";\- js = d.createElement(s); js.id = id;\- js.src = \'https://connect.facebook.net/en_EN/sdk.js#xfbml=1&version=v3.0&appId=\' + appId + \'&autoLogAppEvents=1\';\- fjs.parentNode.insertBefore(js, fjs);\- }(document, \'script\', \'facebook-jssdk\'));</script></div>',-- properties: [{- name: "Small header",- key: "small-header",- htmlAttr: "data-small-header",- child:".fb-page",- inputtype: TextInput- },{- name: "Adapt container width",- key: "adapt-container-width",- htmlAttr: "data-adapt-container-width",- child:".fb-page",- inputtype: TextInput- },{- name: "Hide cover",- key: "hide-cover",- htmlAttr: "data-hide-cover",- child:".fb-page",- inputtype: TextInput- },{- name: "Show facepile",- key: "show-facepile",- htmlAttr: "data-show-facepile",- child:".fb-page",- inputtype: TextInput- },{- name: "App Id",- key: "appid",- htmlAttr: "data-appId",- child:".fb-page",- inputtype: TextInput- }],- onChange: function(node, input, value, component) {- //console.log(component.html);- //console.log(this.html);-- var newElement = $(this.html);- newElement.find(".fb-page").attr(input.htmlAttr, value);-- console.log(node.parent());- console.log(node.parent().html());--- $("[data-fbcssmodules]", Vvveb.Builder.frameHead).remove();- $("[data-fbcssmodules]", Vvveb.Builder.frameBody).remove();- $("script[src^='https://connect.facebook.net']", Vvveb.Builder.frameHead).remove();--- node.parent().html(newElement.html());-- console.log(newElement);--- console.log(newElement.html());-- return newElement;- }-});--Vvveb.Components.extend("_base", "widgets/chartjs", {- name: "Chart.js",- attributes: ["data-component-chartjs"],- image: "icons/chart.svg",- dragHtml: '<img src="' + Vvveb.baseUrl + 'icons/chart.svg">',- html: '<div data-component-chartjs class="chartjs" data-chart=\'{\- "type": "line",\- "data": {\- "labels": ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],\- "datasets": [{\- "data": [12, 19, 3, 5, 2, 3],\- "fill": false,\- "borderColor":"rgba(255, 99, 132, 0.2)"\- }, {\- "fill": false,\- "data": [3, 15, 7, 4, 19, 12],\- "borderColor": "rgba(54, 162, 235, 0.2)"\- }]\- }}\' style="min-height:240px;min-width:240px;width:100%;height:100%;position:relative">\- <canvas></canvas>\- </div>',- chartjs: null,- ctx: null,- node: null,-- config: {/*- type: 'line',- data: {- labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],- datasets: [{- data: [12, 19, 3, 5, 2, 3],- fill: false,- borderColor:'rgba(255, 99, 132, 0.2)',- }, {- fill: false,- data: [3, 15, 7, 4, 19, 12],- borderColor: 'rgba(54, 162, 235, 0.2)',- }]- },*/- },-- dragStart: function (node)- {- //check if chartjs is included and if not add it when drag starts to allow the script to load- body = Vvveb.Builder.frameBody;-- if ($("#chartjs-script", body).length == 0)- {- $(body).append('<script id="chartjs-script" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>');- $(body).append('<script>\- $(document).ready(function() {\- $(".chartjs").each(function () {\- ctx = $("canvas", this).get(0).getContext("2d");\- config = JSON.parse(this.dataset.chart);\- chartjs = new Chart(ctx, config);\- });\- \});\- </script>');- }-- return node;- },--- drawChart: function ()- {- if (this.chartjs != null) this.chartjs.destroy();- this.node.dataset.chart = JSON.stringify(this.config);-- config = Object.assign({}, this.config);//avoid passing by reference to avoid chartjs to fill the object- this.chartjs = new Chart(this.ctx, config);- },-- init: function (node)- {- this.node = node;- this.ctx = $("canvas", node).get(0).getContext("2d");- this.config = JSON.parse(node.dataset.chart);- this.drawChart();-- return node;- },--- beforeInit: function (node)- {- return node;- },-- properties: [- {- name: "Type",- key: "type",- inputtype: SelectInput,- data:{- options: [{- text: "Line",- value: "line"- }, {- text: "Bar",- value: "bar"- }, {- text: "Pie",- value: "pie"- }, {- text: "Doughnut",- value: "doughnut"- }, {- text: "Polar Area",- value: "polarArea"- }, {- text: "Bubble",- value: "bubble"- }, {- text: "Scatter",- value: "scatter"- },{- text: "Radar",- value: "radar"- }]- },- init: function(node) {- return JSON.parse(node.dataset.chart).type;- },- onChange: function(node, value, input, component) {- component.config.type = value;- component.drawChart();-- return node;- }- }]-});+for (const provider of ["youtube", "vimeo", "dailymotion", "flickr", "smugmug", "scribd", "twitter", "soundcloud", "slideshare", "spotify", "imgur", "issuu", "mixcloud", "ted", "animoto", "tumblr", "kickstarter", "reverbnation", "reddit", "speakerdeck", "screencast", "amazon", "someecards", "tiktok","pinterest", "wolfram", "anghami"]) {+ Vvveb.Components.add("embeds/" + provider, {+ name: ucFirst(provider),+ image: "icons/code.svg",+ html: `<div data-component-oembed data-url="">+ <div class="alert alert-light m-5" role="alert">+ <img width="64" src="${Vvveb.baseUrl}icons/code.svg">+ <h6>Enter ${provider} url to embed</h6>+ </div></div>`,+ });+ Vvveb.ComponentsGroup['Embeds'].push("embeds/" + provider);+}