aloha-vue 1.2.91 → 1.2.93
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.
package/package.json
CHANGED
|
@@ -61,6 +61,7 @@ function parseWord({ html }) {
|
|
|
61
61
|
const rootElement = document.createElement("div");
|
|
62
62
|
let currentList = null;
|
|
63
63
|
let lastLevel = 0;
|
|
64
|
+
let lastIndent = 0;
|
|
64
65
|
const listStack = [];
|
|
65
66
|
|
|
66
67
|
forEach(allChildren, element => {
|
|
@@ -68,31 +69,35 @@ function parseWord({ html }) {
|
|
|
68
69
|
if (!isTagP) {
|
|
69
70
|
rootElement.appendChild(element);
|
|
70
71
|
lastLevel = 0;
|
|
72
|
+
lastIndent = 0;
|
|
71
73
|
currentList = null;
|
|
72
74
|
return;
|
|
73
75
|
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
const
|
|
77
|
+
let htmlContent = element.innerHTML.trim();
|
|
78
|
+
const IS_NORMAL_PARAGRAPH = isNormalParagraph({ element, htmlContent });
|
|
79
|
+
htmlContent = htmlContent
|
|
77
80
|
.replace(/<u>/g, "<span style=\"text-decoration: underline;\">")
|
|
78
81
|
.replace(/<\/u>/g, "</span>")
|
|
79
82
|
.replace(/<!--\[if !supportLists]-->.*?<!--\[endif]-->/gs, "")
|
|
80
83
|
.replace(/ /g, " ")
|
|
81
84
|
.replace(/^[\s·o§1-9]+[.)]?/g, "");
|
|
82
85
|
|
|
83
|
-
if (isTagP &&
|
|
86
|
+
if (isTagP && IS_NORMAL_PARAGRAPH) {
|
|
84
87
|
const newParagraph = document.createElement("p");
|
|
85
88
|
newParagraph.innerHTML = htmlContent;
|
|
86
89
|
rootElement.appendChild(newParagraph);
|
|
87
90
|
lastLevel = 0;
|
|
91
|
+
lastIndent = 0;
|
|
88
92
|
currentList = null;
|
|
89
93
|
return;
|
|
90
94
|
}
|
|
91
95
|
|
|
96
|
+
const MARGIN_LEFT = parseInt(element.style.marginLeft) || 0;
|
|
92
97
|
const LIST_LEVEL = getCurrentLevelForList(element);
|
|
93
98
|
const { type, style } = getListTypeAndStyleFromSpanContent(element);
|
|
94
99
|
|
|
95
|
-
if (!currentList || LIST_LEVEL > lastLevel) {
|
|
100
|
+
if (!currentList || LIST_LEVEL > lastLevel || MARGIN_LEFT > lastIndent) {
|
|
96
101
|
const newList = document.createElement(type);
|
|
97
102
|
if (style) {
|
|
98
103
|
newList.style.listStyleType = style;
|
|
@@ -104,12 +109,17 @@ function parseWord({ html }) {
|
|
|
104
109
|
rootElement.appendChild(newList);
|
|
105
110
|
}
|
|
106
111
|
currentList = newList;
|
|
107
|
-
listStack.push({ element: newList, level: LIST_LEVEL });
|
|
112
|
+
listStack.push({ element: newList, level: LIST_LEVEL, marginLeft: MARGIN_LEFT });
|
|
108
113
|
} else if (LIST_LEVEL < lastLevel) {
|
|
109
114
|
while (listStack.length > 1 && LIST_LEVEL < listStack[listStack.length - 1].level) {
|
|
110
115
|
listStack.pop();
|
|
111
116
|
currentList = listStack[listStack.length - 1].element;
|
|
112
117
|
}
|
|
118
|
+
} else if (MARGIN_LEFT < lastIndent && listStack.length > 1) {
|
|
119
|
+
while (listStack.length > 1 && MARGIN_LEFT < listStack[listStack.length - 1].marginLeft) {
|
|
120
|
+
listStack.pop();
|
|
121
|
+
currentList = listStack[listStack.length - 1].element;
|
|
122
|
+
}
|
|
113
123
|
}
|
|
114
124
|
|
|
115
125
|
const li = document.createElement("li");
|
|
@@ -117,6 +127,7 @@ function parseWord({ html }) {
|
|
|
117
127
|
currentList.appendChild(li);
|
|
118
128
|
|
|
119
129
|
lastLevel = LIST_LEVEL;
|
|
130
|
+
lastIndent = MARGIN_LEFT;
|
|
120
131
|
});
|
|
121
132
|
|
|
122
133
|
return rootElement.innerHTML;
|
|
@@ -185,3 +196,9 @@ function getCurrentLevelForList(p) {
|
|
|
185
196
|
|
|
186
197
|
return level;
|
|
187
198
|
}
|
|
199
|
+
|
|
200
|
+
function isNormalParagraph({ element, htmlContent }) {
|
|
201
|
+
return element.className.includes("MsoNormal") ||
|
|
202
|
+
(!element.className.includes("MsoListParagraph") &&
|
|
203
|
+
!/mso-list:/.test(htmlContent));
|
|
204
|
+
}
|