docu version 1.8.5

This commit is contained in:
Wildan Nursahidan
2025-05-17 19:35:31 +07:00
parent 82c3a03d3a
commit a3fcae0112
23 changed files with 866 additions and 6395 deletions

View File

@@ -187,23 +187,24 @@ export default function PlaygroundPage() {
}
};
const insertAtCursor = (textArea: HTMLTextAreaElement, text: string) => {
const insertAtCursor = (textArea: HTMLTextAreaElement, text: string) => {
const start = textArea.selectionStart;
const end = textArea.selectionEnd;
const before = markdown.substring(0, start);
const after = markdown.substring(end);
// Menambahkan satu baris kosong sebelum dan sesudah komponen
const newText = `${before}${text}\n${after}`;
const needsLeadingNewline = before && !before.endsWith('\n\n') ? '\n\n' : '';
const needsTrailingNewline = after && !after.startsWith('\n\n') ? '\n\n' : '';
const newText = `${before}${needsLeadingNewline}${text}${needsTrailingNewline}${after}`;
setMarkdown(newText);
requestAnimationFrame(() => {
textArea.focus();
const newPosition = start + text.length + 1;
textArea.setSelectionRange(newPosition, newPosition);
textArea.focus();
const newPosition = before.length + needsLeadingNewline.length + text.length + 1;
textArea.setSelectionRange(newPosition, newPosition);
});
};
};
if (isMobile) {
return <MobileMessage />;