@bikdotai/bik-component-library 0.0.806-beta.18 → 0.0.806-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js +1 -1
  2. package/dist/cjs/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
  3. package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js +1 -1
  4. package/dist/cjs/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
  5. package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js +1 -1
  6. package/dist/cjs/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
  7. package/dist/cjs/components/feature-announcements/utils/animationHelpers.js.map +1 -1
  8. package/dist/cjs/editor/BikEditor.utils.js +1 -1
  9. package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
  10. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  11. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  12. package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js +1 -1
  13. package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -1
  14. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  15. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  16. package/dist/cjs/editor/serializers/toWhatsAppText.js +1 -1
  17. package/dist/cjs/editor/serializers/toWhatsAppText.js.map +1 -1
  18. package/dist/cjs/src/components/feature-announcements/types/props.types.d.ts +3 -3
  19. package/dist/cjs/src/components/feature-announcements/utils/animationHelpers.d.ts +1 -1
  20. package/dist/cjs/src/editor/BikEditor.utils.d.ts +7 -10
  21. package/dist/cjs/src/editor/serializers/toWhatsAppText.d.ts +2 -2
  22. package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js +1 -1
  23. package/dist/esm/components/feature-announcements/FeatureAnnouncementProvider.js.map +1 -1
  24. package/dist/esm/components/feature-announcements/MajorUpdatePopup.js +1 -1
  25. package/dist/esm/components/feature-announcements/MajorUpdatePopup.js.map +1 -1
  26. package/dist/esm/components/feature-announcements/MinorUpdatePopup.js +1 -1
  27. package/dist/esm/components/feature-announcements/MinorUpdatePopup.js.map +1 -1
  28. package/dist/esm/components/feature-announcements/utils/animationHelpers.js.map +1 -1
  29. package/dist/esm/editor/BikEditor.utils.js +1 -1
  30. package/dist/esm/editor/BikEditor.utils.js.map +1 -1
  31. package/dist/esm/editor/extensions/mention/MentionExtension.js +1 -1
  32. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  33. package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js +1 -1
  34. package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -1
  35. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  36. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  37. package/dist/esm/editor/serializers/toWhatsAppText.js +1 -1
  38. package/dist/esm/editor/serializers/toWhatsAppText.js.map +1 -1
  39. package/dist/esm/src/components/feature-announcements/types/props.types.d.ts +3 -3
  40. package/dist/esm/src/components/feature-announcements/utils/animationHelpers.d.ts +1 -1
  41. package/dist/esm/src/editor/BikEditor.utils.d.ts +7 -10
  42. package/dist/esm/src/editor/serializers/toWhatsAppText.d.ts +2 -2
  43. package/package.json +2 -2
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),n=require("./constants/index.js");require("../../constants/Theme.js"),require("./constants/animations.js");var s=require("./styles/minorPopup.styles.js"),i=require("./utils/htmlHelpers.js"),o=require("./utils/animationHelpers.js"),a=require("./utils/elementHelpers.js");exports.default=l=>{let{feature:c,currentIndex:u,totalFeatures:d,onSkip:f,onExplore:y,onPrevious:g,onNext:j,setIsClosing:v}=l;var p,x;const[T,h]=r.useState(!1),[m,b]=r.useState(!1),[E,O]=r.useState(""),_=r.useRef(null);r.useEffect((()=>{T&&b(!0)}),[T]);const q=s.getMinorPopupStyles(m,E);return t.jsxs("div",Object.assign({ref:_,style:q.container},{children:[t.jsx("div",Object.assign({style:q.imageContainer},{children:c.displayImage?t.jsx("div",Object.assign({style:q.imageWrapper},{children:t.jsx("img",{src:c.displayImage,alt:c.title,style:q.image,onError:e=>{c.image&&(e.target.src=c.image)}})})):t.jsx("div",Object.assign({style:q.imagePlaceholder},{children:n.TEXT.FEATURE_PREVIEW_PLACEHOLDER}))})),t.jsxs("div",Object.assign({style:q.contentContainer},{children:[t.jsxs("div",{children:[t.jsx("h3",Object.assign({style:q.title},{children:c.title})),t.jsx("div",{style:q.content,dangerouslySetInnerHTML:{__html:i.decodeHTMLEntities(c.content||c.body||"")}})]}),t.jsxs("div",Object.assign({style:q.actionsContainer},{children:[(null===(p=c.secondaryButton)||void 0===p?void 0:p.text)&&t.jsx("span",Object.assign({onClick:()=>{var t,r;const n=null===(t=c.secondaryButton)||void 0===t?void 0:t.action,s=f;let i=null;if("Play Video"===n)y("Play Video");else if("Open link"===n){const e=null===(r=c.secondaryButton)||void 0===r?void 0:r.redirectionUrl;if(e){e.startsWith("http")?window.open(e,"_blank","noopener,noreferrer"):i=e}}if(o.hideJoyrideArrow(_.current),_.current&&c.featureTag){const e=a.findFeatureTagElement(c.featureTag);if(e){const t=o.calculateCloseTransform(_.current,e);O(t)}else O("scale(0)")}else O("scale(0)");null==v||v(!0),h(!0),o.executeAfterAnimation((()=>e.__awaiter(void 0,void 0,void 0,(function*(){yield s(),i&&(window.location.href=i)}))))},style:q.understoodText},{children:c.secondaryButton.text})),t.jsx("button",Object.assign({onClick:()=>{var e,t;const r=null===(e=c.primaryButton)||void 0===e?void 0:e.action;if("Open link"===r){const e=(null===(t=c.primaryButton)||void 0===t?void 0:t.redirectionUrl)||c.redirectUrl;if(e){e.startsWith("http")&&window.open(e,"_blank","noopener,noreferrer")}}if(y(r),o.hideJoyrideArrow(_.current),_.current&&c.featureTag){const e=c.featureTag.startsWith("#")||c.featureTag.startsWith(".")||c.featureTag.startsWith("[")?c.featureTag:`#${c.featureTag}`,t=document.querySelector(e);if(t){const e=o.calculateCloseTransform(_.current,t);O(e)}else O("scale(0)")}else O("scale(0)");null==v||v(!0),h(!0)},style:q.exploreButton},{children:(null===(x=c.primaryButton)||void 0===x?void 0:x.text)||c.buttonText||n.TEXT.DEFAULT_BUTTON_TEXT}))]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("./constants/index.js");require("../../constants/Theme.js"),require("./constants/animations.js");var n=require("./styles/minorPopup.styles.js"),s=require("./utils/htmlHelpers.js"),i=require("./utils/animationHelpers.js"),o=require("./utils/elementHelpers.js");exports.default=l=>{let{feature:a,currentIndex:c,totalFeatures:u,onSkip:d,onExplore:f,onPrevious:p,onNext:y,setIsClosing:g}=l;var j,v;const[h,x]=t.useState(!1),[T,m]=t.useState(!1),[b,E]=t.useState(""),O=t.useRef(null);t.useEffect((()=>{h&&m(!0)}),[h]);const q=n.getMinorPopupStyles(T,b);return e.jsxs("div",Object.assign({ref:O,style:q.container},{children:[e.jsx("div",Object.assign({style:q.imageContainer},{children:a.displayImage?e.jsx("div",Object.assign({style:q.imageWrapper},{children:e.jsx("img",{src:a.displayImage,alt:a.title,style:q.image,onError:e=>{a.image&&(e.target.src=a.image)}})})):e.jsx("div",Object.assign({style:q.imagePlaceholder},{children:r.TEXT.FEATURE_PREVIEW_PLACEHOLDER}))})),e.jsxs("div",Object.assign({style:q.contentContainer},{children:[e.jsxs("div",{children:[e.jsx("h3",Object.assign({style:q.title},{children:a.title})),e.jsx("div",{style:q.content,dangerouslySetInnerHTML:{__html:s.decodeHTMLEntities(a.content||a.body||"")}})]}),e.jsxs("div",Object.assign({style:q.actionsContainer},{children:[(null===(j=a.secondaryButton)||void 0===j?void 0:j.text)&&e.jsx("span",Object.assign({onClick:()=>{var e,t,r;const n=null===(e=a.secondaryButton)||void 0===e?void 0:e.action,s=d;if("Play Video"===n)f();else if("Open link"===n){const e=null===(t=a.secondaryButton)||void 0===t?void 0:t.redirectionUrl;if(e){e.startsWith("http")?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}}else"Close popup"!==n&&""!==n||null===(r=a.secondaryButton)||void 0===r||r.action;if(i.hideJoyrideArrow(O.current),O.current&&a.featureTag){const e=o.findFeatureTagElement(a.featureTag);if(e){const t=i.calculateCloseTransform(O.current,e);E(t)}else E("scale(0)")}else E("scale(0)");null==g||g(!0),x(!0),i.executeAfterAnimation(s)},style:q.understoodText},{children:a.secondaryButton.text})),e.jsx("button",Object.assign({onClick:()=>{var e,t;const r=null===(e=a.primaryButton)||void 0===e?void 0:e.action;if("Play Video"===r)f();else if("Open link"===r){const e=(null===(t=a.primaryButton)||void 0===t?void 0:t.redirectionUrl)||a.redirectUrl;if(e){e.startsWith("http")?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}}else f();if(i.hideJoyrideArrow(O.current),O.current&&a.featureTag){const e=a.featureTag.startsWith("#")||a.featureTag.startsWith(".")||a.featureTag.startsWith("[")?a.featureTag:`#${a.featureTag}`,t=document.querySelector(e);if(t){const e=i.calculateCloseTransform(O.current,t);E(e)}else E("scale(0)")}else E("scale(0)");null==g||g(!0),x(!0)},style:q.exploreButton},{children:(null===(v=a.primaryButton)||void 0===v?void 0:v.text)||a.buttonText||r.TEXT.DEFAULT_BUTTON_TEXT}))]}))]}))]}))};
2
2
  //# sourceMappingURL=MinorUpdatePopup.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MinorUpdatePopup.js","sources":["../../../../src/components/feature-announcements/MinorUpdatePopup.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { TEXT } from './constants';\nimport { getMinorPopupStyles } from './styles';\nimport { MinorUpdatePopupProps } from './types';\nimport {\n\tcalculateCloseTransform,\n\tdecodeHTMLEntities,\n\texecuteAfterAnimation,\n\tfindFeatureTagElement,\n\thideJoyrideArrow,\n} from './utils';\n\nconst MinorUpdatePopup: React.FC<MinorUpdatePopupProps> = ({\n\tfeature,\n\tcurrentIndex,\n\ttotalFeatures,\n\tonSkip,\n\tonExplore,\n\tonPrevious,\n\tonNext,\n\tsetIsClosing: setIsClosingParent,\n}) => {\n\tconst [isClosing, setIsClosing] = useState(false);\n\tconst [startAnimation, setStartAnimation] = useState(false);\n\tconst [transform, setTransform] = useState('');\n\tconst popupRef = useRef<HTMLDivElement>(null);\n\n\t// Hide Joyride arrow when closing starts, then trigger animation immediately\n\tuseEffect(() => {\n\t\tif (isClosing) {\n\t\t\t// Start the shrink animation immediately\n\t\t\tsetStartAnimation(true);\n\t\t}\n\t}, [isClosing]);\n\n\tconst handleExplore = (): void => {\n\t\tconst action = feature.primaryButton?.action;\n\n\t\tif (action === 'Open link') {\n\t\t\t// For external links open in new tab immediately.\n\t\t\t// For internal links the provider will navigate AFTER markFeatureAsViewed\n\t\t\t// completes, so we do NOT call window.location.href here.\n\t\t\tconst url = feature.primaryButton?.redirectionUrl || feature.redirectUrl;\n\t\t\tif (url) {\n\t\t\t\tconst isExternal = url.startsWith('http');\n\t\t\t\tif (isExternal) {\n\t\t\t\t\twindow.open(url, '_blank', 'noopener,noreferrer');\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t// Pass the triggered action so the provider knows what to do\n\t\tonExplore(action);\n\n\t\t// Run closing animation in background\n\t\thideJoyrideArrow(popupRef.current);\n\t\tif (popupRef.current && feature.featureTag) {\n\t\t\tconst targetSelector =\n\t\t\t\tfeature.featureTag.startsWith('#') ||\n\t\t\t\tfeature.featureTag.startsWith('.') ||\n\t\t\t\tfeature.featureTag.startsWith('[')\n\t\t\t\t\t? feature.featureTag\n\t\t\t\t\t: `#${feature.featureTag}`;\n\t\t\tconst targetElement = document.querySelector(targetSelector);\n\t\t\tif (targetElement) {\n\t\t\t\tconst transformValue = calculateCloseTransform(\n\t\t\t\t\tpopupRef.current,\n\t\t\t\t\ttargetElement,\n\t\t\t\t);\n\t\t\t\tsetTransform(transformValue);\n\t\t\t} else {\n\t\t\t\tsetTransform('scale(0)');\n\t\t\t}\n\t\t} else {\n\t\t\tsetTransform('scale(0)');\n\t\t}\n\t\tsetIsClosingParent?.(true);\n\t\tsetIsClosing(true);\n\t};\n\n\tconst handleSecondaryAction = (): void => {\n\t\tconst action = feature.secondaryButton?.action;\n\t\tconst closeCallback = onSkip;\n\t\tlet internalUrl: string | null = null;\n\n\t\t// Handle based on action type\n\t\tif (action === 'Play Video') {\n\t\t\t// Pass 'Play Video' explicitly so provider opens video, not redirects\n\t\t\tonExplore('Play Video');\n\t\t} else if (action === 'Open link') {\n\t\t\t// For external links open in new tab immediately.\n\t\t\t// For internal links, navigate AFTER closeCallback fires (which marks as viewed)\n\t\t\tconst url = feature.secondaryButton?.redirectionUrl;\n\t\t\tif (url) {\n\t\t\t\tconst isExternal = url.startsWith('http');\n\t\t\t\tif (isExternal) {\n\t\t\t\t\twindow.open(url, '_blank', 'noopener,noreferrer');\n\t\t\t\t} else {\n\t\t\t\t\tinternalUrl = url;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (action === 'Close popup' || action === '') {\n\t\t\t// Just close the popup\n\t\t}\n\n\t\t// Always close popup after secondary action\n\t\thideJoyrideArrow(popupRef.current);\n\t\tif (popupRef.current && feature.featureTag) {\n\t\t\tconst targetElement = findFeatureTagElement(feature.featureTag);\n\t\t\tif (targetElement) {\n\t\t\t\tconst transformValue = calculateCloseTransform(\n\t\t\t\t\tpopupRef.current,\n\t\t\t\t\ttargetElement,\n\t\t\t\t);\n\t\t\t\tsetTransform(transformValue);\n\t\t\t} else {\n\t\t\t\tsetTransform('scale(0)');\n\t\t\t}\n\t\t} else {\n\t\t\tsetTransform('scale(0)');\n\t\t}\n\t\tsetIsClosingParent?.(true);\n\t\tsetIsClosing(true);\n\t\texecuteAfterAnimation(async () => {\n\t\t\tawait closeCallback();\n\t\t\t// For internal links: navigate after closeCallback awaits markFeatureAsViewed\n\t\t\tif (internalUrl) {\n\t\t\t\twindow.location.href = internalUrl;\n\t\t\t}\n\t\t});\n\t};\n\n\tconst styles = getMinorPopupStyles(startAnimation, transform);\n\n\treturn (\n\t\t<div ref={popupRef} style={styles.container}>\n\t\t\t{/* Image section */}\n\t\t\t<div style={styles.imageContainer}>\n\t\t\t\t{feature.displayImage ? (\n\t\t\t\t\t<div style={styles.imageWrapper}>\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tsrc={feature.displayImage}\n\t\t\t\t\t\t\talt={feature.title}\n\t\t\t\t\t\t\tstyle={styles.image}\n\t\t\t\t\t\t\tonError={(e) => {\n\t\t\t\t\t\t\t\tif (feature.image) {\n\t\t\t\t\t\t\t\t\t(e.target as HTMLImageElement).src = feature.image;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div style={styles.imagePlaceholder}>\n\t\t\t\t\t\t{TEXT.FEATURE_PREVIEW_PLACEHOLDER}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Content section */}\n\t\t\t<div style={styles.contentContainer}>\n\t\t\t\t<div>\n\t\t\t\t\t<h3 style={styles.title}>{feature.title}</h3>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={styles.content}\n\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t__html: decodeHTMLEntities(feature.content || feature.body || ''),\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t{/* Action buttons */}\n\t\t\t\t<div style={styles.actionsContainer}>\n\t\t\t\t\t{/* Secondary Button (if configured, shows as text link on left) */}\n\t\t\t\t\t{feature.secondaryButton?.text && (\n\t\t\t\t\t\t<span onClick={handleSecondaryAction} style={styles.understoodText}>\n\t\t\t\t\t\t\t{feature.secondaryButton.text}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Primary Button (always shows) */}\n\t\t\t\t\t<button onClick={handleExplore} style={styles.exploreButton}>\n\t\t\t\t\t\t{feature.primaryButton?.text ||\n\t\t\t\t\t\t\tfeature.buttonText ||\n\t\t\t\t\t\t\tTEXT.DEFAULT_BUTTON_TEXT}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default MinorUpdatePopup;\n"],"names":["_ref","feature","currentIndex","totalFeatures","onSkip","onExplore","onPrevious","onNext","setIsClosing","setIsClosingParent","isClosing","useState","startAnimation","setStartAnimation","transform","setTransform","popupRef","useRef","useEffect","styles","getMinorPopupStyles","_jsxs","Object","assign","ref","style","container","children","_jsx","jsx","imageContainer","displayImage","imageWrapper","src","alt","title","image","onError","e","target","imagePlaceholder","TEXT","FEATURE_PREVIEW_PLACEHOLDER","jsxs","contentContainer","content","dangerouslySetInnerHTML","__html","decodeHTMLEntities","body","actionsContainer","_a","secondaryButton","text","onClick","handleSecondaryAction","action","closeCallback","internalUrl","url","_b","redirectionUrl","startsWith","window","open","hideJoyrideArrow","current","featureTag","targetElement","findFeatureTagElement","transformValue","calculateCloseTransform","executeAfterAnimation","__awaiter","location","href","understoodText","handleExplore","primaryButton","redirectUrl","targetSelector","document","querySelector","exploreButton","buttonText","DEFAULT_BUTTON_TEXT"],"mappings":"8bAY0DA,IASrD,IATsDC,QAC1DA,EAAOC,aACPA,EAAYC,cACZA,EAAaC,OACbA,EAAMC,UACNA,EAASC,WACTA,EAAUC,OACVA,EACAC,aAAcC,GACdT,UACA,MAAOU,EAAWF,GAAgBG,EAAQA,UAAC,IACpCC,EAAgBC,GAAqBF,EAAQA,UAAC,IAC9CG,EAAWC,GAAgBJ,EAAQA,SAAC,IACrCK,EAAWC,SAAuB,MAGxCC,EAAAA,WAAU,KACLR,GAEHG,GAAkB,EAClB,G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7D,EAAQkE,WAAWL,WAAW,MAC9B7D,EAAQkE,WAAWL,WAAW,KAC3B7D,EAAQkE,WACJ,IAAAlE,EAAQkE,aACVC,EAAgBa,SAASC,cAAcF,GAC7C,GAAIZ,EAAe,CAClB,MAAME,EAAiBC,EAAuBA,wBAC7CvD,EAASkD,QACTE,GAEDrD,EAAauD,EACb,MACAvD,EAAa,WAEd,MACAA,EAAa,YAEdN,SAAAA,GAAqB,GACrBD,GAAa,EAAK,EAuGiBiB,MAAON,EAAOgE,eAAa,CAAAxD,UACpC,QAArBiC,EAAA3D,EAAQ6E,qBAAa,IAAAlB,OAAA,EAAAA,EAAEP,OACvBpD,EAAQmF,YACR3C,EAAAA,KAAK4C,kCAIJ"}
1
+ {"version":3,"file":"MinorUpdatePopup.js","sources":["../../../../src/components/feature-announcements/MinorUpdatePopup.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { TEXT } from './constants';\nimport { getMinorPopupStyles } from './styles';\nimport { MinorUpdatePopupProps } from './types';\nimport {\n\tcalculateCloseTransform,\n\tdecodeHTMLEntities,\n\texecuteAfterAnimation,\n\tfindFeatureTagElement,\n\thideJoyrideArrow,\n} from './utils';\n\nconst MinorUpdatePopup: React.FC<MinorUpdatePopupProps> = ({\n\tfeature,\n\tcurrentIndex,\n\ttotalFeatures,\n\tonSkip,\n\tonExplore,\n\tonPrevious,\n\tonNext,\n\tsetIsClosing: setIsClosingParent,\n}) => {\n\tconst [isClosing, setIsClosing] = useState(false);\n\tconst [startAnimation, setStartAnimation] = useState(false);\n\tconst [transform, setTransform] = useState('');\n\tconst popupRef = useRef<HTMLDivElement>(null);\n\n\t// Hide Joyride arrow when closing starts, then trigger animation immediately\n\tuseEffect(() => {\n\t\tif (isClosing) {\n\t\t\t// Start the shrink animation immediately\n\t\t\tsetStartAnimation(true);\n\t\t}\n\t}, [isClosing]);\n\n\tconst handleExplore = (): void => {\n\t\tconst action = feature.primaryButton?.action;\n\n\t\tif (action === 'Play Video') {\n\t\t\tonExplore();\n\t\t} else if (action === 'Open link') {\n\t\t\t// Navigate to URL\n\t\t\tconst url = feature.primaryButton?.redirectionUrl || feature.redirectUrl;\n\t\t\tif (url) {\n\t\t\t\tconst isExternal = url.startsWith('http');\n\t\t\t\tif (isExternal) {\n\t\t\t\t\twindow.open(url, '_blank', 'noopener,noreferrer');\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = url;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t// Default action - call onExplore callback\n\t\t\tonExplore();\n\t\t}\n\n\t\t// Run closing animation in background\n\t\thideJoyrideArrow(popupRef.current);\n\t\tif (popupRef.current && feature.featureTag) {\n\t\t\tconst targetSelector =\n\t\t\t\tfeature.featureTag.startsWith('#') ||\n\t\t\t\tfeature.featureTag.startsWith('.') ||\n\t\t\t\tfeature.featureTag.startsWith('[')\n\t\t\t\t\t? feature.featureTag\n\t\t\t\t\t: `#${feature.featureTag}`;\n\t\t\tconst targetElement = document.querySelector(targetSelector);\n\t\t\tif (targetElement) {\n\t\t\t\tconst transformValue = calculateCloseTransform(\n\t\t\t\t\tpopupRef.current,\n\t\t\t\t\ttargetElement,\n\t\t\t\t);\n\t\t\t\tsetTransform(transformValue);\n\t\t\t} else {\n\t\t\t\tsetTransform('scale(0)');\n\t\t\t}\n\t\t} else {\n\t\t\tsetTransform('scale(0)');\n\t\t}\n\t\tsetIsClosingParent?.(true);\n\t\tsetIsClosing(true);\n\t};\n\n\tconst handleSecondaryAction = (): void => {\n\t\tconst action = feature.secondaryButton?.action;\n\t\tconst closeCallback = onSkip;\n\n\t\t// Handle based on action type\n\t\tif (action === 'Play Video') {\n\t\t\tonExplore();\n\t\t} else if (action === 'Open link') {\n\t\t\t// Open URL\n\t\t\tconst url = feature.secondaryButton?.redirectionUrl;\n\t\t\tif (url) {\n\t\t\t\tconst isExternal = url.startsWith('http');\n\t\t\t\tif (isExternal) {\n\t\t\t\t\twindow.open(url, '_blank', 'noopener,noreferrer');\n\t\t\t\t} else {\n\t\t\t\t\twindow.location.href = url;\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (action === 'Close popup' || action === '') {\n\t\t\t// Just close the popup\n\t\t\tif (feature.secondaryButton?.action) {\n\t\t\t\t// Call onSecondaryAction if needed\n\t\t\t}\n\t\t}\n\n\t\t// Always close popup after secondary action\n\t\thideJoyrideArrow(popupRef.current);\n\t\tif (popupRef.current && feature.featureTag) {\n\t\t\tconst targetElement = findFeatureTagElement(feature.featureTag);\n\t\t\tif (targetElement) {\n\t\t\t\tconst transformValue = calculateCloseTransform(\n\t\t\t\t\tpopupRef.current,\n\t\t\t\t\ttargetElement,\n\t\t\t\t);\n\t\t\t\tsetTransform(transformValue);\n\t\t\t} else {\n\t\t\t\tsetTransform('scale(0)');\n\t\t\t}\n\t\t} else {\n\t\t\tsetTransform('scale(0)');\n\t\t}\n\t\tsetIsClosingParent?.(true);\n\t\tsetIsClosing(true);\n\t\texecuteAfterAnimation(closeCallback);\n\t};\n\n\tconst styles = getMinorPopupStyles(startAnimation, transform);\n\n\treturn (\n\t\t<div ref={popupRef} style={styles.container}>\n\t\t\t{/* Image section */}\n\t\t\t<div style={styles.imageContainer}>\n\t\t\t\t{feature.displayImage ? (\n\t\t\t\t\t<div style={styles.imageWrapper}>\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tsrc={feature.displayImage}\n\t\t\t\t\t\t\talt={feature.title}\n\t\t\t\t\t\t\tstyle={styles.image}\n\t\t\t\t\t\t\tonError={(e) => {\n\t\t\t\t\t\t\t\tif (feature.image) {\n\t\t\t\t\t\t\t\t\t(e.target as HTMLImageElement).src = feature.image;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<div style={styles.imagePlaceholder}>\n\t\t\t\t\t\t{TEXT.FEATURE_PREVIEW_PLACEHOLDER}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t</div>\n\n\t\t\t{/* Content section */}\n\t\t\t<div style={styles.contentContainer}>\n\t\t\t\t<div>\n\t\t\t\t\t<h3 style={styles.title}>{feature.title}</h3>\n\t\t\t\t\t<div\n\t\t\t\t\t\tstyle={styles.content}\n\t\t\t\t\t\tdangerouslySetInnerHTML={{\n\t\t\t\t\t\t\t__html: decodeHTMLEntities(feature.content || feature.body || ''),\n\t\t\t\t\t\t}}\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\n\t\t\t\t{/* Action buttons */}\n\t\t\t\t<div style={styles.actionsContainer}>\n\t\t\t\t\t{/* Secondary Button (if configured, shows as text link on left) */}\n\t\t\t\t\t{feature.secondaryButton?.text && (\n\t\t\t\t\t\t<span onClick={handleSecondaryAction} style={styles.understoodText}>\n\t\t\t\t\t\t\t{feature.secondaryButton.text}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t)}\n\n\t\t\t\t\t{/* Primary Button (always shows) */}\n\t\t\t\t\t<button onClick={handleExplore} style={styles.exploreButton}>\n\t\t\t\t\t\t{feature.primaryButton?.text ||\n\t\t\t\t\t\t\tfeature.buttonText ||\n\t\t\t\t\t\t\tTEXT.DEFAULT_BUTTON_TEXT}\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default MinorUpdatePopup;\n"],"names":["_ref","feature","currentIndex","totalFeatures","onSkip","onExplore","onPrevious","onNext","setIsClosing","setIsClosingParent","isClosing","useState","startAnimation","setStartAnimation","transform","setTransform","popupRef","useRef","useEffect","styles","getMinorPopupStyles","_jsxs","Object","assign","ref","style","container","children","_jsx","jsx","imageContainer","displayImage","imageWrapper","src","alt","title","image","onError","e","target","imagePlaceholder","TEXT","FEATURE_PREVIEW_PLACEHOLDER","jsxs","contentContainer","content","dangerouslySetInnerHTML","__html","decodeHTMLEntities","body","actionsContainer","_a","secondaryButton","text","onClick","handleSecondaryAction","action","closeCallback","url","_b","redirectionUrl","startsWith","window","open","location","href","_c","hideJoyrideArrow","current","featureTag","targetElement","findFeatureTagElement","transformValue","calculateCloseTransform","executeAfterAnimation","understoodText","handleExplore","primaryButton","redirectUrl","targetSelector","document","querySelector","exploreButton","buttonText","DEFAULT_BUTTON_TEXT"],"mappings":"wZAY0DA,IASrD,IATsDC,QAC1DA,EAAOC,aACPA,EAAYC,cACZA,EAAaC,OACbA,EAAMC,UACNA,EAASC,WACTA,EAAUC,OACVA,EACAC,aAAcC,GACdT,UACA,MAAOU,EAAWF,GAAgBG,EAAQA,UAAC,IACpCC,EAAgBC,GAAqBF,EAAQA,UAAC,IAC9CG,EAAWC,GAAgBJ,EAAQA,SAAC,IACrCK,EAAWC,SAAuB,MAGxCC,EAAAA,WAAU,KACLR,GAEHG,GAAkB,EAClB,GACC,CAACH,IAEJ,MA6FMS,EAASC,EAAAA,oBAAoBR,EAAgBE,GAEnD,OACCO,OAAK,MAAAC,OAAAC,OAAA,CAAAC,IAAKR,EAAUS,MAAON,EAAOO,WAEjC,CAAAC,SAAA,CAAAC,EAAAC,IAAA,MAAAP,OAAAC,OAAA,CAAKE,MAAON,EAAOW,gBACjB,CAAAH,SAAA1B,EAAQ8B,aACRH,EAAKC,IAAA,MAAAP,OAAAC,OAAA,CAAAE,MAAON,EAAOa,cAAY,CAAAL,SAC9BC,EACCC,IAAA,MAAA,CAAAI,IAAKhC,EAAQ8B,aACbG,IAAKjC,EAAQkC,MACbV,MAAON,EAAOiB,MACdC,QAAUC,IACLrC,EAAQmC,QACVE,EAAEC,OAA4BN,IAAMhC,EAAQmC,MAC7C,OAKJR,EAAKC,IAAA,MAAAP,OAAAC,OAAA,CAAAE,MAAON,EAAOqB,kBAAgB,CAAAb,SACjCc,EAAIA,KAACC,kCAMTrB,EAAAsB,KAAA,MAAArB,OAAAC,OAAA,CAAKE,MAAON,EAAOyB,6BAClBvB,EACCsB,KAAA,MAAA,CAAAhB,SAAA,CAAAC,EAAAC,IAAA,KAAAP,OAAAC,OAAA,CAAIE,MAAON,EAAO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AA+B,QA7IUsB,aACrB,MAAMpB,EAA8B,QAArBL,EAAAlD,EAAQ4E,qBAAa,IAAA1B,OAAA,EAAAA,EAAEK,OAEtC,GAAe,eAAXA,EACHnD,SACM,GAAe,cAAXmD,EAAwB,CAElC,MAAME,GAA2B,QAArBC,EAAA1D,EAAQ4E,qBAAa,IAAAlB,OAAA,EAAAA,EAAEC,iBAAkB3D,EAAQ6E,YAC7D,GAAIpB,EAAK,CACWA,EAAIG,WAAW,QAEjCC,OAAOC,KAAKL,EAAK,SAAU,uBAE3BI,OAAOE,SAASC,KAAOP,CAExB,CACD,MAEArD,IAKD,GADA8D,mBAAiBnD,EAASoD,SACtBpD,EAASoD,SAAWnE,EAAQoE,WAAY,CAC3C,MAAMU,EACL9E,EAAQoE,WAAWR,WAAW,MAC9B5D,EAAQoE,WAAWR,WAAW,MAC9B5D,EAAQoE,WAAWR,WAAW,KAC3B5D,EAAQoE,WACJ,IAAApE,EAAQoE,aACVC,EAAgBU,SAASC,cAAcF,GAC7C,GAAIT,EAAe,CAClB,MAAME,EAAiBC,EAAuBA,wBAC7CzD,EAASoD,QACTE,GAEDvD,EAAayD,EACb,MACAzD,EAAa,WAEd,MACAA,EAAa,YAEdN,SAAAA,GAAqB,GACrBD,GAAa,EAAK,EAiGiBiB,MAAON,EAAO+D,eAAa,CAAAvD,UACpC,QAArBgC,EAAA1D,EAAQ4E,qBAAa,IAAAlB,OAAA,EAAAA,EAAEN,OACvBpD,EAAQkF,YACR1C,EAAAA,KAAK2C,kCAIJ"}
@@ -1 +1 @@
1
- {"version":3,"file":"animationHelpers.js","sources":["../../../../../src/components/feature-announcements/utils/animationHelpers.ts"],"sourcesContent":["import { ANIMATION_TIMING } from '../constants';\n\n/**\n * Calculate transform for closing animation\n * @param popupElement - Popup element reference\n * @param targetElement - Target element to animate towards\n * @returns Transform CSS string\n */\nexport const calculateCloseTransform = (\n\tpopupElement: HTMLElement,\n\ttargetElement: Element,\n): string => {\n\tconst popupRect = popupElement.getBoundingClientRect();\n\tconst targetRect = targetElement.getBoundingClientRect();\n\n\tconst translateX =\n\t\ttargetRect.left +\n\t\ttargetRect.width / 2 -\n\t\t(popupRect.left + popupRect.width / 2);\n\tconst translateY =\n\t\ttargetRect.top +\n\t\ttargetRect.height / 2 -\n\t\t(popupRect.top + popupRect.height / 2);\n\n\treturn `translate(${translateX}px, ${translateY}px) scale(0)`;\n};\n\n/**\n * Hide Joyride arrow element\n * @param popupRef - Reference to popup element\n */\nexport const hideJoyrideArrow = (popupRef: HTMLElement | null): void => {\n\tif (!popupRef) return;\n\n\tconst tooltip = popupRef.closest('[class*=\"react-joyride__tooltip\"]');\n\tif (!tooltip) return;\n\n\tconst arrow = tooltip.querySelector(\n\t\t'[class*=\"react-joyride__arrow\"]',\n\t) as HTMLElement;\n\tif (arrow) {\n\t\tarrow.style.display = 'none';\n\t\tarrow.style.visibility = 'hidden';\n\t\tarrow.style.opacity = '0';\n\t}\n};\n\n/**\n * Execute callback after animation completes\n * @param callback - Function to execute\n * @param delay - Optional delay override\n */\nexport const executeAfterAnimation = (\n\tcallback: () => void | Promise<void>,\n\tdelay: number = ANIMATION_TIMING.CLOSE_DURATION,\n): void => {\n\tsetTimeout(callback, delay);\n};\n"],"names":["calculateCloseTransform","popupElement","targetElement","popupRect","getBoundingClientRect","targetRect","left","width","top","height","callback","delay","arguments","length","undefined","ANIMATION_TIMING","CLOSE_DURATION","setTimeout","popupRef","tooltip","closest","arrow","querySelector","style","display","visibility","opacity"],"mappings":"gJAQuCA,CACtCC,EACAC,KAEA,MAAMC,EAAYF,EAAaG,wBACzBC,EAAaH,EAAcE,wBAWjC,MAAoB,aARnBC,EAAWC,KACXD,EAAWE,MAAQ,GAClBJ,EAAUG,KAAOH,EAAUI,MAAQ,SAEpCF,EAAWG,IACXH,EAAWI,OAAS,GACnBN,EAAUK,IAAML,EAAUM,OAAS,gBAEwB,gCA4BzB,SACpCC,GAES,IADTC,EAAAC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAgBG,GAAAA,EAAAA,iBAAiBC,eAEjCC,WAAWP,EAAUC,EACtB,2BA1BiCO,IAChC,IAAKA,EAAU,OAEf,MAAMC,EAAUD,EAASE,QAAQ,qCACjC,IAAKD,EAAS,OAEd,MAAME,EAAQF,EAAQG,cACrB,mCAEGD,IACHA,EAAME,MAAMC,QAAU,OACtBH,EAAME,MAAME,WAAa,SACzBJ,EAAME,MAAMG,QAAU,IACtB"}
1
+ {"version":3,"file":"animationHelpers.js","sources":["../../../../../src/components/feature-announcements/utils/animationHelpers.ts"],"sourcesContent":["import { ANIMATION_TIMING } from '../constants';\n\n/**\n * Calculate transform for closing animation\n * @param popupElement - Popup element reference\n * @param targetElement - Target element to animate towards\n * @returns Transform CSS string\n */\nexport const calculateCloseTransform = (\n\tpopupElement: HTMLElement,\n\ttargetElement: Element,\n): string => {\n\tconst popupRect = popupElement.getBoundingClientRect();\n\tconst targetRect = targetElement.getBoundingClientRect();\n\n\tconst translateX =\n\t\ttargetRect.left +\n\t\ttargetRect.width / 2 -\n\t\t(popupRect.left + popupRect.width / 2);\n\tconst translateY =\n\t\ttargetRect.top +\n\t\ttargetRect.height / 2 -\n\t\t(popupRect.top + popupRect.height / 2);\n\n\treturn `translate(${translateX}px, ${translateY}px) scale(0)`;\n};\n\n/**\n * Hide Joyride arrow element\n * @param popupRef - Reference to popup element\n */\nexport const hideJoyrideArrow = (popupRef: HTMLElement | null): void => {\n\tif (!popupRef) return;\n\n\tconst tooltip = popupRef.closest('[class*=\"react-joyride__tooltip\"]');\n\tif (!tooltip) return;\n\n\tconst arrow = tooltip.querySelector(\n\t\t'[class*=\"react-joyride__arrow\"]',\n\t) as HTMLElement;\n\tif (arrow) {\n\t\tarrow.style.display = 'none';\n\t\tarrow.style.visibility = 'hidden';\n\t\tarrow.style.opacity = '0';\n\t}\n};\n\n/**\n * Execute callback after animation completes\n * @param callback - Function to execute\n * @param delay - Optional delay override\n */\nexport const executeAfterAnimation = (\n\tcallback: () => void,\n\tdelay: number = ANIMATION_TIMING.CLOSE_DURATION,\n): void => {\n\tsetTimeout(callback, delay);\n};\n"],"names":["calculateCloseTransform","popupElement","targetElement","popupRect","getBoundingClientRect","targetRect","left","width","top","height","callback","delay","arguments","length","undefined","ANIMATION_TIMING","CLOSE_DURATION","setTimeout","popupRef","tooltip","closest","arrow","querySelector","style","display","visibility","opacity"],"mappings":"gJAQuCA,CACtCC,EACAC,KAEA,MAAMC,EAAYF,EAAaG,wBACzBC,EAAaH,EAAcE,wBAWjC,MAAoB,aARnBC,EAAWC,KACXD,EAAWE,MAAQ,GAClBJ,EAAUG,KAAOH,EAAUI,MAAQ,SAEpCF,EAAWG,IACXH,EAAWI,OAAS,GACnBN,EAAUK,IAAML,EAAUM,OAAS,gBAEwB,gCA4BzB,SACpCC,GAES,IADTC,EAAAC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAgBG,GAAAA,EAAAA,iBAAiBC,eAEjCC,WAAWP,EAAUC,EACtB,2BA1BiCO,IAChC,IAAKA,EAAU,OAEf,MAAMC,EAAUD,EAASE,QAAQ,qCACjC,IAAKD,EAAS,OAEd,MAAME,EAAQF,EAAQG,cACrB,mCAEGD,IACHA,EAAME,MAAMC,QAAU,OACtBH,EAAME,MAAME,WAAa,SACzBJ,EAAME,MAAMG,QAAU,IACtB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../node_modules/prosemirror-model/dist/index.js");function e(t){return t.replace(/<p>\s*<br\s*\/?>\s*<\/p>/gi,"<p></p>").replace(/<\/?span[^>]*>/gi,"")}const n=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function i(t){var e;if(!t)return"";return null!==(e=r(t).get("body"))&&void 0!==e?e:t}function r(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let r;for(;null!==(r=n.exec(t));)i.push({id:r[1],index:r.index,endIndex:r.index+r[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const r=i[n].endIndex,o=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(r,o))}return e}function o(e,n){var i;const r=s(e,n);if(-1===r)return{html:"",text:"",isEmpty:!0,characterCount:0};const o=c(e,n),l=e.state.doc.slice(r,o),d=document.createElement("div"),u=t.DOMSerializer.fromSchema(e.schema);d.appendChild(u.serializeFragment(l.content));const a=d.innerHTML,f=null!==(i=d.textContent)&&void 0!==i?i:"";return{html:a,text:f,isEmpty:!f.trim(),characterCount:f.length}}function s(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n}function c(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let r=!1,o=-1;return n.descendants(((t,n)=>-1===o&&(r?void("sectionDivider"===t.type.name&&(o=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(r=!0),!1)))),-1!==o?o:i}exports.SECTION_DIVIDER_HTML=n,exports.buildSectionedContent=function(t,e){let i=t;for(const t of e)i+=n(t.id)+t.content;return i},exports.extractActiveFormats=function(t){var e,n,i,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:(()=>{var e,n,i;if(t.isActive("link"))return{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""};const{$from:r}=t.state.selection;if(r.pos>0){const t=r.doc.resolve(r.pos).marks().find((t=>"link"===t.type.name));if(t)return{href:null!==(i=t.attrs.href)&&void 0!==i?i:""};{const t=r.nodeBefore,e=null==t?void 0:t.marks.find((t=>"link"===t.type.name));if(e)return{href:null!==(n=e.attrs.href)&&void 0!==n?n:""}}}return null})(),textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":t.isActive({textAlign:"left"})?"left":null,fontFamily:null!==(e=t.getAttributes("textStyle").fontFamily)&&void 0!==e?e:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(i=t.getAttributes("textStyle").color)&&void 0!==i?i:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null,superscript:t.isActive("superscript"),subscript:t.isActive("subscript")}},exports.extractAllSectionsFromHtml=r,exports.extractBodyContent=function(t){return o(t,"body")},exports.extractContent=function(t){var e,n,i;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(i=null===(n=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==i?i:t.getText().length}},exports.extractSectionContent=o,exports.findSectionEndPos=c,exports.findSectionStartPos=s,exports.getBodyHtml=i,exports.getSectionsHtml=function(t){if(!t)return"";const e=i(t);return t.substring(e.length)},exports.insertInlineHtml=function(n,i){const r=e(i),o=document.createElement("div");o.innerHTML=r;const s=t.DOMParser.fromSchema(n.schema).parseSlice(o);if(0===s.size)return;const{from:c,to:l}=n.state.selection,d=n.state.tr.replaceRange(c,l,s);n.view.dispatch(d)},exports.normalizeHtml=e,exports.setSectionContentInEditor=function(e,i,r){const o=s(e,i);if(-1===o){const t=e.state.doc.content.size,o=n(i)+r;return void e.commands.insertContentAt(t,o,{updateSelection:!1})}const l=c(e,i),d=function(e,n){const i=document.createElement("div");return i.innerHTML=n,t.DOMParser.fromSchema(e.schema).parse(i).content}(e,r),{tr:u}=e.state,a="body"===i?0:o;u.replaceWith(a,l,d),u.setMeta("addToHistory",!1),e.view.dispatch(u)};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("../node_modules/prosemirror-model/dist/index.js");function e(t){return t.replace(/<p[^>]*>\s*<br\s*\/?>\s*<\/p>/gi,"").replace(/<\/?span[^>]*>/gi,"")}const n=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function i(t){var e;if(!t)return"";return null!==(e=r(t).get("body"))&&void 0!==e?e:t}function r(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let r;for(;null!==(r=n.exec(t));)i.push({id:r[1],index:r.index,endIndex:r.index+r[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const r=i[n].endIndex,o=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(r,o))}return e}function o(e,n){var i;const r=s(e,n);if(-1===r)return{html:"",text:"",isEmpty:!0,characterCount:0};const o=c(e,n),l=e.state.doc.slice(r,o),d=document.createElement("div"),u=t.DOMSerializer.fromSchema(e.schema);d.appendChild(u.serializeFragment(l.content));const a=d.innerHTML,f=null!==(i=d.textContent)&&void 0!==i?i:"";return{html:a,text:f,isEmpty:!f.trim(),characterCount:f.length}}function s(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n}function c(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let r=!1,o=-1;return n.descendants(((t,n)=>-1===o&&(r?void("sectionDivider"===t.type.name&&(o=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(r=!0),!1)))),-1!==o?o:i}exports.SECTION_DIVIDER_HTML=n,exports.buildSectionedContent=function(t,e){let i=t;for(const t of e)i+=n(t.id)+t.content;return i},exports.extractActiveFormats=function(t){var e,n,i,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:(()=>{var e,n,i;if(t.isActive("link"))return{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""};const{$from:r}=t.state.selection;if(r.pos>0){const t=r.doc.resolve(r.pos).marks().find((t=>"link"===t.type.name));if(t)return{href:null!==(i=t.attrs.href)&&void 0!==i?i:""};{const t=r.nodeBefore,e=null==t?void 0:t.marks.find((t=>"link"===t.type.name));if(e)return{href:null!==(n=e.attrs.href)&&void 0!==n?n:""}}}return null})(),textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":t.isActive({textAlign:"left"})?"left":null,fontFamily:null!==(e=t.getAttributes("textStyle").fontFamily)&&void 0!==e?e:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(i=t.getAttributes("textStyle").color)&&void 0!==i?i:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null,superscript:t.isActive("superscript"),subscript:t.isActive("subscript")}},exports.extractAllSectionsFromHtml=r,exports.extractBodyContent=function(t){return o(t,"body")},exports.extractContent=function(t){var e,n,i;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(i=null===(n=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==i?i:t.getText().length}},exports.extractSectionContent=o,exports.findSectionEndPos=c,exports.findSectionStartPos=s,exports.getBodyHtml=i,exports.getSectionsHtml=function(t){if(!t)return"";const e=i(t);return t.substring(e.length)},exports.insertInlineHtml=function(n,i){const r=e(i),o=document.createElement("div");o.innerHTML=r;const s=t.DOMParser.fromSchema(n.schema).parseSlice(o);if(0===s.size)return;const{from:c,to:l}=n.state.selection,d=n.state.tr.replaceRange(c,l,s);n.view.dispatch(d)},exports.normalizeHtml=e,exports.setSectionContentInEditor=function(e,i,r){const o=s(e,i);if(-1===o){const t=e.state.doc.content.size,o=n(i)+r;return void e.commands.insertContentAt(t,o,{updateSelection:!1})}const l=c(e,i),d=function(e,n){const i=document.createElement("div");return i.innerHTML=n,t.DOMParser.fromSchema(e.schema).parse(i).content}(e,r),{tr:u}=e.state,a="body"===i?0:o;u.replaceWith(a,l,d),u.setMeta("addToHistory",!1),e.view.dispatch(u)};
2
2
  //# sourceMappingURL=BikEditor.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.utils.js","sources":["../../../src/editor/BikEditor.utils.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { DOMParser, DOMSerializer } from 'prosemirror-model';\nimport { EditorSnapshot, FormatState } from './BikEditor.types';\n\n// ---------------------------------------------------------------------------\n// HTML normalisation\n// ---------------------------------------------------------------------------\n\n/**\n * Normalise HTML before passing it to TipTap.\n *\n * Problem: Quill uses `<p><br></p>` as a blank-line separator. TipTap's\n * HardBreak extension parses that `<br>` as a real `hard_break` node.\n * ProseMirror then also appends `<br class=\"ProseMirror-trailingBreak\">` as a\n * cursor-position decoration, making the empty paragraph render at **2× line\n * height** instead of 1×.\n *\n * Fix: replace `<p><br></p>` → `<p></p>` so TipTap stores a truly empty\n * paragraph. ProseMirror adds only the trailing decoration, giving the correct\n * 1× line height. The WA text output is unchanged (`\\n` either way after\n * surrounding-newline collapse in `toWhatsAppText`).\n */\nexport function normalizeHtml(html: string): string {\n\treturn html\n\t\t.replace(/<p>\\s*<br\\s*\\/?>\\s*<\\/p>/gi, '<p></p>')\n\t\t.replace(/<\\/?span[^>]*>/gi, '');\n}\n\n// ---------------------------------------------------------------------------\n// Inline content insertion\n// ---------------------------------------------------------------------------\n\n/**\n * Insert HTML at the current cursor position, merging the first paragraph\n * inline while preserving the block structure of subsequent paragraphs/lists.\n *\n * Uses `parseSlice` which returns an open-ended Slice — the first block merges\n * at the cursor, middle blocks stay intact, and the last block merges with any\n * text that follows the cursor.\n */\nexport function insertInlineHtml(editor: Editor, html: string): void {\n\tconst normalised = normalizeHtml(html);\n\tconst dom = document.createElement('div');\n\tdom.innerHTML = normalised;\n\tconst slice = DOMParser.fromSchema(editor.schema).parseSlice(dom);\n\n\tif (slice.size === 0) return;\n\n\tconst { from, to } = editor.state.selection;\n\tconst tr = editor.state.tr.replaceRange(from, to, slice);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Section divider HTML\n// ---------------------------------------------------------------------------\n\nexport const SECTION_DIVIDER_HTML = (id: string) =>\n\t`<div data-section-divider=\"${id}\" style=\"display:none;height:0;line-height:0;overflow:hidden;\"></div>`;\n\n/**\n * Build initial HTML for an editor with one or more named sections below the body.\n * Each section is separated by an invisible divider node.\n *\n * @example\n * buildSectionedContent('<p>Body</p>', [\n * { id: 'signature', content: '<p>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- fwd ---</p>' },\n * ])\n */\nexport function buildSectionedContent(\n\tbody: string,\n\tsections: Array<{ id: string; content: string }>,\n): string {\n\tlet html = body;\n\tfor (const s of sections) {\n\t\thtml += SECTION_DIVIDER_HTML(s.id) + s.content;\n\t}\n\treturn html;\n}\n\n// ---------------------------------------------------------------------------\n// Section extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Parse the editor HTML into a Map of sectionId → raw HTML string.\n * The special key `'body'` always holds the content before the first divider.\n * Map iteration order matches document order.\n */\nexport function extractAllSections(editor: Editor): Map<string, string> {\n\treturn extractAllSectionsFromHtml(editor.getHTML());\n}\n\n/**\n * Extract just the body portion (everything before the first section divider)\n * from an HTML string produced by BikEditor. Safe to call on plain HTML too —\n * returns the full string when no dividers are present.\n */\nexport function getBodyHtml(html: string): string {\n\tif (!html) return '';\n\tconst sections = extractAllSectionsFromHtml(html);\n\treturn sections.get('body') ?? html;\n}\n\n/**\n * Extract everything from the first section divider onward (dividers + their\n * content). Returns an empty string when there are no sections.\n */\nexport function getSectionsHtml(html: string): string {\n\tif (!html) return '';\n\tconst body = getBodyHtml(html);\n\treturn html.substring(body.length);\n}\n\nexport function extractAllSectionsFromHtml(html: string): Map<string, string> {\n\tconst sections = new Map<string, string>();\n\tconst dividerRegex =\n\t\t/<div[^>]*data-section-divider=\"([^\"]*)[^>]*>\\s*<\\/div>/g;\n\tconst dividers: Array<{ id: string; index: number; endIndex: number }> = [];\n\n\tlet match: RegExpExecArray | null;\n\twhile ((match = dividerRegex.exec(html)) !== null) {\n\t\tdividers.push({\n\t\t\tid: match[1],\n\t\t\tindex: match.index,\n\t\t\tendIndex: match.index + match[0].length,\n\t\t});\n\t}\n\n\tif (dividers.length === 0) {\n\t\tsections.set('body', html);\n\t\treturn sections;\n\t}\n\n\tsections.set('body', html.slice(0, dividers[0].index));\n\tfor (let i = 0; i < dividers.length; i++) {\n\t\tconst start = dividers[i].endIndex;\n\t\tconst end = i + 1 < dividers.length ? dividers[i + 1].index : html.length;\n\t\tsections.set(dividers[i].id, html.slice(start, end));\n\t}\n\n\treturn sections;\n}\n\n/** Returns BikEditorContent for a single named section (or 'body'). */\nexport function extractSectionContent(\n\teditor: Editor,\n\tid: string,\n): EditorSnapshot {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1)\n\t\treturn { html: '', text: '', isEmpty: true, characterCount: 0 };\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst slice = editor.state.doc.slice(startPos, endPos);\n\tconst container = document.createElement('div');\n\tconst serializer = DOMSerializer.fromSchema(editor.schema);\n\tcontainer.appendChild(serializer.serializeFragment(slice.content));\n\tconst html = container.innerHTML;\n\tconst text = container.textContent ?? '';\n\treturn { html, text, isEmpty: !text.trim(), characterCount: text.length };\n}\n\n/**\n * Parse an HTML string into ProseMirror nodes using the editor's schema.\n */\nfunction parseHtmlToNodes(editor: Editor, html: string) {\n\tconst container = document.createElement('div');\n\tcontainer.innerHTML = html;\n\treturn DOMParser.fromSchema(editor.schema).parse(container).content;\n}\n\n/**\n * Replace the content of a single named section without touching others.\n * Uses a ProseMirror transaction to replace only the target range,\n * preserving undo history and other sections' state.\n * If the section doesn't exist yet, it is appended at the end of the document.\n */\nexport function setSectionContentInEditor(\n\teditor: Editor,\n\tid: string,\n\thtml: string,\n): void {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1) {\n\t\tconst endPos = editor.state.doc.content.size;\n\t\tconst dividerHtml = SECTION_DIVIDER_HTML(id) + html;\n\t\teditor.commands.insertContentAt(endPos, dividerHtml, {\n\t\t\tupdateSelection: false,\n\t\t});\n\t\treturn;\n\t}\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst fragment = parseHtmlToNodes(editor, html);\n\tconst { tr } = editor.state;\n\t// For body, replace from position 0 (before the first paragraph's opening\n\t// boundary) so ProseMirror swaps entire block nodes cleanly. Position 1\n\t// (inside the paragraph) would force ProseMirror to close the open paragraph\n\t// first, creating a ghost empty <p></p>.\n\tconst replaceFrom = id === 'body' ? 0 : startPos;\n\ttr.replaceWith(replaceFrom, endPos, fragment);\n\ttr.setMeta('addToHistory', false);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Convenience shorthands (body = first section)\n// ---------------------------------------------------------------------------\n\n/** Extract BikEditorContent for just the body (before the first divider). */\nexport function extractBodyContent(editor: Editor): EditorSnapshot {\n\treturn extractSectionContent(editor, 'body');\n}\n\n// ---------------------------------------------------------------------------\n// Active formats\n// ---------------------------------------------------------------------------\n\nexport function extractActiveFormats(editor: Editor): FormatState {\n\treturn {\n\t\tbold: editor.isActive('bold'),\n\t\titalic: editor.isActive('italic'),\n\t\tunderline: editor.isActive('underline'),\n\t\tstrike: editor.isActive('strike'),\n\t\tbulletList: editor.isActive('bulletList'),\n\t\torderedList: editor.isActive('orderedList'),\n\t\tblockquote: editor.isActive('blockquote'),\n\t\tcodeBlock: editor.isActive('codeBlock'),\n\t\tlink: (() => {\n\t\t\tif (editor.isActive('link')) {\n\t\t\t\treturn { href: editor.getAttributes('link')['href'] ?? '' };\n\t\t\t}\n\t\t\tconst { $from } = editor.state.selection;\n\t\t\tif ($from.pos > 0) {\n\t\t\t\tconst before = $from.doc.resolve($from.pos);\n\t\t\t\tconst linkMark = before.marks().find((m) => m.type.name === 'link');\n\t\t\t\tif (!linkMark) {\n\t\t\t\t\tconst nodeBefore = $from.nodeBefore;\n\t\t\t\t\tconst markOnPrev = nodeBefore?.marks.find(\n\t\t\t\t\t\t(m) => m.type.name === 'link',\n\t\t\t\t\t);\n\t\t\t\t\tif (markOnPrev) {\n\t\t\t\t\t\treturn { href: markOnPrev.attrs['href'] ?? '' };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn { href: linkMark.attrs['href'] ?? '' };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t})(),\n\t\ttextAlign: editor.isActive({ textAlign: 'center' })\n\t\t\t? 'center'\n\t\t\t: editor.isActive({ textAlign: 'right' })\n\t\t\t? 'right'\n\t\t\t: editor.isActive({ textAlign: 'justify' })\n\t\t\t? 'justify'\n\t\t\t: editor.isActive({ textAlign: 'left' })\n\t\t\t? 'left'\n\t\t\t: null,\n\t\tfontFamily: editor.getAttributes('textStyle')['fontFamily'] ?? null,\n\t\tfontSize: editor.getAttributes('textStyle')['fontSize'] ?? null,\n\t\tcolor: editor.getAttributes('textStyle')['color'] ?? null,\n\t\thighlight: editor.isActive('highlight')\n\t\t\t? editor.getAttributes('highlight')['color'] ?? 'default'\n\t\t\t: null,\n\t\tsuperscript: editor.isActive('superscript'),\n\t\tsubscript: editor.isActive('subscript'),\n\t};\n}\n\nexport function extractContent(editor: Editor): EditorSnapshot {\n\treturn {\n\t\thtml: editor.getHTML(),\n\t\ttext: editor.getText(),\n\t\tisEmpty: editor.isEmpty,\n\t\tcharacterCount:\n\t\t\teditor.storage.characterCount?.characters?.() ?? editor.getText().length,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Section position helpers (used by insertAtSectionStart/End and appendBodyContent)\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the ProseMirror position immediately after a section's opening divider\n * (i.e. the start of the section's own content).\n * For `'body'`, returns 1 (beginning of the document).\n * Returns -1 if the named section's divider is not found.\n */\nexport function findSectionStartPos(editor: Editor, sectionId: string): number {\n\tif (sectionId === 'body') return 1;\n\tlet startPos = -1;\n\teditor.state.doc.descendants((node, pos) => {\n\t\tif (startPos !== -1) return false;\n\t\tif (\n\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t) {\n\t\t\tstartPos = pos + node.nodeSize; // position right after the divider\n\t\t}\n\t});\n\treturn startPos;\n}\n\n/**\n * Returns the ProseMirror position at the end of a named section's content:\n * - For `'body'`: position of the first section divider, or end of document.\n * - For a named section: position of the next divider, or end of document.\n */\nexport function findSectionEndPos(editor: Editor, sectionId: string): number {\n\tconst doc = editor.state.doc;\n\tconst docSize = doc.content.size;\n\n\tif (sectionId === 'body') {\n\t\tlet firstDividerPos = -1;\n\t\tdoc.descendants((node, pos) => {\n\t\t\tif (firstDividerPos !== -1) return false;\n\t\t\tif (node.type.name === 'sectionDivider') {\n\t\t\t\tfirstDividerPos = pos;\n\t\t\t}\n\t\t});\n\t\treturn firstDividerPos !== -1 ? firstDividerPos : docSize;\n\t}\n\n\tlet passedSection = false;\n\tlet nextDividerPos = -1;\n\tdoc.descendants((node, pos) => {\n\t\tif (nextDividerPos !== -1) return false;\n\t\tif (!passedSection) {\n\t\t\tif (\n\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t) {\n\t\t\t\tpassedSection = true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tif (node.type.name === 'sectionDivider') {\n\t\t\tnextDividerPos = pos;\n\t\t}\n\t});\n\treturn nextDividerPos !== -1 ? nextDividerPos : docSize;\n}\n"],"names":["normalizeHtml","html","replace","SECTION_DIVIDER_HTML","id","getBodyHtml","_a","extractAllSectionsFromHtml","get","sections","Map","dividerRegex","dividers","match","exec","push","index","endIndex","length","set","slice","i","start","end","extractSectionContent","editor","startPos","findSectionStartPos","text","isEmpty","characterCount","endPos","findSectionEndPos","state","doc","container","document","createElement","serializer","DOMSerializer","fromSchema","schema","appendChild","serializeFragment","content","innerHTML","textContent","trim","sectionId","descendants","node","pos","type","name","attrs","nodeSize","docSize","size","firstDividerPos","passedSection","nextDividerPos","body","s","bold","isActive","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","href","getAttributes","$from","selection","linkMark","resolve","marks","find","m","_c","nodeBefore","markOnPrev","_b","textAlign","fontFamily","fontSize","color","highlight","_d","superscript","subscript","getHTML","getText","storage","characters","substring","normalised","dom","DOMParser","parseSlice","from","to","tr","replaceRange","view","dispatch","dividerHtml","commands","insertContentAt","updateSelection","fragment","parse","parseHtmlToNodes","replaceFrom","replaceWith","setMeta"],"mappings":"qIAsBM,SAAUA,EAAcC,GAC7B,OAAOA,EACLC,QAAQ,6BAA8B,WACtCA,QAAQ,mBAAoB,GAC/B,OA+BaC,EAAwBC,GACpC,8BAA8BA,yEAyCzB,SAAUC,EAAYJ,SAC3B,IAAKA,EAAM,MAAO,GAElB,OAA+B,QAAxBK,EADUC,EAA2BN,GAC5BO,IAAI,eAAW,IAAAF,EAAAA,EAAAL,CAChC,CAYM,SAAUM,EAA2BN,GAC1C,MAAMQ,EAAW,IAAIC,IACfC,EACL,0DACKC,EAAmE,GAEzE,IAAIC,EACJ,KAA6C,QAArCA,EAAQF,EAAaG,KAAKb,KACjCW,EAASG,KAAK,CACbX,GAAIS,EAAM,GACVG,MAAOH,EAAMG,MACbC,SAAUJ,EAAMG,MAAQH,EAAM,GAAGK,SAInC,GAAwB,IAApBN,EAASM,OAEZ,OADAT,EAASU,IAAI,OAAQlB,GACdQ,EAGRA,EAASU,IAAI,OAAQlB,EAAKmB,MAAM,EAAGR,EAAS,GAAGI,QAC/C,IAAK,IAAIK,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J,GACzB,OAAOA,EAAKiG,UAAUrC,EAAK3C,OAC5B,2BAzEgB,SAAiBO,EAAgBxB,GAChD,MAAMkG,EAAanG,EAAcC,GAC3BmG,EAAMhE,SAASC,cAAc,OACnC+D,EAAIvD,UAAYsD,EAChB,MAAM/E,EAAQiF,EAASA,UAAC7D,WAAWf,EAAOgB,QAAQ6D,WAAWF,GAE7D,GAAmB,IAAfhF,EAAMqC,KAAY,OAEtB,MAAM8C,KAAEA,EAAIC,GAAEA,GAAO/E,EAAOQ,MAAM2C,UAC5B6B,EAAKhF,EAAOQ,MAAMwE,GAAGC,aAAaH,EAAMC,EAAIpF,GAClDK,EAAOkF,KAAKC,SAASH,EACtB,qEAgIChF,EACArB,EACAH,GAEA,MAAMyB,EAAWC,EAAoBF,EAAQrB,GAC7C,IAAkB,IAAdsB,EAAiB,CACpB,MAAMK,EAASN,EAAOQ,MAAMC,IAAIU,QAAQa,KAClCoD,EAAc1G,EAAqBC,GAAMH,EAI/C,YAHAwB,EAAOqF,SAASC,gBAAgBhF,EAAQ8E,EAAa,CACpDG,iBAAiB,GAGlB,CACD,MAAMjF,EAASC,EAAkBP,EAAQrB,GACnC6G,EA3BP,SAA0BxF,EAAgBxB,GACzC,MAAMkC,EAAYC,SAASC,cAAc,OAEzC,OADAF,EAAUU,UAAY5C,EACfoG,EAASA,UAAC7D,WAAWf,EAAOgB,QAAQyE,MAAM/E,GAAWS,OAC7D,CAuBkBuE,CAAiB1F,EAAQxB,IACpCwG,GAAEA,GAAOhF,EAAOQ,MAKhBmF,EAAqB,SAAPhH,EAAgB,EAAIsB,EACxC+E,EAAGY,YAAYD,EAAarF,EAAQkF,GACpCR,EAAGa,QAAQ,gBAAgB,GAC3B7F,EAAOkF,KAAKC,SAASH,EACtB"}
1
+ {"version":3,"file":"BikEditor.utils.js","sources":["../../../src/editor/BikEditor.utils.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { DOMParser, DOMSerializer } from 'prosemirror-model';\nimport { EditorSnapshot, FormatState } from './BikEditor.types';\n\n// ---------------------------------------------------------------------------\n// HTML normalisation\n// ---------------------------------------------------------------------------\n\n/**\n * Normalise HTML before passing it to TipTap.\n *\n * Empty paragraphs containing only a `<br>` (e.g. `<p><br></p>` or\n * `<p style=\"...\"><br></p>`) are removed entirely. ProseMirror adds a\n * trailing `<br>` to every empty paragraph in the DOM for cursor\n * positioning, so stripping just the `<br>` and leaving `<p></p>`\n * doesn't work — the paragraph still renders with height. Removing\n * the whole element avoids creating a node at all. This is in sync\n * with how Gmail renders HTML.\n */\nexport function normalizeHtml(html: string): string {\n\treturn html\n\t\t.replace(/<p[^>]*>\\s*<br\\s*\\/?>\\s*<\\/p>/gi, '')\n\t\t.replace(/<\\/?span[^>]*>/gi, '');\n}\n\n// ---------------------------------------------------------------------------\n// Inline content insertion\n// ---------------------------------------------------------------------------\n\n/**\n * Insert HTML at the current cursor position, merging the first paragraph\n * inline while preserving the block structure of subsequent paragraphs/lists.\n *\n * Uses `parseSlice` which returns an open-ended Slice — the first block merges\n * at the cursor, middle blocks stay intact, and the last block merges with any\n * text that follows the cursor.\n */\nexport function insertInlineHtml(editor: Editor, html: string): void {\n\tconst normalised = normalizeHtml(html);\n\tconst dom = document.createElement('div');\n\tdom.innerHTML = normalised;\n\tconst slice = DOMParser.fromSchema(editor.schema).parseSlice(dom);\n\n\tif (slice.size === 0) return;\n\n\tconst { from, to } = editor.state.selection;\n\tconst tr = editor.state.tr.replaceRange(from, to, slice);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Section divider HTML\n// ---------------------------------------------------------------------------\n\nexport const SECTION_DIVIDER_HTML = (id: string) =>\n\t`<div data-section-divider=\"${id}\" style=\"display:none;height:0;line-height:0;overflow:hidden;\"></div>`;\n\n/**\n * Build initial HTML for an editor with one or more named sections below the body.\n * Each section is separated by an invisible divider node.\n *\n * @example\n * buildSectionedContent('<p>Body</p>', [\n * { id: 'signature', content: '<p>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- fwd ---</p>' },\n * ])\n */\nexport function buildSectionedContent(\n\tbody: string,\n\tsections: Array<{ id: string; content: string }>,\n): string {\n\tlet html = body;\n\tfor (const s of sections) {\n\t\thtml += SECTION_DIVIDER_HTML(s.id) + s.content;\n\t}\n\treturn html;\n}\n\n// ---------------------------------------------------------------------------\n// Section extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Parse the editor HTML into a Map of sectionId → raw HTML string.\n * The special key `'body'` always holds the content before the first divider.\n * Map iteration order matches document order.\n */\nexport function extractAllSections(editor: Editor): Map<string, string> {\n\treturn extractAllSectionsFromHtml(editor.getHTML());\n}\n\n/**\n * Extract just the body portion (everything before the first section divider)\n * from an HTML string produced by BikEditor. Safe to call on plain HTML too —\n * returns the full string when no dividers are present.\n */\nexport function getBodyHtml(html: string): string {\n\tif (!html) return '';\n\tconst sections = extractAllSectionsFromHtml(html);\n\treturn sections.get('body') ?? html;\n}\n\n/**\n * Extract everything from the first section divider onward (dividers + their\n * content). Returns an empty string when there are no sections.\n */\nexport function getSectionsHtml(html: string): string {\n\tif (!html) return '';\n\tconst body = getBodyHtml(html);\n\treturn html.substring(body.length);\n}\n\nexport function extractAllSectionsFromHtml(html: string): Map<string, string> {\n\tconst sections = new Map<string, string>();\n\tconst dividerRegex =\n\t\t/<div[^>]*data-section-divider=\"([^\"]*)[^>]*>\\s*<\\/div>/g;\n\tconst dividers: Array<{ id: string; index: number; endIndex: number }> = [];\n\n\tlet match: RegExpExecArray | null;\n\twhile ((match = dividerRegex.exec(html)) !== null) {\n\t\tdividers.push({\n\t\t\tid: match[1],\n\t\t\tindex: match.index,\n\t\t\tendIndex: match.index + match[0].length,\n\t\t});\n\t}\n\n\tif (dividers.length === 0) {\n\t\tsections.set('body', html);\n\t\treturn sections;\n\t}\n\n\tsections.set('body', html.slice(0, dividers[0].index));\n\tfor (let i = 0; i < dividers.length; i++) {\n\t\tconst start = dividers[i].endIndex;\n\t\tconst end = i + 1 < dividers.length ? dividers[i + 1].index : html.length;\n\t\tsections.set(dividers[i].id, html.slice(start, end));\n\t}\n\n\treturn sections;\n}\n\n/** Returns BikEditorContent for a single named section (or 'body'). */\nexport function extractSectionContent(\n\teditor: Editor,\n\tid: string,\n): EditorSnapshot {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1)\n\t\treturn { html: '', text: '', isEmpty: true, characterCount: 0 };\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst slice = editor.state.doc.slice(startPos, endPos);\n\tconst container = document.createElement('div');\n\tconst serializer = DOMSerializer.fromSchema(editor.schema);\n\tcontainer.appendChild(serializer.serializeFragment(slice.content));\n\tconst html = container.innerHTML;\n\tconst text = container.textContent ?? '';\n\treturn { html, text, isEmpty: !text.trim(), characterCount: text.length };\n}\n\n/**\n * Parse an HTML string into ProseMirror nodes using the editor's schema.\n */\nfunction parseHtmlToNodes(editor: Editor, html: string) {\n\tconst container = document.createElement('div');\n\tcontainer.innerHTML = html;\n\treturn DOMParser.fromSchema(editor.schema).parse(container).content;\n}\n\n/**\n * Replace the content of a single named section without touching others.\n * Uses a ProseMirror transaction to replace only the target range,\n * preserving undo history and other sections' state.\n * If the section doesn't exist yet, it is appended at the end of the document.\n */\nexport function setSectionContentInEditor(\n\teditor: Editor,\n\tid: string,\n\thtml: string,\n): void {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1) {\n\t\tconst endPos = editor.state.doc.content.size;\n\t\tconst dividerHtml = SECTION_DIVIDER_HTML(id) + html;\n\t\teditor.commands.insertContentAt(endPos, dividerHtml, {\n\t\t\tupdateSelection: false,\n\t\t});\n\t\treturn;\n\t}\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst fragment = parseHtmlToNodes(editor, html);\n\tconst { tr } = editor.state;\n\t// For body, replace from position 0 (before the first paragraph's opening\n\t// boundary) so ProseMirror swaps entire block nodes cleanly. Position 1\n\t// (inside the paragraph) would force ProseMirror to close the open paragraph\n\t// first, creating a ghost empty <p></p>.\n\tconst replaceFrom = id === 'body' ? 0 : startPos;\n\ttr.replaceWith(replaceFrom, endPos, fragment);\n\ttr.setMeta('addToHistory', false);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Convenience shorthands (body = first section)\n// ---------------------------------------------------------------------------\n\n/** Extract BikEditorContent for just the body (before the first divider). */\nexport function extractBodyContent(editor: Editor): EditorSnapshot {\n\treturn extractSectionContent(editor, 'body');\n}\n\n// ---------------------------------------------------------------------------\n// Active formats\n// ---------------------------------------------------------------------------\n\nexport function extractActiveFormats(editor: Editor): FormatState {\n\treturn {\n\t\tbold: editor.isActive('bold'),\n\t\titalic: editor.isActive('italic'),\n\t\tunderline: editor.isActive('underline'),\n\t\tstrike: editor.isActive('strike'),\n\t\tbulletList: editor.isActive('bulletList'),\n\t\torderedList: editor.isActive('orderedList'),\n\t\tblockquote: editor.isActive('blockquote'),\n\t\tcodeBlock: editor.isActive('codeBlock'),\n\t\tlink: (() => {\n\t\t\tif (editor.isActive('link')) {\n\t\t\t\treturn { href: editor.getAttributes('link')['href'] ?? '' };\n\t\t\t}\n\t\t\tconst { $from } = editor.state.selection;\n\t\t\tif ($from.pos > 0) {\n\t\t\t\tconst before = $from.doc.resolve($from.pos);\n\t\t\t\tconst linkMark = before.marks().find((m) => m.type.name === 'link');\n\t\t\t\tif (!linkMark) {\n\t\t\t\t\tconst nodeBefore = $from.nodeBefore;\n\t\t\t\t\tconst markOnPrev = nodeBefore?.marks.find(\n\t\t\t\t\t\t(m) => m.type.name === 'link',\n\t\t\t\t\t);\n\t\t\t\t\tif (markOnPrev) {\n\t\t\t\t\t\treturn { href: markOnPrev.attrs['href'] ?? '' };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn { href: linkMark.attrs['href'] ?? '' };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t})(),\n\t\ttextAlign: editor.isActive({ textAlign: 'center' })\n\t\t\t? 'center'\n\t\t\t: editor.isActive({ textAlign: 'right' })\n\t\t\t? 'right'\n\t\t\t: editor.isActive({ textAlign: 'justify' })\n\t\t\t? 'justify'\n\t\t\t: editor.isActive({ textAlign: 'left' })\n\t\t\t? 'left'\n\t\t\t: null,\n\t\tfontFamily: editor.getAttributes('textStyle')['fontFamily'] ?? null,\n\t\tfontSize: editor.getAttributes('textStyle')['fontSize'] ?? null,\n\t\tcolor: editor.getAttributes('textStyle')['color'] ?? null,\n\t\thighlight: editor.isActive('highlight')\n\t\t\t? editor.getAttributes('highlight')['color'] ?? 'default'\n\t\t\t: null,\n\t\tsuperscript: editor.isActive('superscript'),\n\t\tsubscript: editor.isActive('subscript'),\n\t};\n}\n\nexport function extractContent(editor: Editor): EditorSnapshot {\n\treturn {\n\t\thtml: editor.getHTML(),\n\t\ttext: editor.getText(),\n\t\tisEmpty: editor.isEmpty,\n\t\tcharacterCount:\n\t\t\teditor.storage.characterCount?.characters?.() ?? editor.getText().length,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Section position helpers (used by insertAtSectionStart/End and appendBodyContent)\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the ProseMirror position immediately after a section's opening divider\n * (i.e. the start of the section's own content).\n * For `'body'`, returns 1 (beginning of the document).\n * Returns -1 if the named section's divider is not found.\n */\nexport function findSectionStartPos(editor: Editor, sectionId: string): number {\n\tif (sectionId === 'body') return 1;\n\tlet startPos = -1;\n\teditor.state.doc.descendants((node, pos) => {\n\t\tif (startPos !== -1) return false;\n\t\tif (\n\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t) {\n\t\t\tstartPos = pos + node.nodeSize; // position right after the divider\n\t\t}\n\t});\n\treturn startPos;\n}\n\n/**\n * Returns the ProseMirror position at the end of a named section's content:\n * - For `'body'`: position of the first section divider, or end of document.\n * - For a named section: position of the next divider, or end of document.\n */\nexport function findSectionEndPos(editor: Editor, sectionId: string): number {\n\tconst doc = editor.state.doc;\n\tconst docSize = doc.content.size;\n\n\tif (sectionId === 'body') {\n\t\tlet firstDividerPos = -1;\n\t\tdoc.descendants((node, pos) => {\n\t\t\tif (firstDividerPos !== -1) return false;\n\t\t\tif (node.type.name === 'sectionDivider') {\n\t\t\t\tfirstDividerPos = pos;\n\t\t\t}\n\t\t});\n\t\treturn firstDividerPos !== -1 ? firstDividerPos : docSize;\n\t}\n\n\tlet passedSection = false;\n\tlet nextDividerPos = -1;\n\tdoc.descendants((node, pos) => {\n\t\tif (nextDividerPos !== -1) return false;\n\t\tif (!passedSection) {\n\t\t\tif (\n\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t) {\n\t\t\t\tpassedSection = true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tif (node.type.name === 'sectionDivider') {\n\t\t\tnextDividerPos = pos;\n\t\t}\n\t});\n\treturn nextDividerPos !== -1 ? nextDividerPos : docSize;\n}\n"],"names":["normalizeHtml","html","replace","SECTION_DIVIDER_HTML","id","getBodyHtml","_a","extractAllSectionsFromHtml","get","sections","Map","dividerRegex","dividers","match","exec","push","index","endIndex","length","set","slice","i","start","end","extractSectionContent","editor","startPos","findSectionStartPos","text","isEmpty","characterCount","endPos","findSectionEndPos","state","doc","container","document","createElement","serializer","DOMSerializer","fromSchema","schema","appendChild","serializeFragment","content","innerHTML","textContent","trim","sectionId","descendants","node","pos","type","name","attrs","nodeSize","docSize","size","firstDividerPos","passedSection","nextDividerPos","body","s","bold","isActive","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","href","getAttributes","$from","selection","linkMark","resolve","marks","find","m","_c","nodeBefore","markOnPrev","_b","textAlign","fontFamily","fontSize","color","highlight","_d","superscript","subscript","getHTML","getText","storage","characters","substring","normalised","dom","DOMParser","parseSlice","from","to","tr","replaceRange","view","dispatch","dividerHtml","commands","insertContentAt","updateSelection","fragment","parse","parseHtmlToNodes","replaceFrom","replaceWith","setMeta"],"mappings":"qIAmBM,SAAUA,EAAcC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AHAwB,EAAOqF,SAASC,gBAAgBhF,EAAQ8E,EAAa,CACpDG,iBAAiB,GAGlB,CACD,MAAMjF,EAASC,EAAkBP,EAAQrB,GACnC6G,EA3BP,SAA0BxF,EAAgBxB,GACzC,MAAMkC,EAAYC,SAASC,cAAc,OAEzC,OADAF,EAAUU,UAAY5C,EACfoG,EAASA,UAAC7D,WAAWf,EAAOgB,QAAQyE,MAAM/E,GAAWS,OAC7D,CAuBkBuE,CAAiB1F,EAAQxB,IACpCwG,GAAEA,GAAOhF,EAAOQ,MAKhBmF,EAAqB,SAAPhH,EAAgB,EAAIsB,EACxC+E,EAAGY,YAAYD,EAAarF,EAAQkF,GACpCR,EAAGa,QAAQ,gBAAgB,GAC3B7F,EAAOkF,KAAKC,SAASH,EACtB"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/extension-mention"),n=require("@tiptap/react"),r=require("../suggestionPopup.js"),o=require("./MentionDropdown.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);function a(e){let t=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return()=>{let e,s;return{onStart:a=>{e=new n.ReactRenderer(o.MentionDropdown,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r.createSuggestionPopup(e.element,a.clientRect)},onUpdate:n=>{var r;e.updateProps(Object.assign(Object.assign({},n),{renderItem:t,renderDropdown:i})),(null===(r=n.items)||void 0===r?void 0:r.length)?(s.show(),s.updatePosition(n.clientRect)):s.hide()},onKeyDown:t=>{var n,r;return"Escape"===t.event.key?(s.hide(),!0):null!==(r=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(t))&&void 0!==r&&r},onExit:()=>{s.destroy(),e.destroy()}}}}exports.buildAgentMentionExtension=function(t,n,r,o){return s.default.extend({name:"mentionAgent"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--agent"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"@")},render:a(n,"@",r,o)}})},exports.buildTeamMentionExtension=function(t,n,r,o){return s.default.extend({name:"mentionTeam"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--team"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"#")},render:a(n,"#",r,o)}})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/extension-mention"),n=require("@tiptap/react"),r=require("../suggestionPopup.js"),o=require("./MentionDropdown.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);function a(e){let t=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return()=>{let e,s;return{onStart:a=>{e=new n.ReactRenderer(o.MentionDropdown,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r.createSuggestionPopup(e.element,a.clientRect)},onUpdate:n=>{var r;e.updateProps(Object.assign(Object.assign({},n),{renderItem:t,renderDropdown:i})),(null===(r=n.items)||void 0===r?void 0:r.length)?(s.show(),s.updatePosition(n.clientRect)):s.hide()},onKeyDown:t=>{var n,r;return"Escape"===t.event.key?(s.hide(),!0):null!==(r=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(t))&&void 0!==r&&r},onExit:()=>{s.destroy(),e.destroy()}}}}exports.buildAgentMentionExtension=function(t,n,r,o){return s.default.extend({name:"mentionAgent"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--agent"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",allowSpaces:!0,items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"@")},render:a(n,"@",r,o)}})},exports.buildTeamMentionExtension=function(t,n,r,o){return s.default.extend({name:"mentionTeam"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--team"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",allowSpaces:!0,items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"#")},render:a(n,"#",r,o)}})};
2
2
  //# sourceMappingURL=MentionExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionExtension.js","sources":["../../../../../src/editor/extensions/mention/MentionExtension.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\nimport { ReactRenderer } from '@tiptap/react';\nimport type { ReactNode } from 'react';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { MentionDropdown } from './MentionDropdown';\n\nfunction buildRender(\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\tchar: '@' | '#' = '@',\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn () => {\n\t\tlet component: ReactRenderer;\n\t\tlet popup: SuggestionPopup;\n\n\t\treturn {\n\t\t\tonStart: (props: any) => {\n\t\t\t\tcomponent = new ReactRenderer(MentionDropdown, {\n\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\teditor: props.editor,\n\t\t\t\t});\n\t\t\t\tpopup = createSuggestionPopup(component.element, props.clientRect);\n\t\t\t},\n\t\t\tonUpdate: (props: any) => {\n\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpopup.show();\n\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t},\n\t\t\tonKeyDown: (props: any) => {\n\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t},\n\t\t\tonExit: () => {\n\t\t\t\tpopup.destroy();\n\t\t\t\tcomponent.destroy();\n\t\t\t},\n\t\t};\n\t};\n}\n\nexport function buildAgentMentionExtension(\n\tagentsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionAgent' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--agent' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '@',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tagentsRef.current.filter((a) =>\n\t\t\t\t\ta.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionAgent',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '@');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '@', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n\nexport function buildTeamMentionExtension(\n\tteamsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionTeam' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--team' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '#',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tteamsRef.current.filter((t) =>\n\t\t\t\t\tt.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionTeam',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '#');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '#', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n"],"names":["buildRender","onSelect","renderItem","arguments","length","undefined","renderDropdown","component","popup","onStart","props","ReactRenderer","MentionDropdown","editor","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","items","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy","agentsRef","Mention","extend","name","configure","HTMLAttributes","class","renderText","_ref","options","node","suggestion","char","attrs","renderHTML","_ref2","mergeAttributes","_ref3","query","current","filter","a","label","toLowerCase","includes","command","_ref4","range","chain","focus","deleteRange","insertContent","type","id","run","render","teamsRef","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"gWAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAaA,cAACC,kBAAiB,CAC9CF,qCAAYA,GAAK,CAAER,aAAYI,mBAC/BO,OAAQH,EAAMG,SAEfL,EAAQM,EAAqBA,sBAACP,EAAUQ,QAASL,EAAMM,WAAW,EAEnEC,SAAWP,UACVH,EAAUW,YAAiBC,OAAAC,O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vB0D,OAAQpE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD,oCAEM,SACL+D,EACApE,EACAC,EACAI,GAEA,OAAO4B,EAAAA,QAAQC,OAAO,CAAEC,KAAM,gBAAiBC,UAAU,CACxDC,eAAgB,CAAEC,MAAO,iCACzBC,WAAY8B,IAAA,IAAC5B,QAAEA,EAAOC,KAAEA,GAAM2B,EAAA,MAC7B,GAAG5B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYwB,IAAA,IAAC7B,QAAEA,EAAOC,KAAEA,GAAM4B,EAAA,MAAK,CAClC,OACAtB,EAAeA,gBAACP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNvB,MAAOkD,IAAA,IAACrB,MAAEA,GAA0BqB,EAAA,OACnCH,EAASjB,QAAQC,QAAQoB,GACxBA,EAAElB,MAAMC,cAAcC,SAASN,EAAMK,gBACrC,EACFE,QAASgB,IAAkC,IAAjC7D,OAAEA,EAAM+C,MAAEA,EAAKlD,MAAEA,GAAYgE,EACtC7D,EACEgD,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNnB,MAAO,CAAEoB,GAAIxD,EAAMwD,GAAIX,MAAO7C,EAAM6C,SAEpCY,MACFlE,SAAAA,EAAWS,EAAO,IAAI,EAEvB0D,OAAQpE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
1
+ {"version":3,"file":"MentionExtension.js","sources":["../../../../../src/editor/extensions/mention/MentionExtension.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\nimport { ReactRenderer } from '@tiptap/react';\nimport type { ReactNode } from 'react';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { MentionDropdown } from './MentionDropdown';\n\nfunction buildRender(\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\tchar: '@' | '#' = '@',\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn () => {\n\t\tlet component: ReactRenderer;\n\t\tlet popup: SuggestionPopup;\n\n\t\treturn {\n\t\t\tonStart: (props: any) => {\n\t\t\t\tcomponent = new ReactRenderer(MentionDropdown, {\n\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\teditor: props.editor,\n\t\t\t\t});\n\t\t\t\tpopup = createSuggestionPopup(component.element, props.clientRect);\n\t\t\t},\n\t\t\tonUpdate: (props: any) => {\n\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpopup.show();\n\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t},\n\t\t\tonKeyDown: (props: any) => {\n\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t},\n\t\t\tonExit: () => {\n\t\t\t\tpopup.destroy();\n\t\t\t\tcomponent.destroy();\n\t\t\t},\n\t\t};\n\t};\n}\n\nexport function buildAgentMentionExtension(\n\tagentsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionAgent' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--agent' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '@',\n\t\t\tallowSpaces: true,\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tagentsRef.current.filter((a) =>\n\t\t\t\t\ta.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionAgent',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '@');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '@', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n\nexport function buildTeamMentionExtension(\n\tteamsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionTeam' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--team' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '#',\n\t\t\tallowSpaces: true,\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tteamsRef.current.filter((t) =>\n\t\t\t\t\tt.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionTeam',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '#');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '#', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n"],"names":["buildRender","onSelect","renderItem","arguments","length","undefined","renderDropdown","component","popup","onStart","props","ReactRenderer","MentionDropdown","editor","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","items","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy","agentsRef","Mention","extend","name","configure","HTMLAttributes","class","renderText","_ref","options","node","suggestion","char","attrs","renderHTML","_ref2","mergeAttributes","allowSpaces","_ref3","query","current","filter","a","label","toLowerCase","includes","command","_ref4","range","chain","focus","deleteRange","insertContent","type","id","run","render","teamsRef","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"gWAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAaA,cAACC,kBAAiB,CAC9CF,qCAAYA,GAAK,CAAER,aAAYI,mBAC/BO,OAAQH,EAAMG,SAEfL,EAAQM,EAAqBA,sBAACP,EAAUQ,QAASL,EAAMM,WAAW,EAEnEC,SAAWP,UACVH,EAAUW,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAV,IAAOR,aAAYI,qBAC9B,QAAXe,EAAAX,EAAMY,aAAK,IAAAD,OAAA,EAAAA,EAAEjB,SAIlBI,EAAMe,OACNf,EAAMgB,eAAed,EAAMM,aAJ1BR,EAAMiB,MAI+B,E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O,iCACzBC,WAAY+B,IAAA,IAAC7B,QAAEA,EAAOC,KAAEA,GAAM4B,EAAA,MAC7B,GAAG7B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYyB,IAAA,IAAC9B,QAAEA,EAAOC,KAAEA,GAAM6B,EAAA,MAAK,CAClC,OACAvB,EAAeA,gBAACP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNK,aAAa,EACb5B,MAAOmD,IAAA,IAACrB,MAAEA,GAA0BqB,EAAA,OACnCH,EAASjB,QAAQC,QAAQoB,GACxBA,EAAElB,MAAMC,cAAcC,SAASN,EAAMK,gBACrC,EACFE,QAASgB,IAAkC,IAAjC9D,OAAEA,EAAMgD,MAAEA,EAAKnD,MAAEA,GAAYiE,EACtC9D,EACEiD,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNpB,MAAO,CAAEqB,GAAIzD,EAAMyD,GAAIX,MAAO9C,EAAM8C,SAEpCY,MACFnE,SAAAA,EAAWS,EAAO,IAAI,EAEvB2D,OAAQrE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/pm/model"),a=require("@tiptap/pm/state");const r=e.Extension.create({name:"plainClipboard",addProseMirrorPlugins:()=>[new a.Plugin({props:{handlePaste(e,a){var r,i,l,n;if(null===(i=null===(r=a.clipboardData)||void 0===r?void 0:r.files)||void 0===i?void 0:i.length)return!1;const o=null===(l=a.clipboardData)||void 0===l?void 0:l.getData("text/html"),p=null===(n=a.clipboardData)||void 0===n?void 0:n.getData("text/plain");if(!p||!o)return!1;const d=e.state.schema,s=p.split("\n").map((e=>d.node("paragraph",null,e?[d.text(e)]:[]))),u=new t.Slice(t.Fragment.fromArray(s),1,1);return e.dispatch(e.state.tr.replaceSelection(u)),!0}}})]});exports.PlainClipboardExtension=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/pm/model"),a=require("@tiptap/pm/state");const i=e.Extension.create({name:"plainClipboard",addProseMirrorPlugins:()=>[new a.Plugin({props:{handlePaste(e,a){var i,r,l,n;if(null===(r=null===(i=a.clipboardData)||void 0===i?void 0:i.files)||void 0===r?void 0:r.length)return!1;const o=null===(l=a.clipboardData)||void 0===l?void 0:l.getData("text/html"),d=null===(n=a.clipboardData)||void 0===n?void 0:n.getData("text/plain");if(!d||!o)return!1;if(o.includes("data-pm-slice"))return!1;const p=e.state.schema,s=d.split("\n").map((e=>p.node("paragraph",null,e?[p.text(e)]:[]))),u=new t.Slice(t.Fragment.fromArray(s),1,1);return e.dispatch(e.state.tr.replaceSelection(u)),!0}}})]});exports.PlainClipboardExtension=i;
2
2
  //# sourceMappingURL=PlainClipboardExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Fragment, Slice } from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nexport const PlainClipboardExtension = Extension.create({\n\tname: 'plainClipboard',\n\taddProseMirrorPlugins() {\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tprops: {\n\t\t\t\t\thandlePaste(_view, event) {\n\t\t\t\t\t\tif (event.clipboardData?.files?.length) return false; // let ImagePaste handle\n\t\t\t\t\t\tconst html = event.clipboardData?.getData('text/html');\n\t\t\t\t\t\tconst text = event.clipboardData?.getData('text/plain');\n\t\t\t\t\t\tif (!text || !html) return false;\n\n\t\t\t\t\t\tconst schema = _view.state.schema;\n\t\t\t\t\t\t// Split on each newline so that multi-paragraph pastes produce\n\t\t\t\t\t\t// separate paragraph nodes — matching the behaviour of pressing\n\t\t\t\t\t\t// Enter between lines. Using schema.text() collapses all newlines\n\t\t\t\t\t\t// because ProseMirror text nodes cannot contain '\\n'.\n\t\t\t\t\t\tconst paragraphs = text\n\t\t\t\t\t\t\t.split('\\n')\n\t\t\t\t\t\t\t.map((line) =>\n\t\t\t\t\t\t\t\tschema.node('paragraph', null, line ? [schema.text(line)] : []),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tconst slice = new Slice(Fragment.fromArray(paragraphs), 1, 1);\n\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(slice));\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["PlainClipboardExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","text","_d","schema","state","paragraphs","split","map","line","node","slice","Slice","Fragment","fromArray","dispatch","tr","replaceSelection"],"mappings":"wMAIaA,EAA0BC,EAASA,UAACC,OAAO,CACvDC,KAAM,iBACNC,sBAAqBA,IACb,CACN,IAAIC,EAAAA,OAAO,CACVC,MAAO,CACNC,YAAYC,EAAOC,eAClB,WAAIC,EAAqB,UAArBD,EAAME,qBAAe,IAAAC,OAAA,EAAAA,EAAAC,4BAAOC,OAAQ,OAAO,EAC/C,MAAMC,EAA0B,QAAnBC,EAAAP,EAAME,qBAAa,IAAAK,OAAA,EAAAA,EAAEC,QAAQ,aACpCC,EAA0B,QAAnBC,EAAAV,EAAME,qBAAa,IAAAQ,OAAA,EAAAA,EAAEF,QAAQ,cAC1C,IAAKC,IAASH,EAAM,OAAO,EAE3B,MAAMK,EAASZ,EAAMa,MAAMD,OAKrBE,EAAaJ,EACjBK,MAAM,MACNC,KAAKC,GACLL,EAAOM,KAAK,YAAa,KAAMD,EAAO,CAACL,EAAOF,KAAKO,IAAS,MAExDE,EAAQ,IAAIC,EAAAA,MAAMC,EAAQA,SAACC,UAAUR,GAAa,EAAG,GAE3D,OADAd,EAAMuB,SAASvB,EAAMa,MAAMW,GAAGC,iBAAiBN,KACxC,CACR"}
1
+ {"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Fragment, Slice } from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nexport const PlainClipboardExtension = Extension.create({\n\tname: 'plainClipboard',\n\taddProseMirrorPlugins() {\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tprops: {\n\t\t\t\t\thandlePaste(_view, event) {\n\t\t\t\t\t\tif (event.clipboardData?.files?.length) return false; // let ImagePaste handle\n\t\t\t\t\t\tconst html = event.clipboardData?.getData('text/html');\n\t\t\t\t\t\tconst text = event.clipboardData?.getData('text/plain');\n\t\t\t\t\t\tif (!text || !html) return false;\n\n\t\t\t\t\t\t// ProseMirror stamps its own clipboard with data-pm-slice.\n\t\t\t\t\t\t// Let ProseMirror handle its own format natively — it round-trips perfectly.\n\t\t\t\t\t\tif (html.includes('data-pm-slice')) return false;\n\n\t\t\t\t\t\tconst schema = _view.state.schema;\n\t\t\t\t\t\t// Split on each newline so that multi-paragraph pastes produce\n\t\t\t\t\t\t// separate paragraph nodes — matching the behaviour of pressing\n\t\t\t\t\t\t// Enter between lines. Using schema.text() collapses all newlines\n\t\t\t\t\t\t// because ProseMirror text nodes cannot contain '\\n'.\n\t\t\t\t\t\tconst paragraphs = text\n\t\t\t\t\t\t\t.split('\\n')\n\t\t\t\t\t\t\t.map((line) =>\n\t\t\t\t\t\t\t\tschema.node('paragraph', null, line ? [schema.text(line)] : []),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tconst slice = new Slice(Fragment.fromArray(paragraphs), 1, 1);\n\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(slice));\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["PlainClipboardExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","text","_d","includes","schema","state","paragraphs","split","map","line","node","slice","Slice","Fragment","fromArray","dispatch","tr","replaceSelection"],"mappings":"wMAIaA,EAA0BC,EAASA,UAACC,OAAO,CACvDC,KAAM,iBACNC,sBAAqBA,IACb,CACN,IAAIC,EAAAA,OAAO,CACVC,MAAO,CACNC,YAAYC,EAAOC,eAClB,WAAIC,EAAqB,UAArBD,EAAME,qBAAe,IAAAC,OAAA,EAAAA,EAAAC,4BAAOC,OAAQ,OAAO,EAC/C,MAAMC,EAA0B,QAAnBC,EAAAP,EAAME,qBAAa,IAAAK,OAAA,EAAAA,EAAEC,QAAQ,aACpCC,EAA0B,QAAnBC,EAAAV,EAAME,qBAAa,IAAAQ,OAAA,EAAAA,EAAEF,QAAQ,cAC1C,IAAKC,IAASH,EAAM,OAAO,EAI3B,GAAIA,EAAKK,SAAS,iBAAkB,OAAO,EAE3C,MAAMC,EAASb,EAAMc,MAAMD,OAKrBE,EAAaL,EACjBM,MAAM,MACNC,KAAKC,GACLL,EAAOM,KAAK,YAAa,KAAMD,EAAO,CAACL,EAAOH,KAAKQ,IAAS,MAExDE,EAAQ,IAAIC,EAAAA,MAAMC,EAAQA,SAACC,UAAUR,GAAa,EAAG,GAE3D,OADAf,EAAMwB,SAASxB,EAAMc,MAAMW,GAAGC,iBAAiBN,KACxC,CACR"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),r=require("@tiptap/react"),t=require("@tiptap/suggestion"),n=require("../suggestionPopup.js"),o=require("./SlashCommandMenu.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);exports.buildSlashCommandExtension=function(t,i,d,a){return e.Extension.create({name:"slashCommand",addProseMirrorPlugins(){return[s.default({editor:this.editor,char:"/",items:e=>{let{query:r}=e;return t.current.filter((e=>e.label.toLowerCase().includes(r.toLowerCase()))).slice(0,20)},command:e=>{let{editor:r,range:t,props:n}=e;r.chain().focus().deleteRange(t).run(),null==i||i(n)},render:()=>{let e,t;return{onStart:i=>{e=new r.ReactRenderer(o.SlashCommandMenu,{props:Object.assign(Object.assign({},i),{renderItem:d,renderDropdown:a}),editor:i.editor}),t=n.createSuggestionPopup(e.element,i.clientRect)},onUpdate:r=>{var n;e.updateProps(Object.assign(Object.assign({},r),{renderItem:d,renderDropdown:a})),(null===(n=r.items)||void 0===n?void 0:n.length)?(t.show(),t.updatePosition(r.clientRect)):t.hide()},onKeyDown:r=>{var n,o;return"Escape"===r.event.key?(t.hide(),!0):null!==(o=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(r))&&void 0!==o&&o},onExit:()=>{t.destroy(),e.destroy()}}}})]}})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),r=require("@tiptap/react"),t=require("@tiptap/suggestion"),n=require("../suggestionPopup.js"),o=require("./SlashCommandMenu.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);exports.buildSlashCommandExtension=function(t,i,a,d){return e.Extension.create({name:"slashCommand",addProseMirrorPlugins(){return[s.default({editor:this.editor,char:"/",allowSpaces:!0,items:e=>{let{query:r}=e;return t.current.filter((e=>e.label.toLowerCase().includes(r.toLowerCase()))).slice(0,20)},command:e=>{let{editor:r,range:t,props:n}=e;r.chain().focus().deleteRange(t).run(),null==i||i(n)},render:()=>{let e,t;return{onStart:i=>{e=new r.ReactRenderer(o.SlashCommandMenu,{props:Object.assign(Object.assign({},i),{renderItem:a,renderDropdown:d}),editor:i.editor}),t=n.createSuggestionPopup(e.element,i.clientRect)},onUpdate:r=>{var n;e.updateProps(Object.assign(Object.assign({},r),{renderItem:a,renderDropdown:d})),(null===(n=r.items)||void 0===n?void 0:n.length)?(t.show(),t.updatePosition(r.clientRect)):t.hide()},onKeyDown:r=>{var n,o;return"Escape"===r.event.key?(t.hide(),!0):null!==(o=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(r))&&void 0!==o&&o},onExit:()=>{t.destroy(),e.destroy()}}}})]}})};
2
2
  //# sourceMappingURL=SlashCommandExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SlashCommandExtension.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { ReactRenderer } from '@tiptap/react';\nimport Suggestion from '@tiptap/suggestion';\nimport type { ReactNode } from 'react';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { SlashCommandMenu } from './SlashCommandMenu';\n\nexport function buildSlashCommandExtension(\n\tcommandsRef: { current: SlashCommandItem[] },\n\tonSelect?: (command: SlashCommandItem) => void,\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode,\n) {\n\treturn Extension.create({\n\t\tname: 'slashCommand',\n\t\taddProseMirrorPlugins() {\n\t\t\treturn [\n\t\t\t\tSuggestion({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tchar: '/',\n\t\t\t\t\titems: ({ query }: any) =>\n\t\t\t\t\t\tcommandsRef.current\n\t\t\t\t\t\t\t.filter((c) =>\n\t\t\t\t\t\t\t\tc.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.slice(0, 20),\n\t\t\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\t\t\teditor.chain().focus().deleteRange(range).run();\n\t\t\t\t\t\tonSelect?.(props);\n\t\t\t\t\t},\n\t\t\t\t\trender: () => {\n\t\t\t\t\t\tlet component: ReactRenderer;\n\t\t\t\t\t\tlet popup: SuggestionPopup;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tonStart: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent = new ReactRenderer(SlashCommandMenu, {\n\t\t\t\t\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\t\t\t\t\teditor: props.editor,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpopup = createSuggestionPopup(\n\t\t\t\t\t\t\t\t\tcomponent.element,\n\t\t\t\t\t\t\t\t\tprops.clientRect,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonUpdate: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\t\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpopup.show();\n\t\t\t\t\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonKeyDown: (props: any) => {\n\t\t\t\t\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => {\n\t\t\t\t\t\t\t\tpopup.destroy();\n\t\t\t\t\t\t\t\tcomponent.destroy();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t];\n\t\t},\n\t});\n}\n"],"names":["commandsRef","onSelect","renderItem","renderDropdown","Extension","create","name","addProseMirrorPlugins","Suggestion","editor","this","char","items","_ref","query","current","filter","c","label","toLowerCase","includes","slice","command","_ref2","range","props","chain","focus","deleteRange","run","render","component","popup","onStart","ReactRenderer","SlashCommandMenu","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","length","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy"],"mappings":"6XAcM,SACLA,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAAA,UAAUC,OAAO,CACvBC,KAAM,eACNC,wBACC,MAAO,CACNC,EAAAA,QAAW,CACVC,OAAQC,KAAKD,OACbE,KAAM,IACNC,MAAOC,IAAA,IAACC,MAAEA,GAAYD,EAAA,OACrBb,EAAYe,QACVC,QAAQC,GACRA,EAAEC,MAAMC,cAAcC,SAASN,EAAMK,iBAErCE,MAAM,EAAG,GAAG,EACfC,QAASC,IAAkC,IAAjCd,OAAEA,EAAMe,MAAEA,EAAKC,MAAEA,GAAYF,EACtCd,EAAOiB,QAAQC,QAAQC,YAAYJ,GAAOK,MAC1C5B,SAAAA,EAAWwB,EAAM,EAElBK,OAAQA,KACP,IAAIC,EACAC,EAEJ,MAAO,CACNC,QAAUR,IACTM,EAAY,IAAIG,EAAaA,cAACC,mBAAkB,CAC/CV,qCAAYA,GAAK,CAAEvB,aAAYC,mBAC/BM,OAAQgB,EAAMhB,SAEfuB,EAAQI,EAAqBA,sBAC5BL,EAAUM,QACVZ,EAAMa,WACN,EAEFC,SAAWd,UACVM,EAAUS,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAjB,IAAOvB,aAAYC,qBAC9B,QAAXwC,EAAAlB,EAAMb,aAAK,IAAA+B,OAAA,EAAAA,EAAEC,SAIlBZ,EAAMa,OACNb,EAAMc,eAAerB,EAAMa,aAJ1BN,EAAMe,MAI+B,EAEvCC,UAAYvB,YACX,MAAwB,WAApBA,EAAMwB,MAAMC,KACflB,EAAMe,QACC,GAE2C,QAA5CI,EAAsB,QAAtBR,EAACZ,EAAUqB,WAAW,IAAAT,OAAA,EAAAA,EAAEK,UAAUvB,UAAU,IAAA0B,GAAAA,CAAK,EAEzDE,OAAQA,KACPrB,EAAMsB,UACNvB,EAAUuB,SAAS,EAEpB,IAIL,GAEF"}
1
+ {"version":3,"file":"SlashCommandExtension.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { ReactRenderer } from '@tiptap/react';\nimport Suggestion from '@tiptap/suggestion';\nimport type { ReactNode } from 'react';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { SlashCommandMenu } from './SlashCommandMenu';\n\nexport function buildSlashCommandExtension(\n\tcommandsRef: { current: SlashCommandItem[] },\n\tonSelect?: (command: SlashCommandItem) => void,\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode,\n) {\n\treturn Extension.create({\n\t\tname: 'slashCommand',\n\t\taddProseMirrorPlugins() {\n\t\t\treturn [\n\t\t\t\tSuggestion({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tchar: '/',\n\t\t\t\t\tallowSpaces: true,\n\t\t\t\t\titems: ({ query }: any) =>\n\t\t\t\t\t\tcommandsRef.current\n\t\t\t\t\t\t\t.filter((c) =>\n\t\t\t\t\t\t\t\tc.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.slice(0, 20),\n\t\t\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\t\t\teditor.chain().focus().deleteRange(range).run();\n\t\t\t\t\t\tonSelect?.(props);\n\t\t\t\t\t},\n\t\t\t\t\trender: () => {\n\t\t\t\t\t\tlet component: ReactRenderer;\n\t\t\t\t\t\tlet popup: SuggestionPopup;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tonStart: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent = new ReactRenderer(SlashCommandMenu, {\n\t\t\t\t\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\t\t\t\t\teditor: props.editor,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpopup = createSuggestionPopup(\n\t\t\t\t\t\t\t\t\tcomponent.element,\n\t\t\t\t\t\t\t\t\tprops.clientRect,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonUpdate: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\t\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpopup.show();\n\t\t\t\t\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonKeyDown: (props: any) => {\n\t\t\t\t\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => {\n\t\t\t\t\t\t\t\tpopup.destroy();\n\t\t\t\t\t\t\t\tcomponent.destroy();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t];\n\t\t},\n\t});\n}\n"],"names":["commandsRef","onSelect","renderItem","renderDropdown","Extension","create","name","addProseMirrorPlugins","Suggestion","editor","this","char","allowSpaces","items","_ref","query","current","filter","c","label","toLowerCase","includes","slice","command","_ref2","range","props","chain","focus","deleteRange","run","render","component","popup","onStart","ReactRenderer","SlashCommandMenu","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","length","show","updatePosition","hide","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";function e(r){var n,t;if(r.nodeType===Node.TEXT_NODE)return null!==(n=r.textContent)&&void 0!==n?n:"";if(r.nodeType!==Node.ELEMENT_NODE)return"";const a=r,c=a.tagName.toLowerCase(),s=function(r){return Array.from(r.childNodes).map(e).join("")}(a);switch(c){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":return s?`_${s}_`:"";case"s":case"del":case"strike":return s?`~${s}~`:"";case"code":return s?`\`${s}\``:"";case"pre":return s?`\`\`\`${s}\`\`\``:"";case"a":return(null!==(t=a.getAttribute("href"))&&void 0!==t?t:"")||s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"ul":case"ol":case"body":default:return s;case"li":return`• ${s.trimEnd()}\n`;case"blockquote":return s.split("\n").map((e=>e?`> ${e}`:"")).join("\n")+"\n"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toWhatsAppText=function(r){if(!r)return"";if("undefined"!=typeof document){return e((new DOMParser).parseFromString(r,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"_$1_").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"_$1_").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~$1~").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"~$1~").replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`").replace(/<a[^>]*href="([^"]*)"[^>]*>[\s\S]*?<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/\n{3,}/g,"\n\n").trim()}(r)};
1
+ "use strict";function e(r){var n;if(r.nodeType===Node.TEXT_NODE)return null!==(n=r.textContent)&&void 0!==n?n:"";if(r.nodeType!==Node.ELEMENT_NODE)return"";const a=r,c=a.tagName.toLowerCase(),t=function(r){return Array.from(r.childNodes).map(e).join("")}(a);switch(c){case"strong":case"b":return t?`*${t}*`:"";case"em":case"i":return t?`_${t}_`:"";case"s":case"del":case"strike":return t?`~${t}~`:"";case"code":return t?`\`${t}\``:"";case"pre":return t?`\`\`\`${t}\`\`\``:"";case"a":case"ul":case"ol":case"body":default:return t;case"br":return"\n";case"p":case"div":return t?`${t}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t?`*${t}*\n`:"\n";case"li":return`• ${t.trimEnd()}\n`;case"blockquote":return t.split("\n").map((e=>e?`> ${e}`:"")).join("\n")+"\n"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toWhatsAppText=function(r){if(!r)return"";if("undefined"!=typeof document){return e((new DOMParser).parseFromString(r,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"_$1_").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"_$1_").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~$1~").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"~$1~").replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`").replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&nbsp;/g," ").replace(/\n{3,}/g,"\n\n").trim()}(r)};
2
2
  //# sourceMappingURL=toWhatsAppText.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"toWhatsAppText.js","sources":["../../../../src/editor/serializers/toWhatsAppText.ts"],"sourcesContent":["/**\n * Converts TipTap HTML to WhatsApp-flavoured markdown text.\n *\n * WhatsApp formatting:\n * *bold* _italic_ ~strikethrough~ ```monospace```\n *\n * Links: WhatsApp does not support custom display text for hyperlinks.\n * <a href=\"https://…\">Visit us</a> → https://… (href wins, display text dropped)\n *\n * @example\n * const { html } = ref.current?.getContent();\n * const waText = toWhatsAppText(html);\n * sendWhatsApp({ text: waText });\n */\nexport function toWhatsAppText(html: string): string {\n\tif (!html) return '';\n\n\tif (typeof document !== 'undefined') {\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html');\n\t\treturn serializeNode(doc.body)\n\t\t\t.replace(/\\n{3,}/g, '\\n\\n')\n\t\t\t.trim();\n\t}\n\n\t// SSR / Node.js fallback — handles simple non-nested markup\n\treturn ssrFallback(html);\n}\n\n// ---------------------------------------------------------------------------\n// Browser path — DOM-based, handles nested marks correctly\n// ---------------------------------------------------------------------------\n\nfunction serializeNode(node: Node): string {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent ?? '';\n\t}\n\tif (node.nodeType !== Node.ELEMENT_NODE) return '';\n\n\tconst el = node as Element;\n\tconst tag = el.tagName.toLowerCase();\n\tconst inner = serializeChildren(el);\n\n\tswitch (tag) {\n\t\tcase 'strong':\n\t\tcase 'b':\n\t\t\treturn inner ? `*${inner}*` : '';\n\n\t\tcase 'em':\n\t\tcase 'i':\n\t\t\treturn inner ? `_${inner}_` : '';\n\n\t\tcase 's':\n\t\tcase 'del':\n\t\tcase 'strike':\n\t\t\treturn inner ? `~${inner}~` : '';\n\n\t\tcase 'code':\n\t\t\treturn inner ? `\\`${inner}\\`` : '';\n\n\t\tcase 'pre':\n\t\t\treturn inner ? `\\`\\`\\`${inner}\\`\\`\\`` : '';\n\n\t\tcase 'a': {\n\t\t\t// WhatsApp doesn't support custom link text — just emit the URL.\n\t\t\tconst href = el.getAttribute('href') ?? '';\n\t\t\treturn href || inner;\n\t\t}\n\n\t\tcase 'br':\n\t\t\treturn '\\n';\n\n\t\tcase 'p':\n\t\tcase 'div':\n\t\t\treturn inner ? `${inner}\\n` : '\\n';\n\n\t\tcase 'h1':\n\t\tcase 'h2':\n\t\tcase 'h3':\n\t\tcase 'h4':\n\t\tcase 'h5':\n\t\tcase 'h6':\n\t\t\treturn inner ? `*${inner}*\\n` : '\\n';\n\n\t\tcase 'ul':\n\t\tcase 'ol':\n\t\t\treturn inner;\n\n\t\tcase 'li':\n\t\t\treturn `• ${inner.trimEnd()}\\n`;\n\n\t\tcase 'blockquote':\n\t\t\treturn (\n\t\t\t\tinner\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map((l) => (l ? `> ${l}` : ''))\n\t\t\t\t\t.join('\\n') + '\\n'\n\t\t\t);\n\n\t\tcase 'body':\n\t\tdefault:\n\t\t\treturn inner;\n\t}\n}\n\nfunction serializeChildren(el: Element): string {\n\treturn Array.from(el.childNodes).map(serializeNode).join('');\n}\n\n// ---------------------------------------------------------------------------\n// SSR fallback — regex-based, best-effort for simple markup\n// ---------------------------------------------------------------------------\n\nfunction ssrFallback(html: string): string {\n\treturn html\n\t\t.replace(/<strong[^>]*>([\\s\\S]*?)<\\/strong>/gi, '*$1*')\n\t\t.replace(/<b[^>]*>([\\s\\S]*?)<\\/b>/gi, '*$1*')\n\t\t.replace(/<em[^>]*>([\\s\\S]*?)<\\/em>/gi, '_$1_')\n\t\t.replace(/<i[^>]*>([\\s\\S]*?)<\\/i>/gi, '_$1_')\n\t\t.replace(/<s[^>]*>([\\s\\S]*?)<\\/s>/gi, '~$1~')\n\t\t.replace(/<del[^>]*>([\\s\\S]*?)<\\/del>/gi, '~$1~')\n\t\t.replace(/<code[^>]*>([\\s\\S]*?)<\\/code>/gi, '`$1`')\n\t\t.replace(/<a[^>]*href=\"([^\"]*)\"[^>]*>[\\s\\S]*?<\\/a>/gi, '$1')\n\t\t.replace(/<br\\s*\\/?>/gi, '\\n')\n\t\t.replace(/<\\/p>/gi, '\\n')\n\t\t.replace(/<\\/div>/gi, '\\n')\n\t\t.replace(/<\\/h[1-6]>/gi, '\\n')\n\t\t.replace(/<li[^>]*>/gi, '• ')\n\t\t.replace(/<\\/li>/gi, '\\n')\n\t\t.replace(/<[^>]+>/g, '')\n\t\t.replace(/&amp;/g, '&')\n\t\t.replace(/&lt;/g, '<')\n\t\t.replace(/&gt;/g, '>')\n\t\t.replace(/&nbsp;/g, ' ')\n\t\t.replace(/\\n{3,}/g, '\\n\\n')\n\t\t.trim();\n}\n"],"names":["serializeNode","node","nodeType","Node","TEXT_NODE","textContent","_a","ELEMENT_NODE","el","tag","tagName","toLowerCase","inner","Array","from","childNodes","map","join","serializeChildren","_b","getAttribute","trimEnd","split","l","html","document","DOMParser","parseFromString","body","replace","trim","ssrFallback"],"mappings":"aAgCA,SAASA,EAAcC,WACtB,GAAIA,EAAKC,WAAaC,KAAKC,UAC1B,OAAuB,UAAhBH,EAAKI,mBAAW,IAAAC,EAAAA,EAAI,GAE5B,GAAIL,EAAKC,WAAaC,KAAKI,aAAc,MAAO,GAEhD,MAAMC,EAAKP,EACLQ,EAAMD,EAAGE,QAAQC,cACjBC,EAgEP,SAA2BJ,GAC1B,OAAOK,MAAMC,KAAKN,EAAGO,YAAYC,IAAIhB,GAAeiB,KAAK,GAC1D,CAlEeC,CAAkBV,GAEhC,OAAQC,GACP,IAAK,SACL,IAAK,IACJ,OAAOG,EAAQ,IAAIA,KAAW,GAE/B,IAAK,KACL,IAAK,IACJ,OAAOA,EAAQ,IAAIA,KAAW,GAE/B,IAAK,IACL,IAAK,MACL,IAAK,SACJ,OAAOA,EAAQ,IAAIA,KAAW,GAE/B,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toWhatsAppText.js","sources":["../../../../src/editor/serializers/toWhatsAppText.ts"],"sourcesContent":["/**\n * Converts TipTap HTML to WhatsApp-flavoured markdown text.\n *\n * WhatsApp formatting:\n * *bold* _italic_ ~strikethrough~ ```monospace```\n *\n * Links: WhatsApp does not support hyperlinks.\n * <a href=\"https://…\">Visit us</a> → Visit us (display text kept, href dropped)\n *\n * @example\n * const { html } = ref.current?.getContent();\n * const waText = toWhatsAppText(html);\n * sendWhatsApp({ text: waText });\n */\nexport function toWhatsAppText(html: string): string {\n\tif (!html) return '';\n\n\tif (typeof document !== 'undefined') {\n\t\tconst doc = new DOMParser().parseFromString(html, 'text/html');\n\t\treturn serializeNode(doc.body)\n\t\t\t.replace(/\\n{3,}/g, '\\n\\n')\n\t\t\t.trim();\n\t}\n\n\t// SSR / Node.js fallback — handles simple non-nested markup\n\treturn ssrFallback(html);\n}\n\n// ---------------------------------------------------------------------------\n// Browser path — DOM-based, handles nested marks correctly\n// ---------------------------------------------------------------------------\n\nfunction serializeNode(node: Node): string {\n\tif (node.nodeType === Node.TEXT_NODE) {\n\t\treturn node.textContent ?? '';\n\t}\n\tif (node.nodeType !== Node.ELEMENT_NODE) return '';\n\n\tconst el = node as Element;\n\tconst tag = el.tagName.toLowerCase();\n\tconst inner = serializeChildren(el);\n\n\tswitch (tag) {\n\t\tcase 'strong':\n\t\tcase 'b':\n\t\t\treturn inner ? `*${inner}*` : '';\n\n\t\tcase 'em':\n\t\tcase 'i':\n\t\t\treturn inner ? `_${inner}_` : '';\n\n\t\tcase 's':\n\t\tcase 'del':\n\t\tcase 'strike':\n\t\t\treturn inner ? `~${inner}~` : '';\n\n\t\tcase 'code':\n\t\t\treturn inner ? `\\`${inner}\\`` : '';\n\n\t\tcase 'pre':\n\t\t\treturn inner ? `\\`\\`\\`${inner}\\`\\`\\`` : '';\n\n\t\tcase 'a':\n\t\t\treturn inner;\n\n\t\tcase 'br':\n\t\t\treturn '\\n';\n\n\t\tcase 'p':\n\t\tcase 'div':\n\t\t\treturn inner ? `${inner}\\n` : '\\n';\n\n\t\tcase 'h1':\n\t\tcase 'h2':\n\t\tcase 'h3':\n\t\tcase 'h4':\n\t\tcase 'h5':\n\t\tcase 'h6':\n\t\t\treturn inner ? `*${inner}*\\n` : '\\n';\n\n\t\tcase 'ul':\n\t\tcase 'ol':\n\t\t\treturn inner;\n\n\t\tcase 'li':\n\t\t\treturn `• ${inner.trimEnd()}\\n`;\n\n\t\tcase 'blockquote':\n\t\t\treturn (\n\t\t\t\tinner\n\t\t\t\t\t.split('\\n')\n\t\t\t\t\t.map((l) => (l ? `> ${l}` : ''))\n\t\t\t\t\t.join('\\n') + '\\n'\n\t\t\t);\n\n\t\tcase 'body':\n\t\tdefault:\n\t\t\treturn inner;\n\t}\n}\n\nfunction serializeChildren(el: Element): string {\n\treturn Array.from(el.childNodes).map(serializeNode).join('');\n}\n\n// ---------------------------------------------------------------------------\n// SSR fallback — regex-based, best-effort for simple markup\n// ---------------------------------------------------------------------------\n\nfunction ssrFallback(html: string): string {\n\treturn html\n\t\t.replace(/<strong[^>]*>([\\s\\S]*?)<\\/strong>/gi, '*$1*')\n\t\t.replace(/<b[^>]*>([\\s\\S]*?)<\\/b>/gi, '*$1*')\n\t\t.replace(/<em[^>]*>([\\s\\S]*?)<\\/em>/gi, '_$1_')\n\t\t.replace(/<i[^>]*>([\\s\\S]*?)<\\/i>/gi, '_$1_')\n\t\t.replace(/<s[^>]*>([\\s\\S]*?)<\\/s>/gi, '~$1~')\n\t\t.replace(/<del[^>]*>([\\s\\S]*?)<\\/del>/gi, '~$1~')\n\t\t.replace(/<code[^>]*>([\\s\\S]*?)<\\/code>/gi, '`$1`')\n\t\t.replace(/<a[^>]*>([\\s\\S]*?)<\\/a>/gi, '$1')\n\t\t.replace(/<br\\s*\\/?>/gi, '\\n')\n\t\t.replace(/<\\/p>/gi, '\\n')\n\t\t.replace(/<\\/div>/gi, '\\n')\n\t\t.replace(/<\\/h[1-6]>/gi, '\\n')\n\t\t.replace(/<li[^>]*>/gi, '• ')\n\t\t.replace(/<\\/li>/gi, '\\n')\n\t\t.replace(/<[^>]+>/g, '')\n\t\t.replace(/&amp;/g, '&')\n\t\t.replace(/&lt;/g, '<')\n\t\t.replace(/&gt;/g, '>')\n\t\t.replace(/&nbsp;/g, ' ')\n\t\t.replace(/\\n{3,}/g, '\\n\\n')\n\t\t.trim();\n}\n"],"names":["serializeNode","node","nodeType","Node","TEXT_NODE","textContent","_a","ELEMENT_NODE","el","tag","tagName","toLowerCase","inner","Array","from","childNodes","map","join","serializeChildren","trimEnd","split","l","html","document","DOMParser","parseFromString","body","replace","trim","ssrFallback"],"mappings":"aAgCA,SAASA,EAAcC,SACtB,GAAIA,EAAKC,WAAaC,KAAKC,UAC1B,OAAuB,UAAhBH,EAAKI,mBAAW,IAAAC,EAAAA,EAAI,GAE5B,GAAIL,EAAKC,WAAaC,KAAKI,aAAc,MAAO,GAEhD,MAAMC,EAAKP,EACLQ,EAAMD,EAAGE,QAAQC,cACjBC,EA6DP,SAA2BJ,GAC1B,OAAOK,MAAMC,KAAKN,EAAGO,YAAYC,IAAIhB,GAAeiB,KAAK,GAC1D,CA/DeC,CAAkBV,GAEhC,OAAQC,GACP,IAAK,SACL,IAAK,IACJ,OAAOG,EAAQ,IAAIA,KAAW,GAE/B,IAAK,KACL,IAAK,IACJ,OAAOA,EAAQ,IAAIA,KAAW,GAE/B,IAAK,IACL,IAAK,MACL,IAAK,SACJ,OAAOA,EAAQ,IAAIA,KAAW,GAE/B,IAAK,OACJ,OAAOA,EAAQ,KAAKA,MAAY,GAEjC,IAAK,MACJ,OAAOA,EAAQ,SAASA,UAAgB,GAEzC,IAAK,IAkBL,IAAK,KACL,IAAK,KAcL,IAAK,OACL,QACC,OAAOA,EAhCR,IAAK,KACJ,MAAO,KAER,IAAK,IACL,IAAK,MACJ,OAAOA,EAAQ,GAAGA,MAAY,KAE/B,IAAK,KACL,IAAK,KACL,IAAK,KACL,IAAK,KACL,IAAK,KACL,IAAK,KACJ,OAAOA,EAAQ,IAAIA,OAAa,KAMjC,IAAK,KACJ,WAAYA,EAAMO,cAEnB,IAAK,aACJ,OACCP,EACEQ,MAAM,MACNJ,KAAKK,GAAOA,EAAI,KAAKA,IAAM,KAC3BJ,KAAK,MAAQ,KAOnB,+EArFM,SAAyBK,GAC9B,IAAKA,EAAM,MAAO,GAElB,GAAwB,oBAAbC,SAA0B,CAEpC,OAAOvB,GADK,IAAIwB,WAAYC,gBAAgBH,EAAM,aACzBI,MACvBC,QAAQ,UAAW,QACnBC,MACF,CAGD,OAoFD,SAAqBN,GACpB,OAAOA,EACLK,QAAQ,sCAAuC,QAC/CA,QAAQ,4BAA6B,QACrCA,QAAQ,8BAA+B,QACvCA,QAAQ,4BAA6B,QACrCA,QAAQ,4BAA6B,QACrCA,QAAQ,gCAAiC,QACzCA,QAAQ,kCAAmC,QAC3CA,QAAQ,4BAA6B,MACrCA,QAAQ,eAAgB,MACxBA,QAAQ,UAAW,MACnBA,QAAQ,YAAa,MACrBA,QAAQ,eAAgB,MACxBA,QAAQ,cAAe,MACvBA,QAAQ,WAAY,MACpBA,QAAQ,WAAY,IACpBA,QAAQ,SAAU,KAClBA,QAAQ,QAAS,KACjBA,QAAQ,QAAS,KACjBA,QAAQ,UAAW,KACnBA,QAAQ,UAAW,QACnBC,MACH,CA3GQC,CAAYP,EACpB"}
@@ -9,12 +9,12 @@ export interface PopupBaseProps {
9
9
  feature: FeatureAnnouncement;
10
10
  currentIndex: number;
11
11
  totalFeatures: number;
12
- onSkip: () => Promise<void> | void;
13
- onExplore: (triggeredAction?: string) => void;
12
+ onSkip: () => void;
13
+ onExplore: () => void;
14
14
  onPrevious: () => void;
15
15
  onNext: () => void;
16
16
  setIsClosing?: (isClosing: boolean) => void;
17
- onSecondaryAction?: () => Promise<void> | void;
17
+ onSecondaryAction?: () => void;
18
18
  }
19
19
  /**
20
20
  * Major update popup props
@@ -15,4 +15,4 @@ export declare const hideJoyrideArrow: (popupRef: HTMLElement | null) => void;
15
15
  * @param callback - Function to execute
16
16
  * @param delay - Optional delay override
17
17
  */
18
- export declare const executeAfterAnimation: (callback: () => void | Promise<void>, delay?: number) => void;
18
+ export declare const executeAfterAnimation: (callback: () => void, delay?: number) => void;
@@ -3,16 +3,13 @@ import { EditorSnapshot, FormatState } from './BikEditor.types';
3
3
  /**
4
4
  * Normalise HTML before passing it to TipTap.
5
5
  *
6
- * Problem: Quill uses `<p><br></p>` as a blank-line separator. TipTap's
7
- * HardBreak extension parses that `<br>` as a real `hard_break` node.
8
- * ProseMirror then also appends `<br class="ProseMirror-trailingBreak">` as a
9
- * cursor-position decoration, making the empty paragraph render at **2× line
10
- * height** instead of 1×.
11
- *
12
- * Fix: replace `<p><br></p>` `<p></p>` so TipTap stores a truly empty
13
- * paragraph. ProseMirror adds only the trailing decoration, giving the correct
14
- * 1× line height. The WA text output is unchanged (`\n` either way after
15
- * surrounding-newline collapse in `toWhatsAppText`).
6
+ * Empty paragraphs containing only a `<br>` (e.g. `<p><br></p>` or
7
+ * `<p style="..."><br></p>`) are removed entirely. ProseMirror adds a
8
+ * trailing `<br>` to every empty paragraph in the DOM for cursor
9
+ * positioning, so stripping just the `<br>` and leaving `<p></p>`
10
+ * doesn't work the paragraph still renders with height. Removing
11
+ * the whole element avoids creating a node at all. This is in sync
12
+ * with how Gmail renders HTML.
16
13
  */
17
14
  export declare function normalizeHtml(html: string): string;
18
15
  /**
@@ -4,8 +4,8 @@
4
4
  * WhatsApp formatting:
5
5
  * *bold* _italic_ ~strikethrough~ ```monospace```
6
6
  *
7
- * Links: WhatsApp does not support custom display text for hyperlinks.
8
- * <a href="https://…">Visit us</a> → https://… (href wins, display text dropped)
7
+ * Links: WhatsApp does not support hyperlinks.
8
+ * <a href="https://…">Visit us</a> → Visit us (display text kept, href dropped)
9
9
  *
10
10
  * @example
11
11
  * const { html } = ref.current?.getContent();
@@ -1,2 +1,2 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import{useState as i,useEffect as r,useCallback as a}from"react";import d,{ACTIONS as s}from"react-joyride";import"./constants/animations.js";import{SELECTORS as l}from"./constants/selectors.js";import{useFeatureAnnouncements as u}from"./hooks/useFeatureAnnouncements.js";import c from"./MajorUpdatePopup.js";import p from"./MinorUpdatePopup.js";import{VideoModal as f}from"./VideoModal.js";const m=m=>{let{children:b,fetchVisibleFeatures:g,getStoreFeatureProgress:h,fetchFeatureById:y,markFeatureAsViewedForStore:v,isFeatureApplicableToCurrentPage:x,module:k,router:S,storeId:C,onAnnouncementShown:T,onAnnouncementInteracted:w}=m;var B;const{majorUpdateFeatures:I,minorUpdateFeatures:F,isLoading:E,markFeatureAsViewed:N}=u({fetchVisibleFeatures:g,getStoreFeatureProgress:h,fetchFeatureById:y,markFeatureAsViewedForStore:v,isFeatureApplicableToCurrentPage:x,module:k,router:S}),[j,P]=i(null),[U,W]=i(null),[V,O]=i(!1),[M,q]=i([]),[_,A]=i(!1),[L,R]=i([]),[$,z]=i(!1),[H,Z]=i(!1),[D,G]=i([]),[J,K]=i(!1),[Q,X]=i(!1),[Y,tt]=i(!1),[et,ot]=i(""),[nt,it]=i(!1),[rt,at]=i(!1),[dt,st]=i(!1),[lt,ut]=i(0),[ct,pt]=i(0),[ft,mt]=i(new Set);r((()=>{const t="minor-spotlight-cutout-style";let e=document.getElementById(t);return e||(e=document.createElement("style"),e.id=t,document.head.appendChild(e)),e.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__floater {\n\t\t\t\tright: 12px !important;\n\t\t\t\tleft: auto !important;\n\t\t\t}\n\t\t",()=>{const e=document.getElementById(t);e&&e.remove()}}),[]),r((()=>{ut((t=>t+1)),pt((t=>t+1)),at(!1),st(!1),mt(new Set)}),[null==S?void 0:S.pathname]),r((()=>{if(!(I.length>0)||j||E||$||nt)0!==I.length||E||X(!0);else{X(!1),K(!1),O(!1),q([]),W(null),G([]);let t=0;const e=10,o=()=>{t++;document.querySelector('[data-testid="whats-new-button"]')?bt(I[0]):t<e?setTimeout(o,1e3):X(!0)};o()}}),[I,j,E,$,nt]),r((()=>{var t;const e=null===(t=null==S?void 0:S.query)||void 0===t?void 0:t.featureId;if(!e||E||0===F.length)return;const o=F.find((t=>t.id===e));if(!o||!o.featureTag)return;K(!0),Z(!0);let n=0;const i=setInterval((()=>{n++;const t=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(t)){const t=[o];G(t),Ct(o,t),clearInterval(i)}else n>=25&&(Z(!1),clearInterval(i))}),200);return()=>{clearInterval(i)}}),[F,null===(B=null==S?void 0:S.query)||void 0===B?void 0:B.featureId,E]),r((()=>{var t;if(F.length>0&&!E&&!V&&!H&&!U&&!J&&Q&&!nt){let t=null,e=null,o=null,n=!1;const i=()=>{if(n||H||U||J||!Q)return;const i=F.filter((t=>{if(!t.featureTag||""===t.featureTag.trim())return!1;if(ft.has(t.id))return!1;const e=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`;return null!==document.querySelector(e)}));i.length>0&&(G(i),Ct(i[0],i),t&&(t.disconnect(),t=null),e&&(window.removeEventListener("scroll",e),e=null),o&&(clearTimeout(o),o=null))};return t=new MutationObserver((t=>{let e=!1;for(const o of t){if("childList"===o.type&&o.addedNodes.length>0)for(let t=0;t<o.addedNodes.length;t++){const n=o.addedNodes[t];if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(t.id||t.querySelector("[id]")){e=!0;break}}}if(e)break}V||n||H||U||J||!Q||!e||(o&&clearTimeout(o),o=setTimeout((()=>{n||H||U||J||!Q||i()}),200))})),e=()=>{V||n||H||U||J||!Q||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||H||U||J||!Q||i()}),300)})))},t&&t.observe(document.body,{childList:!0,subtree:!0}),e&&window.addEventListener("scroll",e,{passive:!0}),i(),setTimeout((()=>{n||H||U||J||!Q||i()}),100),setTimeout((()=>{n||H||U||J||!Q||i()}),1e3),setTimeout((()=>{n||H||U||J||!Q||i()}),500),()=>{n=!0,t&&t.disconnect(),e&&window.removeEventListener("scroll",e),o&&clearTimeout(o)}}if(0===F.length||E){(null===(t=null==S?void 0:S.query)||void 0===t?void 0:t.featureId)&&U||(O(!1),q([]),W(null),G([]),K(!1))}}),[F,E,V,H,U,J,Q,N,nt]);const bt=t=>{P(t);const o=I.findIndex((e=>e.id===t.id)),n=I.length,i=[{target:l.WHATS_NEW_BUTTON,content:e(c,{feature:t,currentIndex:o,totalFeatures:n,onSkip:()=>gt(t),onExplore:e=>ht(t,e),onPrevious:()=>yt(t),onNext:()=>vt(t),setIsClosing:at}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(i),A(!0),T&&C&&T({storeId:C,announcementId:t.id,announcementTitle:t.title,imageUrl:t.displayImage||t.image,videoUrl:t.productVideo})},gt=a((e=>t(void 0,void 0,void 0,(function*(){const t=e||j;t&&(z(!0),yield Promise.all(I.map((t=>N(t.id)))),A(!1),P(null),R([]),X(!0),w&&C&&w({storeId:C,announcementId:t.id,announcementTitle:t.title,imageUrl:t.displayImage||t.image,videoUrl:t.productVideo,buttonClicked:"Skip",buttonName:"Skip",buttonUrl:void 0}),setTimeout((()=>{z(!1)}),500))}))),[j,I,N]),ht=a(((e,o)=>t(void 0,void 0,void 0,(function*(){var t,n;z(!0),yield N(e.id);const i=null!=o?o:null===(t=e.primaryButton)||void 0===t?void 0:t.action;if("Play Video"===i&&e.productVideo&&(ot(e.productVideo),tt(!0),it(!0)),"Open link"===i){const t=(null===(n=e.primaryButton)||void 0===n?void 0:n.redirectionUrl)||e.redirectUrl;t&&!t.startsWith("http")&&(window.location.href=t)}A(!1),P(null),R([]);I.findIndex((t=>t.id===e.id))===I.length-1&&X(!0),w&&C&&w({storeId:C,announcementId:e.id,announcementTitle:e.title,imageUrl:e.displayImage||e.image,videoUrl:e.productVideo,buttonClicked:"Primary",buttonName:e.buttonText||"Explore",buttonUrl:e.redirectUrl||e.productVideo}),setTimeout((()=>{z(!1)}),500)}))),[I,N]),yt=a((t=>{const o=t||j;if(!o)return;const n=I.findIndex((t=>t.id===o.id));if(n>0){const t=I[n-1];P(t);const o=n-1,i=I.length,r=[{target:'[data-testid="whats-new-button"]',content:e(c,{feature:t,currentIndex:o,totalFeatures:i,onSkip:()=>gt(t),onExplore:()=>ht(t),onPrevious:()=>yt(t),onNext:()=>vt(t),setIsClosing:at}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(r)}}),[j,I]),vt=a((t=>{const o=t||j;if(!o)return;const n=I.findIndex((t=>t.id===o.id));if(n<I.length-1){const t=I[n+1];P(t);const o=n+1,i=I.length,r=[{target:'[data-testid="whats-new-button"]',content:e(c,{feature:t,currentIndex:o,totalFeatures:i,onSkip:()=>gt(t),onExplore:()=>ht(t),onPrevious:()=>yt(t),onNext:()=>vt(t),setIsClosing:at}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(r)}else z(!0),N(o.id),A(!1),P(null),R([]),X(!0),setTimeout((()=>{z(!1)}),500)}),[j,I,N]),xt=()=>{if(I.length>0&&!j){document.querySelector('[data-testid="whats-new-button"]')&&bt(I[0])}};r((()=>(window.showMajorUpdatePopup=xt,()=>{delete window.showMajorUpdatePopup})),[I,j]);const kt=a((t=>{const{action:e}=t;e===s.CLOSE&&(j&&(z(!0),I.forEach((t=>{N(t.id)})),X(!0),setTimeout((()=>{z(!1)}),500)),A(!1),P(null),R([]))}),[j,I,N]),St=a((t=>{const{action:e}=t;if(e===s.CLOSE){if(U){Z(!0),N(U.id);D.findIndex((t=>t.id===U.id))===D.length-1&&K(!0),setTimeout((()=>{Z(!1)}),500)}O(!1),W(null),q([])}}),[U,D,N]),Ct=(o,n)=>t(void 0,void 0,void 0,(function*(){W(o);const t=n||D,i=t.findIndex((t=>t.id===o.id)),r=t.length,a=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,d=document.querySelector(a);if(d)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(d,120)}catch(t){}const s=[{target:a,content:e(p,{feature:o,currentIndex:i,totalFeatures:r,onSkip:()=>Tt(o),onExplore:()=>wt(o),onPrevious:()=>Bt(o),onNext:()=>It(o),setIsClosing:st}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(s),O(!0)})),Tt=a((e=>t(void 0,void 0,void 0,(function*(){const t=e||U;if(t){Z(!0),yield N(t.id),mt((e=>new Set(e).add(t.id))),O(!1),W(null),q([]);const e=D.find((e=>e.id!==t.id&&!ft.has(e.id)));setTimeout((()=>{Z(!1),e?Ct(e,D):K(!0)}),500)}}))),[U,D,N,ft]),wt=a(((e,o)=>t(void 0,void 0,void 0,(function*(){var t,n;Z(!0),yield N(e.id),mt((t=>new Set(t).add(e.id)));const i=null!=o?o:null===(t=e.primaryButton)||void 0===t?void 0:t.action;if("Play Video"===i&&e.productVideo&&(ot(e.productVideo),tt(!0),it(!0)),"Open link"===i){const t=(null===(n=e.primaryButton)||void 0===n?void 0:n.redirectionUrl)||e.redirectUrl;t&&!t.startsWith("http")&&(window.location.href=t)}O(!1),W(null),q([]);const r=D.find((t=>t.id!==e.id&&!ft.has(t.id)));setTimeout((()=>{Z(!1),r&&"Play Video"!==i?Ct(r,D):r||K(!0)}),500)}))),[D,N,ft]),Bt=a((o=>t(void 0,void 0,void 0,(function*(){const t=o||U;if(!t)return;const n=D.findIndex((e=>e.id===t.id));if(n>0){const t=D[n-1];W(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,i=document.querySelector(o);if(i)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(i,120)}catch(t){}const r=n-1,a=D.length,d=[{target:o,content:e(p,{feature:t,currentIndex:r,totalFeatures:a,onSkip:()=>Tt(t),onExplore:()=>wt(t),onPrevious:()=>Bt(t),onNext:()=>It(t),setIsClosing:st}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(d)}}))),[U,D]),It=a((o=>t(void 0,void 0,void 0,(function*(){const t=o||U;if(!t)return;const n=D.findIndex((e=>e.id===t.id));if(n<D.length-1){const t=D[n+1];W(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,i=document.querySelector(o);if(i)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(i,120)}catch(t){}const r=n+1,a=D.length,d=[{target:o,content:e(p,{feature:t,currentIndex:r,totalFeatures:a,onSkip:()=>Tt(t),onExplore:()=>wt(t),onPrevious:()=>Bt(t),onNext:()=>It(t),setIsClosing:st}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(d)}else Z(!0),K(!0),N(t.id),O(!1),W(null),q([]),setTimeout((()=>{Z(!1)}),500)}))),[U,D,N]);return o(n,{children:[b,L.length>0&&e(d,{steps:L,run:_,continuous:!1,showProgress:!1,showSkipButton:!1,callback:kt,disableOverlayClose:!1,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:rt?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${lt}`),M.length>0&&e(d,{steps:M,run:V,continuous:!1,showProgress:!1,showSkipButton:!1,callback:St,disableOverlayClose:!1,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:dt?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:dt?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${ct}`),e(f,{isOpen:Y,videoUrl:et,onClose:()=>{tt(!1),ot(""),it(!1);const t=D.find((t=>!ft.has(t.id)));t?setTimeout((()=>{Ct(t,D)}),300):K(!0)}})]})};export{m as default};
1
+ import{__awaiter as t}from"../../_virtual/_tslib.js";import{jsx as e,jsxs as o,Fragment as n}from"react/jsx-runtime";import{useState as r,useEffect as a,useCallback as i}from"react";import s,{ACTIONS as d}from"react-joyride";import"./constants/animations.js";import{SELECTORS as l}from"./constants/selectors.js";import{useFeatureAnnouncements as u}from"./hooks/useFeatureAnnouncements.js";import c from"./MajorUpdatePopup.js";import p from"./MinorUpdatePopup.js";import{VideoModal as f}from"./VideoModal.js";const m=m=>{let{children:b,fetchVisibleFeatures:g,getStoreFeatureProgress:h,fetchFeatureById:y,markFeatureAsViewedForStore:x,isFeatureApplicableToCurrentPage:k,module:S,router:C,storeId:T,onAnnouncementShown:v,onAnnouncementInteracted:w}=m;var I;const{majorUpdateFeatures:B,minorUpdateFeatures:F,isLoading:E,markFeatureAsViewed:N}=u({fetchVisibleFeatures:g,getStoreFeatureProgress:h,fetchFeatureById:y,markFeatureAsViewedForStore:x,isFeatureApplicableToCurrentPage:k,module:S,router:C}),[j,P]=r(null),[U,W]=r(null),[V,M]=r(!1),[O,q]=r([]),[_,A]=r(!1),[L,R]=r([]),[$,z]=r(!1),[H,Z]=r(!1),[D,G]=r([]),[J,K]=r(!1),[Q,X]=r(!1),[Y,tt]=r(!1),[et,ot]=r(""),[nt,rt]=r(!1),[at,it]=r(!1),[st,dt]=r(!1),[lt,ut]=r(0),[ct,pt]=r(0),[ft,mt]=r(new Set);a((()=>{const t="minor-spotlight-cutout-style";let e=document.getElementById(t);return e||(e=document.createElement("style"),e.id=t,document.head.appendChild(e)),e.textContent="\n\t\t\t.react-joyride__spotlight {\n\t\t\t\ttransition: box-shadow 0.3s ease-in-out !important;\n\t\t\t\twill-change: box-shadow, transform;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__tooltip {\n\t\t\t\twill-change: transform, opacity;\n\t\t\t\ttransform: translateZ(0);\n\t\t\t}\n\t\t\t.react-joyride__floater {\n\t\t\t\tright: 12px !important;\n\t\t\t\tleft: auto !important;\n\t\t\t}\n\t\t",()=>{const e=document.getElementById(t);e&&e.remove()}}),[]),a((()=>{ut((t=>t+1)),pt((t=>t+1)),it(!1),dt(!1),mt(new Set)}),[null==C?void 0:C.pathname]),a((()=>{if(!(B.length>0)||j||E||$||nt)0!==B.length||E||X(!0);else{X(!1),K(!1),M(!1),q([]),W(null),G([]);let t=0;const e=10,o=()=>{t++;document.querySelector('[data-testid="whats-new-button"]')?bt(B[0]):t<e?setTimeout(o,1e3):X(!0)};o()}}),[B,j,E,$,nt]),a((()=>{var t;const e=null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId;if(!e||E||0===F.length)return;const o=F.find((t=>t.id===e));if(!o||!o.featureTag)return;K(!0),Z(!0);let n=0;const r=setInterval((()=>{n++;const t=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`;if(document.querySelector(t)){const t=[o];G(t),Tt(o,t),clearInterval(r)}else n>=25&&(Z(!1),clearInterval(r))}),200);return()=>{clearInterval(r)}}),[F,null===(I=null==C?void 0:C.query)||void 0===I?void 0:I.featureId,E]),a((()=>{var t;if(F.length>0&&!E&&!V&&!H&&!U&&!J&&Q&&!nt){let t=null,e=null,o=null,n=!1;const r=()=>{if(n||H||U||J||!Q)return;const r=F.filter((t=>{if(!t.featureTag||""===t.featureTag.trim())return!1;if(ft.has(t.id))return!1;const e=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`;return null!==document.querySelector(e)}));r.length>0&&(G(r),Tt(r[0],r),t&&(t.disconnect(),t=null),e&&(window.removeEventListener("scroll",e),e=null),o&&(clearTimeout(o),o=null))};return t=new MutationObserver((t=>{let e=!1;for(const o of t){if("childList"===o.type&&o.addedNodes.length>0)for(let t=0;t<o.addedNodes.length;t++){const n=o.addedNodes[t];if(n.nodeType===Node.ELEMENT_NODE){const t=n;if(t.id||t.querySelector("[id]")){e=!0;break}}}if(e)break}V||n||H||U||J||!Q||!e||(o&&clearTimeout(o),o=setTimeout((()=>{n||H||U||J||!Q||r()}),200))})),e=()=>{V||n||H||U||J||!Q||(o&&clearTimeout(o),requestAnimationFrame((()=>{o=setTimeout((()=>{n||H||U||J||!Q||r()}),300)})))},t&&t.observe(document.body,{childList:!0,subtree:!0}),e&&window.addEventListener("scroll",e,{passive:!0}),r(),setTimeout((()=>{n||H||U||J||!Q||r()}),100),setTimeout((()=>{n||H||U||J||!Q||r()}),1e3),setTimeout((()=>{n||H||U||J||!Q||r()}),500),()=>{n=!0,t&&t.disconnect(),e&&window.removeEventListener("scroll",e),o&&clearTimeout(o)}}if(0===F.length||E){(null===(t=null==C?void 0:C.query)||void 0===t?void 0:t.featureId)&&U||(M(!1),q([]),W(null),G([]),K(!1))}}),[F,E,V,H,U,J,Q,N,nt]);const bt=t=>{P(t);const o=B.findIndex((e=>e.id===t.id)),n=B.length,r=[{target:l.WHATS_NEW_BUTTON,content:e(c,{feature:t,currentIndex:o,totalFeatures:n,onSkip:()=>gt(t),onExplore:()=>ht(t),onPrevious:()=>yt(t),onNext:()=>xt(t),setIsClosing:it}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(r),A(!0),v&&T&&v({storeId:T,announcementId:t.id,announcementTitle:t.title,imageUrl:t.displayImage||t.image,videoUrl:t.productVideo})},gt=i((t=>{const e=t||j;e&&(z(!0),B.forEach((t=>{N(t.id)})),A(!1),P(null),R([]),X(!0),w&&T&&w({storeId:T,announcementId:e.id,announcementTitle:e.title,imageUrl:e.displayImage||e.image,videoUrl:e.productVideo,buttonClicked:"Skip",buttonName:"Skip",buttonUrl:void 0}),setTimeout((()=>{z(!1)}),500))}),[j,B,N]),ht=i((t=>{z(!0),N(t.id),t.productVideo&&(ot(t.productVideo),tt(!0),rt(!0)),A(!1),P(null),R([]);B.findIndex((e=>e.id===t.id))===B.length-1&&X(!0),w&&T&&w({storeId:T,announcementId:t.id,announcementTitle:t.title,imageUrl:t.displayImage||t.image,videoUrl:t.productVideo,buttonClicked:"Primary",buttonName:t.buttonText||"Explore",buttonUrl:t.redirectUrl||t.productVideo}),setTimeout((()=>{z(!1)}),500)}),[B,N]),yt=i((t=>{const o=t||j;if(!o)return;const n=B.findIndex((t=>t.id===o.id));if(n>0){const t=B[n-1];P(t);const o=n-1,r=B.length,a=[{target:'[data-testid="whats-new-button"]',content:e(c,{feature:t,currentIndex:o,totalFeatures:r,onSkip:()=>gt(t),onExplore:()=>ht(t),onPrevious:()=>yt(t),onNext:()=>xt(t),setIsClosing:it}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(a)}}),[j,B]),xt=i((t=>{const o=t||j;if(!o)return;const n=B.findIndex((t=>t.id===o.id));if(n<B.length-1){const t=B[n+1];P(t);const o=n+1,r=B.length,a=[{target:'[data-testid="whats-new-button"]',content:e(c,{feature:t,currentIndex:o,totalFeatures:r,onSkip:()=>gt(t),onExplore:()=>ht(t),onPrevious:()=>yt(t),onNext:()=>xt(t),setIsClosing:it}),placement:"bottom-start",placementBeacon:"top-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMajor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"16px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];R(a)}else z(!0),N(o.id),A(!1),P(null),R([]),X(!0),setTimeout((()=>{z(!1)}),500)}),[j,B,N]),kt=()=>{if(B.length>0&&!j){document.querySelector('[data-testid="whats-new-button"]')&&bt(B[0])}};a((()=>(window.showMajorUpdatePopup=kt,()=>{delete window.showMajorUpdatePopup})),[B,j]);const St=i((t=>{const{action:e}=t;e===d.CLOSE&&(j&&(z(!0),B.forEach((t=>{N(t.id)})),X(!0),setTimeout((()=>{z(!1)}),500)),A(!1),P(null),R([]))}),[j,B,N]),Ct=i((t=>{const{action:e}=t;if(e===d.CLOSE){if(U){Z(!0),N(U.id);D.findIndex((t=>t.id===U.id))===D.length-1&&K(!0),setTimeout((()=>{Z(!1)}),500)}M(!1),W(null),q([])}}),[U,D,N]),Tt=(o,n)=>t(void 0,void 0,void 0,(function*(){W(o);const t=n||D,r=t.findIndex((t=>t.id===o.id)),a=t.length,i=o.featureTag.startsWith("#")||o.featureTag.startsWith(".")||o.featureTag.startsWith("[")?o.featureTag:`#${o.featureTag}`,s=document.querySelector(i);if(s)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(s,120)}catch(t){}const d=[{target:i,content:e(p,{feature:o,currentIndex:r,totalFeatures:a,onSkip:()=>vt(o),onExplore:()=>wt(o),onPrevious:()=>It(o),onNext:()=>Bt(o),setIsClosing:dt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:o,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(d),M(!0)})),vt=i((t=>{const e=t||U;if(e){Z(!0),N(e.id),mt((t=>new Set(t).add(e.id))),M(!1),W(null),q([]);const t=D.find((t=>t.id!==e.id&&!ft.has(t.id)));setTimeout((()=>{Z(!1),t?Tt(t,D):K(!0)}),500)}}),[U,D,N,ft]),wt=i((t=>{Z(!0),N(t.id),mt((e=>new Set(e).add(t.id))),t.productVideo&&(ot(t.productVideo),tt(!0),rt(!0)),M(!1),W(null),q([]);const e=D.find((e=>e.id!==t.id&&!ft.has(e.id)));setTimeout((()=>{Z(!1),e&&!t.productVideo?Tt(e,D):e||K(!0)}),500)}),[D,N,ft]),It=i((o=>t(void 0,void 0,void 0,(function*(){const t=o||U;if(!t)return;const n=D.findIndex((e=>e.id===t.id));if(n>0){const t=D[n-1];W(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,r=document.querySelector(o);if(r)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(r,120)}catch(t){}const a=n-1,i=D.length,s=[{target:o,content:e(p,{feature:t,currentIndex:a,totalFeatures:i,onSkip:()=>vt(t),onExplore:()=>wt(t),onPrevious:()=>It(t),onNext:()=>Bt(t),setIsClosing:dt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(s)}}))),[U,D]),Bt=i((o=>t(void 0,void 0,void 0,(function*(){const t=o||U;if(!t)return;const n=D.findIndex((e=>e.id===t.id));if(n<D.length-1){const t=D[n+1];W(t);const o=t.featureTag.startsWith("#")||t.featureTag.startsWith(".")||t.featureTag.startsWith("[")?t.featureTag:`#${t.featureTag}`,r=document.querySelector(o);if(r)try{const{scrollToElementSmooth:t}=yield import("./utils/elementHelpers.js");yield t(r,120)}catch(t){}const a=n+1,i=D.length,s=[{target:o,content:e(p,{feature:t,currentIndex:a,totalFeatures:i,onSkip:()=>vt(t),onExplore:()=>wt(t),onPrevious:()=>It(t),onNext:()=>Bt(t),setIsClosing:dt}),placement:"bottom",placementBeacon:"bottom-end",disableBeacon:!0,hideCloseButton:!0,hideSkipButton:!0,hideFooter:!0,offset:0,data:{feature:t,isMinor:!0},styles:{tooltip:{padding:0,backgroundColor:"transparent",borderRadius:"4px",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}}}];q(s)}else Z(!0),K(!0),N(t.id),M(!1),W(null),q([]),setTimeout((()=>{Z(!1)}),500)}))),[U,D,N]);return o(n,{children:[b,L.length>0&&e(s,{steps:L,run:_,continuous:!1,showProgress:!1,showSkipButton:!1,callback:St,disableOverlayClose:!1,disableCloseOnEsc:!1,disableOverlay:!1,spotlightClicks:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:at?"transparent":"#212121"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",border:"none",boxShadow:"none"},tooltip:{borderRadius:"16px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonClose:{display:"none"},buttonSkip:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`major-joyride-${lt}`),O.length>0&&e(s,{steps:O,run:V,continuous:!1,showProgress:!1,showSkipButton:!1,callback:Ct,disableOverlayClose:!1,disableCloseOnEsc:!1,disableOverlay:!1,scrollToFirstStep:!0,scrollOffset:120,disableScrolling:!1,styles:{options:{primaryColor:"#007bff",zIndex:1e4,width:"auto",arrowColor:st?"transparent":"#ffffff"},overlay:{backgroundColor:"transparent"},spotlight:{backgroundColor:"transparent",borderRadius:"8px",boxShadow:st?"none":"0 0 0 9999px rgba(0, 0, 0, 0.4), 0 0 0 3px rgba(255, 255, 255, 0.8), 0 0 20px 8px rgba(255, 255, 255, 0.4)"},tooltip:{borderRadius:"4px",fontSize:"14px",padding:0,backgroundColor:"transparent",border:"none",filter:"none",boxShadow:"none"},tooltipContent:{padding:0},buttonNext:{display:"none"},buttonBack:{display:"none"},buttonSkip:{display:"none"},buttonClose:{display:"none"}},locale:{back:"Back",close:"Close",last:"Close",next:"Next",skip:"Skip"}},`minor-joyride-${ct}`),e(f,{isOpen:Y,videoUrl:et,onClose:()=>{tt(!1),ot(""),rt(!1);const t=D.find((t=>!ft.has(t.id)));t?setTimeout((()=>{Tt(t,D)}),300):K(!0)}})]})};export{m as default};
2
2
  //# sourceMappingURL=FeatureAnnouncementProvider.js.map