mirror of
https://github.com/marktext/marktext.git
synced 2025-05-04 04:21:38 +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)
|
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 reference = contentState.getPositionReference()
|
||||||
const { formats } = contentState.selectionFormats()
|
const { formats } = contentState.selectionFormats()
|
||||||
eventCenter.dispatch('muya-format-picker', { reference, formats })
|
eventCenter.dispatch('muya-format-picker', { reference, formats })
|
||||||
|
@ -426,12 +426,13 @@ class Selection {
|
|||||||
let count = 0
|
let count = 0
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
const child = childNodes[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)) {
|
if (child.classList && child.classList.contains(CLASS_OR_ID.AG_FRONT_ICON)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
// 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 (count + textLength >= offset) {
|
if (/^\n$/.test(textContent) ? count + textLength > offset : count + textLength >= offset) {
|
||||||
if (
|
if (
|
||||||
child.classList && child.classList.contains('ag-inline-image')
|
child.classList && child.classList.contains('ag-inline-image')
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user