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:
Ran Luo 2019-10-13 01:55:21 +08:00 committed by Felix Häusler
parent 342e9c457a
commit bcb9d97d61
2 changed files with 10 additions and 4 deletions

View File

@ -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 })

View File

@ -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')
) {