- number-поля теперь рендерятся как text + inputMode=numeric, чтобы браузер не округлял значения через input type=number - пробелы при вставке в number-поля удаляются - бэкенд нормализует значения number-полей в строку перед сохранением - добавлен хелпер normalizeFieldValueForStorage Closes: искажение расчётного счёта и других длинных числовых полей
32 lines
952 B
TypeScript
32 lines
952 B
TypeScript
import HTMLtoDOCX from '@turbodocx/html-to-docx';
|
|
|
|
export interface DOCXOptions {
|
|
title?: string;
|
|
creator?: string;
|
|
font?: string;
|
|
margins?: { top: number; right: number; bottom: number; left: number };
|
|
lang?: string;
|
|
}
|
|
|
|
export class DOCXConverterService {
|
|
async convert(html: string, options: DOCXOptions = {}): Promise<Buffer> {
|
|
const opts = {
|
|
title: options.title || 'Document',
|
|
creator: options.creator || 'iistwin CRM',
|
|
font: options.font || 'Noto Sans',
|
|
margins: options.margins || { top: 1440, right: 1440, bottom: 1440, left: 1440 },
|
|
lang: options.lang || 'ru-RU',
|
|
};
|
|
|
|
const result = await HTMLtoDOCX(html, null, opts);
|
|
if (result instanceof ArrayBuffer) {
|
|
return Buffer.from(result);
|
|
}
|
|
if (Buffer.isBuffer(result)) {
|
|
return result;
|
|
}
|
|
// Fallback: некоторые версии возвращают Blob/Buffer
|
|
return Buffer.from(result as any);
|
|
}
|
|
}
|