Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set doNotExpandShiftReturn in Settings #1126

Closed
DRG-Support opened this issue Aug 31, 2021 Discussed in #1033 · 2 comments · Fixed by #1749
Closed

Cannot set doNotExpandShiftReturn in Settings #1126

DRG-Support opened this issue Aug 31, 2021 Discussed in #1033 · 2 comments · Fixed by #1749

Comments

@DRG-Support
Copy link

Discussed in #1033

Originally posted by bkmalan July 8, 2021
Hi,
First of all, Thanks to the contributors for maintaining this great library.

Now coming to my concern, I'm using JUSTIFIED as my alignment type but few paragraphs' last line doesn't cover the entire width so it is justified in this manner.
Screenshot from 2021-07-08 14-11-45

But I don't want the last line to be justified as much as the previous lines.
I went through the documentation and found this line this.doc.Settings.addCompatibility().doNotExpandShiftReturn(); but when I try to use this it says addCompatibility is not a function.

Kindly help me with this.

Thanks


I have just been through the code and as far as I can tell there is no way to make this setting. It looks like only the compatibility mode setting can be made which is a number.

Code exists in docx/src/file/settings/compatibility.ts which defines the interface ( ICompatibilityOptions ) and class ( Compatibility ) where the property doNotExpandShiftReturn (boolean) can be set.
The file docx/src/file/settings/settings.ts imports the Compatibility class but only pushes a version property. I think the ISettingsOptions interface needs to be extended here to add the doNotExpandShiftReturn property too?

Also reference pull request #280 where the original code was added

thanks
Marcus

@vitalets
Copy link

Until this fixed I've used the following workaround:

import { Document, XmlComponent, OnOffElement } from 'docx';

const doc = new Document({ ... });
doc.Settings.addChildElement(new DoNotExpandShiftReturn());

class DoNotExpandShiftReturn extends XmlComponent {
  constructor() {
    super('w:compat');
    this.root.push(new OnOffElement('w:doNotExpandShiftReturn', true));
  }
}

dolanmiu added a commit that referenced this issue Oct 29, 2022
@dolanmiu
Copy link
Owner

Will be added in #1749

All other compabitility options also will be added

dolanmiu added a commit that referenced this issue Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants