41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
import {
|
|
Document,
|
|
Paragraph,
|
|
TextRun,
|
|
CommentRangeStart,
|
|
CommentRangeEnd,
|
|
CommentReference,
|
|
LevelFormat,
|
|
LevelSuffix,
|
|
AlignmentType,
|
|
Packer
|
|
} from 'docx';
|
|
import JSZip from 'jszip';
|
|
import fs from 'fs';
|
|
import { buildBookAmaAuthorComment } from '../src/utils/referenceAuthorAma.js';
|
|
import { buildManuscriptWordDocument } from '../src/utils/exportManuscriptWord.js';
|
|
|
|
const ref = {
|
|
refer_type: 'book',
|
|
author: 'Jacqueline Fawcett, Susan DeSanto-Madeya',
|
|
title: 'Contemporary Nursing Knowledge',
|
|
dateno: '(3rd Edition). Philadelphia, PA: F. A. Davis Company; 2013.',
|
|
isbn: '978-0-8036-2765-9'
|
|
};
|
|
|
|
console.log('comment text:', buildBookAmaAuthorComment(ref));
|
|
|
|
const doc = buildManuscriptWordDocument([], '', [ref], null, null);
|
|
const buf = await Packer.toBuffer(doc);
|
|
fs.writeFileSync('test-ref-comment.docx', buf);
|
|
|
|
const zip = await JSZip.loadAsync(buf);
|
|
const docXml = await zip.file('word/document.xml').async('string');
|
|
const commentsXml = zip.file('word/comments.xml');
|
|
console.log('has comments.xml:', !!commentsXml);
|
|
console.log('has commentReference:', docXml.includes('commentReference'));
|
|
console.log('has commentRangeStart:', docXml.includes('commentRangeStart'));
|
|
if (commentsXml) {
|
|
console.log('comments preview:', (await commentsXml.async('string')).slice(0, 500));
|
|
}
|