From 89c252671ea90f85d171cc8c8d9a49eb52ceb6f5 Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 17 Mar 2022 17:13:19 +0800 Subject: [PATCH] Roo/htmleditor/FilterWord.js --- Roo/htmleditor/FilterWord.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Roo/htmleditor/FilterWord.js b/Roo/htmleditor/FilterWord.js index da1c6f15b6..73cd8dfb92 100644 --- a/Roo/htmleditor/FilterWord.js +++ b/Roo/htmleditor/FilterWord.js @@ -134,7 +134,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, ret[kv[0]] = kv[1]; }); return ret; - } + }, replaceDocBullets : function(doc) @@ -151,6 +151,7 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, // gather all the siblings. var ns = p, parent = p.parentNode, + doc = parent.ownerDocument, items = []; while (ns) { if (!ns.className.match(/MsoListParagraph/)) { @@ -161,13 +162,34 @@ Roo.extend(Roo.htmleditor.FilterWord, Roo.htmleditor.Filter, } var ul = parent.ownerDocument.createElement('ul'); // what about number lists... - + parent.insertBefore(ul, p); + var lvl = 0; + var stack = [ ul ]; + var last_li = false; items.forEach(function(n) { parent.removeChild(n); var spans = n.getElementsByTagName('span'); n.removeChild(spans.item(0)); // remove the fake bullet. + var style = this.styleToObject(n); + var nlvl = (style['mso-list'].split(' ')[1].replace(/level/,'') *1) - 1; + if (nlvl > lvl) { + new indent + var nul = doc.createElement('ul'); // what about number lists... + last_li.appendChild(nul); + stack[nlvl] = nul; + } - }); + var nli = stack[nlvl].appendChild('li'); + last_li = nli; + // copy children of p into nli + while(p.firstChild) { + var fc = p.firstChild; + p.removeChild(fc); + nli.appendChild(fc); + } + + + },this); -- 2.39.2