Как я могу получить индекс пикселей каретки в редакторе TinyMCE? ⇐ Jquery
Как я могу получить индекс пикселей каретки в редакторе TinyMCE?
Я пытаюсь добавить раскрывающийся список в курсоре, но значение CaretPosition.top слишком маленькое:
функция updateDropdownPosition() { const editorElement = editor.editorContainer; const editorRect = editorElement.getBoundingClientRect(); // Вычисляем верхнюю и левую координаты относительно страницы const editorTop = editorRect.top + window.scrollY; const editorLeft = editorRect.left + window.scrollX; // Вычисляем позицию курсора в редакторе const caretPosition = editor.selection.getRng().getClientRects()[0]; const topWithCaret = editorTop + caretPosition.top; const leftWithCaret = editorLeft + caretPosition.left; $dropdownContainer.css({ вверху: topWithCaret + «px», слева: leftWithCaret + «px», }); }
Я пытаюсь добавить раскрывающийся список в курсоре, но значение CaretPosition.top слишком маленькое:
функция updateDropdownPosition() { const editorElement = editor.editorContainer; const editorRect = editorElement.getBoundingClientRect(); // Вычисляем верхнюю и левую координаты относительно страницы const editorTop = editorRect.top + window.scrollY; const editorLeft = editorRect.left + window.scrollX; // Вычисляем позицию курсора в редакторе const caretPosition = editor.selection.getRng().getClientRects()[0]; const topWithCaret = editorTop + caretPosition.top; const leftWithCaret = editorLeft + caretPosition.left; $dropdownContainer.css({ вверху: topWithCaret + «px», слева: leftWithCaret + «px», }); }
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение