mirror of
https://github.com/marktext/marktext.git
synced 2025-05-03 03:12:18 +08:00
Can not focus the first empty line in code block (#1477)
* Fix: do not show inline format float tool bar when select text in language input * Fix: #1460
This commit is contained in:
parent
342e9c457a
commit
bcb9d97d61
@ -276,7 +276,12 @@ class Keyboard {
|
||||
}
|
||||
|
||||
const block = contentState.getBlock(anchor.key)
|
||||
if (anchor.key === focus.key && anchor.offset !== focus.offset && block.functionType !== 'codeContent') {
|
||||
if (
|
||||
anchor.key === focus.key &&
|
||||
anchor.offset !== focus.offset &&
|
||||
block.functionType !== 'codeContent' &&
|
||||
block.functionType !== 'languageInput'
|
||||
) {
|
||||
const reference = contentState.getPositionReference()
|
||||
const { formats } = contentState.selectionFormats()
|
||||
eventCenter.dispatch('muya-format-picker', { reference, formats })
|
||||
|
@ -426,12 +426,13 @@ class Selection {
|
||||
let count = 0
|
||||
for (i = 0; i < len; i++) {
|
||||
const child = childNodes[i]
|
||||
const textLength = getTextContent(child, [CLASS_OR_ID.AG_MATH_RENDER, CLASS_OR_ID.AG_RUBY_RENDER]).length
|
||||
const textContent = getTextContent(child, [CLASS_OR_ID.AG_MATH_RENDER, CLASS_OR_ID.AG_RUBY_RENDER])
|
||||
const textLength = textContent.length
|
||||
if (child.classList && child.classList.contains(CLASS_OR_ID.AG_FRONT_ICON)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (count + textLength >= offset) {
|
||||
// Fix #1460 - put the cursor at the next text node or element if it can be put at the last of /^\n$/ or the next text node/element.
|
||||
if (/^\n$/.test(textContent) ? count + textLength > offset : count + textLength >= offset) {
|
||||
if (
|
||||
child.classList && child.classList.contains('ag-inline-image')
|
||||
) {
|
||||
|
Loading…
Reference in New Issue
Block a user