[FIX] web_editor: shift+enter on styled elements.
Before this commit: After selecting the text of shift+enter which is styled and pressing any key the new hideous child gets born. After this commit: Now, The new input will replace the selected text. Task-3209969 closes odoo/odoo#119506 X-original-commit: f15d5ad27c6b764f54904f6ea8f6a714974b7bd0 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
@@ -1897,12 +1897,7 @@ export function fillEmpty(el) {
|
||||
blockEl.appendChild(br);
|
||||
fillers.br = br;
|
||||
}
|
||||
if (
|
||||
!el.textContent.length &&
|
||||
!isBlock(el) &&
|
||||
el.nodeName !== 'BR' &&
|
||||
!el.hasAttribute("data-oe-zws-empty-inline")
|
||||
) {
|
||||
if (!isVisible(el) && !el.hasAttribute("data-oe-zws-empty-inline")) {
|
||||
// As soon as there is actual content in the node, the zero-width space
|
||||
// is removed by the sanitize function.
|
||||
const zws = document.createTextNode('\u200B');
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** @odoo-module */
|
||||
|
||||
import { isSelectionFormat } from '../../src/utils/utils.js';
|
||||
import { BasicEditor, testEditor, setTestSelection, Direction, unformat } from '../utils.js';
|
||||
import { BasicEditor, testEditor, setTestSelection, Direction, unformat, insertText } from '../utils.js';
|
||||
|
||||
const bold = async editor => {
|
||||
await editor.execCommand('bold');
|
||||
@@ -520,6 +520,27 @@ describe('Format', () => {
|
||||
contentAfter: `<p style="text-decoration: line-through;">a[b]c</p>`,
|
||||
});
|
||||
});
|
||||
it('should insert new character inside strikethrough at first position', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: `<p>d[a${s('bc]<br><br>')}</p>`,
|
||||
stepFunction: async editor => {
|
||||
insertText(editor, 'A');
|
||||
},
|
||||
contentAfter: `<p>dA[]${s(`<br><br>`)}</p>`,
|
||||
});
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: `<p>[a${s('bc]<br><br>')}</p>`,
|
||||
stepFunction: async editor => {
|
||||
insertText(editor, 'A');
|
||||
},
|
||||
contentAfter: `<p>A[]${s(`<br><br>`)}</p>`,
|
||||
// Note: In the browser, the actual result is the following:
|
||||
// contentAfter: `<p>${s(`A[]<br><br>`)}</p>`,
|
||||
// It is arguable which version is better than the other but in
|
||||
// any case this is a trade-off because it matches the native
|
||||
// behavior of contentEditable in that case.
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('underline + strikeThrough', () => {
|
||||
|
||||
Reference in New Issue
Block a user