@arbidocs/coedit 0.5.20 → 0.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,6 +23,11 @@ declare function applyTemplate(document: Uint8Array, template: Uint8Array, optio
23
23
  * File › New from a template: the template package as a new document. A .dotx/.dotm main part
24
24
  * becomes a document part (macros are not carried), the glossary stays behind, and the template
25
25
  * is recorded as attached.
26
+ *
27
+ * Word 2010's `stylesWithEffects.xml`, a second copy of the style definitions that Word 2013 and
28
+ * later neither read nor write, stays behind too: the new document's styles are `styles.xml`
29
+ * alone, and a template saved by python-docx does not put hundreds of kilobytes of duplicate
30
+ * styles into every new note.
26
31
  */
27
32
  declare function newFromTemplate(template: Uint8Array, options?: {
28
33
  attachedTemplate?: string;
@@ -23,6 +23,11 @@ declare function applyTemplate(document: Uint8Array, template: Uint8Array, optio
23
23
  * File › New from a template: the template package as a new document. A .dotx/.dotm main part
24
24
  * becomes a document part (macros are not carried), the glossary stays behind, and the template
25
25
  * is recorded as attached.
26
+ *
27
+ * Word 2010's `stylesWithEffects.xml`, a second copy of the style definitions that Word 2013 and
28
+ * later neither read nor write, stays behind too: the new document's styles are `styles.xml`
29
+ * alone, and a template saved by python-docx does not put hundreds of kilobytes of duplicate
30
+ * styles into every new note.
26
31
  */
27
32
  declare function newFromTemplate(template: Uint8Array, options?: {
28
33
  attachedTemplate?: string;
package/dist/template.js CHANGED
@@ -697,7 +697,8 @@ function newFromTemplate(template, options = {}) {
697
697
  const main = pkg.main;
698
698
  pkg.setContentType(main, CT.document);
699
699
  const rels = pkg.rels(main);
700
- for (const rel of rels.filter((r) => r.type === RT.glossary || /vbaProject$/.test(r.type))) {
700
+ const left = (type) => type === RT.glossary || /vbaProject$/.test(type) || /\/stylesWithEffects$/.test(type);
701
+ for (const rel of rels.filter((r) => left(r.type))) {
701
702
  const target = pkg.find(pkg.target(main, rel));
702
703
  if (target) {
703
704
  for (const sub of pkg.rels(target)) if (!sub.external) pkg.remove(pkg.target(target, sub));
@@ -706,7 +707,7 @@ function newFromTemplate(template, options = {}) {
706
707
  }
707
708
  pkg.setRels(
708
709
  main,
709
- rels.filter((r) => r.type !== RT.glossary && !/vbaProject$/.test(r.type))
710
+ rels.filter((r) => !left(r.type))
710
711
  );
711
712
  if (options.attachedTemplate) {
712
713
  const { part, root } = settingsOf(pkg);