You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -856,6 +857,55 @@ const automizer = new Automizer({
856
857
});
857
858
```
858
859
860
+
## Create a new modifier
861
+
862
+
If the built-in modifiers of `pptx-automizer` are not sufficient to your task, you can access the target xml elements with [xmldom](https://github.com/xmldom/xmldom). A modifier is a wrapper for such an operation.
863
+
864
+
Let's first take a look at a (simplified) existing modifier: `ModifyTextHelper.content('This is my text')`.
865
+
866
+
```ts
867
+
// "setTextContent" is a function that returns a function.
868
+
// A "label" argument needs to be passed to "setTextContent".
// It is possible to output the xml to console at any time.
885
+
// XmlHelper.dump(element);
886
+
};
887
+
};
888
+
```
889
+
This function will construct an anonymous callback function on setup, while the callback function itself will be executed on runtime, when it's up to the target element on a slide.
890
+
891
+
You can use the modifier e.g. on adding an element:
// Notice: don't call XmlHelper.dump, just pass it
899
+
XmlHelper.dump,
900
+
// 2. Apply modifier from the example above:
901
+
setTextContent('New text'),
902
+
XmlHelper.dump,
903
+
]);
904
+
});
905
+
```
906
+
907
+
We can wrap any xml modification by such a modifier. If you have a working example and you think it will be useful to others, you are very welcome to fork this repo and send a pull request or simply [post it](https://github.com/singerla/pptx-automizer/issues/new).
908
+
859
909
## More examples
860
910
861
911
Take a look into [**tests**-directory](https://github.com/singerla/pptx-automizer/blob/main/__tests__) to see a lot of examples for several use cases, e.g.:
@@ -868,6 +918,7 @@ Take a look into [**tests**-directory](https://github.com/singerla/pptx-automize
If you encounter problems when opening a `.pptx`-file modified by this library, you might worry about PowerPoint not giving any details about the error. It can be hard to find the cause, but there are some things you can check:
872
923
873
924
-**Broken relation**: There are still unsupported shape types and `pptx-automizer` wil not copy required relations of those. You can inflate `.pptx`-output and check `ppt/slides/_rels/slide[#].xml.rels`-files to find possible missing files.
0 commit comments