WordPress/wp-includes/js/dist/rich-text.min.js
Gary Pendergast bffe848347 Build Tools: Update the @wordpress/* packages.
Merges [43801,43803] from the 5.0 branch to trunk.

See #45145.


Built from https://develop.svn.wordpress.org/trunk@44163


git-svn-id: http://core.svn.wordpress.org/trunk@43993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2018-12-14 04:44:01 +00:00

1 line
15 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

this.wp=this.wp||{},this.wp.richText=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=293)}({15:function(t,e,n){"use strict";function r(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,"a",function(){return r})},19:function(t,e,n){"use strict";var r=n(33);function o(t){return function(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}(t)||Object(r.a)(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}n.d(e,"a",function(){return o})},2:function(t,e){!function(){t.exports=this.lodash}()},29:function(t,e,n){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t){return(o="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}n.d(e,"a",function(){return o})},293:function(t,e,n){"use strict";n.r(e);var r=n(2);function o(t,e){if(t===e)return!0;if(!t||!e)return!1;if(t.type!==e.type)return!1;var n=t.attributes,r=e.attributes;if(n===r)return!0;if(!n||!r)return!1;var o=Object.keys(n),i=Object.keys(r);if(o.length!==i.length)return!1;for(var a=o.length,u=0;u<a;u++){var f=o[u];if(n[f]!==r[f])return!1}return!0}function i(t){var e=t.formats,n=t.text,r=t.start,i=t.end,a=e.slice(0);return a.forEach(function(t,e){var n=a[e-1];if(n){var r=t.slice(0);r.forEach(function(t,e){var i=n[e];o(t,i)&&(r[e]=i)}),a[e]=r}}),{formats:a,text:n,start:r,end:i}}function a(t,e){var n=t.formats,o=t.text,a=t.start,f=t.end,c=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,l=arguments.length>3&&void 0!==arguments[3]?arguments[3]:f,s=n.slice(0);if(c===l){for(var d=Object(r.find)(s[c],{type:e.type});Object(r.find)(s[c],d);)u(s,c,e),c--;for(l++;Object(r.find)(s[l],d);)u(s,l,e),l++}else for(var m=c;m<l;m++)u(s,m,e);return i({formats:s,text:o,start:a,end:f})}function u(t,e,n){if(t[e]){var r=t[e].filter(function(t){return t.type!==n.type});r.push(n),t[e]=r}else t[e]=[n]}function f(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return i(e.reduce(function(t,e){var n=e.formats,r=e.text;return{text:t.text+r,formats:t.formats.concat(n)}}))}var c=n(19),l=n(29);function s(t){return 0===t.text.length}function d(t){var e=t.text,n=t.start,r=t.end;return n===r&&(0===e.length||(0===n&&"\u2028"===e.slice(0,1)||(n===e.length&&"\u2028"===e.slice(-1)||"\u2028\u2028"===e.slice(n-1,r+1))))}var m=window.Node,p=m.TEXT_NODE,v=m.ELEMENT_NODE;function h(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.element,n=t.text,r=t.html,o=t.range,i=t.multilineTag,a=t.removeNode,u=t.unwrapNode,f=t.filterString,c=t.removeAttribute;return"string"==typeof n&&n.length>0?{formats:Array(n.length),text:n}:("string"==typeof r&&r.length>0&&(e=function(t,e){var n=t.implementation.createHTMLDocument("").body;return n.innerHTML=e,n}(document,r)),"object"!==Object(l.a)(e)?{formats:[],text:""}:i?function(t){var e=t.element,n=t.range,r=t.multilineTag,o=t.removeNode,i=t.unwrapNode,a=t.filterString,u=t.removeAttribute,f={formats:[],text:""};if(!e||!e.hasChildNodes())return f;for(var c=e.children.length,l=0;l<c;l++){var s=e.children[l];if(s.nodeName.toLowerCase()===r){var d=y({element:s,range:n,multilineTag:r,removeNode:o,unwrapNode:i,filterString:a,removeAttribute:u});0!==l&&(f.formats=f.formats.concat([,]),f.text+="\u2028"),g(f,s,n,d),f.formats=f.formats.concat(d.formats),f.text+=d.text}}return f}({element:e,range:o,multilineTag:i,removeNode:a,unwrapNode:u,filterString:f,removeAttribute:c}):y({element:e,range:o,removeNode:a,unwrapNode:u,filterString:f,removeAttribute:c}))}function g(t,e,n,r){if(n){var o=e.parentNode,i=n.startContainer,a=n.startOffset,u=n.endContainer,f=n.endOffset,c=t.text.length;void 0!==r.start?t.start=c+r.start:e===i?t.start=c+a:o===i&&e===i.childNodes[a]&&(t.start=c),void 0!==r.end?t.end=c+r.end:e===u?t.end=c+f:o===u&&e===u.childNodes[f-1]?t.end=c+r.text.length:o===u&&e===u.childNodes[f]&&(t.end=c)}}function b(t,e,n){if(e){var r=e.startContainer,o=e.endContainer,i=e.startOffset,a=e.endOffset;return t===r&&(i=n(t.nodeValue.slice(0,i)).length),t===o&&(a=n(t.nodeValue.slice(0,a)).length),{startContainer:r,startOffset:i,endContainer:o,endOffset:a}}}function y(t){var e=t.element,n=t.range,r=t.removeNode,i=t.unwrapNode,a=t.filterString,u=t.removeAttribute,f={formats:[],text:""};if(!e)return f;if(!e.hasChildNodes())return g(f,e,n,{formats:[],text:""}),f;for(var l=e.childNodes.length,d=function(t){return t=t.replace(/[\r\n]/g,""),a&&(t=a(t)),t},m=0;m<l;m++){var h=e.childNodes[m];if(h.nodeType!==p){if(h.nodeType===v)if(r&&r(h)||i&&i(h)&&!h.hasChildNodes())g(f,h,n,{formats:[],text:""});else if("BR"!==h.nodeName){var O=f.formats[f.formats.length-1],j=O&&O[O.length-1],N=void 0;if(!i||!i(h)){var S=h.nodeName.toLowerCase(),T=x({element:h,removeAttribute:u}),w=T?{type:S,attributes:T}:{type:S};N=o(w,j)?j:w}var E=y({element:h,range:n,removeNode:r,unwrapNode:i,filterString:a,removeAttribute:u}),C=E.text,A=f.text.length;if(g(f,h,n,E),!s(E)||!N||N.attributes){var D=f.formats;if(N&&N.attributes&&0===C.length)N.object=!0,f.text+="",D[A]?D[A].unshift(N):D[A]=[N];else{f.text+=C;for(var P=E.formats.length;P--;){var L,M=A+P;if(N&&(D[M]?D[M].push(N):D[M]=[N]),E.formats[P])if(D[M])(L=D[M]).push.apply(L,Object(c.a)(E.formats[P]));else D[M]=E.formats[P]}}}}else g(f,h,n,{formats:[],text:""}),f.text+="\n",f.formats.length+=1}else{var V=d(h.nodeValue);g(f,h,n=b(h,n,d),{text:V}),f.text+=V,f.formats.length+=V.length}}return f}function x(t){var e=t.element,n=t.removeAttribute;if(e.hasAttributes()){for(var r,o=e.attributes.length,i=0;i<o;i++){var a=e.attributes[i],u=a.name,f=a.value;n&&n(u)||((r=r||{})[u]=f)}return r}}function O(t,e){var n=t.formats,o=t.start;if(void 0!==o)return Object(r.find)(n[o],{type:e})}function j(t){return t.text}function N(t){var e=t.start,n=t.end;if(void 0!==e&&void 0!==n)return e===n}function S(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return"string"==typeof e&&(e=h({text:e})),i(t.reduce(function(t,n){var r=n.formats,o=n.text;return{text:t.text+e.text+o,formats:t.formats.concat(e.formats,r)}}))}function T(t,e){var n=t.formats,o=t.text,a=t.start,u=t.end,f=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,c=arguments.length>3&&void 0!==arguments[3]?arguments[3]:u,l=n.slice(0);if(f===c){for(var s=Object(r.find)(l[f],{type:e});Object(r.find)(l[f],s);)w(l,f,e),f--;for(c++;Object(r.find)(l[c],s);)w(l,c,e),c++}else for(var d=f;d<c;d++)l[d]&&w(l,d,e);return i({formats:l,text:o,start:a,end:u})}function w(t,e,n){var r=t[e].filter(function(t){return t.type!==n});r.length?t[e]=r:delete t[e]}function E(t,e){var n=t.formats,r=t.text,o=t.start,a=t.end,u=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:a;"string"==typeof e&&(e=h({text:e}));var c=u+e.text.length;return i({formats:n.slice(0,u).concat(e.formats,n.slice(f)),text:r.slice(0,u)+e.text+r.slice(f),start:c,end:c})}function C(t,e,n){return E(t,h(),e,n)}function A(t,e,n){var r=t.formats,o=t.text,a=t.start,u=t.end;return o=o.replace(e,function(t){for(var e=arguments.length,o=new Array(e>1?e-1:0),i=1;i<e;i++)o[i-1]=arguments[i];var f,c=o[o.length-2],s=n;return"function"==typeof s&&(s=n.apply(void 0,[t].concat(o))),"object"===Object(l.a)(s)?(f=s.formats,s=s.text):(f=Array(s.length),r[c]&&(f=f.fill(r[c]))),r=r.slice(0,c).concat(f,r.slice(c+t.length)),a&&(a=u=c+s.length),s}),i({formats:r,text:o,start:a,end:u})}function D(t){var e=t.formats,n=t.text,r=t.start,o=t.end,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return void 0===i||void 0===a?{formats:e,text:n}:{formats:e.slice(i,a),text:n.slice(i,a)}}function P(t,e){var n=t.formats,r=t.text,o=t.start,i=t.end;if("string"!=typeof e)return function(t){var e=t.formats,n=t.text,r=t.start,o=t.end,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o,u={formats:e.slice(0,i),text:n.slice(0,i)},f={formats:e.slice(a),text:n.slice(a),start:0,end:0};return[A(u,/\u2028+$/,""),A(f,/^\u2028+/,"")]}.apply(void 0,arguments);var a=0;return r.split(e).map(function(t){var r=a,u={formats:n.slice(r,r+t.length),text:t};return a+=e.length+t.length,void 0!==o&&void 0!==i&&(o>=r&&o<a?u.start=o-r:o<r&&i>r&&(u.start=0),i>=r&&i<a?u.end=i-r:o<a&&i>a&&(u.end=t.length)),u})}var L=n(8);function M(t,e,n){if(e){var r=n.createEmpty,o=n.append,i=r();return P(t,"\u2028").forEach(function(t,r){o(i,M(t,null,Object(L.a)({},n,{tag:e,multilineIndex:r})))}),i}var a=n.tag,u=n.multilineIndex,f=n.createEmpty,c=n.append,l=n.getLastChild,s=n.getParent,d=n.isText,m=n.getText,p=n.remove,v=n.appendText,h=n.onStartIndex,g=n.onEndIndex,b=n.onEmpty,y=t.formats,x=t.text,O=t.start,j=t.end,N=y.length+1,S=f(a);c(S,"");for(var T=function(t){var e=x.charAt(t),n=y[t],r=y[t-1],o=l(S);n&&n.forEach(function(t,e){if(o&&r&&t===r[e])o=l(o);else{var n=t.type,i=t.attributes,a=t.object,u=s(o),f=c(u,{type:n,attributes:i,object:a});d(o)&&0===m(o).length&&p(o),o=c(a?u:f,"")}}),h&&0===O&&0===t&&h(S,o,u),g&&0===j&&0===t&&g(S,o,u),""!==e&&("\n"===e?(o=c(s(o),{type:"br",object:!0}),o=c(s(o),"")):d(o)?v(o,e):o=c(s(o),e)),h&&O===t+1&&h(S,o,u),g&&j===t+1&&g(S,o,u)},w=0;w<N;w++)T(w);return b&&0===x.length&&b(S),S}var V=window.Node,_=V.TEXT_NODE,I=V.ELEMENT_NODE;function H(t,e,n){for(var r=t.parentNode,o=0;t=t.previousSibling;)o++;return n=[o].concat(Object(c.a)(n)),r!==e&&(n=H(r,e,n)),n}function R(t,e){for(e=Object(c.a)(e);t&&e.length>1;)t=t.childNodes[e.shift()];return{node:t,offset:e[0]}}function k(t){var e=document.implementation.createHTMLDocument("").body;return t?e.appendChild(e.ownerDocument.createElement(t)):e}function F(t,e){"string"==typeof e&&(e=t.ownerDocument.createTextNode(e));var n=e,r=n.type,o=n.attributes;if(r)for(var i in e=t.ownerDocument.createElement(r),o)e.setAttribute(i,o[i]);return t.appendChild(e)}function B(t,e){t.appendData(e)}function X(t){return t.lastChild}function $(t){return t.parentNode}function q(t){return t.nodeType===_}function z(t){return t.nodeValue}function G(t){return t.parentNode.removeChild(t)}function J(t,e){var n=[],r=[];return{body:M(t,e,{createEmpty:k,append:F,getLastChild:X,getParent:$,isText:q,getText:z,remove:G,appendText:B,onStartIndex:function(t,e,r){n=H(e,t,[e.nodeValue.length]),void 0!==r&&(n=[r].concat(Object(c.a)(n)))},onEndIndex:function(t,e,n){r=H(e,t,[e.nodeValue.length]),void 0!==n&&(r=[n].concat(Object(c.a)(r)))},onEmpty:function(t){var e=t.ownerDocument.createElement("br");e.setAttribute("data-mce-bogus","1"),t.appendChild(e)}}),selection:{startPath:n,endPath:r}}}function K(t,e,n){var r=J(t,n),o=r.body,i=r.selection;!function(t,e){var n=0;for(;t.firstChild;){var r=e.childNodes[n],o=t.firstChild.nodeType;r?o!==r.nodeType||o!==_||t.firstChild.nodeValue!==r.nodeValue?e.replaceChild(t.firstChild,r):t.removeChild(t.firstChild):e.appendChild(t.firstChild),n++}for(;e.childNodes[n];)e.removeChild(e.childNodes[n])}(o,e),void 0!==t.start&&function(t,e){var n=R(e,t.startPath),r=n.node,o=n.offset,i=R(e,t.endPath),a=i.node,u=i.offset,f=window.getSelection(),c=e.ownerDocument.createRange(),l=r===a&&o===u;l&&0===o&&r.previousSibling&&r.previousSibling.nodeType===I&&"BR"!==r.previousSibling.nodeName?(r.insertData(0,"\ufeff"),c.setStart(r,1),c.setEnd(a,1)):l&&0===o&&r===_&&0===r.nodeValue.length?(r.insertData(0,"\ufeff"),c.setStart(r,1),c.setEnd(a,1)):(c.setStart(r,o),c.setEnd(a,u));f.removeAllRanges(),f.addRange(c)}(i,e)}var Q=n(60);function U(t,e){return it(M(t,e,{createEmpty:W,append:Z,getLastChild:Y,getParent:et,isText:nt,getText:rt,remove:ot,appendText:tt}).children)}function W(t){return{type:t}}function Y(t){var e=t.children;return e&&e[e.length-1]}function Z(t,e){return"string"==typeof e&&(e={text:e}),e.parent=t,t.children=t.children||[],t.children.push(e),e}function tt(t,e){t.text+=e}function et(t){return t.parent}function nt(t){return"string"==typeof t.text}function rt(t){return t.text}function ot(t){var e=t.parent.children.indexOf(t);return-1!==e&&t.parent.children.splice(e,1),t}function it(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).map(function(t){return void 0===t.text?function(t){var e=t.type,n=t.attributes,r=t.object,o=t.children,i="";for(var a in n)Object(Q.isValidAttributeName)(a)&&(i+=" ".concat(a,'="').concat(Object(Q.escapeAttribute)(n[a]),'"'));return r?"<".concat(e).concat(i,">"):"<".concat(e).concat(i,">").concat(it(o),"</").concat(e,">")}(t):Object(Q.escapeHTML)(t.text)}).join("")}n.d(e,"applyFormat",function(){return a}),n.d(e,"concat",function(){return f}),n.d(e,"create",function(){return h}),n.d(e,"getActiveFormat",function(){return O}),n.d(e,"getTextContent",function(){return j}),n.d(e,"isCollapsed",function(){return N}),n.d(e,"isEmpty",function(){return s}),n.d(e,"isEmptyLine",function(){return d}),n.d(e,"join",function(){return S}),n.d(e,"removeFormat",function(){return T}),n.d(e,"remove",function(){return C}),n.d(e,"replace",function(){return A}),n.d(e,"insert",function(){return E}),n.d(e,"slice",function(){return D}),n.d(e,"split",function(){return P}),n.d(e,"apply",function(){return K}),n.d(e,"unstableToDom",function(){return J}),n.d(e,"toHTMLString",function(){return U})},33:function(t,e,n){"use strict";function r(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}n.d(e,"a",function(){return r})},60:function(t,e){!function(){t.exports=this.wp.escapeHtml}()},8:function(t,e,n){"use strict";n.d(e,"a",function(){return o});var r=n(15);function o(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),o.forEach(function(e){Object(r.a)(t,e,n[e])})}return t}}});