@richscripts/richtexteditor 2.14.0 → 2.14.1
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 +1 -1
- package/richtexteditor/all_plugins.js +113 -34
- package/richtexteditor/all_plugins.min.js +52 -52
- package/richtexteditor/plugins/all_plugins.js +113 -34
- package/richtexteditor/plugins/all_plugins.min.js +52 -52
- package/richtexteditor/plugins/documentoutline.js +41 -30
- package/richtexteditor/plugins/documentoutline.min.js +1 -1
- package/richtexteditor/plugins/formattingmarks.js +48 -3
- package/richtexteditor/plugins/formattingmarks.min.js +1 -1
- package/richtexteditor/plugins/sanitizer.js +24 -1
- package/richtexteditor/plugins/sanitizer.min.js +1 -1
- package/richtexteditor/rte-config.js +1 -0
- package/richtexteditor/rte.js +3 -2
- package/richtexteditor/runtime/colorpicker_more_ns.htm +93 -16
|
@@ -224,36 +224,47 @@ function RTE_Plugin_DocumentOutline() {
|
|
|
224
224
|
// valid and the pasted copy becomes "slug-2". Ids on non-heading elements are
|
|
225
225
|
// reserved too, so a heading never takes one. Every heading is checked, including
|
|
226
226
|
// levels the outline does not display, since they share one id namespace.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
// and
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
227
|
+
//
|
|
228
|
+
// 2026-09-25 ...but only when the core does not own heading ids. With
|
|
229
|
+
// autoHeadingAnchors on (the default) the core pass gives every heading a unique id
|
|
230
|
+
// after each change, with the same first-keeps rule, and marks the ids it generated so
|
|
231
|
+
// they can follow the text. This block ran 80 ms after each change instead: a heading
|
|
232
|
+
// a person was typing got the slug of its FIRST letter ("Typed heading" -> id="t"),
|
|
233
|
+
// unmarked, so the core took it for the author's own id and kept it for good. The
|
|
234
|
+
// outline needs no id to work (it navigates by element), so it now leaves ids to the
|
|
235
|
+
// core and keeps this pass for integrations that switched core anchors off.
|
|
236
|
+
if (config.autoHeadingAnchors === false) {
|
|
237
|
+
var used = {};
|
|
238
|
+
var withId = editable.querySelectorAll("[id]");
|
|
239
|
+
for (i = 0; i < withId.length; i++) {
|
|
240
|
+
if (!/^H[1-6]$/.test(withId[i].nodeName)) used[withId[i].id] = true;
|
|
241
|
+
}
|
|
242
|
+
// Headings with text claim ids first. An EMPTY heading is usually the shell a cut
|
|
243
|
+
// leaves behind, still carrying the moved heading's id; letting it claim first would
|
|
244
|
+
// hand the moved heading "-2" and break every link to it. So empty headings go last
|
|
245
|
+
// and simply drop an id that a real heading already holds.
|
|
246
|
+
var textOf = function (el) {
|
|
247
|
+
return (el.innerText || el.textContent || "").replace(/\s+/g, " ").replace(/^\s+|\s+$/g, "");
|
|
248
|
+
};
|
|
249
|
+
var empties = [];
|
|
250
|
+
for (i = 0; i < headings.length; i++) {
|
|
251
|
+
var h = headings[i];
|
|
252
|
+
var t = textOf(h);
|
|
253
|
+
if (!t) { empties.push(h); continue; }
|
|
254
|
+
var base = h.id;
|
|
255
|
+
if (!base) base = slugifyHeading(t);
|
|
256
|
+
else if (!used[base]) { used[base] = true; continue; }
|
|
257
|
+
var unique = base;
|
|
258
|
+
var n = 2;
|
|
259
|
+
while (used[unique]) { unique = base + "-" + n; n++; }
|
|
260
|
+
used[unique] = true;
|
|
261
|
+
if (h.id !== unique) h.id = unique;
|
|
262
|
+
}
|
|
263
|
+
for (i = 0; i < empties.length; i++) {
|
|
264
|
+
if (!empties[i].id) continue;
|
|
265
|
+
if (used[empties[i].id]) empties[i].removeAttribute("id");
|
|
266
|
+
else used[empties[i].id] = true;
|
|
267
|
+
}
|
|
257
268
|
}
|
|
258
269
|
for (i = 0; i < headings.length; i++) {
|
|
259
270
|
var heading = headings[i];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_documentoutline=RTE_Plugin_DocumentOutline;function RTE_Plugin_DocumentOutline(){var E=this,o,i,c=null,d=null,p=null,b=null,D=0,g="";E.PluginName="DocumentOutline",E.InitConfig=function(t){o=t,o.documentOutlineEnabled!==!1&&(o.documentOutlineTitle=o.documentOutlineTitle||"Outline",o.documentOutlineHint=o.documentOutlineHint||"Browse headings and jump through long documents without leaving the editor.",o.documentOutlineEmptyText=o.documentOutlineEmptyText||"Add headings to build the document outline.",typeof o.documentOutlineAutoOpen!="boolean"&&(o.documentOutlineAutoOpen=!1),typeof o.documentOutlineMinLevel!="number"&&(o.documentOutlineMinLevel=1),typeof o.documentOutlineMaxLevel!="number"&&(o.documentOutlineMaxLevel=6),L("toolbar_default","#{documentoutline}"),L("toolbar_full","#{documentoutline}"))},E.InitEditor=function(t){i=t,o.documentOutlineEnabled!==!1&&(i.documentOutline={close:function(){A()},list:function(){return N()},open:function(){T()},refresh:function(){y()},toggle:function(){H()}},I(),i.toolbarFactoryMap=i.toolbarFactoryMap||{},i.toolbarFactoryMap.documentoutline=function(e){return i.createToolbarButton(e)},i.attachEvent("exec_command_documentoutline",function(e){e.returnValue=!0,e.stopBubble=!0,H()}),i.attachEvent("change",function(){z()}),i.attachEvent("selectionchange",function(){$()}),O(),y(),o.documentOutlineAutoOpen&&T())};function L(t,e){o[t]&&o[t].indexOf(e)===-1&&(o[t]=o[t]+e)}function I(){var t=o.container.ownerDocument;if(!t.getElementById("rte-document-outline-style")){var e=[".rte-document-outline-shell{display:flex;align-items:stretch;gap:10px;}",".rte-document-outline-shell>.rte-document-outline-host{flex:1 1 auto;min-width:0;}","/* 2026-07-12 navigation panel precision */",".rte-document-outline-panel{display:none;flex:0 0 286px;min-width:248px;max-width:min(330px,30vw);border:1px solid rgba(148,163,184,.22);border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(248,251,255,.96));box-shadow:0 14px 32px rgba(29,78,216,.1),0 2px 8px rgba(15,23,42,.06);overflow:hidden;color:#172033;font-family:Aptos,'Segoe UI',sans-serif;}",".rte-document-outline-shell.is-open>.rte-document-outline-panel{display:flex;flex-direction:column;}",".rte-document-outline-header{padding:12px 12px 9px 14px;border-bottom:1px solid rgba(148,163,184,.16);background:rgba(255,255,255,.72);}",".rte-document-outline-kicker{font-size:10px;line-height:1.3;letter-spacing:.08em;text-transform:uppercase;color:#52657e;font-weight:850;}",".rte-document-outline-title{margin-top:3px;font-size:15px;line-height:1.2;font-weight:850;color:#172033;}",".rte-document-outline-copy{margin-top:5px;font-size:12px;line-height:1.42;color:#52657e;}",".rte-document-outline-toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 10px 8px 14px;border-bottom:1px solid rgba(148,163,184,.16);gap:10px;background:rgba(255,255,255,.52);}",".rte-document-outline-count{min-width:0;font-size:12px;font-weight:750;color:#52657e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}",".rte-document-outline-close{appearance:none;border:1px solid rgba(100,116,139,.18);background:#fff;color:#315277;cursor:pointer;font-size:12px;font-weight:750;padding:6px 9px;border-radius:7px;line-height:1;}",".rte-document-outline-close:hover,.rte-document-outline-close:focus-visible{background:#eef4ff;color:#0f3f9f;border-color:rgba(37,99,235,.28);}",".rte-document-outline-body{padding:6px;overflow:auto;min-height:140px;max-height:520px;scrollbar-width:thin;}",".rte-document-outline-list{display:flex;flex-direction:column;gap:5px;}",".rte-document-outline-item{appearance:none;width:100%;text-align:left;border:1px solid transparent;background:transparent;color:#172033;cursor:pointer;border-radius:7px;padding:8px 10px 8px calc(10px + (var(--rte-outline-level,1) - 1) * 12px);font-size:13px;line-height:1.35;font-weight:650;}",".rte-document-outline-item:hover,.rte-document-outline-item:focus-visible{background:#f8fbff;border-color:rgba(37,99,235,.18);}",".rte-document-outline-item.is-active{background:#eef4ff;border-color:rgba(37,99,235,.26);color:#0f3f9f;box-shadow:0 8px 18px rgba(37,99,235,.1);}",".rte-document-outline-item-level{display:inline-flex;margin:0 0 3px;padding:2px 6px;border-radius:999px;background:#fff;color:#64748b;font-size:10px;line-height:1.1;letter-spacing:.08em;text-transform:uppercase;font-weight:850;box-shadow:inset 0 0 0 1px rgba(148,163,184,.18);}",".rte-document-outline-empty{margin:6px;padding:14px;color:#52657e;font-size:13px;font-weight:700;line-height:1.55;background:#fff;border:1px dashed rgba(148,163,184,.34);border-radius:8px;}","@media (max-width: 1100px){.rte-document-outline-shell{display:block;}.rte-document-outline-panel{margin-top:12px;max-width:none;width:100%;}.rte-document-outline-body{max-height:320px;}}"].join(""),r=t.createElement("style");r.id="rte-document-outline-style",r.appendChild(t.createTextNode(e)),t.head.appendChild(r),i&&typeof i.ensureStyleSheetLive=="function"&&i.ensureStyleSheetLive(t,r,"rte-document-outline-style",e)}}function O(){if(c)return c;var t=o.container,e=t.ownerDocument;c=e.createElement("div"),c.className="rte-document-outline-shell";var r=e.createElement("div");r.className="rte-document-outline-host";var u=t.parentNode;u.insertBefore(c,t),c.appendChild(r),r.appendChild(t),d=e.createElement("aside"),d.className="rte-document-outline-panel",d.setAttribute("aria-label",o.documentOutlineTitle),d.setAttribute("role","complementary");var l=e.createElement("div");l.className="rte-document-outline-header";var n=e.createElement("div");n.className="rte-document-outline-kicker",n.innerText="Document";var a=e.createElement("div");a.className="rte-document-outline-title",a.innerText=o.documentOutlineTitle;var m=e.createElement("div");m.className="rte-document-outline-copy",m.innerText=o.documentOutlineHint,l.appendChild(n),l.appendChild(a),l.appendChild(m);var v=e.createElement("div");v.className="rte-document-outline-toolbar";var f=e.createElement("div");f.className="rte-document-outline-count",f.setAttribute("data-rte-outline-count","1");var s=e.createElement("button");s.type="button",s.className="rte-document-outline-close",s.innerText="Hide",s.setAttribute("aria-label","Hide document outline"),s.onclick=function(){A()},v.appendChild(f),v.appendChild(s);var h=e.createElement("div");return h.className="rte-document-outline-body",p=e.createElement("div"),p.className="rte-document-outline-list",b=e.createElement("div"),b.className="rte-document-outline-empty",b.innerText=o.documentOutlineEmptyText,h.appendChild(p),h.appendChild(b),d.appendChild(l),d.appendChild(v),d.appendChild(h),c.appendChild(d),c}function H(){c&&c.classList.contains("is-open")?A():T()}function T(){O(),c.classList.add("is-open"),y()}function A(){c&&c.classList.remove("is-open")}function z(){clearTimeout(D),D=setTimeout(function(){y()},80)}function B(t){var e=String(t||"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");return e||"section"}function N(){var t=i.getEditable();if(!t)return[];var e=Math.max(1,Math.min(6,o.documentOutlineMinLevel||1)),r=Math.max(e,Math.min(6,o.documentOutlineMaxLevel||6)),u=t.querySelectorAll("h1,h2,h3,h4,h5,h6"),l=[],n,a={},m=t.querySelectorAll("[id]");for(n=0;n<m.length;n++)/^H[1-6]$/.test(m[n].nodeName)||(a[m[n].id]=!0);var v=function(M){return(M.innerText||M.textContent||"").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")},f=[];for(n=0;n<u.length;n++){var s=u[n],h=v(s);if(!h){f.push(s);continue}var x=s.id;if(!x)x=B(h);else if(!a[x]){a[x]=!0;continue}for(var w=x,_=2;a[w];)w=x+"-"+_,_++;a[w]=!0,s.id!==w&&(s.id=w)}for(n=0;n<f.length;n++)f[n].id&&(a[f[n].id]?f[n].removeAttribute("id"):a[f[n].id]=!0);for(n=0;n<u.length;n++){var C=u[n],S=parseInt(C.nodeName.substring(1),10);if(!(S<e||S>r)){var F=(C.innerText||C.textContent||"").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"");l.push({id:C.id||"__rte-outline-"+l.length,level:S,text:F||"Heading "+(l.length+1),element:C})}}return l}function P(){var t=i.getSelection?i.getSelection():null;if(!t||t.rangeCount===0)return null;try{var e=t.getRangeAt(0).cloneRange();return e.collapse(!0),e}catch{return null}}function R(t){var e=P();if(!e||!t.length)return"";var r=e.startContainer.ownerDocument||i.getEditable().ownerDocument,u=r.createRange(),l="";try{u.setStart(e.startContainer,e.startOffset),u.collapse(!0);for(var n=0;n<t.length;n++){var a=r.createRange();a.selectNodeContents(t[n].element),a.collapse(!0),a.compareBoundaryPoints(Range.START_TO_START,u)<=0&&(l=t[n].id)}}catch{return g}return l}function j(t){if(!(!t||!t.element)){t.element.scrollIntoView({behavior:"smooth",block:"center"});try{var e=i.getSelection?i.getSelection():null,r=t.element.ownerDocument.createRange();r.selectNodeContents(t.element),r.collapse(!0),e&&(e.removeAllRanges(),e.addRange(r))}catch{}i.focus(),g=t.id,k()}}function k(){if(p)for(var t=p.querySelectorAll(".rte-document-outline-item"),e=0;e<t.length;e++){var r=t[e],u=r.getAttribute("data-rte-outline-id")===g;r.classList.toggle("is-active",u),r.setAttribute("aria-current",u?"true":"false")}}function $(){var t=N(),e=R(t);if(e===g&&p&&p.childNodes.length){k();return}g=e,y(t)}function y(t){O();var e=t||N();for(g=R(e)||g;p.firstChild;)p.removeChild(p.firstChild);var r=d.querySelector("[data-rte-outline-count]");r&&(r.innerText=e.length+" heading"+(e.length===1?"":"s")),b.style.display=e.length?"none":"block";for(var u=0;u<e.length;u++)(function(l){var n=d.ownerDocument.createElement("button");n.type="button",n.className="rte-document-outline-item",n.style.setProperty("--rte-outline-level",String(l.level)),n.setAttribute("data-rte-outline-id",l.id),n.setAttribute("aria-current","false");var a=d.ownerDocument.createElement("span");a.className="rte-document-outline-item-level",a.innerText="H"+l.level;var m=d.ownerDocument.createElement("span");m.innerText=l.text,n.appendChild(a),n.appendChild(m),n.onclick=function(){j(l)},p.appendChild(n)})(e[u]);k()}}
|
|
1
|
+
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_documentoutline=RTE_Plugin_DocumentOutline;function RTE_Plugin_DocumentOutline(){var E=this,o,i,c=null,d=null,p=null,b=null,D=0,g="";E.PluginName="DocumentOutline",E.InitConfig=function(t){o=t,o.documentOutlineEnabled!==!1&&(o.documentOutlineTitle=o.documentOutlineTitle||"Outline",o.documentOutlineHint=o.documentOutlineHint||"Browse headings and jump through long documents without leaving the editor.",o.documentOutlineEmptyText=o.documentOutlineEmptyText||"Add headings to build the document outline.",typeof o.documentOutlineAutoOpen!="boolean"&&(o.documentOutlineAutoOpen=!1),typeof o.documentOutlineMinLevel!="number"&&(o.documentOutlineMinLevel=1),typeof o.documentOutlineMaxLevel!="number"&&(o.documentOutlineMaxLevel=6),H("toolbar_default","#{documentoutline}"),H("toolbar_full","#{documentoutline}"))},E.InitEditor=function(t){i=t,o.documentOutlineEnabled!==!1&&(i.documentOutline={close:function(){A()},list:function(){return N()},open:function(){T()},refresh:function(){y()},toggle:function(){L()}},z(),i.toolbarFactoryMap=i.toolbarFactoryMap||{},i.toolbarFactoryMap.documentoutline=function(e){return i.createToolbarButton(e)},i.attachEvent("exec_command_documentoutline",function(e){e.returnValue=!0,e.stopBubble=!0,L()}),i.attachEvent("change",function(){B()}),i.attachEvent("selectionchange",function(){$()}),O(),y(),o.documentOutlineAutoOpen&&T())};function H(t,e){o[t]&&o[t].indexOf(e)===-1&&(o[t]=o[t]+e)}function z(){var t=o.container.ownerDocument;if(!t.getElementById("rte-document-outline-style")){var e=[".rte-document-outline-shell{display:flex;align-items:stretch;gap:10px;}",".rte-document-outline-shell>.rte-document-outline-host{flex:1 1 auto;min-width:0;}","/* 2026-07-12 navigation panel precision */",".rte-document-outline-panel{display:none;flex:0 0 286px;min-width:248px;max-width:min(330px,30vw);border:1px solid rgba(148,163,184,.22);border-radius:8px;background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(248,251,255,.96));box-shadow:0 14px 32px rgba(29,78,216,.1),0 2px 8px rgba(15,23,42,.06);overflow:hidden;color:#172033;font-family:Aptos,'Segoe UI',sans-serif;}",".rte-document-outline-shell.is-open>.rte-document-outline-panel{display:flex;flex-direction:column;}",".rte-document-outline-header{padding:12px 12px 9px 14px;border-bottom:1px solid rgba(148,163,184,.16);background:rgba(255,255,255,.72);}",".rte-document-outline-kicker{font-size:10px;line-height:1.3;letter-spacing:.08em;text-transform:uppercase;color:#52657e;font-weight:850;}",".rte-document-outline-title{margin-top:3px;font-size:15px;line-height:1.2;font-weight:850;color:#172033;}",".rte-document-outline-copy{margin-top:5px;font-size:12px;line-height:1.42;color:#52657e;}",".rte-document-outline-toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 10px 8px 14px;border-bottom:1px solid rgba(148,163,184,.16);gap:10px;background:rgba(255,255,255,.52);}",".rte-document-outline-count{min-width:0;font-size:12px;font-weight:750;color:#52657e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}",".rte-document-outline-close{appearance:none;border:1px solid rgba(100,116,139,.18);background:#fff;color:#315277;cursor:pointer;font-size:12px;font-weight:750;padding:6px 9px;border-radius:7px;line-height:1;}",".rte-document-outline-close:hover,.rte-document-outline-close:focus-visible{background:#eef4ff;color:#0f3f9f;border-color:rgba(37,99,235,.28);}",".rte-document-outline-body{padding:6px;overflow:auto;min-height:140px;max-height:520px;scrollbar-width:thin;}",".rte-document-outline-list{display:flex;flex-direction:column;gap:5px;}",".rte-document-outline-item{appearance:none;width:100%;text-align:left;border:1px solid transparent;background:transparent;color:#172033;cursor:pointer;border-radius:7px;padding:8px 10px 8px calc(10px + (var(--rte-outline-level,1) - 1) * 12px);font-size:13px;line-height:1.35;font-weight:650;}",".rte-document-outline-item:hover,.rte-document-outline-item:focus-visible{background:#f8fbff;border-color:rgba(37,99,235,.18);}",".rte-document-outline-item.is-active{background:#eef4ff;border-color:rgba(37,99,235,.26);color:#0f3f9f;box-shadow:0 8px 18px rgba(37,99,235,.1);}",".rte-document-outline-item-level{display:inline-flex;margin:0 0 3px;padding:2px 6px;border-radius:999px;background:#fff;color:#64748b;font-size:10px;line-height:1.1;letter-spacing:.08em;text-transform:uppercase;font-weight:850;box-shadow:inset 0 0 0 1px rgba(148,163,184,.18);}",".rte-document-outline-empty{margin:6px;padding:14px;color:#52657e;font-size:13px;font-weight:700;line-height:1.55;background:#fff;border:1px dashed rgba(148,163,184,.34);border-radius:8px;}","@media (max-width: 1100px){.rte-document-outline-shell{display:block;}.rte-document-outline-panel{margin-top:12px;max-width:none;width:100%;}.rte-document-outline-body{max-height:320px;}}"].join(""),r=t.createElement("style");r.id="rte-document-outline-style",r.appendChild(t.createTextNode(e)),t.head.appendChild(r),i&&typeof i.ensureStyleSheetLive=="function"&&i.ensureStyleSheetLive(t,r,"rte-document-outline-style",e)}}function O(){if(c)return c;var t=o.container,e=t.ownerDocument;c=e.createElement("div"),c.className="rte-document-outline-shell";var r=e.createElement("div");r.className="rte-document-outline-host";var u=t.parentNode;u.insertBefore(c,t),c.appendChild(r),r.appendChild(t),d=e.createElement("aside"),d.className="rte-document-outline-panel",d.setAttribute("aria-label",o.documentOutlineTitle),d.setAttribute("role","complementary");var l=e.createElement("div");l.className="rte-document-outline-header";var n=e.createElement("div");n.className="rte-document-outline-kicker",n.innerText="Document";var a=e.createElement("div");a.className="rte-document-outline-title",a.innerText=o.documentOutlineTitle;var m=e.createElement("div");m.className="rte-document-outline-copy",m.innerText=o.documentOutlineHint,l.appendChild(n),l.appendChild(a),l.appendChild(m);var v=e.createElement("div");v.className="rte-document-outline-toolbar";var f=e.createElement("div");f.className="rte-document-outline-count",f.setAttribute("data-rte-outline-count","1");var s=e.createElement("button");s.type="button",s.className="rte-document-outline-close",s.innerText="Hide",s.setAttribute("aria-label","Hide document outline"),s.onclick=function(){A()},v.appendChild(f),v.appendChild(s);var h=e.createElement("div");return h.className="rte-document-outline-body",p=e.createElement("div"),p.className="rte-document-outline-list",b=e.createElement("div"),b.className="rte-document-outline-empty",b.innerText=o.documentOutlineEmptyText,h.appendChild(p),h.appendChild(b),d.appendChild(l),d.appendChild(v),d.appendChild(h),c.appendChild(d),c}function L(){c&&c.classList.contains("is-open")?A():T()}function T(){O(),c.classList.add("is-open"),y()}function A(){c&&c.classList.remove("is-open")}function B(){clearTimeout(D),D=setTimeout(function(){y()},80)}function I(t){var e=String(t||"").toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");return e||"section"}function N(){var t=i.getEditable();if(!t)return[];var e=Math.max(1,Math.min(6,o.documentOutlineMinLevel||1)),r=Math.max(e,Math.min(6,o.documentOutlineMaxLevel||6)),u=t.querySelectorAll("h1,h2,h3,h4,h5,h6"),l=[],n;if(o.autoHeadingAnchors===!1){var a={},m=t.querySelectorAll("[id]");for(n=0;n<m.length;n++)/^H[1-6]$/.test(m[n].nodeName)||(a[m[n].id]=!0);var v=function(M){return(M.innerText||M.textContent||"").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")},f=[];for(n=0;n<u.length;n++){var s=u[n],h=v(s);if(!h){f.push(s);continue}var x=s.id;if(!x)x=I(h);else if(!a[x]){a[x]=!0;continue}for(var w=x,_=2;a[w];)w=x+"-"+_,_++;a[w]=!0,s.id!==w&&(s.id=w)}for(n=0;n<f.length;n++)f[n].id&&(a[f[n].id]?f[n].removeAttribute("id"):a[f[n].id]=!0)}for(n=0;n<u.length;n++){var C=u[n],S=parseInt(C.nodeName.substring(1),10);if(!(S<e||S>r)){var F=(C.innerText||C.textContent||"").replace(/\s+/g," ").replace(/^\s+|\s+$/g,"");l.push({id:C.id||"__rte-outline-"+l.length,level:S,text:F||"Heading "+(l.length+1),element:C})}}return l}function P(){var t=i.getSelection?i.getSelection():null;if(!t||t.rangeCount===0)return null;try{var e=t.getRangeAt(0).cloneRange();return e.collapse(!0),e}catch{return null}}function R(t){var e=P();if(!e||!t.length)return"";var r=e.startContainer.ownerDocument||i.getEditable().ownerDocument,u=r.createRange(),l="";try{u.setStart(e.startContainer,e.startOffset),u.collapse(!0);for(var n=0;n<t.length;n++){var a=r.createRange();a.selectNodeContents(t[n].element),a.collapse(!0),a.compareBoundaryPoints(Range.START_TO_START,u)<=0&&(l=t[n].id)}}catch{return g}return l}function j(t){if(!(!t||!t.element)){t.element.scrollIntoView({behavior:"smooth",block:"center"});try{var e=i.getSelection?i.getSelection():null,r=t.element.ownerDocument.createRange();r.selectNodeContents(t.element),r.collapse(!0),e&&(e.removeAllRanges(),e.addRange(r))}catch{}i.focus(),g=t.id,k()}}function k(){if(p)for(var t=p.querySelectorAll(".rte-document-outline-item"),e=0;e<t.length;e++){var r=t[e],u=r.getAttribute("data-rte-outline-id")===g;r.classList.toggle("is-active",u),r.setAttribute("aria-current",u?"true":"false")}}function $(){var t=N(),e=R(t);if(e===g&&p&&p.childNodes.length){k();return}g=e,y(t)}function y(t){O();var e=t||N();for(g=R(e)||g;p.firstChild;)p.removeChild(p.firstChild);var r=d.querySelector("[data-rte-outline-count]");r&&(r.innerText=e.length+" heading"+(e.length===1?"":"s")),b.style.display=e.length?"none":"block";for(var u=0;u<e.length;u++)(function(l){var n=d.ownerDocument.createElement("button");n.type="button",n.className="rte-document-outline-item",n.style.setProperty("--rte-outline-level",String(l.level)),n.setAttribute("data-rte-outline-id",l.id),n.setAttribute("aria-current","false");var a=d.ownerDocument.createElement("span");a.className="rte-document-outline-item-level",a.innerText="H"+l.level;var m=d.ownerDocument.createElement("span");m.innerText=l.text,n.appendChild(a),n.appendChild(m),n.onclick=function(){j(l)},p.appendChild(n)})(e[u]);k()}}
|
|
@@ -148,22 +148,67 @@ function RTE_Plugin_FormattingMarks() {
|
|
|
148
148
|
// may be deliberate.
|
|
149
149
|
if (parent.nodeName === "CODE" || parent.nodeName === "PRE") return;
|
|
150
150
|
|
|
151
|
+
// Replacing the text node moves a caret inside it to the node's old place in its
|
|
152
|
+
// parent - usually the paragraph start. This runs on every keyup, and the first
|
|
153
|
+
// space typed at a line end is always a non-breaking one, so with marks on every
|
|
154
|
+
// later character landed at the start, reversed: " edited" became "detide".
|
|
155
|
+
// Remember where the selection was inside this node and put it back.
|
|
156
|
+
var sel = doc.getSelection ? doc.getSelection() : null;
|
|
157
|
+
var range = sel && sel.rangeCount ? sel.getRangeAt(0) : null;
|
|
158
|
+
var keepStart = range && range.startContainer === node ? range.startOffset : -1;
|
|
159
|
+
var keepEnd = range && range.endContainer === node ? range.endOffset : -1;
|
|
160
|
+
|
|
151
161
|
var frag = doc.createDocumentFragment();
|
|
162
|
+
var pieces = []; // in order: { node, marker } - every marker stands for ONE character
|
|
152
163
|
var buf = "";
|
|
153
164
|
for (var i = 0; i < text.length; i++) {
|
|
154
165
|
var def = chars[text[i]];
|
|
166
|
+
// A space typed at a line end is inserted as a non-breaking placeholder that the
|
|
167
|
+
// browser turns back into a space when the next character arrives. Wrapped in a
|
|
168
|
+
// non-editable marker it never could, and saved as a hard . Leave the one
|
|
169
|
+
// right before the caret alone; it is marked once the caret moves on.
|
|
170
|
+
if (def && text[i] === " " && i === keepStart - 1 && keepStart === keepEnd) def = null;
|
|
155
171
|
if (!def) { buf += text[i]; continue; }
|
|
156
|
-
if (buf) { frag.appendChild(doc.createTextNode(buf)); buf = ""; }
|
|
172
|
+
if (buf) { pieces.push({ node: frag.appendChild(doc.createTextNode(buf)), marker: false }); buf = ""; }
|
|
157
173
|
var span = doc.createElement("span");
|
|
158
174
|
span.setAttribute("data-rte-fm", "1");
|
|
159
175
|
span.setAttribute("data-rte-fm-char", text[i]);
|
|
160
176
|
span.className = def.cls;
|
|
161
177
|
span.setAttribute("contenteditable", "false");
|
|
162
178
|
span.textContent = def.label;
|
|
163
|
-
frag.appendChild(span);
|
|
179
|
+
pieces.push({ node: frag.appendChild(span), marker: true });
|
|
164
180
|
}
|
|
165
|
-
if (buf) frag.appendChild(doc.createTextNode(buf));
|
|
181
|
+
if (buf) pieces.push({ node: frag.appendChild(doc.createTextNode(buf)), marker: false });
|
|
166
182
|
parent.replaceChild(frag, node);
|
|
183
|
+
|
|
184
|
+
if (keepStart < 0 && keepEnd < 0) return;
|
|
185
|
+
// Offset k in the old text -> a point in the pieces. Inside text where possible;
|
|
186
|
+
// never inside a marker (it is not editable): just before or after it.
|
|
187
|
+
function pointAt(k) {
|
|
188
|
+
var pos = 0;
|
|
189
|
+
for (var p = 0; p < pieces.length; p++) {
|
|
190
|
+
var piece = pieces[p];
|
|
191
|
+
if (piece.marker) {
|
|
192
|
+
if (k <= pos) return { node: parent, offset: Array.prototype.indexOf.call(parent.childNodes, piece.node) };
|
|
193
|
+
pos += 1;
|
|
194
|
+
} else {
|
|
195
|
+
var len = piece.node.nodeValue.length;
|
|
196
|
+
if (k <= pos + len) return { node: piece.node, offset: k - pos };
|
|
197
|
+
pos += len;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
var last = pieces[pieces.length - 1].node;
|
|
201
|
+
return { node: parent, offset: Array.prototype.indexOf.call(parent.childNodes, last) + 1 };
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
var r = doc.createRange();
|
|
205
|
+
var a = pointAt(keepStart >= 0 ? keepStart : 0);
|
|
206
|
+
var b = keepEnd >= 0 ? pointAt(keepEnd) : a;
|
|
207
|
+
if (keepStart < 0) { r.setStart(range.startContainer, range.startOffset); } else r.setStart(a.node, a.offset);
|
|
208
|
+
if (keepEnd < 0) { r.setEnd(range.endContainer, range.endOffset); } else r.setEnd(b.node, b.offset);
|
|
209
|
+
sel.removeAllRanges();
|
|
210
|
+
sel.addRange(r);
|
|
211
|
+
} catch (e) { /* a selection we cannot restore is no reason to lose the marks */ }
|
|
167
212
|
}
|
|
168
213
|
|
|
169
214
|
// ---- serialization safety -------------------------------------------
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_formattingmarks=RTE_Plugin_FormattingMarks,typeof RTE_DefaultConfig.formattingMarkPilcrow>"u"&&(RTE_DefaultConfig.formattingMarkPilcrow=!0),typeof RTE_DefaultConfig.formattingMarkBlocks>"u"&&(RTE_DefaultConfig.formattingMarkBlocks=!0),typeof RTE_DefaultConfig.formattingMarkInvisibles>"u"&&(RTE_DefaultConfig.formattingMarkInvisibles=!0);function RTE_Plugin_FormattingMarks(){var
|
|
1
|
+
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_formattingmarks=RTE_Plugin_FormattingMarks,typeof RTE_DefaultConfig.formattingMarkPilcrow>"u"&&(RTE_DefaultConfig.formattingMarkPilcrow=!0),typeof RTE_DefaultConfig.formattingMarkBlocks>"u"&&(RTE_DefaultConfig.formattingMarkBlocks=!0),typeof RTE_DefaultConfig.formattingMarkInvisibles>"u"&&(RTE_DefaultConfig.formattingMarkInvisibles=!0);function RTE_Plugin_FormattingMarks(){var m=this,C,o,S=null,u=!1,A=!1,x=!1,v=[{ch:"\xA0",cls:"rte-fm-nbsp",label:"\xB7"},{ch:"\u200B",cls:"rte-fm-zwsp",label:"\u2400"},{ch:"\u200E",cls:"rte-fm-bidi",label:"\u200E"},{ch:"\u200F",cls:"rte-fm-bidi",label:"\u200F"},{ch:"\xAD",cls:"rte-fm-shy",label:"-"}];m.PluginName="FormattingMarks",m.InitConfig=function(e){C=e},m.InitEditor=function(e){o=e,o.attachEvent("exec_command_formattingmarks",function(t){t.returnValue=!0,m.Toggle()}),E();try{o.attachEvent("ready",E)}catch{}try{o.attachEvent("aftersethtml",function(){E(),u&&_()})}catch{}setTimeout(E,0),o.setFormattingMarks=function(t){return u=!!t,I(),u},o.toggleFormattingMarks=function(){return m.Toggle()},o.isFormattingMarks=function(){return u},o.getFormattingMarksCss=function(){return O()}},m.Toggle=function(){return u=!u,I(),u};function E(){var e=R();if(e&&(H(e),W(),e!==S)){S=e;var t=h();t&&(t.addEventListener("keyup",function(){u&&_()}),t.addEventListener("paste",function(){u&&_()}))}}function R(){try{return o.getDocument()}catch{return null}}function h(){try{return o.getEditable()}catch{return null}}function _(){x||(x=!0,setTimeout(function(){x=!1,F()},0))}function I(){var e=h();e&&(e.classList&&(e.classList.toggle("rte-fm-on",u),e.classList.toggle("rte-fm-pilcrow",u&&C.formattingMarkPilcrow!==!1),e.classList.toggle("rte-fm-blocks",u&&C.formattingMarkBlocks!==!1)),u&&C.formattingMarkInvisibles!==!1?F():L())}function L(){var e=h();if(e)for(var t=e.querySelectorAll("span[data-rte-fm]"),n=0;n<t.length;n++){var r=t[n],a=r.parentNode;a&&(a.replaceChild(r.ownerDocument.createTextNode(r.getAttribute("data-rte-fm-char")||""),r),a.normalize())}}function F(){var e=h(),t=R();if(!(!e||!t)){L();for(var n={},r=0;r<v.length;r++)n[v[r].ch]=v[r];for(var a=t.createTreeWalker(e,4,null,!1),i=[],f;f=a.nextNode();)if(f.nodeValue){for(var l=0;l<v.length;l++)if(f.nodeValue.indexOf(v[l].ch)>=0){i.push(f);break}}for(var s=0;s<i.length;s++)V(t,i[s],n)}}function V(e,t,n){var r=t.nodeValue,a=t.parentNode;if(!a||a.nodeName==="CODE"||a.nodeName==="PRE")return;for(var i=e.getSelection?e.getSelection():null,f=i&&i.rangeCount?i.getRangeAt(0):null,l=f&&f.startContainer===t?f.startOffset:-1,s=f&&f.endContainer===t?f.endOffset:-1,w=e.createDocumentFragment(),c=[],g="",d=0;d<r.length;d++){var b=n[r[d]];if(b&&r[d]==="\xA0"&&d===l-1&&l===s&&(b=null),!b){g+=r[d];continue}g&&(c.push({node:w.appendChild(e.createTextNode(g)),marker:!1}),g="");var p=e.createElement("span");p.setAttribute("data-rte-fm","1"),p.setAttribute("data-rte-fm-char",r[d]),p.className=b.cls,p.setAttribute("contenteditable","false"),p.textContent=b.label,c.push({node:w.appendChild(p),marker:!0})}if(g&&c.push({node:w.appendChild(e.createTextNode(g)),marker:!1}),a.replaceChild(w,t),l<0&&s<0)return;function q(T){for(var y=0,D=0;D<c.length;D++){var N=c[D];if(N.marker){if(T<=y)return{node:a,offset:Array.prototype.indexOf.call(a.childNodes,N.node)};y+=1}else{var P=N.node.nodeValue.length;if(T<=y+P)return{node:N.node,offset:T-y};y+=P}}var J=c[c.length-1].node;return{node:a,offset:Array.prototype.indexOf.call(a.childNodes,J)+1}}try{var k=e.createRange(),M=q(l>=0?l:0),B=s>=0?q(s):M;l<0?k.setStart(f.startContainer,f.startOffset):k.setStart(M.node,M.offset),s<0?k.setEnd(f.endContainer,f.endOffset):k.setEnd(B.node,B.offset),i.removeAllRanges(),i.addRange(k)}catch{}}function z(){var e=h();if(!e)return function(){};var t=Array.prototype.slice.call(e.querySelectorAll("span[data-rte-fm]"));if(!t.length)return function(){};for(var n=[],r=0;r<t.length;r++){var a=t[r],i=a.ownerDocument.createTextNode(a.getAttribute("data-rte-fm-char")||"");n.push({span:a,parent:a.parentNode,text:i}),a.parentNode&&a.parentNode.replaceChild(i,a)}return function(){for(var l=0;l<n.length;l++){var s=n[l];s.text.parentNode&&s.text.parentNode.replaceChild(s.span,s.text)}}}function W(){if(!A){for(var e=["getHTMLCode","getJSON","getHTMLContent","getText"],t=!1,n=0;n<e.length;n++)(function(r){var a=o[r];if(!(typeof a!="function"||a.__rteFmWrapped)){var i=function(){var f=z();try{return a.apply(o,arguments)}finally{f()}};i.__rteFmWrapped=!0,o[r]=i,t=!0}})(e[n]);t&&(A=!0)}}function O(){return".rte-fm-pilcrow p::after,.rte-fm-pilcrow h1::after,.rte-fm-pilcrow h2::after,.rte-fm-pilcrow h3::after,.rte-fm-pilcrow h4::after,.rte-fm-pilcrow h5::after,.rte-fm-pilcrow h6::after,.rte-fm-pilcrow li::after,.rte-fm-pilcrow blockquote::after{content:'\\00b6';color:#9aa4b5;opacity:.65;font-weight:400;}.rte-fm-blocks p,.rte-fm-blocks h1,.rte-fm-blocks h2,.rte-fm-blocks h3,.rte-fm-blocks h4,.rte-fm-blocks h5,.rte-fm-blocks h6,.rte-fm-blocks ul,.rte-fm-blocks ol,.rte-fm-blocks blockquote,.rte-fm-blocks table,.rte-fm-blocks div{outline:1px dashed rgba(120,140,170,.45);outline-offset:1px;}span[data-rte-fm]{color:#c2410c;opacity:.75;user-select:none;}.rte-fm-nbsp{background:rgba(194,65,12,.10);border-radius:2px;}.rte-fm-zwsp,.rte-fm-shy,.rte-fm-bidi{background:rgba(194,65,12,.18);border-radius:2px;font-size:.8em;vertical-align:middle;}"}function H(e){if(e){var t=e.getElementById("rte-formatting-marks-styles"),n=O();if(t){if(t.getAttribute("data-css")===n)return;t.parentNode&&t.parentNode.removeChild(t)}var r=e.createElement("style");r.id="rte-formatting-marks-styles",r.setAttribute("data-css",n),r.appendChild(e.createTextNode(n)),(e.head||e.getElementsByTagName("head")[0]||e.documentElement).appendChild(r),o&&typeof o.ensureStyleSheetLive=="function"&&o.ensureStyleSheetLive(e,r,"rte-formatting-marks-styles",r.textContent)}}}
|
|
@@ -380,6 +380,7 @@ function RTE_Plugin_Sanitizer() {
|
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
var attrs = [];
|
|
383
|
+
var strippedSrc = false;
|
|
383
384
|
for (var a = 0; a < el.attributes.length; a++) attrs.push(el.attributes[a]);
|
|
384
385
|
for (var k = 0; k < attrs.length; k++) {
|
|
385
386
|
var name = attrs[k].name.toLowerCase();
|
|
@@ -397,7 +398,11 @@ function RTE_Plugin_Sanitizer() {
|
|
|
397
398
|
if (name.indexOf("data-") === 0 || name.indexOf("aria-") === 0) continue;
|
|
398
399
|
|
|
399
400
|
if (URL_ATTRS[name]) {
|
|
400
|
-
if (!isSafeUrl(value, tag, name)) {
|
|
401
|
+
if (!isSafeUrl(value, tag, name)) {
|
|
402
|
+
note(report.removedAttributes, tag + "[" + name + "]");
|
|
403
|
+
el.removeAttribute(attrs[k].name);
|
|
404
|
+
if (name === "src") strippedSrc = true;
|
|
405
|
+
}
|
|
401
406
|
continue;
|
|
402
407
|
}
|
|
403
408
|
if (!ALLOWED_ATTRS[name] && !attrExtra(name)) {
|
|
@@ -406,6 +411,18 @@ function RTE_Plugin_Sanitizer() {
|
|
|
406
411
|
}
|
|
407
412
|
}
|
|
408
413
|
|
|
414
|
+
// An <img> whose only source was just stripped is an empty box that
|
|
415
|
+
// saves as <img> with no src -- dragging a page image into the editor
|
|
416
|
+
// from a page opened on disk did exactly that (its file: src is not a
|
|
417
|
+
// safe scheme). Drop the element when nothing is left to show. Keep it
|
|
418
|
+
// when srcset or a lazy-load data-*src still carries an image, and never
|
|
419
|
+
// touch an <img> that arrived without a src (an app placeholder).
|
|
420
|
+
if (tag === "img" && strippedSrc && !el.hasAttribute("srcset") && !hasDataSource(el)) {
|
|
421
|
+
note(report.removedTags, "img");
|
|
422
|
+
el.parentNode.removeChild(el);
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
|
|
409
426
|
// A link that opens a new tab without rel="noopener" hands the
|
|
410
427
|
// opener window to the destination.
|
|
411
428
|
if (tag === "a" && (el.getAttribute("target") || "").toLowerCase() === "_blank") {
|
|
@@ -422,6 +439,12 @@ function RTE_Plugin_Sanitizer() {
|
|
|
422
439
|
parent.removeChild(el);
|
|
423
440
|
}
|
|
424
441
|
function note(list, what) { if (list.indexOf(what) < 0) list.push(what); }
|
|
442
|
+
function hasDataSource(el) {
|
|
443
|
+
for (var i = 0; i < el.attributes.length; i++) {
|
|
444
|
+
if (/^data-(.*-)?(src|srcset|original)$/i.test(el.attributes[i].name)) return true;
|
|
445
|
+
}
|
|
446
|
+
return false;
|
|
447
|
+
}
|
|
425
448
|
|
|
426
449
|
function sanitizeHtml(html) {
|
|
427
450
|
var out = html;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_sanitizer=RTE_Plugin_Sanitizer,typeof RTE_DefaultConfig.contentSanitizer>"u"&&(RTE_DefaultConfig.contentSanitizer=!0);function RTE_Plugin_Sanitizer(){var
|
|
1
|
+
window.RTE_DefaultConfig||(window.RTE_DefaultConfig={}),RTE_DefaultConfig.plugin_sanitizer=RTE_Plugin_Sanitizer,typeof RTE_DefaultConfig.contentSanitizer>"u"&&(RTE_DefaultConfig.contentSanitizer=!0);function RTE_Plugin_Sanitizer(){var w=this,p,l,L=!1,b={removedTags:[],removedAttributes:[],calls:0,lastPasses:0},R=[];w.PluginName="Sanitizer",w.InitConfig=function(t){p=t},w.InitEditor=function(t){if(l=t,p.contentSanitizer===!1)return;l.sanitizeHtml=function(r){return y(String(r??""))},l.getSanitizerReport=function(){return JSON.parse(JSON.stringify(b))};function e(){try{$(),q()}catch{}try{Q()}catch{}try{K()}catch{}}e();try{l.attachEvent("ready",e)}catch{}setTimeout(e,0),setTimeout(e,400)};var z={};"p,div,span,br,hr,h1,h2,h3,h4,h5,h6,b,strong,i,em,u,s,strike,del,ins,mark,small,sub,sup,abbr,cite,q,dfn,kbd,samp,var,time,data,bdi,bdo,wbr,ruby,rt,rp,ul,ol,li,dl,dt,dd,table,thead,tbody,tfoot,tr,td,th,caption,colgroup,col,blockquote,pre,code,figure,figcaption,section,article,header,footer,main,aside,nav,address,details,summary,a,img,picture,source,video,audio,track,map,area,input,label,button,svg,g,path,circle,ellipse,rect,line,polyline,polygon,text,tspan,defs,marker,linearGradient,radialGradient,stop,clipPath,mask,pattern,use,symbol,title,desc".split(",").forEach(function(t){z[t]=!0});var M={script:1,noscript:1,template:1,object:1,embed:1,applet:1,base:1,meta:1,link:1,frame:1,frameset:1,foreignobject:1,xml:1,"script:":1},C={};"id,class,style,title,lang,dir,translate,hidden,tabindex,role,contenteditable,spellcheck,autocomplete,draggable,sandbox,allowfullscreen,allow,frameborder,scrolling,href,src,srcset,sizes,alt,width,height,loading,decoding,referrerpolicy,target,rel,download,type,value,name,placeholder,checked,disabled,readonly,colspan,rowspan,headers,scope,span,align,valign,bgcolor,border,cellpadding,cellspacing,start,reversed,datetime,cite,open,controls,autoplay,loop,muted,playsinline,poster,preload,kind,srclang,label,usemap,ismap,coords,shape,viewbox,xmlns,fill,stroke,stroke-width,stroke-linecap,stroke-linejoin,stroke-dasharray,d,cx,cy,r,rx,ry,x,y,x1,y1,x2,y2,points,transform,opacity,fill-rule,clip-rule,gradientunits,offset,stop-color,stop-opacity,text-anchor,font-size,font-family,font-weight,preserveaspectratio,version".split(",").forEach(function(t){C[t]=!0});var I={href:1,src:1,action:1,formaction:1,poster:1,cite:1,data:1,longdesc:1,background:1,ping:1,srcset:1},H=/^(https?|mailto|tel|ftp|sms|callto|webcal|geo|bitcoin):/i,P=/^data:image\/(png|jpe?g|gif|webp|bmp|x-icon|avif);base64,[a-z0-9+/=\s]+$/i;function x(t,e,r){var a=String(t??"").replace(/[\u0000-\u0020\u007F-\u00A0]+/g,"").trim();if(!a)return!1;if(e==="use")return a.charAt(0)==="#";if(/^[#?/]/.test(a))return!0;var o=/^([a-z][a-z0-9+.\-]*):/i.exec(a);return o?P.test(a)?e==="img"||e==="source"||r==="poster"||r==="srcset":/^blob:/i.test(a)?e==="img"||e==="video"||e==="audio"||e==="source":H.test(a):!0}function j(t){for(var e=[],r=String(t??"").split(";"),a=0;a<r.length;a++){var o=r[a];if(o.trim()&&!/expression\s*\(|(javascript|vbscript|livescript)\s*:|-moz-binding|behaviou?r\s*:|@import|-o-link/i.test(o)){var n=/url\s*\(\s*(['"]?)([^'")]*)\1\s*\)/i.exec(o);n&&!x(n[2],"img","src")||e.push(o.trim())}}return e.join("; ")}var G="allow-scripts allow-same-origin allow-presentation";function U(t,e){var r=G.split(" "),a=!1;try{a=new URL(e,location.href).origin===location.origin}catch{}if(a&&(r=r.filter(function(n){return n!=="allow-same-origin"})),t.hasAttribute("sandbox")){var o=(t.getAttribute("sandbox")||"").toLowerCase().split(/\s+/);r=r.filter(function(n){return o.indexOf(n)>=0})}t.setAttribute("sandbox",r.join(" "))}function F(t){if(p.sanitizerAllowIframes===!1)return!1;var e=t.getAttribute("src")||"";if(!/^https?:/i.test(e))return!1;var r=p.sanitizerAllowedIframeHosts;if(!r||!r.length)return U(t,e),!0;try{for(var a=new URL(e).hostname.toLowerCase(),o=0;o<r.length;o++){var n=String(r[o]).toLowerCase();if(a===n||a.slice(-(n.length+1))==="."+n)return!0}}catch{}return!1}function N(t){var e={},r=[],a=[];(t||[]).forEach(function(n){if(n instanceof RegExp){a.push(n);return}var s=String(n).toLowerCase();if(s.indexOf("*")===-1){e[s]=!0;return}r.push(s.split("*"))});function o(n,s){var i=n[0];if(s.lastIndexOf(i,0)!==0)return!1;var u=n[n.length-1];if(u&&(s.length<u.length||s.indexOf(u,s.length-u.length)===-1))return!1;for(var d=i.length,g=1;g<n.length;g++)if(n[g]){var h=s.indexOf(n[g],d);if(h===-1)return!1;d=h+n[g].length}return!0}return function(n){if(e[n])return!0;for(var s=0;s<r.length;s++)if(o(r[s],n))return!0;for(var i=0;i<a.length;i++)if(a[i].test(n))return!0;return!1}}function A(t,e){var r=N(p.sanitizerAllowTags),a=N(p.sanitizerAllowAttributes),o=p.sanitizerAllowStyleTags===!0,n=[];(function V(k){for(var E=0;E<k.childNodes.length;E++){var m=k.childNodes[E];m.nodeType===1?(n.push(m),V(m)):m.nodeType===8&&n.push(m)}})(t);for(var s=0;s<n.length;s++){var i=n[s];if(i.parentNode){if(i.nodeType===8){O(i.data)&&(c(e.removedTags,"#comment"),i.parentNode.removeChild(i));continue}var u=(i.localName||i.nodeName||"").toLowerCase();if(u==="style"){if(!o){c(e.removedTags,"style"),i.parentNode.removeChild(i);continue}}else if(u==="iframe"){if(i.hasAttribute("srcdoc")&&(c(e.removedAttributes,"iframe[srcdoc]"),i.removeAttribute("srcdoc")),!F(i)){c(e.removedTags,"iframe"),i.parentNode.removeChild(i);continue}}else if(u==="title"||u==="desc"){if(!i.closest||!i.closest("svg")){c(e.removedTags,u),i.parentNode.removeChild(i);continue}}else if(M[u]){c(e.removedTags,u),i.parentNode.removeChild(i);continue}else if(!z[u]&&!r(u)){c(e.removedTags,u),B(i);continue}for(var d=[],g=!1,h=0;h<i.attributes.length;h++)d.push(i.attributes[h]);for(var v=0;v<d.length;v++){var f=d[v].name.toLowerCase(),S=d[v].value;if(f.indexOf("on")===0){c(e.removedAttributes,f),i.removeAttribute(d[v].name);continue}if(f==="xlink:href"||f==="xmlns:xlink"){x(S,u,f)||(c(e.removedAttributes,f),i.removeAttribute(d[v].name));continue}if(f==="srcdoc"){c(e.removedAttributes,"srcdoc"),i.removeAttribute(d[v].name);continue}if(f==="style"){i.setAttribute("style",j(S));continue}if(!(f.indexOf("data-")===0||f.indexOf("aria-")===0)){if(I[f]){x(S,u,f)||(c(e.removedAttributes,u+"["+f+"]"),i.removeAttribute(d[v].name),f==="src"&&(g=!0));continue}!C[f]&&!a(f)&&(c(e.removedAttributes,f),i.removeAttribute(d[v].name))}}if(u==="img"&&g&&!i.hasAttribute("srcset")&&!W(i)){c(e.removedTags,"img"),i.parentNode.removeChild(i);continue}if(u==="a"&&(i.getAttribute("target")||"").toLowerCase()==="_blank"){var _=(i.getAttribute("rel")||"").toLowerCase();_.indexOf("noopener")<0&&i.setAttribute("rel",(_?_+" ":"")+"noopener noreferrer")}}}return t}function B(t){for(var e=t.parentNode;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}function c(t,e){t.indexOf(e)<0&&t.push(e)}function W(t){for(var e=0;e<t.attributes.length;e++)if(/^data-(.*-)?(src|srcset|original)$/i.test(t.attributes[e].name))return!0;return!1}function y(t){var e=t;b.calls++;for(var r=0;r<3;r++){var a=new DOMParser().parseFromString("<body>"+e+"</body>","text/html");A(a.body,b);var o=a.body.innerHTML;if(b.lastPasses=r+1,o===e)break;e=o}return e}function $(){if(!L){for(var t=["getHTMLCode","getHTMLContent"],e=!1,r=0;r<t.length;r++)(function(a){var o=l[a];if(!(typeof o!="function"||o.__rteSanitized)){var n=function(){var s=o.apply(l,arguments);return typeof s!="string"?s:y(s)};n.__rteSanitized=!0,l[a]=n,e=!0}})(t[r]);e&&(L=!0)}}function q(){for(var t=["setHTMLCode","setHTMLContent"],e=0;e<t.length;e++)(function(r){var a=l[r];if(!(typeof a!="function"||a.__rteSanitizedIn)){var o=function(n){var s=[].slice.call(arguments);return typeof n=="string"&&(s[0]=y(n)),a.apply(l,s)};o.__rteSanitizedIn=!0,l[r]=o}})(t[e])}function J(t){return/\son[a-z]+\s*=/i.test(t)||/<\s*(script|iframe|object|embed|base)\b/i.test(t)||/srcdoc\s*=/i.test(t)||/(javascript|vbscript)\s*:/i.test(t)||/data:\s*text\/html/i.test(t)}function O(t){var e=String(t??"");return e.indexOf("-->")!==-1||e.indexOf("--!>")!==-1||e.charAt(0)===">"||e.charAt(0)==="-"&&e.charAt(1)===">"}var D=/^(script|iframe|object|embed|base|meta|link|form)$/;function T(t){if(!t.attributes)return!1;for(var e=0;e<t.attributes.length;e++){var r=t.attributes[e].name.toLowerCase();if(r.indexOf("on")===0||r==="srcdoc"||(r==="href"||r==="src"||r==="data"||r==="action"||r==="xlink:href")&&/(javascript|vbscript)\s*:|data:\s*text\/html/i.test(t.attributes[e].value||""))return!0}return!1}function X(t){if(D.test(t.localName||"")||T(t))return!0;for(var e=t.getElementsByTagName?t.getElementsByTagName("*"):[],r=0;r<e.length;r++)if(D.test(e[r].localName||"")||T(e[r]))return!0;return!1}function K(){if(p.sanitizerGuardLiveDom!==!1){var t=null;try{t=l.getEditable()}catch{return}if(!(!t||t.__rteLiveGuard)){t.__rteLiveGuard=!0;var e=new MutationObserver(function(r){for(var a=!1,o=0;o<r.length&&!a;o++){var n=r[o];if(n.type==="attributes"){var s=(n.attributeName||"").toLowerCase();(s.indexOf("on")===0||s==="srcdoc"||T(n.target))&&(a=!0);continue}for(var i=0;i<n.addedNodes.length;i++){var u=n.addedNodes[i];if(u.nodeType===8){if(O(u.data)){a=!0;break}continue}if(u.nodeType===1&&X(u)){a=!0;break}}}if(a)try{A(t,b)}catch{}});e.observe(t,{childList:!0,subtree:!0,attributes:!0}),R.push(e)}}}function Q(){var t=null;try{t=l.getEditable()}catch{return}if(!t||t.__rteSanitizePaste)return;t.__rteSanitizePaste=!0,t.addEventListener("paste",function(r){var a=r.clipboardData||window.clipboardData;if(a){var o="";try{o=a.getData("text/html")||""}catch{return}if(!(!o||!J(o))){r.preventDefault(),r.stopImmediatePropagation();var n=y(o);try{l.insertHTML(n)}catch{try{l.insertText(a.getData("text/plain")||"")}catch{}}}}},!0);function e(){var r=function(){try{A(t,b)}catch{}};setTimeout(r,0),setTimeout(r,250)}t.addEventListener("paste",e,!1),t.addEventListener("drop",e,!0)}}
|
|
@@ -918,6 +918,7 @@ RTE_DefaultConfig.text_tablecolumn = "Table Column";
|
|
|
918
918
|
RTE_DefaultConfig.text_colorauto = "Automatic";
|
|
919
919
|
|
|
920
920
|
RTE_DefaultConfig.text_colormore = "More Colors...";
|
|
921
|
+
RTE_DefaultConfig.text_colorrecent = "Recent colors";
|
|
921
922
|
RTE_DefaultConfig.text_colorpicker = "Color Picker";
|
|
922
923
|
|
|
923
924
|
RTE_DefaultConfig.text_colorwebpalette = "Web Palette";
|