mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-16 01:40:53 +08:00
4fc945ffc3
* 支持 sdt * 实现NoBreakHyphen * 实现表格行变量替换 * 变量替换时删掉不用的属性
90 lines
2.0 KiB
TypeScript
90 lines
2.0 KiB
TypeScript
import {createWord} from './EmptyWord';
|
|
import {mergeRun} from '../src/util/mergeRun';
|
|
import {parseXML} from '../src/util/xml';
|
|
|
|
test('proofErr', async () => {
|
|
const xmlDoc = parseXML(
|
|
`
|
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
<w:body>
|
|
<w:p>
|
|
<w:r>
|
|
<w:t>{{var</w:t>
|
|
</w:r>
|
|
<w:proofErr w:type="gramStart"/>
|
|
<w:r>
|
|
<w:t>}}</w:t>
|
|
</w:r>
|
|
</w:p>
|
|
</w:body>
|
|
</w:document>
|
|
`.trim()
|
|
);
|
|
|
|
const word = createWord();
|
|
|
|
mergeRun(word, xmlDoc);
|
|
|
|
expect(xmlDoc.getElementsByTagName('w:t')[0]?.innerHTML).toBe('{{var}}');
|
|
});
|
|
|
|
test('font hint', async () => {
|
|
const xmlDoc = parseXML(
|
|
`
|
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
<w:body>
|
|
<w:p>
|
|
<w:r>
|
|
<w:rPr>
|
|
<w:rFonts w:hint="eastAsia"/>
|
|
</w:rPr>
|
|
<w:t>B</w:t>
|
|
</w:r>
|
|
<w:r>
|
|
<w:t>6</w:t>
|
|
</w:r>
|
|
</w:p>
|
|
</w:body>
|
|
</w:document>
|
|
`.trim()
|
|
);
|
|
|
|
const word = createWord();
|
|
mergeRun(word, xmlDoc);
|
|
expect(xmlDoc.getElementsByTagName('w:t')[0]?.innerHTML).toBe('B6');
|
|
});
|
|
|
|
test('space', async () => {
|
|
const xmlDoc = parseXML(
|
|
`
|
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
<w:body>
|
|
<w:p>
|
|
<w:r>
|
|
<w:t>C</w:t>
|
|
</w:r>
|
|
<w:r w:rsidR="007D7B36">
|
|
<w:t>ustom</w:t>
|
|
</w:r>
|
|
<w:r>
|
|
<w:t xml:space="preserve"> </w:t>
|
|
</w:r>
|
|
<w:r w:rsidR="007D7B36">
|
|
<w:t>Style</w:t>
|
|
</w:r>
|
|
</w:p>
|
|
</w:body>
|
|
</w:document>
|
|
`.trim()
|
|
);
|
|
|
|
const word = createWord();
|
|
|
|
mergeRun(word, xmlDoc);
|
|
|
|
expect(xmlDoc.getElementsByTagName('w:t')[0]?.innerHTML).toBe('Custom');
|
|
});
|