{
+ setMarkdown(e.target.value);
+ }}
onInput={handleInput}
+ onKeyDown={onKeyDown}
/>
{tempFiles.map((file, index) => (
@@ -846,6 +548,7 @@ const RichTextEditor: React.FC = ({
filter={mentionFilter}
/>
)}
+
= ({
/>
-
- Remove Link
+
+ setLinkDialogState((prev) => ({ ...prev, showDialog: false }))
+ }
+ >
+ Cancel
Apply Link
@@ -906,3 +614,33 @@ const RichTextEditor: React.FC
= ({
};
export default RichTextEditor;
+
+const getCaretCoordinates = (
+ element: HTMLTextAreaElement,
+ position: number,
+) => {
+ const div = document.createElement("div");
+ const span = document.createElement("span");
+ const computed = getComputedStyle(element);
+
+ div.style.position = "absolute";
+ div.style.whiteSpace = "pre-wrap";
+ div.style.visibility = "hidden";
+
+ for (let i = 0; i < computed.length; i++) {
+ const prop = computed[i];
+ div.style.setProperty(prop, computed.getPropertyValue(prop));
+ }
+
+ div.textContent = element.value.substring(0, position);
+ span.textContent = element.value.substring(position) || ".";
+
+ div.appendChild(span);
+ document.body.appendChild(div);
+
+ const { offsetTop: top, offsetLeft: left } = span;
+
+ document.body.removeChild(div);
+
+ return { top, left, start: position };
+};