MCPcopy Create free account
hub / github.com/TruthHun/BookStack / updateContentTypes

Function updateContentTypes

static/word2md/mammoth.browser.js:1996–2011  ·  view source on GitHub ↗
(docxFile)

Source from the content-addressed store, hash-verified

1994}
1995
1996function updateContentTypes(docxFile) {
1997 var path = "[Content_Types].xml";
1998 var contentTypesUri = "http://schemas.openxmlformats.org/package/2006/content-types";
1999 var overrideName = "{" + contentTypesUri + "}Override";
2000 return docxFile.read(path, "utf8")
2001 .then(xml.readString)
2002 .then(function(typesElement) {
2003 var children = typesElement.children;
2004 addOrUpdateElement(children, overrideName, "PartName", {
2005 "PartName": styleMapAbsolutePath,
2006 "ContentType": "text/prs.mammoth.style-map"
2007 });
2008 var namespaces = {"": contentTypesUri};
2009 return docxFile.write(path, xml.writeString(typesElement, namespaces));
2010 });
2011}
2012
2013function addOrUpdateElement(elements, name, identifyingAttribute, attributes) {
2014 var existingElement = _.find(elements, function(element) {

Callers 1

writeStyleMapFunction · 0.70

Calls 1

addOrUpdateElementFunction · 0.70

Tested by

no test coverage detected