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
@@ -14,7 +14,7 @@
14
14
  "Vue.js"
15
15
  ],
16
16
  "homepage": "https://github.com/ilia-brykin/aloha/#README.md",
17
- "version": "1.2.91",
17
+ "version": "1.2.93",
18
18
  "author": {
19
19
  "name": "Ilia Brykin",
20
20
  "email": "brykin.ilia@gmail.com"
@@ -16,7 +16,7 @@
16
16
  text-align: left;
17
17
  }
18
18
  .a_select_toggle_closeable {
19
- padding: 0;
19
+ padding: 0 30px 0 0;
20
20
  }
21
21
 
22
22
  .a_caret {
@@ -94,6 +94,8 @@ export default function ATinymceAPI(props, context, {
94
94
  readonly: !!disabled.value,
95
95
  valid_elements: validElements.value,
96
96
  valid_styles: validStyles.value,
97
+ force_br_newlines: true,
98
+ indent: false,
97
99
 
98
100
  setup: editor => {
99
101
  vueEditor = editor;
@@ -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
- const isNormalParagraph = element.className.includes("MsoNormal");
76
- const htmlContent = element.innerHTML.trim()
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(/&nbsp;/g, " ")
81
84
  .replace(/^[\s·o§1-9]+[.)]?/g, "");
82
85
 
83
- if (isTagP && isNormalParagraph && !element.className.includes("MsoListParagraph")) {
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
+ }