WordPress/wp-includes/js/dist/format-library.min.js
jorgefilipecosta 80ce372761 Block Editor: Update WordPress Packages.
Updated packages:
@wordpress/annotations: 1.7.2 -> 1.9.0
@wordpress/api-fetch: 3.6.4 -> 3.8.0
@wordpress/block-directory: 1.0.5 -> 1.2.0
@wordpress/block-editor: 3.2.5 -> 3.4.0
@wordpress/block-library: 2.9.6 -> 2.11.0
@wordpress/blocks: 6.7.2 -> 6.9.0
@wordpress/components: 8.3.2 -> 8.5.0
@wordpress/compose: 3.7.2 -> 3.9.0
@wordpress/core-data: 2.7.5 -> 2.9.0
@wordpress/data: 4.9.2 -> 4.11.0
@wordpress/data-controls: 1.3.4 -> 1.5.0
@wordpress/date: 3.5.0 -> 3.7.0
@wordpress/dom: 2.5.2 -> 2.6.0
@wordpress/e2e-test-utils: 3.0.0 -> 4.0.0
@wordpress/edit-post: 3.8.6 -> 3.10.0
@wordpress/editor: 9.7.6 -> 9.9.0
@wordpress/element: 2.8.2 -> 2.10.0
@wordpress/escape-html: 1.5.1 -> 1.6.0
@wordpress/format-library: 1.9.5 -> 1.11.0
@wordpress/i18n: 3.6.1 -> 3.7.0
@wordpress/keycodes: 2.6.2 -> 2.7.0
@wordpress/list-reusable-blocks: 1.8.4 -> 1.10.0
@wordpress/media-utils: 1.2.4 -> 1.4.0
@wordpress/notices: 1.8.2 -> 1.10.0
@wordpress/nux: 3.7.2 -> 3.9.0
@wordpress/plugins: 2.7.2 -> 2.9.0
@wordpress/rich-text: 3.7.2 -> 3.9.0
@wordpress/scripts: 6.0.0 -> 6.1.1
@wordpress/server-side-render: 1.3.4 -> 1.5.0
@wordpress/shortcode: 2.4.1 -> 2.5.0
@wordpress/token-list: 1.6.1 -> 1.8.0
@wordpress/url: 2.8.2 -> 2.9.0
@wordpress/viewport: 2.8.2 -> 2.10.0

Props gziolo, youknowriad.
Fixes #49142.
Built from https://develop.svn.wordpress.org/trunk@47051


git-svn-id: http://core.svn.wordpress.org/trunk@46851 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-01-08 11:57:23 +00:00

2 lines
17 KiB
JavaScript

/*! This file is auto-generated */
this.wp=this.wp||{},this.wp.formatLibrary=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.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 i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));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=372)}({0:function(t,e){!function(){t.exports=this.wp.element}()},1:function(t,e){!function(){t.exports=this.wp.i18n}()},12:function(t,e,n){"use strict";function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function i(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}n.d(e,"a",(function(){return i}))},13:function(t,e,n){"use strict";function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.d(e,"a",(function(){return r}))},14:function(t,e,n){"use strict";function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}n.d(e,"a",(function(){return r}))},15:function(t,e,n){"use strict";n.d(e,"a",(function(){return o}));var r=n(31),i=n(6);function o(t,e){return!e||"object"!==Object(r.a)(e)&&"function"!=typeof e?Object(i.a)(t):e}},16:function(t,e,n){"use strict";function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}n.d(e,"a",(function(){return r}))},17:function(t,e,n){"use strict";function r(t,e){return(r=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r(t,e)}n.d(e,"a",(function(){return i}))},19:function(t,e){!function(){t.exports=this.wp.keycodes}()},2:function(t,e){!function(){t.exports=this.lodash}()},21:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(40);function i(t,e){if(null==t)return{};var n,i,o=Object(r.a)(t,e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);for(i=0;i<a.length;i++)n=a[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}},24:function(t,e){!function(){t.exports=this.wp.richText}()},25:function(t,e){!function(){t.exports=this.wp.url}()},3:function(t,e){!function(){t.exports=this.wp.components}()},31: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)}n.d(e,"a",(function(){return r}))},372:function(t,e,n){"use strict";n.r(e);var r=n(21),i=n(24),o=n(0),a=n(1),c=n(5),u=Object(a.__)("Bold"),l={name:"core/bold",title:u,tagName:"strong",className:null,edit:function(t){var e=t.isActive,n=t.value,r=t.onChange,a=function(){return r(Object(i.toggleFormat)(n,{type:"core/bold"}))};return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.RichTextShortcut,{type:"primary",character:"b",onUse:a}),Object(o.createElement)(c.RichTextToolbarButton,{name:"bold",icon:"editor-bold",title:u,onClick:a,isActive:e,shortcutType:"primary",shortcutCharacter:"b"}),Object(o.createElement)(c.__unstableRichTextInputEvent,{inputType:"formatBold",onInput:a}))}},s=Object(a.__)("Inline Code"),b={name:"core/code",title:s,tagName:"code",className:null,__unstableInputRule:function(t){var e=t,n=e.start,r=e.text;if("`"!==r.slice(n-1,n))return t;var o=r.slice(0,n-1).lastIndexOf("`");if(-1===o)return t;var a=o,c=n-2;return a===c?t:(t=Object(i.remove)(t,a,a+1),t=Object(i.remove)(t,c,c+1),t=Object(i.applyFormat)(t,{type:"core/code"},a,c))},edit:function(t){var e=t.value,n=t.onChange,r=t.isActive;return Object(o.createElement)(c.RichTextToolbarButton,{icon:"editor-code",title:s,onClick:function(){return n(Object(i.toggleFormat)(e,{type:"core/code"}))},isActive:r})}},p=n(7),f=n(13),d=n(12),m=n(15),h=n(16),O=n(6),v=n(17),j=n(3),y=n(19),g=["image"],k=Object(a.__)("Inline image"),w=function(t){return t.stopPropagation()};var _={name:"core/image",title:k,keywords:[Object(a.__)("photo"),Object(a.__)("media")],object:!0,tagName:"img",className:null,attributes:{className:"class",style:"style",url:"src",alt:"alt"},edit:function(t){function e(){var t;return Object(f.a)(this,e),(t=Object(m.a)(this,Object(h.a)(e).apply(this,arguments))).onChange=t.onChange.bind(Object(O.a)(t)),t.onKeyDown=t.onKeyDown.bind(Object(O.a)(t)),t.openModal=t.openModal.bind(Object(O.a)(t)),t.closeModal=t.closeModal.bind(Object(O.a)(t)),t.state={modal:!1},t}return Object(v.a)(e,t),Object(d.a)(e,[{key:"onChange",value:function(t){this.setState({width:t})}},{key:"onKeyDown",value:function(t){[y.LEFT,y.DOWN,y.RIGHT,y.UP,y.BACKSPACE,y.ENTER].indexOf(t.keyCode)>-1&&t.stopPropagation()}},{key:"openModal",value:function(){this.setState({modal:!0})}},{key:"closeModal",value:function(){this.setState({modal:!1})}},{key:"render",value:function(){var t,e=this,n=this.props,r=n.value,u=n.onChange,l=n.isObjectActive,s=n.activeObjectAttributes;return Object(o.createElement)(c.MediaUploadCheck,null,Object(o.createElement)(c.RichTextToolbarButton,{icon:Object(o.createElement)(j.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},Object(o.createElement)(j.Path,{d:"M4 16h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2zM4 5h10v9H4V5zm14 9v2h4v-2h-4zM2 20h20v-2H2v2zm6.4-8.8L7 9.4 5 12h8l-2.6-3.4-2 2.6z"})),title:k,onClick:this.openModal,isActive:l}),this.state.modal&&Object(o.createElement)(c.MediaUpload,{allowedTypes:g,onSelect:function(t){var n=t.id,o=t.url,a=t.alt,c=t.width;e.closeModal(),u(Object(i.insertObject)(r,{type:"core/image",attributes:{className:"wp-image-".concat(n),style:"width: ".concat(Math.min(c,150),"px;"),url:o,alt:a}}))},onClose:this.closeModal,render:function(t){return(0,t.open)(),null}}),l&&Object(o.createElement)(j.Popover,{position:"bottom center",focusOnMount:!1,anchorRef:(t=window.getSelection(),t.rangeCount?t.getRangeAt(0):null)},Object(o.createElement)("form",{className:"editor-format-toolbar__image-container-content block-editor-format-toolbar__image-container-content",onKeyPress:w,onKeyDown:this.onKeyDown,onSubmit:function(t){var n=r.replacements.slice();n[r.start]={type:"core/image",attributes:Object(p.a)({},s,{style:"width: ".concat(e.state.width,"px;")})},u(Object(p.a)({},r,{replacements:n})),t.preventDefault()}},Object(o.createElement)(j.TextControl,{className:"editor-format-toolbar__image-container-value block-editor-format-toolbar__image-container-value",type:"number",label:Object(a.__)("Width"),value:this.state.width,min:1,onChange:this.onChange}),Object(o.createElement)(j.IconButton,{icon:"editor-break",label:Object(a.__)("Apply"),type:"submit"}))))}}],[{key:"getDerivedStateFromProps",value:function(t,e){var n=t.activeObjectAttributes.style;return n===e.previousStyle?null:n?{width:n.replace(/\D/g,""),previousStyle:n}:{width:void 0,previousStyle:n}}}]),e}(o.Component)},E=Object(a.__)("Italic"),C={name:"core/italic",title:E,tagName:"em",className:null,edit:function(t){var e=t.isActive,n=t.value,r=t.onChange,a=function(){return r(Object(i.toggleFormat)(n,{type:"core/italic"}))};return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.RichTextShortcut,{type:"primary",character:"i",onUse:a}),Object(o.createElement)(c.RichTextToolbarButton,{name:"italic",icon:"editor-italic",title:E,onClick:a,isActive:e,shortcutType:"primary",shortcutCharacter:"i"}),Object(o.createElement)(c.__unstableRichTextInputEvent,{inputType:"formatItalic",onInput:a}))}},T=n(25),S=n(53),L=n(14),x=n(2);function P(t){if(!t)return!1;var e=t.trim();if(!e)return!1;if(/^\S+:/.test(e)){var n=Object(T.getProtocol)(e);if(!Object(T.isValidProtocol)(n))return!1;if(Object(x.startsWith)(n,"http")&&!/^https?:\/\/[^\/\s]/i.test(e))return!1;var r=Object(T.getAuthority)(e);if(!Object(T.isValidAuthority)(r))return!1;var i=Object(T.getPath)(e);if(i&&!Object(T.isValidPath)(i))return!1;var o=Object(T.getQueryString)(e);if(o&&!Object(T.isValidQueryString)(o))return!1;var a=Object(T.getFragment)(e);if(a&&!Object(T.isValidFragment)(a))return!1}return!(Object(x.startsWith)(e,"#")&&!Object(T.isValidFragment)(e))}function A(t){var e=t.url,n=t.opensInNewWindow,r=t.text,i={type:"core/link",attributes:{url:e}};if(n){var o=Object(a.sprintf)(Object(a.__)("%s (opens in a new tab)"),r);i.attributes.target="_blank",i.attributes.rel="noreferrer noopener",i.attributes["aria-label"]=o}return i}var R=function(t){return t.stopPropagation()};function N(t,e){return t.addingLink||e.editLink}var F=function(t){var e=t.isActive,n=t.addingLink,i=t.value,a=Object(r.a)(t,["isActive","addingLink","value"]),u=Object(o.useMemo)((function(){var t=window.getSelection();if(t.rangeCount){var e=t.getRangeAt(0);if(n)return e;var r=e.startContainer;for(r=r.nextElementSibling||r;r.nodeType!==window.Node.ELEMENT_NODE;)r=r.parentNode;return r.closest("a")}}),[e,n,i.start,i.end]);return u?Object(o.createElement)(c.URLPopover,Object(L.a)({anchorRef:u},a)):null},I=function(t){function e(){var t;return Object(f.a)(this,e),(t=Object(m.a)(this,Object(h.a)(e).apply(this,arguments))).editLink=t.editLink.bind(Object(O.a)(t)),t.submitLink=t.submitLink.bind(Object(O.a)(t)),t.onKeyDown=t.onKeyDown.bind(Object(O.a)(t)),t.onChangeInputValue=t.onChangeInputValue.bind(Object(O.a)(t)),t.setLinkTarget=t.setLinkTarget.bind(Object(O.a)(t)),t.onFocusOutside=t.onFocusOutside.bind(Object(O.a)(t)),t.resetState=t.resetState.bind(Object(O.a)(t)),t.autocompleteRef=Object(o.createRef)(),t.state={opensInNewWindow:!1,inputValue:""},t}return Object(v.a)(e,t),Object(d.a)(e,[{key:"onKeyDown",value:function(t){[y.LEFT,y.DOWN,y.RIGHT,y.UP,y.BACKSPACE,y.ENTER].indexOf(t.keyCode)>-1&&t.stopPropagation()}},{key:"onChangeInputValue",value:function(t){this.setState({inputValue:t})}},{key:"setLinkTarget",value:function(t){var e=this.props,n=e.activeAttributes.url,r=void 0===n?"":n,o=e.value,a=e.onChange;if(this.setState({opensInNewWindow:t}),!N(this.props,this.state)){var c=Object(i.getTextContent)(Object(i.slice)(o));a(Object(i.applyFormat)(o,A({url:r,opensInNewWindow:t,text:c})))}}},{key:"editLink",value:function(t){this.setState({editLink:!0}),t.preventDefault()}},{key:"submitLink",value:function(t){var e=this.props,n=e.isActive,r=e.value,o=e.onChange,c=e.speak,u=this.state,l=u.inputValue,s=u.opensInNewWindow,b=Object(T.prependHTTP)(l),p=A({url:b,opensInNewWindow:s,text:Object(i.getTextContent)(Object(i.slice)(r))});if(t.preventDefault(),Object(i.isCollapsed)(r)&&!n){var f=Object(i.applyFormat)(Object(i.create)({text:b}),p,0,b.length);o(Object(i.insert)(r,f))}else o(Object(i.applyFormat)(r,p));this.resetState(),P(b)?c(n?Object(a.__)("Link edited."):Object(a.__)("Link inserted."),"assertive"):c(Object(a.__)("Warning: the link has been inserted but may have errors. Please test it."),"assertive")}},{key:"onFocusOutside",value:function(){var t=this.autocompleteRef.current;t&&t.contains(document.activeElement)||this.resetState()}},{key:"resetState",value:function(){this.props.stopAddingLink(),this.setState({editLink:!1})}},{key:"render",value:function(){var t=this,e=this.props,n=e.isActive,r=e.activeAttributes.url,i=e.addingLink,u=e.value;if(!n&&!i)return null;var l=this.state,s=l.inputValue,b=l.opensInNewWindow,p=N(this.props,this.state);return Object(o.createElement)(F,{value:u,isActive:n,addingLink:i,onFocusOutside:this.onFocusOutside,onClose:this.resetState,focusOnMount:!!p&&"firstElement",renderSettings:function(){return Object(o.createElement)(j.ToggleControl,{label:Object(a.__)("Open in New Tab"),checked:b,onChange:t.setLinkTarget})}},p?Object(o.createElement)(c.URLPopover.LinkEditor,{className:"editor-format-toolbar__link-container-content block-editor-format-toolbar__link-container-content",value:s,onChangeInputValue:this.onChangeInputValue,onKeyDown:this.onKeyDown,onKeyPress:R,onSubmit:this.submitLink,autocompleteRef:this.autocompleteRef}):Object(o.createElement)(c.URLPopover.LinkViewer,{className:"editor-format-toolbar__link-container-content block-editor-format-toolbar__link-container-content",onKeyPress:R,url:r,onEditLinkClick:this.editLink,linkClassName:P(Object(T.prependHTTP)(r))?void 0:"has-invalid-link"}))}}],[{key:"getDerivedStateFromProps",value:function(t,e){var n=t.activeAttributes,r=n.url,i="_blank"===n.target;if(!N(t,e)){var o={};return r!==e.inputValue&&(o.inputValue=r),i!==e.opensInNewWindow&&(o.opensInNewWindow=i),Object.keys(o).length?o:null}return null}}]),e}(o.Component),M=Object(j.withSpokenMessages)(I),V=Object(a.__)("Link"),D={name:"core/link",title:V,tagName:"a",className:null,attributes:{url:"href",target:"target"},__unstablePasteRule:function(t,e){var n=e.html,r=e.plainText;if(Object(i.isCollapsed)(t))return t;var o=(n||r).replace(/<[^>]+>/g,"").trim();return Object(T.isURL)(o)?(window.console.log("Created link:\n\n",o),Object(i.applyFormat)(t,{type:"core/link",attributes:{url:Object(S.decodeEntities)(o)}})):t},edit:Object(j.withSpokenMessages)(function(t){function e(){var t;return Object(f.a)(this,e),(t=Object(m.a)(this,Object(h.a)(e).apply(this,arguments))).addLink=t.addLink.bind(Object(O.a)(t)),t.stopAddingLink=t.stopAddingLink.bind(Object(O.a)(t)),t.onRemoveFormat=t.onRemoveFormat.bind(Object(O.a)(t)),t.state={addingLink:!1},t}return Object(v.a)(e,t),Object(d.a)(e,[{key:"addLink",value:function(){var t=this.props,e=t.value,n=t.onChange,r=Object(i.getTextContent)(Object(i.slice)(e));r&&Object(T.isURL)(r)?n(Object(i.applyFormat)(e,{type:"core/link",attributes:{url:r}})):r&&Object(T.isEmail)(r)?n(Object(i.applyFormat)(e,{type:"core/link",attributes:{url:"mailto:".concat(r)}})):this.setState({addingLink:!0})}},{key:"stopAddingLink",value:function(){this.setState({addingLink:!1})}},{key:"onRemoveFormat",value:function(){var t=this.props,e=t.value,n=t.onChange,r=t.speak;n(Object(i.removeFormat)(e,"core/link")),r(Object(a.__)("Link removed."),"assertive")}},{key:"render",value:function(){var t=this.props,e=t.isActive,n=t.activeAttributes,r=t.value,i=t.onChange;return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.RichTextShortcut,{type:"primary",character:"k",onUse:this.addLink}),Object(o.createElement)(c.RichTextShortcut,{type:"primaryShift",character:"k",onUse:this.onRemoveFormat}),e&&Object(o.createElement)(c.RichTextToolbarButton,{name:"link",icon:"editor-unlink",title:Object(a.__)("Unlink"),onClick:this.onRemoveFormat,isActive:e,shortcutType:"primaryShift",shortcutCharacter:"k"}),!e&&Object(o.createElement)(c.RichTextToolbarButton,{name:"link",icon:"admin-links",title:V,onClick:this.addLink,isActive:e,shortcutType:"primary",shortcutCharacter:"k"}),Object(o.createElement)(M,{addingLink:this.state.addingLink,stopAddingLink:this.stopAddingLink,isActive:e,activeAttributes:n,value:r,onChange:i}))}}]),e}(o.Component))},U=Object(a.__)("Strikethrough");[l,b,_,C,D,{name:"core/strikethrough",title:U,tagName:"s",className:null,edit:function(t){var e=t.isActive,n=t.value,r=t.onChange;return Object(o.createElement)(c.RichTextToolbarButton,{icon:"editor-strikethrough",title:U,onClick:function(){return r(Object(i.toggleFormat)(n,{type:"core/strikethrough"}))},isActive:e})}},{name:"core/underline",title:Object(a.__)("Underline"),tagName:"span",className:null,attributes:{style:"style"},edit:function(t){var e=t.value,n=t.onChange,r=function(){n(Object(i.toggleFormat)(e,{type:"core/underline",attributes:{style:"text-decoration: underline;"}}))};return Object(o.createElement)(o.Fragment,null,Object(o.createElement)(c.RichTextShortcut,{type:"primary",character:"u",onUse:r}),Object(o.createElement)(c.__unstableRichTextInputEvent,{inputType:"formatUnderline",onInput:r}))}}].forEach((function(t){var e=t.name,n=Object(r.a)(t,["name"]);return Object(i.registerFormatType)(e,n)}))},40:function(t,e,n){"use strict";function r(t,e){if(null==t)return{};var n,r,i={},o=Object.keys(t);for(r=0;r<o.length;r++)n=o[r],e.indexOf(n)>=0||(i[n]=t[n]);return i}n.d(e,"a",(function(){return r}))},5:function(t,e){!function(){t.exports=this.wp.blockEditor}()},53:function(t,e){!function(){t.exports=this.wp.htmlEntities}()},6:function(t,e,n){"use strict";function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}n.d(e,"a",(function(){return r}))},7:function(t,e,n){"use strict";n.d(e,"a",(function(){return i}));var r=n(9);function i(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},i=Object.keys(Object(n));"function"==typeof Object.getOwnPropertySymbols&&(i=i.concat(Object.getOwnPropertySymbols(n).filter((function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable})))),i.forEach((function(e){Object(r.a)(t,e,n[e])}))}return t}},9: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}))}});