@select-org/select-post-builder 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +16 -16
- package/dist/post-builder.cjs.js +1 -1
- package/dist/post-builder.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -532,22 +532,6 @@ declare module '@tiptap/core' {
|
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
|
|
535
|
-
declare module '@tiptap/core' {
|
|
536
|
-
interface Commands<ReturnType> {
|
|
537
|
-
iframe: {
|
|
538
|
-
/**
|
|
539
|
-
* Insert an iframe node into the document
|
|
540
|
-
*/
|
|
541
|
-
setIframe: (options: {
|
|
542
|
-
src: string;
|
|
543
|
-
width?: string;
|
|
544
|
-
height?: string;
|
|
545
|
-
}) => ReturnType;
|
|
546
|
-
};
|
|
547
|
-
}
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
551
535
|
declare module '@tiptap/core' {
|
|
552
536
|
interface Commands<ReturnType> {
|
|
553
537
|
smartMediaUpload: {
|
|
@@ -607,3 +591,19 @@ declare module '@tiptap/core' {
|
|
|
607
591
|
};
|
|
608
592
|
}
|
|
609
593
|
}
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
declare module '@tiptap/core' {
|
|
597
|
+
interface Commands<ReturnType> {
|
|
598
|
+
iframe: {
|
|
599
|
+
/**
|
|
600
|
+
* Insert an iframe node into the document
|
|
601
|
+
*/
|
|
602
|
+
setIframe: (options: {
|
|
603
|
+
src: string;
|
|
604
|
+
width?: string;
|
|
605
|
+
height?: string;
|
|
606
|
+
}) => ReturnType;
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
}
|
package/dist/post-builder.cjs.js
CHANGED
|
@@ -165,7 +165,7 @@ self.addEventListener('message', async (e) => {
|
|
|
165
165
|
self.postMessage({ error: e.message + '\\n' + e.stack, id })
|
|
166
166
|
}
|
|
167
167
|
})
|
|
168
|
-
`;let c;function compressOnWebWorker(u,n){return new Promise(((d,p)=>{c||(c=(function(y){const b=[];return b.push(y),URL.createObjectURL(new Blob(b))})(l));const m=new Worker(c);m.addEventListener("message",(function(y){if(n.signal&&n.signal.aborted)m.terminate();else if(y.data.progress===void 0){if(y.data.error)return p(new Error(y.data.error)),void m.terminate();d(y.data.file),m.terminate()}else n.onProgress(y.data.progress)})),m.addEventListener("error",p),n.signal&&n.signal.addEventListener("abort",(()=>{p(n.signal.reason),m.terminate()})),m.postMessage({file:u,imageCompressionLibUrl:n.libURL,options:{...n,onProgress:void 0,signal:void 0}})}))}function imageCompression(u,n){return new Promise((function(d,p){let m,g,y,b,S,E;if(m={...n},y=0,{onProgress:b}=m,m.maxSizeMB=m.maxSizeMB||Number.POSITIVE_INFINITY,S=typeof m.useWebWorker!="boolean"||m.useWebWorker,delete m.useWebWorker,m.onProgress=A=>{y=A,typeof b=="function"&&b(y)},!(u instanceof Blob||u instanceof CustomFile))return p(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(u.type))return p(new Error("The file given is not an image"));if(E=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!S||typeof Worker!="function"||E)return compress(u,m).then((function(A){try{return g=A,R.call(this)}catch(C){return p(C)}}).bind(this),p);var T=(function(){try{return R.call(this)}catch(A){return p(A)}}).bind(this),_=function(A){try{return compress(u,m).then((function(C){try{return g=C,T()}catch(k){return p(k)}}),p)}catch(C){return p(C)}};try{return m.libURL=m.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",compressOnWebWorker(u,m).then((function(A){try{return g=A,T()}catch{return _()}}),_)}catch{_()}function R(){try{g.name=u.name,g.lastModified=u.lastModified}catch{}try{m.preserveExif&&u.type==="image/jpeg"&&(!m.fileType||m.fileType&&m.fileType===u.type)&&(g=copyExifWithoutOrientation(u,g))}catch{}return d(g)}}))}imageCompression.getDataUrlFromFile=getDataUrlFromFile,imageCompression.getFilefromDataUrl=getFilefromDataUrl,imageCompression.loadImage=loadImage,imageCompression.drawImageInCanvas=drawImageInCanvas,imageCompression.drawFileInCanvas=drawFileInCanvas,imageCompression.canvasToFile=canvasToFile,imageCompression.getExifOrientation=getExifOrientation,imageCompression.handleMaxWidthOrHeight=handleMaxWidthOrHeight,imageCompression.followExifOrientation=followExifOrientation,imageCompression.cleanupCanvasMemory=cleanupCanvasMemory,imageCompression.isAutoOrientationInBrowser=isAutoOrientationInBrowser,imageCompression.approximateBelowMaximumCanvasSizeOfBrowser=approximateBelowMaximumCanvasSizeOfBrowser,imageCompression.copyExifWithoutOrientation=copyExifWithoutOrientation,imageCompression.getBrowserName=getBrowserName,imageCompression.version="2.0.2";const ImageSearchModal$1=React.lazy(()=>Promise.resolve().then(()=>mediaSearch).then(u=>({default:u.ImageSearchModal}))),LinkDecoratorModal$1=React.lazy(()=>Promise.resolve().then(()=>linkDecorator).then(u=>({default:u.LinkDecoratorModal}))),TOOLBAR_FEATURES={[EditorTypes.Blog]:{showFormatting:!0,showImage:!0,showVideo:!0,showAudio:!1,showImageSearch:!0,showLink:!0},[EditorTypes.Media]:{showFormatting:!1,showImage:!0,showVideo:!0,showAudio:!1,showImageSearch:!0,showLink:!0},[EditorTypes.Poll]:{}},QUICK_GIF_HOLD_MS=500,Toolbar=({actions:u,editorType:n,children:d,isSubmitting:p,onSubmit:m,placement:g,onVoiceComment:y,onVoiceRecord:b,onQuickGif:S,hideSubmitButton:E})=>{const T=React.useRef(null),[_,R]=React.useState(null),[A,C]=React.useState(!1),[k,I]=React.useState(!1),[P,D]=React.useState(!1),{editor:O}=useCurrentEditor(),N=useEditorStateSnapshot(O),{showCrossMentionIndicator:F}=useEditorWithMentionTracking(O,{debounceMs:150}),{trackFeature:L}=useAnalyticsTracking(),{t:V,allowSendWhileUploading:j,unauthenticatedMode:Y}=usePostBuilder(),{fileStore:J}=useApi(),{isRecording:te,duration:Q,volume:se,startRecording:Z,stopRecording:re,cancelRecording:B}=useVoiceRecorder({maxDuration:60}),[q,H]=React.useState(!1),W=useUploadingState(O),ee=g===EditorPlacement.Comment&&!!y&&N?.isEmpty&&!p&&!te&&!Y,ne=async()=>{try{await Z()}catch{toast.error("Could not access microphone. Please check your browser permissions.")}},oe=async()=>{if(te)try{const{blob:Te,duration:Ie}=await re();if(j&&b){b({blob:Te,voiceTime:Ie});return}H(!0);const $e=Te.type.split("/")[1]?.split(";")[0]??"webm",Ue=new File([Te],`${v4()}.${$e}`),Ye=await J.uploadVoiceV2(Ue);Ye?.url&&y?.({voiceUrl:Ye.url,voiceTime:Ie})}catch{}finally{H(!1)}},le=()=>{B()},ce=React.useRef(null),ae=React.useRef(!1),de=React.useRef(!1),[fe,pe]=React.useState(!1),ye=()=>{if(!O)return!1;const Te=O.getJSON(),Ie=findByType(Te,"media"),$e=findByType(Te,"mediaGroup");return Ie.length>0||$e.length>0},ve=()=>!!S&&!te&&!!O&&O.getText().trim().length>0&&!ye()&&!Y,be=()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},ge=()=>{be(),ae.current=!1,pe(!1)},Se=()=>{de.current=!1,ae.current=!1,ve()&&(ce.current=setTimeout(()=>{ae.current=!0,pe(!0)},QUICK_GIF_HOLD_MS))},me=()=>{if(be(),ae.current){ae.current=!1,pe(!1);const Te=O?.getText().trim()??"";Te&&S&&(de.current=!0,S({text:Te,sendCrossMention:P}))}},Re=()=>{ge()};if(!O)return null;const Ce=TOOLBAR_FEATURES[n],Ae=Te=>{if(N?.isLink){O.chain().focus().unsetLink().run(),Te.preventDefault();return}C(!0)},ke=(Te,Ie,$e,Ue)=>{const Ye=n===EditorTypes.Blog&&Ie||Te;if($e){O.commands.updateLink($e,{href:Te,text:Ye,previewPayload:Ue});return}O.commands.insertLink({href:Te,text:Ye,previewPayload:Ue})},De=()=>{const Te=O.getJSON();return findByType(Te,"media").length>=10?(toast.error(`You can upload up to ${MAX_FILES} files per post. Please remove some files before adding new ones.`),!0):!1},je=()=>{if(n!==EditorTypes.Media){T?.current?.click();return}De()||T?.current?.click()},Ne=async Te=>{const Ie=Te.target.files;if(!Ie||!_)return;let $e=Array.from(Ie);$e.length>MAX_FILES&&(toast.error(`You can upload up to ${MAX_FILES} files per post. Picking the first ${MAX_FILES} files`),$e=$e.slice(0,MAX_FILES));const Ue=MAX_FILE_SIZE,Ye=Ue/(1024*1024),ze=$e.filter(We=>We.size>Ue);if(ze.length>0){const We=ze.map(Ge=>Ge.name).join(", ");if(toast.error(`${ze.length>1?"Some files exceed":`"${We}" exceeds`} the ${Ye}MB limit`),$e=$e.filter(Ge=>Ge.size<=Ue),$e.length===0){Te.target.value="";return}}_===MediaNodeTypes.Image&&($e=await Promise.all($e.map(async We=>{try{return await imageCompression(We,{maxSizeMB:10})}catch{return We}}))),$e.forEach(We=>{let Ge=_;We.type.startsWith("image/")?Ge=MediaNodeTypes.Image:We.type.startsWith("video/")?Ge=MediaNodeTypes.Video:We.type.startsWith("audio/")&&(Ge=MediaNodeTypes.Audio),O.commands.insertMediaWithUpload({source:We,type:Ge,mediaType:MediaItemType.MEDIA_ITEM})}),Te.target.value=""},Fe=Te=>{if(De()){Te.preventDefault();return}I(!0)},Le=(Te,Ie)=>{Ie&&L(Ie===ImageSearchFrom.Gif?"gif_search":"image_search"),O?.commands.insertMediaWithUpload({source:Te,type:MediaNodeTypes.Image,mediaType:MediaItemType.IMAGE_ITEM,searchFrom:Ie})},Oe=Te=>Te?.isHeading1?Heading1:Te?.isHeading2?Heading2:Te?.isHeading3?Heading3:Type;return jsxRuntime.jsxs("div",{className:"flex flex-col grow overflow-y-auto",children:[Ce.showFormatting&&jsxRuntime.jsxs("div",{className:"shrink-0 flex flex-wrap items-center gap-2 sm:gap-2 p-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.undo,icon:Undo,tooltip:"undoKey",onClick:u?.undo,disabled:!N?.canUndo}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.redo,icon:Redo,tooltip:"redoKey",onClick:u?.redo,disabled:!N?.canRedo}),jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{tooltip:"headingOptionsKey",icon:Oe(N),"aria-label":"More formatting options"})}),jsxRuntime.jsx(DropdownMenuContent,{align:"start",className:"w-44 px-1 py-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-stretch gap-1",children:[jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:FEATURE_NAME_MAP.paragraph,className:"w-full justify-start",tooltip:"paragraphKey",onClick:u?.setParagraph,active:N?.isParagraph,disabled:!N?.canParagraph,children:[jsxRuntime.jsx(Type,{})," ",V("paragraphKey")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[1],className:"w-full justify-start",tooltip:"heading1Key",onClick:()=>u?.toggleHeading(1),active:N?.isHeading1,disabled:!N?.canHeading1,children:[jsxRuntime.jsx(Heading1,{})," ",V("heading1Key")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[2],className:"w-full justify-start",tooltip:"heading2Key",onClick:()=>u?.toggleHeading(2),active:N?.isHeading2,disabled:!N?.canHeading2,children:[jsxRuntime.jsx(Heading2,{})," ",V("heading2Key")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[3],className:"w-full justify-start",tooltip:"heading3Key",onClick:()=>u?.toggleHeading(3),active:N?.isHeading3,disabled:!N?.canHeading3,children:[jsxRuntime.jsx(Heading3,{})," ",V("heading3Key")]})})]})})]}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.bold,icon:Bold$1,tooltip:"boldKey",onClick:u?.toggleBold,active:N?.isBold,disabled:!N?.canBold}),jsxRuntime.jsxs("div",{className:"hidden xl:flex items-center gap-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.italic,icon:Italic$1,tooltip:"italicKey",onClick:u?.toggleItalic,active:N?.isItalic,disabled:!N?.canItalic}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.strike,icon:Strikethrough,tooltip:"strikethroughKey",onClick:u?.toggleStrikethrough,active:N?.isStrike,disabled:!N?.canStrike})]}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.bulletList,icon:List,tooltip:"bulletListKey",onClick:u?.toggleBulletList,active:N?.isBulletList,disabled:!N?.canBulletList}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.orderedList,icon:ListOrdered,tooltip:"orderedListKey",onClick:u?.toggleOrderedList,active:N?.isOrderedList,disabled:!N?.canOrderedList}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsxs("div",{className:"hidden xl:flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.blockquote,icon:TextQuote,tooltip:"blockquoteKey",onClick:u?.toggleBlockquote,active:N?.isBlockquote,disabled:!N?.canBlockquote}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.code,icon:Code$1,tooltip:"codeKey",onClick:u?.toggleCode,active:N?.isCode,disabled:!N?.canCode}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.codeBlock,icon:FileCode2,tooltip:"codeBlockKey",onClick:u?.toggleCodeBlock,active:N?.isCodeBlock,disabled:!N?.canCodeBlock})]}),jsxRuntime.jsx("div",{className:"flex xl:hidden",children:jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{tooltip:"moreOptionsKey",icon:Ellipsis,"aria-label":"More formatting options"})}),jsxRuntime.jsx(DropdownMenuContent,{align:"end",className:"w-fit px-2 py-1",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.italic,icon:Italic$1,tooltip:"italicKey",onClick:u?.toggleItalic,active:N?.isItalic,disabled:!N?.canItalic})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.strike,icon:Strikethrough,tooltip:"strikethroughKey",onClick:u?.toggleStrikethrough,active:N?.isStrike,disabled:!N?.canStrike})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.blockquote,icon:TextQuote,tooltip:"blockquoteKey",onClick:u?.toggleBlockquote,active:N?.isBlockquote,disabled:!N?.canBlockquote})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.code,icon:Code$1,tooltip:"codeKey",onClick:u?.toggleCode,active:N?.isCode,disabled:!N?.canCode})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.codeBlock,icon:FileCode2,tooltip:"codeBlockKey",onClick:u?.toggleCodeBlock,active:N?.isCodeBlock,disabled:!N?.canCodeBlock})})]})})]})})]}),jsxRuntime.jsxs("div",{className:"relative grow flex flex-col overflow-y-auto",children:[jsxRuntime.jsx(VoiceRecordingOverlay,{isRecording:te,duration:Q,volume:se}),d]}),F&&jsxRuntime.jsxs("div",{className:"sm:hidden flex flex-col gap-1 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"send-cross-mention",checked:P,onCheckedChange:D}),jsxRuntime.jsxs(Label,{htmlFor:"send-cross-mention",className:"text-xs",children:["Cross-post to groups you #mention? ",jsxRuntime.jsx(Forward,{className:"size-4"})]})]}),P&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:V("crossPostLimitKey")})]}),jsxRuntime.jsxs("div",{className:cn("shrink-0 flex items-center sm:gap-2 p-2 border-t",E&&!Ce.showImage&&!Ce.showVideo&&!Ce.showImageSearch&&!Ce.showLink&&"hidden"),children:[jsxRuntime.jsx("input",{ref:T,type:"file",multiple:!0,maxLength:2,accept:`${MEDIA_ACCEPTS[MediaNodeTypes.Image]}, ${MEDIA_ACCEPTS[MediaNodeTypes.Video]}`,hidden:!0,onChange:Ne}),Ce.showImage&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.image,icon:ImagePlus,tooltip:"insertImageKey",disabled:te||!N?.canInsertImage,onMouseOver:()=>R(MediaNodeTypes.Image),onClick:je}),Ce.showVideo&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.video,icon:Video,disabled:te||!N?.canInsertVideo,tooltip:"insertVideoKey",onMouseOver:()=>R(MediaNodeTypes.Video),onClick:je}),Ce.showAudio&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.audio,icon:Music,disabled:te||!N?.canInsertAudio,tooltip:"insertAudioKey",onMouseOver:()=>R(MediaNodeTypes.Audio),onClick:je}),Ce.showImageSearch&&!Y&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ToolbarButton,{onClick:Fe,disabled:te||!N?.canInsertImage,icon:GifIcon,tooltip:"searchGifOrImagesKey",className:"p-1 [&>svg]:size-5!"}),k&&jsxRuntime.jsx(React.Suspense,{fallback:null,children:jsxRuntime.jsx(ImageSearchModal$1,{open:k,onOpenChange:I,onImageSelect:Le,initialQuery:extractInitialSearchQuery(O)})})]}),Ce.showLink&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.customLink,icon:Link$1,tooltip:"addLinkPreviewKey",onClick:Ae,active:N?.isLink,disabled:te||!N?.canLink}),A&&jsxRuntime.jsx(React.Suspense,{fallback:null,children:jsxRuntime.jsx(LinkDecoratorModal$1,{hideTextInput:!0,open:A,onOpenChange:C,onInsertLink:ke})})]}),F&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col gap-1 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"send-cross-mention",checked:P,onCheckedChange:D}),jsxRuntime.jsxs(Label,{htmlFor:"send-cross-mention",children:[V("crossPostKey")," ",jsxRuntime.jsx(Forward,{})]})]}),P&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:V("crossPostLimitKey")})]})]}),te?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:le,className:"cursor-pointer active:scale-95",children:jsxRuntime.jsx(X,{})}),jsxRuntime.jsx(Button,{onClick:()=>{oe()},disabled:q,className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95"),children:q?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(SendHorizontal,{})})]}):ee?jsxRuntime.jsx(Button,{onClick:()=>{ne()},disabled:q,className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit ml-auto"),children:q?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(Mic,{})}):E?null:jsxRuntime.jsxs(Tooltip,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[fe&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground px-2","data-testid":"quick-gif-generating",children:V("quickGifGeneratingKey")}),jsxRuntime.jsxs(Button,{disabled:N?.isEmpty||p||!j&&W,onPointerDown:Se,onPointerUp:me,onPointerLeave:Re,onPointerCancel:Re,onClick:Te=>{if(de.current){de.current=!1,Te.preventDefault();return}m(P)},className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit",(!j&&W||p)&&"pointer-events-none"),children:[V("postKey")," ",p?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(SendHorizontal,{})]})]})}),jsxRuntime.jsx(TooltipContent,{side:"top",hidden:!W||j,children:V("uploadsInProgressKey")})]})]})]})},VerticalSeparator=()=>jsxRuntime.jsx("div",{className:"h-3 w-px bg-border"});function createSlot$1(u){const n=createSlotClone$1(u),d=React__namespace.forwardRef((p,m)=>{const{children:g,...y}=p,b=React__namespace.Children.toArray(g),S=b.find(isSlottable$1);if(S){const E=S.props.children,T=b.map(_=>_===S?React__namespace.Children.count(E)>1?React__namespace.Children.only(null):React__namespace.isValidElement(E)?E.props.children:null:_);return jsxRuntime.jsx(n,{...y,ref:m,children:React__namespace.isValidElement(E)?React__namespace.cloneElement(E,void 0,T):null})}return jsxRuntime.jsx(n,{...y,ref:m,children:g})});return d.displayName=`${u}.Slot`,d}function createSlotClone$1(u){const n=React__namespace.forwardRef((d,p)=>{const{children:m,...g}=d;if(React__namespace.isValidElement(m)){const y=getElementRef$1(m),b=mergeProps$1(g,m.props);return m.type!==React__namespace.Fragment&&(b.ref=p?composeRefs(p,y):y),React__namespace.cloneElement(m,b)}return React__namespace.Children.count(m)>1?React__namespace.Children.only(null):null});return n.displayName=`${u}.SlotClone`,n}var SLOTTABLE_IDENTIFIER$1=Symbol("radix.slottable");function isSlottable$1(u){return React__namespace.isValidElement(u)&&typeof u.type=="function"&&"__radixId"in u.type&&u.type.__radixId===SLOTTABLE_IDENTIFIER$1}function mergeProps$1(u,n){const d={...n};for(const p in n){const m=u[p],g=n[p];/^on[A-Z]/.test(p)?m&&g?d[p]=(...b)=>{const S=g(...b);return m(...b),S}:m&&(d[p]=m):p==="style"?d[p]={...m,...g}:p==="className"&&(d[p]=[m,g].filter(Boolean).join(" "))}return{...u,...d}}function getElementRef$1(u){let n=Object.getOwnPropertyDescriptor(u.props,"ref")?.get,d=n&&"isReactWarning"in n&&n.isReactWarning;return d?u.ref:(n=Object.getOwnPropertyDescriptor(u,"ref")?.get,d=n&&"isReactWarning"in n&&n.isReactWarning,d?u.props.ref:u.props.ref||u.ref)}var DIALOG_NAME="Dialog",[createDialogContext]=createContextScope$2(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=u=>{const{__scopeDialog:n,children:d,open:p,defaultOpen:m,onOpenChange:g,modal:y=!0}=u,b=React__namespace.useRef(null),S=React__namespace.useRef(null),[E,T]=useControllableState({prop:p,defaultProp:m??!1,onChange:g,caller:DIALOG_NAME});return jsxRuntime.jsx(DialogProvider,{scope:n,triggerRef:b,contentRef:S,contentId:useId(),titleId:useId(),descriptionId:useId(),open:E,onOpenChange:T,onOpenToggle:React__namespace.useCallback(()=>T(_=>!_),[T]),modal:y,children:d})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME$1="DialogTrigger",DialogTrigger$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(TRIGGER_NAME$1,d),g=useComposedRefs(n,m.triggerRef);return jsxRuntime.jsx(Primitive$5.button,{type:"button","aria-haspopup":"dialog","aria-expanded":m.open,"aria-controls":m.contentId,"data-state":getState$2(m.open),...p,ref:g,onClick:composeEventHandlers(u.onClick,m.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME$1;var PORTAL_NAME$1="DialogPortal",[PortalProvider$1,usePortalContext$1]=createDialogContext(PORTAL_NAME$1,{forceMount:void 0}),DialogPortal$1=u=>{const{__scopeDialog:n,forceMount:d,children:p,container:m}=u,g=useDialogContext(PORTAL_NAME$1,n);return jsxRuntime.jsx(PortalProvider$1,{scope:n,forceMount:d,children:React__namespace.Children.map(p,y=>jsxRuntime.jsx(Presence,{present:d||g.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:m,children:y})}))})};DialogPortal$1.displayName=PORTAL_NAME$1;var OVERLAY_NAME="DialogOverlay",DialogOverlay$1=React__namespace.forwardRef((u,n)=>{const d=usePortalContext$1(OVERLAY_NAME,u.__scopeDialog),{forceMount:p=d.forceMount,...m}=u,g=useDialogContext(OVERLAY_NAME,u.__scopeDialog);return g.modal?jsxRuntime.jsx(Presence,{present:p||g.open,children:jsxRuntime.jsx(DialogOverlayImpl,{...m,ref:n})}):null});DialogOverlay$1.displayName=OVERLAY_NAME;var Slot$1=createSlot$1("DialogOverlay.RemoveScroll"),DialogOverlayImpl=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(OVERLAY_NAME,d);return jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,shards:[m.contentRef],children:jsxRuntime.jsx(Primitive$5.div,{"data-state":getState$2(m.open),...p,ref:n,style:{pointerEvents:"auto",...p.style}})})}),CONTENT_NAME$1="DialogContent",DialogContent$1=React__namespace.forwardRef((u,n)=>{const d=usePortalContext$1(CONTENT_NAME$1,u.__scopeDialog),{forceMount:p=d.forceMount,...m}=u,g=useDialogContext(CONTENT_NAME$1,u.__scopeDialog);return jsxRuntime.jsx(Presence,{present:p||g.open,children:g.modal?jsxRuntime.jsx(DialogContentModal,{...m,ref:n}):jsxRuntime.jsx(DialogContentNonModal,{...m,ref:n})})});DialogContent$1.displayName=CONTENT_NAME$1;var DialogContentModal=React__namespace.forwardRef((u,n)=>{const d=useDialogContext(CONTENT_NAME$1,u.__scopeDialog),p=React__namespace.useRef(null),m=useComposedRefs(n,d.contentRef,p);return React__namespace.useEffect(()=>{const g=p.current;if(g)return hideOthers(g)},[]),jsxRuntime.jsx(DialogContentImpl,{...u,ref:m,trapFocus:d.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(u.onCloseAutoFocus,g=>{g.preventDefault(),d.triggerRef.current?.focus()}),onPointerDownOutside:composeEventHandlers(u.onPointerDownOutside,g=>{const y=g.detail.originalEvent,b=y.button===0&&y.ctrlKey===!0;(y.button===2||b)&&g.preventDefault()}),onFocusOutside:composeEventHandlers(u.onFocusOutside,g=>g.preventDefault())})}),DialogContentNonModal=React__namespace.forwardRef((u,n)=>{const d=useDialogContext(CONTENT_NAME$1,u.__scopeDialog),p=React__namespace.useRef(!1),m=React__namespace.useRef(!1);return jsxRuntime.jsx(DialogContentImpl,{...u,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:g=>{u.onCloseAutoFocus?.(g),g.defaultPrevented||(p.current||d.triggerRef.current?.focus(),g.preventDefault()),p.current=!1,m.current=!1},onInteractOutside:g=>{u.onInteractOutside?.(g),g.defaultPrevented||(p.current=!0,g.detail.originalEvent.type==="pointerdown"&&(m.current=!0));const y=g.target;d.triggerRef.current?.contains(y)&&g.preventDefault(),g.detail.originalEvent.type==="focusin"&&m.current&&g.preventDefault()}})}),DialogContentImpl=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,trapFocus:p,onOpenAutoFocus:m,onCloseAutoFocus:g,...y}=u,b=useDialogContext(CONTENT_NAME$1,d),S=React__namespace.useRef(null),E=useComposedRefs(n,S);return useFocusGuards(),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:p,onMountAutoFocus:m,onUnmountAutoFocus:g,children:jsxRuntime.jsx(DismissableLayer,{role:"dialog",id:b.contentId,"aria-describedby":b.descriptionId,"aria-labelledby":b.titleId,"data-state":getState$2(b.open),...y,ref:E,onDismiss:()=>b.onOpenChange(!1)})}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleWarning,{titleId:b.titleId}),jsxRuntime.jsx(DescriptionWarning,{contentRef:S,descriptionId:b.descriptionId})]})]})}),TITLE_NAME="DialogTitle",DialogTitle$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(TITLE_NAME,d);return jsxRuntime.jsx(Primitive$5.h2,{id:m.titleId,...p,ref:n})});DialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="DialogDescription",DialogDescription$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(DESCRIPTION_NAME,d);return jsxRuntime.jsx(Primitive$5.p,{id:m.descriptionId,...p,ref:n})});DialogDescription$1.displayName=DESCRIPTION_NAME;var CLOSE_NAME$1="DialogClose",DialogClose$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(CLOSE_NAME$1,d);return jsxRuntime.jsx(Primitive$5.button,{type:"button",...p,ref:n,onClick:composeEventHandlers(u.onClick,()=>m.onOpenChange(!1))})});DialogClose$1.displayName=CLOSE_NAME$1;function getState$2(u){return u?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME$1,titleName:TITLE_NAME,docsSlug:"dialog"}),TitleWarning=({titleId:u})=>{const n=useWarningContext(TITLE_WARNING_NAME),d=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
|
|
168
|
+
`;let c;function compressOnWebWorker(u,n){return new Promise(((d,p)=>{c||(c=(function(y){const b=[];return b.push(y),URL.createObjectURL(new Blob(b))})(l));const m=new Worker(c);m.addEventListener("message",(function(y){if(n.signal&&n.signal.aborted)m.terminate();else if(y.data.progress===void 0){if(y.data.error)return p(new Error(y.data.error)),void m.terminate();d(y.data.file),m.terminate()}else n.onProgress(y.data.progress)})),m.addEventListener("error",p),n.signal&&n.signal.addEventListener("abort",(()=>{p(n.signal.reason),m.terminate()})),m.postMessage({file:u,imageCompressionLibUrl:n.libURL,options:{...n,onProgress:void 0,signal:void 0}})}))}function imageCompression(u,n){return new Promise((function(d,p){let m,g,y,b,S,E;if(m={...n},y=0,{onProgress:b}=m,m.maxSizeMB=m.maxSizeMB||Number.POSITIVE_INFINITY,S=typeof m.useWebWorker!="boolean"||m.useWebWorker,delete m.useWebWorker,m.onProgress=A=>{y=A,typeof b=="function"&&b(y)},!(u instanceof Blob||u instanceof CustomFile))return p(new Error("The file given is not an instance of Blob or File"));if(!/^image/.test(u.type))return p(new Error("The file given is not an image"));if(E=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope,!S||typeof Worker!="function"||E)return compress(u,m).then((function(A){try{return g=A,R.call(this)}catch(C){return p(C)}}).bind(this),p);var T=(function(){try{return R.call(this)}catch(A){return p(A)}}).bind(this),_=function(A){try{return compress(u,m).then((function(C){try{return g=C,T()}catch(k){return p(k)}}),p)}catch(C){return p(C)}};try{return m.libURL=m.libURL||"https://cdn.jsdelivr.net/npm/browser-image-compression@2.0.2/dist/browser-image-compression.js",compressOnWebWorker(u,m).then((function(A){try{return g=A,T()}catch{return _()}}),_)}catch{_()}function R(){try{g.name=u.name,g.lastModified=u.lastModified}catch{}try{m.preserveExif&&u.type==="image/jpeg"&&(!m.fileType||m.fileType&&m.fileType===u.type)&&(g=copyExifWithoutOrientation(u,g))}catch{}return d(g)}}))}imageCompression.getDataUrlFromFile=getDataUrlFromFile,imageCompression.getFilefromDataUrl=getFilefromDataUrl,imageCompression.loadImage=loadImage,imageCompression.drawImageInCanvas=drawImageInCanvas,imageCompression.drawFileInCanvas=drawFileInCanvas,imageCompression.canvasToFile=canvasToFile,imageCompression.getExifOrientation=getExifOrientation,imageCompression.handleMaxWidthOrHeight=handleMaxWidthOrHeight,imageCompression.followExifOrientation=followExifOrientation,imageCompression.cleanupCanvasMemory=cleanupCanvasMemory,imageCompression.isAutoOrientationInBrowser=isAutoOrientationInBrowser,imageCompression.approximateBelowMaximumCanvasSizeOfBrowser=approximateBelowMaximumCanvasSizeOfBrowser,imageCompression.copyExifWithoutOrientation=copyExifWithoutOrientation,imageCompression.getBrowserName=getBrowserName,imageCompression.version="2.0.2";const ImageSearchModal$1=React.lazy(()=>Promise.resolve().then(()=>mediaSearch).then(u=>({default:u.ImageSearchModal}))),LinkDecoratorModal$1=React.lazy(()=>Promise.resolve().then(()=>linkDecorator).then(u=>({default:u.LinkDecoratorModal}))),TOOLBAR_FEATURES={[EditorTypes.Blog]:{showFormatting:!0,showImage:!0,showVideo:!0,showAudio:!0,showImageSearch:!0,showLink:!0},[EditorTypes.Media]:{showFormatting:!1,showImage:!0,showVideo:!0,showAudio:!1,showImageSearch:!0,showLink:!0},[EditorTypes.Poll]:{}},QUICK_GIF_HOLD_MS=500,Toolbar=({actions:u,editorType:n,children:d,isSubmitting:p,onSubmit:m,placement:g,onVoiceComment:y,onVoiceRecord:b,onQuickGif:S,hideSubmitButton:E})=>{const T=React.useRef(null),[_,R]=React.useState(null),[A,C]=React.useState(!1),[k,I]=React.useState(!1),[P,D]=React.useState(!1),{editor:O}=useCurrentEditor(),N=useEditorStateSnapshot(O),{showCrossMentionIndicator:F}=useEditorWithMentionTracking(O,{debounceMs:150}),{trackFeature:L}=useAnalyticsTracking(),{t:V,allowSendWhileUploading:j,unauthenticatedMode:Y}=usePostBuilder(),{fileStore:J}=useApi(),{isRecording:te,duration:Q,volume:se,startRecording:Z,stopRecording:re,cancelRecording:B}=useVoiceRecorder({maxDuration:60}),[q,H]=React.useState(!1),W=useUploadingState(O),ee=g===EditorPlacement.Comment&&!!y&&N?.isEmpty&&!p&&!te&&!Y,ne=async()=>{try{await Z()}catch{toast.error("Could not access microphone. Please check your browser permissions.")}},oe=async()=>{if(te)try{const{blob:Te,duration:Ie}=await re();if(j&&b){b({blob:Te,voiceTime:Ie});return}H(!0);const $e=Te.type.split("/")[1]?.split(";")[0]??"webm",Ue=new File([Te],`${v4()}.${$e}`),Ye=await J.uploadVoiceV2(Ue);Ye?.url&&y?.({voiceUrl:Ye.url,voiceTime:Ie})}catch{}finally{H(!1)}},le=()=>{B()},ce=React.useRef(null),ae=React.useRef(!1),de=React.useRef(!1),[fe,pe]=React.useState(!1),ye=()=>{if(!O)return!1;const Te=O.getJSON(),Ie=findByType(Te,"media"),$e=findByType(Te,"mediaGroup");return Ie.length>0||$e.length>0},ve=()=>!!S&&!te&&!!O&&O.getText().trim().length>0&&!ye()&&!Y,be=()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},ge=()=>{be(),ae.current=!1,pe(!1)},Se=()=>{de.current=!1,ae.current=!1,ve()&&(ce.current=setTimeout(()=>{ae.current=!0,pe(!0)},QUICK_GIF_HOLD_MS))},me=()=>{if(be(),ae.current){ae.current=!1,pe(!1);const Te=O?.getText().trim()??"";Te&&S&&(de.current=!0,S({text:Te,sendCrossMention:P}))}},Re=()=>{ge()};if(!O)return null;const Ce=TOOLBAR_FEATURES[n],Ae=Te=>{if(N?.isLink){O.chain().focus().unsetLink().run(),Te.preventDefault();return}C(!0)},ke=(Te,Ie,$e,Ue)=>{const Ye=n===EditorTypes.Blog&&Ie||Te;if($e){O.commands.updateLink($e,{href:Te,text:Ye,previewPayload:Ue});return}O.commands.insertLink({href:Te,text:Ye,previewPayload:Ue})},De=()=>{const Te=O.getJSON();return findByType(Te,"media").length>=10?(toast.error(`You can upload up to ${MAX_FILES} files per post. Please remove some files before adding new ones.`),!0):!1},je=()=>{if(n!==EditorTypes.Media){T?.current?.click();return}De()||T?.current?.click()},Ne=async Te=>{const Ie=Te.target.files;if(!Ie||!_)return;let $e=Array.from(Ie);$e.length>MAX_FILES&&(toast.error(`You can upload up to ${MAX_FILES} files per post. Picking the first ${MAX_FILES} files`),$e=$e.slice(0,MAX_FILES));const Ue=MAX_FILE_SIZE,Ye=Ue/(1024*1024),ze=$e.filter(We=>We.size>Ue);if(ze.length>0){const We=ze.map(Ge=>Ge.name).join(", ");if(toast.error(`${ze.length>1?"Some files exceed":`"${We}" exceeds`} the ${Ye}MB limit`),$e=$e.filter(Ge=>Ge.size<=Ue),$e.length===0){Te.target.value="";return}}_===MediaNodeTypes.Image&&($e=await Promise.all($e.map(async We=>{try{return await imageCompression(We,{maxSizeMB:10})}catch{return We}}))),$e.forEach(We=>{let Ge=_;We.type.startsWith("image/")?Ge=MediaNodeTypes.Image:We.type.startsWith("video/")?Ge=MediaNodeTypes.Video:We.type.startsWith("audio/")&&(Ge=MediaNodeTypes.Audio),O.commands.insertMediaWithUpload({source:We,type:Ge,mediaType:MediaItemType.MEDIA_ITEM})}),Te.target.value=""},Fe=Te=>{if(De()){Te.preventDefault();return}I(!0)},Le=(Te,Ie)=>{Ie&&L(Ie===ImageSearchFrom.Gif?"gif_search":"image_search"),O?.commands.insertMediaWithUpload({source:Te,type:MediaNodeTypes.Image,mediaType:MediaItemType.IMAGE_ITEM,searchFrom:Ie})},Oe=Te=>Te?.isHeading1?Heading1:Te?.isHeading2?Heading2:Te?.isHeading3?Heading3:Type;return jsxRuntime.jsxs("div",{className:"flex flex-col grow overflow-y-auto",children:[Ce.showFormatting&&jsxRuntime.jsxs("div",{className:"shrink-0 flex flex-wrap items-center gap-2 sm:gap-2 p-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.undo,icon:Undo,tooltip:"undoKey",onClick:u?.undo,disabled:!N?.canUndo}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.redo,icon:Redo,tooltip:"redoKey",onClick:u?.redo,disabled:!N?.canRedo}),jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{tooltip:"headingOptionsKey",icon:Oe(N),"aria-label":"More formatting options"})}),jsxRuntime.jsx(DropdownMenuContent,{align:"start",className:"w-44 px-1 py-1",children:jsxRuntime.jsxs("div",{className:"flex flex-col items-stretch gap-1",children:[jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:FEATURE_NAME_MAP.paragraph,className:"w-full justify-start",tooltip:"paragraphKey",onClick:u?.setParagraph,active:N?.isParagraph,disabled:!N?.canParagraph,children:[jsxRuntime.jsx(Type,{})," ",V("paragraphKey")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[1],className:"w-full justify-start",tooltip:"heading1Key",onClick:()=>u?.toggleHeading(1),active:N?.isHeading1,disabled:!N?.canHeading1,children:[jsxRuntime.jsx(Heading1,{})," ",V("heading1Key")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[2],className:"w-full justify-start",tooltip:"heading2Key",onClick:()=>u?.toggleHeading(2),active:N?.isHeading2,disabled:!N?.canHeading2,children:[jsxRuntime.jsx(Heading2,{})," ",V("heading2Key")]})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsxs(ToolbarButton,{id:HEADING_FEATURE_MAP[3],className:"w-full justify-start",tooltip:"heading3Key",onClick:()=>u?.toggleHeading(3),active:N?.isHeading3,disabled:!N?.canHeading3,children:[jsxRuntime.jsx(Heading3,{})," ",V("heading3Key")]})})]})})]}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.bold,icon:Bold$1,tooltip:"boldKey",onClick:u?.toggleBold,active:N?.isBold,disabled:!N?.canBold}),jsxRuntime.jsxs("div",{className:"hidden xl:flex items-center gap-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.italic,icon:Italic$1,tooltip:"italicKey",onClick:u?.toggleItalic,active:N?.isItalic,disabled:!N?.canItalic}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.strike,icon:Strikethrough,tooltip:"strikethroughKey",onClick:u?.toggleStrikethrough,active:N?.isStrike,disabled:!N?.canStrike})]}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.bulletList,icon:List,tooltip:"bulletListKey",onClick:u?.toggleBulletList,active:N?.isBulletList,disabled:!N?.canBulletList}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.orderedList,icon:ListOrdered,tooltip:"orderedListKey",onClick:u?.toggleOrderedList,active:N?.isOrderedList,disabled:!N?.canOrderedList}),jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsxs("div",{className:"hidden xl:flex flex-wrap items-center gap-2",children:[jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.blockquote,icon:TextQuote,tooltip:"blockquoteKey",onClick:u?.toggleBlockquote,active:N?.isBlockquote,disabled:!N?.canBlockquote}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.code,icon:Code$1,tooltip:"codeKey",onClick:u?.toggleCode,active:N?.isCode,disabled:!N?.canCode}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.codeBlock,icon:FileCode2,tooltip:"codeBlockKey",onClick:u?.toggleCodeBlock,active:N?.isCodeBlock,disabled:!N?.canCodeBlock})]}),jsxRuntime.jsx("div",{className:"flex xl:hidden",children:jsxRuntime.jsxs(DropdownMenu,{children:[jsxRuntime.jsx(DropdownMenuTrigger,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{tooltip:"moreOptionsKey",icon:Ellipsis,"aria-label":"More formatting options"})}),jsxRuntime.jsx(DropdownMenuContent,{align:"end",className:"w-fit px-2 py-1",children:jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.italic,icon:Italic$1,tooltip:"italicKey",onClick:u?.toggleItalic,active:N?.isItalic,disabled:!N?.canItalic})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.strike,icon:Strikethrough,tooltip:"strikethroughKey",onClick:u?.toggleStrikethrough,active:N?.isStrike,disabled:!N?.canStrike})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.blockquote,icon:TextQuote,tooltip:"blockquoteKey",onClick:u?.toggleBlockquote,active:N?.isBlockquote,disabled:!N?.canBlockquote})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.code,icon:Code$1,tooltip:"codeKey",onClick:u?.toggleCode,active:N?.isCode,disabled:!N?.canCode})}),jsxRuntime.jsx(DropdownMenuItem,{asChild:!0,children:jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.codeBlock,icon:FileCode2,tooltip:"codeBlockKey",onClick:u?.toggleCodeBlock,active:N?.isCodeBlock,disabled:!N?.canCodeBlock})})]})})]})})]}),jsxRuntime.jsxs("div",{className:"relative grow flex flex-col overflow-y-auto",children:[jsxRuntime.jsx(VoiceRecordingOverlay,{isRecording:te,duration:Q,volume:se}),d]}),F&&jsxRuntime.jsxs("div",{className:"sm:hidden flex flex-col gap-1 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"send-cross-mention",checked:P,onCheckedChange:D}),jsxRuntime.jsxs(Label,{htmlFor:"send-cross-mention",className:"text-xs",children:["Cross-post to groups you #mention? ",jsxRuntime.jsx(Forward,{className:"size-4"})]})]}),P&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:V("crossPostLimitKey")})]}),jsxRuntime.jsxs("div",{className:cn("shrink-0 flex items-center sm:gap-2 p-2 border-t",E&&!Ce.showImage&&!Ce.showVideo&&!Ce.showImageSearch&&!Ce.showLink&&"hidden"),children:[jsxRuntime.jsx("input",{ref:T,type:"file",multiple:!0,maxLength:2,accept:`${MEDIA_ACCEPTS[MediaNodeTypes.Image]}, ${MEDIA_ACCEPTS[MediaNodeTypes.Video]}`,hidden:!0,onChange:Ne}),Ce.showImage&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.image,icon:ImagePlus,tooltip:"insertImageKey",disabled:te||!N?.canInsertImage,onMouseOver:()=>R(MediaNodeTypes.Image),onClick:je}),Ce.showVideo&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.video,icon:Video,disabled:te||!N?.canInsertVideo,tooltip:"insertVideoKey",onMouseOver:()=>R(MediaNodeTypes.Video),onClick:je}),Ce.showAudio&&jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.audio,icon:Music,disabled:te||!N?.canInsertAudio,tooltip:"insertAudioKey",onMouseOver:()=>R(MediaNodeTypes.Audio),onClick:je}),Ce.showImageSearch&&!Y&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ToolbarButton,{onClick:Fe,disabled:te||!N?.canInsertImage,icon:GifIcon,tooltip:"searchGifOrImagesKey",className:"p-1 [&>svg]:size-5!"}),k&&jsxRuntime.jsx(React.Suspense,{fallback:null,children:jsxRuntime.jsx(ImageSearchModal$1,{open:k,onOpenChange:I,onImageSelect:Le,initialQuery:extractInitialSearchQuery(O)})})]}),Ce.showLink&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsx(ToolbarButton,{id:FEATURE_NAME_MAP.customLink,icon:Link$1,tooltip:"addLinkPreviewKey",onClick:Ae,active:N?.isLink,disabled:te||!N?.canLink}),A&&jsxRuntime.jsx(React.Suspense,{fallback:null,children:jsxRuntime.jsx(LinkDecoratorModal$1,{hideTextInput:!0,open:A,onOpenChange:C,onInsertLink:ke})})]}),F&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(VerticalSeparator,{}),jsxRuntime.jsxs("div",{className:"hidden sm:flex flex-col gap-1 px-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center space-x-2",children:[jsxRuntime.jsx(Switch,{id:"send-cross-mention",checked:P,onCheckedChange:D}),jsxRuntime.jsxs(Label,{htmlFor:"send-cross-mention",children:[V("crossPostKey")," ",jsxRuntime.jsx(Forward,{})]})]}),P&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:V("crossPostLimitKey")})]})]}),te?jsxRuntime.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[jsxRuntime.jsx(Button,{variant:"outline",onClick:le,className:"cursor-pointer active:scale-95",children:jsxRuntime.jsx(X,{})}),jsxRuntime.jsx(Button,{onClick:()=>{oe()},disabled:q,className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95"),children:q?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(SendHorizontal,{})})]}):ee?jsxRuntime.jsx(Button,{onClick:()=>{ne()},disabled:q,className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit ml-auto"),children:q?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(Mic,{})}):E?null:jsxRuntime.jsxs(Tooltip,{children:[jsxRuntime.jsx(TooltipTrigger,{asChild:!0,children:jsxRuntime.jsxs("span",{className:"ml-auto flex items-center gap-2",children:[fe&&jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground px-2","data-testid":"quick-gif-generating",children:V("quickGifGeneratingKey")}),jsxRuntime.jsxs(Button,{disabled:N?.isEmpty||p||!j&&W,onPointerDown:Se,onPointerUp:me,onPointerLeave:Re,onPointerCancel:Re,onClick:Te=>{if(de.current){de.current=!1,Te.preventDefault();return}m(P)},className:cn("cursor-pointer bg-primary-send text-primary-send-fg hover:bg-primary-send/85 active:scale-95 w-fit",(!j&&W||p)&&"pointer-events-none"),children:[V("postKey")," ",p?jsxRuntime.jsx(Spinner,{}):jsxRuntime.jsx(SendHorizontal,{})]})]})}),jsxRuntime.jsx(TooltipContent,{side:"top",hidden:!W||j,children:V("uploadsInProgressKey")})]})]})]})},VerticalSeparator=()=>jsxRuntime.jsx("div",{className:"h-3 w-px bg-border"});function createSlot$1(u){const n=createSlotClone$1(u),d=React__namespace.forwardRef((p,m)=>{const{children:g,...y}=p,b=React__namespace.Children.toArray(g),S=b.find(isSlottable$1);if(S){const E=S.props.children,T=b.map(_=>_===S?React__namespace.Children.count(E)>1?React__namespace.Children.only(null):React__namespace.isValidElement(E)?E.props.children:null:_);return jsxRuntime.jsx(n,{...y,ref:m,children:React__namespace.isValidElement(E)?React__namespace.cloneElement(E,void 0,T):null})}return jsxRuntime.jsx(n,{...y,ref:m,children:g})});return d.displayName=`${u}.Slot`,d}function createSlotClone$1(u){const n=React__namespace.forwardRef((d,p)=>{const{children:m,...g}=d;if(React__namespace.isValidElement(m)){const y=getElementRef$1(m),b=mergeProps$1(g,m.props);return m.type!==React__namespace.Fragment&&(b.ref=p?composeRefs(p,y):y),React__namespace.cloneElement(m,b)}return React__namespace.Children.count(m)>1?React__namespace.Children.only(null):null});return n.displayName=`${u}.SlotClone`,n}var SLOTTABLE_IDENTIFIER$1=Symbol("radix.slottable");function isSlottable$1(u){return React__namespace.isValidElement(u)&&typeof u.type=="function"&&"__radixId"in u.type&&u.type.__radixId===SLOTTABLE_IDENTIFIER$1}function mergeProps$1(u,n){const d={...n};for(const p in n){const m=u[p],g=n[p];/^on[A-Z]/.test(p)?m&&g?d[p]=(...b)=>{const S=g(...b);return m(...b),S}:m&&(d[p]=m):p==="style"?d[p]={...m,...g}:p==="className"&&(d[p]=[m,g].filter(Boolean).join(" "))}return{...u,...d}}function getElementRef$1(u){let n=Object.getOwnPropertyDescriptor(u.props,"ref")?.get,d=n&&"isReactWarning"in n&&n.isReactWarning;return d?u.ref:(n=Object.getOwnPropertyDescriptor(u,"ref")?.get,d=n&&"isReactWarning"in n&&n.isReactWarning,d?u.props.ref:u.props.ref||u.ref)}var DIALOG_NAME="Dialog",[createDialogContext]=createContextScope$2(DIALOG_NAME),[DialogProvider,useDialogContext]=createDialogContext(DIALOG_NAME),Dialog$1=u=>{const{__scopeDialog:n,children:d,open:p,defaultOpen:m,onOpenChange:g,modal:y=!0}=u,b=React__namespace.useRef(null),S=React__namespace.useRef(null),[E,T]=useControllableState({prop:p,defaultProp:m??!1,onChange:g,caller:DIALOG_NAME});return jsxRuntime.jsx(DialogProvider,{scope:n,triggerRef:b,contentRef:S,contentId:useId(),titleId:useId(),descriptionId:useId(),open:E,onOpenChange:T,onOpenToggle:React__namespace.useCallback(()=>T(_=>!_),[T]),modal:y,children:d})};Dialog$1.displayName=DIALOG_NAME;var TRIGGER_NAME$1="DialogTrigger",DialogTrigger$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(TRIGGER_NAME$1,d),g=useComposedRefs(n,m.triggerRef);return jsxRuntime.jsx(Primitive$5.button,{type:"button","aria-haspopup":"dialog","aria-expanded":m.open,"aria-controls":m.contentId,"data-state":getState$2(m.open),...p,ref:g,onClick:composeEventHandlers(u.onClick,m.onOpenToggle)})});DialogTrigger$1.displayName=TRIGGER_NAME$1;var PORTAL_NAME$1="DialogPortal",[PortalProvider$1,usePortalContext$1]=createDialogContext(PORTAL_NAME$1,{forceMount:void 0}),DialogPortal$1=u=>{const{__scopeDialog:n,forceMount:d,children:p,container:m}=u,g=useDialogContext(PORTAL_NAME$1,n);return jsxRuntime.jsx(PortalProvider$1,{scope:n,forceMount:d,children:React__namespace.Children.map(p,y=>jsxRuntime.jsx(Presence,{present:d||g.open,children:jsxRuntime.jsx(Portal$5,{asChild:!0,container:m,children:y})}))})};DialogPortal$1.displayName=PORTAL_NAME$1;var OVERLAY_NAME="DialogOverlay",DialogOverlay$1=React__namespace.forwardRef((u,n)=>{const d=usePortalContext$1(OVERLAY_NAME,u.__scopeDialog),{forceMount:p=d.forceMount,...m}=u,g=useDialogContext(OVERLAY_NAME,u.__scopeDialog);return g.modal?jsxRuntime.jsx(Presence,{present:p||g.open,children:jsxRuntime.jsx(DialogOverlayImpl,{...m,ref:n})}):null});DialogOverlay$1.displayName=OVERLAY_NAME;var Slot$1=createSlot$1("DialogOverlay.RemoveScroll"),DialogOverlayImpl=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(OVERLAY_NAME,d);return jsxRuntime.jsx(ReactRemoveScroll,{as:Slot$1,allowPinchZoom:!0,shards:[m.contentRef],children:jsxRuntime.jsx(Primitive$5.div,{"data-state":getState$2(m.open),...p,ref:n,style:{pointerEvents:"auto",...p.style}})})}),CONTENT_NAME$1="DialogContent",DialogContent$1=React__namespace.forwardRef((u,n)=>{const d=usePortalContext$1(CONTENT_NAME$1,u.__scopeDialog),{forceMount:p=d.forceMount,...m}=u,g=useDialogContext(CONTENT_NAME$1,u.__scopeDialog);return jsxRuntime.jsx(Presence,{present:p||g.open,children:g.modal?jsxRuntime.jsx(DialogContentModal,{...m,ref:n}):jsxRuntime.jsx(DialogContentNonModal,{...m,ref:n})})});DialogContent$1.displayName=CONTENT_NAME$1;var DialogContentModal=React__namespace.forwardRef((u,n)=>{const d=useDialogContext(CONTENT_NAME$1,u.__scopeDialog),p=React__namespace.useRef(null),m=useComposedRefs(n,d.contentRef,p);return React__namespace.useEffect(()=>{const g=p.current;if(g)return hideOthers(g)},[]),jsxRuntime.jsx(DialogContentImpl,{...u,ref:m,trapFocus:d.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:composeEventHandlers(u.onCloseAutoFocus,g=>{g.preventDefault(),d.triggerRef.current?.focus()}),onPointerDownOutside:composeEventHandlers(u.onPointerDownOutside,g=>{const y=g.detail.originalEvent,b=y.button===0&&y.ctrlKey===!0;(y.button===2||b)&&g.preventDefault()}),onFocusOutside:composeEventHandlers(u.onFocusOutside,g=>g.preventDefault())})}),DialogContentNonModal=React__namespace.forwardRef((u,n)=>{const d=useDialogContext(CONTENT_NAME$1,u.__scopeDialog),p=React__namespace.useRef(!1),m=React__namespace.useRef(!1);return jsxRuntime.jsx(DialogContentImpl,{...u,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:g=>{u.onCloseAutoFocus?.(g),g.defaultPrevented||(p.current||d.triggerRef.current?.focus(),g.preventDefault()),p.current=!1,m.current=!1},onInteractOutside:g=>{u.onInteractOutside?.(g),g.defaultPrevented||(p.current=!0,g.detail.originalEvent.type==="pointerdown"&&(m.current=!0));const y=g.target;d.triggerRef.current?.contains(y)&&g.preventDefault(),g.detail.originalEvent.type==="focusin"&&m.current&&g.preventDefault()}})}),DialogContentImpl=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,trapFocus:p,onOpenAutoFocus:m,onCloseAutoFocus:g,...y}=u,b=useDialogContext(CONTENT_NAME$1,d),S=React__namespace.useRef(null),E=useComposedRefs(n,S);return useFocusGuards(),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(FocusScope,{asChild:!0,loop:!0,trapped:p,onMountAutoFocus:m,onUnmountAutoFocus:g,children:jsxRuntime.jsx(DismissableLayer,{role:"dialog",id:b.contentId,"aria-describedby":b.descriptionId,"aria-labelledby":b.titleId,"data-state":getState$2(b.open),...y,ref:E,onDismiss:()=>b.onOpenChange(!1)})}),jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(TitleWarning,{titleId:b.titleId}),jsxRuntime.jsx(DescriptionWarning,{contentRef:S,descriptionId:b.descriptionId})]})]})}),TITLE_NAME="DialogTitle",DialogTitle$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(TITLE_NAME,d);return jsxRuntime.jsx(Primitive$5.h2,{id:m.titleId,...p,ref:n})});DialogTitle$1.displayName=TITLE_NAME;var DESCRIPTION_NAME="DialogDescription",DialogDescription$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(DESCRIPTION_NAME,d);return jsxRuntime.jsx(Primitive$5.p,{id:m.descriptionId,...p,ref:n})});DialogDescription$1.displayName=DESCRIPTION_NAME;var CLOSE_NAME$1="DialogClose",DialogClose$1=React__namespace.forwardRef((u,n)=>{const{__scopeDialog:d,...p}=u,m=useDialogContext(CLOSE_NAME$1,d);return jsxRuntime.jsx(Primitive$5.button,{type:"button",...p,ref:n,onClick:composeEventHandlers(u.onClick,()=>m.onOpenChange(!1))})});DialogClose$1.displayName=CLOSE_NAME$1;function getState$2(u){return u?"open":"closed"}var TITLE_WARNING_NAME="DialogTitleWarning",[WarningProvider,useWarningContext]=createContext2(TITLE_WARNING_NAME,{contentName:CONTENT_NAME$1,titleName:TITLE_NAME,docsSlug:"dialog"}),TitleWarning=({titleId:u})=>{const n=useWarningContext(TITLE_WARNING_NAME),d=`\`${n.contentName}\` requires a \`${n.titleName}\` for the component to be accessible for screen reader users.
|
|
169
169
|
|
|
170
170
|
If you want to hide the \`${n.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
171
171
|
|
package/dist/post-builder.js
CHANGED
|
@@ -38759,7 +38759,7 @@ const ImageSearchModal$1 = lazy(
|
|
|
38759
38759
|
showFormatting: !0,
|
|
38760
38760
|
showImage: !0,
|
|
38761
38761
|
showVideo: !0,
|
|
38762
|
-
showAudio: !
|
|
38762
|
+
showAudio: !0,
|
|
38763
38763
|
showImageSearch: !0,
|
|
38764
38764
|
showLink: !0
|
|
38765
38765
|
},
|
package/package.json
CHANGED