[FIX] web_editor: space before word lost
Current behaviour before commit: In website, space before the word is lost when deleting the word. Desired behaviour after commit: Now space is preserved when deleting the word. task-3233352 closes odoo/odoo#148492 X-original-commit: 5f5d12dd1bbdc63a9565aa84f197c4a9bba55d7a Signed-off-by: Antoine Guenet (age) <age@odoo.com>
This commit is contained in:
@@ -80,6 +80,7 @@ import {
|
||||
prepareUpdate,
|
||||
boundariesOut,
|
||||
getFontSizeDisplayValue,
|
||||
rightLeafOnlyNotBlockPath,
|
||||
} from './utils/utils.js';
|
||||
import { editorCommands } from './commands/commands.js';
|
||||
import { Powerbox } from './powerbox/Powerbox.js';
|
||||
@@ -2237,7 +2238,11 @@ export class OdooEditor extends EventTarget {
|
||||
fillEmpty(closestBlock(start));
|
||||
}
|
||||
fillEmpty(closestBlock(range.endContainer));
|
||||
const joinWith = range.endContainer;
|
||||
let joinWith = range.endContainer;
|
||||
const rightLeaf = rightLeafOnlyNotBlockPath(joinWith).next().value;
|
||||
if (rightLeaf && rightLeaf.nodeValue === ' ') {
|
||||
joinWith = rightLeaf;
|
||||
}
|
||||
// Rejoin blocks that extractContents may have split in two.
|
||||
while (
|
||||
doJoin &&
|
||||
|
||||
@@ -2659,7 +2659,8 @@ export function enforceWhitespace(el, offset, direction, rule) {
|
||||
if (
|
||||
spaceVisibility &&
|
||||
!foundVisibleSpaceTextNode &&
|
||||
getState(...rightPos(spaceNode), DIRECTIONS.RIGHT).cType & CTGROUPS.BLOCK
|
||||
getState(...rightPos(spaceNode), DIRECTIONS.RIGHT).cType & CTGROUPS.BLOCK &&
|
||||
getState(...leftPos(spaceNode), DIRECTIONS.LEFT).cType !== CTYPES.CONTENT
|
||||
) {
|
||||
spaceVisibility = false;
|
||||
}
|
||||
|
||||
@@ -3425,6 +3425,15 @@ X[]
|
||||
contentAfter: `<p>a []</p>`,
|
||||
});
|
||||
});
|
||||
it('should transform the space node preceded by a styled element to ', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: `<p><strong>ab</strong> [cd]</p>`,
|
||||
stepFunction: async editor => {
|
||||
await insertText(editor, 'x');
|
||||
},
|
||||
contentAfter: `<p><strong>ab</strong> x[]</p>`,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('insertParagraphBreak', () => {
|
||||
|
||||
Reference in New Issue
Block a user