@nexusui/components
Version:
These are custom components specially-developed for NexusUI applications. They will make your life easier by giving you out-of-the-box implementations for various high-level UI elements that you can drop directly into your application.
2 lines (1 loc) • 2.11 kB
JavaScript
;Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),a=require("@lexical/react/LexicalComposer"),i=require("@lexical/react/LexicalRichTextPlugin"),n=require("@lexical/react/LexicalContentEditable"),l=require("@lexical/react/LexicalErrorBoundary"),r=require("@mui/material/Box"),s=require("./CommentRichTextConfig.js"),o=require("./plugins/ReadMorePlugin.js"),u=require("../../locales/index.js"),c=require("../locale.json.js"),g=require("./plugins/HighlightPlugin.js"),x=require("./plugins/AttachmentsPlugin.js"),d=require("./plugins/ReplyAttachmentLabelPlugin.js"),h=require("./plugins/TagsPlugin.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var j=m(l),p=m(r);const C="NexusCommentRichTextBlock";exports.CommentRichTextBlock=l=>{const{data:r,replies:m=0,attachments:f=[],tags:q=[],metadata:P,tagging:T,onTagCancel:R,onSave:L,maxLines:y=3,highlight:b,selected:B,richTextConfig:v,onLayoutChange:A,sx:E,...M}=l,k={...s.sharedEditorConfig,namespace:C,editorState:r||null,editable:!1},N=u.useTranslate(c.default),$=t.useRef(),w=v?.plugin?.BlockMetaPlugin;return e.jsx(p.default,{ref:$,sx:[{outline:"none",width:"100%",...s.sharedSxProps,"& .NexusCommentRichTextBlock-item":{overflow:"hidden",lineHeight:"16px"}},...Array.isArray(E)?E:[E]],"data-testid":`${C}-root`,className:`${C}-root`,...M,children:e.jsxs(a.LexicalComposer,{initialConfig:k,children:[e.jsx(i.RichTextPlugin,{contentEditable:e.jsx(n.ContentEditable,{"data-testid":`${C}-item`,className:`${C}-item`}),ErrorBoundary:j.default,placeholder:null}),e.jsx(o.ReadMorePlugin,{maxLines:y,selected:B,onLayoutChange:A,t:N}),e.jsx(g.HighlightPlugin,{highlight:b,initialData:r}),w&&e.jsx(w,{boxRef:$,metadata:P,onMetadataChange:e=>{L?.(r,f,q,e)}}),B&&f.length>0&&e.jsx(x.AttachmentsPlugin,{attachments:f,sx:{mt:r?2:0},t:N,...v?.attachment}),e.jsx(d.ReplyAttachmentLabelPlugin,{selected:B,replies:m,attachments:f,t:N}),e.jsx(h.TagsPlugin,{ref:$,mode:"view",tagging:T,tags:q,tagOptions:v?.tag?.tagOptions,onTagsChange:e=>{L?.(r,f,e,P)},onTagCancel:R,t:N})]})})};