mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
fix hyphen in textarea
This commit is contained in:
parent
444c22ce93
commit
36cae315aa
@ -36,8 +36,8 @@ describe('textarea-layout', () => {
|
||||
['Donaudampfsc', 'x2']);
|
||||
});
|
||||
it('should wrap lines at -', () => {
|
||||
layoutEqual(' Long text- message with sev lines.',
|
||||
[' Long text-', 'message with','sev lines.']);
|
||||
layoutEqual(' Long text- message with lines.',
|
||||
[' Long text', '- message','with lines.']);
|
||||
});
|
||||
it('should wrap lines at - 2', () => {
|
||||
layoutEqual('Long text- message with sev lines.',
|
||||
|
@ -13,7 +13,7 @@ export function layout(chars: string[], width: number, measure: (s: string, len:
|
||||
const lineWidth = measure(lineString, lineLen);
|
||||
pos.push([lineWidth - measure(chars[i], 1), line]);
|
||||
if (lineWidth > width) {
|
||||
if (chars[i] === ' ' || chars[i] === '-') {
|
||||
if (chars[i] === ' ') {
|
||||
let p = i;
|
||||
while (p > 0 && pos[p][1] === line && chars[p] === ' ') p--;
|
||||
for (let j = i; j > p; j--) {
|
||||
@ -25,6 +25,10 @@ export function layout(chars: string[], width: number, measure: (s: string, len:
|
||||
pos.push([-1, line]);
|
||||
i++;
|
||||
}
|
||||
} else if (chars[i] === '-') {
|
||||
line++;
|
||||
setLine(i, i + 1);
|
||||
pos[i] = [0, line];
|
||||
} else {
|
||||
let p = i;
|
||||
while (p > 0 && pos[p][1] === line && chars[p] !== ' ' && chars[p] !== '-') p--;
|
||||
|
Loading…
Reference in New Issue
Block a user