diff --git a/README.md b/README.md
new file mode 100644
index 0000000..f7e9256
--- /dev/null
+++ b/README.md
@@ -0,0 +1,43 @@
+DOCX.js
+=======
+
+DOCX.js is a JavaScript library for converting the data in base64 DOCX files into HTML - and back! Please note that this library is licensed under the Microsoft Office Extensible File License - a license NOT approved by the OSI. While this license is based off of the MS-PL, which is OSI-approved, there are significant differences.
+
+Docx.js for tinyMCE
+
+This is a modified version of docx.js from [https://github.com/stephen-hardy/docx.js](https://github.com/stephen-hardy/docx.js).
+
+## Dependencies
+
+ * JsZip.js
+
+## How to
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docx.js b/docx.js
index 3a93746..e194ece 100644
--- a/docx.js
+++ b/docx.js
@@ -36,7 +36,9 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing
if (inNodeChild.nodeName === 'r') {
val = inNodeChild.textContent;
if (inNodeChild.getElementsByTagName('b').length) { val = '' + val + ''; }
+ if (inNodeChild.getElementsByTagName('strong').length) { val = '' + val + ''; }
if (inNodeChild.getElementsByTagName('i').length) { val = '' + val + ''; }
+ if (inNodeChild.getElementsByTagName('em').length) { val = '' + val + ''; }
if (inNodeChild.getElementsByTagName('u').length) { val = '' + val + ''; }
if (inNodeChild.getElementsByTagName('strike').length) { val = '' + val + ''; }
if (styleAttrNode = inNodeChild.getElementsByTagName('vertAlign')[0]) {
@@ -71,7 +73,7 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing
for (i = 0; inNode = input.childNodes[i]; i++) {
outNode = output.appendChild(newXMLnode('p'));
pCount++;
- if (inNode.style.textAlign) { outNode.appendChild(newXMLnode('pPr')).appendChild(newXMLnode('jc')).setAttribute('val', inNode.style.textAlign); }
+ if (inNode.style && inNode.style.textAlign) { outNode.appendChild(newXMLnode('pPr')).appendChild(newXMLnode('jc')).setAttribute('val', inNode.style.textAlign); }
if (inNode.nodeName === '#text') { outNode.appendChild(newXMLnode('r')).appendChild(newXMLnode('t', inNode.nodeValue)); }
else {
for (j = 0; inNodeChild = inNode.childNodes[j]; j++) {
@@ -80,7 +82,11 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing
styleAttrNode = outNodeChild.appendChild(newXMLnode('rPr'));
tempStr = inNodeChild.outerHTML;
if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('b')); }
+ if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('b')); }
+ if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('i')); }
+ if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('i')); }
if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('i')); }
+ if (tempStr.indexOf(' -1) { styleAttrNode.appendChild(newXMLnode('u')).setAttribute('val', 'single'); }
if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('u')).setAttribute('val', 'single'); }
if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('strike')); }
if (tempStr.indexOf('') > -1) { styleAttrNode.appendChild(newXMLnode('vertAlign')).setAttribute('val', 'subscript'); }
@@ -98,6 +104,7 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing
output = {
string: new XMLSerializer().serializeToString(output).replace(//g, '').replace(/val=/g, 'w:val='),
charSpaceCount: input.textContent.length, charCount: input.textContent.replace(/\s/g, '').length, pCount: pCount
+ //charSpaceCount: 0, charCount: 0, pCount: pCount
};
}
return output;
@@ -106,7 +113,7 @@ function convertContent(input) { 'use strict'; // Convert HTML to Wordprocessing
function docx(file) { 'use strict'; // v1.0.1
var result, zip = new JSZip(), zipTime, processTime, docProps, word, content;
- if (typeof file === 'string') { // Load
+ if (typeof file === "string") { // Load
zipTime = Date.now();
zip = zip.load(file, { base64: true });
result = { zipTime: Date.now() - zipTime };
@@ -127,9 +134,9 @@ function docx(file) { 'use strict'; // v1.0.1
result.processTime = Date.now() - processTime;
}
else { // Save
- content = convertContent(file.DOM);
+ content = convertContent(file);
processTime = Date.now();
- sharedStrings = [[], 0];
+ var sharedStrings = [[], 0];
//{ Fully static
zip.file('[Content_Types].xml', '');
zip.folder('_rels').file('.rels', '');
@@ -169,4 +176,4 @@ function docx(file) { 'use strict'; // v1.0.1
}
}
return result;
-}
\ No newline at end of file
+}