@restnfeel/agentc-starter-kit
Version:
한국어 기업용 CMS 모듈 - Task Master AI와 함께 빠르게 웹사이트를 구현할 수 있는 재사용 가능한 컴포넌트 시스템
91 lines (77 loc) • 3.27 kB
JavaScript
import { __exports as styleMap } from '../../../../_virtual/style-map.js';
import require$$0 from '../../../../_virtual/index-all.js';
import { __require as requirePromises } from '../promises.js';
import { __require as requireXml } from '../xml/index.js';
var hasRequiredStyleMap;
function requireStyleMap () {
if (hasRequiredStyleMap) return styleMap;
hasRequiredStyleMap = 1;
var _ = require$$0;
var promises = /*@__PURE__*/ requirePromises();
var xml = /*@__PURE__*/ requireXml();
styleMap.writeStyleMap = writeStyleMap;
styleMap.readStyleMap = readStyleMap;
var schema = "http://schemas.zwobble.org/mammoth/style-map";
var styleMapPath = "mammoth/style-map";
var styleMapAbsolutePath = "/" + styleMapPath;
function writeStyleMap(docxFile, styleMap) {
docxFile.write(styleMapPath, styleMap);
return updateRelationships(docxFile).then(function() {
return updateContentTypes(docxFile);
});
}
function updateRelationships(docxFile) {
var path = "word/_rels/document.xml.rels";
var relationshipsUri = "http://schemas.openxmlformats.org/package/2006/relationships";
var relationshipElementName = "{" + relationshipsUri + "}Relationship";
return docxFile.read(path, "utf8")
.then(xml.readString)
.then(function(relationshipsContainer) {
var relationships = relationshipsContainer.children;
addOrUpdateElement(relationships, relationshipElementName, "Id", {
"Id": "rMammothStyleMap",
"Type": schema,
"Target": styleMapAbsolutePath
});
var namespaces = {"": relationshipsUri};
return docxFile.write(path, xml.writeString(relationshipsContainer, namespaces));
});
}
function updateContentTypes(docxFile) {
var path = "[Content_Types].xml";
var contentTypesUri = "http://schemas.openxmlformats.org/package/2006/content-types";
var overrideName = "{" + contentTypesUri + "}Override";
return docxFile.read(path, "utf8")
.then(xml.readString)
.then(function(typesElement) {
var children = typesElement.children;
addOrUpdateElement(children, overrideName, "PartName", {
"PartName": styleMapAbsolutePath,
"ContentType": "text/prs.mammoth.style-map"
});
var namespaces = {"": contentTypesUri};
return docxFile.write(path, xml.writeString(typesElement, namespaces));
});
}
function addOrUpdateElement(elements, name, identifyingAttribute, attributes) {
var existingElement = _.find(elements, function(element) {
return element.name === name &&
element.attributes[identifyingAttribute] === attributes[identifyingAttribute];
});
if (existingElement) {
existingElement.attributes = attributes;
} else {
elements.push(xml.element(name, attributes));
}
}
function readStyleMap(docxFile) {
if (docxFile.exists(styleMapPath)) {
return docxFile.read(styleMapPath, "utf8");
} else {
return promises.resolve(null);
}
}
return styleMap;
}
export { requireStyleMap as __require };
//# sourceMappingURL=style-map.js.map