docx icon indicating copy to clipboard operation
docx copied to clipboard

When using `patchDocument()` the custom numbering flow doesn't work.

Open martijn10kb opened this issue 1 year ago • 3 comments

When using patchDocument() the custom numbering flow doesn't work. Or if it's possible where would we insert the INumberingOptions object? When trying to open a docx that has been generated that has custom numbering it fails to open.

Expect that I can somewhere insert this and use

import { AlignmentType, convertInchesToTwip, INumberingOptions, LevelFormat } from 'docx';

export const CHECKLIST_NUMBERING = 'checklist-numbering';

const numbering: INumberingOptions = {
  config: [
    {
      reference: CHECKLIST_NUMBERING,
      levels: [
        {
          level: 0,
          format: LevelFormat.BULLET,
          text: '⬜',
          alignment: AlignmentType.START,
#         style: {},
        },
        {
          level: 1,
          format: LevelFormat.BULLET,
          text: '✅',
          alignment: AlignmentType.START,
#         style: {},
        },
      ],
    },
  ],
};

export default numbering;

And then reference it like so: import { CHECKLIST_NUMBERING } from '../numbering';

const bulletStyle = styles.isChecklist
      ? { numbering: { level: isChecked ? 1 : 0, reference: CHECKLIST_NUMBERING } }
      : { bullet: { level: 0 } };

martijn10kb avatar Apr 18 '23 14:04 martijn10kb

Same thing, trying to figure out how to make numbering paragraphs patching document

yarosalvpp avatar Mar 07 '24 11:03 yarosalvpp

This is required, not possible to do at the moment...

lcampanis avatar Mar 24 '24 19:03 lcampanis

I am even unable to insert a simple bullet point using patchDocument. When the document is opened in Libre Office or Google Docs, the bullet point appears as plain text instead of as a bullet point.

const updatedDocBuffer = await patchDocument(docBuffer, {
  patches: {
      placeholder: {
          type: PatchType.DOCUMENT,
          children: [ new Paragraph({ text: "Bullet point content", bullet: { level: 0 }} ],
      }
})

Are you experiencing similar issues? @lcampanis @yarosalvpp @martijn10kb

valentindoering avatar Jul 17 '24 13:07 valentindoering