Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 1x 1x 736x 606x 606x 606x 21x 21x 21x 993x 993x 8x | import { calcAlign, ResultMap } from '../utils/dir'; import { directionFormatHandler } from './directionFormatHandler'; import type { DirectionFormat, HtmlAlignFormat, TextAlignFormat, } from 'roosterjs-content-model-types'; import type { FormatHandler } from '../FormatHandler'; /** * @internal */ export const htmlAlignFormatHandler: FormatHandler< DirectionFormat & HtmlAlignFormat & TextAlignFormat > = { parse: (format, element, context, defaultStyle) => { // When there is text-align in CSS style on the same element, we should ignore HTML align if (!element.style.textAlign) { directionFormatHandler.parse(format, element, context, defaultStyle); const htmlAlign = element.getAttribute('align'); if (htmlAlign) { format.htmlAlign = calcAlign(htmlAlign, format.direction); delete format.textAlign; delete context.blockFormat.textAlign; } } }, apply: (format, element) => { const dir: 'ltr' | 'rtl' = format.direction == 'rtl' ? 'rtl' : 'ltr'; if (format.htmlAlign) { element.setAttribute('align', ResultMap[format.htmlAlign][dir]); } }, }; |