In this article, we analyse CopilotTextArea usage in Postiz. Postiz is an open-source social media scheduling tool. As I was reading through its source code, I wanted to find out what sort of editor Postiz uses to let you write content and that is when I came across a file named editor.tsx
There’s two kinds of editor in this editor.tsx file based on user.tier.ai flag.
import { CopilotTextarea } from '@copilotkit/react-textarea';import "@copilotkit/react-textarea/styles.css";<CopilotTextarea autosuggestionsConfig={{ textareaPurpose: "the body of an email message", chatApiConfigs: {}, }}/>
Let’s compare this with the code snippet from Postiz editor.tsx. This is how Postiz has configured its CopilotTextarea.
<CopilotTextarea disableBranding={true} className={clsx( '!min-h-40 !max-h-80 p-2 overflow-hidden bg-customColor2 outline-none' )} value={props.value} onChange={(e) => props?.onChange?.(e.target.value)} placeholder="Write your reply…" autosuggestionsConfig={{ textareaPurpose: `Assist me in writing social media posts.`, chatApiConfigs: {}, }} />
If you do not have AI tier enabled, you will be using MDEditor by @uiw/react-md-editor
MDEditor is a simple markdown editor with preview, implemented with React.js and TypeScript. This React Component aims to provide a simple Markdown editor with syntax highlighting support. This is based on textarea encapsulation, so it does not depend on any modern code editors such as Acs, CodeMirror, Monaco etc.
MDEditor has 115k weekly downloads in the npm registry.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.