jodit-pro
Version:
PRO Version of Jodit Editor
2 lines (1 loc) • 1.91 kB
JavaScript
var l=Object.defineProperty;var n=(t,e)=>l(t,"name",{value:e,configurable:!0});import{SPACE_REG_EXP as S}from"jodit/esm/core/constants.js";import{LEVEL_KEY as s,listStyleMap as E,STYLE_CSS_KEY as u,STYLE_KEY as p,STYLE_VALID_KEY as m,TYPE_KEY as v}from"../constants.js";import{html as f,isLeaf as y,isList as b,isPseudoLeaf as L,isSameType as c}from"../element/index.js";import{calcListLevels as _}from"../helpers/calc-list-levels.js";import{calcStartBySymbol as Y}from"../helpers/helpers.js";function B(t){var e;if(L(t)){t.name="li",t.style.set("text-indent",null);const i=x(t),o=/[\da-np-zA-NP-Z].?/.test(i)?"ol":"ul",r=k(i,o);t.attributes[v]=o,t.attributes[p]=r,_(t),T(t);const{parent:a}=t;if(!b(a)||!c(t,a)){const d=K(t,o,i,r);return b(a)&&(d.remove(),(e=a.lastElement)===null||e===void 0||e.append(d)),t}}return t}n(B,"convertToList");function T(t){for(;t;){const e=t.previousElement;if(!(y(e)||b(e)))break;if(y(e)){if(t.attributes[s]<e.attributes[s]||t.attributes[s]===e.attributes[s]&&t.parent&&c(t,t.parent))break;e.append(t);continue}const i=e;if(t.attributes[s]<i.attributes[s]||t.attributes[s]===i.attributes[s]&&!c(t,i))break;i.append(t)}}n(T,"moveUp");function g(t){var e;b(t)&&((e=t.parent)===null||e===void 0?void 0:e.name)!=="li"&&(t.style.get(u)==="disc"||t.style.get(u)==="decimal")&&t.style.set(u,null)}n(g,"removeRedundancyStyle");function k(t,e){for(const i in E)if(RegExp(i).test(t))return E[i];return e==="ol"?"decimal":"disc"}n(k,"defineOrderedListStyle");const x=n(t=>t.textBetween(e=>e.isComment&&/\[if.*supportLists.*]/.test(f(e)),e=>e.isComment&&/\[endif]/.test(f(e))).replace(/ /g,"").replace(S(),""),"getSymbol");function K(t,e,i,o){const r=t.wrap(e);return r.attributes.start=Y(i),r.attributes[s]=t.attributes[s],r.attributes[p]=t.attributes[p],r.attributes[m]=t.attributes[p],r.style.set(u,o),g(r),r}n(K,"wrapInNewList");export{B as convertToList,g as removeRedundancyStyle};