wip
This commit is contained in:
@@ -635,11 +635,28 @@
|
||||
/**
|
||||
* Preview changes to custom css.
|
||||
*
|
||||
* @param {string} value Custom CSS..
|
||||
* @param {string} value Custom CSS.
|
||||
* @return {void}
|
||||
*/
|
||||
custom_css: function( value ) {
|
||||
$( '#wp-custom-css' ).text( value );
|
||||
var style;
|
||||
if ( api.settings.theme.isBlockTheme ) {
|
||||
style = $( 'style#global-styles-inline-css' );
|
||||
|
||||
// Forbid milestone comments from appearing in Custom CSS which would break live preview.
|
||||
value = value.replace( /\/\*(BEGIN|END)_CUSTOMIZER_CUSTOM_CSS\*\//g, '' );
|
||||
|
||||
var textContent = style.text().replace(
|
||||
/(\/\*BEGIN_CUSTOMIZER_CUSTOM_CSS\*\/)((?:.|\s)*?)(\/\*END_CUSTOMIZER_CUSTOM_CSS\*\/)/,
|
||||
function ( match, beforeComment, oldValue, afterComment ) {
|
||||
return beforeComment + '\n' + value + '\n' + afterComment;
|
||||
}
|
||||
);
|
||||
style.text( textContent );
|
||||
} else {
|
||||
style = $( 'style#wp-custom-css' );
|
||||
style.text( value );
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -37,10 +37,14 @@
|
||||
|
||||
setButtons: function() {
|
||||
var elements = $('#customize-control-header_image .actions .remove');
|
||||
var addButton = $('#customize-control-header_image .actions .new');
|
||||
|
||||
if (this.model.get('choice')) {
|
||||
elements.show();
|
||||
addButton.removeClass('upload-button');
|
||||
} else {
|
||||
elements.hide();
|
||||
addButton.addClass('upload-button');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
!function(i,e,o){var t;e&&e.customize&&((t=e.customize).HeaderTool.CurrentView=e.Backbone.View.extend({template:e.template("header-current"),initialize:function(){this.listenTo(this.model,"change",this.render),this.render()},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.setButtons(),this},setButtons:function(){var e=i("#customize-control-header_image .actions .remove");this.model.get("choice")?e.show():e.hide()}}),t.HeaderTool.ChoiceView=e.Backbone.View.extend({template:e.template("header-choice"),className:"header-view",events:{"click .choice,.random":"select","click .close":"removeImage"},initialize:function(){var e=[this.model.get("header").url,this.model.get("choice")];this.listenTo(this.model,"change:selected",this.toggleSelected),o.contains(e,t.get().header_image)&&t.HeaderTool.currentHeader.set(this.extendedModel())},render:function(){return this.$el.html(this.template(this.extendedModel())),this.toggleSelected(),this},toggleSelected:function(){this.$el.toggleClass("selected",this.model.get("selected"))},extendedModel:function(){var e=this.model.get("collection");return o.extend(this.model.toJSON(),{type:e.type})},select:function(){this.preventJump(),this.model.save(),t.HeaderTool.currentHeader.set(this.extendedModel())},preventJump:function(){var e=i(".wp-full-overlay-sidebar-content"),t=e.scrollTop();o.defer(function(){e.scrollTop(t)})},removeImage:function(e){e.stopPropagation(),this.model.destroy(),this.remove()}}),t.HeaderTool.ChoiceListView=e.Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addOne),this.listenTo(this.collection,"remove",this.render),this.listenTo(this.collection,"sort",this.render),this.listenTo(this.collection,"change",this.toggleList),this.render()},render:function(){this.$el.empty(),this.collection.each(this.addOne,this),this.toggleList()},addOne:function(e){e.set({collection:this.collection}),e=new t.HeaderTool.ChoiceView({model:e}),this.$el.append(e.render().el)},toggleList:function(){var e=this.$el.parents().prev(".customize-control-title"),t=this.$el.find(".random").parent();this.collection.shouldHideTitle()?e.add(t).hide():e.add(t).show()}}),t.HeaderTool.CombinedList=e.Backbone.View.extend({initialize:function(e){this.collections=e,this.on("all",this.propagate,this)},propagate:function(t,i){o.each(this.collections,function(e){e.trigger(t,i)})}}))}(jQuery,window.wp,_);
|
||||
!function(i,e,o){var t;e&&e.customize&&((t=e.customize).HeaderTool.CurrentView=e.Backbone.View.extend({template:e.template("header-current"),initialize:function(){this.listenTo(this.model,"change",this.render),this.render()},render:function(){return this.$el.html(this.template(this.model.toJSON())),this.setButtons(),this},setButtons:function(){var e=i("#customize-control-header_image .actions .remove"),t=i("#customize-control-header_image .actions .new");this.model.get("choice")?(e.show(),t.removeClass("upload-button")):(e.hide(),t.addClass("upload-button"))}}),t.HeaderTool.ChoiceView=e.Backbone.View.extend({template:e.template("header-choice"),className:"header-view",events:{"click .choice,.random":"select","click .close":"removeImage"},initialize:function(){var e=[this.model.get("header").url,this.model.get("choice")];this.listenTo(this.model,"change:selected",this.toggleSelected),o.contains(e,t.get().header_image)&&t.HeaderTool.currentHeader.set(this.extendedModel())},render:function(){return this.$el.html(this.template(this.extendedModel())),this.toggleSelected(),this},toggleSelected:function(){this.$el.toggleClass("selected",this.model.get("selected"))},extendedModel:function(){var e=this.model.get("collection");return o.extend(this.model.toJSON(),{type:e.type})},select:function(){this.preventJump(),this.model.save(),t.HeaderTool.currentHeader.set(this.extendedModel())},preventJump:function(){var e=i(".wp-full-overlay-sidebar-content"),t=e.scrollTop();o.defer(function(){e.scrollTop(t)})},removeImage:function(e){e.stopPropagation(),this.model.destroy(),this.remove()}}),t.HeaderTool.ChoiceListView=e.Backbone.View.extend({initialize:function(){this.listenTo(this.collection,"add",this.addOne),this.listenTo(this.collection,"remove",this.render),this.listenTo(this.collection,"sort",this.render),this.listenTo(this.collection,"change",this.toggleList),this.render()},render:function(){this.$el.empty(),this.collection.each(this.addOne,this),this.toggleList()},addOne:function(e){e.set({collection:this.collection}),e=new t.HeaderTool.ChoiceView({model:e}),this.$el.append(e.render().el)},toggleList:function(){var e=this.$el.parents().prev(".customize-control-title"),t=this.$el.find(".random").parent();this.collection.shouldHideTitle()?e.add(t).hide():e.add(t).show()}}),t.HeaderTool.CombinedList=e.Backbone.View.extend({initialize:function(e){this.collections=e,this.on("all",this.propagate,this)},propagate:function(t,i){o.each(this.collections,function(e){e.trigger(t,i)})}}))}(jQuery,window.wp,_);
|
||||
Vendored
+51
-129
@@ -59,196 +59,118 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
const external_wp_domReady_namespaceObject = window["wp"]["domReady"];
|
||||
var external_wp_domReady_default = /*#__PURE__*/__webpack_require__.n(external_wp_domReady_namespaceObject);
|
||||
;// ./node_modules/@wordpress/a11y/build-module/script/add-container.js
|
||||
/**
|
||||
* Build the live regions markup.
|
||||
*
|
||||
* @param {string} [ariaLive] Value for the 'aria-live' attribute; default: 'polite'.
|
||||
*
|
||||
* @return {HTMLDivElement} The ARIA live region HTML element.
|
||||
*/
|
||||
function addContainer(ariaLive = 'polite') {
|
||||
const container = document.createElement('div');
|
||||
function addContainer(ariaLive = "polite") {
|
||||
const container = document.createElement("div");
|
||||
container.id = `a11y-speak-${ariaLive}`;
|
||||
container.className = 'a11y-speak-region';
|
||||
container.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
|
||||
container.setAttribute('aria-live', ariaLive);
|
||||
container.setAttribute('aria-relevant', 'additions text');
|
||||
container.setAttribute('aria-atomic', 'true');
|
||||
const {
|
||||
body
|
||||
} = document;
|
||||
container.className = "a11y-speak-region";
|
||||
container.setAttribute(
|
||||
"style",
|
||||
"position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;"
|
||||
);
|
||||
container.setAttribute("aria-live", ariaLive);
|
||||
container.setAttribute("aria-relevant", "additions text");
|
||||
container.setAttribute("aria-atomic", "true");
|
||||
const { body } = document;
|
||||
if (body) {
|
||||
body.appendChild(container);
|
||||
}
|
||||
return container;
|
||||
}
|
||||
|
||||
|
||||
;// external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// ./node_modules/@wordpress/a11y/build-module/script/add-intro-text.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Build the explanatory text to be placed before the aria live regions.
|
||||
*
|
||||
* This text is initially hidden from assistive technologies by using a `hidden`
|
||||
* HTML attribute which is then removed once a message fills the aria-live regions.
|
||||
*
|
||||
* @return {HTMLParagraphElement} The explanatory text HTML element.
|
||||
*/
|
||||
function addIntroText() {
|
||||
const introText = document.createElement('p');
|
||||
introText.id = 'a11y-speak-intro-text';
|
||||
introText.className = 'a11y-speak-intro-text';
|
||||
introText.textContent = (0,external_wp_i18n_namespaceObject.__)('Notifications');
|
||||
introText.setAttribute('style', 'position: absolute;' + 'margin: -1px;' + 'padding: 0;' + 'height: 1px;' + 'width: 1px;' + 'overflow: hidden;' + 'clip: rect(1px, 1px, 1px, 1px);' + '-webkit-clip-path: inset(50%);' + 'clip-path: inset(50%);' + 'border: 0;' + 'word-wrap: normal !important;');
|
||||
introText.setAttribute('hidden', 'hidden');
|
||||
const {
|
||||
body
|
||||
} = document;
|
||||
const introText = document.createElement("p");
|
||||
introText.id = "a11y-speak-intro-text";
|
||||
introText.className = "a11y-speak-intro-text";
|
||||
introText.textContent = (0,external_wp_i18n_namespaceObject.__)("Notifications");
|
||||
introText.setAttribute(
|
||||
"style",
|
||||
"position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;"
|
||||
);
|
||||
introText.setAttribute("hidden", "");
|
||||
const { body } = document;
|
||||
if (body) {
|
||||
body.appendChild(introText);
|
||||
}
|
||||
return introText;
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/a11y/build-module/shared/clear.js
|
||||
/**
|
||||
* Clears the a11y-speak-region elements and hides the explanatory text.
|
||||
*/
|
||||
function clear() {
|
||||
const regions = document.getElementsByClassName('a11y-speak-region');
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
for (let i = 0; i < regions.length; i++) {
|
||||
regions[i].textContent = '';
|
||||
}
|
||||
|
||||
// Make sure the explanatory text is hidden from assistive technologies.
|
||||
;// ./node_modules/@wordpress/a11y/build-module/shared/clear.js
|
||||
function clear() {
|
||||
const regions = document.getElementsByClassName("a11y-speak-region");
|
||||
const introText = document.getElementById("a11y-speak-intro-text");
|
||||
for (let i = 0; i < regions.length; i++) {
|
||||
regions[i].textContent = "";
|
||||
}
|
||||
if (introText) {
|
||||
introText.setAttribute('hidden', 'hidden');
|
||||
introText.setAttribute("hidden", "hidden");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/a11y/build-module/shared/filter-message.js
|
||||
let previousMessage = '';
|
||||
|
||||
/**
|
||||
* Filter the message to be announced to the screenreader.
|
||||
*
|
||||
* @param {string} message The message to be announced.
|
||||
*
|
||||
* @return {string} The filtered message.
|
||||
*/
|
||||
let previousMessage = "";
|
||||
function filterMessage(message) {
|
||||
/*
|
||||
* Strip HTML tags (if any) from the message string. Ideally, messages should
|
||||
* be simple strings, carefully crafted for specific use with A11ySpeak.
|
||||
* When re-using already existing strings this will ensure simple HTML to be
|
||||
* stripped out and replaced with a space. Browsers will collapse multiple
|
||||
* spaces natively.
|
||||
*/
|
||||
message = message.replace(/<[^<>]+>/g, ' ');
|
||||
|
||||
/*
|
||||
* Safari + VoiceOver don't announce repeated, identical strings. We use
|
||||
* a `no-break space` to force them to think identical strings are different.
|
||||
*/
|
||||
message = message.replace(/<[^<>]+>/g, " ");
|
||||
if (previousMessage === message) {
|
||||
message += '\u00A0';
|
||||
message += "\xA0";
|
||||
}
|
||||
previousMessage = message;
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/a11y/build-module/shared/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Allows you to easily announce dynamic interface updates to screen readers using ARIA live regions.
|
||||
* This module is inspired by the `speak` function in `wp-a11y.js`.
|
||||
*
|
||||
* @param {string} message The message to be announced by assistive technologies.
|
||||
* @param {'polite'|'assertive'} [ariaLive] The politeness level for aria-live; default: 'polite'.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { speak } from '@wordpress/a11y';
|
||||
*
|
||||
* // For polite messages that shouldn't interrupt what screen readers are currently announcing.
|
||||
* speak( 'The message you want to send to the ARIA live region' );
|
||||
*
|
||||
* // For assertive messages that should interrupt what screen readers are currently announcing.
|
||||
* speak( 'The message you want to send to the ARIA live region', 'assertive' );
|
||||
* ```
|
||||
*/
|
||||
function speak(message, ariaLive) {
|
||||
/*
|
||||
* Clear previous messages to allow repeated strings being read out and hide
|
||||
* the explanatory text from assistive technologies.
|
||||
*/
|
||||
clear();
|
||||
message = filterMessage(message);
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
const containerAssertive = document.getElementById('a11y-speak-assertive');
|
||||
const containerPolite = document.getElementById('a11y-speak-polite');
|
||||
if (containerAssertive && ariaLive === 'assertive') {
|
||||
const introText = document.getElementById("a11y-speak-intro-text");
|
||||
const containerAssertive = document.getElementById(
|
||||
"a11y-speak-assertive"
|
||||
);
|
||||
const containerPolite = document.getElementById("a11y-speak-polite");
|
||||
if (containerAssertive && ariaLive === "assertive") {
|
||||
containerAssertive.textContent = message;
|
||||
} else if (containerPolite) {
|
||||
containerPolite.textContent = message;
|
||||
}
|
||||
|
||||
/*
|
||||
* Make the explanatory text available to assistive technologies by removing
|
||||
* the 'hidden' HTML attribute.
|
||||
*/
|
||||
if (introText) {
|
||||
introText.removeAttribute('hidden');
|
||||
introText.removeAttribute("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/a11y/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create the live regions.
|
||||
*/
|
||||
function setup() {
|
||||
const introText = document.getElementById('a11y-speak-intro-text');
|
||||
const containerAssertive = document.getElementById('a11y-speak-assertive');
|
||||
const containerPolite = document.getElementById('a11y-speak-polite');
|
||||
const introText = document.getElementById("a11y-speak-intro-text");
|
||||
const containerAssertive = document.getElementById(
|
||||
"a11y-speak-assertive"
|
||||
);
|
||||
const containerPolite = document.getElementById("a11y-speak-polite");
|
||||
if (introText === null) {
|
||||
addIntroText();
|
||||
}
|
||||
if (containerAssertive === null) {
|
||||
addContainer('assertive');
|
||||
addContainer("assertive");
|
||||
}
|
||||
if (containerPolite === null) {
|
||||
addContainer('polite');
|
||||
addContainer("polite");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run setup on domReady.
|
||||
*/
|
||||
external_wp_domReady_default()(setup);
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).a11y = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{setup:()=>p,speak:()=>d});const n=window.wp.domReady;var o=e.n(n);function i(e="polite"){const t=document.createElement("div");t.id=`a11y-speak-${e}`,t.className="a11y-speak-region",t.setAttribute("style","position: absolute;margin: -1px;padding: 0;height: 1px;width: 1px;overflow: hidden;clip: rect(1px, 1px, 1px, 1px);-webkit-clip-path: inset(50%);clip-path: inset(50%);border: 0;word-wrap: normal !important;"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions text"),t.setAttribute("aria-atomic","true");const{body:n}=document;return n&&n.appendChild(t),t}const a=window.wp.i18n;let r="";function d(e,t){!function(){const e=document.getElementsByClassName("a11y-speak-region"),t=document.getElementById("a11y-speak-intro-text");for(let t=0;t<e.length;t++)e[t].textContent="";t&&t.setAttribute("hidden","hidden")}(),e=function(e){return e=e.replace(/<[^<>]+>/g," "),r===e&&(e+=" "),r=e,e}(e);const n=document.getElementById("a11y-speak-intro-text"),o=document.getElementById("a11y-speak-assertive"),i=document.getElementById("a11y-speak-polite");o&&"assertive"===t?o.textContent=e:i&&(i.textContent=e),n&&n.removeAttribute("hidden")}function p(){const e=document.getElementById("a11y-speak-intro-text"),t=document.getElementById("a11y-speak-assertive"),n=document.getElementById("a11y-speak-polite");null===e&&function(){const e=document.createElement("p");e.id="a11y-speak-intro-text",e.className="a11y-speak-intro-text",e.textContent=(0,a.__)("Notifications"),e.setAttribute("style","position: absolute;margin: -1px;padding: 0;height: 1px;width: 1px;overflow: hidden;clip: rect(1px, 1px, 1px, 1px);-webkit-clip-path: inset(50%);clip-path: inset(50%);border: 0;word-wrap: normal !important;"),e.setAttribute("hidden","hidden");const{body:t}=document;t&&t.appendChild(e)}(),null===t&&i("assertive"),null===n&&i("polite")}o()(p),(window.wp=window.wp||{}).a11y=t})();
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{setup:()=>s,speak:()=>d});const n=window.wp.domReady;var o=e.n(n);function i(e="polite"){const t=document.createElement("div");t.id=`a11y-speak-${e}`,t.className="a11y-speak-region",t.setAttribute("style","position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;"),t.setAttribute("aria-live",e),t.setAttribute("aria-relevant","additions text"),t.setAttribute("aria-atomic","true");const{body:n}=document;return n&&n.appendChild(t),t}const a=window.wp.i18n;let r="";function d(e,t){!function(){const e=document.getElementsByClassName("a11y-speak-region"),t=document.getElementById("a11y-speak-intro-text");for(let t=0;t<e.length;t++)e[t].textContent="";t&&t.setAttribute("hidden","hidden")}(),e=function(e){return e=e.replace(/<[^<>]+>/g," "),r===e&&(e+=" "),r=e,e}(e);const n=document.getElementById("a11y-speak-intro-text"),o=document.getElementById("a11y-speak-assertive"),i=document.getElementById("a11y-speak-polite");o&&"assertive"===t?o.textContent=e:i&&(i.textContent=e),n&&n.removeAttribute("hidden")}function s(){const e=document.getElementById("a11y-speak-intro-text"),t=document.getElementById("a11y-speak-assertive"),n=document.getElementById("a11y-speak-polite");null===e&&function(){const e=document.createElement("p");e.id="a11y-speak-intro-text",e.className="a11y-speak-intro-text",e.textContent=(0,a.__)("Notifications"),e.setAttribute("style","position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip-path:inset(50%);border:0;word-wrap:normal !important;"),e.setAttribute("hidden","");const{body:t}=document;t&&t.appendChild(e)}(),null===t&&i("assertive"),null===n&&i("polite")}o()(s),(window.wp=window.wp||{}).a11y=t})();
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
/******/ __webpack_require__.d = (exports, definition) => {
|
||||
/******/ for(var key in definition) {
|
||||
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
||||
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
||||
/******/ }
|
||||
/******/ }
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
||||
/******/ (() => {
|
||||
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/make namespace object */
|
||||
/******/ (() => {
|
||||
/******/ // define __esModule on exports
|
||||
/******/ __webpack_require__.r = (exports) => {
|
||||
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
||||
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
||||
/******/ }
|
||||
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
NavigableRegion: () => (/* reexport */ navigable_region_default),
|
||||
Page: () => (/* reexport */ page_default)
|
||||
});
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/clsx/dist/clsx.mjs
|
||||
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// ./node_modules/@wordpress/admin-ui/build-module/navigable-region/index.js
|
||||
|
||||
|
||||
|
||||
const NavigableRegion = (0,external_wp_element_namespaceObject.forwardRef)(
|
||||
({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
Tag,
|
||||
{
|
||||
ref,
|
||||
className: dist_clsx("admin-ui-navigable-region", className),
|
||||
"aria-label": ariaLabel,
|
||||
role: "region",
|
||||
tabIndex: "-1",
|
||||
...props,
|
||||
children
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
NavigableRegion.displayName = "NavigableRegion";
|
||||
var navigable_region_default = NavigableRegion;
|
||||
|
||||
|
||||
;// external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// ./node_modules/@wordpress/admin-ui/build-module/page/header.js
|
||||
|
||||
|
||||
function Header({
|
||||
breadcrumbs,
|
||||
badges,
|
||||
title,
|
||||
subTitle,
|
||||
actions
|
||||
}) {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(
|
||||
external_wp_components_namespaceObject.__experimentalHStack,
|
||||
{
|
||||
className: "admin-ui-page__header-title",
|
||||
justify: "space-between",
|
||||
spacing: 2,
|
||||
children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { spacing: 2, children: [
|
||||
title && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }),
|
||||
breadcrumbs,
|
||||
badges
|
||||
] }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.__experimentalHStack,
|
||||
{
|
||||
style: { width: "auto", flexShrink: 0 },
|
||||
spacing: 2,
|
||||
className: "admin-ui-page__header-actions",
|
||||
children: actions
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
),
|
||||
subTitle && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle })
|
||||
] });
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/admin-ui/build-module/page/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
function Page({
|
||||
breadcrumbs,
|
||||
badges,
|
||||
title,
|
||||
subTitle,
|
||||
children,
|
||||
className,
|
||||
actions,
|
||||
hasPadding = false
|
||||
}) {
|
||||
const classes = dist_clsx("admin-ui-page", className);
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [
|
||||
(title || breadcrumbs || badges) && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
Header,
|
||||
{
|
||||
breadcrumbs,
|
||||
badges,
|
||||
title,
|
||||
subTitle,
|
||||
actions
|
||||
}
|
||||
),
|
||||
hasPadding ? /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children
|
||||
] });
|
||||
}
|
||||
var page_default = Page;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/admin-ui/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).adminUi = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(a,i)=>{for(var n in i)e.o(i,n)&&!e.o(a,n)&&Object.defineProperty(a,n,{enumerable:!0,get:i[n]})},o:(e,a)=>Object.prototype.hasOwnProperty.call(e,a),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},a={};e.r(a),e.d(a,{NavigableRegion:()=>s,Page:()=>c});const i=window.ReactJSXRuntime;function n(e){var a,i,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var t=e.length;for(a=0;a<t;a++)e[a]&&(i=n(e[a]))&&(r&&(r+=" "),r+=i)}else for(i in e)e[i]&&(r&&(r+=" "),r+=i);return r}const r=function(){for(var e,a,i=0,r="",t=arguments.length;i<t;i++)(e=arguments[i])&&(a=n(e))&&(r&&(r+=" "),r+=a);return r},t=(0,window.wp.element.forwardRef)((({children:e,className:a,ariaLabel:n,as:t="div",...s},l)=>(0,i.jsx)(t,{ref:l,className:r("admin-ui-navigable-region",a),"aria-label":n,role:"region",tabIndex:"-1",...s,children:e})));t.displayName="NavigableRegion";var s=t;const l=window.wp.components;function d({breadcrumbs:e,badges:a,title:n,subTitle:r,actions:t}){return(0,i.jsxs)(l.__experimentalVStack,{className:"admin-ui-page__header",as:"header",children:[(0,i.jsxs)(l.__experimentalHStack,{className:"admin-ui-page__header-title",justify:"space-between",spacing:2,children:[(0,i.jsxs)(l.__experimentalHStack,{spacing:2,children:[n&&(0,i.jsx)(l.__experimentalHeading,{as:"h2",level:3,weight:500,truncate:!0,children:n}),e,a]}),(0,i.jsx)(l.__experimentalHStack,{style:{width:"auto",flexShrink:0},spacing:2,className:"admin-ui-page__header-actions",children:t})]}),r&&(0,i.jsx)("p",{className:"admin-ui-page__header-subtitle",children:r})]})}var c=function({breadcrumbs:e,badges:a,title:n,subTitle:t,children:l,className:c,actions:o,hasPadding:m=!1}){const u=r("admin-ui-page",c);return(0,i.jsxs)(s,{className:u,ariaLabel:n,children:[(n||e||a)&&(0,i.jsx)(d,{breadcrumbs:e,badges:a,title:n,subTitle:t,actions:o}),m?(0,i.jsx)("div",{className:"admin-ui-page__content has-padding",children:l}):l]})};(window.wp=window.wp||{}).adminUi=a})();
|
||||
Vendored
+152
-370
@@ -67,161 +67,109 @@ const external_wp_richText_namespaceObject = window["wp"]["richText"];
|
||||
;// external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// ./node_modules/@wordpress/annotations/build-module/store/constants.js
|
||||
/**
|
||||
* The identifier for the data store.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const STORE_NAME = 'core/annotations';
|
||||
const STORE_NAME = "core/annotations";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/format/annotation.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const FORMAT_NAME = 'core/annotation';
|
||||
const ANNOTATION_ATTRIBUTE_PREFIX = 'annotation-text-';
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const FORMAT_NAME = "core/annotation";
|
||||
const ANNOTATION_ATTRIBUTE_PREFIX = "annotation-text-";
|
||||
|
||||
|
||||
/**
|
||||
* Applies given annotations to the given record.
|
||||
*
|
||||
* @param {Object} record The record to apply annotations to.
|
||||
* @param {Array} annotations The annotation to apply.
|
||||
* @return {Object} A record with the annotations applied.
|
||||
*/
|
||||
function applyAnnotations(record, annotations = []) {
|
||||
annotations.forEach(annotation => {
|
||||
let {
|
||||
start,
|
||||
end
|
||||
} = annotation;
|
||||
annotations.forEach((annotation2) => {
|
||||
let { start, end } = annotation2;
|
||||
if (start > record.text.length) {
|
||||
start = record.text.length;
|
||||
}
|
||||
if (end > record.text.length) {
|
||||
end = record.text.length;
|
||||
}
|
||||
const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation.source;
|
||||
const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation.id;
|
||||
record = (0,external_wp_richText_namespaceObject.applyFormat)(record, {
|
||||
type: FORMAT_NAME,
|
||||
attributes: {
|
||||
className,
|
||||
id
|
||||
}
|
||||
}, start, end);
|
||||
const className = ANNOTATION_ATTRIBUTE_PREFIX + annotation2.source;
|
||||
const id = ANNOTATION_ATTRIBUTE_PREFIX + annotation2.id;
|
||||
record = (0,external_wp_richText_namespaceObject.applyFormat)(
|
||||
record,
|
||||
{
|
||||
type: FORMAT_NAME,
|
||||
attributes: {
|
||||
className,
|
||||
id
|
||||
}
|
||||
},
|
||||
start,
|
||||
end
|
||||
);
|
||||
});
|
||||
return record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes annotations from the given record.
|
||||
*
|
||||
* @param {Object} record Record to remove annotations from.
|
||||
* @return {Object} The cleaned record.
|
||||
*/
|
||||
function removeAnnotations(record) {
|
||||
return removeFormat(record, 'core/annotation', 0, record.text.length);
|
||||
return removeFormat(record, "core/annotation", 0, record.text.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the positions of annotations inside an array of formats.
|
||||
*
|
||||
* @param {Array} formats Formats with annotations in there.
|
||||
* @return {Object} ID keyed positions of annotations.
|
||||
*/
|
||||
function retrieveAnnotationPositions(formats) {
|
||||
const positions = {};
|
||||
formats.forEach((characterFormats, i) => {
|
||||
characterFormats = characterFormats || [];
|
||||
characterFormats = characterFormats.filter(format => format.type === FORMAT_NAME);
|
||||
characterFormats.forEach(format => {
|
||||
let {
|
||||
id
|
||||
} = format.attributes;
|
||||
id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, '');
|
||||
characterFormats = characterFormats.filter(
|
||||
(format) => format.type === FORMAT_NAME
|
||||
);
|
||||
characterFormats.forEach((format) => {
|
||||
let { id } = format.attributes;
|
||||
id = id.replace(ANNOTATION_ATTRIBUTE_PREFIX, "");
|
||||
if (!positions.hasOwnProperty(id)) {
|
||||
positions[id] = {
|
||||
start: i
|
||||
};
|
||||
}
|
||||
|
||||
// Annotations refer to positions between characters.
|
||||
// Formats refer to the character themselves.
|
||||
// So we need to adjust for that here.
|
||||
positions[id].end = i + 1;
|
||||
});
|
||||
});
|
||||
return positions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates annotations in the state based on positions retrieved from RichText.
|
||||
*
|
||||
* @param {Array} annotations The annotations that are currently applied.
|
||||
* @param {Array} positions The current positions of the given annotations.
|
||||
* @param {Object} actions
|
||||
* @param {Function} actions.removeAnnotation Function to remove an annotation from the state.
|
||||
* @param {Function} actions.updateAnnotationRange Function to update an annotation range in the state.
|
||||
*/
|
||||
function updateAnnotationsWithPositions(annotations, positions, {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
}) {
|
||||
annotations.forEach(currentAnnotation => {
|
||||
function updateAnnotationsWithPositions(annotations, positions, { removeAnnotation, updateAnnotationRange }) {
|
||||
annotations.forEach((currentAnnotation) => {
|
||||
const position = positions[currentAnnotation.id];
|
||||
// If we cannot find an annotation, delete it.
|
||||
if (!position) {
|
||||
// Apparently the annotation has been removed, so remove it from the state:
|
||||
// Remove...
|
||||
removeAnnotation(currentAnnotation.id);
|
||||
return;
|
||||
}
|
||||
const {
|
||||
start,
|
||||
end
|
||||
} = currentAnnotation;
|
||||
const { start, end } = currentAnnotation;
|
||||
if (start !== position.start || end !== position.end) {
|
||||
updateAnnotationRange(currentAnnotation.id, position.start, position.end);
|
||||
updateAnnotationRange(
|
||||
currentAnnotation.id,
|
||||
position.start,
|
||||
position.end
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
const annotation = {
|
||||
name: FORMAT_NAME,
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Annotation'),
|
||||
tagName: 'mark',
|
||||
className: 'annotation-text',
|
||||
title: (0,external_wp_i18n_namespaceObject.__)("Annotation"),
|
||||
tagName: "mark",
|
||||
className: "annotation-text",
|
||||
attributes: {
|
||||
className: 'class',
|
||||
id: 'id'
|
||||
className: "class",
|
||||
id: "id"
|
||||
},
|
||||
edit() {
|
||||
return null;
|
||||
},
|
||||
__experimentalGetPropsForEditableTreePreparation(select, {
|
||||
richTextIdentifier,
|
||||
blockClientId
|
||||
}) {
|
||||
__experimentalGetPropsForEditableTreePreparation(select, { richTextIdentifier, blockClientId }) {
|
||||
return {
|
||||
annotations: select(STORE_NAME).__experimentalGetAnnotationsForRichText(blockClientId, richTextIdentifier)
|
||||
annotations: select(
|
||||
STORE_NAME
|
||||
).__experimentalGetAnnotationsForRichText(
|
||||
blockClientId,
|
||||
richTextIdentifier
|
||||
)
|
||||
};
|
||||
},
|
||||
__experimentalCreatePrepareEditableTree({
|
||||
annotations
|
||||
}) {
|
||||
__experimentalCreatePrepareEditableTree({ annotations }) {
|
||||
return (formats, text) => {
|
||||
if (annotations.length === 0) {
|
||||
return formats;
|
||||
}
|
||||
let record = {
|
||||
formats,
|
||||
text
|
||||
};
|
||||
let record = { formats, text };
|
||||
record = applyAnnotations(record, annotations);
|
||||
return record.formats;
|
||||
};
|
||||
@@ -233,13 +181,9 @@ const annotation = {
|
||||
};
|
||||
},
|
||||
__experimentalCreateOnChangeEditableValue(props) {
|
||||
return formats => {
|
||||
return (formats) => {
|
||||
const positions = retrieveAnnotationPositions(formats);
|
||||
const {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange,
|
||||
annotations
|
||||
} = props;
|
||||
const { removeAnnotation, updateAnnotationRange, annotations } = props;
|
||||
updateAnnotationsWithPositions(annotations, positions, {
|
||||
removeAnnotation,
|
||||
updateAnnotationRange
|
||||
@@ -248,20 +192,11 @@ const annotation = {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/format/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
name: format_name,
|
||||
...settings
|
||||
} = annotation;
|
||||
const { name: format_name, ...settings } = annotation;
|
||||
(0,external_wp_richText_namespaceObject.registerFormatType)(format_name, settings);
|
||||
|
||||
;// external ["wp","hooks"]
|
||||
@@ -269,87 +204,45 @@ const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// ./node_modules/@wordpress/annotations/build-module/block/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds annotation className to the block-list-block component.
|
||||
*
|
||||
* @param {Object} OriginalComponent The original BlockListBlock component.
|
||||
* @return {Object} The enhanced component.
|
||||
*/
|
||||
const addAnnotationClassName = OriginalComponent => {
|
||||
return (0,external_wp_data_namespaceObject.withSelect)((select, {
|
||||
clientId,
|
||||
className
|
||||
}) => {
|
||||
const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(clientId);
|
||||
const addAnnotationClassName = (OriginalComponent) => {
|
||||
return (0,external_wp_data_namespaceObject.withSelect)((select, { clientId, className }) => {
|
||||
const annotations = select(STORE_NAME).__experimentalGetAnnotationsForBlock(
|
||||
clientId
|
||||
);
|
||||
return {
|
||||
className: annotations.map(annotation => {
|
||||
return 'is-annotated-by-' + annotation.source;
|
||||
}).concat(className).filter(Boolean).join(' ')
|
||||
className: annotations.map((annotation) => {
|
||||
return "is-annotated-by-" + annotation.source;
|
||||
}).concat(className).filter(Boolean).join(" ")
|
||||
};
|
||||
})(OriginalComponent);
|
||||
};
|
||||
(0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockListBlock', 'core/annotations', addAnnotationClassName);
|
||||
(0,external_wp_hooks_namespaceObject.addFilter)(
|
||||
"editor.BlockListBlock",
|
||||
"core/annotations",
|
||||
addAnnotationClassName
|
||||
);
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/store/reducer.js
|
||||
/**
|
||||
* Filters an array based on the predicate, but keeps the reference the same if
|
||||
* the array hasn't changed.
|
||||
*
|
||||
* @param {Array} collection The collection to filter.
|
||||
* @param {Function} predicate Function that determines if the item should stay
|
||||
* in the array.
|
||||
* @return {Array} Filtered array.
|
||||
*/
|
||||
function filterWithReference(collection, predicate) {
|
||||
const filteredCollection = collection.filter(predicate);
|
||||
return collection.length === filteredCollection.length ? collection : filteredCollection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new object with the same keys, but with `callback()` called as
|
||||
* a transformer function on each of the values.
|
||||
*
|
||||
* @param {Object} obj The object to transform.
|
||||
* @param {Function} callback The function to transform each object value.
|
||||
* @return {Array} Transformed object.
|
||||
*/
|
||||
const mapValues = (obj, callback) => Object.entries(obj).reduce((acc, [key, value]) => ({
|
||||
...acc,
|
||||
[key]: callback(value)
|
||||
}), {});
|
||||
|
||||
/**
|
||||
* Verifies whether the given annotations is a valid annotation.
|
||||
*
|
||||
* @param {Object} annotation The annotation to verify.
|
||||
* @return {boolean} Whether the given annotation is valid.
|
||||
*/
|
||||
const mapValues = (obj, callback) => Object.entries(obj).reduce(
|
||||
(acc, [key, value]) => ({
|
||||
...acc,
|
||||
[key]: callback(value)
|
||||
}),
|
||||
{}
|
||||
);
|
||||
function isValidAnnotationRange(annotation) {
|
||||
return typeof annotation.start === 'number' && typeof annotation.end === 'number' && annotation.start <= annotation.end;
|
||||
return typeof annotation.start === "number" && typeof annotation.end === "number" && annotation.start <= annotation.end;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer managing annotations.
|
||||
*
|
||||
* @param {Object} state The annotations currently shown in the editor.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Array} Updated state.
|
||||
*/
|
||||
function annotations(state = {}, action) {
|
||||
var _state$blockClientId;
|
||||
switch (action.type) {
|
||||
case 'ANNOTATION_ADD':
|
||||
case "ANNOTATION_ADD":
|
||||
const blockClientId = action.blockClientId;
|
||||
const newAnnotation = {
|
||||
id: action.id,
|
||||
@@ -359,129 +252,94 @@ function annotations(state = {}, action) {
|
||||
selector: action.selector,
|
||||
range: action.range
|
||||
};
|
||||
if (newAnnotation.selector === 'range' && !isValidAnnotationRange(newAnnotation.range)) {
|
||||
if (newAnnotation.selector === "range" && !isValidAnnotationRange(newAnnotation.range)) {
|
||||
return state;
|
||||
}
|
||||
const previousAnnotationsForBlock = (_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : [];
|
||||
const previousAnnotationsForBlock = state?.[blockClientId] ?? [];
|
||||
return {
|
||||
...state,
|
||||
[blockClientId]: [...previousAnnotationsForBlock, newAnnotation]
|
||||
[blockClientId]: [
|
||||
...previousAnnotationsForBlock,
|
||||
newAnnotation
|
||||
]
|
||||
};
|
||||
case 'ANNOTATION_REMOVE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
return filterWithReference(annotationsForBlock, annotation => {
|
||||
return annotation.id !== action.annotationId;
|
||||
});
|
||||
});
|
||||
case 'ANNOTATION_UPDATE_RANGE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
let hasChangedRange = false;
|
||||
const newAnnotations = annotationsForBlock.map(annotation => {
|
||||
if (annotation.id === action.annotationId) {
|
||||
hasChangedRange = true;
|
||||
return {
|
||||
...annotation,
|
||||
range: {
|
||||
start: action.start,
|
||||
end: action.end
|
||||
}
|
||||
};
|
||||
case "ANNOTATION_REMOVE":
|
||||
return mapValues(state, (annotationsForBlock) => {
|
||||
return filterWithReference(
|
||||
annotationsForBlock,
|
||||
(annotation) => {
|
||||
return annotation.id !== action.annotationId;
|
||||
}
|
||||
return annotation;
|
||||
});
|
||||
);
|
||||
});
|
||||
case "ANNOTATION_UPDATE_RANGE":
|
||||
return mapValues(state, (annotationsForBlock) => {
|
||||
let hasChangedRange = false;
|
||||
const newAnnotations = annotationsForBlock.map(
|
||||
(annotation) => {
|
||||
if (annotation.id === action.annotationId) {
|
||||
hasChangedRange = true;
|
||||
return {
|
||||
...annotation,
|
||||
range: {
|
||||
start: action.start,
|
||||
end: action.end
|
||||
}
|
||||
};
|
||||
}
|
||||
return annotation;
|
||||
}
|
||||
);
|
||||
return hasChangedRange ? newAnnotations : annotationsForBlock;
|
||||
});
|
||||
case 'ANNOTATION_REMOVE_SOURCE':
|
||||
return mapValues(state, annotationsForBlock => {
|
||||
return filterWithReference(annotationsForBlock, annotation => {
|
||||
return annotation.source !== action.source;
|
||||
});
|
||||
case "ANNOTATION_REMOVE_SOURCE":
|
||||
return mapValues(state, (annotationsForBlock) => {
|
||||
return filterWithReference(
|
||||
annotationsForBlock,
|
||||
(annotation) => {
|
||||
return annotation.source !== action.source;
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ const reducer = (annotations);
|
||||
var reducer_default = annotations;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Shared reference to an empty array for cases where it is important to avoid
|
||||
* returning a new array reference on every invocation, as in a connected or
|
||||
* other pure component which performs `shouldComponentUpdate` check on props.
|
||||
* This should be used as a last resort, since the normalized data should be
|
||||
* maintained by the reducer result in state.
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
const EMPTY_ARRAY = [];
|
||||
|
||||
/**
|
||||
* Returns the annotations for a specific client ID.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @param {string} clientId The ID of the block to get the annotations for.
|
||||
*
|
||||
* @return {Array} The annotations applicable to this block.
|
||||
*/
|
||||
const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId) => {
|
||||
var _state$blockClientId;
|
||||
return ((_state$blockClientId = state?.[blockClientId]) !== null && _state$blockClientId !== void 0 ? _state$blockClientId : []).filter(annotation => {
|
||||
return annotation.selector === 'block';
|
||||
});
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId2;
|
||||
return [(_state$blockClientId2 = state?.[blockClientId]) !== null && _state$blockClientId2 !== void 0 ? _state$blockClientId2 : EMPTY_ARRAY];
|
||||
});
|
||||
const __experimentalGetAnnotationsForBlock = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, blockClientId) => {
|
||||
return (state?.[blockClientId] ?? []).filter((annotation) => {
|
||||
return annotation.selector === "block";
|
||||
});
|
||||
},
|
||||
(state, blockClientId) => [state?.[blockClientId] ?? EMPTY_ARRAY]
|
||||
);
|
||||
function __experimentalGetAllAnnotationsForBlock(state, blockClientId) {
|
||||
var _state$blockClientId3;
|
||||
return (_state$blockClientId3 = state?.[blockClientId]) !== null && _state$blockClientId3 !== void 0 ? _state$blockClientId3 : EMPTY_ARRAY;
|
||||
return state?.[blockClientId] ?? EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the annotations that apply to the given RichText instance.
|
||||
*
|
||||
* Both a blockClientId and a richTextIdentifier are required. This is because
|
||||
* a block might have multiple `RichText` components. This does mean that every
|
||||
* block needs to implement annotations itself.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @param {string} blockClientId The client ID for the block.
|
||||
* @param {string} richTextIdentifier Unique identifier that identifies the given RichText.
|
||||
* @return {Array} All the annotations relevant for the `RichText`.
|
||||
*/
|
||||
const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)((state, blockClientId, richTextIdentifier) => {
|
||||
var _state$blockClientId4;
|
||||
return ((_state$blockClientId4 = state?.[blockClientId]) !== null && _state$blockClientId4 !== void 0 ? _state$blockClientId4 : []).filter(annotation => {
|
||||
return annotation.selector === 'range' && richTextIdentifier === annotation.richTextIdentifier;
|
||||
}).map(annotation => {
|
||||
const {
|
||||
range,
|
||||
...other
|
||||
} = annotation;
|
||||
return {
|
||||
...range,
|
||||
...other
|
||||
};
|
||||
});
|
||||
}, (state, blockClientId) => {
|
||||
var _state$blockClientId5;
|
||||
return [(_state$blockClientId5 = state?.[blockClientId]) !== null && _state$blockClientId5 !== void 0 ? _state$blockClientId5 : EMPTY_ARRAY];
|
||||
});
|
||||
|
||||
/**
|
||||
* Returns all annotations in the editor state.
|
||||
*
|
||||
* @param {Object} state Editor state.
|
||||
* @return {Array} All annotations currently applied.
|
||||
*/
|
||||
const __experimentalGetAnnotationsForRichText = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, blockClientId, richTextIdentifier) => {
|
||||
return (state?.[blockClientId] ?? []).filter((annotation) => {
|
||||
return annotation.selector === "range" && richTextIdentifier === annotation.richTextIdentifier;
|
||||
}).map((annotation) => {
|
||||
const { range, ...other } = annotation;
|
||||
return {
|
||||
...range,
|
||||
...other
|
||||
};
|
||||
});
|
||||
},
|
||||
(state, blockClientId) => [state?.[blockClientId] ?? EMPTY_ARRAY]
|
||||
);
|
||||
function __experimentalGetAnnotations(state) {
|
||||
return Object.values(state).flat();
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/node_modules/uuid/dist/esm-browser/native.js
|
||||
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
||||
/* harmony default export */ const esm_browser_native = ({
|
||||
@@ -571,142 +429,66 @@ function v4(options, buf, offset) {
|
||||
|
||||
/* harmony default export */ const esm_browser_v4 = (v4);
|
||||
;// ./node_modules/@wordpress/annotations/build-module/store/actions.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef WPAnnotationRange
|
||||
*
|
||||
* @property {number} start The offset where the annotation should start.
|
||||
* @property {number} end The offset where the annotation should end.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds an annotation to a block.
|
||||
*
|
||||
* The `block` attribute refers to a block ID that needs to be annotated.
|
||||
* `isBlockAnnotation` controls whether or not the annotation is a block
|
||||
* annotation. The `source` is the source of the annotation, this will be used
|
||||
* to identity groups of annotations.
|
||||
*
|
||||
* The `range` property is only relevant if the selector is 'range'.
|
||||
*
|
||||
* @param {Object} annotation The annotation to add.
|
||||
* @param {string} annotation.blockClientId The blockClientId to add the annotation to.
|
||||
* @param {string} annotation.richTextIdentifier Identifier for the RichText instance the annotation applies to.
|
||||
* @param {WPAnnotationRange} annotation.range The range at which to apply this annotation.
|
||||
* @param {string} [annotation.selector="range"] The way to apply this annotation.
|
||||
* @param {string} [annotation.source="default"] The source that added the annotation.
|
||||
* @param {string} [annotation.id] The ID the annotation should have. Generates a UUID by default.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalAddAnnotation({
|
||||
blockClientId,
|
||||
richTextIdentifier = null,
|
||||
range = null,
|
||||
selector = 'range',
|
||||
source = 'default',
|
||||
selector = "range",
|
||||
source = "default",
|
||||
id = esm_browser_v4()
|
||||
}) {
|
||||
const action = {
|
||||
type: 'ANNOTATION_ADD',
|
||||
type: "ANNOTATION_ADD",
|
||||
id,
|
||||
blockClientId,
|
||||
richTextIdentifier,
|
||||
source,
|
||||
selector
|
||||
};
|
||||
if (selector === 'range') {
|
||||
if (selector === "range") {
|
||||
action.range = range;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an annotation with a specific ID.
|
||||
*
|
||||
* @param {string} annotationId The annotation to remove.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalRemoveAnnotation(annotationId) {
|
||||
return {
|
||||
type: 'ANNOTATION_REMOVE',
|
||||
type: "ANNOTATION_REMOVE",
|
||||
annotationId
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the range of an annotation.
|
||||
*
|
||||
* @param {string} annotationId ID of the annotation to update.
|
||||
* @param {number} start The start of the new range.
|
||||
* @param {number} end The end of the new range.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalUpdateAnnotationRange(annotationId, start, end) {
|
||||
return {
|
||||
type: 'ANNOTATION_UPDATE_RANGE',
|
||||
type: "ANNOTATION_UPDATE_RANGE",
|
||||
annotationId,
|
||||
start,
|
||||
end
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all annotations of a specific source.
|
||||
*
|
||||
* @param {string} source The source to remove.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function __experimentalRemoveAnnotationsBySource(source) {
|
||||
return {
|
||||
type: 'ANNOTATION_REMOVE_SOURCE',
|
||||
type: "ANNOTATION_REMOVE_SOURCE",
|
||||
source
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Module Constants
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the annotations namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
reducer: reducer_default,
|
||||
selectors: selectors_namespaceObject,
|
||||
actions: actions_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/annotations/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+228
-487
@@ -26,29 +26,17 @@ var __webpack_exports__ = {};
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
"default": () => (/* binding */ build_module)
|
||||
"default": () => (/* binding */ index_default)
|
||||
});
|
||||
|
||||
;// external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/nonce.js
|
||||
/**
|
||||
* @param {string} nonce
|
||||
* @return {import('../types').APIFetchMiddleware & { nonce: string }} A middleware to enhance a request with a nonce.
|
||||
*/
|
||||
function createNonceMiddleware(nonce) {
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware & { nonce: string }}
|
||||
*/
|
||||
const middleware = (options, next) => {
|
||||
const {
|
||||
headers = {}
|
||||
} = options;
|
||||
|
||||
// If an 'X-WP-Nonce' header (or any case-insensitive variation
|
||||
// thereof) was specified, no need to add a nonce header.
|
||||
const { headers = {} } = options;
|
||||
for (const headerName in headers) {
|
||||
if (headerName.toLowerCase() === 'x-wp-nonce' && headers[headerName] === middleware.nonce) {
|
||||
if (headerName.toLowerCase() === "x-wp-nonce" && headers[headerName] === middleware.nonce) {
|
||||
return next(options);
|
||||
}
|
||||
}
|
||||
@@ -56,27 +44,25 @@ function createNonceMiddleware(nonce) {
|
||||
...options,
|
||||
headers: {
|
||||
...headers,
|
||||
'X-WP-Nonce': middleware.nonce
|
||||
"X-WP-Nonce": middleware.nonce
|
||||
}
|
||||
});
|
||||
};
|
||||
middleware.nonce = nonce;
|
||||
return middleware;
|
||||
}
|
||||
/* harmony default export */ const nonce = (createNonceMiddleware);
|
||||
var nonce_default = createNonceMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/namespace-endpoint.js
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const namespaceAndEndpointMiddleware = (options, next) => {
|
||||
let path = options.path;
|
||||
let namespaceTrimmed, endpointTrimmed;
|
||||
if (typeof options.namespace === 'string' && typeof options.endpoint === 'string') {
|
||||
namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, '');
|
||||
endpointTrimmed = options.endpoint.replace(/^\//, '');
|
||||
if (typeof options.namespace === "string" && typeof options.endpoint === "string") {
|
||||
namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, "");
|
||||
endpointTrimmed = options.endpoint.replace(/^\//, "");
|
||||
if (endpointTrimmed) {
|
||||
path = namespaceTrimmed + '/' + endpointTrimmed;
|
||||
path = namespaceTrimmed + "/" + endpointTrimmed;
|
||||
} else {
|
||||
path = namespaceTrimmed;
|
||||
}
|
||||
@@ -88,34 +74,24 @@ const namespaceAndEndpointMiddleware = (options, next) => {
|
||||
path
|
||||
});
|
||||
};
|
||||
/* harmony default export */ const namespace_endpoint = (namespaceAndEndpointMiddleware);
|
||||
var namespace_endpoint_default = namespaceAndEndpointMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/root-url.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} rootURL
|
||||
* @return {import('../types').APIFetchMiddleware} Root URL middleware.
|
||||
*/
|
||||
const createRootURLMiddleware = rootURL => (options, next) => {
|
||||
return namespace_endpoint(options, optionsWithPath => {
|
||||
const createRootURLMiddleware = (rootURL) => (options, next) => {
|
||||
return namespace_endpoint_default(options, (optionsWithPath) => {
|
||||
let url = optionsWithPath.url;
|
||||
let path = optionsWithPath.path;
|
||||
let apiRoot;
|
||||
if (typeof path === 'string') {
|
||||
if (typeof path === "string") {
|
||||
apiRoot = rootURL;
|
||||
if (-1 !== rootURL.indexOf('?')) {
|
||||
path = path.replace('?', '&');
|
||||
if (-1 !== rootURL.indexOf("?")) {
|
||||
path = path.replace("?", "&");
|
||||
}
|
||||
path = path.replace(/^\//, '');
|
||||
|
||||
// API root may already include query parameter prefix if site is
|
||||
// configured to use plain permalinks.
|
||||
if ('string' === typeof apiRoot && -1 !== apiRoot.indexOf('?')) {
|
||||
path = path.replace('?', '&');
|
||||
path = path.replace(/^\//, "");
|
||||
if ("string" === typeof apiRoot && -1 !== apiRoot.indexOf("?")) {
|
||||
path = path.replace("?", "&");
|
||||
}
|
||||
url = apiRoot + path;
|
||||
}
|
||||
@@ -125,133 +101,93 @@ const createRootURLMiddleware = rootURL => (options, next) => {
|
||||
});
|
||||
});
|
||||
};
|
||||
/* harmony default export */ const root_url = (createRootURLMiddleware);
|
||||
var root_url_default = createRootURLMiddleware;
|
||||
|
||||
|
||||
;// external ["wp","url"]
|
||||
const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/preloading.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {Record<string, any>} preloadedData
|
||||
* @return {import('../types').APIFetchMiddleware} Preloading middleware.
|
||||
*/
|
||||
function createPreloadingMiddleware(preloadedData) {
|
||||
const cache = Object.fromEntries(Object.entries(preloadedData).map(([path, data]) => [(0,external_wp_url_namespaceObject.normalizePath)(path), data]));
|
||||
const cache = Object.fromEntries(
|
||||
Object.entries(preloadedData).map(([path, data]) => [
|
||||
(0,external_wp_url_namespaceObject.normalizePath)(path),
|
||||
data
|
||||
])
|
||||
);
|
||||
return (options, next) => {
|
||||
const {
|
||||
parse = true
|
||||
} = options;
|
||||
/** @type {string | void} */
|
||||
const { parse = true } = options;
|
||||
let rawPath = options.path;
|
||||
if (!rawPath && options.url) {
|
||||
const {
|
||||
rest_route: pathFromQuery,
|
||||
...queryArgs
|
||||
} = (0,external_wp_url_namespaceObject.getQueryArgs)(options.url);
|
||||
if (typeof pathFromQuery === 'string') {
|
||||
const { rest_route: pathFromQuery, ...queryArgs } = (0,external_wp_url_namespaceObject.getQueryArgs)(
|
||||
options.url
|
||||
);
|
||||
if (typeof pathFromQuery === "string") {
|
||||
rawPath = (0,external_wp_url_namespaceObject.addQueryArgs)(pathFromQuery, queryArgs);
|
||||
}
|
||||
}
|
||||
if (typeof rawPath !== 'string') {
|
||||
if (typeof rawPath !== "string") {
|
||||
return next(options);
|
||||
}
|
||||
const method = options.method || 'GET';
|
||||
const method = options.method || "GET";
|
||||
const path = (0,external_wp_url_namespaceObject.normalizePath)(rawPath);
|
||||
if ('GET' === method && cache[path]) {
|
||||
if ("GET" === method && cache[path]) {
|
||||
const cacheData = cache[path];
|
||||
|
||||
// Unsetting the cache key ensures that the data is only used a single time.
|
||||
delete cache[path];
|
||||
return prepareResponse(cacheData, !!parse);
|
||||
} else if ('OPTIONS' === method && cache[method] && cache[method][path]) {
|
||||
} else if ("OPTIONS" === method && cache[method] && cache[method][path]) {
|
||||
const cacheData = cache[method][path];
|
||||
|
||||
// Unsetting the cache key ensures that the data is only used a single time.
|
||||
delete cache[method][path];
|
||||
return prepareResponse(cacheData, !!parse);
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a helper function that sends a success response.
|
||||
*
|
||||
* @param {Record<string, any>} responseData
|
||||
* @param {boolean} parse
|
||||
* @return {Promise<any>} Promise with the response.
|
||||
*/
|
||||
function prepareResponse(responseData, parse) {
|
||||
if (parse) {
|
||||
return Promise.resolve(responseData.body);
|
||||
}
|
||||
try {
|
||||
return Promise.resolve(new window.Response(JSON.stringify(responseData.body), {
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: responseData.headers
|
||||
}));
|
||||
return Promise.resolve(
|
||||
new window.Response(JSON.stringify(responseData.body), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: responseData.headers
|
||||
})
|
||||
);
|
||||
} catch {
|
||||
// See: https://github.com/WordPress/gutenberg/issues/67358#issuecomment-2621163926.
|
||||
Object.entries(responseData.headers).forEach(([key, value]) => {
|
||||
if (key.toLowerCase() === 'link') {
|
||||
responseData.headers[key] = value.replace(/<([^>]+)>/, (/** @type {any} */_, /** @type {string} */url) => `<${encodeURI(url)}>`);
|
||||
Object.entries(
|
||||
responseData.headers
|
||||
).forEach(([key, value]) => {
|
||||
if (key.toLowerCase() === "link") {
|
||||
responseData.headers[key] = value.replace(
|
||||
/<([^>]+)>/,
|
||||
(_, url) => `<${encodeURI(url)}>`
|
||||
);
|
||||
}
|
||||
});
|
||||
return Promise.resolve(parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
|
||||
status: 200,
|
||||
statusText: 'OK',
|
||||
headers: responseData.headers
|
||||
}));
|
||||
return Promise.resolve(
|
||||
parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
|
||||
status: 200,
|
||||
statusText: "OK",
|
||||
headers: responseData.headers
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
/* harmony default export */ const preloading = (createPreloadingMiddleware);
|
||||
var preloading_default = createPreloadingMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/fetch-all-middleware.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Apply query arguments to both URL and Path, whichever is present.
|
||||
*
|
||||
* @param {import('../types').APIFetchOptions} props
|
||||
* @param {Record<string, string | number>} queryArgs
|
||||
* @return {import('../types').APIFetchOptions} The request with the modified query args
|
||||
*/
|
||||
const modifyQuery = ({
|
||||
path,
|
||||
url,
|
||||
...options
|
||||
}, queryArgs) => ({
|
||||
const modifyQuery = ({ path, url, ...options }, queryArgs) => ({
|
||||
...options,
|
||||
url: url && (0,external_wp_url_namespaceObject.addQueryArgs)(url, queryArgs),
|
||||
path: path && (0,external_wp_url_namespaceObject.addQueryArgs)(path, queryArgs)
|
||||
});
|
||||
|
||||
/**
|
||||
* Duplicates parsing functionality from apiFetch.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Promise<any>} Parsed response json.
|
||||
*/
|
||||
const parseResponse = response => response.json ? response.json() : Promise.reject(response);
|
||||
|
||||
/**
|
||||
* @param {string | null} linkHeader
|
||||
* @return {{ next?: string }} The parsed link header.
|
||||
*/
|
||||
const parseLinkHeader = linkHeader => {
|
||||
const parseResponse = (response) => response.json ? response.json() : Promise.reject(response);
|
||||
const parseLinkHeader = (linkHeader) => {
|
||||
if (!linkHeader) {
|
||||
return {};
|
||||
}
|
||||
@@ -260,47 +196,23 @@ const parseLinkHeader = linkHeader => {
|
||||
next: match[1]
|
||||
} : {};
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Response} response
|
||||
* @return {string | undefined} The next page URL.
|
||||
*/
|
||||
const getNextPageUrl = response => {
|
||||
const {
|
||||
next
|
||||
} = parseLinkHeader(response.headers.get('link'));
|
||||
const getNextPageUrl = (response) => {
|
||||
const { next } = parseLinkHeader(response.headers.get("link"));
|
||||
return next;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('../types').APIFetchOptions} options
|
||||
* @return {boolean} True if the request contains an unbounded query.
|
||||
*/
|
||||
const requestContainsUnboundedQuery = options => {
|
||||
const pathIsUnbounded = !!options.path && options.path.indexOf('per_page=-1') !== -1;
|
||||
const urlIsUnbounded = !!options.url && options.url.indexOf('per_page=-1') !== -1;
|
||||
const requestContainsUnboundedQuery = (options) => {
|
||||
const pathIsUnbounded = !!options.path && options.path.indexOf("per_page=-1") !== -1;
|
||||
const urlIsUnbounded = !!options.url && options.url.indexOf("per_page=-1") !== -1;
|
||||
return pathIsUnbounded || urlIsUnbounded;
|
||||
};
|
||||
|
||||
/**
|
||||
* The REST API enforces an upper limit on the per_page option. To handle large
|
||||
* collections, apiFetch consumers can pass `per_page=-1`; this middleware will
|
||||
* then recursively assemble a full response array from all available pages.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const fetchAllMiddleware = async (options, next) => {
|
||||
if (options.parse === false) {
|
||||
// If a consumer has opted out of parsing, do not apply middleware.
|
||||
return next(options);
|
||||
}
|
||||
if (!requestContainsUnboundedQuery(options)) {
|
||||
// If neither url nor path is requesting all items, do not apply middleware.
|
||||
return next(options);
|
||||
}
|
||||
|
||||
// Retrieve requested page of results.
|
||||
const response = await build_module({
|
||||
const response = await index_default({
|
||||
...modifyQuery(options, {
|
||||
per_page: 100
|
||||
}),
|
||||
@@ -309,22 +221,18 @@ const fetchAllMiddleware = async (options, next) => {
|
||||
});
|
||||
const results = await parseResponse(response);
|
||||
if (!Array.isArray(results)) {
|
||||
// We have no reliable way of merging non-array results.
|
||||
return results;
|
||||
}
|
||||
let nextPage = getNextPageUrl(response);
|
||||
if (!nextPage) {
|
||||
// There are no further pages to request.
|
||||
return results;
|
||||
}
|
||||
|
||||
// Iteratively fetch all remaining pages until no "next" header is found.
|
||||
let mergedResults = /** @type {any[]} */[].concat(results);
|
||||
let mergedResults = [].concat(results);
|
||||
while (nextPage) {
|
||||
const nextResponse = await build_module({
|
||||
const nextResponse = await index_default({
|
||||
...options,
|
||||
// Ensure the URL for the next page is used instead of any provided path.
|
||||
path: undefined,
|
||||
path: void 0,
|
||||
url: nextPage,
|
||||
// Ensure we still get headers so we can identify the next page.
|
||||
parse: false
|
||||
@@ -335,198 +243,93 @@ const fetchAllMiddleware = async (options, next) => {
|
||||
}
|
||||
return mergedResults;
|
||||
};
|
||||
/* harmony default export */ const fetch_all_middleware = (fetchAllMiddleware);
|
||||
var fetch_all_middleware_default = fetchAllMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/http-v1.js
|
||||
/**
|
||||
* Set of HTTP methods which are eligible to be overridden.
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
const OVERRIDE_METHODS = new Set(['PATCH', 'PUT', 'DELETE']);
|
||||
|
||||
/**
|
||||
* Default request method.
|
||||
*
|
||||
* "A request has an associated method (a method). Unless stated otherwise it
|
||||
* is `GET`."
|
||||
*
|
||||
* @see https://fetch.spec.whatwg.org/#requests
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_METHOD = 'GET';
|
||||
|
||||
/**
|
||||
* API Fetch middleware which overrides the request method for HTTP v1
|
||||
* compatibility leveraging the REST API X-HTTP-Method-Override header.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const OVERRIDE_METHODS = /* @__PURE__ */ new Set(["PATCH", "PUT", "DELETE"]);
|
||||
const DEFAULT_METHOD = "GET";
|
||||
const httpV1Middleware = (options, next) => {
|
||||
const {
|
||||
method = DEFAULT_METHOD
|
||||
} = options;
|
||||
const { method = DEFAULT_METHOD } = options;
|
||||
if (OVERRIDE_METHODS.has(method.toUpperCase())) {
|
||||
options = {
|
||||
...options,
|
||||
headers: {
|
||||
...options.headers,
|
||||
'X-HTTP-Method-Override': method,
|
||||
'Content-Type': 'application/json'
|
||||
"X-HTTP-Method-Override": method,
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
method: 'POST'
|
||||
method: "POST"
|
||||
};
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ const http_v1 = (httpV1Middleware);
|
||||
var http_v1_default = httpV1Middleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/user-locale.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const userLocaleMiddleware = (options, next) => {
|
||||
if (typeof options.url === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.url, '_locale')) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, {
|
||||
_locale: 'user'
|
||||
});
|
||||
if (typeof options.url === "string" && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.url, "_locale")) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, { _locale: "user" });
|
||||
}
|
||||
if (typeof options.path === 'string' && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.path, '_locale')) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, {
|
||||
_locale: 'user'
|
||||
});
|
||||
if (typeof options.path === "string" && !(0,external_wp_url_namespaceObject.hasQueryArg)(options.path, "_locale")) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, { _locale: "user" });
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ const user_locale = (userLocaleMiddleware);
|
||||
var user_locale_default = userLocaleMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/utils/response.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Parses the apiFetch response.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
*
|
||||
* @return {Promise<any> | null | Response} Parsed response.
|
||||
*/
|
||||
const response_parseResponse = (response, shouldParseResponse = true) => {
|
||||
if (shouldParseResponse) {
|
||||
if (response.status === 204) {
|
||||
return null;
|
||||
}
|
||||
return response.json ? response.json() : Promise.reject(response);
|
||||
async function parseJsonAndNormalizeError(response) {
|
||||
try {
|
||||
return await response.json();
|
||||
} catch {
|
||||
throw {
|
||||
code: "invalid_json",
|
||||
message: (0,external_wp_i18n_namespaceObject.__)("The response is not a valid JSON response.")
|
||||
};
|
||||
}
|
||||
return response;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls the `json` function on the Response, throwing an error if the response
|
||||
* doesn't have a json function or if parsing the json itself fails.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
const parseJsonAndNormalizeError = response => {
|
||||
const invalidJsonError = {
|
||||
code: 'invalid_json',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('The response is not a valid JSON response.')
|
||||
};
|
||||
if (!response || !response.json) {
|
||||
throw invalidJsonError;
|
||||
}
|
||||
async function parseResponseAndNormalizeError(response, shouldParseResponse = true) {
|
||||
if (!shouldParseResponse) {
|
||||
return response;
|
||||
}
|
||||
return response.json().catch(() => {
|
||||
throw invalidJsonError;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the apiFetch response properly and normalize response errors.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
*
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
const parseResponseAndNormalizeError = (response, shouldParseResponse = true) => {
|
||||
return Promise.resolve(response_parseResponse(response, shouldParseResponse)).catch(res => parseAndThrowError(res, shouldParseResponse));
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a response, throwing an error if parsing the response fails.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @param {boolean} shouldParseResponse
|
||||
* @return {Promise<any>} Parsed response.
|
||||
*/
|
||||
function parseAndThrowError(response, shouldParseResponse = true) {
|
||||
if (response.status === 204) {
|
||||
return null;
|
||||
}
|
||||
return await parseJsonAndNormalizeError(response);
|
||||
}
|
||||
async function parseAndThrowError(response, shouldParseResponse = true) {
|
||||
if (!shouldParseResponse) {
|
||||
throw response;
|
||||
}
|
||||
return parseJsonAndNormalizeError(response).then(error => {
|
||||
const unknownError = {
|
||||
code: 'unknown_error',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('An unknown error occurred.')
|
||||
};
|
||||
throw error || unknownError;
|
||||
});
|
||||
throw await parseJsonAndNormalizeError(response);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/media-upload.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @param {import('../types').APIFetchOptions} options
|
||||
* @return {boolean} True if the request is for media upload.
|
||||
*/
|
||||
function isMediaUploadRequest(options) {
|
||||
const isCreateMethod = !!options.method && options.method === 'POST';
|
||||
const isMediaEndpoint = !!options.path && options.path.indexOf('/wp/v2/media') !== -1 || !!options.url && options.url.indexOf('/wp/v2/media') !== -1;
|
||||
const isCreateMethod = !!options.method && options.method === "POST";
|
||||
const isMediaEndpoint = !!options.path && options.path.indexOf("/wp/v2/media") !== -1 || !!options.url && options.url.indexOf("/wp/v2/media") !== -1;
|
||||
return isMediaEndpoint && isCreateMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware handling media upload failures and retries.
|
||||
*
|
||||
* @type {import('../types').APIFetchMiddleware}
|
||||
*/
|
||||
const mediaUploadMiddleware = (options, next) => {
|
||||
if (!isMediaUploadRequest(options)) {
|
||||
return next(options);
|
||||
}
|
||||
let retries = 0;
|
||||
const maxRetries = 5;
|
||||
|
||||
/**
|
||||
* @param {string} attachmentId
|
||||
* @return {Promise<any>} Processed post response.
|
||||
*/
|
||||
const postProcess = attachmentId => {
|
||||
const postProcess = (attachmentId) => {
|
||||
retries++;
|
||||
return next({
|
||||
path: `/wp/v2/media/${attachmentId}/post-process`,
|
||||
method: 'POST',
|
||||
data: {
|
||||
action: 'create-image-subsizes'
|
||||
},
|
||||
method: "POST",
|
||||
data: { action: "create-image-subsizes" },
|
||||
parse: false
|
||||
}).catch(() => {
|
||||
if (retries < maxRetries) {
|
||||
@@ -534,86 +337,80 @@ const mediaUploadMiddleware = (options, next) => {
|
||||
}
|
||||
next({
|
||||
path: `/wp/v2/media/${attachmentId}?force=true`,
|
||||
method: 'DELETE'
|
||||
method: "DELETE"
|
||||
});
|
||||
return Promise.reject();
|
||||
});
|
||||
};
|
||||
return next({
|
||||
...options,
|
||||
parse: false
|
||||
}).catch(response => {
|
||||
// `response` could actually be an error thrown by `defaultFetchHandler`.
|
||||
if (!response.headers) {
|
||||
return next({ ...options, parse: false }).catch((response) => {
|
||||
if (!(response instanceof globalThis.Response)) {
|
||||
return Promise.reject(response);
|
||||
}
|
||||
const attachmentId = response.headers.get('x-wp-upload-attachment-id');
|
||||
const attachmentId = response.headers.get(
|
||||
"x-wp-upload-attachment-id"
|
||||
);
|
||||
if (response.status >= 500 && response.status < 600 && attachmentId) {
|
||||
return postProcess(attachmentId).catch(() => {
|
||||
if (options.parse !== false) {
|
||||
return Promise.reject({
|
||||
code: 'post_process',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('Media upload failed. If this is a photo or a large image, please scale it down and try again.')
|
||||
code: "post_process",
|
||||
message: (0,external_wp_i18n_namespaceObject.__)(
|
||||
"Media upload failed. If this is a photo or a large image, please scale it down and try again."
|
||||
)
|
||||
});
|
||||
}
|
||||
return Promise.reject(response);
|
||||
});
|
||||
}
|
||||
return parseAndThrowError(response, options.parse);
|
||||
}).then(response => parseResponseAndNormalizeError(response, options.parse));
|
||||
}).then(
|
||||
(response) => parseResponseAndNormalizeError(response, options.parse)
|
||||
);
|
||||
};
|
||||
/* harmony default export */ const media_upload = (mediaUploadMiddleware);
|
||||
var media_upload_default = mediaUploadMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/middlewares/theme-preview.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This appends a `wp_theme_preview` parameter to the REST API request URL if
|
||||
* the admin URL contains a `theme` GET parameter.
|
||||
*
|
||||
* If the REST API request URL has contained the `wp_theme_preview` parameter as `''`,
|
||||
* then bypass this middleware.
|
||||
*
|
||||
* @param {Record<string, any>} themePath
|
||||
* @return {import('../types').APIFetchMiddleware} Preloading middleware.
|
||||
*/
|
||||
const createThemePreviewMiddleware = themePath => (options, next) => {
|
||||
if (typeof options.url === 'string') {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(options.url, 'wp_theme_preview');
|
||||
if (wpThemePreview === undefined) {
|
||||
const createThemePreviewMiddleware = (themePath) => (options, next) => {
|
||||
if (typeof options.url === "string") {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(
|
||||
options.url,
|
||||
"wp_theme_preview"
|
||||
);
|
||||
if (wpThemePreview === void 0) {
|
||||
options.url = (0,external_wp_url_namespaceObject.addQueryArgs)(options.url, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
} else if (wpThemePreview === '') {
|
||||
options.url = (0,external_wp_url_namespaceObject.removeQueryArgs)(options.url, 'wp_theme_preview');
|
||||
} else if (wpThemePreview === "") {
|
||||
options.url = (0,external_wp_url_namespaceObject.removeQueryArgs)(
|
||||
options.url,
|
||||
"wp_theme_preview"
|
||||
);
|
||||
}
|
||||
}
|
||||
if (typeof options.path === 'string') {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(options.path, 'wp_theme_preview');
|
||||
if (wpThemePreview === undefined) {
|
||||
if (typeof options.path === "string") {
|
||||
const wpThemePreview = (0,external_wp_url_namespaceObject.getQueryArg)(
|
||||
options.path,
|
||||
"wp_theme_preview"
|
||||
);
|
||||
if (wpThemePreview === void 0) {
|
||||
options.path = (0,external_wp_url_namespaceObject.addQueryArgs)(options.path, {
|
||||
wp_theme_preview: themePath
|
||||
});
|
||||
} else if (wpThemePreview === '') {
|
||||
options.path = (0,external_wp_url_namespaceObject.removeQueryArgs)(options.path, 'wp_theme_preview');
|
||||
} else if (wpThemePreview === "") {
|
||||
options.path = (0,external_wp_url_namespaceObject.removeQueryArgs)(
|
||||
options.path,
|
||||
"wp_theme_preview"
|
||||
);
|
||||
}
|
||||
}
|
||||
return next(options);
|
||||
};
|
||||
/* harmony default export */ const theme_preview = (createThemePreviewMiddleware);
|
||||
var theme_preview_default = createThemePreviewMiddleware;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/api-fetch/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -625,164 +422,108 @@ const createThemePreviewMiddleware = themePath => (options, next) => {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default set of header values which should be sent with every request unless
|
||||
* explicitly provided through apiFetch options.
|
||||
*
|
||||
* @type {Record<string, string>}
|
||||
*/
|
||||
const DEFAULT_HEADERS = {
|
||||
// The backend uses the Accept header as a condition for considering an
|
||||
// incoming request as a REST request.
|
||||
//
|
||||
// See: https://core.trac.wordpress.org/ticket/44534
|
||||
Accept: 'application/json, */*;q=0.1'
|
||||
Accept: "application/json, */*;q=0.1"
|
||||
};
|
||||
|
||||
/**
|
||||
* Default set of fetch option values which should be sent with every request
|
||||
* unless explicitly provided through apiFetch options.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const DEFAULT_OPTIONS = {
|
||||
credentials: 'include'
|
||||
credentials: "include"
|
||||
};
|
||||
|
||||
/** @typedef {import('./types').APIFetchMiddleware} APIFetchMiddleware */
|
||||
/** @typedef {import('./types').APIFetchOptions} APIFetchOptions */
|
||||
|
||||
/**
|
||||
* @type {import('./types').APIFetchMiddleware[]}
|
||||
*/
|
||||
const middlewares = [user_locale, namespace_endpoint, http_v1, fetch_all_middleware];
|
||||
|
||||
/**
|
||||
* Register a middleware
|
||||
*
|
||||
* @param {import('./types').APIFetchMiddleware} middleware
|
||||
*/
|
||||
const middlewares = [
|
||||
user_locale_default,
|
||||
namespace_endpoint_default,
|
||||
http_v1_default,
|
||||
fetch_all_middleware_default
|
||||
];
|
||||
function registerMiddleware(middleware) {
|
||||
middlewares.unshift(middleware);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the status of a response, throwing the Response as an error if
|
||||
* it is outside the 200 range.
|
||||
*
|
||||
* @param {Response} response
|
||||
* @return {Response} The response if the status is in the 200 range.
|
||||
*/
|
||||
const checkStatus = response => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
return response;
|
||||
}
|
||||
throw response;
|
||||
};
|
||||
|
||||
/** @typedef {(options: import('./types').APIFetchOptions) => Promise<any>} FetchHandler*/
|
||||
|
||||
/**
|
||||
* @type {FetchHandler}
|
||||
*/
|
||||
const defaultFetchHandler = nextOptions => {
|
||||
const {
|
||||
url,
|
||||
path,
|
||||
data,
|
||||
parse = true,
|
||||
...remainingOptions
|
||||
} = nextOptions;
|
||||
let {
|
||||
body,
|
||||
headers
|
||||
} = nextOptions;
|
||||
|
||||
// Merge explicitly-provided headers with default values.
|
||||
headers = {
|
||||
...DEFAULT_HEADERS,
|
||||
...headers
|
||||
};
|
||||
|
||||
// The `data` property is a shorthand for sending a JSON body.
|
||||
const defaultFetchHandler = (nextOptions) => {
|
||||
const { url, path, data, parse = true, ...remainingOptions } = nextOptions;
|
||||
let { body, headers } = nextOptions;
|
||||
headers = { ...DEFAULT_HEADERS, ...headers };
|
||||
if (data) {
|
||||
body = JSON.stringify(data);
|
||||
headers['Content-Type'] = 'application/json';
|
||||
headers["Content-Type"] = "application/json";
|
||||
}
|
||||
const responsePromise = window.fetch(
|
||||
// Fall back to explicitly passing `window.location` which is the behavior if `undefined` is passed.
|
||||
url || path || window.location.href, {
|
||||
...DEFAULT_OPTIONS,
|
||||
...remainingOptions,
|
||||
body,
|
||||
headers
|
||||
});
|
||||
return responsePromise.then(value => Promise.resolve(value).then(checkStatus).catch(response => parseAndThrowError(response, parse)).then(response => parseResponseAndNormalizeError(response, parse)), err => {
|
||||
// Re-throw AbortError for the users to handle it themselves.
|
||||
if (err && err.name === 'AbortError') {
|
||||
throw err;
|
||||
const responsePromise = globalThis.fetch(
|
||||
// Fall back to explicitly passing `window.location` which is the behavior if `undefined` is passed.
|
||||
url || path || window.location.href,
|
||||
{
|
||||
...DEFAULT_OPTIONS,
|
||||
...remainingOptions,
|
||||
body,
|
||||
headers
|
||||
}
|
||||
|
||||
// Otherwise, there is most likely no network connection.
|
||||
// Unfortunately the message might depend on the browser.
|
||||
throw {
|
||||
code: 'fetch_error',
|
||||
message: (0,external_wp_i18n_namespaceObject.__)('You are probably offline.')
|
||||
};
|
||||
});
|
||||
);
|
||||
return responsePromise.then(
|
||||
(response) => {
|
||||
if (!response.ok) {
|
||||
return parseAndThrowError(response, parse);
|
||||
}
|
||||
return parseResponseAndNormalizeError(response, parse);
|
||||
},
|
||||
(err) => {
|
||||
if (err && err.name === "AbortError") {
|
||||
throw err;
|
||||
}
|
||||
if (!globalThis.navigator.onLine) {
|
||||
throw {
|
||||
code: "offline_error",
|
||||
message: (0,external_wp_i18n_namespaceObject.__)(
|
||||
"Unable to connect. Please check your Internet connection."
|
||||
)
|
||||
};
|
||||
}
|
||||
throw {
|
||||
code: "fetch_error",
|
||||
message: (0,external_wp_i18n_namespaceObject.__)(
|
||||
"Could not get a valid response from the server."
|
||||
)
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/** @type {FetchHandler} */
|
||||
let fetchHandler = defaultFetchHandler;
|
||||
|
||||
/**
|
||||
* Defines a custom fetch handler for making the requests that will override
|
||||
* the default one using window.fetch
|
||||
*
|
||||
* @param {FetchHandler} newFetchHandler The new fetch handler
|
||||
*/
|
||||
function setFetchHandler(newFetchHandler) {
|
||||
fetchHandler = newFetchHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template T
|
||||
* @param {import('./types').APIFetchOptions} options
|
||||
* @return {Promise<T>} A promise representing the request processed via the registered middlewares.
|
||||
*/
|
||||
function apiFetch(options) {
|
||||
// creates a nested function chain that calls all middlewares and finally the `fetchHandler`,
|
||||
// converting `middlewares = [ m1, m2, m3 ]` into:
|
||||
// ```
|
||||
// opts1 => m1( opts1, opts2 => m2( opts2, opts3 => m3( opts3, fetchHandler ) ) );
|
||||
// ```
|
||||
const enhancedHandler = middlewares.reduceRight((/** @type {FetchHandler} */next, middleware) => {
|
||||
return workingOptions => middleware(workingOptions, next);
|
||||
}, fetchHandler);
|
||||
return enhancedHandler(options).catch(error => {
|
||||
if (error.code !== 'rest_cookie_invalid_nonce') {
|
||||
const apiFetch = (options) => {
|
||||
const enhancedHandler = middlewares.reduceRight(
|
||||
(next, middleware) => {
|
||||
return (workingOptions) => middleware(workingOptions, next);
|
||||
},
|
||||
fetchHandler
|
||||
);
|
||||
return enhancedHandler(options).catch((error) => {
|
||||
if (error.code !== "rest_cookie_invalid_nonce") {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
|
||||
// If the nonce is invalid, refresh it and try again.
|
||||
return window
|
||||
// @ts-ignore
|
||||
.fetch(apiFetch.nonceEndpoint).then(checkStatus).then(data => data.text()).then(text => {
|
||||
// @ts-ignore
|
||||
return globalThis.fetch(apiFetch.nonceEndpoint).then((response) => {
|
||||
if (!response.ok) {
|
||||
return Promise.reject(error);
|
||||
}
|
||||
return response.text();
|
||||
}).then((text) => {
|
||||
apiFetch.nonceMiddleware.nonce = text;
|
||||
return apiFetch(options);
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
apiFetch.use = registerMiddleware;
|
||||
apiFetch.setFetchHandler = setFetchHandler;
|
||||
apiFetch.createNonceMiddleware = nonce;
|
||||
apiFetch.createPreloadingMiddleware = preloading;
|
||||
apiFetch.createRootURLMiddleware = root_url;
|
||||
apiFetch.fetchAllMiddleware = fetch_all_middleware;
|
||||
apiFetch.mediaUploadMiddleware = media_upload;
|
||||
apiFetch.createThemePreviewMiddleware = theme_preview;
|
||||
/* harmony default export */ const build_module = (apiFetch);
|
||||
apiFetch.createNonceMiddleware = nonce_default;
|
||||
apiFetch.createPreloadingMiddleware = preloading_default;
|
||||
apiFetch.createRootURLMiddleware = root_url_default;
|
||||
apiFetch.fetchAllMiddleware = fetch_all_middleware_default;
|
||||
apiFetch.mediaUploadMiddleware = media_upload_default;
|
||||
apiFetch.createThemePreviewMiddleware = theme_preview_default;
|
||||
var index_default = apiFetch;
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).apiFetch = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+160
-327
@@ -39,75 +39,21 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ autop: () => (/* binding */ autop),
|
||||
/* harmony export */ removep: () => (/* binding */ removep)
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* The regular expression for an HTML element.
|
||||
*/
|
||||
const htmlSplitRegex = (() => {
|
||||
/* eslint-disable no-multi-spaces */
|
||||
const comments = '!' +
|
||||
// Start of comment, after the <.
|
||||
'(?:' +
|
||||
// Unroll the loop: Consume everything until --> is found.
|
||||
'-(?!->)' +
|
||||
// Dash not followed by end of comment.
|
||||
'[^\\-]*' +
|
||||
// Consume non-dashes.
|
||||
')*' +
|
||||
// Loop possessively.
|
||||
'(?:-->)?'; // End of comment. If not found, match all input.
|
||||
|
||||
const cdata = '!\\[CDATA\\[' +
|
||||
// Start of comment, after the <.
|
||||
'[^\\]]*' +
|
||||
// Consume non-].
|
||||
'(?:' +
|
||||
// Unroll the loop: Consume everything until ]]> is found.
|
||||
'](?!]>)' +
|
||||
// One ] not followed by end of comment.
|
||||
'[^\\]]*' +
|
||||
// Consume non-].
|
||||
')*?' +
|
||||
// Loop possessively.
|
||||
'(?:]]>)?'; // End of comment. If not found, match all input.
|
||||
|
||||
const escaped = '(?=' +
|
||||
// Is the element escaped?
|
||||
'!--' + '|' + '!\\[CDATA\\[' + ')' + '((?=!-)' +
|
||||
// If yes, which type?
|
||||
comments + '|' + cdata + ')';
|
||||
const regex = '(' +
|
||||
// Capture the entire match.
|
||||
'<' +
|
||||
// Find start of element.
|
||||
'(' +
|
||||
// Conditional expression follows.
|
||||
escaped +
|
||||
// Find end of escaped element.
|
||||
'|' +
|
||||
// ... else ...
|
||||
'[^>]*>?' +
|
||||
// Find end of normal element.
|
||||
')' + ')';
|
||||
const comments = "!(?:-(?!->)[^\\-]*)*(?:-->)?";
|
||||
const cdata = "!\\[CDATA\\[[^\\]]*(?:](?!]>)[^\\]]*)*?(?:]]>)?";
|
||||
const escaped = "(?=!--|!\\[CDATA\\[)((?=!-)" + // If yes, which type?
|
||||
comments + "|" + cdata + ")";
|
||||
const regex = "(<(" + // Conditional expression follows.
|
||||
escaped + // Find end of escaped element.
|
||||
"|[^>]*>?))";
|
||||
return new RegExp(regex);
|
||||
/* eslint-enable no-multi-spaces */
|
||||
})();
|
||||
|
||||
/**
|
||||
* Separate HTML elements and comments from the text.
|
||||
*
|
||||
* @param input The text which has to be formatted.
|
||||
*
|
||||
* @return The formatted text.
|
||||
*/
|
||||
function htmlSplit(input) {
|
||||
const parts = [];
|
||||
let workingInput = input;
|
||||
let match;
|
||||
while (match = workingInput.match(htmlSplitRegex)) {
|
||||
// The `match` result, when invoked on a RegExp with the `g` flag (`/foo/g`) will not include `index`.
|
||||
// If the `g` flag is omitted, `index` is included.
|
||||
// `htmlSplitRegex` does not have the `g` flag so we can assert it will have an index number.
|
||||
// Assert `match.index` is a number.
|
||||
const index = match.index;
|
||||
parts.push(workingInput.slice(0, index));
|
||||
parts.push(match[0]);
|
||||
@@ -118,341 +64,227 @@ function htmlSplit(input) {
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace characters or phrases within HTML elements only.
|
||||
*
|
||||
* @param haystack The text which has to be formatted.
|
||||
* @param replacePairs In the form {from: 'to', …}.
|
||||
*
|
||||
* @return The formatted text.
|
||||
*/
|
||||
function replaceInHtmlTags(haystack, replacePairs) {
|
||||
// Find all elements.
|
||||
const textArr = htmlSplit(haystack);
|
||||
let changed = false;
|
||||
|
||||
// Extract all needles.
|
||||
const needles = Object.keys(replacePairs);
|
||||
|
||||
// Loop through delimiters (elements) only.
|
||||
for (let i = 1; i < textArr.length; i += 2) {
|
||||
for (let j = 0; j < needles.length; j++) {
|
||||
const needle = needles[j];
|
||||
if (-1 !== textArr[i].indexOf(needle)) {
|
||||
textArr[i] = textArr[i].replace(new RegExp(needle, 'g'), replacePairs[needle]);
|
||||
textArr[i] = textArr[i].replace(
|
||||
new RegExp(needle, "g"),
|
||||
replacePairs[needle]
|
||||
);
|
||||
changed = true;
|
||||
// After one strtr() break out of the foreach loop and look at next element.
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
haystack = textArr.join('');
|
||||
haystack = textArr.join("");
|
||||
}
|
||||
return haystack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces double line-breaks with paragraph elements.
|
||||
*
|
||||
* A group of regex replaces used to identify text formatted with newlines and
|
||||
* replace double line-breaks with HTML paragraph tags. The remaining line-
|
||||
* breaks after conversion become `<br />` tags, unless br is set to 'false'.
|
||||
*
|
||||
* @param text The text which has to be formatted.
|
||||
* @param br Optional. If set, will convert all remaining line-
|
||||
* breaks after paragraphing. Default true.
|
||||
*
|
||||
* @example
|
||||
*```js
|
||||
* import { autop } from '@wordpress/autop';
|
||||
* autop( 'my text' ); // "<p>my text</p>"
|
||||
* ```
|
||||
*
|
||||
* @return Text which has been converted into paragraph tags.
|
||||
*/
|
||||
function autop(text, br = true) {
|
||||
const preTags = [];
|
||||
if (text.trim() === '') {
|
||||
return '';
|
||||
if (text.trim() === "") {
|
||||
return "";
|
||||
}
|
||||
|
||||
// Just to make things a little easier, pad the end.
|
||||
text = text + '\n';
|
||||
|
||||
/*
|
||||
* Pre tags shouldn't be touched by autop.
|
||||
* Replace pre tags with placeholders and bring them back after autop.
|
||||
*/
|
||||
if (text.indexOf('<pre') !== -1) {
|
||||
const textParts = text.split('</pre>');
|
||||
text = text + "\n";
|
||||
if (text.indexOf("<pre") !== -1) {
|
||||
const textParts = text.split("</pre>");
|
||||
const lastText = textParts.pop();
|
||||
text = '';
|
||||
text = "";
|
||||
for (let i = 0; i < textParts.length; i++) {
|
||||
const textPart = textParts[i];
|
||||
const start = textPart.indexOf('<pre');
|
||||
|
||||
// Malformed html?
|
||||
const start = textPart.indexOf("<pre");
|
||||
if (start === -1) {
|
||||
text += textPart;
|
||||
continue;
|
||||
}
|
||||
const name = '<pre wp-pre-tag-' + i + '></pre>';
|
||||
preTags.push([name, textPart.substr(start) + '</pre>']);
|
||||
const name = "<pre wp-pre-tag-" + i + "></pre>";
|
||||
preTags.push([name, textPart.substr(start) + "</pre>"]);
|
||||
text += textPart.substr(0, start) + name;
|
||||
}
|
||||
text += lastText;
|
||||
}
|
||||
// Change multiple <br>s into two line breaks, which will turn into paragraphs.
|
||||
text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, '\n\n');
|
||||
const allBlocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)';
|
||||
|
||||
// Add a double line break above block-level opening tags.
|
||||
text = text.replace(new RegExp('(<' + allBlocks + '[\\s/>])', 'g'), '\n\n$1');
|
||||
|
||||
// Add a double line break below block-level closing tags.
|
||||
text = text.replace(new RegExp('(</' + allBlocks + '>)', 'g'), '$1\n\n');
|
||||
|
||||
// Standardize newline characters to "\n".
|
||||
text = text.replace(/\r\n|\r/g, '\n');
|
||||
|
||||
// Find newlines in all elements and add placeholders.
|
||||
text = replaceInHtmlTags(text, {
|
||||
'\n': ' <!-- wpnl --> '
|
||||
});
|
||||
|
||||
// Collapse line breaks before and after <option> elements so they don't get autop'd.
|
||||
if (text.indexOf('<option') !== -1) {
|
||||
text = text.replace(/\s*<option/g, '<option');
|
||||
text = text.replace(/<\/option>\s*/g, '</option>');
|
||||
text = text.replace(/<br\s*\/?>\s*<br\s*\/?>/g, "\n\n");
|
||||
const allBlocks = "(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|form|map|area|blockquote|address|math|style|p|h[1-6]|hr|fieldset|legend|section|article|aside|hgroup|header|footer|nav|figure|figcaption|details|menu|summary)";
|
||||
text = text.replace(
|
||||
new RegExp("(<" + allBlocks + "[\\s/>])", "g"),
|
||||
"\n\n$1"
|
||||
);
|
||||
text = text.replace(
|
||||
new RegExp("(</" + allBlocks + ">)", "g"),
|
||||
"$1\n\n"
|
||||
);
|
||||
text = text.replace(/\r\n|\r/g, "\n");
|
||||
text = replaceInHtmlTags(text, { "\n": " <!-- wpnl --> " });
|
||||
if (text.indexOf("<option") !== -1) {
|
||||
text = text.replace(/\s*<option/g, "<option");
|
||||
text = text.replace(/<\/option>\s*/g, "</option>");
|
||||
}
|
||||
|
||||
/*
|
||||
* Collapse line breaks inside <object> elements, before <param> and <embed> elements
|
||||
* so they don't get autop'd.
|
||||
*/
|
||||
if (text.indexOf('</object>') !== -1) {
|
||||
text = text.replace(/(<object[^>]*>)\s*/g, '$1');
|
||||
text = text.replace(/\s*<\/object>/g, '</object>');
|
||||
text = text.replace(/\s*(<\/?(?:param|embed)[^>]*>)\s*/g, '$1');
|
||||
if (text.indexOf("</object>") !== -1) {
|
||||
text = text.replace(/(<object[^>]*>)\s*/g, "$1");
|
||||
text = text.replace(/\s*<\/object>/g, "</object>");
|
||||
text = text.replace(/\s*(<\/?(?:param|embed)[^>]*>)\s*/g, "$1");
|
||||
}
|
||||
|
||||
/*
|
||||
* Collapse line breaks inside <audio> and <video> elements,
|
||||
* before and after <source> and <track> elements.
|
||||
*/
|
||||
if (text.indexOf('<source') !== -1 || text.indexOf('<track') !== -1) {
|
||||
text = text.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/g, '$1');
|
||||
text = text.replace(/\s*([<\[]\/(?:audio|video)[>\]])/g, '$1');
|
||||
text = text.replace(/\s*(<(?:source|track)[^>]*>)\s*/g, '$1');
|
||||
if (text.indexOf("<source") !== -1 || text.indexOf("<track") !== -1) {
|
||||
text = text.replace(/([<\[](?:audio|video)[^>\]]*[>\]])\s*/g, "$1");
|
||||
text = text.replace(/\s*([<\[]\/(?:audio|video)[>\]])/g, "$1");
|
||||
text = text.replace(/\s*(<(?:source|track)[^>]*>)\s*/g, "$1");
|
||||
}
|
||||
|
||||
// Collapse line breaks before and after <figcaption> elements.
|
||||
if (text.indexOf('<figcaption') !== -1) {
|
||||
text = text.replace(/\s*(<figcaption[^>]*>)/, '$1');
|
||||
text = text.replace(/<\/figcaption>\s*/, '</figcaption>');
|
||||
if (text.indexOf("<figcaption") !== -1) {
|
||||
text = text.replace(/\s*(<figcaption[^>]*>)/, "$1");
|
||||
text = text.replace(/<\/figcaption>\s*/, "</figcaption>");
|
||||
}
|
||||
|
||||
// Remove more than two contiguous line breaks.
|
||||
text = text.replace(/\n\n+/g, '\n\n');
|
||||
|
||||
// Split up the contents into an array of strings, separated by double line breaks.
|
||||
text = text.replace(/\n\n+/g, "\n\n");
|
||||
const texts = text.split(/\n\s*\n/).filter(Boolean);
|
||||
|
||||
// Reset text prior to rebuilding.
|
||||
text = '';
|
||||
|
||||
// Rebuild the content as a string, wrapping every bit with a <p>.
|
||||
texts.forEach(textPiece => {
|
||||
text += '<p>' + textPiece.replace(/^\n*|\n*$/g, '') + '</p>\n';
|
||||
text = "";
|
||||
texts.forEach((textPiece) => {
|
||||
text += "<p>" + textPiece.replace(/^\n*|\n*$/g, "") + "</p>\n";
|
||||
});
|
||||
|
||||
// Under certain strange conditions it could create a P of entirely whitespace.
|
||||
text = text.replace(/<p>\s*<\/p>/g, '');
|
||||
|
||||
// Add a closing <p> inside <div>, <address>, or <form> tag if missing.
|
||||
text = text.replace(/<p>([^<]+)<\/(div|address|form)>/g, '<p>$1</p></$2>');
|
||||
|
||||
// If an opening or closing block element tag is wrapped in a <p>, unwrap it.
|
||||
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
|
||||
|
||||
// In some cases <li> may get wrapped in <p>, fix them.
|
||||
text = text.replace(/<p>(<li.+?)<\/p>/g, '$1');
|
||||
|
||||
// If a <blockquote> is wrapped with a <p>, move it inside the <blockquote>.
|
||||
text = text.replace(/<p><blockquote([^>]*)>/gi, '<blockquote$1><p>');
|
||||
text = text.replace(/<\/blockquote><\/p>/g, '</p></blockquote>');
|
||||
|
||||
// If an opening or closing block element tag is preceded by an opening <p> tag, remove it.
|
||||
text = text.replace(new RegExp('<p>\\s*(</?' + allBlocks + '[^>]*>)', 'g'), '$1');
|
||||
|
||||
// If an opening or closing block element tag is followed by a closing <p> tag, remove it.
|
||||
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*</p>', 'g'), '$1');
|
||||
|
||||
// Optionally insert line breaks.
|
||||
text = text.replace(/<p>\s*<\/p>/g, "");
|
||||
text = text.replace(
|
||||
/<p>([^<]+)<\/(div|address|form)>/g,
|
||||
"<p>$1</p></$2>"
|
||||
);
|
||||
text = text.replace(
|
||||
new RegExp("<p>\\s*(</?" + allBlocks + "[^>]*>)\\s*</p>", "g"),
|
||||
"$1"
|
||||
);
|
||||
text = text.replace(/<p>(<li.+?)<\/p>/g, "$1");
|
||||
text = text.replace(/<p><blockquote([^>]*)>/gi, "<blockquote$1><p>");
|
||||
text = text.replace(/<\/blockquote><\/p>/g, "</p></blockquote>");
|
||||
text = text.replace(
|
||||
new RegExp("<p>\\s*(</?" + allBlocks + "[^>]*>)", "g"),
|
||||
"$1"
|
||||
);
|
||||
text = text.replace(
|
||||
new RegExp("(</?" + allBlocks + "[^>]*>)\\s*</p>", "g"),
|
||||
"$1"
|
||||
);
|
||||
if (br) {
|
||||
// Replace newlines that shouldn't be touched with a placeholder.
|
||||
text = text.replace(/<(script|style).*?<\/\\1>/g, match => match[0].replace(/\n/g, '<WPPreserveNewline />'));
|
||||
|
||||
// Normalize <br>
|
||||
text = text.replace(/<br>|<br\/>/g, '<br />');
|
||||
|
||||
// Replace any new line characters that aren't preceded by a <br /> with a <br />.
|
||||
text = text.replace(/(<br \/>)?\s*\n/g, (a, b) => b ? a : '<br />\n');
|
||||
|
||||
// Replace newline placeholders with newlines.
|
||||
text = text.replace(/<WPPreserveNewline \/>/g, '\n');
|
||||
text = text.replace(
|
||||
/<(script|style).*?<\/\\1>/g,
|
||||
(match) => match[0].replace(/\n/g, "<WPPreserveNewline />")
|
||||
);
|
||||
text = text.replace(/<br>|<br\/>/g, "<br />");
|
||||
text = text.replace(
|
||||
/(<br \/>)?\s*\n/g,
|
||||
(a, b) => b ? a : "<br />\n"
|
||||
);
|
||||
text = text.replace(/<WPPreserveNewline \/>/g, "\n");
|
||||
}
|
||||
|
||||
// If a <br /> tag is after an opening or closing block tag, remove it.
|
||||
text = text.replace(new RegExp('(</?' + allBlocks + '[^>]*>)\\s*<br />', 'g'), '$1');
|
||||
|
||||
// If a <br /> tag is before a subset of opening or closing block tags, remove it.
|
||||
text = text.replace(/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g, '$1');
|
||||
text = text.replace(/\n<\/p>$/g, '</p>');
|
||||
|
||||
// Replace placeholder <pre> tags with their original content.
|
||||
preTags.forEach(preTag => {
|
||||
text = text.replace(
|
||||
new RegExp("(</?" + allBlocks + "[^>]*>)\\s*<br />", "g"),
|
||||
"$1"
|
||||
);
|
||||
text = text.replace(
|
||||
/<br \/>(\s*<\/?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol)[^>]*>)/g,
|
||||
"$1"
|
||||
);
|
||||
text = text.replace(/\n<\/p>$/g, "</p>");
|
||||
preTags.forEach((preTag) => {
|
||||
const [name, original] = preTag;
|
||||
text = text.replace(name, original);
|
||||
});
|
||||
|
||||
// Restore newlines in all elements.
|
||||
if (-1 !== text.indexOf('<!-- wpnl -->')) {
|
||||
text = text.replace(/\s?<!-- wpnl -->\s?/g, '\n');
|
||||
if (-1 !== text.indexOf("<!-- wpnl -->")) {
|
||||
text = text.replace(/\s?<!-- wpnl -->\s?/g, "\n");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces `<p>` tags with two line breaks. "Opposite" of autop().
|
||||
*
|
||||
* Replaces `<p>` tags with two line breaks except where the `<p>` has attributes.
|
||||
* Unifies whitespace. Indents `<li>`, `<dt>` and `<dd>` for better readability.
|
||||
*
|
||||
* @param html The content from the editor.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { removep } from '@wordpress/autop';
|
||||
* removep( '<p>my text</p>' ); // "my text"
|
||||
* ```
|
||||
*
|
||||
* @return The content with stripped paragraph tags.
|
||||
*/
|
||||
function removep(html) {
|
||||
const blocklist = 'blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure';
|
||||
const blocklist1 = blocklist + '|div|p';
|
||||
const blocklist2 = blocklist + '|pre';
|
||||
const blocklist = "blockquote|ul|ol|li|dl|dt|dd|table|thead|tbody|tfoot|tr|th|td|h[1-6]|fieldset|figure";
|
||||
const blocklist1 = blocklist + "|div|p";
|
||||
const blocklist2 = blocklist + "|pre";
|
||||
const preserve = [];
|
||||
let preserveLinebreaks = false;
|
||||
let preserveBr = false;
|
||||
if (!html) {
|
||||
return '';
|
||||
return "";
|
||||
}
|
||||
|
||||
// Protect script and style tags.
|
||||
if (html.indexOf('<script') !== -1 || html.indexOf('<style') !== -1) {
|
||||
html = html.replace(/<(script|style)[^>]*>[\s\S]*?<\/\1>/g, match => {
|
||||
preserve.push(match);
|
||||
return '<wp-preserve>';
|
||||
});
|
||||
if (html.indexOf("<script") !== -1 || html.indexOf("<style") !== -1) {
|
||||
html = html.replace(
|
||||
/<(script|style)[^>]*>[\s\S]*?<\/\1>/g,
|
||||
(match) => {
|
||||
preserve.push(match);
|
||||
return "<wp-preserve>";
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Protect pre tags.
|
||||
if (html.indexOf('<pre') !== -1) {
|
||||
if (html.indexOf("<pre") !== -1) {
|
||||
preserveLinebreaks = true;
|
||||
html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, a => {
|
||||
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, '<wp-line-break>');
|
||||
a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, '<wp-line-break>');
|
||||
return a.replace(/\r?\n/g, '<wp-line-break>');
|
||||
html = html.replace(/<pre[^>]*>[\s\S]+?<\/pre>/g, (a) => {
|
||||
a = a.replace(/<br ?\/?>(\r\n|\n)?/g, "<wp-line-break>");
|
||||
a = a.replace(/<\/?p( [^>]*)?>(\r\n|\n)?/g, "<wp-line-break>");
|
||||
return a.replace(/\r?\n/g, "<wp-line-break>");
|
||||
});
|
||||
}
|
||||
|
||||
// Remove line breaks but keep <br> tags inside image captions.
|
||||
if (html.indexOf('[caption') !== -1) {
|
||||
if (html.indexOf("[caption") !== -1) {
|
||||
preserveBr = true;
|
||||
html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, a => {
|
||||
return a.replace(/<br([^>]*)>/g, '<wp-temp-br$1>').replace(/[\r\n\t]+/, '');
|
||||
html = html.replace(/\[caption[\s\S]+?\[\/caption\]/g, (a) => {
|
||||
return a.replace(/<br([^>]*)>/g, "<wp-temp-br$1>").replace(/[\r\n\t]+/, "");
|
||||
});
|
||||
}
|
||||
|
||||
// Normalize white space characters before and after block tags.
|
||||
html = html.replace(new RegExp('\\s*</(' + blocklist1 + ')>\\s*', 'g'), '</$1>\n');
|
||||
html = html.replace(new RegExp('\\s*<((?:' + blocklist1 + ')(?: [^>]*)?)>', 'g'), '\n<$1>');
|
||||
|
||||
// Mark </p> if it has any attributes.
|
||||
html = html.replace(/(<p [^>]+>[\s\S]*?)<\/p>/g, '$1</p#>');
|
||||
|
||||
// Preserve the first <p> inside a <div>.
|
||||
html = html.replace(/<div( [^>]*)?>\s*<p>/gi, '<div$1>\n\n');
|
||||
|
||||
// Remove paragraph tags.
|
||||
html = html.replace(/\s*<p>/gi, '');
|
||||
html = html.replace(/\s*<\/p>\s*/gi, '\n\n');
|
||||
|
||||
// Normalize white space chars and remove multiple line breaks.
|
||||
html = html.replace(/\n[\s\u00a0]+\n/g, '\n\n');
|
||||
|
||||
// Replace <br> tags with line breaks.
|
||||
html = html.replace(
|
||||
new RegExp("\\s*</(" + blocklist1 + ")>\\s*", "g"),
|
||||
"</$1>\n"
|
||||
);
|
||||
html = html.replace(
|
||||
new RegExp("\\s*<((?:" + blocklist1 + ")(?: [^>]*)?)>", "g"),
|
||||
"\n<$1>"
|
||||
);
|
||||
html = html.replace(/(<p [^>]+>[\s\S]*?)<\/p>/g, "$1</p#>");
|
||||
html = html.replace(/<div( [^>]*)?>\s*<p>/gi, "<div$1>\n\n");
|
||||
html = html.replace(/\s*<p>/gi, "");
|
||||
html = html.replace(/\s*<\/p>\s*/gi, "\n\n");
|
||||
html = html.replace(/\n[\s\u00a0]+\n/g, "\n\n");
|
||||
html = html.replace(/(\s*)<br ?\/?>\s*/gi, (_, space) => {
|
||||
if (space && space.indexOf('\n') !== -1) {
|
||||
return '\n\n';
|
||||
if (space && space.indexOf("\n") !== -1) {
|
||||
return "\n\n";
|
||||
}
|
||||
return '\n';
|
||||
return "\n";
|
||||
});
|
||||
|
||||
// Fix line breaks around <div>.
|
||||
html = html.replace(/\s*<div/g, '\n<div');
|
||||
html = html.replace(/<\/div>\s*/g, '</div>\n');
|
||||
|
||||
// Fix line breaks around caption shortcodes.
|
||||
html = html.replace(/\s*\[caption([^\[]+)\[\/caption\]\s*/gi, '\n\n[caption$1[/caption]\n\n');
|
||||
html = html.replace(/caption\]\n\n+\[caption/g, 'caption]\n\n[caption');
|
||||
|
||||
// Pad block elements tags with a line break.
|
||||
html = html.replace(new RegExp('\\s*<((?:' + blocklist2 + ')(?: [^>]*)?)\\s*>', 'g'), '\n<$1>');
|
||||
html = html.replace(new RegExp('\\s*</(' + blocklist2 + ')>\\s*', 'g'), '</$1>\n');
|
||||
|
||||
// Indent <li>, <dt> and <dd> tags.
|
||||
html = html.replace(/<((li|dt|dd)[^>]*)>/g, ' \t<$1>');
|
||||
|
||||
// Fix line breaks around <select> and <option>.
|
||||
if (html.indexOf('<option') !== -1) {
|
||||
html = html.replace(/\s*<option/g, '\n<option');
|
||||
html = html.replace(/\s*<\/select>/g, '\n</select>');
|
||||
html = html.replace(/\s*<div/g, "\n<div");
|
||||
html = html.replace(/<\/div>\s*/g, "</div>\n");
|
||||
html = html.replace(
|
||||
/\s*\[caption([^\[]+)\[\/caption\]\s*/gi,
|
||||
"\n\n[caption$1[/caption]\n\n"
|
||||
);
|
||||
html = html.replace(/caption\]\n\n+\[caption/g, "caption]\n\n[caption");
|
||||
html = html.replace(
|
||||
new RegExp("\\s*<((?:" + blocklist2 + ")(?: [^>]*)?)\\s*>", "g"),
|
||||
"\n<$1>"
|
||||
);
|
||||
html = html.replace(
|
||||
new RegExp("\\s*</(" + blocklist2 + ")>\\s*", "g"),
|
||||
"</$1>\n"
|
||||
);
|
||||
html = html.replace(/<((li|dt|dd)[^>]*)>/g, " <$1>");
|
||||
if (html.indexOf("<option") !== -1) {
|
||||
html = html.replace(/\s*<option/g, "\n<option");
|
||||
html = html.replace(/\s*<\/select>/g, "\n</select>");
|
||||
}
|
||||
|
||||
// Pad <hr> with two line breaks.
|
||||
if (html.indexOf('<hr') !== -1) {
|
||||
html = html.replace(/\s*<hr( [^>]*)?>\s*/g, '\n\n<hr$1>\n\n');
|
||||
if (html.indexOf("<hr") !== -1) {
|
||||
html = html.replace(/\s*<hr( [^>]*)?>\s*/g, "\n\n<hr$1>\n\n");
|
||||
}
|
||||
|
||||
// Remove line breaks in <object> tags.
|
||||
if (html.indexOf('<object') !== -1) {
|
||||
html = html.replace(/<object[\s\S]+?<\/object>/g, a => {
|
||||
return a.replace(/[\r\n]+/g, '');
|
||||
if (html.indexOf("<object") !== -1) {
|
||||
html = html.replace(/<object[\s\S]+?<\/object>/g, (a) => {
|
||||
return a.replace(/[\r\n]+/g, "");
|
||||
});
|
||||
}
|
||||
|
||||
// Unmark special paragraph closing tags.
|
||||
html = html.replace(/<\/p#>/g, '</p>\n');
|
||||
|
||||
// Pad remaining <p> tags whit a line break.
|
||||
html = html.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, '\n$1');
|
||||
|
||||
// Trim.
|
||||
html = html.replace(/^\s+/, '');
|
||||
html = html.replace(/[\s\u00a0]+$/, '');
|
||||
html = html.replace(/<\/p#>/g, "</p>\n");
|
||||
html = html.replace(/\s*(<p [^>]+>[\s\S]*?<\/p>)/g, "\n$1");
|
||||
html = html.replace(/^\s+/, "");
|
||||
html = html.replace(/[\s\u00a0]+$/, "");
|
||||
if (preserveLinebreaks) {
|
||||
html = html.replace(/<wp-line-break>/g, '\n');
|
||||
html = html.replace(/<wp-line-break>/g, "\n");
|
||||
}
|
||||
if (preserveBr) {
|
||||
html = html.replace(/<wp-temp-br([^>]*)>/g, '<br$1>');
|
||||
html = html.replace(/<wp-temp-br([^>]*)>/g, "<br$1>");
|
||||
}
|
||||
|
||||
// Restore preserved tags.
|
||||
if (preserve.length) {
|
||||
html = html.replace(/<wp-preserve>/g, () => {
|
||||
return preserve.shift();
|
||||
@@ -461,6 +293,7 @@ function removep(html) {
|
||||
return html;
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).autop = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
var __webpack_exports__ = {};
|
||||
/**
|
||||
* This file is intentionally left blank and acts as
|
||||
* a resolvable JavaScript entry point for this package.
|
||||
*/
|
||||
|
||||
(window.wp = window.wp || {}).baseStyles = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(window.wp=window.wp||{}).baseStyles={};
|
||||
Vendored
+7
-75
@@ -43,115 +43,47 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ isBlobURL: () => (/* binding */ isBlobURL),
|
||||
/* harmony export */ revokeBlobURL: () => (/* binding */ revokeBlobURL)
|
||||
/* harmony export */ });
|
||||
/* wp:polyfill */
|
||||
const cache = {};
|
||||
|
||||
/**
|
||||
* Create a blob URL from a file.
|
||||
*
|
||||
* @param file The file to create a blob URL for.
|
||||
*
|
||||
* @return The blob URL.
|
||||
*/
|
||||
function createBlobURL(file) {
|
||||
const url = window.URL.createObjectURL(file);
|
||||
cache[url] = file;
|
||||
return url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a file based on a blob URL. The file must have been created by
|
||||
* `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
|
||||
* `undefined`.
|
||||
*
|
||||
* @param url The blob URL.
|
||||
*
|
||||
* @return The file for the blob URL.
|
||||
*/
|
||||
function getBlobByURL(url) {
|
||||
return cache[url];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a blob type based on URL. The file must have been created by
|
||||
* `createBlobURL` and not removed by `revokeBlobURL`, otherwise it will return
|
||||
* `undefined`.
|
||||
*
|
||||
* @param url The blob URL.
|
||||
*
|
||||
* @return The blob type.
|
||||
*/
|
||||
function getBlobTypeByURL(url) {
|
||||
return getBlobByURL(url)?.type.split('/')[0]; // 0: media type , 1: file extension eg ( type: 'image/jpeg' ).
|
||||
return getBlobByURL(url)?.type.split("/")[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the resource and file cache from memory.
|
||||
*
|
||||
* @param url The blob URL.
|
||||
*/
|
||||
function revokeBlobURL(url) {
|
||||
if (cache[url]) {
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
delete cache[url];
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a url is a blob url.
|
||||
*
|
||||
* @param url The URL.
|
||||
*
|
||||
* @return Is the url a blob url?
|
||||
*/
|
||||
function isBlobURL(url) {
|
||||
if (!url || !url.indexOf) {
|
||||
return false;
|
||||
}
|
||||
return url.indexOf('blob:') === 0;
|
||||
return url.indexOf("blob:") === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Downloads a file, e.g., a text or readable stream, in the browser.
|
||||
* Appropriate for downloading smaller file sizes, e.g., < 5 MB.
|
||||
*
|
||||
* Example usage:
|
||||
*
|
||||
* ```js
|
||||
* const fileContent = JSON.stringify(
|
||||
* {
|
||||
* "title": "My Post",
|
||||
* },
|
||||
* null,
|
||||
* 2
|
||||
* );
|
||||
* const filename = 'file.json';
|
||||
*
|
||||
* downloadBlob( filename, fileContent, 'application/json' );
|
||||
* ```
|
||||
*
|
||||
* @param filename File name.
|
||||
* @param content File content (BufferSource | Blob | string).
|
||||
* @param contentType (Optional) File mime type. Default is `''`.
|
||||
*/
|
||||
function downloadBlob(filename, content, contentType = '') {
|
||||
function downloadBlob(filename, content, contentType = "") {
|
||||
if (!filename || !content) {
|
||||
return;
|
||||
}
|
||||
const file = new window.Blob([content], {
|
||||
type: contentType
|
||||
});
|
||||
const file = new window.Blob([content], { type: contentType });
|
||||
const url = window.URL.createObjectURL(file);
|
||||
const anchorElement = document.createElement('a');
|
||||
const anchorElement = document.createElement("a");
|
||||
anchorElement.href = url;
|
||||
anchorElement.download = filename;
|
||||
anchorElement.style.display = 'none';
|
||||
anchorElement.style.display = "none";
|
||||
document.body.appendChild(anchorElement);
|
||||
anchorElement.click();
|
||||
document.body.removeChild(anchorElement);
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).blob = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+674
-1058
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+32761
-42239
File diff suppressed because one or more lines are too long
+4
-2
File diff suppressed because one or more lines are too long
Vendored
+39190
-48227
File diff suppressed because one or more lines are too long
+2
-2
File diff suppressed because one or more lines are too long
+67
-307
@@ -38,106 +38,11 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ parse: () => (/* binding */ parse)
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* @type {string}
|
||||
*/
|
||||
let document;
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
let offset;
|
||||
/**
|
||||
* @type {ParsedBlock[]}
|
||||
*/
|
||||
let output;
|
||||
/**
|
||||
* @type {ParsedFrame[]}
|
||||
*/
|
||||
let stack;
|
||||
|
||||
/**
|
||||
* @typedef {Object|null} Attributes
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParsedBlock
|
||||
* @property {string|null} blockName Block name.
|
||||
* @property {Attributes} attrs Block attributes.
|
||||
* @property {ParsedBlock[]} innerBlocks Inner blocks.
|
||||
* @property {string} innerHTML Inner HTML.
|
||||
* @property {Array<string|null>} innerContent Inner content.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ParsedFrame
|
||||
* @property {ParsedBlock} block Block.
|
||||
* @property {number} tokenStart Token start.
|
||||
* @property {number} tokenLength Token length.
|
||||
* @property {number} prevOffset Previous offset.
|
||||
* @property {number|null} leadingHtmlStart Leading HTML start.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'no-more-tokens'|'void-block'|'block-opener'|'block-closer'} TokenType
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {[TokenType, string, Attributes, number, number]} Token
|
||||
*/
|
||||
|
||||
/**
|
||||
* Matches block comment delimiters
|
||||
*
|
||||
* While most of this pattern is straightforward the attribute parsing
|
||||
* incorporates a tricks to make sure we don't choke on specific input
|
||||
*
|
||||
* - since JavaScript has no possessive quantifier or atomic grouping
|
||||
* we are emulating it with a trick
|
||||
*
|
||||
* we want a possessive quantifier or atomic group to prevent backtracking
|
||||
* on the `}`s should we fail to match the remainder of the pattern
|
||||
*
|
||||
* we can emulate this with a positive lookahead and back reference
|
||||
* (a++)*c === ((?=(a+))\1)*c
|
||||
*
|
||||
* let's examine an example:
|
||||
* - /(a+)*c/.test('aaaaaaaaaaaaad') fails after over 49,000 steps
|
||||
* - /(a++)*c/.test('aaaaaaaaaaaaad') fails after 85 steps
|
||||
* - /(?>a+)*c/.test('aaaaaaaaaaaaad') fails after 126 steps
|
||||
*
|
||||
* this is because the possessive `++` and the atomic group `(?>)`
|
||||
* tell the engine that all those `a`s belong together as a single group
|
||||
* and so it won't split it up when stepping backwards to try and match
|
||||
*
|
||||
* if we use /((?=(a+))\1)*c/ then we get the same behavior as the atomic group
|
||||
* or possessive and prevent the backtracking because the `a+` is matched but
|
||||
* not captured. thus, we find the long string of `a`s and remember it, then
|
||||
* reference it as a whole unit inside our pattern
|
||||
*
|
||||
* @see http://instanceof.me/post/52245507631/regex-emulate-atomic-grouping-with-lookahead
|
||||
* @see http://blog.stevenlevithan.com/archives/mimic-atomic-groups
|
||||
* @see https://javascript.info/regexp-infinite-backtracking-problem
|
||||
*
|
||||
* once browsers reliably support atomic grouping or possessive
|
||||
* quantifiers natively we should remove this trick and simplify
|
||||
*
|
||||
* @type {RegExp}
|
||||
*
|
||||
* @since 3.8.0
|
||||
* @since 4.6.1 added optimization to prevent backtracking on attribute parsing
|
||||
*/
|
||||
const tokenizer = /<!--\s+(\/)?wp:([a-z][a-z0-9_-]*\/)?([a-z][a-z0-9_-]*)\s+({(?:(?=([^}]+|}+(?=})|(?!}\s+\/?-->)[^])*)\5|[^]*?)}\s+)?(\/)?-->/g;
|
||||
|
||||
/**
|
||||
* Constructs a block object.
|
||||
*
|
||||
* @param {string|null} blockName
|
||||
* @param {Attributes} attrs
|
||||
* @param {ParsedBlock[]} innerBlocks
|
||||
* @param {string} innerHTML
|
||||
* @param {string[]} innerContent
|
||||
* @return {ParsedBlock} The block object.
|
||||
*/
|
||||
function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
||||
return {
|
||||
blockName,
|
||||
@@ -147,27 +52,9 @@ function Block(blockName, attrs, innerBlocks, innerHTML, innerContent) {
|
||||
innerContent
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a freeform block object.
|
||||
*
|
||||
* @param {string} innerHTML
|
||||
* @return {ParsedBlock} The freeform block object.
|
||||
*/
|
||||
function Freeform(innerHTML) {
|
||||
return Block(null, {}, [], innerHTML, [innerHTML]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a frame object.
|
||||
*
|
||||
* @param {ParsedBlock} block
|
||||
* @param {number} tokenStart
|
||||
* @param {number} tokenLength
|
||||
* @param {number} prevOffset
|
||||
* @param {number|null} leadingHtmlStart
|
||||
* @return {ParsedFrame} The frame object.
|
||||
*/
|
||||
function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
||||
return {
|
||||
block,
|
||||
@@ -177,202 +64,101 @@ function Frame(block, tokenStart, tokenLength, prevOffset, leadingHtmlStart) {
|
||||
leadingHtmlStart
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Parser function, that converts input HTML into a block based structure.
|
||||
*
|
||||
* @param {string} doc The HTML document to parse.
|
||||
*
|
||||
* @example
|
||||
* Input post:
|
||||
* ```html
|
||||
* <!-- wp:columns {"columns":3} -->
|
||||
* <div class="wp-block-columns has-3-columns"><!-- wp:column -->
|
||||
* <div class="wp-block-column"><!-- wp:paragraph -->
|
||||
* <p>Left</p>
|
||||
* <!-- /wp:paragraph --></div>
|
||||
* <!-- /wp:column -->
|
||||
*
|
||||
* <!-- wp:column -->
|
||||
* <div class="wp-block-column"><!-- wp:paragraph -->
|
||||
* <p><strong>Middle</strong></p>
|
||||
* <!-- /wp:paragraph --></div>
|
||||
* <!-- /wp:column -->
|
||||
*
|
||||
* <!-- wp:column -->
|
||||
* <div class="wp-block-column"></div>
|
||||
* <!-- /wp:column --></div>
|
||||
* <!-- /wp:columns -->
|
||||
* ```
|
||||
*
|
||||
* Parsing code:
|
||||
* ```js
|
||||
* import { parse } from '@wordpress/block-serialization-default-parser';
|
||||
*
|
||||
* parse( post ) === [
|
||||
* {
|
||||
* blockName: "core/columns",
|
||||
* attrs: {
|
||||
* columns: 3
|
||||
* },
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/paragraph",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: "\n<p>Left</p>\n"
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* },
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [
|
||||
* {
|
||||
* blockName: "core/paragraph",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: "\n<p><strong>Middle</strong></p>\n"
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* },
|
||||
* {
|
||||
* blockName: "core/column",
|
||||
* attrs: null,
|
||||
* innerBlocks: [],
|
||||
* innerHTML: '\n<div class="wp-block-column"></div>\n'
|
||||
* }
|
||||
* ],
|
||||
* innerHTML: '\n<div class="wp-block-columns has-3-columns">\n\n\n\n</div>\n'
|
||||
* }
|
||||
* ];
|
||||
* ```
|
||||
* @return {ParsedBlock[]} A block-based representation of the input HTML.
|
||||
*/
|
||||
const parse = doc => {
|
||||
const parse = (doc) => {
|
||||
document = doc;
|
||||
offset = 0;
|
||||
output = [];
|
||||
stack = [];
|
||||
tokenizer.lastIndex = 0;
|
||||
do {
|
||||
// twiddle our thumbs
|
||||
} while (proceed());
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses the next token in the input document.
|
||||
*
|
||||
* @return {boolean} Returns true when there is more tokens to parse.
|
||||
*/
|
||||
function proceed() {
|
||||
const stackDepth = stack.length;
|
||||
const next = nextToken();
|
||||
const [tokenType, blockName, attrs, startOffset, tokenLength] = next;
|
||||
|
||||
// We may have some HTML soup before the next block.
|
||||
const leadingHtmlStart = startOffset > offset ? offset : null;
|
||||
switch (tokenType) {
|
||||
case 'no-more-tokens':
|
||||
// If not in a block then flush output.
|
||||
case "no-more-tokens":
|
||||
if (0 === stackDepth) {
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise we have a problem
|
||||
// This is an error
|
||||
// we have options
|
||||
// - treat it all as freeform text
|
||||
// - assume an implicit closer (easiest when not nesting)
|
||||
|
||||
// For the easy case we'll assume an implicit closer.
|
||||
if (1 === stackDepth) {
|
||||
addBlockFromStack();
|
||||
return false;
|
||||
}
|
||||
|
||||
// For the nested case where it's more difficult we'll
|
||||
// have to assume that multiple closers are missing
|
||||
// and so we'll collapse the whole stack piecewise.
|
||||
while (0 < stack.length) {
|
||||
addBlockFromStack();
|
||||
}
|
||||
return false;
|
||||
case 'void-block':
|
||||
// easy case is if we stumbled upon a void block
|
||||
// in the top-level of the document.
|
||||
case "void-block":
|
||||
if (0 === stackDepth) {
|
||||
if (null !== leadingHtmlStart) {
|
||||
output.push(Freeform(document.substr(leadingHtmlStart, startOffset - leadingHtmlStart)));
|
||||
output.push(
|
||||
Freeform(
|
||||
document.substr(
|
||||
leadingHtmlStart,
|
||||
startOffset - leadingHtmlStart
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
output.push(Block(blockName, attrs, [], '', []));
|
||||
output.push(Block(blockName, attrs, [], "", []));
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise we found an inner block.
|
||||
addInnerBlock(Block(blockName, attrs, [], '', []), startOffset, tokenLength);
|
||||
addInnerBlock(
|
||||
Block(blockName, attrs, [], "", []),
|
||||
startOffset,
|
||||
tokenLength
|
||||
);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
case 'block-opener':
|
||||
// Track all newly-opened blocks on the stack.
|
||||
stack.push(Frame(Block(blockName, attrs, [], '', []), startOffset, tokenLength, startOffset + tokenLength, leadingHtmlStart));
|
||||
case "block-opener":
|
||||
stack.push(
|
||||
Frame(
|
||||
Block(blockName, attrs, [], "", []),
|
||||
startOffset,
|
||||
tokenLength,
|
||||
startOffset + tokenLength,
|
||||
leadingHtmlStart
|
||||
)
|
||||
);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
case 'block-closer':
|
||||
// If we're missing an opener we're in trouble
|
||||
// This is an error.
|
||||
case "block-closer":
|
||||
if (0 === stackDepth) {
|
||||
// We have options
|
||||
// - assume an implicit opener
|
||||
// - assume _this_ is the opener
|
||||
// - give up and close out the document.
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we're not nesting then this is easy - close the block.
|
||||
if (1 === stackDepth) {
|
||||
addBlockFromStack(startOffset);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Otherwise we're nested and we have to close out the current
|
||||
// block and add it as a innerBlock to the parent.
|
||||
const stackTop = /** @type {ParsedFrame} */stack.pop();
|
||||
const html = document.substr(stackTop.prevOffset, startOffset - stackTop.prevOffset);
|
||||
const stackTop = stack.pop();
|
||||
const html = document.substr(
|
||||
stackTop.prevOffset,
|
||||
startOffset - stackTop.prevOffset
|
||||
);
|
||||
stackTop.block.innerHTML += html;
|
||||
stackTop.block.innerContent.push(html);
|
||||
stackTop.prevOffset = startOffset + tokenLength;
|
||||
addInnerBlock(stackTop.block, stackTop.tokenStart, stackTop.tokenLength, startOffset + tokenLength);
|
||||
addInnerBlock(
|
||||
stackTop.block,
|
||||
stackTop.tokenStart,
|
||||
stackTop.tokenLength,
|
||||
startOffset + tokenLength
|
||||
);
|
||||
offset = startOffset + tokenLength;
|
||||
return true;
|
||||
default:
|
||||
// This is an error.
|
||||
addFreeform();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse JSON if valid, otherwise return null
|
||||
*
|
||||
* Note that JSON coming from the block comment
|
||||
* delimiters is constrained to be an object
|
||||
* and cannot be things like `true` or `null`
|
||||
*
|
||||
* @param {string} input JSON input string to parse
|
||||
* @return {Object|null} parsed JSON if valid
|
||||
*/
|
||||
function parseJSON(input) {
|
||||
try {
|
||||
return JSON.parse(input);
|
||||
@@ -380,55 +166,38 @@ function parseJSON(input) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds the next token in the document.
|
||||
*
|
||||
* @return {Token} The next matched token.
|
||||
*/
|
||||
function nextToken() {
|
||||
// Aye the magic
|
||||
// we're using a single RegExp to tokenize the block comment delimiters
|
||||
// we're also using a trick here because the only difference between a
|
||||
// block opener and a block closer is the leading `/` before `wp:` (and
|
||||
// a closer has no attributes). we can trap them both and process the
|
||||
// match back in JavaScript to see which one it was.
|
||||
const matches = tokenizer.exec(document);
|
||||
|
||||
// We have no more tokens.
|
||||
if (null === matches) {
|
||||
return ['no-more-tokens', '', null, 0, 0];
|
||||
return ["no-more-tokens", "", null, 0, 0];
|
||||
}
|
||||
const startedAt = matches.index;
|
||||
const [match, closerMatch, namespaceMatch, nameMatch, attrsMatch /* Internal/unused. */,, voidMatch] = matches;
|
||||
const [
|
||||
match,
|
||||
closerMatch,
|
||||
namespaceMatch,
|
||||
nameMatch,
|
||||
attrsMatch,
|
||||
,
|
||||
voidMatch
|
||||
] = matches;
|
||||
const length = match.length;
|
||||
const isCloser = !!closerMatch;
|
||||
const isVoid = !!voidMatch;
|
||||
const namespace = namespaceMatch || 'core/';
|
||||
const namespace = namespaceMatch || "core/";
|
||||
const name = namespace + nameMatch;
|
||||
const hasAttrs = !!attrsMatch;
|
||||
const attrs = hasAttrs ? parseJSON(attrsMatch) : {};
|
||||
|
||||
// This state isn't allowed
|
||||
// This is an error.
|
||||
if (isCloser && (isVoid || hasAttrs)) {
|
||||
// We can ignore them since they don't hurt anything
|
||||
// we may warn against this at some point or reject it.
|
||||
}
|
||||
if (isVoid) {
|
||||
return ['void-block', name, attrs, startedAt, length];
|
||||
return ["void-block", name, attrs, startedAt, length];
|
||||
}
|
||||
if (isCloser) {
|
||||
return ['block-closer', name, null, startedAt, length];
|
||||
return ["block-closer", name, null, startedAt, length];
|
||||
}
|
||||
return ['block-opener', name, attrs, startedAt, length];
|
||||
return ["block-opener", name, attrs, startedAt, length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a freeform block to the output.
|
||||
*
|
||||
* @param {number} [rawLength]
|
||||
*/
|
||||
function addFreeform(rawLength) {
|
||||
const length = rawLength ? rawLength : document.length - offset;
|
||||
if (0 === length) {
|
||||
@@ -436,19 +205,13 @@ function addFreeform(rawLength) {
|
||||
}
|
||||
output.push(Freeform(document.substr(offset, length)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds inner block to the parent block.
|
||||
*
|
||||
* @param {ParsedBlock} block
|
||||
* @param {number} tokenStart
|
||||
* @param {number} tokenLength
|
||||
* @param {number} [lastOffset]
|
||||
*/
|
||||
function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
||||
const parent = stack[stack.length - 1];
|
||||
parent.block.innerBlocks.push(block);
|
||||
const html = document.substr(parent.prevOffset, tokenStart - parent.prevOffset);
|
||||
const html = document.substr(
|
||||
parent.prevOffset,
|
||||
tokenStart - parent.prevOffset
|
||||
);
|
||||
if (html) {
|
||||
parent.block.innerHTML += html;
|
||||
parent.block.innerContent.push(html);
|
||||
@@ -456,30 +219,27 @@ function addInnerBlock(block, tokenStart, tokenLength, lastOffset) {
|
||||
parent.block.innerContent.push(null);
|
||||
parent.prevOffset = lastOffset ? lastOffset : tokenStart + tokenLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds block from the stack to the output.
|
||||
*
|
||||
* @param {number} [endOffset]
|
||||
*/
|
||||
function addBlockFromStack(endOffset) {
|
||||
const {
|
||||
block,
|
||||
leadingHtmlStart,
|
||||
prevOffset,
|
||||
tokenStart
|
||||
} = /** @type {ParsedFrame} */stack.pop();
|
||||
const { block, leadingHtmlStart, prevOffset, tokenStart } = stack.pop();
|
||||
const html = endOffset ? document.substr(prevOffset, endOffset - prevOffset) : document.substr(prevOffset);
|
||||
if (html) {
|
||||
block.innerHTML += html;
|
||||
block.innerContent.push(html);
|
||||
}
|
||||
if (null !== leadingHtmlStart) {
|
||||
output.push(Freeform(document.substr(leadingHtmlStart, tokenStart - leadingHtmlStart)));
|
||||
output.push(
|
||||
Freeform(
|
||||
document.substr(
|
||||
leadingHtmlStart,
|
||||
tokenStart - leadingHtmlStart
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
output.push(block);
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).blockSerializationDefaultParser = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1906
-5451
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+343
-632
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+24080
-22210
File diff suppressed because one or more lines are too long
+4
-4
File diff suppressed because one or more lines are too long
Vendored
+734
-2128
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+401
-409
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+5095
-6754
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1210
-1450
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+20
-116
@@ -68,152 +68,56 @@ const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// ./node_modules/@wordpress/data-controls/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Dispatches a control action for triggering an api fetch call.
|
||||
*
|
||||
* @param {Object} request Arguments for the fetch request.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { apiFetch } from '@wordpress/data-controls';
|
||||
*
|
||||
* // Action generator using apiFetch
|
||||
* export function* myAction() {
|
||||
* const path = '/v2/my-api/items';
|
||||
* const items = yield apiFetch( { path } );
|
||||
* // do something with the items.
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return {Object} The control descriptor.
|
||||
*/
|
||||
function apiFetch(request) {
|
||||
return {
|
||||
type: 'API_FETCH',
|
||||
type: "API_FETCH",
|
||||
request
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for resolving a selector in a registered data store.
|
||||
* Alias for the `resolveSelect` built-in control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param selectorName The selector name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function build_module_select(storeNameOrDescriptor, selectorName, ...args) {
|
||||
external_wp_deprecated_default()('`select` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `resolveSelect` control in `@wordpress/data`'
|
||||
external_wp_deprecated_default()("`select` control in `@wordpress/data-controls`", {
|
||||
since: "5.7",
|
||||
alternative: "built-in `resolveSelect` control in `@wordpress/data`"
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.resolveSelect(storeNameOrDescriptor, selectorName, ...args);
|
||||
return external_wp_data_namespaceObject.controls.resolveSelect(
|
||||
storeNameOrDescriptor,
|
||||
selectorName,
|
||||
...args
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for calling a selector in a registered data store.
|
||||
* Alias for the `select` built-in control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param selectorName The selector name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function syncSelect(storeNameOrDescriptor, selectorName, ...args) {
|
||||
external_wp_deprecated_default()('`syncSelect` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `select` control in `@wordpress/data`'
|
||||
external_wp_deprecated_default()("`syncSelect` control in `@wordpress/data-controls`", {
|
||||
since: "5.7",
|
||||
alternative: "built-in `select` control in `@wordpress/data`"
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.select(storeNameOrDescriptor, selectorName, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Control for dispatching an action in a registered data store.
|
||||
* Alias for the `dispatch` control in the `@wordpress/data` package.
|
||||
*
|
||||
* @param storeNameOrDescriptor The store object or identifier.
|
||||
* @param actionName The action name.
|
||||
* @param args Arguments passed without change to the `@wordpress/data` control.
|
||||
*/
|
||||
function dispatch(storeNameOrDescriptor, actionName, ...args) {
|
||||
external_wp_deprecated_default()('`dispatch` control in `@wordpress/data-controls`', {
|
||||
since: '5.7',
|
||||
alternative: 'built-in `dispatch` control in `@wordpress/data`'
|
||||
external_wp_deprecated_default()("`dispatch` control in `@wordpress/data-controls`", {
|
||||
since: "5.7",
|
||||
alternative: "built-in `dispatch` control in `@wordpress/data`"
|
||||
});
|
||||
return external_wp_data_namespaceObject.controls.dispatch(storeNameOrDescriptor, actionName, ...args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches a control action for awaiting on a promise to be resolved.
|
||||
*
|
||||
* @param {Object} promise Promise to wait for.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __unstableAwaitPromise } from '@wordpress/data-controls';
|
||||
*
|
||||
* // Action generator using apiFetch
|
||||
* export function* myAction() {
|
||||
* const promise = getItemsAsync();
|
||||
* const items = yield __unstableAwaitPromise( promise );
|
||||
* // do something with the items.
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @return {Object} The control descriptor.
|
||||
*/
|
||||
const __unstableAwaitPromise = function (promise) {
|
||||
const __unstableAwaitPromise = function(promise) {
|
||||
return {
|
||||
type: 'AWAIT_PROMISE',
|
||||
type: "AWAIT_PROMISE",
|
||||
promise
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* The default export is what you use to register the controls with your custom
|
||||
* store.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // WordPress dependencies
|
||||
* import { controls } from '@wordpress/data-controls';
|
||||
* import { registerStore } from '@wordpress/data';
|
||||
*
|
||||
* // Internal dependencies
|
||||
* import reducer from './reducer';
|
||||
* import * as selectors from './selectors';
|
||||
* import * as actions from './actions';
|
||||
* import * as resolvers from './resolvers';
|
||||
*
|
||||
* registerStore( 'my-custom-store', {
|
||||
* reducer,
|
||||
* controls,
|
||||
* actions,
|
||||
* selectors,
|
||||
* resolvers,
|
||||
* } );
|
||||
* ```
|
||||
* @return {Object} An object for registering the default controls with the
|
||||
* store.
|
||||
*/
|
||||
const controls = {
|
||||
AWAIT_PROMISE({
|
||||
promise
|
||||
}) {
|
||||
AWAIT_PROMISE({ promise }) {
|
||||
return promise;
|
||||
},
|
||||
API_FETCH({
|
||||
request
|
||||
}) {
|
||||
API_FETCH({ request }) {
|
||||
return external_wp_apiFetch_default()(request);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).dataControls = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+649
-2104
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+220
-437
@@ -1058,6 +1058,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
||||
}));
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4040:
|
||||
/***/ ((module) => {
|
||||
|
||||
"use strict";
|
||||
module.exports = window["wp"]["deprecated"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 5537:
|
||||
@@ -1075,6 +1083,13 @@ moment.tz.load(__webpack_require__(1681));
|
||||
"use strict";
|
||||
module.exports = window["moment"];
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7140:
|
||||
/***/ (() => {
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
@@ -1149,180 +1164,123 @@ var __webpack_exports__ = {};
|
||||
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
|
||||
(() => {
|
||||
"use strict";
|
||||
// ESM COMPAT FLAG
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
__experimentalGetSettings: () => (/* binding */ __experimentalGetSettings),
|
||||
date: () => (/* binding */ date),
|
||||
dateI18n: () => (/* binding */ dateI18n),
|
||||
format: () => (/* binding */ format),
|
||||
getDate: () => (/* binding */ getDate),
|
||||
getSettings: () => (/* binding */ getSettings),
|
||||
gmdate: () => (/* binding */ gmdate),
|
||||
gmdateI18n: () => (/* binding */ gmdateI18n),
|
||||
humanTimeDiff: () => (/* binding */ humanTimeDiff),
|
||||
isInTheFuture: () => (/* binding */ isInTheFuture),
|
||||
setSettings: () => (/* binding */ setSettings)
|
||||
});
|
||||
|
||||
// EXTERNAL MODULE: external "moment"
|
||||
var external_moment_ = __webpack_require__(6154);
|
||||
var external_moment_default = /*#__PURE__*/__webpack_require__.n(external_moment_);
|
||||
// EXTERNAL MODULE: ./node_modules/moment-timezone/moment-timezone.js
|
||||
var moment_timezone = __webpack_require__(3849);
|
||||
// EXTERNAL MODULE: ./node_modules/moment-timezone/moment-timezone-utils.js
|
||||
var moment_timezone_utils = __webpack_require__(1685);
|
||||
;// external ["wp","deprecated"]
|
||||
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// ./node_modules/@wordpress/date/build-module/index.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ __experimentalGetSettings: () => (/* binding */ __experimentalGetSettings),
|
||||
/* harmony export */ date: () => (/* binding */ date),
|
||||
/* harmony export */ dateI18n: () => (/* binding */ dateI18n),
|
||||
/* harmony export */ format: () => (/* binding */ format),
|
||||
/* harmony export */ getDate: () => (/* binding */ getDate),
|
||||
/* harmony export */ getSettings: () => (/* binding */ getSettings),
|
||||
/* harmony export */ gmdate: () => (/* binding */ gmdate),
|
||||
/* harmony export */ gmdateI18n: () => (/* binding */ gmdateI18n),
|
||||
/* harmony export */ humanTimeDiff: () => (/* binding */ humanTimeDiff),
|
||||
/* harmony export */ isInTheFuture: () => (/* binding */ isInTheFuture),
|
||||
/* harmony export */ setSettings: () => (/* binding */ setSettings)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(6154);
|
||||
/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony import */ var moment_timezone_moment_timezone__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3849);
|
||||
/* harmony import */ var moment_timezone_moment_timezone__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(moment_timezone_moment_timezone__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var moment_timezone_moment_timezone_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(1685);
|
||||
/* harmony import */ var moment_timezone_moment_timezone_utils__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(moment_timezone_moment_timezone_utils__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _wordpress_deprecated__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4040);
|
||||
/* harmony import */ var _wordpress_deprecated__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_deprecated__WEBPACK_IMPORTED_MODULE_3__);
|
||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7140);
|
||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_4__);
|
||||
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
||||
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_4__) if(["default","__experimentalGetSettings","date","dateI18n","format","getDate","getSettings","gmdate","gmdateI18n","humanTimeDiff","isInTheFuture","setSettings"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _types__WEBPACK_IMPORTED_MODULE_4__[__WEBPACK_IMPORT_KEY__]
|
||||
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {import('moment').Moment} Moment */
|
||||
/** @typedef {import('moment').LocaleSpecification} MomentLocaleSpecification */
|
||||
|
||||
/**
|
||||
* @typedef MeridiemConfig
|
||||
* @property {string} am Lowercase AM.
|
||||
* @property {string} AM Uppercase AM.
|
||||
* @property {string} pm Lowercase PM.
|
||||
* @property {string} PM Uppercase PM.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef FormatsConfig
|
||||
* @property {string} time Time format.
|
||||
* @property {string} date Date format.
|
||||
* @property {string} datetime Datetime format.
|
||||
* @property {string} datetimeAbbreviated Abbreviated datetime format.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef TimezoneConfig
|
||||
* @property {string} offset Offset setting.
|
||||
* @property {string} offsetFormatted Offset setting with decimals formatted to minutes.
|
||||
* @property {string} string The timezone as a string (e.g., `'America/Los_Angeles'`).
|
||||
* @property {string} abbr Abbreviation for the timezone.
|
||||
*/
|
||||
|
||||
/* eslint-disable jsdoc/valid-types */
|
||||
/**
|
||||
* @typedef L10nSettings
|
||||
* @property {string} locale Moment locale.
|
||||
* @property {MomentLocaleSpecification['months']} months Locale months.
|
||||
* @property {MomentLocaleSpecification['monthsShort']} monthsShort Locale months short.
|
||||
* @property {MomentLocaleSpecification['weekdays']} weekdays Locale weekdays.
|
||||
* @property {MomentLocaleSpecification['weekdaysShort']} weekdaysShort Locale weekdays short.
|
||||
* @property {MeridiemConfig} meridiem Meridiem config.
|
||||
* @property {MomentLocaleSpecification['relativeTime']} relative Relative time config.
|
||||
* @property {0|1|2|3|4|5|6} startOfWeek Day that the week starts on.
|
||||
*/
|
||||
/* eslint-enable jsdoc/valid-types */
|
||||
|
||||
/**
|
||||
* @typedef DateSettings
|
||||
* @property {L10nSettings} l10n Localization settings.
|
||||
* @property {FormatsConfig} formats Date/time formats config.
|
||||
* @property {TimezoneConfig} timezone Timezone settings.
|
||||
*/
|
||||
|
||||
const WP_ZONE = 'WP';
|
||||
|
||||
// This regular expression tests positive for UTC offsets as described in ISO 8601.
|
||||
// See: https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
|
||||
const WP_ZONE = "WP";
|
||||
const VALID_UTC_OFFSET = /^[+-][0-1][0-9](:?[0-9][0-9])?$/;
|
||||
|
||||
// Changes made here will likely need to be synced with Core in the file
|
||||
// src/wp-includes/script-loader.php in `wp_default_packages_inline_scripts()`.
|
||||
/** @type {DateSettings} */
|
||||
let settings = {
|
||||
l10n: {
|
||||
locale: 'en',
|
||||
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||
weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
|
||||
meridiem: {
|
||||
am: 'am',
|
||||
pm: 'pm',
|
||||
AM: 'AM',
|
||||
PM: 'PM'
|
||||
},
|
||||
locale: "en",
|
||||
months: [
|
||||
"January",
|
||||
"February",
|
||||
"March",
|
||||
"April",
|
||||
"May",
|
||||
"June",
|
||||
"July",
|
||||
"August",
|
||||
"September",
|
||||
"October",
|
||||
"November",
|
||||
"December"
|
||||
],
|
||||
monthsShort: [
|
||||
"Jan",
|
||||
"Feb",
|
||||
"Mar",
|
||||
"Apr",
|
||||
"May",
|
||||
"Jun",
|
||||
"Jul",
|
||||
"Aug",
|
||||
"Sep",
|
||||
"Oct",
|
||||
"Nov",
|
||||
"Dec"
|
||||
],
|
||||
weekdays: [
|
||||
"Sunday",
|
||||
"Monday",
|
||||
"Tuesday",
|
||||
"Wednesday",
|
||||
"Thursday",
|
||||
"Friday",
|
||||
"Saturday"
|
||||
],
|
||||
weekdaysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
meridiem: { am: "am", pm: "pm", AM: "AM", PM: "PM" },
|
||||
relative: {
|
||||
future: '%s from now',
|
||||
past: '%s ago',
|
||||
s: 'a few seconds',
|
||||
ss: '%d seconds',
|
||||
m: 'a minute',
|
||||
mm: '%d minutes',
|
||||
h: 'an hour',
|
||||
hh: '%d hours',
|
||||
d: 'a day',
|
||||
dd: '%d days',
|
||||
M: 'a month',
|
||||
MM: '%d months',
|
||||
y: 'a year',
|
||||
yy: '%d years'
|
||||
future: "%s from now",
|
||||
past: "%s ago",
|
||||
s: "a few seconds",
|
||||
ss: "%d seconds",
|
||||
m: "a minute",
|
||||
mm: "%d minutes",
|
||||
h: "an hour",
|
||||
hh: "%d hours",
|
||||
d: "a day",
|
||||
dd: "%d days",
|
||||
M: "a month",
|
||||
MM: "%d months",
|
||||
y: "a year",
|
||||
yy: "%d years"
|
||||
},
|
||||
startOfWeek: 0
|
||||
},
|
||||
formats: {
|
||||
time: 'g: i a',
|
||||
date: 'F j, Y',
|
||||
datetime: 'F j, Y g: i a',
|
||||
datetimeAbbreviated: 'M j, Y g: i a'
|
||||
time: "g: i a",
|
||||
date: "F j, Y",
|
||||
datetime: "F j, Y g: i a",
|
||||
datetimeAbbreviated: "M j, Y g: i a"
|
||||
},
|
||||
timezone: {
|
||||
offset: '0',
|
||||
offsetFormatted: '0',
|
||||
string: '',
|
||||
abbr: ''
|
||||
}
|
||||
timezone: { offset: "0", offsetFormatted: "0", string: "", abbr: "" }
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a locale to moment, using the format supplied by `wp_localize_script()`.
|
||||
*
|
||||
* @param {DateSettings} dateSettings Settings, including locale data.
|
||||
*/
|
||||
function setSettings(dateSettings) {
|
||||
settings = dateSettings;
|
||||
setupWPTimezone();
|
||||
|
||||
// Does moment already have a locale with the right name?
|
||||
if (external_moment_default().locales().includes(dateSettings.l10n.locale)) {
|
||||
// Is that locale misconfigured, e.g. because we are on a site running
|
||||
// WordPress < 6.0?
|
||||
if (external_moment_default().localeData(dateSettings.l10n.locale).longDateFormat('LTS') === null) {
|
||||
// Delete the misconfigured locale.
|
||||
// @ts-ignore Type definitions are incorrect - null is permitted.
|
||||
external_moment_default().defineLocale(dateSettings.l10n.locale, null);
|
||||
if (moment__WEBPACK_IMPORTED_MODULE_0___default().locales().includes(dateSettings.l10n.locale)) {
|
||||
if (moment__WEBPACK_IMPORTED_MODULE_0___default().localeData(dateSettings.l10n.locale).longDateFormat("LTS") === null) {
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().defineLocale(dateSettings.l10n.locale, null);
|
||||
} else {
|
||||
// We have a properly configured locale, so no need to create one.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// defineLocale() will modify the current locale, so back it up.
|
||||
const currentLocale = external_moment_default().locale();
|
||||
|
||||
// Create locale.
|
||||
external_moment_default().defineLocale(dateSettings.l10n.locale, {
|
||||
const currentLocale = moment__WEBPACK_IMPORTED_MODULE_0___default().locale();
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().defineLocale(dateSettings.l10n.locale, {
|
||||
// Inherit anything missing from English. We don't load
|
||||
// moment-with-locales.js so English is all there is.
|
||||
parentLocale: 'en',
|
||||
parentLocale: "en",
|
||||
months: dateSettings.l10n.months,
|
||||
monthsShort: dateSettings.l10n.monthsShort,
|
||||
weekdays: dateSettings.l10n.weekdays,
|
||||
@@ -1335,144 +1293,96 @@ function setSettings(dateSettings) {
|
||||
},
|
||||
longDateFormat: {
|
||||
LT: dateSettings.formats.time,
|
||||
LTS: external_moment_default().localeData('en').longDateFormat('LTS'),
|
||||
L: external_moment_default().localeData('en').longDateFormat('L'),
|
||||
LTS: moment__WEBPACK_IMPORTED_MODULE_0___default().localeData("en").longDateFormat("LTS"),
|
||||
L: moment__WEBPACK_IMPORTED_MODULE_0___default().localeData("en").longDateFormat("L"),
|
||||
LL: dateSettings.formats.date,
|
||||
LLL: dateSettings.formats.datetime,
|
||||
LLLL: external_moment_default().localeData('en').longDateFormat('LLLL')
|
||||
LLLL: moment__WEBPACK_IMPORTED_MODULE_0___default().localeData("en").longDateFormat("LLLL")
|
||||
},
|
||||
// From human_time_diff?
|
||||
// Set to `(number, withoutSuffix, key, isFuture) => {}` instead.
|
||||
relativeTime: dateSettings.l10n.relative
|
||||
});
|
||||
|
||||
// Restore the locale to what it was.
|
||||
external_moment_default().locale(currentLocale);
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().locale(currentLocale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently defined date settings.
|
||||
*
|
||||
* @return {DateSettings} Settings, including locale data.
|
||||
*/
|
||||
function getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently defined date settings.
|
||||
*
|
||||
* @deprecated
|
||||
* @return {DateSettings} Settings, including locale data.
|
||||
*/
|
||||
function __experimentalGetSettings() {
|
||||
external_wp_deprecated_default()('wp.date.__experimentalGetSettings', {
|
||||
since: '6.1',
|
||||
alternative: 'wp.date.getSettings'
|
||||
_wordpress_deprecated__WEBPACK_IMPORTED_MODULE_3___default()("wp.date.__experimentalGetSettings", {
|
||||
since: "6.1",
|
||||
alternative: "wp.date.getSettings"
|
||||
});
|
||||
return getSettings();
|
||||
}
|
||||
function setupWPTimezone() {
|
||||
// Get the current timezone settings from the WP timezone string.
|
||||
const currentTimezone = external_moment_default().tz.zone(settings.timezone.string);
|
||||
|
||||
// Check to see if we have a valid TZ data, if so, use it for the custom WP_ZONE timezone, otherwise just use the offset.
|
||||
const currentTimezone = moment__WEBPACK_IMPORTED_MODULE_0___default().tz.zone(settings.timezone.string);
|
||||
if (currentTimezone) {
|
||||
// Create WP timezone based off settings.timezone.string. We need to include the additional data so that we
|
||||
// don't lose information about daylight savings time and other items.
|
||||
// See https://github.com/WordPress/gutenberg/pull/48083
|
||||
external_moment_default().tz.add(external_moment_default().tz.pack({
|
||||
name: WP_ZONE,
|
||||
abbrs: currentTimezone.abbrs,
|
||||
untils: currentTimezone.untils,
|
||||
offsets: currentTimezone.offsets
|
||||
}));
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().tz.add(
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().tz.pack({
|
||||
name: WP_ZONE,
|
||||
abbrs: currentTimezone.abbrs,
|
||||
untils: currentTimezone.untils,
|
||||
offsets: currentTimezone.offsets
|
||||
})
|
||||
);
|
||||
} else {
|
||||
// Create WP timezone based off dateSettings.
|
||||
external_moment_default().tz.add(external_moment_default().tz.pack({
|
||||
name: WP_ZONE,
|
||||
abbrs: [WP_ZONE],
|
||||
untils: [null],
|
||||
offsets: [-settings.timezone.offset * 60 || 0]
|
||||
}));
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().tz.add(
|
||||
moment__WEBPACK_IMPORTED_MODULE_0___default().tz.pack({
|
||||
name: WP_ZONE,
|
||||
abbrs: [WP_ZONE],
|
||||
untils: [null],
|
||||
offsets: [-settings.timezone.offset * 60 || 0]
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Date constants.
|
||||
/**
|
||||
* Number of seconds in one minute.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const MINUTE_IN_SECONDS = 60;
|
||||
/**
|
||||
* Number of minutes in one hour.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const HOUR_IN_MINUTES = 60;
|
||||
/**
|
||||
* Number of seconds in one hour.
|
||||
*
|
||||
* @type {number}
|
||||
*/
|
||||
const HOUR_IN_SECONDS = 60 * MINUTE_IN_SECONDS;
|
||||
|
||||
/**
|
||||
* Map of PHP formats to Moment.js formats.
|
||||
*
|
||||
* These are used internally by {@link wp.date.format}, and are either
|
||||
* a string representing the corresponding Moment.js format code, or a
|
||||
* function which returns the formatted string.
|
||||
*
|
||||
* This should only be used through {@link wp.date.format}, not
|
||||
* directly.
|
||||
*/
|
||||
const formatMap = {
|
||||
// Day.
|
||||
d: 'DD',
|
||||
D: 'ddd',
|
||||
j: 'D',
|
||||
l: 'dddd',
|
||||
N: 'E',
|
||||
d: "DD",
|
||||
D: "ddd",
|
||||
j: "D",
|
||||
l: "dddd",
|
||||
N: "E",
|
||||
/**
|
||||
* Gets the ordinal suffix.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
S(momentDate) {
|
||||
// Do - D.
|
||||
const num = momentDate.format('D');
|
||||
const withOrdinal = momentDate.format('Do');
|
||||
return withOrdinal.replace(num, '');
|
||||
const num = momentDate.format("D");
|
||||
const withOrdinal = momentDate.format("Do");
|
||||
return withOrdinal.replace(num, "");
|
||||
},
|
||||
w: 'd',
|
||||
w: "d",
|
||||
/**
|
||||
* Gets the day of the year (zero-indexed).
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
z(momentDate) {
|
||||
// DDD - 1.
|
||||
return (parseInt(momentDate.format('DDD'), 10) - 1).toString();
|
||||
return (parseInt(momentDate.format("DDD"), 10) - 1).toString();
|
||||
},
|
||||
// Week.
|
||||
W: 'W',
|
||||
W: "W",
|
||||
// Month.
|
||||
F: 'MMMM',
|
||||
m: 'MM',
|
||||
M: 'MMM',
|
||||
n: 'M',
|
||||
F: "MMMM",
|
||||
m: "MM",
|
||||
M: "MMM",
|
||||
n: "M",
|
||||
/**
|
||||
* Gets the days in the month.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {number} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
t(momentDate) {
|
||||
return momentDate.daysInMonth();
|
||||
@@ -1481,273 +1391,153 @@ const formatMap = {
|
||||
/**
|
||||
* Gets whether the current year is a leap year.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
L(momentDate) {
|
||||
return momentDate.isLeapYear() ? '1' : '0';
|
||||
return momentDate.isLeapYear() ? "1" : "0";
|
||||
},
|
||||
o: 'GGGG',
|
||||
Y: 'YYYY',
|
||||
y: 'YY',
|
||||
o: "GGGG",
|
||||
Y: "YYYY",
|
||||
y: "YY",
|
||||
// Time.
|
||||
a: 'a',
|
||||
A: 'A',
|
||||
a: "a",
|
||||
A: "A",
|
||||
/**
|
||||
* Gets the current time in Swatch Internet Time (.beats).
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {number} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
B(momentDate) {
|
||||
const timezoned = external_moment_default()(momentDate).utcOffset(60);
|
||||
const seconds = parseInt(timezoned.format('s'), 10),
|
||||
minutes = parseInt(timezoned.format('m'), 10),
|
||||
hours = parseInt(timezoned.format('H'), 10);
|
||||
return parseInt(((seconds + minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS) / 86.4).toString(), 10);
|
||||
const timezoned = moment__WEBPACK_IMPORTED_MODULE_0___default()(momentDate).utcOffset(60);
|
||||
const seconds = parseInt(timezoned.format("s"), 10), minutes = parseInt(timezoned.format("m"), 10), hours = parseInt(timezoned.format("H"), 10);
|
||||
return parseInt(
|
||||
((seconds + minutes * MINUTE_IN_SECONDS + hours * HOUR_IN_SECONDS) / 86.4).toString(),
|
||||
10
|
||||
);
|
||||
},
|
||||
g: 'h',
|
||||
G: 'H',
|
||||
h: 'hh',
|
||||
H: 'HH',
|
||||
i: 'mm',
|
||||
s: 'ss',
|
||||
u: 'SSSSSS',
|
||||
v: 'SSS',
|
||||
g: "h",
|
||||
G: "H",
|
||||
h: "hh",
|
||||
H: "HH",
|
||||
i: "mm",
|
||||
s: "ss",
|
||||
u: "SSSSSS",
|
||||
v: "SSS",
|
||||
// Timezone.
|
||||
e: 'zz',
|
||||
e: "zz",
|
||||
/**
|
||||
* Gets whether the timezone is in DST currently.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
I(momentDate) {
|
||||
return momentDate.isDST() ? '1' : '0';
|
||||
return momentDate.isDST() ? "1" : "0";
|
||||
},
|
||||
O: 'ZZ',
|
||||
P: 'Z',
|
||||
T: 'z',
|
||||
O: "ZZ",
|
||||
P: "Z",
|
||||
T: "z",
|
||||
/**
|
||||
* Gets the timezone offset in seconds.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {number} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
Z(momentDate) {
|
||||
// Timezone offset in seconds.
|
||||
const offset = momentDate.format('Z');
|
||||
const sign = offset[0] === '-' ? -1 : 1;
|
||||
const parts = offset.substring(1).split(':').map(n => parseInt(n, 10));
|
||||
const offset = momentDate.format("Z");
|
||||
const sign = offset[0] === "-" ? -1 : 1;
|
||||
const parts = offset.substring(1).split(":").map((n) => parseInt(n, 10));
|
||||
return sign * (parts[0] * HOUR_IN_MINUTES + parts[1]) * MINUTE_IN_SECONDS;
|
||||
},
|
||||
// Full date/time.
|
||||
c: 'YYYY-MM-DDTHH:mm:ssZ',
|
||||
c: "YYYY-MM-DDTHH:mm:ssZ",
|
||||
// .toISOString.
|
||||
/**
|
||||
* Formats the date as RFC2822.
|
||||
*
|
||||
* @param {Moment} momentDate Moment instance.
|
||||
* @param momentDate Moment instance.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
* @return Formatted date.
|
||||
*/
|
||||
r(momentDate) {
|
||||
return momentDate.locale('en').format('ddd, DD MMM YYYY HH:mm:ss ZZ');
|
||||
return momentDate.locale("en").format("ddd, DD MMM YYYY HH:mm:ss ZZ");
|
||||
},
|
||||
U: 'X'
|
||||
U: "X"
|
||||
};
|
||||
|
||||
/**
|
||||
* Formats a date. Does not alter the date's timezone.
|
||||
*
|
||||
* @param {string} dateFormat PHP-style formatting string.
|
||||
* See [php.net/date](https://www.php.net/manual/en/function.date.php).
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string,
|
||||
* parsable by moment.js.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
*/
|
||||
function format(dateFormat, dateValue = new Date()) {
|
||||
function format(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
|
||||
let i, char;
|
||||
const newFormat = [];
|
||||
const momentDate = external_moment_default()(dateValue);
|
||||
const momentDate = moment__WEBPACK_IMPORTED_MODULE_0___default()(dateValue);
|
||||
for (i = 0; i < dateFormat.length; i++) {
|
||||
char = dateFormat[i];
|
||||
// Is this an escape?
|
||||
if ('\\' === char) {
|
||||
// Add next character, then move on.
|
||||
if ("\\" === char) {
|
||||
i++;
|
||||
newFormat.push('[' + dateFormat[i] + ']');
|
||||
newFormat.push("[" + dateFormat[i] + "]");
|
||||
continue;
|
||||
}
|
||||
if (char in formatMap) {
|
||||
const formatter = formatMap[(/** @type {keyof formatMap} */char)];
|
||||
if (typeof formatter !== 'string') {
|
||||
// If the format is a function, call it.
|
||||
newFormat.push('[' + formatter(momentDate) + ']');
|
||||
const formatter = formatMap[char];
|
||||
if (typeof formatter !== "string") {
|
||||
newFormat.push("[" + formatter(momentDate) + "]");
|
||||
} else {
|
||||
// Otherwise, add as a formatting string.
|
||||
newFormat.push(formatter);
|
||||
}
|
||||
} else {
|
||||
newFormat.push('[' + char + ']');
|
||||
newFormat.push("[" + char + "]");
|
||||
}
|
||||
}
|
||||
// Join with [] between to separate characters, and replace
|
||||
// unneeded separators with static text.
|
||||
return momentDate.format(newFormat.join('[]'));
|
||||
return momentDate.format(newFormat.join("[]"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date (like `date()` in PHP).
|
||||
*
|
||||
* @param {string} dateFormat PHP-style formatting string.
|
||||
* See [php.net/date](https://www.php.net/manual/en/function.date.php).
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
|
||||
* by moment.js.
|
||||
* @param {string | number | undefined} timezone Timezone to output result in or a
|
||||
* UTC offset. Defaults to timezone from
|
||||
* site.
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
|
||||
*
|
||||
* @return {string} Formatted date in English.
|
||||
*/
|
||||
function date(dateFormat, dateValue = new Date(), timezone) {
|
||||
function date(dateFormat, dateValue = /* @__PURE__ */ new Date(), timezone) {
|
||||
const dateMoment = buildMoment(dateValue, timezone);
|
||||
return format(dateFormat, dateMoment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date (like `date()` in PHP), in the UTC timezone.
|
||||
*
|
||||
* @param {string} dateFormat PHP-style formatting string.
|
||||
* See [php.net/date](https://www.php.net/manual/en/function.date.php).
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string,
|
||||
* parsable by moment.js.
|
||||
*
|
||||
* @return {string} Formatted date in English.
|
||||
*/
|
||||
function gmdate(dateFormat, dateValue = new Date()) {
|
||||
const dateMoment = external_moment_default()(dateValue).utc();
|
||||
function gmdate(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
|
||||
const dateMoment = moment__WEBPACK_IMPORTED_MODULE_0___default()(dateValue).utc();
|
||||
return format(dateFormat, dateMoment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date (like `wp_date()` in PHP), translating it into site's locale.
|
||||
*
|
||||
* Backward Compatibility Notice: if `timezone` is set to `true`, the function
|
||||
* behaves like `gmdateI18n`.
|
||||
*
|
||||
* @param {string} dateFormat PHP-style formatting string.
|
||||
* See [php.net/date](https://www.php.net/manual/en/function.date.php).
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string, parsable by
|
||||
* moment.js.
|
||||
* @param {string | number | boolean | undefined=} timezone Timezone to output result in or a
|
||||
* UTC offset. Defaults to timezone from
|
||||
* site. Notice: `boolean` is effectively
|
||||
* deprecated, but still supported for
|
||||
* backward compatibility reasons.
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
*/
|
||||
function dateI18n(dateFormat, dateValue = new Date(), timezone) {
|
||||
function dateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date(), timezone) {
|
||||
if (true === timezone) {
|
||||
return gmdateI18n(dateFormat, dateValue);
|
||||
}
|
||||
if (false === timezone) {
|
||||
timezone = undefined;
|
||||
timezone = void 0;
|
||||
}
|
||||
const dateMoment = buildMoment(dateValue, timezone);
|
||||
dateMoment.locale(settings.l10n.locale);
|
||||
return format(dateFormat, dateMoment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats a date (like `wp_date()` in PHP), translating it into site's locale
|
||||
* and using the UTC timezone.
|
||||
*
|
||||
* @param {string} dateFormat PHP-style formatting string.
|
||||
* See [php.net/date](https://www.php.net/manual/en/function.date.php).
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string,
|
||||
* parsable by moment.js.
|
||||
*
|
||||
* @return {string} Formatted date.
|
||||
*/
|
||||
function gmdateI18n(dateFormat, dateValue = new Date()) {
|
||||
const dateMoment = external_moment_default()(dateValue).utc();
|
||||
function gmdateI18n(dateFormat, dateValue = /* @__PURE__ */ new Date()) {
|
||||
const dateMoment = moment__WEBPACK_IMPORTED_MODULE_0___default()(dateValue).utc();
|
||||
dateMoment.locale(settings.l10n.locale);
|
||||
return format(dateFormat, dateMoment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a date is considered in the future according to the WordPress settings.
|
||||
*
|
||||
* @param {string} dateValue Date String or Date object in the Defined WP Timezone.
|
||||
*
|
||||
* @return {boolean} Is in the future.
|
||||
*/
|
||||
function isInTheFuture(dateValue) {
|
||||
const now = external_moment_default().tz(WP_ZONE);
|
||||
const momentObject = external_moment_default().tz(dateValue, WP_ZONE);
|
||||
const now = moment__WEBPACK_IMPORTED_MODULE_0___default().tz(WP_ZONE);
|
||||
const momentObject = moment__WEBPACK_IMPORTED_MODULE_0___default().tz(dateValue, WP_ZONE);
|
||||
return momentObject.isAfter(now);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create and return a JavaScript Date Object from a date string in the WP timezone.
|
||||
*
|
||||
* @param {?string} dateString Date formatted in the WP timezone.
|
||||
*
|
||||
* @return {Date} Date
|
||||
*/
|
||||
function getDate(dateString) {
|
||||
if (!dateString) {
|
||||
return external_moment_default().tz(WP_ZONE).toDate();
|
||||
return moment__WEBPACK_IMPORTED_MODULE_0___default().tz(WP_ZONE).toDate();
|
||||
}
|
||||
return external_moment_default().tz(dateString, WP_ZONE).toDate();
|
||||
return moment__WEBPACK_IMPORTED_MODULE_0___default().tz(dateString, WP_ZONE).toDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a human-readable time difference between two dates, like human_time_diff() in PHP.
|
||||
*
|
||||
* @param {Moment | Date | string} from From date, in the WP timezone.
|
||||
* @param {Moment | Date | string | undefined} to To date, formatted in the WP timezone.
|
||||
*
|
||||
* @return {string} Human-readable time difference.
|
||||
*/
|
||||
function humanTimeDiff(from, to) {
|
||||
const fromMoment = external_moment_default().tz(from, WP_ZONE);
|
||||
const toMoment = to ? external_moment_default().tz(to, WP_ZONE) : external_moment_default().tz(WP_ZONE);
|
||||
const fromMoment = moment__WEBPACK_IMPORTED_MODULE_0___default().tz(from, WP_ZONE);
|
||||
const toMoment = to ? moment__WEBPACK_IMPORTED_MODULE_0___default().tz(to, WP_ZONE) : moment__WEBPACK_IMPORTED_MODULE_0___default().tz(WP_ZONE);
|
||||
return fromMoment.from(toMoment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a moment instance using the given timezone or, if none is provided, using global settings.
|
||||
*
|
||||
* @param {Moment | Date | string | undefined} dateValue Date object or string, parsable
|
||||
* by moment.js.
|
||||
* @param {string | number | undefined} timezone Timezone to output result in or a
|
||||
* UTC offset. Defaults to timezone from
|
||||
* site.
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
|
||||
* @see https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC
|
||||
*
|
||||
* @return {Moment} a moment instance.
|
||||
*/
|
||||
function buildMoment(dateValue, timezone = '') {
|
||||
const dateMoment = external_moment_default()(dateValue);
|
||||
function buildMoment(dateValue, timezone = "") {
|
||||
const dateMoment = moment__WEBPACK_IMPORTED_MODULE_0___default()(dateValue);
|
||||
if (timezone && !isUTCOffset(timezone)) {
|
||||
// The ! isUTCOffset() check guarantees that timezone is a string.
|
||||
return dateMoment.tz(/** @type {string} */timezone);
|
||||
return dateMoment.tz(timezone);
|
||||
}
|
||||
if (timezone && isUTCOffset(timezone)) {
|
||||
return dateMoment.utcOffset(timezone);
|
||||
@@ -1757,22 +1547,15 @@ function buildMoment(dateValue, timezone = '') {
|
||||
}
|
||||
return dateMoment.utcOffset(+settings.timezone.offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a certain UTC offset is valid or not.
|
||||
*
|
||||
* @param {number|string} offset a UTC offset.
|
||||
*
|
||||
* @return {boolean} whether a certain UTC offset is valid or not.
|
||||
*/
|
||||
function isUTCOffset(offset) {
|
||||
if ('number' === typeof offset) {
|
||||
if ("number" === typeof offset) {
|
||||
return true;
|
||||
}
|
||||
return VALID_UTC_OFFSET.test(offset);
|
||||
}
|
||||
setupWPTimezone();
|
||||
|
||||
|
||||
})();
|
||||
|
||||
(window.wp = window.wp || {}).date = __webpack_exports__;
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+9
-73
@@ -34,89 +34,25 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
;// external ["wp","hooks"]
|
||||
const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
|
||||
;// ./node_modules/@wordpress/deprecated/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Object map tracking messages which have been logged, for use in ensuring a
|
||||
* message is only logged once.
|
||||
*
|
||||
* @type {Record<string, true | undefined>}
|
||||
*/
|
||||
const logged = Object.create(null);
|
||||
|
||||
/**
|
||||
* Logs a message to notify developers about a deprecated feature.
|
||||
*
|
||||
* @param {string} feature Name of the deprecated feature.
|
||||
* @param {Object} [options] Personalisation options
|
||||
* @param {string} [options.since] Version in which the feature was deprecated.
|
||||
* @param {string} [options.version] Version in which the feature will be removed.
|
||||
* @param {string} [options.alternative] Feature to use instead
|
||||
* @param {string} [options.plugin] Plugin name if it's a plugin feature
|
||||
* @param {string} [options.link] Link to documentation
|
||||
* @param {string} [options.hint] Additional message to help transition away from the deprecated feature.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import deprecated from '@wordpress/deprecated';
|
||||
*
|
||||
* deprecated( 'Eating meat', {
|
||||
* since: '2019.01.01'
|
||||
* version: '2020.01.01',
|
||||
* alternative: 'vegetables',
|
||||
* plugin: 'the earth',
|
||||
* hint: 'You may find it beneficial to transition gradually.',
|
||||
* } );
|
||||
*
|
||||
* // Logs: 'Eating meat is deprecated since version 2019.01.01 and will be removed from the earth in version 2020.01.01. Please use vegetables instead. Note: You may find it beneficial to transition gradually.'
|
||||
* ```
|
||||
*/
|
||||
const logged = /* @__PURE__ */ Object.create(null);
|
||||
function deprecated(feature, options = {}) {
|
||||
const {
|
||||
since,
|
||||
version,
|
||||
alternative,
|
||||
plugin,
|
||||
link,
|
||||
hint
|
||||
} = options;
|
||||
const pluginMessage = plugin ? ` from ${plugin}` : '';
|
||||
const sinceMessage = since ? ` since version ${since}` : '';
|
||||
const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : '';
|
||||
const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : '';
|
||||
const linkMessage = link ? ` See: ${link}` : '';
|
||||
const hintMessage = hint ? ` Note: ${hint}` : '';
|
||||
const { since, version, alternative, plugin, link, hint } = options;
|
||||
const pluginMessage = plugin ? ` from ${plugin}` : "";
|
||||
const sinceMessage = since ? ` since version ${since}` : "";
|
||||
const versionMessage = version ? ` and will be removed${pluginMessage} in version ${version}` : "";
|
||||
const useInsteadMessage = alternative ? ` Please use ${alternative} instead.` : "";
|
||||
const linkMessage = link ? ` See: ${link}` : "";
|
||||
const hintMessage = hint ? ` Note: ${hint}` : "";
|
||||
const message = `${feature} is deprecated${sinceMessage}${versionMessage}.${useInsteadMessage}${linkMessage}${hintMessage}`;
|
||||
|
||||
// Skip if already logged.
|
||||
if (message in logged) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires whenever a deprecated feature is encountered
|
||||
*
|
||||
* @param {string} feature Name of the deprecated feature.
|
||||
* @param {?Object} options Personalisation options
|
||||
* @param {string} options.since Version in which the feature was deprecated.
|
||||
* @param {?string} options.version Version in which the feature will be removed.
|
||||
* @param {?string} options.alternative Feature to use instead
|
||||
* @param {?string} options.plugin Plugin name if it's a plugin feature
|
||||
* @param {?string} options.link Link to documentation
|
||||
* @param {?string} options.hint Additional message to help transition away from the deprecated feature.
|
||||
* @param {?string} message Message sent to console.warn
|
||||
*/
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('deprecated', feature, options, message);
|
||||
|
||||
// eslint-disable-next-line no-console
|
||||
(0,external_wp_hooks_namespaceObject.doAction)("deprecated", feature, options, message);
|
||||
console.warn(message);
|
||||
logged[message] = true;
|
||||
}
|
||||
|
||||
/** @typedef {import('utility-types').NonUndefined<Parameters<typeof deprecated>[1]>} DeprecatedOptions */
|
||||
|
||||
(window.wp = window.wp || {}).deprecated = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
\***************************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
eval("/* global __react_refresh_library__ */\n\nconst safeThis = __webpack_require__(/*! core-js-pure/features/global-this */ \"./node_modules/core-js-pure/features/global-this.js\");\nconst RefreshRuntime = __webpack_require__(/*! react-refresh/runtime */ \"react-refresh/runtime\");\n\nif (true) {\n if (typeof safeThis !== 'undefined') {\n var $RefreshInjected$ = '__reactRefreshInjected';\n // Namespace the injected flag (if necessary) for monorepo compatibility\n if (typeof __react_refresh_library__ !== 'undefined' && __react_refresh_library__) {\n $RefreshInjected$ += '_' + __react_refresh_library__;\n }\n\n // Only inject the runtime if it hasn't been injected\n if (!safeThis[$RefreshInjected$]) {\n // Inject refresh runtime into global scope\n RefreshRuntime.injectIntoGlobalHook(safeThis);\n\n // Mark the runtime as injected to prevent double-injection\n safeThis[$RefreshInjected$] = true;\n }\n }\n}\n\n\n//# sourceURL=webpack://WordPress/./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js?");
|
||||
eval("/* global __react_refresh_library__ */\n\nif (true) {\n const safeThis = __webpack_require__(/*! core-js-pure/features/global-this */ \"./node_modules/core-js-pure/features/global-this.js\");\n const RefreshRuntime = __webpack_require__(/*! react-refresh/runtime */ \"react-refresh/runtime\");\n\n if (typeof safeThis !== 'undefined') {\n var $RefreshInjected$ = '__reactRefreshInjected';\n // Namespace the injected flag (if necessary) for monorepo compatibility\n if (typeof __react_refresh_library__ !== 'undefined' && __react_refresh_library__) {\n $RefreshInjected$ += '_' + __react_refresh_library__;\n }\n\n // Only inject the runtime if it hasn't been injected\n if (!safeThis[$RefreshInjected$]) {\n // Inject refresh runtime into global scope\n RefreshRuntime.injectIntoGlobalHook(safeThis);\n\n // Mark the runtime as injected to prevent double-injection\n safeThis[$RefreshInjected$] = true;\n }\n }\n}\n\n\n//# sourceURL=webpack://WordPress/./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js?");
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
\***************************************************************************************/
|
||||
/***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => {
|
||||
|
||||
eval("/* global __react_refresh_library__ */\n\nconst safeThis = __webpack_require__(/*! core-js-pure/features/global-this */ \"./node_modules/core-js-pure/features/global-this.js\");\nconst RefreshRuntime = __webpack_require__(/*! react-refresh/runtime */ \"react-refresh/runtime\");\n\nif (true) {\n if (typeof safeThis !== 'undefined') {\n var $RefreshInjected$ = '__reactRefreshInjected';\n // Namespace the injected flag (if necessary) for monorepo compatibility\n if (typeof __react_refresh_library__ !== 'undefined' && __react_refresh_library__) {\n $RefreshInjected$ += '_' + __react_refresh_library__;\n }\n\n // Only inject the runtime if it hasn't been injected\n if (!safeThis[$RefreshInjected$]) {\n // Inject refresh runtime into global scope\n RefreshRuntime.injectIntoGlobalHook(safeThis);\n\n // Mark the runtime as injected to prevent double-injection\n safeThis[$RefreshInjected$] = true;\n }\n }\n}\n\n\n//# sourceURL=webpack://WordPress/./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js?");
|
||||
eval("/* global __react_refresh_library__ */\n\nif (true) {\n const safeThis = __webpack_require__(/*! core-js-pure/features/global-this */ \"./node_modules/core-js-pure/features/global-this.js\");\n const RefreshRuntime = __webpack_require__(/*! react-refresh/runtime */ \"react-refresh/runtime\");\n\n if (typeof safeThis !== 'undefined') {\n var $RefreshInjected$ = '__reactRefreshInjected';\n // Namespace the injected flag (if necessary) for monorepo compatibility\n if (typeof __react_refresh_library__ !== 'undefined' && __react_refresh_library__) {\n $RefreshInjected$ += '_' + __react_refresh_library__;\n }\n\n // Only inject the runtime if it hasn't been injected\n if (!safeThis[$RefreshInjected$]) {\n // Inject refresh runtime into global scope\n RefreshRuntime.injectIntoGlobalHook(safeThis);\n\n // Mark the runtime as injected to prevent double-injection\n safeThis[$RefreshInjected$] = true;\n }\n }\n}\n\n\n//# sourceURL=webpack://WordPress/./node_modules/@pmmmwh/react-refresh-webpack-plugin/client/ReactRefreshEntry.js?");
|
||||
|
||||
/***/ }),
|
||||
|
||||
|
||||
Vendored
+5
-38
@@ -26,51 +26,18 @@ var __webpack_exports__ = {};
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ "default": () => (/* binding */ domReady)
|
||||
/* harmony export */ });
|
||||
/**
|
||||
* @typedef {() => void} Callback
|
||||
*
|
||||
* TODO: Remove this typedef and inline `() => void` type.
|
||||
*
|
||||
* This typedef is used so that a descriptive type is provided in our
|
||||
* automatically generated documentation.
|
||||
*
|
||||
* An in-line type `() => void` would be preferable, but the generated
|
||||
* documentation is `null` in that case.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/issues/18045
|
||||
*/
|
||||
|
||||
/**
|
||||
* Specify a function to execute when the DOM is fully loaded.
|
||||
*
|
||||
* @param {Callback} callback A function to execute after the DOM is ready.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import domReady from '@wordpress/dom-ready';
|
||||
*
|
||||
* domReady( function() {
|
||||
* //do something after DOM loads.
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @return {void}
|
||||
*/
|
||||
function domReady(callback) {
|
||||
if (typeof document === 'undefined') {
|
||||
if (typeof document === "undefined") {
|
||||
return;
|
||||
}
|
||||
if (document.readyState === 'complete' ||
|
||||
// DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
|
||||
document.readyState === 'interactive' // DOMContentLoaded fires at this point, so we call directly.
|
||||
) {
|
||||
if (document.readyState === "complete" || // DOMContentLoaded + Images/Styles/etc loaded, so we call directly.
|
||||
document.readyState === "interactive") {
|
||||
return void callback();
|
||||
}
|
||||
|
||||
// DOMContentLoaded has not fired yet, delay callback until then.
|
||||
document.addEventListener('DOMContentLoaded', callback);
|
||||
document.addEventListener("DOMContentLoaded", callback);
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).domReady = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+387
-1183
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1514
-2368
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+25908
-19669
File diff suppressed because one or more lines are too long
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+2367
-3153
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+18976
-22295
File diff suppressed because one or more lines are too long
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+480
-968
File diff suppressed because it is too large
Load Diff
Vendored
+2
-2
File diff suppressed because one or more lines are too long
Vendored
+10
-114
@@ -49,143 +49,39 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
});
|
||||
|
||||
;// ./node_modules/@wordpress/escape-html/build-module/escape-greater.js
|
||||
/**
|
||||
* Returns a string with greater-than sign replaced.
|
||||
*
|
||||
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
|
||||
* necessary for `__unstableEscapeGreaterThan` to exist.
|
||||
*
|
||||
* See: https://core.trac.wordpress.org/ticket/45387
|
||||
*
|
||||
* @param value Original string.
|
||||
*
|
||||
* @return Escaped string.
|
||||
*/
|
||||
function __unstableEscapeGreaterThan(value) {
|
||||
return value.replace(/>/g, '>');
|
||||
return value.replace(/>/g, ">");
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/escape-html/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Regular expression matching invalid attribute names.
|
||||
*
|
||||
* "Attribute names must consist of one or more characters other than controls,
|
||||
* U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (>), U+002F (/), U+003D (=),
|
||||
* and noncharacters."
|
||||
*
|
||||
* @see https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
||||
*/
|
||||
const REGEXP_INVALID_ATTRIBUTE_NAME = /[\u007F-\u009F "'>/="\uFDD0-\uFDEF]/;
|
||||
|
||||
/**
|
||||
* Returns a string with ampersands escaped. Note that this is an imperfect
|
||||
* implementation, where only ampersands which do not appear as a pattern of
|
||||
* named, decimal, or hexadecimal character references are escaped. Invalid
|
||||
* named references (i.e. ambiguous ampersand) are still permitted.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#character-references
|
||||
* @see https://w3c.github.io/html/syntax.html#ambiguous-ampersand
|
||||
* @see https://w3c.github.io/html/syntax.html#named-character-references
|
||||
*
|
||||
* @param value Original string.
|
||||
*
|
||||
* @return Escaped string.
|
||||
*/
|
||||
function escapeAmpersand(value) {
|
||||
return value.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi, '&');
|
||||
return value.replace(/&(?!([a-z0-9]+|#[0-9]+|#x[a-f0-9]+);)/gi, "&");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with quotation marks replaced.
|
||||
*
|
||||
* @param value Original string.
|
||||
*
|
||||
* @return Escaped string.
|
||||
*/
|
||||
function escapeQuotationMark(value) {
|
||||
return value.replace(/"/g, '"');
|
||||
return value.replace(/"/g, """);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string with less-than sign replaced.
|
||||
*
|
||||
* @param value Original string.
|
||||
*
|
||||
* @return Escaped string.
|
||||
*/
|
||||
function escapeLessThan(value) {
|
||||
return value.replace(/</g, '<');
|
||||
return value.replace(/</g, "<");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped attribute value.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#elements-attributes
|
||||
*
|
||||
* "[...] the text cannot contain an ambiguous ampersand [...] must not contain
|
||||
* any literal U+0022 QUOTATION MARK characters (")"
|
||||
*
|
||||
* Note we also escape the greater than symbol, as this is used by wptexturize to
|
||||
* split HTML strings. This is a WordPress specific fix
|
||||
*
|
||||
* Note that if a resolution for Trac#45387 comes to fruition, it is no longer
|
||||
* necessary for `__unstableEscapeGreaterThan` to be used.
|
||||
*
|
||||
* See: https://core.trac.wordpress.org/ticket/45387
|
||||
*
|
||||
* @param value Attribute value.
|
||||
*
|
||||
* @return Escaped attribute value.
|
||||
*/
|
||||
function escapeAttribute(value) {
|
||||
return __unstableEscapeGreaterThan(escapeQuotationMark(escapeAmpersand(value)));
|
||||
return __unstableEscapeGreaterThan(
|
||||
escapeQuotationMark(escapeAmpersand(value))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped HTML element value.
|
||||
*
|
||||
* @see https://w3c.github.io/html/syntax.html#writing-html-documents-elements
|
||||
*
|
||||
* "the text must not contain the character U+003C LESS-THAN SIGN (<) or an
|
||||
* ambiguous ampersand."
|
||||
*
|
||||
* @param value Element value.
|
||||
*
|
||||
* @return Escaped HTML element value.
|
||||
*/
|
||||
function escapeHTML(value) {
|
||||
return escapeLessThan(escapeAmpersand(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an escaped Editable HTML element value. This is different from
|
||||
* `escapeHTML`, because for editable HTML, ALL ampersands must be escaped in
|
||||
* order to render the content correctly on the page.
|
||||
*
|
||||
* @param value Element value.
|
||||
*
|
||||
* @return Escaped HTML element value.
|
||||
*/
|
||||
function escapeEditableHTML(value) {
|
||||
return escapeLessThan(value.replace(/&/g, '&'));
|
||||
return escapeLessThan(value.replace(/&/g, "&"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given attribute name is valid, or false otherwise.
|
||||
*
|
||||
* @param name Attribute name to test.
|
||||
*
|
||||
* @return Whether attribute is valid.
|
||||
*/
|
||||
function isValidAttributeName(name) {
|
||||
return !REGEXP_INVALID_ATTRIBUTE_NAME.test(name);
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).escapeHtml = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1288
-1202
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+416
-559
@@ -1,9 +1,386 @@
|
||||
/******/ (() => { // webpackBootstrap
|
||||
/******/ "use strict";
|
||||
/******/ // The require scope
|
||||
/******/ var __webpack_require__ = {};
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 507:
|
||||
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
A: () => (/* binding */ createHooks_default)
|
||||
});
|
||||
|
||||
// UNUSED EXPORTS: _Hooks
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
||||
function validateNamespace(namespace) {
|
||||
if ("string" !== typeof namespace || "" === namespace) {
|
||||
console.error("The namespace must be a non-empty string.");
|
||||
return false;
|
||||
}
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
||||
console.error(
|
||||
"The namespace can only contain numbers, letters, dashes, periods, underscores and slashes."
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var validateNamespace_default = validateNamespace;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/validateHookName.js
|
||||
function validateHookName(hookName) {
|
||||
if ("string" !== typeof hookName || "" === hookName) {
|
||||
console.error("The hook name must be a non-empty string.");
|
||||
return false;
|
||||
}
|
||||
if (/^__/.test(hookName)) {
|
||||
console.error("The hook name cannot begin with `__`.");
|
||||
return false;
|
||||
}
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
||||
console.error(
|
||||
"The hook name can only contain numbers, letters, dashes, periods and underscores."
|
||||
);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
var validateHookName_default = validateHookName;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createAddHook.js
|
||||
|
||||
|
||||
function createAddHook(hooks, storeKey) {
|
||||
return function addHook(hookName, namespace, callback, priority = 10) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!validateHookName_default(hookName)) {
|
||||
return;
|
||||
}
|
||||
if (!validateNamespace_default(namespace)) {
|
||||
return;
|
||||
}
|
||||
if ("function" !== typeof callback) {
|
||||
console.error("The hook callback must be a function.");
|
||||
return;
|
||||
}
|
||||
if ("number" !== typeof priority) {
|
||||
console.error(
|
||||
"If specified, the hook priority must be a number."
|
||||
);
|
||||
return;
|
||||
}
|
||||
const handler = { callback, priority, namespace };
|
||||
if (hooksStore[hookName]) {
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
let i;
|
||||
for (i = handlers.length; i > 0; i--) {
|
||||
if (priority >= handlers[i - 1].priority) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === handlers.length) {
|
||||
handlers[i] = handler;
|
||||
} else {
|
||||
handlers.splice(i, 0, handler);
|
||||
}
|
||||
hooksStore.__current.forEach((hookInfo) => {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
hooksStore[hookName] = {
|
||||
handlers: [handler],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
if (hookName !== "hookAdded") {
|
||||
hooks.doAction(
|
||||
"hookAdded",
|
||||
hookName,
|
||||
namespace,
|
||||
callback,
|
||||
priority
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
var createAddHook_default = createAddHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
||||
|
||||
|
||||
function createRemoveHook(hooks, storeKey, removeAll = false) {
|
||||
return function removeHook(hookName, namespace) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!validateHookName_default(hookName)) {
|
||||
return;
|
||||
}
|
||||
if (!removeAll && !validateNamespace_default(namespace)) {
|
||||
return;
|
||||
}
|
||||
if (!hooksStore[hookName]) {
|
||||
return 0;
|
||||
}
|
||||
let handlersRemoved = 0;
|
||||
if (removeAll) {
|
||||
handlersRemoved = hooksStore[hookName].handlers.length;
|
||||
hooksStore[hookName] = {
|
||||
runs: hooksStore[hookName].runs,
|
||||
handlers: []
|
||||
};
|
||||
} else {
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
for (let i = handlers.length - 1; i >= 0; i--) {
|
||||
if (handlers[i].namespace === namespace) {
|
||||
handlers.splice(i, 1);
|
||||
handlersRemoved++;
|
||||
hooksStore.__current.forEach((hookInfo) => {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex--;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hookName !== "hookRemoved") {
|
||||
hooks.doAction("hookRemoved", hookName, namespace);
|
||||
}
|
||||
return handlersRemoved;
|
||||
};
|
||||
}
|
||||
var createRemoveHook_default = createRemoveHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createHasHook.js
|
||||
function createHasHook(hooks, storeKey) {
|
||||
return function hasHook(hookName, namespace) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if ("undefined" !== typeof namespace) {
|
||||
return hookName in hooksStore && hooksStore[hookName].handlers.some(
|
||||
(hook) => hook.namespace === namespace
|
||||
);
|
||||
}
|
||||
return hookName in hooksStore;
|
||||
};
|
||||
}
|
||||
var createHasHook_default = createHasHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createRunHook.js
|
||||
function createRunHook(hooks, storeKey, returnFirstArg, async) {
|
||||
return function runHook(hookName, ...args) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!hooksStore[hookName]) {
|
||||
hooksStore[hookName] = {
|
||||
handlers: [],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
hooksStore[hookName].runs++;
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
if (false) {}
|
||||
if (!handlers || !handlers.length) {
|
||||
return returnFirstArg ? args[0] : void 0;
|
||||
}
|
||||
const hookInfo = {
|
||||
name: hookName,
|
||||
currentIndex: 0
|
||||
};
|
||||
async function asyncRunner() {
|
||||
try {
|
||||
hooksStore.__current.add(hookInfo);
|
||||
let result = returnFirstArg ? args[0] : void 0;
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
const handler = handlers[hookInfo.currentIndex];
|
||||
result = await handler.callback.apply(null, args);
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
return returnFirstArg ? result : void 0;
|
||||
} finally {
|
||||
hooksStore.__current.delete(hookInfo);
|
||||
}
|
||||
}
|
||||
function syncRunner() {
|
||||
try {
|
||||
hooksStore.__current.add(hookInfo);
|
||||
let result = returnFirstArg ? args[0] : void 0;
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
const handler = handlers[hookInfo.currentIndex];
|
||||
result = handler.callback.apply(null, args);
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
return returnFirstArg ? result : void 0;
|
||||
} finally {
|
||||
hooksStore.__current.delete(hookInfo);
|
||||
}
|
||||
}
|
||||
return (async ? asyncRunner : syncRunner)();
|
||||
};
|
||||
}
|
||||
var createRunHook_default = createRunHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
||||
function createCurrentHook(hooks, storeKey) {
|
||||
return function currentHook() {
|
||||
const hooksStore = hooks[storeKey];
|
||||
const currentArray = Array.from(hooksStore.__current);
|
||||
return currentArray.at(-1)?.name ?? null;
|
||||
};
|
||||
}
|
||||
var createCurrentHook_default = createCurrentHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
||||
function createDoingHook(hooks, storeKey) {
|
||||
return function doingHook(hookName) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if ("undefined" === typeof hookName) {
|
||||
return hooksStore.__current.size > 0;
|
||||
}
|
||||
return Array.from(hooksStore.__current).some(
|
||||
(hook) => hook.name === hookName
|
||||
);
|
||||
};
|
||||
}
|
||||
var createDoingHook_default = createDoingHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createDidHook.js
|
||||
|
||||
function createDidHook(hooks, storeKey) {
|
||||
return function didHook(hookName) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!validateHookName_default(hookName)) {
|
||||
return;
|
||||
}
|
||||
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
|
||||
};
|
||||
}
|
||||
var createDidHook_default = createDidHook;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createHooks.js
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class _Hooks {
|
||||
actions;
|
||||
filters;
|
||||
addAction;
|
||||
addFilter;
|
||||
removeAction;
|
||||
removeFilter;
|
||||
hasAction;
|
||||
hasFilter;
|
||||
removeAllActions;
|
||||
removeAllFilters;
|
||||
doAction;
|
||||
doActionAsync;
|
||||
applyFilters;
|
||||
applyFiltersAsync;
|
||||
currentAction;
|
||||
currentFilter;
|
||||
doingAction;
|
||||
doingFilter;
|
||||
didAction;
|
||||
didFilter;
|
||||
constructor() {
|
||||
this.actions = /* @__PURE__ */ Object.create(null);
|
||||
this.actions.__current = /* @__PURE__ */ new Set();
|
||||
this.filters = /* @__PURE__ */ Object.create(null);
|
||||
this.filters.__current = /* @__PURE__ */ new Set();
|
||||
this.addAction = createAddHook_default(this, "actions");
|
||||
this.addFilter = createAddHook_default(this, "filters");
|
||||
this.removeAction = createRemoveHook_default(this, "actions");
|
||||
this.removeFilter = createRemoveHook_default(this, "filters");
|
||||
this.hasAction = createHasHook_default(this, "actions");
|
||||
this.hasFilter = createHasHook_default(this, "filters");
|
||||
this.removeAllActions = createRemoveHook_default(this, "actions", true);
|
||||
this.removeAllFilters = createRemoveHook_default(this, "filters", true);
|
||||
this.doAction = createRunHook_default(this, "actions", false, false);
|
||||
this.doActionAsync = createRunHook_default(this, "actions", false, true);
|
||||
this.applyFilters = createRunHook_default(this, "filters", true, false);
|
||||
this.applyFiltersAsync = createRunHook_default(this, "filters", true, true);
|
||||
this.currentAction = createCurrentHook_default(this, "actions");
|
||||
this.currentFilter = createCurrentHook_default(this, "filters");
|
||||
this.doingAction = createDoingHook_default(this, "actions");
|
||||
this.doingFilter = createDoingHook_default(this, "filters");
|
||||
this.didAction = createDidHook_default(this, "actions");
|
||||
this.didFilter = createDidHook_default(this, "filters");
|
||||
}
|
||||
}
|
||||
function createHooks() {
|
||||
return new _Hooks();
|
||||
}
|
||||
var createHooks_default = createHooks;
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 8770:
|
||||
/***/ (() => {
|
||||
|
||||
|
||||
|
||||
/***/ })
|
||||
|
||||
/******/ });
|
||||
/************************************************************************/
|
||||
/******/ // The module cache
|
||||
/******/ var __webpack_module_cache__ = {};
|
||||
/******/
|
||||
/******/ // The require function
|
||||
/******/ function __webpack_require__(moduleId) {
|
||||
/******/ // Check if module is in cache
|
||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
||||
/******/ if (cachedModule !== undefined) {
|
||||
/******/ return cachedModule.exports;
|
||||
/******/ }
|
||||
/******/ // Create a new module (and put it into the cache)
|
||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
||||
/******/ // no module.id needed
|
||||
/******/ // no module.loaded needed
|
||||
/******/ exports: {}
|
||||
/******/ };
|
||||
/******/
|
||||
/******/ // Execute the module function
|
||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
||||
/******/
|
||||
/******/ // Return the exports of the module
|
||||
/******/ return module.exports;
|
||||
/******/ }
|
||||
/******/
|
||||
/************************************************************************/
|
||||
/******/ /* webpack/runtime/compat get default export */
|
||||
/******/ (() => {
|
||||
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
||||
/******/ __webpack_require__.n = (module) => {
|
||||
/******/ var getter = module && module.__esModule ?
|
||||
/******/ () => (module['default']) :
|
||||
/******/ () => (module);
|
||||
/******/ __webpack_require__.d(getter, { a: getter });
|
||||
/******/ return getter;
|
||||
/******/ };
|
||||
/******/ })();
|
||||
/******/
|
||||
/******/ /* webpack/runtime/define property getters */
|
||||
/******/ (() => {
|
||||
/******/ // define getter functions for harmony exports
|
||||
@@ -34,565 +411,43 @@
|
||||
/******/
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
// ESM COMPAT FLAG
|
||||
// This entry needs to be wrapped in an IIFE because it needs to be in strict mode.
|
||||
(() => {
|
||||
"use strict";
|
||||
__webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
actions: () => (/* binding */ actions),
|
||||
addAction: () => (/* binding */ addAction),
|
||||
addFilter: () => (/* binding */ addFilter),
|
||||
applyFilters: () => (/* binding */ applyFilters),
|
||||
applyFiltersAsync: () => (/* binding */ applyFiltersAsync),
|
||||
createHooks: () => (/* reexport */ build_module_createHooks),
|
||||
currentAction: () => (/* binding */ currentAction),
|
||||
currentFilter: () => (/* binding */ currentFilter),
|
||||
defaultHooks: () => (/* binding */ defaultHooks),
|
||||
didAction: () => (/* binding */ didAction),
|
||||
didFilter: () => (/* binding */ didFilter),
|
||||
doAction: () => (/* binding */ doAction),
|
||||
doActionAsync: () => (/* binding */ doActionAsync),
|
||||
doingAction: () => (/* binding */ doingAction),
|
||||
doingFilter: () => (/* binding */ doingFilter),
|
||||
filters: () => (/* binding */ filters),
|
||||
hasAction: () => (/* binding */ hasAction),
|
||||
hasFilter: () => (/* binding */ hasFilter),
|
||||
removeAction: () => (/* binding */ removeAction),
|
||||
removeAllActions: () => (/* binding */ removeAllActions),
|
||||
removeAllFilters: () => (/* binding */ removeAllFilters),
|
||||
removeFilter: () => (/* binding */ removeFilter)
|
||||
});
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/validateNamespace.js
|
||||
/**
|
||||
* Validate a namespace string.
|
||||
*
|
||||
* @param {string} namespace The namespace to validate - should take the form
|
||||
* `vendor/plugin/function`.
|
||||
*
|
||||
* @return {boolean} Whether the namespace is valid.
|
||||
*/
|
||||
function validateNamespace(namespace) {
|
||||
if ('string' !== typeof namespace || '' === namespace) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(namespace)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The namespace can only contain numbers, letters, dashes, periods, underscores and slashes.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* harmony default export */ const build_module_validateNamespace = (validateNamespace);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/validateHookName.js
|
||||
/**
|
||||
* Validate a hookName string.
|
||||
*
|
||||
* @param {string} hookName The hook name to validate. Should be a non empty string containing
|
||||
* only numbers, letters, dashes, periods and underscores. Also,
|
||||
* the hook name cannot begin with `__`.
|
||||
*
|
||||
* @return {boolean} Whether the hook name is valid.
|
||||
*/
|
||||
function validateHookName(hookName) {
|
||||
if ('string' !== typeof hookName || '' === hookName) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name must be a non-empty string.');
|
||||
return false;
|
||||
}
|
||||
if (/^__/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name cannot begin with `__`.');
|
||||
return false;
|
||||
}
|
||||
if (!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(hookName)) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook name can only contain numbers, letters, dashes, periods and underscores.');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/* harmony default export */ const build_module_validateHookName = (validateHookName);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createAddHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ actions: () => (/* binding */ actions),
|
||||
/* harmony export */ addAction: () => (/* binding */ addAction),
|
||||
/* harmony export */ addFilter: () => (/* binding */ addFilter),
|
||||
/* harmony export */ applyFilters: () => (/* binding */ applyFilters),
|
||||
/* harmony export */ applyFiltersAsync: () => (/* binding */ applyFiltersAsync),
|
||||
/* harmony export */ createHooks: () => (/* reexport safe */ _createHooks__WEBPACK_IMPORTED_MODULE_1__.A),
|
||||
/* harmony export */ currentAction: () => (/* binding */ currentAction),
|
||||
/* harmony export */ currentFilter: () => (/* binding */ currentFilter),
|
||||
/* harmony export */ defaultHooks: () => (/* binding */ defaultHooks),
|
||||
/* harmony export */ didAction: () => (/* binding */ didAction),
|
||||
/* harmony export */ didFilter: () => (/* binding */ didFilter),
|
||||
/* harmony export */ doAction: () => (/* binding */ doAction),
|
||||
/* harmony export */ doActionAsync: () => (/* binding */ doActionAsync),
|
||||
/* harmony export */ doingAction: () => (/* binding */ doingAction),
|
||||
/* harmony export */ doingFilter: () => (/* binding */ doingFilter),
|
||||
/* harmony export */ filters: () => (/* binding */ filters),
|
||||
/* harmony export */ hasAction: () => (/* binding */ hasAction),
|
||||
/* harmony export */ hasFilter: () => (/* binding */ hasFilter),
|
||||
/* harmony export */ removeAction: () => (/* binding */ removeAction),
|
||||
/* harmony export */ removeAllActions: () => (/* binding */ removeAllActions),
|
||||
/* harmony export */ removeAllFilters: () => (/* binding */ removeAllFilters),
|
||||
/* harmony export */ removeFilter: () => (/* binding */ removeFilter)
|
||||
/* harmony export */ });
|
||||
/* harmony import */ var _createHooks__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(507);
|
||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8770);
|
||||
/* harmony import */ var _types__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_types__WEBPACK_IMPORTED_MODULE_0__);
|
||||
/* harmony reexport (unknown) */ var __WEBPACK_REEXPORT_OBJECT__ = {};
|
||||
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in _types__WEBPACK_IMPORTED_MODULE_0__) if(["default","actions","addAction","addFilter","applyFilters","applyFiltersAsync","createHooks","currentAction","currentFilter","defaultHooks","didAction","didFilter","doAction","doActionAsync","doingAction","doingFilter","filters","hasAction","hasFilter","removeAction","removeAllActions","removeAllFilters","removeFilter"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = () => _types__WEBPACK_IMPORTED_MODULE_0__[__WEBPACK_IMPORT_KEY__]
|
||||
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @callback AddHook
|
||||
*
|
||||
* Adds the hook to the appropriate hooks container.
|
||||
*
|
||||
* @param {string} hookName Name of hook to add
|
||||
* @param {string} namespace The unique namespace identifying the callback in the form `vendor/plugin/function`.
|
||||
* @param {import('.').Callback} callback Function to call when the hook is run
|
||||
* @param {number} [priority=10] Priority of this hook
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will add a hook.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
*
|
||||
* @return {AddHook} Function that adds a new hook.
|
||||
*/
|
||||
function createAddHook(hooks, storeKey) {
|
||||
return function addHook(hookName, namespace, callback, priority = 10) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
if (!build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
}
|
||||
if ('function' !== typeof callback) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('The hook callback must be a function.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate numeric priority
|
||||
if ('number' !== typeof priority) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error('If specified, the hook priority must be a number.');
|
||||
return;
|
||||
}
|
||||
const handler = {
|
||||
callback,
|
||||
priority,
|
||||
namespace
|
||||
};
|
||||
if (hooksStore[hookName]) {
|
||||
// Find the correct insert index of the new hook.
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
|
||||
/** @type {number} */
|
||||
let i;
|
||||
for (i = handlers.length; i > 0; i--) {
|
||||
if (priority >= handlers[i - 1].priority) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i === handlers.length) {
|
||||
// If append, operate via direct assignment.
|
||||
handlers[i] = handler;
|
||||
} else {
|
||||
// Otherwise, insert before index via splice.
|
||||
handlers.splice(i, 0, handler);
|
||||
}
|
||||
|
||||
// We may also be currently executing this hook. If the callback
|
||||
// we're adding would come after the current callback, there's no
|
||||
// problem; otherwise we need to increase the execution index of
|
||||
// any other runs by 1 to account for the added element.
|
||||
hooksStore.__current.forEach(hookInfo => {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// This is the first hook of its type.
|
||||
hooksStore[hookName] = {
|
||||
handlers: [handler],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
if (hookName !== 'hookAdded') {
|
||||
hooks.doAction('hookAdded', hookName, namespace, callback, priority);
|
||||
}
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createAddHook = (createAddHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createRemoveHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @callback RemoveHook
|
||||
* Removes the specified callback (or all callbacks) from the hook with a given hookName
|
||||
* and namespace.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to modify.
|
||||
* @param {string} namespace The unique namespace identifying the callback in the
|
||||
* form `vendor/plugin/function`.
|
||||
*
|
||||
* @return {number | undefined} The number of callbacks removed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will remove a specified hook or all
|
||||
* hooks by the given name.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
* @param {boolean} [removeAll=false] Whether to remove all callbacks for a hookName,
|
||||
* without regard to namespace. Used to create
|
||||
* `removeAll*` functions.
|
||||
*
|
||||
* @return {RemoveHook} Function that removes hooks.
|
||||
*/
|
||||
function createRemoveHook(hooks, storeKey, removeAll = false) {
|
||||
return function removeHook(hookName, namespace) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
if (!removeAll && !build_module_validateNamespace(namespace)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if no hooks exist by this name.
|
||||
if (!hooksStore[hookName]) {
|
||||
return 0;
|
||||
}
|
||||
let handlersRemoved = 0;
|
||||
if (removeAll) {
|
||||
handlersRemoved = hooksStore[hookName].handlers.length;
|
||||
hooksStore[hookName] = {
|
||||
runs: hooksStore[hookName].runs,
|
||||
handlers: []
|
||||
};
|
||||
} else {
|
||||
// Try to find the specified callback to remove.
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
for (let i = handlers.length - 1; i >= 0; i--) {
|
||||
if (handlers[i].namespace === namespace) {
|
||||
handlers.splice(i, 1);
|
||||
handlersRemoved++;
|
||||
// This callback may also be part of a hook that is
|
||||
// currently executing. If the callback we're removing
|
||||
// comes after the current callback, there's no problem;
|
||||
// otherwise we need to decrease the execution index of any
|
||||
// other runs by 1 to account for the removed element.
|
||||
hooksStore.__current.forEach(hookInfo => {
|
||||
if (hookInfo.name === hookName && hookInfo.currentIndex >= i) {
|
||||
hookInfo.currentIndex--;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hookName !== 'hookRemoved') {
|
||||
hooks.doAction('hookRemoved', hookName, namespace);
|
||||
}
|
||||
return handlersRemoved;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createRemoveHook = (createRemoveHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createHasHook.js
|
||||
/**
|
||||
* @callback HasHook
|
||||
*
|
||||
* Returns whether any handlers are attached for the given hookName and optional namespace.
|
||||
*
|
||||
* @param {string} hookName The name of the hook to check for.
|
||||
* @param {string} [namespace] Optional. The unique namespace identifying the callback
|
||||
* in the form `vendor/plugin/function`.
|
||||
*
|
||||
* @return {boolean} Whether there are handlers that are attached to the given hook.
|
||||
*/
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether any handlers are
|
||||
* attached to a particular hook.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
*
|
||||
* @return {HasHook} Function that returns whether any handlers are
|
||||
* attached to a particular hook and optional namespace.
|
||||
*/
|
||||
function createHasHook(hooks, storeKey) {
|
||||
return function hasHook(hookName, namespace) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
|
||||
// Use the namespace if provided.
|
||||
if ('undefined' !== typeof namespace) {
|
||||
return hookName in hooksStore && hooksStore[hookName].handlers.some(hook => hook.namespace === namespace);
|
||||
}
|
||||
return hookName in hooksStore;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createHasHook = (createHasHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createRunHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will execute all callbacks
|
||||
* registered to a hook of the specified type, optionally returning the final
|
||||
* value of the call chain.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
* @param {boolean} returnFirstArg Whether each hook callback is expected to return its first argument.
|
||||
* @param {boolean} async Whether the hook callback should be run asynchronously
|
||||
*
|
||||
* @return {(hookName:string, ...args: unknown[]) => undefined|unknown} Function that runs hook callbacks.
|
||||
*/
|
||||
function createRunHook(hooks, storeKey, returnFirstArg, async) {
|
||||
return function runHook(hookName, ...args) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!hooksStore[hookName]) {
|
||||
hooksStore[hookName] = {
|
||||
handlers: [],
|
||||
runs: 0
|
||||
};
|
||||
}
|
||||
hooksStore[hookName].runs++;
|
||||
const handlers = hooksStore[hookName].handlers;
|
||||
|
||||
// The following code is stripped from production builds.
|
||||
if (false) {}
|
||||
if (!handlers || !handlers.length) {
|
||||
return returnFirstArg ? args[0] : undefined;
|
||||
}
|
||||
const hookInfo = {
|
||||
name: hookName,
|
||||
currentIndex: 0
|
||||
};
|
||||
async function asyncRunner() {
|
||||
try {
|
||||
hooksStore.__current.add(hookInfo);
|
||||
let result = returnFirstArg ? args[0] : undefined;
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
const handler = handlers[hookInfo.currentIndex];
|
||||
result = await handler.callback.apply(null, args);
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
return returnFirstArg ? result : undefined;
|
||||
} finally {
|
||||
hooksStore.__current.delete(hookInfo);
|
||||
}
|
||||
}
|
||||
function syncRunner() {
|
||||
try {
|
||||
hooksStore.__current.add(hookInfo);
|
||||
let result = returnFirstArg ? args[0] : undefined;
|
||||
while (hookInfo.currentIndex < handlers.length) {
|
||||
const handler = handlers[hookInfo.currentIndex];
|
||||
result = handler.callback.apply(null, args);
|
||||
if (returnFirstArg) {
|
||||
args[0] = result;
|
||||
}
|
||||
hookInfo.currentIndex++;
|
||||
}
|
||||
return returnFirstArg ? result : undefined;
|
||||
} finally {
|
||||
hooksStore.__current.delete(hookInfo);
|
||||
}
|
||||
}
|
||||
return (async ? asyncRunner : syncRunner)();
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createRunHook = (createRunHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createCurrentHook.js
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the name of the
|
||||
* currently running hook, or `null` if no hook of the given type is currently
|
||||
* running.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
*
|
||||
* @return {() => string | null} Function that returns the current hook name or null.
|
||||
*/
|
||||
function createCurrentHook(hooks, storeKey) {
|
||||
return function currentHook() {
|
||||
var _currentArray$at$name;
|
||||
const hooksStore = hooks[storeKey];
|
||||
const currentArray = Array.from(hooksStore.__current);
|
||||
return (_currentArray$at$name = currentArray.at(-1)?.name) !== null && _currentArray$at$name !== void 0 ? _currentArray$at$name : null;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createCurrentHook = (createCurrentHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createDoingHook.js
|
||||
/**
|
||||
* @callback DoingHook
|
||||
* Returns whether a hook is currently being executed.
|
||||
*
|
||||
* @param {string} [hookName] The name of the hook to check for. If
|
||||
* omitted, will check for any hook being executed.
|
||||
*
|
||||
* @return {boolean} Whether the hook is being executed.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will return whether a hook is
|
||||
* currently being executed.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
*
|
||||
* @return {DoingHook} Function that returns whether a hook is currently
|
||||
* being executed.
|
||||
*/
|
||||
function createDoingHook(hooks, storeKey) {
|
||||
return function doingHook(hookName) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
|
||||
// If the hookName was not passed, check for any current hook.
|
||||
if ('undefined' === typeof hookName) {
|
||||
return hooksStore.__current.size > 0;
|
||||
}
|
||||
|
||||
// Find if the `hookName` hook is in `__current`.
|
||||
return Array.from(hooksStore.__current).some(hook => hook.name === hookName);
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createDoingHook = (createDoingHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createDidHook.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @callback DidHook
|
||||
*
|
||||
* Returns the number of times an action has been fired.
|
||||
*
|
||||
* @param {string} hookName The hook name to check.
|
||||
*
|
||||
* @return {number | undefined} The number of times the hook has run.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a function which, when invoked, will return the number of times a
|
||||
* hook has been called.
|
||||
*
|
||||
* @param {import('.').Hooks} hooks Hooks instance.
|
||||
* @param {import('.').StoreKey} storeKey
|
||||
*
|
||||
* @return {DidHook} Function that returns a hook's call count.
|
||||
*/
|
||||
function createDidHook(hooks, storeKey) {
|
||||
return function didHook(hookName) {
|
||||
const hooksStore = hooks[storeKey];
|
||||
if (!build_module_validateHookName(hookName)) {
|
||||
return;
|
||||
}
|
||||
return hooksStore[hookName] && hooksStore[hookName].runs ? hooksStore[hookName].runs : 0;
|
||||
};
|
||||
}
|
||||
/* harmony default export */ const build_module_createDidHook = (createDidHook);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/createHooks.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal class for constructing hooks. Use `createHooks()` function
|
||||
*
|
||||
* Note, it is necessary to expose this class to make its type public.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
class _Hooks {
|
||||
constructor() {
|
||||
/** @type {import('.').Store} actions */
|
||||
this.actions = Object.create(null);
|
||||
this.actions.__current = new Set();
|
||||
|
||||
/** @type {import('.').Store} filters */
|
||||
this.filters = Object.create(null);
|
||||
this.filters.__current = new Set();
|
||||
this.addAction = build_module_createAddHook(this, 'actions');
|
||||
this.addFilter = build_module_createAddHook(this, 'filters');
|
||||
this.removeAction = build_module_createRemoveHook(this, 'actions');
|
||||
this.removeFilter = build_module_createRemoveHook(this, 'filters');
|
||||
this.hasAction = build_module_createHasHook(this, 'actions');
|
||||
this.hasFilter = build_module_createHasHook(this, 'filters');
|
||||
this.removeAllActions = build_module_createRemoveHook(this, 'actions', true);
|
||||
this.removeAllFilters = build_module_createRemoveHook(this, 'filters', true);
|
||||
this.doAction = build_module_createRunHook(this, 'actions', false, false);
|
||||
this.doActionAsync = build_module_createRunHook(this, 'actions', false, true);
|
||||
this.applyFilters = build_module_createRunHook(this, 'filters', true, false);
|
||||
this.applyFiltersAsync = build_module_createRunHook(this, 'filters', true, true);
|
||||
this.currentAction = build_module_createCurrentHook(this, 'actions');
|
||||
this.currentFilter = build_module_createCurrentHook(this, 'filters');
|
||||
this.doingAction = build_module_createDoingHook(this, 'actions');
|
||||
this.doingFilter = build_module_createDoingHook(this, 'filters');
|
||||
this.didAction = build_module_createDidHook(this, 'actions');
|
||||
this.didFilter = build_module_createDidHook(this, 'filters');
|
||||
}
|
||||
}
|
||||
|
||||
/** @typedef {_Hooks} Hooks */
|
||||
|
||||
/**
|
||||
* Returns an instance of the hooks object.
|
||||
*
|
||||
* @return {Hooks} A Hooks instance.
|
||||
*/
|
||||
function createHooks() {
|
||||
return new _Hooks();
|
||||
}
|
||||
/* harmony default export */ const build_module_createHooks = (createHooks);
|
||||
|
||||
;// ./node_modules/@wordpress/hooks/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {(...args: any[])=>any} Callback */
|
||||
|
||||
/**
|
||||
* @typedef Handler
|
||||
* @property {Callback} callback The callback
|
||||
* @property {string} namespace The namespace
|
||||
* @property {number} priority The namespace
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Hook
|
||||
* @property {Handler[]} handlers Array of handlers
|
||||
* @property {number} runs Run counter
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef Current
|
||||
* @property {string} name Hook name
|
||||
* @property {number} currentIndex The index
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Record<string, Hook> & {__current: Set<Current>}} Store
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {'actions' | 'filters'} StoreKey
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {import('./createHooks').Hooks} Hooks
|
||||
*/
|
||||
|
||||
const defaultHooks = build_module_createHooks();
|
||||
const defaultHooks = (0,_createHooks__WEBPACK_IMPORTED_MODULE_1__/* ["default"] */ .A)();
|
||||
const {
|
||||
addAction,
|
||||
addFilter,
|
||||
@@ -617,6 +472,8 @@ const {
|
||||
} = defaultHooks;
|
||||
|
||||
|
||||
})();
|
||||
|
||||
(window.wp = window.wp || {}).hooks = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+8
-45
@@ -38,62 +38,25 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
||||
/* harmony export */ decodeEntities: () => (/* binding */ decodeEntities)
|
||||
/* harmony export */ });
|
||||
/** @type {HTMLTextAreaElement} */
|
||||
let _decodeTextArea;
|
||||
|
||||
/**
|
||||
* Decodes the HTML entities from a given string.
|
||||
*
|
||||
* @param {string} html String that contain HTML entities.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { decodeEntities } from '@wordpress/html-entities';
|
||||
*
|
||||
* const result = decodeEntities( 'á' );
|
||||
* console.log( result ); // result will be "á"
|
||||
* ```
|
||||
*
|
||||
* @return {string} The decoded string.
|
||||
*/
|
||||
function decodeEntities(html) {
|
||||
// Not a string, or no entities to decode.
|
||||
if ('string' !== typeof html || -1 === html.indexOf('&')) {
|
||||
if ("string" !== typeof html || -1 === html.indexOf("&")) {
|
||||
return html;
|
||||
}
|
||||
|
||||
// Create a textarea for decoding entities, that we can reuse.
|
||||
if (undefined === _decodeTextArea) {
|
||||
if (void 0 === _decodeTextArea) {
|
||||
if (document.implementation && document.implementation.createHTMLDocument) {
|
||||
_decodeTextArea = document.implementation.createHTMLDocument('').createElement('textarea');
|
||||
_decodeTextArea = document.implementation.createHTMLDocument("").createElement("textarea");
|
||||
} else {
|
||||
_decodeTextArea = document.createElement('textarea');
|
||||
_decodeTextArea = document.createElement("textarea");
|
||||
}
|
||||
}
|
||||
_decodeTextArea.innerHTML = html;
|
||||
const decoded = _decodeTextArea.textContent;
|
||||
_decodeTextArea.innerHTML = '';
|
||||
|
||||
/**
|
||||
* Cast to string, HTMLTextAreaElement should always have `string` textContent.
|
||||
*
|
||||
* > The `textContent` property of the `Node` interface represents the text content of the
|
||||
* > node and its descendants.
|
||||
* >
|
||||
* > Value: A string or `null`
|
||||
* >
|
||||
* > * If the node is a `document` or a Doctype, `textContent` returns `null`.
|
||||
* > * If the node is a CDATA section, comment, processing instruction, or text node,
|
||||
* > textContent returns the text inside the node, i.e., the `Node.nodeValue`.
|
||||
* > * For other node types, `textContent returns the concatenation of the textContent of
|
||||
* > every child node, excluding comments and processing instructions. (This is an empty
|
||||
* > string if the node has no children.)
|
||||
*
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
||||
*/
|
||||
return /** @type {string} */decoded;
|
||||
const decoded = _decodeTextArea.textContent ?? "";
|
||||
_decodeTextArea.innerHTML = "";
|
||||
return decoded;
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).htmlEntities = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let n;function o(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===n&&(n=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),n.innerHTML=e;const t=n.textContent;return n.innerHTML="",t}e.r(t),e.d(t,{decodeEntities:()=>o}),(window.wp=window.wp||{}).htmlEntities=t})();
|
||||
(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};let n;function o(e){if("string"!=typeof e||-1===e.indexOf("&"))return e;void 0===n&&(n=document.implementation&&document.implementation.createHTMLDocument?document.implementation.createHTMLDocument("").createElement("textarea"):document.createElement("textarea")),n.innerHTML=e;const t=n.textContent??"";return n.innerHTML="",t}e.r(t),e.d(t,{decodeEntities:()=>o}),(window.wp=window.wp||{}).htmlEntities=t})();
|
||||
Vendored
+291
-901
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+10
-39
@@ -45,14 +45,6 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
});
|
||||
|
||||
;// ./node_modules/@wordpress/is-shallow-equal/build-module/objects.js
|
||||
/**
|
||||
* Returns true if the two objects are shallow equal, or false otherwise.
|
||||
*
|
||||
* @param {import('.').ComparableObject} a First object to compare.
|
||||
* @param {import('.').ComparableObject} b Second object to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two objects are shallow equal.
|
||||
*/
|
||||
function isShallowEqualObjects(a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
@@ -67,12 +59,13 @@ function isShallowEqualObjects(a, b) {
|
||||
const key = aKeys[i];
|
||||
const aValue = a[key];
|
||||
if (
|
||||
// In iterating only the keys of the first object after verifying
|
||||
// equal lengths, account for the case that an explicit `undefined`
|
||||
// value in the first is implicitly undefined in the second.
|
||||
//
|
||||
// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
|
||||
aValue === undefined && !b.hasOwnProperty(key) || aValue !== b[key]) {
|
||||
// In iterating only the keys of the first object after verifying
|
||||
// equal lengths, account for the case that an explicit `undefined`
|
||||
// value in the first is implicitly undefined in the second.
|
||||
//
|
||||
// Example: isShallowEqualObjects( { a: undefined }, { b: 5 } )
|
||||
aValue === void 0 && !b.hasOwnProperty(key) || aValue !== b[key]
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
i++;
|
||||
@@ -80,15 +73,8 @@ function isShallowEqualObjects(a, b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/is-shallow-equal/build-module/arrays.js
|
||||
/**
|
||||
* Returns true if the two arrays are shallow equal, or false otherwise.
|
||||
*
|
||||
* @param {any[]} a First array to compare.
|
||||
* @param {any[]} b Second array to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two arrays are shallow equal.
|
||||
*/
|
||||
function isShallowEqualArrays(a, b) {
|
||||
if (a === b) {
|
||||
return true;
|
||||
@@ -104,28 +90,12 @@ function isShallowEqualArrays(a, b) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/is-shallow-equal/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Record<string, any>} ComparableObject
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns true if the two arrays or objects are shallow equal, or false
|
||||
* otherwise. Also handles primitive values, just in case.
|
||||
*
|
||||
* @param {unknown} a First object or array to compare.
|
||||
* @param {unknown} b Second object or array to compare.
|
||||
*
|
||||
* @return {boolean} Whether the two values are shallow equal.
|
||||
*/
|
||||
function isShallowEqual(a, b) {
|
||||
if (a && b) {
|
||||
if (a.constructor === Object && b.constructor === Object) {
|
||||
@@ -137,6 +107,7 @@ function isShallowEqual(a, b) {
|
||||
return a === b;
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).isShallowEqual = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+63
-566
@@ -69,17 +69,9 @@ __webpack_require__.d(selectors_namespaceObject, {
|
||||
;// external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/reducer.js
|
||||
/**
|
||||
* Reducer returning the registered shortcuts
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function reducer(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'REGISTER_SHORTCUT':
|
||||
case "REGISTER_SHORTCUT":
|
||||
return {
|
||||
...state,
|
||||
[action.name]: {
|
||||
@@ -89,86 +81,16 @@ function reducer(state = {}, action) {
|
||||
description: action.description
|
||||
}
|
||||
};
|
||||
case 'UNREGISTER_SHORTCUT':
|
||||
const {
|
||||
[action.name]: actionName,
|
||||
...remainingState
|
||||
} = state;
|
||||
case "UNREGISTER_SHORTCUT":
|
||||
const { [action.name]: actionName, ...remainingState } = state;
|
||||
return remainingState;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ const store_reducer = (reducer);
|
||||
var reducer_default = reducer;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/actions.js
|
||||
/** @typedef {import('@wordpress/keycodes').WPKeycodeModifier} WPKeycodeModifier */
|
||||
|
||||
/**
|
||||
* Keyboard key combination.
|
||||
*
|
||||
* @typedef {Object} WPShortcutKeyCombination
|
||||
*
|
||||
* @property {string} character Character.
|
||||
* @property {WPKeycodeModifier|undefined} modifier Modifier.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Configuration of a registered keyboard shortcut.
|
||||
*
|
||||
* @typedef {Object} WPShortcutConfig
|
||||
*
|
||||
* @property {string} name Shortcut name.
|
||||
* @property {string} category Shortcut category.
|
||||
* @property {string} description Shortcut description.
|
||||
* @property {WPShortcutKeyCombination} keyCombination Shortcut key combination.
|
||||
* @property {WPShortcutKeyCombination[]} [aliases] Shortcut aliases.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an action object used to register a new keyboard shortcut.
|
||||
*
|
||||
* @param {WPShortcutConfig} config Shortcut config.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useEffect } from 'react';
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect, useDispatch } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { registerShortcut } = useDispatch( keyboardShortcutsStore );
|
||||
*
|
||||
* useEffect( () => {
|
||||
* registerShortcut( {
|
||||
* name: 'custom/my-custom-shortcut',
|
||||
* category: 'my-category',
|
||||
* description: __( 'My custom shortcut' ),
|
||||
* keyCombination: {
|
||||
* modifier: 'primary',
|
||||
* character: 'j',
|
||||
* },
|
||||
* } );
|
||||
* }, [] );
|
||||
*
|
||||
* const shortcut = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'custom/my-custom-shortcut'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcut ? (
|
||||
* <p>{ __( 'Shortcut is registered.' ) }</p>
|
||||
* ) : (
|
||||
* <p>{ __( 'Shortcut is not registered.' ) }</p>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {Object} action.
|
||||
*/
|
||||
function registerShortcut({
|
||||
name,
|
||||
category,
|
||||
@@ -177,7 +99,7 @@ function registerShortcut({
|
||||
aliases
|
||||
}) {
|
||||
return {
|
||||
type: 'REGISTER_SHORTCUT',
|
||||
type: "REGISTER_SHORTCUT",
|
||||
name,
|
||||
category,
|
||||
keyCombination,
|
||||
@@ -185,536 +107,136 @@ function registerShortcut({
|
||||
description
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used to unregister a keyboard shortcut.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useEffect } from 'react';
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect, useDispatch } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { unregisterShortcut } = useDispatch( keyboardShortcutsStore );
|
||||
*
|
||||
* useEffect( () => {
|
||||
* unregisterShortcut( 'core/editor/next-region' );
|
||||
* }, [] );
|
||||
*
|
||||
* const shortcut = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcut ? (
|
||||
* <p>{ __( 'Shortcut is not unregistered.' ) }</p>
|
||||
* ) : (
|
||||
* <p>{ __( 'Shortcut is unregistered.' ) }</p>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {Object} action.
|
||||
*/
|
||||
function unregisterShortcut(name) {
|
||||
return {
|
||||
type: 'UNREGISTER_SHORTCUT',
|
||||
type: "UNREGISTER_SHORTCUT",
|
||||
name
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// external ["wp","keycodes"]
|
||||
const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/** @typedef {import('./actions').WPShortcutKeyCombination} WPShortcutKeyCombination */
|
||||
|
||||
/** @typedef {import('@wordpress/keycodes').WPKeycodeHandlerByModifier} WPKeycodeHandlerByModifier */
|
||||
|
||||
/**
|
||||
* Shared reference to an empty array for cases where it is important to avoid
|
||||
* returning a new array reference on every invocation.
|
||||
*
|
||||
* @type {Array<any>}
|
||||
*/
|
||||
const EMPTY_ARRAY = [];
|
||||
|
||||
/**
|
||||
* Shortcut formatting methods.
|
||||
*
|
||||
* @property {WPKeycodeHandlerByModifier} display Display formatting.
|
||||
* @property {WPKeycodeHandlerByModifier} rawShortcut Raw shortcut formatting.
|
||||
* @property {WPKeycodeHandlerByModifier} ariaLabel ARIA label formatting.
|
||||
*/
|
||||
const FORMATTING_METHODS = {
|
||||
display: external_wp_keycodes_namespaceObject.displayShortcut,
|
||||
raw: external_wp_keycodes_namespaceObject.rawShortcut,
|
||||
ariaLabel: external_wp_keycodes_namespaceObject.shortcutAriaLabel
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a string representing the key combination.
|
||||
*
|
||||
* @param {?WPShortcutKeyCombination} shortcut Key combination.
|
||||
* @param {keyof FORMATTING_METHODS} representation Type of representation
|
||||
* (display, raw, ariaLabel).
|
||||
*
|
||||
* @return {?string} Shortcut representation.
|
||||
*/
|
||||
function getKeyCombinationRepresentation(shortcut, representation) {
|
||||
if (!shortcut) {
|
||||
return null;
|
||||
}
|
||||
return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](shortcut.character) : shortcut.character;
|
||||
return shortcut.modifier ? FORMATTING_METHODS[representation][shortcut.modifier](
|
||||
shortcut.character
|
||||
) : shortcut.character;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the main key combination for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const {character, modifier} = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutKeyCombination(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* <div>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </div>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination?} Key combination.
|
||||
*/
|
||||
function getShortcutKeyCombination(state, name) {
|
||||
return state[name] ? state[name].keyCombination : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the main key combination for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {keyof FORMATTING_METHODS} representation Type of representation
|
||||
* (display, raw, ariaLabel).
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const {display, raw, ariaLabel} = useSelect(
|
||||
* ( select ) =>{
|
||||
* return {
|
||||
* display: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region' ),
|
||||
* raw: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region','raw' ),
|
||||
* ariaLabel: select( keyboardShortcutsStore ).getShortcutRepresentation('core/editor/next-region', 'ariaLabel')
|
||||
* }
|
||||
* },
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* <ul>
|
||||
* <li>{ sprintf( 'display string: %s', display ) }</li>
|
||||
* <li>{ sprintf( 'raw string: %s', raw ) }</li>
|
||||
* <li>{ sprintf( 'ariaLabel string: %s', ariaLabel ) }</li>
|
||||
* </ul>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {?string} Shortcut representation.
|
||||
*/
|
||||
function getShortcutRepresentation(state, name, representation = 'display') {
|
||||
function getShortcutRepresentation(state, name, representation = "display") {
|
||||
const shortcut = getShortcutKeyCombination(state, name);
|
||||
return getKeyCombinationRepresentation(shortcut, representation);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the shortcut description given its name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const shortcutDescription = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutDescription( 'core/editor/next-region' ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return shortcutDescription ? (
|
||||
* <div>{ shortcutDescription }</div>
|
||||
* ) : (
|
||||
* <div>{ __( 'No description.' ) }</div>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {?string} Shortcut description.
|
||||
*/
|
||||
function getShortcutDescription(state, name) {
|
||||
return state[name] ? state[name].description : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the aliases for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
* const ExampleComponent = () => {
|
||||
* const shortcutAliases = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getShortcutAliases(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* shortcutAliases.length > 0 && (
|
||||
* <ul>
|
||||
* { shortcutAliases.map( ( { character, modifier }, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination[]} Key combinations.
|
||||
*/
|
||||
function getShortcutAliases(state, name) {
|
||||
return state[name] && state[name].aliases ? state[name].aliases : EMPTY_ARRAY;
|
||||
}
|
||||
const getAllShortcutKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, name) => {
|
||||
return [
|
||||
getShortcutKeyCombination(state, name),
|
||||
...getShortcutAliases(state, name)
|
||||
].filter(Boolean);
|
||||
},
|
||||
(state, name) => [state[name]]
|
||||
);
|
||||
const getAllShortcutRawKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, name) => {
|
||||
return getAllShortcutKeyCombinations(state, name).map(
|
||||
(combination) => getKeyCombinationRepresentation(combination, "raw")
|
||||
);
|
||||
},
|
||||
(state, name) => [state[name]]
|
||||
);
|
||||
const getCategoryShortcuts = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, categoryName) => {
|
||||
return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
|
||||
},
|
||||
(state) => [state]
|
||||
);
|
||||
|
||||
/**
|
||||
* Returns the shortcuts that include aliases for a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const allShortcutKeyCombinations = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getAllShortcutKeyCombinations(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* allShortcutKeyCombinations.length > 0 && (
|
||||
* <ul>
|
||||
* { allShortcutKeyCombinations.map(
|
||||
* ( { character, modifier }, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* 'Character: <code>%s</code> / Modifier: <code>%s</code>',
|
||||
* character,
|
||||
* modifier
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* )
|
||||
* ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPShortcutKeyCombination[]} Key combinations.
|
||||
*/
|
||||
const getAllShortcutKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
|
||||
return [getShortcutKeyCombination(state, name), ...getShortcutAliases(state, name)].filter(Boolean);
|
||||
}, (state, name) => [state[name]]);
|
||||
|
||||
/**
|
||||
* Returns the raw representation of all the keyboard combinations of a given shortcut name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Shortcut name.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { createInterpolateElement } from '@wordpress/element';
|
||||
* import { sprintf } from '@wordpress/i18n';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const allShortcutRawKeyCombinations = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getAllShortcutRawKeyCombinations(
|
||||
* 'core/editor/next-region'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* allShortcutRawKeyCombinations.length > 0 && (
|
||||
* <ul>
|
||||
* { allShortcutRawKeyCombinations.map(
|
||||
* ( shortcutRawKeyCombination, index ) => (
|
||||
* <li key={ index }>
|
||||
* { createInterpolateElement(
|
||||
* sprintf(
|
||||
* ' <code>%s</code>',
|
||||
* shortcutRawKeyCombination
|
||||
* ),
|
||||
* {
|
||||
* code: <code />,
|
||||
* }
|
||||
* ) }
|
||||
* </li>
|
||||
* )
|
||||
* ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {string[]} Shortcuts.
|
||||
*/
|
||||
const getAllShortcutRawKeyCombinations = (0,external_wp_data_namespaceObject.createSelector)((state, name) => {
|
||||
return getAllShortcutKeyCombinations(state, name).map(combination => getKeyCombinationRepresentation(combination, 'raw'));
|
||||
}, (state, name) => [state[name]]);
|
||||
|
||||
/**
|
||||
* Returns the shortcut names list for a given category name.
|
||||
*
|
||||
* @param {Object} state Global state.
|
||||
* @param {string} name Category name.
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const categoryShortcuts = useSelect(
|
||||
* ( select ) =>
|
||||
* select( keyboardShortcutsStore ).getCategoryShortcuts(
|
||||
* 'block'
|
||||
* ),
|
||||
* []
|
||||
* );
|
||||
*
|
||||
* return (
|
||||
* categoryShortcuts.length > 0 && (
|
||||
* <ul>
|
||||
* { categoryShortcuts.map( ( categoryShortcut ) => (
|
||||
* <li key={ categoryShortcut }>{ categoryShortcut }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
* @return {string[]} Shortcut names.
|
||||
*/
|
||||
const getCategoryShortcuts = (0,external_wp_data_namespaceObject.createSelector)((state, categoryName) => {
|
||||
return Object.entries(state).filter(([, shortcut]) => shortcut.category === categoryName).map(([name]) => name);
|
||||
}, state => [state]);
|
||||
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/keyboard-shortcuts';
|
||||
|
||||
/**
|
||||
* Store definition for the keyboard shortcuts namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const STORE_NAME = "core/keyboard-shortcuts";
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: store_reducer,
|
||||
reducer: reducer_default,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut-event-match.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Returns a function to check if a keyboard event matches a shortcut name.
|
||||
*
|
||||
* @return {Function} A function to check if a keyboard event matches a
|
||||
* predefined shortcut combination.
|
||||
*/
|
||||
function useShortcutEventMatch() {
|
||||
const {
|
||||
getAllShortcutKeyCombinations
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(store);
|
||||
|
||||
/**
|
||||
* A function to check if a keyboard event matches a predefined shortcut
|
||||
* combination.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {KeyboardEvent} event Event to check.
|
||||
*
|
||||
* @return {boolean} True if the event matches any shortcuts, false if not.
|
||||
*/
|
||||
const { getAllShortcutKeyCombinations } = (0,external_wp_data_namespaceObject.useSelect)(
|
||||
store
|
||||
);
|
||||
function isMatch(name, event) {
|
||||
return getAllShortcutKeyCombinations(name).some(({
|
||||
modifier,
|
||||
character
|
||||
}) => {
|
||||
return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
|
||||
});
|
||||
return getAllShortcutKeyCombinations(name).some(
|
||||
({ modifier, character }) => {
|
||||
return external_wp_keycodes_namespaceObject.isKeyboardEvent[modifier](event, character);
|
||||
}
|
||||
);
|
||||
}
|
||||
return isMatch;
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const globalShortcuts = new Set();
|
||||
const globalListener = event => {
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/context.js
|
||||
|
||||
const globalShortcuts = /* @__PURE__ */ new Set();
|
||||
const globalListener = (event) => {
|
||||
for (const keyboardShortcut of globalShortcuts) {
|
||||
keyboardShortcut(event);
|
||||
}
|
||||
};
|
||||
const context = (0,external_wp_element_namespaceObject.createContext)({
|
||||
add: shortcut => {
|
||||
add: (shortcut) => {
|
||||
if (globalShortcuts.size === 0) {
|
||||
document.addEventListener('keydown', globalListener);
|
||||
document.addEventListener("keydown", globalListener);
|
||||
}
|
||||
globalShortcuts.add(shortcut);
|
||||
},
|
||||
delete: shortcut => {
|
||||
delete: (shortcut) => {
|
||||
globalShortcuts.delete(shortcut);
|
||||
if (globalShortcuts.size === 0) {
|
||||
document.removeEventListener('keydown', globalListener);
|
||||
document.removeEventListener("keydown", globalListener);
|
||||
}
|
||||
}
|
||||
});
|
||||
context.displayName = "KeyboardShortcutsContext";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/hooks/use-shortcut.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Attach a keyboard shortcut handler.
|
||||
*
|
||||
* @param {string} name Shortcut name.
|
||||
* @param {Function} callback Shortcut callback.
|
||||
* @param {Object} options Shortcut options.
|
||||
* @param {boolean} options.isDisabled Whether to disable to shortut.
|
||||
*/
|
||||
function useShortcut(name, callback, {
|
||||
isDisabled = false
|
||||
} = {}) {
|
||||
function useShortcut(name, callback, { isDisabled = false } = {}) {
|
||||
const shortcuts = (0,external_wp_element_namespaceObject.useContext)(context);
|
||||
const isMatch = useShortcutEventMatch();
|
||||
const callbackRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
@@ -737,34 +259,16 @@ function useShortcut(name, callback, {
|
||||
}, [name, isDisabled, shortcuts]);
|
||||
}
|
||||
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/components/shortcut-provider.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
const {
|
||||
Provider
|
||||
} = context;
|
||||
|
||||
/**
|
||||
* Handles callbacks added to context by `useShortcut`.
|
||||
* Adding a provider allows to register contextual shortcuts
|
||||
* that are only active when a certain part of the UI is focused.
|
||||
*
|
||||
* @param {Object} props Props to pass to `div`.
|
||||
*
|
||||
* @return {Element} Component.
|
||||
*/
|
||||
const { Provider } = context;
|
||||
function ShortcutProvider(props) {
|
||||
const [keyboardShortcuts] = (0,external_wp_element_namespaceObject.useState)(() => new Set());
|
||||
const [keyboardShortcuts] = (0,external_wp_element_namespaceObject.useState)(() => /* @__PURE__ */ new Set());
|
||||
function onKeyDown(event) {
|
||||
if (props.onKeyDown) {
|
||||
props.onKeyDown(event);
|
||||
@@ -773,24 +277,17 @@ function ShortcutProvider(props) {
|
||||
keyboardShortcut(event);
|
||||
}
|
||||
}
|
||||
|
||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Provider, {
|
||||
value: keyboardShortcuts,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
...props,
|
||||
onKeyDown: onKeyDown
|
||||
})
|
||||
});
|
||||
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(Provider, { value: keyboardShortcuts, children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { ...props, onKeyDown }) });
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/keyboard-shortcuts/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).keyboardShortcuts = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:()=>K,__unstableUseShortcutEventMatch:()=>R,store:()=>h,useShortcut:()=>T});var o={};e.r(o),e.d(o,{registerShortcut:()=>c,unregisterShortcut:()=>a});var n={};e.r(n),e.d(n,{getAllShortcutKeyCombinations:()=>m,getAllShortcutRawKeyCombinations:()=>p,getCategoryShortcuts:()=>b,getShortcutAliases:()=>w,getShortcutDescription:()=>f,getShortcutKeyCombination:()=>y,getShortcutRepresentation:()=>S});const r=window.wp.data;const i=function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:o,...n}=e;return n}return e};function c({name:e,category:t,description:o,keyCombination:n,aliases:r}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:n,aliases:r,description:o}}function a(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const s=window.wp.keycodes,u=[],d={display:s.displayShortcut,raw:s.rawShortcut,ariaLabel:s.shortcutAriaLabel};function l(e,t){return e?e.modifier?d[t][e.modifier](e.character):e.character:null}function y(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,o="display"){return l(y(e,t),o)}function f(e,t){return e[t]?e[t].description:null}function w(e,t){return e[t]&&e[t].aliases?e[t].aliases:u}const m=(0,r.createSelector)(((e,t)=>[y(e,t),...w(e,t)].filter(Boolean)),((e,t)=>[e[t]])),p=(0,r.createSelector)(((e,t)=>m(e,t).map((e=>l(e,"raw")))),((e,t)=>[e[t]])),b=(0,r.createSelector)(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),h=(0,r.createReduxStore)("core/keyboard-shortcuts",{reducer:i,actions:o,selectors:n});(0,r.register)(h);const g=window.wp.element;function R(){const{getAllShortcutKeyCombinations:e}=(0,r.useSelect)(h);return function(t,o){return e(t).some((({modifier:e,character:t})=>s.isKeyboardEvent[e](o,t)))}}const C=new Set,v=e=>{for(const t of C)t(e)},E=(0,g.createContext)({add:e=>{0===C.size&&document.addEventListener("keydown",v),C.add(e)},delete:e=>{C.delete(e),0===C.size&&document.removeEventListener("keydown",v)}});function T(e,t,{isDisabled:o=!1}={}){const n=(0,g.useContext)(E),r=R(),i=(0,g.useRef)();(0,g.useEffect)((()=>{i.current=t}),[t]),(0,g.useEffect)((()=>{if(!o)return n.add(t),()=>{n.delete(t)};function t(t){r(e,t)&&i.current(t)}}),[e,o,n])}const k=window.ReactJSXRuntime,{Provider:O}=E;function K(e){const[t]=(0,g.useState)((()=>new Set));return(0,k.jsx)(O,{value:t,children:(0,k.jsx)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}})})}(window.wp=window.wp||{}).keyboardShortcuts=t})();
|
||||
(()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ShortcutProvider:()=>K,__unstableUseShortcutEventMatch:()=>R,store:()=>h,useShortcut:()=>T});var o={};e.r(o),e.d(o,{registerShortcut:()=>c,unregisterShortcut:()=>a});var r={};e.r(r),e.d(r,{getAllShortcutKeyCombinations:()=>w,getAllShortcutRawKeyCombinations:()=>p,getCategoryShortcuts:()=>b,getShortcutAliases:()=>m,getShortcutDescription:()=>f,getShortcutKeyCombination:()=>y,getShortcutRepresentation:()=>S});const n=window.wp.data;var i=function(e={},t){switch(t.type){case"REGISTER_SHORTCUT":return{...e,[t.name]:{category:t.category,keyCombination:t.keyCombination,aliases:t.aliases,description:t.description}};case"UNREGISTER_SHORTCUT":const{[t.name]:o,...r}=e;return r}return e};function c({name:e,category:t,description:o,keyCombination:r,aliases:n}){return{type:"REGISTER_SHORTCUT",name:e,category:t,keyCombination:r,aliases:n,description:o}}function a(e){return{type:"UNREGISTER_SHORTCUT",name:e}}const s=window.wp.keycodes,u=[],d={display:s.displayShortcut,raw:s.rawShortcut,ariaLabel:s.shortcutAriaLabel};function l(e,t){return e?e.modifier?d[t][e.modifier](e.character):e.character:null}function y(e,t){return e[t]?e[t].keyCombination:null}function S(e,t,o="display"){return l(y(e,t),o)}function f(e,t){return e[t]?e[t].description:null}function m(e,t){return e[t]&&e[t].aliases?e[t].aliases:u}const w=(0,n.createSelector)(((e,t)=>[y(e,t),...m(e,t)].filter(Boolean)),((e,t)=>[e[t]])),p=(0,n.createSelector)(((e,t)=>w(e,t).map((e=>l(e,"raw")))),((e,t)=>[e[t]])),b=(0,n.createSelector)(((e,t)=>Object.entries(e).filter((([,e])=>e.category===t)).map((([e])=>e))),(e=>[e])),h=(0,n.createReduxStore)("core/keyboard-shortcuts",{reducer:i,actions:o,selectors:r});(0,n.register)(h);const g=window.wp.element;function R(){const{getAllShortcutKeyCombinations:e}=(0,n.useSelect)(h);return function(t,o){return e(t).some((({modifier:e,character:t})=>s.isKeyboardEvent[e](o,t)))}}const C=new Set,v=e=>{for(const t of C)t(e)},E=(0,g.createContext)({add:e=>{0===C.size&&document.addEventListener("keydown",v),C.add(e)},delete:e=>{C.delete(e),0===C.size&&document.removeEventListener("keydown",v)}});function T(e,t,{isDisabled:o=!1}={}){const r=(0,g.useContext)(E),n=R(),i=(0,g.useRef)();(0,g.useEffect)((()=>{i.current=t}),[t]),(0,g.useEffect)((()=>{if(!o)return r.add(t),()=>{r.delete(t)};function t(t){n(e,t)&&i.current(t)}}),[e,o,r])}E.displayName="KeyboardShortcutsContext";const k=window.ReactJSXRuntime,{Provider:O}=E;function K(e){const[t]=(0,g.useState)((()=>new Set));return(0,k.jsx)(O,{value:t,children:(0,k.jsx)("div",{...e,onKeyDown:function(o){e.onKeyDown&&e.onKeyDown(o);for(const e of t)e(o)}})})}(window.wp=window.wp||{}).keyboardShortcuts=t})();
|
||||
Vendored
+91
-320
@@ -71,206 +71,58 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
;// external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// ./node_modules/@wordpress/keycodes/build-module/platform.js
|
||||
/**
|
||||
* Return true if platform is MacOS.
|
||||
*
|
||||
* @param {Window?} _window window object by default; used for DI testing.
|
||||
*
|
||||
* @return {boolean} True if MacOS; false otherwise.
|
||||
*/
|
||||
function isAppleOS(_window = null) {
|
||||
function isAppleOS(_window) {
|
||||
if (!_window) {
|
||||
if (typeof window === 'undefined') {
|
||||
if (typeof window === "undefined") {
|
||||
return false;
|
||||
}
|
||||
_window = window;
|
||||
}
|
||||
const {
|
||||
platform
|
||||
} = _window.navigator;
|
||||
return platform.indexOf('Mac') !== -1 || ['iPad', 'iPhone'].includes(platform);
|
||||
const { platform } = _window.navigator;
|
||||
return platform.indexOf("Mac") !== -1 || ["iPad", "iPhone"].includes(platform);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/keycodes/build-module/index.js
|
||||
/**
|
||||
* Note: The order of the modifier keys in many of the [foo]Shortcut()
|
||||
* functions in this file are intentional and should not be changed. They're
|
||||
* designed to fit with the standard menu keyboard shortcuts shown in the
|
||||
* user's platform.
|
||||
*
|
||||
* For example, on MacOS menu shortcuts will place Shift before Command, but
|
||||
* on Windows Control will usually come first. So don't provide your own
|
||||
* shortcut combos directly to keyboardShortcut().
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {typeof ALT | CTRL | COMMAND | SHIFT } WPModifierPart */
|
||||
|
||||
/** @typedef {'primary' | 'primaryShift' | 'primaryAlt' | 'secondary' | 'access' | 'ctrl' | 'alt' | 'ctrlShift' | 'shift' | 'shiftAlt' | 'undefined'} WPKeycodeModifier */
|
||||
|
||||
/**
|
||||
* An object of handler functions for each of the possible modifier
|
||||
* combinations. A handler will return a value for a given key.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @typedef {Record<WPKeycodeModifier, T>} WPModifierHandler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @typedef {(character: string, isApple?: () => boolean) => T} WPKeyHandler
|
||||
*/
|
||||
/** @typedef {(event: import('react').KeyboardEvent<HTMLElement> | KeyboardEvent, character: string, isApple?: () => boolean) => boolean} WPEventKeyHandler */
|
||||
|
||||
/** @typedef {( isApple: () => boolean ) => WPModifierPart[]} WPModifier */
|
||||
|
||||
/**
|
||||
* Keycode for BACKSPACE key.
|
||||
*/
|
||||
const BACKSPACE = 8;
|
||||
|
||||
/**
|
||||
* Keycode for TAB key.
|
||||
*/
|
||||
const TAB = 9;
|
||||
|
||||
/**
|
||||
* Keycode for ENTER key.
|
||||
*/
|
||||
const ENTER = 13;
|
||||
|
||||
/**
|
||||
* Keycode for ESCAPE key.
|
||||
*/
|
||||
const ESCAPE = 27;
|
||||
|
||||
/**
|
||||
* Keycode for SPACE key.
|
||||
*/
|
||||
const SPACE = 32;
|
||||
|
||||
/**
|
||||
* Keycode for PAGEUP key.
|
||||
*/
|
||||
const PAGEUP = 33;
|
||||
|
||||
/**
|
||||
* Keycode for PAGEDOWN key.
|
||||
*/
|
||||
const PAGEDOWN = 34;
|
||||
|
||||
/**
|
||||
* Keycode for END key.
|
||||
*/
|
||||
const END = 35;
|
||||
|
||||
/**
|
||||
* Keycode for HOME key.
|
||||
*/
|
||||
const HOME = 36;
|
||||
|
||||
/**
|
||||
* Keycode for LEFT key.
|
||||
*/
|
||||
const LEFT = 37;
|
||||
|
||||
/**
|
||||
* Keycode for UP key.
|
||||
*/
|
||||
const UP = 38;
|
||||
|
||||
/**
|
||||
* Keycode for RIGHT key.
|
||||
*/
|
||||
const RIGHT = 39;
|
||||
|
||||
/**
|
||||
* Keycode for DOWN key.
|
||||
*/
|
||||
const DOWN = 40;
|
||||
|
||||
/**
|
||||
* Keycode for DELETE key.
|
||||
*/
|
||||
const DELETE = 46;
|
||||
|
||||
/**
|
||||
* Keycode for F10 key.
|
||||
*/
|
||||
const F10 = 121;
|
||||
|
||||
/**
|
||||
* Keycode for ALT key.
|
||||
*/
|
||||
const ALT = 'alt';
|
||||
|
||||
/**
|
||||
* Keycode for CTRL key.
|
||||
*/
|
||||
const CTRL = 'ctrl';
|
||||
|
||||
/**
|
||||
* Keycode for COMMAND/META key.
|
||||
*/
|
||||
const COMMAND = 'meta';
|
||||
|
||||
/**
|
||||
* Keycode for SHIFT key.
|
||||
*/
|
||||
const SHIFT = 'shift';
|
||||
|
||||
/**
|
||||
* Keycode for ZERO key.
|
||||
*/
|
||||
const ALT = "alt";
|
||||
const CTRL = "ctrl";
|
||||
const COMMAND = "meta";
|
||||
const SHIFT = "shift";
|
||||
const ZERO = 48;
|
||||
|
||||
|
||||
/**
|
||||
* Capitalise the first character of a string.
|
||||
* @param {string} string String to capitalise.
|
||||
* @return {string} Capitalised string.
|
||||
*/
|
||||
function capitaliseFirstCharacter(string) {
|
||||
return string.length < 2 ? string.toUpperCase() : string.charAt(0).toUpperCase() + string.slice(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map the values of an object with a specified callback and return the result object.
|
||||
*
|
||||
* @template {{ [s: string]: any; } | ArrayLike<any>} T
|
||||
*
|
||||
* @param {T} object Object to map values of.
|
||||
* @param {( value: any ) => any} mapFn Mapping function
|
||||
*
|
||||
* @return {any} Active modifier constants.
|
||||
*/
|
||||
function mapValues(object, mapFn) {
|
||||
return Object.fromEntries(Object.entries(object).map(([key, value]) => [key, mapFn(value)]));
|
||||
return Object.fromEntries(
|
||||
Object.entries(object).map(([key, value]) => [
|
||||
key,
|
||||
mapFn(value)
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Object that contains functions that return the available modifier
|
||||
* depending on platform.
|
||||
*
|
||||
* @type {WPModifierHandler< ( isApple: () => boolean ) => WPModifierPart[]>}
|
||||
*/
|
||||
const modifiers = {
|
||||
primary: _isApple => _isApple() ? [COMMAND] : [CTRL],
|
||||
primaryShift: _isApple => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
||||
primaryAlt: _isApple => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
||||
secondary: _isApple => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
||||
access: _isApple => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
||||
primary: (_isApple) => _isApple() ? [COMMAND] : [CTRL],
|
||||
primaryShift: (_isApple) => _isApple() ? [SHIFT, COMMAND] : [CTRL, SHIFT],
|
||||
primaryAlt: (_isApple) => _isApple() ? [ALT, COMMAND] : [CTRL, ALT],
|
||||
secondary: (_isApple) => _isApple() ? [SHIFT, ALT, COMMAND] : [CTRL, SHIFT, ALT],
|
||||
access: (_isApple) => _isApple() ? [CTRL, ALT] : [SHIFT, ALT],
|
||||
ctrl: () => [CTRL],
|
||||
alt: () => [ALT],
|
||||
ctrlShift: () => [CTRL, SHIFT],
|
||||
@@ -278,194 +130,113 @@ const modifiers = {
|
||||
shiftAlt: () => [SHIFT, ALT],
|
||||
undefined: () => []
|
||||
};
|
||||
|
||||
/**
|
||||
* An object that contains functions to get raw shortcuts.
|
||||
*
|
||||
* These are intended for user with the KeyboardShortcuts.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* rawShortcut.primary( 'm' )
|
||||
* // "meta+m""
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to raw
|
||||
* shortcuts.
|
||||
*/
|
||||
const rawShortcut = /* @__PURE__ */
|
||||
mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
|
||||
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
||||
return [...modifier(_isApple), character.toLowerCase()].join('+');
|
||||
const rawShortcut = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
||||
return (character, _isApple = isAppleOS) => {
|
||||
return [...modifier(_isApple), character.toLowerCase()].join(
|
||||
"+"
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* Return an array of the parts of a keyboard shortcut chord for display.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* displayShortcutList.primary( 'm' );
|
||||
* // [ "⌘", "M" ]
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string[]>>} Keyed map of functions to
|
||||
* shortcut sequences.
|
||||
*/
|
||||
const displayShortcutList = /* @__PURE__ */
|
||||
mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
|
||||
return /** @type {WPKeyHandler<string[]>} */(character, _isApple = isAppleOS) => {
|
||||
const isApple = _isApple();
|
||||
const replacementKeyMap = {
|
||||
[ALT]: isApple ? '⌥' : 'Alt',
|
||||
[CTRL]: isApple ? '⌃' : 'Ctrl',
|
||||
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
||||
[COMMAND]: '⌘',
|
||||
[SHIFT]: isApple ? '⇧' : 'Shift'
|
||||
const displayShortcutList = /* @__PURE__ */ mapValues(
|
||||
modifiers,
|
||||
(modifier) => {
|
||||
return (character, _isApple = isAppleOS) => {
|
||||
const isApple = _isApple();
|
||||
const replacementKeyMap = {
|
||||
[ALT]: isApple ? "\u2325" : "Alt",
|
||||
[CTRL]: isApple ? "\u2303" : "Ctrl",
|
||||
// Make sure ⌃ is the U+2303 UP ARROWHEAD unicode character and not the caret character.
|
||||
[COMMAND]: "\u2318",
|
||||
[SHIFT]: isApple ? "\u21E7" : "Shift"
|
||||
};
|
||||
const modifierKeys = modifier(_isApple).reduce(
|
||||
(accumulator, key) => {
|
||||
const replacementKey = replacementKeyMap[key] ?? key;
|
||||
if (isApple) {
|
||||
return [...accumulator, replacementKey];
|
||||
}
|
||||
return [...accumulator, replacementKey, "+"];
|
||||
},
|
||||
[]
|
||||
);
|
||||
return [
|
||||
...modifierKeys,
|
||||
capitaliseFirstCharacter(character)
|
||||
];
|
||||
};
|
||||
const modifierKeys = modifier(_isApple).reduce((accumulator, key) => {
|
||||
var _replacementKeyMap$ke;
|
||||
const replacementKey = (_replacementKeyMap$ke = replacementKeyMap[key]) !== null && _replacementKeyMap$ke !== void 0 ? _replacementKeyMap$ke : key;
|
||||
// If on the Mac, adhere to platform convention and don't show plus between keys.
|
||||
if (isApple) {
|
||||
return [...accumulator, replacementKey];
|
||||
}
|
||||
return [...accumulator, replacementKey, '+'];
|
||||
}, /** @type {string[]} */[]);
|
||||
return [...modifierKeys, capitaliseFirstCharacter(character)];
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* An object that contains functions to display shortcuts.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* displayShortcut.primary( 'm' );
|
||||
* // "⌘M"
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
||||
* display shortcuts.
|
||||
*/
|
||||
const displayShortcut = /* @__PURE__ */
|
||||
mapValues(displayShortcutList, (/** @type {WPKeyHandler<string[]>} */shortcutList) => {
|
||||
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => shortcutList(character, _isApple).join('');
|
||||
});
|
||||
|
||||
/**
|
||||
* An object that contains functions to return an aria label for a keyboard
|
||||
* shortcut.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming macOS:
|
||||
* shortcutAriaLabel.primary( '.' );
|
||||
* // "Command + Period"
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPKeyHandler<string>>} Keyed map of functions to
|
||||
* shortcut ARIA labels.
|
||||
*/
|
||||
const shortcutAriaLabel = /* @__PURE__ */
|
||||
mapValues(modifiers, (/** @type {WPModifier} */modifier) => {
|
||||
return /** @type {WPKeyHandler<string>} */(character, _isApple = isAppleOS) => {
|
||||
}
|
||||
);
|
||||
const displayShortcut = /* @__PURE__ */ mapValues(
|
||||
displayShortcutList,
|
||||
(shortcutList) => {
|
||||
return (character, _isApple = isAppleOS) => shortcutList(character, _isApple).join("");
|
||||
}
|
||||
);
|
||||
const shortcutAriaLabel = /* @__PURE__ */ mapValues(modifiers, (modifier) => {
|
||||
return (character, _isApple = isAppleOS) => {
|
||||
const isApple = _isApple();
|
||||
/** @type {Record<string,string>} */
|
||||
const replacementKeyMap = {
|
||||
[SHIFT]: 'Shift',
|
||||
[COMMAND]: isApple ? 'Command' : 'Control',
|
||||
[CTRL]: 'Control',
|
||||
[ALT]: isApple ? 'Option' : 'Alt',
|
||||
[SHIFT]: "Shift",
|
||||
[COMMAND]: isApple ? "Command" : "Control",
|
||||
[CTRL]: "Control",
|
||||
[ALT]: isApple ? "Option" : "Alt",
|
||||
/* translators: comma as in the character ',' */
|
||||
',': (0,external_wp_i18n_namespaceObject.__)('Comma'),
|
||||
",": (0,external_wp_i18n_namespaceObject.__)("Comma"),
|
||||
/* translators: period as in the character '.' */
|
||||
'.': (0,external_wp_i18n_namespaceObject.__)('Period'),
|
||||
".": (0,external_wp_i18n_namespaceObject.__)("Period"),
|
||||
/* translators: backtick as in the character '`' */
|
||||
'`': (0,external_wp_i18n_namespaceObject.__)('Backtick'),
|
||||
"`": (0,external_wp_i18n_namespaceObject.__)("Backtick"),
|
||||
/* translators: tilde as in the character '~' */
|
||||
'~': (0,external_wp_i18n_namespaceObject.__)('Tilde')
|
||||
"~": (0,external_wp_i18n_namespaceObject.__)("Tilde")
|
||||
};
|
||||
return [...modifier(_isApple), character].map(key => {
|
||||
var _replacementKeyMap$ke2;
|
||||
return capitaliseFirstCharacter((_replacementKeyMap$ke2 = replacementKeyMap[key]) !== null && _replacementKeyMap$ke2 !== void 0 ? _replacementKeyMap$ke2 : key);
|
||||
}).join(isApple ? ' ' : ' + ');
|
||||
return [...modifier(_isApple), character].map(
|
||||
(key) => capitaliseFirstCharacter(replacementKeyMap[key] ?? key)
|
||||
).join(isApple ? " " : " + ");
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* From a given KeyboardEvent, returns an array of active modifier constants for
|
||||
* the event.
|
||||
*
|
||||
* @param {import('react').KeyboardEvent<HTMLElement> | KeyboardEvent} event Keyboard event.
|
||||
*
|
||||
* @return {Array<WPModifierPart>} Active modifier constants.
|
||||
*/
|
||||
function getEventModifiers(event) {
|
||||
return /** @type {WPModifierPart[]} */[ALT, CTRL, COMMAND, SHIFT].filter(key => event[(/** @type {'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey'} */
|
||||
`${key}Key`)]);
|
||||
return [ALT, CTRL, COMMAND, SHIFT].filter(
|
||||
(key) => event[`${key}Key`]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* An object that contains functions to check if a keyboard event matches a
|
||||
* predefined shortcut combination.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Assuming an event for ⌘M key press:
|
||||
* isKeyboardEvent.primary( event, 'm' );
|
||||
* // true
|
||||
* ```
|
||||
*
|
||||
* @type {WPModifierHandler<WPEventKeyHandler>} Keyed map of functions
|
||||
* to match events.
|
||||
*/
|
||||
const isKeyboardEvent = /* @__PURE__ */
|
||||
mapValues(modifiers, (/** @type {WPModifier} */getModifiers) => {
|
||||
return /** @type {WPEventKeyHandler} */(event, character, _isApple = isAppleOS) => {
|
||||
const isKeyboardEvent = /* @__PURE__ */ mapValues(modifiers, (getModifiers) => {
|
||||
return (event, character, _isApple = isAppleOS) => {
|
||||
const mods = getModifiers(_isApple);
|
||||
const eventMods = getEventModifiers(event);
|
||||
/** @type {Record<string,string>} */
|
||||
const replacementWithShiftKeyMap = {
|
||||
Comma: ',',
|
||||
Backslash: '\\',
|
||||
Comma: ",",
|
||||
Backslash: "\\",
|
||||
// Windows returns `\` for both IntlRo and IntlYen.
|
||||
IntlRo: '\\',
|
||||
IntlYen: '\\'
|
||||
IntlRo: "\\",
|
||||
IntlYen: "\\"
|
||||
};
|
||||
const modsDiff = mods.filter(mod => !eventMods.includes(mod));
|
||||
const eventModsDiff = eventMods.filter(mod => !mods.includes(mod));
|
||||
const modsDiff = mods.filter(
|
||||
(mod) => !eventMods.includes(mod)
|
||||
);
|
||||
const eventModsDiff = eventMods.filter(
|
||||
(mod) => !mods.includes(mod)
|
||||
);
|
||||
if (modsDiff.length > 0 || eventModsDiff.length > 0) {
|
||||
return false;
|
||||
}
|
||||
let key = event.key.toLowerCase();
|
||||
if (!character) {
|
||||
return mods.includes(/** @type {WPModifierPart} */key);
|
||||
return mods.includes(key);
|
||||
}
|
||||
if (event.altKey && character.length === 1) {
|
||||
key = String.fromCharCode(event.keyCode).toLowerCase();
|
||||
}
|
||||
|
||||
// `event.key` returns the value of the key pressed, taking into the state of
|
||||
// modifier keys such as `Shift`. If the shift key is pressed, a different
|
||||
// value may be returned depending on the keyboard layout. It is necessary to
|
||||
// convert to the physical key value that don't take into account keyboard
|
||||
// layout or modifier key state.
|
||||
if (event.shiftKey && character.length === 1 && replacementWithShiftKeyMap[event.code]) {
|
||||
key = replacementWithShiftKeyMap[event.code];
|
||||
}
|
||||
|
||||
// For backwards compatibility.
|
||||
if (character === 'del') {
|
||||
character = 'delete';
|
||||
if (character === "del") {
|
||||
character = "delete";
|
||||
}
|
||||
return key === character.toLowerCase();
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).keycodes = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALT:()=>S,BACKSPACE:()=>n,COMMAND:()=>A,CTRL:()=>E,DELETE:()=>m,DOWN:()=>C,END:()=>u,ENTER:()=>l,ESCAPE:()=>a,F10:()=>w,HOME:()=>f,LEFT:()=>p,PAGEDOWN:()=>d,PAGEUP:()=>s,RIGHT:()=>h,SHIFT:()=>O,SPACE:()=>c,TAB:()=>i,UP:()=>y,ZERO:()=>P,displayShortcut:()=>_,displayShortcutList:()=>L,isAppleOS:()=>o,isKeyboardEvent:()=>k,modifiers:()=>T,rawShortcut:()=>v,shortcutAriaLabel:()=>j});const r=window.wp.i18n;function o(e=null){if(!e){if("undefined"==typeof window)return!1;e=window}const{platform:t}=e.navigator;return-1!==t.indexOf("Mac")||["iPad","iPhone"].includes(t)}const n=8,i=9,l=13,a=27,c=32,s=33,d=34,u=35,f=36,p=37,y=38,h=39,C=40,m=46,w=121,S="alt",E="ctrl",A="meta",O="shift",P=48;function b(e){return e.length<2?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)}function g(e,t){return Object.fromEntries(Object.entries(e).map((([e,r])=>[e,t(r)])))}const T={primary:e=>e()?[A]:[E],primaryShift:e=>e()?[O,A]:[E,O],primaryAlt:e=>e()?[S,A]:[E,S],secondary:e=>e()?[O,S,A]:[E,O,S],access:e=>e()?[E,S]:[O,S],ctrl:()=>[E],alt:()=>[S],ctrlShift:()=>[E,O],shift:()=>[O],shiftAlt:()=>[O,S],undefined:()=>[]},v=g(T,(e=>(t,r=o)=>[...e(r),t.toLowerCase()].join("+"))),L=g(T,(e=>(t,r=o)=>{const n=r(),i={[S]:n?"⌥":"Alt",[E]:n?"⌃":"Ctrl",[A]:"⌘",[O]:n?"⇧":"Shift"};return[...e(r).reduce(((e,t)=>{var r;const o=null!==(r=i[t])&&void 0!==r?r:t;return n?[...e,o]:[...e,o,"+"]}),[]),b(t)]})),_=g(L,(e=>(t,r=o)=>e(t,r).join(""))),j=g(T,(e=>(t,n=o)=>{const i=n(),l={[O]:"Shift",[A]:i?"Command":"Control",[E]:"Control",[S]:i?"Option":"Alt",",":(0,r.__)("Comma"),".":(0,r.__)("Period"),"`":(0,r.__)("Backtick"),"~":(0,r.__)("Tilde")};return[...e(n),t].map((e=>{var t;return b(null!==(t=l[e])&&void 0!==t?t:e)})).join(i?" ":" + ")}));const k=g(T,(e=>(t,r,n=o)=>{const i=e(n),l=function(e){return[S,E,A,O].filter((t=>e[`${t}Key`]))}(t),a={Comma:",",Backslash:"\\",IntlRo:"\\",IntlYen:"\\"},c=i.filter((e=>!l.includes(e))),s=l.filter((e=>!i.includes(e)));if(c.length>0||s.length>0)return!1;let d=t.key.toLowerCase();return r?(t.altKey&&1===r.length&&(d=String.fromCharCode(t.keyCode).toLowerCase()),t.shiftKey&&1===r.length&&a[t.code]&&(d=a[t.code]),"del"===r&&(r="delete"),d===r.toLowerCase()):i.includes(d)}));(window.wp=window.wp||{}).keycodes=t})();
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{ALT:()=>S,BACKSPACE:()=>n,COMMAND:()=>A,CTRL:()=>E,DELETE:()=>m,DOWN:()=>C,END:()=>f,ENTER:()=>l,ESCAPE:()=>a,F10:()=>w,HOME:()=>u,LEFT:()=>p,PAGEDOWN:()=>d,PAGEUP:()=>s,RIGHT:()=>h,SHIFT:()=>O,SPACE:()=>c,TAB:()=>i,UP:()=>y,ZERO:()=>P,displayShortcut:()=>j,displayShortcutList:()=>_,isAppleOS:()=>o,isKeyboardEvent:()=>v,modifiers:()=>T,rawShortcut:()=>L,shortcutAriaLabel:()=>k});const r=window.wp.i18n;function o(e){if(!e){if("undefined"==typeof window)return!1;e=window}const{platform:t}=e.navigator;return-1!==t.indexOf("Mac")||["iPad","iPhone"].includes(t)}const n=8,i=9,l=13,a=27,c=32,s=33,d=34,f=35,u=36,p=37,y=38,h=39,C=40,m=46,w=121,S="alt",E="ctrl",A="meta",O="shift",P=48;function b(e){return e.length<2?e.toUpperCase():e.charAt(0).toUpperCase()+e.slice(1)}function g(e,t){return Object.fromEntries(Object.entries(e).map((([e,r])=>[e,t(r)])))}const T={primary:e=>e()?[A]:[E],primaryShift:e=>e()?[O,A]:[E,O],primaryAlt:e=>e()?[S,A]:[E,S],secondary:e=>e()?[O,S,A]:[E,O,S],access:e=>e()?[E,S]:[O,S],ctrl:()=>[E],alt:()=>[S],ctrlShift:()=>[E,O],shift:()=>[O],shiftAlt:()=>[O,S],undefined:()=>[]},L=g(T,(e=>(t,r=o)=>[...e(r),t.toLowerCase()].join("+"))),_=g(T,(e=>(t,r=o)=>{const n=r(),i={[S]:n?"⌥":"Alt",[E]:n?"⌃":"Ctrl",[A]:"⌘",[O]:n?"⇧":"Shift"};return[...e(r).reduce(((e,t)=>{const r=i[t]??t;return n?[...e,r]:[...e,r,"+"]}),[]),b(t)]})),j=g(_,(e=>(t,r=o)=>e(t,r).join(""))),k=g(T,(e=>(t,n=o)=>{const i=n(),l={[O]:"Shift",[A]:i?"Command":"Control",[E]:"Control",[S]:i?"Option":"Alt",",":(0,r.__)("Comma"),".":(0,r.__)("Period"),"`":(0,r.__)("Backtick"),"~":(0,r.__)("Tilde")};return[...e(n),t].map((e=>b(l[e]??e))).join(i?" ":" + ")}));const v=g(T,(e=>(t,r,n=o)=>{const i=e(n),l=function(e){return[S,E,A,O].filter((t=>e[`${t}Key`]))}(t),a={Comma:",",Backslash:"\\",IntlRo:"\\",IntlYen:"\\"},c=i.filter((e=>!l.includes(e))),s=l.filter((e=>!i.includes(e)));if(c.length>0||s.length>0)return!1;let d=t.key.toLowerCase();return r?(t.altKey&&1===r.length&&(d=String.fromCharCode(t.keyCode).toLowerCase()),t.shiftKey&&1===r.length&&a[t.code]&&(d=a[t.code]),"del"===r&&(r="delete"),d===r.toLowerCase()):i.includes(d)}));(window.wp=window.wp||{}).keycodes=t})();
|
||||
+13982
File diff suppressed because it is too large
Load Diff
+2
File diff suppressed because one or more lines are too long
+111
-176
@@ -36,6 +36,8 @@
|
||||
/************************************************************************/
|
||||
var __webpack_exports__ = {};
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// external ["wp","i18n"]
|
||||
@@ -546,61 +548,41 @@ var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_w
|
||||
;// external ["wp","blob"]
|
||||
const external_wp_blob_namespaceObject = window["wp"]["blob"];
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Export a reusable block as a JSON file.
|
||||
*
|
||||
* @param {number} id
|
||||
*/
|
||||
async function exportReusableBlock(id) {
|
||||
const postType = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/types/wp_block`
|
||||
});
|
||||
const postType = await external_wp_apiFetch_default()({ path: `/wp/v2/types/wp_block` });
|
||||
const post = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/${postType.rest_base}/${id}?context=edit`
|
||||
});
|
||||
const title = post.title.raw;
|
||||
const content = post.content.raw;
|
||||
const syncStatus = post.wp_pattern_sync_status;
|
||||
const fileContent = JSON.stringify({
|
||||
__file: 'wp_block',
|
||||
title,
|
||||
content,
|
||||
syncStatus
|
||||
}, null, 2);
|
||||
const fileName = paramCase(title) + '.json';
|
||||
(0,external_wp_blob_namespaceObject.downloadBlob)(fileName, fileContent, 'application/json');
|
||||
const fileContent = JSON.stringify(
|
||||
{
|
||||
__file: "wp_block",
|
||||
title,
|
||||
content,
|
||||
syncStatus
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
const fileName = paramCase(title) + ".json";
|
||||
(0,external_wp_blob_namespaceObject.downloadBlob)(fileName, fileContent, "application/json");
|
||||
}
|
||||
/* harmony default export */ const utils_export = (exportReusableBlock);
|
||||
var export_default = exportReusableBlock;
|
||||
|
||||
|
||||
;// external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
|
||||
/**
|
||||
* Reads the textual content of the given file.
|
||||
*
|
||||
* @param {File} file File.
|
||||
* @return {Promise<string>} Content of the file.
|
||||
*/
|
||||
function readTextFile(file) {
|
||||
const reader = new window.FileReader();
|
||||
return new Promise(resolve => {
|
||||
return new Promise((resolve) => {
|
||||
reader.onload = () => {
|
||||
resolve(reader.result);
|
||||
};
|
||||
@@ -608,110 +590,80 @@ function readTextFile(file) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Import a reusable block from a JSON file.
|
||||
*
|
||||
* @param {File} file File.
|
||||
* @return {Promise} Promise returning the imported reusable block.
|
||||
*/
|
||||
async function importReusableBlock(file) {
|
||||
const fileContent = await readTextFile(file);
|
||||
let parsedContent;
|
||||
try {
|
||||
parsedContent = JSON.parse(fileContent);
|
||||
} catch (e) {
|
||||
throw new Error('Invalid JSON file');
|
||||
throw new Error("Invalid JSON file");
|
||||
}
|
||||
if (parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== 'string' || typeof parsedContent.content !== 'string' || parsedContent.syncStatus && typeof parsedContent.syncStatus !== 'string') {
|
||||
throw new Error('Invalid pattern JSON file');
|
||||
if (parsedContent.__file !== "wp_block" || !parsedContent.title || !parsedContent.content || typeof parsedContent.title !== "string" || typeof parsedContent.content !== "string" || parsedContent.syncStatus && typeof parsedContent.syncStatus !== "string") {
|
||||
throw new Error("Invalid pattern JSON file");
|
||||
}
|
||||
const postType = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/types/wp_block`
|
||||
});
|
||||
const postType = await external_wp_apiFetch_default()({ path: `/wp/v2/types/wp_block` });
|
||||
const reusableBlock = await external_wp_apiFetch_default()({
|
||||
path: `/wp/v2/${postType.rest_base}`,
|
||||
data: {
|
||||
title: parsedContent.title,
|
||||
content: parsedContent.content,
|
||||
status: 'publish',
|
||||
meta: parsedContent.syncStatus === 'unsynced' ? {
|
||||
wp_pattern_sync_status: parsedContent.syncStatus
|
||||
} : undefined
|
||||
status: "publish",
|
||||
meta: parsedContent.syncStatus === "unsynced" ? { wp_pattern_sync_status: parsedContent.syncStatus } : void 0
|
||||
},
|
||||
method: 'POST'
|
||||
method: "POST"
|
||||
});
|
||||
return reusableBlock;
|
||||
}
|
||||
/* harmony default export */ const utils_import = (importReusableBlock);
|
||||
var import_default = importReusableBlock;
|
||||
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function ImportForm({
|
||||
instanceId,
|
||||
onUpload
|
||||
}) {
|
||||
const inputId = 'list-reusable-blocks-import-form-' + instanceId;
|
||||
function ImportForm({ instanceId, onUpload }) {
|
||||
const inputId = "list-reusable-blocks-import-form-" + instanceId;
|
||||
const formRef = (0,external_wp_element_namespaceObject.useRef)();
|
||||
const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
|
||||
const [error, setError] = (0,external_wp_element_namespaceObject.useState)(null);
|
||||
const [file, setFile] = (0,external_wp_element_namespaceObject.useState)(null);
|
||||
const onChangeFile = event => {
|
||||
const onChangeFile = (event) => {
|
||||
setFile(event.target.files[0]);
|
||||
setError(null);
|
||||
};
|
||||
const onSubmit = event => {
|
||||
const onSubmit = (event) => {
|
||||
event.preventDefault();
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
setIsLoading({
|
||||
isLoading: true
|
||||
});
|
||||
utils_import(file).then(reusableBlock => {
|
||||
setIsLoading({ isLoading: true });
|
||||
import_default(file).then((reusableBlock) => {
|
||||
if (!formRef) {
|
||||
return;
|
||||
}
|
||||
setIsLoading(false);
|
||||
onUpload(reusableBlock);
|
||||
}).catch(errors => {
|
||||
}).catch((errors) => {
|
||||
if (!formRef) {
|
||||
return;
|
||||
}
|
||||
let uiMessage;
|
||||
switch (errors.message) {
|
||||
case 'Invalid JSON file':
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid JSON file');
|
||||
case "Invalid JSON file":
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)("Invalid JSON file");
|
||||
break;
|
||||
case 'Invalid pattern JSON file':
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Invalid pattern JSON file');
|
||||
case "Invalid pattern JSON file":
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)("Invalid pattern JSON file");
|
||||
break;
|
||||
default:
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)('Unknown error');
|
||||
uiMessage = (0,external_wp_i18n_namespaceObject.__)("Unknown error");
|
||||
}
|
||||
setIsLoading(false);
|
||||
setError(uiMessage);
|
||||
@@ -720,124 +672,107 @@ function ImportForm({
|
||||
const onDismissError = () => {
|
||||
setError(null);
|
||||
};
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("form", {
|
||||
className: "list-reusable-blocks-import-form",
|
||||
onSubmit: onSubmit,
|
||||
ref: formRef,
|
||||
children: [error && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
|
||||
status: "error",
|
||||
onRemove: () => onDismissError(),
|
||||
children: error
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
|
||||
htmlFor: inputId,
|
||||
className: "list-reusable-blocks-import-form__label",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('File')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
|
||||
id: inputId,
|
||||
type: "file",
|
||||
onChange: onChangeFile
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
__next40pxDefaultSize: true,
|
||||
type: "submit",
|
||||
isBusy: isLoading,
|
||||
accessibleWhenDisabled: true,
|
||||
disabled: !file || isLoading,
|
||||
variant: "secondary",
|
||||
className: "list-reusable-blocks-import-form__button",
|
||||
children: (0,external_wp_i18n_namespaceObject._x)('Import', 'button label')
|
||||
})]
|
||||
});
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(
|
||||
"form",
|
||||
{
|
||||
className: "list-reusable-blocks-import-form",
|
||||
onSubmit,
|
||||
ref: formRef,
|
||||
children: [
|
||||
error && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, { status: "error", onRemove: () => onDismissError(), children: error }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
"label",
|
||||
{
|
||||
htmlFor: inputId,
|
||||
className: "list-reusable-blocks-import-form__label",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)("File")
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("input", { id: inputId, type: "file", onChange: onChangeFile }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
__next40pxDefaultSize: true,
|
||||
type: "submit",
|
||||
isBusy: isLoading,
|
||||
accessibleWhenDisabled: true,
|
||||
disabled: !file || isLoading,
|
||||
variant: "secondary",
|
||||
className: "list-reusable-blocks-import-form__button",
|
||||
children: (0,external_wp_i18n_namespaceObject._x)("Import", "button label")
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
);
|
||||
}
|
||||
/* harmony default export */ const import_form = ((0,external_wp_compose_namespaceObject.withInstanceId)(ImportForm));
|
||||
var import_form_default = (0,external_wp_compose_namespaceObject.withInstanceId)(ImportForm);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function ImportDropdown({
|
||||
onUpload
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
|
||||
popoverProps: {
|
||||
placement: 'bottom-start'
|
||||
},
|
||||
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
||||
renderToggle: ({
|
||||
isOpen,
|
||||
onToggle
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
size: "compact",
|
||||
className: "list-reusable-blocks-import-dropdown__button",
|
||||
"aria-expanded": isOpen,
|
||||
onClick: onToggle,
|
||||
variant: "primary",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Import from JSON')
|
||||
}),
|
||||
renderContent: ({
|
||||
onClose
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_form, {
|
||||
onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload)
|
||||
})
|
||||
});
|
||||
function ImportDropdown({ onUpload }) {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Dropdown,
|
||||
{
|
||||
popoverProps: { placement: "bottom-start" },
|
||||
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
||||
renderToggle: ({ isOpen, onToggle }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
size: "compact",
|
||||
className: "list-reusable-blocks-import-dropdown__button",
|
||||
"aria-expanded": isOpen,
|
||||
onClick: onToggle,
|
||||
variant: "primary",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)("Import from JSON")
|
||||
}
|
||||
),
|
||||
renderContent: ({ onClose }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(import_form_default, { onUpload: (0,external_wp_compose_namespaceObject.pipe)(onClose, onUpload) })
|
||||
}
|
||||
);
|
||||
}
|
||||
/* harmony default export */ const import_dropdown = (ImportDropdown);
|
||||
var import_dropdown_default = ImportDropdown;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Setup Export Links.
|
||||
|
||||
document.body.addEventListener('click', event => {
|
||||
if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
|
||||
document.body.addEventListener("click", (event) => {
|
||||
if (!event.target.classList.contains("wp-list-reusable-blocks__export")) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
utils_export(event.target.dataset.id);
|
||||
export_default(event.target.dataset.id);
|
||||
});
|
||||
|
||||
// Setup Import Form.
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const button = document.querySelector('.page-title-action');
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const button = document.querySelector(".page-title-action");
|
||||
if (!button) {
|
||||
return;
|
||||
}
|
||||
const showNotice = () => {
|
||||
const notice = document.createElement('div');
|
||||
notice.className = 'notice notice-success is-dismissible';
|
||||
notice.innerHTML = `<p>${(0,external_wp_i18n_namespaceObject.__)('Pattern imported successfully!')}</p>`;
|
||||
const headerEnd = document.querySelector('.wp-header-end');
|
||||
const notice = document.createElement("div");
|
||||
notice.className = "notice notice-success is-dismissible";
|
||||
notice.innerHTML = `<p>${(0,external_wp_i18n_namespaceObject.__)("Pattern imported successfully!")}</p>`;
|
||||
const headerEnd = document.querySelector(".wp-header-end");
|
||||
if (!headerEnd) {
|
||||
return;
|
||||
}
|
||||
headerEnd.parentNode.insertBefore(notice, headerEnd);
|
||||
};
|
||||
const container = document.createElement('div');
|
||||
container.className = 'list-reusable-blocks__container';
|
||||
const container = document.createElement("div");
|
||||
container.className = "list-reusable-blocks__container";
|
||||
button.parentNode.insertBefore(container, button);
|
||||
(0,external_wp_element_namespaceObject.createRoot)(container).render(/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.StrictMode, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(import_dropdown, {
|
||||
onUpload: showNotice
|
||||
})
|
||||
}));
|
||||
(0,external_wp_element_namespaceObject.createRoot)(container).render(
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.StrictMode, { children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(import_dropdown_default, { onUpload: showNotice }) })
|
||||
);
|
||||
});
|
||||
|
||||
(window.wp = window.wp || {}).listReusableBlocks = __webpack_exports__;
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.element,n=window.wp.i18n;var o=function(){return o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},o.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function r(e){return e.toLowerCase()}var s=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],a=/[^A-Z0-9]+/gi;function i(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function l(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,o=void 0===n?s:n,l=t.stripRegexp,c=void 0===l?a:l,p=t.transform,d=void 0===p?r:p,u=t.delimiter,w=void 0===u?" ":u,f=i(i(e,o,"$1\0$2"),c,"\0"),m=0,b=f.length;"\0"===f.charAt(m);)m++;for(;"\0"===f.charAt(b-1);)b--;return f.slice(m,b).split("\0").map(d).join(w)}(e,o({delimiter:"."},t))}const c=window.wp.apiFetch;var p=e.n(c);const d=window.wp.blob;const u=async function(e){const t=await p()({path:"/wp/v2/types/wp_block"}),n=await p()({path:`/wp/v2/${t.rest_base}/${e}?context=edit`}),r=n.title.raw,s=n.content.raw,a=n.wp_pattern_sync_status,i=JSON.stringify({__file:"wp_block",title:r,content:s,syncStatus:a},null,2),c=(void 0===u&&(u={}),l(r,o({delimiter:"-"},u))+".json");var u;(0,d.downloadBlob)(c,i,"application/json")},w=window.wp.compose,f=window.wp.components;const m=async function(e){const t=await function(e){const t=new window.FileReader;return new Promise((n=>{t.onload=()=>{n(t.result)},t.readAsText(e)}))}(e);let n;try{n=JSON.parse(t)}catch(e){throw new Error("Invalid JSON file")}if("wp_block"!==n.__file||!n.title||!n.content||"string"!=typeof n.title||"string"!=typeof n.content||n.syncStatus&&"string"!=typeof n.syncStatus)throw new Error("Invalid pattern JSON file");const o=await p()({path:"/wp/v2/types/wp_block"});return await p()({path:`/wp/v2/${o.rest_base}`,data:{title:n.title,content:n.content,status:"publish",meta:"unsynced"===n.syncStatus?{wp_pattern_sync_status:n.syncStatus}:void 0},method:"POST"})},b=window.ReactJSXRuntime;const _=(0,w.withInstanceId)((function({instanceId:e,onUpload:o}){const r="list-reusable-blocks-import-form-"+e,s=(0,t.useRef)(),[a,i]=(0,t.useState)(!1),[l,c]=(0,t.useState)(null),[p,d]=(0,t.useState)(null);return(0,b.jsxs)("form",{className:"list-reusable-blocks-import-form",onSubmit:e=>{e.preventDefault(),p&&(i({isLoading:!0}),m(p).then((e=>{s&&(i(!1),o(e))})).catch((e=>{if(!s)return;let t;switch(e.message){case"Invalid JSON file":t=(0,n.__)("Invalid JSON file");break;case"Invalid pattern JSON file":t=(0,n.__)("Invalid pattern JSON file");break;default:t=(0,n.__)("Unknown error")}i(!1),c(t)})))},ref:s,children:[l&&(0,b.jsx)(f.Notice,{status:"error",onRemove:()=>{c(null)},children:l}),(0,b.jsx)("label",{htmlFor:r,className:"list-reusable-blocks-import-form__label",children:(0,n.__)("File")}),(0,b.jsx)("input",{id:r,type:"file",onChange:e=>{d(e.target.files[0]),c(null)}}),(0,b.jsx)(f.Button,{__next40pxDefaultSize:!0,type:"submit",isBusy:a,accessibleWhenDisabled:!0,disabled:!p||a,variant:"secondary",className:"list-reusable-blocks-import-form__button",children:(0,n._x)("Import","button label")})]})}));const v=function({onUpload:e}){return(0,b.jsx)(f.Dropdown,{popoverProps:{placement:"bottom-start"},contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:({isOpen:e,onToggle:t})=>(0,b.jsx)(f.Button,{size:"compact",className:"list-reusable-blocks-import-dropdown__button","aria-expanded":e,onClick:t,variant:"primary",children:(0,n.__)("Import from JSON")}),renderContent:({onClose:t})=>(0,b.jsx)(_,{onUpload:(0,w.pipe)(t,e)})})};document.body.addEventListener("click",(e=>{e.target.classList.contains("wp-list-reusable-blocks__export")&&(e.preventDefault(),u(e.target.dataset.id))})),document.addEventListener("DOMContentLoaded",(()=>{const e=document.querySelector(".page-title-action");if(!e)return;const o=document.createElement("div");o.className="list-reusable-blocks__container",e.parentNode.insertBefore(o,e),(0,t.createRoot)(o).render((0,b.jsx)(t.StrictMode,{children:(0,b.jsx)(v,{onUpload:()=>{const e=document.createElement("div");e.className="notice notice-success is-dismissible",e.innerHTML=`<p>${(0,n.__)("Pattern imported successfully!")}</p>`;const t=document.querySelector(".wp-header-end");t&&t.parentNode.insertBefore(e,t)}})}))})),(window.wp=window.wp||{}).listReusableBlocks={}})();
|
||||
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.ReactJSXRuntime,n=window.wp.element,o=window.wp.i18n;var r=function(){return r=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},r.apply(this,arguments)};Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function s(e){return e.toLowerCase()}var a=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],i=/[^A-Z0-9]+/gi;function l(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function c(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,o=void 0===n?a:n,r=t.stripRegexp,c=void 0===r?i:r,p=t.transform,d=void 0===p?s:p,u=t.delimiter,w=void 0===u?" ":u,f=l(l(e,o,"$1\0$2"),c,"\0"),m=0,b=f.length;"\0"===f.charAt(m);)m++;for(;"\0"===f.charAt(b-1);)b--;return f.slice(m,b).split("\0").map(d).join(w)}(e,r({delimiter:"."},t))}const p=window.wp.apiFetch;var d=e.n(p);const u=window.wp.blob;var w=async function(e){const t=await d()({path:"/wp/v2/types/wp_block"}),n=await d()({path:`/wp/v2/${t.rest_base}/${e}?context=edit`}),o=n.title.raw,s=n.content.raw,a=n.wp_pattern_sync_status,i=JSON.stringify({__file:"wp_block",title:o,content:s,syncStatus:a},null,2),l=(void 0===p&&(p={}),c(o,r({delimiter:"-"},p))+".json");var p;(0,u.downloadBlob)(l,i,"application/json")};const f=window.wp.compose,m=window.wp.components;var b=async function(e){const t=await function(e){const t=new window.FileReader;return new Promise((n=>{t.onload=()=>{n(t.result)},t.readAsText(e)}))}(e);let n;try{n=JSON.parse(t)}catch(e){throw new Error("Invalid JSON file")}if("wp_block"!==n.__file||!n.title||!n.content||"string"!=typeof n.title||"string"!=typeof n.content||n.syncStatus&&"string"!=typeof n.syncStatus)throw new Error("Invalid pattern JSON file");const o=await d()({path:"/wp/v2/types/wp_block"});return await d()({path:`/wp/v2/${o.rest_base}`,data:{title:n.title,content:n.content,status:"publish",meta:"unsynced"===n.syncStatus?{wp_pattern_sync_status:n.syncStatus}:void 0},method:"POST"})};var _=(0,f.withInstanceId)((function({instanceId:e,onUpload:r}){const s="list-reusable-blocks-import-form-"+e,a=(0,n.useRef)(),[i,l]=(0,n.useState)(!1),[c,p]=(0,n.useState)(null),[d,u]=(0,n.useState)(null);return(0,t.jsxs)("form",{className:"list-reusable-blocks-import-form",onSubmit:e=>{e.preventDefault(),d&&(l({isLoading:!0}),b(d).then((e=>{a&&(l(!1),r(e))})).catch((e=>{if(!a)return;let t;switch(e.message){case"Invalid JSON file":t=(0,o.__)("Invalid JSON file");break;case"Invalid pattern JSON file":t=(0,o.__)("Invalid pattern JSON file");break;default:t=(0,o.__)("Unknown error")}l(!1),p(t)})))},ref:a,children:[c&&(0,t.jsx)(m.Notice,{status:"error",onRemove:()=>{p(null)},children:c}),(0,t.jsx)("label",{htmlFor:s,className:"list-reusable-blocks-import-form__label",children:(0,o.__)("File")}),(0,t.jsx)("input",{id:s,type:"file",onChange:e=>{u(e.target.files[0]),p(null)}}),(0,t.jsx)(m.Button,{__next40pxDefaultSize:!0,type:"submit",isBusy:i,accessibleWhenDisabled:!0,disabled:!d||i,variant:"secondary",className:"list-reusable-blocks-import-form__button",children:(0,o._x)("Import","button label")})]})}));var v=function({onUpload:e}){return(0,t.jsx)(m.Dropdown,{popoverProps:{placement:"bottom-start"},contentClassName:"list-reusable-blocks-import-dropdown__content",renderToggle:({isOpen:e,onToggle:n})=>(0,t.jsx)(m.Button,{size:"compact",className:"list-reusable-blocks-import-dropdown__button","aria-expanded":e,onClick:n,variant:"primary",children:(0,o.__)("Import from JSON")}),renderContent:({onClose:n})=>(0,t.jsx)(_,{onUpload:(0,f.pipe)(n,e)})})};document.body.addEventListener("click",(e=>{e.target.classList.contains("wp-list-reusable-blocks__export")&&(e.preventDefault(),w(e.target.dataset.id))})),document.addEventListener("DOMContentLoaded",(()=>{const e=document.querySelector(".page-title-action");if(!e)return;const r=document.createElement("div");r.className="list-reusable-blocks__container",e.parentNode.insertBefore(r,e),(0,n.createRoot)(r).render((0,t.jsx)(n.StrictMode,{children:(0,t.jsx)(v,{onUpload:()=>{const e=document.createElement("div");e.className="notice notice-success is-dismissible",e.innerHTML=`<p>${(0,o.__)("Pattern imported successfully!")}</p>`;const t=document.querySelector(".wp-header-end");t&&t.parentNode.insertBefore(e,t)}})}))})),(window.wp=window.wp||{}).listReusableBlocks={}})();
|
||||
Vendored
+276
-482
File diff suppressed because it is too large
Load Diff
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+36
-501
@@ -66,24 +66,11 @@ __webpack_require__.d(selectors_namespaceObject, {
|
||||
;// external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/utils/on-sub-key.js
|
||||
/**
|
||||
* Higher-order reducer creator which creates a combined reducer object, keyed
|
||||
* by a property on the action object.
|
||||
*
|
||||
* @param {string} actionProperty Action property by which to key object.
|
||||
*
|
||||
* @return {Function} Higher-order reducer.
|
||||
*/
|
||||
const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
// Retrieve subkey from action. Do not track if undefined; useful for cases
|
||||
// where reducer is scoped by action shape.
|
||||
const onSubKey = (actionProperty) => (reducer) => (state = {}, action) => {
|
||||
const key = action[actionProperty];
|
||||
if (key === undefined) {
|
||||
if (key === void 0) {
|
||||
return state;
|
||||
}
|
||||
|
||||
// Avoid updating state if unchanged. Note that this also accounts for a
|
||||
// reducer which returns undefined on a key which is not yet tracked.
|
||||
const nextKeyState = reducer(state[key], action);
|
||||
if (nextKeyState === state[key]) {
|
||||
return state;
|
||||
@@ -93,133 +80,38 @@ const onSubKey = actionProperty => reducer => (state = {}, action) => {
|
||||
[key]: nextKeyState
|
||||
};
|
||||
};
|
||||
/* harmony default export */ const on_sub_key = (onSubKey);
|
||||
var on_sub_key_default = onSubKey;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/reducer.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer returning the next notices state. The notices state is an object
|
||||
* where each key is a context, its value an array of notice objects.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
const notices = on_sub_key('context')((state = [], action) => {
|
||||
const notices = on_sub_key_default("context")((state = [], action) => {
|
||||
switch (action.type) {
|
||||
case 'CREATE_NOTICE':
|
||||
// Avoid duplicates on ID.
|
||||
return [...state.filter(({
|
||||
id
|
||||
}) => id !== action.notice.id), action.notice];
|
||||
case 'REMOVE_NOTICE':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => id !== action.id);
|
||||
case 'REMOVE_NOTICES':
|
||||
return state.filter(({
|
||||
id
|
||||
}) => !action.ids.includes(id));
|
||||
case 'REMOVE_ALL_NOTICES':
|
||||
return state.filter(({
|
||||
type
|
||||
}) => type !== action.noticeType);
|
||||
case "CREATE_NOTICE":
|
||||
return [
|
||||
...state.filter(({ id }) => id !== action.notice.id),
|
||||
action.notice
|
||||
];
|
||||
case "REMOVE_NOTICE":
|
||||
return state.filter(({ id }) => id !== action.id);
|
||||
case "REMOVE_NOTICES":
|
||||
return state.filter(({ id }) => !action.ids.includes(id));
|
||||
case "REMOVE_ALL_NOTICES":
|
||||
return state.filter(({ type }) => type !== action.noticeType);
|
||||
}
|
||||
return state;
|
||||
});
|
||||
/* harmony default export */ const reducer = (notices);
|
||||
var reducer_default = notices;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/constants.js
|
||||
/**
|
||||
* Default context to use for notice grouping when not otherwise specified. Its
|
||||
* specific value doesn't hold much meaning, but it must be reasonably unique
|
||||
* and, more importantly, referenced consistently in the store implementation.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_CONTEXT = 'global';
|
||||
const DEFAULT_CONTEXT = "global";
|
||||
const DEFAULT_STATUS = "info";
|
||||
|
||||
/**
|
||||
* Default notice status.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const DEFAULT_STATUS = 'info';
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/actions.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNoticeAction Object describing a user action option associated with a notice.
|
||||
*
|
||||
* @property {string} label Message to use as action label.
|
||||
* @property {?string} url Optional URL of resource if action incurs
|
||||
* browser navigation.
|
||||
* @property {?Function} onClick Optional function to invoke when action is
|
||||
* triggered by user.
|
||||
*/
|
||||
|
||||
let uniqueId = 0;
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be created.
|
||||
*
|
||||
* @param {string|undefined} status Notice status ("info" if undefined is passed).
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Notice options.
|
||||
* @param {string} [options.context='global'] Context under which to
|
||||
* group notice.
|
||||
* @param {string} [options.id] Identifier for notice.
|
||||
* Automatically assigned
|
||||
* if not specified.
|
||||
* @param {boolean} [options.isDismissible=true] Whether the notice can
|
||||
* be dismissed by user.
|
||||
* @param {string} [options.type='default'] Type of notice, one of
|
||||
* `default`, or `snackbar`.
|
||||
* @param {boolean} [options.speak=true] Whether the notice
|
||||
* content should be
|
||||
* announced to screen
|
||||
* readers.
|
||||
* @param {Array<WPNoticeAction>} [options.actions] User actions to be
|
||||
* presented with notice.
|
||||
* @param {string} [options.icon] An icon displayed with the notice.
|
||||
* Only used when type is set to `snackbar`.
|
||||
* @param {boolean} [options.explicitDismiss] Whether the notice includes
|
||||
* an explicit dismiss button and
|
||||
* can't be dismissed by clicking
|
||||
* the body of the notice. Only applies
|
||||
* when type is set to `snackbar`.
|
||||
* @param {Function} [options.onDismiss] Called when the notice is dismissed.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () => createNotice( 'success', __( 'Notice message' ) ) }
|
||||
* >
|
||||
* { __( 'Generate a success notice!' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
const {
|
||||
speak = true,
|
||||
@@ -227,19 +119,15 @@ function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
context = DEFAULT_CONTEXT,
|
||||
id = `${context}${++uniqueId}`,
|
||||
actions = [],
|
||||
type = 'default',
|
||||
type = "default",
|
||||
__unstableHTML,
|
||||
icon = null,
|
||||
explicitDismiss = false,
|
||||
onDismiss
|
||||
} = options;
|
||||
|
||||
// The supported value shape of content is currently limited to plain text
|
||||
// strings. To avoid setting expectation that e.g. a React Element could be
|
||||
// supported, cast to a string.
|
||||
content = String(content);
|
||||
return {
|
||||
type: 'CREATE_NOTICE',
|
||||
type: "CREATE_NOTICE",
|
||||
context,
|
||||
notice: {
|
||||
id,
|
||||
@@ -256,419 +144,66 @@ function createNotice(status = DEFAULT_STATUS, content, options = {}) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a success notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createSuccessNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createSuccessNotice( __( 'Success!' ), {
|
||||
* type: 'snackbar',
|
||||
* icon: '🔥',
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a snackbar success notice!' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createSuccessNotice(content, options) {
|
||||
return createNotice('success', content, options);
|
||||
return createNotice("success", content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an info notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createInfoNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createInfoNotice( __( 'Something happened!' ), {
|
||||
* isDismissible: false,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a notice that cannot be dismissed.' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createInfoNotice(content, options) {
|
||||
return createNotice('info', content, options);
|
||||
return createNotice("info", content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that an error notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createErrorNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createErrorNotice( __( 'An error occurred!' ), {
|
||||
* type: 'snackbar',
|
||||
* explicitDismiss: true,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __(
|
||||
* 'Generate an snackbar error notice with explicit dismiss button.'
|
||||
* ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createErrorNotice(content, options) {
|
||||
return createNotice('error', content, options);
|
||||
return createNotice("error", content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a warning notice is to be
|
||||
* created. Refer to `createNotice` for options documentation.
|
||||
*
|
||||
* @see createNotice
|
||||
*
|
||||
* @param {string} content Notice message.
|
||||
* @param {Object} [options] Optional notice options.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const { createWarningNotice, createInfoNotice } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createWarningNotice( __( 'Warning!' ), {
|
||||
* onDismiss: () => {
|
||||
* createInfoNotice(
|
||||
* __( 'The warning has been dismissed!' )
|
||||
* );
|
||||
* },
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generates a warning notice with onDismiss callback' ) }
|
||||
* </Button>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function createWarningNotice(content, options) {
|
||||
return createNotice('warning', content, options);
|
||||
return createNotice("warning", content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a notice is to be removed.
|
||||
*
|
||||
* @param {string} id Notice unique identifier.
|
||||
* @param {string} [context='global'] Optional context (grouping) in which the notice is
|
||||
* intended to appear. Defaults to default context.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
|
||||
* const { createWarningNotice, removeNotice } = useDispatch( noticesStore );
|
||||
*
|
||||
* return (
|
||||
* <>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* createWarningNotice( __( 'Warning!' ), {
|
||||
* isDismissible: false,
|
||||
* } )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Generate a notice' ) }
|
||||
* </Button>
|
||||
* { notices.length > 0 && (
|
||||
* <Button onClick={ () => removeNotice( notices[ 0 ].id ) }>
|
||||
* { __( 'Remove the notice' ) }
|
||||
* </Button>
|
||||
* ) }
|
||||
* </>
|
||||
* );
|
||||
*};
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeNotice(id, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICE',
|
||||
type: "REMOVE_NOTICE",
|
||||
id,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all notices from a given context. Defaults to the default context.
|
||||
*
|
||||
* @param {string} noticeType The context to remove all notices from.
|
||||
* @param {string} context The context to remove all notices from.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch, useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* export const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) =>
|
||||
* select( noticesStore ).getNotices()
|
||||
* );
|
||||
* const { removeAllNotices } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <>
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.id }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeAllNotices()
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all notices', 'woo-gutenberg-products-block' ) }
|
||||
* </Button>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeAllNotices( 'snackbar' )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all snackbar notices', 'woo-gutenberg-products-block' ) }
|
||||
* </Button>
|
||||
* </>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeAllNotices(noticeType = 'default', context = DEFAULT_CONTEXT) {
|
||||
function removeAllNotices(noticeType = "default", context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_ALL_NOTICES',
|
||||
type: "REMOVE_ALL_NOTICES",
|
||||
noticeType,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that several notices are to be removed.
|
||||
*
|
||||
* @param {string[]} ids List of unique notice identifiers.
|
||||
* @param {string} [context='global'] Optional context (grouping) in which the notices are
|
||||
* intended to appear. Defaults to default context.
|
||||
* @example
|
||||
* ```js
|
||||
* import { __ } from '@wordpress/i18n';
|
||||
* import { useDispatch, useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
* import { Button } from '@wordpress/components';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) =>
|
||||
* select( noticesStore ).getNotices()
|
||||
* );
|
||||
* const { removeNotices } = useDispatch( noticesStore );
|
||||
* return (
|
||||
* <>
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.id }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* <Button
|
||||
* onClick={ () =>
|
||||
* removeNotices( notices.map( ( { id } ) => id ) )
|
||||
* }
|
||||
* >
|
||||
* { __( 'Clear all notices' ) }
|
||||
* </Button>
|
||||
* </>
|
||||
* );
|
||||
* };
|
||||
* ```
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function removeNotices(ids, context = DEFAULT_CONTEXT) {
|
||||
return {
|
||||
type: 'REMOVE_NOTICES',
|
||||
type: "REMOVE_NOTICES",
|
||||
ids,
|
||||
context
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/selectors.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {import('./actions').WPNoticeAction} WPNoticeAction */
|
||||
|
||||
/**
|
||||
* The default empty set of notices to return when there are no notices
|
||||
* assigned for a given notices context. This can occur if the getNotices
|
||||
* selector is called without a notice ever having been created for the
|
||||
* context. A shared value is used to ensure referential equality between
|
||||
* sequential selector calls, since otherwise `[] !== []`.
|
||||
*
|
||||
* @type {Array}
|
||||
*/
|
||||
const DEFAULT_NOTICES = [];
|
||||
|
||||
/**
|
||||
* @typedef {Object} WPNotice Notice object.
|
||||
*
|
||||
* @property {string} id Unique identifier of notice.
|
||||
* @property {string} status Status of notice, one of `success`,
|
||||
* `info`, `error`, or `warning`. Defaults
|
||||
* to `info`.
|
||||
* @property {string} content Notice message.
|
||||
* @property {string} spokenMessage Audibly announced message text used by
|
||||
* assistive technologies.
|
||||
* @property {string} __unstableHTML Notice message as raw HTML. Intended to
|
||||
* serve primarily for compatibility of
|
||||
* server-rendered notices, and SHOULD NOT
|
||||
* be used for notices. It is subject to
|
||||
* removal without notice.
|
||||
* @property {boolean} isDismissible Whether the notice can be dismissed by
|
||||
* user. Defaults to `true`.
|
||||
* @property {string} type Type of notice, one of `default`,
|
||||
* or `snackbar`. Defaults to `default`.
|
||||
* @property {boolean} speak Whether the notice content should be
|
||||
* announced to screen readers. Defaults to
|
||||
* `true`.
|
||||
* @property {WPNoticeAction[]} actions User actions to present with notice.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns all notices as an array, optionally for a given context. Defaults to
|
||||
* the global context.
|
||||
*
|
||||
* @param {Object} state Notices state.
|
||||
* @param {?string} context Optional grouping context.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*```js
|
||||
* import { useSelect } from '@wordpress/data';
|
||||
* import { store as noticesStore } from '@wordpress/notices';
|
||||
*
|
||||
* const ExampleComponent = () => {
|
||||
* const notices = useSelect( ( select ) => select( noticesStore ).getNotices() );
|
||||
* return (
|
||||
* <ul>
|
||||
* { notices.map( ( notice ) => (
|
||||
* <li key={ notice.ID }>{ notice.content }</li>
|
||||
* ) ) }
|
||||
* </ul>
|
||||
* )
|
||||
* };
|
||||
*```
|
||||
*
|
||||
* @return {WPNotice[]} Array of notices.
|
||||
*/
|
||||
function getNotices(state, context = DEFAULT_CONTEXT) {
|
||||
return state[context] || DEFAULT_NOTICES;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the notices namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)('core/notices', {
|
||||
reducer: reducer,
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)("core/notices", {
|
||||
reducer: reducer_default,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/notices/build-module/index.js
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).notices = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:()=>b});var n={};e.r(n),e.d(n,{createErrorNotice:()=>E,createInfoNotice:()=>f,createNotice:()=>l,createSuccessNotice:()=>d,createWarningNotice:()=>p,removeAllNotices:()=>O,removeNotice:()=>y,removeNotices:()=>N});var i={};e.r(i),e.d(i,{getNotices:()=>_});const r=window.wp.data,o=e=>t=>(n={},i)=>{const r=i[e];if(void 0===r)return n;const o=t(n[r],i);return o===n[r]?n:{...n,[r]:o}},c=o("context")(((e=[],t)=>{switch(t.type){case"CREATE_NOTICE":return[...e.filter((({id:e})=>e!==t.notice.id)),t.notice];case"REMOVE_NOTICE":return e.filter((({id:e})=>e!==t.id));case"REMOVE_NOTICES":return e.filter((({id:e})=>!t.ids.includes(e)));case"REMOVE_ALL_NOTICES":return e.filter((({type:e})=>e!==t.noticeType))}return e})),s="global",u="info";let a=0;function l(e=u,t,n={}){const{speak:i=!0,isDismissible:r=!0,context:o=s,id:c=`${o}${++a}`,actions:l=[],type:d="default",__unstableHTML:f,icon:E=null,explicitDismiss:p=!1,onDismiss:y}=n;return{type:"CREATE_NOTICE",context:o,notice:{id:c,status:e,content:t=String(t),spokenMessage:i?t:null,__unstableHTML:f,isDismissible:r,actions:l,type:d,icon:E,explicitDismiss:p,onDismiss:y}}}function d(e,t){return l("success",e,t)}function f(e,t){return l("info",e,t)}function E(e,t){return l("error",e,t)}function p(e,t){return l("warning",e,t)}function y(e,t=s){return{type:"REMOVE_NOTICE",id:e,context:t}}function O(e="default",t=s){return{type:"REMOVE_ALL_NOTICES",noticeType:e,context:t}}function N(e,t=s){return{type:"REMOVE_NOTICES",ids:e,context:t}}const T=[];function _(e,t=s){return e[t]||T}const b=(0,r.createReduxStore)("core/notices",{reducer:c,actions:n,selectors:i});(0,r.register)(b),(window.wp=window.wp||{}).notices=t})();
|
||||
(()=>{"use strict";var e={d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{store:()=>_});var n={};e.r(n),e.d(n,{createErrorNotice:()=>f,createInfoNotice:()=>d,createNotice:()=>a,createSuccessNotice:()=>l,createWarningNotice:()=>E,removeAllNotices:()=>y,removeNotice:()=>p,removeNotices:()=>O});var i={};e.r(i),e.d(i,{getNotices:()=>T});const r=window.wp.data;var o=(e=>t=>(n={},i)=>{const r=i[e];if(void 0===r)return n;const o=t(n[r],i);return o===n[r]?n:{...n,[r]:o}})("context")(((e=[],t)=>{switch(t.type){case"CREATE_NOTICE":return[...e.filter((({id:e})=>e!==t.notice.id)),t.notice];case"REMOVE_NOTICE":return e.filter((({id:e})=>e!==t.id));case"REMOVE_NOTICES":return e.filter((({id:e})=>!t.ids.includes(e)));case"REMOVE_ALL_NOTICES":return e.filter((({type:e})=>e!==t.noticeType))}return e}));const c="global",s="info";let u=0;function a(e=s,t,n={}){const{speak:i=!0,isDismissible:r=!0,context:o=c,id:a=`${o}${++u}`,actions:l=[],type:d="default",__unstableHTML:f,icon:E=null,explicitDismiss:p=!1,onDismiss:y}=n;return{type:"CREATE_NOTICE",context:o,notice:{id:a,status:e,content:t=String(t),spokenMessage:i?t:null,__unstableHTML:f,isDismissible:r,actions:l,type:d,icon:E,explicitDismiss:p,onDismiss:y}}}function l(e,t){return a("success",e,t)}function d(e,t){return a("info",e,t)}function f(e,t){return a("error",e,t)}function E(e,t){return a("warning",e,t)}function p(e,t=c){return{type:"REMOVE_NOTICE",id:e,context:t}}function y(e="default",t=c){return{type:"REMOVE_ALL_NOTICES",noticeType:e,context:t}}function O(e,t=c){return{type:"REMOVE_NOTICES",ids:e,context:t}}const N=[];function T(e,t=c){return e[t]||N}const _=(0,r.createReduxStore)("core/notices",{reducer:o,actions:n,selectors:i});(0,r.register)(_),(window.wp=window.wp||{}).notices=t})();
|
||||
Vendored
+115
-249
@@ -51,7 +51,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
DotTip: () => (/* reexport */ dot_tip),
|
||||
DotTip: () => (/* reexport */ dot_tip_default),
|
||||
store: () => (/* reexport */ store)
|
||||
});
|
||||
|
||||
@@ -80,179 +80,83 @@ var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external
|
||||
;// external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// ./node_modules/@wordpress/nux/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer that tracks which tips are in a guide. Each guide is represented by
|
||||
* an array which contains the tip identifiers contained within that guide.
|
||||
*
|
||||
* @param {Array} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Array} Updated state.
|
||||
*/
|
||||
function guides(state = [], action) {
|
||||
switch (action.type) {
|
||||
case 'TRIGGER_GUIDE':
|
||||
case "TRIGGER_GUIDE":
|
||||
return [...state, action.tipIds];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer that tracks whether or not tips are globally enabled.
|
||||
*
|
||||
* @param {boolean} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {boolean} Updated state.
|
||||
*/
|
||||
function areTipsEnabled(state = true, action) {
|
||||
switch (action.type) {
|
||||
case 'DISABLE_TIPS':
|
||||
case "DISABLE_TIPS":
|
||||
return false;
|
||||
case 'ENABLE_TIPS':
|
||||
case "ENABLE_TIPS":
|
||||
return true;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer that tracks which tips have been dismissed. If the state object
|
||||
* contains a tip identifier, then that tip is dismissed.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function dismissedTips(state = {}, action) {
|
||||
switch (action.type) {
|
||||
case 'DISMISS_TIP':
|
||||
case "DISMISS_TIP":
|
||||
return {
|
||||
...state,
|
||||
[action.id]: true
|
||||
};
|
||||
case 'ENABLE_TIPS':
|
||||
case "ENABLE_TIPS":
|
||||
return {};
|
||||
}
|
||||
return state;
|
||||
}
|
||||
const preferences = (0,external_wp_data_namespaceObject.combineReducers)({
|
||||
areTipsEnabled,
|
||||
dismissedTips
|
||||
});
|
||||
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
guides,
|
||||
preferences
|
||||
}));
|
||||
const preferences = (0,external_wp_data_namespaceObject.combineReducers)({ areTipsEnabled, dismissedTips });
|
||||
var reducer_default = (0,external_wp_data_namespaceObject.combineReducers)({ guides, preferences });
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/nux/build-module/store/actions.js
|
||||
/**
|
||||
* Returns an action object that, when dispatched, presents a guide that takes
|
||||
* the user through a series of tips step by step.
|
||||
*
|
||||
* @param {string[]} tipIds Which tips to show in the guide.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function triggerGuide(tipIds) {
|
||||
return {
|
||||
type: 'TRIGGER_GUIDE',
|
||||
type: "TRIGGER_GUIDE",
|
||||
tipIds
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, dismisses the given tip. A
|
||||
* dismissed tip will not show again.
|
||||
*
|
||||
* @param {string} id The tip to dismiss.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function dismissTip(id) {
|
||||
return {
|
||||
type: 'DISMISS_TIP',
|
||||
type: "DISMISS_TIP",
|
||||
id
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, prevents all tips from
|
||||
* showing again.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function disableTips() {
|
||||
return {
|
||||
type: 'DISABLE_TIPS'
|
||||
type: "DISABLE_TIPS"
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object that, when dispatched, makes all tips show again.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function enableTips() {
|
||||
return {
|
||||
type: 'ENABLE_TIPS'
|
||||
type: "ENABLE_TIPS"
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/nux/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An object containing information about a guide.
|
||||
*
|
||||
* @typedef {Object} NUXGuideInfo
|
||||
* @property {string[]} tipIds Which tips the guide contains.
|
||||
* @property {?string} currentTipId The guide's currently showing tip.
|
||||
* @property {?string} nextTipId The guide's next tip to show.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns an object describing the guide, if any, that the given tip is a part
|
||||
* of.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {string} tipId The tip to query.
|
||||
*
|
||||
* @return {?NUXGuideInfo} Information about the associated guide.
|
||||
*/
|
||||
const getAssociatedGuide = (0,external_wp_data_namespaceObject.createSelector)((state, tipId) => {
|
||||
for (const tipIds of state.guides) {
|
||||
if (tipIds.includes(tipId)) {
|
||||
const nonDismissedTips = tipIds.filter(tId => !Object.keys(state.preferences.dismissedTips).includes(tId));
|
||||
const [currentTipId = null, nextTipId = null] = nonDismissedTips;
|
||||
return {
|
||||
tipIds,
|
||||
currentTipId,
|
||||
nextTipId
|
||||
};
|
||||
const getAssociatedGuide = (0,external_wp_data_namespaceObject.createSelector)(
|
||||
(state, tipId) => {
|
||||
for (const tipIds of state.guides) {
|
||||
if (tipIds.includes(tipId)) {
|
||||
const nonDismissedTips = tipIds.filter(
|
||||
(tId) => !Object.keys(
|
||||
state.preferences.dismissedTips
|
||||
).includes(tId)
|
||||
);
|
||||
const [currentTipId = null, nextTipId = null] = nonDismissedTips;
|
||||
return { tipIds, currentTipId, nextTipId };
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}, state => [state.guides, state.preferences.dismissedTips]);
|
||||
|
||||
/**
|
||||
* Determines whether or not the given tip is showing. Tips are hidden if they
|
||||
* are disabled, have been dismissed, or are not the current tip in any
|
||||
* guide that they have been added to.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {string} tipId The tip to query.
|
||||
*
|
||||
* @return {boolean} Whether or not the given tip is showing.
|
||||
*/
|
||||
return null;
|
||||
},
|
||||
(state) => [state.guides, state.preferences.dismissedTips]
|
||||
);
|
||||
function isTipVisible(state, tipId) {
|
||||
if (!state.preferences.areTipsEnabled) {
|
||||
return false;
|
||||
@@ -266,55 +170,33 @@ function isTipVisible(state, tipId) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not tips are globally enabled.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
*
|
||||
* @return {boolean} Whether tips are globally enabled.
|
||||
*/
|
||||
function selectors_areTipsEnabled(state) {
|
||||
return state.preferences.areTipsEnabled;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/nux/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/nux';
|
||||
|
||||
/**
|
||||
* Store definition for the nux namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const STORE_NAME = "core/nux";
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
reducer: reducer_default,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject,
|
||||
persist: ['preferences']
|
||||
persist: ["preferences"]
|
||||
});
|
||||
|
||||
// Once we build a more generic persistence plugin that works across types of stores
|
||||
// we'd be able to replace this with a register call.
|
||||
(0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
reducer: reducer_default,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject,
|
||||
persist: ['preferences']
|
||||
persist: ["preferences"]
|
||||
});
|
||||
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// external ["wp","components"]
|
||||
@@ -325,27 +207,13 @@ const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/close.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const close_close = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_close = (close_close);
|
||||
var close_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" }) });
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/nux/build-module/components/dot-tip/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -353,18 +221,12 @@ const close_close = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function onClick(event) {
|
||||
// Tips are often nested within buttons. We stop propagation so that clicking
|
||||
// on a tip doesn't result in the button being clicked.
|
||||
event.stopPropagation();
|
||||
}
|
||||
function DotTip({
|
||||
position = 'middle right',
|
||||
position = "middle right",
|
||||
children,
|
||||
isVisible,
|
||||
hasNextTip,
|
||||
@@ -372,86 +234,90 @@ function DotTip({
|
||||
onDisable
|
||||
}) {
|
||||
const anchorParent = (0,external_wp_element_namespaceObject.useRef)(null);
|
||||
const onFocusOutsideCallback = (0,external_wp_element_namespaceObject.useCallback)(event => {
|
||||
if (!anchorParent.current) {
|
||||
return;
|
||||
}
|
||||
if (anchorParent.current.contains(event.relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
onDisable();
|
||||
}, [onDisable, anchorParent]);
|
||||
const onFocusOutsideCallback = (0,external_wp_element_namespaceObject.useCallback)(
|
||||
(event) => {
|
||||
if (!anchorParent.current) {
|
||||
return;
|
||||
}
|
||||
if (anchorParent.current.contains(event.relatedTarget)) {
|
||||
return;
|
||||
}
|
||||
onDisable();
|
||||
},
|
||||
[onDisable, anchorParent]
|
||||
);
|
||||
if (!isVisible) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Popover, {
|
||||
className: "nux-dot-tip",
|
||||
position: position,
|
||||
focusOnMount: true,
|
||||
role: "dialog",
|
||||
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Editor tips'),
|
||||
onClick: onClick,
|
||||
onFocusOutside: onFocusOutsideCallback,
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
children: children
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "link",
|
||||
onClick: onDismiss,
|
||||
children: hasNextTip ? (0,external_wp_i18n_namespaceObject.__)('See next tip') : (0,external_wp_i18n_namespaceObject.__)('Got it')
|
||||
})
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
size: "small",
|
||||
className: "nux-dot-tip__disable",
|
||||
icon: library_close,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Disable tips'),
|
||||
onClick: onDisable
|
||||
})]
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const dot_tip = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
|
||||
tipId
|
||||
}) => {
|
||||
const {
|
||||
isTipVisible,
|
||||
getAssociatedGuide
|
||||
} = select(store);
|
||||
const associatedGuide = getAssociatedGuide(tipId);
|
||||
return {
|
||||
isVisible: isTipVisible(tipId),
|
||||
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
|
||||
};
|
||||
}), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
|
||||
tipId
|
||||
}) => {
|
||||
const {
|
||||
dismissTip,
|
||||
disableTips
|
||||
} = dispatch(store);
|
||||
return {
|
||||
onDismiss() {
|
||||
dismissTip(tipId);
|
||||
},
|
||||
onDisable() {
|
||||
disableTips();
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(
|
||||
external_wp_components_namespaceObject.Popover,
|
||||
{
|
||||
className: "nux-dot-tip",
|
||||
position,
|
||||
focusOnMount: true,
|
||||
role: "dialog",
|
||||
"aria-label": (0,external_wp_i18n_namespaceObject.__)("Editor tips"),
|
||||
onClick,
|
||||
onFocusOutside: onFocusOutsideCallback,
|
||||
children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { children }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "link",
|
||||
onClick: onDismiss,
|
||||
children: hasNextTip ? (0,external_wp_i18n_namespaceObject.__)("See next tip") : (0,external_wp_i18n_namespaceObject.__)("Got it")
|
||||
}
|
||||
) }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
size: "small",
|
||||
className: "nux-dot-tip__disable",
|
||||
icon: close_default,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)("Disable tips"),
|
||||
onClick: onDisable
|
||||
}
|
||||
)
|
||||
]
|
||||
}
|
||||
};
|
||||
}))(DotTip));
|
||||
);
|
||||
}
|
||||
var dot_tip_default = (0,external_wp_compose_namespaceObject.compose)(
|
||||
(0,external_wp_data_namespaceObject.withSelect)((select, { tipId }) => {
|
||||
const { isTipVisible, getAssociatedGuide } = select(store);
|
||||
const associatedGuide = getAssociatedGuide(tipId);
|
||||
return {
|
||||
isVisible: isTipVisible(tipId),
|
||||
hasNextTip: !!(associatedGuide && associatedGuide.nextTipId)
|
||||
};
|
||||
}),
|
||||
(0,external_wp_data_namespaceObject.withDispatch)((dispatch, { tipId }) => {
|
||||
const { dismissTip, disableTips } = dispatch(store);
|
||||
return {
|
||||
onDismiss() {
|
||||
dismissTip(tipId);
|
||||
},
|
||||
onDisable() {
|
||||
disableTips();
|
||||
}
|
||||
};
|
||||
})
|
||||
)(DotTip);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/nux/build-module/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
external_wp_deprecated_default()('wp.nux', {
|
||||
since: '5.4',
|
||||
hint: 'wp.components.Guide can be used to show a user guide.',
|
||||
version: '6.2'
|
||||
external_wp_deprecated_default()("wp.nux", {
|
||||
since: "5.4",
|
||||
hint: "wp.components.Guide can be used to show a user guide.",
|
||||
version: "6.2"
|
||||
});
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).nux = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:i=>{var n=i&&i.__esModule?()=>i.default:()=>i;return e.d(n,{a:n}),n},d:(i,n)=>{for(var t in n)e.o(n,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:n[t]})},o:(e,i)=>Object.prototype.hasOwnProperty.call(e,i),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},i={};e.r(i),e.d(i,{DotTip:()=>P,store:()=>m});var n={};e.r(n),e.d(n,{disableTips:()=>l,dismissTip:()=>u,enableTips:()=>a,triggerGuide:()=>p});var t={};e.r(t),e.d(t,{areTipsEnabled:()=>T,getAssociatedGuide:()=>w,isTipVisible:()=>f});const s=window.wp.deprecated;var r=e.n(s);const o=window.wp.data;const c=(0,o.combineReducers)({areTipsEnabled:function(e=!0,i){switch(i.type){case"DISABLE_TIPS":return!1;case"ENABLE_TIPS":return!0}return e},dismissedTips:function(e={},i){switch(i.type){case"DISMISS_TIP":return{...e,[i.id]:!0};case"ENABLE_TIPS":return{}}return e}}),d=(0,o.combineReducers)({guides:function(e=[],i){return"TRIGGER_GUIDE"===i.type?[...e,i.tipIds]:e},preferences:c});function p(e){return{type:"TRIGGER_GUIDE",tipIds:e}}function u(e){return{type:"DISMISS_TIP",id:e}}function l(){return{type:"DISABLE_TIPS"}}function a(){return{type:"ENABLE_TIPS"}}const w=(0,o.createSelector)(((e,i)=>{for(const n of e.guides)if(n.includes(i)){const i=n.filter((i=>!Object.keys(e.preferences.dismissedTips).includes(i))),[t=null,s=null]=i;return{tipIds:n,currentTipId:t,nextTipId:s}}return null}),(e=>[e.guides,e.preferences.dismissedTips]));function f(e,i){if(!e.preferences.areTipsEnabled)return!1;if(e.preferences.dismissedTips?.hasOwnProperty(i))return!1;const n=w(e,i);return!n||n.currentTipId===i}function T(e){return e.preferences.areTipsEnabled}const b="core/nux",m=(0,o.createReduxStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});(0,o.registerStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});const I=window.wp.compose,S=window.wp.components,_=window.wp.i18n,x=window.wp.element,g=window.wp.primitives,h=window.ReactJSXRuntime,y=(0,h.jsx)(g.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,h.jsx)(g.Path,{d:"m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"})});function E(e){e.stopPropagation()}const P=(0,I.compose)((0,o.withSelect)(((e,{tipId:i})=>{const{isTipVisible:n,getAssociatedGuide:t}=e(m),s=t(i);return{isVisible:n(i),hasNextTip:!(!s||!s.nextTipId)}})),(0,o.withDispatch)(((e,{tipId:i})=>{const{dismissTip:n,disableTips:t}=e(m);return{onDismiss(){n(i)},onDisable(){t()}}})))((function({position:e="middle right",children:i,isVisible:n,hasNextTip:t,onDismiss:s,onDisable:r}){const o=(0,x.useRef)(null),c=(0,x.useCallback)((e=>{o.current&&(o.current.contains(e.relatedTarget)||r())}),[r,o]);return n?(0,h.jsxs)(S.Popover,{className:"nux-dot-tip",position:e,focusOnMount:!0,role:"dialog","aria-label":(0,_.__)("Editor tips"),onClick:E,onFocusOutside:c,children:[(0,h.jsx)("p",{children:i}),(0,h.jsx)("p",{children:(0,h.jsx)(S.Button,{__next40pxDefaultSize:!0,variant:"link",onClick:s,children:t?(0,_.__)("See next tip"):(0,_.__)("Got it")})}),(0,h.jsx)(S.Button,{size:"small",className:"nux-dot-tip__disable",icon:y,label:(0,_.__)("Disable tips"),onClick:r})]}):null}));r()("wp.nux",{since:"5.4",hint:"wp.components.Guide can be used to show a user guide.",version:"6.2"}),(window.wp=window.wp||{}).nux=i})();
|
||||
(()=>{"use strict";var e={n:i=>{var n=i&&i.__esModule?()=>i.default:()=>i;return e.d(n,{a:n}),n},d:(i,n)=>{for(var t in n)e.o(n,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:n[t]})},o:(e,i)=>Object.prototype.hasOwnProperty.call(e,i),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},i={};e.r(i),e.d(i,{DotTip:()=>E,store:()=>m});var n={};e.r(n),e.d(n,{disableTips:()=>a,dismissTip:()=>u,enableTips:()=>l,triggerGuide:()=>p});var t={};e.r(t),e.d(t,{areTipsEnabled:()=>T,getAssociatedGuide:()=>w,isTipVisible:()=>f});const s=window.wp.deprecated;var r=e.n(s);const o=window.wp.data;const c=(0,o.combineReducers)({areTipsEnabled:function(e=!0,i){switch(i.type){case"DISABLE_TIPS":return!1;case"ENABLE_TIPS":return!0}return e},dismissedTips:function(e={},i){switch(i.type){case"DISMISS_TIP":return{...e,[i.id]:!0};case"ENABLE_TIPS":return{}}return e}});var d=(0,o.combineReducers)({guides:function(e=[],i){return"TRIGGER_GUIDE"===i.type?[...e,i.tipIds]:e},preferences:c});function p(e){return{type:"TRIGGER_GUIDE",tipIds:e}}function u(e){return{type:"DISMISS_TIP",id:e}}function a(){return{type:"DISABLE_TIPS"}}function l(){return{type:"ENABLE_TIPS"}}const w=(0,o.createSelector)(((e,i)=>{for(const n of e.guides)if(n.includes(i)){const i=n.filter((i=>!Object.keys(e.preferences.dismissedTips).includes(i))),[t=null,s=null]=i;return{tipIds:n,currentTipId:t,nextTipId:s}}return null}),(e=>[e.guides,e.preferences.dismissedTips]));function f(e,i){if(!e.preferences.areTipsEnabled)return!1;if(e.preferences.dismissedTips?.hasOwnProperty(i))return!1;const n=w(e,i);return!n||n.currentTipId===i}function T(e){return e.preferences.areTipsEnabled}const b="core/nux",m=(0,o.createReduxStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});(0,o.registerStore)(b,{reducer:d,actions:n,selectors:t,persist:["preferences"]});const I=window.ReactJSXRuntime,S=window.wp.compose,_=window.wp.components,x=window.wp.i18n,g=window.wp.element,h=window.wp.primitives;var y=(0,I.jsx)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,I.jsx)(h.Path,{d:"m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"})});function v(e){e.stopPropagation()}var E=(0,S.compose)((0,o.withSelect)(((e,{tipId:i})=>{const{isTipVisible:n,getAssociatedGuide:t}=e(m),s=t(i);return{isVisible:n(i),hasNextTip:!(!s||!s.nextTipId)}})),(0,o.withDispatch)(((e,{tipId:i})=>{const{dismissTip:n,disableTips:t}=e(m);return{onDismiss(){n(i)},onDisable(){t()}}})))((function({position:e="middle right",children:i,isVisible:n,hasNextTip:t,onDismiss:s,onDisable:r}){const o=(0,g.useRef)(null),c=(0,g.useCallback)((e=>{o.current&&(o.current.contains(e.relatedTarget)||r())}),[r,o]);return n?(0,I.jsxs)(_.Popover,{className:"nux-dot-tip",position:e,focusOnMount:!0,role:"dialog","aria-label":(0,x.__)("Editor tips"),onClick:v,onFocusOutside:c,children:[(0,I.jsx)("p",{children:i}),(0,I.jsx)("p",{children:(0,I.jsx)(_.Button,{__next40pxDefaultSize:!0,variant:"link",onClick:s,children:t?(0,x.__)("See next tip"):(0,x.__)("Got it")})}),(0,I.jsx)(_.Button,{size:"small",className:"nux-dot-tip__disable",icon:y,label:(0,x.__)("Disable tips"),onClick:r})]}):null}));r()("wp.nux",{since:"5.4",hint:"wp.components.Guide can be used to show a user guide.",version:"6.2"}),(window.wp=window.wp||{}).nux=i})();
|
||||
Vendored
+918
-1026
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+96
-304
@@ -51,7 +51,7 @@ __webpack_require__.r(__webpack_exports__);
|
||||
|
||||
// EXPORTS
|
||||
__webpack_require__.d(__webpack_exports__, {
|
||||
PluginArea: () => (/* reexport */ plugin_area),
|
||||
PluginArea: () => (/* reexport */ plugin_area_default),
|
||||
getPlugin: () => (/* reexport */ getPlugin),
|
||||
getPlugins: () => (/* reexport */ getPlugins),
|
||||
registerPlugin: () => (/* reexport */ registerPlugin),
|
||||
@@ -60,6 +60,8 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
withPluginContext: () => (/* reexport */ withPluginContext)
|
||||
});
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/memize/dist/index.js
|
||||
/**
|
||||
* Memize options object.
|
||||
@@ -234,69 +236,38 @@ const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// external ["wp","deprecated"]
|
||||
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/plugins/build-module/components/plugin-context/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const Context = (0,external_wp_element_namespaceObject.createContext)({
|
||||
name: null,
|
||||
icon: null
|
||||
});
|
||||
Context.displayName = "PluginContext";
|
||||
const PluginContextProvider = Context.Provider;
|
||||
|
||||
/**
|
||||
* A hook that returns the plugin context.
|
||||
*
|
||||
* @return {PluginContext} Plugin context
|
||||
*/
|
||||
function usePluginContext() {
|
||||
return (0,external_wp_element_namespaceObject.useContext)(Context);
|
||||
}
|
||||
|
||||
/**
|
||||
* A Higher Order Component used to inject Plugin context to the
|
||||
* wrapped component.
|
||||
*
|
||||
* @deprecated 6.8.0 Use `usePluginContext` hook instead.
|
||||
*
|
||||
* @param mapContextToProps Function called on every context change,
|
||||
* expected to return object of props to
|
||||
* merge with the component's own props.
|
||||
*
|
||||
* @return {Component} Enhanced component with injected context as props.
|
||||
*/
|
||||
const withPluginContext = mapContextToProps => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(OriginalComponent => {
|
||||
external_wp_deprecated_default()('wp.plugins.withPluginContext', {
|
||||
since: '6.8.0',
|
||||
alternative: 'wp.plugins.usePluginContext'
|
||||
const withPluginContext = (mapContextToProps) => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)((OriginalComponent) => {
|
||||
external_wp_deprecated_default()("wp.plugins.withPluginContext", {
|
||||
since: "6.8.0",
|
||||
alternative: "wp.plugins.usePluginContext"
|
||||
});
|
||||
return props => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Context.Consumer, {
|
||||
children: context => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OriginalComponent, {
|
||||
return (props) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(Context.Consumer, { children: (context) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
OriginalComponent,
|
||||
{
|
||||
...props,
|
||||
...mapContextToProps(context, props)
|
||||
})
|
||||
});
|
||||
}, 'withPluginContext');
|
||||
}
|
||||
) });
|
||||
}, "withPluginContext");
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/plugins/build-module/components/plugin-error-boundary/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
class PluginErrorBoundary extends external_wp_element_namespaceObject.Component {
|
||||
/**
|
||||
* @param {Object} props
|
||||
*/
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@@ -304,19 +275,10 @@ class PluginErrorBoundary extends external_wp_element_namespaceObject.Component
|
||||
};
|
||||
}
|
||||
static getDerivedStateFromError() {
|
||||
return {
|
||||
hasError: true
|
||||
};
|
||||
return { hasError: true };
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Error} error Error object passed by React.
|
||||
*/
|
||||
componentDidCatch(error) {
|
||||
const {
|
||||
name,
|
||||
onError
|
||||
} = this.props;
|
||||
const { name, onError } = this.props;
|
||||
if (onError) {
|
||||
onError(name, error);
|
||||
}
|
||||
@@ -329,285 +291,104 @@ class PluginErrorBoundary extends external_wp_element_namespaceObject.Component
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
;// external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/plugins.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const plugins = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_plugins = (plugins);
|
||||
var plugins_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z" }) });
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/plugins/build-module/api/index.js
|
||||
/* eslint no-console: [ 'error', { allow: [ 'error' ] } ] */
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defined behavior of a plugin type.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Plugin definitions keyed by plugin name.
|
||||
*/
|
||||
const api_plugins = {};
|
||||
|
||||
/**
|
||||
* Registers a plugin to the editor.
|
||||
*
|
||||
* @param name A string identifying the plugin. Must be
|
||||
* unique across all registered plugins.
|
||||
* @param settings The settings for this plugin.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var el = React.createElement;
|
||||
* var Fragment = wp.element.Fragment;
|
||||
* var PluginSidebar = wp.editor.PluginSidebar;
|
||||
* var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
|
||||
* var registerPlugin = wp.plugins.registerPlugin;
|
||||
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
||||
*
|
||||
* function Component() {
|
||||
* return el(
|
||||
* Fragment,
|
||||
* {},
|
||||
* el(
|
||||
* PluginSidebarMoreMenuItem,
|
||||
* {
|
||||
* target: 'sidebar-name',
|
||||
* },
|
||||
* 'My Sidebar'
|
||||
* ),
|
||||
* el(
|
||||
* PluginSidebar,
|
||||
* {
|
||||
* name: 'sidebar-name',
|
||||
* title: 'My Sidebar',
|
||||
* },
|
||||
* 'Content of the sidebar'
|
||||
* )
|
||||
* );
|
||||
* }
|
||||
* registerPlugin( 'plugin-name', {
|
||||
* icon: moreIcon,
|
||||
* render: Component,
|
||||
* scope: 'my-page',
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { PluginSidebar, PluginSidebarMoreMenuItem } from '@wordpress/editor';
|
||||
* import { registerPlugin } from '@wordpress/plugins';
|
||||
* import { more } from '@wordpress/icons';
|
||||
*
|
||||
* const Component = () => (
|
||||
* <>
|
||||
* <PluginSidebarMoreMenuItem
|
||||
* target="sidebar-name"
|
||||
* >
|
||||
* My Sidebar
|
||||
* </PluginSidebarMoreMenuItem>
|
||||
* <PluginSidebar
|
||||
* name="sidebar-name"
|
||||
* title="My Sidebar"
|
||||
* >
|
||||
* Content of the sidebar
|
||||
* </PluginSidebar>
|
||||
* </>
|
||||
* );
|
||||
*
|
||||
* registerPlugin( 'plugin-name', {
|
||||
* icon: more,
|
||||
* render: Component,
|
||||
* scope: 'my-page',
|
||||
* } );
|
||||
* ```
|
||||
*
|
||||
* @return The final plugin settings object.
|
||||
*/
|
||||
const plugins = {};
|
||||
function registerPlugin(name, settings) {
|
||||
if (typeof settings !== 'object') {
|
||||
console.error('No settings object provided!');
|
||||
if (typeof settings !== "object") {
|
||||
console.error("No settings object provided!");
|
||||
return null;
|
||||
}
|
||||
if (typeof name !== 'string') {
|
||||
console.error('Plugin name must be string.');
|
||||
if (typeof name !== "string") {
|
||||
console.error("Plugin name must be string.");
|
||||
return null;
|
||||
}
|
||||
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
||||
console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".');
|
||||
console.error(
|
||||
'Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
if (api_plugins[name]) {
|
||||
if (plugins[name]) {
|
||||
console.error(`Plugin "${name}" is already registered.`);
|
||||
}
|
||||
settings = (0,external_wp_hooks_namespaceObject.applyFilters)('plugins.registerPlugin', settings, name);
|
||||
const {
|
||||
render,
|
||||
scope
|
||||
} = settings;
|
||||
if (typeof render !== 'function') {
|
||||
console.error('The "render" property must be specified and must be a valid function.');
|
||||
settings = (0,external_wp_hooks_namespaceObject.applyFilters)(
|
||||
"plugins.registerPlugin",
|
||||
settings,
|
||||
name
|
||||
);
|
||||
const { render, scope } = settings;
|
||||
if (typeof render !== "function") {
|
||||
console.error(
|
||||
'The "render" property must be specified and must be a valid function.'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
if (scope) {
|
||||
if (typeof scope !== 'string') {
|
||||
console.error('Plugin scope must be string.');
|
||||
if (typeof scope !== "string") {
|
||||
console.error("Plugin scope must be string.");
|
||||
return null;
|
||||
}
|
||||
if (!/^[a-z][a-z0-9-]*$/.test(scope)) {
|
||||
console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".');
|
||||
console.error(
|
||||
'Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'
|
||||
);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
api_plugins[name] = {
|
||||
plugins[name] = {
|
||||
name,
|
||||
icon: library_plugins,
|
||||
icon: plugins_default,
|
||||
...settings
|
||||
};
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginRegistered', settings, name);
|
||||
(0,external_wp_hooks_namespaceObject.doAction)("plugins.pluginRegistered", settings, name);
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a plugin by name.
|
||||
*
|
||||
* @param name Plugin name.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var unregisterPlugin = wp.plugins.unregisterPlugin;
|
||||
*
|
||||
* unregisterPlugin( 'plugin-name' );
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { unregisterPlugin } from '@wordpress/plugins';
|
||||
*
|
||||
* unregisterPlugin( 'plugin-name' );
|
||||
* ```
|
||||
*
|
||||
* @return The previous plugin settings object, if it has been
|
||||
* successfully unregistered; otherwise `undefined`.
|
||||
*/
|
||||
function unregisterPlugin(name) {
|
||||
if (!api_plugins[name]) {
|
||||
if (!plugins[name]) {
|
||||
console.error('Plugin "' + name + '" is not registered.');
|
||||
return;
|
||||
}
|
||||
const oldPlugin = api_plugins[name];
|
||||
delete api_plugins[name];
|
||||
(0,external_wp_hooks_namespaceObject.doAction)('plugins.pluginUnregistered', oldPlugin, name);
|
||||
const oldPlugin = plugins[name];
|
||||
delete plugins[name];
|
||||
(0,external_wp_hooks_namespaceObject.doAction)("plugins.pluginUnregistered", oldPlugin, name);
|
||||
return oldPlugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a registered plugin settings.
|
||||
*
|
||||
* @param name Plugin name.
|
||||
*
|
||||
* @return Plugin setting.
|
||||
*/
|
||||
function getPlugin(name) {
|
||||
return api_plugins[name];
|
||||
return plugins[name];
|
||||
}
|
||||
function getPlugins(scope) {
|
||||
return Object.values(plugins).filter(
|
||||
(plugin) => plugin.scope === scope
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all registered plugins without a scope or for a given scope.
|
||||
*
|
||||
* @param scope The scope to be used when rendering inside
|
||||
* a plugin area. No scope by default.
|
||||
*
|
||||
* @return The list of plugins without a scope or for a given scope.
|
||||
*/
|
||||
function getPlugins(scope) {
|
||||
return Object.values(api_plugins).filter(plugin => plugin.scope === scope);
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/plugins/build-module/components/plugin-area/index.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
const getPluginContext = memize((icon, name) => ({
|
||||
icon,
|
||||
name
|
||||
}));
|
||||
|
||||
/**
|
||||
* A component that renders all plugin fills in a hidden div.
|
||||
*
|
||||
* @param props
|
||||
* @param props.scope
|
||||
* @param props.onError
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ES5 syntax
|
||||
* var el = React.createElement;
|
||||
* var PluginArea = wp.plugins.PluginArea;
|
||||
*
|
||||
* function Layout() {
|
||||
* return el(
|
||||
* 'div',
|
||||
* { scope: 'my-page' },
|
||||
* 'Content of the page',
|
||||
* PluginArea
|
||||
* );
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* // Using ESNext syntax
|
||||
* import { PluginArea } from '@wordpress/plugins';
|
||||
*
|
||||
* const Layout = () => (
|
||||
* <div>
|
||||
* Content of the page
|
||||
* <PluginArea scope="my-page" />
|
||||
* </div>
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* @return {Component} The component to be rendered.
|
||||
*/
|
||||
const getPluginContext = memize(
|
||||
(icon, name) => ({
|
||||
icon,
|
||||
name
|
||||
})
|
||||
);
|
||||
function PluginArea({
|
||||
scope,
|
||||
onError
|
||||
@@ -616,11 +397,25 @@ function PluginArea({
|
||||
let lastValue = [];
|
||||
return {
|
||||
subscribe(listener) {
|
||||
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', listener);
|
||||
(0,external_wp_hooks_namespaceObject.addAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', listener);
|
||||
(0,external_wp_hooks_namespaceObject.addAction)(
|
||||
"plugins.pluginRegistered",
|
||||
"core/plugins/plugin-area/plugins-registered",
|
||||
listener
|
||||
);
|
||||
(0,external_wp_hooks_namespaceObject.addAction)(
|
||||
"plugins.pluginUnregistered",
|
||||
"core/plugins/plugin-area/plugins-unregistered",
|
||||
listener
|
||||
);
|
||||
return () => {
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)(
|
||||
"plugins.pluginRegistered",
|
||||
"core/plugins/plugin-area/plugins-registered"
|
||||
);
|
||||
(0,external_wp_hooks_namespaceObject.removeAction)(
|
||||
"plugins.pluginUnregistered",
|
||||
"core/plugins/plugin-area/plugins-unregistered"
|
||||
);
|
||||
};
|
||||
},
|
||||
getValue() {
|
||||
@@ -632,31 +427,28 @@ function PluginArea({
|
||||
}
|
||||
};
|
||||
}, [scope]);
|
||||
const plugins = (0,external_wp_element_namespaceObject.useSyncExternalStore)(store.subscribe, store.getValue, store.getValue);
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
style: {
|
||||
display: 'none'
|
||||
},
|
||||
children: plugins.map(({
|
||||
icon,
|
||||
name,
|
||||
render: Plugin
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginContextProvider, {
|
||||
const plugins = (0,external_wp_element_namespaceObject.useSyncExternalStore)(
|
||||
store.subscribe,
|
||||
store.getValue,
|
||||
store.getValue
|
||||
);
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { style: { display: "none" }, children: plugins.map(({ icon, name, render: Plugin }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
PluginContextProvider,
|
||||
{
|
||||
value: getPluginContext(icon, name),
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginErrorBoundary, {
|
||||
name: name,
|
||||
onError: onError,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Plugin, {})
|
||||
})
|
||||
}, name))
|
||||
});
|
||||
children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginErrorBoundary, { name, onError, children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(Plugin, {}) })
|
||||
},
|
||||
name
|
||||
)) });
|
||||
}
|
||||
/* harmony default export */ const plugin_area = (PluginArea);
|
||||
var plugin_area_default = PluginArea;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/plugins/build-module/components/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/plugins/build-module/index.js
|
||||
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{PluginArea:()=>j,getPlugin:()=>y,getPlugins:()=>P,registerPlugin:()=>f,unregisterPlugin:()=>x,usePluginContext:()=>g,withPluginContext:()=>d});const r=window.wp.element,t=window.wp.hooks,i=window.wp.isShallowEqual;var o=e.n(i);const l=window.wp.compose,s=window.wp.deprecated;var u=e.n(s);const a=window.ReactJSXRuntime,c=(0,r.createContext)({name:null,icon:null}),p=c.Provider;function g(){return(0,r.useContext)(c)}const d=e=>(0,l.createHigherOrderComponent)((n=>(u()("wp.plugins.withPluginContext",{since:"6.8.0",alternative:"wp.plugins.usePluginContext"}),r=>(0,a.jsx)(c.Consumer,{children:t=>(0,a.jsx)(n,{...r,...e(t,r)})}))),"withPluginContext");class v extends r.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){const{name:n,onError:r}=this.props;r&&r(n,e)}render(){return this.state.hasError?null:this.props.children}}const w=window.wp.primitives,h=(0,a.jsx)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(w.Path,{d:"M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"})}),m={};function f(e,n){if("object"!=typeof n)return console.error("No settings object provided!"),null;if("string"!=typeof e)return console.error("Plugin name must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(e))return console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'),null;m[e]&&console.error(`Plugin "${e}" is already registered.`),n=(0,t.applyFilters)("plugins.registerPlugin",n,e);const{render:r,scope:i}=n;if("function"!=typeof r)return console.error('The "render" property must be specified and must be a valid function.'),null;if(i){if("string"!=typeof i)return console.error("Plugin scope must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(i))return console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'),null}return m[e]={name:e,icon:h,...n},(0,t.doAction)("plugins.pluginRegistered",n,e),n}function x(e){if(!m[e])return void console.error('Plugin "'+e+'" is not registered.');const n=m[e];return delete m[e],(0,t.doAction)("plugins.pluginUnregistered",n,e),n}function y(e){return m[e]}function P(e){return Object.values(m).filter((n=>n.scope===e))}const b=function(e,n){var r,t,i=0;function o(){var o,l,s=r,u=arguments.length;e:for(;s;){if(s.args.length===arguments.length){for(l=0;l<u;l++)if(s.args[l]!==arguments[l]){s=s.next;continue e}return s!==r&&(s===t&&(t=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=r,s.prev=null,r.prev=s,r=s),s.val}s=s.next}for(o=new Array(u),l=0;l<u;l++)o[l]=arguments[l];return s={args:o,val:e.apply(null,o)},r?(r.prev=s,s.next=r):t=s,i===n.maxSize?(t=t.prev).next=null:i++,r=s,s.val}return n=n||{},o.clear=function(){r=null,t=null,i=0},o}(((e,n)=>({icon:e,name:n})));const j=function({scope:e,onError:n}){const i=(0,r.useMemo)((()=>{let n=[];return{subscribe:e=>((0,t.addAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered",e),(0,t.addAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered",e),()=>{(0,t.removeAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered"),(0,t.removeAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered")}),getValue(){const r=P(e);return o()(n,r)||(n=r),n}}}),[e]),l=(0,r.useSyncExternalStore)(i.subscribe,i.getValue,i.getValue);return(0,a.jsx)("div",{style:{display:"none"},children:l.map((({icon:e,name:r,render:t})=>(0,a.jsx)(p,{value:b(e,r),children:(0,a.jsx)(v,{name:r,onError:n,children:(0,a.jsx)(t,{})})},r)))})};(window.wp=window.wp||{}).plugins=n})();
|
||||
(()=>{"use strict";var e={n:n=>{var r=n&&n.__esModule?()=>n.default:()=>n;return e.d(r,{a:r}),r},d:(n,r)=>{for(var t in r)e.o(r,t)&&!e.o(n,t)&&Object.defineProperty(n,t,{enumerable:!0,get:r[t]})},o:(e,n)=>Object.prototype.hasOwnProperty.call(e,n),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},n={};e.r(n),e.d(n,{PluginArea:()=>j,getPlugin:()=>y,getPlugins:()=>P,registerPlugin:()=>f,unregisterPlugin:()=>x,usePluginContext:()=>g,withPluginContext:()=>d});const r=window.ReactJSXRuntime;const t=window.wp.element,i=window.wp.hooks,o=window.wp.isShallowEqual;var l=e.n(o);const s=window.wp.compose,u=window.wp.deprecated;var a=e.n(u);const c=(0,t.createContext)({name:null,icon:null});c.displayName="PluginContext";const p=c.Provider;function g(){return(0,t.useContext)(c)}const d=e=>(0,s.createHigherOrderComponent)((n=>(a()("wp.plugins.withPluginContext",{since:"6.8.0",alternative:"wp.plugins.usePluginContext"}),t=>(0,r.jsx)(c.Consumer,{children:i=>(0,r.jsx)(n,{...t,...e(i,t)})}))),"withPluginContext");class v extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){const{name:n,onError:r}=this.props;r&&r(n,e)}render(){return this.state.hasError?null:this.props.children}}const w=window.wp.primitives;var m=(0,r.jsx)(w.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(w.Path,{d:"M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"})});const h={};function f(e,n){if("object"!=typeof n)return console.error("No settings object provided!"),null;if("string"!=typeof e)return console.error("Plugin name must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(e))return console.error('Plugin name must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-plugin".'),null;h[e]&&console.error(`Plugin "${e}" is already registered.`),n=(0,i.applyFilters)("plugins.registerPlugin",n,e);const{render:r,scope:t}=n;if("function"!=typeof r)return console.error('The "render" property must be specified and must be a valid function.'),null;if(t){if("string"!=typeof t)return console.error("Plugin scope must be string."),null;if(!/^[a-z][a-z0-9-]*$/.test(t))return console.error('Plugin scope must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-page".'),null}return h[e]={name:e,icon:m,...n},(0,i.doAction)("plugins.pluginRegistered",n,e),n}function x(e){if(!h[e])return void console.error('Plugin "'+e+'" is not registered.');const n=h[e];return delete h[e],(0,i.doAction)("plugins.pluginUnregistered",n,e),n}function y(e){return h[e]}function P(e){return Object.values(h).filter((n=>n.scope===e))}const b=function(e,n){var r,t,i=0;function o(){var o,l,s=r,u=arguments.length;e:for(;s;){if(s.args.length===arguments.length){for(l=0;l<u;l++)if(s.args[l]!==arguments[l]){s=s.next;continue e}return s!==r&&(s===t&&(t=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=r,s.prev=null,r.prev=s,r=s),s.val}s=s.next}for(o=new Array(u),l=0;l<u;l++)o[l]=arguments[l];return s={args:o,val:e.apply(null,o)},r?(r.prev=s,s.next=r):t=s,i===n.maxSize?(t=t.prev).next=null:i++,r=s,s.val}return n=n||{},o.clear=function(){r=null,t=null,i=0},o}(((e,n)=>({icon:e,name:n})));var j=function({scope:e,onError:n}){const o=(0,t.useMemo)((()=>{let n=[];return{subscribe:e=>((0,i.addAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered",e),(0,i.addAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered",e),()=>{(0,i.removeAction)("plugins.pluginRegistered","core/plugins/plugin-area/plugins-registered"),(0,i.removeAction)("plugins.pluginUnregistered","core/plugins/plugin-area/plugins-unregistered")}),getValue(){const r=P(e);return l()(n,r)||(n=r),n}}}),[e]),s=(0,t.useSyncExternalStore)(o.subscribe,o.getValue,o.getValue);return(0,r.jsx)("div",{style:{display:"none"},children:s.map((({icon:e,name:t,render:i})=>(0,r.jsx)(p,{value:b(e,t),children:(0,r.jsx)(v,{name:t,onError:n,children:(0,r.jsx)(i,{})})},t)))})};(window.wp=window.wp||{}).plugins=n})();
|
||||
+152
-504
@@ -59,66 +59,35 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
|
||||
var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/create/debounce-async.js
|
||||
/**
|
||||
* Performs a leading edge debounce of async functions.
|
||||
*
|
||||
* If three functions are throttled at the same time:
|
||||
* - The first happens immediately.
|
||||
* - The second is never called.
|
||||
* - The third happens `delayMS` milliseconds after the first has resolved.
|
||||
*
|
||||
* This is distinct from `{ debounce } from @wordpress/compose` in that it
|
||||
* waits for promise resolution.
|
||||
*
|
||||
* @param {Function} func A function that returns a promise.
|
||||
* @param {number} delayMS A delay in milliseconds.
|
||||
*
|
||||
* @return {Function} A function that debounce whatever function is passed
|
||||
* to it.
|
||||
*/
|
||||
function debounceAsync(func, delayMS) {
|
||||
let timeoutId;
|
||||
let activePromise;
|
||||
return async function debounced(...args) {
|
||||
// This is a leading edge debounce. If there's no promise or timeout
|
||||
// in progress, call the debounced function immediately.
|
||||
if (!activePromise && !timeoutId) {
|
||||
return new Promise((resolve, reject) => {
|
||||
// Keep a reference to the promise.
|
||||
activePromise = func(...args).then((...thenArgs) => {
|
||||
resolve(...thenArgs);
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
}).finally(() => {
|
||||
// As soon this promise is complete, clear the way for the
|
||||
// next one to happen immediately.
|
||||
activePromise = null;
|
||||
});
|
||||
});
|
||||
}
|
||||
if (activePromise) {
|
||||
// Let any active promises finish before queuing the next request.
|
||||
await activePromise;
|
||||
}
|
||||
|
||||
// Clear any active timeouts, abandoning any requests that have
|
||||
// been queued but not been made.
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
timeoutId = null;
|
||||
}
|
||||
|
||||
// Trigger any trailing edge calls to the function.
|
||||
return new Promise((resolve, reject) => {
|
||||
// Schedule the next request but with a delay.
|
||||
timeoutId = setTimeout(() => {
|
||||
activePromise = func(...args).then((...thenArgs) => {
|
||||
resolve(...thenArgs);
|
||||
}).catch(error => {
|
||||
}).catch((error) => {
|
||||
reject(error);
|
||||
}).finally(() => {
|
||||
// As soon this promise is complete, clear the way for the
|
||||
// next one to happen immediately.
|
||||
activePromise = null;
|
||||
timeoutId = null;
|
||||
});
|
||||
@@ -127,39 +96,15 @@ function debounceAsync(func, delayMS) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/create/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
const EMPTY_OBJECT = {};
|
||||
const localStorage = window.localStorage;
|
||||
|
||||
/**
|
||||
* Creates a persistence layer that stores data in WordPress user meta via the
|
||||
* REST API.
|
||||
*
|
||||
* @param {Object} options
|
||||
* @param {?Object} options.preloadedData Any persisted preferences data that should be preloaded.
|
||||
* When set, the persistence layer will avoid fetching data
|
||||
* from the REST API.
|
||||
* @param {?string} options.localStorageRestoreKey The key to use for restoring the localStorage backup, used
|
||||
* when the persistence layer calls `localStorage.getItem` or
|
||||
* `localStorage.setItem`.
|
||||
* @param {?number} options.requestDebounceMS Debounce requests to the API so that they only occur at
|
||||
* minimum every `requestDebounceMS` milliseconds, and don't
|
||||
* swamp the server. Defaults to 2500ms.
|
||||
*
|
||||
* @return {Object} A persistence layer for WordPress user meta.
|
||||
*/
|
||||
function create({
|
||||
preloadedData,
|
||||
localStorageRestoreKey = 'WP_PREFERENCES_RESTORE_DATA',
|
||||
localStorageRestoreKey = "WP_PREFERENCES_RESTORE_DATA",
|
||||
requestDebounceMS = 2500
|
||||
} = {}) {
|
||||
let cache = preloadedData;
|
||||
@@ -169,18 +114,14 @@ function create({
|
||||
return cache;
|
||||
}
|
||||
const user = await external_wp_apiFetch_default()({
|
||||
path: '/wp/v2/users/me?context=edit'
|
||||
path: "/wp/v2/users/me?context=edit"
|
||||
});
|
||||
const serverData = user?.meta?.persisted_preferences;
|
||||
const localData = JSON.parse(localStorage.getItem(localStorageRestoreKey));
|
||||
|
||||
// Date parse returns NaN for invalid input. Coerce anything invalid
|
||||
// into a conveniently comparable zero.
|
||||
const localData = JSON.parse(
|
||||
localStorage.getItem(localStorageRestoreKey)
|
||||
);
|
||||
const serverTimestamp = Date.parse(serverData?._modified) || 0;
|
||||
const localTimestamp = Date.parse(localData?._modified) || 0;
|
||||
|
||||
// Prefer server data if it exists and is more recent.
|
||||
// Otherwise fallback to localStorage data.
|
||||
if (serverData && serverTimestamp >= localTimestamp) {
|
||||
cache = serverData;
|
||||
} else if (localData) {
|
||||
@@ -193,23 +134,16 @@ function create({
|
||||
function set(newData) {
|
||||
const dataWithTimestamp = {
|
||||
...newData,
|
||||
_modified: new Date().toISOString()
|
||||
_modified: (/* @__PURE__ */ new Date()).toISOString()
|
||||
};
|
||||
cache = dataWithTimestamp;
|
||||
|
||||
// Store data in local storage as a fallback. If for some reason the
|
||||
// api request does not complete or becomes unavailable, this data
|
||||
// can be used to restore preferences.
|
||||
localStorage.setItem(localStorageRestoreKey, JSON.stringify(dataWithTimestamp));
|
||||
|
||||
// The user meta endpoint seems susceptible to errors when consecutive
|
||||
// requests are made in quick succession. Ensure there's a gap between
|
||||
// any consecutive requests.
|
||||
//
|
||||
// Catch and do nothing with errors from the REST API.
|
||||
localStorage.setItem(
|
||||
localStorageRestoreKey,
|
||||
JSON.stringify(dataWithTimestamp)
|
||||
);
|
||||
debouncedApiFetch({
|
||||
path: '/wp/v2/users/me',
|
||||
method: 'PUT',
|
||||
path: "/wp/v2/users/me",
|
||||
method: "PUT",
|
||||
// `keepalive` will still send the request in the background,
|
||||
// even when a browser unload event might interrupt it.
|
||||
// This should hopefully make things more resilient.
|
||||
@@ -221,7 +155,8 @@ function create({
|
||||
persisted_preferences: dataWithTimestamp
|
||||
}
|
||||
}
|
||||
}).catch(() => {});
|
||||
}).catch(() => {
|
||||
});
|
||||
}
|
||||
return {
|
||||
get,
|
||||
@@ -229,72 +164,11 @@ function create({
|
||||
};
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js
|
||||
/**
|
||||
* Move the 'features' object in local storage from the sourceStoreName to the
|
||||
* preferences store data structure.
|
||||
*
|
||||
* Previously, editors used a data structure like this for feature preferences:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/edit-post': {
|
||||
* preferences: {
|
||||
* features; {
|
||||
* topToolbar: true,
|
||||
* // ... other boolean 'feature' preferences
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* And for a while these feature preferences lived in the interface package:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/interface': {
|
||||
* preferences: {
|
||||
* features: {
|
||||
* 'core/edit-post': {
|
||||
* topToolbar: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* In the preferences store, 'features' aren't considered special, they're
|
||||
* merged to the root level of the scope along with other preferences:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/preferences': {
|
||||
* preferences: {
|
||||
* 'core/edit-post': {
|
||||
* topToolbar: true,
|
||||
* // ... any other preferences.
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* This function handles moving from either the source store or the interface
|
||||
* store to the preferences data structure.
|
||||
*
|
||||
* @param {Object} state The state before migration.
|
||||
* @param {string} sourceStoreName The name of the store that has persisted
|
||||
* preferences to migrate to the preferences
|
||||
* package.
|
||||
* @return {Object} The migrated state
|
||||
*/
|
||||
function moveFeaturePreferences(state, sourceStoreName) {
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const interfaceStoreName = 'core/interface';
|
||||
|
||||
// Features most recently (and briefly) lived in the interface package.
|
||||
// If data exists there, prioritize using that for the migration. If not
|
||||
// also check the original package as the user may have updated from an
|
||||
// older block editor version.
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-feature-preferences.js
|
||||
function moveFeaturePreferences(state, sourceStoreName) {
|
||||
const preferencesStoreName = "core/preferences";
|
||||
const interfaceStoreName = "core/interface";
|
||||
const interfaceFeatures = state?.[interfaceStoreName]?.preferences?.features?.[sourceStoreName];
|
||||
const sourceFeatures = state?.[sourceStoreName]?.preferences?.features;
|
||||
const featuresToMigrate = interfaceFeatures ? interfaceFeatures : sourceFeatures;
|
||||
@@ -302,8 +176,6 @@ function moveFeaturePreferences(state, sourceStoreName) {
|
||||
return state;
|
||||
}
|
||||
const existingPreferences = state?.[preferencesStoreName]?.preferences;
|
||||
|
||||
// Avoid migrating features again if they've previously been migrated.
|
||||
if (existingPreferences?.[sourceStoreName]) {
|
||||
return state;
|
||||
}
|
||||
@@ -317,7 +189,7 @@ function moveFeaturePreferences(state, sourceStoreName) {
|
||||
preferences: {
|
||||
features: {
|
||||
...otherInterfaceScopes,
|
||||
[sourceStoreName]: undefined
|
||||
[sourceStoreName]: void 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -332,15 +204,11 @@ function moveFeaturePreferences(state, sourceStoreName) {
|
||||
...otherSourceState,
|
||||
preferences: {
|
||||
...sourcePreferences,
|
||||
features: undefined
|
||||
features: void 0
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Set the feature values in the interface store, the features
|
||||
// object is keyed by 'scope', which matches the store name for
|
||||
// the source.
|
||||
return {
|
||||
...state,
|
||||
[preferencesStoreName]: {
|
||||
@@ -354,58 +222,18 @@ function moveFeaturePreferences(state, sourceStoreName) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-third-party-feature-preferences.js
|
||||
/**
|
||||
* The interface package previously had a public API that could be used by
|
||||
* plugins to set persisted boolean 'feature' preferences.
|
||||
*
|
||||
* While usage was likely non-existent or very small, this function ensures
|
||||
* those are migrated to the preferences data structure. The interface
|
||||
* package's APIs have now been deprecated and use the preferences store.
|
||||
*
|
||||
* This will convert data that looks like this:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/interface': {
|
||||
* preferences: {
|
||||
* features: {
|
||||
* 'my-plugin': {
|
||||
* myPluginFeature: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* To this:
|
||||
* ```js
|
||||
* * {
|
||||
* 'core/preferences': {
|
||||
* preferences: {
|
||||
* 'my-plugin': {
|
||||
* myPluginFeature: true
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param {Object} state The local storage state
|
||||
*
|
||||
* @return {Object} The state with third party preferences moved to the
|
||||
* preferences data structure.
|
||||
*/
|
||||
function moveThirdPartyFeaturePreferencesToPreferences(state) {
|
||||
const interfaceStoreName = 'core/interface';
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const interfaceStoreName = "core/interface";
|
||||
const preferencesStoreName = "core/preferences";
|
||||
const interfaceScopes = state?.[interfaceStoreName]?.preferences?.features;
|
||||
const interfaceScopeKeys = interfaceScopes ? Object.keys(interfaceScopes) : [];
|
||||
if (!interfaceScopeKeys?.length) {
|
||||
return state;
|
||||
}
|
||||
return interfaceScopeKeys.reduce(function (convertedState, scope) {
|
||||
if (scope.startsWith('core')) {
|
||||
return interfaceScopeKeys.reduce(function(convertedState, scope) {
|
||||
if (scope.startsWith("core")) {
|
||||
return convertedState;
|
||||
}
|
||||
const featuresToMigrate = interfaceScopes?.[scope];
|
||||
@@ -432,7 +260,7 @@ function moveThirdPartyFeaturePreferencesToPreferences(state) {
|
||||
preferences: {
|
||||
features: {
|
||||
...otherInterfaceScopes,
|
||||
[scope]: undefined
|
||||
[scope]: void 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -440,58 +268,16 @@ function moveThirdPartyFeaturePreferencesToPreferences(state) {
|
||||
}, state);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-individual-preference.js
|
||||
const identity = arg => arg;
|
||||
|
||||
/**
|
||||
* Migrates an individual item inside the `preferences` object for a package's store.
|
||||
*
|
||||
* Previously, some packages had individual 'preferences' of any data type, and many used
|
||||
* complex nested data structures. For example:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/edit-post': {
|
||||
* preferences: {
|
||||
* panels: {
|
||||
* publish: {
|
||||
* opened: true,
|
||||
* enabled: true,
|
||||
* }
|
||||
* },
|
||||
* // ...other preferences.
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
*
|
||||
* This function supports moving an individual preference like 'panels' above into the
|
||||
* preferences package data structure.
|
||||
*
|
||||
* It supports moving a preference to a particular scope in the preferences store and
|
||||
* optionally converting the data using a `convert` function.
|
||||
*
|
||||
* ```
|
||||
*
|
||||
* @param {Object} state The original state.
|
||||
* @param {Object} migrate An options object that contains details of the migration.
|
||||
* @param {string} migrate.from The name of the store to migrate from.
|
||||
* @param {string} migrate.to The scope in the preferences store to migrate to.
|
||||
* @param {string} key The key in the preferences object to migrate.
|
||||
* @param {?Function} convert A function that converts preferences from one format to another.
|
||||
*/
|
||||
function moveIndividualPreferenceToPreferences(state, {
|
||||
from: sourceStoreName,
|
||||
to: scope
|
||||
}, key, convert = identity) {
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const identity = (arg) => arg;
|
||||
function moveIndividualPreferenceToPreferences(state, { from: sourceStoreName, to: scope }, key, convert = identity) {
|
||||
const preferencesStoreName = "core/preferences";
|
||||
const sourcePreference = state?.[sourceStoreName]?.preferences?.[key];
|
||||
|
||||
// There's nothing to migrate, exit early.
|
||||
if (sourcePreference === undefined) {
|
||||
if (sourcePreference === void 0) {
|
||||
return state;
|
||||
}
|
||||
const targetPreference = state?.[preferencesStoreName]?.preferences?.[scope]?.[key];
|
||||
|
||||
// There's existing data at the target, so don't overwrite it, exit early.
|
||||
if (targetPreference) {
|
||||
return state;
|
||||
}
|
||||
@@ -499,12 +285,7 @@ function moveIndividualPreferenceToPreferences(state, {
|
||||
const otherPreferences = state?.[preferencesStoreName]?.preferences?.[scope];
|
||||
const otherSourceState = state?.[sourceStoreName];
|
||||
const allSourcePreferences = state?.[sourceStoreName]?.preferences;
|
||||
|
||||
// Pass an object with the key and value as this allows the convert
|
||||
// function to convert to a data structure that has different keys.
|
||||
const convertedPreferences = convert({
|
||||
[key]: sourcePreference
|
||||
});
|
||||
const convertedPreferences = convert({ [key]: sourcePreference });
|
||||
return {
|
||||
...state,
|
||||
[preferencesStoreName]: {
|
||||
@@ -520,80 +301,27 @@ function moveIndividualPreferenceToPreferences(state, {
|
||||
...otherSourceState,
|
||||
preferences: {
|
||||
...allSourcePreferences,
|
||||
[key]: undefined
|
||||
[key]: void 0
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js
|
||||
/**
|
||||
* Migrates interface 'enableItems' data to the preferences store.
|
||||
*
|
||||
* The interface package stores this data in this format:
|
||||
* ```js
|
||||
* {
|
||||
* enableItems: {
|
||||
* singleEnableItems: {
|
||||
* complementaryArea: {
|
||||
* 'core/edit-post': 'edit-post/document',
|
||||
* 'core/edit-site': 'edit-site/global-styles',
|
||||
* }
|
||||
* },
|
||||
* multipleEnableItems: {
|
||||
* pinnedItems: {
|
||||
* 'core/edit-post': {
|
||||
* 'plugin-1': true,
|
||||
* },
|
||||
* 'core/edit-site': {
|
||||
* 'plugin-2': true,
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* and it should be converted it to:
|
||||
* ```js
|
||||
* {
|
||||
* 'core/edit-post': {
|
||||
* complementaryArea: 'edit-post/document',
|
||||
* pinnedItems: {
|
||||
* 'plugin-1': true,
|
||||
* },
|
||||
* },
|
||||
* 'core/edit-site': {
|
||||
* complementaryArea: 'edit-site/global-styles',
|
||||
* pinnedItems: {
|
||||
* 'plugin-2': true,
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @param {Object} state The local storage state.
|
||||
*/
|
||||
function moveInterfaceEnableItems(state) {
|
||||
var _state$preferencesSto, _sourceEnableItems$si, _sourceEnableItems$mu;
|
||||
const interfaceStoreName = 'core/interface';
|
||||
const preferencesStoreName = 'core/preferences';
|
||||
const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
|
||||
|
||||
// There's nothing to migrate, exit early.
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/move-interface-enable-items.js
|
||||
function moveInterfaceEnableItems(state) {
|
||||
const interfaceStoreName = "core/interface";
|
||||
const preferencesStoreName = "core/preferences";
|
||||
const sourceEnableItems = state?.[interfaceStoreName]?.enableItems;
|
||||
if (!sourceEnableItems) {
|
||||
return state;
|
||||
}
|
||||
const allPreferences = (_state$preferencesSto = state?.[preferencesStoreName]?.preferences) !== null && _state$preferencesSto !== void 0 ? _state$preferencesSto : {};
|
||||
|
||||
// First convert complementaryAreas into the right format.
|
||||
// Use the existing preferences as the accumulator so that the data is
|
||||
// merged.
|
||||
const sourceComplementaryAreas = (_sourceEnableItems$si = sourceEnableItems?.singleEnableItems?.complementaryArea) !== null && _sourceEnableItems$si !== void 0 ? _sourceEnableItems$si : {};
|
||||
const preferencesWithConvertedComplementaryAreas = Object.keys(sourceComplementaryAreas).reduce((accumulator, scope) => {
|
||||
const allPreferences = state?.[preferencesStoreName]?.preferences ?? {};
|
||||
const sourceComplementaryAreas = sourceEnableItems?.singleEnableItems?.complementaryArea ?? {};
|
||||
const preferencesWithConvertedComplementaryAreas = Object.keys(
|
||||
sourceComplementaryAreas
|
||||
).reduce((accumulator, scope) => {
|
||||
const data = sourceComplementaryAreas[scope];
|
||||
|
||||
// Don't overwrite any existing data in the preferences store.
|
||||
if (accumulator?.[scope]?.complementaryArea) {
|
||||
return accumulator;
|
||||
}
|
||||
@@ -605,24 +333,23 @@ function moveInterfaceEnableItems(state) {
|
||||
}
|
||||
};
|
||||
}, allPreferences);
|
||||
|
||||
// Next feed the converted complementary areas back into a reducer that
|
||||
// converts the pinned items, resulting in the fully migrated data.
|
||||
const sourcePinnedItems = (_sourceEnableItems$mu = sourceEnableItems?.multipleEnableItems?.pinnedItems) !== null && _sourceEnableItems$mu !== void 0 ? _sourceEnableItems$mu : {};
|
||||
const allConvertedData = Object.keys(sourcePinnedItems).reduce((accumulator, scope) => {
|
||||
const data = sourcePinnedItems[scope];
|
||||
// Don't overwrite any existing data in the preferences store.
|
||||
if (accumulator?.[scope]?.pinnedItems) {
|
||||
return accumulator;
|
||||
}
|
||||
return {
|
||||
...accumulator,
|
||||
[scope]: {
|
||||
...accumulator[scope],
|
||||
pinnedItems: data
|
||||
const sourcePinnedItems = sourceEnableItems?.multipleEnableItems?.pinnedItems ?? {};
|
||||
const allConvertedData = Object.keys(sourcePinnedItems).reduce(
|
||||
(accumulator, scope) => {
|
||||
const data = sourcePinnedItems[scope];
|
||||
if (accumulator?.[scope]?.pinnedItems) {
|
||||
return accumulator;
|
||||
}
|
||||
};
|
||||
}, preferencesWithConvertedComplementaryAreas);
|
||||
return {
|
||||
...accumulator,
|
||||
[scope]: {
|
||||
...accumulator[scope],
|
||||
pinnedItems: data
|
||||
}
|
||||
};
|
||||
},
|
||||
preferencesWithConvertedComplementaryAreas
|
||||
);
|
||||
const otherInterfaceItems = state[interfaceStoreName];
|
||||
return {
|
||||
...state,
|
||||
@@ -631,168 +358,97 @@ function moveInterfaceEnableItems(state) {
|
||||
},
|
||||
[interfaceStoreName]: {
|
||||
...otherInterfaceItems,
|
||||
enableItems: undefined
|
||||
enableItems: void 0
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/convert-edit-post-panels.js
|
||||
/**
|
||||
* Convert the post editor's panels state from:
|
||||
* ```
|
||||
* {
|
||||
* panels: {
|
||||
* tags: {
|
||||
* enabled: true,
|
||||
* opened: true,
|
||||
* },
|
||||
* permalinks: {
|
||||
* enabled: false,
|
||||
* opened: false,
|
||||
* },
|
||||
* },
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* to a new, more concise data structure:
|
||||
* {
|
||||
* inactivePanels: [
|
||||
* 'permalinks',
|
||||
* ],
|
||||
* openPanels: [
|
||||
* 'tags',
|
||||
* ],
|
||||
* }
|
||||
*
|
||||
* @param {Object} preferences A preferences object.
|
||||
*
|
||||
* @return {Object} The converted data.
|
||||
*/
|
||||
function convertEditPostPanels(preferences) {
|
||||
var _preferences$panels;
|
||||
const panels = (_preferences$panels = preferences?.panels) !== null && _preferences$panels !== void 0 ? _preferences$panels : {};
|
||||
return Object.keys(panels).reduce((convertedData, panelName) => {
|
||||
const panel = panels[panelName];
|
||||
if (panel?.enabled === false) {
|
||||
convertedData.inactivePanels.push(panelName);
|
||||
}
|
||||
if (panel?.opened === true) {
|
||||
convertedData.openPanels.push(panelName);
|
||||
}
|
||||
return convertedData;
|
||||
}, {
|
||||
inactivePanels: [],
|
||||
openPanels: []
|
||||
});
|
||||
const panels = preferences?.panels ?? {};
|
||||
return Object.keys(panels).reduce(
|
||||
(convertedData, panelName) => {
|
||||
const panel = panels[panelName];
|
||||
if (panel?.enabled === false) {
|
||||
convertedData.inactivePanels.push(panelName);
|
||||
}
|
||||
if (panel?.opened === true) {
|
||||
convertedData.openPanels.push(panelName);
|
||||
}
|
||||
return convertedData;
|
||||
},
|
||||
{ inactivePanels: [], openPanels: [] }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/legacy-local-storage-data/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the legacy local storage data for a given user.
|
||||
*
|
||||
* @param {string | number} userId The user id.
|
||||
*
|
||||
* @return {Object | null} The local storage data.
|
||||
*/
|
||||
function getLegacyData(userId) {
|
||||
const key = `WP_DATA_USER_${userId}`;
|
||||
const unparsedData = window.localStorage.getItem(key);
|
||||
return JSON.parse(unparsedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts data from the old `@wordpress/data` package format.
|
||||
*
|
||||
* @param {Object | null | undefined} data The legacy data in its original format.
|
||||
*
|
||||
* @return {Object | undefined} The converted data or `undefined` if there was
|
||||
* nothing to convert.
|
||||
*/
|
||||
function convertLegacyData(data) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Move boolean feature preferences from each editor into the
|
||||
// preferences store data structure.
|
||||
data = moveFeaturePreferences(data, 'core/edit-widgets');
|
||||
data = moveFeaturePreferences(data, 'core/customize-widgets');
|
||||
data = moveFeaturePreferences(data, 'core/edit-post');
|
||||
data = moveFeaturePreferences(data, 'core/edit-site');
|
||||
|
||||
// Move third party boolean feature preferences from the interface package
|
||||
// to the preferences store data structure.
|
||||
data = moveFeaturePreferences(data, "core/edit-widgets");
|
||||
data = moveFeaturePreferences(data, "core/customize-widgets");
|
||||
data = moveFeaturePreferences(data, "core/edit-post");
|
||||
data = moveFeaturePreferences(data, "core/edit-site");
|
||||
data = moveThirdPartyFeaturePreferencesToPreferences(data);
|
||||
|
||||
// Move and convert the interface store's `enableItems` data into the
|
||||
// preferences data structure.
|
||||
data = moveInterfaceEnableItems(data);
|
||||
|
||||
// Move individual ad-hoc preferences from various packages into the
|
||||
// preferences store data structure.
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'hiddenBlockTypes');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'editorMode');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core/edit-post'
|
||||
}, 'panels', convertEditPostPanels);
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/editor',
|
||||
to: 'core'
|
||||
}, 'isPublishSidebarEnabled');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-post',
|
||||
to: 'core'
|
||||
}, 'isPublishSidebarEnabled');
|
||||
data = moveIndividualPreferenceToPreferences(data, {
|
||||
from: 'core/edit-site',
|
||||
to: 'core/edit-site'
|
||||
}, 'editorMode');
|
||||
|
||||
// The new system is only concerned with persisting
|
||||
// 'core/preferences' preferences reducer, so only return that.
|
||||
return data?.['core/preferences']?.preferences;
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/edit-post", to: "core/edit-post" },
|
||||
"hiddenBlockTypes"
|
||||
);
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/edit-post", to: "core/edit-post" },
|
||||
"editorMode"
|
||||
);
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/edit-post", to: "core/edit-post" },
|
||||
"panels",
|
||||
convertEditPostPanels
|
||||
);
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/editor", to: "core" },
|
||||
"isPublishSidebarEnabled"
|
||||
);
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/edit-post", to: "core" },
|
||||
"isPublishSidebarEnabled"
|
||||
);
|
||||
data = moveIndividualPreferenceToPreferences(
|
||||
data,
|
||||
{ from: "core/edit-site", to: "core/edit-site" },
|
||||
"editorMode"
|
||||
);
|
||||
return data?.["core/preferences"]?.preferences;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the legacy local storage data for the given user and returns the
|
||||
* data converted to the new format.
|
||||
*
|
||||
* @param {string | number} userId The user id.
|
||||
*
|
||||
* @return {Object | undefined} The converted data or undefined if no local
|
||||
* storage data could be found.
|
||||
*/
|
||||
function convertLegacyLocalStorageData(userId) {
|
||||
const data = getLegacyData(userId);
|
||||
return convertLegacyData(data);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-complementary-areas.js
|
||||
function convertComplementaryAreas(state) {
|
||||
return Object.keys(state).reduce((stateAccumulator, scope) => {
|
||||
const scopeData = state[scope];
|
||||
|
||||
// If a complementary area is truthy, convert it to the `isComplementaryAreaVisible` boolean.
|
||||
if (scopeData?.complementaryArea) {
|
||||
const updatedScopeData = {
|
||||
...scopeData
|
||||
};
|
||||
const updatedScopeData = { ...scopeData };
|
||||
delete updatedScopeData.complementaryArea;
|
||||
updatedScopeData.isComplementaryAreaVisible = true;
|
||||
stateAccumulator[scope] = updatedScopeData;
|
||||
@@ -802,43 +458,54 @@ function convertComplementaryAreas(state) {
|
||||
}, state);
|
||||
}
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-editor-settings.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/convert-editor-settings.js
|
||||
function convertEditorSettings(data) {
|
||||
var _newData$coreEditPo, _newData$coreEditSi;
|
||||
let newData = data;
|
||||
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
|
||||
settingsToMoveToCore.forEach(setting => {
|
||||
if (data?.['core/edit-post']?.[setting] !== undefined) {
|
||||
const settingsToMoveToCore = [
|
||||
"allowRightClickOverrides",
|
||||
"distractionFree",
|
||||
"editorMode",
|
||||
"fixedToolbar",
|
||||
"focusMode",
|
||||
"hiddenBlockTypes",
|
||||
"inactivePanels",
|
||||
"keepCaretInsideBlock",
|
||||
"mostUsedBlocks",
|
||||
"openPanels",
|
||||
"showBlockBreadcrumbs",
|
||||
"showIconLabels",
|
||||
"showListViewByDefault",
|
||||
"isPublishSidebarEnabled",
|
||||
"isComplementaryAreaVisible",
|
||||
"pinnedItems"
|
||||
];
|
||||
settingsToMoveToCore.forEach((setting) => {
|
||||
if (data?.["core/edit-post"]?.[setting] !== void 0) {
|
||||
newData = {
|
||||
...newData,
|
||||
core: {
|
||||
...newData?.core,
|
||||
[setting]: data['core/edit-post'][setting]
|
||||
[setting]: data["core/edit-post"][setting]
|
||||
}
|
||||
};
|
||||
delete newData['core/edit-post'][setting];
|
||||
delete newData["core/edit-post"][setting];
|
||||
}
|
||||
if (data?.['core/edit-site']?.[setting] !== undefined) {
|
||||
delete newData['core/edit-site'][setting];
|
||||
if (data?.["core/edit-site"]?.[setting] !== void 0) {
|
||||
delete newData["core/edit-site"][setting];
|
||||
}
|
||||
});
|
||||
if (Object.keys((_newData$coreEditPo = newData?.['core/edit-post']) !== null && _newData$coreEditPo !== void 0 ? _newData$coreEditPo : {})?.length === 0) {
|
||||
delete newData['core/edit-post'];
|
||||
if (Object.keys(newData?.["core/edit-post"] ?? {})?.length === 0) {
|
||||
delete newData["core/edit-post"];
|
||||
}
|
||||
if (Object.keys((_newData$coreEditSi = newData?.['core/edit-site']) !== null && _newData$coreEditSi !== void 0 ? _newData$coreEditSi : {})?.length === 0) {
|
||||
delete newData['core/edit-site'];
|
||||
if (Object.keys(newData?.["core/edit-site"] ?? {})?.length === 0) {
|
||||
delete newData["core/edit-site"];
|
||||
}
|
||||
return newData;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/migrations/preferences-package-data/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function convertPreferencesPackageData(data) {
|
||||
@@ -847,35 +514,16 @@ function convertPreferencesPackageData(data) {
|
||||
return newData;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences-persistence/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates the persistence layer with preloaded data.
|
||||
*
|
||||
* It prioritizes any data from the server, but falls back first to localStorage
|
||||
* restore data, and then to any legacy data.
|
||||
*
|
||||
* This function is used internally by WordPress in an inline script, so
|
||||
* prefixed with `__unstable`.
|
||||
*
|
||||
* @param {Object} serverData Preferences data preloaded from the server.
|
||||
* @param {string} userId The user id.
|
||||
*
|
||||
* @return {Object} The persistence layer initialized with the preloaded data.
|
||||
*/
|
||||
function __unstableCreatePersistenceLayer(serverData, userId) {
|
||||
const localStorageRestoreKey = `WP_PREFERENCES_USER_${userId}`;
|
||||
const localData = JSON.parse(window.localStorage.getItem(localStorageRestoreKey));
|
||||
|
||||
// Date parse returns NaN for invalid input. Coerce anything invalid
|
||||
// into a conveniently comparable zero.
|
||||
const localData = JSON.parse(
|
||||
window.localStorage.getItem(localStorageRestoreKey)
|
||||
);
|
||||
const serverModified = Date.parse(serverData && serverData._modified) || 0;
|
||||
const localModified = Date.parse(localData && localData._modified) || 0;
|
||||
let preloadedData;
|
||||
@@ -884,7 +532,6 @@ function __unstableCreatePersistenceLayer(serverData, userId) {
|
||||
} else if (localData) {
|
||||
preloadedData = convertPreferencesPackageData(localData);
|
||||
} else {
|
||||
// Check if there is data in the legacy format from the old persistence system.
|
||||
preloadedData = convertLegacyLocalStorageData(userId);
|
||||
}
|
||||
return create({
|
||||
@@ -893,6 +540,7 @@ function __unstableCreatePersistenceLayer(serverData, userId) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).preferencesPersistence = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+260
-460
@@ -73,6 +73,8 @@ __webpack_require__.d(selectors_namespaceObject, {
|
||||
get: () => (get)
|
||||
});
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// external ["wp","data"]
|
||||
const external_wp_data_namespaceObject = window["wp"]["data"];
|
||||
;// external ["wp","components"]
|
||||
@@ -81,48 +83,19 @@ const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/check.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_check = (check);
|
||||
var check_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" }) });
|
||||
|
||||
|
||||
;// external ["wp","a11y"]
|
||||
const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
|
||||
;// ./node_modules/@wordpress/preferences/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Reducer returning the defaults for user preferences.
|
||||
*
|
||||
* This is kept intentionally separate from the preferences
|
||||
* themselves so that defaults are not persisted.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
function defaults(state = {}, action) {
|
||||
if (action.type === 'SET_PREFERENCE_DEFAULTS') {
|
||||
const {
|
||||
scope,
|
||||
defaults: values
|
||||
} = action;
|
||||
if (action.type === "SET_PREFERENCE_DEFAULTS") {
|
||||
const { scope, defaults: values } = action;
|
||||
return {
|
||||
...state,
|
||||
[scope]: {
|
||||
@@ -133,53 +106,24 @@ function defaults(state = {}, action) {
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Higher order reducer that does the following:
|
||||
* - Merges any data from the persistence layer into the state when the
|
||||
* `SET_PERSISTENCE_LAYER` action is received.
|
||||
* - Passes any preferences changes to the persistence layer.
|
||||
*
|
||||
* @param {Function} reducer The preferences reducer.
|
||||
*
|
||||
* @return {Function} The enhanced reducer.
|
||||
*/
|
||||
function withPersistenceLayer(reducer) {
|
||||
let persistenceLayer;
|
||||
return (state, action) => {
|
||||
// Setup the persistence layer, and return the persisted data
|
||||
// as the state.
|
||||
if (action.type === 'SET_PERSISTENCE_LAYER') {
|
||||
const {
|
||||
persistenceLayer: persistence,
|
||||
persistedData
|
||||
} = action;
|
||||
if (action.type === "SET_PERSISTENCE_LAYER") {
|
||||
const { persistenceLayer: persistence, persistedData } = action;
|
||||
persistenceLayer = persistence;
|
||||
return persistedData;
|
||||
}
|
||||
const nextState = reducer(state, action);
|
||||
if (action.type === 'SET_PREFERENCE_VALUE') {
|
||||
if (action.type === "SET_PREFERENCE_VALUE") {
|
||||
persistenceLayer?.set(nextState);
|
||||
}
|
||||
return nextState;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Reducer returning the user preferences.
|
||||
*
|
||||
* @param {Object} state Current state.
|
||||
* @param {Object} action Dispatched action.
|
||||
*
|
||||
* @return {Object} Updated state.
|
||||
*/
|
||||
const preferences = withPersistenceLayer((state = {}, action) => {
|
||||
if (action.type === 'SET_PREFERENCE_VALUE') {
|
||||
const {
|
||||
scope,
|
||||
name,
|
||||
value
|
||||
} = action;
|
||||
if (action.type === "SET_PREFERENCE_VALUE") {
|
||||
const { scope, name, value } = action;
|
||||
return {
|
||||
...state,
|
||||
[scope]: {
|
||||
@@ -190,183 +134,111 @@ const preferences = withPersistenceLayer((state = {}, action) => {
|
||||
}
|
||||
return state;
|
||||
});
|
||||
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
var reducer_default = (0,external_wp_data_namespaceObject.combineReducers)({
|
||||
defaults,
|
||||
preferences
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/store/actions.js
|
||||
/**
|
||||
* Returns an action object used in signalling that a preference should be
|
||||
* toggled.
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {string} name The preference name.
|
||||
*/
|
||||
function toggle(scope, name) {
|
||||
return function ({
|
||||
select,
|
||||
dispatch
|
||||
}) {
|
||||
return function({ select, dispatch }) {
|
||||
const currentValue = select.get(scope, name);
|
||||
dispatch.set(scope, name, !currentValue);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that a preference should be set
|
||||
* to a value
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {string} name The preference name.
|
||||
* @param {*} value The value to set.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function set(scope, name, value) {
|
||||
return {
|
||||
type: 'SET_PREFERENCE_VALUE',
|
||||
type: "SET_PREFERENCE_VALUE",
|
||||
scope,
|
||||
name,
|
||||
value
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an action object used in signalling that preference defaults should
|
||||
* be set.
|
||||
*
|
||||
* @param {string} scope The preference scope (e.g. core/edit-post).
|
||||
* @param {Object<string, *>} defaults A key/value map of preference names to values.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
function setDefaults(scope, defaults) {
|
||||
return {
|
||||
type: 'SET_PREFERENCE_DEFAULTS',
|
||||
type: "SET_PREFERENCE_DEFAULTS",
|
||||
scope,
|
||||
defaults
|
||||
};
|
||||
}
|
||||
|
||||
/** @typedef {() => Promise<Object>} WPPreferencesPersistenceLayerGet */
|
||||
/** @typedef {(Object) => void} WPPreferencesPersistenceLayerSet */
|
||||
/**
|
||||
* @typedef WPPreferencesPersistenceLayer
|
||||
*
|
||||
* @property {WPPreferencesPersistenceLayerGet} get An async function that gets data from the persistence layer.
|
||||
* @property {WPPreferencesPersistenceLayerSet} set A function that sets data in the persistence layer.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Sets the persistence layer.
|
||||
*
|
||||
* When a persistence layer is set, the preferences store will:
|
||||
* - call `get` immediately and update the store state to the value returned.
|
||||
* - call `set` with all preferences whenever a preference changes value.
|
||||
*
|
||||
* `setPersistenceLayer` should ideally be dispatched at the start of an
|
||||
* application's lifecycle, before any other actions have been dispatched to
|
||||
* the preferences store.
|
||||
*
|
||||
* @param {WPPreferencesPersistenceLayer} persistenceLayer The persistence layer.
|
||||
*
|
||||
* @return {Object} Action object.
|
||||
*/
|
||||
async function setPersistenceLayer(persistenceLayer) {
|
||||
const persistedData = await persistenceLayer.get();
|
||||
return {
|
||||
type: 'SET_PERSISTENCE_LAYER',
|
||||
type: "SET_PERSISTENCE_LAYER",
|
||||
persistenceLayer,
|
||||
persistedData
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// external ["wp","deprecated"]
|
||||
const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
|
||||
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
|
||||
;// ./node_modules/@wordpress/preferences/build-module/store/selectors.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const withDeprecatedKeys = originalGet => (state, scope, name) => {
|
||||
const settingsToMoveToCore = ['allowRightClickOverrides', 'distractionFree', 'editorMode', 'fixedToolbar', 'focusMode', 'hiddenBlockTypes', 'inactivePanels', 'keepCaretInsideBlock', 'mostUsedBlocks', 'openPanels', 'showBlockBreadcrumbs', 'showIconLabels', 'showListViewByDefault', 'isPublishSidebarEnabled', 'isComplementaryAreaVisible', 'pinnedItems'];
|
||||
if (settingsToMoveToCore.includes(name) && ['core/edit-post', 'core/edit-site'].includes(scope)) {
|
||||
external_wp_deprecated_default()(`wp.data.select( 'core/preferences' ).get( '${scope}', '${name}' )`, {
|
||||
since: '6.5',
|
||||
alternative: `wp.data.select( 'core/preferences' ).get( 'core', '${name}' )`
|
||||
});
|
||||
return originalGet(state, 'core', name);
|
||||
const withDeprecatedKeys = (originalGet) => (state, scope, name) => {
|
||||
const settingsToMoveToCore = [
|
||||
"allowRightClickOverrides",
|
||||
"distractionFree",
|
||||
"editorMode",
|
||||
"fixedToolbar",
|
||||
"focusMode",
|
||||
"hiddenBlockTypes",
|
||||
"inactivePanels",
|
||||
"keepCaretInsideBlock",
|
||||
"mostUsedBlocks",
|
||||
"openPanels",
|
||||
"showBlockBreadcrumbs",
|
||||
"showIconLabels",
|
||||
"showListViewByDefault",
|
||||
"isPublishSidebarEnabled",
|
||||
"isComplementaryAreaVisible",
|
||||
"pinnedItems"
|
||||
];
|
||||
if (settingsToMoveToCore.includes(name) && ["core/edit-post", "core/edit-site"].includes(scope)) {
|
||||
external_wp_deprecated_default()(
|
||||
`wp.data.select( 'core/preferences' ).get( '${scope}', '${name}' )`,
|
||||
{
|
||||
since: "6.5",
|
||||
alternative: `wp.data.select( 'core/preferences' ).get( 'core', '${name}' )`
|
||||
}
|
||||
);
|
||||
return originalGet(state, "core", name);
|
||||
}
|
||||
return originalGet(state, scope, name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating whether a prefer is active for a particular
|
||||
* scope.
|
||||
*
|
||||
* @param {Object} state The store state.
|
||||
* @param {string} scope The scope of the feature (e.g. core/edit-post).
|
||||
* @param {string} name The name of the feature.
|
||||
*
|
||||
* @return {*} Is the feature enabled?
|
||||
*/
|
||||
const get = withDeprecatedKeys((state, scope, name) => {
|
||||
const value = state.preferences[scope]?.[name];
|
||||
return value !== undefined ? value : state.defaults[scope]?.[name];
|
||||
return value !== void 0 ? value : state.defaults[scope]?.[name];
|
||||
});
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/store/constants.js
|
||||
/**
|
||||
* The identifier for the data store.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
const STORE_NAME = 'core/preferences';
|
||||
const STORE_NAME = "core/preferences";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Store definition for the preferences namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
reducer: reducer,
|
||||
reducer: reducer_default,
|
||||
actions: actions_namespaceObject,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preference-toggle-menu-item/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function PreferenceToggleMenuItem({
|
||||
scope,
|
||||
@@ -380,373 +252,299 @@ function PreferenceToggleMenuItem({
|
||||
onToggle = () => null,
|
||||
disabled = false
|
||||
}) {
|
||||
const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, name), [scope, name]);
|
||||
const {
|
||||
toggle
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const isActive = (0,external_wp_data_namespaceObject.useSelect)(
|
||||
(select) => !!select(store).get(scope, name),
|
||||
[scope, name]
|
||||
);
|
||||
const { toggle } = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const speakMessage = () => {
|
||||
if (isActive) {
|
||||
const message = messageDeactivated || (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)('Preference deactivated - %s'), label);
|
||||
const message = messageDeactivated || (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)("Preference deactivated - %s"),
|
||||
label
|
||||
);
|
||||
(0,external_wp_a11y_namespaceObject.speak)(message);
|
||||
} else {
|
||||
const message = messageActivated || (0,external_wp_i18n_namespaceObject.sprintf)(/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)('Preference activated - %s'), label);
|
||||
const message = messageActivated || (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
/* translators: %s: preference name, e.g. 'Fullscreen mode' */
|
||||
(0,external_wp_i18n_namespaceObject.__)("Preference activated - %s"),
|
||||
label
|
||||
);
|
||||
(0,external_wp_a11y_namespaceObject.speak)(message);
|
||||
}
|
||||
};
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
||||
icon: isActive && library_check,
|
||||
isSelected: isActive,
|
||||
onClick: () => {
|
||||
onToggle();
|
||||
if (handleToggling) {
|
||||
toggle(scope, name);
|
||||
}
|
||||
speakMessage();
|
||||
},
|
||||
role: "menuitemcheckbox",
|
||||
info: info,
|
||||
shortcut: shortcut,
|
||||
disabled: disabled,
|
||||
children: label
|
||||
});
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.MenuItem,
|
||||
{
|
||||
icon: isActive && check_default,
|
||||
isSelected: isActive,
|
||||
onClick: () => {
|
||||
onToggle();
|
||||
if (handleToggling) {
|
||||
toggle(scope, name);
|
||||
}
|
||||
speakMessage();
|
||||
},
|
||||
role: "menuitemcheckbox",
|
||||
info,
|
||||
shortcut,
|
||||
disabled,
|
||||
children: label
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/index.js
|
||||
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preference-base-option/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
function BaseOption({
|
||||
help,
|
||||
label,
|
||||
isChecked,
|
||||
onChange,
|
||||
children
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
|
||||
className: "preference-base-option",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
|
||||
__nextHasNoMarginBottom: true,
|
||||
help: help,
|
||||
label: label,
|
||||
checked: isChecked,
|
||||
onChange: onChange
|
||||
}), children]
|
||||
});
|
||||
function BaseOption({ help, label, isChecked, onChange, children }) {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", { className: "preference-base-option", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.ToggleControl,
|
||||
{
|
||||
__nextHasNoMarginBottom: true,
|
||||
help,
|
||||
label,
|
||||
checked: isChecked,
|
||||
onChange
|
||||
}
|
||||
),
|
||||
children
|
||||
] });
|
||||
}
|
||||
/* harmony default export */ const preference_base_option = (BaseOption);
|
||||
var preference_base_option_default = BaseOption;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preference-toggle-control/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function PreferenceToggleControl(props) {
|
||||
const {
|
||||
scope,
|
||||
featureName,
|
||||
onToggle = () => {},
|
||||
onToggle = () => {
|
||||
},
|
||||
...remainingProps
|
||||
} = props;
|
||||
const isChecked = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(store).get(scope, featureName), [scope, featureName]);
|
||||
const {
|
||||
toggle
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const isChecked = (0,external_wp_data_namespaceObject.useSelect)(
|
||||
(select) => !!select(store).get(scope, featureName),
|
||||
[scope, featureName]
|
||||
);
|
||||
const { toggle } = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const onChange = () => {
|
||||
onToggle();
|
||||
toggle(scope, featureName);
|
||||
};
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(preference_base_option, {
|
||||
onChange: onChange,
|
||||
isChecked: isChecked,
|
||||
...remainingProps
|
||||
});
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
preference_base_option_default,
|
||||
{
|
||||
onChange,
|
||||
isChecked,
|
||||
...remainingProps
|
||||
}
|
||||
);
|
||||
}
|
||||
/* harmony default export */ const preference_toggle_control = (PreferenceToggleControl);
|
||||
var preference_toggle_control_default = PreferenceToggleControl;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preferences-modal/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function PreferencesModal({
|
||||
closeModal,
|
||||
children
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
|
||||
className: "preferences-modal",
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Preferences'),
|
||||
onRequestClose: closeModal,
|
||||
children: children
|
||||
});
|
||||
function PreferencesModal({ closeModal, children }) {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Modal,
|
||||
{
|
||||
className: "preferences-modal",
|
||||
title: (0,external_wp_i18n_namespaceObject.__)("Preferences"),
|
||||
onRequestClose: closeModal,
|
||||
children
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preferences-modal-section/index.js
|
||||
|
||||
const Section = ({
|
||||
description,
|
||||
title,
|
||||
children
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
|
||||
className: "preferences-modal__section",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("legend", {
|
||||
className: "preferences-modal__section-legend",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
|
||||
className: "preferences-modal__section-title",
|
||||
children: title
|
||||
}), description && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
|
||||
className: "preferences-modal__section-description",
|
||||
children: description
|
||||
})]
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
className: "preferences-modal__section-content",
|
||||
children: children
|
||||
})]
|
||||
});
|
||||
/* harmony default export */ const preferences_modal_section = (Section);
|
||||
const Section = ({ description, title, children }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", { className: "preferences-modal__section", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)("legend", { className: "preferences-modal__section-legend", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", { className: "preferences-modal__section-title", children: title }),
|
||||
description && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("p", { className: "preferences-modal__section-description", children: description })
|
||||
] }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { className: "preferences-modal__section-content", children })
|
||||
] });
|
||||
var preferences_modal_section_default = Section;
|
||||
|
||||
|
||||
;// external ["wp","compose"]
|
||||
const external_wp_compose_namespaceObject = window["wp"]["compose"];
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// ./node_modules/@wordpress/icons/build-module/icon/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
var icon_default = (0,external_wp_element_namespaceObject.forwardRef)(
|
||||
({ icon, size = 24, ...props }, ref) => {
|
||||
return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
|
||||
width: size,
|
||||
height: size,
|
||||
...props,
|
||||
ref
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
/** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
|
||||
|
||||
/**
|
||||
* Return an SVG icon.
|
||||
*
|
||||
* @param {IconProps} props icon is the SVG component to render
|
||||
* size is a number specifying the icon size in pixels
|
||||
* Other props will be passed to wrapped SVG component
|
||||
* @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
|
||||
*
|
||||
* @return {JSX.Element} Icon component
|
||||
*/
|
||||
function Icon({
|
||||
icon,
|
||||
size = 24,
|
||||
...props
|
||||
}, ref) {
|
||||
return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
|
||||
width: size,
|
||||
height: size,
|
||||
...props,
|
||||
ref
|
||||
});
|
||||
}
|
||||
/* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
|
||||
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const chevronLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const chevron_left = (chevronLeft);
|
||||
var chevron_left_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const chevronRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const chevron_right = (chevronRight);
|
||||
var chevron_right_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });
|
||||
|
||||
|
||||
;// external ["wp","privateApis"]
|
||||
const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
|
||||
;// ./node_modules/@wordpress/preferences/build-module/lock-unlock.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
const {
|
||||
lock,
|
||||
unlock
|
||||
} = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/preferences');
|
||||
const { lock, unlock } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)(
|
||||
"I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.",
|
||||
"@wordpress/preferences"
|
||||
);
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/components/preferences-modal-tabs/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
const {
|
||||
Tabs
|
||||
} = unlock(external_wp_components_namespaceObject.privateApis);
|
||||
const PREFERENCES_MENU = 'preferences-menu';
|
||||
function PreferencesModalTabs({
|
||||
sections
|
||||
}) {
|
||||
const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
|
||||
|
||||
// This is also used to sync the two different rendered components
|
||||
// between small and large viewports.
|
||||
const { Tabs } = unlock(external_wp_components_namespaceObject.privateApis);
|
||||
const PREFERENCES_MENU = "preferences-menu";
|
||||
function PreferencesModalTabs({ sections }) {
|
||||
const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)("medium");
|
||||
const [activeMenu, setActiveMenu] = (0,external_wp_element_namespaceObject.useState)(PREFERENCES_MENU);
|
||||
/**
|
||||
* Create helper objects from `sections` for easier data handling.
|
||||
* `tabs` is used for creating the `Tabs` and `sectionsContentMap`
|
||||
* is used for easier access to active tab's content.
|
||||
*/
|
||||
const {
|
||||
tabs,
|
||||
sectionsContentMap
|
||||
} = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
const { tabs, sectionsContentMap } = (0,external_wp_element_namespaceObject.useMemo)(() => {
|
||||
let mappedTabs = {
|
||||
tabs: [],
|
||||
sectionsContentMap: {}
|
||||
};
|
||||
if (sections.length) {
|
||||
mappedTabs = sections.reduce((accumulator, {
|
||||
name,
|
||||
tabLabel: title,
|
||||
content
|
||||
}) => {
|
||||
accumulator.tabs.push({
|
||||
name,
|
||||
title
|
||||
});
|
||||
accumulator.sectionsContentMap[name] = content;
|
||||
return accumulator;
|
||||
}, {
|
||||
tabs: [],
|
||||
sectionsContentMap: {}
|
||||
});
|
||||
mappedTabs = sections.reduce(
|
||||
(accumulator, { name, tabLabel: title, content }) => {
|
||||
accumulator.tabs.push({ name, title });
|
||||
accumulator.sectionsContentMap[name] = content;
|
||||
return accumulator;
|
||||
},
|
||||
{ tabs: [], sectionsContentMap: {} }
|
||||
);
|
||||
}
|
||||
return mappedTabs;
|
||||
}, [sections]);
|
||||
let modalContent;
|
||||
// We render different components based on the viewport size.
|
||||
if (isLargeViewport) {
|
||||
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
|
||||
className: "preferences__tabs",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, {
|
||||
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu : undefined,
|
||||
modalContent = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", { className: "preferences__tabs", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(
|
||||
Tabs,
|
||||
{
|
||||
defaultTabId: activeMenu !== PREFERENCES_MENU ? activeMenu : void 0,
|
||||
onSelect: setActiveMenu,
|
||||
orientation: "vertical",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabList, {
|
||||
className: "preferences__tabs-tablist",
|
||||
children: tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tab",
|
||||
children: tab.title
|
||||
}, tab.name))
|
||||
}), tabs.map(tab => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tabpanel",
|
||||
focusable: false,
|
||||
children: sectionsContentMap[tab.name] || null
|
||||
}, tab.name))]
|
||||
})
|
||||
});
|
||||
children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabList, { className: "preferences__tabs-tablist", children: tabs.map((tab) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
Tabs.Tab,
|
||||
{
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tab",
|
||||
children: tab.title
|
||||
},
|
||||
tab.name
|
||||
)) }),
|
||||
tabs.map((tab) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
Tabs.TabPanel,
|
||||
{
|
||||
tabId: tab.name,
|
||||
className: "preferences__tabs-tabpanel",
|
||||
focusable: false,
|
||||
children: sectionsContentMap[tab.name] || null
|
||||
},
|
||||
tab.name
|
||||
))
|
||||
]
|
||||
}
|
||||
) });
|
||||
} else {
|
||||
modalContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Navigator, {
|
||||
initialPath: "/",
|
||||
className: "preferences__provider",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Navigator.Screen, {
|
||||
path: "/",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Card, {
|
||||
isBorderless: true,
|
||||
size: "small",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalItemGroup, {
|
||||
children: tabs.map(tab => {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Navigator.Button, {
|
||||
path: `/${tab.name}`,
|
||||
as: external_wp_components_namespaceObject.__experimentalItem,
|
||||
isAction: true,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
|
||||
justify: "space-between",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTruncate, {
|
||||
children: tab.title
|
||||
})
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left : chevron_right
|
||||
})
|
||||
})]
|
||||
})
|
||||
}, tab.name);
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
}), sections.length && sections.map(section => {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Navigator.Screen, {
|
||||
path: `/${section.name}`,
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Card, {
|
||||
isBorderless: true,
|
||||
size: "large",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.CardHeader, {
|
||||
isBorderless: false,
|
||||
justify: "left",
|
||||
size: "small",
|
||||
gap: "6",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Navigator.BackButton, {
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right : chevron_left,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Back')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
|
||||
size: "16",
|
||||
children: section.tabLabel
|
||||
})]
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, {
|
||||
children: section.content
|
||||
})]
|
||||
})
|
||||
}, `${section.name}-menu`);
|
||||
})]
|
||||
});
|
||||
modalContent = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Navigator, { initialPath: "/", className: "preferences__provider", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Card, { isBorderless: true, size: "small", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, { children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalItemGroup, { children: tabs.map((tab) => {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Navigator.Button,
|
||||
{
|
||||
path: `/${tab.name}`,
|
||||
as: external_wp_components_namespaceObject.__experimentalItem,
|
||||
isAction: true,
|
||||
children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "space-between", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, { children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalTruncate, { children: tab.title }) }),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, { children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
icon_default,
|
||||
{
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_left_default : chevron_right_default
|
||||
}
|
||||
) })
|
||||
] })
|
||||
},
|
||||
tab.name
|
||||
);
|
||||
}) }) }) }) }),
|
||||
sections.length && sections.map((section) => {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Navigator.Screen,
|
||||
{
|
||||
path: `/${section.name}`,
|
||||
children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Card, { isBorderless: true, size: "large", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(
|
||||
external_wp_components_namespaceObject.CardHeader,
|
||||
{
|
||||
isBorderless: false,
|
||||
justify: "left",
|
||||
size: "small",
|
||||
gap: "6",
|
||||
children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Navigator.BackButton,
|
||||
{
|
||||
icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_default : chevron_left_default,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)("Back")
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, { size: "16", children: section.tabLabel })
|
||||
]
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CardBody, { children: section.content })
|
||||
] })
|
||||
},
|
||||
`${section.name}-menu`
|
||||
);
|
||||
})
|
||||
] });
|
||||
}
|
||||
return modalContent;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/private-apis.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -755,18 +553,20 @@ function PreferencesModalTabs({
|
||||
|
||||
const privateApis = {};
|
||||
lock(privateApis, {
|
||||
PreferenceBaseOption: preference_base_option,
|
||||
PreferenceToggleControl: preference_toggle_control,
|
||||
PreferenceBaseOption: preference_base_option_default,
|
||||
PreferenceToggleControl: preference_toggle_control_default,
|
||||
PreferencesModal: PreferencesModal,
|
||||
PreferencesModalSection: preferences_modal_section,
|
||||
PreferencesModalSection: preferences_modal_section_default,
|
||||
PreferencesModalTabs: PreferencesModalTabs
|
||||
});
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/preferences/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).preferences = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+36
-112
@@ -55,134 +55,58 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
View: () => (/* reexport */ View)
|
||||
});
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/clsx/dist/clsx.mjs
|
||||
function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/primitives/build-module/svg/index.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/** @typedef {{isPressed?: boolean} & import('react').ComponentPropsWithoutRef<'svg'>} SVGProps */
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'circle'>} props
|
||||
*
|
||||
* @return {JSX.Element} Circle component
|
||||
*/
|
||||
|
||||
const Circle = props => (0,external_wp_element_namespaceObject.createElement)('circle', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'g'>} props
|
||||
*
|
||||
* @return {JSX.Element} G component
|
||||
*/
|
||||
const G = props => (0,external_wp_element_namespaceObject.createElement)('g', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'line'>} props
|
||||
*
|
||||
* @return {JSX.Element} Path component
|
||||
*/
|
||||
const Line = props => (0,external_wp_element_namespaceObject.createElement)('line', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'path'>} props
|
||||
*
|
||||
* @return {JSX.Element} Path component
|
||||
*/
|
||||
const Path = props => (0,external_wp_element_namespaceObject.createElement)('path', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'polygon'>} props
|
||||
*
|
||||
* @return {JSX.Element} Polygon component
|
||||
*/
|
||||
const Polygon = props => (0,external_wp_element_namespaceObject.createElement)('polygon', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'rect'>} props
|
||||
*
|
||||
* @return {JSX.Element} Rect component
|
||||
*/
|
||||
const Rect = props => (0,external_wp_element_namespaceObject.createElement)('rect', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'defs'>} props
|
||||
*
|
||||
* @return {JSX.Element} Defs component
|
||||
*/
|
||||
const Defs = props => (0,external_wp_element_namespaceObject.createElement)('defs', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'radialGradient'>} props
|
||||
*
|
||||
* @return {JSX.Element} RadialGradient component
|
||||
*/
|
||||
const RadialGradient = props => (0,external_wp_element_namespaceObject.createElement)('radialGradient', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'linearGradient'>} props
|
||||
*
|
||||
* @return {JSX.Element} LinearGradient component
|
||||
*/
|
||||
const LinearGradient = props => (0,external_wp_element_namespaceObject.createElement)('linearGradient', props);
|
||||
|
||||
/**
|
||||
* @param {import('react').ComponentPropsWithoutRef<'stop'>} props
|
||||
*
|
||||
* @return {JSX.Element} Stop component
|
||||
*/
|
||||
const Stop = props => (0,external_wp_element_namespaceObject.createElement)('stop', props);
|
||||
const Circle = (props) => (0,external_wp_element_namespaceObject.createElement)("circle", props);
|
||||
const G = (props) => (0,external_wp_element_namespaceObject.createElement)("g", props);
|
||||
const Line = (props) => (0,external_wp_element_namespaceObject.createElement)("line", props);
|
||||
const Path = (props) => (0,external_wp_element_namespaceObject.createElement)("path", props);
|
||||
const Polygon = (props) => (0,external_wp_element_namespaceObject.createElement)("polygon", props);
|
||||
const Rect = (props) => (0,external_wp_element_namespaceObject.createElement)("rect", props);
|
||||
const Defs = (props) => (0,external_wp_element_namespaceObject.createElement)("defs", props);
|
||||
const RadialGradient = (props) => (0,external_wp_element_namespaceObject.createElement)("radialGradient", props);
|
||||
const LinearGradient = (props) => (0,external_wp_element_namespaceObject.createElement)("linearGradient", props);
|
||||
const Stop = (props) => (0,external_wp_element_namespaceObject.createElement)("stop", props);
|
||||
const SVG = (0,external_wp_element_namespaceObject.forwardRef)(
|
||||
/**
|
||||
* @param {SVGProps} props isPressed indicates whether the SVG should appear as pressed.
|
||||
* Other props will be passed through to svg component.
|
||||
* @param {import('react').ForwardedRef<SVGSVGElement>} ref The forwarded ref to the SVG element.
|
||||
*
|
||||
* @return {JSX.Element} Stop component
|
||||
*/
|
||||
({
|
||||
className,
|
||||
isPressed,
|
||||
...props
|
||||
}, ref) => {
|
||||
const appliedProps = {
|
||||
...props,
|
||||
className: dist_clsx(className, {
|
||||
'is-pressed': isPressed
|
||||
}) || undefined,
|
||||
'aria-hidden': true,
|
||||
focusable: false
|
||||
};
|
||||
/**
|
||||
* @param {SVGProps} props isPressed indicates whether the SVG should appear as pressed.
|
||||
* Other props will be passed through to svg component.
|
||||
* @param {import('react').ForwardedRef<SVGSVGElement>} ref The forwarded ref to the SVG element.
|
||||
*
|
||||
* @return {JSX.Element} Stop component
|
||||
*/
|
||||
({ className, isPressed, ...props }, ref) => {
|
||||
const appliedProps = {
|
||||
...props,
|
||||
className: dist_clsx(className, { "is-pressed": isPressed }) || void 0,
|
||||
"aria-hidden": true,
|
||||
focusable: false
|
||||
};
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)("svg", { ...appliedProps, ref });
|
||||
}
|
||||
);
|
||||
SVG.displayName = "SVG";
|
||||
|
||||
// Disable reason: We need to have a way to render HTML tag for web.
|
||||
// eslint-disable-next-line react/forbid-elements
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("svg", {
|
||||
...appliedProps,
|
||||
ref: ref
|
||||
});
|
||||
});
|
||||
SVG.displayName = 'SVG';
|
||||
|
||||
;// ./node_modules/@wordpress/primitives/build-module/horizontal-rule/index.js
|
||||
const HorizontalRule = 'hr';
|
||||
const HorizontalRule = "hr";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/primitives/build-module/block-quotation/index.js
|
||||
const BlockQuotation = 'blockquote';
|
||||
const BlockQuotation = "blockquote";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/primitives/build-module/view/index.js
|
||||
const View = 'div';
|
||||
const View = "div";
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/primitives/build-module/index.js
|
||||
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){var t,n,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(n=r(e[t]))&&(o&&(o+=" "),o+=n)}else for(n in e)e[n]&&(o&&(o+=" "),o+=n);return o}e.r(t),e.d(t,{BlockQuotation:()=>g,Circle:()=>i,Defs:()=>m,G:()=>l,HorizontalRule:()=>b,Line:()=>c,LinearGradient:()=>u,Path:()=>s,Polygon:()=>d,RadialGradient:()=>p,Rect:()=>f,SVG:()=>w,Stop:()=>y,View:()=>v});const n=function(){for(var e,t,n=0,o="",a=arguments.length;n<a;n++)(e=arguments[n])&&(t=r(e))&&(o&&(o+=" "),o+=t);return o},o=window.wp.element,a=window.ReactJSXRuntime,i=e=>(0,o.createElement)("circle",e),l=e=>(0,o.createElement)("g",e),c=e=>(0,o.createElement)("line",e),s=e=>(0,o.createElement)("path",e),d=e=>(0,o.createElement)("polygon",e),f=e=>(0,o.createElement)("rect",e),m=e=>(0,o.createElement)("defs",e),p=e=>(0,o.createElement)("radialGradient",e),u=e=>(0,o.createElement)("linearGradient",e),y=e=>(0,o.createElement)("stop",e),w=(0,o.forwardRef)((({className:e,isPressed:t,...r},o)=>{const i={...r,className:n(e,{"is-pressed":t})||void 0,"aria-hidden":!0,focusable:!1};return(0,a.jsx)("svg",{...i,ref:o})}));w.displayName="SVG";const b="hr",g="blockquote",v="div";(window.wp=window.wp||{}).primitives=t})();
|
||||
(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{BlockQuotation:()=>g,Circle:()=>i,Defs:()=>m,G:()=>l,HorizontalRule:()=>b,Line:()=>c,LinearGradient:()=>u,Path:()=>s,Polygon:()=>d,RadialGradient:()=>p,Rect:()=>f,SVG:()=>w,Stop:()=>y,View:()=>v});const r=window.ReactJSXRuntime;function n(e){var t,r,o="";if("string"==typeof e||"number"==typeof e)o+=e;else if("object"==typeof e)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=n(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}const o=function(){for(var e,t,r=0,o="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=n(e))&&(o&&(o+=" "),o+=t);return o},a=window.wp.element,i=e=>(0,a.createElement)("circle",e),l=e=>(0,a.createElement)("g",e),c=e=>(0,a.createElement)("line",e),s=e=>(0,a.createElement)("path",e),d=e=>(0,a.createElement)("polygon",e),f=e=>(0,a.createElement)("rect",e),m=e=>(0,a.createElement)("defs",e),p=e=>(0,a.createElement)("radialGradient",e),u=e=>(0,a.createElement)("linearGradient",e),y=e=>(0,a.createElement)("stop",e),w=(0,a.forwardRef)((({className:e,isPressed:t,...n},a)=>{const i={...n,className:o(e,{"is-pressed":t})||void 0,"aria-hidden":!0,focusable:!1};return(0,r.jsx)("svg",{...i,ref:a})}));w.displayName="SVG";const b="hr",g="blockquote",v="div";(window.wp=window.wp||{}).primitives=t})();
|
||||
+13
-150
@@ -303,123 +303,28 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
// EXTERNAL MODULE: ./node_modules/requestidlecallback/index.js
|
||||
var requestidlecallback = __webpack_require__(5033);
|
||||
;// ./node_modules/@wordpress/priority-queue/build-module/request-idle-callback.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return {(callback: Callback) => void} RequestIdleCallback
|
||||
*/
|
||||
function createRequestIdleCallback() {
|
||||
if (typeof window === 'undefined') {
|
||||
return callback => {
|
||||
if (typeof window === "undefined") {
|
||||
return (callback) => {
|
||||
setTimeout(() => callback(Date.now()), 0);
|
||||
};
|
||||
}
|
||||
return window.requestIdleCallback;
|
||||
}
|
||||
/* harmony default export */ const request_idle_callback = (createRequestIdleCallback());
|
||||
var request_idle_callback_default = createRequestIdleCallback();
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/priority-queue/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Enqueued callback to invoke once idle time permits.
|
||||
*
|
||||
* @typedef {()=>void} WPPriorityQueueCallback
|
||||
*/
|
||||
|
||||
/**
|
||||
* An object used to associate callbacks in a particular context grouping.
|
||||
*
|
||||
* @typedef {{}} WPPriorityQueueContext
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to add callback to priority queue.
|
||||
*
|
||||
* @typedef {(element:WPPriorityQueueContext,item:WPPriorityQueueCallback)=>void} WPPriorityQueueAdd
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function to flush callbacks from priority queue.
|
||||
*
|
||||
* @typedef {(element:WPPriorityQueueContext)=>boolean} WPPriorityQueueFlush
|
||||
*/
|
||||
|
||||
/**
|
||||
* Reset the queue.
|
||||
*
|
||||
* @typedef {()=>void} WPPriorityQueueReset
|
||||
*/
|
||||
|
||||
/**
|
||||
* Priority queue instance.
|
||||
*
|
||||
* @typedef {Object} WPPriorityQueue
|
||||
*
|
||||
* @property {WPPriorityQueueAdd} add Add callback to queue for context.
|
||||
* @property {WPPriorityQueueFlush} flush Flush queue for context.
|
||||
* @property {WPPriorityQueueFlush} cancel Clear queue for context.
|
||||
* @property {WPPriorityQueueReset} reset Reset queue.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a context-aware queue that only executes
|
||||
* the last task of a given context.
|
||||
*
|
||||
* @example
|
||||
*```js
|
||||
* import { createQueue } from '@wordpress/priority-queue';
|
||||
*
|
||||
* const queue = createQueue();
|
||||
*
|
||||
* // Context objects.
|
||||
* const ctx1 = {};
|
||||
* const ctx2 = {};
|
||||
*
|
||||
* // For a given context in the queue, only the last callback is executed.
|
||||
* queue.add( ctx1, () => console.log( 'This will be printed first' ) );
|
||||
* queue.add( ctx2, () => console.log( 'This won\'t be printed' ) );
|
||||
* queue.add( ctx2, () => console.log( 'This will be printed second' ) );
|
||||
*```
|
||||
*
|
||||
* @return {WPPriorityQueue} Queue object with `add`, `flush` and `reset` methods.
|
||||
*/
|
||||
const createQueue = () => {
|
||||
/** @type {Map<WPPriorityQueueContext, WPPriorityQueueCallback>} */
|
||||
const waitingList = new Map();
|
||||
const waitingList = /* @__PURE__ */ new Map();
|
||||
let isRunning = false;
|
||||
|
||||
/**
|
||||
* Callback to process as much queue as time permits.
|
||||
*
|
||||
* Map Iteration follows the original insertion order. This means that here
|
||||
* we can iterate the queue and know that the first contexts which were
|
||||
* added will be run first. On the other hand, if anyone adds a new callback
|
||||
* for an existing context it will supplant the previously-set callback for
|
||||
* that context because we reassigned that map key's value.
|
||||
*
|
||||
* In the case that a callback adds a new callback to its own context then
|
||||
* the callback it adds will appear at the end of the iteration and will be
|
||||
* run only after all other existing contexts have finished executing.
|
||||
*
|
||||
* @param {IdleDeadline|number} deadline Idle callback deadline object, or
|
||||
* animation frame timestamp.
|
||||
*/
|
||||
const runWaitingList = deadline => {
|
||||
const runWaitingList = (deadline) => {
|
||||
for (const [nextElement, callback] of waitingList) {
|
||||
waitingList.delete(nextElement);
|
||||
callback();
|
||||
if ('number' === typeof deadline || deadline.timeRemaining() <= 0) {
|
||||
if ("number" === typeof deadline || deadline.timeRemaining() <= 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -427,70 +332,27 @@ const createQueue = () => {
|
||||
isRunning = false;
|
||||
return;
|
||||
}
|
||||
request_idle_callback(runWaitingList);
|
||||
request_idle_callback_default(runWaitingList);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a callback to the queue for a given context.
|
||||
*
|
||||
* If errors with undefined callbacks are encountered double check that
|
||||
* all of your useSelect calls have the right dependencies set correctly
|
||||
* in their second parameter. Missing dependencies can cause unexpected
|
||||
* loops and race conditions in the queue.
|
||||
*
|
||||
* @type {WPPriorityQueueAdd}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
* @param {WPPriorityQueueCallback} item Callback function.
|
||||
*/
|
||||
const add = (element, item) => {
|
||||
waitingList.set(element, item);
|
||||
if (!isRunning) {
|
||||
isRunning = true;
|
||||
request_idle_callback(runWaitingList);
|
||||
request_idle_callback_default(runWaitingList);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Flushes queue for a given context, returning true if the flush was
|
||||
* performed, or false if there is no queue for the given context.
|
||||
*
|
||||
* @type {WPPriorityQueueFlush}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
*
|
||||
* @return {boolean} Whether flush was performed.
|
||||
*/
|
||||
const flush = element => {
|
||||
const flush = (element) => {
|
||||
const callback = waitingList.get(element);
|
||||
if (undefined === callback) {
|
||||
if (void 0 === callback) {
|
||||
return false;
|
||||
}
|
||||
waitingList.delete(element);
|
||||
callback();
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the queue for a given context, cancelling the callbacks without
|
||||
* executing them. Returns `true` if there were scheduled callbacks to cancel,
|
||||
* or `false` if there was is no queue for the given context.
|
||||
*
|
||||
* @type {WPPriorityQueueFlush}
|
||||
*
|
||||
* @param {WPPriorityQueueContext} element Context object.
|
||||
*
|
||||
* @return {boolean} Whether any callbacks got cancelled.
|
||||
*/
|
||||
const cancel = element => {
|
||||
const cancel = (element) => {
|
||||
return waitingList.delete(element);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset the queue without running the pending callbacks.
|
||||
*
|
||||
* @type {WPPriorityQueueReset}
|
||||
*/
|
||||
const reset = () => {
|
||||
waitingList.clear();
|
||||
isRunning = false;
|
||||
@@ -503,6 +365,7 @@ const createQueue = () => {
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
})();
|
||||
|
||||
(window.wp = window.wp || {}).priorityQueue = __webpack_exports__;
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{var e={5033:(e,t,n)=>{var o,r,i;r=[],void 0===(i="function"==typeof(o=function(){"use strict";var e,t,o,r,i="undefined"!=typeof window?window:null!=typeof n.g?n.g:this||{},u=i.cancelRequestAnimationFrame&&i.requestAnimationFrame||setTimeout,a=i.cancelRequestAnimationFrame||clearTimeout,c=[],l=0,s=!1,d=7,f=35,m=125,b=0,p=0,w=0,v={get didTimeout(){return!1},timeRemaining:function(){var e=d-(Date.now()-p);return e<0?0:e}},y=g((function(){d=22,m=66,f=0}));function g(e){var t,n,o=99,r=function(){var i=Date.now()-n;i<o?t=setTimeout(r,o-i):(t=null,e())};return function(){n=Date.now(),t||(t=setTimeout(r,o))}}function h(){s&&(r&&a(r),o&&clearTimeout(o),s=!1)}function k(){125!=m&&(d=7,m=125,f=35,s&&(h(),C())),y()}function T(){r=null,o=setTimeout(D,0)}function q(){o=null,u(T)}function C(){s||(t=m-(Date.now()-p),e=Date.now(),s=!0,f&&t<f&&(t=f),t>9?o=setTimeout(q,t):(t=0,q()))}function D(){var n,r,i,u=d>9?9:1;if(p=Date.now(),s=!1,o=null,l>2||p-t-50<e)for(r=0,i=c.length;r<i&&v.timeRemaining()>u;r++)n=c.shift(),w++,n&&n(v);c.length?C():l=0}function I(e){return b++,c.push(e),C(),b}function O(e){var t=e-1-w;c[t]&&(c[t]=null)}if(i.requestIdleCallback&&i.cancelIdleCallback)try{i.requestIdleCallback((function(){}),{timeout:0})}catch(e){!function(e){var t,n;if(i.requestIdleCallback=function(t,n){return n&&"number"==typeof n.timeout?e(t,n.timeout):e(t)},i.IdleCallbackDeadline&&(t=IdleCallbackDeadline.prototype)){if(!(n=Object.getOwnPropertyDescriptor(t,"timeRemaining"))||!n.configurable||!n.get)return;Object.defineProperty(t,"timeRemaining",{value:function(){return n.get.call(this)},enumerable:!0,configurable:!0})}}(i.requestIdleCallback)}else i.requestIdleCallback=I,i.cancelIdleCallback=O,i.document&&document.addEventListener&&(i.addEventListener("scroll",k,!0),i.addEventListener("resize",k),document.addEventListener("focus",k,!0),document.addEventListener("mouseover",k,!0),["click","keypress","touchstart","mousedown"].forEach((function(e){document.addEventListener(e,k,{capture:!0,passive:!0})})),i.MutationObserver&&new MutationObserver(k).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}));return{request:I,cancel:O}})?o.apply(t,r):o)||(e.exports=i)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{createQueue:()=>t});n(5033);const e="undefined"==typeof window?e=>{setTimeout((()=>e(Date.now())),0)}:window.requestIdleCallback,t=()=>{const t=new Map;let n=!1;const o=r=>{for(const[e,n]of t)if(t.delete(e),n(),"number"==typeof r||r.timeRemaining()<=0)break;0!==t.size?e(o):n=!1};return{add:(r,i)=>{t.set(r,i),n||(n=!0,e(o))},flush:e=>{const n=t.get(e);return void 0!==n&&(t.delete(e),n(),!0)},cancel:e=>t.delete(e),reset:()=>{t.clear(),n=!1}}}})(),(window.wp=window.wp||{}).priorityQueue=o})();
|
||||
(()=>{var e={5033:(e,t,n)=>{var o,r,i;r=[],void 0===(i="function"==typeof(o=function(){"use strict";var e,t,o,r,i="undefined"!=typeof window?window:null!=typeof n.g?n.g:this||{},u=i.cancelRequestAnimationFrame&&i.requestAnimationFrame||setTimeout,a=i.cancelRequestAnimationFrame||clearTimeout,c=[],l=0,s=!1,d=7,f=35,m=125,b=0,p=0,v=0,w={get didTimeout(){return!1},timeRemaining:function(){var e=d-(Date.now()-p);return e<0?0:e}},y=g((function(){d=22,m=66,f=0}));function g(e){var t,n,o=99,r=function(){var i=Date.now()-n;i<o?t=setTimeout(r,o-i):(t=null,e())};return function(){n=Date.now(),t||(t=setTimeout(r,o))}}function h(){s&&(r&&a(r),o&&clearTimeout(o),s=!1)}function k(){125!=m&&(d=7,m=125,f=35,s&&(h(),C())),y()}function T(){r=null,o=setTimeout(D,0)}function q(){o=null,u(T)}function C(){s||(t=m-(Date.now()-p),e=Date.now(),s=!0,f&&t<f&&(t=f),t>9?o=setTimeout(q,t):(t=0,q()))}function D(){var n,r,i,u=d>9?9:1;if(p=Date.now(),s=!1,o=null,l>2||p-t-50<e)for(r=0,i=c.length;r<i&&w.timeRemaining()>u;r++)n=c.shift(),v++,n&&n(w);c.length?C():l=0}function I(e){return b++,c.push(e),C(),b}function O(e){var t=e-1-v;c[t]&&(c[t]=null)}if(i.requestIdleCallback&&i.cancelIdleCallback)try{i.requestIdleCallback((function(){}),{timeout:0})}catch(e){!function(e){var t,n;if(i.requestIdleCallback=function(t,n){return n&&"number"==typeof n.timeout?e(t,n.timeout):e(t)},i.IdleCallbackDeadline&&(t=IdleCallbackDeadline.prototype)){if(!(n=Object.getOwnPropertyDescriptor(t,"timeRemaining"))||!n.configurable||!n.get)return;Object.defineProperty(t,"timeRemaining",{value:function(){return n.get.call(this)},enumerable:!0,configurable:!0})}}(i.requestIdleCallback)}else i.requestIdleCallback=I,i.cancelIdleCallback=O,i.document&&document.addEventListener&&(i.addEventListener("scroll",k,!0),i.addEventListener("resize",k),document.addEventListener("focus",k,!0),document.addEventListener("mouseover",k,!0),["click","keypress","touchstart","mousedown"].forEach((function(e){document.addEventListener(e,k,{capture:!0,passive:!0})})),i.MutationObserver&&new MutationObserver(k).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0}));return{request:I,cancel:O}})?o.apply(t,r):o)||(e.exports=i)}},t={};function n(o){var r=t[o];if(void 0!==r)return r.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};(()=>{"use strict";n.r(o),n.d(o,{createQueue:()=>t});n(5033);var e="undefined"==typeof window?e=>{setTimeout((()=>e(Date.now())),0)}:window.requestIdleCallback;const t=()=>{const t=new Map;let n=!1;const o=r=>{for(const[e,n]of t)if(t.delete(e),n(),"number"==typeof r||r.timeRemaining()<=0)break;0!==t.size?e(o):n=!1};return{add:(r,i)=>{t.set(r,i),n||(n=!0,e(o))},flush:e=>{const n=t.get(e);return void 0!==n&&(t.delete(e),n(),!0)},cancel:e=>t.delete(e),reset:()=>{t.clear(),n=!1}}}})(),(window.wp=window.wp||{}).priorityQueue=o})();
|
||||
Vendored
+45
-127
@@ -43,64 +43,50 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
});
|
||||
|
||||
;// ./node_modules/@wordpress/private-apis/build-module/implementation.js
|
||||
/**
|
||||
* wordpress/private-apis – the utilities to enable private cross-package
|
||||
* exports of private APIs.
|
||||
*
|
||||
* This "implementation.ts" file is needed for the sake of the unit tests. It
|
||||
* exports more than the public API of the package to aid in testing.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The list of core modules allowed to opt-in to the private APIs.
|
||||
*/
|
||||
const CORE_MODULES_USING_PRIVATE_APIS = ['@wordpress/block-directory', '@wordpress/block-editor', '@wordpress/block-library', '@wordpress/blocks', '@wordpress/commands', '@wordpress/components', '@wordpress/core-commands', '@wordpress/core-data', '@wordpress/customize-widgets', '@wordpress/data', '@wordpress/edit-post', '@wordpress/edit-site', '@wordpress/edit-widgets', '@wordpress/editor', '@wordpress/format-library', '@wordpress/patterns', '@wordpress/preferences', '@wordpress/reusable-blocks', '@wordpress/router', '@wordpress/dataviews', '@wordpress/fields', '@wordpress/media-utils', '@wordpress/upload-media'];
|
||||
|
||||
/**
|
||||
* A list of core modules that already opted-in to
|
||||
* the privateApis package.
|
||||
*/
|
||||
const CORE_MODULES_USING_PRIVATE_APIS = [
|
||||
"@wordpress/block-directory",
|
||||
"@wordpress/block-editor",
|
||||
"@wordpress/block-library",
|
||||
"@wordpress/blocks",
|
||||
"@wordpress/commands",
|
||||
"@wordpress/components",
|
||||
"@wordpress/core-commands",
|
||||
"@wordpress/core-data",
|
||||
"@wordpress/customize-widgets",
|
||||
"@wordpress/data",
|
||||
"@wordpress/edit-post",
|
||||
"@wordpress/edit-site",
|
||||
"@wordpress/edit-widgets",
|
||||
"@wordpress/editor",
|
||||
"@wordpress/format-library",
|
||||
"@wordpress/patterns",
|
||||
"@wordpress/preferences",
|
||||
"@wordpress/reusable-blocks",
|
||||
"@wordpress/router",
|
||||
"@wordpress/sync",
|
||||
"@wordpress/dataviews",
|
||||
"@wordpress/fields",
|
||||
"@wordpress/media-utils",
|
||||
"@wordpress/upload-media"
|
||||
];
|
||||
const registeredPrivateApis = [];
|
||||
|
||||
/*
|
||||
* Warning for theme and plugin developers.
|
||||
*
|
||||
* The use of private developer APIs is intended for use by WordPress Core
|
||||
* and the Gutenberg plugin exclusively.
|
||||
*
|
||||
* Dangerously opting in to using these APIs is NOT RECOMMENDED. Furthermore,
|
||||
* the WordPress Core philosophy to strive to maintain backward compatibility
|
||||
* for third-party developers DOES NOT APPLY to private APIs.
|
||||
*
|
||||
* THE CONSENT STRING FOR OPTING IN TO THESE APIS MAY CHANGE AT ANY TIME AND
|
||||
* WITHOUT NOTICE. THIS CHANGE WILL BREAK EXISTING THIRD-PARTY CODE. SUCH A
|
||||
* CHANGE MAY OCCUR IN EITHER A MAJOR OR MINOR RELEASE.
|
||||
*/
|
||||
const requiredConsent = 'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.';
|
||||
|
||||
// The safety measure is meant for WordPress core where IS_WORDPRESS_CORE is set to true.
|
||||
const requiredConsent = "I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.";
|
||||
const allowReRegistration = true ? false : 0;
|
||||
|
||||
/**
|
||||
* Called by a @wordpress package wishing to opt-in to accessing or exposing
|
||||
* private private APIs.
|
||||
*
|
||||
* @param consent The consent string.
|
||||
* @param moduleName The name of the module that is opting in.
|
||||
* @return An object containing the lock and unlock functions.
|
||||
*/
|
||||
const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) => {
|
||||
if (!CORE_MODULES_USING_PRIVATE_APIS.includes(moduleName)) {
|
||||
throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}". ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
|
||||
throw new Error(
|
||||
`You tried to opt-in to unstable APIs as module "${moduleName}". This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`
|
||||
);
|
||||
}
|
||||
if (!allowReRegistration && registeredPrivateApis.includes(moduleName)) {
|
||||
// This check doesn't play well with Story Books / Hot Module Reloading
|
||||
// and isn't included in the Gutenberg plugin. It only matters in the
|
||||
// WordPress core release.
|
||||
throw new Error(`You tried to opt-in to unstable APIs as module "${moduleName}" which is already registered. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will be removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on one of the next WordPress releases.');
|
||||
throw new Error(
|
||||
`You tried to opt-in to unstable APIs as module "${moduleName}" which is already registered. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`
|
||||
);
|
||||
}
|
||||
if (consent !== requiredConsent) {
|
||||
throw new Error(`You tried to opt-in to unstable APIs without confirming you know the consequences. ` + 'This feature is only for JavaScript modules shipped with WordPress core. ' + 'Please do not use it in plugins and themes as the unstable APIs will removed ' + 'without a warning. If you ignore this error and depend on unstable features, ' + 'your product will inevitably break on the next WordPress release.');
|
||||
throw new Error(
|
||||
`You tried to opt-in to unstable APIs without confirming you know the consequences. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on the next WordPress release.`
|
||||
);
|
||||
}
|
||||
registeredPrivateApis.push(moduleName);
|
||||
return {
|
||||
@@ -108,34 +94,9 @@ const __dangerousOptInToUnstableAPIsOnlyForCoreModules = (consent, moduleName) =
|
||||
unlock
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Binds private data to an object.
|
||||
* It does not alter the passed object in any way, only
|
||||
* registers it in an internal map of private data.
|
||||
*
|
||||
* The private data can't be accessed by any other means
|
||||
* than the `unlock` function.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const object = {};
|
||||
* const privateData = { a: 1 };
|
||||
* lock( object, privateData );
|
||||
*
|
||||
* object
|
||||
* // {}
|
||||
*
|
||||
* unlock( object );
|
||||
* // { a: 1 }
|
||||
* ```
|
||||
*
|
||||
* @param object The object to bind the private data to.
|
||||
* @param privateData The private data to bind to the object.
|
||||
*/
|
||||
function lock(object, privateData) {
|
||||
if (!object) {
|
||||
throw new Error('Cannot lock an undefined object.');
|
||||
throw new Error("Cannot lock an undefined object.");
|
||||
}
|
||||
const _object = object;
|
||||
if (!(__private in _object)) {
|
||||
@@ -143,82 +104,39 @@ function lock(object, privateData) {
|
||||
}
|
||||
lockedData.set(_object[__private], privateData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlocks the private data bound to an object.
|
||||
*
|
||||
* It does not alter the passed object in any way, only
|
||||
* returns the private data paired with it using the `lock()`
|
||||
* function.
|
||||
*
|
||||
* @example
|
||||
* ```js
|
||||
* const object = {};
|
||||
* const privateData = { a: 1 };
|
||||
* lock( object, privateData );
|
||||
*
|
||||
* object
|
||||
* // {}
|
||||
*
|
||||
* unlock( object );
|
||||
* // { a: 1 }
|
||||
* ```
|
||||
*
|
||||
* @param object The object to unlock the private data from.
|
||||
* @return The private data bound to the object.
|
||||
*/
|
||||
function unlock(object) {
|
||||
if (!object) {
|
||||
throw new Error('Cannot unlock an undefined object.');
|
||||
throw new Error("Cannot unlock an undefined object.");
|
||||
}
|
||||
const _object = object;
|
||||
if (!(__private in _object)) {
|
||||
throw new Error('Cannot unlock an object that was not locked before. ');
|
||||
throw new Error(
|
||||
"Cannot unlock an object that was not locked before. "
|
||||
);
|
||||
}
|
||||
return lockedData.get(_object[__private]);
|
||||
}
|
||||
const lockedData = new WeakMap();
|
||||
|
||||
/**
|
||||
* Used by lock() and unlock() to uniquely identify the private data
|
||||
* related to a containing object.
|
||||
*/
|
||||
const __private = Symbol('Private API ID');
|
||||
|
||||
// Unit tests utilities:
|
||||
|
||||
/**
|
||||
* Private function to allow the unit tests to allow
|
||||
* a mock module to access the private APIs.
|
||||
*
|
||||
* @param name The name of the module.
|
||||
*/
|
||||
const lockedData = /* @__PURE__ */ new WeakMap();
|
||||
const __private = Symbol("Private API ID");
|
||||
function allowCoreModule(name) {
|
||||
CORE_MODULES_USING_PRIVATE_APIS.push(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Private function to allow the unit tests to set
|
||||
* a custom list of allowed modules.
|
||||
*/
|
||||
function resetAllowedCoreModules() {
|
||||
while (CORE_MODULES_USING_PRIVATE_APIS.length) {
|
||||
CORE_MODULES_USING_PRIVATE_APIS.pop();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Private function to allow the unit tests to reset
|
||||
* the list of registered private apis.
|
||||
*/
|
||||
function resetRegisteredPrivateApis() {
|
||||
while (registeredPrivateApis.length) {
|
||||
registeredPrivateApis.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/private-apis/build-module/index.js
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).privateApis = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
/*! This file is auto-generated */
|
||||
(()=>{"use strict";var e={d:(r,o)=>{for(var s in o)e.o(o,s)&&!e.o(r,s)&&Object.defineProperty(r,s,{enumerable:!0,get:o[s]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{__dangerousOptInToUnstableAPIsOnlyForCoreModules:()=>t});const o=["@wordpress/block-directory","@wordpress/block-editor","@wordpress/block-library","@wordpress/blocks","@wordpress/commands","@wordpress/components","@wordpress/core-commands","@wordpress/core-data","@wordpress/customize-widgets","@wordpress/data","@wordpress/edit-post","@wordpress/edit-site","@wordpress/edit-widgets","@wordpress/editor","@wordpress/format-library","@wordpress/patterns","@wordpress/preferences","@wordpress/reusable-blocks","@wordpress/router","@wordpress/dataviews","@wordpress/fields","@wordpress/media-utils","@wordpress/upload-media"],s=[],t=(e,r)=>{if(!o.includes(r))throw new Error(`You tried to opt-in to unstable APIs as module "${r}". This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if(s.includes(r))throw new Error(`You tried to opt-in to unstable APIs as module "${r}" which is already registered. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress."!==e)throw new Error("You tried to opt-in to unstable APIs without confirming you know the consequences. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on the next WordPress release.");return s.push(r),{lock:n,unlock:i}};function n(e,r){if(!e)throw new Error("Cannot lock an undefined object.");const o=e;a in o||(o[a]={}),d.set(o[a],r)}function i(e){if(!e)throw new Error("Cannot unlock an undefined object.");const r=e;if(!(a in r))throw new Error("Cannot unlock an object that was not locked before. ");return d.get(r[a])}const d=new WeakMap,a=Symbol("Private API ID");(window.wp=window.wp||{}).privateApis=r})();
|
||||
(()=>{"use strict";var e={d:(r,o)=>{for(var s in o)e.o(o,s)&&!e.o(r,s)&&Object.defineProperty(r,s,{enumerable:!0,get:o[s]})},o:(e,r)=>Object.prototype.hasOwnProperty.call(e,r),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},r={};e.r(r),e.d(r,{__dangerousOptInToUnstableAPIsOnlyForCoreModules:()=>t});const o=["@wordpress/block-directory","@wordpress/block-editor","@wordpress/block-library","@wordpress/blocks","@wordpress/commands","@wordpress/components","@wordpress/core-commands","@wordpress/core-data","@wordpress/customize-widgets","@wordpress/data","@wordpress/edit-post","@wordpress/edit-site","@wordpress/edit-widgets","@wordpress/editor","@wordpress/format-library","@wordpress/patterns","@wordpress/preferences","@wordpress/reusable-blocks","@wordpress/router","@wordpress/sync","@wordpress/dataviews","@wordpress/fields","@wordpress/media-utils","@wordpress/upload-media"],s=[],t=(e,r)=>{if(!o.includes(r))throw new Error(`You tried to opt-in to unstable APIs as module "${r}". This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if(s.includes(r))throw new Error(`You tried to opt-in to unstable APIs as module "${r}" which is already registered. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will be removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on one of the next WordPress releases.`);if("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress."!==e)throw new Error("You tried to opt-in to unstable APIs without confirming you know the consequences. This feature is only for JavaScript modules shipped with WordPress core. Please do not use it in plugins and themes as the unstable APIs will removed without a warning. If you ignore this error and depend on unstable features, your product will inevitably break on the next WordPress release.");return s.push(r),{lock:n,unlock:i}};function n(e,r){if(!e)throw new Error("Cannot lock an undefined object.");const o=e;a in o||(o[a]={}),d.set(o[a],r)}function i(e){if(!e)throw new Error("Cannot unlock an undefined object.");const r=e;if(!(a in r))throw new Error("Cannot unlock an object that was not locked before. ");return d.get(r[a])}const d=new WeakMap,a=Symbol("Private API ID");(window.wp=window.wp||{}).privateApis=r})();
|
||||
Vendored
+33
-88
@@ -704,23 +704,11 @@ __webpack_require__.d(__webpack_exports__, {
|
||||
});
|
||||
|
||||
;// ./node_modules/@wordpress/redux-routine/build-module/is-generator.js
|
||||
/* eslint-disable jsdoc/valid-types */
|
||||
/**
|
||||
* Returns true if the given object is a generator, or false otherwise.
|
||||
*
|
||||
* @see https://www.ecma-international.org/ecma-262/6.0/#sec-generator-objects
|
||||
*
|
||||
* @param {any} object Object to test.
|
||||
*
|
||||
* @return {object is Generator} Whether object is a generator.
|
||||
*/
|
||||
function isGenerator(object) {
|
||||
/* eslint-enable jsdoc/valid-types */
|
||||
// Check that iterator (next) and iterable (Symbol.iterator) interfaces are satisfied.
|
||||
// These checks seem to be compatible with several generator helpers as well as the native implementation.
|
||||
return !!object && typeof object[Symbol.iterator] === 'function' && typeof object.next === 'function';
|
||||
return !!object && typeof object[Symbol.iterator] === "function" && typeof object.next === "function";
|
||||
}
|
||||
|
||||
|
||||
// EXTERNAL MODULE: ./node_modules/rungen/dist/index.js
|
||||
var dist = __webpack_require__(8975);
|
||||
;// ./node_modules/is-promise/index.mjs
|
||||
@@ -765,69 +753,34 @@ function isPlainObject(o) {
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/redux-routine/build-module/is-action.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
/* eslint-disable jsdoc/valid-types */
|
||||
/**
|
||||
* Returns true if the given object quacks like an action.
|
||||
*
|
||||
* @param {any} object Object to test
|
||||
*
|
||||
* @return {object is import('redux').AnyAction} Whether object is an action.
|
||||
*/
|
||||
function isAction(object) {
|
||||
return isPlainObject(object) && typeof object.type === 'string';
|
||||
return isPlainObject(object) && typeof object.type === "string";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given object quacks like an action and has a specific
|
||||
* action type
|
||||
*
|
||||
* @param {unknown} object Object to test
|
||||
* @param {string} expectedType The expected type for the action.
|
||||
*
|
||||
* @return {object is import('redux').AnyAction} Whether object is an action and is of specific type.
|
||||
*/
|
||||
function isActionOfType(object, expectedType) {
|
||||
/* eslint-enable jsdoc/valid-types */
|
||||
return isAction(object) && object.type === expectedType;
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/redux-routine/build-module/runtime.js
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Create a co-routine runtime.
|
||||
*
|
||||
* @param controls Object of control handlers.
|
||||
* @param dispatch Unhandled action dispatch.
|
||||
*/
|
||||
function createRuntime(controls = {}, dispatch) {
|
||||
const rungenControls = Object.entries(controls).map(([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
|
||||
if (!isActionOfType(value, actionType)) {
|
||||
return false;
|
||||
const rungenControls = Object.entries(controls).map(
|
||||
([actionType, control]) => (value, next, iterate, yieldNext, yieldError) => {
|
||||
if (!isActionOfType(value, actionType)) {
|
||||
return false;
|
||||
}
|
||||
const routine = control(value);
|
||||
if (isPromise(routine)) {
|
||||
routine.then(yieldNext, yieldError);
|
||||
} else {
|
||||
yieldNext(routine);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const routine = control(value);
|
||||
if (isPromise(routine)) {
|
||||
// Async control routine awaits resolution.
|
||||
routine.then(yieldNext, yieldError);
|
||||
} else {
|
||||
yieldNext(routine);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
);
|
||||
const unhandledActionControl = (value, next) => {
|
||||
if (!isAction(value)) {
|
||||
return false;
|
||||
@@ -838,37 +791,28 @@ function createRuntime(controls = {}, dispatch) {
|
||||
};
|
||||
rungenControls.push(unhandledActionControl);
|
||||
const rungenRuntime = (0,dist.create)(rungenControls);
|
||||
return action => new Promise((resolve, reject) => rungenRuntime(action, result => {
|
||||
if (isAction(result)) {
|
||||
dispatch(result);
|
||||
}
|
||||
resolve(result);
|
||||
}, reject));
|
||||
return (action) => new Promise(
|
||||
(resolve, reject) => rungenRuntime(
|
||||
action,
|
||||
(result) => {
|
||||
if (isAction(result)) {
|
||||
dispatch(result);
|
||||
}
|
||||
resolve(result);
|
||||
},
|
||||
reject
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/redux-routine/build-module/index.js
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a Redux middleware, given an object of controls where each key is an
|
||||
* action type for which to act upon, the value a function which returns either
|
||||
* a promise which is to resolve when evaluation of the action should continue,
|
||||
* or a value. The value or resolved promise value is assigned on the return
|
||||
* value of the yield assignment. If the control handler returns undefined, the
|
||||
* execution is not continued.
|
||||
*
|
||||
* @param {Record<string, (value: import('redux').AnyAction) => Promise<boolean> | boolean>} controls Object of control handlers.
|
||||
*
|
||||
* @return {import('redux').Middleware} Co-routine runtime
|
||||
*/
|
||||
function createMiddleware(controls = {}) {
|
||||
return store => {
|
||||
return (store) => {
|
||||
const runtime = createRuntime(controls, store.dispatch);
|
||||
return next => action => {
|
||||
return (next) => (action) => {
|
||||
if (!isGenerator(action)) {
|
||||
return next(action);
|
||||
}
|
||||
@@ -877,6 +821,7 @@ function createMiddleware(controls = {}) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).reduxRoutine = __webpack_exports__["default"];
|
||||
/******/ })()
|
||||
;
|
||||
+256
-319
@@ -69,107 +69,76 @@ const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
|
||||
;// external ["wp","i18n"]
|
||||
const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns a generator converting a reusable block into a static block.
|
||||
*
|
||||
* @param {string} clientId The client ID of the block to attach.
|
||||
*/
|
||||
const __experimentalConvertBlockToStatic = clientId => ({
|
||||
registry
|
||||
}) => {
|
||||
const __experimentalConvertBlockToStatic = (clientId) => ({ registry }) => {
|
||||
const oldBlock = registry.select(external_wp_blockEditor_namespaceObject.store).getBlock(clientId);
|
||||
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
|
||||
const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(typeof reusableBlock.content === 'function' ? reusableBlock.content(reusableBlock) : reusableBlock.content);
|
||||
const reusableBlock = registry.select("core").getEditedEntityRecord(
|
||||
"postType",
|
||||
"wp_block",
|
||||
oldBlock.attributes.ref
|
||||
);
|
||||
const newBlocks = (0,external_wp_blocks_namespaceObject.parse)(
|
||||
typeof reusableBlock.content === "function" ? reusableBlock.content(reusableBlock) : reusableBlock.content
|
||||
);
|
||||
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(oldBlock.clientId, newBlocks);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a generator converting one or more static blocks into a pattern.
|
||||
*
|
||||
* @param {string[]} clientIds The client IDs of the block to detach.
|
||||
* @param {string} title Pattern title.
|
||||
* @param {undefined|'unsynced'} syncType They way block is synced, current undefined (synced) and 'unsynced'.
|
||||
*/
|
||||
const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({
|
||||
registry,
|
||||
dispatch
|
||||
}) => {
|
||||
const meta = syncType === 'unsynced' ? {
|
||||
const __experimentalConvertBlocksToReusable = (clientIds, title, syncType) => async ({ registry, dispatch }) => {
|
||||
const meta = syncType === "unsynced" ? {
|
||||
wp_pattern_sync_status: syncType
|
||||
} : undefined;
|
||||
} : void 0;
|
||||
const reusableBlock = {
|
||||
title: title || (0,external_wp_i18n_namespaceObject.__)('Untitled pattern block'),
|
||||
content: (0,external_wp_blocks_namespaceObject.serialize)(registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)),
|
||||
status: 'publish',
|
||||
title: title || (0,external_wp_i18n_namespaceObject.__)("Untitled pattern block"),
|
||||
content: (0,external_wp_blocks_namespaceObject.serialize)(
|
||||
registry.select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds)
|
||||
),
|
||||
status: "publish",
|
||||
meta
|
||||
};
|
||||
const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
|
||||
if (syncType === 'unsynced') {
|
||||
const updatedRecord = await registry.dispatch("core").saveEntityRecord("postType", "wp_block", reusableBlock);
|
||||
if (syncType === "unsynced") {
|
||||
return;
|
||||
}
|
||||
const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)('core/block', {
|
||||
const newBlock = (0,external_wp_blocks_namespaceObject.createBlock)("core/block", {
|
||||
ref: updatedRecord.id
|
||||
});
|
||||
registry.dispatch(external_wp_blockEditor_namespaceObject.store).replaceBlocks(clientIds, newBlock);
|
||||
dispatch.__experimentalSetEditingReusableBlock(newBlock.clientId, true);
|
||||
dispatch.__experimentalSetEditingReusableBlock(
|
||||
newBlock.clientId,
|
||||
true
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a generator deleting a reusable block.
|
||||
*
|
||||
* @param {string} id The ID of the reusable block to delete.
|
||||
*/
|
||||
const __experimentalDeleteReusableBlock = id => async ({
|
||||
registry
|
||||
}) => {
|
||||
const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id);
|
||||
|
||||
// Don't allow a reusable block with a temporary ID to be deleted.
|
||||
const __experimentalDeleteReusableBlock = (id) => async ({ registry }) => {
|
||||
const reusableBlock = registry.select("core").getEditedEntityRecord("postType", "wp_block", id);
|
||||
if (!reusableBlock) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove any other blocks that reference this reusable block.
|
||||
const allBlocks = registry.select(external_wp_blockEditor_namespaceObject.store).getBlocks();
|
||||
const associatedBlocks = allBlocks.filter(block => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id);
|
||||
const associatedBlockClientIds = associatedBlocks.map(block => block.clientId);
|
||||
|
||||
// Remove the parsed block.
|
||||
const associatedBlocks = allBlocks.filter(
|
||||
(block) => (0,external_wp_blocks_namespaceObject.isReusableBlock)(block) && block.attributes.ref === id
|
||||
);
|
||||
const associatedBlockClientIds = associatedBlocks.map(
|
||||
(block) => block.clientId
|
||||
);
|
||||
if (associatedBlockClientIds.length) {
|
||||
registry.dispatch(external_wp_blockEditor_namespaceObject.store).removeBlocks(associatedBlockClientIds);
|
||||
}
|
||||
await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
|
||||
await registry.dispatch("core").deleteEntityRecord("postType", "wp_block", id);
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
|
||||
*
|
||||
* @param {string} clientId The clientID of the reusable block to target.
|
||||
* @param {boolean} isEditing Whether the block should be in editing state.
|
||||
* @return {Object} Action descriptor.
|
||||
*/
|
||||
function __experimentalSetEditingReusableBlock(clientId, isEditing) {
|
||||
return {
|
||||
type: 'SET_EDITING_REUSABLE_BLOCK',
|
||||
type: "SET_EDITING_REUSABLE_BLOCK",
|
||||
clientId,
|
||||
isEditing
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
function isEditingReusableBlock(state = {}, action) {
|
||||
if (action?.type === 'SET_EDITING_REUSABLE_BLOCK') {
|
||||
if (action?.type === "SET_EDITING_REUSABLE_BLOCK") {
|
||||
return {
|
||||
...state,
|
||||
[action.clientId]: action.isEditing
|
||||
@@ -177,81 +146,50 @@ function isEditingReusableBlock(state = {}, action) {
|
||||
}
|
||||
return state;
|
||||
}
|
||||
/* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
|
||||
var reducer_default = (0,external_wp_data_namespaceObject.combineReducers)({
|
||||
isEditingReusableBlock
|
||||
}));
|
||||
});
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
|
||||
/**
|
||||
* Returns true if reusable block is in the editing state.
|
||||
*
|
||||
* @param {Object} state Global application state.
|
||||
* @param {number} clientId the clientID of the block.
|
||||
* @return {boolean} Whether the reusable block is in the editing state.
|
||||
*/
|
||||
function __experimentalIsEditingReusableBlock(state, clientId) {
|
||||
return state.isEditingReusableBlock[clientId];
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
const STORE_NAME = 'core/reusable-blocks';
|
||||
|
||||
/**
|
||||
* Store definition for the reusable blocks namespace.
|
||||
*
|
||||
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
const STORE_NAME = "core/reusable-blocks";
|
||||
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
|
||||
actions: actions_namespaceObject,
|
||||
reducer: reducer,
|
||||
reducer: reducer_default,
|
||||
selectors: selectors_namespaceObject
|
||||
});
|
||||
(0,external_wp_data_namespaceObject.register)(store);
|
||||
|
||||
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// external ["wp","element"]
|
||||
const external_wp_element_namespaceObject = window["wp"]["element"];
|
||||
;// external ["wp","components"]
|
||||
const external_wp_components_namespaceObject = window["wp"]["components"];
|
||||
;// external ["wp","primitives"]
|
||||
const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
|
||||
;// external "ReactJSXRuntime"
|
||||
const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
|
||||
;// ./node_modules/@wordpress/icons/build-module/library/symbol.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
|
||||
xmlns: "http://www.w3.org/2000/svg",
|
||||
viewBox: "0 0 24 24",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
|
||||
d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
|
||||
})
|
||||
});
|
||||
/* harmony default export */ const library_symbol = (symbol);
|
||||
var symbol_default = /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, { d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z" }) });
|
||||
|
||||
|
||||
;// external ["wp","notices"]
|
||||
const external_wp_notices_namespaceObject = window["wp"]["notices"];
|
||||
;// external ["wp","coreData"]
|
||||
const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -262,155 +200,178 @@ const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Menu control to convert block(s) to reusable block.
|
||||
*
|
||||
* @param {Object} props Component props.
|
||||
* @param {string[]} props.clientIds Client ids of selected blocks.
|
||||
* @param {string} props.rootClientId ID of the currently selected top-level block.
|
||||
* @param {()=>void} props.onClose Callback to close the menu.
|
||||
* @return {import('react').ComponentType} The menu control or null.
|
||||
*/
|
||||
|
||||
function ReusableBlockConvertButton({
|
||||
clientIds,
|
||||
rootClientId,
|
||||
onClose
|
||||
}) {
|
||||
const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(undefined);
|
||||
const [syncType, setSyncType] = (0,external_wp_element_namespaceObject.useState)(void 0);
|
||||
const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
|
||||
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
|
||||
const canConvert = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
var _getBlocksByClientId;
|
||||
const {
|
||||
canUser
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const {
|
||||
getBlocksByClientId,
|
||||
canInsertBlockType,
|
||||
getBlockRootClientId
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : undefined);
|
||||
const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
|
||||
const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
|
||||
const _canConvert =
|
||||
// Hide when this is already a reusable block.
|
||||
!isReusable &&
|
||||
// Hide when reusable blocks are disabled.
|
||||
canInsertBlockType('core/block', rootId) && blocks.every(block =>
|
||||
// Guard against the case where a regular block has *just* been converted.
|
||||
!!block &&
|
||||
// Hide on invalid blocks.
|
||||
block.isValid &&
|
||||
// Hide when block doesn't support being made reusable.
|
||||
(0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, 'reusable', true)) &&
|
||||
// Hide when current doesn't have permission to do that.
|
||||
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
|
||||
!!canUser('create', {
|
||||
kind: 'postType',
|
||||
name: 'wp_block'
|
||||
});
|
||||
return _canConvert;
|
||||
}, [clientIds, rootClientId]);
|
||||
const {
|
||||
__experimentalConvertBlocksToReusable: convertBlocksToReusable
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const {
|
||||
createSuccessNotice,
|
||||
createErrorNotice
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
||||
const onConvert = (0,external_wp_element_namespaceObject.useCallback)(async function (reusableBlockTitle) {
|
||||
try {
|
||||
await convertBlocksToReusable(clientIds, reusableBlockTitle, syncType);
|
||||
createSuccessNotice(!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)('Synced pattern created: %s'), reusableBlockTitle) : (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)('Unsynced pattern created: %s'), reusableBlockTitle), {
|
||||
type: 'snackbar',
|
||||
id: 'convert-to-reusable-block-success'
|
||||
});
|
||||
} catch (error) {
|
||||
createErrorNotice(error.message, {
|
||||
type: 'snackbar',
|
||||
id: 'convert-to-reusable-block-error'
|
||||
});
|
||||
}
|
||||
}, [convertBlocksToReusable, clientIds, syncType, createSuccessNotice, createErrorNotice]);
|
||||
const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)("");
|
||||
const canConvert = (0,external_wp_data_namespaceObject.useSelect)(
|
||||
(select) => {
|
||||
const { canUser } = select(external_wp_coreData_namespaceObject.store);
|
||||
const {
|
||||
getBlocksByClientId,
|
||||
canInsertBlockType,
|
||||
getBlockRootClientId
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const rootId = rootClientId || (clientIds.length > 0 ? getBlockRootClientId(clientIds[0]) : void 0);
|
||||
const blocks = getBlocksByClientId(clientIds) ?? [];
|
||||
const isReusable = blocks.length === 1 && blocks[0] && (0,external_wp_blocks_namespaceObject.isReusableBlock)(blocks[0]) && !!select(external_wp_coreData_namespaceObject.store).getEntityRecord(
|
||||
"postType",
|
||||
"wp_block",
|
||||
blocks[0].attributes.ref
|
||||
);
|
||||
const _canConvert = (
|
||||
// Hide when this is already a reusable block.
|
||||
!isReusable && // Hide when reusable blocks are disabled.
|
||||
canInsertBlockType("core/block", rootId) && blocks.every(
|
||||
(block) => (
|
||||
// Guard against the case where a regular block has *just* been converted.
|
||||
!!block && // Hide on invalid blocks.
|
||||
block.isValid && // Hide when block doesn't support being made reusable.
|
||||
(0,external_wp_blocks_namespaceObject.hasBlockSupport)(block.name, "reusable", true)
|
||||
)
|
||||
) && // Hide when current doesn't have permission to do that.
|
||||
// Blocks refers to the wp_block post type, this checks the ability to create a post of that type.
|
||||
!!canUser("create", {
|
||||
kind: "postType",
|
||||
name: "wp_block"
|
||||
})
|
||||
);
|
||||
return _canConvert;
|
||||
},
|
||||
[clientIds, rootClientId]
|
||||
);
|
||||
const { __experimentalConvertBlocksToReusable: convertBlocksToReusable } = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
const { createSuccessNotice, createErrorNotice } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
|
||||
const onConvert = (0,external_wp_element_namespaceObject.useCallback)(
|
||||
async function(reusableBlockTitle) {
|
||||
try {
|
||||
await convertBlocksToReusable(
|
||||
clientIds,
|
||||
reusableBlockTitle,
|
||||
syncType
|
||||
);
|
||||
createSuccessNotice(
|
||||
!syncType ? (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)("Synced pattern created: %s"),
|
||||
reusableBlockTitle
|
||||
) : (0,external_wp_i18n_namespaceObject.sprintf)(
|
||||
// translators: %s: the name the user has given to the pattern.
|
||||
(0,external_wp_i18n_namespaceObject.__)("Unsynced pattern created: %s"),
|
||||
reusableBlockTitle
|
||||
),
|
||||
{
|
||||
type: "snackbar",
|
||||
id: "convert-to-reusable-block-success"
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
createErrorNotice(error.message, {
|
||||
type: "snackbar",
|
||||
id: "convert-to-reusable-block-error"
|
||||
});
|
||||
}
|
||||
},
|
||||
[
|
||||
convertBlocksToReusable,
|
||||
clientIds,
|
||||
syncType,
|
||||
createSuccessNotice,
|
||||
createErrorNotice
|
||||
]
|
||||
);
|
||||
if (!canConvert) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
||||
icon: library_symbol,
|
||||
onClick: () => setIsModalOpen(true),
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Create pattern')
|
||||
}), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
|
||||
title: (0,external_wp_i18n_namespaceObject.__)('Create pattern'),
|
||||
onRequestClose: () => {
|
||||
setIsModalOpen(false);
|
||||
setTitle('');
|
||||
},
|
||||
overlayClassName: "reusable-blocks-menu-items__convert-modal",
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
|
||||
onSubmit: event => {
|
||||
event.preventDefault();
|
||||
onConvert(title);
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { icon: symbol_default, onClick: () => setIsModalOpen(true), children: (0,external_wp_i18n_namespaceObject.__)("Create pattern") }),
|
||||
isModalOpen && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Modal,
|
||||
{
|
||||
title: (0,external_wp_i18n_namespaceObject.__)("Create pattern"),
|
||||
onRequestClose: () => {
|
||||
setIsModalOpen(false);
|
||||
setTitle('');
|
||||
onClose();
|
||||
setTitle("");
|
||||
},
|
||||
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
|
||||
spacing: "5",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
|
||||
__next40pxDefaultSize: true,
|
||||
__nextHasNoMarginBottom: true,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)('Name'),
|
||||
value: title,
|
||||
onChange: setTitle,
|
||||
placeholder: (0,external_wp_i18n_namespaceObject.__)('My pattern')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
|
||||
__nextHasNoMarginBottom: true,
|
||||
label: (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)'),
|
||||
help: (0,external_wp_i18n_namespaceObject.__)('Sync this pattern across multiple locations.'),
|
||||
checked: !syncType,
|
||||
onChange: () => {
|
||||
setSyncType(!syncType ? 'unsynced' : undefined);
|
||||
}
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
|
||||
justify: "right",
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "tertiary",
|
||||
onClick: () => {
|
||||
setIsModalOpen(false);
|
||||
setTitle('');
|
||||
},
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
|
||||
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "primary",
|
||||
type: "submit",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Create')
|
||||
})]
|
||||
})]
|
||||
})
|
||||
})
|
||||
})]
|
||||
});
|
||||
overlayClassName: "reusable-blocks-menu-items__convert-modal",
|
||||
children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
"form",
|
||||
{
|
||||
onSubmit: (event) => {
|
||||
event.preventDefault();
|
||||
onConvert(title);
|
||||
setIsModalOpen(false);
|
||||
setTitle("");
|
||||
onClose();
|
||||
},
|
||||
children: /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, { spacing: "5", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.TextControl,
|
||||
{
|
||||
__next40pxDefaultSize: true,
|
||||
__nextHasNoMarginBottom: true,
|
||||
label: (0,external_wp_i18n_namespaceObject.__)("Name"),
|
||||
value: title,
|
||||
onChange: setTitle,
|
||||
placeholder: (0,external_wp_i18n_namespaceObject.__)("My pattern")
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.ToggleControl,
|
||||
{
|
||||
__nextHasNoMarginBottom: true,
|
||||
label: (0,external_wp_i18n_namespaceObject._x)("Synced", "pattern (singular)"),
|
||||
help: (0,external_wp_i18n_namespaceObject.__)(
|
||||
"Sync this pattern across multiple locations."
|
||||
),
|
||||
checked: !syncType,
|
||||
onChange: () => {
|
||||
setSyncType(
|
||||
!syncType ? "unsynced" : void 0
|
||||
);
|
||||
}
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, { justify: "right", children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "tertiary",
|
||||
onClick: () => {
|
||||
setIsModalOpen(false);
|
||||
setTitle("");
|
||||
},
|
||||
children: (0,external_wp_i18n_namespaceObject.__)("Cancel")
|
||||
}
|
||||
),
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
external_wp_components_namespaceObject.Button,
|
||||
{
|
||||
__next40pxDefaultSize: true,
|
||||
variant: "primary",
|
||||
type: "submit",
|
||||
children: (0,external_wp_i18n_namespaceObject.__)("Create")
|
||||
}
|
||||
)
|
||||
] })
|
||||
] })
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
] });
|
||||
}
|
||||
|
||||
|
||||
;// external ["wp","url"]
|
||||
const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -419,105 +380,81 @@ const external_wp_url_namespaceObject = window["wp"]["url"];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
function ReusableBlocksManageButton({
|
||||
clientId
|
||||
}) {
|
||||
const {
|
||||
canRemove,
|
||||
isVisible,
|
||||
managePatternsUrl
|
||||
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
|
||||
const {
|
||||
getBlock,
|
||||
canRemoveBlock,
|
||||
getBlockCount
|
||||
} = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const {
|
||||
canUser
|
||||
} = select(external_wp_coreData_namespaceObject.store);
|
||||
const reusableBlock = getBlock(clientId);
|
||||
return {
|
||||
canRemove: canRemoveBlock(clientId),
|
||||
isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser('update', {
|
||||
kind: 'postType',
|
||||
name: 'wp_block',
|
||||
id: reusableBlock.attributes.ref
|
||||
}),
|
||||
innerBlockCount: getBlockCount(clientId),
|
||||
// The site editor and templates both check whether the user
|
||||
// has edit_theme_options capabilities. We can leverage that here
|
||||
// and omit the manage patterns link if the user can't access it.
|
||||
managePatternsUrl: canUser('create', {
|
||||
kind: 'postType',
|
||||
name: 'wp_template'
|
||||
}) ? (0,external_wp_url_namespaceObject.addQueryArgs)('site-editor.php', {
|
||||
path: '/patterns'
|
||||
}) : (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
|
||||
post_type: 'wp_block'
|
||||
})
|
||||
};
|
||||
}, [clientId]);
|
||||
const {
|
||||
__experimentalConvertBlockToStatic: convertBlockToStatic
|
||||
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
function ReusableBlocksManageButton({ clientId }) {
|
||||
const { canRemove, isVisible, managePatternsUrl } = (0,external_wp_data_namespaceObject.useSelect)(
|
||||
(select) => {
|
||||
const { getBlock, canRemoveBlock } = select(external_wp_blockEditor_namespaceObject.store);
|
||||
const { canUser } = select(external_wp_coreData_namespaceObject.store);
|
||||
const reusableBlock = getBlock(clientId);
|
||||
return {
|
||||
canRemove: canRemoveBlock(clientId),
|
||||
isVisible: !!reusableBlock && (0,external_wp_blocks_namespaceObject.isReusableBlock)(reusableBlock) && !!canUser("update", {
|
||||
kind: "postType",
|
||||
name: "wp_block",
|
||||
id: reusableBlock.attributes.ref
|
||||
}),
|
||||
// The site editor and templates both check whether the user
|
||||
// has edit_theme_options capabilities. We can leverage that here
|
||||
// and omit the manage patterns link if the user can't access it.
|
||||
managePatternsUrl: canUser("create", {
|
||||
kind: "postType",
|
||||
name: "wp_template"
|
||||
}) ? (0,external_wp_url_namespaceObject.addQueryArgs)("site-editor.php", {
|
||||
p: "/pattern"
|
||||
}) : (0,external_wp_url_namespaceObject.addQueryArgs)("edit.php", {
|
||||
post_type: "wp_block"
|
||||
})
|
||||
};
|
||||
},
|
||||
[clientId]
|
||||
);
|
||||
const { __experimentalConvertBlockToStatic: convertBlockToStatic } = (0,external_wp_data_namespaceObject.useDispatch)(store);
|
||||
if (!isVisible) {
|
||||
return null;
|
||||
}
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
||||
href: managePatternsUrl,
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Manage patterns')
|
||||
}), canRemove && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
|
||||
onClick: () => convertBlockToStatic(clientId),
|
||||
children: (0,external_wp_i18n_namespaceObject.__)('Detach')
|
||||
})]
|
||||
});
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { href: managePatternsUrl, children: (0,external_wp_i18n_namespaceObject.__)("Manage patterns") }),
|
||||
canRemove && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, { onClick: () => convertBlockToStatic(clientId), children: (0,external_wp_i18n_namespaceObject.__)("Detach") })
|
||||
] });
|
||||
}
|
||||
/* harmony default export */ const reusable_blocks_manage_button = (ReusableBlocksManageButton);
|
||||
var reusable_blocks_manage_button_default = ReusableBlocksManageButton;
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
|
||||
/**
|
||||
* WordPress dependencies
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function ReusableBlocksMenuItems({
|
||||
rootClientId
|
||||
}) {
|
||||
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
|
||||
children: ({
|
||||
onClose,
|
||||
selectedClientIds
|
||||
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
|
||||
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ReusableBlockConvertButton, {
|
||||
|
||||
function ReusableBlocksMenuItems({ rootClientId }) {
|
||||
return /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, { children: ({ onClose, selectedClientIds }) => /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, { children: [
|
||||
/* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
ReusableBlockConvertButton,
|
||||
{
|
||||
clientIds: selectedClientIds,
|
||||
rootClientId: rootClientId,
|
||||
onClose: onClose
|
||||
}), selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(reusable_blocks_manage_button, {
|
||||
rootClientId,
|
||||
onClose
|
||||
}
|
||||
),
|
||||
selectedClientIds.length === 1 && /* @__PURE__ */ (0,external_ReactJSXRuntime_namespaceObject.jsx)(
|
||||
reusable_blocks_manage_button_default,
|
||||
{
|
||||
clientId: selectedClientIds[0]
|
||||
})]
|
||||
})
|
||||
});
|
||||
}
|
||||
)
|
||||
] }) });
|
||||
}
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
|
||||
|
||||
|
||||
|
||||
;// ./node_modules/@wordpress/reusable-blocks/build-module/index.js
|
||||
|
||||
|
||||
|
||||
|
||||
(window.wp = window.wp || {}).reusableBlocks = __webpack_exports__;
|
||||
/******/ })()
|
||||
;
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+721
-2086
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user