bugfix
This commit is contained in:
parent
59436a7d39
commit
d23c3e7a67
|
|
@ -556,7 +556,9 @@ export class RibbitEditor extends Ribbit {
|
||||||
const newBlock = this.#buildBlock(lineText);
|
const newBlock = this.#buildBlock(lineText);
|
||||||
block.className = newBlock.className;
|
block.className = newBlock.className;
|
||||||
block.innerHTML = '';
|
block.innerHTML = '';
|
||||||
while (newBlock.firstChild) block.appendChild(newBlock.firstChild);
|
while (newBlock.firstChild) {
|
||||||
|
block.appendChild(newBlock.firstChild);
|
||||||
|
}
|
||||||
|
|
||||||
// Place caret after any prefix span, never inside it
|
// Place caret after any prefix span, never inside it
|
||||||
const prefixSpan = block.firstElementChild;
|
const prefixSpan = block.firstElementChild;
|
||||||
|
|
@ -578,6 +580,13 @@ export class RibbitEditor extends Ribbit {
|
||||||
sel.removeAllRanges();
|
sel.removeAllRanges();
|
||||||
sel.addRange(range);
|
sel.addRange(range);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// switch spaces back to non-breaking spaces to avoid a chromium bug where a trailing space is ignored when
|
||||||
|
// positioning the caret. We only do this if the last character is a space; if we do it unconditionally it
|
||||||
|
// breaks detection of header nodes etc.
|
||||||
|
if (lineText.endsWith(' ')) {
|
||||||
|
block.innerHTML = block.innerHTML.replace(/\s/g, '\u00A0');
|
||||||
|
}
|
||||||
this.#restoreCaret(block, caretOffset);
|
this.#restoreCaret(block, caretOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -748,6 +757,7 @@ export class RibbitEditor extends Ribbit {
|
||||||
let remaining = offset;
|
let remaining = offset;
|
||||||
|
|
||||||
const placed = this.#walkForCaret(block, range, remaining);
|
const placed = this.#walkForCaret(block, range, remaining);
|
||||||
|
|
||||||
if (!placed) {
|
if (!placed) {
|
||||||
range.selectNodeContents(block);
|
range.selectNodeContents(block);
|
||||||
range.collapse(false);
|
range.collapse(false);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user