PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.5.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.5.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / Modules / Gutenberg / editor / index.js

index.js in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.5.0, at Modules/Gutenberg/editor/index.js

1 lines 15.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (()=>{"use strict";var e,t,o,n,s,a={114(e,t,o){o.d(t,{A:()=>s});const n=window.fcomEditorI18n||{};function s(e){return n[e]||e}},144(e,t,o){o.a(e,async(e,t)=>{try{var n=o(279),s=o(656),a=o(427),i=o(87),r=o(143),c=o(619),d=o(997),l=o(114),m=o(445),u=o(730),p=o(823),h=o(790);const f=()=>{const[e,t]=(0,i.useState)(window.fcomMetaSettings||null);(0,i.useEffect)(()=>{const e=e=>{e.detail&&t({...e.detail})};return window.addEventListener("fcomMetaSettingsReady",e),()=>window.removeEventListener("fcomMetaSettingsReady",e)},[]);const[o,n]=(0,i.useState)(!!e&&"yes"===e.enable_media),r=(0,i.useRef)(e?e.enable_media:"no");(0,i.useEffect)(()=>{e&&e.enable_media!==r.current&&(r.current=e.enable_media,"yes"===e.enable_media&&n(!0))},[e]);const c=(e,o)=>{const n={...window.fcomMetaSettings,[e]:o};window.fcomMetaSettings=n,t({...n}),window.parent.postMessage({action:"META_UPDATED",content:n},"*")};return(0,h.jsxs)(h.Fragment,{children:[(0,h.jsx)(s.PluginPostStatusInfo,{children:e&&(0,h.jsxs)("div",{className:"fcom_feature_checkboxes",style:{width:"100%"},children:[(0,h.jsx)(a.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,l.A)("Enable Video Embed"),checked:"yes"===e.enable_media,onChange:e=>c("enable_media",e?"yes":"no")}),(0,h.jsx)(a.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,l.A)("Enable Comments"),checked:"yes"===e.enable_comments,onChange:e=>c("enable_comments",e?"yes":"no")}),(0,h.jsx)(a.CheckboxControl,{__nextHasNoMarginBottom:!0,label:(0,l.A)("Free Preview Lesson"),help:(0,l.A)("If enabled, public users can view this lesson without enrolling the course."),checked:"yes"===e.free_preview_lesson,onChange:e=>c("free_preview_lesson",e?"yes":"no")})]})}),(0,h.jsx)(s.PluginDocumentSettingPanel,{name:"fcom-media-embed",title:(0,l.A)("Media Embed"),className:e&&"yes"===e.enable_media?"":"fcom-panel-hidden",isOpen:o,onToggle:()=>n(!o),children:e&&"yes"===e.enable_media&&(0,h.jsx)(u.A,{media:e.media,videoLength:e.video_length,onUpdate:(e,t)=>c(e,t)})}),(0,h.jsx)(s.PluginDocumentSettingPanel,{name:"fcom-documents",title:(0,l.A)("Documents & Files"),className:e?"":"fcom-panel-hidden",initialOpen:!1,children:e&&(0,h.jsx)(p.A,{})}),(0,h.jsx)(s.PluginDocumentSettingPanel,{name:"fcom-smartcodes",title:(0,l.A)("Smartcodes"),initialOpen:!1,children:(0,h.jsxs)("div",{className:"fcom_lesson_info_codes",children:[(0,h.jsx)("p",{children:(0,l.A)("You may use following smartcode in your lesson:")}),(0,h.jsxs)("ul",{children:[(0,h.jsxs)("li",{children:[(0,h.jsx)("b",{children:(0,l.A)("User's Name:")})," ",(0,h.jsx)("span",{children:"{{user.display_name|fallback}}"})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)("b",{children:(0,l.A)("User's Email:")})," ",(0,h.jsx)("span",{children:"{{user.user_email|fallback}}"})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)("b",{children:(0,l.A)("User's photo HTML:")})," ",(0,h.jsx)("span",{children:"{{user.photo_html.50px}}"})]}),(0,h.jsxs)("li",{children:[(0,h.jsx)("b",{children:(0,l.A)("User's Profile Link:")})," ",(0,h.jsx)("span",{children:"##user.profile_link##"})]})]})]})})]})};(0,n.registerPlugin)("fcom-document-settings",{render:f});let w=!1;const x=()=>(w||((0,r.select)("core/edit-post").isFeatureActive("welcomeGuide")&&(0,r.dispatch)("core/edit-post").toggleFeature("welcomeGuide"),(0,r.select)("core/edit-post").isFeatureActive("fullscreenMode")||(0,r.dispatch)("core/edit-post").toggleFeature("fullscreenMode"),"text"===(0,r.select)("core/edit-post").getEditorMode()&&(0,r.dispatch)("core/edit-post").switchEditorMode("visual"),(0,r.dispatch)("core/editor").lockPostSaving(),(0,r.dispatch)("core/editor").lockPostAutosaving(),w=!0),null);async function _(){await new Promise(e=>{const t=(0,r.subscribe)(()=>{((0,r.select)("core/editor").isCleanNewPost()||(0,r.select)("core/block-editor").getBlockCount()>0)&&(t(),e())})});const e=document.querySelector('[name="editor-canvas"]');return new Promise(t=>{e?e.loading?e.onload=()=>{t(e)}:t(e):t(null)})}(0,n.registerPlugin)("fluent-com-disable-gutenberg-features",{render:x}),(0,c.addFilter)("editor.DocumentBar","fluentcom-custom-document-bar",()=>null),(0,c.addFilter)("editor.Autocomplete.completers","fluent_com/add_autocmplete",function(e,t){return e=e.filter(e=>"users"!==e.name),[...e,m.A]}),window.addEventListener("beforeunload",function(e){e.stopImmediatePropagation()}),await _(),console.log("editor iframe is now ready");let v=!1;window.addEventListener("message",e=>{if("SYNC_META"===e.data?.type)return window.fcomMetaSettings=e.data.data,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:e.data.data})),void window.dispatchEvent(new CustomEvent("fcomDocumentsUpdated"));if("UPDATE_EDITOR"!==e.data?.type)return;const{content:t,title:o,featured_image_id:n,metaSettings:s}=e.data.data;console.log("UPDATE_EDITOR",s,e.data.data),s?(window.fcomMetaSettings=s,window.dispatchEvent(new CustomEvent("fcomMetaSettingsReady",{detail:s}))):window.fcomMetaSettings=null,t&&(0,r.dispatch)("core/block-editor").resetBlocks((0,d.parse)(t));let a=null;o&&(a={title:o}),n&&(a?a.featured_media=n:a={featured_media:n}),a&&(0,r.dispatch)("core/editor").editPost(a),setTimeout(()=>{v=!0},1e3)}),window._wpLoadBlockEditor.then(()=>{window.parent.postMessage({content:"ping",action:"EDITOR_READY"},"*");let e="",t="",o=null;(0,r.subscribe)(()=>{if(!v)return;const n=(0,r.select)("core/editor").getEditedPostAttribute("title");n!=t&&(t=n,window.parent.postMessage({content:n,action:"TITLE_UPDATED"},"*"));const s=(0,r.select)("core/editor").getEditedPostAttribute("featured_media");o!=s&&(o=s,window.parent.postMessage({content:s,action:"FEATURED_MEDIA_UPDATED"},"*"));const a=(0,r.select)("core/block-editor").getBlocks(),i=(0,d.serialize)(a);e!=i&&(e=i,window.parent.postMessage({content:i,action:"EDITOR_UPDATED"},"*"))})}),t()}catch(g){t(g)}},1)},823(e,t,o){o.d(t,{A:()=>r});var n=o(427),s=o(87),a=o(114),i=o(790);const r=()=>{const[e,t]=(0,s.useState)(window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)?window.fcomMetaSettings.document_lists:[]);return(0,s.useEffect)(()=>{const e=e=>{e.detail&&Array.isArray(e.detail.document_lists)&&t([...e.detail.document_lists])};window.addEventListener("fcomMetaSettingsReady",e);const o=()=>{window.fcomMetaSettings&&Array.isArray(window.fcomMetaSettings.document_lists)&&t([...window.fcomMetaSettings.document_lists])};return window.addEventListener("fcomDocumentsUpdated",o),()=>{window.removeEventListener("fcomMetaSettingsReady",e),window.removeEventListener("fcomDocumentsUpdated",o)}},[]),(0,i.jsxs)("div",{className:"fcom-documents-panel",children:[e.length>0?(0,i.jsx)("ul",{className:"fcom-documents-list",children:e.map(e=>{return(0,i.jsxs)("li",{className:"fcom-document-item",children:[(0,i.jsx)("span",{className:"fcom-document-icon",children:(t=e.type,t?t.includes("pdf")?"📄":t.includes("image")?"🖼️":t.includes("video")?"🎥":t.includes("audio")?"🎵":t.includes("zip")||t.includes("rar")||t.includes("archive")?"🗜️":"📄":"📄")}),(0,i.jsx)("span",{className:"fcom-document-title",children:e.title}),e.url&&(0,i.jsx)("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"fcom-document-view",title:(0,a.A)("View"),children:(0,i.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"16",height:"16",fill:"currentColor",children:(0,i.jsx)("path",{d:"M19.5 14.5v3c0 .8-.7 1.5-1.5 1.5H6c-.8 0-1.5-.7-1.5-1.5v-3H6v3h12v-3h1.5zM12 4.5C7.3 4.5 3.4 7.6 2 12c1.4 4.4 5.3 7.5 10 7.5s8.6-3.1 10-7.5c-1.4-4.4-5.3-7.5-10-7.5zm0 12.5c-2.8 0-5-2.2-5-5s2.2-5 5-5 5 2.2 5 5-2.2 5-5 5zm0-8c-1.7 0-3 1.3-3 3s1.3 3 3 3 3-1.3 3-3-1.3-3-3-3z"})})})]},e.id);var t})}):(0,i.jsx)("p",{className:"fcom-documents-empty",children:(0,a.A)("No documents attached yet.")}),(0,i.jsx)(n.Button,{variant:"secondary",onClick:()=>{window.parent.postMessage({action:"MANAGE_DOCUMENTS",content:null},"*")},size:"compact",className:"fcom-documents-manage-btn",children:(0,a.A)("Manage Documents & Files")})]})}},730(e,t,o){o.d(t,{A:()=>l});var n=o(427),s=o(87);const a=window.wp.apiFetch;var i=o.n(a),r=o(114),c=o(790);const d={type:"oembed",url:"",inner_html:"",content_type:"video",html:"",provider:"",title:"",author_name:"",image:""},l=({media:e,videoLength:t,onUpdate:o})=>{const a=e&&"object"==typeof e?e:d,[l,m]=(0,s.useState)(a.html?{...a}:null),[u,p]=(0,s.useState)(!1),[h,f]=(0,s.useState)("oembed"),[w,x]=(0,s.useState)(""),[_,v]=(0,s.useState)(""),[g,b]=(0,s.useState)(!1),[j,y]=(0,s.useState)(""),A=parseInt(t)||0,[E,M]=(0,s.useState)(Math.floor(A/60)),[N,S]=(0,s.useState)(A%60),k=(e,t)=>{const n=Math.max(0,parseInt(e)||0),s=Math.min(59,Math.max(0,parseInt(t)||0));M(n),S(s),o("video_length",60*n+s)},C=e=>{o("media",{...e})},P=()=>{if(l){const e="iframe_html"===l.type?"iframe_html":"oembed";f(e),x("oembed"===e&&l.url||""),v("iframe_html"===e&&l.html||"")}else f("oembed"),x(""),v("");y(""),p(!0)},D=()=>{p(!1),y("")},L=e=>{f(e),x(""),v(""),y("")},T=()=>{w&&(b(!0),y(""),i()({path:`/fluent-community/v2/feeds/oembed?url=${encodeURIComponent(w)}`}).then(e=>{const t=e.oembed,o={type:t.type||"oembed",url:w,inner_html:"",content_type:"video",html:t.html,provider:t.provider||"",title:t.title||"",author_name:t.author_name||"",image:t.image||""};m(o),C(o),D()}).catch(()=>{y((0,r.A)("Failed to fetch embed. Please check the URL."))}).finally(()=>{b(!1)}))};return(0,c.jsxs)("div",{className:"fcom-media-embedder",children:[l?(0,c.jsxs)("div",{className:"fcom-media-preview",children:["iframe_html"===l.type?(0,c.jsx)("div",{className:"fcom-media-iframe-preview",dangerouslySetInnerHTML:{__html:l.html},style:{width:"100%"}}):(0,c.jsxs)(c.Fragment,{children:[l.image&&(0,c.jsx)("img",{src:l.image,alt:l.title||(0,r.A)("Video thumbnail"),style:{width:"100%",borderRadius:"4px",display:"block"}}),l.title&&(0,c.jsx)("p",{className:"fcom-media-preview__title",children:l.title}),l.provider&&(0,c.jsxs)("p",{className:"fcom-media-preview__meta",children:[l.provider,l.author_name?`${l.author_name}`:""]}),!l.image&&!l.title&&(0,c.jsx)("p",{className:"fcom-media-preview__meta",children:(0,r.A)("Media embedded successfully")})]}),(0,c.jsxs)("div",{className:"fcom-media-preview__actions",children:[(0,c.jsx)(n.Button,{variant:"secondary",size:"compact",onClick:P,children:(0,r.A)("Edit media")}),(0,c.jsx)(n.Button,{variant:"tertiary",size:"compact",isDestructive:!0,onClick:()=>{m(null),C({...d})},children:(0,r.A)("Remove")})]})]}):(0,c.jsx)("div",{className:"fcom-media-empty",children:(0,c.jsx)(n.Button,{variant:"secondary",size:"compact",onClick:P,className:"fcom-media-add-btn",children:(0,r.A)("+ Add Media")})}),u&&(0,c.jsx)(n.Modal,{title:l?(0,r.A)("Edit Media"):(0,r.A)("Add Media"),onRequestClose:D,className:"fcom-media-modal",size:"medium",children:(0,c.jsxs)("div",{className:"fcom-media-modal__body",children:[(0,c.jsxs)(n.ButtonGroup,{className:"fcom-media-mode-toggle",children:[(0,c.jsx)(n.Button,{variant:"oembed"===h?"primary":"secondary",onClick:()=>L("oembed"),size:"compact",children:(0,r.A)("Oembed URL")}),(0,c.jsx)(n.Button,{variant:"iframe_html"===h?"primary":"secondary",onClick:()=>L("iframe_html"),size:"compact",children:(0,r.A)("Custom HTML")})]}),"iframe_html"===h?(0,c.jsxs)("div",{className:"fcom-media-field",children:[(0,c.jsx)(n.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,r.A)("Custom HTML Code"),value:_,onChange:v,placeholder:(0,r.A)("Paste an iframe code"),rows:5}),j&&(0,c.jsx)("p",{className:"fcom-media-error",children:j}),(0,c.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,c.jsx)(n.Button,{variant:"tertiary",onClick:D,children:(0,r.A)("Cancel")}),(0,c.jsx)(n.Button,{variant:"primary",onClick:()=>{const e={...d,type:"iframe_html",html:_,content_type:"video"};m(e),C(e),D()},disabled:!_,children:(0,r.A)("Embed")})]})]}):(0,c.jsxs)("div",{className:"fcom-media-field",children:[(0,c.jsx)("label",{className:"fcom-media-url-label",children:(0,r.A)("Video URL")}),(0,c.jsx)("div",{className:"fcom-url-input-row",children:(0,c.jsx)("input",{type:"url",className:"components-text-control__input",value:w,onChange:e=>x(e.target.value),placeholder:(0,r.A)("Paste a URL to embed"),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),T())},autoFocus:!0})}),(0,c.jsx)("p",{className:"fcom-media-help",children:(0,r.A)("Supports Vimeo, YouTube, Wistia and more")}),j&&(0,c.jsx)("p",{className:"fcom-media-error",children:j}),(0,c.jsxs)("div",{className:"fcom-media-modal__footer",children:[(0,c.jsx)(n.Button,{variant:"tertiary",onClick:D,children:(0,r.A)("Cancel")}),(0,c.jsx)(n.Button,{variant:"primary",onClick:T,disabled:!w||g,isBusy:g,children:g?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n.Spinner,{}),(0,r.A)("Embedding…")]}):(0,r.A)("Embed")})]})]})]})}),(0,c.jsxs)("div",{className:"fcom-duration-section",children:[(0,c.jsx)("p",{className:"fcom-duration-label",children:(0,r.A)("Lesson Duration")}),(0,c.jsxs)("div",{className:"fcom-duration-row",children:[(0,c.jsxs)("div",{className:"fcom-duration-field",children:[(0,c.jsx)("input",{type:"number",className:"components-text-control__input",value:E,onChange:e=>k(e.target.value,N),min:0,max:1444}),(0,c.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Minutes")})]}),(0,c.jsx)("span",{className:"fcom-duration-separator",children:":"}),(0,c.jsxs)("div",{className:"fcom-duration-field",children:[(0,c.jsx)("input",{type:"number",className:"components-text-control__input",value:N,onChange:e=>k(E,e.target.value),min:0,max:59}),(0,c.jsx)("span",{className:"fcom-duration-unit",children:(0,r.A)("Seconds")})]})]})]})]})}},445(e,t,o){o.d(t,{A:()=>a});var n=o(114),s=o(790);const a={name:"fcom_prefixed",className:"editor-autocompleters__fcom",triggerPrefix:"@",options:e=>[{code:"{{user.display_name|fallback}}",title:(0,n.A)("User's Name"),prefix:"user"},{code:"{{user.user_email|fallback}}",title:(0,n.A)("User's Email"),prefix:"user"},{code:"{{user.photo_html.50px}}",title:(0,n.A)("User's photo HTML"),prefix:"user"},{code:"##user.profile_link##",title:(0,n.A)("Profile Link"),prefix:"user"}],isDebounced:!0,getOptionKeywords:e=>[e.title,e.code],getOptionLabel:e=>[(0,s.jsx)("span",{className:"editor-autocompleters__user-name",children:e.title},"name")],getOptionCompletion:e=>e.code}},790(e){e.exports=window.ReactJSXRuntime},997(e){e.exports=window.wp.blocks},427(e){e.exports=window.wp.components},143(e){e.exports=window.wp.data},656(e){e.exports=window.wp.editor},87(e){e.exports=window.wp.element},619(e){e.exports=window.wp.hooks},279(e){e.exports=window.wp.plugins}},i={};function r(e){var t=i[e];if(void 0!==t)return t.exports;var o=i[e]={exports:{}};return a[e](o,o.exports,r),o.exports}e="function"==typeof Symbol,t=e?Symbol("webpack queues"):"__webpack_queues__",o=e?Symbol("webpack exports"):"__webpack_exports__",n=e?Symbol("webpack error"):"__webpack_error__",s=e=>{e&&e.d<1&&(e.d=1,e.forEach(e=>e.r--),e.forEach(e=>e.r--?e.r++:e()))},r.a=(e,a,i)=>{var r;i&&((r=[]).d=-1);var c,d,l,m=new Set,u=e.exports,p=new Promise((e,t)=>{l=t,d=e});p[o]=u,p[t]=e=>(r&&e(r),m.forEach(e),p.catch(e=>{})),e.exports=p,a(e=>{var a;c=(e=>e.map(e=>{if(null!==e&&"object"==typeof e){if(e[t])return e;if(e.then){var a=[];a.d=0,e.then(e=>{i[o]=e,s(a)},e=>{i[n]=e,s(a)});var i={};return i[t]=e=>e(a),i}}var r={};return r[t]=e=>{},r[o]=e,r}))(e);var i=()=>c.map(e=>{if(e[n])throw e[n];return e[o]}),d=new Promise(e=>{(a=()=>e(i)).r=0;var o=e=>e!==r&&!m.has(e)&&(m.add(e),e&&!e.d&&(a.r++,e.push(a)));c.map(e=>e[t](o))});return a.r?d:i()},e=>(e?l(p[n]=e):d(u),s(r))),r&&r.d<0&&(r.d=0)},r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var o in t)r.o(t,o)&&!r.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r(144)})();