Simple Markdown Editor: Bold Text
At Ola, clear and effective communication is paramount, especially within our internal tools. We're building a lightweight text editor for our team's project management platform. This problem challenges you to implement a core feature of rich text editing: applying bold formatting to selected text, mirroring a common markdown-like syntax. This exercise will assess your ability to manage UI state, handle user interactions, and perform basic text manipulation.
Your goal is to build a simple React component that allows users to type text, select a portion of it, and apply bold formatting using a button.
textarea for text input and a "Bold" button.textarea.** on both sides (e.g., hello becomes **hello**).textarea's value with the newly formatted text. Ensure the cursor position and selection are maintained or reset appropriately after formatting.** in the textarea should be rendered as visually bolded HTML (e.g., <strong>).textarea should be clearly visible and allow multi-line input.textarea.textarea should display the formatted preview.aria-label) are a good practice.textarea and a "Bold" button are rendered on the screen.textarea updates its content.textarea and clicks "Bold", the selected text is wrapped with ** markers in the textarea's value.** as bold using <strong> HTML tags.**** and place the cursor in between (handling either is acceptable for this problem).Constraints
selectionStart and selectionEnd properties are available on textarea elements.textarea to retrieve selection information.Loading editor...