agenda-libre-ruby/public/assets/tinymce/plugins/searchreplace/plugin-d66ecd8b832b21ecea59d9925ed6a7863b4a544b18040760ce786d2b1a3e64d3.js
2019-08-04 22:45:24 +02:00

11 lines
9.1 KiB
JavaScript

/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.0.12 (2019-07-18)
*/
!function(){"use strict";var o=function(e){var t=e,n=function(){return t};return{get:n,set:function(e){t=e},clone:function(){return o(n())}}},e=tinymce.util.Tools.resolve("tinymce.PluginManager"),p=function(){return(p=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},m=tinymce.util.Tools.resolve("tinymce.util.Tools");function x(e){return e&&1===e.nodeType&&"false"===e.contentEditable}var t,n,r,a,i,f={findAndReplaceDOMText:function D(e,t,n,r,o){var a,i,h,f,g,p,c=[],d=0;function u(e,t){if(t=t||0,!e[0])throw new Error("findAndReplaceDOMText cannot handle zero-length matches");var n=e.index;if(0<t){var r=e[t];if(!r)throw new Error("Invalid capture group");n+=e[0].indexOf(r),e[0]=r}return[n,n+e[0].length,[e[0]]]}if(h=t.ownerDocument,f=o.getBlockElements(),g=o.getWhiteSpaceElements(),p=o.getShortEndedElements(),i=function l(e){var t;if(3===e.nodeType)return e.data;if(g[e.nodeName]&&!f[e.nodeName])return"";if(t="",x(e))return"\n";if((f[e.nodeName]||p[e.nodeName])&&(t+="\n"),e=e.firstChild)for(;t+=l(e),e=e.nextSibling;);return t}(t)){if(e.global)for(;a=e.exec(i);)c.push(u(a,r));else a=i.match(e),c.push(u(a,r));return c.length&&(d=c.length,function m(e,t,n){var r,o,a,i,c=[],d=0,u=e,l=t.shift(),s=0;e:for(;;){if((f[u.nodeName]||p[u.nodeName]||x(u))&&d++,3===u.nodeType&&(!o&&u.length+d>=l[1]?(o=u,i=l[1]-d):r&&c.push(u),!r&&u.length+d>l[0]&&(r=u,a=l[0]-d),d+=u.length),r&&o){if(u=n({startNode:r,startNodeIndex:a,endNode:o,endNodeIndex:i,innerNodes:c,match:l[2],matchIndex:s}),d-=o.length-i,o=r=null,c=[],s++,!(l=t.shift()))break}else if(g[u.nodeName]&&!f[u.nodeName]||!u.firstChild){if(u.nextSibling){u=u.nextSibling;continue}}else if(!x(u)){u=u.firstChild;continue}for(;;){if(u.nextSibling){u=u.nextSibling;break}if(u.parentNode===e)break e;u=u.parentNode}}}(t,c,function s(e){var m;if("function"!=typeof e){var r=e.nodeType?e:h.createElement(e);m=function(e,t){var n=r.cloneNode(!1);return n.setAttribute("data-mce-index",t),e&&n.appendChild(h.createTextNode(e)),n}}else m=e;return function(e){var t,n,r,o=e.startNode,a=e.endNode,i=e.matchIndex;if(o===a){var c=o;r=c.parentNode,0<e.startNodeIndex&&(t=h.createTextNode(c.data.substring(0,e.startNodeIndex)),r.insertBefore(t,c));var d=m(e.match[0],i);return r.insertBefore(d,c),e.endNodeIndex<c.length&&(n=h.createTextNode(c.data.substring(e.endNodeIndex)),r.insertBefore(n,c)),c.parentNode.removeChild(c),d}t=h.createTextNode(o.data.substring(0,e.startNodeIndex)),n=h.createTextNode(a.data.substring(e.endNodeIndex));for(var u=m(o.data.substring(e.startNodeIndex),i),l=0,s=e.innerNodes.length;l<s;++l){var f=e.innerNodes[l],g=m(f.data,i);f.parentNode.replaceChild(g,f)}var p=m(a.data.substring(0,e.endNodeIndex),i);return(r=o.parentNode).insertBefore(t,o),r.insertBefore(u,o),r.removeChild(o),(r=a.parentNode).insertBefore(p,a),r.insertBefore(n,a),r.removeChild(a),p}}(n))),d}}},h=function(e){var t=e.getAttribute("data-mce-index");return"number"==typeof t?""+t:t},v=function(e){var t=e.parentNode;e.firstChild&&t.insertBefore(e.firstChild,e),e.parentNode.removeChild(e)},c=function(e,t){var n,r=[];if((n=m.toArray(e.getBody().getElementsByTagName("span"))).length)for(var o=0;o<n.length;o++){var a=h(n[o]);null!==a&&a.length&&(a===t.toString()&&r.push(n[o]))}return r},g=function(e,t,n){var r=t.get(),o=r.index,a=e.dom;(n=!1!==n)?o+1===r.count?o=0:o++:o-1==-1?o=r.count-1:o--,a.removeClass(c(e,r.index),"mce-match-marker-selected");var i=c(e,o);return i.length?(a.addClass(c(e,o),"mce-match-marker-selected"),e.selection.scrollIntoView(i[0]),o):-1},b=function(e,t){var n=t.parentNode;e.remove(t),e.isEmpty(n)&&e.remove(n)},y=function(e,t,n,r,o){n=(n=n.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")).replace(/\s/g,"[^\\S\\r\\n]"),n=o?"\\b"+n+"\\b":n;var a,i,c,d,u,l=(a=e,i=t,c=new RegExp(n,r?"g":"gi"),(u=a.dom.create("span",{"data-mce-bogus":1})).className="mce-match-marker",d=a.getBody(),T(a,i,!1),f.findAndReplaceDOMText(c,d,u,!1,a.schema));if(l){var s=g(e,t,!0);t.set({index:s,count:l,text:n,matchCase:r,wholeWord:o})}return l},N=function(e,t){var n=g(e,t,!0);t.set(p({},t.get(),{index:n}))},C=function(e,t){var n=g(e,t,!1);t.set(p({},t.get(),{index:n}))},w=function(e){var t=h(e);return null!==t&&0<t.length},A=function(e,t,n,r,o){var a,i,c,d,u,l=t.get(),s=l.index,f=s;for(r=!1!==r,c=e.getBody(),i=m.grep(m.toArray(c.getElementsByTagName("span")),w),a=0;a<i.length;a++){var g=h(i[a]);if(d=u=parseInt(g,10),o||d===l.index){for(n.length?(i[a].firstChild.nodeValue=n,v(i[a])):b(e.dom,i[a]);i[++a];){if((d=parseInt(h(i[a]),10))!==u){a--;break}b(e.dom,i[a])}r&&f--}else s<u&&i[a].setAttribute("data-mce-index",String(u-1))}return t.set(p({},l,{count:o?0:l.count-1,index:f})),r?N(e,t):C(e,t),!o&&0<t.get().count},T=function(e,t,n){var r,o,a,i,c=t.get();for(o=m.toArray(e.getBody().getElementsByTagName("span")),r=0;r<o.length;r++){var d=h(o[r]);null!==d&&d.length&&(d===c.index.toString()&&(a||(a=o[r].firstChild),i=o[r].firstChild),v(o[r]))}if(t.set(p({},c,{index:-1,count:0,text:""})),a&&i){var u=e.dom.createRng();return u.setStart(a,0),u.setEnd(i,i.data.length),!1!==n&&e.selection.setRng(u),u}},d=function(r,o){return{done:function(e){return T(r,o,e)},find:function(e,t,n){return y(r,o,e,t,n)},next:function(){return N(r,o)},prev:function(){return C(r,o)},replace:function(e,t,n){return A(r,o,e,t,n)}}},u=function(e){return function(){return e}},l=u(!1),s=u(!0),S=function(){return B},B=(a={fold:function(e,t){return e()},is:l,isSome:l,isNone:s,getOr:r=function(e){return e},getOrThunk:n=function(e){return e()},getOrDie:function(e){throw new Error(e||"error: getOrDie called on none.")},getOrNull:function(){return null},getOrUndefined:function(){return undefined},or:r,orThunk:n,map:S,ap:S,each:function(){},bind:S,flatten:S,exists:l,forall:s,filter:S,equals:t=function(e){return e.isNone()},equals_:t,toArray:function(){return[]},toString:u("none()")},Object.freeze&&Object.freeze(a),a),I=(i="function",function(e){return function(e){if(null===e)return"null";var t=typeof e;return"object"===t&&(Array.prototype.isPrototypeOf(e)||e.constructor&&"Array"===e.constructor.name)?"array":"object"===t&&(String.prototype.isPrototypeOf(e)||e.constructor&&"String"===e.constructor.name)?"string":t}(e)===i}),O=Array.prototype.slice,E=(I(Array.from)&&Array.from,function(a,i){var c=o(i.get().matchCase),d=o(i.get().wholeWord);a.undoManager.add();var e=m.trim(a.selection.getContent({format:"text"}));function u(e){(1<i.get().count?e.enable:e.disable)("next"),(1<i.get().count?e.enable:e.disable)("prev")}var l=function(e,t){!function(e,t){for(var n=0,r=e.length;n<r;n++)t(e[n],n,e)}(["replace","replaceall","prev","next"],t?e.disable:e.enable)};var s=function(e){T(a,i,!1),l(e,!0),u(e)},r=function(e){var t=e.getData(),n=i.get();if(t.findtext.length){if(n.text===t.findtext&&n.matchCase===c.get()&&n.wholeWord===d.get())N(a,i);else{var r=y(a,i,t.findtext,c.get(),d.get());r<=0&&function o(e){a.windowManager.alert("Could not find the specified string.",function(){e.focus("findtext")})}(e),l(e,0===r)}u(e)}else s(e)},t={title:"Find and Replace",size:"normal",body:{type:"panel",items:[{type:"bar",items:[{type:"input",name:"findtext",placeholder:"Find",maximized:!0},{type:"button",name:"prev",text:"Previous",icon:"action-prev",disabled:!0,borderless:!0},{type:"button",name:"next",text:"Next",icon:"action-next",disabled:!0,borderless:!0}]},{type:"input",name:"replacetext",placeholder:"Replace with"}]},buttons:[{type:"menu",name:"options",icon:"preferences",tooltip:"Preferences",align:"start",fetch:function(e){e([{type:"togglemenuitem",text:"Match case",onAction:function(e){c.set(!c.get())},active:c.get()},{type:"togglemenuitem",text:"Find whole words only",onAction:function(e){d.set(!d.get())},active:d.get()}])}},{type:"custom",name:"find",text:"Find",primary:!0},{type:"custom",name:"replace",text:"Replace",disabled:!0},{type:"custom",name:"replaceall",text:"Replace All",disabled:!0}],initialData:{findtext:e,replacetext:""},onChange:function(e,t){"findtext"===t.name&&0<i.get().count&&s(e)},onAction:function(e,t){var n=e.getData();switch(t.name){case"find":r(e);break;case"replace":A(a,i,n.replacetext)?u(e):s(e);break;case"replaceall":A(a,i,n.replacetext,!0,!0),s(e);break;case"prev":C(a,i),u(e);break;case"next":N(a,i),u(e)}},onSubmit:r,onClose:function(){a.focus(),T(a,i),a.undoManager.add()}};a.windowManager.open(t,{inline:"toolbar"})}),k=function(e,t){e.addCommand("SearchReplace",function(){E(e,t)})},M=function(e,t){return function(){E(e,t)}},R=function(e,t){e.ui.registry.addMenuItem("searchreplace",{text:"Find and replace...",shortcut:"Meta+F",onAction:M(e,t),icon:"search"}),e.ui.registry.addButton("searchreplace",{tooltip:"Find and replace",onAction:M(e,t),icon:"search"}),e.shortcuts.add("Meta+F","",M(e,t))};!function F(){e.add("searchreplace",function(e){var t=o({index:-1,count:0,text:"",matchCase:!1,wholeWord:!1});return k(e,t),R(e,t),d(e,t)})}()}();