UNPKG

@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) 1.98 kB
import{jsx as t,jsxs as e}from"react/jsx-runtime";import{useRef as a}from"react";import{LexicalComposer as i}from"@lexical/react/LexicalComposer";import{RichTextPlugin as o}from"@lexical/react/LexicalRichTextPlugin";import{ContentEditable as n}from"@lexical/react/LexicalContentEditable";import r from"@lexical/react/LexicalErrorBoundary";import l from"@mui/material/Box";import{sharedEditorConfig as m,sharedSxProps as s}from"./CommentRichTextConfig.js";import{ReadMorePlugin as c}from"./plugins/ReadMorePlugin.js";import{useTranslate as g}from"../../locales/index.js";import p from"../locale.json.js";import{HighlightPlugin as h}from"./plugins/HighlightPlugin.js";import{AttachmentsPlugin as d}from"./plugins/AttachmentsPlugin.js";import{ReplyAttachmentLabelPlugin as x}from"./plugins/ReplyAttachmentLabelPlugin.js";import{TagsPlugin as u}from"./plugins/TagsPlugin.js";const f="NexusCommentRichTextBlock",C=C=>{const{data:j,replies:L=0,attachments:T=[],tags:y=[],metadata:P,tagging:R,onTagCancel:B,onSave:b,maxLines:A=3,highlight:E,selected:N,richTextConfig:$,onLayoutChange:k,sx:v,...w}=C,M={...m,namespace:f,editorState:j||null,editable:!1},H=g(p),O=a(),S=$?.plugin?.BlockMetaPlugin;return t(l,{ref:O,sx:[{outline:"none",width:"100%",...s,"& .NexusCommentRichTextBlock-item":{overflow:"hidden",lineHeight:"16px"}},...Array.isArray(v)?v:[v]],"data-testid":`${f}-root`,className:`${f}-root`,...w,children:e(i,{initialConfig:M,children:[t(o,{contentEditable:t(n,{"data-testid":`${f}-item`,className:`${f}-item`}),ErrorBoundary:r,placeholder:null}),t(c,{maxLines:A,selected:N,onLayoutChange:k,t:H}),t(h,{highlight:E,initialData:j}),S&&t(S,{boxRef:O,metadata:P,onMetadataChange:t=>{b?.(j,T,y,t)}}),N&&T.length>0&&t(d,{attachments:T,sx:{mt:j?2:0},t:H,...$?.attachment}),t(x,{selected:N,replies:L,attachments:T,t:H}),t(u,{ref:O,mode:"view",tagging:R,tags:y,tagOptions:$?.tag?.tagOptions,onTagsChange:t=>{b?.(j,T,t,P)},onTagCancel:B,t:H})]})})};export{C as CommentRichTextBlock};