oont-contents/plugins/woocommerce/assets/client/admin/wp-admin-scripts/product-tour.js
2025-04-06 08:34:48 +02:00

2 lines
No EOL
9.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! For license information please see product-tour.js.LICENSE.txt */
(()=>{"use strict";var e={93359:(e,t,o)=>{var r=o(99196),c=Symbol.for("react.element"),n=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,d={key:!0,ref:!0,__self:!0,__source:!0};function a(e,t,o){var r,n={},a=null,u=null;for(r in void 0!==o&&(a=""+o),void 0!==t.key&&(a=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,r)&&!d.hasOwnProperty(r)&&(n[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===n[r]&&(n[r]=t[r]);return{$$typeof:c,type:e,key:a,ref:u,props:n,_owner:s.current}}t.Fragment=n,t.jsx=a,t.jsxs=a},81514:(e,t,o)=>{e.exports=o(93359)},99196:e=>{e.exports=window.React}},t={};function o(r){var c=t[r];if(void 0!==c)return c.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,o),n.exports}o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};(()=>{o.r(r);const e=window.wp.element,t=window.wp.hooks,c=window.wp.i18n,n=window.wc.components,i=window.wc.tracks,s=({iframeSelector:t,isActive:o})=>((0,e.useEffect)((()=>{if(!o)return;const e=(({iframeSelector:e,childSelector:t,className:o})=>{const r=document.querySelector(e),c=r?.contentDocument||r?.contentWindow&&r?.contentWindow.document;if(c){const e=()=>r?.classList.add(o),n=()=>r?.classList.remove(o),i=c.querySelector(t);return i?.addEventListener("focus",e),i?.addEventListener("blur",n),()=>{i?.removeEventListener("focus",e),i?.removeEventListener("blur",n)}}return()=>({})})({iframeSelector:`${t}`,childSelector:"#tinymce",className:"focus-within"});return()=>{e()}}),[o,t]),{style:o?`\n\t\t\t\t${t}.focus-within {\n\t\t\t\t\tborder: 1.5px solid #007CBA;\n\t\t\t\t}\n\t\t\t\t`:null}),d=({editorWrapSelector:t})=>{const o=(0,e.useRef)(document.querySelector(t));o||console.warn(`Editor Wrap ${t} not found`);const[r,c]=(0,e.useState)(o.current&&o.current.classList.contains("html-active")?"html":"tmce");return(0,e.useEffect)((()=>{const e=e=>{e.target&&c(e.target.classList.contains("switch-html")?"html":"tmce")},o=document.querySelector(`${t} .switch-tmce`);o?.addEventListener("click",e);const r=document.querySelector(`${t} .switch-html`);return r?.addEventListener("click",e),()=>{o?.removeEventListener("click",e),r?.removeEventListener("click",e)}}),[t]),{activeEditor:r,isTmce:"tmce"===r,isHtml:"html"===r}},a=e=>document.querySelector(e).value,u=e=>{const t=document.querySelector(e),o=t?.contentWindow?.document.querySelector("#tinymce");return o?.innerHTML||""},p=e=>document.querySelector(e)?.value||"",l=e=>e?u("#content_ifr"):p("#wp-content-editor-container > .wp-editor-area"),m=e=>e?u("#excerpt_ifr"):p("#wp-excerpt-editor-container > .wp-editor-area");var w=o(81514);const h=()=>{const[o,r]=(0,e.useState)(!1),{setIsLoaded:u,hasUpdatedInfo:p}=(()=>{const{isTmce:t}=d({editorWrapSelector:"#wp-content-wrap"}),{isTmce:o}=d({editorWrapSelector:"#wp-excerpt-wrap"}),[r,c]=(0,e.useState)({}),[n,i]=(0,e.useState)(!1),s=(0,e.useCallback)((()=>({"product-name":a("#title"),"product-description":l(t),"product-data":a("#_regular_price"),"product-short-description":m(o),"product-image":document.querySelector("#set-post-thumbnail img")?.src||"","product-tags":Array.from(document.querySelectorAll("#product_tag li")).map((e=>e.lastChild.textContent)).join(","),"product-categories":Array.from(document.querySelectorAll("#product_cat-all #product_catchecklist input")).map((e=>e.checked)).join(",")})),[t,o]),u=(0,e.useCallback)((e=>{const t=s();return r[e]!==t[e]&&""!==t[e]}),[s,r]);return(0,e.useEffect)((()=>{n&&c(s())}),[c,n,s]),{setIsLoaded:i,hasUpdatedInfo:u}})(),{isTmce:h}=d({editorWrapSelector:"#wp-content-wrap"}),{isTmce:f}=d({editorWrapSelector:"#wp-excerpt-wrap"}),{style:_}=s({isActive:o&&h,iframeSelector:"#content_ifr"}),{style:y}=s({isActive:o&&f,iframeSelector:"#excerpt_ifr"}),g=(({isExcerptEditorTmceActive:e,isContentEditorTmceActive:o,closeHandler:r,onNextStepHandler:n})=>{const i=new URLSearchParams(window.location.search),s=[{referenceElements:{desktop:"#title"},focusElement:{desktop:"#title"},meta:{name:"product-name",heading:(0,c.__)("Product name","woocommerce"),descriptions:{desktop:(0,c.__)("Start typing your new product name here. This will be what your customers will see in your store.","woocommerce")}}},{referenceElements:{desktop:"#postdivrich"},focusElement:{iframe:o?"#content_ifr":void 0,desktop:o?"#tinymce":"#wp-content-editor-container > .wp-editor-area"},meta:{name:"product-description",heading:(0,c.__)("Add your product description","woocommerce"),descriptions:{desktop:(0,c.__)("Add your full product description here. Describe your product in detail.","woocommerce")}}},{referenceElements:{desktop:"#woocommerce-product-data"},focusElement:{desktop:"#_regular_price"},meta:{name:"product-data",heading:(0,c.__)("Add your product data","woocommerce"),descriptions:{desktop:(0,c.__)("Use the tabs to switch between sections and insert product details. Start by adding your product price.","woocommerce")}}},{referenceElements:{desktop:"#postexcerpt"},focusElement:{iframe:e?"#excerpt_ifr":void 0,desktop:e?"#tinymce":"#wp-excerpt-editor-container > .wp-editor-area"},meta:{name:"product-short-description",heading:(0,c.__)("Add your short product description","woocommerce"),descriptions:{desktop:(0,c.__)("Type a quick summary for your product here. This will appear on the product page right under the product name.","woocommerce")}}},{referenceElements:{desktop:"#postimagediv"},focusElement:{desktop:"#set-post-thumbnail"},meta:{name:"product-image",heading:(0,c.__)("Add your product image","woocommerce"),descriptions:{desktop:(0,c.__)("Upload an image to your product here. Ideally a JPEG or PNG about 600 px wide or bigger. This image will be shown in your stores catalog.","woocommerce")}}},{referenceElements:{desktop:"#tagsdiv-product_tag"},focusElement:{desktop:"#new-tag-product_tag"},meta:{name:"product-tags",heading:(0,c.__)("Add your product tags","woocommerce"),descriptions:{desktop:(0,c.__)("Add your product tags here. Tags are a method of labeling your products to make them easier for customers to find. For example, if you sell clothing, and you have a lot of cat prints, you could make a tag for “cat.”","woocommerce")}}},{referenceElements:{desktop:"#product_catdiv"},meta:{name:"product-categories",heading:(0,c.__)("Add your product categories","woocommerce"),descriptions:{desktop:(0,c.__)("Add your product categories here. Assign categories to your products to make them easier to browse through and find in your store.","woocommerce")}}},{referenceElements:{desktop:"#submitdiv"},focusElement:{desktop:"#submitdiv"},meta:{name:"publish",heading:(0,c.__)("Publish your product 🎉","woocommerce"),descriptions:{desktop:(0,c.__)("Good work! Now you can publish your product to your store by hitting the “Publish” button or keep editing it.","woocommerce")},primaryButton:{text:(0,c.__)("Keep editing","woocommerce")}}}],d=(0,t.applyFilters)("experimental_woocommerce_admin_product_tour_steps",s,i.get("tutorial_type"));if(!Array.isArray(d))throw new Error("Tour guide steps must be an array.");return{placement:"bottom-start",options:{effects:{spotlight:{interactivity:{enabled:!0,rootElementSelector:"#wpwrap"}},arrowIndicator:!0,autoScroll:{behavior:"auto",block:"center"},liveResize:{mutation:!0,resize:!0,rootElementSelector:"#wpwrap"}},popperModifiers:[{name:"arrow",options:{padding:({popper:e})=>({right:e.width-34})}}],callbacks:{onNextStep:n}},steps:d,closeHandler:r}})({isContentEditorTmceActive:h,isExcerptEditorTmceActive:f,closeHandler:(e,t)=>{r(!1),e.length-1===t?(0,i.recordEvent)("walkthrough_product_completed"):(0,i.recordEvent)("walkthrough_product_dismissed",{step_name:e[t].meta.name})},onNextStepHandler:e=>{const t=g.steps[e-1].meta.name;(0,i.recordEvent)("walkthrough_product_step_completed",{step_name:t,added_info:p(t)?"yes":"no"})}});return(0,e.useEffect)((()=>{var e;if(e=e=>{e.preventDefault(),r(!0),(0,i.recordEvent)("walkthrough_product_enable_button_click")},window.document.querySelector(".wp-heading-inline + .page-title-action")?.addEventListener("click",e),"true"===new URLSearchParams(window.location.search).get("tutorial")&&g.steps?.length>0){const e=((e,t,o)=>{const c=document.querySelector(e);let n=c?.getBoundingClientRect().top;const s=setInterval((()=>{const e=c?.getBoundingClientRect().top;n===e&&(r(!0),(0,i.recordEvent)("walkthrough_product_view",{spotlight:"yes",product_template:"physical"}),u(!0),clearInterval(s)),n=e}),500);return s})(g.steps[0].referenceElements?.desktop||"");return()=>clearInterval(e)}}),[]),(t=>{const o=(0,e.useRef)((()=>{}));(0,e.useEffect)((()=>(t?o.current=(e=>{const t=window.document.querySelector("#publish");return t&&t.addEventListener("click",e),function(){t?.removeEventListener("click",e)}})((()=>{(0,i.recordEvent)("walkthrough_product_completed")})):(o.current(),o.current=()=>{}),function(){o.current()})),[t])})(o),o?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)("style",{children:[_,y,".wp-editor-area:focus {\n\t\t\t\t\t\tborder: 1.5px solid #007CBA;\n\t\t\t\t\t}"]}),(0,w.jsx)(n.TourKit,{config:g})]}):null},f=document.createElement("div");f.setAttribute("id","product-tour-root"),(0,e.createRoot)(document.body.appendChild(f)).render((0,w.jsx)(h,{}))})(),(window.wc=window.wc||{}).productTour=r})();