this["wp"] = this["wp"] || {}; this["wp"]["blockEditor"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 440);
/******/ })
/************************************************************************/
/******/ ({
/***/ 0:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["element"]; }());
/***/ }),
/***/ 1:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["i18n"]; }());
/***/ }),
/***/ 10:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
(function () {
'use strict';
var hasOwn = {}.hasOwnProperty;
function classNames () {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg) && arg.length) {
var inner = classNames.apply(null, arg);
if (inner) {
classes.push(inner);
}
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
if ( true && module.exports) {
classNames.default = classNames;
module.exports = classNames;
} else if (true) {
// register as 'classnames', consistent with npm package name
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
return classNames;
}).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else {}
}());
/***/ }),
/***/ 11:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
var arrayWithHoles = __webpack_require__(38);
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
var unsupportedIterableToArray = __webpack_require__(31);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
var nonIterableRest = __webpack_require__(39);
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
function _slicedToArray(arr, i) {
return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
}
/***/ }),
/***/ 113:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _extends = _interopDefault(__webpack_require__(185));
var _objectWithoutPropertiesLoose = _interopDefault(__webpack_require__(186));
var React = __webpack_require__(14);
var React__default = _interopDefault(React);
var _inheritsLoose = _interopDefault(__webpack_require__(158));
var _assertThisInitialized = _interopDefault(__webpack_require__(188));
var is = {
arr: Array.isArray,
obj: function obj(a) {
return Object.prototype.toString.call(a) === '[object Object]';
},
fun: function fun(a) {
return typeof a === 'function';
},
str: function str(a) {
return typeof a === 'string';
},
num: function num(a) {
return typeof a === 'number';
},
und: function und(a) {
return a === void 0;
},
nul: function nul(a) {
return a === null;
},
set: function set(a) {
return a instanceof Set;
},
map: function map(a) {
return a instanceof Map;
},
equ: function equ(a, b) {
if (typeof a !== typeof b) return false;
if (is.str(a) || is.num(a)) return a === b;
if (is.obj(a) && is.obj(b) && Object.keys(a).length + Object.keys(b).length === 0) return true;
var i;
for (i in a) {
if (!(i in b)) return false;
}
for (i in b) {
if (a[i] !== b[i]) return false;
}
return is.und(i) ? a === b : true;
}
};
function merge(target, lowercase) {
if (lowercase === void 0) {
lowercase = true;
}
return function (object) {
return (is.arr(object) ? object : Object.keys(object)).reduce(function (acc, element) {
var key = lowercase ? element[0].toLowerCase() + element.substring(1) : element;
acc[key] = target(key);
return acc;
}, target);
};
}
function useForceUpdate() {
var _useState = React.useState(false),
f = _useState[1];
var forceUpdate = React.useCallback(function () {
return f(function (v) {
return !v;
});
}, []);
return forceUpdate;
}
function withDefault(value, defaultValue) {
return is.und(value) || is.nul(value) ? defaultValue : value;
}
function toArray(a) {
return !is.und(a) ? is.arr(a) ? a : [a] : [];
}
function callProp(obj) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
return is.fun(obj) ? obj.apply(void 0, args) : obj;
}
function getForwardProps(props) {
var to = props.to,
from = props.from,
config = props.config,
onStart = props.onStart,
onRest = props.onRest,
onFrame = props.onFrame,
children = props.children,
reset = props.reset,
reverse = props.reverse,
force = props.force,
immediate = props.immediate,
delay = props.delay,
attach = props.attach,
destroyed = props.destroyed,
interpolateTo = props.interpolateTo,
ref = props.ref,
lazy = props.lazy,
forward = _objectWithoutPropertiesLoose(props, ["to", "from", "config", "onStart", "onRest", "onFrame", "children", "reset", "reverse", "force", "immediate", "delay", "attach", "destroyed", "interpolateTo", "ref", "lazy"]);
return forward;
}
function interpolateTo(props) {
var forward = getForwardProps(props);
if (is.und(forward)) return _extends({
to: forward
}, props);
var rest = Object.keys(props).reduce(function (a, k) {
var _extends2;
return !is.und(forward[k]) ? a : _extends({}, a, (_extends2 = {}, _extends2[k] = props[k], _extends2));
}, {});
return _extends({
to: forward
}, rest);
}
function handleRef(ref, forward) {
if (forward) {
// If it's a function, assume it's a ref callback
if (is.fun(forward)) forward(ref);else if (is.obj(forward)) {
forward.current = ref;
}
}
return ref;
}
var Animated =
/*#__PURE__*/
function () {
function Animated() {
this.payload = void 0;
this.children = [];
}
var _proto = Animated.prototype;
_proto.getAnimatedValue = function getAnimatedValue() {
return this.getValue();
};
_proto.getPayload = function getPayload() {
return this.payload || this;
};
_proto.attach = function attach() {};
_proto.detach = function detach() {};
_proto.getChildren = function getChildren() {
return this.children;
};
_proto.addChild = function addChild(child) {
if (this.children.length === 0) this.attach();
this.children.push(child);
};
_proto.removeChild = function removeChild(child) {
var index = this.children.indexOf(child);
this.children.splice(index, 1);
if (this.children.length === 0) this.detach();
};
return Animated;
}();
var AnimatedArray =
/*#__PURE__*/
function (_Animated) {
_inheritsLoose(AnimatedArray, _Animated);
function AnimatedArray() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _Animated.call.apply(_Animated, [this].concat(args)) || this;
_this.payload = [];
_this.attach = function () {
return _this.payload.forEach(function (p) {
return p instanceof Animated && p.addChild(_assertThisInitialized(_this));
});
};
_this.detach = function () {
return _this.payload.forEach(function (p) {
return p instanceof Animated && p.removeChild(_assertThisInitialized(_this));
});
};
return _this;
}
return AnimatedArray;
}(Animated);
var AnimatedObject =
/*#__PURE__*/
function (_Animated2) {
_inheritsLoose(AnimatedObject, _Animated2);
function AnimatedObject() {
var _this2;
for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
args[_key3] = arguments[_key3];
}
_this2 = _Animated2.call.apply(_Animated2, [this].concat(args)) || this;
_this2.payload = {};
_this2.attach = function () {
return Object.values(_this2.payload).forEach(function (s) {
return s instanceof Animated && s.addChild(_assertThisInitialized(_this2));
});
};
_this2.detach = function () {
return Object.values(_this2.payload).forEach(function (s) {
return s instanceof Animated && s.removeChild(_assertThisInitialized(_this2));
});
};
return _this2;
}
var _proto2 = AnimatedObject.prototype;
_proto2.getValue = function getValue(animated) {
if (animated === void 0) {
animated = false;
}
var payload = {};
for (var _key4 in this.payload) {
var value = this.payload[_key4];
if (animated && !(value instanceof Animated)) continue;
payload[_key4] = value instanceof Animated ? value[animated ? 'getAnimatedValue' : 'getValue']() : value;
}
return payload;
};
_proto2.getAnimatedValue = function getAnimatedValue() {
return this.getValue(true);
};
return AnimatedObject;
}(Animated);
var applyAnimatedValues;
function injectApplyAnimatedValues(fn, transform) {
applyAnimatedValues = {
fn: fn,
transform: transform
};
}
var colorNames;
function injectColorNames(names) {
colorNames = names;
}
var requestFrame = function requestFrame(cb) {
return typeof window !== 'undefined' ? window.requestAnimationFrame(cb) : -1;
};
var cancelFrame = function cancelFrame(id) {
typeof window !== 'undefined' && window.cancelAnimationFrame(id);
};
function injectFrame(raf, caf) {
requestFrame = raf;
cancelFrame = caf;
}
var interpolation;
function injectStringInterpolator(fn) {
interpolation = fn;
}
var now = function now() {
return Date.now();
};
function injectNow(nowFn) {
now = nowFn;
}
var defaultElement;
function injectDefaultElement(el) {
defaultElement = el;
}
var animatedApi = function animatedApi(node) {
return node.current;
};
function injectAnimatedApi(fn) {
animatedApi = fn;
}
var createAnimatedStyle;
function injectCreateAnimatedStyle(factory) {
createAnimatedStyle = factory;
}
var manualFrameloop;
function injectManualFrameloop(callback) {
manualFrameloop = callback;
}
var Globals = /*#__PURE__*/Object.freeze({
get applyAnimatedValues () { return applyAnimatedValues; },
injectApplyAnimatedValues: injectApplyAnimatedValues,
get colorNames () { return colorNames; },
injectColorNames: injectColorNames,
get requestFrame () { return requestFrame; },
get cancelFrame () { return cancelFrame; },
injectFrame: injectFrame,
get interpolation () { return interpolation; },
injectStringInterpolator: injectStringInterpolator,
get now () { return now; },
injectNow: injectNow,
get defaultElement () { return defaultElement; },
injectDefaultElement: injectDefaultElement,
get animatedApi () { return animatedApi; },
injectAnimatedApi: injectAnimatedApi,
get createAnimatedStyle () { return createAnimatedStyle; },
injectCreateAnimatedStyle: injectCreateAnimatedStyle,
get manualFrameloop () { return manualFrameloop; },
injectManualFrameloop: injectManualFrameloop
});
/**
* Wraps the `style` property with `AnimatedStyle`.
*/
var AnimatedProps =
/*#__PURE__*/
function (_AnimatedObject) {
_inheritsLoose(AnimatedProps, _AnimatedObject);
function AnimatedProps(props, callback) {
var _this;
_this = _AnimatedObject.call(this) || this;
_this.update = void 0;
_this.payload = !props.style ? props : _extends({}, props, {
style: createAnimatedStyle(props.style)
});
_this.update = callback;
_this.attach();
return _this;
}
return AnimatedProps;
}(AnimatedObject);
var isFunctionComponent = function isFunctionComponent(val) {
return is.fun(val) && !(val.prototype instanceof React__default.Component);
};
var createAnimatedComponent = function createAnimatedComponent(Component) {
var AnimatedComponent = React.forwardRef(function (props, ref) {
var forceUpdate = useForceUpdate();
var mounted = React.useRef(true);
var propsAnimated = React.useRef(null);
var node = React.useRef(null);
var attachProps = React.useCallback(function (props) {
var oldPropsAnimated = propsAnimated.current;
var callback = function callback() {
var didUpdate = false;
if (node.current) {
didUpdate = applyAnimatedValues.fn(node.current, propsAnimated.current.getAnimatedValue());
}
if (!node.current || didUpdate === false) {
// If no referenced node has been found, or the update target didn't have a
// native-responder, then forceUpdate the animation ...
forceUpdate();
}
};
propsAnimated.current = new AnimatedProps(props, callback);
oldPropsAnimated && oldPropsAnimated.detach();
}, []);
React.useEffect(function () {
return function () {
mounted.current = false;
propsAnimated.current && propsAnimated.current.detach();
};
}, []);
React.useImperativeHandle(ref, function () {
return animatedApi(node, mounted, forceUpdate);
});
attachProps(props);
var _getValue = propsAnimated.current.getValue(),
scrollTop = _getValue.scrollTop,
scrollLeft = _getValue.scrollLeft,
animatedProps = _objectWithoutPropertiesLoose(_getValue, ["scrollTop", "scrollLeft"]); // Functions cannot have refs, see:
// See: https://github.com/react-spring/react-spring/issues/569
var refFn = isFunctionComponent(Component) ? undefined : function (childRef) {
return node.current = handleRef(childRef, ref);
};
return React__default.createElement(Component, _extends({}, animatedProps, {
ref: refFn
}));
});
return AnimatedComponent;
};
var active = false;
var controllers = new Set();
var update = function update() {
if (!active) return false;
var time = now();
for (var _iterator = controllers, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref;
if (_isArray) {
if (_i >= _iterator.length) break;
_ref = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) break;
_ref = _i.value;
}
var controller = _ref;
var isActive = false;
for (var configIdx = 0; configIdx < controller.configs.length; configIdx++) {
var config = controller.configs[configIdx];
var endOfAnimation = void 0,
lastTime = void 0;
for (var valIdx = 0; valIdx < config.animatedValues.length; valIdx++) {
var animation = config.animatedValues[valIdx]; // If an animation is done, skip, until all of them conclude
if (animation.done) continue;
var from = config.fromValues[valIdx];
var to = config.toValues[valIdx];
var position = animation.lastPosition;
var isAnimated = to instanceof Animated;
var velocity = Array.isArray(config.initialVelocity) ? config.initialVelocity[valIdx] : config.initialVelocity;
if (isAnimated) to = to.getValue(); // Conclude animation if it's either immediate, or from-values match end-state
if (config.immediate) {
animation.setValue(to);
animation.done = true;
continue;
} // Break animation when string values are involved
if (typeof from === 'string' || typeof to === 'string') {
animation.setValue(to);
animation.done = true;
continue;
}
if (config.duration !== void 0) {
/** Duration easing */
position = from + config.easing((time - animation.startTime) / config.duration) * (to - from);
endOfAnimation = time >= animation.startTime + config.duration;
} else if (config.decay) {
/** Decay easing */
position = from + velocity / (1 - 0.998) * (1 - Math.exp(-(1 - 0.998) * (time - animation.startTime)));
endOfAnimation = Math.abs(animation.lastPosition - position) < 0.1;
if (endOfAnimation) to = position;
} else {
/** Spring easing */
lastTime = animation.lastTime !== void 0 ? animation.lastTime : time;
velocity = animation.lastVelocity !== void 0 ? animation.lastVelocity : config.initialVelocity; // If we lost a lot of frames just jump to the end.
if (time > lastTime + 64) lastTime = time; // http://gafferongames.com/game-physics/fix-your-timestep/
var numSteps = Math.floor(time - lastTime);
for (var i = 0; i < numSteps; ++i) {
var force = -config.tension * (position - to);
var damping = -config.friction * velocity;
var acceleration = (force + damping) / config.mass;
velocity = velocity + acceleration * 1 / 1000;
position = position + velocity * 1 / 1000;
} // Conditions for stopping the spring animation
var isOvershooting = config.clamp && config.tension !== 0 ? from < to ? position > to : position < to : false;
var isVelocity = Math.abs(velocity) <= config.precision;
var isDisplacement = config.tension !== 0 ? Math.abs(to - position) <= config.precision : true;
endOfAnimation = isOvershooting || isVelocity && isDisplacement;
animation.lastVelocity = velocity;
animation.lastTime = time;
} // Trails aren't done until their parents conclude
if (isAnimated && !config.toValues[valIdx].done) endOfAnimation = false;
if (endOfAnimation) {
// Ensure that we end up with a round value
if (animation.value !== to) position = to;
animation.done = true;
} else isActive = true;
animation.setValue(position);
animation.lastPosition = position;
} // Keep track of updated values only when necessary
if (controller.props.onFrame) controller.values[config.name] = config.interpolation.getValue();
} // Update callbacks in the end of the frame
if (controller.props.onFrame) controller.props.onFrame(controller.values); // Either call onEnd or next frame
if (!isActive) {
controllers.delete(controller);
controller.stop(true);
}
} // Loop over as long as there are controllers ...
if (controllers.size) {
if (manualFrameloop) manualFrameloop();else requestFrame(update);
} else {
active = false;
}
return active;
};
var start = function start(controller) {
if (!controllers.has(controller)) controllers.add(controller);
if (!active) {
active = true;
if (manualFrameloop) requestFrame(manualFrameloop);else requestFrame(update);
}
};
var stop = function stop(controller) {
if (controllers.has(controller)) controllers.delete(controller);
};
function createInterpolator(range, output, extrapolate) {
if (typeof range === 'function') {
return range;
}
if (Array.isArray(range)) {
return createInterpolator({
range: range,
output: output,
extrapolate: extrapolate
});
}
if (interpolation && typeof range.output[0] === 'string') {
return interpolation(range);
}
var config = range;
var outputRange = config.output;
var inputRange = config.range || [0, 1];
var extrapolateLeft = config.extrapolateLeft || config.extrapolate || 'extend';
var extrapolateRight = config.extrapolateRight || config.extrapolate || 'extend';
var easing = config.easing || function (t) {
return t;
};
return function (input) {
var range = findRange(input, inputRange);
return interpolate(input, inputRange[range], inputRange[range + 1], outputRange[range], outputRange[range + 1], easing, extrapolateLeft, extrapolateRight, config.map);
};
}
function interpolate(input, inputMin, inputMax, outputMin, outputMax, easing, extrapolateLeft, extrapolateRight, map) {
var result = map ? map(input) : input; // Extrapolate
if (result < inputMin) {
if (extrapolateLeft === 'identity') return result;else if (extrapolateLeft === 'clamp') result = inputMin;
}
if (result > inputMax) {
if (extrapolateRight === 'identity') return result;else if (extrapolateRight === 'clamp') result = inputMax;
}
if (outputMin === outputMax) return outputMin;
if (inputMin === inputMax) return input <= inputMin ? outputMin : outputMax; // Input Range
if (inputMin === -Infinity) result = -result;else if (inputMax === Infinity) result = result - inputMin;else result = (result - inputMin) / (inputMax - inputMin); // Easing
result = easing(result); // Output Range
if (outputMin === -Infinity) result = -result;else if (outputMax === Infinity) result = result + outputMin;else result = result * (outputMax - outputMin) + outputMin;
return result;
}
function findRange(input, inputRange) {
for (var i = 1; i < inputRange.length - 1; ++i) {
if (inputRange[i] >= input) break;
}
return i - 1;
}
var AnimatedInterpolation =
/*#__PURE__*/
function (_AnimatedArray) {
_inheritsLoose(AnimatedInterpolation, _AnimatedArray);
function AnimatedInterpolation(parents, range, output, extrapolate) {
var _this;
_this = _AnimatedArray.call(this) || this;
_this.calc = void 0;
_this.payload = parents instanceof AnimatedArray && !(parents instanceof AnimatedInterpolation) ? parents.getPayload() : Array.isArray(parents) ? parents : [parents];
_this.calc = createInterpolator(range, output, extrapolate);
return _this;
}
var _proto = AnimatedInterpolation.prototype;
_proto.getValue = function getValue() {
return this.calc.apply(this, this.payload.map(function (value) {
return value.getValue();
}));
};
_proto.updateConfig = function updateConfig(range, output, extrapolate) {
this.calc = createInterpolator(range, output, extrapolate);
};
_proto.interpolate = function interpolate(range, output, extrapolate) {
return new AnimatedInterpolation(this, range, output, extrapolate);
};
return AnimatedInterpolation;
}(AnimatedArray);
var interpolate$1 = function interpolate(parents, range, output) {
return parents && new AnimatedInterpolation(parents, range, output);
};
var config = {
default: {
tension: 170,
friction: 26
},
gentle: {
tension: 120,
friction: 14
},
wobbly: {
tension: 180,
friction: 12
},
stiff: {
tension: 210,
friction: 20
},
slow: {
tension: 280,
friction: 60
},
molasses: {
tension: 280,
friction: 120
}
};
/** API
* useChain(references, timeSteps, timeFrame)
*/
function useChain(refs, timeSteps, timeFrame) {
if (timeFrame === void 0) {
timeFrame = 1000;
}
var previous = React.useRef();
React.useEffect(function () {
if (is.equ(refs, previous.current)) refs.forEach(function (_ref) {
var current = _ref.current;
return current && current.start();
});else if (timeSteps) {
refs.forEach(function (_ref2, index) {
var current = _ref2.current;
if (current) {
var ctrls = current.controllers;
if (ctrls.length) {
var t = timeFrame * timeSteps[index];
ctrls.forEach(function (ctrl) {
ctrl.queue = ctrl.queue.map(function (e) {
return _extends({}, e, {
delay: e.delay + t
});
});
ctrl.start();
});
}
}
});
} else refs.reduce(function (q, _ref3, rI) {
var current = _ref3.current;
return q = q.then(function () {
return current.start();
});
}, Promise.resolve());
previous.current = refs;
});
}
/**
* Animated works by building a directed acyclic graph of dependencies
* transparently when you render your Animated components.
*
* new Animated.Value(0)
* .interpolate() .interpolate() new Animated.Value(1)
* opacity translateY scale
* style transform
* View#234 style
* View#123
*
* A) Top Down phase
* When an AnimatedValue is updated, we recursively go down through this
* graph in order to find leaf nodes: the views that we flag as needing
* an update.
*
* B) Bottom Up phase
* When a view is flagged as needing an update, we recursively go back up
* in order to build the new value that it needs. The reason why we need
* this two-phases process is to deal with composite props such as
* transform which can receive values from multiple parents.
*/
function addAnimatedStyles(node, styles) {
if ('update' in node) {
styles.add(node);
} else {
node.getChildren().forEach(function (child) {
return addAnimatedStyles(child, styles);
});
}
}
var AnimatedValue =
/*#__PURE__*/
function (_Animated) {
_inheritsLoose(AnimatedValue, _Animated);
function AnimatedValue(_value) {
var _this;
_this = _Animated.call(this) || this;
_this.animatedStyles = new Set();
_this.value = void 0;
_this.startPosition = void 0;
_this.lastPosition = void 0;
_this.lastVelocity = void 0;
_this.startTime = void 0;
_this.lastTime = void 0;
_this.done = false;
_this.setValue = function (value, flush) {
if (flush === void 0) {
flush = true;
}
_this.value = value;
if (flush) _this.flush();
};
_this.value = _value;
_this.startPosition = _value;
_this.lastPosition = _value;
return _this;
}
var _proto = AnimatedValue.prototype;
_proto.flush = function flush() {
if (this.animatedStyles.size === 0) {
addAnimatedStyles(this, this.animatedStyles);
}
this.animatedStyles.forEach(function (animatedStyle) {
return animatedStyle.update();
});
};
_proto.clearStyles = function clearStyles() {
this.animatedStyles.clear();
};
_proto.getValue = function getValue() {
return this.value;
};
_proto.interpolate = function interpolate(range, output, extrapolate) {
return new AnimatedInterpolation(this, range, output, extrapolate);
};
return AnimatedValue;
}(Animated);
var AnimatedValueArray =
/*#__PURE__*/
function (_AnimatedArray) {
_inheritsLoose(AnimatedValueArray, _AnimatedArray);
function AnimatedValueArray(values) {
var _this;
_this = _AnimatedArray.call(this) || this;
_this.payload = values.map(function (n) {
return new AnimatedValue(n);
});
return _this;
}
var _proto = AnimatedValueArray.prototype;
_proto.setValue = function setValue(value, flush) {
var _this2 = this;
if (flush === void 0) {
flush = true;
}
if (Array.isArray(value)) {
if (value.length === this.payload.length) {
value.forEach(function (v, i) {
return _this2.payload[i].setValue(v, flush);
});
}
} else {
this.payload.forEach(function (p) {
return p.setValue(value, flush);
});
}
};
_proto.getValue = function getValue() {
return this.payload.map(function (v) {
return v.getValue();
});
};
_proto.interpolate = function interpolate(range, output) {
return new AnimatedInterpolation(this, range, output);
};
return AnimatedValueArray;
}(AnimatedArray);
var G = 0;
var Controller =
/*#__PURE__*/
function () {
function Controller() {
var _this = this;
this.id = void 0;
this.idle = true;
this.hasChanged = false;
this.guid = 0;
this.local = 0;
this.props = {};
this.merged = {};
this.animations = {};
this.interpolations = {};
this.values = {};
this.configs = [];
this.listeners = [];
this.queue = [];
this.localQueue = void 0;
this.getValues = function () {
return _this.interpolations;
};
this.id = G++;
}
/** update(props)
* This function filters input props and creates an array of tasks which are executed in .start()
* Each task is allowed to carry a delay, which means it can execute asnychroneously */
var _proto = Controller.prototype;
_proto.update = function update$$1(args) {
//this._id = n + this.id
if (!args) return this; // Extract delay and the to-prop from props
var _ref = interpolateTo(args),
_ref$delay = _ref.delay,
delay = _ref$delay === void 0 ? 0 : _ref$delay,
to = _ref.to,
props = _objectWithoutPropertiesLoose(_ref, ["delay", "to"]);
if (is.arr(to) || is.fun(to)) {
// If config is either a function or an array queue it up as is
this.queue.push(_extends({}, props, {
delay: delay,
to: to
}));
} else if (to) {
// Otherwise go through each key since it could be delayed individually
var ops = {};
Object.entries(to).forEach(function (_ref2) {
var _to;
var k = _ref2[0],
v = _ref2[1];
// Fetch delay and create an entry, consisting of the to-props, the delay, and basic props
var entry = _extends({
to: (_to = {}, _to[k] = v, _to),
delay: callProp(delay, k)
}, props);
var previous = ops[entry.delay] && ops[entry.delay].to;
ops[entry.delay] = _extends({}, ops[entry.delay], entry, {
to: _extends({}, previous, entry.to)
});
});
this.queue = Object.values(ops);
} // Sort queue, so that async calls go last
this.queue = this.queue.sort(function (a, b) {
return a.delay - b.delay;
}); // Diff the reduced props immediately (they'll contain the from-prop and some config)
this.diff(props);
return this;
}
/** start(onEnd)
* This function either executes a queue, if present, or starts the frameloop, which animates */
;
_proto.start = function start$$1(onEnd) {
var _this2 = this;
// If a queue is present we must excecute it
if (this.queue.length) {
this.idle = false; // Updates can interrupt trailing queues, in that case we just merge values
if (this.localQueue) {
this.localQueue.forEach(function (_ref3) {
var _ref3$from = _ref3.from,
from = _ref3$from === void 0 ? {} : _ref3$from,
_ref3$to = _ref3.to,
to = _ref3$to === void 0 ? {} : _ref3$to;
if (is.obj(from)) _this2.merged = _extends({}, from, _this2.merged);
if (is.obj(to)) _this2.merged = _extends({}, _this2.merged, to);
});
} // The guid helps us tracking frames, a new queue over an old one means an override
// We discard async calls in that caseÍ
var local = this.local = ++this.guid;
var queue = this.localQueue = this.queue;
this.queue = []; // Go through each entry and execute it
queue.forEach(function (_ref4, index) {
var delay = _ref4.delay,
props = _objectWithoutPropertiesLoose(_ref4, ["delay"]);
var cb = function cb(finished) {
if (index === queue.length - 1 && local === _this2.guid && finished) {
_this2.idle = true;
if (_this2.props.onRest) _this2.props.onRest(_this2.merged);
}
if (onEnd) onEnd();
}; // Entries can be delayed, ansyc or immediate
var async = is.arr(props.to) || is.fun(props.to);
if (delay) {
setTimeout(function () {
if (local === _this2.guid) {
if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
}
}, delay);
} else if (async) _this2.runAsync(props, cb);else _this2.diff(props).start(cb);
});
} // Otherwise we kick of the frameloop
else {
if (is.fun(onEnd)) this.listeners.push(onEnd);
if (this.props.onStart) this.props.onStart();
start(this);
}
return this;
};
_proto.stop = function stop$$1(finished) {
this.listeners.forEach(function (onEnd) {
return onEnd(finished);
});
this.listeners = [];
return this;
}
/** Pause sets onEnd listeners free, but also removes the controller from the frameloop */
;
_proto.pause = function pause(finished) {
this.stop(true);
if (finished) stop(this);
return this;
};
_proto.runAsync = function runAsync(_ref5, onEnd) {
var _this3 = this;
var delay = _ref5.delay,
props = _objectWithoutPropertiesLoose(_ref5, ["delay"]);
var local = this.local; // If "to" is either a function or an array it will be processed async, therefor "to" should be empty right now
// If the view relies on certain values "from" has to be present
var queue = Promise.resolve(undefined);
if (is.arr(props.to)) {
var _loop = function _loop(i) {
var index = i;
var fresh = _extends({}, props, interpolateTo(props.to[index]));
if (is.arr(fresh.config)) fresh.config = fresh.config[index];
queue = queue.then(function () {
//this.stop()
if (local === _this3.guid) return new Promise(function (r) {
return _this3.diff(fresh).start(r);
});
});
};
for (var i = 0; i < props.to.length; i++) {
_loop(i);
}
} else if (is.fun(props.to)) {
var index = 0;
var last;
queue = queue.then(function () {
return props.to( // next(props)
function (p) {
var fresh = _extends({}, props, interpolateTo(p));
if (is.arr(fresh.config)) fresh.config = fresh.config[index];
index++; //this.stop()
if (local === _this3.guid) return last = new Promise(function (r) {
return _this3.diff(fresh).start(r);
});
return;
}, // cancel()
function (finished) {
if (finished === void 0) {
finished = true;
}
return _this3.stop(finished);
}).then(function () {
return last;
});
});
}
queue.then(onEnd);
};
_proto.diff = function diff(props) {
var _this4 = this;
this.props = _extends({}, this.props, props);
var _this$props = this.props,
_this$props$from = _this$props.from,
from = _this$props$from === void 0 ? {} : _this$props$from,
_this$props$to = _this$props.to,
to = _this$props$to === void 0 ? {} : _this$props$to,
_this$props$config = _this$props.config,
config = _this$props$config === void 0 ? {} : _this$props$config,
reverse = _this$props.reverse,
attach = _this$props.attach,
reset = _this$props.reset,
immediate = _this$props.immediate; // Reverse values when requested
if (reverse) {
var _ref6 = [to, from];
from = _ref6[0];
to = _ref6[1];
} // This will collect all props that were ever set, reset merged props when necessary
this.merged = _extends({}, from, this.merged, to);
this.hasChanged = false; // Attachment handling, trailed springs can "attach" themselves to a previous spring
var target = attach && attach(this); // Reduces input { name: value } pairs into animated values
this.animations = Object.entries(this.merged).reduce(function (acc, _ref7) {
var name = _ref7[0],
value = _ref7[1];
// Issue cached entries, except on reset
var entry = acc[name] || {}; // Figure out what the value is supposed to be
var isNumber = is.num(value);
var isString = is.str(value) && !value.startsWith('#') && !/\d/.test(value) && !colorNames[value];
var isArray = is.arr(value);
var isInterpolation = !isNumber && !isArray && !isString;
var fromValue = !is.und(from[name]) ? from[name] : value;
var toValue = isNumber || isArray ? value : isString ? value : 1;
var toConfig = callProp(config, name);
if (target) toValue = target.animations[name].parent;
var parent = entry.parent,
interpolation$$1 = entry.interpolation,
toValues = toArray(target ? toValue.getPayload() : toValue),
animatedValues;
var newValue = value;
if (isInterpolation) newValue = interpolation({
range: [0, 1],
output: [value, value]
})(1);
var currentValue = interpolation$$1 && interpolation$$1.getValue(); // Change detection flags
var isFirst = is.und(parent);
var isActive = !isFirst && entry.animatedValues.some(function (v) {
return !v.done;
});
var currentValueDiffersFromGoal = !is.equ(newValue, currentValue);
var hasNewGoal = !is.equ(newValue, entry.previous);
var hasNewConfig = !is.equ(toConfig, entry.config); // Change animation props when props indicate a new goal (new value differs from previous one)
// and current values differ from it. Config changes trigger a new update as well (though probably shouldn't?)
if (reset || hasNewGoal && currentValueDiffersFromGoal || hasNewConfig) {
var _extends2;
// Convert regular values into animated values, ALWAYS re-use if possible
if (isNumber || isString) parent = interpolation$$1 = entry.parent || new AnimatedValue(fromValue);else if (isArray) parent = interpolation$$1 = entry.parent || new AnimatedValueArray(fromValue);else if (isInterpolation) {
var prev = entry.interpolation && entry.interpolation.calc(entry.parent.value);
prev = prev !== void 0 && !reset ? prev : fromValue;
if (entry.parent) {
parent = entry.parent;
parent.setValue(0, false);
} else parent = new AnimatedValue(0);
var range = {
output: [prev, value]
};
if (entry.interpolation) {
interpolation$$1 = entry.interpolation;
entry.interpolation.updateConfig(range);
} else interpolation$$1 = parent.interpolate(range);
}
toValues = toArray(target ? toValue.getPayload() : toValue);
animatedValues = toArray(parent.getPayload());
if (reset && !isInterpolation) parent.setValue(fromValue, false);
_this4.hasChanged = true; // Reset animated values
animatedValues.forEach(function (value) {
value.startPosition = value.value;
value.lastPosition = value.value;
value.lastVelocity = isActive ? value.lastVelocity : undefined;
value.lastTime = isActive ? value.lastTime : undefined;
value.startTime = now();
value.done = false;
value.animatedStyles.clear();
}); // Set immediate values
if (callProp(immediate, name)) {
parent.setValue(isInterpolation ? toValue : value, false);
}
return _extends({}, acc, (_extends2 = {}, _extends2[name] = _extends({}, entry, {
name: name,
parent: parent,
interpolation: interpolation$$1,
animatedValues: animatedValues,
toValues: toValues,
previous: newValue,
config: toConfig,
fromValues: toArray(parent.getValue()),
immediate: callProp(immediate, name),
initialVelocity: withDefault(toConfig.velocity, 0),
clamp: withDefault(toConfig.clamp, false),
precision: withDefault(toConfig.precision, 0.01),
tension: withDefault(toConfig.tension, 170),
friction: withDefault(toConfig.friction, 26),
mass: withDefault(toConfig.mass, 1),
duration: toConfig.duration,
easing: withDefault(toConfig.easing, function (t) {
return t;
}),
decay: toConfig.decay
}), _extends2));
} else {
if (!currentValueDiffersFromGoal) {
var _extends3;
// So ... the current target value (newValue) appears to be different from the previous value,
// which normally constitutes an update, but the actual value (currentValue) matches the target!
// In order to resolve this without causing an animation update we silently flag the animation as done,
// which it technically is. Interpolations also needs a config update with their target set to 1.
if (isInterpolation) {
parent.setValue(1, false);
interpolation$$1.updateConfig({
output: [newValue, newValue]
});
}
parent.done = true;
_this4.hasChanged = true;
return _extends({}, acc, (_extends3 = {}, _extends3[name] = _extends({}, acc[name], {
previous: newValue
}), _extends3));
}
return acc;
}
}, this.animations);
if (this.hasChanged) {
// Make animations available to frameloop
this.configs = Object.values(this.animations);
this.values = {};
this.interpolations = {};
for (var key in this.animations) {
this.interpolations[key] = this.animations[key].interpolation;
this.values[key] = this.animations[key].interpolation.getValue();
}
}
return this;
};
_proto.destroy = function destroy() {
this.stop();
this.props = {};
this.merged = {};
this.animations = {};
this.interpolations = {};
this.values = {};
this.configs = [];
this.local = 0;
};
return Controller;
}();
/** API
* const props = useSprings(number, [{ ... }, { ... }, ...])
* const [props, set] = useSprings(number, (i, controller) => ({ ... }))
*/
var useSprings = function useSprings(length, props) {
var mounted = React.useRef(false);
var ctrl = React.useRef();
var isFn = is.fun(props); // The controller maintains the animation values, starts and stops animations
var _useMemo = React.useMemo(function () {
// Remove old controllers
if (ctrl.current) {
ctrl.current.map(function (c) {
return c.destroy();
});
ctrl.current = undefined;
}
var ref;
return [new Array(length).fill().map(function (_, i) {
var ctrl = new Controller();
var newProps = isFn ? callProp(props, i, ctrl) : props[i];
if (i === 0) ref = newProps.ref;
ctrl.update(newProps);
if (!ref) ctrl.start();
return ctrl;
}), ref];
}, [length]),
controllers = _useMemo[0],
ref = _useMemo[1];
ctrl.current = controllers; // The hooks reference api gets defined here ...
var api = React.useImperativeHandle(ref, function () {
return {
start: function start() {
return Promise.all(ctrl.current.map(function (c) {
return new Promise(function (r) {
return c.start(r);
});
}));
},
stop: function stop(finished) {
return ctrl.current.forEach(function (c) {
return c.stop(finished);
});
},
get controllers() {
return ctrl.current;
}
};
}); // This function updates the controllers
var updateCtrl = React.useMemo(function () {
return function (updateProps) {
return ctrl.current.map(function (c, i) {
c.update(isFn ? callProp(updateProps, i, c) : updateProps[i]);
if (!ref) c.start();
});
};
}, [length]); // Update controller if props aren't functional
React.useEffect(function () {
if (mounted.current) {
if (!isFn) updateCtrl(props);
} else if (!ref) ctrl.current.forEach(function (c) {
return c.start();
});
}); // Update mounted flag and destroy controller on unmount
React.useEffect(function () {
return mounted.current = true, function () {
return ctrl.current.forEach(function (c) {
return c.destroy();
});
};
}, []); // Return animated props, or, anim-props + the update-setter above
var propValues = ctrl.current.map(function (c) {
return c.getValues();
});
return isFn ? [propValues, updateCtrl, function (finished) {
return ctrl.current.forEach(function (c) {
return c.pause(finished);
});
}] : propValues;
};
/** API
* const props = useSpring({ ... })
* const [props, set] = useSpring(() => ({ ... }))
*/
var useSpring = function useSpring(props) {
var isFn = is.fun(props);
var _useSprings = useSprings(1, isFn ? props : [props]),
result = _useSprings[0],
set = _useSprings[1],
pause = _useSprings[2];
return isFn ? [result[0], set, pause] : result;
};
/** API
* const trails = useTrail(number, { ... })
* const [trails, set] = useTrail(number, () => ({ ... }))
*/
var useTrail = function useTrail(length, props) {
var mounted = React.useRef(false);
var isFn = is.fun(props);
var updateProps = callProp(props);
var instances = React.useRef();
var _useSprings = useSprings(length, function (i, ctrl) {
if (i === 0) instances.current = [];
instances.current.push(ctrl);
return _extends({}, updateProps, {
config: callProp(updateProps.config, i),
attach: i > 0 && function () {
return instances.current[i - 1];
}
});
}),
result = _useSprings[0],
set = _useSprings[1],
pause = _useSprings[2]; // Set up function to update controller
var updateCtrl = React.useMemo(function () {
return function (props) {
return set(function (i, ctrl) {
var last = props.reverse ? i === 0 : length - 1 === i;
var attachIdx = props.reverse ? i + 1 : i - 1;
var attachController = instances.current[attachIdx];
return _extends({}, props, {
config: callProp(props.config || updateProps.config, i),
attach: attachController && function () {
return attachController;
}
});
});
};
}, [length, updateProps.reverse]); // Update controller if props aren't functional
React.useEffect(function () {
return void (mounted.current && !isFn && updateCtrl(props));
}); // Update mounted flag and destroy controller on unmount
React.useEffect(function () {
return void (mounted.current = true);
}, []);
return isFn ? [result, updateCtrl, pause] : result;
};
/** API
* const transitions = useTransition(items, itemKeys, { ... })
* const [transitions, update] = useTransition(items, itemKeys, () => ({ ... }))
*/
var guid = 0;
var ENTER = 'enter';
var LEAVE = 'leave';
var UPDATE = 'update';
var mapKeys = function mapKeys(items, keys) {
return (typeof keys === 'function' ? items.map(keys) : toArray(keys)).map(String);
};
var get = function get(props) {
var items = props.items,
_props$keys = props.keys,
keys = _props$keys === void 0 ? function (item) {
return item;
} : _props$keys,
rest = _objectWithoutPropertiesLoose(props, ["items", "keys"]);
items = toArray(items !== void 0 ? items : null);
return _extends({
items: items,
keys: mapKeys(items, keys)
}, rest);
};
function useTransition(input, keyTransform, config) {
var props = _extends({
items: input,
keys: keyTransform || function (i) {
return i;
}
}, config);
var _get = get(props),
_get$lazy = _get.lazy,
lazy = _get$lazy === void 0 ? false : _get$lazy,
_get$unique = _get.unique,
_get$reset = _get.reset,
reset = _get$reset === void 0 ? false : _get$reset,
enter = _get.enter,
leave = _get.leave,
update = _get.update,
onDestroyed = _get.onDestroyed,
keys = _get.keys,
items = _get.items,
onFrame = _get.onFrame,
_onRest = _get.onRest,
onStart = _get.onStart,
ref = _get.ref,
extra = _objectWithoutPropertiesLoose(_get, ["lazy", "unique", "reset", "enter", "leave", "update", "onDestroyed", "keys", "items", "onFrame", "onRest", "onStart", "ref"]);
var forceUpdate = useForceUpdate();
var mounted = React.useRef(false);
var state = React.useRef({
mounted: false,
first: true,
deleted: [],
current: {},
transitions: [],
prevProps: {},
paused: !!props.ref,
instances: !mounted.current && new Map(),
forceUpdate: forceUpdate
});
React.useImperativeHandle(props.ref, function () {
return {
start: function start() {
return Promise.all(Array.from(state.current.instances).map(function (_ref) {
var c = _ref[1];
return new Promise(function (r) {
return c.start(r);
});
}));
},
stop: function stop(finished) {
return Array.from(state.current.instances).forEach(function (_ref2) {
var c = _ref2[1];
return c.stop(finished);
});
},
get controllers() {
return Array.from(state.current.instances).map(function (_ref3) {
var c = _ref3[1];
return c;
});
}
};
}); // Update state
state.current = diffItems(state.current, props);
if (state.current.changed) {
// Update state
state.current.transitions.forEach(function (transition) {
var slot = transition.slot,
from = transition.from,
to = transition.to,
config = transition.config,
trail = transition.trail,
key = transition.key,
item = transition.item;
if (!state.current.instances.has(key)) state.current.instances.set(key, new Controller()); // update the map object
var ctrl = state.current.instances.get(key);
var newProps = _extends({}, extra, {
to: to,
from: from,
config: config,
ref: ref,
onRest: function onRest(values) {
if (state.current.mounted) {
if (transition.destroyed) {
// If no ref is given delete destroyed items immediately
if (!ref && !lazy) cleanUp(state, key);
if (onDestroyed) onDestroyed(item);
} // A transition comes to rest once all its springs conclude
var curInstances = Array.from(state.current.instances);
var active = curInstances.some(function (_ref4) {
var c = _ref4[1];
return !c.idle;
});
if (!active && (ref || lazy) && state.current.deleted.length > 0) cleanUp(state);
if (_onRest) _onRest(item, slot, values);
}
},
onStart: onStart && function () {
return onStart(item, slot);
},
onFrame: onFrame && function (values) {
return onFrame(item, slot, values);
},
delay: trail,
reset: reset && slot === ENTER // Update controller
});
ctrl.update(newProps);
if (!state.current.paused) ctrl.start();
});
}
React.useEffect(function () {
state.current.mounted = mounted.current = true;
return function () {
state.current.mounted = mounted.current = false;
Array.from(state.current.instances).map(function (_ref5) {
var c = _ref5[1];
return c.destroy();
});
state.current.instances.clear();
};
}, []);
return state.current.transitions.map(function (_ref6) {
var item = _ref6.item,
slot = _ref6.slot,
key = _ref6.key;
return {
item: item,
key: key,
state: slot,
props: state.current.instances.get(key).getValues()
};
});
}
function cleanUp(state, filterKey) {
var deleted = state.current.deleted;
var _loop = function _loop() {
if (_isArray) {
if (_i >= _iterator.length) return "break";
_ref8 = _iterator[_i++];
} else {
_i = _iterator.next();
if (_i.done) return "break";
_ref8 = _i.value;
}
var _ref7 = _ref8;
var key = _ref7.key;
var filter = function filter(t) {
return t.key !== key;
};
if (is.und(filterKey) || filterKey === key) {
state.current.instances.delete(key);
state.current.transitions = state.current.transitions.filter(filter);
state.current.deleted = state.current.deleted.filter(filter);
}
};
for (var _iterator = deleted, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
var _ref8;
var _ret = _loop();
if (_ret === "break") break;
}
state.current.forceUpdate();
}
function diffItems(_ref9, props) {
var first = _ref9.first,
prevProps = _ref9.prevProps,
state = _objectWithoutPropertiesLoose(_ref9, ["first", "prevProps"]);
var _get2 = get(props),
items = _get2.items,
keys = _get2.keys,
initial = _get2.initial,
from = _get2.from,
enter = _get2.enter,
leave = _get2.leave,
update = _get2.update,
_get2$trail = _get2.trail,
trail = _get2$trail === void 0 ? 0 : _get2$trail,
unique = _get2.unique,
config = _get2.config,
_get2$order = _get2.order,
order = _get2$order === void 0 ? [ENTER, LEAVE, UPDATE] : _get2$order;
var _get3 = get(prevProps),
_keys = _get3.keys,
_items = _get3.items;
var current = _extends({}, state.current);
var deleted = [].concat(state.deleted); // Compare next keys with current keys
var currentKeys = Object.keys(current);
var currentSet = new Set(currentKeys);
var nextSet = new Set(keys);
var added = keys.filter(function (item) {
return !currentSet.has(item);
});
var removed = state.transitions.filter(function (item) {
return !item.destroyed && !nextSet.has(item.originalKey);
}).map(function (i) {
return i.originalKey;
});
var updated = keys.filter(function (item) {
return currentSet.has(item);
});
var delay = -trail;
while (order.length) {
var changeType = order.shift();
switch (changeType) {
case ENTER:
{
added.forEach(function (key, index) {
// In unique mode, remove fading out transitions if their key comes in again
if (unique && deleted.find(function (d) {
return d.originalKey === key;
})) deleted = deleted.filter(function (t) {
return t.originalKey !== key;
});
var keyIndex = keys.indexOf(key);
var item = items[keyIndex];
var slot = first && initial !== void 0 ? 'initial' : ENTER;
current[key] = {
slot: slot,
originalKey: key,
key: unique ? String(key) : guid++,
item: item,
trail: delay = delay + trail,
config: callProp(config, item, slot),
from: callProp(first ? initial !== void 0 ? initial || {} : from : from, item),
to: callProp(enter, item)
};
});
break;
}
case LEAVE:
{
removed.forEach(function (key) {
var keyIndex = _keys.indexOf(key);
var item = _items[keyIndex];
var slot = LEAVE;
deleted.unshift(_extends({}, current[key], {
slot: slot,
destroyed: true,
left: _keys[Math.max(0, keyIndex - 1)],
right: _keys[Math.min(_keys.length, keyIndex + 1)],
trail: delay = delay + trail,
config: callProp(config, item, slot),
to: callProp(leave, item)
}));
delete current[key];
});
break;
}
case UPDATE:
{
updated.forEach(function (key) {
var keyIndex = keys.indexOf(key);
var item = items[keyIndex];
var slot = UPDATE;
current[key] = _extends({}, current[key], {
item: item,
slot: slot,
trail: delay = delay + trail,
config: callProp(config, item, slot),
to: callProp(update, item)
});
});
break;
}
}
}
var out = keys.map(function (key) {
return current[key];
}); // This tries to restore order for deleted items by finding their last known siblings
// only using the left sibling to keep order placement consistent for all deleted items
deleted.forEach(function (_ref10) {
var left = _ref10.left,
right = _ref10.right,
item = _objectWithoutPropertiesLoose(_ref10, ["left", "right"]);
var pos; // Was it the element on the left, if yes, move there ...
if ((pos = out.findIndex(function (t) {
return t.originalKey === left;
})) !== -1) pos += 1; // And if nothing else helps, move it to the start ¯\_(ツ)_/¯
pos = Math.max(0, pos);
out = [].concat(out.slice(0, pos), [item], out.slice(pos));
});
return _extends({}, state, {
changed: added.length || removed.length || updated.length,
first: first && added.length === 0,
transitions: out,
current: current,
deleted: deleted,
prevProps: props
});
}
var AnimatedStyle =
/*#__PURE__*/
function (_AnimatedObject) {
_inheritsLoose(AnimatedStyle, _AnimatedObject);
function AnimatedStyle(style) {
var _this;
if (style === void 0) {
style = {};
}
_this = _AnimatedObject.call(this) || this;
if (style.transform && !(style.transform instanceof Animated)) {
style = applyAnimatedValues.transform(style);
}
_this.payload = style;
return _this;
}
return AnimatedStyle;
}(AnimatedObject);
// http://www.w3.org/TR/css3-color/#svg-color
var colors = {
transparent: 0x00000000,
aliceblue: 0xf0f8ffff,
antiquewhite: 0xfaebd7ff,
aqua: 0x00ffffff,
aquamarine: 0x7fffd4ff,
azure: 0xf0ffffff,
beige: 0xf5f5dcff,
bisque: 0xffe4c4ff,
black: 0x000000ff,
blanchedalmond: 0xffebcdff,
blue: 0x0000ffff,
blueviolet: 0x8a2be2ff,
brown: 0xa52a2aff,
burlywood: 0xdeb887ff,
burntsienna: 0xea7e5dff,
cadetblue: 0x5f9ea0ff,
chartreuse: 0x7fff00ff,
chocolate: 0xd2691eff,
coral: 0xff7f50ff,
cornflowerblue: 0x6495edff,
cornsilk: 0xfff8dcff,
crimson: 0xdc143cff,
cyan: 0x00ffffff,
darkblue: 0x00008bff,
darkcyan: 0x008b8bff,
darkgoldenrod: 0xb8860bff,
darkgray: 0xa9a9a9ff,
darkgreen: 0x006400ff,
darkgrey: 0xa9a9a9ff,
darkkhaki: 0xbdb76bff,
darkmagenta: 0x8b008bff,
darkolivegreen: 0x556b2fff,
darkorange: 0xff8c00ff,
darkorchid: 0x9932ccff,
darkred: 0x8b0000ff,
darksalmon: 0xe9967aff,
darkseagreen: 0x8fbc8fff,
darkslateblue: 0x483d8bff,
darkslategray: 0x2f4f4fff,
darkslategrey: 0x2f4f4fff,
darkturquoise: 0x00ced1ff,
darkviolet: 0x9400d3ff,
deeppink: 0xff1493ff,
deepskyblue: 0x00bfffff,
dimgray: 0x696969ff,
dimgrey: 0x696969ff,
dodgerblue: 0x1e90ffff,
firebrick: 0xb22222ff,
floralwhite: 0xfffaf0ff,
forestgreen: 0x228b22ff,
fuchsia: 0xff00ffff,
gainsboro: 0xdcdcdcff,
ghostwhite: 0xf8f8ffff,
gold: 0xffd700ff,
goldenrod: 0xdaa520ff,
gray: 0x808080ff,
green: 0x008000ff,
greenyellow: 0xadff2fff,
grey: 0x808080ff,
honeydew: 0xf0fff0ff,
hotpink: 0xff69b4ff,
indianred: 0xcd5c5cff,
indigo: 0x4b0082ff,
ivory: 0xfffff0ff,
khaki: 0xf0e68cff,
lavender: 0xe6e6faff,
lavenderblush: 0xfff0f5ff,
lawngreen: 0x7cfc00ff,
lemonchiffon: 0xfffacdff,
lightblue: 0xadd8e6ff,
lightcoral: 0xf08080ff,
lightcyan: 0xe0ffffff,
lightgoldenrodyellow: 0xfafad2ff,
lightgray: 0xd3d3d3ff,
lightgreen: 0x90ee90ff,
lightgrey: 0xd3d3d3ff,
lightpink: 0xffb6c1ff,
lightsalmon: 0xffa07aff,
lightseagreen: 0x20b2aaff,
lightskyblue: 0x87cefaff,
lightslategray: 0x778899ff,
lightslategrey: 0x778899ff,
lightsteelblue: 0xb0c4deff,
lightyellow: 0xffffe0ff,
lime: 0x00ff00ff,
limegreen: 0x32cd32ff,
linen: 0xfaf0e6ff,
magenta: 0xff00ffff,
maroon: 0x800000ff,
mediumaquamarine: 0x66cdaaff,
mediumblue: 0x0000cdff,
mediumorchid: 0xba55d3ff,
mediumpurple: 0x9370dbff,
mediumseagreen: 0x3cb371ff,
mediumslateblue: 0x7b68eeff,
mediumspringgreen: 0x00fa9aff,
mediumturquoise: 0x48d1ccff,
mediumvioletred: 0xc71585ff,
midnightblue: 0x191970ff,
mintcream: 0xf5fffaff,
mistyrose: 0xffe4e1ff,
moccasin: 0xffe4b5ff,
navajowhite: 0xffdeadff,
navy: 0x000080ff,
oldlace: 0xfdf5e6ff,
olive: 0x808000ff,
olivedrab: 0x6b8e23ff,
orange: 0xffa500ff,
orangered: 0xff4500ff,
orchid: 0xda70d6ff,
palegoldenrod: 0xeee8aaff,
palegreen: 0x98fb98ff,
paleturquoise: 0xafeeeeff,
palevioletred: 0xdb7093ff,
papayawhip: 0xffefd5ff,
peachpuff: 0xffdab9ff,
peru: 0xcd853fff,
pink: 0xffc0cbff,
plum: 0xdda0ddff,
powderblue: 0xb0e0e6ff,
purple: 0x800080ff,
rebeccapurple: 0x663399ff,
red: 0xff0000ff,
rosybrown: 0xbc8f8fff,
royalblue: 0x4169e1ff,
saddlebrown: 0x8b4513ff,
salmon: 0xfa8072ff,
sandybrown: 0xf4a460ff,
seagreen: 0x2e8b57ff,
seashell: 0xfff5eeff,
sienna: 0xa0522dff,
silver: 0xc0c0c0ff,
skyblue: 0x87ceebff,
slateblue: 0x6a5acdff,
slategray: 0x708090ff,
slategrey: 0x708090ff,
snow: 0xfffafaff,
springgreen: 0x00ff7fff,
steelblue: 0x4682b4ff,
tan: 0xd2b48cff,
teal: 0x008080ff,
thistle: 0xd8bfd8ff,
tomato: 0xff6347ff,
turquoise: 0x40e0d0ff,
violet: 0xee82eeff,
wheat: 0xf5deb3ff,
white: 0xffffffff,
whitesmoke: 0xf5f5f5ff,
yellow: 0xffff00ff,
yellowgreen: 0x9acd32ff
};
// const INTEGER = '[-+]?\\d+';
var NUMBER = '[-+]?\\d*\\.?\\d+';
var PERCENTAGE = NUMBER + '%';
function call() {
for (var _len = arguments.length, parts = new Array(_len), _key = 0; _key < _len; _key++) {
parts[_key] = arguments[_key];
}
return '\\(\\s*(' + parts.join(')\\s*,\\s*(') + ')\\s*\\)';
}
var rgb = new RegExp('rgb' + call(NUMBER, NUMBER, NUMBER));
var rgba = new RegExp('rgba' + call(NUMBER, NUMBER, NUMBER, NUMBER));
var hsl = new RegExp('hsl' + call(NUMBER, PERCENTAGE, PERCENTAGE));
var hsla = new RegExp('hsla' + call(NUMBER, PERCENTAGE, PERCENTAGE, NUMBER));
var hex3 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
var hex4 = /^#([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;
var hex6 = /^#([0-9a-fA-F]{6})$/;
var hex8 = /^#([0-9a-fA-F]{8})$/;
/*
https://github.com/react-community/normalize-css-color
BSD 3-Clause License
Copyright (c) 2016, React Community
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
function normalizeColor(color) {
var match;
if (typeof color === 'number') {
return color >>> 0 === color && color >= 0 && color <= 0xffffffff ? color : null;
} // Ordered based on occurrences on Facebook codebase
if (match = hex6.exec(color)) return parseInt(match[1] + 'ff', 16) >>> 0;
if (colors.hasOwnProperty(color)) return colors[color];
if (match = rgb.exec(color)) {
return (parse255(match[1]) << 24 | // r
parse255(match[2]) << 16 | // g
parse255(match[3]) << 8 | // b
0x000000ff) >>> // a
0;
}
if (match = rgba.exec(color)) {
return (parse255(match[1]) << 24 | // r
parse255(match[2]) << 16 | // g
parse255(match[3]) << 8 | // b
parse1(match[4])) >>> // a
0;
}
if (match = hex3.exec(color)) {
return parseInt(match[1] + match[1] + // r
match[2] + match[2] + // g
match[3] + match[3] + // b
'ff', // a
16) >>> 0;
} // https://drafts.csswg.org/css-color-4/#hex-notation
if (match = hex8.exec(color)) return parseInt(match[1], 16) >>> 0;
if (match = hex4.exec(color)) {
return parseInt(match[1] + match[1] + // r
match[2] + match[2] + // g
match[3] + match[3] + // b
match[4] + match[4], // a
16) >>> 0;
}
if (match = hsl.exec(color)) {
return (hslToRgb(parse360(match[1]), // h
parsePercentage(match[2]), // s
parsePercentage(match[3]) // l
) | 0x000000ff) >>> // a
0;
}
if (match = hsla.exec(color)) {
return (hslToRgb(parse360(match[1]), // h
parsePercentage(match[2]), // s
parsePercentage(match[3]) // l
) | parse1(match[4])) >>> // a
0;
}
return null;
}
function hue2rgb(p, q, t) {
if (t < 0) t += 1;
if (t > 1) t -= 1;
if (t < 1 / 6) return p + (q - p) * 6 * t;
if (t < 1 / 2) return q;
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
return p;
}
function hslToRgb(h, s, l) {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
var r = hue2rgb(p, q, h + 1 / 3);
var g = hue2rgb(p, q, h);
var b = hue2rgb(p, q, h - 1 / 3);
return Math.round(r * 255) << 24 | Math.round(g * 255) << 16 | Math.round(b * 255) << 8;
}
function parse255(str) {
var int = parseInt(str, 10);
if (int < 0) return 0;
if (int > 255) return 255;
return int;
}
function parse360(str) {
var int = parseFloat(str);
return (int % 360 + 360) % 360 / 360;
}
function parse1(str) {
var num = parseFloat(str);
if (num < 0) return 0;
if (num > 1) return 255;
return Math.round(num * 255);
}
function parsePercentage(str) {
// parseFloat conveniently ignores the final %
var int = parseFloat(str);
if (int < 0) return 0;
if (int > 100) return 1;
return int / 100;
}
function colorToRgba(input) {
var int32Color = normalizeColor(input);
if (int32Color === null) return input;
int32Color = int32Color || 0;
var r = (int32Color & 0xff000000) >>> 24;
var g = (int32Color & 0x00ff0000) >>> 16;
var b = (int32Color & 0x0000ff00) >>> 8;
var a = (int32Color & 0x000000ff) / 255;
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
} // Problem: https://github.com/animatedjs/animated/pull/102
// Solution: https://stackoverflow.com/questions/638565/parsing-scientific-notation-sensibly/658662
var stringShapeRegex = /[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; // Covers rgb, rgba, hsl, hsla
// Taken from https://gist.github.com/olmokramer/82ccce673f86db7cda5e
var colorRegex = /(#(?:[0-9a-f]{2}){2,4}|(#[0-9a-f]{3})|(rgb|hsl)a?\((-?\d+%?[,\s]+){2,3}\s*[\d\.]+%?\))/gi; // Covers color names (transparent, blue, etc.)
var colorNamesRegex = new RegExp("(" + Object.keys(colors).join('|') + ")", 'g');
/**
* Supports string shapes by extracting numbers so new values can be computed,
* and recombines those values into new strings of the same shape. Supports
* things like:
*
* rgba(123, 42, 99, 0.36) // colors
* -45deg // values with units
* 0 2px 2px 0px rgba(0, 0, 0, 0.12) // box shadows
*/
var createStringInterpolator = function createStringInterpolator(config) {
// Replace colors with rgba
var outputRange = config.output.map(function (rangeValue) {
return rangeValue.replace(colorRegex, colorToRgba);
}).map(function (rangeValue) {
return rangeValue.replace(colorNamesRegex, colorToRgba);
});
var outputRanges = outputRange[0].match(stringShapeRegex).map(function () {
return [];
});
outputRange.forEach(function (value) {
value.match(stringShapeRegex).forEach(function (number, i) {
return outputRanges[i].push(+number);
});
});
var interpolations = outputRange[0].match(stringShapeRegex).map(function (_value, i) {
return createInterpolator(_extends({}, config, {
output: outputRanges[i]
}));
});
return function (input) {
var i = 0;
return outputRange[0] // 'rgba(0, 100, 200, 0)'
// ->
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...'
.replace(stringShapeRegex, function () {
return interpolations[i++](input);
}) // rgba requires that the r,g,b are integers.... so we want to round them, but we *dont* want to
// round the opacity (4th column).
.replace(/rgba\(([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+), ([0-9\.-]+)\)/gi, function (_, p1, p2, p3, p4) {
return "rgba(" + Math.round(p1) + ", " + Math.round(p2) + ", " + Math.round(p3) + ", " + p4 + ")";
});
};
};
var isUnitlessNumber = {
animationIterationCount: true,
borderImageOutset: true,
borderImageSlice: true,
borderImageWidth: true,
boxFlex: true,
boxFlexGroup: true,
boxOrdinalGroup: true,
columnCount: true,
columns: true,
flex: true,
flexGrow: true,
flexPositive: true,
flexShrink: true,
flexNegative: true,
flexOrder: true,
gridRow: true,
gridRowEnd: true,
gridRowSpan: true,
gridRowStart: true,
gridColumn: true,
gridColumnEnd: true,
gridColumnSpan: true,
gridColumnStart: true,
fontWeight: true,
lineClamp: true,
lineHeight: true,
opacity: true,
order: true,
orphans: true,
tabSize: true,
widows: true,
zIndex: true,
zoom: true,
// SVG-related properties
fillOpacity: true,
floodOpacity: true,
stopOpacity: true,
strokeDasharray: true,
strokeDashoffset: true,
strokeMiterlimit: true,
strokeOpacity: true,
strokeWidth: true
};
var prefixKey = function prefixKey(prefix, key) {
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
};
var prefixes = ['Webkit', 'Ms', 'Moz', 'O'];
isUnitlessNumber = Object.keys(isUnitlessNumber).reduce(function (acc, prop) {
prefixes.forEach(function (prefix) {
return acc[prefixKey(prefix, prop)] = acc[prop];
});
return acc;
}, isUnitlessNumber);
function dangerousStyleValue(name, value, isCustomProperty) {
if (value == null || typeof value === 'boolean' || value === '') return '';
if (!isCustomProperty && typeof value === 'number' && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) return value + 'px'; // Presumes implicit 'px' suffix for unitless numbers
return ('' + value).trim();
}
var attributeCache = {};
injectCreateAnimatedStyle(function (style) {
return new AnimatedStyle(style);
});
injectDefaultElement('div');
injectStringInterpolator(createStringInterpolator);
injectColorNames(colors);
injectApplyAnimatedValues(function (instance, props) {
if (instance.nodeType && instance.setAttribute !== undefined) {
var style = props.style,
children = props.children,
scrollTop = props.scrollTop,
scrollLeft = props.scrollLeft,
attributes = _objectWithoutPropertiesLoose(props, ["style", "children", "scrollTop", "scrollLeft"]);
var filter = instance.nodeName === 'filter' || instance.parentNode && instance.parentNode.nodeName === 'filter';
if (scrollTop !== void 0) instance.scrollTop = scrollTop;
if (scrollLeft !== void 0) instance.scrollLeft = scrollLeft; // Set textContent, if children is an animatable value
if (children !== void 0) instance.textContent = children; // Set styles ...
for (var styleName in style) {
if (!style.hasOwnProperty(styleName)) continue;
var isCustomProperty = styleName.indexOf('--') === 0;
var styleValue = dangerousStyleValue(styleName, style[styleName], isCustomProperty);
if (styleName === 'float') styleName = 'cssFloat';
if (isCustomProperty) instance.style.setProperty(styleName, styleValue);else instance.style[styleName] = styleValue;
} // Set attributes ...
for (var name in attributes) {
// Attributes are written in dash case
var dashCase = filter ? name : attributeCache[name] || (attributeCache[name] = name.replace(/([A-Z])/g, function (n) {
return '-' + n.toLowerCase();
}));
if (typeof instance.getAttribute(dashCase) !== 'undefined') instance.setAttribute(dashCase, attributes[name]);
}
return;
} else return false;
}, function (style) {
return style;
});
var domElements = ['a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'keygen', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'menu', 'menuitem', 'meta', 'meter', 'nav', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'u', 'ul', 'var', 'video', 'wbr', // SVG
'circle', 'clipPath', 'defs', 'ellipse', 'foreignObject', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'svg', 'text', 'tspan'];
// Extend animated with all the available THREE elements
var apply = merge(createAnimatedComponent, false);
var extendedAnimated = apply(domElements);
exports.apply = apply;
exports.config = config;
exports.update = update;
exports.animated = extendedAnimated;
exports.a = extendedAnimated;
exports.interpolate = interpolate$1;
exports.Globals = Globals;
exports.useSpring = useSpring;
exports.useTrail = useTrail;
exports.useTransition = useTransition;
exports.useChain = useChain;
exports.useSprings = useSprings;
/***/ }),
/***/ 12:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["compose"]; }());
/***/ }),
/***/ 123:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = __webpack_require__(193);
/***/ }),
/***/ 124:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["wordcount"]; }());
/***/ }),
/***/ 127:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["shortcode"]; }());
/***/ }),
/***/ 13:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; });
/* harmony import */ var _babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(44);
function _objectWithoutProperties(source, excluded) {
if (source == null) return {};
var target = Object(_babel_runtime_helpers_esm_objectWithoutPropertiesLoose__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(source, excluded);
var key, i;
if (Object.getOwnPropertySymbols) {
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
for (i = 0; i < sourceSymbolKeys.length; i++) {
key = sourceSymbolKeys[i];
if (excluded.indexOf(key) >= 0) continue;
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
target[key] = source[key];
}
}
return target;
}
/***/ }),
/***/ 135:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
/* harmony import */ var _babel_runtime_helpers_esm_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(13);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__);
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(_babel_runtime_helpers_esm_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/** @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 specifiying the icon size in pixels
* Other props will be passed to wrapped SVG component
*
* @return {JSX.Element} Icon component
*/
function Icon(_ref) {
var icon = _ref.icon,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 24 : _ref$size,
props = Object(_babel_runtime_helpers_esm_objectWithoutProperties__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(_ref, ["icon", "size"]);
return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_2__["cloneElement"])(icon, _objectSpread({
width: size,
height: size
}, props));
}
/* harmony default export */ __webpack_exports__["a"] = (Icon);
/***/ }),
/***/ 136:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = __webpack_require__(137);
function emptyFunction() {}
function emptyFunctionWithReset() {}
emptyFunctionWithReset.resetWarningCache = emptyFunction;
module.exports = function() {
function shim(props, propName, componentName, location, propFullName, secret) {
if (secret === ReactPropTypesSecret) {
// It is still safe when called from React.
return;
}
var err = new Error(
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
'Use PropTypes.checkPropTypes() to call them. ' +
'Read more at http://fb.me/use-check-prop-types'
);
err.name = 'Invariant Violation';
throw err;
};
shim.isRequired = shim;
function getShim() {
return shim;
};
// Important!
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
var ReactPropTypes = {
array: shim,
bool: shim,
func: shim,
number: shim,
object: shim,
string: shim,
symbol: shim,
any: shim,
arrayOf: getShim,
element: shim,
elementType: shim,
instanceOf: getShim,
node: shim,
objectOf: getShim,
oneOf: getShim,
oneOfType: getShim,
shape: getShim,
exact: getShim,
checkPropTypes: emptyFunctionWithReset,
resetWarningCache: emptyFunction
};
ReactPropTypes.PropTypes = ReactPropTypes;
return ReactPropTypes;
};
/***/ }),
/***/ 137:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
module.exports = ReactPropTypesSecret;
/***/ }),
/***/ 14:
/***/ (function(module, exports) {
(function() { module.exports = window["React"]; }());
/***/ }),
/***/ 15:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXPORTS
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _toConsumableArray; });
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
var arrayLikeToArray = __webpack_require__(24);
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return Object(arrayLikeToArray["a" /* default */])(arr);
}
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js
var iterableToArray = __webpack_require__(37);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
var unsupportedIterableToArray = __webpack_require__(31);
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || Object(unsupportedIterableToArray["a" /* default */])(arr) || _nonIterableSpread();
}
/***/ }),
/***/ 155:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["tokenList"]; }());
/***/ }),
/***/ 158:
/***/ (function(module, exports, __webpack_require__) {
var setPrototypeOf = __webpack_require__(187);
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
setPrototypeOf(subClass, superClass);
}
module.exports = _inheritsLoose;
/***/ }),
/***/ 159:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var closeSmall = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M13 11.9l3.3-3.4-1.1-1-3.2 3.3-3.2-3.3-1.1 1 3.3 3.4-3.5 3.6 1 1L12 13l3.5 3.5 1-1z"
}));
/* harmony default export */ __webpack_exports__["a"] = (closeSmall);
/***/ }),
/***/ 16:
/***/ (function(module, exports) {
(function() { module.exports = window["regeneratorRuntime"]; }());
/***/ }),
/***/ 160:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var close = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"
}));
/* harmony default export */ __webpack_exports__["a"] = (close);
/***/ }),
/***/ 161:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var check = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M18.3 5.6L9.9 16.9l-4.6-3.4-.9 1.2 5.8 4.3 9.3-12.6z"
}));
/* harmony default export */ __webpack_exports__["a"] = (check);
/***/ }),
/***/ 17:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["keycodes"]; }());
/***/ }),
/***/ 175:
/***/ (function(module, exports) {
if (typeof Object.create === 'function') {
// implementation from standard node.js 'util' module
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
ctor.prototype = Object.create(superCtor.prototype, {
constructor: {
value: ctor,
enumerable: false,
writable: true,
configurable: true
}
})
}
};
} else {
// old school shim for old browsers
module.exports = function inherits(ctor, superCtor) {
if (superCtor) {
ctor.super_ = superCtor
var TempCtor = function () {}
TempCtor.prototype = superCtor.prototype
ctor.prototype = new TempCtor()
ctor.prototype.constructor = ctor
}
}
}
/***/ }),
/***/ 18:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
/***/ }),
/***/ 185:
/***/ (function(module, exports) {
function _extends() {
module.exports = _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
module.exports = _extends;
/***/ }),
/***/ 186:
/***/ (function(module, exports) {
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
module.exports = _objectWithoutPropertiesLoose;
/***/ }),
/***/ 187:
/***/ (function(module, exports) {
function _setPrototypeOf(o, p) {
module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
module.exports = _setPrototypeOf;
/***/ }),
/***/ 188:
/***/ (function(module, exports) {
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
module.exports = _assertThisInitialized;
/***/ }),
/***/ 189:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
t[p[i]] = s[p[i]];
return t;
};
exports.__esModule = true;
var React = __webpack_require__(14);
var PropTypes = __webpack_require__(30);
var autosize = __webpack_require__(190);
var _getLineHeight = __webpack_require__(191);
var getLineHeight = _getLineHeight;
var RESIZED = "autosize:resized";
/**
* A light replacement for built-in textarea component
* which automaticaly adjusts its height to match the content
*/
var TextareaAutosizeClass = /** @class */ (function (_super) {
__extends(TextareaAutosizeClass, _super);
function TextareaAutosizeClass() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.state = {
lineHeight: null
};
_this.textarea = null;
_this.onResize = function (e) {
if (_this.props.onResize) {
_this.props.onResize(e);
}
};
_this.updateLineHeight = function () {
if (_this.textarea) {
_this.setState({
lineHeight: getLineHeight(_this.textarea)
});
}
};
_this.onChange = function (e) {
var onChange = _this.props.onChange;
_this.currentValue = e.currentTarget.value;
onChange && onChange(e);
};
return _this;
}
TextareaAutosizeClass.prototype.componentDidMount = function () {
var _this = this;
var _a = this.props, maxRows = _a.maxRows, async = _a.async;
if (typeof maxRows === "number") {
this.updateLineHeight();
}
if (typeof maxRows === "number" || async) {
/*
the defer is needed to:
- force "autosize" to activate the scrollbar when this.props.maxRows is passed
- support StyledComponents (see #71)
*/
setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
}
else {
this.textarea && autosize(this.textarea);
}
if (this.textarea) {
this.textarea.addEventListener(RESIZED, this.onResize);
}
};
TextareaAutosizeClass.prototype.componentWillUnmount = function () {
if (this.textarea) {
this.textarea.removeEventListener(RESIZED, this.onResize);
autosize.destroy(this.textarea);
}
};
TextareaAutosizeClass.prototype.render = function () {
var _this = this;
var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
_this.textarea = element;
if (typeof _this.props.innerRef === 'function') {
_this.props.innerRef(element);
}
else if (_this.props.innerRef) {
_this.props.innerRef.current = element;
}
} }), children));
};
TextareaAutosizeClass.prototype.componentDidUpdate = function () {
this.textarea && autosize.update(this.textarea);
};
TextareaAutosizeClass.defaultProps = {
rows: 1,
async: false
};
TextareaAutosizeClass.propTypes = {
rows: PropTypes.number,
maxRows: PropTypes.number,
onResize: PropTypes.func,
innerRef: PropTypes.any,
async: PropTypes.bool
};
return TextareaAutosizeClass;
}(React.Component));
exports.TextareaAutosize = React.forwardRef(function (props, ref) {
return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
});
/***/ }),
/***/ 19:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
/***/ }),
/***/ 190:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
autosize 4.0.2
license: MIT
http://www.jacklmoore.com/autosize
*/
(function (global, factory) {
if (true) {
!(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
__WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
(__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
} else { var mod; }
})(this, function (module, exports) {
'use strict';
var map = typeof Map === "function" ? new Map() : function () {
var keys = [];
var values = [];
return {
has: function has(key) {
return keys.indexOf(key) > -1;
},
get: function get(key) {
return values[keys.indexOf(key)];
},
set: function set(key, value) {
if (keys.indexOf(key) === -1) {
keys.push(key);
values.push(value);
}
},
delete: function _delete(key) {
var index = keys.indexOf(key);
if (index > -1) {
keys.splice(index, 1);
values.splice(index, 1);
}
}
};
}();
var createEvent = function createEvent(name) {
return new Event(name, { bubbles: true });
};
try {
new Event('test');
} catch (e) {
// IE does not support `new Event()`
createEvent = function createEvent(name) {
var evt = document.createEvent('Event');
evt.initEvent(name, true, false);
return evt;
};
}
function assign(ta) {
if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
var heightOffset = null;
var clientWidth = null;
var cachedHeight = null;
function init() {
var style = window.getComputedStyle(ta, null);
if (style.resize === 'vertical') {
ta.style.resize = 'none';
} else if (style.resize === 'both') {
ta.style.resize = 'horizontal';
}
if (style.boxSizing === 'content-box') {
heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
} else {
heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
}
// Fix when a textarea is not on document body and heightOffset is Not a Number
if (isNaN(heightOffset)) {
heightOffset = 0;
}
update();
}
function changeOverflow(value) {
{
// Chrome/Safari-specific fix:
// When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
// made available by removing the scrollbar. The following forces the necessary text reflow.
var width = ta.style.width;
ta.style.width = '0px';
// Force reflow:
/* jshint ignore:start */
ta.offsetWidth;
/* jshint ignore:end */
ta.style.width = width;
}
ta.style.overflowY = value;
}
function getParentOverflows(el) {
var arr = [];
while (el && el.parentNode && el.parentNode instanceof Element) {
if (el.parentNode.scrollTop) {
arr.push({
node: el.parentNode,
scrollTop: el.parentNode.scrollTop
});
}
el = el.parentNode;
}
return arr;
}
function resize() {
if (ta.scrollHeight === 0) {
// If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
return;
}
var overflows = getParentOverflows(ta);
var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
ta.style.height = '';
ta.style.height = ta.scrollHeight + heightOffset + 'px';
// used to check if an update is actually necessary on window.resize
clientWidth = ta.clientWidth;
// prevents scroll-position jumping
overflows.forEach(function (el) {
el.node.scrollTop = el.scrollTop;
});
if (docTop) {
document.documentElement.scrollTop = docTop;
}
}
function update() {
resize();
var styleHeight = Math.round(parseFloat(ta.style.height));
var computed = window.getComputedStyle(ta, null);
// Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
// The actual height not matching the style height (set via the resize method) indicates that
// the max-height has been exceeded, in which case the overflow should be allowed.
if (actualHeight < styleHeight) {
if (computed.overflowY === 'hidden') {
changeOverflow('scroll');
resize();
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
} else {
// Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
if (computed.overflowY !== 'hidden') {
changeOverflow('hidden');
resize();
actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
}
}
if (cachedHeight !== actualHeight) {
cachedHeight = actualHeight;
var evt = createEvent('autosize:resized');
try {
ta.dispatchEvent(evt);
} catch (err) {
// Firefox will throw an error on dispatchEvent for a detached element
// https://bugzilla.mozilla.org/show_bug.cgi?id=889376
}
}
}
var pageResize = function pageResize() {
if (ta.clientWidth !== clientWidth) {
update();
}
};
var destroy = function (style) {
window.removeEventListener('resize', pageResize, false);
ta.removeEventListener('input', update, false);
ta.removeEventListener('keyup', update, false);
ta.removeEventListener('autosize:destroy', destroy, false);
ta.removeEventListener('autosize:update', update, false);
Object.keys(style).forEach(function (key) {
ta.style[key] = style[key];
});
map.delete(ta);
}.bind(ta, {
height: ta.style.height,
resize: ta.style.resize,
overflowY: ta.style.overflowY,
overflowX: ta.style.overflowX,
wordWrap: ta.style.wordWrap
});
ta.addEventListener('autosize:destroy', destroy, false);
// IE9 does not fire onpropertychange or oninput for deletions,
// so binding to onkeyup to catch most of those events.
// There is no way that I know of to detect something like 'cut' in IE9.
if ('onpropertychange' in ta && 'oninput' in ta) {
ta.addEventListener('keyup', update, false);
}
window.addEventListener('resize', pageResize, false);
ta.addEventListener('input', update, false);
ta.addEventListener('autosize:update', update, false);
ta.style.overflowX = 'hidden';
ta.style.wordWrap = 'break-word';
map.set(ta, {
destroy: destroy,
update: update
});
init();
}
function destroy(ta) {
var methods = map.get(ta);
if (methods) {
methods.destroy();
}
}
function update(ta) {
var methods = map.get(ta);
if (methods) {
methods.update();
}
}
var autosize = null;
// Do nothing in Node.js environment and IE8 (or lower)
if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
autosize = function autosize(el) {
return el;
};
autosize.destroy = function (el) {
return el;
};
autosize.update = function (el) {
return el;
};
} else {
autosize = function autosize(el, options) {
if (el) {
Array.prototype.forEach.call(el.length ? el : [el], function (x) {
return assign(x, options);
});
}
return el;
};
autosize.destroy = function (el) {
if (el) {
Array.prototype.forEach.call(el.length ? el : [el], destroy);
}
return el;
};
autosize.update = function (el) {
if (el) {
Array.prototype.forEach.call(el.length ? el : [el], update);
}
return el;
};
}
exports.default = autosize;
module.exports = exports['default'];
});
/***/ }),
/***/ 191:
/***/ (function(module, exports, __webpack_require__) {
// Load in dependencies
var computedStyle = __webpack_require__(192);
/**
* Calculate the `line-height` of a given node
* @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
* @returns {Number} `line-height` of the element in pixels
*/
function lineHeight(node) {
// Grab the line-height via style
var lnHeightStr = computedStyle(node, 'line-height');
var lnHeight = parseFloat(lnHeightStr, 10);
// If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
if (lnHeightStr === lnHeight + '') {
// Save the old lineHeight style and update the em unit to the element
var _lnHeightStyle = node.style.lineHeight;
node.style.lineHeight = lnHeightStr + 'em';
// Calculate the em based height
lnHeightStr = computedStyle(node, 'line-height');
lnHeight = parseFloat(lnHeightStr, 10);
// Revert the lineHeight style
if (_lnHeightStyle) {
node.style.lineHeight = _lnHeightStyle;
} else {
delete node.style.lineHeight;
}
}
// If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
// DEV: `em` units are converted to `pt` in IE6
// Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
if (lnHeightStr.indexOf('pt') !== -1) {
lnHeight *= 4;
lnHeight /= 3;
// Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
} else if (lnHeightStr.indexOf('mm') !== -1) {
lnHeight *= 96;
lnHeight /= 25.4;
// Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
} else if (lnHeightStr.indexOf('cm') !== -1) {
lnHeight *= 96;
lnHeight /= 2.54;
// Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
} else if (lnHeightStr.indexOf('in') !== -1) {
lnHeight *= 96;
// Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
} else if (lnHeightStr.indexOf('pc') !== -1) {
lnHeight *= 16;
}
// Continue our computation
lnHeight = Math.round(lnHeight);
// If the line-height is "normal", calculate by font-size
if (lnHeightStr === 'normal') {
// Create a temporary node
var nodeName = node.nodeName;
var _node = document.createElement(nodeName);
_node.innerHTML = ' ';
// If we have a text area, reset it to only 1 row
// https://github.com/twolfson/line-height/issues/4
if (nodeName.toUpperCase() === 'TEXTAREA') {
_node.setAttribute('rows', '1');
}
// Set the font-size of the element
var fontSizeStr = computedStyle(node, 'font-size');
_node.style.fontSize = fontSizeStr;
// Remove default padding/border which can affect offset height
// https://github.com/twolfson/line-height/issues/4
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
_node.style.padding = '0px';
_node.style.border = '0px';
// Append it to the body
var body = document.body;
body.appendChild(_node);
// Assume the line height of the element is the height
var height = _node.offsetHeight;
lnHeight = height;
// Remove our child from the DOM
body.removeChild(_node);
}
// Return the calculated height
return lnHeight;
}
// Export lineHeight
module.exports = lineHeight;
/***/ }),
/***/ 192:
/***/ (function(module, exports) {
// This code has been refactored for 140 bytes
// You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
var computedStyle = function (el, prop, getComputedStyle) {
getComputedStyle = window.getComputedStyle;
// In one fell swoop
return (
// If we have getComputedStyle
getComputedStyle ?
// Query it
// TODO: From CSS-Query notes, we might need (node, null) for FF
getComputedStyle(el) :
// Otherwise, we are in IE and use currentStyle
el.currentStyle
)[
// Switch to camelCase for CSSOM
// DEV: Grabbed from jQuery
// https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
// https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
prop.replace(/-(\w)/gi, function (word, letter) {
return letter.toUpperCase();
})
];
};
module.exports = computedStyle;
/***/ }),
/***/ 193:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var util = __webpack_require__(194);
function scrollIntoView(elem, container, config) {
config = config || {};
// document 归一化到 window
if (container.nodeType === 9) {
container = util.getWindow(container);
}
var allowHorizontalScroll = config.allowHorizontalScroll;
var onlyScrollIfNeeded = config.onlyScrollIfNeeded;
var alignWithTop = config.alignWithTop;
var alignWithLeft = config.alignWithLeft;
var offsetTop = config.offsetTop || 0;
var offsetLeft = config.offsetLeft || 0;
var offsetBottom = config.offsetBottom || 0;
var offsetRight = config.offsetRight || 0;
allowHorizontalScroll = allowHorizontalScroll === undefined ? true : allowHorizontalScroll;
var isWin = util.isWindow(container);
var elemOffset = util.offset(elem);
var eh = util.outerHeight(elem);
var ew = util.outerWidth(elem);
var containerOffset = undefined;
var ch = undefined;
var cw = undefined;
var containerScroll = undefined;
var diffTop = undefined;
var diffBottom = undefined;
var win = undefined;
var winScroll = undefined;
var ww = undefined;
var wh = undefined;
if (isWin) {
win = container;
wh = util.height(win);
ww = util.width(win);
winScroll = {
left: util.scrollLeft(win),
top: util.scrollTop(win)
};
// elem 相对 container 可视视窗的距离
diffTop = {
left: elemOffset.left - winScroll.left - offsetLeft,
top: elemOffset.top - winScroll.top - offsetTop
};
diffBottom = {
left: elemOffset.left + ew - (winScroll.left + ww) + offsetRight,
top: elemOffset.top + eh - (winScroll.top + wh) + offsetBottom
};
containerScroll = winScroll;
} else {
containerOffset = util.offset(container);
ch = container.clientHeight;
cw = container.clientWidth;
containerScroll = {
left: container.scrollLeft,
top: container.scrollTop
};
// elem 相对 container 可视视窗的距离
// 注意边框, offset 是边框到根节点
diffTop = {
left: elemOffset.left - (containerOffset.left + (parseFloat(util.css(container, 'borderLeftWidth')) || 0)) - offsetLeft,
top: elemOffset.top - (containerOffset.top + (parseFloat(util.css(container, 'borderTopWidth')) || 0)) - offsetTop
};
diffBottom = {
left: elemOffset.left + ew - (containerOffset.left + cw + (parseFloat(util.css(container, 'borderRightWidth')) || 0)) + offsetRight,
top: elemOffset.top + eh - (containerOffset.top + ch + (parseFloat(util.css(container, 'borderBottomWidth')) || 0)) + offsetBottom
};
}
if (diffTop.top < 0 || diffBottom.top > 0) {
// 强制向上
if (alignWithTop === true) {
util.scrollTop(container, containerScroll.top + diffTop.top);
} else if (alignWithTop === false) {
util.scrollTop(container, containerScroll.top + diffBottom.top);
} else {
// 自动调整
if (diffTop.top < 0) {
util.scrollTop(container, containerScroll.top + diffTop.top);
} else {
util.scrollTop(container, containerScroll.top + diffBottom.top);
}
}
} else {
if (!onlyScrollIfNeeded) {
alignWithTop = alignWithTop === undefined ? true : !!alignWithTop;
if (alignWithTop) {
util.scrollTop(container, containerScroll.top + diffTop.top);
} else {
util.scrollTop(container, containerScroll.top + diffBottom.top);
}
}
}
if (allowHorizontalScroll) {
if (diffTop.left < 0 || diffBottom.left > 0) {
// 强制向上
if (alignWithLeft === true) {
util.scrollLeft(container, containerScroll.left + diffTop.left);
} else if (alignWithLeft === false) {
util.scrollLeft(container, containerScroll.left + diffBottom.left);
} else {
// 自动调整
if (diffTop.left < 0) {
util.scrollLeft(container, containerScroll.left + diffTop.left);
} else {
util.scrollLeft(container, containerScroll.left + diffBottom.left);
}
}
} else {
if (!onlyScrollIfNeeded) {
alignWithLeft = alignWithLeft === undefined ? true : !!alignWithLeft;
if (alignWithLeft) {
util.scrollLeft(container, containerScroll.left + diffTop.left);
} else {
util.scrollLeft(container, containerScroll.left + diffBottom.left);
}
}
}
}
}
module.exports = scrollIntoView;
/***/ }),
/***/ 194:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var RE_NUM = /[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source;
function getClientPosition(elem) {
var box = undefined;
var x = undefined;
var y = undefined;
var doc = elem.ownerDocument;
var body = doc.body;
var docElem = doc && doc.documentElement;
// 根据 GBS 最新数据,A-Grade Browsers 都已支持 getBoundingClientRect 方法,不用再考虑传统的实现方式
box = elem.getBoundingClientRect();
// 注:jQuery 还考虑减去 docElem.clientLeft/clientTop
// 但测试发现,这样反而会导致当 html 和 body 有边距/边框样式时,获取的值不正确
// 此外,ie6 会忽略 html 的 margin 值,幸运地是没有谁会去设置 html 的 margin
x = box.left;
y = box.top;
// In IE, most of the time, 2 extra pixels are added to the top and left
// due to the implicit 2-pixel inset border. In IE6/7 quirks mode and
// IE6 standards mode, this border can be overridden by setting the
// document element's border to zero -- thus, we cannot rely on the
// offset always being 2 pixels.
// In quirks mode, the offset can be determined by querying the body's
// clientLeft/clientTop, but in standards mode, it is found by querying
// the document element's clientLeft/clientTop. Since we already called
// getClientBoundingRect we have already forced a reflow, so it is not
// too expensive just to query them all.
// ie 下应该减去窗口的边框吧,毕竟默认 absolute 都是相对窗口定位的
// 窗口边框标准是设 documentElement ,quirks 时设置 body
// 最好禁止在 body 和 html 上边框 ,但 ie < 9 html 默认有 2px ,减去
// 但是非 ie 不可能设置窗口边框,body html 也不是窗口 ,ie 可以通过 html,body 设置
// 标准 ie 下 docElem.clientTop 就是 border-top
// ie7 html 即窗口边框改变不了。永远为 2
// 但标准 firefox/chrome/ie9 下 docElem.clientTop 是窗口边框,即使设了 border-top 也为 0
x -= docElem.clientLeft || body.clientLeft || 0;
y -= docElem.clientTop || body.clientTop || 0;
return {
left: x,
top: y
};
}
function getScroll(w, top) {
var ret = w['page' + (top ? 'Y' : 'X') + 'Offset'];
var method = 'scroll' + (top ? 'Top' : 'Left');
if (typeof ret !== 'number') {
var d = w.document;
// ie6,7,8 standard mode
ret = d.documentElement[method];
if (typeof ret !== 'number') {
// quirks mode
ret = d.body[method];
}
}
return ret;
}
function getScrollLeft(w) {
return getScroll(w);
}
function getScrollTop(w) {
return getScroll(w, true);
}
function getOffset(el) {
var pos = getClientPosition(el);
var doc = el.ownerDocument;
var w = doc.defaultView || doc.parentWindow;
pos.left += getScrollLeft(w);
pos.top += getScrollTop(w);
return pos;
}
function _getComputedStyle(elem, name, computedStyle_) {
var val = '';
var d = elem.ownerDocument;
var computedStyle = computedStyle_ || d.defaultView.getComputedStyle(elem, null);
// https://github.com/kissyteam/kissy/issues/61
if (computedStyle) {
val = computedStyle.getPropertyValue(name) || computedStyle[name];
}
return val;
}
var _RE_NUM_NO_PX = new RegExp('^(' + RE_NUM + ')(?!px)[a-z%]+$', 'i');
var RE_POS = /^(top|right|bottom|left)$/;
var CURRENT_STYLE = 'currentStyle';
var RUNTIME_STYLE = 'runtimeStyle';
var LEFT = 'left';
var PX = 'px';
function _getComputedStyleIE(elem, name) {
// currentStyle maybe null
// http://msdn.microsoft.com/en-us/library/ms535231.aspx
var ret = elem[CURRENT_STYLE] && elem[CURRENT_STYLE][name];
// 当 width/height 设置为百分比时,通过 pixelLeft 方式转换的 width/height 值
// 一开始就处理了! CUSTOM_STYLE.height,CUSTOM_STYLE.width ,cssHook 解决@2011-08-19
// 在 ie 下不对,需要直接用 offset 方式
// borderWidth 等值也有问题,但考虑到 borderWidth 设为百分比的概率很小,这里就不考虑了
// From the awesome hack by Dean Edwards
// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
// If we're not dealing with a regular pixel number
// but a number that has a weird ending, we need to convert it to pixels
// exclude left right for relativity
if (_RE_NUM_NO_PX.test(ret) && !RE_POS.test(name)) {
// Remember the original values
var style = elem.style;
var left = style[LEFT];
var rsLeft = elem[RUNTIME_STYLE][LEFT];
// prevent flashing of content
elem[RUNTIME_STYLE][LEFT] = elem[CURRENT_STYLE][LEFT];
// Put in the new values to get a computed value out
style[LEFT] = name === 'fontSize' ? '1em' : ret || 0;
ret = style.pixelLeft + PX;
// Revert the changed values
style[LEFT] = left;
elem[RUNTIME_STYLE][LEFT] = rsLeft;
}
return ret === '' ? 'auto' : ret;
}
var getComputedStyleX = undefined;
if (typeof window !== 'undefined') {
getComputedStyleX = window.getComputedStyle ? _getComputedStyle : _getComputedStyleIE;
}
function each(arr, fn) {
for (var i = 0; i < arr.length; i++) {
fn(arr[i]);
}
}
function isBorderBoxFn(elem) {
return getComputedStyleX(elem, 'boxSizing') === 'border-box';
}
var BOX_MODELS = ['margin', 'border', 'padding'];
var CONTENT_INDEX = -1;
var PADDING_INDEX = 2;
var BORDER_INDEX = 1;
var MARGIN_INDEX = 0;
function swap(elem, options, callback) {
var old = {};
var style = elem.style;
var name = undefined;
// Remember the old values, and insert the new ones
for (name in options) {
if (options.hasOwnProperty(name)) {
old[name] = style[name];
style[name] = options[name];
}
}
callback.call(elem);
// Revert the old values
for (name in options) {
if (options.hasOwnProperty(name)) {
style[name] = old[name];
}
}
}
function getPBMWidth(elem, props, which) {
var value = 0;
var prop = undefined;
var j = undefined;
var i = undefined;
for (j = 0; j < props.length; j++) {
prop = props[j];
if (prop) {
for (i = 0; i < which.length; i++) {
var cssProp = undefined;
if (prop === 'border') {
cssProp = prop + which[i] + 'Width';
} else {
cssProp = prop + which[i];
}
value += parseFloat(getComputedStyleX(elem, cssProp)) || 0;
}
}
}
return value;
}
/**
* A crude way of determining if an object is a window
* @member util
*/
function isWindow(obj) {
// must use == for ie8
/* eslint eqeqeq:0 */
return obj != null && obj == obj.window;
}
var domUtils = {};
each(['Width', 'Height'], function (name) {
domUtils['doc' + name] = function (refWin) {
var d = refWin.document;
return Math.max(
// firefox chrome documentElement.scrollHeight< body.scrollHeight
// ie standard mode : documentElement.scrollHeight> body.scrollHeight
d.documentElement['scroll' + name],
// quirks : documentElement.scrollHeight 最大等于可视窗口多一点?
d.body['scroll' + name], domUtils['viewport' + name](d));
};
domUtils['viewport' + name] = function (win) {
// pc browser includes scrollbar in window.innerWidth
var prop = 'client' + name;
var doc = win.document;
var body = doc.body;
var documentElement = doc.documentElement;
var documentElementProp = documentElement[prop];
// 标准模式取 documentElement
// backcompat 取 body
return doc.compatMode === 'CSS1Compat' && documentElementProp || body && body[prop] || documentElementProp;
};
});
/*
得到元素的大小信息
@param elem
@param name
@param {String} [extra] 'padding' : (css width) + padding
'border' : (css width) + padding + border
'margin' : (css width) + padding + border + margin
*/
function getWH(elem, name, extra) {
if (isWindow(elem)) {
return name === 'width' ? domUtils.viewportWidth(elem) : domUtils.viewportHeight(elem);
} else if (elem.nodeType === 9) {
return name === 'width' ? domUtils.docWidth(elem) : domUtils.docHeight(elem);
}
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
var borderBoxValue = name === 'width' ? elem.offsetWidth : elem.offsetHeight;
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem, computedStyle);
var cssBoxValue = 0;
if (borderBoxValue == null || borderBoxValue <= 0) {
borderBoxValue = undefined;
// Fall back to computed then un computed css if necessary
cssBoxValue = getComputedStyleX(elem, name);
if (cssBoxValue == null || Number(cssBoxValue) < 0) {
cssBoxValue = elem.style[name] || 0;
}
// Normalize '', auto, and prepare for extra
cssBoxValue = parseFloat(cssBoxValue) || 0;
}
if (extra === undefined) {
extra = isBorderBox ? BORDER_INDEX : CONTENT_INDEX;
}
var borderBoxValueOrIsBorderBox = borderBoxValue !== undefined || isBorderBox;
var val = borderBoxValue || cssBoxValue;
if (extra === CONTENT_INDEX) {
if (borderBoxValueOrIsBorderBox) {
return val - getPBMWidth(elem, ['border', 'padding'], which, computedStyle);
}
return cssBoxValue;
}
if (borderBoxValueOrIsBorderBox) {
var padding = extra === PADDING_INDEX ? -getPBMWidth(elem, ['border'], which, computedStyle) : getPBMWidth(elem, ['margin'], which, computedStyle);
return val + (extra === BORDER_INDEX ? 0 : padding);
}
return cssBoxValue + getPBMWidth(elem, BOX_MODELS.slice(extra), which, computedStyle);
}
var cssShow = {
position: 'absolute',
visibility: 'hidden',
display: 'block'
};
// fix #119 : https://github.com/kissyteam/kissy/issues/119
function getWHIgnoreDisplay(elem) {
var val = undefined;
var args = arguments;
// in case elem is window
// elem.offsetWidth === undefined
if (elem.offsetWidth !== 0) {
val = getWH.apply(undefined, args);
} else {
swap(elem, cssShow, function () {
val = getWH.apply(undefined, args);
});
}
return val;
}
function css(el, name, v) {
var value = v;
if ((typeof name === 'undefined' ? 'undefined' : _typeof(name)) === 'object') {
for (var i in name) {
if (name.hasOwnProperty(i)) {
css(el, i, name[i]);
}
}
return undefined;
}
if (typeof value !== 'undefined') {
if (typeof value === 'number') {
value += 'px';
}
el.style[name] = value;
return undefined;
}
return getComputedStyleX(el, name);
}
each(['width', 'height'], function (name) {
var first = name.charAt(0).toUpperCase() + name.slice(1);
domUtils['outer' + first] = function (el, includeMargin) {
return el && getWHIgnoreDisplay(el, name, includeMargin ? MARGIN_INDEX : BORDER_INDEX);
};
var which = name === 'width' ? ['Left', 'Right'] : ['Top', 'Bottom'];
domUtils[name] = function (elem, val) {
if (val !== undefined) {
if (elem) {
var computedStyle = getComputedStyleX(elem);
var isBorderBox = isBorderBoxFn(elem);
if (isBorderBox) {
val += getPBMWidth(elem, ['padding', 'border'], which, computedStyle);
}
return css(elem, name, val);
}
return undefined;
}
return elem && getWHIgnoreDisplay(elem, name, CONTENT_INDEX);
};
});
// 设置 elem 相对 elem.ownerDocument 的坐标
function setOffset(elem, offset) {
// set position first, in-case top/left are set even on static elem
if (css(elem, 'position') === 'static') {
elem.style.position = 'relative';
}
var old = getOffset(elem);
var ret = {};
var current = undefined;
var key = undefined;
for (key in offset) {
if (offset.hasOwnProperty(key)) {
current = parseFloat(css(elem, key)) || 0;
ret[key] = current + offset[key] - old[key];
}
}
css(elem, ret);
}
module.exports = _extends({
getWindow: function getWindow(node) {
var doc = node.ownerDocument || node;
return doc.defaultView || doc.parentWindow;
},
offset: function offset(el, value) {
if (typeof value !== 'undefined') {
setOffset(el, value);
} else {
return getOffset(el);
}
},
isWindow: isWindow,
each: each,
css: css,
clone: function clone(obj) {
var ret = {};
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
ret[i] = obj[i];
}
}
var overflow = obj.overflow;
if (overflow) {
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
ret.overflow[i] = obj.overflow[i];
}
}
}
return ret;
},
scrollLeft: function scrollLeft(w, v) {
if (isWindow(w)) {
if (v === undefined) {
return getScrollLeft(w);
}
window.scrollTo(v, getScrollTop(w));
} else {
if (v === undefined) {
return w.scrollLeft;
}
w.scrollLeft = v;
}
},
scrollTop: function scrollTop(w, v) {
if (isWindow(w)) {
if (v === undefined) {
return getScrollTop(w);
}
window.scrollTo(getScrollLeft(w), v);
} else {
if (v === undefined) {
return w.scrollTop;
}
w.scrollTop = v;
}
},
viewportWidth: 0,
viewportHeight: 0
}, domUtils);
/***/ }),
/***/ 195:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var link = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"
}));
/* harmony default export */ __webpack_exports__["a"] = (link);
/***/ }),
/***/ 2:
/***/ (function(module, exports) {
(function() { module.exports = window["lodash"]; }());
/***/ }),
/***/ 21:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["richText"]; }());
/***/ }),
/***/ 213:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var blockDefault = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
}));
/* harmony default export */ __webpack_exports__["a"] = (blockDefault);
/***/ }),
/***/ 214:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var plus = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M18 11.2h-5.2V6h-1.6v5.2H6v1.6h5.2V18h1.6v-5.2H18z"
}));
/* harmony default export */ __webpack_exports__["a"] = (plus);
/***/ }),
/***/ 215:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var search = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M13.5 6C10.5 6 8 8.5 8 11.5c0 1.1.3 2.1.9 3l-3.4 3 1 1.1 3.4-2.9c1 .9 2.2 1.4 3.6 1.4 3 0 5.5-2.5 5.5-5.5C19 8.5 16.5 6 13.5 6zm0 9.5c-2.2 0-4-1.8-4-4s1.8-4 4-4 4 1.8 4 4-1.8 4-4 4z"
}));
/* harmony default export */ __webpack_exports__["a"] = (search);
/***/ }),
/***/ 216:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var chevronRight = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"
}));
/* harmony default export */ __webpack_exports__["a"] = (chevronRight);
/***/ }),
/***/ 217:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var chevronLeft = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"
}));
/* harmony default export */ __webpack_exports__["a"] = (chevronLeft);
/***/ }),
/***/ 218:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var keyboardReturn = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "-2 -2 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z"
}));
/* harmony default export */ __webpack_exports__["a"] = (keyboardReturn);
/***/ }),
/***/ 219:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var upload = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M18.5 15v3.5H13V6.7l4.5 4.1 1-1.1-6.2-5.8-5.8 5.8 1 1.1 4-4v11.7h-6V15H4v5h16v-5z"
}));
/* harmony default export */ __webpack_exports__["a"] = (upload);
/***/ }),
/***/ 24:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
/***/ }),
/***/ 25:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
/***/ }),
/***/ 26:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
/***/ }),
/***/ 27:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["dom"]; }());
/***/ }),
/***/ 270:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// EXTERNAL MODULE: external ["wp","element"]
var external_wp_element_ = __webpack_require__(0);
// EXTERNAL MODULE: external ["wp","primitives"]
var external_wp_primitives_ = __webpack_require__(7);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/pencil.js
/**
* WordPress dependencies
*/
var pencil = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M20.1 5.1L16.9 2 6.2 12.7l-1.3 4.4 4.5-1.3L20.1 5.1zM4 20.8h8v-1.5H4v1.5z"
}));
/* harmony default export */ var library_pencil = (pencil);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js
/**
* Internal dependencies
*/
/* harmony default export */ var edit = __webpack_exports__["a"] = (library_pencil);
/***/ }),
/***/ 273:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*istanbul ignore start*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.diffChars = diffChars;
exports.characterDiff = void 0;
/*istanbul ignore end*/
var
/*istanbul ignore start*/
_base = _interopRequireDefault(__webpack_require__(306))
/*istanbul ignore end*/
;
/*istanbul ignore start*/ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/*istanbul ignore end*/
var characterDiff = new
/*istanbul ignore start*/
_base
/*istanbul ignore end*/
.
/*istanbul ignore start*/
default
/*istanbul ignore end*/
();
/*istanbul ignore start*/
exports.characterDiff = characterDiff;
/*istanbul ignore end*/
function diffChars(oldStr, newStr, options) {
return characterDiff.diff(oldStr, newStr, options);
}
/***/ }),
/***/ 274:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
Copyright (c) 2014, Yahoo! Inc. All rights reserved.
Copyrights licensed under the New BSD License.
See the accompanying LICENSE file for terms.
*/
exports.match = matchQuery;
exports.parse = parseQuery;
// -----------------------------------------------------------------------------
var RE_MEDIA_QUERY = /(?:(only|not)?\s*([^\s\(\)]+)(?:\s*and)?\s*)?(.+)?/i,
RE_MQ_EXPRESSION = /\(\s*([^\s\:\)]+)\s*(?:\:\s*([^\s\)]+))?\s*\)/,
RE_MQ_FEATURE = /^(?:(min|max)-)?(.+)/,
RE_LENGTH_UNIT = /(em|rem|px|cm|mm|in|pt|pc)?$/,
RE_RESOLUTION_UNIT = /(dpi|dpcm|dppx)?$/;
function matchQuery(mediaQuery, values) {
return parseQuery(mediaQuery).some(function (query) {
var inverse = query.inverse;
// Either the parsed or specified `type` is "all", or the types must be
// equal for a match.
var typeMatch = query.type === 'all' || values.type === query.type;
// Quit early when `type` doesn't match, but take "not" into account.
if ((typeMatch && inverse) || !(typeMatch || inverse)) {
return false;
}
var expressionsMatch = query.expressions.every(function (expression) {
var feature = expression.feature,
modifier = expression.modifier,
expValue = expression.value,
value = values[feature];
// Missing or falsy values don't match.
if (!value) { return false; }
switch (feature) {
case 'orientation':
case 'scan':
return value.toLowerCase() === expValue.toLowerCase();
case 'width':
case 'height':
case 'device-width':
case 'device-height':
expValue = toPx(expValue);
value = toPx(value);
break;
case 'resolution':
expValue = toDpi(expValue);
value = toDpi(value);
break;
case 'aspect-ratio':
case 'device-aspect-ratio':
case /* Deprecated */ 'device-pixel-ratio':
expValue = toDecimal(expValue);
value = toDecimal(value);
break;
case 'grid':
case 'color':
case 'color-index':
case 'monochrome':
expValue = parseInt(expValue, 10) || 1;
value = parseInt(value, 10) || 0;
break;
}
switch (modifier) {
case 'min': return value >= expValue;
case 'max': return value <= expValue;
default : return value === expValue;
}
});
return (expressionsMatch && !inverse) || (!expressionsMatch && inverse);
});
}
function parseQuery(mediaQuery) {
return mediaQuery.split(',').map(function (query) {
query = query.trim();
var captures = query.match(RE_MEDIA_QUERY),
modifier = captures[1],
type = captures[2],
expressions = captures[3] || '',
parsed = {};
parsed.inverse = !!modifier && modifier.toLowerCase() === 'not';
parsed.type = type ? type.toLowerCase() : 'all';
// Split expressions into a list.
expressions = expressions.match(/\([^\)]+\)/g) || [];
parsed.expressions = expressions.map(function (expression) {
var captures = expression.match(RE_MQ_EXPRESSION),
feature = captures[1].toLowerCase().match(RE_MQ_FEATURE);
return {
modifier: feature[1],
feature : feature[2],
value : captures[2]
};
});
return parsed;
});
}
// -- Utilities ----------------------------------------------------------------
function toDecimal(ratio) {
var decimal = Number(ratio),
numbers;
if (!decimal) {
numbers = ratio.match(/^(\d+)\s*\/\s*(\d+)$/);
decimal = numbers[1] / numbers[2];
}
return decimal;
}
function toDpi(resolution) {
var value = parseFloat(resolution),
units = String(resolution).match(RE_RESOLUTION_UNIT)[1];
switch (units) {
case 'dpcm': return value / 2.54;
case 'dppx': return value * 96;
default : return value;
}
}
function toPx(length) {
var value = parseFloat(length),
units = String(length).match(RE_LENGTH_UNIT)[1];
switch (units) {
case 'em' : return value * 16;
case 'rem': return value * 16;
case 'cm' : return value * 96 / 2.54;
case 'mm' : return value * 96 / 2.54 / 10;
case 'in' : return value * 96;
case 'pt' : return value * 72;
case 'pc' : return value * 72 / 12;
default : return value;
}
}
/***/ }),
/***/ 275:
/***/ (function(module, exports) {
var traverse = module.exports = function (obj) {
return new Traverse(obj);
};
function Traverse (obj) {
this.value = obj;
}
Traverse.prototype.get = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!node || !hasOwnProperty.call(node, key)) {
node = undefined;
break;
}
node = node[key];
}
return node;
};
Traverse.prototype.has = function (ps) {
var node = this.value;
for (var i = 0; i < ps.length; i ++) {
var key = ps[i];
if (!node || !hasOwnProperty.call(node, key)) {
return false;
}
node = node[key];
}
return true;
};
Traverse.prototype.set = function (ps, value) {
var node = this.value;
for (var i = 0; i < ps.length - 1; i ++) {
var key = ps[i];
if (!hasOwnProperty.call(node, key)) node[key] = {};
node = node[key];
}
node[ps[i]] = value;
return value;
};
Traverse.prototype.map = function (cb) {
return walk(this.value, cb, true);
};
Traverse.prototype.forEach = function (cb) {
this.value = walk(this.value, cb, false);
return this.value;
};
Traverse.prototype.reduce = function (cb, init) {
var skip = arguments.length === 1;
var acc = skip ? this.value : init;
this.forEach(function (x) {
if (!this.isRoot || !skip) {
acc = cb.call(this, acc, x);
}
});
return acc;
};
Traverse.prototype.paths = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.path);
});
return acc;
};
Traverse.prototype.nodes = function () {
var acc = [];
this.forEach(function (x) {
acc.push(this.node);
});
return acc;
};
Traverse.prototype.clone = function () {
var parents = [], nodes = [];
return (function clone (src) {
for (var i = 0; i < parents.length; i++) {
if (parents[i] === src) {
return nodes[i];
}
}
if (typeof src === 'object' && src !== null) {
var dst = copy(src);
parents.push(src);
nodes.push(dst);
forEach(objectKeys(src), function (key) {
dst[key] = clone(src[key]);
});
parents.pop();
nodes.pop();
return dst;
}
else {
return src;
}
})(this.value);
};
function walk (root, cb, immutable) {
var path = [];
var parents = [];
var alive = true;
return (function walker (node_) {
var node = immutable ? copy(node_) : node_;
var modifiers = {};
var keepGoing = true;
var state = {
node : node,
node_ : node_,
path : [].concat(path),
parent : parents[parents.length - 1],
parents : parents,
key : path.slice(-1)[0],
isRoot : path.length === 0,
level : path.length,
circular : null,
update : function (x, stopHere) {
if (!state.isRoot) {
state.parent.node[state.key] = x;
}
state.node = x;
if (stopHere) keepGoing = false;
},
'delete' : function (stopHere) {
delete state.parent.node[state.key];
if (stopHere) keepGoing = false;
},
remove : function (stopHere) {
if (isArray(state.parent.node)) {
state.parent.node.splice(state.key, 1);
}
else {
delete state.parent.node[state.key];
}
if (stopHere) keepGoing = false;
},
keys : null,
before : function (f) { modifiers.before = f },
after : function (f) { modifiers.after = f },
pre : function (f) { modifiers.pre = f },
post : function (f) { modifiers.post = f },
stop : function () { alive = false },
block : function () { keepGoing = false }
};
if (!alive) return state;
function updateState() {
if (typeof state.node === 'object' && state.node !== null) {
if (!state.keys || state.node_ !== state.node) {
state.keys = objectKeys(state.node)
}
state.isLeaf = state.keys.length == 0;
for (var i = 0; i < parents.length; i++) {
if (parents[i].node_ === node_) {
state.circular = parents[i];
break;
}
}
}
else {
state.isLeaf = true;
state.keys = null;
}
state.notLeaf = !state.isLeaf;
state.notRoot = !state.isRoot;
}
updateState();
// use return values to update if defined
var ret = cb.call(state, state.node);
if (ret !== undefined && state.update) state.update(ret);
if (modifiers.before) modifiers.before.call(state, state.node);
if (!keepGoing) return state;
if (typeof state.node == 'object'
&& state.node !== null && !state.circular) {
parents.push(state);
updateState();
forEach(state.keys, function (key, i) {
path.push(key);
if (modifiers.pre) modifiers.pre.call(state, state.node[key], key);
var child = walker(state.node[key]);
if (immutable && hasOwnProperty.call(state.node, key)) {
state.node[key] = child.node;
}
child.isLast = i == state.keys.length - 1;
child.isFirst = i == 0;
if (modifiers.post) modifiers.post.call(state, child);
path.pop();
});
parents.pop();
}
if (modifiers.after) modifiers.after.call(state, state.node);
return state;
})(root).node;
}
function copy (src) {
if (typeof src === 'object' && src !== null) {
var dst;
if (isArray(src)) {
dst = [];
}
else if (isDate(src)) {
dst = new Date(src.getTime ? src.getTime() : src);
}
else if (isRegExp(src)) {
dst = new RegExp(src);
}
else if (isError(src)) {
dst = { message: src.message };
}
else if (isBoolean(src)) {
dst = new Boolean(src);
}
else if (isNumber(src)) {
dst = new Number(src);
}
else if (isString(src)) {
dst = new String(src);
}
else if (Object.create && Object.getPrototypeOf) {
dst = Object.create(Object.getPrototypeOf(src));
}
else if (src.constructor === Object) {
dst = {};
}
else {
var proto =
(src.constructor && src.constructor.prototype)
|| src.__proto__
|| {}
;
var T = function () {};
T.prototype = proto;
dst = new T;
}
forEach(objectKeys(src), function (key) {
dst[key] = src[key];
});
return dst;
}
else return src;
}
var objectKeys = Object.keys || function keys (obj) {
var res = [];
for (var key in obj) res.push(key)
return res;
};
function toS (obj) { return Object.prototype.toString.call(obj) }
function isDate (obj) { return toS(obj) === '[object Date]' }
function isRegExp (obj) { return toS(obj) === '[object RegExp]' }
function isError (obj) { return toS(obj) === '[object Error]' }
function isBoolean (obj) { return toS(obj) === '[object Boolean]' }
function isNumber (obj) { return toS(obj) === '[object Number]' }
function isString (obj) { return toS(obj) === '[object String]' }
var isArray = Array.isArray || function isArray (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
var forEach = function (xs, fn) {
if (xs.forEach) return xs.forEach(fn)
else for (var i = 0; i < xs.length; i++) {
fn(xs[i], i, xs);
}
};
forEach(objectKeys(Traverse.prototype), function (key) {
traverse[key] = function (obj) {
var args = [].slice.call(arguments, 1);
var t = new Traverse(obj);
return t[key].apply(t, args);
};
});
var hasOwnProperty = Object.hasOwnProperty || function (obj, key) {
return key in obj;
};
/***/ }),
/***/ 28:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
/* harmony import */ var _babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52);
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) Object(_babel_runtime_helpers_esm_setPrototypeOf__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(subClass, superClass);
}
/***/ }),
/***/ 29:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
/* harmony import */ var _babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(42);
/* harmony import */ var _babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
function _possibleConstructorReturn(self, call) {
if (call && (Object(_babel_runtime_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
return call;
}
return Object(_babel_runtime_helpers_esm_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
}
/***/ }),
/***/ 299:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var formatStrikethrough = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M9.1 9v-.5c0-.6.2-1.1.7-1.4.5-.3 1.2-.5 2-.5.7 0 1.4.1 2.1.3.7.2 1.4.5 2.1.9l.2-1.9c-.6-.3-1.2-.5-1.9-.7-.8-.1-1.6-.2-2.4-.2-1.5 0-2.7.3-3.6 1-.8.7-1.2 1.5-1.2 2.6V9h2zM20 12H4v1h8.3c.3.1.6.2.8.3.5.2.9.5 1.1.8.3.3.4.7.4 1.2 0 .7-.2 1.1-.8 1.5-.5.3-1.2.5-2.1.5-.8 0-1.6-.1-2.4-.3-.8-.2-1.5-.5-2.2-.8L7 18.1c.5.2 1.2.4 2 .6.8.2 1.6.3 2.4.3 1.7 0 3-.3 3.9-1 .9-.7 1.3-1.6 1.3-2.8 0-.9-.2-1.7-.7-2.2H20v-1z"
}));
/* harmony default export */ __webpack_exports__["a"] = (formatStrikethrough);
/***/ }),
/***/ 3:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["components"]; }());
/***/ }),
/***/ 30:
/***/ (function(module, exports, __webpack_require__) {
/**
* Copyright (c) 2013-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
if (false) { var throwOnDirectAccess, ReactIs; } else {
// By explicitly using `prop-types` you are opting into new production behavior.
// http://fb.me/prop-types-in-prod
module.exports = __webpack_require__(136)();
}
/***/ }),
/***/ 300:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var alignLeft = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M4 19.8h8.9v-1.5H4v1.5zm8.9-15.6H4v1.5h8.9V4.2zm-8.9 7v1.5h16v-1.5H4z"
}));
/* harmony default export */ __webpack_exports__["a"] = (alignLeft);
/***/ }),
/***/ 301:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var alignCenter = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M16.4 4.2H7.6v1.5h8.9V4.2zM4 11.2v1.5h16v-1.5H4zm3.6 8.6h8.9v-1.5H7.6v1.5z"
}));
/* harmony default export */ __webpack_exports__["a"] = (alignCenter);
/***/ }),
/***/ 302:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var alignRight = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M11.1 19.8H20v-1.5h-8.9v1.5zm0-15.6v1.5H20V4.2h-8.9zM4 12.8h16v-1.5H4v1.5z"
}));
/* harmony default export */ __webpack_exports__["a"] = (alignRight);
/***/ }),
/***/ 303:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var chevronUp = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
}));
/* harmony default export */ __webpack_exports__["a"] = (chevronUp);
/***/ }),
/***/ 304:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var chevronDown = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M17.5 11.6L12 16l-5.5-4.4.9-1.2L12 14l4.5-3.6 1 1.2z"
}));
/* harmony default export */ __webpack_exports__["a"] = (chevronDown);
/***/ }),
/***/ 305:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var moreVertical = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
}));
/* harmony default export */ __webpack_exports__["a"] = (moreVertical);
/***/ }),
/***/ 306:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*istanbul ignore start*/
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Diff;
/*istanbul ignore end*/
function Diff() {}
Diff.prototype = {
/*istanbul ignore start*/
/*istanbul ignore end*/
diff: function diff(oldString, newString) {
/*istanbul ignore start*/
var
/*istanbul ignore end*/
options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var callback = options.callback;
if (typeof options === 'function') {
callback = options;
options = {};
}
this.options = options;
var self = this;
function done(value) {
if (callback) {
setTimeout(function () {
callback(undefined, value);
}, 0);
return true;
} else {
return value;
}
} // Allow subclasses to massage the input prior to running
oldString = this.castInput(oldString);
newString = this.castInput(newString);
oldString = this.removeEmpty(this.tokenize(oldString));
newString = this.removeEmpty(this.tokenize(newString));
var newLen = newString.length,
oldLen = oldString.length;
var editLength = 1;
var maxEditLength = newLen + oldLen;
var bestPath = [{
newPos: -1,
components: []
}]; // Seed editLength = 0, i.e. the content starts with the same values
var oldPos = this.extractCommon(bestPath[0], newString, oldString, 0);
if (bestPath[0].newPos + 1 >= newLen && oldPos + 1 >= oldLen) {
// Identity per the equality and tokenizer
return done([{
value: this.join(newString),
count: newString.length
}]);
} // Main worker method. checks all permutations of a given edit length for acceptance.
function execEditLength() {
for (var diagonalPath = -1 * editLength; diagonalPath <= editLength; diagonalPath += 2) {
var basePath =
/*istanbul ignore start*/
void 0
/*istanbul ignore end*/
;
var addPath = bestPath[diagonalPath - 1],
removePath = bestPath[diagonalPath + 1],
_oldPos = (removePath ? removePath.newPos : 0) - diagonalPath;
if (addPath) {
// No one else is going to attempt to use this value, clear it
bestPath[diagonalPath - 1] = undefined;
}
var canAdd = addPath && addPath.newPos + 1 < newLen,
canRemove = removePath && 0 <= _oldPos && _oldPos < oldLen;
if (!canAdd && !canRemove) {
// If this path is a terminal then prune
bestPath[diagonalPath] = undefined;
continue;
} // Select the diagonal that we want to branch from. We select the prior
// path whose position in the new string is the farthest from the origin
// and does not pass the bounds of the diff graph
if (!canAdd || canRemove && addPath.newPos < removePath.newPos) {
basePath = clonePath(removePath);
self.pushComponent(basePath.components, undefined, true);
} else {
basePath = addPath; // No need to clone, we've pulled it from the list
basePath.newPos++;
self.pushComponent(basePath.components, true, undefined);
}
_oldPos = self.extractCommon(basePath, newString, oldString, diagonalPath); // If we have hit the end of both strings, then we are done
if (basePath.newPos + 1 >= newLen && _oldPos + 1 >= oldLen) {
return done(buildValues(self, basePath.components, newString, oldString, self.useLongestToken));
} else {
// Otherwise track this path as a potential candidate and continue.
bestPath[diagonalPath] = basePath;
}
}
editLength++;
} // Performs the length of edit iteration. Is a bit fugly as this has to support the
// sync and async mode which is never fun. Loops over execEditLength until a value
// is produced.
if (callback) {
(function exec() {
setTimeout(function () {
// This should not happen, but we want to be safe.
/* istanbul ignore next */
if (editLength > maxEditLength) {
return callback();
}
if (!execEditLength()) {
exec();
}
}, 0);
})();
} else {
while (editLength <= maxEditLength) {
var ret = execEditLength();
if (ret) {
return ret;
}
}
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
pushComponent: function pushComponent(components, added, removed) {
var last = components[components.length - 1];
if (last && last.added === added && last.removed === removed) {
// We need to clone here as the component clone operation is just
// as shallow array clone
components[components.length - 1] = {
count: last.count + 1,
added: added,
removed: removed
};
} else {
components.push({
count: 1,
added: added,
removed: removed
});
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
extractCommon: function extractCommon(basePath, newString, oldString, diagonalPath) {
var newLen = newString.length,
oldLen = oldString.length,
newPos = basePath.newPos,
oldPos = newPos - diagonalPath,
commonCount = 0;
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(newString[newPos + 1], oldString[oldPos + 1])) {
newPos++;
oldPos++;
commonCount++;
}
if (commonCount) {
basePath.components.push({
count: commonCount
});
}
basePath.newPos = newPos;
return oldPos;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
equals: function equals(left, right) {
if (this.options.comparator) {
return this.options.comparator(left, right);
} else {
return left === right || this.options.ignoreCase && left.toLowerCase() === right.toLowerCase();
}
},
/*istanbul ignore start*/
/*istanbul ignore end*/
removeEmpty: function removeEmpty(array) {
var ret = [];
for (var i = 0; i < array.length; i++) {
if (array[i]) {
ret.push(array[i]);
}
}
return ret;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
castInput: function castInput(value) {
return value;
},
/*istanbul ignore start*/
/*istanbul ignore end*/
tokenize: function tokenize(value) {
return value.split('');
},
/*istanbul ignore start*/
/*istanbul ignore end*/
join: function join(chars) {
return chars.join('');
}
};
function buildValues(diff, components, newString, oldString, useLongestToken) {
var componentPos = 0,
componentLen = components.length,
newPos = 0,
oldPos = 0;
for (; componentPos < componentLen; componentPos++) {
var component = components[componentPos];
if (!component.removed) {
if (!component.added && useLongestToken) {
var value = newString.slice(newPos, newPos + component.count);
value = value.map(function (value, i) {
var oldValue = oldString[oldPos + i];
return oldValue.length > value.length ? oldValue : value;
});
component.value = diff.join(value);
} else {
component.value = diff.join(newString.slice(newPos, newPos + component.count));
}
newPos += component.count; // Common case
if (!component.added) {
oldPos += component.count;
}
} else {
component.value = diff.join(oldString.slice(oldPos, oldPos + component.count));
oldPos += component.count; // Reverse add and remove so removes are output first to match common convention
// The diffing algorithm is tied to add then remove output and this is the simplest
// route to get the desired output with minimal overhead.
if (componentPos && components[componentPos - 1].added) {
var tmp = components[componentPos - 1];
components[componentPos - 1] = components[componentPos];
components[componentPos] = tmp;
}
}
} // Special case handle for when one terminal is ignored (i.e. whitespace).
// For this case we merge the terminal into the prior string and drop the change.
// This is only available for string mode.
var lastComponent = components[componentLen - 1];
if (componentLen > 1 && typeof lastComponent.value === 'string' && (lastComponent.added || lastComponent.removed) && diff.equals('', lastComponent.value)) {
components[componentLen - 2].value += lastComponent.value;
components.pop();
}
return components;
}
function clonePath(path) {
return {
newPos: path.newPos,
components: path.components.slice(0)
};
}
/***/ }),
/***/ 307:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var layout = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "-2 -2 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M2 2h5v11H2V2zm6 0h5v5H8V2zm6 0h4v16h-4V2zM8 8h5v5H8V8zm-6 6h11v4H2v-4z"
}));
/* harmony default export */ __webpack_exports__["a"] = (layout);
/***/ }),
/***/ 308:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
/* harmony import */ var _wordpress_primitives__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__);
/**
* WordPress dependencies
*/
var media = Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_0__["createElement"])(_wordpress_primitives__WEBPACK_IMPORTED_MODULE_1__["Path"], {
d: "M18.7 3H5.3C4 3 3 4 3 5.3v13.4C3 20 4 21 5.3 21h13.4c1.3 0 2.3-1 2.3-2.3V5.3C21 4 20 3 18.7 3zm.8 15.7c0 .4-.4.8-.8.8H5.3c-.4 0-.8-.4-.8-.8V5.3c0-.4.4-.8.8-.8h13.4c.4 0 .8.4.8.8v13.4zM10 15l5-3-5-3v6z"
}));
/* harmony default export */ __webpack_exports__["a"] = (media);
/***/ }),
/***/ 31:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
/* harmony import */ var _babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_babel_runtime_helpers_esm_arrayLikeToArray__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
}
/***/ }),
/***/ 32:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["url"]; }());
/***/ }),
/***/ 33:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["hooks"]; }());
/***/ }),
/***/ 35:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["deprecated"]; }());
/***/ }),
/***/ 37:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; });
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
/***/ }),
/***/ 38:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
/***/ }),
/***/ 39:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/***/ }),
/***/ 4:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["data"]; }());
/***/ }),
/***/ 41:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
var LEAF_KEY, hasWeakMap;
/**
* Arbitrary value used as key for referencing cache object in WeakMap tree.
*
* @type {Object}
*/
LEAF_KEY = {};
/**
* Whether environment supports WeakMap.
*
* @type {boolean}
*/
hasWeakMap = typeof WeakMap !== 'undefined';
/**
* Returns the first argument as the sole entry in an array.
*
* @param {*} value Value to return.
*
* @return {Array} Value returned as entry in array.
*/
function arrayOf( value ) {
return [ value ];
}
/**
* Returns true if the value passed is object-like, or false otherwise. A value
* is object-like if it can support property assignment, e.g. object or array.
*
* @param {*} value Value to test.
*
* @return {boolean} Whether value is object-like.
*/
function isObjectLike( value ) {
return !! value && 'object' === typeof value;
}
/**
* Creates and returns a new cache object.
*
* @return {Object} Cache object.
*/
function createCache() {
var cache = {
clear: function() {
cache.head = null;
},
};
return cache;
}
/**
* Returns true if entries within the two arrays are strictly equal by
* reference from a starting index.
*
* @param {Array} a First array.
* @param {Array} b Second array.
* @param {number} fromIndex Index from which to start comparison.
*
* @return {boolean} Whether arrays are shallowly equal.
*/
function isShallowEqual( a, b, fromIndex ) {
var i;
if ( a.length !== b.length ) {
return false;
}
for ( i = fromIndex; i < a.length; i++ ) {
if ( a[ i ] !== b[ i ] ) {
return false;
}
}
return true;
}
/**
* Returns a memoized selector function. The getDependants function argument is
* called before the memoized selector and is expected to return an immutable
* reference or array of references on which the selector depends for computing
* its own return value. The memoize cache is preserved only as long as those
* dependant references remain the same. If getDependants returns a different
* reference(s), the cache is cleared and the selector value regenerated.
*
* @param {Function} selector Selector function.
* @param {Function} getDependants Dependant getter returning an immutable
* reference or array of reference used in
* cache bust consideration.
*
* @return {Function} Memoized selector.
*/
/* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) {
var rootCache, getCache;
// Use object source as dependant if getter not provided
if ( ! getDependants ) {
getDependants = arrayOf;
}
/**
* Returns the root cache. If WeakMap is supported, this is assigned to the
* root WeakMap cache set, otherwise it is a shared instance of the default
* cache object.
*
* @return {(WeakMap|Object)} Root cache object.
*/
function getRootCache() {
return rootCache;
}
/**
* Returns the cache for a given dependants array. When possible, a WeakMap
* will be used to create a unique cache for each set of dependants. This
* is feasible due to the nature of WeakMap in allowing garbage collection
* to occur on entries where the key object is no longer referenced. Since
* WeakMap requires the key to be an object, this is only possible when the
* dependant is object-like. The root cache is created as a hierarchy where
* each top-level key is the first entry in a dependants set, the value a
* WeakMap where each key is the next dependant, and so on. This continues
* so long as the dependants are object-like. If no dependants are object-
* like, then the cache is shared across all invocations.
*
* @see isObjectLike
*
* @param {Array} dependants Selector dependants.
*
* @return {Object} Cache object.
*/
function getWeakMapCache( dependants ) {
var caches = rootCache,
isUniqueByDependants = true,
i, dependant, map, cache;
for ( i = 0; i < dependants.length; i++ ) {
dependant = dependants[ i ];
// Can only compose WeakMap from object-like key.
if ( ! isObjectLike( dependant ) ) {
isUniqueByDependants = false;
break;
}
// Does current segment of cache already have a WeakMap?
if ( caches.has( dependant ) ) {
// Traverse into nested WeakMap.
caches = caches.get( dependant );
} else {
// Create, set, and traverse into a new one.
map = new WeakMap();
caches.set( dependant, map );
caches = map;
}
}
// We use an arbitrary (but consistent) object as key for the last item
// in the WeakMap to serve as our running cache.
if ( ! caches.has( LEAF_KEY ) ) {
cache = createCache();
cache.isUniqueByDependants = isUniqueByDependants;
caches.set( LEAF_KEY, cache );
}
return caches.get( LEAF_KEY );
}
// Assign cache handler by availability of WeakMap
getCache = hasWeakMap ? getWeakMapCache : getRootCache;
/**
* Resets root memoization cache.
*/
function clear() {
rootCache = hasWeakMap ? new WeakMap() : createCache();
}
// eslint-disable-next-line jsdoc/check-param-names
/**
* The augmented selector call, considering first whether dependants have
* changed before passing it to underlying memoize function.
*
* @param {Object} source Source object for derivation.
* @param {...*} extraArgs Additional arguments to pass to selector.
*
* @return {*} Selector result.
*/
function callSelector( /* source, ...extraArgs */ ) {
var len = arguments.length,
cache, node, i, args, dependants;
// Create copy of arguments (avoid leaking deoptimization).
args = new Array( len );
for ( i = 0; i < len; i++ ) {
args[ i ] = arguments[ i ];
}
dependants = getDependants.apply( null, args );
cache = getCache( dependants );
// If not guaranteed uniqueness by dependants (primitive type or lack
// of WeakMap support), shallow compare against last dependants and, if
// references have changed, destroy cache to recalculate result.
if ( ! cache.isUniqueByDependants ) {
if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) {
cache.clear();
}
cache.lastDependants = dependants;
}
node = cache.head;
while ( node ) {
// Check whether node arguments match arguments
if ( ! isShallowEqual( node.args, args, 1 ) ) {
node = node.next;
continue;
}
// At this point we can assume we've found a match
// Surface matched node to head if not already
if ( node !== cache.head ) {
// Adjust siblings to point to each other.
node.prev.next = node.next;
if ( node.next ) {
node.next.prev = node.prev;
}
node.next = cache.head;
node.prev = null;
cache.head.prev = node;
cache.head = node;
}
// Return immediately
return node.val;
}
// No cached value found. Continue to insertion phase:
node = {
// Generate the result from original function
val: selector.apply( null, args ),
};
// Avoid including the source object in the cache.
args[ 0 ] = null;
node.args = args;
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
if ( cache.head ) {
cache.head.prev = node;
node.next = cache.head;
}
cache.head = node;
return node.val;
}
callSelector.getDependants = getDependants;
callSelector.clear = clear;
clear();
return callSelector;
});
/***/ }),
/***/ 42:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function _typeof(obj) {
return typeof obj;
};
} else {
_typeof = function _typeof(obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
/***/ }),
/***/ 43:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["blob"]; }());
/***/ }),
/***/ 44:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutPropertiesLoose; });
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
/***/ }),
/***/ 440:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
// ESM COMPAT FLAG
__webpack_require__.r(__webpack_exports__);
// EXPORTS
__webpack_require__.d(__webpack_exports__, "getColorClassName", function() { return /* reexport */ getColorClassName; });
__webpack_require__.d(__webpack_exports__, "getColorObjectByAttributeValues", function() { return /* reexport */ utils_getColorObjectByAttributeValues; });
__webpack_require__.d(__webpack_exports__, "getColorObjectByColorValue", function() { return /* reexport */ utils_getColorObjectByColorValue; });
__webpack_require__.d(__webpack_exports__, "createCustomColorsHOC", function() { return /* reexport */ createCustomColorsHOC; });
__webpack_require__.d(__webpack_exports__, "withColors", function() { return /* reexport */ withColors; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseColors", function() { return /* reexport */ __experimentalUseColors; });
__webpack_require__.d(__webpack_exports__, "__experimentalGetGradientClass", function() { return /* reexport */ __experimentalGetGradientClass; });
__webpack_require__.d(__webpack_exports__, "getGradientValueBySlug", function() { return /* reexport */ getGradientValueBySlug; });
__webpack_require__.d(__webpack_exports__, "__experimentalGetGradientObjectByGradientValue", function() { return /* reexport */ __experimentalGetGradientObjectByGradientValue; });
__webpack_require__.d(__webpack_exports__, "getGradientSlugByValue", function() { return /* reexport */ getGradientSlugByValue; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseGradient", function() { return /* reexport */ __experimentalUseGradient; });
__webpack_require__.d(__webpack_exports__, "getFontSize", function() { return /* reexport */ utils_getFontSize; });
__webpack_require__.d(__webpack_exports__, "getFontSizeClass", function() { return /* reexport */ getFontSizeClass; });
__webpack_require__.d(__webpack_exports__, "getFontSizeObjectByValue", function() { return /* reexport */ getFontSizeObjectByValue; });
__webpack_require__.d(__webpack_exports__, "FontSizePicker", function() { return /* reexport */ font_size_picker; });
__webpack_require__.d(__webpack_exports__, "withFontSizes", function() { return /* reexport */ with_font_sizes; });
__webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return /* reexport */ alignment_toolbar; });
__webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return /* reexport */ autocomplete; });
__webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return /* reexport */ block_alignment_toolbar; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockFullHeightAligmentToolbar", function() { return /* reexport */ block_full_height_alignment_toolbar; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockAlignmentMatrixToolbar", function() { return /* reexport */ block_alignment_matrix_toolbar; });
__webpack_require__.d(__webpack_exports__, "BlockBreadcrumb", function() { return /* reexport */ block_breadcrumb; });
__webpack_require__.d(__webpack_exports__, "BlockContextProvider", function() { return /* reexport */ BlockContextProvider; });
__webpack_require__.d(__webpack_exports__, "BlockControls", function() { return /* reexport */ block_controls; });
__webpack_require__.d(__webpack_exports__, "BlockColorsStyleSelector", function() { return /* reexport */ color_style_selector; });
__webpack_require__.d(__webpack_exports__, "BlockEdit", function() { return /* reexport */ block_edit_BlockEdit; });
__webpack_require__.d(__webpack_exports__, "useBlockEditContext", function() { return /* reexport */ useBlockEditContext; });
__webpack_require__.d(__webpack_exports__, "BlockFormatControls", function() { return /* reexport */ block_format_controls; });
__webpack_require__.d(__webpack_exports__, "BlockIcon", function() { return /* reexport */ BlockIcon; });
__webpack_require__.d(__webpack_exports__, "BlockNavigationDropdown", function() { return /* reexport */ dropdown; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationBlockFill", function() { return /* reexport */ block_slot_BlockNavigationBlockFill; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationEditor", function() { return /* reexport */ BlockNavigationEditor; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockNavigationTree", function() { return /* reexport */ BlockNavigationTree; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockVariationPicker", function() { return /* reexport */ block_variation_picker; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockVariationTransforms", function() { return /* reexport */ block_variation_transforms; });
__webpack_require__.d(__webpack_exports__, "BlockVerticalAlignmentToolbar", function() { return /* reexport */ block_vertical_alignment_toolbar; });
__webpack_require__.d(__webpack_exports__, "ButtonBlockerAppender", function() { return /* reexport */ button_block_appender; });
__webpack_require__.d(__webpack_exports__, "ColorPalette", function() { return /* reexport */ color_palette; });
__webpack_require__.d(__webpack_exports__, "ColorPaletteControl", function() { return /* reexport */ ColorPaletteControl; });
__webpack_require__.d(__webpack_exports__, "ContrastChecker", function() { return /* reexport */ contrast_checker; });
__webpack_require__.d(__webpack_exports__, "__experimentalGradientPicker", function() { return /* reexport */ gradient_picker; });
__webpack_require__.d(__webpack_exports__, "__experimentalGradientPickerControl", function() { return /* reexport */ GradientPickerControl; });
__webpack_require__.d(__webpack_exports__, "__experimentalGradientPickerPanel", function() { return /* reexport */ GradientPanel; });
__webpack_require__.d(__webpack_exports__, "__experimentalFontAppearanceControl", function() { return /* reexport */ FontAppearanceControl; });
__webpack_require__.d(__webpack_exports__, "__experimentalFontFamilyControl", function() { return /* reexport */ FontFamilyControl; });
__webpack_require__.d(__webpack_exports__, "__experimentalColorGradientControl", function() { return /* reexport */ control; });
__webpack_require__.d(__webpack_exports__, "__experimentalPanelColorGradientSettings", function() { return /* reexport */ panel_color_gradient_settings; });
__webpack_require__.d(__webpack_exports__, "__experimentalImageSizeControl", function() { return /* reexport */ ImageSizeControl; });
__webpack_require__.d(__webpack_exports__, "InnerBlocks", function() { return /* reexport */ inner_blocks; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseInnerBlocksProps", function() { return /* reexport */ useInnerBlocksProps; });
__webpack_require__.d(__webpack_exports__, "InspectorAdvancedControls", function() { return /* reexport */ inspector_advanced_controls; });
__webpack_require__.d(__webpack_exports__, "InspectorControls", function() { return /* reexport */ inspector_controls; });
__webpack_require__.d(__webpack_exports__, "__experimentalLinkControl", function() { return /* reexport */ link_control; });
__webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchInput", function() { return /* reexport */ search_input; });
__webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchResults", function() { return /* reexport */ LinkControlSearchResults; });
__webpack_require__.d(__webpack_exports__, "__experimentalLinkControlSearchItem", function() { return /* reexport */ search_item; });
__webpack_require__.d(__webpack_exports__, "LineHeightControl", function() { return /* reexport */ LineHeightControl; });
__webpack_require__.d(__webpack_exports__, "MediaReplaceFlow", function() { return /* reexport */ media_replace_flow; });
__webpack_require__.d(__webpack_exports__, "MediaPlaceholder", function() { return /* reexport */ media_placeholder; });
__webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return /* reexport */ media_upload; });
__webpack_require__.d(__webpack_exports__, "MediaUploadCheck", function() { return /* reexport */ check; });
__webpack_require__.d(__webpack_exports__, "PanelColorSettings", function() { return /* reexport */ panel_color_settings; });
__webpack_require__.d(__webpack_exports__, "PlainText", function() { return /* reexport */ plain_text; });
__webpack_require__.d(__webpack_exports__, "__experimentalResponsiveBlockControl", function() { return /* reexport */ responsive_block_control; });
__webpack_require__.d(__webpack_exports__, "RichText", function() { return /* reexport */ rich_text; });
__webpack_require__.d(__webpack_exports__, "RichTextShortcut", function() { return /* reexport */ RichTextShortcut; });
__webpack_require__.d(__webpack_exports__, "RichTextToolbarButton", function() { return /* reexport */ RichTextToolbarButton; });
__webpack_require__.d(__webpack_exports__, "__unstableRichTextInputEvent", function() { return /* reexport */ input_event_unstableRichTextInputEvent; });
__webpack_require__.d(__webpack_exports__, "ToolSelector", function() { return /* reexport */ tool_selector; });
__webpack_require__.d(__webpack_exports__, "__experimentalUnitControl", function() { return /* reexport */ UnitControl; });
__webpack_require__.d(__webpack_exports__, "URLInput", function() { return /* reexport */ url_input; });
__webpack_require__.d(__webpack_exports__, "URLInputButton", function() { return /* reexport */ url_input_button; });
__webpack_require__.d(__webpack_exports__, "URLPopover", function() { return /* reexport */ url_popover; });
__webpack_require__.d(__webpack_exports__, "__experimentalImageURLInputUI", function() { return /* reexport */ image_url_input_ui_ImageURLInputUI; });
__webpack_require__.d(__webpack_exports__, "withColorContext", function() { return /* reexport */ with_color_context; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlockSettingsMenuFirstItem", function() { return /* reexport */ block_settings_menu_first_item; });
__webpack_require__.d(__webpack_exports__, "__experimentalInserterMenuExtension", function() { return /* reexport */ inserter_menu_extension; });
__webpack_require__.d(__webpack_exports__, "__experimentalPreviewOptions", function() { return /* reexport */ PreviewOptions; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseResizeCanvas", function() { return /* reexport */ useResizeCanvas; });
__webpack_require__.d(__webpack_exports__, "BlockInspector", function() { return /* reexport */ block_inspector; });
__webpack_require__.d(__webpack_exports__, "BlockList", function() { return /* reexport */ BlockList; });
__webpack_require__.d(__webpack_exports__, "useBlockProps", function() { return /* reexport */ useBlockProps; });
__webpack_require__.d(__webpack_exports__, "__experimentalBlock", function() { return /* reexport */ block_wrapper_Block; });
__webpack_require__.d(__webpack_exports__, "BlockMover", function() { return /* reexport */ block_mover; });
__webpack_require__.d(__webpack_exports__, "BlockPreview", function() { return /* reexport */ block_preview; });
__webpack_require__.d(__webpack_exports__, "BlockSelectionClearer", function() { return /* reexport */ BlockSelectionClearer; });
__webpack_require__.d(__webpack_exports__, "__unstableUseBlockSelectionClearer", function() { return /* reexport */ useBlockSelectionClearer; });
__webpack_require__.d(__webpack_exports__, "BlockSettingsMenu", function() { return /* reexport */ block_settings_menu; });
__webpack_require__.d(__webpack_exports__, "BlockSettingsMenuControls", function() { return /* reexport */ block_settings_menu_controls; });
__webpack_require__.d(__webpack_exports__, "BlockTitle", function() { return /* reexport */ BlockTitle; });
__webpack_require__.d(__webpack_exports__, "BlockToolbar", function() { return /* reexport */ BlockToolbar; });
__webpack_require__.d(__webpack_exports__, "CopyHandler", function() { return /* reexport */ copy_handler; });
__webpack_require__.d(__webpack_exports__, "__unstableUseClipboardHandler", function() { return /* reexport */ useClipboardHandler; });
__webpack_require__.d(__webpack_exports__, "DefaultBlockAppender", function() { return /* reexport */ default_block_appender; });
__webpack_require__.d(__webpack_exports__, "__unstableUseEditorStyles", function() { return /* reexport */ useEditorStyles; });
__webpack_require__.d(__webpack_exports__, "Inserter", function() { return /* reexport */ inserter; });
__webpack_require__.d(__webpack_exports__, "__experimentalLibrary", function() { return /* reexport */ library; });
__webpack_require__.d(__webpack_exports__, "__experimentalSearchForm", function() { return /* reexport */ search_form; });
__webpack_require__.d(__webpack_exports__, "BlockEditorKeyboardShortcuts", function() { return /* reexport */ keyboard_shortcuts; });
__webpack_require__.d(__webpack_exports__, "MultiSelectScrollIntoView", function() { return /* reexport */ MultiSelectScrollIntoView; });
__webpack_require__.d(__webpack_exports__, "__unstableUseScrollMultiSelectionIntoView", function() { return /* reexport */ useScrollMultiSelectionIntoView; });
__webpack_require__.d(__webpack_exports__, "NavigableToolbar", function() { return /* reexport */ navigable_toolbar; });
__webpack_require__.d(__webpack_exports__, "ObserveTyping", function() { return /* reexport */ observe_typing; });
__webpack_require__.d(__webpack_exports__, "__unstableUseTypingObserver", function() { return /* reexport */ useTypingObserver; });
__webpack_require__.d(__webpack_exports__, "__unstableUseMouseMoveTypingReset", function() { return /* reexport */ useMouseMoveTypingReset; });
__webpack_require__.d(__webpack_exports__, "PreserveScrollInReorder", function() { return /* reexport */ PreserveScrollInReorder; });
__webpack_require__.d(__webpack_exports__, "SkipToSelectedBlock", function() { return /* reexport */ skip_to_selected_block; });
__webpack_require__.d(__webpack_exports__, "Typewriter", function() { return /* reexport */ typewriter; });
__webpack_require__.d(__webpack_exports__, "__unstableUseTypewriter", function() { return /* reexport */ useTypewriter; });
__webpack_require__.d(__webpack_exports__, "Warning", function() { return /* reexport */ warning; });
__webpack_require__.d(__webpack_exports__, "WritingFlow", function() { return /* reexport */ WritingFlow; });
__webpack_require__.d(__webpack_exports__, "__unstableUseCanvasClickRedirect", function() { return /* reexport */ useCanvasClickRedirect; });
__webpack_require__.d(__webpack_exports__, "useBlockDisplayInformation", function() { return /* reexport */ useBlockDisplayInformation; });
__webpack_require__.d(__webpack_exports__, "__unstableIframe", function() { return /* reexport */ iframe; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseNoRecursiveRenders", function() { return /* reexport */ useNoRecursiveRenders; });
__webpack_require__.d(__webpack_exports__, "BlockEditorProvider", function() { return /* reexport */ provider; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseSimulatedMediaQuery", function() { return /* reexport */ useSimulatedMediaQuery; });
__webpack_require__.d(__webpack_exports__, "__experimentalUseEditorFeature", function() { return /* reexport */ useEditorFeature; });
__webpack_require__.d(__webpack_exports__, "transformStyles", function() { return /* reexport */ transform_styles; });
__webpack_require__.d(__webpack_exports__, "validateThemeColors", function() { return /* reexport */ validateThemeColors; });
__webpack_require__.d(__webpack_exports__, "validateThemeGradients", function() { return /* reexport */ validateThemeGradients; });
__webpack_require__.d(__webpack_exports__, "__experimentalGetMatchingVariation", function() { return /* reexport */ block_variation_transforms_experimentalGetMatchingVariation; });
__webpack_require__.d(__webpack_exports__, "storeConfig", function() { return /* reexport */ storeConfig; });
__webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
__webpack_require__.d(__webpack_exports__, "SETTINGS_DEFAULTS", function() { return /* reexport */ SETTINGS_DEFAULTS; });
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
var selectors_namespaceObject = {};
__webpack_require__.r(selectors_namespaceObject);
__webpack_require__.d(selectors_namespaceObject, "getBlockName", function() { return selectors_getBlockName; });
__webpack_require__.d(selectors_namespaceObject, "isBlockValid", function() { return selectors_isBlockValid; });
__webpack_require__.d(selectors_namespaceObject, "getBlockAttributes", function() { return selectors_getBlockAttributes; });
__webpack_require__.d(selectors_namespaceObject, "getBlock", function() { return selectors_getBlock; });
__webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithoutInnerBlocks", function() { return selectors_unstableGetBlockWithoutInnerBlocks; });
__webpack_require__.d(selectors_namespaceObject, "getBlocks", function() { return selectors_getBlocks; });
__webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithBlockTree", function() { return __unstableGetBlockWithBlockTree; });
__webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockTree", function() { return __unstableGetBlockTree; });
__webpack_require__.d(selectors_namespaceObject, "getClientIdsOfDescendants", function() { return selectors_getClientIdsOfDescendants; });
__webpack_require__.d(selectors_namespaceObject, "getClientIdsWithDescendants", function() { return getClientIdsWithDescendants; });
__webpack_require__.d(selectors_namespaceObject, "getGlobalBlockCount", function() { return getGlobalBlockCount; });
__webpack_require__.d(selectors_namespaceObject, "getBlocksByClientId", function() { return selectors_getBlocksByClientId; });
__webpack_require__.d(selectors_namespaceObject, "getBlockCount", function() { return selectors_getBlockCount; });
__webpack_require__.d(selectors_namespaceObject, "getSelectionStart", function() { return selectors_getSelectionStart; });
__webpack_require__.d(selectors_namespaceObject, "getSelectionEnd", function() { return selectors_getSelectionEnd; });
__webpack_require__.d(selectors_namespaceObject, "getBlockSelectionStart", function() { return selectors_getBlockSelectionStart; });
__webpack_require__.d(selectors_namespaceObject, "getBlockSelectionEnd", function() { return getBlockSelectionEnd; });
__webpack_require__.d(selectors_namespaceObject, "getSelectedBlockCount", function() { return selectors_getSelectedBlockCount; });
__webpack_require__.d(selectors_namespaceObject, "hasSelectedBlock", function() { return selectors_hasSelectedBlock; });
__webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientId", function() { return selectors_getSelectedBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "getSelectedBlock", function() { return getSelectedBlock; });
__webpack_require__.d(selectors_namespaceObject, "getBlockRootClientId", function() { return selectors_getBlockRootClientId; });
__webpack_require__.d(selectors_namespaceObject, "getBlockParents", function() { return selectors_getBlockParents; });
__webpack_require__.d(selectors_namespaceObject, "getBlockParentsByBlockName", function() { return getBlockParentsByBlockName; });
__webpack_require__.d(selectors_namespaceObject, "getBlockHierarchyRootClientId", function() { return getBlockHierarchyRootClientId; });
__webpack_require__.d(selectors_namespaceObject, "getLowestCommonAncestorWithSelectedBlock", function() { return getLowestCommonAncestorWithSelectedBlock; });
__webpack_require__.d(selectors_namespaceObject, "getAdjacentBlockClientId", function() { return getAdjacentBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "getPreviousBlockClientId", function() { return selectors_getPreviousBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "getNextBlockClientId", function() { return selectors_getNextBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "getSelectedBlocksInitialCaretPosition", function() { return getSelectedBlocksInitialCaretPosition; });
__webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientIds", function() { return selectors_getSelectedBlockClientIds; });
__webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlockClientIds", function() { return selectors_getMultiSelectedBlockClientIds; });
__webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocks", function() { return getMultiSelectedBlocks; });
__webpack_require__.d(selectors_namespaceObject, "getFirstMultiSelectedBlockClientId", function() { return selectors_getFirstMultiSelectedBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "getLastMultiSelectedBlockClientId", function() { return selectors_getLastMultiSelectedBlockClientId; });
__webpack_require__.d(selectors_namespaceObject, "isFirstMultiSelectedBlock", function() { return isFirstMultiSelectedBlock; });
__webpack_require__.d(selectors_namespaceObject, "isBlockMultiSelected", function() { return isBlockMultiSelected; });
__webpack_require__.d(selectors_namespaceObject, "isAncestorMultiSelected", function() { return isAncestorMultiSelected; });
__webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksStartClientId", function() { return selectors_getMultiSelectedBlocksStartClientId; });
__webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksEndClientId", function() { return selectors_getMultiSelectedBlocksEndClientId; });
__webpack_require__.d(selectors_namespaceObject, "getBlockOrder", function() { return selectors_getBlockOrder; });
__webpack_require__.d(selectors_namespaceObject, "getBlockIndex", function() { return selectors_getBlockIndex; });
__webpack_require__.d(selectors_namespaceObject, "isBlockSelected", function() { return selectors_isBlockSelected; });
__webpack_require__.d(selectors_namespaceObject, "hasSelectedInnerBlock", function() { return hasSelectedInnerBlock; });
__webpack_require__.d(selectors_namespaceObject, "isBlockWithinSelection", function() { return isBlockWithinSelection; });
__webpack_require__.d(selectors_namespaceObject, "hasMultiSelection", function() { return selectors_hasMultiSelection; });
__webpack_require__.d(selectors_namespaceObject, "isMultiSelecting", function() { return selectors_isMultiSelecting; });
__webpack_require__.d(selectors_namespaceObject, "isSelectionEnabled", function() { return selectors_isSelectionEnabled; });
__webpack_require__.d(selectors_namespaceObject, "getBlockMode", function() { return selectors_getBlockMode; });
__webpack_require__.d(selectors_namespaceObject, "isTyping", function() { return selectors_isTyping; });
__webpack_require__.d(selectors_namespaceObject, "isDraggingBlocks", function() { return isDraggingBlocks; });
__webpack_require__.d(selectors_namespaceObject, "getDraggedBlockClientIds", function() { return selectors_getDraggedBlockClientIds; });
__webpack_require__.d(selectors_namespaceObject, "isBlockBeingDragged", function() { return isBlockBeingDragged; });
__webpack_require__.d(selectors_namespaceObject, "isAncestorBeingDragged", function() { return isAncestorBeingDragged; });
__webpack_require__.d(selectors_namespaceObject, "isCaretWithinFormattedText", function() { return selectors_isCaretWithinFormattedText; });
__webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return getBlockInsertionPoint; });
__webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return isBlockInsertionPointVisible; });
__webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return selectors_isValidTemplate; });
__webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; });
__webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return selectors_getTemplateLock; });
__webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return selectors_canInsertBlockType; });
__webpack_require__.d(selectors_namespaceObject, "canInsertBlocks", function() { return selectors_canInsertBlocks; });
__webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return selectors_getInserterItems; });
__webpack_require__.d(selectors_namespaceObject, "getBlockTransformItems", function() { return selectors_getBlockTransformItems; });
__webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return selectors_hasInserterItems; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetAllowedBlocks", function() { return selectors_experimentalGetAllowedBlocks; });
__webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return selectors_getBlockListSettings; });
__webpack_require__.d(selectors_namespaceObject, "getSettings", function() { return selectors_getSettings; });
__webpack_require__.d(selectors_namespaceObject, "isLastBlockChangePersistent", function() { return isLastBlockChangePersistent; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetBlockListSettingsForBlocks", function() { return selectors_experimentalGetBlockListSettingsForBlocks; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetParsedReusableBlock", function() { return __experimentalGetParsedReusableBlock; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetReusableBlockTitle", function() { return selectors_experimentalGetReusableBlockTitle; });
__webpack_require__.d(selectors_namespaceObject, "__unstableIsLastBlockChangeIgnored", function() { return __unstableIsLastBlockChangeIgnored; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetLastBlockAttributeChanges", function() { return __experimentalGetLastBlockAttributeChanges; });
__webpack_require__.d(selectors_namespaceObject, "isNavigationMode", function() { return selectors_isNavigationMode; });
__webpack_require__.d(selectors_namespaceObject, "hasBlockMovingClientId", function() { return selectors_hasBlockMovingClientId; });
__webpack_require__.d(selectors_namespaceObject, "didAutomaticChange", function() { return selectors_didAutomaticChange; });
__webpack_require__.d(selectors_namespaceObject, "isBlockHighlighted", function() { return isBlockHighlighted; });
__webpack_require__.d(selectors_namespaceObject, "areInnerBlocksControlled", function() { return areInnerBlocksControlled; });
__webpack_require__.d(selectors_namespaceObject, "__experimentalGetActiveBlockIdByBlockNames", function() { return __experimentalGetActiveBlockIdByBlockNames; });
// NAMESPACE OBJECT: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
var actions_namespaceObject = {};
__webpack_require__.r(actions_namespaceObject);
__webpack_require__.d(actions_namespaceObject, "resetBlocks", function() { return actions_resetBlocks; });
__webpack_require__.d(actions_namespaceObject, "validateBlocksToTemplate", function() { return validateBlocksToTemplate; });
__webpack_require__.d(actions_namespaceObject, "resetSelection", function() { return actions_resetSelection; });
__webpack_require__.d(actions_namespaceObject, "receiveBlocks", function() { return receiveBlocks; });
__webpack_require__.d(actions_namespaceObject, "updateBlockAttributes", function() { return actions_updateBlockAttributes; });
__webpack_require__.d(actions_namespaceObject, "updateBlock", function() { return actions_updateBlock; });
__webpack_require__.d(actions_namespaceObject, "selectBlock", function() { return actions_selectBlock; });
__webpack_require__.d(actions_namespaceObject, "selectPreviousBlock", function() { return selectPreviousBlock; });
__webpack_require__.d(actions_namespaceObject, "selectNextBlock", function() { return selectNextBlock; });
__webpack_require__.d(actions_namespaceObject, "startMultiSelect", function() { return actions_startMultiSelect; });
__webpack_require__.d(actions_namespaceObject, "stopMultiSelect", function() { return actions_stopMultiSelect; });
__webpack_require__.d(actions_namespaceObject, "multiSelect", function() { return actions_multiSelect; });
__webpack_require__.d(actions_namespaceObject, "clearSelectedBlock", function() { return actions_clearSelectedBlock; });
__webpack_require__.d(actions_namespaceObject, "toggleSelection", function() { return actions_toggleSelection; });
__webpack_require__.d(actions_namespaceObject, "replaceBlocks", function() { return actions_replaceBlocks; });
__webpack_require__.d(actions_namespaceObject, "replaceBlock", function() { return replaceBlock; });
__webpack_require__.d(actions_namespaceObject, "moveBlocksDown", function() { return actions_moveBlocksDown; });
__webpack_require__.d(actions_namespaceObject, "moveBlocksUp", function() { return actions_moveBlocksUp; });
__webpack_require__.d(actions_namespaceObject, "moveBlocksToPosition", function() { return actions_moveBlocksToPosition; });
__webpack_require__.d(actions_namespaceObject, "moveBlockToPosition", function() { return actions_moveBlockToPosition; });
__webpack_require__.d(actions_namespaceObject, "insertBlock", function() { return actions_insertBlock; });
__webpack_require__.d(actions_namespaceObject, "insertBlocks", function() { return actions_insertBlocks; });
__webpack_require__.d(actions_namespaceObject, "__unstableSetInsertionPoint", function() { return actions_unstableSetInsertionPoint; });
__webpack_require__.d(actions_namespaceObject, "showInsertionPoint", function() { return actions_showInsertionPoint; });
__webpack_require__.d(actions_namespaceObject, "hideInsertionPoint", function() { return actions_hideInsertionPoint; });
__webpack_require__.d(actions_namespaceObject, "setTemplateValidity", function() { return setTemplateValidity; });
__webpack_require__.d(actions_namespaceObject, "synchronizeTemplate", function() { return synchronizeTemplate; });
__webpack_require__.d(actions_namespaceObject, "mergeBlocks", function() { return actions_mergeBlocks; });
__webpack_require__.d(actions_namespaceObject, "removeBlocks", function() { return actions_removeBlocks; });
__webpack_require__.d(actions_namespaceObject, "removeBlock", function() { return actions_removeBlock; });
__webpack_require__.d(actions_namespaceObject, "replaceInnerBlocks", function() { return actions_replaceInnerBlocks; });
__webpack_require__.d(actions_namespaceObject, "toggleBlockMode", function() { return toggleBlockMode; });
__webpack_require__.d(actions_namespaceObject, "startTyping", function() { return actions_startTyping; });
__webpack_require__.d(actions_namespaceObject, "stopTyping", function() { return actions_stopTyping; });
__webpack_require__.d(actions_namespaceObject, "startDraggingBlocks", function() { return actions_startDraggingBlocks; });
__webpack_require__.d(actions_namespaceObject, "stopDraggingBlocks", function() { return actions_stopDraggingBlocks; });
__webpack_require__.d(actions_namespaceObject, "enterFormattedText", function() { return actions_enterFormattedText; });
__webpack_require__.d(actions_namespaceObject, "exitFormattedText", function() { return actions_exitFormattedText; });
__webpack_require__.d(actions_namespaceObject, "selectionChange", function() { return actions_selectionChange; });
__webpack_require__.d(actions_namespaceObject, "insertDefaultBlock", function() { return actions_insertDefaultBlock; });
__webpack_require__.d(actions_namespaceObject, "updateBlockListSettings", function() { return actions_updateBlockListSettings; });
__webpack_require__.d(actions_namespaceObject, "updateSettings", function() { return actions_updateSettings; });
__webpack_require__.d(actions_namespaceObject, "__unstableSaveReusableBlock", function() { return __unstableSaveReusableBlock; });
__webpack_require__.d(actions_namespaceObject, "__unstableMarkLastChangeAsPersistent", function() { return actions_unstableMarkLastChangeAsPersistent; });
__webpack_require__.d(actions_namespaceObject, "__unstableMarkNextChangeAsNotPersistent", function() { return actions_unstableMarkNextChangeAsNotPersistent; });
__webpack_require__.d(actions_namespaceObject, "__unstableMarkAutomaticChange", function() { return actions_unstableMarkAutomaticChange; });
__webpack_require__.d(actions_namespaceObject, "__unstableMarkAutomaticChangeFinal", function() { return __unstableMarkAutomaticChangeFinal; });
__webpack_require__.d(actions_namespaceObject, "setNavigationMode", function() { return actions_setNavigationMode; });
__webpack_require__.d(actions_namespaceObject, "setBlockMovingClientId", function() { return actions_setBlockMovingClientId; });
__webpack_require__.d(actions_namespaceObject, "duplicateBlocks", function() { return actions_duplicateBlocks; });
__webpack_require__.d(actions_namespaceObject, "insertBeforeBlock", function() { return actions_insertBeforeBlock; });
__webpack_require__.d(actions_namespaceObject, "insertAfterBlock", function() { return actions_insertAfterBlock; });
__webpack_require__.d(actions_namespaceObject, "toggleBlockHighlight", function() { return actions_toggleBlockHighlight; });
__webpack_require__.d(actions_namespaceObject, "flashBlock", function() { return actions_flashBlock; });
__webpack_require__.d(actions_namespaceObject, "setHasControlledInnerBlocks", function() { return actions_setHasControlledInnerBlocks; });
// EXTERNAL MODULE: external ["wp","richText"]
var external_wp_richText_ = __webpack_require__(21);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
var esm_extends = __webpack_require__(8);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
var defineProperty = __webpack_require__(5);
// EXTERNAL MODULE: external ["wp","element"]
var external_wp_element_ = __webpack_require__(0);
// EXTERNAL MODULE: ./node_modules/classnames/index.js
var classnames = __webpack_require__(10);
var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
// EXTERNAL MODULE: external "lodash"
var external_lodash_ = __webpack_require__(2);
// EXTERNAL MODULE: external ["wp","compose"]
var external_wp_compose_ = __webpack_require__(12);
// EXTERNAL MODULE: external ["wp","hooks"]
var external_wp_hooks_ = __webpack_require__(33);
// EXTERNAL MODULE: external ["wp","blocks"]
var external_wp_blocks_ = __webpack_require__(9);
// EXTERNAL MODULE: external ["wp","data"]
var external_wp_data_ = __webpack_require__(4);
// EXTERNAL MODULE: external ["wp","components"]
var external_wp_components_ = __webpack_require__(3);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/context.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var Context = Object(external_wp_element_["createContext"])({
name: '',
isSelected: false,
focusedElement: null,
setFocusedElement: external_lodash_["noop"],
clientId: null
});
var context_Provider = Context.Provider;
/**
* A hook that returns the block edit context.
*
* @return {Object} Block edit context
*/
function useBlockEditContext() {
return Object(external_wp_element_["useContext"])(Context);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-display-block-controls/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function useDisplayBlockControls() {
var _useBlockEditContext = useBlockEditContext(),
isSelected = _useBlockEditContext.isSelected,
clientId = _useBlockEditContext.clientId,
name = _useBlockEditContext.name;
var isFirstAndSameTypeMultiSelected = Object(external_wp_data_["useSelect"])(function (select) {
// Don't bother checking, see OR statement below.
if (isSelected) {
return;
}
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
isFirstMultiSelectedBlock = _select.isFirstMultiSelectedBlock,
getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds;
if (!isFirstMultiSelectedBlock(clientId)) {
return false;
}
return getMultiSelectedBlockClientIds().every(function (id) {
return getBlockName(id) === name;
});
}, [clientId, isSelected, name]);
return isSelected || isFirstAndSameTypeMultiSelected;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-controls/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var _createSlotFill = Object(external_wp_components_["createSlotFill"])('BlockControls'),
Fill = _createSlotFill.Fill,
Slot = _createSlotFill.Slot;
function BlockControlsSlot(props) {
var accessibleToolbarState = Object(external_wp_element_["useContext"])(external_wp_components_["__experimentalToolbarContext"]);
return Object(external_wp_element_["createElement"])(Slot, Object(esm_extends["a" /* default */])({}, props, {
fillProps: accessibleToolbarState
}));
}
function BlockControlsFill(_ref) {
var controls = _ref.controls,
children = _ref.children;
if (!useDisplayBlockControls()) {
return null;
}
return Object(external_wp_element_["createElement"])(Fill, null, function (fillProps) {
// Children passed to BlockControlsFill will not have access to any
// React Context whose Provider is part of the BlockControlsSlot tree.
// So we re-create the Provider in this subtree.
var value = !Object(external_lodash_["isEmpty"])(fillProps) ? fillProps : null;
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalToolbarContext"].Provider, {
value: value
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
controls: controls
}), children);
});
}
var BlockControls = BlockControlsFill;
BlockControls.Slot = BlockControlsSlot;
/* harmony default export */ var block_controls = (BlockControls);
// EXTERNAL MODULE: external ["wp","i18n"]
var external_wp_i18n_ = __webpack_require__(1);
// EXTERNAL MODULE: external ["wp","primitives"]
var external_wp_primitives_ = __webpack_require__(7);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-left.js
/**
* WordPress dependencies
*/
var positionLeft = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M4 9v6h14V9H4zm8-4.8H4v1.5h8V4.2zM4 19.8h8v-1.5H4v1.5z"
}));
/* harmony default export */ var position_left = (positionLeft);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-center.js
/**
* WordPress dependencies
*/
var positionCenter = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M5 15h14V9H5v6zm0 4.8h14v-1.5H5v1.5zM5 4.2v1.5h14V4.2H5z"
}));
/* harmony default export */ var position_center = (positionCenter);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/position-right.js
/**
* WordPress dependencies
*/
var positionRight = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M6 15h14V9H6v6zm6-10.8v1.5h8V4.2h-8zm0 15.6h8v-1.5h-8v1.5z"
}));
/* harmony default export */ var position_right = (positionRight);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-wide.js
/**
* WordPress dependencies
*/
var stretchWide = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M5 9v6h14V9H5zm11-4.8H8v1.5h8V4.2zM8 19.8h8v-1.5H8v1.5z"
}));
/* harmony default export */ var stretch_wide = (stretchWide);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stretch-full-width.js
/**
* WordPress dependencies
*/
var stretchFullWidth = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M5 4v11h14V4H5zm3 15.8h8v-1.5H8v1.5z"
}));
/* harmony default export */ var stretch_full_width = (stretchFullWidth);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/layout.js
/**
* WordPress dependencies
*/
var defaultLayout = {
type: 'default'
};
var Layout = Object(external_wp_element_["createContext"])(defaultLayout);
/**
* Allows to define the layout.
*/
var LayoutProvider = Layout.Provider;
/**
* React hook used to retrieve the layout config.
*/
function useLayout() {
return Object(external_wp_element_["useContext"])(Layout);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-toolbar/index.js
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var BLOCK_ALIGNMENTS_CONTROLS = {
left: {
icon: position_left,
title: Object(external_wp_i18n_["__"])('Align left')
},
center: {
icon: position_center,
title: Object(external_wp_i18n_["__"])('Align center')
},
right: {
icon: position_right,
title: Object(external_wp_i18n_["__"])('Align right')
},
wide: {
icon: stretch_wide,
title: Object(external_wp_i18n_["__"])('Wide width')
},
full: {
icon: stretch_full_width,
title: Object(external_wp_i18n_["__"])('Full width')
}
};
var DEFAULT_CONTROLS = ['left', 'center', 'right', 'wide', 'full'];
var DEFAULT_CONTROL = 'center';
var WIDE_CONTROLS = ['wide', 'full'];
var block_alignment_toolbar_POPOVER_PROPS = {
isAlternate: true
};
function BlockAlignmentToolbar(_ref) {
var value = _ref.value,
onChange = _ref.onChange,
_ref$controls = _ref.controls,
controls = _ref$controls === void 0 ? DEFAULT_CONTROLS : _ref$controls,
_ref$isCollapsed = _ref.isCollapsed,
isCollapsed = _ref$isCollapsed === void 0 ? true : _ref$isCollapsed;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSettings = _select.getSettings;
var settings = getSettings();
return {
wideControlsEnabled: settings.alignWide
};
}),
_useSelect$wideContro = _useSelect.wideControlsEnabled,
wideControlsEnabled = _useSelect$wideContro === void 0 ? false : _useSelect$wideContro;
var layout = useLayout();
var supportsAlignments = layout.type === 'default';
if (!supportsAlignments) {
return null;
}
var _layout$alignments = layout.alignments,
availableAlignments = _layout$alignments === void 0 ? DEFAULT_CONTROLS : _layout$alignments;
var enabledControls = controls.filter(function (control) {
return (wideControlsEnabled || !WIDE_CONTROLS.includes(control)) && availableAlignments.includes(control);
});
if (enabledControls.length === 0) {
return null;
}
function applyOrUnset(align) {
return function () {
return onChange(value === align ? undefined : align);
};
}
var activeAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[value];
var defaultAlignmentControl = BLOCK_ALIGNMENTS_CONTROLS[DEFAULT_CONTROL];
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
popoverProps: block_alignment_toolbar_POPOVER_PROPS,
isCollapsed: isCollapsed,
icon: activeAlignmentControl ? activeAlignmentControl.icon : defaultAlignmentControl.icon,
label: Object(external_wp_i18n_["__"])('Align'),
toggleProps: {
describedBy: Object(external_wp_i18n_["__"])('Change alignment')
},
controls: enabledControls.map(function (control) {
return _objectSpread(_objectSpread({}, BLOCK_ALIGNMENTS_CONTROLS[control]), {}, {
isActive: value === control,
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: applyOrUnset(control)
});
})
});
}
/* harmony default export */ var block_alignment_toolbar = (BlockAlignmentToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/align.js
function align_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function align_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { align_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { align_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* An array which includes all possible valid alignments,
* used to validate if an alignment is valid or not.
*
* @constant
* @type {string[]}
*/
var ALL_ALIGNMENTS = ['left', 'center', 'right', 'wide', 'full'];
/**
* An array which includes all wide alignments.
* In order for this alignments to be valid they need to be supported by the block,
* and by the theme.
*
* @constant
* @type {string[]}
*/
var WIDE_ALIGNMENTS = ['wide', 'full'];
/**
* Returns the valid alignments.
* Takes into consideration the aligns supported by a block, if the block supports wide controls or not and if theme supports wide controls or not.
* Exported just for testing purposes, not exported outside the module.
*
* @param {?boolean|string[]} blockAlign Aligns supported by the block.
* @param {?boolean} hasWideBlockSupport True if block supports wide alignments. And False otherwise.
* @param {?boolean} hasWideEnabled True if theme supports wide alignments. And False otherwise.
*
* @return {string[]} Valid alignments.
*/
function getValidAlignments(blockAlign) {
var hasWideBlockSupport = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
var hasWideEnabled = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
var validAlignments;
if (Array.isArray(blockAlign)) {
validAlignments = ALL_ALIGNMENTS.filter(function (value) {
return blockAlign.includes(value);
});
} else if (blockAlign === true) {
// `true` includes all alignments...
validAlignments = ALL_ALIGNMENTS;
} else {
validAlignments = [];
}
if (!hasWideEnabled || blockAlign === true && !hasWideBlockSupport) {
return external_lodash_["without"].apply(void 0, [validAlignments].concat(WIDE_ALIGNMENTS));
}
return validAlignments;
}
/**
* Filters registered block settings, extending attributes to include `align`.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function addAttribute(settings) {
// allow blocks to specify their own attribute definition with default values if needed.
if (Object(external_lodash_["has"])(settings.attributes, ['align', 'type'])) {
return settings;
}
if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'align')) {
// Gracefully handle if settings.attributes is undefined.
settings.attributes = align_objectSpread(align_objectSpread({}, settings.attributes), {}, {
align: {
type: 'string',
// Allow for '' since it is used by updateAlignment function
// in withToolbarControls for special cases with defined default values.
enum: [].concat(ALL_ALIGNMENTS, [''])
}
});
}
return settings;
}
/**
* Override the default edit UI to include new toolbar controls for block
* alignment, if block defines support.
*
* @param {Function} BlockEdit Original component
* @return {Function} Wrapped component
*/
var withToolbarControls = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) {
return function (props) {
var blockName = props.name; // Compute valid alignments without taking into account,
// if the theme supports wide alignments or not
// and without checking the layout for availble alignments.
// BlockAlignmentToolbar takes both of these into account.
var validAlignments = getValidAlignments(Object(external_wp_blocks_["getBlockSupport"])(blockName, 'align'), Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'alignWide', true));
var updateAlignment = function updateAlignment(nextAlign) {
if (!nextAlign) {
var _blockType$attributes, _blockType$attributes2;
var blockType = Object(external_wp_blocks_["getBlockType"])(props.name);
var blockDefaultAlign = (_blockType$attributes = blockType.attributes) === null || _blockType$attributes === void 0 ? void 0 : (_blockType$attributes2 = _blockType$attributes.align) === null || _blockType$attributes2 === void 0 ? void 0 : _blockType$attributes2.default;
if (blockDefaultAlign) {
nextAlign = '';
}
}
props.setAttributes({
align: nextAlign
});
};
return [validAlignments.length > 0 && props.isSelected && Object(external_wp_element_["createElement"])(block_controls, {
key: "align-controls"
}, Object(external_wp_element_["createElement"])(block_alignment_toolbar, {
value: props.attributes.align,
onChange: updateAlignment,
controls: validAlignments
})), Object(external_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({
key: "edit"
}, props))];
};
}, 'withToolbarControls');
/**
* Override the default block element to add alignment wrapper props.
*
* @param {Function} BlockListBlock Original component
* @return {Function} Wrapped component
*/
var withDataAlign = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockListBlock) {
return function (props) {
var name = props.name,
attributes = props.attributes;
var align = attributes.align;
var hasWideEnabled = Object(external_wp_data_["useSelect"])(function (select) {
return !!select('core/block-editor').getSettings().alignWide;
}, []); // If an alignment is not assigned, there's no need to go through the
// effort to validate or assign its value.
if (align === undefined) {
return Object(external_wp_element_["createElement"])(BlockListBlock, props);
}
var validAlignments = getValidAlignments(Object(external_wp_blocks_["getBlockSupport"])(name, 'align'), Object(external_wp_blocks_["hasBlockSupport"])(name, 'alignWide', true), hasWideEnabled);
var wrapperProps = props.wrapperProps;
if (validAlignments.includes(align)) {
wrapperProps = align_objectSpread(align_objectSpread({}, wrapperProps), {}, {
'data-align': align
});
}
return Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
wrapperProps: wrapperProps
}));
};
});
/**
* Override props assigned to save component to inject alignment class name if
* block supports it.
*
* @param {Object} props Additional props applied to save element
* @param {Object} blockType Block type
* @param {Object} attributes Block attributes
* @return {Object} Filtered props applied to save element
*/
function addAssignedAlign(props, blockType, attributes) {
var align = attributes.align;
var blockAlign = Object(external_wp_blocks_["getBlockSupport"])(blockType, 'align');
var hasWideBlockSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'alignWide', true); // Compute valid alignments without taking into account if
// the theme supports wide alignments or not.
// This way changing themes does not impact the block save.
var isAlignValid = getValidAlignments(blockAlign, hasWideBlockSupport).includes(align);
if (isAlignValid) {
props.className = classnames_default()("align".concat(align), props.className);
}
return props;
}
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/align/addAttribute', addAttribute);
Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/editor/align/with-data-align', withDataAlign);
Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/align/with-toolbar-controls', withToolbarControls);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/align/addAssignedAlign', addAssignedAlign);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-advanced-controls/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var inspector_advanced_controls_name = 'InspectorAdvancedControls';
var inspector_advanced_controls_createSlotFill = Object(external_wp_components_["createSlotFill"])(inspector_advanced_controls_name),
inspector_advanced_controls_Fill = inspector_advanced_controls_createSlotFill.Fill,
inspector_advanced_controls_Slot = inspector_advanced_controls_createSlotFill.Slot;
function InspectorAdvancedControls(_ref) {
var children = _ref.children;
var _useBlockEditContext = useBlockEditContext(),
isSelected = _useBlockEditContext.isSelected;
return isSelected ? Object(external_wp_element_["createElement"])(inspector_advanced_controls_Fill, null, children) : null;
}
InspectorAdvancedControls.slotName = inspector_advanced_controls_name;
InspectorAdvancedControls.Slot = inspector_advanced_controls_Slot;
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-advanced-controls/README.md
*/
/* harmony default export */ var inspector_advanced_controls = (InspectorAdvancedControls);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inspector-controls/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var inspector_controls_createSlotFill = Object(external_wp_components_["createSlotFill"])('InspectorControls'),
inspector_controls_Fill = inspector_controls_createSlotFill.Fill,
inspector_controls_Slot = inspector_controls_createSlotFill.Slot;
function InspectorControls(_ref) {
var children = _ref.children;
return useDisplayBlockControls() ? Object(external_wp_element_["createElement"])(inspector_controls_Fill, null, children) : null;
}
InspectorControls.Slot = inspector_controls_Slot;
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inspector-controls/README.md
*/
/* harmony default export */ var inspector_controls = (InspectorControls);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/anchor.js
function anchor_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function anchor_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { anchor_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { anchor_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Regular expression matching invalid anchor characters for replacement.
*
* @type {RegExp}
*/
var ANCHOR_REGEX = /[\s#]/g;
/**
* Filters registered block settings, extending attributes with anchor using ID
* of the first node.
*
* @param {Object} settings Original block settings.
*
* @return {Object} Filtered block settings.
*/
function anchor_addAttribute(settings) {
// allow blocks to specify their own attribute definition with default values if needed.
if (Object(external_lodash_["has"])(settings.attributes, ['anchor', 'type'])) {
return settings;
}
if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'anchor')) {
// Gracefully handle if settings.attributes is undefined.
settings.attributes = anchor_objectSpread(anchor_objectSpread({}, settings.attributes), {}, {
anchor: {
type: 'string',
source: 'attribute',
attribute: 'id',
selector: '*'
}
});
}
return settings;
}
/**
* Override the default edit UI to include a new block inspector control for
* assigning the anchor ID, if block supports anchor.
*
* @param {WPComponent} BlockEdit Original component.
*
* @return {WPComponent} Wrapped component.
*/
var withInspectorControl = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) {
return function (props) {
var hasAnchor = Object(external_wp_blocks_["hasBlockSupport"])(props.name, 'anchor');
if (hasAnchor && props.isSelected) {
var isWeb = external_wp_element_["Platform"].OS === 'web';
var textControl = Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
className: "html-anchor-control",
label: Object(external_wp_i18n_["__"])('HTML anchor'),
help: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_i18n_["__"])('Enter a word or two — without spaces — to make a unique web address just for this block, called an “anchor.” Then, you’ll be able to link directly to this section of your page.'), Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
href: 'https://wordpress.org/support/article/page-jumps/'
}, Object(external_wp_i18n_["__"])('Learn more about anchors'))),
value: props.attributes.anchor || '',
valuePlaceholder: !isWeb ? Object(external_wp_i18n_["__"])('Add an anchor') : null,
onChange: function onChange(nextValue) {
nextValue = nextValue.replace(ANCHOR_REGEX, '-');
props.setAttributes({
anchor: nextValue
});
},
autoCapitalize: "none",
autoComplete: "off"
});
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), isWeb && Object(external_wp_element_["createElement"])(inspector_advanced_controls, null, textControl), !isWeb && props.name === 'core/heading' && Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Heading settings')
}, textControl)));
}
return Object(external_wp_element_["createElement"])(BlockEdit, props);
};
}, 'withInspectorControl');
/**
* Override props assigned to save component to inject anchor ID, if block
* supports anchor. This is only applied if the block's save result is an
* element and not a markup string.
*
* @param {Object} extraProps Additional props applied to save element.
* @param {Object} blockType Block type.
* @param {Object} attributes Current block attributes.
*
* @return {Object} Filtered props applied to save element.
*/
function addSaveProps(extraProps, blockType, attributes) {
if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'anchor')) {
extraProps.id = attributes.anchor === '' ? null : attributes.anchor;
}
return extraProps;
}
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/anchor/attribute', anchor_addAttribute);
Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/anchor/with-inspector-control', withInspectorControl);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/anchor/save-props', addSaveProps);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/custom-class-name.js
function custom_class_name_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function custom_class_name_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { custom_class_name_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { custom_class_name_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Filters registered block settings, extending attributes with anchor using ID
* of the first node.
*
* @param {Object} settings Original block settings.
*
* @return {Object} Filtered block settings.
*/
function custom_class_name_addAttribute(settings) {
if (Object(external_wp_blocks_["hasBlockSupport"])(settings, 'customClassName', true)) {
// Gracefully handle if settings.attributes is undefined.
settings.attributes = custom_class_name_objectSpread(custom_class_name_objectSpread({}, settings.attributes), {}, {
className: {
type: 'string'
}
});
}
return settings;
}
/**
* Override the default edit UI to include a new block inspector control for
* assigning the custom class name, if block supports custom class name.
*
* @param {WPComponent} BlockEdit Original component.
*
* @return {WPComponent} Wrapped component.
*/
var custom_class_name_withInspectorControl = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) {
return function (props) {
var hasCustomClassName = Object(external_wp_blocks_["hasBlockSupport"])(props.name, 'customClassName', true);
if (hasCustomClassName && props.isSelected) {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockEdit, props), Object(external_wp_element_["createElement"])(inspector_advanced_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
autoComplete: "off",
label: Object(external_wp_i18n_["__"])('Additional CSS class(es)'),
value: props.attributes.className || '',
onChange: function onChange(nextValue) {
props.setAttributes({
className: nextValue !== '' ? nextValue : undefined
});
},
help: Object(external_wp_i18n_["__"])('Separate multiple classes with spaces.')
})));
}
return Object(external_wp_element_["createElement"])(BlockEdit, props);
};
}, 'withInspectorControl');
/**
* Override props assigned to save component to inject anchor ID, if block
* supports anchor. This is only applied if the block's save result is an
* element and not a markup string.
*
* @param {Object} extraProps Additional props applied to save element.
* @param {Object} blockType Block type.
* @param {Object} attributes Current block attributes.
*
* @return {Object} Filtered props applied to save element.
*/
function custom_class_name_addSaveProps(extraProps, blockType, attributes) {
if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true) && attributes.className) {
extraProps.className = classnames_default()(extraProps.className, attributes.className);
}
return extraProps;
}
/**
* Given an HTML string, returns an array of class names assigned to the root
* element in the markup.
*
* @param {string} innerHTML Markup string from which to extract classes.
*
* @return {string[]} Array of class names assigned to the root element.
*/
function getHTMLRootElementClasses(innerHTML) {
innerHTML = "
".concat(innerHTML, "
");
var parsed = Object(external_wp_blocks_["parseWithAttributeSchema"])(innerHTML, {
type: 'string',
source: 'attribute',
selector: '[data-custom-class-name] > *',
attribute: 'class'
});
return parsed ? parsed.trim().split(/\s+/) : [];
}
/**
* Given a parsed set of block attributes, if the block supports custom class
* names and an unknown class (per the block's serialization behavior) is
* found, the unknown classes are treated as custom classes. This prevents the
* block from being considered as invalid.
*
* @param {Object} blockAttributes Original block attributes.
* @param {Object} blockType Block type settings.
* @param {string} innerHTML Original block markup.
*
* @return {Object} Filtered block attributes.
*/
function addParsedDifference(blockAttributes, blockType, innerHTML) {
if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'customClassName', true)) {
// To determine difference, serialize block given the known set of
// attributes, with the exception of `className`. This will determine
// the default set of classes. From there, any difference in innerHTML
// can be considered as custom classes.
var attributesSansClassName = Object(external_lodash_["omit"])(blockAttributes, ['className']);
var serialized = Object(external_wp_blocks_["getSaveContent"])(blockType, attributesSansClassName);
var defaultClasses = getHTMLRootElementClasses(serialized);
var actualClasses = getHTMLRootElementClasses(innerHTML);
var customClasses = Object(external_lodash_["difference"])(actualClasses, defaultClasses);
if (customClasses.length) {
blockAttributes.className = customClasses.join(' ');
} else if (serialized) {
delete blockAttributes.className;
}
}
return blockAttributes;
}
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/custom-class-name/attribute', custom_class_name_addAttribute);
Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/editor/custom-class-name/with-inspector-control', custom_class_name_withInspectorControl);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/custom-class-name/save-props', custom_class_name_addSaveProps);
Object(external_wp_hooks_["addFilter"])('blocks.getBlockAttributes', 'core/custom-class-name/addParsedDifference', addParsedDifference);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules
var toConsumableArray = __webpack_require__(15);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/generated-class-name.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Override props assigned to save component to inject generated className if
* block supports it. This is only applied if the block's save result is an
* element and not a markup string.
*
* @param {Object} extraProps Additional props applied to save element.
* @param {Object} blockType Block type.
*
* @return {Object} Filtered props applied to save element.
*/
function addGeneratedClassName(extraProps, blockType) {
// Adding the generated className
if (Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'className', true)) {
if (typeof extraProps.className === 'string') {
// We have some extra classes and want to add the default classname
// We use uniq to prevent duplicate classnames
extraProps.className = Object(external_lodash_["uniq"])([Object(external_wp_blocks_["getBlockDefaultClassName"])(blockType.name)].concat(Object(toConsumableArray["a" /* default */])(extraProps.className.split(' ')))).join(' ').trim();
} else {
// There is no string in the className variable,
// so we just dump the default name in there
extraProps.className = Object(external_wp_blocks_["getBlockDefaultClassName"])(blockType.name);
}
}
return extraProps;
}
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/generated-class-name/save-props', addGeneratedClassName);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-editor-feature/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var deprecatedFlags = {
'color.palette': function colorPalette(settings) {
return settings.colors === undefined ? undefined : settings.colors;
},
'color.gradients': function colorGradients(settings) {
return settings.gradients === undefined ? undefined : settings.gradients;
},
'color.custom': function colorCustom(settings) {
return settings.disableCustomColors === undefined ? undefined : !settings.disableCustomColors;
},
'color.customGradient': function colorCustomGradient(settings) {
return settings.disableCustomGradients === undefined ? undefined : !settings.disableCustomGradients;
},
'typography.fontSizes': function typographyFontSizes(settings) {
return settings.fontSizes === undefined ? undefined : settings.fontSizes;
},
'typography.customFontSize': function typographyCustomFontSize(settings) {
return settings.disableCustomFontSizes === undefined ? undefined : !settings.disableCustomFontSizes;
},
'typography.customLineHeight': function typographyCustomLineHeight(settings) {
return settings.enableCustomLineHeight;
},
'spacing.units': function spacingUnits(settings) {
if (settings.enableCustomUnits === undefined) {
return;
}
if (settings.enableCustomUnits === true) {
return ['px', 'em', 'rem', 'vh', 'vw'];
}
return settings.enableCustomUnits;
},
'spacing.customPadding': function spacingCustomPadding(settings) {
return settings.enableCustomSpacing;
}
};
function blockAttributesMatch(blockAttributes, attributes) {
for (var attribute in attributes) {
if (attributes[attribute] !== blockAttributes[attribute]) {
return false;
}
}
return true;
}
/**
* Hook that retrieves the setting for the given editor feature.
* It works with nested objects using by finding the value at path.
*
* @param {string} featurePath The path to the feature.
*
* @return {any} Returns the value defined for the setting.
*
* @example
* ```js
* const isEnabled = useEditorFeature( 'typography.dropCap' );
* ```
*/
function useEditorFeature(featurePath) {
var _useBlockEditContext = useBlockEditContext(),
blockName = _useBlockEditContext.name,
clientId = _useBlockEditContext.clientId;
var setting = Object(external_wp_data_["useSelect"])(function (select) {
var _get;
var _select = select('core/block-editor'),
getBlockAttributes = _select.getBlockAttributes,
getSettings = _select.getSettings;
var settings = getSettings();
var blockType = select(external_wp_blocks_["store"]).getBlockType(blockName);
var context = blockName;
var selectors = Object(external_lodash_["get"])(blockType, ['supports', '__experimentalSelector']);
if (Object(external_lodash_["isObject"])(selectors)) {
var blockAttributes = getBlockAttributes(clientId) || {};
for (var contextSelector in selectors) {
var attributes = selectors[contextSelector].attributes;
if (blockAttributesMatch(blockAttributes, attributes)) {
context = contextSelector;
break;
}
}
} // 1 - Use __experimental features, if available.
// We cascade to the all value if the block one is not available.
var defaultsPath = "__experimentalFeatures.defaults.".concat(featurePath);
var blockPath = "__experimentalFeatures.".concat(context, ".").concat(featurePath);
var experimentalFeaturesResult = (_get = Object(external_lodash_["get"])(settings, blockPath)) !== null && _get !== void 0 ? _get : Object(external_lodash_["get"])(settings, defaultsPath);
if (experimentalFeaturesResult !== undefined) {
return experimentalFeaturesResult;
} // 2 - Use deprecated settings, otherwise.
var deprecatedSettingsValue = deprecatedFlags[featurePath] ? deprecatedFlags[featurePath](settings) : undefined;
if (deprecatedSettingsValue !== undefined) {
return deprecatedSettingsValue;
} // 3 - Fall back for typography.dropCap:
// This is only necessary to support typography.dropCap.
// when __experimentalFeatures are not present (core without plugin).
// To remove when __experimentalFeatures are ported to core.
return featurePath === 'typography.dropCap' ? true : undefined;
}, [blockName, clientId, featurePath]);
return setting;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/utils.js
/**
* External dependencies
*/
/**
* Removed undefined values from nested object.
*
* @param {*} object
* @return {*} Object cleaned from undefined values
*/
var utils_cleanEmptyObject = function cleanEmptyObject(object) {
if (!Object(external_lodash_["isObject"])(object)) {
return object;
}
var cleanedNestedObjects = Object(external_lodash_["pickBy"])(Object(external_lodash_["mapValues"])(object, cleanEmptyObject), external_lodash_["identity"]);
return Object(external_lodash_["isEqual"])(cleanedNestedObjects, {}) ? undefined : cleanedNestedObjects;
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border-radius.js
function border_radius_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function border_radius_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { border_radius_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { border_radius_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var MIN_BORDER_RADIUS_VALUE = 0;
var MAX_BORDER_RADIUS_VALUE = 50;
/**
* Inspector control panel containing the border radius related configuration.
*
* @param {Object} props Block properties.
* @return {WPElement} Border radius edit element.
*/
function BorderRadiusEdit(props) {
var _style$border;
var style = props.attributes.style,
setAttributes = props.setAttributes;
if (useIsBorderRadiusDisabled(props)) {
return null;
}
var onChange = function onChange(newRadius) {
var newStyle = border_radius_objectSpread(border_radius_objectSpread({}, style), {}, {
border: border_radius_objectSpread(border_radius_objectSpread({}, style === null || style === void 0 ? void 0 : style.border), {}, {
radius: newRadius
})
});
setAttributes({
style: utils_cleanEmptyObject(newStyle)
});
};
return Object(external_wp_element_["createElement"])(external_wp_components_["RangeControl"], {
value: style === null || style === void 0 ? void 0 : (_style$border = style.border) === null || _style$border === void 0 ? void 0 : _style$border.radius,
label: Object(external_wp_i18n_["__"])('Border radius'),
min: MIN_BORDER_RADIUS_VALUE,
max: MAX_BORDER_RADIUS_VALUE,
initialPosition: 0,
allowReset: true,
onChange: onChange
});
}
/**
* Determines if there is border radius support.
*
* @param {string|Object} blockType Block name or Block Type object.
* @return {boolean} Whether there is support.
*/
function hasBorderRadiusSupport(blockType) {
var support = Object(external_wp_blocks_["getBlockSupport"])(blockType, BORDER_SUPPORT_KEY);
return !!(true === support || support !== null && support !== void 0 && support.radius);
}
/**
* Custom hook that checks if border radius settings have been disabled.
*
* @param {string} name The name of the block.
* @return {boolean} Whether border radius setting is disabled.
*/
function useIsBorderRadiusDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var isDisabled = !useEditorFeature('border.customRadius');
return !hasBorderRadiusSupport(blockName) || isDisabled;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/border.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var BORDER_SUPPORT_KEY = '__experimentalBorder';
function BorderPanel(props) {
var isDisabled = border_useIsBorderDisabled(props);
var isSupported = hasBorderSupport(props.name);
if (isDisabled || !isSupported) {
return null;
}
return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Border settings')
}, Object(external_wp_element_["createElement"])(BorderRadiusEdit, props)));
}
/**
* Determine whether there is block support for borders.
*
* @param {string} blockName Block name.
* @return {boolean} Whether there is support.
*/
function hasBorderSupport(blockName) {
if (external_wp_element_["Platform"].OS !== 'web') {
return false;
}
var support = Object(external_wp_blocks_["getBlockSupport"])(blockName, BORDER_SUPPORT_KEY); // Further border properties to be added in future iterations.
// e.g. support && ( support.radius || support.width || support.style )
return !!(true === support || support !== null && support !== void 0 && support.radius);
}
/**
* Determines whether there is any block support for borders e.g. border radius,
* style, width etc.
*
* @param {Object} props Block properties.
* @return {boolean} If border support is completely disabled.
*/
var border_useIsBorderDisabled = function useIsBorderDisabled() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
// Further border properties to be added in future iterations.
// e.g. const configs = [
// useIsBorderRadiusDisabled( props ),
// useIsBorderWidthDisabled( props ),
// ];
var configs = [useIsBorderRadiusDisabled(props)];
return configs.every(Boolean);
};
// EXTERNAL MODULE: ./node_modules/tinycolor2/tinycolor.js
var tinycolor = __webpack_require__(60);
var tinycolor_default = /*#__PURE__*/__webpack_require__.n(tinycolor);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/utils.js
/**
* External dependencies
*/
/**
* Provided an array of color objects as set by the theme or by the editor defaults,
* and the values of the defined color or custom color returns a color object describing the color.
*
* @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
* @param {?string} definedColor A string containing the color slug.
* @param {?string} customColor A string containing the customColor value.
*
* @return {?Object} If definedColor is passed and the name is found in colors,
* the color object exactly as set by the theme or editor defaults is returned.
* Otherwise, an object that just sets the color is defined.
*/
var utils_getColorObjectByAttributeValues = function getColorObjectByAttributeValues(colors, definedColor, customColor) {
if (definedColor) {
var colorObj = Object(external_lodash_["find"])(colors, {
slug: definedColor
});
if (colorObj) {
return colorObj;
}
}
return {
color: customColor
};
};
/**
* Provided an array of color objects as set by the theme or by the editor defaults, and a color value returns the color object matching that value or undefined.
*
* @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
* @param {?string} colorValue A string containing the color value.
*
* @return {?Object} Color object included in the colors array whose color property equals colorValue.
* Returns undefined if no color object matches this requirement.
*/
var utils_getColorObjectByColorValue = function getColorObjectByColorValue(colors, colorValue) {
return Object(external_lodash_["find"])(colors, {
color: colorValue
});
};
/**
* Returns a class based on the context a color is being used and its slug.
*
* @param {string} colorContextName Context/place where color is being used e.g: background, text etc...
* @param {string} colorSlug Slug of the color.
*
* @return {?string} String with the class corresponding to the color in the provided context.
* Returns undefined if either colorContextName or colorSlug are not provided.
*/
function getColorClassName(colorContextName, colorSlug) {
if (!colorContextName || !colorSlug) {
return undefined;
}
return "has-".concat(Object(external_lodash_["kebabCase"])(colorSlug), "-").concat(colorContextName);
}
/**
* Given an array of color objects and a color value returns the color value of the most readable color in the array.
*
* @param {Array} colors Array of color objects as set by the theme or by the editor defaults.
* @param {?string} colorValue A string containing the color value.
*
* @return {string} String with the color value of the most readable color.
*/
function utils_getMostReadableColor(colors, colorValue) {
return tinycolor_default.a.mostReadable(colorValue, Object(external_lodash_["map"])(colors, 'color')).toHexString();
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/use-gradient.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var EMPTY_ARRAY = [];
function __experimentalGetGradientClass(gradientSlug) {
if (!gradientSlug) {
return undefined;
}
return "has-".concat(gradientSlug, "-gradient-background");
}
/**
* Retrieves the gradient value per slug.
*
* @param {Array} gradients Gradient Palette
* @param {string} slug Gradient slug
*
* @return {string} Gradient value.
*/
function getGradientValueBySlug(gradients, slug) {
var gradient = Object(external_lodash_["find"])(gradients, ['slug', slug]);
return gradient && gradient.gradient;
}
function __experimentalGetGradientObjectByGradientValue(gradients, value) {
var gradient = Object(external_lodash_["find"])(gradients, ['gradient', value]);
return gradient;
}
/**
* Retrieves the gradient slug per slug.
*
* @param {Array} gradients Gradient Palette
* @param {string} value Gradient value
* @return {string} Gradient slug.
*/
function getGradientSlugByValue(gradients, value) {
var gradient = __experimentalGetGradientObjectByGradientValue(gradients, value);
return gradient && gradient.slug;
}
function __experimentalUseGradient() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$gradientAttribut = _ref.gradientAttribute,
gradientAttribute = _ref$gradientAttribut === void 0 ? 'gradient' : _ref$gradientAttribut,
_ref$customGradientAt = _ref.customGradientAttribute,
customGradientAttribute = _ref$customGradientAt === void 0 ? 'customGradient' : _ref$customGradientAt;
var _useBlockEditContext = useBlockEditContext(),
clientId = _useBlockEditContext.clientId;
var gradients = useEditorFeature('color.gradients') || EMPTY_ARRAY;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockAttributes = _select.getBlockAttributes;
var attributes = getBlockAttributes(clientId) || {};
return {
customGradient: attributes[customGradientAttribute],
gradient: attributes[gradientAttribute]
};
}, [clientId, gradientAttribute, customGradientAttribute]),
gradient = _useSelect.gradient,
customGradient = _useSelect.customGradient;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlockAttributes = _useDispatch.updateBlockAttributes;
var setGradient = Object(external_wp_element_["useCallback"])(function (newGradientValue) {
var _updateBlockAttribute2;
var slug = getGradientSlugByValue(gradients, newGradientValue);
if (slug) {
var _updateBlockAttribute;
updateBlockAttributes(clientId, (_updateBlockAttribute = {}, Object(defineProperty["a" /* default */])(_updateBlockAttribute, gradientAttribute, slug), Object(defineProperty["a" /* default */])(_updateBlockAttribute, customGradientAttribute, undefined), _updateBlockAttribute));
return;
}
updateBlockAttributes(clientId, (_updateBlockAttribute2 = {}, Object(defineProperty["a" /* default */])(_updateBlockAttribute2, gradientAttribute, undefined), Object(defineProperty["a" /* default */])(_updateBlockAttribute2, customGradientAttribute, newGradientValue), _updateBlockAttribute2));
}, [gradients, clientId, updateBlockAttributes]);
var gradientClass = __experimentalGetGradientClass(gradient);
var gradientValue;
if (gradient) {
gradientValue = getGradientValueBySlug(gradients, gradient);
} else {
gradientValue = customGradient;
}
return {
gradientClass: gradientClass,
gradientValue: gradientValue,
setGradient: setGradient
};
}
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
var slicedToArray = __webpack_require__(11);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
var objectWithoutProperties = __webpack_require__(13);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/control.js
function control_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function control_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { control_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { control_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
// translators: first %s: the color name or value (e.g. red or #ff0000)
var colorIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(Color: %s)'); // translators: first %s: the gradient name or value (e.g. red to green or linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)
var gradientIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(Gradient: %s)');
var colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
function VisualLabel(_ref) {
var colors = _ref.colors,
gradients = _ref.gradients,
label = _ref.label,
currentTab = _ref.currentTab,
colorValue = _ref.colorValue,
gradientValue = _ref.gradientValue;
var value, ariaLabel;
if (currentTab === 'color') {
if (colorValue) {
value = colorValue;
var colorObject = utils_getColorObjectByColorValue(colors, value);
var colorName = colorObject && colorObject.name;
ariaLabel = Object(external_wp_i18n_["sprintf"])(colorIndicatorAriaLabel, colorName || value);
}
} else if (currentTab === 'gradient' && gradientValue) {
value = gradientValue;
var gradientObject = __experimentalGetGradientObjectByGradientValue(gradients, value);
var gradientName = gradientObject && gradientObject.name;
ariaLabel = Object(external_wp_i18n_["sprintf"])(gradientIndicatorAriaLabel, gradientName || value);
}
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, label, !!value && Object(external_wp_element_["createElement"])(external_wp_components_["ColorIndicator"], {
colorValue: value,
"aria-label": ariaLabel
}));
}
function ColorGradientControlInner(_ref2) {
var colors = _ref2.colors,
gradients = _ref2.gradients,
disableCustomColors = _ref2.disableCustomColors,
disableCustomGradients = _ref2.disableCustomGradients,
className = _ref2.className,
label = _ref2.label,
onColorChange = _ref2.onColorChange,
onGradientChange = _ref2.onGradientChange,
colorValue = _ref2.colorValue,
gradientValue = _ref2.gradientValue,
clearable = _ref2.clearable;
var canChooseAColor = onColorChange && (!Object(external_lodash_["isEmpty"])(colors) || !disableCustomColors);
var canChooseAGradient = onGradientChange && (!Object(external_lodash_["isEmpty"])(gradients) || !disableCustomGradients);
var _useState = Object(external_wp_element_["useState"])(gradientValue ? 'gradient' : !!canChooseAColor && 'color'),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
currentTab = _useState2[0],
setCurrentTab = _useState2[1];
if (!canChooseAColor && !canChooseAGradient) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], {
className: classnames_default()('block-editor-color-gradient-control', className)
}, Object(external_wp_element_["createElement"])("fieldset", null, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-color-gradient-control__color-indicator"
}, Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"].VisualLabel, null, Object(external_wp_element_["createElement"])(VisualLabel, {
currentTab: currentTab,
label: label,
colorValue: colorValue,
gradientValue: gradientValue
})))), canChooseAColor && canChooseAGradient && Object(external_wp_element_["createElement"])(external_wp_components_["ButtonGroup"], {
className: "block-editor-color-gradient-control__button-tabs"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSmall: true,
isPressed: currentTab === 'color',
onClick: function onClick() {
return setCurrentTab('color');
}
}, Object(external_wp_i18n_["__"])('Solid')), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSmall: true,
isPressed: currentTab === 'gradient',
onClick: function onClick() {
return setCurrentTab('gradient');
}
}, Object(external_wp_i18n_["__"])('Gradient'))), (currentTab === 'color' || !canChooseAGradient) && Object(external_wp_element_["createElement"])(external_wp_components_["ColorPalette"], Object(esm_extends["a" /* default */])({
value: colorValue,
onChange: canChooseAGradient ? function (newColor) {
onColorChange(newColor);
onGradientChange();
} : onColorChange
}, {
colors: colors,
disableCustomColors: disableCustomColors
}, {
clearable: clearable
})), (currentTab === 'gradient' || !canChooseAColor) && Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalGradientPicker"], Object(esm_extends["a" /* default */])({
value: gradientValue,
onChange: canChooseAColor ? function (newGradient) {
onGradientChange(newGradient);
onColorChange();
} : onGradientChange
}, {
gradients: gradients,
disableCustomGradients: disableCustomGradients
}, {
clearable: clearable
}))));
}
function ColorGradientControlSelect(props) {
var colorGradientSettings = {};
colorGradientSettings.colors = useEditorFeature('color.palette');
colorGradientSettings.gradients = useEditorFeature('color.gradients');
colorGradientSettings.disableCustomColors = !useEditorFeature('color.custom');
colorGradientSettings.disableCustomGradients = !useEditorFeature('color.customGradient');
return Object(external_wp_element_["createElement"])(ColorGradientControlInner, control_objectSpread(control_objectSpread({}, colorGradientSettings), props));
}
function ColorGradientControl(props) {
if (Object(external_lodash_["every"])(colorsAndGradientKeys, function (key) {
return props.hasOwnProperty(key);
})) {
return Object(external_wp_element_["createElement"])(ColorGradientControlInner, props);
}
return Object(external_wp_element_["createElement"])(ColorGradientControlSelect, props);
}
/* harmony default export */ var control = (ColorGradientControl);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors-gradients/panel-color-gradient-settings.js
function panel_color_gradient_settings_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function panel_color_gradient_settings_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { panel_color_gradient_settings_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { panel_color_gradient_settings_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
// translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
var panel_color_gradient_settings_colorIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(%s: color %s)'); // translators: first %s: The type of color or gradient (e.g. background, overlay...), second %s: the color name or value (e.g. red or #ff0000)
var panel_color_gradient_settings_gradientIndicatorAriaLabel = Object(external_wp_i18n_["__"])('(%s: gradient %s)');
var panel_color_gradient_settings_colorsAndGradientKeys = ['colors', 'disableCustomColors', 'gradients', 'disableCustomGradients'];
var panel_color_gradient_settings_Indicators = function Indicators(_ref) {
var colors = _ref.colors,
gradients = _ref.gradients,
settings = _ref.settings;
return settings.map(function (_ref2, index) {
var colorValue = _ref2.colorValue,
gradientValue = _ref2.gradientValue,
label = _ref2.label,
availableColors = _ref2.colors,
availableGradients = _ref2.gradients;
if (!colorValue && !gradientValue) {
return null;
}
var ariaLabel;
if (colorValue) {
var colorObject = utils_getColorObjectByColorValue(availableColors || colors, colorValue);
ariaLabel = Object(external_wp_i18n_["sprintf"])(panel_color_gradient_settings_colorIndicatorAriaLabel, label.toLowerCase(), colorObject && colorObject.name || colorValue);
} else {
var gradientObject = __experimentalGetGradientObjectByGradientValue(availableGradients || gradients, colorValue);
ariaLabel = Object(external_wp_i18n_["sprintf"])(panel_color_gradient_settings_gradientIndicatorAriaLabel, label.toLowerCase(), gradientObject && gradientObject.name || gradientValue);
}
return Object(external_wp_element_["createElement"])(external_wp_components_["ColorIndicator"], {
key: index,
colorValue: colorValue || gradientValue,
"aria-label": ariaLabel
});
});
};
var panel_color_gradient_settings_PanelColorGradientSettingsInner = function PanelColorGradientSettingsInner(_ref3) {
var className = _ref3.className,
colors = _ref3.colors,
gradients = _ref3.gradients,
disableCustomColors = _ref3.disableCustomColors,
disableCustomGradients = _ref3.disableCustomGradients,
children = _ref3.children,
settings = _ref3.settings,
title = _ref3.title,
props = Object(objectWithoutProperties["a" /* default */])(_ref3, ["className", "colors", "gradients", "disableCustomColors", "disableCustomGradients", "children", "settings", "title"]);
if (Object(external_lodash_["isEmpty"])(colors) && Object(external_lodash_["isEmpty"])(gradients) && disableCustomColors && disableCustomGradients && Object(external_lodash_["every"])(settings, function (setting) {
return Object(external_lodash_["isEmpty"])(setting.colors) && Object(external_lodash_["isEmpty"])(setting.gradients) && (setting.disableCustomColors === undefined || setting.disableCustomColors) && (setting.disableCustomGradients === undefined || setting.disableCustomGradients);
})) {
return null;
}
var titleElement = Object(external_wp_element_["createElement"])("span", {
className: "block-editor-panel-color-gradient-settings__panel-title"
}, title, Object(external_wp_element_["createElement"])(panel_color_gradient_settings_Indicators, {
colors: colors,
gradients: gradients,
settings: settings
}));
return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], Object(esm_extends["a" /* default */])({
className: classnames_default()('block-editor-panel-color-gradient-settings', className),
title: titleElement
}, props), settings.map(function (setting, index) {
return Object(external_wp_element_["createElement"])(control, Object(esm_extends["a" /* default */])({
key: index
}, panel_color_gradient_settings_objectSpread({
colors: colors,
gradients: gradients,
disableCustomColors: disableCustomColors,
disableCustomGradients: disableCustomGradients
}, setting)));
}), children);
};
var panel_color_gradient_settings_PanelColorGradientSettingsSelect = function PanelColorGradientSettingsSelect(props) {
var colorGradientSettings = {};
colorGradientSettings.colors = useEditorFeature('color.palette');
colorGradientSettings.gradients = useEditorFeature('color.gradients');
colorGradientSettings.disableCustomColors = !useEditorFeature('color.custom');
colorGradientSettings.disableCustomGradients = !useEditorFeature('color.customGradient');
return Object(external_wp_element_["createElement"])(panel_color_gradient_settings_PanelColorGradientSettingsInner, panel_color_gradient_settings_objectSpread(panel_color_gradient_settings_objectSpread({}, colorGradientSettings), props));
};
var panel_color_gradient_settings_PanelColorGradientSettings = function PanelColorGradientSettings(props) {
if (Object(external_lodash_["every"])(panel_color_gradient_settings_colorsAndGradientKeys, function (key) {
return props.hasOwnProperty(key);
})) {
return Object(external_wp_element_["createElement"])(panel_color_gradient_settings_PanelColorGradientSettingsInner, props);
}
return Object(external_wp_element_["createElement"])(panel_color_gradient_settings_PanelColorGradientSettingsSelect, props);
};
/* harmony default export */ var panel_color_gradient_settings = (panel_color_gradient_settings_PanelColorGradientSettings);
// EXTERNAL MODULE: external ["wp","a11y"]
var external_wp_a11y_ = __webpack_require__(48);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/contrast-checker/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function ContrastCheckerMessage(_ref) {
var tinyBackgroundColor = _ref.tinyBackgroundColor,
tinyTextColor = _ref.tinyTextColor,
backgroundColor = _ref.backgroundColor,
textColor = _ref.textColor;
var msg = tinyBackgroundColor.getBrightness() < tinyTextColor.getBrightness() ? Object(external_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a darker background color and/or a brighter text color.') : Object(external_wp_i18n_["__"])('This color combination may be hard for people to read. Try using a brighter background color and/or a darker text color.'); // Note: The `Notice` component can speak messages via its `spokenMessage`
// prop, but the contrast checker requires granular control over when the
// announcements are made. Notably, the message will be re-announced if a
// new color combination is selected and the contrast is still insufficient.
Object(external_wp_element_["useEffect"])(function () {
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('This color combination may be hard for people to read.'));
}, [backgroundColor, textColor]);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-contrast-checker"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
spokenMessage: null,
status: "warning",
isDismissible: false
}, msg));
}
function ContrastChecker(_ref2) {
var backgroundColor = _ref2.backgroundColor,
fallbackBackgroundColor = _ref2.fallbackBackgroundColor,
fallbackTextColor = _ref2.fallbackTextColor,
fontSize = _ref2.fontSize,
isLargeText = _ref2.isLargeText,
textColor = _ref2.textColor;
if (!(backgroundColor || fallbackBackgroundColor) || !(textColor || fallbackTextColor)) {
return null;
}
var tinyBackgroundColor = tinycolor_default()(backgroundColor || fallbackBackgroundColor);
var tinyTextColor = tinycolor_default()(textColor || fallbackTextColor);
var hasTransparency = tinyBackgroundColor.getAlpha() !== 1 || tinyTextColor.getAlpha() !== 1;
if (hasTransparency || tinycolor_default.a.isReadable(tinyBackgroundColor, tinyTextColor, {
level: 'AA',
size: isLargeText || isLargeText !== false && fontSize >= 24 ? 'large' : 'small'
})) {
return null;
}
return Object(external_wp_element_["createElement"])(ContrastCheckerMessage, {
backgroundColor: backgroundColor,
textColor: textColor,
tinyBackgroundColor: tinyBackgroundColor,
tinyTextColor: tinyTextColor
});
}
/* harmony default export */ var contrast_checker = (ContrastChecker);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/dom.js
/**
* Given a block client ID, returns the corresponding DOM node for the block,
* if exists. As much as possible, this helper should be avoided, and used only
* in cases where isolated behaviors need remote access to a block node.
*
* @param {string} clientId Block client ID.
* @param {Document} doc Document to search.
*
* @return {Element?} Block DOM node.
*/
function getBlockDOMNode(clientId, doc) {
return doc.getElementById('block-' + clientId);
}
/**
* Returns the preview container DOM node for a given block client ID, or
* undefined if the container cannot be determined.
*
* @param {string} clientId Block client ID.
* @param {Document} doc Document to search.
*
* @return {Node|undefined} Preview container DOM node.
*/
function getBlockPreviewContainerDOMNode(clientId, doc) {
var domNode = getBlockDOMNode(clientId, doc);
if (!domNode) {
return;
}
return domNode.firstChild || domNode;
}
/**
* Returns true if the given element is a block focus stop. Blocks without their
* own text fields rely on the focus stop to be keyboard navigable.
*
* @param {Element} element Element to test.
*
* @return {boolean} Whether element is a block focus stop.
*/
function isBlockFocusStop(element) {
return element.classList.contains('block-editor-block-list__block');
}
/**
* Returns true if two elements are contained within the same block.
*
* @param {Element} a First element.
* @param {Element} b Second element.
*
* @return {boolean} Whether elements are in the same block.
*/
function isInSameBlock(a, b) {
return a.closest('.block-editor-block-list__block') === b.closest('.block-editor-block-list__block');
}
/**
* Returns true if an element is considered part of the block and not its
* children.
*
* @param {Element} blockElement Block container element.
* @param {Element} element Element.
*
* @return {boolean} Whether element is in the block Element but not its
* children.
*/
function isInsideRootBlock(blockElement, element) {
var parentBlock = element.closest('.block-editor-block-list__block');
return parentBlock === blockElement;
}
/**
* Returns true if the given element contains inner blocks (an InnerBlocks
* element).
*
* @param {Element} element Element to test.
*
* @return {boolean} Whether element contains inner blocks.
*/
function hasInnerBlocksContext(element) {
return element.classList.contains('block-editor-block-list__layout') || !!element.querySelector('.block-editor-block-list__layout');
}
/**
* Finds the block client ID given any DOM node inside the block.
*
* @param {Node?} node DOM node.
*
* @return {string|undefined} Client ID or undefined if the node is not part of
* a block.
*/
function getBlockClientId(node) {
while (node && node.nodeType !== node.ELEMENT_NODE) {
node = node.parentNode;
}
if (!node) {
return;
}
var elementNode =
/** @type {Element} */
node;
var blockNode = elementNode.closest('.block-editor-block-list__block');
if (!blockNode) {
return;
}
return blockNode.id.slice('block-'.length);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color-panel.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function getComputedStyle(node) {
return node.ownerDocument.defaultView.getComputedStyle(node);
}
function ColorPanel(_ref) {
var settings = _ref.settings,
clientId = _ref.clientId,
_ref$enableContrastCh = _ref.enableContrastChecking,
enableContrastChecking = _ref$enableContrastCh === void 0 ? true : _ref$enableContrastCh;
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
detectedBackgroundColor = _useState2[0],
setDetectedBackgroundColor = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
detectedColor = _useState4[0],
setDetectedColor = _useState4[1];
Object(external_wp_element_["useEffect"])(function () {
if (!enableContrastChecking) {
return;
}
var colorsDetectionElement = getBlockDOMNode(clientId, document);
if (!colorsDetectionElement) {
return;
}
setDetectedColor(getComputedStyle(colorsDetectionElement).color);
var backgroundColorNode = colorsDetectionElement;
var backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
backgroundColorNode = backgroundColorNode.parentNode;
backgroundColor = getComputedStyle(backgroundColorNode).backgroundColor;
}
setDetectedBackgroundColor(backgroundColor);
});
return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(panel_color_gradient_settings, {
title: Object(external_wp_i18n_["__"])('Color settings'),
initialOpen: false,
settings: settings
}, enableContrastChecking && Object(external_wp_element_["createElement"])(contrast_checker, {
backgroundColor: detectedBackgroundColor,
textColor: detectedColor
})));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/color.js
function color_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function color_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { color_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { color_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var COLOR_SUPPORT_KEY = 'color';
var color_EMPTY_ARRAY = [];
var color_hasColorSupport = function hasColorSupport(blockType) {
var colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
return colorSupport && (colorSupport.link === true || colorSupport.gradient === true || colorSupport.background !== false || colorSupport.text !== false);
};
var color_hasLinkColorSupport = function hasLinkColorSupport(blockType) {
if (external_wp_element_["Platform"].OS !== 'web') {
return false;
}
var colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
return Object(external_lodash_["isObject"])(colorSupport) && !!colorSupport.link;
};
var color_hasGradientSupport = function hasGradientSupport(blockType) {
if (external_wp_element_["Platform"].OS !== 'web') {
return false;
}
var colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
return Object(external_lodash_["isObject"])(colorSupport) && !!colorSupport.gradients;
};
var color_hasBackgroundColorSupport = function hasBackgroundColorSupport(blockType) {
var colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
return colorSupport && colorSupport.background !== false;
};
var color_hasTextColorSupport = function hasTextColorSupport(blockType) {
var colorSupport = Object(external_wp_blocks_["getBlockSupport"])(blockType, COLOR_SUPPORT_KEY);
return colorSupport && colorSupport.text !== false;
};
/**
* Filters registered block settings, extending attributes to include
* `backgroundColor` and `textColor` attribute.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function addAttributes(settings) {
if (!color_hasColorSupport(settings)) {
return settings;
} // allow blocks to specify their own attribute definition with default values if needed.
if (!settings.attributes.backgroundColor) {
Object.assign(settings.attributes, {
backgroundColor: {
type: 'string'
}
});
}
if (!settings.attributes.textColor) {
Object.assign(settings.attributes, {
textColor: {
type: 'string'
}
});
}
if (color_hasGradientSupport(settings) && !settings.attributes.gradient) {
Object.assign(settings.attributes, {
gradient: {
type: 'string'
}
});
}
return settings;
}
/**
* Override props assigned to save component to inject colors classnames.
*
* @param {Object} props Additional props applied to save element
* @param {Object} blockType Block type
* @param {Object} attributes Block attributes
* @return {Object} Filtered props applied to save element
*/
function color_addSaveProps(props, blockType, attributes) {
var _style$color, _style$color2, _style$color3, _style$color4, _style$color5, _classnames;
if (!color_hasColorSupport(blockType)) {
return props;
}
var hasGradient = color_hasGradientSupport(blockType); // I'd have prefered to avoid the "style" attribute usage here
var backgroundColor = attributes.backgroundColor,
textColor = attributes.textColor,
gradient = attributes.gradient,
style = attributes.style;
var backgroundClass = getColorClassName('background-color', backgroundColor);
var gradientClass = __experimentalGetGradientClass(gradient);
var textClass = getColorClassName('color', textColor);
var newClassName = classnames_default()(props.className, textClass, gradientClass, (_classnames = {}, Object(defineProperty["a" /* default */])(_classnames, backgroundClass, (!hasGradient || !(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.gradient)) && !!backgroundClass), Object(defineProperty["a" /* default */])(_classnames, 'has-text-color', textColor || (style === null || style === void 0 ? void 0 : (_style$color2 = style.color) === null || _style$color2 === void 0 ? void 0 : _style$color2.text)), Object(defineProperty["a" /* default */])(_classnames, 'has-background', backgroundColor || (style === null || style === void 0 ? void 0 : (_style$color3 = style.color) === null || _style$color3 === void 0 ? void 0 : _style$color3.background) || hasGradient && (gradient || (style === null || style === void 0 ? void 0 : (_style$color4 = style.color) === null || _style$color4 === void 0 ? void 0 : _style$color4.gradient))), Object(defineProperty["a" /* default */])(_classnames, 'has-link-color', style === null || style === void 0 ? void 0 : (_style$color5 = style.color) === null || _style$color5 === void 0 ? void 0 : _style$color5.link), _classnames));
props.className = newClassName ? newClassName : undefined;
return props;
}
/**
* Filters registered block settings to extand the block edit wrapper
* to apply the desired styles and classnames properly.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function addEditProps(settings) {
if (!color_hasColorSupport(settings)) {
return settings;
}
var existingGetEditWrapperProps = settings.getEditWrapperProps;
settings.getEditWrapperProps = function (attributes) {
var props = {};
if (existingGetEditWrapperProps) {
props = existingGetEditWrapperProps(attributes);
}
return color_addSaveProps(props, settings, attributes);
};
return settings;
}
var color_getLinkColorFromAttributeValue = function getLinkColorFromAttributeValue(colors, value) {
var attributeParsed = /var:preset\|color\|(.+)/.exec(value);
if (attributeParsed && attributeParsed[1]) {
return utils_getColorObjectByAttributeValues(colors, attributeParsed[1]).color;
}
return value;
};
/**
* Inspector control panel containing the color related configuration
*
* @param {Object} props
*
* @return {WPElement} Color edit element.
*/
function ColorEdit(props) {
var _style$color7, _style$color8, _style$color9, _style$color10, _props$attributes$sty2, _props$attributes$sty3;
var blockName = props.name,
attributes = props.attributes;
var isLinkColorEnabled = useEditorFeature('color.link');
var colors = useEditorFeature('color.palette') || color_EMPTY_ARRAY;
var gradients = useEditorFeature('color.gradients') || color_EMPTY_ARRAY; // Shouldn't be needed but right now the ColorGradientsPanel
// can trigger both onChangeColor and onChangeBackground
// synchronously causing our two callbacks to override changes
// from each other.
var localAttributes = Object(external_wp_element_["useRef"])(attributes);
Object(external_wp_element_["useEffect"])(function () {
localAttributes.current = attributes;
}, [attributes]);
if (!color_hasColorSupport(blockName) || external_wp_element_["Platform"].OS !== 'web') {
return null;
}
var hasBackground = color_hasBackgroundColorSupport(blockName);
var hasGradient = color_hasGradientSupport(blockName);
var style = attributes.style,
textColor = attributes.textColor,
backgroundColor = attributes.backgroundColor,
gradient = attributes.gradient;
var gradientValue;
if (hasGradient && gradient) {
gradientValue = getGradientValueBySlug(gradients, gradient);
} else if (hasGradient) {
var _style$color6;
gradientValue = style === null || style === void 0 ? void 0 : (_style$color6 = style.color) === null || _style$color6 === void 0 ? void 0 : _style$color6.gradient;
}
var onChangeColor = function onChangeColor(name) {
return function (value) {
var _localAttributes$curr, _localAttributes$curr2;
var colorObject = utils_getColorObjectByColorValue(colors, value);
var attributeName = name + 'Color';
var newStyle = color_objectSpread(color_objectSpread({}, localAttributes.current.style), {}, {
color: color_objectSpread(color_objectSpread({}, (_localAttributes$curr = localAttributes.current) === null || _localAttributes$curr === void 0 ? void 0 : (_localAttributes$curr2 = _localAttributes$curr.style) === null || _localAttributes$curr2 === void 0 ? void 0 : _localAttributes$curr2.color), {}, Object(defineProperty["a" /* default */])({}, name, colorObject !== null && colorObject !== void 0 && colorObject.slug ? undefined : value))
});
var newNamedColor = colorObject !== null && colorObject !== void 0 && colorObject.slug ? colorObject.slug : undefined;
var newAttributes = Object(defineProperty["a" /* default */])({
style: utils_cleanEmptyObject(newStyle)
}, attributeName, newNamedColor);
props.setAttributes(newAttributes);
localAttributes.current = color_objectSpread(color_objectSpread({}, localAttributes.current), newAttributes);
};
};
var onChangeGradient = function onChangeGradient(value) {
var slug = getGradientSlugByValue(gradients, value);
var newAttributes;
if (slug) {
var _localAttributes$curr3, _localAttributes$curr4, _localAttributes$curr5;
var newStyle = color_objectSpread(color_objectSpread({}, (_localAttributes$curr3 = localAttributes.current) === null || _localAttributes$curr3 === void 0 ? void 0 : _localAttributes$curr3.style), {}, {
color: color_objectSpread(color_objectSpread({}, (_localAttributes$curr4 = localAttributes.current) === null || _localAttributes$curr4 === void 0 ? void 0 : (_localAttributes$curr5 = _localAttributes$curr4.style) === null || _localAttributes$curr5 === void 0 ? void 0 : _localAttributes$curr5.color), {}, {
gradient: undefined
})
});
newAttributes = {
style: utils_cleanEmptyObject(newStyle),
gradient: slug
};
} else {
var _localAttributes$curr6, _localAttributes$curr7, _localAttributes$curr8;
var _newStyle = color_objectSpread(color_objectSpread({}, (_localAttributes$curr6 = localAttributes.current) === null || _localAttributes$curr6 === void 0 ? void 0 : _localAttributes$curr6.style), {}, {
color: color_objectSpread(color_objectSpread({}, (_localAttributes$curr7 = localAttributes.current) === null || _localAttributes$curr7 === void 0 ? void 0 : (_localAttributes$curr8 = _localAttributes$curr7.style) === null || _localAttributes$curr8 === void 0 ? void 0 : _localAttributes$curr8.color), {}, {
gradient: value
})
});
newAttributes = {
style: utils_cleanEmptyObject(_newStyle),
gradient: undefined
};
}
props.setAttributes(newAttributes);
localAttributes.current = color_objectSpread(color_objectSpread({}, localAttributes.current), newAttributes);
};
var onChangeLinkColor = function onChangeLinkColor(value) {
var _props$attributes$sty;
var colorObject = utils_getColorObjectByColorValue(colors, value);
props.setAttributes({
style: color_objectSpread(color_objectSpread({}, props.attributes.style), {}, {
color: color_objectSpread(color_objectSpread({}, (_props$attributes$sty = props.attributes.style) === null || _props$attributes$sty === void 0 ? void 0 : _props$attributes$sty.color), {}, {
link: colorObject !== null && colorObject !== void 0 && colorObject.slug ? "var:preset|color|".concat(colorObject.slug) : value
})
})
});
};
return Object(external_wp_element_["createElement"])(ColorPanel, {
enableContrastChecking: // Turn on contrast checker for web only since it's not supported on mobile yet.
external_wp_element_["Platform"].OS === 'web' && !gradient && !(style !== null && style !== void 0 && (_style$color7 = style.color) !== null && _style$color7 !== void 0 && _style$color7.gradient),
clientId: props.clientId,
settings: [].concat(Object(toConsumableArray["a" /* default */])(color_hasTextColorSupport(blockName) ? [{
label: Object(external_wp_i18n_["__"])('Text Color'),
onColorChange: onChangeColor('text'),
colorValue: utils_getColorObjectByAttributeValues(colors, textColor, style === null || style === void 0 ? void 0 : (_style$color8 = style.color) === null || _style$color8 === void 0 ? void 0 : _style$color8.text).color
}] : []), Object(toConsumableArray["a" /* default */])(hasBackground || hasGradient ? [{
label: Object(external_wp_i18n_["__"])('Background Color'),
onColorChange: hasBackground ? onChangeColor('background') : undefined,
colorValue: utils_getColorObjectByAttributeValues(colors, backgroundColor, style === null || style === void 0 ? void 0 : (_style$color9 = style.color) === null || _style$color9 === void 0 ? void 0 : _style$color9.background).color,
gradientValue: gradientValue,
onGradientChange: hasGradient ? onChangeGradient : undefined
}] : []), Object(toConsumableArray["a" /* default */])(isLinkColorEnabled && color_hasLinkColorSupport(blockName) ? [{
label: Object(external_wp_i18n_["__"])('Link Color'),
onColorChange: onChangeLinkColor,
colorValue: color_getLinkColorFromAttributeValue(colors, style === null || style === void 0 ? void 0 : (_style$color10 = style.color) === null || _style$color10 === void 0 ? void 0 : _style$color10.link),
clearable: !!((_props$attributes$sty2 = props.attributes.style) !== null && _props$attributes$sty2 !== void 0 && (_props$attributes$sty3 = _props$attributes$sty2.color) !== null && _props$attributes$sty3 !== void 0 && _props$attributes$sty3.link)
}] : []))
});
}
/**
* This adds inline styles for color palette colors.
* Ideally, this is not needed and themes should load their palettes on the editor.
*
* @param {Function} BlockListBlock Original component
* @return {Function} Wrapped component
*/
var withColorPaletteStyles = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockListBlock) {
return function (props) {
var _getColorObjectByAttr, _getColorObjectByAttr2, _props$wrapperProps;
var name = props.name,
attributes = props.attributes;
var backgroundColor = attributes.backgroundColor,
textColor = attributes.textColor;
var colors = useEditorFeature('color.palette') || color_EMPTY_ARRAY;
if (!color_hasColorSupport(name)) {
return Object(external_wp_element_["createElement"])(BlockListBlock, props);
}
var extraStyles = {
color: textColor ? (_getColorObjectByAttr = utils_getColorObjectByAttributeValues(colors, textColor)) === null || _getColorObjectByAttr === void 0 ? void 0 : _getColorObjectByAttr.color : undefined,
backgroundColor: backgroundColor ? (_getColorObjectByAttr2 = utils_getColorObjectByAttributeValues(colors, backgroundColor)) === null || _getColorObjectByAttr2 === void 0 ? void 0 : _getColorObjectByAttr2.color : undefined
};
var wrapperProps = props.wrapperProps;
wrapperProps = color_objectSpread(color_objectSpread({}, props.wrapperProps), {}, {
style: color_objectSpread(color_objectSpread({}, extraStyles), (_props$wrapperProps = props.wrapperProps) === null || _props$wrapperProps === void 0 ? void 0 : _props$wrapperProps.style)
});
return Object(external_wp_element_["createElement"])(BlockListBlock, Object(esm_extends["a" /* default */])({}, props, {
wrapperProps: wrapperProps
}));
};
});
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/color/addAttribute', addAttributes);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/color/addSaveProps', color_addSaveProps);
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/color/addEditProps', addEditProps);
Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/color/with-color-palette-styles', withColorPaletteStyles);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-underline.js
/**
* WordPress dependencies
*/
var formatUnderline = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M7 18v1h10v-1H7zm5-2c1.5 0 2.6-.4 3.4-1.2.8-.8 1.1-2 1.1-3.5V5H15v5.8c0 1.2-.2 2.1-.6 2.8-.4.7-1.2 1-2.4 1s-2-.3-2.4-1c-.4-.7-.6-1.6-.6-2.8V5H7.5v6.2c0 1.5.4 2.7 1.1 3.5.8.9 1.9 1.3 3.4 1.3z"
}));
/* harmony default export */ var format_underline = (formatUnderline);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/format-strikethrough.js
var format_strikethrough = __webpack_require__(299);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-control/index.js
/**
* WordPress dependencies
*/
var TEXT_DECORATIONS = [{
name: Object(external_wp_i18n_["__"])('Underline'),
value: 'underline',
icon: format_underline
}, {
name: Object(external_wp_i18n_["__"])('Strikethrough'),
value: 'line-through',
icon: format_strikethrough["a" /* default */]
}];
/**
* Control to facilitate text decoration selections.
*
* @param {Object} props Component props.
* @param {string} props.value Currently selected text decoration.
* @param {Function} props.onChange Handles change in text decoration selection.
* @return {WPElement} Text decoration control.
*/
function TextDecorationControl(_ref) {
var value = _ref.value,
onChange = _ref.onChange;
return Object(external_wp_element_["createElement"])("fieldset", {
className: "block-editor-text-decoration-control"
}, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_i18n_["__"])('Decoration')), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-text-decoration-control__buttons"
}, TEXT_DECORATIONS.map(function (textDecoration) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
key: textDecoration.value,
icon: textDecoration.icon,
isSmall: true,
isPressed: textDecoration.value === value,
onClick: function onClick() {
return onChange(textDecoration.value === value ? undefined : textDecoration.value);
},
"aria-label": textDecoration.name
});
})));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-decoration.js
function text_decoration_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function text_decoration_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { text_decoration_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { text_decoration_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Key within block settings' supports array indicating support for text
* decorations e.g. settings found in `block.json`.
*/
var TEXT_DECORATION_SUPPORT_KEY = '__experimentalTextDecoration';
/**
* Inspector control panel containing the text decoration options.
*
* @param {Object} props Block properties.
* @return {WPElement} Text decoration edit element.
*/
function TextDecorationEdit(props) {
var _style$typography;
var style = props.attributes.style,
setAttributes = props.setAttributes;
var isDisabled = useIsTextDecorationDisabled(props);
if (isDisabled) {
return null;
}
function onChange(newDecoration) {
setAttributes({
style: utils_cleanEmptyObject(text_decoration_objectSpread(text_decoration_objectSpread({}, style), {}, {
typography: text_decoration_objectSpread(text_decoration_objectSpread({}, style === null || style === void 0 ? void 0 : style.typography), {}, {
textDecoration: newDecoration
})
}))
});
}
return Object(external_wp_element_["createElement"])(TextDecorationControl, {
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textDecoration,
onChange: onChange
});
}
/**
* Checks if text-decoration settings have been disabled.
*
* @param {string} name Name of the block.
* @return {boolean} Whether or not the setting is disabled.
*/
function useIsTextDecorationDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var notSupported = !Object(external_wp_blocks_["hasBlockSupport"])(blockName, TEXT_DECORATION_SUPPORT_KEY);
var hasTextDecoration = useEditorFeature('typography.customTextDecorations');
return notSupported || !hasTextDecoration;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-uppercase.js
/**
* WordPress dependencies
*/
var formatUppercase = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M6.1 6.8L2.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H6.1zm-.8 6.8L7 8.9l1.7 4.7H5.3zm15.1-.7c-.4-.5-.9-.8-1.6-1 .4-.2.7-.5.8-.9.2-.4.3-.9.3-1.4 0-.9-.3-1.6-.8-2-.6-.5-1.3-.7-2.4-.7h-3.5V18h4.2c1.1 0 2-.3 2.6-.8.6-.6 1-1.4 1-2.4-.1-.8-.3-1.4-.6-1.9zm-5.7-4.7h1.8c.6 0 1.1.1 1.4.4.3.2.5.7.5 1.3 0 .6-.2 1.1-.5 1.3-.3.2-.8.4-1.4.4h-1.8V8.2zm4 8c-.4.3-.9.5-1.5.5h-2.6v-3.8h2.6c1.4 0 2 .6 2 1.9.1.6-.1 1-.5 1.4z"
}));
/* harmony default export */ var format_uppercase = (formatUppercase);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-lowercase.js
/**
* WordPress dependencies
*/
var formatLowercase = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M10.8 16.8c-.1-.1-.2-.3-.3-.5v-2.6c0-.9-.1-1.7-.3-2.2-.2-.5-.5-.9-.9-1.1-.4-.3-.9-.4-1.6-.4-.5 0-1 .1-1.5.2s-.9.3-1.2.6l.3 1.2c.4-.3.7-.4 1.1-.5.3-.1.7-.2 1-.2.6 0 1 .1 1.3.4.3.2.4.7.4 1.4-1.2 0-2.3.2-3.3.7s-1.4 1.1-1.4 2.1c0 .7.2 1.2.7 1.6.4.4 1 .6 1.8.6.9 0 1.7-.4 2.4-1.2.1.3.2.5.4.7.1.2.3.3.6.4.3.1.6.1 1.1.1h.1l.2-1.2h-.1c-.5.1-.7 0-.8-.1zM9.1 16c-.2.3-.5.6-.9.8-.4.1-.7.2-1.1.2-.4 0-.7-.1-.9-.3-.2-.2-.3-.5-.3-.9 0-.6.2-1 .7-1.3.5-.3 1.3-.4 2.5-.5v2zm10.5-3.9c-.3-.6-.7-1.1-1.2-1.5-.5-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1 0-.6-.2-1.3-.5-1.9zm-1.6 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.5-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2s-.2 1.4-.6 2z"
}));
/* harmony default export */ var format_lowercase = (formatLowercase);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/format-capitalize.js
/**
* WordPress dependencies
*/
var formatCapitalize = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M7.1 6.8L3.1 18h1.6l1.1-3h4.3l1.1 3h1.6l-4-11.2H7.1zm-.8 6.8L8 8.9l1.7 4.7H6.3zm14.5-1.5c-.3-.6-.7-1.1-1.2-1.5-.6-.4-1.2-.6-1.9-.6-.5 0-.9.1-1.4.3-.4.2-.8.5-1.1.8V6h-1.4v12h1.3l.2-1c.2.4.6.6 1 .8.4.2.9.3 1.4.3.7 0 1.2-.2 1.8-.5.5-.4 1-.9 1.3-1.5.3-.6.5-1.3.5-2.1-.1-.6-.2-1.3-.5-1.9zm-1.7 4c-.4.5-.9.8-1.6.8s-1.2-.2-1.7-.7c-.4-.5-.7-1.2-.7-2.1 0-.9.2-1.6.7-2.1.4-.5 1-.7 1.7-.7s1.2.3 1.6.8c.4.5.6 1.2.6 2 .1.8-.2 1.4-.6 2z"
}));
/* harmony default export */ var format_capitalize = (formatCapitalize);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-transform-control/index.js
/**
* WordPress dependencies
*/
var TEXT_TRANSFORMS = [{
name: Object(external_wp_i18n_["__"])('Uppercase'),
value: 'uppercase',
icon: format_uppercase
}, {
name: Object(external_wp_i18n_["__"])('Lowercase'),
value: 'lowercase',
icon: format_lowercase
}, {
name: Object(external_wp_i18n_["__"])('Capitalize'),
value: 'capitalize',
icon: format_capitalize
}];
/**
* Control to facilitate text transform selections.
*
* @param {Object} props Component props.
* @param {string} props.value Currently selected text transform.
* @param {Function} props.onChange Handles change in text transform selection.
* @return {WPElement} Text transform control.
*/
function TextTransformControl(_ref) {
var value = _ref.value,
onChange = _ref.onChange;
return Object(external_wp_element_["createElement"])("fieldset", {
className: "block-editor-text-transform-control"
}, Object(external_wp_element_["createElement"])("legend", null, Object(external_wp_i18n_["__"])('Letter case')), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-text-transform-control__buttons"
}, TEXT_TRANSFORMS.map(function (textTransform) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
key: textTransform.value,
icon: textTransform.icon,
isSmall: true,
isPressed: value === textTransform.value,
"aria-label": textTransform.name,
onClick: function onClick() {
return onChange(value === textTransform.value ? undefined : textTransform.value);
}
});
})));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/text-transform.js
function text_transform_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function text_transform_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { text_transform_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { text_transform_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Key within block settings' supports array indicating support for text
* transforms e.g. settings found in `block.json`.
*/
var TEXT_TRANSFORM_SUPPORT_KEY = '__experimentalTextTransform';
/**
* Inspector control panel containing the text transform options.
*
* @param {Object} props Block properties.
* @return {WPElement} Text transform edit element.
*/
function TextTransformEdit(props) {
var _style$typography;
var style = props.attributes.style,
setAttributes = props.setAttributes;
var isDisabled = useIsTextTransformDisabled(props);
if (isDisabled) {
return null;
}
function onChange(newTransform) {
setAttributes({
style: utils_cleanEmptyObject(text_transform_objectSpread(text_transform_objectSpread({}, style), {}, {
typography: text_transform_objectSpread(text_transform_objectSpread({}, style === null || style === void 0 ? void 0 : style.typography), {}, {
textTransform: newTransform
})
}))
});
}
return Object(external_wp_element_["createElement"])(TextTransformControl, {
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.textTransform,
onChange: onChange
});
}
/**
* Checks if text-transform settings have been disabled.
*
* @param {string} name Name of the block.
* @return {boolean} Whether or not the setting is disabled.
*/
function useIsTextTransformDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var notSupported = !Object(external_wp_blocks_["hasBlockSupport"])(blockName, TEXT_TRANSFORM_SUPPORT_KEY);
var hasTextTransforms = useEditorFeature('typography.customTextTransforms');
return notSupported || !hasTextTransforms;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/text-decoration-and-transform/index.js
/**
* Internal dependencies
*/
/**
* Handles grouping related text decoration and text transform edit components
* so they can be laid out in a more flexible manner within the Typography
* InspectorControls panel.
*
* @param {Object} props Block props to be passed on to individual controls.
* @return {WPElement} Component containing text decoration or transform controls.
*/
function TextDecorationAndTransformEdit(props) {
var decorationAvailable = !useIsTextDecorationDisabled(props);
var transformAvailable = !useIsTextTransformDisabled(props);
if (!decorationAvailable && !transformAvailable) {
return null;
}
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-text-decoration-and-transform"
}, decorationAvailable && Object(external_wp_element_["createElement"])(TextDecorationEdit, props), transformAvailable && Object(external_wp_element_["createElement"])(TextTransformEdit, props));
}
// EXTERNAL MODULE: external ["wp","keycodes"]
var external_wp_keycodes_ = __webpack_require__(17);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/utils.js
var BASE_DEFAULT_VALUE = 1.5;
var STEP = 0.1;
/**
* There are varying value types within LineHeightControl:
*
* {undefined} Initial value. No changes from the user.
* {string} Input value. Value consumed/outputted by the input. Empty would be ''.
* {number} Block attribute type. Input value needs to be converted for attribute setting.
*
* Note: If the value is undefined, the input requires it to be an empty string ('')
* in order to be considered "controlled" by props (rather than internal state).
*/
var RESET_VALUE = '';
/**
* Determines if the lineHeight attribute has been properly defined.
*
* @param {any} lineHeight The value to check.
*
* @return {boolean} Whether the lineHeight attribute is valid.
*/
function isLineHeightDefined(lineHeight) {
return lineHeight !== undefined && lineHeight !== RESET_VALUE;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/line-height-control/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LineHeightControl(_ref) {
var lineHeight = _ref.value,
onChange = _ref.onChange;
var isDefined = isLineHeightDefined(lineHeight);
var handleOnKeyDown = function handleOnKeyDown(event) {
var keyCode = event.keyCode;
if (keyCode === external_wp_keycodes_["ZERO"] && !isDefined) {
/**
* Prevents the onChange callback from firing, which prevents
* the logic from assuming the change was triggered from
* an input arrow CLICK.
*/
event.preventDefault();
onChange('0');
}
};
var handleOnChange = function handleOnChange(nextValue) {
// Set the next value without modification if lineHeight has been defined
if (isDefined) {
onChange(nextValue);
return;
} // Otherwise...
/**
* The following logic handles the initial up/down arrow CLICK of the
* input element. This is so that the next values (from an undefined value state)
* are more better suited for line-height rendering.
*/
var adjustedNextValue = nextValue;
switch (nextValue) {
case "".concat(STEP):
// Increment by step value
adjustedNextValue = BASE_DEFAULT_VALUE + STEP;
break;
case '0':
// Decrement by step value
adjustedNextValue = BASE_DEFAULT_VALUE - STEP;
break;
}
onChange(adjustedNextValue);
};
var value = isDefined ? lineHeight : RESET_VALUE;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-line-height-control"
}, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
autoComplete: "off",
onKeyDown: handleOnKeyDown,
onChange: handleOnChange,
label: Object(external_wp_i18n_["__"])('Line height'),
placeholder: BASE_DEFAULT_VALUE,
step: STEP,
type: "number",
value: value,
min: 0
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/line-height.js
function line_height_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function line_height_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { line_height_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { line_height_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var LINE_HEIGHT_SUPPORT_KEY = 'lineHeight';
/**
* Inspector control panel containing the line height related configuration
*
* @param {Object} props
*
* @return {WPElement} Line height edit element.
*/
function LineHeightEdit(props) {
var _style$typography;
var style = props.attributes.style;
var isDisabled = useIsLineHeightDisabled(props);
if (isDisabled) {
return null;
}
var onChange = function onChange(newLineHeightValue) {
var newStyle = line_height_objectSpread(line_height_objectSpread({}, style), {}, {
typography: line_height_objectSpread(line_height_objectSpread({}, style === null || style === void 0 ? void 0 : style.typography), {}, {
lineHeight: newLineHeightValue
})
});
props.setAttributes({
style: utils_cleanEmptyObject(newStyle)
});
};
return Object(external_wp_element_["createElement"])(LineHeightControl, {
value: style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.lineHeight,
onChange: onChange
});
}
/**
* Custom hook that checks if line-height settings have been disabled.
*
* @param {string} name The name of the block.
* @return {boolean} Whether setting is disabled.
*/
function useIsLineHeightDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var isDisabled = !useEditorFeature('typography.customLineHeight');
return !Object(external_wp_blocks_["hasBlockSupport"])(blockName, LINE_HEIGHT_SUPPORT_KEY) || isDisabled;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-appearance-control/index.js
/**
* WordPress dependencies
*/
var FONT_STYLES = [{
name: Object(external_wp_i18n_["__"])('Regular'),
value: 'normal'
}, {
name: Object(external_wp_i18n_["__"])('Italic'),
value: 'italic'
}];
var FONT_WEIGHTS = [{
name: Object(external_wp_i18n_["__"])('Thin'),
value: '100'
}, {
name: Object(external_wp_i18n_["__"])('Extra Light'),
value: '200'
}, {
name: Object(external_wp_i18n_["__"])('Light'),
value: '300'
}, {
name: Object(external_wp_i18n_["__"])('Regular'),
value: '400'
}, {
name: Object(external_wp_i18n_["__"])('Medium'),
value: '500'
}, {
name: Object(external_wp_i18n_["__"])('Semi Bold'),
value: '600'
}, {
name: Object(external_wp_i18n_["__"])('Bold'),
value: '700'
}, {
name: Object(external_wp_i18n_["__"])('Extra Bold'),
value: '800'
}, {
name: Object(external_wp_i18n_["__"])('Black'),
value: '900'
}];
/**
* Control to display unified font style and weight options.
*
* @param {Object} props Component props.
* @return {WPElement} Font appearance control.
*/
function FontAppearanceControl(props) {
var _onChange = props.onChange,
_props$hasFontStyles = props.hasFontStyles,
hasFontStyles = _props$hasFontStyles === void 0 ? true : _props$hasFontStyles,
_props$hasFontWeights = props.hasFontWeights,
hasFontWeights = _props$hasFontWeights === void 0 ? true : _props$hasFontWeights,
_props$value = props.value,
fontStyle = _props$value.fontStyle,
fontWeight = _props$value.fontWeight;
var hasStylesOrWeights = hasFontStyles || hasFontWeights;
var defaultOption = {
key: 'default',
name: Object(external_wp_i18n_["__"])('Default'),
style: {
fontStyle: undefined,
fontWeight: undefined
}
}; // Combines both font style and weight options into a single dropdown.
var combineOptions = function combineOptions() {
var combinedOptions = [defaultOption];
FONT_STYLES.forEach(function (_ref) {
var styleName = _ref.name,
styleValue = _ref.value;
FONT_WEIGHTS.forEach(function (_ref2) {
var weightName = _ref2.name,
weightValue = _ref2.value;
var optionName = styleValue === 'normal' ? weightName : Object(external_wp_i18n_["sprintf"])(
/* translators: 1: Font weight name. 2: Font style name. */
Object(external_wp_i18n_["__"])('%1$s %2$s'), weightName, styleName);
combinedOptions.push({
key: "".concat(styleValue, "-").concat(weightValue),
name: optionName,
style: {
fontStyle: styleValue,
fontWeight: weightValue
}
});
});
});
return combinedOptions;
}; // Generates select options for font styles only.
var styleOptions = function styleOptions() {
var combinedOptions = [defaultOption];
FONT_STYLES.forEach(function (_ref3) {
var name = _ref3.name,
value = _ref3.value;
combinedOptions.push({
key: value,
name: name,
style: {
fontStyle: value,
fontWeight: undefined
}
});
});
return combinedOptions;
}; // Generates select options for font weights only.
var weightOptions = function weightOptions() {
var combinedOptions = [defaultOption];
FONT_WEIGHTS.forEach(function (_ref4) {
var name = _ref4.name,
value = _ref4.value;
combinedOptions.push({
key: value,
name: name,
style: {
fontStyle: undefined,
fontWeight: value
}
});
});
return combinedOptions;
}; // Map font styles and weights to select options.
var selectOptions = Object(external_wp_element_["useMemo"])(function () {
if (hasFontStyles && hasFontWeights) {
return combineOptions();
}
return hasFontStyles ? styleOptions() : weightOptions();
}, [props.options]); // Find current selection by comparing font style & weight against options.
var currentSelection = selectOptions.find(function (option) {
return option.style.fontStyle === fontStyle && option.style.fontWeight === fontWeight;
}); // Adjusts field label in case either styles or weights are disabled.
var getLabel = function getLabel() {
if (!hasFontStyles) {
return Object(external_wp_i18n_["__"])('Font weight');
}
if (!hasFontWeights) {
return Object(external_wp_i18n_["__"])('Font style');
}
return Object(external_wp_i18n_["__"])('Appearance');
};
return Object(external_wp_element_["createElement"])("fieldset", {
className: "components-font-appearance-control"
}, hasStylesOrWeights && Object(external_wp_element_["createElement"])(external_wp_components_["CustomSelectControl"], {
className: "components-font-appearance-control__select",
label: getLabel(),
options: selectOptions,
value: currentSelection,
onChange: function onChange(_ref5) {
var selectedItem = _ref5.selectedItem;
return _onChange(selectedItem.style);
}
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-appearance.js
function font_appearance_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function font_appearance_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { font_appearance_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { font_appearance_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Key within block settings' support array indicating support for font style.
*/
var FONT_STYLE_SUPPORT_KEY = '__experimentalFontStyle';
/**
* Key within block settings' support array indicating support for font weight.
*/
var FONT_WEIGHT_SUPPORT_KEY = '__experimentalFontWeight';
/**
* Inspector control panel containing the font appearance options.
*
* @param {Object} props Block properties.
* @return {WPElement} Font appearance edit element.
*/
function FontAppearanceEdit(props) {
var _style$typography, _style$typography2;
var style = props.attributes.style,
setAttributes = props.setAttributes;
var hasFontStyles = !useIsFontStyleDisabled(props);
var hasFontWeights = !useIsFontWeightDisabled(props);
if (!hasFontStyles && !hasFontWeights) {
return null;
}
var onChange = function onChange(newStyles) {
setAttributes({
style: utils_cleanEmptyObject(font_appearance_objectSpread(font_appearance_objectSpread({}, style), {}, {
typography: font_appearance_objectSpread(font_appearance_objectSpread({}, style === null || style === void 0 ? void 0 : style.typography), {}, {
fontStyle: newStyles.fontStyle,
fontWeight: newStyles.fontWeight
})
}))
});
};
var fontStyle = style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontStyle;
var fontWeight = style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontWeight;
return Object(external_wp_element_["createElement"])(FontAppearanceControl, {
onChange: onChange,
hasFontStyles: hasFontStyles,
hasFontWeights: hasFontWeights,
value: {
fontStyle: fontStyle,
fontWeight: fontWeight
}
});
}
/**
* Checks if font style support has been disabled either by not opting in for
* support or by failing to provide preset styles.
*
* @param {Object} props Block properties.
* @param {string} props.name Name for the block type.
* @return {boolean} Whether font style support has been disabled.
*/
function useIsFontStyleDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var styleSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_STYLE_SUPPORT_KEY);
var hasFontStyles = useEditorFeature('typography.customFontStyle');
return !styleSupport || !hasFontStyles;
}
/**
* Checks if font weight support has been disabled either by not opting in for
* support or by failing to provide preset weights.
*
* @param {Object} props Block properties.
* @param {string} props.name Name for the block type.
* @return {boolean} Whether font weight support has been disabled.
*/
function useIsFontWeightDisabled() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref2.name;
var weightSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_WEIGHT_SUPPORT_KEY);
var hasFontWeights = useEditorFeature('typography.customFontWeight');
return !weightSupport || !hasFontWeights;
}
/**
* Checks if font appearance support has been disabled.
*
* @param {Object} props Block properties.
* @return {boolean} Whether font appearance support has been disabled.
*/
function useIsFontAppearanceDisabled(props) {
var stylesDisabled = useIsFontStyleDisabled(props);
var weightsDisabled = useIsFontWeightDisabled(props);
return stylesDisabled && weightsDisabled;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-family/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function FontFamilyControl(_ref) {
var _ref$value = _ref.value,
value = _ref$value === void 0 ? '' : _ref$value,
onChange = _ref.onChange,
fontFamilies = _ref.fontFamilies,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["value", "onChange", "fontFamilies"]);
var blockLevelFontFamilies = useEditorFeature('typography.fontFamilies');
if (!fontFamilies) {
fontFamilies = blockLevelFontFamilies;
}
if (Object(external_lodash_["isEmpty"])(fontFamilies)) {
return null;
}
var options = [{
value: '',
label: Object(external_wp_i18n_["__"])('Default')
}].concat(Object(toConsumableArray["a" /* default */])(fontFamilies.map(function (_ref2) {
var fontFamily = _ref2.fontFamily,
name = _ref2.name;
return {
value: fontFamily,
label: name || fontFamily
};
})));
return Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], Object(esm_extends["a" /* default */])({
label: Object(external_wp_i18n_["__"])('Font family'),
options: options,
value: value,
onChange: onChange,
labelPosition: "top"
}, props));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-family.js
function font_family_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function font_family_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { font_family_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { font_family_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var FONT_FAMILY_SUPPORT_KEY = '__experimentalFontFamily';
var font_family_getFontFamilyFromAttributeValue = function getFontFamilyFromAttributeValue(fontFamilies, value) {
var attributeParsed = /var:preset\|font-family\|(.+)/.exec(value);
if (attributeParsed && attributeParsed[1]) {
var fontFamilyObject = Object(external_lodash_["find"])(fontFamilies, function (_ref) {
var slug = _ref.slug;
return slug === attributeParsed[1];
});
if (fontFamilyObject) {
return fontFamilyObject.fontFamily;
}
}
return value;
};
function FontFamilyEdit(_ref2) {
var _style$typography;
var name = _ref2.name,
setAttributes = _ref2.setAttributes,
_ref2$attributes$styl = _ref2.attributes.style,
style = _ref2$attributes$styl === void 0 ? {} : _ref2$attributes$styl;
var fontFamilies = useEditorFeature('typography.fontFamilies');
var isDisable = useIsFontFamilyDisabled({
name: name
});
if (isDisable) {
return null;
}
var value = font_family_getFontFamilyFromAttributeValue(fontFamilies, (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontFamily);
function onChange(newValue) {
var predefinedFontFamily = Object(external_lodash_["find"])(fontFamilies, function (_ref3) {
var fontFamily = _ref3.fontFamily;
return fontFamily === newValue;
});
setAttributes({
style: utils_cleanEmptyObject(font_family_objectSpread(font_family_objectSpread({}, style), {}, {
typography: font_family_objectSpread(font_family_objectSpread({}, style.typography || {}), {}, {
fontFamily: predefinedFontFamily ? "var:preset|font-family|".concat(predefinedFontFamily.slug) : newValue || undefined
})
}))
});
}
return Object(external_wp_element_["createElement"])(FontFamilyControl, {
className: "block-editor-hooks-font-family-control",
fontFamilies: fontFamilies,
value: value,
onChange: onChange
});
}
/**
* Custom hook that checks if font-family functionality is disabled.
*
* @param {string} name The name of the block.
* @return {boolean} Whether setting is disabled.
*/
function useIsFontFamilyDisabled(_ref4) {
var name = _ref4.name;
var fontFamilies = useEditorFeature('typography.fontFamilies');
return !fontFamilies || fontFamilies.length === 0 || !Object(external_wp_blocks_["hasBlockSupport"])(name, FONT_FAMILY_SUPPORT_KEY);
}
// EXTERNAL MODULE: external ["wp","tokenList"]
var external_wp_tokenList_ = __webpack_require__(155);
var external_wp_tokenList_default = /*#__PURE__*/__webpack_require__.n(external_wp_tokenList_);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/utils.js
/**
* External dependencies
*/
/**
* Returns the font size object based on an array of named font sizes and the namedFontSize and customFontSize values.
* If namedFontSize is undefined or not found in fontSizes an object with just the size value based on customFontSize is returned.
*
* @param {Array} fontSizes Array of font size objects containing at least the "name" and "size" values as properties.
* @param {?string} fontSizeAttribute Content of the font size attribute (slug).
* @param {?number} customFontSizeAttribute Contents of the custom font size attribute (value).
*
* @return {?Object} If fontSizeAttribute is set and an equal slug is found in fontSizes it returns the font size object for that slug.
* Otherwise, an object with just the size value based on customFontSize is returned.
*/
var utils_getFontSize = function getFontSize(fontSizes, fontSizeAttribute, customFontSizeAttribute) {
if (fontSizeAttribute) {
var fontSizeObject = Object(external_lodash_["find"])(fontSizes, {
slug: fontSizeAttribute
});
if (fontSizeObject) {
return fontSizeObject;
}
}
return {
size: customFontSizeAttribute
};
};
/**
* Returns the corresponding font size object for a given value.
*
* @param {Array} fontSizes Array of font size objects.
* @param {number} value Font size value.
*
* @return {Object} Font size object.
*/
function getFontSizeObjectByValue(fontSizes, value) {
var fontSizeObject = Object(external_lodash_["find"])(fontSizes, {
size: value
});
if (fontSizeObject) {
return fontSizeObject;
}
return {
size: value
};
}
/**
* Returns a class based on fontSizeName.
*
* @param {string} fontSizeSlug Slug of the fontSize.
*
* @return {string} String with the class corresponding to the fontSize passed.
* The class is generated by appending 'has-' followed by fontSizeSlug in kebabCase and ending with '-font-size'.
*/
function getFontSizeClass(fontSizeSlug) {
if (!fontSizeSlug) {
return;
}
return "has-".concat(Object(external_lodash_["kebabCase"])(fontSizeSlug), "-font-size");
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/font-size-picker.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function FontSizePicker(props) {
var fontSizes = useEditorFeature('typography.fontSizes');
var disableCustomFontSizes = !useEditorFeature('typography.customFontSize');
return Object(external_wp_element_["createElement"])(external_wp_components_["FontSizePicker"], Object(esm_extends["a" /* default */])({}, props, {
fontSizes: fontSizes,
disableCustomFontSizes: disableCustomFontSizes
}));
}
/* harmony default export */ var font_size_picker = (FontSizePicker);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/font-size.js
function font_size_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function font_size_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { font_size_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { font_size_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var FONT_SIZE_SUPPORT_KEY = 'fontSize';
/**
* Filters registered block settings, extending attributes to include
* `fontSize` and `fontWeight` attributes.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function font_size_addAttributes(settings) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(settings, FONT_SIZE_SUPPORT_KEY)) {
return settings;
} // Allow blocks to specify a default value if needed.
if (!settings.attributes.fontSize) {
Object.assign(settings.attributes, {
fontSize: {
type: 'string'
}
});
}
return settings;
}
/**
* Override props assigned to save component to inject font size.
*
* @param {Object} props Additional props applied to save element
* @param {Object} blockType Block type
* @param {Object} attributes Block attributes
* @return {Object} Filtered props applied to save element
*/
function font_size_addSaveProps(props, blockType, attributes) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, FONT_SIZE_SUPPORT_KEY)) {
return props;
} // Use TokenList to dedupe classes.
var classes = new external_wp_tokenList_default.a(props.className);
classes.add(getFontSizeClass(attributes.fontSize));
var newClassName = classes.value;
props.className = newClassName ? newClassName : undefined;
return props;
}
/**
* Filters registered block settings to expand the block edit wrapper
* by applying the desired styles and classnames.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function font_size_addEditProps(settings) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(settings, FONT_SIZE_SUPPORT_KEY)) {
return settings;
}
var existingGetEditWrapperProps = settings.getEditWrapperProps;
settings.getEditWrapperProps = function (attributes) {
var props = {};
if (existingGetEditWrapperProps) {
props = existingGetEditWrapperProps(attributes);
}
return font_size_addSaveProps(props, settings, attributes);
};
return settings;
}
/**
* Inspector control panel containing the font size related configuration
*
* @param {Object} props
*
* @return {WPElement} Font size edit element.
*/
function FontSizeEdit(props) {
var _style$typography, _style$typography2;
var _props$attributes = props.attributes,
fontSize = _props$attributes.fontSize,
style = _props$attributes.style,
setAttributes = props.setAttributes;
var isDisabled = useIsFontSizeDisabled(props);
var fontSizes = useEditorFeature('typography.fontSizes');
var onChange = function onChange(value) {
var fontSizeSlug = getFontSizeObjectByValue(fontSizes, value).slug;
setAttributes({
style: utils_cleanEmptyObject(font_size_objectSpread(font_size_objectSpread({}, style), {}, {
typography: font_size_objectSpread(font_size_objectSpread({}, style === null || style === void 0 ? void 0 : style.typography), {}, {
fontSize: fontSizeSlug ? undefined : value
})
})),
fontSize: fontSizeSlug
});
};
if (isDisabled) {
return null;
}
var fontSizeObject = utils_getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography = style.typography) === null || _style$typography === void 0 ? void 0 : _style$typography.fontSize);
var fontSizeValue = (fontSizeObject === null || fontSizeObject === void 0 ? void 0 : fontSizeObject.size) || (style === null || style === void 0 ? void 0 : (_style$typography2 = style.typography) === null || _style$typography2 === void 0 ? void 0 : _style$typography2.fontSize) || fontSize;
return Object(external_wp_element_["createElement"])(font_size_picker, {
onChange: onChange,
value: fontSizeValue
});
}
/**
* Custom hook that checks if font-size settings have been disabled.
*
* @param {string} name The name of the block.
* @return {boolean} Whether setting is disabled.
*/
function useIsFontSizeDisabled() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
blockName = _ref.name;
var fontSizes = useEditorFeature('typography.fontSizes');
var hasFontSizes = !!(fontSizes !== null && fontSizes !== void 0 && fontSizes.length);
return !Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_SIZE_SUPPORT_KEY) || !hasFontSizes;
}
/**
* Add inline styles for font sizes.
* Ideally, this is not needed and themes load the font-size classes on the
* editor.
*
* @param {Function} BlockListBlock Original component
* @return {Function} Wrapped component
*/
var withFontSizeInlineStyles = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockListBlock) {
return function (props) {
var _style$typography3;
var fontSizes = useEditorFeature('typography.fontSizes');
var blockName = props.name,
_props$attributes2 = props.attributes,
fontSize = _props$attributes2.fontSize,
style = _props$attributes2.style,
wrapperProps = props.wrapperProps;
var newProps = font_size_objectSpread({}, props); // Only add inline styles if the block supports font sizes, doesn't
// already have an inline font size, and does have a class to extract
// the font size from.
if (Object(external_wp_blocks_["hasBlockSupport"])(blockName, FONT_SIZE_SUPPORT_KEY) && fontSize && !(style !== null && style !== void 0 && (_style$typography3 = style.typography) !== null && _style$typography3 !== void 0 && _style$typography3.fontSize)) {
var _style$typography4;
var fontSizeValue = utils_getFontSize(fontSizes, fontSize, style === null || style === void 0 ? void 0 : (_style$typography4 = style.typography) === null || _style$typography4 === void 0 ? void 0 : _style$typography4.fontSize).size;
newProps.wrapperProps = font_size_objectSpread(font_size_objectSpread({}, wrapperProps), {}, {
style: font_size_objectSpread({
fontSize: fontSizeValue
}, wrapperProps === null || wrapperProps === void 0 ? void 0 : wrapperProps.style)
});
}
return Object(external_wp_element_["createElement"])(BlockListBlock, newProps);
};
}, 'withFontSizeInlineStyles');
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/font/addAttribute', font_size_addAttributes);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/font/addSaveProps', font_size_addSaveProps);
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/font/addEditProps', font_size_addEditProps);
Object(external_wp_hooks_["addFilter"])('editor.BlockListBlock', 'core/font-size/with-font-size-inline-styles', withFontSizeInlineStyles);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/typography.js
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
/**
* Internal dependencies
*/
var TYPOGRAPHY_SUPPORT_KEYS = [LINE_HEIGHT_SUPPORT_KEY, FONT_SIZE_SUPPORT_KEY, FONT_STYLE_SUPPORT_KEY, FONT_WEIGHT_SUPPORT_KEY, FONT_FAMILY_SUPPORT_KEY, TEXT_DECORATION_SUPPORT_KEY, TEXT_TRANSFORM_SUPPORT_KEY];
function TypographyPanel(props) {
var isDisabled = useIsTypographyDisabled(props);
var isSupported = typography_hasTypographySupport(props.name);
if (isDisabled || !isSupported) return null;
return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Typography')
}, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComponentSystemProvider"], {
__unstableNextInclude: ['WPComponentsFontSizePicker']
}, Object(external_wp_element_["createElement"])(FontFamilyEdit, props), Object(external_wp_element_["createElement"])(FontSizeEdit, props), Object(external_wp_element_["createElement"])(FontAppearanceEdit, props), Object(external_wp_element_["createElement"])(LineHeightEdit, props), Object(external_wp_element_["createElement"])(TextDecorationAndTransformEdit, props))));
}
var typography_hasTypographySupport = function hasTypographySupport(blockName) {
return external_wp_element_["Platform"].OS === 'web' && TYPOGRAPHY_SUPPORT_KEYS.some(function (key) {
return Object(external_wp_blocks_["hasBlockSupport"])(blockName, key);
});
};
function useIsTypographyDisabled() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var configs = [useIsFontAppearanceDisabled(props), useIsFontSizeDisabled(props), useIsLineHeightDisabled(props), useIsFontFamilyDisabled(props), useIsTextDecorationDisabled(props), useIsTextTransformDisabled(props)];
return configs.filter(Boolean).length === configs.length;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/unit-control/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function UnitControl(_ref) {
var unitsProp = _ref.units,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["units"]);
var units = useCustomUnits(unitsProp);
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalUnitControl"], Object(esm_extends["a" /* default */])({
units: units
}, props));
}
/**
* Filters available units based on values defined by settings.
*
* @param {Array} settings Collection of preferred units.
* @param {Array} units Collection of available units.
*
* @return {Array} Filtered units based on settings.
*/
function filterUnitsWithSettings() {
var settings = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var units = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return units.filter(function (unit) {
return settings.includes(unit.value);
});
}
/**
* Custom hook to retrieve and consolidate units setting from add_theme_support().
*
* @param {Array} units Collection of available units.
*
* @return {Array} Filtered units based on settings.
*/
function useCustomUnits(units) {
var availableUnits = useEditorFeature('spacing.units');
var usedUnits = filterUnitsWithSettings(!availableUnits ? [] : availableUnits, units);
return usedUnits.length === 0 ? false : usedUnits;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/padding.js
function padding_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function padding_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { padding_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { padding_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var SPACING_SUPPORT_KEY = 'spacing';
var padding_hasPaddingSupport = function hasPaddingSupport(blockName) {
var spacingSupport = Object(external_wp_blocks_["getBlockSupport"])(blockName, SPACING_SUPPORT_KEY);
return spacingSupport && spacingSupport.padding !== false;
};
/**
* Inspector control panel containing the padding related configuration
*
* @param {Object} props
*
* @return {WPElement} Padding edit element.
*/
function PaddingEdit(props) {
var _style$spacing;
var blockName = props.name,
style = props.attributes.style,
setAttributes = props.setAttributes;
var units = useCustomUnits();
if (!padding_hasPaddingSupport(blockName)) {
return null;
}
var onChange = function onChange(next) {
var newStyle = padding_objectSpread(padding_objectSpread({}, style), {}, {
spacing: {
padding: next
}
});
setAttributes({
style: utils_cleanEmptyObject(newStyle)
});
};
var onChangeShowVisualizer = function onChangeShowVisualizer(next) {
var newStyle = padding_objectSpread(padding_objectSpread({}, style), {}, {
visualizers: {
padding: next
}
});
setAttributes({
style: utils_cleanEmptyObject(newStyle)
});
};
return external_wp_element_["Platform"].select({
web: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalBoxControl"], {
values: style === null || style === void 0 ? void 0 : (_style$spacing = style.spacing) === null || _style$spacing === void 0 ? void 0 : _style$spacing.padding,
onChange: onChange,
onChangeShowVisualizer: onChangeShowVisualizer,
label: Object(external_wp_i18n_["__"])('Padding'),
units: units
})),
native: null
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/spacing-panel-control/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function SpacingPanelControl(_ref) {
var children = _ref.children,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["children"]);
var isSpacingEnabled = useEditorFeature('spacing.customPadding');
if (!isSpacingEnabled) return null;
return Object(external_wp_element_["createElement"])(inspector_controls, props, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Spacing')
}, children));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/style.js
function style_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function style_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { style_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { style_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var styleSupportKeys = [].concat(Object(toConsumableArray["a" /* default */])(TYPOGRAPHY_SUPPORT_KEYS), [BORDER_SUPPORT_KEY, COLOR_SUPPORT_KEY, SPACING_SUPPORT_KEY]);
var style_hasStyleSupport = function hasStyleSupport(blockType) {
return styleSupportKeys.some(function (key) {
return Object(external_wp_blocks_["hasBlockSupport"])(blockType, key);
});
};
var VARIABLE_REFERENCE_PREFIX = 'var:';
var VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE = '|';
var VARIABLE_PATH_SEPARATOR_TOKEN_STYLE = '--';
function compileStyleValue(uncompiledValue) {
if (Object(external_lodash_["startsWith"])(uncompiledValue, VARIABLE_REFERENCE_PREFIX)) {
var variable = uncompiledValue.slice(VARIABLE_REFERENCE_PREFIX.length).split(VARIABLE_PATH_SEPARATOR_TOKEN_ATTRIBUTE).join(VARIABLE_PATH_SEPARATOR_TOKEN_STYLE);
return "var(--wp--".concat(variable, ")");
}
return uncompiledValue;
}
/**
* Returns the inline styles to add depending on the style object
*
* @param {Object} styles Styles configuration
* @return {Object} Flattened CSS variables declaration
*/
function getInlineStyles() {
var styles = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var output = {};
Object.keys(external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"]).forEach(function (propKey) {
var path = external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"][propKey].value;
var subPaths = external_wp_blocks_["__EXPERIMENTAL_STYLE_PROPERTY"][propKey].properties;
if (Object(external_lodash_["has"])(styles, path)) {
if (!!subPaths) {
subPaths.forEach(function (suffix) {
output[propKey + Object(external_lodash_["capitalize"])(suffix)] = compileStyleValue(Object(external_lodash_["get"])(styles, [].concat(Object(toConsumableArray["a" /* default */])(path), [suffix])));
});
} else {
output[propKey] = compileStyleValue(Object(external_lodash_["get"])(styles, path));
}
}
});
return output;
}
/**
* Filters registered block settings, extending attributes to include `style` attribute.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function style_addAttribute(settings) {
if (!style_hasStyleSupport(settings)) {
return settings;
} // allow blocks to specify their own attribute definition with default values if needed.
if (!settings.attributes.style) {
Object.assign(settings.attributes, {
style: {
type: 'object'
}
});
}
return settings;
}
/**
* Override props assigned to save component to inject the CSS variables definition.
*
* @param {Object} props Additional props applied to save element
* @param {Object} blockType Block type
* @param {Object} attributes Block attributes
* @return {Object} Filtered props applied to save element
*/
function style_addSaveProps(props, blockType, attributes) {
if (!style_hasStyleSupport(blockType)) {
return props;
}
var style = attributes.style;
props.style = style_objectSpread(style_objectSpread({}, getInlineStyles(style)), props.style);
return props;
}
/**
* Filters registered block settings to extand the block edit wrapper
* to apply the desired styles and classnames properly.
*
* @param {Object} settings Original block settings
* @return {Object} Filtered block settings
*/
function style_addEditProps(settings) {
if (!style_hasStyleSupport(settings)) {
return settings;
}
var existingGetEditWrapperProps = settings.getEditWrapperProps;
settings.getEditWrapperProps = function (attributes) {
var props = {};
if (existingGetEditWrapperProps) {
props = existingGetEditWrapperProps(attributes);
}
return style_addSaveProps(props, settings, attributes);
};
return settings;
}
/**
* Override the default edit UI to include new inspector controls for
* all the custom styles configs.
*
* @param {Function} BlockEdit Original component
* @return {Function} Wrapped component
*/
var withBlockControls = Object(external_wp_compose_["createHigherOrderComponent"])(function (BlockEdit) {
return function (props) {
var blockName = props.name;
var hasSpacingSupport = Object(external_wp_blocks_["hasBlockSupport"])(blockName, SPACING_SUPPORT_KEY);
return [Object(external_wp_element_["createElement"])(TypographyPanel, Object(esm_extends["a" /* default */])({
key: "typography"
}, props)), Object(external_wp_element_["createElement"])(BorderPanel, Object(esm_extends["a" /* default */])({
key: "border"
}, props)), Object(external_wp_element_["createElement"])(ColorEdit, Object(esm_extends["a" /* default */])({
key: "colors"
}, props)), Object(external_wp_element_["createElement"])(BlockEdit, Object(esm_extends["a" /* default */])({
key: "edit"
}, props)), hasSpacingSupport && Object(external_wp_element_["createElement"])(SpacingPanelControl, {
key: "spacing"
}, Object(external_wp_element_["createElement"])(PaddingEdit, props))];
};
}, 'withToolbarControls');
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/style/addAttribute', style_addAttribute);
Object(external_wp_hooks_["addFilter"])('blocks.getSaveContent.extraProps', 'core/style/addSaveProps', style_addSaveProps);
Object(external_wp_hooks_["addFilter"])('blocks.registerBlockType', 'core/style/addEditProps', style_addEditProps);
Object(external_wp_hooks_["addFilter"])('editor.BlockEdit', 'core/style/with-block-controls', withBlockControls);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/hooks/index.js
/**
* Internal dependencies
*/
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
var classCallCheck = __webpack_require__(25);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
var createClass = __webpack_require__(26);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
var assertThisInitialized = __webpack_require__(18);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
var inherits = __webpack_require__(28);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
var possibleConstructorReturn = __webpack_require__(29);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
var getPrototypeOf = __webpack_require__(19);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/with-colors.js
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
function with_colors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function with_colors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { with_colors_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { with_colors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var DEFAULT_COLORS = [];
/**
* Higher order component factory for injecting the `colorsArray` argument as
* the colors prop in the `withCustomColors` HOC.
*
* @param {Array} colorsArray An array of color objects.
*
* @return {Function} The higher order component.
*/
var with_colors_withCustomColorPalette = function withCustomColorPalette(colorsArray) {
return Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return function (props) {
return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
colors: colorsArray
}));
};
}, 'withCustomColorPalette');
};
/**
* Higher order component factory for injecting the editor colors as the
* `colors` prop in the `withColors` HOC.
*
* @return {Function} The higher order component.
*/
var with_colors_withEditorColorPalette = function withEditorColorPalette() {
return Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return function (props) {
var colors = useEditorFeature('color.palette') || DEFAULT_COLORS;
return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
colors: colors
}));
};
}, 'withEditorColorPalette');
};
/**
* Helper function used with `createHigherOrderComponent` to create
* higher order components for managing color logic.
*
* @param {Array} colorTypes An array of color types (e.g. 'backgroundColor, borderColor).
* @param {Function} withColorPalette A HOC for injecting the 'colors' prop into the WrappedComponent.
*
* @return {WPComponent} The component that can be used as a HOC.
*/
function createColorHOC(colorTypes, withColorPalette) {
var colorMap = Object(external_lodash_["reduce"])(colorTypes, function (colorObject, colorType) {
return with_colors_objectSpread(with_colors_objectSpread({}, colorObject), Object(external_lodash_["isString"])(colorType) ? Object(defineProperty["a" /* default */])({}, colorType, Object(external_lodash_["kebabCase"])(colorType)) : colorType);
}, {});
return Object(external_wp_compose_["compose"])([withColorPalette, function (WrappedComponent) {
return /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(_class, _Component);
var _super = _createSuper(_class);
function _class(props) {
var _this;
Object(classCallCheck["a" /* default */])(this, _class);
_this = _super.call(this, props);
_this.setters = _this.createSetters();
_this.colorUtils = {
getMostReadableColor: _this.getMostReadableColor.bind(Object(assertThisInitialized["a" /* default */])(_this))
};
_this.state = {};
return _this;
}
Object(createClass["a" /* default */])(_class, [{
key: "getMostReadableColor",
value: function getMostReadableColor(colorValue) {
var colors = this.props.colors;
return utils_getMostReadableColor(colors, colorValue);
}
}, {
key: "createSetters",
value: function createSetters() {
var _this2 = this;
return Object(external_lodash_["reduce"])(colorMap, function (settersAccumulator, colorContext, colorAttributeName) {
var upperFirstColorAttributeName = Object(external_lodash_["upperFirst"])(colorAttributeName);
var customColorAttributeName = "custom".concat(upperFirstColorAttributeName);
settersAccumulator["set".concat(upperFirstColorAttributeName)] = _this2.createSetColor(colorAttributeName, customColorAttributeName);
return settersAccumulator;
}, {});
}
}, {
key: "createSetColor",
value: function createSetColor(colorAttributeName, customColorAttributeName) {
var _this3 = this;
return function (colorValue) {
var _this3$props$setAttri;
var colorObject = utils_getColorObjectByColorValue(_this3.props.colors, colorValue);
_this3.props.setAttributes((_this3$props$setAttri = {}, Object(defineProperty["a" /* default */])(_this3$props$setAttri, colorAttributeName, colorObject && colorObject.slug ? colorObject.slug : undefined), Object(defineProperty["a" /* default */])(_this3$props$setAttri, customColorAttributeName, colorObject && colorObject.slug ? undefined : colorValue), _this3$props$setAttri));
};
}
}, {
key: "render",
value: function render() {
return Object(external_wp_element_["createElement"])(WrappedComponent, with_colors_objectSpread(with_colors_objectSpread(with_colors_objectSpread(with_colors_objectSpread({}, this.props), {}, {
colors: undefined
}, this.state), this.setters), {}, {
colorUtils: this.colorUtils
}));
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(_ref2, previousState) {
var attributes = _ref2.attributes,
colors = _ref2.colors;
return Object(external_lodash_["reduce"])(colorMap, function (newState, colorContext, colorAttributeName) {
var colorObject = utils_getColorObjectByAttributeValues(colors, attributes[colorAttributeName], attributes["custom".concat(Object(external_lodash_["upperFirst"])(colorAttributeName))]);
var previousColorObject = previousState[colorAttributeName];
var previousColor = previousColorObject === null || previousColorObject === void 0 ? void 0 : previousColorObject.color;
/**
* The "and previousColorObject" condition checks that a previous color object was already computed.
* At the start previousColorObject and colorValue are both equal to undefined
* bus as previousColorObject does not exist we should compute the object.
*/
if (previousColor === colorObject.color && previousColorObject) {
newState[colorAttributeName] = previousColorObject;
} else {
newState[colorAttributeName] = with_colors_objectSpread(with_colors_objectSpread({}, colorObject), {}, {
class: getColorClassName(colorContext, colorObject.slug)
});
}
return newState;
}, {});
}
}]);
return _class;
}(external_wp_element_["Component"]);
}]);
}
/**
* A higher-order component factory for creating a 'withCustomColors' HOC, which handles color logic
* for class generation color value, retrieval and color attribute setting.
*
* Use this higher-order component to work with a custom set of colors.
*
* @example
*
* ```jsx
* const CUSTOM_COLORS = [ { name: 'Red', slug: 'red', color: '#ff0000' }, { name: 'Blue', slug: 'blue', color: '#0000ff' } ];
* const withCustomColors = createCustomColorsHOC( CUSTOM_COLORS );
* // ...
* export default compose(
* withCustomColors( 'backgroundColor', 'borderColor' ),
* MyColorfulComponent,
* );
* ```
*
* @param {Array} colorsArray The array of color objects (name, slug, color, etc... ).
*
* @return {Function} Higher-order component.
*/
function createCustomColorsHOC(colorsArray) {
return function () {
var withColorPalette = with_colors_withCustomColorPalette(colorsArray);
for (var _len = arguments.length, colorTypes = new Array(_len), _key = 0; _key < _len; _key++) {
colorTypes[_key] = arguments[_key];
}
return Object(external_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withCustomColors');
};
}
/**
* A higher-order component, which handles color logic for class generation color value, retrieval and color attribute setting.
*
* For use with the default editor/theme color palette.
*
* @example
*
* ```jsx
* export default compose(
* withColors( 'backgroundColor', { textColor: 'color' } ),
* MyColorfulComponent,
* );
* ```
*
* @param {...(Object|string)} colorTypes The arguments can be strings or objects. If the argument is an object,
* it should contain the color attribute name as key and the color context as value.
* If the argument is a string the value should be the color attribute name,
* the color context is computed by applying a kebab case transform to the value.
* Color context represents the context/place where the color is going to be used.
* The class name of the color is generated using 'has' followed by the color name
* and ending with the color context all in kebab case e.g: has-green-background-color.
*
* @return {Function} Higher-order component.
*/
function withColors() {
var withColorPalette = with_colors_withEditorColorPalette();
for (var _len2 = arguments.length, colorTypes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
colorTypes[_key2] = arguments[_key2];
}
return Object(external_wp_compose_["createHigherOrderComponent"])(createColorHOC(colorTypes, withColorPalette), 'withColors');
}
// EXTERNAL MODULE: ./node_modules/memize/index.js
var memize = __webpack_require__(71);
var memize_default = /*#__PURE__*/__webpack_require__.n(memize);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/panel-color-settings/index.js
function panel_color_settings_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function panel_color_settings_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { panel_color_settings_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { panel_color_settings_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* Internal dependencies
*/
var panel_color_settings_PanelColorSettings = function PanelColorSettings(_ref) {
var colorSettings = _ref.colorSettings,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["colorSettings"]);
var settings = colorSettings.map(function (_ref2) {
var value = _ref2.value,
onChange = _ref2.onChange,
otherSettings = Object(objectWithoutProperties["a" /* default */])(_ref2, ["value", "onChange"]);
return panel_color_settings_objectSpread(panel_color_settings_objectSpread({}, otherSettings), {}, {
colorValue: value,
onColorChange: onChange
});
});
return Object(external_wp_element_["createElement"])(panel_color_gradient_settings, Object(esm_extends["a" /* default */])({
settings: settings,
gradients: [],
disableCustomGradients: true
}, props));
};
/* harmony default export */ var panel_color_settings = (panel_color_settings_PanelColorSettings);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/color-panel.js
/**
* External dependencies
*/
/**
* Internal dependencies
*/
var resolveContrastCheckerColor = function resolveContrastCheckerColor(color, colorSettings, detectedColor) {
if (typeof color === 'function') {
return color(colorSettings);
} else if (color === true) {
return detectedColor;
}
return color;
};
function color_panel_ColorPanel(_ref) {
var title = _ref.title,
colorSettings = _ref.colorSettings,
colorPanelProps = _ref.colorPanelProps,
contrastCheckers = _ref.contrastCheckers,
detectedBackgroundColor = _ref.detectedBackgroundColor,
detectedColor = _ref.detectedColor,
panelChildren = _ref.panelChildren,
initialOpen = _ref.initialOpen;
return Object(external_wp_element_["createElement"])(panel_color_settings, Object(esm_extends["a" /* default */])({
title: title,
initialOpen: initialOpen,
colorSettings: Object.values(colorSettings)
}, colorPanelProps), contrastCheckers && (Array.isArray(contrastCheckers) ? contrastCheckers.map(function (_ref2) {
var backgroundColor = _ref2.backgroundColor,
textColor = _ref2.textColor,
rest = Object(objectWithoutProperties["a" /* default */])(_ref2, ["backgroundColor", "textColor"]);
backgroundColor = resolveContrastCheckerColor(backgroundColor, colorSettings, detectedBackgroundColor);
textColor = resolveContrastCheckerColor(textColor, colorSettings, detectedColor);
return Object(external_wp_element_["createElement"])(contrast_checker, Object(esm_extends["a" /* default */])({
key: "".concat(backgroundColor, "-").concat(textColor),
backgroundColor: backgroundColor,
textColor: textColor
}, rest));
}) : Object(external_lodash_["map"])(colorSettings, function (_ref3) {
var value = _ref3.value;
var backgroundColor = contrastCheckers.backgroundColor,
textColor = contrastCheckers.textColor;
backgroundColor = resolveContrastCheckerColor(backgroundColor || value, colorSettings, detectedBackgroundColor);
textColor = resolveContrastCheckerColor(textColor || value, colorSettings, detectedColor);
return Object(external_wp_element_["createElement"])(contrast_checker, Object(esm_extends["a" /* default */])({}, contrastCheckers, {
key: "".concat(backgroundColor, "-").concat(textColor),
backgroundColor: backgroundColor,
textColor: textColor
}));
})), typeof panelChildren === 'function' ? panelChildren(colorSettings) : panelChildren);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/use-colors.js
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function use_colors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function use_colors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_colors_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_colors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function use_colors_getComputedStyle(node) {
return node.ownerDocument.defaultView.getComputedStyle(node);
}
var use_colors_DEFAULT_COLORS = [];
var COMMON_COLOR_LABELS = {
textColor: Object(external_wp_i18n_["__"])('Text Color'),
backgroundColor: Object(external_wp_i18n_["__"])('Background Color')
};
var use_colors_InspectorControlsColorPanel = function InspectorControlsColorPanel(props) {
return Object(external_wp_element_["createElement"])(inspector_controls, null, Object(external_wp_element_["createElement"])(color_panel_ColorPanel, props));
};
function __experimentalUseColors(colorConfigs) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
panelTitle: Object(external_wp_i18n_["__"])('Color settings')
},
_ref$panelTitle = _ref.panelTitle,
panelTitle = _ref$panelTitle === void 0 ? Object(external_wp_i18n_["__"])('Color settings') : _ref$panelTitle,
colorPanelProps = _ref.colorPanelProps,
contrastCheckers = _ref.contrastCheckers,
panelChildren = _ref.panelChildren,
_ref$colorDetector = _ref.colorDetector;
_ref$colorDetector = _ref$colorDetector === void 0 ? {} : _ref$colorDetector;
var targetRef = _ref$colorDetector.targetRef,
_ref$colorDetector$ba = _ref$colorDetector.backgroundColorTargetRef,
backgroundColorTargetRef = _ref$colorDetector$ba === void 0 ? targetRef : _ref$colorDetector$ba,
_ref$colorDetector$te = _ref$colorDetector.textColorTargetRef,
textColorTargetRef = _ref$colorDetector$te === void 0 ? targetRef : _ref$colorDetector$te;
var deps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var _useBlockEditContext = useBlockEditContext(),
clientId = _useBlockEditContext.clientId;
var settingsColors = useEditorFeature('color.palette') || use_colors_DEFAULT_COLORS;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockAttributes = _select.getBlockAttributes;
return {
attributes: getBlockAttributes(clientId)
};
}, [clientId]),
attributes = _useSelect.attributes;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlockAttributes = _useDispatch.updateBlockAttributes;
var setAttributes = Object(external_wp_element_["useCallback"])(function (newAttributes) {
return updateBlockAttributes(clientId, newAttributes);
}, [updateBlockAttributes, clientId]);
var createComponent = Object(external_wp_element_["useMemo"])(function () {
return memize_default()(function (name, property, className, color, colorValue, customColor) {
return function (_ref2) {
var _classnames;
var children = _ref2.children,
_ref2$className = _ref2.className,
componentClassName = _ref2$className === void 0 ? '' : _ref2$className,
_ref2$style = _ref2.style,
componentStyle = _ref2$style === void 0 ? {} : _ref2$style;
var colorStyle = {};
if (color) {
colorStyle = Object(defineProperty["a" /* default */])({}, property, colorValue);
} else if (customColor) {
colorStyle = Object(defineProperty["a" /* default */])({}, property, customColor);
}
var extraProps = {
className: classnames_default()(componentClassName, (_classnames = {}, Object(defineProperty["a" /* default */])(_classnames, "has-".concat(Object(external_lodash_["kebabCase"])(color), "-").concat(Object(external_lodash_["kebabCase"])(property)), color), Object(defineProperty["a" /* default */])(_classnames, className || "has-".concat(Object(external_lodash_["kebabCase"])(name)), color || customColor), _classnames)),
style: use_colors_objectSpread(use_colors_objectSpread({}, colorStyle), componentStyle)
};
if (Object(external_lodash_["isFunction"])(children)) {
return children(extraProps);
}
return (// Clone children, setting the style property from the color configuration,
// if not already set explicitly through props.
external_wp_element_["Children"].map(children, function (child) {
return Object(external_wp_element_["cloneElement"])(child, {
className: classnames_default()(child.props.className, extraProps.className),
style: use_colors_objectSpread(use_colors_objectSpread({}, extraProps.style), child.props.style || {})
});
})
);
};
}, {
maxSize: colorConfigs.length
});
}, [colorConfigs.length]);
var createSetColor = Object(external_wp_element_["useMemo"])(function () {
return memize_default()(function (name, colors) {
return function (newColor) {
var color = colors.find(function (_color) {
return _color.color === newColor;
});
setAttributes(Object(defineProperty["a" /* default */])({}, color ? Object(external_lodash_["camelCase"])("custom ".concat(name)) : name, undefined));
setAttributes(Object(defineProperty["a" /* default */])({}, color ? name : Object(external_lodash_["camelCase"])("custom ".concat(name)), color ? color.slug : newColor));
};
}, {
maxSize: colorConfigs.length
});
}, [setAttributes, colorConfigs.length]);
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
detectedBackgroundColor = _useState2[0],
setDetectedBackgroundColor = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
detectedColor = _useState4[0],
setDetectedColor = _useState4[1];
Object(external_wp_element_["useEffect"])(function () {
if (!contrastCheckers) {
return undefined;
}
var needsBackgroundColor = false;
var needsColor = false;
var _iterator = _createForOfIteratorHelper(Object(external_lodash_["castArray"])(contrastCheckers)),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var _step$value = _step.value,
_backgroundColor = _step$value.backgroundColor,
textColor = _step$value.textColor;
if (!needsBackgroundColor) {
needsBackgroundColor = _backgroundColor === true;
}
if (!needsColor) {
needsColor = textColor === true;
}
if (needsBackgroundColor && needsColor) {
break;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (needsColor) {
setDetectedColor(use_colors_getComputedStyle(textColorTargetRef.current).color);
}
if (needsBackgroundColor) {
var backgroundColorNode = backgroundColorTargetRef.current;
var backgroundColor = use_colors_getComputedStyle(backgroundColorNode).backgroundColor;
while (backgroundColor === 'rgba(0, 0, 0, 0)' && backgroundColorNode.parentNode && backgroundColorNode.parentNode.nodeType === backgroundColorNode.parentNode.ELEMENT_NODE) {
backgroundColorNode = backgroundColorNode.parentNode;
backgroundColor = use_colors_getComputedStyle(backgroundColorNode).backgroundColor;
}
setDetectedBackgroundColor(backgroundColor);
}
}, [colorConfigs.reduce(function (acc, colorConfig) {
return "".concat(acc, " | ").concat(attributes[colorConfig.name], " | ").concat(attributes[Object(external_lodash_["camelCase"])("custom ".concat(colorConfig.name))]);
}, '')].concat(Object(toConsumableArray["a" /* default */])(deps)));
return Object(external_wp_element_["useMemo"])(function () {
var colorSettings = {};
var components = colorConfigs.reduce(function (acc, colorConfig) {
if (typeof colorConfig === 'string') {
colorConfig = {
name: colorConfig
};
}
var _colorConfig$color = use_colors_objectSpread(use_colors_objectSpread({}, colorConfig), {}, {
color: attributes[colorConfig.name]
}),
name = _colorConfig$color.name,
_colorConfig$color$pr = _colorConfig$color.property,
property = _colorConfig$color$pr === void 0 ? name : _colorConfig$color$pr,
className = _colorConfig$color.className,
_colorConfig$color$pa = _colorConfig$color.panelLabel,
panelLabel = _colorConfig$color$pa === void 0 ? colorConfig.label || COMMON_COLOR_LABELS[name] || Object(external_lodash_["startCase"])(name) : _colorConfig$color$pa,
_colorConfig$color$co = _colorConfig$color.componentName,
componentName = _colorConfig$color$co === void 0 ? Object(external_lodash_["startCase"])(name).replace(/\s/g, '') : _colorConfig$color$co,
_colorConfig$color$co2 = _colorConfig$color.color,
color = _colorConfig$color$co2 === void 0 ? colorConfig.color : _colorConfig$color$co2,
_colorConfig$color$co3 = _colorConfig$color.colors,
colors = _colorConfig$color$co3 === void 0 ? settingsColors : _colorConfig$color$co3;
var customColor = attributes[Object(external_lodash_["camelCase"])("custom ".concat(name))]; // We memoize the non-primitives to avoid unnecessary updates
// when they are used as props for other components.
var _color = customColor ? undefined : colors.find(function (__color) {
return __color.slug === color;
});
acc[componentName] = createComponent(name, property, className, color, _color && _color.color, customColor);
acc[componentName].displayName = componentName;
acc[componentName].color = customColor ? customColor : _color && _color.color;
acc[componentName].slug = color;
acc[componentName].setColor = createSetColor(name, colors);
colorSettings[componentName] = {
value: _color ? _color.color : attributes[Object(external_lodash_["camelCase"])("custom ".concat(name))],
onChange: acc[componentName].setColor,
label: panelLabel,
colors: colors
}; // These settings will be spread over the `colors` in
// `colorPanelProps`, so we need to unset the key here,
// if not set to an actual value, to avoid overwriting
// an actual value in `colorPanelProps`.
if (!colors) {
delete colorSettings[componentName].colors;
}
return acc;
}, {});
var wrappedColorPanelProps = {
title: panelTitle,
initialOpen: false,
colorSettings: colorSettings,
colorPanelProps: colorPanelProps,
contrastCheckers: contrastCheckers,
detectedBackgroundColor: detectedBackgroundColor,
detectedColor: detectedColor,
panelChildren: panelChildren
};
return use_colors_objectSpread(use_colors_objectSpread({}, components), {}, {
ColorPanel: Object(external_wp_element_["createElement"])(color_panel_ColorPanel, wrappedColorPanelProps),
InspectorControlsColorPanel: Object(external_wp_element_["createElement"])(use_colors_InspectorControlsColorPanel, wrappedColorPanelProps)
});
}, [attributes, setAttributes, detectedColor, detectedBackgroundColor].concat(Object(toConsumableArray["a" /* default */])(deps)));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/colors/index.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradients/index.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/with-font-sizes.js
function with_font_sizes_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function with_font_sizes_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { with_font_sizes_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { with_font_sizes_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function with_font_sizes_createSuper(Derived) { var hasNativeReflectConstruct = with_font_sizes_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function with_font_sizes_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var DEFAULT_FONT_SIZES = [];
/**
* Higher-order component, which handles font size logic for class generation,
* font size value retrieval, and font size change handling.
*
* @param {...(Object|string)} fontSizeNames The arguments should all be strings.
* Each string contains the font size
* attribute name e.g: 'fontSize'.
*
* @return {Function} Higher-order component.
*/
/* harmony default export */ var with_font_sizes = (function () {
for (var _len = arguments.length, fontSizeNames = new Array(_len), _key = 0; _key < _len; _key++) {
fontSizeNames[_key] = arguments[_key];
}
/*
* Computes an object whose key is the font size attribute name as passed in the array,
* and the value is the custom font size attribute name.
* Custom font size is automatically compted by appending custom followed by the font size attribute name in with the first letter capitalized.
*/
var fontSizeAttributeNames = Object(external_lodash_["reduce"])(fontSizeNames, function (fontSizeAttributeNamesAccumulator, fontSizeAttributeName) {
fontSizeAttributeNamesAccumulator[fontSizeAttributeName] = "custom".concat(Object(external_lodash_["upperFirst"])(fontSizeAttributeName));
return fontSizeAttributeNamesAccumulator;
}, {});
return Object(external_wp_compose_["createHigherOrderComponent"])(Object(external_wp_compose_["compose"])([Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return function (props) {
var fontSizes = useEditorFeature('typography.fontSizes') || DEFAULT_FONT_SIZES;
return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
fontSizes: fontSizes
}));
};
}, 'withFontSizes'), function (WrappedComponent) {
return /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(_class, _Component);
var _super = with_font_sizes_createSuper(_class);
function _class(props) {
var _this;
Object(classCallCheck["a" /* default */])(this, _class);
_this = _super.call(this, props);
_this.setters = _this.createSetters();
_this.state = {};
return _this;
}
Object(createClass["a" /* default */])(_class, [{
key: "createSetters",
value: function createSetters() {
var _this2 = this;
return Object(external_lodash_["reduce"])(fontSizeAttributeNames, function (settersAccumulator, customFontSizeAttributeName, fontSizeAttributeName) {
var upperFirstFontSizeAttributeName = Object(external_lodash_["upperFirst"])(fontSizeAttributeName);
settersAccumulator["set".concat(upperFirstFontSizeAttributeName)] = _this2.createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName);
return settersAccumulator;
}, {});
}
}, {
key: "createSetFontSize",
value: function createSetFontSize(fontSizeAttributeName, customFontSizeAttributeName) {
var _this3 = this;
return function (fontSizeValue) {
var _this3$props$setAttri;
var fontSizeObject = Object(external_lodash_["find"])(_this3.props.fontSizes, {
size: Number(fontSizeValue)
});
_this3.props.setAttributes((_this3$props$setAttri = {}, Object(defineProperty["a" /* default */])(_this3$props$setAttri, fontSizeAttributeName, fontSizeObject && fontSizeObject.slug ? fontSizeObject.slug : undefined), Object(defineProperty["a" /* default */])(_this3$props$setAttri, customFontSizeAttributeName, fontSizeObject && fontSizeObject.slug ? undefined : fontSizeValue), _this3$props$setAttri));
};
}
}, {
key: "render",
value: function render() {
return Object(external_wp_element_["createElement"])(WrappedComponent, with_font_sizes_objectSpread(with_font_sizes_objectSpread(with_font_sizes_objectSpread({}, this.props), {}, {
fontSizes: undefined
}, this.state), this.setters));
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(_ref, previousState) {
var attributes = _ref.attributes,
fontSizes = _ref.fontSizes;
var didAttributesChange = function didAttributesChange(customFontSizeAttributeName, fontSizeAttributeName) {
if (previousState[fontSizeAttributeName]) {
// if new font size is name compare with the previous slug
if (attributes[fontSizeAttributeName]) {
return attributes[fontSizeAttributeName] !== previousState[fontSizeAttributeName].slug;
} // if font size is not named, update when the font size value changes.
return previousState[fontSizeAttributeName].size !== attributes[customFontSizeAttributeName];
} // in this case we need to build the font size object
return true;
};
if (!Object(external_lodash_["some"])(fontSizeAttributeNames, didAttributesChange)) {
return null;
}
var newState = Object(external_lodash_["reduce"])(Object(external_lodash_["pickBy"])(fontSizeAttributeNames, didAttributesChange), function (newStateAccumulator, customFontSizeAttributeName, fontSizeAttributeName) {
var fontSizeAttributeValue = attributes[fontSizeAttributeName];
var fontSizeObject = utils_getFontSize(fontSizes, fontSizeAttributeValue, attributes[customFontSizeAttributeName]);
newStateAccumulator[fontSizeAttributeName] = with_font_sizes_objectSpread(with_font_sizes_objectSpread({}, fontSizeObject), {}, {
class: getFontSizeClass(fontSizeAttributeValue)
});
return newStateAccumulator;
}, {});
return with_font_sizes_objectSpread(with_font_sizes_objectSpread({}, previousState), newState);
}
}]);
return _class;
}(external_wp_element_["Component"]);
}]), 'withFontSizes');
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/index.js
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-left.js
var align_left = __webpack_require__(300);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-center.js
var align_center = __webpack_require__(301);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/align-right.js
var align_right = __webpack_require__(302);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/alignment-toolbar/index.js
function alignment_toolbar_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function alignment_toolbar_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { alignment_toolbar_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { alignment_toolbar_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var DEFAULT_ALIGNMENT_CONTROLS = [{
icon: align_left["a" /* default */],
title: Object(external_wp_i18n_["__"])('Align text left'),
align: 'left'
}, {
icon: align_center["a" /* default */],
title: Object(external_wp_i18n_["__"])('Align text center'),
align: 'center'
}, {
icon: align_right["a" /* default */],
title: Object(external_wp_i18n_["__"])('Align text right'),
align: 'right'
}];
var alignment_toolbar_POPOVER_PROPS = {
position: 'bottom right',
isAlternate: true
};
function AlignmentToolbar(props) {
var value = props.value,
onChange = props.onChange,
_props$alignmentContr = props.alignmentControls,
alignmentControls = _props$alignmentContr === void 0 ? DEFAULT_ALIGNMENT_CONTROLS : _props$alignmentContr,
_props$label = props.label,
label = _props$label === void 0 ? Object(external_wp_i18n_["__"])('Align') : _props$label,
_props$describedBy = props.describedBy,
describedBy = _props$describedBy === void 0 ? Object(external_wp_i18n_["__"])('Change text alignment') : _props$describedBy,
_props$isCollapsed = props.isCollapsed,
isCollapsed = _props$isCollapsed === void 0 ? true : _props$isCollapsed;
function applyOrUnset(align) {
return function () {
return onChange(value === align ? undefined : align);
};
}
var activeAlignment = Object(external_lodash_["find"])(alignmentControls, function (control) {
return control.align === value;
});
function setIcon() {
if (activeAlignment) return activeAlignment.icon;
return Object(external_wp_i18n_["isRTL"])() ? align_right["a" /* default */] : align_left["a" /* default */];
}
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
isCollapsed: isCollapsed,
icon: setIcon(),
label: label,
toggleProps: {
describedBy: describedBy
},
popoverProps: alignment_toolbar_POPOVER_PROPS,
controls: alignmentControls.map(function (control) {
var align = control.align;
var isActive = value === align;
return alignment_toolbar_objectSpread(alignment_toolbar_objectSpread({}, control), {}, {
isActive: isActive,
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: applyOrUnset(align)
});
})
});
}
/* harmony default export */ var alignment_toolbar = (AlignmentToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-items.js
/**
* External dependencies
*/
// Default search helpers
var defaultGetName = function defaultGetName(item) {
return item.name || '';
};
var defaultGetTitle = function defaultGetTitle(item) {
return item.title;
};
var defaultGetDescription = function defaultGetDescription(item) {
return item.description || '';
};
var defaultGetKeywords = function defaultGetKeywords(item) {
return item.keywords || [];
};
var defaultGetCategory = function defaultGetCategory(item) {
return item.category;
};
var defaultGetCollection = function defaultGetCollection() {
return null;
};
/**
* Sanitizes the search input string.
*
* @param {string} input The search input to normalize.
*
* @return {string} The normalized search input.
*/
function normalizeSearchInput() {
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
// Disregard diacritics.
// Input: "média"
input = Object(external_lodash_["deburr"])(input); // Accommodate leading slash, matching autocomplete expectations.
// Input: "/media"
input = input.replace(/^\//, ''); // Lowercase.
// Input: "MEDIA"
input = input.toLowerCase();
return input;
}
/**
* Converts the search term into a list of normalized terms.
*
* @param {string} input The search term to normalize.
*
* @return {string[]} The normalized list of search terms.
*/
var search_items_getNormalizedSearchTerms = function getNormalizedSearchTerms() {
var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
// Extract words.
return Object(external_lodash_["words"])(normalizeSearchInput(input));
};
var search_items_removeMatchingTerms = function removeMatchingTerms(unmatchedTerms, unprocessedTerms) {
return Object(external_lodash_["differenceWith"])(unmatchedTerms, search_items_getNormalizedSearchTerms(unprocessedTerms), function (unmatchedTerm, unprocessedTerm) {
return unprocessedTerm.includes(unmatchedTerm);
});
};
var search_items_searchBlockItems = function searchBlockItems(items, categories, collections, searchInput) {
var normalizedSearchTerms = search_items_getNormalizedSearchTerms(searchInput);
if (normalizedSearchTerms.length === 0) {
return items;
}
var config = {
getCategory: function getCategory(item) {
var _find;
return (_find = Object(external_lodash_["find"])(categories, {
slug: item.category
})) === null || _find === void 0 ? void 0 : _find.title;
},
getCollection: function getCollection(item) {
var _collections$item$nam;
return (_collections$item$nam = collections[item.name.split('/')[0]]) === null || _collections$item$nam === void 0 ? void 0 : _collections$item$nam.title;
}
};
return search_items_searchItems(items, searchInput, config);
};
/**
* Filters an item list given a search term.
*
* @param {Array} items Item list
* @param {string} searchInput Search input.
* @param {Object} config Search Config.
* @return {Array} Filtered item list.
*/
var search_items_searchItems = function searchItems() {
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var searchInput = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var normalizedSearchTerms = search_items_getNormalizedSearchTerms(searchInput);
if (normalizedSearchTerms.length === 0) {
return items;
}
var rankedItems = items.map(function (item) {
return [item, getItemSearchRank(item, searchInput, config)];
}).filter(function (_ref) {
var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 2),
rank = _ref2[1];
return rank > 0;
});
rankedItems.sort(function (_ref3, _ref4) {
var _ref5 = Object(slicedToArray["a" /* default */])(_ref3, 2),
rank1 = _ref5[1];
var _ref6 = Object(slicedToArray["a" /* default */])(_ref4, 2),
rank2 = _ref6[1];
return rank2 - rank1;
});
return rankedItems.map(function (_ref7) {
var _ref8 = Object(slicedToArray["a" /* default */])(_ref7, 1),
item = _ref8[0];
return item;
});
};
/**
* Get the search rank for a given item and a specific search term.
* The better the match, the higher the rank.
* If the rank equals 0, it should be excluded from the results.
*
* @param {Object} item Item to filter.
* @param {string} searchTerm Search term.
* @param {Object} config Search Config.
* @return {number} Search Rank.
*/
function getItemSearchRank(item, searchTerm) {
var config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var _config$getName = config.getName,
getName = _config$getName === void 0 ? defaultGetName : _config$getName,
_config$getTitle = config.getTitle,
getTitle = _config$getTitle === void 0 ? defaultGetTitle : _config$getTitle,
_config$getDescriptio = config.getDescription,
getDescription = _config$getDescriptio === void 0 ? defaultGetDescription : _config$getDescriptio,
_config$getKeywords = config.getKeywords,
getKeywords = _config$getKeywords === void 0 ? defaultGetKeywords : _config$getKeywords,
_config$getCategory = config.getCategory,
getCategory = _config$getCategory === void 0 ? defaultGetCategory : _config$getCategory,
_config$getCollection = config.getCollection,
getCollection = _config$getCollection === void 0 ? defaultGetCollection : _config$getCollection;
var name = getName(item);
var title = getTitle(item);
var description = getDescription(item);
var keywords = getKeywords(item);
var category = getCategory(item);
var collection = getCollection(item);
var normalizedSearchInput = normalizeSearchInput(searchTerm);
var normalizedTitle = normalizeSearchInput(title);
var rank = 0; // Prefers exact matches
// Then prefers if the beginning of the title matches the search term
// name, keywords, categories, collection, variations match come later.
if (normalizedSearchInput === normalizedTitle) {
rank += 30;
} else if (normalizedTitle.startsWith(normalizedSearchInput)) {
rank += 20;
} else {
var terms = [name, title, description].concat(Object(toConsumableArray["a" /* default */])(keywords), [category, collection]).join(' ');
var normalizedSearchTerms = Object(external_lodash_["words"])(normalizedSearchInput);
var unmatchedTerms = search_items_removeMatchingTerms(normalizedSearchTerms, terms);
if (unmatchedTerms.length === 0) {
rank += 10;
}
} // Give a better rank to "core" namespaced items.
if (rank !== 0 && name.startsWith('core/')) {
rank++;
}
return rank;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-block-types-state.js
/**
* WordPress dependencies
*/
/**
* Retrieves the block types inserter state.
*
* @param {string=} rootClientId Insertion's root client ID.
* @param {Function} onInsert function called when inserter a list of blocks.
* @return {Array} Returns the block types state. (block types, categories, collections, onSelect handler)
*/
var use_block_types_state_useBlockTypesState = function useBlockTypesState(rootClientId, onInsert) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getInserterItems = _select.getInserterItems;
var _select2 = select(external_wp_blocks_["store"]),
getCategories = _select2.getCategories,
getCollections = _select2.getCollections;
return {
categories: getCategories(),
collections: getCollections(),
items: getInserterItems(rootClientId)
};
}, [rootClientId]),
categories = _useSelect.categories,
collections = _useSelect.collections,
items = _useSelect.items;
var onSelectItem = Object(external_wp_element_["useCallback"])(function (_ref) {
var name = _ref.name,
initialAttributes = _ref.initialAttributes,
innerBlocks = _ref.innerBlocks;
var insertedBlock = Object(external_wp_blocks_["createBlock"])(name, initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(innerBlocks));
onInsert(insertedBlock);
}, [onInsert]);
return [items, categories, collections, onSelectItem];
};
/* harmony default export */ var use_block_types_state = (use_block_types_state_useBlockTypesState);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/block-default.js
var block_default = __webpack_require__(213);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-icon/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function BlockIcon(_ref) {
var _icon;
var icon = _ref.icon,
_ref$showColors = _ref.showColors,
showColors = _ref$showColors === void 0 ? false : _ref$showColors,
className = _ref.className;
if (((_icon = icon) === null || _icon === void 0 ? void 0 : _icon.src) === 'block-default') {
icon = {
src: block_default["a" /* default */]
};
}
var renderedIcon = Object(external_wp_element_["createElement"])(external_wp_components_["Icon"], {
icon: icon && icon.src ? icon.src : icon
});
var style = showColors ? {
backgroundColor: icon && icon.background,
color: icon && icon.foreground
} : {};
return Object(external_wp_element_["createElement"])("span", {
style: style,
className: classnames_default()('block-editor-block-icon', className, {
'has-colors': showColors
})
}, renderedIcon);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/autocompleters/block.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var SHOWN_BLOCK_TYPES = 9;
/** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
/**
* Creates a blocks repeater for replacing the current block with a selected block type.
*
* @return {WPCompleter} A blocks completer.
*/
function createBlockCompleter() {
return {
name: 'blocks',
className: 'block-editor-autocompleters__block',
triggerPrefix: '/',
useItems: function useItems(filterValue) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getBlockName = _select.getBlockName,
getBlockInsertionPoint = _select.getBlockInsertionPoint;
var selectedBlockClientId = getSelectedBlockClientId();
return {
selectedBlockName: selectedBlockClientId ? getBlockName(selectedBlockClientId) : null,
rootClientId: getBlockInsertionPoint().rootClientId
};
}, []),
rootClientId = _useSelect.rootClientId,
selectedBlockName = _useSelect.selectedBlockName;
var _useBlockTypesState = use_block_types_state(rootClientId, external_lodash_["noop"]),
_useBlockTypesState2 = Object(slicedToArray["a" /* default */])(_useBlockTypesState, 3),
items = _useBlockTypesState2[0],
categories = _useBlockTypesState2[1],
collections = _useBlockTypesState2[2];
var filteredItems = Object(external_wp_element_["useMemo"])(function () {
var initialFilteredItems = !!filterValue.trim() ? search_items_searchBlockItems(items, categories, collections, filterValue) : Object(external_lodash_["orderBy"])(items, ['frecency'], ['desc']);
return initialFilteredItems.filter(function (item) {
return item.name !== selectedBlockName;
}).slice(0, SHOWN_BLOCK_TYPES);
}, [filterValue, selectedBlockName, items, categories, collections]);
var options = Object(external_wp_element_["useMemo"])(function () {
return filteredItems.map(function (blockItem) {
var title = blockItem.title,
icon = blockItem.icon,
isDisabled = blockItem.isDisabled;
return {
key: "block-".concat(blockItem.id),
value: blockItem,
label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
key: "icon",
icon: icon,
showColors: true
}), title),
isDisabled: isDisabled
};
});
}, [filteredItems]);
return [options];
},
allowContext: function allowContext(before, after) {
return !(/\S/.test(before) || /\S/.test(after));
},
getOptionCompletion: function getOptionCompletion(inserterItem) {
var name = inserterItem.name,
initialAttributes = inserterItem.initialAttributes,
innerBlocks = inserterItem.innerBlocks;
return {
action: 'replace',
value: Object(external_wp_blocks_["createBlock"])(name, initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(innerBlocks))
};
}
};
}
/**
* Creates a blocks repeater for replacing the current block with a selected block type.
*
* @return {WPCompleter} A blocks completer.
*/
/* harmony default export */ var autocompleters_block = (createBlockCompleter());
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/autocomplete/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Shared reference to an empty array for cases where it is important to avoid
* returning a new array reference on every invocation.
*
* @type {Array}
*/
var autocomplete_EMPTY_ARRAY = [];
/**
* Wrap the default Autocomplete component with one that supports a filter hook
* for customizing its list of autocompleters.
*
* @type {import('react').FC}
*/
function BlockEditorAutocomplete(props) {
var _useBlockEditContext = useBlockEditContext(),
name = _useBlockEditContext.name;
var _props$completers = props.completers,
completers = _props$completers === void 0 ? autocomplete_EMPTY_ARRAY : _props$completers;
completers = Object(external_wp_element_["useMemo"])(function () {
var filteredCompleters = completers;
if (name === Object(external_wp_blocks_["getDefaultBlockName"])()) {
filteredCompleters = filteredCompleters.concat([autocompleters_block]);
}
if (Object(external_wp_hooks_["hasFilter"])('editor.Autocomplete.completers')) {
// Provide copies so filters may directly modify them.
if (filteredCompleters === completers) {
filteredCompleters = filteredCompleters.map(external_lodash_["clone"]);
}
filteredCompleters = Object(external_wp_hooks_["applyFilters"])('editor.Autocomplete.completers', filteredCompleters, name);
}
return filteredCompleters;
}, [completers, name]);
return Object(external_wp_element_["createElement"])(external_wp_components_["Autocomplete"], Object(esm_extends["a" /* default */])({}, props, {
completers: completers
}));
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/autocomplete/README.md
*/
/* harmony default export */ var autocomplete = (BlockEditorAutocomplete);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/fullscreen.js
/**
* WordPress dependencies
*/
var fullscreen = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M4.2 9h1.5V5.8H9V4.2H4.2V9zm14 9.2H15v1.5h4.8V15h-1.5v3.2zM15 4.2v1.5h3.2V9h1.5V4.2H15zM5.8 15H4.2v4.8H9v-1.5H5.8V15z"
}));
/* harmony default export */ var library_fullscreen = (fullscreen);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-full-height-alignment-toolbar/index.js
/**
* WordPress dependencies
*/
function BlockFullHeightAlignmentToolbar(_ref) {
var isActive = _ref.isActive,
_ref$label = _ref.label,
label = _ref$label === void 0 ? Object(external_wp_i18n_["__"])('Toggle full height') : _ref$label,
onToggle = _ref.onToggle,
isDisabled = _ref.isDisabled;
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
isActive: isActive,
icon: library_fullscreen,
label: label,
onClick: function onClick() {
return onToggle(!isActive);
},
disabled: isDisabled
}));
}
/* harmony default export */ var block_full_height_alignment_toolbar = (BlockFullHeightAlignmentToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-alignment-matrix-toolbar/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function BlockAlignmentMatrixToolbar(props) {
var _props$label = props.label,
label = _props$label === void 0 ? Object(external_wp_i18n_["__"])('Change matrix alignment') : _props$label,
_props$onChange = props.onChange,
onChange = _props$onChange === void 0 ? external_lodash_["noop"] : _props$onChange,
_props$value = props.value,
value = _props$value === void 0 ? 'center' : _props$value,
isDisabled = props.isDisabled;
var icon = Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalAlignmentMatrixControl"].Icon, {
value: value
});
var className = 'block-editor-block-alignment-matrix-toolbar';
var popoverClassName = "".concat(className, "__popover");
var isAlternate = true;
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
position: "bottom right",
className: className,
popoverProps: {
className: popoverClassName,
isAlternate: isAlternate
},
renderToggle: function renderToggle(_ref) {
var onToggle = _ref.onToggle,
isOpen = _ref.isOpen;
var openOnArrowDown = function openOnArrowDown(event) {
if (!isOpen && event.keyCode === external_wp_keycodes_["DOWN"]) {
event.preventDefault();
event.stopPropagation();
onToggle();
}
};
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
onClick: onToggle,
"aria-haspopup": "true",
"aria-expanded": isOpen,
onKeyDown: openOnArrowDown,
label: label,
icon: icon,
showTooltip: true,
disabled: isDisabled
}));
},
renderContent: function renderContent() {
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalAlignmentMatrixControl"], {
hasFocusBorder: false,
onChange: onChange,
value: value
});
}
});
}
/* harmony default export */ var block_alignment_matrix_toolbar = (BlockAlignmentMatrixToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/defaults.js
/**
* WordPress dependencies
*/
var PREFERENCES_DEFAULTS = {
insertUsage: {}
};
/**
* The default editor settings
*
* @typedef {Object} SETTINGS_DEFAULT
* @property {boolean} alignWide Enable/Disable Wide/Full Alignments
* @property {Array} availableLegacyWidgets Array of objects representing the legacy widgets available.
* @property {boolean} imageEditing Image Editing settings set to false to disable.
* @property {Array} imageSizes Available image sizes
* @property {number} maxWidth Max width to constraint resizing
* @property {boolean|Array} allowedBlockTypes Allowed block types
* @property {boolean} hasFixedToolbar Whether or not the editor toolbar is fixed
* @property {boolean} focusMode Whether the focus mode is enabled or not
* @property {Array} styles Editor Styles
* @property {boolean} keepCaretInsideBlock Whether caret should move between blocks in edit mode
* @property {string} bodyPlaceholder Empty post placeholder
* @property {string} titlePlaceholder Empty title placeholder
* @property {boolean} codeEditingEnabled Whether or not the user can switch to the code editor
* @property {boolean} __experimentalCanUserUseUnfilteredHTML Whether the user should be able to use unfiltered HTML or the HTML should be filtered e.g., to remove elements considered insecure like iframes.
* @property {boolean} __experimentalBlockDirectory Whether the user has enabled the Block Directory
* @property {Array} __experimentalBlockPatterns Array of objects representing the block patterns
* @property {Array} __experimentalBlockPatternCategories Array of objects representing the block pattern categories
*/
var SETTINGS_DEFAULTS = {
alignWide: false,
// colors setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
// The setting is only kept for backward compatibility purposes.
colors: [{
name: Object(external_wp_i18n_["__"])('Black'),
slug: 'black',
color: '#000000'
}, {
name: Object(external_wp_i18n_["__"])('Cyan bluish gray'),
slug: 'cyan-bluish-gray',
color: '#abb8c3'
}, {
name: Object(external_wp_i18n_["__"])('White'),
slug: 'white',
color: '#ffffff'
}, {
name: Object(external_wp_i18n_["__"])('Pale pink'),
slug: 'pale-pink',
color: '#f78da7'
}, {
name: Object(external_wp_i18n_["__"])('Vivid red'),
slug: 'vivid-red',
color: '#cf2e2e'
}, {
name: Object(external_wp_i18n_["__"])('Luminous vivid orange'),
slug: 'luminous-vivid-orange',
color: '#ff6900'
}, {
name: Object(external_wp_i18n_["__"])('Luminous vivid amber'),
slug: 'luminous-vivid-amber',
color: '#fcb900'
}, {
name: Object(external_wp_i18n_["__"])('Light green cyan'),
slug: 'light-green-cyan',
color: '#7bdcb5'
}, {
name: Object(external_wp_i18n_["__"])('Vivid green cyan'),
slug: 'vivid-green-cyan',
color: '#00d084'
}, {
name: Object(external_wp_i18n_["__"])('Pale cyan blue'),
slug: 'pale-cyan-blue',
color: '#8ed1fc'
}, {
name: Object(external_wp_i18n_["__"])('Vivid cyan blue'),
slug: 'vivid-cyan-blue',
color: '#0693e3'
}, {
name: Object(external_wp_i18n_["__"])('Vivid purple'),
slug: 'vivid-purple',
color: '#9b51e0'
}],
// fontSizes setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
// The setting is only kept for backward compatibility purposes.
fontSizes: [{
name: Object(external_wp_i18n_["_x"])('Small', 'font size name'),
size: 13,
slug: 'small'
}, {
name: Object(external_wp_i18n_["_x"])('Normal', 'font size name'),
size: 16,
slug: 'normal'
}, {
name: Object(external_wp_i18n_["_x"])('Medium', 'font size name'),
size: 20,
slug: 'medium'
}, {
name: Object(external_wp_i18n_["_x"])('Large', 'font size name'),
size: 36,
slug: 'large'
}, {
name: Object(external_wp_i18n_["_x"])('Huge', 'font size name'),
size: 42,
slug: 'huge'
}],
imageSizes: [{
slug: 'thumbnail',
name: Object(external_wp_i18n_["__"])('Thumbnail')
}, {
slug: 'medium',
name: Object(external_wp_i18n_["__"])('Medium')
}, {
slug: 'large',
name: Object(external_wp_i18n_["__"])('Large')
}, {
slug: 'full',
name: Object(external_wp_i18n_["__"])('Full Size')
}],
// Allow plugin to disable Image Editor if need be
imageEditing: true,
// This is current max width of the block inner area
// It's used to constraint image resizing and this value could be overridden later by themes
maxWidth: 580,
// Allowed block types for the editor, defaulting to true (all supported).
allowedBlockTypes: true,
// Maximum upload size in bytes allowed for the site.
maxUploadFileSize: 0,
// List of allowed mime types and file extensions.
allowedMimeTypes: null,
availableLegacyWidgets: {},
__experimentalCanUserUseUnfilteredHTML: false,
__experimentalBlockDirectory: false,
__mobileEnablePageTemplates: false,
__experimentalBlockPatterns: [],
__experimentalBlockPatternCategories: [],
__experimentalSpotlightEntityBlocks: [],
// gradients setting is not used anymore now defaults are passed from theme.json on the server and core has its own defaults.
// The setting is only kept for backward compatibility purposes.
gradients: [{
name: Object(external_wp_i18n_["__"])('Vivid cyan blue to vivid purple'),
gradient: 'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
slug: 'vivid-cyan-blue-to-vivid-purple'
}, {
name: Object(external_wp_i18n_["__"])('Light green cyan to vivid green cyan'),
gradient: 'linear-gradient(135deg,rgb(122,220,180) 0%,rgb(0,208,130) 100%)',
slug: 'light-green-cyan-to-vivid-green-cyan'
}, {
name: Object(external_wp_i18n_["__"])('Luminous vivid amber to luminous vivid orange'),
gradient: 'linear-gradient(135deg,rgba(252,185,0,1) 0%,rgba(255,105,0,1) 100%)',
slug: 'luminous-vivid-amber-to-luminous-vivid-orange'
}, {
name: Object(external_wp_i18n_["__"])('Luminous vivid orange to vivid red'),
gradient: 'linear-gradient(135deg,rgba(255,105,0,1) 0%,rgb(207,46,46) 100%)',
slug: 'luminous-vivid-orange-to-vivid-red'
}, {
name: Object(external_wp_i18n_["__"])('Very light gray to cyan bluish gray'),
gradient: 'linear-gradient(135deg,rgb(238,238,238) 0%,rgb(169,184,195) 100%)',
slug: 'very-light-gray-to-cyan-bluish-gray'
}, {
name: Object(external_wp_i18n_["__"])('Cool to warm spectrum'),
gradient: 'linear-gradient(135deg,rgb(74,234,220) 0%,rgb(151,120,209) 20%,rgb(207,42,186) 40%,rgb(238,44,130) 60%,rgb(251,105,98) 80%,rgb(254,248,76) 100%)',
slug: 'cool-to-warm-spectrum'
}, {
name: Object(external_wp_i18n_["__"])('Blush light purple'),
gradient: 'linear-gradient(135deg,rgb(255,206,236) 0%,rgb(152,150,240) 100%)',
slug: 'blush-light-purple'
}, {
name: Object(external_wp_i18n_["__"])('Blush bordeaux'),
gradient: 'linear-gradient(135deg,rgb(254,205,165) 0%,rgb(254,45,45) 50%,rgb(107,0,62) 100%)',
slug: 'blush-bordeaux'
}, {
name: Object(external_wp_i18n_["__"])('Luminous dusk'),
gradient: 'linear-gradient(135deg,rgb(255,203,112) 0%,rgb(199,81,192) 50%,rgb(65,88,208) 100%)',
slug: 'luminous-dusk'
}, {
name: Object(external_wp_i18n_["__"])('Pale ocean'),
gradient: 'linear-gradient(135deg,rgb(255,245,203) 0%,rgb(182,227,212) 50%,rgb(51,167,181) 100%)',
slug: 'pale-ocean'
}, {
name: Object(external_wp_i18n_["__"])('Electric grass'),
gradient: 'linear-gradient(135deg,rgb(202,248,128) 0%,rgb(113,206,126) 100%)',
slug: 'electric-grass'
}, {
name: Object(external_wp_i18n_["__"])('Midnight'),
gradient: 'linear-gradient(135deg,rgb(2,3,129) 0%,rgb(40,116,252) 100%)',
slug: 'midnight'
}]
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/array.js
/**
* External dependencies
*/
/**
* Insert one or multiple elements into a given position of an array.
*
* @param {Array} array Source array.
* @param {*} elements Elements to insert.
* @param {number} index Insert Position.
*
* @return {Array} Result.
*/
function insertAt(array, elements, index) {
return [].concat(Object(toConsumableArray["a" /* default */])(array.slice(0, index)), Object(toConsumableArray["a" /* default */])(Object(external_lodash_["castArray"])(elements)), Object(toConsumableArray["a" /* default */])(array.slice(index)));
}
/**
* Moves an element in an array.
*
* @param {Array} array Source array.
* @param {number} from Source index.
* @param {number} to Destination index.
* @param {number} count Number of elements to move.
*
* @return {Array} Result.
*/
function moveTo(array, from, to) {
var count = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
var withoutMovedElements = Object(toConsumableArray["a" /* default */])(array);
withoutMovedElements.splice(from, count);
return insertAt(withoutMovedElements, array.slice(from, from + count), to);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/reducer.js
function reducer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function reducer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { reducer_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { reducer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Given an array of blocks, returns an object where each key is a nesting
* context, the value of which is an array of block client IDs existing within
* that nesting context.
*
* @param {Array} blocks Blocks to map.
* @param {?string} rootClientId Assumed root client ID.
*
* @return {Object} Block order map object.
*/
function mapBlockOrder(blocks) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var result = Object(defineProperty["a" /* default */])({}, rootClientId, []);
blocks.forEach(function (block) {
var clientId = block.clientId,
innerBlocks = block.innerBlocks;
result[rootClientId].push(clientId);
Object.assign(result, mapBlockOrder(innerBlocks, clientId));
});
return result;
}
/**
* Given an array of blocks, returns an object where each key contains
* the clientId of the block and the value is the parent of the block.
*
* @param {Array} blocks Blocks to map.
* @param {?string} rootClientId Assumed root client ID.
*
* @return {Object} Block order map object.
*/
function mapBlockParents(blocks) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return blocks.reduce(function (result, block) {
return Object.assign(result, Object(defineProperty["a" /* default */])({}, block.clientId, rootClientId), mapBlockParents(block.innerBlocks, block.clientId));
}, {});
}
/**
* Helper method to iterate through all blocks, recursing into inner blocks,
* applying a transformation function to each one.
* Returns a flattened object with the transformed blocks.
*
* @param {Array} blocks Blocks to flatten.
* @param {Function} transform Transforming function to be applied to each block.
*
* @return {Object} Flattened object.
*/
function flattenBlocks(blocks) {
var transform = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : external_lodash_["identity"];
var result = {};
var stack = Object(toConsumableArray["a" /* default */])(blocks);
while (stack.length) {
var _stack$shift = stack.shift(),
innerBlocks = _stack$shift.innerBlocks,
block = Object(objectWithoutProperties["a" /* default */])(_stack$shift, ["innerBlocks"]);
stack.push.apply(stack, Object(toConsumableArray["a" /* default */])(innerBlocks));
result[block.clientId] = transform(block);
}
return result;
}
/**
* Given an array of blocks, returns an object containing all blocks, without
* attributes, recursing into inner blocks. Keys correspond to the block client
* ID, the value of which is the attributes object.
*
* @param {Array} blocks Blocks to flatten.
*
* @return {Object} Flattened block attributes object.
*/
function getFlattenedBlocksWithoutAttributes(blocks) {
return flattenBlocks(blocks, function (block) {
return Object(external_lodash_["omit"])(block, 'attributes');
});
}
/**
* Given an array of blocks, returns an object containing all block attributes,
* recursing into inner blocks. Keys correspond to the block client ID, the
* value of which is the attributes object.
*
* @param {Array} blocks Blocks to flatten.
*
* @return {Object} Flattened block attributes object.
*/
function getFlattenedBlockAttributes(blocks) {
return flattenBlocks(blocks, function (block) {
return block.attributes;
});
}
/**
* Given a block order map object, returns *all* of the block client IDs that are
* a descendant of the given root client ID.
*
* Calling this with `rootClientId` set to `''` results in a list of client IDs
* that are in the post. That is, it excludes blocks like fetched reusable
* blocks which are stored into state but not visible. It also excludes
* InnerBlocks controllers, like template parts.
*
* It is important to exclude the full inner block controller and not just the
* inner blocks because in many cases, we need to persist the previous value of
* an inner block controller. To do so, it must be excluded from the list of
* client IDs which are considered to be part of the top-level entity.
*
* @param {Object} blocksOrder Object that maps block client IDs to a list of
* nested block client IDs.
* @param {?string} rootClientId The root client ID to search. Defaults to ''.
* @param {?Object} controlledInnerBlocks The InnerBlocks controller state.
*
* @return {Array} List of descendant client IDs.
*/
function getNestedBlockClientIds(blocksOrder) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
var controlledInnerBlocks = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
return Object(external_lodash_["reduce"])(blocksOrder[rootClientId], function (result, clientId) {
if (!!controlledInnerBlocks[clientId]) {
return result;
}
return [].concat(Object(toConsumableArray["a" /* default */])(result), [clientId], Object(toConsumableArray["a" /* default */])(getNestedBlockClientIds(blocksOrder, clientId)));
}, []);
}
/**
* Returns an object against which it is safe to perform mutating operations,
* given the original object and its current working copy.
*
* @param {Object} original Original object.
* @param {Object} working Working object.
*
* @return {Object} Mutation-safe object.
*/
function getMutateSafeObject(original, working) {
if (original === working) {
return reducer_objectSpread({}, original);
}
return working;
}
/**
* Returns true if the two object arguments have the same keys, or false
* otherwise.
*
* @param {Object} a First object.
* @param {Object} b Second object.
*
* @return {boolean} Whether the two objects have the same keys.
*/
function hasSameKeys(a, b) {
return Object(external_lodash_["isEqual"])(Object(external_lodash_["keys"])(a), Object(external_lodash_["keys"])(b));
}
/**
* Returns true if, given the currently dispatching action and the previously
* dispatched action, the two actions are updating the same block attribute, or
* false otherwise.
*
* @param {Object} action Currently dispatching action.
* @param {Object} lastAction Previously dispatched action.
*
* @return {boolean} Whether actions are updating the same block attribute.
*/
function isUpdatingSameBlockAttribute(action, lastAction) {
return action.type === 'UPDATE_BLOCK_ATTRIBUTES' && lastAction !== undefined && lastAction.type === 'UPDATE_BLOCK_ATTRIBUTES' && Object(external_lodash_["isEqual"])(action.clientIds, lastAction.clientIds) && hasSameKeys(action.attributes, lastAction.attributes);
}
/**
* Utility returning an object with an empty object value for each key.
*
* @param {Array} objectKeys Keys to fill.
* @return {Object} Object filled with empty object as values for each clientId.
*/
var fillKeysWithEmptyObject = function fillKeysWithEmptyObject(objectKeys) {
return objectKeys.reduce(function (result, key) {
result[key] = {};
return result;
}, {});
};
/**
* Higher-order reducer intended to compute a cache key for each block in the post.
* A new instance of the cache key (empty object) is created each time the block object
* needs to be refreshed (for any change in the block or its children).
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
var reducer_withBlockCache = function withBlockCache(reducer) {
return function () {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
var newState = reducer(state, action);
if (newState === state) {
return state;
}
newState.cache = state.cache ? state.cache : {};
/**
* For each clientId provided, traverses up parents, adding the provided clientIds
* and each parent's clientId to the returned array.
*
* When calling this function consider that it uses the old state, so any state
* modifications made by the `reducer` will not be present.
*
* @param {Array} clientIds an Array of block clientIds.
*
* @return {Array} The provided clientIds and all of their parent clientIds.
*/
var getBlocksWithParentsClientIds = function getBlocksWithParentsClientIds(clientIds) {
return clientIds.reduce(function (result, clientId) {
var current = clientId;
do {
result.push(current);
current = state.parents[current];
} while (current && !state.controlledInnerBlocks[current]);
return result;
}, []);
};
switch (action.type) {
case 'RESET_BLOCKS':
newState.cache = Object(external_lodash_["mapValues"])(flattenBlocks(action.blocks), function () {
return {};
});
break;
case 'RECEIVE_BLOCKS':
case 'INSERT_BLOCKS':
{
var updatedBlockUids = Object(external_lodash_["keys"])(flattenBlocks(action.blocks));
if (action.rootClientId && !state.controlledInnerBlocks[action.rootClientId]) {
updatedBlockUids.push(action.rootClientId);
}
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds(updatedBlockUids)));
break;
}
case 'UPDATE_BLOCK':
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds([action.clientId])));
break;
case 'UPDATE_BLOCK_ATTRIBUTES':
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds(action.clientIds)));
break;
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
var parentClientIds = fillKeysWithEmptyObject(getBlocksWithParentsClientIds(action.replacedClientIds));
newState.cache = reducer_objectSpread(reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(newState.cache, action.replacedClientIds)), Object(external_lodash_["omit"])(parentClientIds, action.replacedClientIds)), fillKeysWithEmptyObject(Object(external_lodash_["keys"])(flattenBlocks(action.blocks))));
break;
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
newState.cache = reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(newState.cache, action.removedClientIds)), fillKeysWithEmptyObject(Object(external_lodash_["difference"])(getBlocksWithParentsClientIds(action.clientIds), action.clientIds)));
break;
case 'MOVE_BLOCKS_TO_POSITION':
{
var _updatedBlockUids = Object(toConsumableArray["a" /* default */])(action.clientIds);
if (action.fromRootClientId) {
_updatedBlockUids.push(action.fromRootClientId);
}
if (action.toRootClientId) {
_updatedBlockUids.push(action.toRootClientId);
}
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds(_updatedBlockUids)));
break;
}
case 'MOVE_BLOCKS_UP':
case 'MOVE_BLOCKS_DOWN':
{
var _updatedBlockUids2 = [];
if (action.rootClientId) {
_updatedBlockUids2.push(action.rootClientId);
}
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds(_updatedBlockUids2)));
break;
}
case 'SAVE_REUSABLE_BLOCK_SUCCESS':
{
var _updatedBlockUids3 = Object(external_lodash_["keys"])(Object(external_lodash_["omitBy"])(newState.attributes, function (attributes, clientId) {
return newState.byClientId[clientId].name !== 'core/block' || attributes.ref !== action.updatedId;
}));
newState.cache = reducer_objectSpread(reducer_objectSpread({}, newState.cache), fillKeysWithEmptyObject(getBlocksWithParentsClientIds(_updatedBlockUids3)));
}
}
return newState;
};
};
/**
* Higher-order reducer intended to augment the blocks reducer, assigning an
* `isPersistentChange` property value corresponding to whether a change in
* state can be considered as persistent. All changes are considered persistent
* except when updating the same block attribute as in the previous action.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
function withPersistentBlockChange(reducer) {
var lastAction;
var markNextChangeAsNotPersistent = false;
return function (state, action) {
var nextState = reducer(state, action);
var isExplicitPersistentChange = action.type === 'MARK_LAST_CHANGE_AS_PERSISTENT' || markNextChangeAsNotPersistent; // Defer to previous state value (or default) unless changing or
// explicitly marking as persistent.
if (state === nextState && !isExplicitPersistentChange) {
var _state$isPersistentCh;
markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
var nextIsPersistentChange = (_state$isPersistentCh = state === null || state === void 0 ? void 0 : state.isPersistentChange) !== null && _state$isPersistentCh !== void 0 ? _state$isPersistentCh : true;
if (state.isPersistentChange === nextIsPersistentChange) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, nextState), {}, {
isPersistentChange: nextIsPersistentChange
});
}
nextState = reducer_objectSpread(reducer_objectSpread({}, nextState), {}, {
isPersistentChange: isExplicitPersistentChange ? !markNextChangeAsNotPersistent : !isUpdatingSameBlockAttribute(action, lastAction)
}); // In comparing against the previous action, consider only those which
// would have qualified as one which would have been ignored or not
// have resulted in a changed state.
lastAction = action;
markNextChangeAsNotPersistent = action.type === 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT';
return nextState;
};
}
/**
* Higher-order reducer intended to augment the blocks reducer, assigning an
* `isIgnoredChange` property value corresponding to whether a change in state
* can be considered as ignored. A change is considered ignored when the result
* of an action not incurred by direct user interaction.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
function withIgnoredBlockChange(reducer) {
/**
* Set of action types for which a blocks state change should be ignored.
*
* @type {Set}
*/
var IGNORED_ACTION_TYPES = new Set(['RECEIVE_BLOCKS']);
return function (state, action) {
var nextState = reducer(state, action);
if (nextState !== state) {
nextState.isIgnoredChange = IGNORED_ACTION_TYPES.has(action.type);
}
return nextState;
};
}
/**
* Higher-order reducer targeting the combined blocks reducer, augmenting
* block client IDs in remove action to include cascade of inner blocks.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
var reducer_withInnerBlocksRemoveCascade = function withInnerBlocksRemoveCascade(reducer) {
return function (state, action) {
// Gets all children which need to be removed.
var getAllChildren = function getAllChildren(clientIds) {
var result = clientIds;
for (var i = 0; i < result.length; i++) {
var _result2;
if (!state.order[result[i]] || action.keepControlledInnerBlocks && action.keepControlledInnerBlocks[result[i]]) {
continue;
}
if (result === clientIds) {
result = Object(toConsumableArray["a" /* default */])(result);
}
(_result2 = result).push.apply(_result2, Object(toConsumableArray["a" /* default */])(state.order[result[i]]));
}
return result;
};
if (state) {
switch (action.type) {
case 'REMOVE_BLOCKS':
action = reducer_objectSpread(reducer_objectSpread({}, action), {}, {
type: 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN',
removedClientIds: getAllChildren(action.clientIds)
});
break;
case 'REPLACE_BLOCKS':
action = reducer_objectSpread(reducer_objectSpread({}, action), {}, {
type: 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN',
replacedClientIds: getAllChildren(action.clientIds)
});
break;
}
}
return reducer(state, action);
};
};
/**
* Higher-order reducer which targets the combined blocks reducer and handles
* the `RESET_BLOCKS` action. When dispatched, this action will replace all
* blocks that exist in the post, leaving blocks that exist only in state (e.g.
* reusable blocks and blocks controlled by inner blocks controllers) alone.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
var reducer_withBlockReset = function withBlockReset(reducer) {
return function (state, action) {
if (state && action.type === 'RESET_BLOCKS') {
/**
* A list of client IDs associated with the top level entity (like a
* post or template). It excludes the client IDs of blocks associated
* with other entities, like inner block controllers or reusable blocks.
*/
var visibleClientIds = getNestedBlockClientIds(state.order, '', state.controlledInnerBlocks); // pickBy returns only the truthy values from controlledInnerBlocks
var controlledInnerBlocks = Object.keys(Object(external_lodash_["pickBy"])(state.controlledInnerBlocks));
/**
* Each update operation consists of a few parts:
* 1. First, the client IDs associated with the top level entity are
* removed from the existing state key, leaving in place controlled
* blocks (like reusable blocks and inner block controllers).
* 2. Second, the blocks from the reset action are used to calculate the
* individual state keys. This will re-populate the clientIDs which
* were removed in step 1.
* 3. In some cases, we remove the recalculated inner block controllers,
* letting their old values persist. We need to do this because the
* reset block action from a top-level entity is not aware of any
* inner blocks inside InnerBlock controllers. So if the new values
* were used, it would not take into account the existing InnerBlocks
* which already exist in the state for inner block controllers. For
* example, `attributes` uses the newly computed value for controllers
* since attributes are stored in the top-level entity. But `order`
* uses the previous value for the controllers since the new value
* does not include the order of controlled inner blocks. So if the
* new value was used, template parts would disappear from the editor
* whenever you try to undo a change in the top level entity.
*/
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
byClientId: reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state.byClientId, visibleClientIds)), getFlattenedBlocksWithoutAttributes(action.blocks)),
attributes: reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state.attributes, visibleClientIds)), getFlattenedBlockAttributes(action.blocks)),
order: reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state.order, visibleClientIds)), Object(external_lodash_["omit"])(mapBlockOrder(action.blocks), controlledInnerBlocks)),
parents: reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state.parents, visibleClientIds)), mapBlockParents(action.blocks)),
cache: reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state.cache, visibleClientIds)), Object(external_lodash_["omit"])(Object(external_lodash_["mapValues"])(flattenBlocks(action.blocks), function () {
return {};
}), controlledInnerBlocks))
});
}
return reducer(state, action);
};
};
/**
* Higher-order reducer which targets the combined blocks reducer and handles
* the `REPLACE_INNER_BLOCKS` action. When dispatched, this action the state
* should become equivalent to the execution of a `REMOVE_BLOCKS` action
* containing all the child's of the root block followed by the execution of
* `INSERT_BLOCKS` with the new blocks.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
var reducer_withReplaceInnerBlocks = function withReplaceInnerBlocks(reducer) {
return function (state, action) {
if (action.type !== 'REPLACE_INNER_BLOCKS') {
return reducer(state, action);
} // Finds every nested inner block controller. We must check the action blocks
// and not just the block parent state because some inner block controllers
// should be deleted if specified, whereas others should not be deleted. If
// a controlled should not be deleted, then we need to avoid deleting its
// inner blocks from the block state because its inner blocks will not be
// attached to the block in the action.
var nestedControllers = {};
if (Object.keys(state.controlledInnerBlocks).length) {
var stack = Object(toConsumableArray["a" /* default */])(action.blocks);
while (stack.length) {
var _stack$shift2 = stack.shift(),
innerBlocks = _stack$shift2.innerBlocks,
block = Object(objectWithoutProperties["a" /* default */])(_stack$shift2, ["innerBlocks"]);
stack.push.apply(stack, Object(toConsumableArray["a" /* default */])(innerBlocks));
if (!!state.controlledInnerBlocks[block.clientId]) {
nestedControllers[block.clientId] = true;
}
}
} // The `keepControlledInnerBlocks` prop will keep the inner blocks of the
// marked block in the block state so that they can be reattached to the
// marked block when we re-insert everything a few lines below.
var stateAfterBlocksRemoval = state;
if (state.order[action.rootClientId]) {
stateAfterBlocksRemoval = reducer(stateAfterBlocksRemoval, {
type: 'REMOVE_BLOCKS',
keepControlledInnerBlocks: nestedControllers,
clientIds: state.order[action.rootClientId]
});
}
var stateAfterInsert = stateAfterBlocksRemoval;
if (action.blocks.length) {
stateAfterInsert = reducer(stateAfterInsert, reducer_objectSpread(reducer_objectSpread({}, action), {}, {
type: 'INSERT_BLOCKS',
index: 0
})); // We need to re-attach the block order of the controlled inner blocks.
// Otherwise, an inner block controller's blocks will be deleted entirely
// from its entity..
stateAfterInsert.order = reducer_objectSpread(reducer_objectSpread({}, stateAfterInsert.order), Object(external_lodash_["reduce"])(nestedControllers, function (result, value, key) {
if (state.order[key]) {
result[key] = state.order[key];
}
return result;
}, {}));
}
return stateAfterInsert;
};
};
/**
* Higher-order reducer which targets the combined blocks reducer and handles
* the `SAVE_REUSABLE_BLOCK_SUCCESS` action. This action can't be handled by
* regular reducers and needs a higher-order reducer since it needs access to
* both `byClientId` and `attributes` simultaneously.
*
* @param {Function} reducer Original reducer function.
*
* @return {Function} Enhanced reducer function.
*/
var reducer_withSaveReusableBlock = function withSaveReusableBlock(reducer) {
return function (state, action) {
if (state && action.type === 'SAVE_REUSABLE_BLOCK_SUCCESS') {
var id = action.id,
updatedId = action.updatedId; // If a temporary reusable block is saved, we swap the temporary id with the final one
if (id === updatedId) {
return state;
}
state = reducer_objectSpread({}, state);
state.attributes = Object(external_lodash_["mapValues"])(state.attributes, function (attributes, clientId) {
var name = state.byClientId[clientId].name;
if (name === 'core/block' && attributes.ref === id) {
return reducer_objectSpread(reducer_objectSpread({}, attributes), {}, {
ref: updatedId
});
}
return attributes;
});
}
return reducer(state, action);
};
};
/**
* Reducer returning the blocks state.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
var reducer_blocks = Object(external_lodash_["flow"])(external_wp_data_["combineReducers"], reducer_withSaveReusableBlock, // needs to be before withBlockCache
reducer_withBlockCache, // needs to be before withInnerBlocksRemoveCascade
reducer_withInnerBlocksRemoveCascade, reducer_withReplaceInnerBlocks, // needs to be after withInnerBlocksRemoveCascade
reducer_withBlockReset, withPersistentBlockChange, withIgnoredBlockChange)({
byClientId: function byClientId() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'RESET_BLOCKS':
return getFlattenedBlocksWithoutAttributes(action.blocks);
case 'RECEIVE_BLOCKS':
case 'INSERT_BLOCKS':
return reducer_objectSpread(reducer_objectSpread({}, state), getFlattenedBlocksWithoutAttributes(action.blocks));
case 'UPDATE_BLOCK':
// Ignore updates if block isn't known
if (!state[action.clientId]) {
return state;
} // Do nothing if only attributes change.
var changes = Object(external_lodash_["omit"])(action.updates, 'attributes');
if (Object(external_lodash_["isEmpty"])(changes)) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.clientId, reducer_objectSpread(reducer_objectSpread({}, state[action.clientId]), changes)));
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
if (!action.blocks) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state, action.replacedClientIds)), getFlattenedBlocksWithoutAttributes(action.blocks));
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
return Object(external_lodash_["omit"])(state, action.removedClientIds);
}
return state;
},
attributes: function attributes() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'RESET_BLOCKS':
return getFlattenedBlockAttributes(action.blocks);
case 'RECEIVE_BLOCKS':
case 'INSERT_BLOCKS':
return reducer_objectSpread(reducer_objectSpread({}, state), getFlattenedBlockAttributes(action.blocks));
case 'UPDATE_BLOCK':
// Ignore updates if block isn't known or there are no attribute changes.
if (!state[action.clientId] || !action.updates.attributes) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.clientId, reducer_objectSpread(reducer_objectSpread({}, state[action.clientId]), action.updates.attributes)));
case 'UPDATE_BLOCK_ATTRIBUTES':
{
// Avoid a state change if none of the block IDs are known.
if (action.clientIds.every(function (id) {
return !state[id];
})) {
return state;
}
var next = action.clientIds.reduce(function (accumulator, id) {
return reducer_objectSpread(reducer_objectSpread({}, accumulator), {}, Object(defineProperty["a" /* default */])({}, id, Object(external_lodash_["reduce"])(action.attributes, function (result, value, key) {
// Consider as updates only changed values.
if (value !== result[key]) {
result = getMutateSafeObject(state[id], result);
result[key] = value;
}
return result;
}, state[id])));
}, {});
if (action.clientIds.every(function (id) {
return next[id] === state[id];
})) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, state), next);
}
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
if (!action.blocks) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state, action.replacedClientIds)), getFlattenedBlockAttributes(action.blocks));
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
return Object(external_lodash_["omit"])(state, action.removedClientIds);
}
return state;
},
order: function order() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'RESET_BLOCKS':
return mapBlockOrder(action.blocks);
case 'RECEIVE_BLOCKS':
return reducer_objectSpread(reducer_objectSpread({}, state), Object(external_lodash_["omit"])(mapBlockOrder(action.blocks), ''));
case 'INSERT_BLOCKS':
{
var _action$rootClientId = action.rootClientId,
rootClientId = _action$rootClientId === void 0 ? '' : _action$rootClientId;
var subState = state[rootClientId] || [];
var mappedBlocks = mapBlockOrder(action.blocks, rootClientId);
var _action$index = action.index,
index = _action$index === void 0 ? subState.length : _action$index;
return reducer_objectSpread(reducer_objectSpread(reducer_objectSpread({}, state), mappedBlocks), {}, Object(defineProperty["a" /* default */])({}, rootClientId, insertAt(subState, mappedBlocks[rootClientId], index)));
}
case 'MOVE_BLOCKS_TO_POSITION':
{
var _objectSpread7;
var _action$fromRootClien = action.fromRootClientId,
fromRootClientId = _action$fromRootClien === void 0 ? '' : _action$fromRootClien,
_action$toRootClientI = action.toRootClientId,
toRootClientId = _action$toRootClientI === void 0 ? '' : _action$toRootClientI,
clientIds = action.clientIds;
var _action$index2 = action.index,
_index = _action$index2 === void 0 ? state[toRootClientId].length : _action$index2; // Moving inside the same parent block
if (fromRootClientId === toRootClientId) {
var _subState = state[toRootClientId];
var fromIndex = _subState.indexOf(clientIds[0]);
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, toRootClientId, moveTo(state[toRootClientId], fromIndex, _index, clientIds.length)));
} // Moving from a parent block to another
return reducer_objectSpread(reducer_objectSpread({}, state), {}, (_objectSpread7 = {}, Object(defineProperty["a" /* default */])(_objectSpread7, fromRootClientId, external_lodash_["without"].apply(void 0, [state[fromRootClientId]].concat(Object(toConsumableArray["a" /* default */])(clientIds)))), Object(defineProperty["a" /* default */])(_objectSpread7, toRootClientId, insertAt(state[toRootClientId], clientIds, _index)), _objectSpread7));
}
case 'MOVE_BLOCKS_UP':
{
var _clientIds = action.clientIds,
_action$rootClientId2 = action.rootClientId,
_rootClientId = _action$rootClientId2 === void 0 ? '' : _action$rootClientId2;
var firstClientId = Object(external_lodash_["first"])(_clientIds);
var _subState2 = state[_rootClientId];
if (!_subState2.length || firstClientId === Object(external_lodash_["first"])(_subState2)) {
return state;
}
var firstIndex = _subState2.indexOf(firstClientId);
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, _rootClientId, moveTo(_subState2, firstIndex, firstIndex - 1, _clientIds.length)));
}
case 'MOVE_BLOCKS_DOWN':
{
var _clientIds2 = action.clientIds,
_action$rootClientId3 = action.rootClientId,
_rootClientId2 = _action$rootClientId3 === void 0 ? '' : _action$rootClientId3;
var _firstClientId = Object(external_lodash_["first"])(_clientIds2);
var lastClientId = Object(external_lodash_["last"])(_clientIds2);
var _subState3 = state[_rootClientId2];
if (!_subState3.length || lastClientId === Object(external_lodash_["last"])(_subState3)) {
return state;
}
var _firstIndex = _subState3.indexOf(_firstClientId);
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, _rootClientId2, moveTo(_subState3, _firstIndex, _firstIndex + 1, _clientIds2.length)));
}
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
{
var _clientIds3 = action.clientIds;
if (!action.blocks) {
return state;
}
var _mappedBlocks = mapBlockOrder(action.blocks);
return Object(external_lodash_["flow"])([function (nextState) {
return Object(external_lodash_["omit"])(nextState, action.replacedClientIds);
}, function (nextState) {
return reducer_objectSpread(reducer_objectSpread({}, nextState), Object(external_lodash_["omit"])(_mappedBlocks, ''));
}, function (nextState) {
return Object(external_lodash_["mapValues"])(nextState, function (subState) {
return Object(external_lodash_["reduce"])(subState, function (result, clientId) {
if (clientId === _clientIds3[0]) {
return [].concat(Object(toConsumableArray["a" /* default */])(result), Object(toConsumableArray["a" /* default */])(_mappedBlocks['']));
}
if (_clientIds3.indexOf(clientId) === -1) {
result.push(clientId);
}
return result;
}, []);
});
}])(state);
}
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
return Object(external_lodash_["flow"])([// Remove inner block ordering for removed blocks
function (nextState) {
return Object(external_lodash_["omit"])(nextState, action.removedClientIds);
}, // Remove deleted blocks from other blocks' orderings
function (nextState) {
return Object(external_lodash_["mapValues"])(nextState, function (subState) {
return external_lodash_["without"].apply(void 0, [subState].concat(Object(toConsumableArray["a" /* default */])(action.removedClientIds)));
});
}])(state);
}
return state;
},
// While technically redundant data as the inverse of `order`, it serves as
// an optimization for the selectors which derive the ancestry of a block.
parents: function parents() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'RESET_BLOCKS':
return mapBlockParents(action.blocks);
case 'RECEIVE_BLOCKS':
return reducer_objectSpread(reducer_objectSpread({}, state), mapBlockParents(action.blocks));
case 'INSERT_BLOCKS':
return reducer_objectSpread(reducer_objectSpread({}, state), mapBlockParents(action.blocks, action.rootClientId || ''));
case 'MOVE_BLOCKS_TO_POSITION':
{
return reducer_objectSpread(reducer_objectSpread({}, state), action.clientIds.reduce(function (accumulator, id) {
accumulator[id] = action.toRootClientId || '';
return accumulator;
}, {}));
}
case 'REPLACE_BLOCKS_AUGMENTED_WITH_CHILDREN':
return reducer_objectSpread(reducer_objectSpread({}, Object(external_lodash_["omit"])(state, action.replacedClientIds)), mapBlockParents(action.blocks, state[action.clientIds[0]]));
case 'REMOVE_BLOCKS_AUGMENTED_WITH_CHILDREN':
return Object(external_lodash_["omit"])(state, action.removedClientIds);
}
return state;
},
controlledInnerBlocks: function controlledInnerBlocks() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _ref = arguments.length > 1 ? arguments[1] : undefined,
type = _ref.type,
clientId = _ref.clientId,
hasControlledInnerBlocks = _ref.hasControlledInnerBlocks;
if (type === 'SET_HAS_CONTROLLED_INNER_BLOCKS') {
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, clientId, hasControlledInnerBlocks));
}
return state;
}
});
/**
* Reducer returning typing state.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_isTyping() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'START_TYPING':
return true;
case 'STOP_TYPING':
return false;
}
return state;
}
/**
* Reducer returning dragged block client id.
*
* @param {string[]} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string[]} Updated state.
*/
function draggedBlocks() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'START_DRAGGING_BLOCKS':
return action.clientIds;
case 'STOP_DRAGGING_BLOCKS':
return [];
}
return state;
}
/**
* Reducer returning whether the caret is within formatted text.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_isCaretWithinFormattedText() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'ENTER_FORMATTED_TEXT':
return true;
case 'EXIT_FORMATTED_TEXT':
return false;
}
return state;
}
/**
* Internal helper reducer for selectionStart and selectionEnd. Can hold a block
* selection, represented by an object with property clientId.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function selectionHelper() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'CLEAR_SELECTED_BLOCK':
{
if (state.clientId) {
return {};
}
return state;
}
case 'SELECT_BLOCK':
if (action.clientId === state.clientId) {
return state;
}
return {
clientId: action.clientId
};
case 'REPLACE_INNER_BLOCKS': // REPLACE_INNER_BLOCKS and INSERT_BLOCKS should follow the same logic.
case 'INSERT_BLOCKS':
{
// REPLACE_INNER_BLOCKS can be called with an empty array.
if (!action.updateSelection || !action.blocks.length) {
return state;
}
return {
clientId: action.blocks[0].clientId
};
}
case 'REMOVE_BLOCKS':
if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.clientId) === -1) {
return state;
}
return {};
case 'REPLACE_BLOCKS':
{
if (action.clientIds.indexOf(state.clientId) === -1) {
return state;
}
var indexToSelect = action.indexToSelect || action.blocks.length - 1;
var blockToSelect = action.blocks[indexToSelect];
if (!blockToSelect) {
return {};
}
if (blockToSelect.clientId === state.clientId) {
return state;
}
var newState = {
clientId: blockToSelect.clientId
};
if (typeof action.initialPosition === 'number') {
newState.initialPosition = action.initialPosition;
}
return newState;
}
}
return state;
}
/**
* Reducer returning the selection state.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_selection() {
var _state$selectionStart, _state$selectionEnd;
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'SELECTION_CHANGE':
return {
selectionStart: {
clientId: action.clientId,
attributeKey: action.attributeKey,
offset: action.startOffset
},
selectionEnd: {
clientId: action.clientId,
attributeKey: action.attributeKey,
offset: action.endOffset
}
};
case 'RESET_SELECTION':
var selectionStart = action.selectionStart,
selectionEnd = action.selectionEnd;
return {
selectionStart: selectionStart,
selectionEnd: selectionEnd
};
case 'MULTI_SELECT':
var start = action.start,
end = action.end;
return {
selectionStart: {
clientId: start
},
selectionEnd: {
clientId: end
}
};
case 'RESET_BLOCKS':
var startClientId = state === null || state === void 0 ? void 0 : (_state$selectionStart = state.selectionStart) === null || _state$selectionStart === void 0 ? void 0 : _state$selectionStart.clientId;
var endClientId = state === null || state === void 0 ? void 0 : (_state$selectionEnd = state.selectionEnd) === null || _state$selectionEnd === void 0 ? void 0 : _state$selectionEnd.clientId; // Do nothing if there's no selected block.
if (!startClientId && !endClientId) {
return state;
} // If the start of the selection won't exist after reset, remove selection.
if (!action.blocks.some(function (block) {
return block.clientId === startClientId;
})) {
return {
selectionStart: {},
selectionEnd: {}
};
} // If the end of the selection won't exist after reset, collapse selection.
if (!action.blocks.some(function (block) {
return block.clientId === endClientId;
})) {
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
selectionEnd: state.selectionStart
});
}
}
return {
selectionStart: selectionHelper(state.selectionStart, action),
selectionEnd: selectionHelper(state.selectionEnd, action)
};
}
/**
* Reducer returning whether the user is multi-selecting.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_isMultiSelecting() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'START_MULTI_SELECT':
return true;
case 'STOP_MULTI_SELECT':
return false;
}
return state;
}
/**
* Reducer returning whether selection is enabled.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_isSelectionEnabled() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'TOGGLE_SELECTION':
return action.isSelectionEnabled;
}
return state;
}
/**
* Reducer returning the intial block selection.
*
* Currently this in only used to restore the selection after block deletion and
* pasting new content.This reducer should eventually be removed in favour of setting
* selection directly.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {?number} Initial position: -1 or undefined.
*/
function reducer_initialPosition(state, action) {
if (action.type === 'REPLACE_BLOCKS' && typeof action.initialPosition === 'number') {
return action.initialPosition;
} else if (action.type === 'SELECT_BLOCK') {
return action.initialPosition;
} else if (action.type === 'REMOVE_BLOCKS') {
return state;
} else if (action.type === 'START_TYPING') {
return state;
} // Reset the state by default (for any action not handled).
}
function blocksMode() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
if (action.type === 'TOGGLE_BLOCK_MODE') {
var clientId = action.clientId;
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, clientId, state[clientId] && state[clientId] === 'html' ? 'visual' : 'html'));
}
return state;
}
/**
* A helper for resetting the insertion point state.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
* @param {*} defaultValue The default value for the reducer.
*
* @return {*} Either the default value if a reset is required, or the state.
*/
function resetInsertionPoint(state, action, defaultValue) {
switch (action.type) {
case 'CLEAR_SELECTED_BLOCK':
case 'SELECT_BLOCK':
case 'SELECTION_CHANGE':
case 'REPLACE_INNER_BLOCKS':
case 'INSERT_BLOCKS':
case 'REMOVE_BLOCKS':
case 'REPLACE_BLOCKS':
return defaultValue;
}
return state;
}
/**
* Reducer returning the insertion point position, consisting of the
* rootClientId and an index.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function reducer_insertionPoint() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'SET_INSERTION_POINT':
case 'SHOW_INSERTION_POINT':
{
var rootClientId = action.rootClientId,
index = action.index;
return {
rootClientId: rootClientId,
index: index
};
}
}
return resetInsertionPoint(state, action, null);
}
/**
* Reducer returning the visibility of the insertion point.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function insertionPointVisibility() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'SHOW_INSERTION_POINT':
return true;
case 'HIDE_INSERTION_POINT':
return false;
}
return resetInsertionPoint(state, action, false);
}
/**
* Reducer returning whether the post blocks match the defined template or not.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {boolean} Updated state.
*/
function reducer_template() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
isValid: true
};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'SET_TEMPLATE_VALIDITY':
return reducer_objectSpread(reducer_objectSpread({}, state), {}, {
isValid: action.isValid
});
}
return state;
}
/**
* Reducer returning the editor setting.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
function reducer_settings() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : SETTINGS_DEFAULTS;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'UPDATE_SETTINGS':
return reducer_objectSpread(reducer_objectSpread({}, state), action.settings);
}
return state;
}
/**
* Reducer returning the user preferences.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string} Updated state.
*/
function preferences() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS;
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
case 'INSERT_BLOCKS':
case 'REPLACE_BLOCKS':
return action.blocks.reduce(function (prevState, block) {
var id = block.name;
var insert = {
name: block.name
};
if (Object(external_wp_blocks_["isReusableBlock"])(block)) {
insert.ref = block.attributes.ref;
id += '/' + block.attributes.ref;
}
return reducer_objectSpread(reducer_objectSpread({}, prevState), {}, {
insertUsage: reducer_objectSpread(reducer_objectSpread({}, prevState.insertUsage), {}, Object(defineProperty["a" /* default */])({}, id, {
time: action.time,
count: prevState.insertUsage[id] ? prevState.insertUsage[id].count + 1 : 1,
insert: insert
}))
});
}, state);
}
return state;
}
/**
* Reducer returning an object where each key is a block client ID, its value
* representing the settings for its nested blocks.
*
* @param {Object} state Current state.
* @param {Object} action Dispatched action.
*
* @return {Object} Updated state.
*/
var reducer_blockListSettings = function blockListSettings() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var action = arguments.length > 1 ? arguments[1] : undefined;
switch (action.type) {
// Even if the replaced blocks have the same client ID, our logic
// should correct the state.
case 'REPLACE_BLOCKS':
case 'REMOVE_BLOCKS':
{
return Object(external_lodash_["omit"])(state, action.clientIds);
}
case 'UPDATE_BLOCK_LIST_SETTINGS':
{
var clientId = action.clientId;
if (!action.settings) {
if (state.hasOwnProperty(clientId)) {
return Object(external_lodash_["omit"])(state, clientId);
}
return state;
}
if (Object(external_lodash_["isEqual"])(state[clientId], action.settings)) {
return state;
}
return reducer_objectSpread(reducer_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, clientId, action.settings));
}
}
return state;
};
/**
* Reducer returning whether the navigation mode is enabled or not.
*
* @param {string} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string} Updated state.
*/
function reducer_isNavigationMode() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
var action = arguments.length > 1 ? arguments[1] : undefined;
// Let inserting block always trigger Edit mode.
if (action.type === 'INSERT_BLOCKS') {
return false;
}
if (action.type === 'SET_NAVIGATION_MODE') {
return action.isNavigationMode;
}
return state;
}
/**
* Reducer returning whether the block moving mode is enabled or not.
*
* @param {string|null} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string|null} Updated state.
*/
function reducer_hasBlockMovingClientId() {
var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
var action = arguments.length > 1 ? arguments[1] : undefined;
// Let inserting block always trigger Edit mode.
if (action.type === 'SET_BLOCK_MOVING_MODE') {
return action.hasBlockMovingClientId;
}
if (action.type === 'SET_NAVIGATION_MODE') {
return null;
}
return state;
}
/**
* Reducer return an updated state representing the most recent block attribute
* update. The state is structured as an object where the keys represent the
* client IDs of blocks, the values a subset of attributes from the most recent
* block update. The state is always reset to null if the last action is
* anything other than an attributes update.
*
* @param {Object} state Current state.
* @param {Object} action Action object.
*
* @return {[string,Object]} Updated state.
*/
function lastBlockAttributesChange(state, action) {
switch (action.type) {
case 'UPDATE_BLOCK':
if (!action.updates.attributes) {
break;
}
return Object(defineProperty["a" /* default */])({}, action.clientId, action.updates.attributes);
case 'UPDATE_BLOCK_ATTRIBUTES':
return action.clientIds.reduce(function (accumulator, id) {
return reducer_objectSpread(reducer_objectSpread({}, accumulator), {}, Object(defineProperty["a" /* default */])({}, id, action.attributes));
}, {});
}
return null;
}
/**
* Reducer returning automatic change state.
*
* @param {boolean} state Current state.
* @param {Object} action Dispatched action.
*
* @return {string} Updated state.
*/
function automaticChangeStatus(state, action) {
switch (action.type) {
case 'MARK_AUTOMATIC_CHANGE':
return 'pending';
case 'MARK_AUTOMATIC_CHANGE_FINAL':
if (state === 'pending') {
return 'final';
}
return;
case 'SELECTION_CHANGE':
// As long as the state is not final, ignore any selection changes.
if (state !== 'final') {
return state;
}
return;
// Undoing an automatic change should still be possible after mouse
// move.
case 'START_TYPING':
case 'STOP_TYPING':
return state;
} // Reset the state by default (for any action not handled).
}
/**
* Reducer returning current highlighted block.
*
* @param {boolean} state Current highlighted block.
* @param {Object} action Dispatched action.
*
* @return {string} Updated state.
*/
function highlightedBlock(state, action) {
switch (action.type) {
case 'TOGGLE_BLOCK_HIGHLIGHT':
var clientId = action.clientId,
isHighlighted = action.isHighlighted;
if (isHighlighted) {
return clientId;
} else if (state === clientId) {
return null;
}
return state;
case 'SELECT_BLOCK':
if (action.clientId !== state) {
return null;
}
}
return state;
}
/* harmony default export */ var store_reducer = (Object(external_wp_data_["combineReducers"])({
blocks: reducer_blocks,
isTyping: reducer_isTyping,
draggedBlocks: draggedBlocks,
isCaretWithinFormattedText: reducer_isCaretWithinFormattedText,
selection: reducer_selection,
isMultiSelecting: reducer_isMultiSelecting,
isSelectionEnabled: reducer_isSelectionEnabled,
initialPosition: reducer_initialPosition,
blocksMode: blocksMode,
blockListSettings: reducer_blockListSettings,
insertionPoint: reducer_insertionPoint,
insertionPointVisibility: insertionPointVisibility,
template: reducer_template,
settings: reducer_settings,
preferences: preferences,
lastBlockAttributesChange: lastBlockAttributesChange,
isNavigationMode: reducer_isNavigationMode,
hasBlockMovingClientId: reducer_hasBlockMovingClientId,
automaticChangeStatus: automaticChangeStatus,
highlightedBlock: highlightedBlock
}));
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js
var esm_typeof = __webpack_require__(42);
// EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js
var rememo = __webpack_require__(41);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/selectors.js
function selectors_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = selectors_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function selectors_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return selectors_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return selectors_arrayLikeToArray(o, minLen); }
function selectors_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function selectors_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function selectors_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { selectors_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { selectors_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* A block selection object.
*
* @typedef {Object} WPBlockSelection
*
* @property {string} clientId A block client ID.
* @property {string} attributeKey A block attribute key.
* @property {number} offset An attribute value offset, based on the rich
* text value. See `wp.richText.create`.
*/
// Module constants
var MILLISECONDS_PER_HOUR = 3600 * 1000;
var MILLISECONDS_PER_DAY = 24 * 3600 * 1000;
var MILLISECONDS_PER_WEEK = 7 * 24 * 3600 * 1000;
var templateIcon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Rect"], {
x: "0",
fill: "none",
width: "24",
height: "24"
}), Object(external_wp_element_["createElement"])(external_wp_components_["G"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M19 3H5c-1.105 0-2 .895-2 2v14c0 1.105.895 2 2 2h14c1.105 0 2-.895 2-2V5c0-1.105-.895-2-2-2zM6 6h5v5H6V6zm4.5 13C9.12 19 8 17.88 8 16.5S9.12 14 10.5 14s2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5zm3-6l3-5 3 5h-6z"
})));
/**
* 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}
*/
var selectors_EMPTY_ARRAY = [];
/**
* Returns a block's name given its client ID, or null if no block exists with
* the client ID.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {string} Block name.
*/
function selectors_getBlockName(state, clientId) {
var block = state.blocks.byClientId[clientId];
var socialLinkName = 'core/social-link';
if (external_wp_element_["Platform"].OS !== 'web' && (block === null || block === void 0 ? void 0 : block.name) === socialLinkName) {
var attributes = state.blocks.attributes[clientId];
var service = attributes.service;
return service ? "".concat(socialLinkName, "-").concat(service) : socialLinkName;
}
return block ? block.name : null;
}
/**
* Returns whether a block is valid or not.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Is Valid.
*/
function selectors_isBlockValid(state, clientId) {
var block = state.blocks.byClientId[clientId];
return !!block && block.isValid;
}
/**
* Returns a block's attributes given its client ID, or null if no block exists with
* the client ID.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {Object?} Block attributes.
*/
function selectors_getBlockAttributes(state, clientId) {
var block = state.blocks.byClientId[clientId];
if (!block) {
return null;
}
return state.blocks.attributes[clientId];
}
/**
* Returns a block given its client ID. This is a parsed copy of the block,
* containing its `blockName`, `clientId`, and current `attributes` state. This
* is not the block's registration settings, which must be retrieved from the
* blocks module registration store.
*
* getBlock recurses through its inner blocks until all its children blocks have
* been retrieved. Note that getBlock will not return the child inner blocks of
* an inner block controller. This is because an inner block controller syncs
* itself with its own entity, and should therefore not be included with the
* blocks of a different entity. For example, say you call `getBlocks( TP )` to
* get the blocks of a template part. If another template part is a child of TP,
* then the nested template part's child blocks will not be returned. This way,
* the template block itself is considered part of the parent, but the children
* are not.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {Object} Parsed block object.
*/
var selectors_getBlock = Object(rememo["a" /* default */])(function (state, clientId) {
var block = state.blocks.byClientId[clientId];
if (!block) {
return null;
}
return selectors_objectSpread(selectors_objectSpread({}, block), {}, {
attributes: selectors_getBlockAttributes(state, clientId),
innerBlocks: areInnerBlocksControlled(state, clientId) ? selectors_EMPTY_ARRAY : selectors_getBlocks(state, clientId)
});
}, function (state, clientId) {
return [// Normally, we'd have both `getBlockAttributes` dependencies and
// `getBlocks` (children) dependencies here but for performance reasons
// we use a denormalized cache key computed in the reducer that takes both
// the attributes and inner blocks into account. The value of the cache key
// is being changed whenever one of these dependencies is out of date.
state.blocks.cache[clientId]];
});
var selectors_unstableGetBlockWithoutInnerBlocks = Object(rememo["a" /* default */])(function (state, clientId) {
var block = state.blocks.byClientId[clientId];
if (!block) {
return null;
}
return selectors_objectSpread(selectors_objectSpread({}, block), {}, {
attributes: selectors_getBlockAttributes(state, clientId)
});
}, function (state, clientId) {
return [state.blocks.byClientId[clientId], state.blocks.attributes[clientId]];
});
/**
* Returns all block objects for the current post being edited as an array in
* the order they appear in the post. Note that this will exclude child blocks
* of nested inner block controllers.
*
* Note: It's important to memoize this selector to avoid return a new instance
* on each call. We use the block cache state for each top-level block of the
* given clientID. This way, the selector only refreshes on changes to blocks
* associated with the given entity, and does not refresh when changes are made
* to blocks which are part of different inner block controllers.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {Object[]} Post blocks.
*/
var selectors_getBlocks = Object(rememo["a" /* default */])(function (state, rootClientId) {
return Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), function (clientId) {
return selectors_getBlock(state, clientId);
});
}, function (state, rootClientId) {
return Object(external_lodash_["map"])(state.blocks.order[rootClientId || ''], function (id) {
return state.blocks.cache[id];
});
});
/**
* Similar to getBlock, except it will include the entire nested block tree as
* inner blocks. The normal getBlock selector will exclude sections of the block
* tree which belong to different entities.
*
* @param {Object} state Editor state.
* @param {string} clientId Client ID of the block to get.
*
* @return {Object} The block with all
*/
var __unstableGetBlockWithBlockTree = Object(rememo["a" /* default */])(function (state, clientId) {
var block = state.blocks.byClientId[clientId];
if (!block) {
return null;
}
return selectors_objectSpread(selectors_objectSpread({}, block), {}, {
attributes: selectors_getBlockAttributes(state, clientId),
innerBlocks: __unstableGetBlockTree(state, clientId)
});
}, function (state) {
return [state.blocks.byClientId, state.blocks.order, state.blocks.attributes];
});
/**
* Similar to getBlocks, except this selector returns the entire block tree
* represented in the block-editor store from the given root regardless of any
* inner block controllers.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {Object[]} Post blocks.
*/
var __unstableGetBlockTree = Object(rememo["a" /* default */])(function (state) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return Object(external_lodash_["map"])(selectors_getBlockOrder(state, rootClientId), function (clientId) {
return __unstableGetBlockWithBlockTree(state, clientId);
});
}, function (state) {
return [state.blocks.byClientId, state.blocks.order, state.blocks.attributes];
});
/**
* Returns an array containing the clientIds of all descendants
* of the blocks given.
*
* @param {Object} state Global application state.
* @param {Array} clientIds Array of blocks to inspect.
*
* @return {Array} ids of descendants.
*/
var selectors_getClientIdsOfDescendants = function getClientIdsOfDescendants(state, clientIds) {
return Object(external_lodash_["flatMap"])(clientIds, function (clientId) {
var descendants = selectors_getBlockOrder(state, clientId);
return [].concat(Object(toConsumableArray["a" /* default */])(descendants), Object(toConsumableArray["a" /* default */])(getClientIdsOfDescendants(state, descendants)));
});
};
/**
* Returns an array containing the clientIds of the top-level blocks
* and their descendants of any depth (for nested blocks).
*
* @param {Object} state Global application state.
*
* @return {Array} ids of top-level and descendant blocks.
*/
var getClientIdsWithDescendants = Object(rememo["a" /* default */])(function (state) {
var topLevelIds = selectors_getBlockOrder(state);
return [].concat(Object(toConsumableArray["a" /* default */])(topLevelIds), Object(toConsumableArray["a" /* default */])(selectors_getClientIdsOfDescendants(state, topLevelIds)));
}, function (state) {
return [state.blocks.order];
});
/**
* Returns the total number of blocks, or the total number of blocks with a specific name in a post.
* The number returned includes nested blocks.
*
* @param {Object} state Global application state.
* @param {?string} blockName Optional block name, if specified only blocks of that type will be counted.
*
* @return {number} Number of blocks in the post, or number of blocks with name equal to blockName.
*/
var getGlobalBlockCount = Object(rememo["a" /* default */])(function (state, blockName) {
var clientIds = getClientIdsWithDescendants(state);
if (!blockName) {
return clientIds.length;
}
return Object(external_lodash_["reduce"])(clientIds, function (accumulator, clientId) {
var block = state.blocks.byClientId[clientId];
return block.name === blockName ? accumulator + 1 : accumulator;
}, 0);
}, function (state) {
return [state.blocks.order, state.blocks.byClientId];
});
/**
* Given an array of block client IDs, returns the corresponding array of block
* objects.
*
* @param {Object} state Editor state.
* @param {string[]} clientIds Client IDs for which blocks are to be returned.
*
* @return {WPBlock[]} Block objects.
*/
var selectors_getBlocksByClientId = Object(rememo["a" /* default */])(function (state, clientIds) {
return Object(external_lodash_["map"])(Object(external_lodash_["castArray"])(clientIds), function (clientId) {
return selectors_getBlock(state, clientId);
});
}, function (state) {
return [state.blocks.byClientId, state.blocks.order, state.blocks.attributes];
});
/**
* Returns the number of blocks currently present in the post.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {number} Number of blocks in the post.
*/
function selectors_getBlockCount(state, rootClientId) {
return selectors_getBlockOrder(state, rootClientId).length;
}
/**
* Returns the current selection start block client ID, attribute key and text
* offset.
*
* @param {Object} state Block editor state.
*
* @return {WPBlockSelection} Selection start information.
*/
function selectors_getSelectionStart(state) {
return state.selection.selectionStart;
}
/**
* Returns the current selection end block client ID, attribute key and text
* offset.
*
* @param {Object} state Block editor state.
*
* @return {WPBlockSelection} Selection end information.
*/
function selectors_getSelectionEnd(state) {
return state.selection.selectionEnd;
}
/**
* Returns the current block selection start. This value may be null, and it
* may represent either a singular block selection or multi-selection start.
* A selection is singular if its start and end match.
*
* @param {Object} state Global application state.
*
* @return {?string} Client ID of block selection start.
*/
function selectors_getBlockSelectionStart(state) {
return state.selection.selectionStart.clientId;
}
/**
* Returns the current block selection end. This value may be null, and it
* may represent either a singular block selection or multi-selection end.
* A selection is singular if its start and end match.
*
* @param {Object} state Global application state.
*
* @return {?string} Client ID of block selection end.
*/
function getBlockSelectionEnd(state) {
return state.selection.selectionEnd.clientId;
}
/**
* Returns the number of blocks currently selected in the post.
*
* @param {Object} state Global application state.
*
* @return {number} Number of blocks selected in the post.
*/
function selectors_getSelectedBlockCount(state) {
var multiSelectedBlockCount = selectors_getMultiSelectedBlockClientIds(state).length;
if (multiSelectedBlockCount) {
return multiSelectedBlockCount;
}
return state.selection.selectionStart.clientId ? 1 : 0;
}
/**
* Returns true if there is a single selected block, or false otherwise.
*
* @param {Object} state Editor state.
*
* @return {boolean} Whether a single block is selected.
*/
function selectors_hasSelectedBlock(state) {
var _state$selection = state.selection,
selectionStart = _state$selection.selectionStart,
selectionEnd = _state$selection.selectionEnd;
return !!selectionStart.clientId && selectionStart.clientId === selectionEnd.clientId;
}
/**
* Returns the currently selected block client ID, or null if there is no
* selected block.
*
* @param {Object} state Editor state.
*
* @return {?string} Selected block client ID.
*/
function selectors_getSelectedBlockClientId(state) {
var _state$selection2 = state.selection,
selectionStart = _state$selection2.selectionStart,
selectionEnd = _state$selection2.selectionEnd;
var clientId = selectionStart.clientId;
if (!clientId || clientId !== selectionEnd.clientId) {
return null;
}
return clientId;
}
/**
* Returns the currently selected block, or null if there is no selected block.
*
* @param {Object} state Global application state.
*
* @return {?Object} Selected block.
*/
function getSelectedBlock(state) {
var clientId = selectors_getSelectedBlockClientId(state);
return clientId ? selectors_getBlock(state, clientId) : null;
}
/**
* Given a block client ID, returns the root block from which the block is
* nested, an empty string for top-level blocks, or null if the block does not
* exist.
*
* @param {Object} state Editor state.
* @param {string} clientId Block from which to find root client ID.
*
* @return {?string} Root client ID, if exists
*/
function selectors_getBlockRootClientId(state, clientId) {
return state.blocks.parents[clientId] !== undefined ? state.blocks.parents[clientId] : null;
}
/**
* Given a block client ID, returns the list of all its parents from top to bottom.
*
* @param {Object} state Editor state.
* @param {string} clientId Block from which to find root client ID.
* @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
*
* @return {Array} ClientIDs of the parent blocks.
*/
var selectors_getBlockParents = Object(rememo["a" /* default */])(function (state, clientId) {
var ascending = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
var parents = [];
var current = clientId;
while (!!state.blocks.parents[current]) {
current = state.blocks.parents[current];
parents.push(current);
}
return ascending ? parents : parents.reverse();
}, function (state) {
return [state.blocks.parents];
});
/**
* Given a block client ID and a block name, returns the list of all its parents
* from top to bottom, filtered by the given name(s). For example, if passed
* 'core/group' as the blockName, it will only return parents which are group
* blocks. If passed `[ 'core/group', 'core/cover']`, as the blockName, it will
* return parents which are group blocks and parents which are cover blocks.
*
* @param {Object} state Editor state.
* @param {string} clientId Block from which to find root client ID.
* @param {string|string[]} blockName Block name(s) to filter.
* @param {boolean} ascending Order results from bottom to top (true) or top to bottom (false).
*
* @return {Array} ClientIDs of the parent blocks.
*/
var getBlockParentsByBlockName = Object(rememo["a" /* default */])(function (state, clientId, blockName) {
var ascending = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var parents = selectors_getBlockParents(state, clientId, ascending);
return Object(external_lodash_["map"])(Object(external_lodash_["filter"])(Object(external_lodash_["map"])(parents, function (id) {
return {
id: id,
name: selectors_getBlockName(state, id)
};
}), function (_ref) {
var name = _ref.name;
if (Array.isArray(blockName)) {
return blockName.includes(name);
}
return name === blockName;
}), function (_ref2) {
var id = _ref2.id;
return id;
});
}, function (state) {
return [state.blocks.parents];
});
/**
* Given a block client ID, returns the root of the hierarchy from which the block is nested, return the block itself for root level blocks.
*
* @param {Object} state Editor state.
* @param {string} clientId Block from which to find root client ID.
*
* @return {string} Root client ID
*/
function getBlockHierarchyRootClientId(state, clientId) {
var current = clientId;
var parent;
do {
parent = current;
current = state.blocks.parents[current];
} while (current);
return parent;
}
/**
* Given a block client ID, returns the lowest common ancestor with selected client ID.
*
* @param {Object} state Editor state.
* @param {string} clientId Block from which to find common ancestor client ID.
*
* @return {string} Common ancestor client ID or undefined
*/
function getLowestCommonAncestorWithSelectedBlock(state, clientId) {
var selectedId = selectors_getSelectedBlockClientId(state);
var clientParents = [].concat(Object(toConsumableArray["a" /* default */])(selectors_getBlockParents(state, clientId)), [clientId]);
var selectedParents = [].concat(Object(toConsumableArray["a" /* default */])(selectors_getBlockParents(state, selectedId)), [selectedId]);
var lowestCommonAncestor;
var maxDepth = Math.min(clientParents.length, selectedParents.length);
for (var index = 0; index < maxDepth; index++) {
if (clientParents[index] === selectedParents[index]) {
lowestCommonAncestor = clientParents[index];
} else {
break;
}
}
return lowestCommonAncestor;
}
/**
* Returns the client ID of the block adjacent one at the given reference
* startClientId and modifier directionality. Defaults start startClientId to
* the selected block, and direction as next block. Returns null if there is no
* adjacent block.
*
* @param {Object} state Editor state.
* @param {?string} startClientId Optional client ID of block from which to
* search.
* @param {?number} modifier Directionality multiplier (1 next, -1
* previous).
*
* @return {?string} Return the client ID of the block, or null if none exists.
*/
function getAdjacentBlockClientId(state, startClientId) {
var modifier = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
// Default to selected block.
if (startClientId === undefined) {
startClientId = selectors_getSelectedBlockClientId(state);
} // Try multi-selection starting at extent based on modifier.
if (startClientId === undefined) {
if (modifier < 0) {
startClientId = selectors_getFirstMultiSelectedBlockClientId(state);
} else {
startClientId = selectors_getLastMultiSelectedBlockClientId(state);
}
} // Validate working start client ID.
if (!startClientId) {
return null;
} // Retrieve start block root client ID, being careful to allow the falsey
// empty string top-level root by explicitly testing against null.
var rootClientId = selectors_getBlockRootClientId(state, startClientId);
if (rootClientId === null) {
return null;
}
var order = state.blocks.order;
var orderSet = order[rootClientId];
var index = orderSet.indexOf(startClientId);
var nextIndex = index + 1 * modifier; // Block was first in set and we're attempting to get previous.
if (nextIndex < 0) {
return null;
} // Block was last in set and we're attempting to get next.
if (nextIndex === orderSet.length) {
return null;
} // Assume incremented index is within the set.
return orderSet[nextIndex];
}
/**
* Returns the previous block's client ID from the given reference start ID.
* Defaults start to the selected block. Returns null if there is no previous
* block.
*
* @param {Object} state Editor state.
* @param {?string} startClientId Optional client ID of block from which to
* search.
*
* @return {?string} Adjacent block's client ID, or null if none exists.
*/
function selectors_getPreviousBlockClientId(state, startClientId) {
return getAdjacentBlockClientId(state, startClientId, -1);
}
/**
* Returns the next block's client ID from the given reference start ID.
* Defaults start to the selected block. Returns null if there is no next
* block.
*
* @param {Object} state Editor state.
* @param {?string} startClientId Optional client ID of block from which to
* search.
*
* @return {?string} Adjacent block's client ID, or null if none exists.
*/
function selectors_getNextBlockClientId(state, startClientId) {
return getAdjacentBlockClientId(state, startClientId, 1);
}
/**
* Returns the initial caret position for the selected block.
* This position is to used to position the caret properly when the selected block changes.
*
* @param {Object} state Global application state.
*
* @return {?Object} Selected block.
*/
function getSelectedBlocksInitialCaretPosition(state) {
return state.initialPosition;
}
/**
* Returns the current selection set of block client IDs (multiselection or single selection).
*
* @param {Object} state Editor state.
*
* @return {Array} Multi-selected block client IDs.
*/
var selectors_getSelectedBlockClientIds = Object(rememo["a" /* default */])(function (state) {
var _state$selection3 = state.selection,
selectionStart = _state$selection3.selectionStart,
selectionEnd = _state$selection3.selectionEnd;
if (selectionStart.clientId === undefined || selectionEnd.clientId === undefined) {
return selectors_EMPTY_ARRAY;
}
if (selectionStart.clientId === selectionEnd.clientId) {
return [selectionStart.clientId];
} // Retrieve root client ID to aid in retrieving relevant nested block
// order, being careful to allow the falsey empty string top-level root
// by explicitly testing against null.
var rootClientId = selectors_getBlockRootClientId(state, selectionStart.clientId);
if (rootClientId === null) {
return selectors_EMPTY_ARRAY;
}
var blockOrder = selectors_getBlockOrder(state, rootClientId);
var startIndex = blockOrder.indexOf(selectionStart.clientId);
var endIndex = blockOrder.indexOf(selectionEnd.clientId);
if (startIndex > endIndex) {
return blockOrder.slice(endIndex, startIndex + 1);
}
return blockOrder.slice(startIndex, endIndex + 1);
}, function (state) {
return [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId];
});
/**
* Returns the current multi-selection set of block client IDs, or an empty
* array if there is no multi-selection.
*
* @param {Object} state Editor state.
*
* @return {Array} Multi-selected block client IDs.
*/
function selectors_getMultiSelectedBlockClientIds(state) {
var _state$selection4 = state.selection,
selectionStart = _state$selection4.selectionStart,
selectionEnd = _state$selection4.selectionEnd;
if (selectionStart.clientId === selectionEnd.clientId) {
return selectors_EMPTY_ARRAY;
}
return selectors_getSelectedBlockClientIds(state);
}
/**
* Returns the current multi-selection set of blocks, or an empty array if
* there is no multi-selection.
*
* @param {Object} state Editor state.
*
* @return {Array} Multi-selected block objects.
*/
var getMultiSelectedBlocks = Object(rememo["a" /* default */])(function (state) {
var multiSelectedBlockClientIds = selectors_getMultiSelectedBlockClientIds(state);
if (!multiSelectedBlockClientIds.length) {
return selectors_EMPTY_ARRAY;
}
return multiSelectedBlockClientIds.map(function (clientId) {
return selectors_getBlock(state, clientId);
});
}, function (state) {
return [].concat(Object(toConsumableArray["a" /* default */])(selectors_getSelectedBlockClientIds.getDependants(state)), [state.blocks.byClientId, state.blocks.order, state.blocks.attributes]);
});
/**
* Returns the client ID of the first block in the multi-selection set, or null
* if there is no multi-selection.
*
* @param {Object} state Editor state.
*
* @return {?string} First block client ID in the multi-selection set.
*/
function selectors_getFirstMultiSelectedBlockClientId(state) {
return Object(external_lodash_["first"])(selectors_getMultiSelectedBlockClientIds(state)) || null;
}
/**
* Returns the client ID of the last block in the multi-selection set, or null
* if there is no multi-selection.
*
* @param {Object} state Editor state.
*
* @return {?string} Last block client ID in the multi-selection set.
*/
function selectors_getLastMultiSelectedBlockClientId(state) {
return Object(external_lodash_["last"])(selectors_getMultiSelectedBlockClientIds(state)) || null;
}
/**
* Returns true if a multi-selection exists, and the block corresponding to the
* specified client ID is the first block of the multi-selection set, or false
* otherwise.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is first in multi-selection.
*/
function isFirstMultiSelectedBlock(state, clientId) {
return selectors_getFirstMultiSelectedBlockClientId(state) === clientId;
}
/**
* Returns true if the client ID occurs within the block multi-selection, or
* false otherwise.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is in multi-selection set.
*/
function isBlockMultiSelected(state, clientId) {
return selectors_getMultiSelectedBlockClientIds(state).indexOf(clientId) !== -1;
}
/**
* Returns true if an ancestor of the block is multi-selected, or false
* otherwise.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Whether an ancestor of the block is in multi-selection
* set.
*/
var isAncestorMultiSelected = Object(rememo["a" /* default */])(function (state, clientId) {
var ancestorClientId = clientId;
var isMultiSelected = false;
while (ancestorClientId && !isMultiSelected) {
ancestorClientId = selectors_getBlockRootClientId(state, ancestorClientId);
isMultiSelected = isBlockMultiSelected(state, ancestorClientId);
}
return isMultiSelected;
}, function (state) {
return [state.blocks.order, state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId];
});
/**
* Returns the client ID of the block which begins the multi-selection set, or
* null if there is no multi-selection.
*
* This is not necessarily the first client ID in the selection.
*
* @see getFirstMultiSelectedBlockClientId
*
* @param {Object} state Editor state.
*
* @return {?string} Client ID of block beginning multi-selection.
*/
function selectors_getMultiSelectedBlocksStartClientId(state) {
var _state$selection5 = state.selection,
selectionStart = _state$selection5.selectionStart,
selectionEnd = _state$selection5.selectionEnd;
if (selectionStart.clientId === selectionEnd.clientId) {
return null;
}
return selectionStart.clientId || null;
}
/**
* Returns the client ID of the block which ends the multi-selection set, or
* null if there is no multi-selection.
*
* This is not necessarily the last client ID in the selection.
*
* @see getLastMultiSelectedBlockClientId
*
* @param {Object} state Editor state.
*
* @return {?string} Client ID of block ending multi-selection.
*/
function selectors_getMultiSelectedBlocksEndClientId(state) {
var _state$selection6 = state.selection,
selectionStart = _state$selection6.selectionStart,
selectionEnd = _state$selection6.selectionEnd;
if (selectionStart.clientId === selectionEnd.clientId) {
return null;
}
return selectionEnd.clientId || null;
}
/**
* Returns an array containing all block client IDs in the editor in the order
* they appear. Optionally accepts a root client ID of the block list for which
* the order should be returned, defaulting to the top-level block order.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {Array} Ordered client IDs of editor blocks.
*/
function selectors_getBlockOrder(state, rootClientId) {
return state.blocks.order[rootClientId || ''] || selectors_EMPTY_ARRAY;
}
/**
* Returns the index at which the block corresponding to the specified client
* ID occurs within the block order, or `-1` if the block does not exist.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {number} Index at which block exists in order.
*/
function selectors_getBlockIndex(state, clientId, rootClientId) {
return selectors_getBlockOrder(state, rootClientId).indexOf(clientId);
}
/**
* Returns true if the block corresponding to the specified client ID is
* currently selected and no multi-selection exists, or false otherwise.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is selected and multi-selection exists.
*/
function selectors_isBlockSelected(state, clientId) {
var _state$selection7 = state.selection,
selectionStart = _state$selection7.selectionStart,
selectionEnd = _state$selection7.selectionEnd;
if (selectionStart.clientId !== selectionEnd.clientId) {
return false;
}
return selectionStart.clientId === clientId;
}
/**
* Returns true if one of the block's inner blocks is selected.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
* @param {boolean} deep Perform a deep check.
*
* @return {boolean} Whether the block as an inner block selected
*/
function hasSelectedInnerBlock(state, clientId) {
var deep = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return Object(external_lodash_["some"])(selectors_getBlockOrder(state, clientId), function (innerClientId) {
return selectors_isBlockSelected(state, innerClientId) || isBlockMultiSelected(state, innerClientId) || deep && hasSelectedInnerBlock(state, innerClientId, deep);
});
}
/**
* Returns true if the block corresponding to the specified client ID is
* currently selected but isn't the last of the selected blocks. Here "last"
* refers to the block sequence in the document, _not_ the sequence of
* multi-selection, which is why `state.selectionEnd` isn't used.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {boolean} Whether block is selected and not the last in the
* selection.
*/
function isBlockWithinSelection(state, clientId) {
if (!clientId) {
return false;
}
var clientIds = selectors_getMultiSelectedBlockClientIds(state);
var index = clientIds.indexOf(clientId);
return index > -1 && index < clientIds.length - 1;
}
/**
* Returns true if a multi-selection has been made, or false otherwise.
*
* @param {Object} state Editor state.
*
* @return {boolean} Whether multi-selection has been made.
*/
function selectors_hasMultiSelection(state) {
var _state$selection8 = state.selection,
selectionStart = _state$selection8.selectionStart,
selectionEnd = _state$selection8.selectionEnd;
return selectionStart.clientId !== selectionEnd.clientId;
}
/**
* Whether in the process of multi-selecting or not. This flag is only true
* while the multi-selection is being selected (by mouse move), and is false
* once the multi-selection has been settled.
*
* @see hasMultiSelection
*
* @param {Object} state Global application state.
*
* @return {boolean} True if multi-selecting, false if not.
*/
function selectors_isMultiSelecting(state) {
return state.isMultiSelecting;
}
/**
* Selector that returns if multi-selection is enabled or not.
*
* @param {Object} state Global application state.
*
* @return {boolean} True if it should be possible to multi-select blocks, false if multi-selection is disabled.
*/
function selectors_isSelectionEnabled(state) {
return state.isSelectionEnabled;
}
/**
* Returns the block's editing mode, defaulting to "visual" if not explicitly
* assigned.
*
* @param {Object} state Editor state.
* @param {string} clientId Block client ID.
*
* @return {Object} Block editing mode.
*/
function selectors_getBlockMode(state, clientId) {
return state.blocksMode[clientId] || 'visual';
}
/**
* Returns true if the user is typing, or false otherwise.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether user is typing.
*/
function selectors_isTyping(state) {
return state.isTyping;
}
/**
* Returns true if the user is dragging blocks, or false otherwise.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether user is dragging blocks.
*/
function isDraggingBlocks(state) {
return !!state.draggedBlocks.length;
}
/**
* Returns the client ids of any blocks being directly dragged.
*
* This does not include children of a parent being dragged.
*
* @param {Object} state Global application state.
*
* @return {string[]} Array of dragged block client ids.
*/
function selectors_getDraggedBlockClientIds(state) {
return state.draggedBlocks;
}
/**
* Returns whether the block is being dragged.
*
* Only returns true if the block is being directly dragged,
* not if the block is a child of a parent being dragged.
* See `isAncestorBeingDragged` for child blocks.
*
* @param {Object} state Global application state.
* @param {string} clientId Client id for block to check.
*
* @return {boolean} Whether the block is being dragged.
*/
function isBlockBeingDragged(state, clientId) {
return state.draggedBlocks.includes(clientId);
}
/**
* Returns whether a parent/ancestor of the block is being dragged.
*
* @param {Object} state Global application state.
* @param {string} clientId Client id for block to check.
*
* @return {boolean} Whether the block's ancestor is being dragged.
*/
function isAncestorBeingDragged(state, clientId) {
// Return early if no blocks are being dragged rather than
// the more expensive check for parents.
if (!isDraggingBlocks(state)) {
return false;
}
var parents = selectors_getBlockParents(state, clientId);
return Object(external_lodash_["some"])(parents, function (parentClientId) {
return isBlockBeingDragged(state, parentClientId);
});
}
/**
* Returns true if the caret is within formatted text, or false otherwise.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether the caret is within formatted text.
*/
function selectors_isCaretWithinFormattedText(state) {
return state.isCaretWithinFormattedText;
}
/**
* Returns the insertion point. This will be:
*
* 1) The insertion point manually set using setInsertionPoint() or
* showInsertionPoint(); or
* 2) The point after the current block selection, if there is a selection; or
* 3) The point at the end of the block list.
*
* Components like will default to inserting blocks at this point.
*
* @param {Object} state Global application state.
*
* @return {Object} Insertion point object with `rootClientId` and `index`.
*/
function getBlockInsertionPoint(state) {
var rootClientId, index;
var insertionPoint = state.insertionPoint,
selectionEnd = state.selection.selectionEnd;
if (insertionPoint !== null) {
return insertionPoint;
}
var clientId = selectionEnd.clientId;
if (clientId) {
rootClientId = selectors_getBlockRootClientId(state, clientId) || undefined;
index = selectors_getBlockIndex(state, selectionEnd.clientId, rootClientId) + 1;
} else {
index = selectors_getBlockOrder(state).length;
}
return {
rootClientId: rootClientId,
index: index
};
}
/**
* Whether or not the insertion point should be shown to users. This is set
* using showInsertionPoint() or hideInsertionPoint().
*
* @param {Object} state Global application state.
*
* @return {?boolean} Whether the insertion point should be shown.
*/
function isBlockInsertionPointVisible(state) {
return state.insertionPointVisibility;
}
/**
* Returns whether the blocks matches the template or not.
*
* @param {boolean} state
* @return {?boolean} Whether the template is valid or not.
*/
function selectors_isValidTemplate(state) {
return state.template.isValid;
}
/**
* Returns the defined block template
*
* @param {boolean} state
* @return {?Array} Block Template
*/
function getTemplate(state) {
return state.settings.template;
}
/**
* Returns the defined block template lock. Optionally accepts a root block
* client ID as context, otherwise defaulting to the global context.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional block root client ID.
*
* @return {?string} Block Template Lock
*/
function selectors_getTemplateLock(state, rootClientId) {
if (!rootClientId) {
return state.settings.templateLock;
}
var blockListSettings = selectors_getBlockListSettings(state, rootClientId);
if (!blockListSettings) {
return null;
}
return blockListSettings.templateLock;
}
/**
* Determines if the given block type is allowed to be inserted into the block list.
* This function is not exported and not memoized because using a memoized selector
* inside another memoized selector is just a waste of time.
*
* @param {Object} state Editor state.
* @param {string|Object} blockName The block type object, e.g., the response
* from the block directory; or a string name of
* an installed block type, e.g.' core/paragraph'.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Whether the given block type is allowed to be inserted.
*/
var selectors_canInsertBlockTypeUnmemoized = function canInsertBlockTypeUnmemoized(state, blockName) {
var rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var checkAllowList = function checkAllowList(list, item) {
var defaultResult = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
if (Object(external_lodash_["isBoolean"])(list)) {
return list;
}
if (Object(external_lodash_["isArray"])(list)) {
// TODO: when there is a canonical way to detect that we are editing a post
// the following check should be changed to something like:
// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )
if (list.includes('core/post-content') && item === null) {
return true;
}
return list.includes(item);
}
return defaultResult;
};
var blockType;
if (blockName && 'object' === Object(esm_typeof["a" /* default */])(blockName)) {
blockType = blockName;
blockName = blockType.name;
} else {
blockType = Object(external_wp_blocks_["getBlockType"])(blockName);
}
if (!blockType) {
return false;
}
var _getSettings = selectors_getSettings(state),
allowedBlockTypes = _getSettings.allowedBlockTypes;
var isBlockAllowedInEditor = checkAllowList(allowedBlockTypes, blockName, true);
if (!isBlockAllowedInEditor) {
return false;
}
var isLocked = !!selectors_getTemplateLock(state, rootClientId);
if (isLocked) {
return false;
}
var parentBlockListSettings = selectors_getBlockListSettings(state, rootClientId); // The parent block doesn't have settings indicating it doesn't support
// inner blocks, return false.
if (rootClientId && parentBlockListSettings === undefined) {
return false;
}
var parentAllowedBlocks = parentBlockListSettings === null || parentBlockListSettings === void 0 ? void 0 : parentBlockListSettings.allowedBlocks;
var hasParentAllowedBlock = checkAllowList(parentAllowedBlocks, blockName);
var blockAllowedParentBlocks = blockType.parent;
var parentName = selectors_getBlockName(state, rootClientId);
var hasBlockAllowedParent = checkAllowList(blockAllowedParentBlocks, parentName);
if (hasParentAllowedBlock !== null && hasBlockAllowedParent !== null) {
return hasParentAllowedBlock || hasBlockAllowedParent;
} else if (hasParentAllowedBlock !== null) {
return hasParentAllowedBlock;
} else if (hasBlockAllowedParent !== null) {
return hasBlockAllowedParent;
}
return true;
};
/**
* Determines if the given block type is allowed to be inserted into the block list.
*
* @param {Object} state Editor state.
* @param {string} blockName The name of the block type, e.g.' core/paragraph'.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Whether the given block type is allowed to be inserted.
*/
var selectors_canInsertBlockType = Object(rememo["a" /* default */])(selectors_canInsertBlockTypeUnmemoized, function (state, blockName, rootClientId) {
return [state.blockListSettings[rootClientId], state.blocks.byClientId[rootClientId], state.settings.allowedBlockTypes, state.settings.templateLock];
});
/**
* Determines if the given blocks are allowed to be inserted into the block
* list.
*
* @param {Object} state Editor state.
* @param {string} clientIds The block client IDs to be inserted.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Whether the given blocks are allowed to be inserted.
*/
function selectors_canInsertBlocks(state, clientIds) {
var rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
return clientIds.every(function (id) {
return selectors_canInsertBlockType(state, selectors_getBlockName(state, id), rootClientId);
});
}
/**
* Returns information about how recently and frequently a block has been inserted.
*
* @param {Object} state Global application state.
* @param {string} id A string which identifies the insert, e.g. 'core/block/12'
*
* @return {?{ time: number, count: number }} An object containing `time` which is when the last
* insert occurred as a UNIX epoch, and `count` which is
* the number of inserts that have occurred.
*/
function getInsertUsage(state, id) {
var _state$preferences$in, _state$preferences$in2;
return (_state$preferences$in = (_state$preferences$in2 = state.preferences.insertUsage) === null || _state$preferences$in2 === void 0 ? void 0 : _state$preferences$in2[id]) !== null && _state$preferences$in !== void 0 ? _state$preferences$in : null;
}
/**
* Returns whether we can show a block type in the inserter
*
* @param {Object} state Global State
* @param {Object} blockType BlockType
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Whether the given block type is allowed to be shown in the inserter.
*/
var selectors_canIncludeBlockTypeInInserter = function canIncludeBlockTypeInInserter(state, blockType, rootClientId) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'inserter', true)) {
return false;
}
return selectors_canInsertBlockTypeUnmemoized(state, blockType.name, rootClientId);
};
/**
* Return a function to be used to tranform a block variation to an inserter item
*
* @param {Object} item Denormalized inserter item
* @return {Function} Function to transform a block variation to inserter item
*/
var getItemFromVariation = function getItemFromVariation(item) {
return function (variation) {
return selectors_objectSpread(selectors_objectSpread({}, item), {}, {
id: "".concat(item.id, "-").concat(variation.name),
icon: variation.icon || item.icon,
title: variation.title || item.title,
description: variation.description || item.description,
category: variation.category || item.category,
// If `example` is explicitly undefined for the variation, the preview will not be shown.
example: variation.hasOwnProperty('example') ? variation.example : item.example,
initialAttributes: selectors_objectSpread(selectors_objectSpread({}, item.initialAttributes), variation.attributes),
innerBlocks: variation.innerBlocks,
keywords: variation.keywords || item.keywords
});
};
};
/**
* Returns the calculated frecency.
*
* 'frecency' is a heuristic (https://en.wikipedia.org/wiki/Frecency)
* that combines block usage frequenty and recency.
*
* @param {number} time When the last insert occurred as a UNIX epoch
* @param {number} count The number of inserts that have occurred.
*
* @return {number} The calculated frecency.
*/
var calculateFrecency = function calculateFrecency(time, count) {
if (!time) {
return count;
} // The selector is cached, which means Date.now() is the last time that the
// relevant state changed. This suits our needs.
var duration = Date.now() - time;
switch (true) {
case duration < MILLISECONDS_PER_HOUR:
return count * 4;
case duration < MILLISECONDS_PER_DAY:
return count * 2;
case duration < MILLISECONDS_PER_WEEK:
return count / 2;
default:
return count / 4;
}
};
/**
* Returns a function that accepts a block type and builds an item to be shown
* in a specific context. It's used for building items for Inserter and available
* block Transfroms list.
*
* @param {Object} state Editor state.
* @param {Object} options Options object for handling the building of a block type.
* @param {string} options.buildScope The scope for which the item is going to be used.
* @return {Function} Function returns an item to be shown in a specific context (Inserter|Transforms list).
*/
var selectors_buildBlockTypeItem = function buildBlockTypeItem(state, _ref3) {
var _ref3$buildScope = _ref3.buildScope,
buildScope = _ref3$buildScope === void 0 ? 'inserter' : _ref3$buildScope;
return function (blockType) {
var id = blockType.name;
var isDisabled = false;
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType.name, 'multiple', true)) {
isDisabled = Object(external_lodash_["some"])(selectors_getBlocksByClientId(state, getClientIdsWithDescendants(state)), {
name: blockType.name
});
}
var _ref4 = getInsertUsage(state, id) || {},
time = _ref4.time,
_ref4$count = _ref4.count,
count = _ref4$count === void 0 ? 0 : _ref4$count;
var blockItemBase = {
id: id,
name: blockType.name,
title: blockType.title,
icon: blockType.icon,
isDisabled: isDisabled,
frecency: calculateFrecency(time, count)
};
if (buildScope === 'transform') return blockItemBase;
var inserterVariations = blockType.variations.filter(function (_ref5) {
var scope = _ref5.scope;
return !scope || scope.includes('inserter');
});
return selectors_objectSpread(selectors_objectSpread({}, blockItemBase), {}, {
initialAttributes: {},
description: blockType.description,
category: blockType.category,
keywords: blockType.keywords,
variations: inserterVariations,
example: blockType.example,
utility: 1 // deprecated
});
};
};
/**
* Determines the items that appear in the inserter. Includes both static
* items (e.g. a regular block type) and dynamic items (e.g. a reusable block).
*
* Each item object contains what's necessary to display a button in the
* inserter and handle its selection.
*
* The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
* that combines block usage frequenty and recency.
*
* Items are returned ordered descendingly by their 'utility' and 'frecency'.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {WPEditorInserterItem[]} Items that appear in inserter.
*
* @typedef {Object} WPEditorInserterItem
* @property {string} id Unique identifier for the item.
* @property {string} name The type of block to create.
* @property {Object} initialAttributes Attributes to pass to the newly created block.
* @property {string} title Title of the item, as it appears in the inserter.
* @property {string} icon Dashicon for the item, as it appears in the inserter.
* @property {string} category Block category that the item is associated with.
* @property {string[]} keywords Keywords that can be searched to find this item.
* @property {boolean} isDisabled Whether or not the user should be prevented from inserting
* this item.
* @property {number} frecency Heuristic that combines frequency and recency.
*/
var selectors_getInserterItems = Object(rememo["a" /* default */])(function (state) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var buildBlockTypeInserterItem = selectors_buildBlockTypeItem(state, {
buildScope: 'inserter'
});
var buildReusableBlockInserterItem = function buildReusableBlockInserterItem(reusableBlock) {
var id = "core/block/".concat(reusableBlock.id);
var referencedBlocks = __experimentalGetParsedReusableBlock(state, reusableBlock.id);
var referencedBlockType;
if (referencedBlocks.length === 1) {
referencedBlockType = Object(external_wp_blocks_["getBlockType"])(referencedBlocks[0].name);
}
var _ref6 = getInsertUsage(state, id) || {},
time = _ref6.time,
_ref6$count = _ref6.count,
count = _ref6$count === void 0 ? 0 : _ref6$count;
var frecency = calculateFrecency(time, count);
return {
id: id,
name: 'core/block',
initialAttributes: {
ref: reusableBlock.id
},
title: reusableBlock.title.raw,
icon: referencedBlockType ? referencedBlockType.icon : templateIcon,
category: 'reusable',
keywords: [],
isDisabled: false,
utility: 1,
// deprecated
frecency: frecency
};
};
var blockTypeInserterItems = Object(external_wp_blocks_["getBlockTypes"])().filter(function (blockType) {
return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId);
}).map(buildBlockTypeInserterItem);
var reusableBlockInserterItems = selectors_canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) ? getReusableBlocks(state).map(buildReusableBlockInserterItem) : []; // Exclude any block type item that is to be replaced by a default
// variation.
var visibleBlockTypeInserterItems = blockTypeInserterItems.filter(function (_ref7) {
var _ref7$variations = _ref7.variations,
variations = _ref7$variations === void 0 ? [] : _ref7$variations;
return !variations.some(function (_ref8) {
var isDefault = _ref8.isDefault;
return isDefault;
});
});
var blockVariations = []; // Show all available blocks with variations
var _iterator = selectors_createForOfIteratorHelper(blockTypeInserterItems),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var item = _step.value;
var _item$variations = item.variations,
variations = _item$variations === void 0 ? [] : _item$variations;
if (variations.length) {
var variationMapper = getItemFromVariation(item);
blockVariations.push.apply(blockVariations, Object(toConsumableArray["a" /* default */])(variations.map(variationMapper)));
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return [].concat(Object(toConsumableArray["a" /* default */])(visibleBlockTypeInserterItems), blockVariations, Object(toConsumableArray["a" /* default */])(reusableBlockInserterItems));
}, function (state, rootClientId) {
return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.blocks.order, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_wp_blocks_["getBlockTypes"])()];
});
/**
* Determines the items that appear in the available block transforms list.
*
* Each item object contains what's necessary to display a menu item in the
* transform list and handle its selection.
*
* The 'frecency' property is a heuristic (https://en.wikipedia.org/wiki/Frecency)
* that combines block usage frequenty and recency.
*
* Items are returned ordered descendingly by their 'frecency'.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {WPEditorTransformItem[]} Items that appear in inserter.
*
* @typedef {Object} WPEditorTransformItem
* @property {string} id Unique identifier for the item.
* @property {string} name The type of block to create.
* @property {string} title Title of the item, as it appears in the inserter.
* @property {string} icon Dashicon for the item, as it appears in the inserter.
* @property {boolean} isDisabled Whether or not the user should be prevented from inserting
* this item.
* @property {number} frecency Heuristic that combines frequency and recency.
*/
var selectors_getBlockTransformItems = Object(rememo["a" /* default */])(function (state, blocks) {
var rootClientId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
var buildBlockTypeTransformItem = selectors_buildBlockTypeItem(state, {
buildScope: 'transform'
});
var blockTypeTransformItems = Object(external_wp_blocks_["getBlockTypes"])().filter(function (blockType) {
return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId);
}).map(buildBlockTypeTransformItem);
var itemsByName = Object(external_lodash_["mapKeys"])(blockTypeTransformItems, function (_ref9) {
var name = _ref9.name;
return name;
});
var possibleTransforms = Object(external_wp_blocks_["getPossibleBlockTransformations"])(blocks).reduce(function (accumulator, block) {
if (itemsByName[block === null || block === void 0 ? void 0 : block.name]) {
accumulator.push(itemsByName[block.name]);
}
return accumulator;
}, []);
var possibleBlockTransformations = Object(external_lodash_["orderBy"])(possibleTransforms, function (block) {
return itemsByName[block.name].frecency;
}, 'desc');
return possibleBlockTransformations;
}, function (state, rootClientId) {
return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.preferences.insertUsage, state.settings.allowedBlockTypes, state.settings.templateLock, Object(external_wp_blocks_["getBlockTypes"])()];
});
/**
* Determines whether there are items to show in the inserter.
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {boolean} Items that appear in inserter.
*/
var selectors_hasInserterItems = Object(rememo["a" /* default */])(function (state) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var hasBlockType = Object(external_lodash_["some"])(Object(external_wp_blocks_["getBlockTypes"])(), function (blockType) {
return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId);
});
if (hasBlockType) {
return true;
}
var hasReusableBlock = selectors_canInsertBlockTypeUnmemoized(state, 'core/block', rootClientId) && getReusableBlocks(state).length > 0;
return hasReusableBlock;
}, function (state, rootClientId) {
return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, getReusableBlocks(state), Object(external_wp_blocks_["getBlockTypes"])()];
});
/**
* Returns the list of allowed inserter blocks for inner blocks children
*
* @param {Object} state Editor state.
* @param {?string} rootClientId Optional root client ID of block list.
*
* @return {Array?} The list of allowed block types.
*/
var selectors_experimentalGetAllowedBlocks = Object(rememo["a" /* default */])(function (state) {
var rootClientId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
if (!rootClientId) {
return;
}
return Object(external_lodash_["filter"])(Object(external_wp_blocks_["getBlockTypes"])(), function (blockType) {
return selectors_canIncludeBlockTypeInInserter(state, blockType, rootClientId);
});
}, function (state, rootClientId) {
return [state.blockListSettings[rootClientId], state.blocks.byClientId, state.settings.allowedBlockTypes, state.settings.templateLock, Object(external_wp_blocks_["getBlockTypes"])()];
});
/**
* Returns the Block List settings of a block, if any exist.
*
* @param {Object} state Editor state.
* @param {?string} clientId Block client ID.
*
* @return {?Object} Block settings of the block if set.
*/
function selectors_getBlockListSettings(state, clientId) {
return state.blockListSettings[clientId];
}
/**
* Returns the editor settings.
*
* @param {Object} state Editor state.
*
* @return {Object} The editor settings object.
*/
function selectors_getSettings(state) {
return state.settings;
}
/**
* Returns true if the most recent block change is be considered persistent, or
* false otherwise. A persistent change is one committed by BlockEditorProvider
* via its `onChange` callback, in addition to `onInput`.
*
* @param {Object} state Block editor state.
*
* @return {boolean} Whether the most recent block change was persistent.
*/
function isLastBlockChangePersistent(state) {
return state.blocks.isPersistentChange;
}
/**
* Returns the Block List settings for an array of blocks, if any exist.
*
* @param {Object} state Editor state.
* @param {Array} clientIds Block client IDs.
*
* @return {Array} Block List Settings for each of the found blocks
*/
var selectors_experimentalGetBlockListSettingsForBlocks = Object(rememo["a" /* default */])(function (state, clientIds) {
return Object(external_lodash_["filter"])(state.blockListSettings, function (value, key) {
return clientIds.includes(key);
});
}, function (state) {
return [state.blockListSettings];
});
/**
* Returns the parsed block saved as shared block with the given ID.
*
* @param {Object} state Global application state.
* @param {number|string} ref The shared block's ID.
*
* @return {Object} The parsed block.
*/
var __experimentalGetParsedReusableBlock = Object(rememo["a" /* default */])(function (state, ref) {
var reusableBlock = Object(external_lodash_["find"])(getReusableBlocks(state), function (block) {
return block.id === ref;
});
if (!reusableBlock) {
return null;
} // Only reusableBlock.content.raw should be used here, `reusableBlock.content` is a
// workaround until #22127 is fixed.
return Object(external_wp_blocks_["parse"])(typeof reusableBlock.content.raw === 'string' ? reusableBlock.content.raw : reusableBlock.content);
}, function (state) {
return [getReusableBlocks(state)];
});
/**
* Returns the title of a given reusable block
*
* @param {Object} state Global application state.
* @param {number|string} ref The shared block's ID.
*
* @return {string} The reusable block saved title.
*/
var selectors_experimentalGetReusableBlockTitle = Object(rememo["a" /* default */])(function (state, ref) {
var _reusableBlock$title;
var reusableBlock = Object(external_lodash_["find"])(getReusableBlocks(state), function (block) {
return block.id === ref;
});
if (!reusableBlock) {
return null;
}
return (_reusableBlock$title = reusableBlock.title) === null || _reusableBlock$title === void 0 ? void 0 : _reusableBlock$title.raw;
}, function (state) {
return [getReusableBlocks(state)];
});
/**
* Returns true if the most recent block change is be considered ignored, or
* false otherwise. An ignored change is one not to be committed by
* BlockEditorProvider, neither via `onChange` nor `onInput`.
*
* @param {Object} state Block editor state.
*
* @return {boolean} Whether the most recent block change was ignored.
*/
function __unstableIsLastBlockChangeIgnored(state) {
// TODO: Removal Plan: Changes incurred by RECEIVE_BLOCKS should not be
// ignored if in-fact they result in a change in blocks state. The current
// need to ignore changes not a result of user interaction should be
// accounted for in the refactoring of reusable blocks as occurring within
// their own separate block editor / state (#7119).
return state.blocks.isIgnoredChange;
}
/**
* Returns the block attributes changed as a result of the last dispatched
* action.
*
* @param {Object} state Block editor state.
*
* @return {Object} Subsets of block attributes changed, keyed
* by block client ID.
*/
function __experimentalGetLastBlockAttributeChanges(state) {
return state.lastBlockAttributesChange;
}
/**
* Returns the available reusable blocks
*
* @param {Object} state Global application state.
*
* @return {Array} Reusable blocks
*/
function getReusableBlocks(state) {
var _state$settings$__exp, _state$settings;
return (_state$settings$__exp = state === null || state === void 0 ? void 0 : (_state$settings = state.settings) === null || _state$settings === void 0 ? void 0 : _state$settings.__experimentalReusableBlocks) !== null && _state$settings$__exp !== void 0 ? _state$settings$__exp : selectors_EMPTY_ARRAY;
}
/**
* Returns whether the navigation mode is enabled.
*
* @param {Object} state Editor state.
*
* @return {boolean} Is navigation mode enabled.
*/
function selectors_isNavigationMode(state) {
return state.isNavigationMode;
}
/**
* Returns whether block moving mode is enabled.
*
* @param {Object} state Editor state.
*
* @return {string} Client Id of moving block.
*/
function selectors_hasBlockMovingClientId(state) {
return state.hasBlockMovingClientId;
}
/**
* Returns true if the last change was an automatic change, false otherwise.
*
* @param {Object} state Global application state.
*
* @return {boolean} Whether the last change was automatic.
*/
function selectors_didAutomaticChange(state) {
return !!state.automaticChangeStatus;
}
/**
* Returns true if the current highlighted block matches the block clientId.
*
* @param {Object} state Global application state.
* @param {string} clientId The block to check.
*
* @return {boolean} Whether the block is currently highlighted.
*/
function isBlockHighlighted(state, clientId) {
return state.highlightedBlock === clientId;
}
/**
* Checks if a given block has controlled inner blocks.
*
* @param {Object} state Global application state.
* @param {string} clientId The block to check.
*
* @return {boolean} True if the block has controlled inner blocks.
*/
function areInnerBlocksControlled(state, clientId) {
return !!state.blocks.controlledInnerBlocks[clientId];
}
/**
* Returns the clientId for the first 'active' block of a given array of block names.
* A block is 'active' if it (or a child) is the selected block.
* Returns the first match moving up the DOM from the selected block.
*
* @param {Object} state Global application state.
* @param {string[]} validBlocksNames The names of block types to check for.
*
* @return {string} The matching block's clientId.
*/
var __experimentalGetActiveBlockIdByBlockNames = Object(rememo["a" /* default */])(function (state, validBlockNames) {
if (!validBlockNames.length) {
return null;
} // Check if selected block is a valid entity area.
var selectedBlockClientId = selectors_getSelectedBlockClientId(state);
if (validBlockNames.includes(selectors_getBlockName(state, selectedBlockClientId))) {
return selectedBlockClientId;
} // Check if first selected block is a child of a valid entity area.
var multiSelectedBlockClientIds = selectors_getMultiSelectedBlockClientIds(state);
var entityAreaParents = getBlockParentsByBlockName(state, selectedBlockClientId || multiSelectedBlockClientIds[0], validBlockNames);
if (entityAreaParents) {
// Last parent closest/most interior.
return Object(external_lodash_["last"])(entityAreaParents);
}
return null;
}, function (state, validBlockNames) {
return [state.selection.selectionStart.clientId, state.selection.selectionEnd.clientId, validBlockNames];
});
// EXTERNAL MODULE: external "regeneratorRuntime"
var external_regeneratorRuntime_ = __webpack_require__(16);
var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/controls.js
/**
* WordPress dependencies
*/
var __unstableMarkAutomaticChangeFinalControl = function __unstableMarkAutomaticChangeFinalControl() {
return {
type: 'MARK_AUTOMATIC_CHANGE_FINAL_CONTROL'
};
};
var controls_controls = {
SLEEP: function SLEEP(_ref) {
var duration = _ref.duration;
return new Promise(function (resolve) {
setTimeout(resolve, duration);
});
},
MARK_AUTOMATIC_CHANGE_FINAL_CONTROL: Object(external_wp_data_["createRegistryControl"])(function (registry) {
return function () {
var _window = window,
_window$requestIdleCa = _window.requestIdleCallback,
requestIdleCallback = _window$requestIdleCa === void 0 ? function (callback) {
return setTimeout(callback, 100);
} : _window$requestIdleCa;
requestIdleCallback(function () {
return registry.dispatch('core/block-editor').__unstableMarkAutomaticChangeFinal();
});
};
})
};
/* harmony default export */ var store_controls = (controls_controls);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/actions.js
function actions_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = actions_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function actions_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return actions_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return actions_arrayLikeToArray(o, minLen); }
function actions_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function actions_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function actions_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { actions_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { actions_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
var _marked = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(ensureDefaultBlock),
_marked2 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_resetBlocks),
_marked3 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(validateBlocksToTemplate),
_marked4 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(selectPreviousBlock),
_marked5 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(selectNextBlock),
_marked6 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_multiSelect),
_marked7 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_replaceBlocks),
_marked8 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_moveBlocksToPosition),
_marked9 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_moveBlockToPosition),
_marked10 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_insertBlocks),
_marked11 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(synchronizeTemplate),
_marked12 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_mergeBlocks),
_marked13 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_removeBlocks),
_marked14 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_unstableMarkAutomaticChange),
_marked15 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_setNavigationMode),
_marked16 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_setBlockMovingClientId),
_marked17 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_duplicateBlocks),
_marked18 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_insertBeforeBlock),
_marked19 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_insertAfterBlock),
_marked20 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(actions_flashBlock);
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Generator which will yield a default block insert action if there
* are no other blocks at the root of the editor. This generator should be used
* in actions which may result in no blocks remaining in the editor (removal,
* replacement, etc).
*/
function ensureDefaultBlock() {
var count;
return external_regeneratorRuntime_default.a.wrap(function ensureDefaultBlock$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockCount');
case 2:
count = _context.sent;
if (!(count === 0)) {
_context.next = 7;
break;
}
_context.next = 6;
return actions_insertDefaultBlock();
case 6:
return _context.abrupt("return", _context.sent);
case 7:
case "end":
return _context.stop();
}
}
}, _marked);
}
/**
* Returns an action object used in signalling that blocks state should be
* reset to the specified array of blocks, taking precedence over any other
* content reflected as an edit in state.
*
* @param {Array} blocks Array of blocks.
*/
function actions_resetBlocks(blocks) {
return external_regeneratorRuntime_default.a.wrap(function resetBlocks$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return {
type: 'RESET_BLOCKS',
blocks: blocks
};
case 2:
return _context2.delegateYield(validateBlocksToTemplate(blocks), "t0", 3);
case 3:
return _context2.abrupt("return", _context2.t0);
case 4:
case "end":
return _context2.stop();
}
}
}, _marked2);
}
/**
* Block validity is a function of blocks state (at the point of a
* reset) and the template setting. As a compromise to its placement
* across distinct parts of state, it is implemented here as a side-
* effect of the block reset action.
*
* @param {Array} blocks Array of blocks.
*/
function validateBlocksToTemplate(blocks) {
var template, templateLock, isBlocksValidToTemplate, isValidTemplate;
return external_regeneratorRuntime_default.a.wrap(function validateBlocksToTemplate$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplate');
case 2:
template = _context3.sent;
_context3.next = 5;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplateLock');
case 5:
templateLock = _context3.sent;
// Unlocked templates are considered always valid because they act
// as default values only.
isBlocksValidToTemplate = !template || templateLock !== 'all' || Object(external_wp_blocks_["doBlocksMatchTemplate"])(blocks, template); // Update if validity has changed.
_context3.next = 9;
return external_wp_data_["controls"].select('core/block-editor', 'isValidTemplate');
case 9:
isValidTemplate = _context3.sent;
if (!(isBlocksValidToTemplate !== isValidTemplate)) {
_context3.next = 14;
break;
}
_context3.next = 13;
return setTemplateValidity(isBlocksValidToTemplate);
case 13:
return _context3.abrupt("return", isBlocksValidToTemplate);
case 14:
case "end":
return _context3.stop();
}
}
}, _marked3);
}
/**
* A block selection object.
*
* @typedef {Object} WPBlockSelection
*
* @property {string} clientId A block client ID.
* @property {string} attributeKey A block attribute key.
* @property {number} offset An attribute value offset, based on the rich
* text value. See `wp.richText.create`.
*/
/**
* Returns an action object used in signalling that selection state should be
* reset to the specified selection.
*
* @param {WPBlockSelection} selectionStart The selection start.
* @param {WPBlockSelection} selectionEnd The selection end.
*
* @return {Object} Action object.
*/
function actions_resetSelection(selectionStart, selectionEnd) {
return {
type: 'RESET_SELECTION',
selectionStart: selectionStart,
selectionEnd: selectionEnd
};
}
/**
* Returns an action object used in signalling that blocks have been received.
* Unlike resetBlocks, these should be appended to the existing known set, not
* replacing.
*
* @param {Object[]} blocks Array of block objects.
*
* @return {Object} Action object.
*/
function receiveBlocks(blocks) {
return {
type: 'RECEIVE_BLOCKS',
blocks: blocks
};
}
/**
* Returns an action object used in signalling that the multiple blocks'
* attributes with the specified client IDs have been updated.
*
* @param {string|string[]} clientIds Block client IDs.
* @param {Object} attributes Block attributes to be merged.
*
* @return {Object} Action object.
*/
function actions_updateBlockAttributes(clientIds, attributes) {
return {
type: 'UPDATE_BLOCK_ATTRIBUTES',
clientIds: Object(external_lodash_["castArray"])(clientIds),
attributes: attributes
};
}
/**
* Returns an action object used in signalling that the block with the
* specified client ID has been updated.
*
* @param {string} clientId Block client ID.
* @param {Object} updates Block attributes to be merged.
*
* @return {Object} Action object.
*/
function actions_updateBlock(clientId, updates) {
return {
type: 'UPDATE_BLOCK',
clientId: clientId,
updates: updates
};
}
/**
* Returns an action object used in signalling that the block with the
* specified client ID has been selected, optionally accepting a position
* value reflecting its selection directionality. An initialPosition of -1
* reflects a reverse selection.
*
* @param {string} clientId Block client ID.
* @param {?number} initialPosition Optional initial position. Pass as -1 to
* reflect reverse selection.
*
* @return {Object} Action object.
*/
function actions_selectBlock(clientId) {
var initialPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
return {
type: 'SELECT_BLOCK',
initialPosition: initialPosition,
clientId: clientId
};
}
/**
* Yields action objects used in signalling that the block preceding the given
* clientId should be selected.
*
* @param {string} clientId Block client ID.
*/
function selectPreviousBlock(clientId) {
var previousBlockClientId;
return external_regeneratorRuntime_default.a.wrap(function selectPreviousBlock$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return external_wp_data_["controls"].select('core/block-editor', 'getPreviousBlockClientId', clientId);
case 2:
previousBlockClientId = _context4.sent;
if (!previousBlockClientId) {
_context4.next = 7;
break;
}
_context4.next = 6;
return actions_selectBlock(previousBlockClientId, -1);
case 6:
return _context4.abrupt("return", [previousBlockClientId]);
case 7:
case "end":
return _context4.stop();
}
}
}, _marked4);
}
/**
* Yields action objects used in signalling that the block following the given
* clientId should be selected.
*
* @param {string} clientId Block client ID.
*/
function selectNextBlock(clientId) {
var nextBlockClientId;
return external_regeneratorRuntime_default.a.wrap(function selectNextBlock$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
_context5.next = 2;
return external_wp_data_["controls"].select('core/block-editor', 'getNextBlockClientId', clientId);
case 2:
nextBlockClientId = _context5.sent;
if (!nextBlockClientId) {
_context5.next = 7;
break;
}
_context5.next = 6;
return actions_selectBlock(nextBlockClientId);
case 6:
return _context5.abrupt("return", [nextBlockClientId]);
case 7:
case "end":
return _context5.stop();
}
}
}, _marked5);
}
/**
* Returns an action object used in signalling that a block multi-selection has started.
*
* @return {Object} Action object.
*/
function actions_startMultiSelect() {
return {
type: 'START_MULTI_SELECT'
};
}
/**
* Returns an action object used in signalling that block multi-selection stopped.
*
* @return {Object} Action object.
*/
function actions_stopMultiSelect() {
return {
type: 'STOP_MULTI_SELECT'
};
}
/**
* Returns an action object used in signalling that block multi-selection changed.
*
* @param {string} start First block of the multi selection.
* @param {string} end Last block of the multiselection.
*/
function actions_multiSelect(start, end) {
var blockCount;
return external_regeneratorRuntime_default.a.wrap(function multiSelect$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
_context6.next = 2;
return {
type: 'MULTI_SELECT',
start: start,
end: end
};
case 2:
_context6.next = 4;
return external_wp_data_["controls"].select('core/block-editor', 'getSelectedBlockCount');
case 4:
blockCount = _context6.sent;
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["sprintf"])(
/* translators: %s: number of selected blocks */
Object(external_wp_i18n_["_n"])('%s block selected.', '%s blocks selected.', blockCount), blockCount), 'assertive');
case 6:
case "end":
return _context6.stop();
}
}
}, _marked6);
}
/**
* Returns an action object used in signalling that the block selection is cleared.
*
* @return {Object} Action object.
*/
function actions_clearSelectedBlock() {
return {
type: 'CLEAR_SELECTED_BLOCK'
};
}
/**
* Returns an action object that enables or disables block selection.
*
* @param {boolean} [isSelectionEnabled=true] Whether block selection should
* be enabled.
*
* @return {Object} Action object.
*/
function actions_toggleSelection() {
var isSelectionEnabled = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
return {
type: 'TOGGLE_SELECTION',
isSelectionEnabled: isSelectionEnabled
};
}
function getBlocksWithDefaultStylesApplied(blocks, blockEditorSettings) {
var _blockEditorSettings$, _blockEditorSettings$2;
var preferredStyleVariations = (_blockEditorSettings$ = blockEditorSettings === null || blockEditorSettings === void 0 ? void 0 : (_blockEditorSettings$2 = blockEditorSettings.__experimentalPreferredStyleVariations) === null || _blockEditorSettings$2 === void 0 ? void 0 : _blockEditorSettings$2.value) !== null && _blockEditorSettings$ !== void 0 ? _blockEditorSettings$ : {};
return blocks.map(function (block) {
var _block$attributes;
var blockName = block.name;
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'defaultStylePicker', true)) {
return block;
}
if (!preferredStyleVariations[blockName]) {
return block;
}
var className = (_block$attributes = block.attributes) === null || _block$attributes === void 0 ? void 0 : _block$attributes.className;
if (className !== null && className !== void 0 && className.includes('is-style-')) {
return block;
}
var _block$attributes2 = block.attributes,
attributes = _block$attributes2 === void 0 ? {} : _block$attributes2;
var blockStyle = preferredStyleVariations[blockName];
return actions_objectSpread(actions_objectSpread({}, block), {}, {
attributes: actions_objectSpread(actions_objectSpread({}, attributes), {}, {
className: "".concat(className || '', " is-style-").concat(blockStyle).trim()
})
});
});
}
/**
* Returns an action object signalling that a blocks should be replaced with
* one or more replacement blocks.
*
* @param {(string|string[])} clientIds Block client ID(s) to replace.
* @param {(Object|Object[])} blocks Replacement block(s).
* @param {number} indexToSelect Index of replacement block to select.
* @param {number} initialPosition Index of caret after in the selected block after the operation.
* @param {?Object} meta Optional Meta values to be passed to the action object.
*
* @yield {Object} Action object.
*/
function actions_replaceBlocks(clientIds, blocks, indexToSelect, initialPosition, meta) {
var rootClientId, index, block, canInsertBlock;
return external_regeneratorRuntime_default.a.wrap(function replaceBlocks$(_context7) {
while (1) {
switch (_context7.prev = _context7.next) {
case 0:
clientIds = Object(external_lodash_["castArray"])(clientIds);
_context7.t0 = getBlocksWithDefaultStylesApplied;
_context7.t1 = Object(external_lodash_["castArray"])(blocks);
_context7.next = 5;
return external_wp_data_["controls"].select('core/block-editor', 'getSettings');
case 5:
_context7.t2 = _context7.sent;
blocks = (0, _context7.t0)(_context7.t1, _context7.t2);
_context7.next = 9;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockRootClientId', Object(external_lodash_["first"])(clientIds));
case 9:
rootClientId = _context7.sent;
index = 0;
case 11:
if (!(index < blocks.length)) {
_context7.next = 21;
break;
}
block = blocks[index];
_context7.next = 15;
return external_wp_data_["controls"].select('core/block-editor', 'canInsertBlockType', block.name, rootClientId);
case 15:
canInsertBlock = _context7.sent;
if (canInsertBlock) {
_context7.next = 18;
break;
}
return _context7.abrupt("return");
case 18:
index++;
_context7.next = 11;
break;
case 21:
_context7.next = 23;
return {
type: 'REPLACE_BLOCKS',
clientIds: clientIds,
blocks: blocks,
time: Date.now(),
indexToSelect: indexToSelect,
initialPosition: initialPosition,
meta: meta
};
case 23:
return _context7.delegateYield(ensureDefaultBlock(), "t3", 24);
case 24:
case "end":
return _context7.stop();
}
}
}, _marked7);
}
/**
* Returns an action object signalling that a single block should be replaced
* with one or more replacement blocks.
*
* @param {(string|string[])} clientId Block client ID to replace.
* @param {(Object|Object[])} block Replacement block(s).
*
* @return {Object} Action object.
*/
function replaceBlock(clientId, block) {
return actions_replaceBlocks(clientId, block);
}
/**
* Higher-order action creator which, given the action type to dispatch creates
* an action creator for managing block movement.
*
* @param {string} type Action type to dispatch.
*
* @return {Function} Action creator.
*/
function createOnMove(type) {
return function (clientIds, rootClientId) {
return {
clientIds: Object(external_lodash_["castArray"])(clientIds),
type: type,
rootClientId: rootClientId
};
};
}
var actions_moveBlocksDown = createOnMove('MOVE_BLOCKS_DOWN');
var actions_moveBlocksUp = createOnMove('MOVE_BLOCKS_UP');
/**
* Returns an action object signalling that the given blocks should be moved to
* a new position.
*
* @param {?string} clientIds The client IDs of the blocks.
* @param {?string} fromRootClientId Root client ID source.
* @param {?string} toRootClientId Root client ID destination.
* @param {number} index The index to move the blocks to.
*
* @yield {Object} Action object.
*/
function actions_moveBlocksToPosition(clientIds) {
var fromRootClientId,
toRootClientId,
index,
templateLock,
action,
canInsertBlocks,
_args8 = arguments;
return external_regeneratorRuntime_default.a.wrap(function moveBlocksToPosition$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
fromRootClientId = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : '';
toRootClientId = _args8.length > 2 && _args8[2] !== undefined ? _args8[2] : '';
index = _args8.length > 3 ? _args8[3] : undefined;
_context8.next = 5;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplateLock', fromRootClientId);
case 5:
templateLock = _context8.sent;
if (!(templateLock === 'all')) {
_context8.next = 8;
break;
}
return _context8.abrupt("return");
case 8:
action = {
type: 'MOVE_BLOCKS_TO_POSITION',
fromRootClientId: fromRootClientId,
toRootClientId: toRootClientId,
clientIds: clientIds,
index: index
}; // If moving inside the same root block the move is always possible.
if (!(fromRootClientId === toRootClientId)) {
_context8.next = 13;
break;
}
_context8.next = 12;
return action;
case 12:
return _context8.abrupt("return");
case 13:
if (!(templateLock === 'insert')) {
_context8.next = 15;
break;
}
return _context8.abrupt("return");
case 15:
_context8.next = 17;
return external_wp_data_["controls"].select('core/block-editor', 'canInsertBlocks', clientIds, toRootClientId);
case 17:
canInsertBlocks = _context8.sent;
if (!canInsertBlocks) {
_context8.next = 21;
break;
}
_context8.next = 21;
return action;
case 21:
case "end":
return _context8.stop();
}
}
}, _marked8);
}
/**
* Returns an action object signalling that the given block should be moved to a
* new position.
*
* @param {?string} clientId The client ID of the block.
* @param {?string} fromRootClientId Root client ID source.
* @param {?string} toRootClientId Root client ID destination.
* @param {number} index The index to move the block to.
*
* @yield {Object} Action object.
*/
function actions_moveBlockToPosition(clientId) {
var fromRootClientId,
toRootClientId,
index,
_args9 = arguments;
return external_regeneratorRuntime_default.a.wrap(function moveBlockToPosition$(_context9) {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
fromRootClientId = _args9.length > 1 && _args9[1] !== undefined ? _args9[1] : '';
toRootClientId = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : '';
index = _args9.length > 3 ? _args9[3] : undefined;
_context9.next = 5;
return actions_moveBlocksToPosition([clientId], fromRootClientId, toRootClientId, index);
case 5:
case "end":
return _context9.stop();
}
}
}, _marked9);
}
/**
* Returns an action object used in signalling that a single block should be
* inserted, optionally at a specific index respective a root block list.
*
* @param {Object} block Block object to insert.
* @param {?number} index Index at which block should be inserted.
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
*
* @return {Object} Action object.
*/
function actions_insertBlock(block, index, rootClientId) {
var updateSelection = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
return actions_insertBlocks([block], index, rootClientId, updateSelection);
}
/**
* Returns an action object used in signalling that an array of blocks should
* be inserted, optionally at a specific index respective a root block list.
*
* @param {Object[]} blocks Block objects to insert.
* @param {?number} index Index at which block should be inserted.
* @param {?string} rootClientId Optional root client ID of block list on which to insert.
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
* @param {?Object} meta Optional Meta values to be passed to the action object.
*
* @return {Object} Action object.
*/
function actions_insertBlocks(blocks, index, rootClientId) {
var updateSelection,
meta,
allowedBlocks,
_iterator,
_step,
block,
isValid,
_args10 = arguments;
return external_regeneratorRuntime_default.a.wrap(function insertBlocks$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
updateSelection = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : true;
meta = _args10.length > 4 ? _args10[4] : undefined;
_context10.t0 = getBlocksWithDefaultStylesApplied;
_context10.t1 = Object(external_lodash_["castArray"])(blocks);
_context10.next = 6;
return external_wp_data_["controls"].select('core/block-editor', 'getSettings');
case 6:
_context10.t2 = _context10.sent;
blocks = (0, _context10.t0)(_context10.t1, _context10.t2);
allowedBlocks = [];
_iterator = actions_createForOfIteratorHelper(blocks);
_context10.prev = 10;
_iterator.s();
case 12:
if ((_step = _iterator.n()).done) {
_context10.next = 20;
break;
}
block = _step.value;
_context10.next = 16;
return external_wp_data_["controls"].select('core/block-editor', 'canInsertBlockType', block.name, rootClientId);
case 16:
isValid = _context10.sent;
if (isValid) {
allowedBlocks.push(block);
}
case 18:
_context10.next = 12;
break;
case 20:
_context10.next = 25;
break;
case 22:
_context10.prev = 22;
_context10.t3 = _context10["catch"](10);
_iterator.e(_context10.t3);
case 25:
_context10.prev = 25;
_iterator.f();
return _context10.finish(25);
case 28:
if (!allowedBlocks.length) {
_context10.next = 30;
break;
}
return _context10.abrupt("return", {
type: 'INSERT_BLOCKS',
blocks: allowedBlocks,
index: index,
rootClientId: rootClientId,
time: Date.now(),
updateSelection: updateSelection,
meta: meta
});
case 30:
case "end":
return _context10.stop();
}
}
}, _marked10, null, [[10, 22, 25, 28]]);
}
/**
* Sets the insertion point without showing it to users.
*
* Components like will default to inserting blocks at this point.
*
* @param {?string} rootClientId Root client ID of block list in which to
* insert. Use `undefined` for the root block
* list.
* @param {number} index Index at which block should be inserted.
*
* @return {Object} Action object.
*/
function actions_unstableSetInsertionPoint(rootClientId, index) {
return {
type: 'SET_INSERTION_POINT',
rootClientId: rootClientId,
index: index
};
}
/**
* Sets the insertion point and shows it to users.
*
* Components like will default to inserting blocks at this point.
*
* @param {?string} rootClientId Root client ID of block list in which to
* insert. Use `undefined` for the root block
* list.
* @param {number} index Index at which block should be inserted.
*
* @return {Object} Action object.
*/
function actions_showInsertionPoint(rootClientId, index) {
return {
type: 'SHOW_INSERTION_POINT',
rootClientId: rootClientId,
index: index
};
}
/**
* Hides the insertion point for users.
*
* @return {Object} Action object.
*/
function actions_hideInsertionPoint() {
return {
type: 'HIDE_INSERTION_POINT'
};
}
/**
* Returns an action object resetting the template validity.
*
* @param {boolean} isValid template validity flag.
*
* @return {Object} Action object.
*/
function setTemplateValidity(isValid) {
return {
type: 'SET_TEMPLATE_VALIDITY',
isValid: isValid
};
}
/**
* Returns an action object synchronize the template with the list of blocks
*
* @return {Object} Action object.
*/
function synchronizeTemplate() {
var blocks, template, updatedBlockList;
return external_regeneratorRuntime_default.a.wrap(function synchronizeTemplate$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
_context11.next = 2;
return {
type: 'SYNCHRONIZE_TEMPLATE'
};
case 2:
_context11.next = 4;
return external_wp_data_["controls"].select('core/block-editor', 'getBlocks');
case 4:
blocks = _context11.sent;
_context11.next = 7;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplate');
case 7:
template = _context11.sent;
updatedBlockList = Object(external_wp_blocks_["synchronizeBlocksWithTemplate"])(blocks, template);
_context11.next = 11;
return actions_resetBlocks(updatedBlockList);
case 11:
return _context11.abrupt("return", _context11.sent);
case 12:
case "end":
return _context11.stop();
}
}
}, _marked11);
}
/**
* Returns an action object used in signalling that two blocks should be merged
*
* @param {string} firstBlockClientId Client ID of the first block to merge.
* @param {string} secondBlockClientId Client ID of the second block to merge.
*/
function actions_mergeBlocks(firstBlockClientId, secondBlockClientId) {
var blocks, clientIdA, clientIdB, blockA, blockAType, blockB, blockBType, _yield$controls$selec, clientId, attributeKey, offset, selectedBlockType, attributeDefinition, canRestoreTextSelection, START_OF_SELECTED_AREA, cloneA, cloneB, selectedBlock, html, multilineTag, multilineWrapperTags, preserveWhiteSpace, value, blocksWithTheSameType, updatedAttributes, newAttributeKey, convertedHtml, _blockAType$attribute, _multilineTag, _multilineWrapperTags, _preserveWhiteSpace, convertedValue, newOffset, newValue, newHtml;
return external_regeneratorRuntime_default.a.wrap(function mergeBlocks$(_context12) {
while (1) {
switch (_context12.prev = _context12.next) {
case 0:
blocks = [firstBlockClientId, secondBlockClientId];
_context12.next = 3;
return {
type: 'MERGE_BLOCKS',
blocks: blocks
};
case 3:
clientIdA = blocks[0], clientIdB = blocks[1];
_context12.next = 6;
return external_wp_data_["controls"].select('core/block-editor', 'getBlock', clientIdA);
case 6:
blockA = _context12.sent;
blockAType = Object(external_wp_blocks_["getBlockType"])(blockA.name); // Only focus the previous block if it's not mergeable
if (blockAType.merge) {
_context12.next = 12;
break;
}
_context12.next = 11;
return actions_selectBlock(blockA.clientId);
case 11:
return _context12.abrupt("return");
case 12:
_context12.next = 14;
return external_wp_data_["controls"].select('core/block-editor', 'getBlock', clientIdB);
case 14:
blockB = _context12.sent;
blockBType = Object(external_wp_blocks_["getBlockType"])(blockB.name);
_context12.next = 18;
return external_wp_data_["controls"].select('core/block-editor', 'getSelectionStart');
case 18:
_yield$controls$selec = _context12.sent;
clientId = _yield$controls$selec.clientId;
attributeKey = _yield$controls$selec.attributeKey;
offset = _yield$controls$selec.offset;
selectedBlockType = clientId === clientIdA ? blockAType : blockBType;
attributeDefinition = selectedBlockType.attributes[attributeKey];
canRestoreTextSelection = (clientId === clientIdA || clientId === clientIdB) && attributeKey !== undefined && offset !== undefined && // We cannot restore text selection if the RichText identifier
// is not a defined block attribute key. This can be the case if the
// fallback intance ID is used to store selection (and no RichText
// identifier is set), or when the identifier is wrong.
!!attributeDefinition;
if (!attributeDefinition) {
if (typeof attributeKey === 'number') {
window.console.error("RichText needs an identifier prop that is the block attribute key of the attribute it controls. Its type is expected to be a string, but was ".concat(Object(esm_typeof["a" /* default */])(attributeKey)));
} else {
window.console.error('The RichText identifier prop does not match any attributes defined by the block.');
}
} // A robust way to retain selection position through various transforms
// is to insert a special character at the position and then recover it.
START_OF_SELECTED_AREA = "\x86"; // Clone the blocks so we don't insert the character in a "live" block.
cloneA = Object(external_wp_blocks_["cloneBlock"])(blockA);
cloneB = Object(external_wp_blocks_["cloneBlock"])(blockB);
if (canRestoreTextSelection) {
selectedBlock = clientId === clientIdA ? cloneA : cloneB;
html = selectedBlock.attributes[attributeKey];
multilineTag = attributeDefinition.multiline, multilineWrapperTags = attributeDefinition.__unstableMultilineWrapperTags, preserveWhiteSpace = attributeDefinition.__unstablePreserveWhiteSpace;
value = Object(external_wp_richText_["insert"])(Object(external_wp_richText_["create"])({
html: html,
multilineTag: multilineTag,
multilineWrapperTags: multilineWrapperTags,
preserveWhiteSpace: preserveWhiteSpace
}), START_OF_SELECTED_AREA, offset, offset);
selectedBlock.attributes[attributeKey] = Object(external_wp_richText_["toHTMLString"])({
value: value,
multilineTag: multilineTag,
preserveWhiteSpace: preserveWhiteSpace
});
} // We can only merge blocks with similar types
// thus, we transform the block to merge first
blocksWithTheSameType = blockA.name === blockB.name ? [cloneB] : Object(external_wp_blocks_["switchToBlockType"])(cloneB, blockA.name); // If the block types can not match, do nothing
if (!(!blocksWithTheSameType || !blocksWithTheSameType.length)) {
_context12.next = 33;
break;
}
return _context12.abrupt("return");
case 33:
// Calling the merge to update the attributes and remove the block to be merged
updatedAttributes = blockAType.merge(cloneA.attributes, blocksWithTheSameType[0].attributes);
if (!canRestoreTextSelection) {
_context12.next = 45;
break;
}
newAttributeKey = Object(external_lodash_["findKey"])(updatedAttributes, function (v) {
return typeof v === 'string' && v.indexOf(START_OF_SELECTED_AREA) !== -1;
});
convertedHtml = updatedAttributes[newAttributeKey];
_blockAType$attribute = blockAType.attributes[newAttributeKey], _multilineTag = _blockAType$attribute.multiline, _multilineWrapperTags = _blockAType$attribute.__unstableMultilineWrapperTags, _preserveWhiteSpace = _blockAType$attribute.__unstablePreserveWhiteSpace;
convertedValue = Object(external_wp_richText_["create"])({
html: convertedHtml,
multilineTag: _multilineTag,
multilineWrapperTags: _multilineWrapperTags,
preserveWhiteSpace: _preserveWhiteSpace
});
newOffset = convertedValue.text.indexOf(START_OF_SELECTED_AREA);
newValue = Object(external_wp_richText_["remove"])(convertedValue, newOffset, newOffset + 1);
newHtml = Object(external_wp_richText_["toHTMLString"])({
value: newValue,
multilineTag: _multilineTag,
preserveWhiteSpace: _preserveWhiteSpace
});
updatedAttributes[newAttributeKey] = newHtml;
_context12.next = 45;
return actions_selectionChange(blockA.clientId, newAttributeKey, newOffset, newOffset);
case 45:
return _context12.delegateYield(actions_replaceBlocks([blockA.clientId, blockB.clientId], [actions_objectSpread(actions_objectSpread({}, blockA), {}, {
attributes: actions_objectSpread(actions_objectSpread({}, blockA.attributes), updatedAttributes)
})].concat(Object(toConsumableArray["a" /* default */])(blocksWithTheSameType.slice(1)))), "t0", 46);
case 46:
case "end":
return _context12.stop();
}
}
}, _marked12);
}
/**
* Yields action objects used in signalling that the blocks corresponding to
* the set of specified client IDs are to be removed.
*
* @param {string|string[]} clientIds Client IDs of blocks to remove.
* @param {boolean} selectPrevious True if the previous block should be
* selected when a block is removed.
*/
function actions_removeBlocks(clientIds) {
var selectPrevious,
rootClientId,
isLocked,
previousBlockId,
defaultBlockId,
_args13 = arguments;
return external_regeneratorRuntime_default.a.wrap(function removeBlocks$(_context13) {
while (1) {
switch (_context13.prev = _context13.next) {
case 0:
selectPrevious = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : true;
if (!(!clientIds || !clientIds.length)) {
_context13.next = 3;
break;
}
return _context13.abrupt("return");
case 3:
clientIds = Object(external_lodash_["castArray"])(clientIds);
_context13.next = 6;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockRootClientId', clientIds[0]);
case 6:
rootClientId = _context13.sent;
_context13.next = 9;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplateLock', rootClientId);
case 9:
isLocked = _context13.sent;
if (!isLocked) {
_context13.next = 12;
break;
}
return _context13.abrupt("return");
case 12:
if (!selectPrevious) {
_context13.next = 18;
break;
}
_context13.next = 15;
return selectPreviousBlock(clientIds[0]);
case 15:
previousBlockId = _context13.sent;
_context13.next = 21;
break;
case 18:
_context13.next = 20;
return external_wp_data_["controls"].select('core/block-editor', 'getPreviousBlockClientId', clientIds[0]);
case 20:
previousBlockId = _context13.sent;
case 21:
_context13.next = 23;
return {
type: 'REMOVE_BLOCKS',
clientIds: clientIds
};
case 23:
return _context13.delegateYield(ensureDefaultBlock(), "t0", 24);
case 24:
defaultBlockId = _context13.t0;
return _context13.abrupt("return", [previousBlockId || defaultBlockId]);
case 26:
case "end":
return _context13.stop();
}
}
}, _marked13);
}
/**
* Returns an action object used in signalling that the block with the
* specified client ID is to be removed.
*
* @param {string} clientId Client ID of block to remove.
* @param {boolean} selectPrevious True if the previous block should be
* selected when a block is removed.
*
* @return {Object} Action object.
*/
function actions_removeBlock(clientId, selectPrevious) {
return actions_removeBlocks([clientId], selectPrevious);
}
/**
* Returns an action object used in signalling that the inner blocks with the
* specified client ID should be replaced.
*
* @param {string} rootClientId Client ID of the block whose InnerBlocks will re replaced.
* @param {Object[]} blocks Block objects to insert as new InnerBlocks
* @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to false.
*
* @return {Object} Action object.
*/
function actions_replaceInnerBlocks(rootClientId, blocks) {
var updateSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
return {
type: 'REPLACE_INNER_BLOCKS',
rootClientId: rootClientId,
blocks: blocks,
updateSelection: updateSelection,
time: Date.now()
};
}
/**
* Returns an action object used to toggle the block editing mode between
* visual and HTML modes.
*
* @param {string} clientId Block client ID.
*
* @return {Object} Action object.
*/
function toggleBlockMode(clientId) {
return {
type: 'TOGGLE_BLOCK_MODE',
clientId: clientId
};
}
/**
* Returns an action object used in signalling that the user has begun to type.
*
* @return {Object} Action object.
*/
function actions_startTyping() {
return {
type: 'START_TYPING'
};
}
/**
* Returns an action object used in signalling that the user has stopped typing.
*
* @return {Object} Action object.
*/
function actions_stopTyping() {
return {
type: 'STOP_TYPING'
};
}
/**
* Returns an action object used in signalling that the user has begun to drag blocks.
*
* @param {string[]} clientIds An array of client ids being dragged
*
* @return {Object} Action object.
*/
function actions_startDraggingBlocks() {
var clientIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
return {
type: 'START_DRAGGING_BLOCKS',
clientIds: clientIds
};
}
/**
* Returns an action object used in signalling that the user has stopped dragging blocks.
*
* @return {Object} Action object.
*/
function actions_stopDraggingBlocks() {
return {
type: 'STOP_DRAGGING_BLOCKS'
};
}
/**
* Returns an action object used in signalling that the caret has entered formatted text.
*
* @return {Object} Action object.
*/
function actions_enterFormattedText() {
return {
type: 'ENTER_FORMATTED_TEXT'
};
}
/**
* Returns an action object used in signalling that the user caret has exited formatted text.
*
* @return {Object} Action object.
*/
function actions_exitFormattedText() {
return {
type: 'EXIT_FORMATTED_TEXT'
};
}
/**
* Returns an action object used in signalling that the user caret has changed
* position.
*
* @param {string} clientId The selected block client ID.
* @param {string} attributeKey The selected block attribute key.
* @param {number} startOffset The start offset.
* @param {number} endOffset The end offset.
*
* @return {Object} Action object.
*/
function actions_selectionChange(clientId, attributeKey, startOffset, endOffset) {
return {
type: 'SELECTION_CHANGE',
clientId: clientId,
attributeKey: attributeKey,
startOffset: startOffset,
endOffset: endOffset
};
}
/**
* Returns an action object used in signalling that a new block of the default
* type should be added to the block list.
*
* @param {?Object} attributes Optional attributes of the block to assign.
* @param {?string} rootClientId Optional root client ID of block list on which
* to append.
* @param {?number} index Optional index where to insert the default block
*
* @return {Object} Action object
*/
function actions_insertDefaultBlock(attributes, rootClientId, index) {
// Abort if there is no default block type (if it has been unregistered).
var defaultBlockName = Object(external_wp_blocks_["getDefaultBlockName"])();
if (!defaultBlockName) {
return;
}
var block = Object(external_wp_blocks_["createBlock"])(defaultBlockName, attributes);
return actions_insertBlock(block, index, rootClientId);
}
/**
* Returns an action object that changes the nested settings of a given block.
*
* @param {string} clientId Client ID of the block whose nested setting are
* being received.
* @param {Object} settings Object with the new settings for the nested block.
*
* @return {Object} Action object
*/
function actions_updateBlockListSettings(clientId, settings) {
return {
type: 'UPDATE_BLOCK_LIST_SETTINGS',
clientId: clientId,
settings: settings
};
}
/**
* Returns an action object used in signalling that the block editor settings have been updated.
*
* @param {Object} settings Updated settings
*
* @return {Object} Action object
*/
function actions_updateSettings(settings) {
return {
type: 'UPDATE_SETTINGS',
settings: settings
};
}
/**
* Returns an action object used in signalling that a temporary reusable blocks have been saved
* in order to switch its temporary id with the real id.
*
* @param {string} id Reusable block's id.
* @param {string} updatedId Updated block's id.
*
* @return {Object} Action object.
*/
function __unstableSaveReusableBlock(id, updatedId) {
return {
type: 'SAVE_REUSABLE_BLOCK_SUCCESS',
id: id,
updatedId: updatedId
};
}
/**
* Returns an action object used in signalling that the last block change should be marked explicitly as persistent.
*
* @return {Object} Action object.
*/
function actions_unstableMarkLastChangeAsPersistent() {
return {
type: 'MARK_LAST_CHANGE_AS_PERSISTENT'
};
}
/**
* Returns an action object used in signalling that the next block change should be marked explicitly as not persistent.
*
* @return {Object} Action object.
*/
function actions_unstableMarkNextChangeAsNotPersistent() {
return {
type: 'MARK_NEXT_CHANGE_AS_NOT_PERSISTENT'
};
}
/**
* Returns an action object used in signalling that the last block change is
* an automatic change, meaning it was not performed by the user, and can be
* undone using the `Escape` and `Backspace` keys. This action must be called
* after the change was made, and any actions that are a consequence of it, so
* it is recommended to be called at the next idle period to ensure all
* selection changes have been recorded.
*/
function actions_unstableMarkAutomaticChange() {
return external_regeneratorRuntime_default.a.wrap(function __unstableMarkAutomaticChange$(_context14) {
while (1) {
switch (_context14.prev = _context14.next) {
case 0:
_context14.next = 2;
return {
type: 'MARK_AUTOMATIC_CHANGE'
};
case 2:
_context14.next = 4;
return __unstableMarkAutomaticChangeFinalControl();
case 4:
case "end":
return _context14.stop();
}
}
}, _marked14);
}
function __unstableMarkAutomaticChangeFinal() {
return {
type: 'MARK_AUTOMATIC_CHANGE_FINAL'
};
}
/**
* Generators that triggers an action used to enable or disable the navigation mode.
*
* @param {string} isNavigationMode Enable/Disable navigation mode.
*/
function actions_setNavigationMode() {
var isNavigationMode,
_args15 = arguments;
return external_regeneratorRuntime_default.a.wrap(function setNavigationMode$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
isNavigationMode = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : true;
_context15.next = 3;
return {
type: 'SET_NAVIGATION_MODE',
isNavigationMode: isNavigationMode
};
case 3:
if (isNavigationMode) {
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('You are currently in navigation mode. Navigate blocks using the Tab key and Arrow keys. Use Left and Right Arrow keys to move between nesting levels. To exit navigation mode and edit the selected block, press Enter.'));
} else {
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('You are currently in edit mode. To return to the navigation mode, press Escape.'));
}
case 4:
case "end":
return _context15.stop();
}
}
}, _marked15);
}
/**
* Generator that triggers an action used to enable or disable the block moving mode.
*
* @param {string|null} hasBlockMovingClientId Enable/Disable block moving mode.
*/
function actions_setBlockMovingClientId() {
var hasBlockMovingClientId,
_args16 = arguments;
return external_regeneratorRuntime_default.a.wrap(function setBlockMovingClientId$(_context16) {
while (1) {
switch (_context16.prev = _context16.next) {
case 0:
hasBlockMovingClientId = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : null;
_context16.next = 3;
return {
type: 'SET_BLOCK_MOVING_MODE',
hasBlockMovingClientId: hasBlockMovingClientId
};
case 3:
if (hasBlockMovingClientId) {
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('Use the Tab key and Arrow keys to choose new block location. Use Left and Right Arrow keys to move between nesting levels. Once location is selected press Enter or Space to move the block.'));
}
case 4:
case "end":
return _context16.stop();
}
}
}, _marked16);
}
/**
* Generator that triggers an action used to duplicate a list of blocks.
*
* @param {string[]} clientIds
* @param {boolean} updateSelection
*/
function actions_duplicateBlocks(clientIds) {
var updateSelection,
blocks,
rootClientId,
blockNames,
lastSelectedIndex,
clonedBlocks,
_args17 = arguments;
return external_regeneratorRuntime_default.a.wrap(function duplicateBlocks$(_context17) {
while (1) {
switch (_context17.prev = _context17.next) {
case 0:
updateSelection = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : true;
if (!(!clientIds && !clientIds.length)) {
_context17.next = 3;
break;
}
return _context17.abrupt("return");
case 3:
_context17.next = 5;
return external_wp_data_["controls"].select('core/block-editor', 'getBlocksByClientId', clientIds);
case 5:
blocks = _context17.sent;
_context17.next = 8;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockRootClientId', clientIds[0]);
case 8:
rootClientId = _context17.sent;
if (!Object(external_lodash_["some"])(blocks, function (block) {
return !block;
})) {
_context17.next = 11;
break;
}
return _context17.abrupt("return");
case 11:
blockNames = blocks.map(function (block) {
return block.name;
}); // Return early if blocks don't support multiple usage.
if (!Object(external_lodash_["some"])(blockNames, function (blockName) {
return !Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'multiple', true);
})) {
_context17.next = 14;
break;
}
return _context17.abrupt("return");
case 14:
_context17.next = 16;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockIndex', Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)), rootClientId);
case 16:
lastSelectedIndex = _context17.sent;
clonedBlocks = blocks.map(function (block) {
return Object(external_wp_blocks_["__experimentalCloneSanitizedBlock"])(block);
});
_context17.next = 20;
return actions_insertBlocks(clonedBlocks, lastSelectedIndex + 1, rootClientId, updateSelection);
case 20:
if (!(clonedBlocks.length > 1 && updateSelection)) {
_context17.next = 23;
break;
}
_context17.next = 23;
return actions_multiSelect(Object(external_lodash_["first"])(clonedBlocks).clientId, Object(external_lodash_["last"])(clonedBlocks).clientId);
case 23:
return _context17.abrupt("return", clonedBlocks.map(function (block) {
return block.clientId;
}));
case 24:
case "end":
return _context17.stop();
}
}
}, _marked17);
}
/**
* Generator used to insert an empty block after a given block.
*
* @param {string} clientId
*/
function actions_insertBeforeBlock(clientId) {
var rootClientId, isLocked, firstSelectedIndex;
return external_regeneratorRuntime_default.a.wrap(function insertBeforeBlock$(_context18) {
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
if (clientId) {
_context18.next = 2;
break;
}
return _context18.abrupt("return");
case 2:
_context18.next = 4;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockRootClientId', clientId);
case 4:
rootClientId = _context18.sent;
_context18.next = 7;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplateLock', rootClientId);
case 7:
isLocked = _context18.sent;
if (!isLocked) {
_context18.next = 10;
break;
}
return _context18.abrupt("return");
case 10:
_context18.next = 12;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockIndex', clientId, rootClientId);
case 12:
firstSelectedIndex = _context18.sent;
_context18.next = 15;
return actions_insertDefaultBlock({}, rootClientId, firstSelectedIndex);
case 15:
return _context18.abrupt("return", _context18.sent);
case 16:
case "end":
return _context18.stop();
}
}
}, _marked18);
}
/**
* Generator used to insert an empty block before a given block.
*
* @param {string} clientId
*/
function actions_insertAfterBlock(clientId) {
var rootClientId, isLocked, firstSelectedIndex;
return external_regeneratorRuntime_default.a.wrap(function insertAfterBlock$(_context19) {
while (1) {
switch (_context19.prev = _context19.next) {
case 0:
if (clientId) {
_context19.next = 2;
break;
}
return _context19.abrupt("return");
case 2:
_context19.next = 4;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockRootClientId', clientId);
case 4:
rootClientId = _context19.sent;
_context19.next = 7;
return external_wp_data_["controls"].select('core/block-editor', 'getTemplateLock', rootClientId);
case 7:
isLocked = _context19.sent;
if (!isLocked) {
_context19.next = 10;
break;
}
return _context19.abrupt("return");
case 10:
_context19.next = 12;
return external_wp_data_["controls"].select('core/block-editor', 'getBlockIndex', clientId, rootClientId);
case 12:
firstSelectedIndex = _context19.sent;
_context19.next = 15;
return actions_insertDefaultBlock({}, rootClientId, firstSelectedIndex + 1);
case 15:
return _context19.abrupt("return", _context19.sent);
case 16:
case "end":
return _context19.stop();
}
}
}, _marked19);
}
/**
* Returns an action object that toggles the highlighted block state.
*
* @param {string} clientId The block's clientId.
* @param {boolean} isHighlighted The highlight state.
*/
function actions_toggleBlockHighlight(clientId, isHighlighted) {
return {
type: 'TOGGLE_BLOCK_HIGHLIGHT',
clientId: clientId,
isHighlighted: isHighlighted
};
}
/**
* Yields action objects used in signalling that the block corresponding to the
* given clientId should appear to "flash" by rhythmically highlighting it.
*
* @param {string} clientId Target block client ID.
*/
function actions_flashBlock(clientId) {
return external_regeneratorRuntime_default.a.wrap(function flashBlock$(_context20) {
while (1) {
switch (_context20.prev = _context20.next) {
case 0:
_context20.next = 2;
return actions_toggleBlockHighlight(clientId, true);
case 2:
_context20.next = 4;
return {
type: 'SLEEP',
duration: 150
};
case 4:
_context20.next = 6;
return actions_toggleBlockHighlight(clientId, false);
case 6:
case "end":
return _context20.stop();
}
}
}, _marked20);
}
/**
* Returns an action object that sets whether the block has controlled innerblocks.
*
* @param {string} clientId The block's clientId.
* @param {boolean} hasControlledInnerBlocks True if the block's inner blocks are controlled.
*/
function actions_setHasControlledInnerBlocks(clientId, hasControlledInnerBlocks) {
return {
type: 'SET_HAS_CONTROLLED_INNER_BLOCKS',
hasControlledInnerBlocks: hasControlledInnerBlocks,
clientId: clientId
};
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js
function store_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function store_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { store_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { store_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Module Constants
*/
var STORE_NAME = 'core/block-editor';
/**
* Block editor data store configuration.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
*
* @type {Object}
*/
var storeConfig = {
reducer: store_reducer,
selectors: selectors_namespaceObject,
actions: actions_namespaceObject,
controls: store_controls
};
/**
* Store definition for the block editor namespace.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
*
* @type {Object}
*/
var store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, store_objectSpread(store_objectSpread({}, storeConfig), {}, {
persist: ['preferences']
})); // Ideally we'd use register instead of register stores.
Object(external_wp_data_["registerStore"])(STORE_NAME, store_objectSpread(store_objectSpread({}, storeConfig), {}, {
persist: ['preferences']
}));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-display-information/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('@wordpress/blocks').WPIcon} WPIcon */
/**
* Contains basic block's information for display reasons.
*
* @typedef {Object} WPBlockDisplayInformation
*
* @property {string} title Human-readable block type label.
* @property {WPIcon} icon Block type icon.
* @property {string} description A detailed block type description.
*/
/**
* Hook used to try to find a matching block variation and return
* the appropriate information for display reasons. In order to
* to try to find a match we need to things:
* 1. Block's client id to extract it's current attributes.
* 2. A block variation should have set `isActive` prop to a proper function.
*
* If for any reason a block variaton match cannot be found,
* the returned information come from the Block Type.
* If no blockType is found with the provided clientId, returns null.
*
* @param {string} clientId Block's client id.
* @return {?WPBlockDisplayInformation} Block's display information, or `null` when the block or its type not found.
*/
function useBlockDisplayInformation(clientId) {
return Object(external_wp_data_["useSelect"])(function (select) {
if (!clientId) return null;
var _select = select(store),
getBlockName = _select.getBlockName,
getBlockAttributes = _select.getBlockAttributes;
var _select2 = select(external_wp_blocks_["store"]),
getBlockType = _select2.getBlockType,
getBlockVariations = _select2.getBlockVariations;
var blockName = getBlockName(clientId);
var blockType = getBlockType(blockName);
if (!blockType) return null;
var variations = getBlockVariations(blockName);
var blockTypeInfo = {
title: blockType.title,
icon: blockType.icon,
description: blockType.description
};
if (!(variations !== null && variations !== void 0 && variations.length)) return blockTypeInfo;
var attributes = getBlockAttributes(clientId);
var match = variations.find(function (variation) {
var _variation$isActive;
return (_variation$isActive = variation.isActive) === null || _variation$isActive === void 0 ? void 0 : _variation$isActive.call(variation, attributes, variation.attributes);
});
if (!match) return blockTypeInfo;
return {
title: match.title || blockType.title,
icon: match.icon || blockType.icon,
description: match.description || blockType.description
};
}, [clientId]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-title/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Renders the block's configured title as a string, or empty if the title
* cannot be determined.
*
* @example
*
* ```jsx
*
* ```
*
* @param {Object} props
* @param {string} props.clientId Client ID of block.
*
* @return {?string} Block title.
*/
function BlockTitle(_ref) {
var clientId = _ref.clientId;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
if (!clientId) {
return {};
}
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
getBlockAttributes = _select.getBlockAttributes,
__experimentalGetReusableBlockTitle = _select.__experimentalGetReusableBlockTitle;
var blockName = getBlockName(clientId);
if (!blockName) {
return {};
}
var isReusable = Object(external_wp_blocks_["isReusableBlock"])(Object(external_wp_blocks_["getBlockType"])(blockName));
return {
attributes: getBlockAttributes(clientId),
name: blockName,
reusableBlockTitle: isReusable && __experimentalGetReusableBlockTitle(getBlockAttributes(clientId).ref)
};
}, [clientId]),
attributes = _useSelect.attributes,
name = _useSelect.name,
reusableBlockTitle = _useSelect.reusableBlockTitle;
var blockInformation = useBlockDisplayInformation(clientId);
if (!name || !blockInformation) return null;
var blockType = Object(external_wp_blocks_["getBlockType"])(name);
var label = Object(external_wp_blocks_["__experimentalGetBlockLabel"])(blockType, attributes); // Label will fallback to the title if no label is defined for the
// current label context. We do not want "Paragraph: Paragraph".
// If label is defined we prioritize it over possible possible
// block variation match title.
if (label !== blockType.title) {
return "".concat(blockType.title, ": ").concat(Object(external_lodash_["truncate"])(label, {
length: 15
}));
}
if (reusableBlockTitle) {
return Object(external_lodash_["truncate"])(reusableBlockTitle, {
length: 35
});
}
return blockInformation.title;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-breadcrumb/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Block breadcrumb component, displaying the hierarchy of the current block selection as a breadcrumb.
*
* @return {WPElement} Block Breadcrumb.
*/
function BlockBreadcrumb() {
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
selectBlock = _useDispatch.selectBlock,
clearSelectedBlock = _useDispatch.clearSelectedBlock;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectionStart = _select.getSelectionStart,
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getBlockParents = _select.getBlockParents;
var selectedBlockClientId = getSelectedBlockClientId();
return {
parents: getBlockParents(selectedBlockClientId),
clientId: selectedBlockClientId,
hasSelection: !!getSelectionStart().clientId
};
}, []),
clientId = _useSelect.clientId,
parents = _useSelect.parents,
hasSelection = _useSelect.hasSelection;
/*
* Disable reason: The `list` ARIA role is redundant but
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
return Object(external_wp_element_["createElement"])("ul", {
className: "block-editor-block-breadcrumb",
role: "list",
"aria-label": Object(external_wp_i18n_["__"])('Block breadcrumb')
}, Object(external_wp_element_["createElement"])("li", {
className: !hasSelection ? 'block-editor-block-breadcrumb__current' : undefined,
"aria-current": !hasSelection ? 'true' : undefined
}, hasSelection && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-block-breadcrumb__button",
isTertiary: true,
onClick: clearSelectedBlock
}, Object(external_wp_i18n_["__"])('Document')), !hasSelection && Object(external_wp_i18n_["__"])('Document')), parents.map(function (parentClientId) {
return Object(external_wp_element_["createElement"])("li", {
key: parentClientId
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-block-breadcrumb__button",
isTertiary: true,
onClick: function onClick() {
return selectBlock(parentClientId);
}
}, Object(external_wp_element_["createElement"])(BlockTitle, {
clientId: parentClientId
})));
}), !!clientId && Object(external_wp_element_["createElement"])("li", {
className: "block-editor-block-breadcrumb__current",
"aria-current": "true"
}, Object(external_wp_element_["createElement"])(BlockTitle, {
clientId: clientId
})))
/* eslint-enable jsx-a11y/no-redundant-roles */
;
}
/* harmony default export */ var block_breadcrumb = (BlockBreadcrumb);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-context/index.js
function block_context_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_context_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_context_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_context_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/** @typedef {import('react').ReactNode} ReactNode */
/**
* @typedef BlockContextProviderProps
*
* @property {Record} value Context value to merge with current
* value.
* @property {ReactNode} children Component children.
*/
/** @type {import('react').Context>} */
var block_context_Context = Object(external_wp_element_["createContext"])({});
/**
* Component which merges passed value with current consumed block context.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-context/README.md
*
* @param {BlockContextProviderProps} props
*/
function BlockContextProvider(_ref) {
var value = _ref.value,
children = _ref.children;
var context = Object(external_wp_element_["useContext"])(block_context_Context);
var nextValue = Object(external_wp_element_["useMemo"])(function () {
return block_context_objectSpread(block_context_objectSpread({}, context), value);
}, [context, value]);
return Object(external_wp_element_["createElement"])(block_context_Context.Provider, {
value: nextValue,
children: children
});
}
/* harmony default export */ var block_context = (block_context_Context);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-style-selector/index.js
/**
* WordPress dependencies
*/
var color_style_selector_ColorSelectorSVGIcon = function ColorSelectorSVGIcon() {
return Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "https://www.w3.org/2000/svg",
viewBox: "0 0 20 20"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M7.434 5l3.18 9.16H8.538l-.692-2.184H4.628l-.705 2.184H2L5.18 5h2.254zm-1.13 1.904h-.115l-1.148 3.593H7.44L6.304 6.904zM14.348 7.006c1.853 0 2.9.876 2.9 2.374v4.78h-1.79v-.914h-.114c-.362.64-1.123 1.022-2.031 1.022-1.346 0-2.292-.826-2.292-2.108 0-1.27.972-2.006 2.71-2.107l1.696-.102V9.38c0-.584-.42-.914-1.18-.914-.667 0-1.112.228-1.264.647h-1.701c.12-1.295 1.307-2.107 3.066-2.107zm1.079 4.1l-1.416.09c-.793.056-1.18.342-1.18.844 0 .52.45.837 1.091.837.857 0 1.505-.545 1.505-1.256v-.515z"
}));
};
/**
* Color Selector Icon component.
*
* @param {Object} props Component properties.
* @param {Object} props.style Style object.
* @param {string} props.className Class name for component.
*
* @return {*} React Icon component.
*/
var color_style_selector_ColorSelectorIcon = function ColorSelectorIcon(_ref) {
var style = _ref.style,
className = _ref.className;
return Object(external_wp_element_["createElement"])("div", {
className: "block-library-colors-selector__icon-container"
}, Object(external_wp_element_["createElement"])("div", {
className: "".concat(className, " block-library-colors-selector__state-selection"),
style: style
}, Object(external_wp_element_["createElement"])(color_style_selector_ColorSelectorSVGIcon, null)));
};
/**
* Renders the Colors Selector Toolbar with the icon button.
*
* @param {Object} props Component properties.
* @param {Object} props.TextColor Text color component that wraps icon.
* @param {Object} props.BackgroundColor Background color component that wraps icon.
*
* @return {*} React toggle button component.
*/
var color_style_selector_renderToggleComponent = function renderToggleComponent(_ref2) {
var TextColor = _ref2.TextColor,
BackgroundColor = _ref2.BackgroundColor;
return function (_ref3) {
var onToggle = _ref3.onToggle,
isOpen = _ref3.isOpen;
var openOnArrowDown = function openOnArrowDown(event) {
if (!isOpen && event.keyCode === external_wp_keycodes_["DOWN"]) {
event.preventDefault();
event.stopPropagation();
onToggle();
}
};
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
className: "components-toolbar__control block-library-colors-selector__toggle",
label: Object(external_wp_i18n_["__"])('Open Colors Selector'),
onClick: onToggle,
onKeyDown: openOnArrowDown,
icon: Object(external_wp_element_["createElement"])(BackgroundColor, null, Object(external_wp_element_["createElement"])(TextColor, null, Object(external_wp_element_["createElement"])(color_style_selector_ColorSelectorIcon, null)))
}));
};
};
var color_style_selector_BlockColorsStyleSelector = function BlockColorsStyleSelector(_ref4) {
var children = _ref4.children,
other = Object(objectWithoutProperties["a" /* default */])(_ref4, ["children"]);
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
position: "bottom right",
className: "block-library-colors-selector",
contentClassName: "block-library-colors-selector__popover",
renderToggle: color_style_selector_renderToggleComponent(other),
renderContent: function renderContent() {
return children;
}
});
};
/* harmony default export */ var color_style_selector = (color_style_selector_BlockColorsStyleSelector);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/edit.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Default value used for blocks which do not define their own context needs,
* used to guarantee that a block's `context` prop will always be an object. It
* is assigned as a constant since it is always expected to be an empty object,
* and in order to avoid unnecessary React reconciliations of a changing object.
*
* @type {{}}
*/
var DEFAULT_BLOCK_CONTEXT = {};
var edit_Edit = function Edit(props) {
var _props$attributes = props.attributes,
attributes = _props$attributes === void 0 ? {} : _props$attributes,
name = props.name;
var blockType = Object(external_wp_blocks_["getBlockType"])(name);
var blockContext = Object(external_wp_element_["useContext"])(block_context); // Assign context values using the block type's declared context needs.
var context = Object(external_wp_element_["useMemo"])(function () {
return blockType && blockType.usesContext ? Object(external_lodash_["pick"])(blockContext, blockType.usesContext) : DEFAULT_BLOCK_CONTEXT;
}, [blockType, blockContext]);
if (!blockType) {
return null;
} // `edit` and `save` are functions or components describing the markup
// with which a block is displayed. If `blockType` is valid, assign
// them preferentially as the render value for the block.
var Component = blockType.edit || blockType.save;
if (blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false)) {
return Object(external_wp_element_["createElement"])(Component, Object(esm_extends["a" /* default */])({}, props, {
context: context
}));
} // Generate a class name for the block's editable form
var generatedClassName = Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'className', true) ? Object(external_wp_blocks_["getBlockDefaultClassName"])(name) : null;
var className = classnames_default()(generatedClassName, attributes.className);
return Object(external_wp_element_["createElement"])(Component, Object(esm_extends["a" /* default */])({}, props, {
context: context,
className: className
}));
};
/* harmony default export */ var edit = (Object(external_wp_components_["withFilters"])('editor.BlockEdit')(edit_Edit));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-edit/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function block_edit_BlockEdit(props) {
var name = props.name,
isSelected = props.isSelected,
clientId = props.clientId,
onFocus = props.onFocus,
onCaretVerticalPositionChange = props.onCaretVerticalPositionChange;
var context = {
name: name,
isSelected: isSelected,
clientId: clientId,
onFocus: onFocus,
onCaretVerticalPositionChange: onCaretVerticalPositionChange
};
return Object(external_wp_element_["createElement"])(context_Provider // It is important to return the same object if props haven't
// changed to avoid unnecessary rerenders.
// See https://reactjs.org/docs/context.html#caveats.
, {
value: Object(external_wp_element_["useMemo"])(function () {
return context;
}, Object.values(context))
}, Object(external_wp_element_["createElement"])(edit, props));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-format-controls/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_format_controls_createSlotFill = Object(external_wp_components_["createSlotFill"])('BlockFormatControls'),
block_format_controls_Fill = block_format_controls_createSlotFill.Fill,
block_format_controls_Slot = block_format_controls_createSlotFill.Slot;
function BlockFormatControlsSlot(props) {
var accessibleToolbarState = Object(external_wp_element_["useContext"])(external_wp_components_["__experimentalToolbarContext"]);
return Object(external_wp_element_["createElement"])(block_format_controls_Slot, Object(esm_extends["a" /* default */])({}, props, {
fillProps: accessibleToolbarState
}));
}
function BlockFormatControlsFill(props) {
var _useBlockEditContext = useBlockEditContext(),
isSelected = _useBlockEditContext.isSelected;
if (!isSelected) {
return null;
}
return Object(external_wp_element_["createElement"])(block_format_controls_Fill, null, function (fillProps) {
var value = !Object(external_lodash_["isEmpty"])(fillProps) ? fillProps : null;
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalToolbarContext"].Provider, {
value: value
}, props.children);
});
}
var BlockFormatControls = BlockFormatControlsFill;
BlockFormatControls.Slot = BlockFormatControlsSlot;
/* harmony default export */ var block_format_controls = (BlockFormatControls);
// EXTERNAL MODULE: external ["wp","keyboardShortcuts"]
var external_wp_keyboardShortcuts_ = __webpack_require__(46);
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
var asyncToGenerator = __webpack_require__(47);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/more-vertical.js
var more_vertical = __webpack_require__(305);
// EXTERNAL MODULE: ./node_modules/react-spring/web.cjs.js
var web_cjs = __webpack_require__(113);
// EXTERNAL MODULE: external ["wp","dom"]
var external_wp_dom_ = __webpack_require__(27);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-moving-animation/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Simple reducer used to increment a counter.
*
* @param {number} state Previous counter value.
* @return {number} New state value.
*/
var counterReducer = function counterReducer(state) {
return state + 1;
};
var getAbsolutePosition = function getAbsolutePosition(element) {
return {
top: element.offsetTop,
left: element.offsetLeft
};
};
/**
* Hook used to compute the styles required to move a div into a new position.
*
* The way this animation works is the following:
* - It first renders the element as if there was no animation.
* - It takes a snapshot of the position of the block to use it
* as a destination point for the animation.
* - It restores the element to the previous position using a CSS transform
* - It uses the "resetAnimation" flag to reset the animation
* from the beginning in order to animate to the new destination point.
*
* @param {Object} ref Reference to the element to animate.
* @param {boolean} isSelected Whether it's the current block or not.
* @param {boolean} adjustScrolling Adjust the scroll position to the current block.
* @param {boolean} enableAnimation Enable/Disable animation.
* @param {*} triggerAnimationOnChange Variable used to trigger the animation if it changes.
*/
function useMovingAnimation(ref, isSelected, adjustScrolling, enableAnimation, triggerAnimationOnChange) {
var prefersReducedMotion = Object(external_wp_compose_["useReducedMotion"])() || !enableAnimation;
var _useReducer = Object(external_wp_element_["useReducer"])(counterReducer, 0),
_useReducer2 = Object(slicedToArray["a" /* default */])(_useReducer, 2),
triggeredAnimation = _useReducer2[0],
triggerAnimation = _useReducer2[1];
var _useReducer3 = Object(external_wp_element_["useReducer"])(counterReducer, 0),
_useReducer4 = Object(slicedToArray["a" /* default */])(_useReducer3, 2),
finishedAnimation = _useReducer4[0],
endAnimation = _useReducer4[1];
var _useState = Object(external_wp_element_["useState"])({
x: 0,
y: 0
}),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
transform = _useState2[0],
setTransform = _useState2[1];
var previous = Object(external_wp_element_["useMemo"])(function () {
return ref.current ? getAbsolutePosition(ref.current) : null;
}, [triggerAnimationOnChange]); // Calculate the previous position of the block relative to the viewport and
// return a function to maintain that position by scrolling.
var preserveScrollPosition = Object(external_wp_element_["useMemo"])(function () {
if (!adjustScrolling || !ref.current) {
return function () {};
}
var scrollContainer = Object(external_wp_dom_["getScrollContainer"])(ref.current);
if (!scrollContainer) {
return function () {};
}
var prevRect = ref.current.getBoundingClientRect();
return function () {
var blockRect = ref.current.getBoundingClientRect();
var diff = blockRect.top - prevRect.top;
if (diff) {
scrollContainer.scrollTop += diff;
}
};
}, [triggerAnimationOnChange, adjustScrolling]);
Object(external_wp_element_["useLayoutEffect"])(function () {
if (triggeredAnimation) {
endAnimation();
}
}, [triggeredAnimation]);
Object(external_wp_element_["useLayoutEffect"])(function () {
if (!previous) {
return;
}
if (prefersReducedMotion) {
// if the animation is disabled and the scroll needs to be adjusted,
// just move directly to the final scroll position.
preserveScrollPosition();
return;
}
ref.current.style.transform = '';
var destination = getAbsolutePosition(ref.current);
triggerAnimation();
setTransform({
x: Math.round(previous.left - destination.left),
y: Math.round(previous.top - destination.top)
});
}, [triggerAnimationOnChange]); // Only called when either the x or y value changes.
function onFrameChange(_ref) {
var x = _ref.x,
y = _ref.y;
if (!ref.current) {
return;
}
var isMoving = x === 0 && y === 0;
ref.current.style.transformOrigin = isMoving ? '' : 'center';
ref.current.style.transform = isMoving ? '' : "translate3d(".concat(x, "px,").concat(y, "px,0)");
ref.current.style.zIndex = !isSelected || isMoving ? '' : '1';
preserveScrollPosition();
} // Called for every frame computed by useSpring.
function onFrame(_ref2) {
var x = _ref2.x,
y = _ref2.y;
x = Math.round(x);
y = Math.round(y);
if (x !== onFrame.x || y !== onFrame.y) {
onFrameChange({
x: x,
y: y
});
onFrame.x = x;
onFrame.y = y;
}
}
onFrame.x = 0;
onFrame.y = 0;
Object(web_cjs["useSpring"])({
from: {
x: transform.x,
y: transform.y
},
to: {
x: 0,
y: 0
},
reset: triggeredAnimation !== finishedAnimation,
config: {
mass: 5,
tension: 2000,
friction: 200
},
immediate: prefersReducedMotion,
onFrame: onFrame
});
}
/* harmony default export */ var use_moving_animation = (useMovingAnimation);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/leaf.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var AnimatedTreeGridRow = Object(web_cjs["animated"])(external_wp_components_["__experimentalTreeGridRow"]);
function BlockNavigationLeaf(_ref) {
var isSelected = _ref.isSelected,
position = _ref.position,
level = _ref.level,
rowCount = _ref.rowCount,
children = _ref.children,
className = _ref.className,
path = _ref.path,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isSelected", "position", "level", "rowCount", "children", "className", "path"]);
var wrapper = Object(external_wp_element_["useRef"])(null);
var adjustScrolling = false;
var enableAnimation = true;
var animateOnChange = path.join('_');
var style = use_moving_animation(wrapper, isSelected, adjustScrolling, enableAnimation, animateOnChange);
return Object(external_wp_element_["createElement"])(AnimatedTreeGridRow, Object(esm_extends["a" /* default */])({
ref: wrapper,
style: style,
className: classnames_default()('block-editor-block-navigation-leaf', className),
level: level,
positionInSet: position,
setSize: rowCount
}, props), children);
}
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-right.js
var chevron_right = __webpack_require__(216);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-left.js
var chevron_left = __webpack_require__(217);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-up.js
var chevron_up = __webpack_require__(303);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/chevron-down.js
var chevron_down = __webpack_require__(304);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/mover-description.js
/**
* WordPress dependencies
*/
/**
* Return a label for the block movement controls depending on block position.
*
* @param {number} selectedCount Number of blocks selected.
* @param {string} type Block type - in the case of a single block, should
* define its 'type'. I.e. 'Text', 'Heading', 'Image' etc.
* @param {number} firstIndex The index (position - 1) of the first block selected.
* @param {boolean} isFirst This is the first block.
* @param {boolean} isLast This is the last block.
* @param {number} dir Direction of movement (> 0 is considered to be going
* down, < 0 is up).
* @param {string} orientation The orientation of the block movers, vertical or
* horizontal.
*
* @return {string} Label for the block movement controls.
*/
function getBlockMoverDescription(selectedCount, type, firstIndex, isFirst, isLast, dir, orientation) {
var position = firstIndex + 1;
var getMovementDirection = function getMovementDirection(moveDirection) {
if (moveDirection === 'up') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? 'right' : 'left';
}
return 'up';
} else if (moveDirection === 'down') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? 'left' : 'right';
}
return 'down';
}
return null;
};
if (selectedCount > 1) {
return getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir);
}
if (isFirst && isLast) {
return Object(external_wp_i18n_["sprintf"])( // translators: %s: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %s is the only block, and cannot be moved'), type);
}
if (dir > 0 && !isLast) {
// moving down
var movementDirection = getMovementDirection('down');
if (movementDirection === 'down') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d down to position %3$d'), type, position, position + 1);
}
if (movementDirection === 'left') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d left to position %3$d'), type, position, position + 1);
}
if (movementDirection === 'right') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d right to position %3$d'), type, position, position + 1);
}
}
if (dir > 0 && isLast) {
// moving down, and is the last item
var _movementDirection = getMovementDirection('down');
if (_movementDirection === 'down') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved down'), type);
}
if (_movementDirection === 'left') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved left'), type);
}
if (_movementDirection === 'right') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the end of the content and can’t be moved right'), type);
}
}
if (dir < 0 && !isFirst) {
// moving up
var _movementDirection2 = getMovementDirection('up');
if (_movementDirection2 === 'up') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d up to position %3$d'), type, position, position - 1);
}
if (_movementDirection2 === 'left') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d left to position %3$d'), type, position, position - 1);
}
if (_movementDirection2 === 'right') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc), 2: Position of selected block, 3: New position
Object(external_wp_i18n_["__"])('Move %1$s block from position %2$d right to position %3$d'), type, position, position - 1);
}
}
if (dir < 0 && isFirst) {
// moving up, and is the first item
var _movementDirection3 = getMovementDirection('up');
if (_movementDirection3 === 'up') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved up'), type);
}
if (_movementDirection3 === 'left') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved left'), type);
}
if (_movementDirection3 === 'right') {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Type of block (i.e. Text, Image etc)
Object(external_wp_i18n_["__"])('Block %1$s is at the beginning of the content and can’t be moved right'), type);
}
}
}
/**
* Return a label for the block movement controls depending on block position.
*
* @param {number} selectedCount Number of blocks selected.
* @param {number} firstIndex The index (position - 1) of the first block selected.
* @param {boolean} isFirst This is the first block.
* @param {boolean} isLast This is the last block.
* @param {number} dir Direction of movement (> 0 is considered to be going
* down, < 0 is up).
*
* @return {string} Label for the block movement controls.
*/
function getMultiBlockMoverDescription(selectedCount, firstIndex, isFirst, isLast, dir) {
var position = firstIndex + 1;
if (dir < 0 && isFirst) {
return Object(external_wp_i18n_["__"])('Blocks cannot be moved up as they are already at the top');
}
if (dir > 0 && isLast) {
return Object(external_wp_i18n_["__"])('Blocks cannot be moved down as they are already at the bottom');
}
if (dir < 0 && !isFirst) {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks
Object(external_wp_i18n_["_n"])('Move %1$d block from position %2$d up by one place', 'Move %1$d blocks from position %2$d up by one place', selectedCount), selectedCount, position);
}
if (dir > 0 && !isLast) {
return Object(external_wp_i18n_["sprintf"])( // translators: 1: Number of selected blocks, 2: Position of selected blocks
Object(external_wp_i18n_["_n"])('Move %1$d block from position %2$d down by one place', 'Move %1$d blocks from position %2$d down by one place', selectedCount), selectedCount, position);
}
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/button.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var button_getArrowIcon = function getArrowIcon(direction, orientation) {
if (direction === 'up') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? chevron_right["a" /* default */] : chevron_left["a" /* default */];
}
return chevron_up["a" /* default */];
} else if (direction === 'down') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? chevron_left["a" /* default */] : chevron_right["a" /* default */];
}
return chevron_down["a" /* default */];
}
return null;
};
var button_getMovementDirectionLabel = function getMovementDirectionLabel(moveDirection, orientation) {
if (moveDirection === 'up') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? Object(external_wp_i18n_["__"])('Move right') : Object(external_wp_i18n_["__"])('Move left');
}
return Object(external_wp_i18n_["__"])('Move up');
} else if (moveDirection === 'down') {
if (orientation === 'horizontal') {
return Object(external_wp_i18n_["isRTL"])() ? Object(external_wp_i18n_["__"])('Move left') : Object(external_wp_i18n_["__"])('Move right');
}
return Object(external_wp_i18n_["__"])('Move down');
}
return null;
};
var BlockMoverButton = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var clientIds = _ref.clientIds,
direction = _ref.direction,
moverOrientation = _ref.orientation,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["clientIds", "direction", "orientation"]);
var instanceId = Object(external_wp_compose_["useInstanceId"])(BlockMoverButton);
var blocksCount = Object(external_lodash_["castArray"])(clientIds).length;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockIndex = _select.getBlockIndex,
getBlockRootClientId = _select.getBlockRootClientId,
getBlockOrder = _select.getBlockOrder,
getBlock = _select.getBlock,
getBlockListSettings = _select.getBlockListSettings;
var normalizedClientIds = Object(external_lodash_["castArray"])(clientIds);
var firstClientId = Object(external_lodash_["first"])(normalizedClientIds);
var blockRootClientId = getBlockRootClientId(firstClientId);
var firstBlockIndex = getBlockIndex(firstClientId, blockRootClientId);
var lastBlockIndex = getBlockIndex(Object(external_lodash_["last"])(normalizedClientIds), blockRootClientId);
var blockOrder = getBlockOrder(blockRootClientId);
var block = getBlock(firstClientId);
var isFirstBlock = firstBlockIndex === 0;
var isLastBlock = lastBlockIndex === blockOrder.length - 1;
var _ref2 = getBlockListSettings(blockRootClientId) || {},
blockListOrientation = _ref2.orientation;
return {
blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
isDisabled: direction === 'up' ? isFirstBlock : isLastBlock,
rootClientId: blockRootClientId,
firstIndex: firstBlockIndex,
isFirst: isFirstBlock,
isLast: isLastBlock,
orientation: moverOrientation || blockListOrientation
};
}, [clientIds, direction]),
blockType = _useSelect.blockType,
isDisabled = _useSelect.isDisabled,
rootClientId = _useSelect.rootClientId,
isFirst = _useSelect.isFirst,
isLast = _useSelect.isLast,
firstIndex = _useSelect.firstIndex,
_useSelect$orientatio = _useSelect.orientation,
orientation = _useSelect$orientatio === void 0 ? 'vertical' : _useSelect$orientatio;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
moveBlocksDown = _useDispatch.moveBlocksDown,
moveBlocksUp = _useDispatch.moveBlocksUp;
var moverFunction = direction === 'up' ? moveBlocksUp : moveBlocksDown;
var onClick = function onClick(event) {
moverFunction(clientIds, rootClientId);
if (props.onClick) {
props.onClick(event);
}
};
var descriptionId = "block-editor-block-mover-button__description-".concat(instanceId);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
ref: ref,
className: classnames_default()('block-editor-block-mover-button', "is-".concat(direction, "-button")),
icon: button_getArrowIcon(direction, orientation),
label: button_getMovementDirectionLabel(direction, orientation),
"aria-describedby": descriptionId
}, props, {
onClick: isDisabled ? null : onClick,
"aria-disabled": isDisabled
})), Object(external_wp_element_["createElement"])("span", {
id: descriptionId,
className: "block-editor-block-mover-button__description"
}, getBlockMoverDescription(blocksCount, blockType && blockType.title, firstIndex, isFirst, isLast, direction === 'up' ? -1 : 1, orientation)));
});
var BlockMoverUpButton = Object(external_wp_element_["forwardRef"])(function (props, ref) {
return Object(external_wp_element_["createElement"])(BlockMoverButton, Object(esm_extends["a" /* default */])({
direction: "up",
ref: ref
}, props));
});
var BlockMoverDownButton = Object(external_wp_element_["forwardRef"])(function (props, ref) {
return Object(external_wp_element_["createElement"])(BlockMoverButton, Object(esm_extends["a" /* default */])({
direction: "down",
ref: ref
}, props));
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/context.js
/**
* WordPress dependencies
*/
var BlockNavigationContext = Object(external_wp_element_["createContext"])({
__experimentalFeatures: false
});
var context_useBlockNavigationContext = function useBlockNavigationContext() {
return Object(external_wp_element_["useContext"])(BlockNavigationContext);
};
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/more-horizontal.js
/**
* WordPress dependencies
*/
var moreHorizontal = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"
}));
/* harmony default export */ var more_horizontal = (moreHorizontal);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/warning/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function Warning(_ref) {
var className = _ref.className,
actions = _ref.actions,
children = _ref.children,
secondaryActions = _ref.secondaryActions;
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()(className, 'block-editor-warning')
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-warning__contents"
}, Object(external_wp_element_["createElement"])("p", {
className: "block-editor-warning__message"
}, children), (external_wp_element_["Children"].count(actions) > 0 || secondaryActions) && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-warning__actions"
}, external_wp_element_["Children"].count(actions) > 0 && external_wp_element_["Children"].map(actions, function (action, i) {
return Object(external_wp_element_["createElement"])("span", {
key: i,
className: "block-editor-warning__action"
}, action);
}), secondaryActions && Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
className: "block-editor-warning__secondary",
icon: more_horizontal,
label: Object(external_wp_i18n_["__"])('More options'),
popoverProps: {
position: 'bottom left',
className: 'block-editor-warning__dropdown'
},
noIcons: true
}, function () {
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, secondaryActions.map(function (item, pos) {
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: item.onClick,
key: pos
}, item.title);
}));
}))));
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
*/
/* harmony default export */ var warning = (Warning);
// EXTERNAL MODULE: ./node_modules/diff/lib/diff/character.js
var diff_character = __webpack_require__(273);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/block-view.js
/**
* WordPress dependencies
*/
var block_view_BlockView = function BlockView(_ref) {
var title = _ref.title,
rawContent = _ref.rawContent,
renderedContent = _ref.renderedContent,
action = _ref.action,
actionText = _ref.actionText,
className = _ref.className;
return Object(external_wp_element_["createElement"])("div", {
className: className
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-compare__content"
}, Object(external_wp_element_["createElement"])("h2", {
className: "block-editor-block-compare__heading"
}, title), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-compare__html"
}, rawContent), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-compare__preview edit-post-visual-editor"
}, renderedContent)), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-compare__action"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSecondary: true,
tabIndex: "0",
onClick: action
}, actionText)));
};
/* harmony default export */ var block_view = (block_view_BlockView);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-compare/index.js
/**
* External dependencies
*/
// diff doesn't tree-shake correctly, so we import from the individual
// module here, to avoid including too much of the library
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockCompare(_ref) {
var block = _ref.block,
onKeep = _ref.onKeep,
onConvert = _ref.onConvert,
convertor = _ref.convertor,
convertButtonText = _ref.convertButtonText;
function getDifference(originalContent, newContent) {
var difference = Object(diff_character["diffChars"])(originalContent, newContent);
return difference.map(function (item, pos) {
var classes = classnames_default()({
'block-editor-block-compare__added': item.added,
'block-editor-block-compare__removed': item.removed
});
return Object(external_wp_element_["createElement"])("span", {
key: pos,
className: classes
}, item.value);
});
}
function getConvertedContent(convertedBlock) {
// The convertor may return an array of items or a single item
var newBlocks = Object(external_lodash_["castArray"])(convertedBlock); // Get converted block details
var newContent = newBlocks.map(function (item) {
return Object(external_wp_blocks_["getSaveContent"])(item.name, item.attributes, item.innerBlocks);
});
var renderedContent = newBlocks.map(function (item) {
return Object(external_wp_blocks_["getSaveElement"])(item.name, item.attributes, item.innerBlocks);
});
return {
rawContent: newContent.join(''),
renderedContent: renderedContent
};
}
var original = {
rawContent: block.originalContent,
renderedContent: Object(external_wp_blocks_["getSaveElement"])(block.name, block.attributes)
};
var converted = getConvertedContent(convertor(block));
var difference = getDifference(original.rawContent, converted.rawContent);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-compare__wrapper"
}, Object(external_wp_element_["createElement"])(block_view, {
title: Object(external_wp_i18n_["__"])('Current'),
className: "block-editor-block-compare__current",
action: onKeep,
actionText: Object(external_wp_i18n_["__"])('Convert to HTML'),
rawContent: original.rawContent,
renderedContent: original.renderedContent
}), Object(external_wp_element_["createElement"])(block_view, {
title: Object(external_wp_i18n_["__"])('After Conversion'),
className: "block-editor-block-compare__converted",
action: onConvert,
actionText: convertButtonText,
rawContent: difference,
renderedContent: converted.renderedContent
}));
}
/* harmony default export */ var block_compare = (BlockCompare);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-invalid-warning.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockInvalidWarning(_ref) {
var convertToHTML = _ref.convertToHTML,
convertToBlocks = _ref.convertToBlocks,
convertToClassic = _ref.convertToClassic,
attemptBlockRecovery = _ref.attemptBlockRecovery,
block = _ref.block;
var hasHTMLBlock = !!Object(external_wp_blocks_["getBlockType"])('core/html');
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
compare = _useState2[0],
setCompare = _useState2[1];
var onCompare = Object(external_wp_element_["useCallback"])(function () {
return setCompare(true);
}, []);
var onCompareClose = Object(external_wp_element_["useCallback"])(function () {
return setCompare(false);
}, []); // We memo the array here to prevent the children components from being updated unexpectedly
var hiddenActions = Object(external_wp_element_["useMemo"])(function () {
return [{
// translators: Button to fix block content
title: Object(external_wp_i18n_["_x"])('Resolve', 'imperative verb'),
onClick: onCompare
}, hasHTMLBlock && {
title: Object(external_wp_i18n_["__"])('Convert to HTML'),
onClick: convertToHTML
}, {
title: Object(external_wp_i18n_["__"])('Convert to Classic Block'),
onClick: convertToClassic
}].filter(Boolean);
}, [onCompare, convertToHTML, convertToClassic]);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(warning, {
actions: [Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
key: "recover",
onClick: attemptBlockRecovery,
isPrimary: true
}, Object(external_wp_i18n_["__"])('Attempt Block Recovery'))],
secondaryActions: hiddenActions
}, Object(external_wp_i18n_["__"])('This block contains unexpected or invalid content.')), compare && Object(external_wp_element_["createElement"])(external_wp_components_["Modal"], {
title: // translators: Dialog title to fix block content
Object(external_wp_i18n_["__"])('Resolve Block'),
onRequestClose: onCompareClose,
className: "block-editor-block-compare"
}, Object(external_wp_element_["createElement"])(block_compare, {
block: block,
onKeep: convertToHTML,
onConvert: convertToBlocks,
convertor: block_invalid_warning_blockToBlocks,
convertButtonText: Object(external_wp_i18n_["__"])('Convert to Blocks')
})));
}
var block_invalid_warning_blockToClassic = function blockToClassic(block) {
return Object(external_wp_blocks_["createBlock"])('core/freeform', {
content: block.originalContent
});
};
var block_invalid_warning_blockToHTML = function blockToHTML(block) {
return Object(external_wp_blocks_["createBlock"])('core/html', {
content: block.originalContent
});
};
var block_invalid_warning_blockToBlocks = function blockToBlocks(block) {
return Object(external_wp_blocks_["rawHandler"])({
HTML: block.originalContent
});
};
var block_invalid_warning_recoverBlock = function recoverBlock(_ref2) {
var name = _ref2.name,
attributes = _ref2.attributes,
innerBlocks = _ref2.innerBlocks;
return Object(external_wp_blocks_["createBlock"])(name, attributes, innerBlocks);
};
/* harmony default export */ var block_invalid_warning = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(function (select, _ref3) {
var clientId = _ref3.clientId;
return {
block: select('core/block-editor').getBlock(clientId)
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, _ref4) {
var block = _ref4.block;
var _dispatch = dispatch('core/block-editor'),
replaceBlock = _dispatch.replaceBlock;
return {
convertToClassic: function convertToClassic() {
replaceBlock(block.clientId, block_invalid_warning_blockToClassic(block));
},
convertToHTML: function convertToHTML() {
replaceBlock(block.clientId, block_invalid_warning_blockToHTML(block));
},
convertToBlocks: function convertToBlocks() {
replaceBlock(block.clientId, block_invalid_warning_blockToBlocks(block));
},
attemptBlockRecovery: function attemptBlockRecovery() {
replaceBlock(block.clientId, block_invalid_warning_recoverBlock(block));
}
};
})])(BlockInvalidWarning));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-warning.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_crash_warning_warning = Object(external_wp_element_["createElement"])(warning, {
className: "block-editor-block-list__block-crash-warning"
}, Object(external_wp_i18n_["__"])('This block has encountered an error and cannot be previewed.'));
/* harmony default export */ var block_crash_warning = (function () {
return block_crash_warning_warning;
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-crash-boundary.js
function block_crash_boundary_createSuper(Derived) { var hasNativeReflectConstruct = block_crash_boundary_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function block_crash_boundary_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* WordPress dependencies
*/
var block_crash_boundary_BlockCrashBoundary = /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(BlockCrashBoundary, _Component);
var _super = block_crash_boundary_createSuper(BlockCrashBoundary);
function BlockCrashBoundary() {
var _this;
Object(classCallCheck["a" /* default */])(this, BlockCrashBoundary);
_this = _super.apply(this, arguments);
_this.state = {
hasError: false
};
return _this;
}
Object(createClass["a" /* default */])(BlockCrashBoundary, [{
key: "componentDidCatch",
value: function componentDidCatch(error) {
this.props.onError(error);
this.setState({
hasError: true
});
}
}, {
key: "render",
value: function render() {
if (this.state.hasError) {
return null;
}
return this.props.children;
}
}]);
return BlockCrashBoundary;
}(external_wp_element_["Component"]);
/* harmony default export */ var block_crash_boundary = (block_crash_boundary_BlockCrashBoundary);
// EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
var lib = __webpack_require__(90);
var lib_default = /*#__PURE__*/__webpack_require__.n(lib);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-html.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function BlockHTML(_ref) {
var clientId = _ref.clientId;
var _useState = Object(external_wp_element_["useState"])(''),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
html = _useState2[0],
setHtml = _useState2[1];
var block = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').getBlock(clientId);
}, [clientId]);
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlock = _useDispatch.updateBlock;
var onChange = function onChange() {
var blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
var attributes = Object(external_wp_blocks_["getBlockAttributes"])(blockType, html, block.attributes); // If html is empty we reset the block to the default HTML and mark it as valid to avoid triggering an error
var content = html ? html : Object(external_wp_blocks_["getSaveContent"])(blockType, attributes);
var isValid = html ? Object(external_wp_blocks_["isValidBlockContent"])(blockType, attributes, content) : true;
updateBlock(clientId, {
attributes: attributes,
originalContent: content,
isValid: isValid
}); // Ensure the state is updated if we reset so it displays the default content
if (!html) {
setHtml({
content: content
});
}
};
Object(external_wp_element_["useEffect"])(function () {
setHtml(Object(external_wp_blocks_["getBlockContent"])(block));
}, [block]);
return Object(external_wp_element_["createElement"])(lib_default.a, {
className: "block-editor-block-list__block-html-textarea",
value: html,
onBlur: onChange,
onChange: function onChange(event) {
return setHtml(event.target.value);
}
});
}
/* harmony default export */ var block_html = (BlockHTML);
// EXTERNAL MODULE: external ["wp","htmlEntities"]
var external_wp_htmlEntities_ = __webpack_require__(64);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/plus.js
var plus = __webpack_require__(214);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tips.js
/**
* WordPress dependencies
*/
var globalTips = [Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('While writing, you can press / to quickly insert new blocks.'), {
kbd: Object(external_wp_element_["createElement"])("kbd", null)
}), Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('Indent a list by pressing space at the beginning of a line.'), {
kbd: Object(external_wp_element_["createElement"])("kbd", null)
}), Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["__"])('Outdent a list by pressing backspace at the beginning of a line.'), {
kbd: Object(external_wp_element_["createElement"])("kbd", null)
}), Object(external_wp_i18n_["__"])('Drag files into the editor to automatically insert media blocks.'), Object(external_wp_i18n_["__"])("Change a block's type by pressing the block icon on the toolbar.")];
function Tips() {
var _useState = Object(external_wp_element_["useState"])( // Disable Reason: I'm not generating an HTML id.
// eslint-disable-next-line no-restricted-syntax
Math.floor(Math.random() * globalTips.length)),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 1),
randomIndex = _useState2[0];
return Object(external_wp_element_["createElement"])(external_wp_components_["Tip"], null, globalTips[randomIndex]);
}
/* harmony default export */ var tips = (Tips);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close-small.js
var close_small = __webpack_require__(159);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/icon/index.js
var build_module_icon = __webpack_require__(135);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/search.js
var search = __webpack_require__(215);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-form.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function InserterSearchForm(_ref) {
var className = _ref.className,
_onChange = _ref.onChange,
value = _ref.value,
placeholder = _ref.placeholder;
var instanceId = Object(external_wp_compose_["useInstanceId"])(InserterSearchForm);
var searchInput = Object(external_wp_element_["useRef"])();
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-inserter__search', className)
}, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
as: "label",
htmlFor: "block-editor-inserter__search-".concat(instanceId)
}, placeholder), Object(external_wp_element_["createElement"])("input", {
ref: searchInput,
className: "block-editor-inserter__search-input",
id: "block-editor-inserter__search-".concat(instanceId),
type: "search",
placeholder: placeholder,
onChange: function onChange(event) {
return _onChange(event.target.value);
},
autoComplete: "off",
value: value || ''
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__search-icon"
}, !!value && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: close_small["a" /* default */],
label: Object(external_wp_i18n_["__"])('Reset search'),
onClick: function onClick() {
_onChange('');
searchInput.current.focus();
}
}), !value && Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
icon: search["a" /* default */]
})));
}
/* harmony default export */ var search_form = (InserterSearchForm);
// EXTERNAL MODULE: external ["wp","deprecated"]
var external_wp_deprecated_ = __webpack_require__(35);
var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-card/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockCard(_ref) {
var title = _ref.title,
icon = _ref.icon,
description = _ref.description,
blockType = _ref.blockType;
if (blockType) {
external_wp_deprecated_default()('`blockType` property in `BlockCard component`', {
alternative: '`title, icon and description` properties'
});
title = blockType.title;
icon = blockType.icon;
description = blockType.description;
}
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-card"
}, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: icon,
showColors: true
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-card__content"
}, Object(external_wp_element_["createElement"])("h2", {
className: "block-editor-block-card__title"
}, title), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-card__description"
}, description)));
}
/* harmony default export */ var block_card = (BlockCard);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/with-registry-provider.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var withRegistryProvider = Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return Object(external_wp_data_["withRegistry"])(function (_ref) {
var _ref$useSubRegistry = _ref.useSubRegistry,
useSubRegistry = _ref$useSubRegistry === void 0 ? true : _ref$useSubRegistry,
registry = _ref.registry,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["useSubRegistry", "registry"]);
if (!useSubRegistry) {
return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({
registry: registry
}, props));
}
var _useState = Object(external_wp_element_["useState"])(null),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
subRegistry = _useState2[0],
setSubRegistry = _useState2[1];
Object(external_wp_element_["useEffect"])(function () {
var newRegistry = Object(external_wp_data_["createRegistry"])({}, registry);
newRegistry.registerStore('core/block-editor', storeConfig);
setSubRegistry(newRegistry);
}, [registry]);
if (!subRegistry) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_data_["RegistryProvider"], {
value: subRegistry
}, Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({
registry: subRegistry
}, props)));
});
}, 'withRegistryProvider');
/* harmony default export */ var with_registry_provider = (withRegistryProvider);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/use-block-sync.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* A function to call when the block value has been updated in the block-editor
* store.
*
* @callback onBlockUpdate
* @param {Object[]} blocks The updated blocks.
* @param {Object} options The updated block options, such as selectionStart
* and selectionEnd.
*/
/**
* useBlockSync is a side effect which handles bidirectional sync between the
* block-editor store and a controlling data source which provides blocks. This
* is most commonly used by the BlockEditorProvider to synchronize the contents
* of the block-editor store with the root entity, like a post.
*
* Another example would be the template part block, which provides blocks from
* a separate entity data source than a root entity. This hook syncs edits to
* the template part in the block editor back to the entity and vice-versa.
*
* Here are some of its basic functions:
* - Initalizes the block-editor store for the given clientID to the blocks
* given via props.
* - Adds incoming changes (like undo) to the block-editor store.
* - Adds outgoing changes (like editing content) to the controlling entity,
* determining if a change should be considered persistent or not.
* - Handles edge cases and race conditions which occur in those operations.
* - Ignores changes which happen to other entities (like nested inner block
* controllers.
* - Passes selection state from the block-editor store to the controlling entity.
*
* @param {Object} props Props for the block sync hook
* @param {string} props.clientId The client ID of the inner block controller.
* If none is passed, then it is assumed to be a
* root controller rather than an inner block
* controller.
* @param {Object[]} props.value The control value for the blocks. This value
* is used to initalize the block-editor store
* and for resetting the blocks to incoming
* changes like undo.
* @param {Object} props.selectionStart The selection start vlaue from the
* controlling component.
* @param {Object} props.selectionEnd The selection end vlaue from the
* controlling component.
* @param {onBlockUpdate} props.onChange Function to call when a persistent
* change has been made in the block-editor blocks
* for the given clientId. For example, after
* this function is called, an entity is marked
* dirty because it has changes to save.
* @param {onBlockUpdate} props.onInput Function to call when a non-persistent
* change has been made in the block-editor blocks
* for the given clientId. When this is called,
* controlling sources do not become dirty.
*/
function useBlockSync(_ref) {
var _ref$clientId = _ref.clientId,
clientId = _ref$clientId === void 0 ? null : _ref$clientId,
controlledBlocks = _ref.value,
controlledSelectionStart = _ref.selectionStart,
controlledSelectionEnd = _ref.selectionEnd,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange,
_ref$onInput = _ref.onInput,
onInput = _ref$onInput === void 0 ? external_lodash_["noop"] : _ref$onInput;
var registry = Object(external_wp_data_["useRegistry"])();
var _registry$dispatch = registry.dispatch('core/block-editor'),
resetBlocks = _registry$dispatch.resetBlocks,
resetSelection = _registry$dispatch.resetSelection,
replaceInnerBlocks = _registry$dispatch.replaceInnerBlocks,
setHasControlledInnerBlocks = _registry$dispatch.setHasControlledInnerBlocks,
__unstableMarkNextChangeAsNotPersistent = _registry$dispatch.__unstableMarkNextChangeAsNotPersistent;
var _registry$select = registry.select('core/block-editor'),
getBlockName = _registry$select.getBlockName,
getBlocks = _registry$select.getBlocks;
var pendingChanges = Object(external_wp_element_["useRef"])({
incoming: null,
outgoing: []
});
var subscribed = Object(external_wp_element_["useRef"])(false);
var setControlledBlocks = function setControlledBlocks() {
if (!controlledBlocks) {
return;
} // We don't need to persist this change because we only replace
// controlled inner blocks when the change was caused by an entity,
// and so it would already be persisted.
__unstableMarkNextChangeAsNotPersistent();
if (clientId) {
setHasControlledInnerBlocks(clientId, true);
__unstableMarkNextChangeAsNotPersistent();
var storeBlocks = controlledBlocks.map(function (block) {
return Object(external_wp_blocks_["cloneBlock"])(block);
});
if (subscribed.current) {
pendingChanges.current.incoming = storeBlocks;
}
replaceInnerBlocks(clientId, storeBlocks);
} else {
if (subscribed.current) {
pendingChanges.current.incoming = controlledBlocks;
}
resetBlocks(controlledBlocks);
}
}; // Add a subscription to the block-editor registry to detect when changes
// have been made. This lets us inform the data source of changes. This
// is an effect so that the subscriber can run synchronously without
// waiting for React renders for changes.
var onInputRef = Object(external_wp_element_["useRef"])(onInput);
var onChangeRef = Object(external_wp_element_["useRef"])(onChange);
Object(external_wp_element_["useEffect"])(function () {
onInputRef.current = onInput;
onChangeRef.current = onChange;
}, [onInput, onChange]); // Determine if blocks need to be reset when they change.
Object(external_wp_element_["useEffect"])(function () {
if (pendingChanges.current.outgoing.includes(controlledBlocks)) {
// Skip block reset if the value matches expected outbound sync
// triggered by this component by a preceding change detection.
// Only skip if the value matches expectation, since a reset should
// still occur if the value is modified (not equal by reference),
// to allow that the consumer may apply modifications to reflect
// back on the editor.
if (Object(external_lodash_["last"])(pendingChanges.current.outgoing) === controlledBlocks) {
pendingChanges.current.outgoing = [];
}
} else if (getBlocks(clientId) !== controlledBlocks) {
// Reset changing value in all other cases than the sync described
// above. Since this can be reached in an update following an out-
// bound sync, unset the outbound value to avoid considering it in
// subsequent renders.
pendingChanges.current.outgoing = [];
setControlledBlocks();
if (controlledSelectionStart && controlledSelectionEnd) {
resetSelection(controlledSelectionStart, controlledSelectionEnd);
}
}
}, [controlledBlocks, clientId]);
Object(external_wp_element_["useEffect"])(function () {
var _registry$select2 = registry.select('core/block-editor'),
getSelectionStart = _registry$select2.getSelectionStart,
getSelectionEnd = _registry$select2.getSelectionEnd,
isLastBlockChangePersistent = _registry$select2.isLastBlockChangePersistent,
__unstableIsLastBlockChangeIgnored = _registry$select2.__unstableIsLastBlockChangeIgnored;
var blocks = getBlocks(clientId);
var isPersistent = isLastBlockChangePersistent();
var previousAreBlocksDifferent = false;
subscribed.current = true;
var unsubscribe = registry.subscribe(function () {
// Sometimes, when changing block lists, lingering subscriptions
// might trigger before they are cleaned up. If the block for which
// the subscription runs is no longer in the store, this would clear
// its parent entity's block list. To avoid this, we bail out if
// the subscription is triggering for a block (`clientId !== null`)
// and its block name can't be found because it's not on the list.
// (`getBlockName( clientId ) === null`).
if (clientId !== null && getBlockName(clientId) === null) return;
var newIsPersistent = isLastBlockChangePersistent();
var newBlocks = getBlocks(clientId);
var areBlocksDifferent = newBlocks !== blocks;
blocks = newBlocks;
if (areBlocksDifferent && (pendingChanges.current.incoming || __unstableIsLastBlockChangeIgnored())) {
pendingChanges.current.incoming = null;
isPersistent = newIsPersistent;
return;
} // Since we often dispatch an action to mark the previous action as
// persistent, we need to make sure that the blocks changed on the
// previous action before committing the change.
var didPersistenceChange = previousAreBlocksDifferent && !areBlocksDifferent && newIsPersistent && !isPersistent;
if (areBlocksDifferent || didPersistenceChange) {
isPersistent = newIsPersistent; // We know that onChange/onInput will update controlledBlocks.
// We need to be aware that it was caused by an outgoing change
// so that we do not treat it as an incoming change later on,
// which would cause a block reset.
pendingChanges.current.outgoing.push(blocks); // Inform the controlling entity that changes have been made to
// the block-editor store they should be aware about.
var updateParent = isPersistent ? onChangeRef.current : onInputRef.current;
updateParent(blocks, {
selectionStart: getSelectionStart(),
selectionEnd: getSelectionEnd()
});
}
previousAreBlocksDifferent = areBlocksDifferent;
});
return function () {
return unsubscribe();
};
}, [registry, clientId]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/provider/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
function BlockEditorProvider(props) {
var children = props.children,
settings = props.settings;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateSettings = _useDispatch.updateSettings;
Object(external_wp_element_["useEffect"])(function () {
updateSettings(settings);
}, [settings]); // Syncs the entity provider with changes in the block-editor store.
useBlockSync(props);
return children;
}
/* harmony default export */ var provider = (with_registry_provider(BlockEditorProvider));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/live.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LiveBlockPreview(_ref) {
var onClick = _ref.onClick;
return Object(external_wp_element_["createElement"])("div", {
tabIndex: 0,
role: "button",
onClick: onClick,
onKeyPress: onClick
}, Object(external_wp_element_["createElement"])(external_wp_components_["Disabled"], null, Object(external_wp_element_["createElement"])(BlockList, null)));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/auto.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
// This is used to avoid rendering the block list if the sizes change.
var MemoizedBlockList;
function AutoBlockPreview(_ref) {
var viewportWidth = _ref.viewportWidth,
__experimentalPadding = _ref.__experimentalPadding;
var _useResizeObserver = Object(external_wp_compose_["useResizeObserver"])(),
_useResizeObserver2 = Object(slicedToArray["a" /* default */])(_useResizeObserver, 2),
containerResizeListener = _useResizeObserver2[0],
containerWidth = _useResizeObserver2[1].width;
var _useResizeObserver3 = Object(external_wp_compose_["useResizeObserver"])(),
_useResizeObserver4 = Object(slicedToArray["a" /* default */])(_useResizeObserver3, 2),
containtResizeListener = _useResizeObserver4[0],
contentHeight = _useResizeObserver4[1].height; // Initialize on render instead of module top level, to avoid circular dependency issues.
MemoizedBlockList = MemoizedBlockList || Object(external_wp_compose_["pure"])(BlockList);
var scale = (containerWidth - 2 * __experimentalPadding) / viewportWidth;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-preview__container editor-styles-wrapper",
"aria-hidden": true,
style: {
height: contentHeight * scale + 2 * __experimentalPadding
}
}, containerResizeListener, Object(external_wp_element_["createElement"])(external_wp_components_["Disabled"], {
style: {
transform: "scale(".concat(scale, ")"),
width: viewportWidth,
left: __experimentalPadding,
right: __experimentalPadding,
top: __experimentalPadding
},
className: "block-editor-block-preview__content"
}, containtResizeListener, Object(external_wp_element_["createElement"])(MemoizedBlockList, null)));
}
/* harmony default export */ var auto = (AutoBlockPreview);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-preview/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockPreview(_ref) {
var blocks = _ref.blocks,
_ref$__experimentalPa = _ref.__experimentalPadding,
__experimentalPadding = _ref$__experimentalPa === void 0 ? 0 : _ref$__experimentalPa,
_ref$viewportWidth = _ref.viewportWidth,
viewportWidth = _ref$viewportWidth === void 0 ? 1200 : _ref$viewportWidth,
_ref$__experimentalLi = _ref.__experimentalLive,
__experimentalLive = _ref$__experimentalLi === void 0 ? false : _ref$__experimentalLi,
__experimentalOnClick = _ref.__experimentalOnClick;
var settings = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').getSettings();
}, []);
var renderedBlocks = Object(external_wp_element_["useMemo"])(function () {
return Object(external_lodash_["castArray"])(blocks);
}, [blocks]);
if (!blocks || blocks.length === 0) {
return null;
}
return Object(external_wp_element_["createElement"])(provider, {
value: renderedBlocks,
settings: settings
}, __experimentalLive ? Object(external_wp_element_["createElement"])(LiveBlockPreview, {
onClick: __experimentalOnClick
}) : Object(external_wp_element_["createElement"])(auto, {
viewportWidth: viewportWidth,
__experimentalPadding: __experimentalPadding
}));
}
/**
* BlockPreview renders a preview of a block or array of blocks.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-preview/README.md
*
* @param {Object} preview options for how the preview should be shown
* @param {Array|Object} preview.blocks A block instance (object) or an array of blocks to be previewed.
* @param {number} preview.viewportWidth Width of the preview container in pixels. Controls at what size the blocks will be rendered inside the preview. Default: 700.
*
* @return {WPComponent} The component to be rendered.
*/
/* harmony default export */ var block_preview = (Object(external_wp_element_["memo"])(BlockPreview));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/preview-panel.js
function preview_panel_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function preview_panel_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { preview_panel_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { preview_panel_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InserterPreviewPanel(_ref) {
var _hoveredItemBlockType, _hoveredItemBlockType2;
var item = _ref.item;
var name = item.name,
title = item.title,
icon = item.icon,
description = item.description,
initialAttributes = item.initialAttributes;
var hoveredItemBlockType = Object(external_wp_blocks_["getBlockType"])(name);
var isReusable = Object(external_wp_blocks_["isReusableBlock"])(item);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__preview-container"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__preview"
}, isReusable || hoveredItemBlockType.example ? Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__preview-content"
}, Object(external_wp_element_["createElement"])(block_preview, {
__experimentalPadding: 16,
viewportWidth: (_hoveredItemBlockType = (_hoveredItemBlockType2 = hoveredItemBlockType.example) === null || _hoveredItemBlockType2 === void 0 ? void 0 : _hoveredItemBlockType2.viewportWidth) !== null && _hoveredItemBlockType !== void 0 ? _hoveredItemBlockType : 500,
blocks: hoveredItemBlockType.example ? Object(external_wp_blocks_["getBlockFromExample"])(item.name, {
attributes: preview_panel_objectSpread(preview_panel_objectSpread({}, hoveredItemBlockType.example.attributes), initialAttributes),
innerBlocks: hoveredItemBlockType.example.innerBlocks
}) : Object(external_wp_blocks_["createBlock"])(name, initialAttributes)
})) : Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__preview-content-missing"
}, Object(external_wp_i18n_["__"])('No Preview Available.'))), !isReusable && Object(external_wp_element_["createElement"])(block_card, {
title: title,
icon: icon,
description: description
}));
}
/* harmony default export */ var preview_panel = (InserterPreviewPanel);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/drag-handle.js
/**
* WordPress dependencies
*/
var dragHandle = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
width: "18",
height: "18",
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 18 18"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M5 4h2V2H5v2zm6-2v2h2V2h-2zm-6 8h2V8H5v2zm6 0h2V8h-2v2zm-6 6h2v-2H5v2zm6 0h2v-2h-2v2z"
}));
/* harmony default export */ var drag_handle = (dragHandle);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/draggable-chip.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockDraggableChip(_ref) {
var count = _ref.count,
icon = _ref.icon;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-draggable-chip-wrapper"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-draggable-chip"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], {
justify: "center",
className: "block-editor-block-draggable-chip__content"
}, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, icon ? Object(external_wp_element_["createElement"])(BlockIcon, {
icon: icon
}) : Object(external_wp_i18n_["sprintf"])(
/* translators: %d: Number of blocks. */
Object(external_wp_i18n_["_n"])('%d block', '%d blocks', count), count)), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: drag_handle
})))));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-draggable-blocks/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var inserter_draggable_blocks_InserterDraggableBlocks = function InserterDraggableBlocks(_ref) {
var isEnabled = _ref.isEnabled,
blocks = _ref.blocks,
icon = _ref.icon,
children = _ref.children;
var transferData = {
type: 'inserter',
blocks: blocks
};
return Object(external_wp_element_["createElement"])(external_wp_components_["Draggable"], {
transferData: transferData,
__experimentalDragComponent: Object(external_wp_element_["createElement"])(BlockDraggableChip, {
count: blocks.length,
icon: icon
})
}, function (_ref2) {
var onDraggableStart = _ref2.onDraggableStart,
onDraggableEnd = _ref2.onDraggableEnd;
return children({
draggable: isEnabled,
onDragStart: isEnabled ? onDraggableStart : undefined,
onDragEnd: isEnabled ? onDraggableEnd : undefined
});
});
};
/* harmony default export */ var inserter_draggable_blocks = (inserter_draggable_blocks_InserterDraggableBlocks);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-list-item/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InserterListItem(_ref) {
var className = _ref.className,
composite = _ref.composite,
item = _ref.item,
onSelect = _ref.onSelect,
onHover = _ref.onHover,
isDraggable = _ref.isDraggable,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["className", "composite", "item", "onSelect", "onHover", "isDraggable"]);
var isDragging = Object(external_wp_element_["useRef"])(false);
var itemIconStyle = item.icon ? {
backgroundColor: item.icon.background,
color: item.icon.foreground
} : {};
var blocks = Object(external_wp_element_["useMemo"])(function () {
return [Object(external_wp_blocks_["createBlock"])(item.name, item.initialAttributes, Object(external_wp_blocks_["createBlocksFromInnerBlocksTemplate"])(item.innerBlocks))];
}, [item.name, item.initialAttributes, item.initialAttributes]);
return Object(external_wp_element_["createElement"])(inserter_draggable_blocks, {
isEnabled: isDraggable && !item.disabled,
blocks: blocks,
icon: item.icon
}, function (_ref2) {
var draggable = _ref2.draggable,
_onDragStart = _ref2.onDragStart,
_onDragEnd = _ref2.onDragEnd;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-types-list__list-item",
draggable: draggable,
onDragStart: function onDragStart(event) {
isDragging.current = true;
if (_onDragStart) {
onHover(null);
_onDragStart(event);
}
},
onDragEnd: function onDragEnd(event) {
isDragging.current = false;
if (_onDragEnd) {
_onDragEnd(event);
}
}
}, Object(external_wp_element_["createElement"])(external_wp_components_["__unstableCompositeItem"], Object(esm_extends["a" /* default */])({
role: "option",
as: external_wp_components_["Button"]
}, composite, {
className: classnames_default()('block-editor-block-types-list__item', className),
disabled: item.isDisabled,
onClick: function onClick(event) {
event.preventDefault();
onSelect(item);
onHover(null);
},
onFocus: function onFocus() {
if (isDragging.current) {
return;
}
onHover(item);
},
onMouseEnter: function onMouseEnter() {
if (isDragging.current) {
return;
}
onHover(item);
},
onMouseLeave: function onMouseLeave() {
return onHover(null);
},
onBlur: function onBlur() {
return onHover(null);
} // Use the CompositeItem `focusable` prop over Button's
// isFocusable. The latter was shown to cause an issue
// with tab order in the inserter list.
,
focusable: true
}, props), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-types-list__item-icon",
style: itemIconStyle
}, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: item.icon,
showColors: true
})), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-types-list__item-title"
}, item.title)));
});
}
/* harmony default export */ var inserter_list_item = (Object(external_wp_element_["memo"])(InserterListItem));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-types-list/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockTypesList(_ref) {
var _ref$items = _ref.items,
items = _ref$items === void 0 ? [] : _ref$items,
onSelect = _ref.onSelect,
_ref$onHover = _ref.onHover,
onHover = _ref$onHover === void 0 ? function () {} : _ref$onHover,
children = _ref.children,
label = _ref.label,
_ref$isDraggable = _ref.isDraggable,
isDraggable = _ref$isDraggable === void 0 ? true : _ref$isDraggable;
var composite = Object(external_wp_components_["__unstableUseCompositeState"])();
return (
/*
* Disable reason: The `list` ARIA role is redundant but
* Safari+VoiceOver won't announce the list otherwise.
*/
/* eslint-disable jsx-a11y/no-redundant-roles */
Object(external_wp_element_["createElement"])(external_wp_components_["__unstableComposite"], Object(esm_extends["a" /* default */])({}, composite, {
role: "listbox",
className: "block-editor-block-types-list",
"aria-label": label
}), items.map(function (item) {
return Object(external_wp_element_["createElement"])(inserter_list_item, {
key: item.id,
item: item,
className: Object(external_wp_blocks_["getBlockMenuDefaultClassName"])(item.id),
onSelect: onSelect,
onHover: onHover,
composite: composite,
isDraggable: isDraggable
});
}), children)
/* eslint-enable jsx-a11y/no-redundant-roles */
);
}
/* harmony default export */ var block_types_list = (BlockTypesList);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/panel.js
/**
* WordPress dependencies
*/
function InserterPanel(_ref) {
var title = _ref.title,
icon = _ref.icon,
children = _ref.children;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__panel-header"
}, Object(external_wp_element_["createElement"])("h2", {
className: "block-editor-inserter__panel-title"
}, title), Object(external_wp_element_["createElement"])(external_wp_components_["Icon"], {
icon: icon
})), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__panel-content"
}, children));
}
/* harmony default export */ var panel = (InserterPanel);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-types-tab.js
function block_types_tab_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_types_tab_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_types_tab_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_types_tab_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var getBlockNamespace = function getBlockNamespace(item) {
return item.name.split('/')[0];
};
var MAX_SUGGESTED_ITEMS = 6;
function BlockTypesTab(_ref) {
var rootClientId = _ref.rootClientId,
onInsert = _ref.onInsert,
onHover = _ref.onHover,
showMostUsedBlocks = _ref.showMostUsedBlocks;
var _useBlockTypesState = use_block_types_state(rootClientId, onInsert),
_useBlockTypesState2 = Object(slicedToArray["a" /* default */])(_useBlockTypesState, 4),
items = _useBlockTypesState2[0],
categories = _useBlockTypesState2[1],
collections = _useBlockTypesState2[2],
onSelectItem = _useBlockTypesState2[3];
var suggestedItems = Object(external_wp_element_["useMemo"])(function () {
return Object(external_lodash_["orderBy"])(items, ['frecency'], ['desc']).slice(0, MAX_SUGGESTED_ITEMS);
}, [items]);
var uncategorizedItems = Object(external_wp_element_["useMemo"])(function () {
return items.filter(function (item) {
return !item.category;
});
}, [items]);
var itemsPerCategory = Object(external_wp_element_["useMemo"])(function () {
var getCategoryIndex = function getCategoryIndex(item) {
return Object(external_lodash_["findIndex"])(categories, function (category) {
return category.slug === item.category;
});
};
return Object(external_lodash_["flow"])(function (itemList) {
return itemList.filter(function (item) {
return item.category && item.category !== 'reusable';
});
}, function (itemList) {
return Object(external_lodash_["sortBy"])(itemList, getCategoryIndex);
}, function (itemList) {
return Object(external_lodash_["groupBy"])(itemList, 'category');
})(items);
}, [items, categories]);
var itemsPerCollection = Object(external_wp_element_["useMemo"])(function () {
// Create a new Object to avoid mutating collection.
var result = block_types_tab_objectSpread({}, collections);
Object.keys(collections).forEach(function (namespace) {
result[namespace] = items.filter(function (item) {
return getBlockNamespace(item) === namespace;
});
if (result[namespace].length === 0) {
delete result[namespace];
}
});
return result;
}, [items, collections]); // Hide block preview on unmount.
Object(external_wp_element_["useEffect"])(function () {
return function () {
return onHover(null);
};
}, []);
return Object(external_wp_element_["createElement"])("div", null, showMostUsedBlocks && !!suggestedItems.length && Object(external_wp_element_["createElement"])(panel, {
title: Object(external_wp_i18n_["_x"])('Most used', 'blocks')
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: suggestedItems,
onSelect: onSelectItem,
onHover: onHover,
label: Object(external_wp_i18n_["_x"])('Most used', 'blocks')
})), Object(external_lodash_["map"])(categories, function (category) {
var categoryItems = itemsPerCategory[category.slug];
if (!categoryItems || !categoryItems.length) {
return null;
}
return Object(external_wp_element_["createElement"])(panel, {
key: category.slug,
title: category.title,
icon: category.icon
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: categoryItems,
onSelect: onSelectItem,
onHover: onHover,
label: category.title
}));
}), uncategorizedItems.length > 0 && Object(external_wp_element_["createElement"])(panel, {
className: "block-editor-inserter__uncategorized-blocks-panel",
title: Object(external_wp_i18n_["__"])('Uncategorized')
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: uncategorizedItems,
onSelect: onSelectItem,
onHover: onHover,
label: Object(external_wp_i18n_["__"])('Uncategorized')
})), Object(external_lodash_["map"])(collections, function (collection, namespace) {
var collectionItems = itemsPerCollection[namespace];
if (!collectionItems || !collectionItems.length) {
return null;
}
return Object(external_wp_element_["createElement"])(panel, {
key: namespace,
title: collection.title,
icon: collection.icon
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: collectionItems,
onSelect: onSelectItem,
onHover: onHover,
label: collection.title
}));
}));
}
/* harmony default export */ var block_types_tab = (BlockTypesTab);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/pattern-panel.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function PatternInserterPanel(_ref) {
var selectedCategory = _ref.selectedCategory,
patternCategories = _ref.patternCategories,
onClickCategory = _ref.onClickCategory,
children = _ref.children;
var categoryOptions = function categoryOptions() {
var options = [];
patternCategories.map(function (patternCategory) {
return options.push({
value: patternCategory.name,
label: patternCategory.label
});
});
return options;
};
var onChangeSelect = function onChangeSelect(selected) {
onClickCategory(patternCategories.find(function (patternCategory) {
return selected === patternCategory.name;
}));
};
var getPanelHeaderClassName = function getPanelHeaderClassName() {
return classnames_default()('block-editor-inserter__panel-header', 'block-editor-inserter__panel-header-patterns');
};
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
className: getPanelHeaderClassName()
}, Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
className: "block-editor-inserter__panel-dropdown",
label: Object(external_wp_i18n_["__"])('Filter patterns'),
hideLabelFromVision: true,
value: selectedCategory.name,
onChange: onChangeSelect,
options: categoryOptions()
})), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__panel-content"
}, children));
}
/* harmony default export */ var pattern_panel = (PatternInserterPanel);
// EXTERNAL MODULE: external ["wp","notices"]
var external_wp_notices_ = __webpack_require__(51);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-patterns-state.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Retrieves the block patterns inserter state.
*
* @param {Function} onInsert function called when inserter a list of blocks.
*
* @return {Array} Returns the patterns state. (patterns, categories, onSelect handler)
*/
var use_patterns_state_usePatternsState = function usePatternsState(onInsert) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select$getSettings = select('core/block-editor').getSettings(),
__experimentalBlockPatterns = _select$getSettings.__experimentalBlockPatterns,
__experimentalBlockPatternCategories = _select$getSettings.__experimentalBlockPatternCategories;
return {
patterns: __experimentalBlockPatterns,
patternCategories: __experimentalBlockPatternCategories
};
}, []),
patternCategories = _useSelect.patternCategories,
patterns = _useSelect.patterns;
var _useDispatch = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]),
createSuccessNotice = _useDispatch.createSuccessNotice;
var onClickPattern = Object(external_wp_element_["useCallback"])(function (pattern, blocks) {
onInsert(Object(external_lodash_["map"])(blocks, function (block) {
return Object(external_wp_blocks_["cloneBlock"])(block);
}), pattern.name);
createSuccessNotice(Object(external_wp_i18n_["sprintf"])(
/* translators: %s: block pattern title. */
Object(external_wp_i18n_["__"])('Block pattern "%s" inserted.'), pattern.title), {
type: 'snackbar'
});
}, []);
return [patterns, patternCategories, onClickPattern];
};
/* harmony default export */ var use_patterns_state = (use_patterns_state_usePatternsState);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-patterns-list/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockPattern(_ref) {
var isDraggable = _ref.isDraggable,
pattern = _ref.pattern,
_onClick = _ref.onClick;
var content = pattern.content,
viewportWidth = pattern.viewportWidth;
var blocks = Object(external_wp_element_["useMemo"])(function () {
return Object(external_wp_blocks_["parse"])(content);
}, [content]);
var instanceId = Object(external_wp_compose_["useInstanceId"])(BlockPattern);
var descriptionId = "block-editor-block-patterns-list__item-description-".concat(instanceId);
return Object(external_wp_element_["createElement"])(inserter_draggable_blocks, {
isEnabled: isDraggable,
blocks: blocks
}, function (_ref2) {
var draggable = _ref2.draggable,
onDragStart = _ref2.onDragStart,
onDragEnd = _ref2.onDragEnd;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-patterns-list__item",
role: "button",
onClick: function onClick() {
return _onClick(pattern, blocks);
},
onKeyDown: function onKeyDown(event) {
if (external_wp_keycodes_["ENTER"] === event.keyCode || external_wp_keycodes_["SPACE"] === event.keyCode) {
_onClick(pattern, blocks);
}
},
tabIndex: 0,
"aria-label": pattern.title,
"aria-describedby": pattern.description ? descriptionId : undefined,
draggable: draggable,
onDragStart: onDragStart,
onDragEnd: onDragEnd
}, Object(external_wp_element_["createElement"])(block_preview, {
blocks: blocks,
viewportWidth: viewportWidth
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-patterns-list__item-title"
}, pattern.title), !!pattern.description && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
id: descriptionId
}, pattern.description));
});
}
function BlockPatternPlaceholder() {
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-patterns-list__item is-placeholder"
});
}
function BlockPatternList(_ref3) {
var isDraggable = _ref3.isDraggable,
blockPatterns = _ref3.blockPatterns,
shownPatterns = _ref3.shownPatterns,
onClickPattern = _ref3.onClickPattern;
return blockPatterns.map(function (pattern) {
var isShown = shownPatterns.includes(pattern);
return isShown ? Object(external_wp_element_["createElement"])(BlockPattern, {
key: pattern.name,
pattern: pattern,
onClick: onClickPattern,
isDraggable: isDraggable
}) : Object(external_wp_element_["createElement"])(BlockPatternPlaceholder, {
key: pattern.name
});
});
}
/* harmony default export */ var block_patterns_list = (BlockPatternList);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/block-patterns-tab.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockPatternsCategory(_ref) {
var onInsert = _ref.onInsert,
selectedCategory = _ref.selectedCategory,
onClickCategory = _ref.onClickCategory;
var _usePatternsState = use_patterns_state(onInsert),
_usePatternsState2 = Object(slicedToArray["a" /* default */])(_usePatternsState, 3),
allPatterns = _usePatternsState2[0],
allCategories = _usePatternsState2[1],
onClick = _usePatternsState2[2]; // Remove any empty categories
var populatedCategories = Object(external_wp_element_["useMemo"])(function () {
return allCategories.filter(function (category) {
return allPatterns.some(function (pattern) {
var _pattern$categories;
return (_pattern$categories = pattern.categories) === null || _pattern$categories === void 0 ? void 0 : _pattern$categories.includes(category.name);
});
});
}, [allPatterns, allCategories]);
var patternCategory = selectedCategory ? selectedCategory : populatedCategories[0];
Object(external_wp_element_["useEffect"])(function () {
if (allPatterns.some(function (pattern) {
return getPatternIndex(pattern) === Infinity;
}) && !populatedCategories.find(function (category) {
return category.name === 'uncategorized';
})) {
populatedCategories.push({
name: 'uncategorized',
label: Object(external_wp_i18n_["_x"])('Uncategorized')
});
}
}, [populatedCategories, allPatterns]);
var getPatternIndex = Object(external_wp_element_["useCallback"])(function (pattern) {
if (!pattern.categories || !pattern.categories.length) {
return Infinity;
}
var indexedCategories = Object(external_lodash_["fromPairs"])(populatedCategories.map(function (_ref2, index) {
var name = _ref2.name;
return [name, index];
}));
return Math.min.apply(Math, Object(toConsumableArray["a" /* default */])(pattern.categories.map(function (cat) {
return indexedCategories[cat] !== undefined ? indexedCategories[cat] : Infinity;
})));
}, [populatedCategories]);
var currentCategoryPatterns = Object(external_wp_element_["useMemo"])(function () {
return allPatterns.filter(function (pattern) {
return patternCategory.name === 'uncategorized' ? getPatternIndex(pattern) === Infinity : pattern.categories && pattern.categories.includes(patternCategory.name);
});
}, [allPatterns, patternCategory]); // Ordering the patterns is important for the async rendering.
var orderedPatterns = Object(external_wp_element_["useMemo"])(function () {
return currentCategoryPatterns.sort(function (a, b) {
return getPatternIndex(a) - getPatternIndex(b);
});
}, [currentCategoryPatterns, getPatternIndex]);
var currentShownPatterns = Object(external_wp_compose_["useAsyncList"])(orderedPatterns);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, !!currentCategoryPatterns.length && Object(external_wp_element_["createElement"])(pattern_panel, {
title: patternCategory.title,
selectedCategory: patternCategory,
patternCategories: populatedCategories,
onClickCategory: onClickCategory
}, Object(external_wp_element_["createElement"])(block_patterns_list, {
shownPatterns: currentShownPatterns,
blockPatterns: currentCategoryPatterns,
onClickPattern: onClick,
isDraggable: true
})));
}
function BlockPatternsTabs(_ref3) {
var onInsert = _ref3.onInsert,
onClickCategory = _ref3.onClickCategory,
selectedCategory = _ref3.selectedCategory;
return Object(external_wp_element_["createElement"])(BlockPatternsCategory, {
selectedCategory: selectedCategory,
onInsert: onInsert,
onClickCategory: onClickCategory
});
}
/* harmony default export */ var block_patterns_tab = (BlockPatternsTabs);
// EXTERNAL MODULE: external ["wp","url"]
var external_wp_url_ = __webpack_require__(32);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/no-results.js
/**
* WordPress dependencies
*/
function InserterNoResults() {
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__no-results"
}, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
className: "block-editor-inserter__no-results-icon",
icon: block_default["a" /* default */]
}), Object(external_wp_element_["createElement"])("p", null, Object(external_wp_i18n_["__"])('No results found.')));
}
/* harmony default export */ var no_results = (InserterNoResults);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/reusable-blocks-tab.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function ReusableBlocksList(_ref) {
var onHover = _ref.onHover,
onInsert = _ref.onInsert,
rootClientId = _ref.rootClientId;
var _useBlockTypesState = use_block_types_state(rootClientId, onInsert),
_useBlockTypesState2 = Object(slicedToArray["a" /* default */])(_useBlockTypesState, 4),
items = _useBlockTypesState2[0],
onSelectItem = _useBlockTypesState2[3];
var filteredItems = Object(external_wp_element_["useMemo"])(function () {
return items.filter(function (_ref2) {
var category = _ref2.category;
return category === 'reusable';
});
}, [items]);
if (filteredItems.length === 0) {
return Object(external_wp_element_["createElement"])(no_results, null);
}
return Object(external_wp_element_["createElement"])(panel, {
title: Object(external_wp_i18n_["__"])('Reusable blocks')
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: filteredItems,
onSelect: onSelectItem,
onHover: onHover,
label: Object(external_wp_i18n_["__"])('Reusable blocks')
}));
} // The unwrapped component is only exported for use by unit tests.
/**
* List of reusable blocks shown in the "Reusable" tab of the inserter.
*
* @param {Object} props Component props.
* @param {?string} props.rootClientId Client id of block to insert into.
* @param {Function} props.onInsert Callback to run when item is inserted.
* @param {Function} props.onHover Callback to run when item is hovered.
*
* @return {WPComponent} The component.
*/
function ReusableBlocksTab(_ref3) {
var rootClientId = _ref3.rootClientId,
onInsert = _ref3.onInsert,
onHover = _ref3.onHover;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlocksList, {
onHover: onHover,
onInsert: onInsert,
rootClientId: rootClientId
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__manage-reusable-blocks-container"
}, Object(external_wp_element_["createElement"])("a", {
className: "block-editor-inserter__manage-reusable-blocks",
href: Object(external_wp_url_["addQueryArgs"])('edit.php', {
post_type: 'wp_block'
})
}, Object(external_wp_i18n_["__"])('Manage all reusable blocks'))));
}
/* harmony default export */ var reusable_blocks_tab = (ReusableBlocksTab);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter-menu-extension/index.js
/**
* WordPress dependencies
*/
var inserter_menu_extension_createSlotFill = Object(external_wp_components_["createSlotFill"])('__experimentalInserterMenuExtension'),
__experimentalInserterMenuExtension = inserter_menu_extension_createSlotFill.Fill,
inserter_menu_extension_Slot = inserter_menu_extension_createSlotFill.Slot;
__experimentalInserterMenuExtension.Slot = inserter_menu_extension_Slot;
/* harmony default export */ var inserter_menu_extension = (__experimentalInserterMenuExtension);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/hooks/use-insertion-point.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* @typedef WPInserterConfig
*
* @property {string=} rootClientId If set, insertion will be into the
* block with this ID.
* @property {number=} insertionIndex If set, insertion will be into this
* explicit position.
* @property {string=} clientId If set, insertion will be after the
* block with this ID.
* @property {boolean=} isAppender Whether the inserter is an appender
* or not.
* @property {boolean=} selectBlockOnInsert Whether the block should be
* selected on insert.
* @property {Function=} onSelect Called after insertion.
*/
/**
* Returns the insertion point state given the inserter config.
*
* @param {WPInserterConfig} config Inserter Config.
* @return {Array} Insertion Point State (rootClientID, onInsertBlocks and onToggle).
*/
function useInsertionPoint(_ref) {
var rootClientId = _ref.rootClientId,
insertionIndex = _ref.insertionIndex,
clientId = _ref.clientId,
isAppender = _ref.isAppender,
selectBlockOnInsert = _ref.selectBlockOnInsert,
onSelect = _ref.onSelect;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlock = _select.getSelectedBlock,
getBlockIndex = _select.getBlockIndex,
getBlockOrder = _select.getBlockOrder,
getBlockInsertionPoint = _select.getBlockInsertionPoint;
var _destinationRootClientId, _destinationIndex;
if (rootClientId || insertionIndex || clientId || isAppender) {
// If any of these arguments are set, we're in "manual mode"
// meaning the insertion point is set by the caller.
_destinationRootClientId = rootClientId;
if (insertionIndex) {
// Insert into a specific index.
_destinationIndex = insertionIndex;
} else if (clientId) {
// Insert after a specific client ID.
_destinationIndex = getBlockIndex(clientId, _destinationRootClientId);
} else {
// Insert at the end of the list.
_destinationIndex = getBlockOrder(_destinationRootClientId).length;
}
} else {
// Otherwise, we're in "auto mode" where the insertion point is
// decided by getBlockInsertionPoint().
var insertionPoint = getBlockInsertionPoint();
_destinationRootClientId = insertionPoint.rootClientId;
_destinationIndex = insertionPoint.index;
}
return {
selectedBlock: getSelectedBlock(),
destinationRootClientId: _destinationRootClientId,
destinationIndex: _destinationIndex
};
}, [rootClientId, insertionIndex, clientId, isAppender]),
selectedBlock = _useSelect.selectedBlock,
destinationRootClientId = _useSelect.destinationRootClientId,
destinationIndex = _useSelect.destinationIndex;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
replaceBlocks = _useDispatch.replaceBlocks,
insertBlocks = _useDispatch.insertBlocks,
showInsertionPoint = _useDispatch.showInsertionPoint,
hideInsertionPoint = _useDispatch.hideInsertionPoint;
var onInsertBlocks = Object(external_wp_element_["useCallback"])(function (blocks, meta) {
if (!isAppender && selectedBlock && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(selectedBlock)) {
replaceBlocks(selectedBlock.clientId, blocks, null, null, meta);
} else {
insertBlocks(blocks, destinationIndex, destinationRootClientId, selectBlockOnInsert, meta);
}
if (!selectBlockOnInsert) {
var message = Object(external_wp_i18n_["sprintf"])( // translators: %d: the name of the block that has been added
Object(external_wp_i18n_["_n"])('%d block added.', '%d blocks added.', Object(external_lodash_["castArray"])(blocks).length), Object(external_lodash_["castArray"])(blocks).length);
Object(external_wp_a11y_["speak"])(message);
}
if (onSelect) {
onSelect();
}
}, [isAppender, selectedBlock, replaceBlocks, insertBlocks, destinationRootClientId, destinationIndex, selectBlockOnInsert, onSelect]);
var onToggleInsertionPoint = Object(external_wp_element_["useCallback"])(function (show) {
if (show) {
showInsertionPoint(destinationRootClientId, destinationIndex);
} else {
hideInsertionPoint();
}
}, [showInsertionPoint, hideInsertionPoint, destinationRootClientId, destinationIndex]);
return [destinationRootClientId, onInsertBlocks, onToggleInsertionPoint];
}
/* harmony default export */ var use_insertion_point = (useInsertionPoint);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/search-results.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InserterSearchResults(_ref) {
var filterValue = _ref.filterValue,
onSelect = _ref.onSelect,
onHover = _ref.onHover,
rootClientId = _ref.rootClientId,
clientId = _ref.clientId,
isAppender = _ref.isAppender,
selectBlockOnInsert = _ref.selectBlockOnInsert,
maxBlockPatterns = _ref.maxBlockPatterns,
maxBlockTypes = _ref.maxBlockTypes,
_ref$showBlockDirecto = _ref.showBlockDirectory,
showBlockDirectory = _ref$showBlockDirecto === void 0 ? false : _ref$showBlockDirecto,
_ref$isDraggable = _ref.isDraggable,
isDraggable = _ref$isDraggable === void 0 ? true : _ref$isDraggable;
var debouncedSpeak = Object(external_wp_compose_["useDebounce"])(external_wp_a11y_["speak"], 500);
var _useInsertionPoint = use_insertion_point({
onSelect: onSelect,
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: selectBlockOnInsert
}),
_useInsertionPoint2 = Object(slicedToArray["a" /* default */])(_useInsertionPoint, 2),
destinationRootClientId = _useInsertionPoint2[0],
onInsertBlocks = _useInsertionPoint2[1];
var _useBlockTypesState = use_block_types_state(destinationRootClientId, onInsertBlocks),
_useBlockTypesState2 = Object(slicedToArray["a" /* default */])(_useBlockTypesState, 4),
blockTypes = _useBlockTypesState2[0],
blockTypeCategories = _useBlockTypesState2[1],
blockTypeCollections = _useBlockTypesState2[2],
onSelectBlockType = _useBlockTypesState2[3];
var _usePatternsState = use_patterns_state(onInsertBlocks),
_usePatternsState2 = Object(slicedToArray["a" /* default */])(_usePatternsState, 3),
patterns = _usePatternsState2[0],
onSelectBlockPattern = _usePatternsState2[2];
var filteredBlockTypes = Object(external_wp_element_["useMemo"])(function () {
var results = search_items_searchBlockItems(Object(external_lodash_["orderBy"])(blockTypes, ['frecency'], ['desc']), blockTypeCategories, blockTypeCollections, filterValue);
return maxBlockTypes !== undefined ? results.slice(0, maxBlockTypes) : results;
}, [filterValue, blockTypes, blockTypeCategories, blockTypeCollections, maxBlockTypes]);
var filteredBlockPatterns = Object(external_wp_element_["useMemo"])(function () {
var results = search_items_searchItems(patterns, filterValue);
return maxBlockPatterns !== undefined ? results.slice(0, maxBlockPatterns) : results;
}, [filterValue, patterns, maxBlockPatterns]); // Announce search results on change
Object(external_wp_element_["useEffect"])(function () {
if (!filterValue) {
return;
}
var count = filteredBlockTypes.length + filteredBlockPatterns.length;
var resultsFoundMessage = Object(external_wp_i18n_["sprintf"])(
/* translators: %d: number of results. */
Object(external_wp_i18n_["_n"])('%d result found.', '%d results found.', count), count);
debouncedSpeak(resultsFoundMessage);
}, [filterValue, debouncedSpeak]);
var currentShownPatterns = Object(external_wp_compose_["useAsyncList"])(filteredBlockPatterns);
var hasItems = !Object(external_lodash_["isEmpty"])(filteredBlockTypes) || !Object(external_lodash_["isEmpty"])(filteredBlockPatterns);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, !showBlockDirectory && !hasItems && Object(external_wp_element_["createElement"])(no_results, null), !!filteredBlockTypes.length && Object(external_wp_element_["createElement"])(panel, {
title: Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('Blocks'))
}, Object(external_wp_element_["createElement"])(block_types_list, {
items: filteredBlockTypes,
onSelect: onSelectBlockType,
onHover: onHover,
label: Object(external_wp_i18n_["__"])('Blocks'),
isDraggable: isDraggable
})), !!filteredBlockTypes.length && !!filteredBlockPatterns.length && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__quick-inserter-separator"
}), !!filteredBlockPatterns.length && Object(external_wp_element_["createElement"])(panel, {
title: Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('Block Patterns'))
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__quick-inserter-patterns"
}, Object(external_wp_element_["createElement"])(block_patterns_list, {
shownPatterns: currentShownPatterns,
blockPatterns: filteredBlockPatterns,
onClickPattern: onSelectBlockPattern,
isDraggable: isDraggable
}))), showBlockDirectory && Object(external_wp_element_["createElement"])(inserter_menu_extension.Slot, {
fillProps: {
onSelect: onSelectBlockType,
onHover: onHover,
filterValue: filterValue,
hasItems: hasItems,
rootClientId: destinationRootClientId
}
}, function (fills) {
if (fills.length) {
return fills;
}
if (!hasItems) {
return Object(external_wp_element_["createElement"])(no_results, null);
}
return null;
}));
}
/* harmony default export */ var search_results = (InserterSearchResults);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/tabs.js
/**
* WordPress dependencies
*/
var tabs_blocksTab = {
name: 'blocks',
/* translators: Blocks tab title in the block inserter. */
title: Object(external_wp_i18n_["__"])('Blocks')
};
var tabs_patternsTab = {
name: 'patterns',
/* translators: Patterns tab title in the block inserter. */
title: Object(external_wp_i18n_["__"])('Patterns')
};
var tabs_reusableBlocksTab = {
name: 'reusable',
/* translators: Reusable blocks tab title in the block inserter. */
title: Object(external_wp_i18n_["__"])('Reusable')
};
function InserterTabs(_ref) {
var children = _ref.children,
_ref$showPatterns = _ref.showPatterns,
showPatterns = _ref$showPatterns === void 0 ? false : _ref$showPatterns,
_ref$showReusableBloc = _ref.showReusableBlocks,
showReusableBlocks = _ref$showReusableBloc === void 0 ? false : _ref$showReusableBloc,
onSelect = _ref.onSelect;
var tabs = Object(external_wp_element_["useMemo"])(function () {
var tempTabs = [tabs_blocksTab];
if (showPatterns) {
tempTabs.push(tabs_patternsTab);
}
if (showReusableBlocks) {
tempTabs.push(tabs_reusableBlocksTab);
}
return tempTabs;
}, [tabs_blocksTab, showPatterns, tabs_patternsTab, showReusableBlocks, tabs_reusableBlocksTab]);
return Object(external_wp_element_["createElement"])(external_wp_components_["TabPanel"], {
className: "block-editor-inserter__tabs",
tabs: tabs,
onSelect: onSelect
}, children);
}
/* harmony default export */ var inserter_tabs = (InserterTabs);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/menu.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InserterMenu(_ref) {
var rootClientId = _ref.rootClientId,
clientId = _ref.clientId,
isAppender = _ref.isAppender,
__experimentalSelectBlockOnInsert = _ref.__experimentalSelectBlockOnInsert,
__experimentalInsertionIndex = _ref.__experimentalInsertionIndex,
onSelect = _ref.onSelect,
showInserterHelpPanel = _ref.showInserterHelpPanel,
showMostUsedBlocks = _ref.showMostUsedBlocks;
var _useState = Object(external_wp_element_["useState"])(''),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
filterValue = _useState2[0],
setFilterValue = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(null),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
hoveredItem = _useState4[0],
setHoveredItem = _useState4[1];
var _useState5 = Object(external_wp_element_["useState"])(null),
_useState6 = Object(slicedToArray["a" /* default */])(_useState5, 2),
selectedPatternCategory = _useState6[0],
setSelectedPatternCategory = _useState6[1];
var _useInsertionPoint = use_insertion_point({
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: __experimentalSelectBlockOnInsert,
insertionIndex: __experimentalInsertionIndex
}),
_useInsertionPoint2 = Object(slicedToArray["a" /* default */])(_useInsertionPoint, 3),
destinationRootClientId = _useInsertionPoint2[0],
onInsertBlocks = _useInsertionPoint2[1],
onToggleInsertionPoint = _useInsertionPoint2[2];
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select$getSettings = select('core/block-editor').getSettings(),
__experimentalBlockPatterns = _select$getSettings.__experimentalBlockPatterns,
__experimentalReusableBlocks = _select$getSettings.__experimentalReusableBlocks;
return {
hasPatterns: !!(__experimentalBlockPatterns !== null && __experimentalBlockPatterns !== void 0 && __experimentalBlockPatterns.length),
hasReusableBlocks: !!(__experimentalReusableBlocks !== null && __experimentalReusableBlocks !== void 0 && __experimentalReusableBlocks.length)
};
}, []),
hasPatterns = _useSelect.hasPatterns,
hasReusableBlocks = _useSelect.hasReusableBlocks;
var showPatterns = !destinationRootClientId && hasPatterns;
var onInsert = Object(external_wp_element_["useCallback"])(function (blocks) {
onInsertBlocks(blocks);
onSelect();
}, [onInsertBlocks, onSelect]);
var onInsertPattern = Object(external_wp_element_["useCallback"])(function (blocks, patternName) {
onInsertBlocks(blocks, {
patternName: patternName
});
onSelect();
}, [onInsertBlocks, onSelect]);
var onHover = Object(external_wp_element_["useCallback"])(function (item) {
onToggleInsertionPoint(!!item);
setHoveredItem(item);
}, [onToggleInsertionPoint, setHoveredItem]);
var onClickPatternCategory = Object(external_wp_element_["useCallback"])(function (patternCategory) {
setSelectedPatternCategory(patternCategory);
}, [setSelectedPatternCategory]);
var blocksTab = Object(external_wp_element_["useMemo"])(function () {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__block-list"
}, Object(external_wp_element_["createElement"])(block_types_tab, {
rootClientId: destinationRootClientId,
onInsert: onInsert,
onHover: onHover,
showMostUsedBlocks: showMostUsedBlocks
})), showInserterHelpPanel && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__tips"
}, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
as: "h2"
}, Object(external_wp_i18n_["__"])('A tip for using the block editor')), Object(external_wp_element_["createElement"])(tips, null)));
}, [destinationRootClientId, onInsert, onHover, filterValue, showMostUsedBlocks, showInserterHelpPanel]);
var patternsTab = Object(external_wp_element_["useMemo"])(function () {
return Object(external_wp_element_["createElement"])(block_patterns_tab, {
onInsert: onInsertPattern,
onClickCategory: onClickPatternCategory,
selectedCategory: selectedPatternCategory
});
}, [onInsertPattern, onClickPatternCategory, selectedPatternCategory]);
var reusableBlocksTab = Object(external_wp_element_["useMemo"])(function () {
return Object(external_wp_element_["createElement"])(reusable_blocks_tab, {
rootClientId: destinationRootClientId,
onInsert: onInsert,
onHover: onHover
});
}, [destinationRootClientId, onInsert, onHover]);
var getCurrentTab = Object(external_wp_element_["useCallback"])(function (tab) {
if (tab.name === 'blocks') {
return blocksTab;
} else if (tab.name === 'patterns') {
return patternsTab;
}
return reusableBlocksTab;
}, [blocksTab, patternsTab, reusableBlocksTab]);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__menu"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__main-area"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__content"
}, Object(external_wp_element_["createElement"])(search_form, {
onChange: function onChange(value) {
if (hoveredItem) setHoveredItem(null);
setFilterValue(value);
},
value: filterValue,
placeholder: Object(external_wp_i18n_["__"])('Search')
}), !!filterValue && Object(external_wp_element_["createElement"])(search_results, {
filterValue: filterValue,
onSelect: onSelect,
onHover: onHover,
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: __experimentalSelectBlockOnInsert,
showBlockDirectory: true
}), !filterValue && (showPatterns || hasReusableBlocks) && Object(external_wp_element_["createElement"])(inserter_tabs, {
showPatterns: showPatterns,
showReusableBlocks: hasReusableBlocks
}, getCurrentTab), !filterValue && !showPatterns && !hasReusableBlocks && blocksTab)), showInserterHelpPanel && hoveredItem && Object(external_wp_element_["createElement"])(preview_panel, {
item: hoveredItem
}));
}
/* harmony default export */ var menu = (InserterMenu);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/quick-inserter.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var SEARCH_THRESHOLD = 6;
var quick_inserter_SHOWN_BLOCK_TYPES = 6;
var SHOWN_BLOCK_PATTERNS = 2;
function QuickInserter(_ref) {
var onSelect = _ref.onSelect,
rootClientId = _ref.rootClientId,
clientId = _ref.clientId,
isAppender = _ref.isAppender,
selectBlockOnInsert = _ref.selectBlockOnInsert;
var _useState = Object(external_wp_element_["useState"])(''),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
filterValue = _useState2[0],
setFilterValue = _useState2[1];
var _useInsertionPoint = use_insertion_point({
onSelect: onSelect,
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: selectBlockOnInsert
}),
_useInsertionPoint2 = Object(slicedToArray["a" /* default */])(_useInsertionPoint, 2),
destinationRootClientId = _useInsertionPoint2[0],
onInsertBlocks = _useInsertionPoint2[1];
var _useBlockTypesState = use_block_types_state(destinationRootClientId, onInsertBlocks),
_useBlockTypesState2 = Object(slicedToArray["a" /* default */])(_useBlockTypesState, 1),
blockTypes = _useBlockTypesState2[0];
var _usePatternsState = use_patterns_state(onInsertBlocks),
_usePatternsState2 = Object(slicedToArray["a" /* default */])(_usePatternsState, 1),
patterns = _usePatternsState2[0];
var showPatterns = !destinationRootClientId && patterns.length && !!filterValue;
var showSearch = showPatterns && patterns.length > SEARCH_THRESHOLD || blockTypes.length > SEARCH_THRESHOLD;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSettings = _select.getSettings,
getBlockIndex = _select.getBlockIndex;
return {
setInserterIsOpened: getSettings().__experimentalSetIsInserterOpened,
blockIndex: getBlockIndex(clientId, rootClientId)
};
}, [clientId, rootClientId]),
setInserterIsOpened = _useSelect.setInserterIsOpened,
blockIndex = _useSelect.blockIndex;
Object(external_wp_element_["useEffect"])(function () {
if (setInserterIsOpened) {
setInserterIsOpened(false);
}
}, [setInserterIsOpened]);
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
__unstableSetInsertionPoint = _useDispatch.__unstableSetInsertionPoint; // When clicking Browse All select the appropriate block so as
// the insertion point can work as expected
var onBrowseAll = function onBrowseAll() {
__unstableSetInsertionPoint(rootClientId, blockIndex);
setInserterIsOpened(true);
};
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-inserter__quick-inserter', {
'has-search': showSearch,
'has-expand': setInserterIsOpened
})
}, showSearch && Object(external_wp_element_["createElement"])(search_form, {
value: filterValue,
onChange: function onChange(value) {
setFilterValue(value);
},
placeholder: Object(external_wp_i18n_["__"])('Search for a block')
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inserter__quick-inserter-results"
}, Object(external_wp_element_["createElement"])(search_results, {
filterValue: filterValue,
onSelect: onSelect,
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: selectBlockOnInsert,
maxBlockPatterns: showPatterns ? SHOWN_BLOCK_PATTERNS : 0,
maxBlockTypes: quick_inserter_SHOWN_BLOCK_TYPES,
isDraggable: false
})), setInserterIsOpened && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-inserter__quick-inserter-expand",
onClick: onBrowseAll,
"aria-label": Object(external_wp_i18n_["__"])('Browse all. This will open the main inserter panel in the editor toolbar.')
}, Object(external_wp_i18n_["__"])('Browse all')));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/index.js
function inserter_createSuper(Derived) { var hasNativeReflectConstruct = inserter_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function inserter_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var inserter_defaultRenderToggle = function defaultRenderToggle(_ref) {
var onToggle = _ref.onToggle,
disabled = _ref.disabled,
isOpen = _ref.isOpen,
blockTitle = _ref.blockTitle,
hasSingleBlockType = _ref.hasSingleBlockType,
_ref$toggleProps = _ref.toggleProps,
toggleProps = _ref$toggleProps === void 0 ? {} : _ref$toggleProps;
var label;
if (hasSingleBlockType) {
label = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block when there is only one
Object(external_wp_i18n_["_x"])('Add %s', 'directly add the only allowed block'), blockTitle);
} else {
label = Object(external_wp_i18n_["_x"])('Add block', 'Generic label for block inserter button');
}
var onClick = toggleProps.onClick,
rest = Object(objectWithoutProperties["a" /* default */])(toggleProps, ["onClick"]); // Handle both onClick functions from the toggle and the parent component
function handleClick(event) {
if (onToggle) {
onToggle(event);
}
if (onClick) {
onClick(event);
}
}
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
icon: plus["a" /* default */],
label: label,
tooltipPosition: "bottom",
onClick: handleClick,
className: "block-editor-inserter__toggle",
"aria-haspopup": !hasSingleBlockType ? 'true' : false,
"aria-expanded": !hasSingleBlockType ? isOpen : false,
disabled: disabled
}, rest));
};
var inserter_Inserter = /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(Inserter, _Component);
var _super = inserter_createSuper(Inserter);
function Inserter() {
var _this;
Object(classCallCheck["a" /* default */])(this, Inserter);
_this = _super.apply(this, arguments);
_this.onToggle = _this.onToggle.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.renderToggle = _this.renderToggle.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.renderContent = _this.renderContent.bind(Object(assertThisInitialized["a" /* default */])(_this));
return _this;
}
Object(createClass["a" /* default */])(Inserter, [{
key: "onToggle",
value: function onToggle(isOpen) {
var onToggle = this.props.onToggle; // Surface toggle callback to parent component
if (onToggle) {
onToggle(isOpen);
}
}
/**
* Render callback to display Dropdown toggle element.
*
* @param {Object} options
* @param {Function} options.onToggle Callback to invoke when toggle is
* pressed.
* @param {boolean} options.isOpen Whether dropdown is currently open.
*
* @return {WPElement} Dropdown toggle element.
*/
}, {
key: "renderToggle",
value: function renderToggle(_ref2) {
var onToggle = _ref2.onToggle,
isOpen = _ref2.isOpen;
var _this$props = this.props,
disabled = _this$props.disabled,
blockTitle = _this$props.blockTitle,
hasSingleBlockType = _this$props.hasSingleBlockType,
toggleProps = _this$props.toggleProps,
hasItems = _this$props.hasItems,
_this$props$renderTog = _this$props.renderToggle,
renderToggle = _this$props$renderTog === void 0 ? inserter_defaultRenderToggle : _this$props$renderTog;
return renderToggle({
onToggle: onToggle,
isOpen: isOpen,
disabled: disabled || !hasItems,
blockTitle: blockTitle,
hasSingleBlockType: hasSingleBlockType,
toggleProps: toggleProps
});
}
/**
* Render callback to display Dropdown content element.
*
* @param {Object} options
* @param {Function} options.onClose Callback to invoke when dropdown is
* closed.
*
* @return {WPElement} Dropdown content element.
*/
}, {
key: "renderContent",
value: function renderContent(_ref3) {
var onClose = _ref3.onClose;
var _this$props2 = this.props,
rootClientId = _this$props2.rootClientId,
clientId = _this$props2.clientId,
isAppender = _this$props2.isAppender,
showInserterHelpPanel = _this$props2.showInserterHelpPanel,
selectBlockOnInsert = _this$props2.__experimentalSelectBlockOnInsert,
isQuick = _this$props2.__experimentalIsQuick;
if (isQuick) {
return Object(external_wp_element_["createElement"])(QuickInserter, {
onSelect: function onSelect() {
onClose();
},
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
selectBlockOnInsert: selectBlockOnInsert
});
}
return Object(external_wp_element_["createElement"])(menu, {
onSelect: function onSelect() {
onClose();
},
rootClientId: rootClientId,
clientId: clientId,
isAppender: isAppender,
showInserterHelpPanel: showInserterHelpPanel,
__experimentalSelectBlockOnInsert: selectBlockOnInsert
});
}
}, {
key: "render",
value: function render() {
var _this$props3 = this.props,
position = _this$props3.position,
hasSingleBlockType = _this$props3.hasSingleBlockType,
insertOnlyAllowedBlock = _this$props3.insertOnlyAllowedBlock,
isQuick = _this$props3.__experimentalIsQuick,
onSelectOrClose = _this$props3.onSelectOrClose;
if (hasSingleBlockType) {
return this.renderToggle({
onToggle: insertOnlyAllowedBlock
});
}
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
className: "block-editor-inserter",
contentClassName: classnames_default()('block-editor-inserter__popover', {
'is-quick': isQuick
}),
position: position,
onToggle: this.onToggle,
expandOnMobile: true,
headerTitle: Object(external_wp_i18n_["__"])('Add a block'),
renderToggle: this.renderToggle,
renderContent: this.renderContent,
onClose: onSelectOrClose
});
}
}]);
return Inserter;
}(external_wp_element_["Component"]);
/* harmony default export */ var inserter = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(function (select, _ref4) {
var clientId = _ref4.clientId,
rootClientId = _ref4.rootClientId;
var _select = select('core/block-editor'),
getBlockRootClientId = _select.getBlockRootClientId,
hasInserterItems = _select.hasInserterItems,
__experimentalGetAllowedBlocks = _select.__experimentalGetAllowedBlocks;
var _select2 = select(external_wp_blocks_["store"]),
getBlockVariations = _select2.getBlockVariations;
rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
var allowedBlocks = __experimentalGetAllowedBlocks(rootClientId);
var hasSingleBlockType = Object(external_lodash_["size"])(allowedBlocks) === 1 && Object(external_lodash_["size"])(getBlockVariations(allowedBlocks[0].name, 'inserter')) === 0;
var allowedBlockType = false;
if (hasSingleBlockType) {
allowedBlockType = allowedBlocks[0];
}
return {
hasItems: hasInserterItems(rootClientId),
hasSingleBlockType: hasSingleBlockType,
blockTitle: allowedBlockType ? allowedBlockType.title : '',
allowedBlockType: allowedBlockType,
rootClientId: rootClientId
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref5) {
var select = _ref5.select;
return {
insertOnlyAllowedBlock: function insertOnlyAllowedBlock() {
var rootClientId = ownProps.rootClientId,
clientId = ownProps.clientId,
isAppender = ownProps.isAppender,
onSelectOrClose = ownProps.onSelectOrClose;
var hasSingleBlockType = ownProps.hasSingleBlockType,
allowedBlockType = ownProps.allowedBlockType,
selectBlockOnInsert = ownProps.__experimentalSelectBlockOnInsert;
if (!hasSingleBlockType) {
return;
}
function getInsertionIndex() {
var _select3 = select('core/block-editor'),
getBlockIndex = _select3.getBlockIndex,
getBlockSelectionEnd = _select3.getBlockSelectionEnd,
getBlockOrder = _select3.getBlockOrder; // If the clientId is defined, we insert at the position of the block.
if (clientId) {
return getBlockIndex(clientId, rootClientId);
} // If there a selected block, we insert after the selected block.
var end = getBlockSelectionEnd();
if (!isAppender && end) {
return getBlockIndex(end, rootClientId) + 1;
} // Otherwise, we insert at the end of the current rootClientId
return getBlockOrder(rootClientId).length;
}
var _dispatch = dispatch('core/block-editor'),
insertBlock = _dispatch.insertBlock;
var blockToInsert = Object(external_wp_blocks_["createBlock"])(allowedBlockType.name);
insertBlock(blockToInsert, getInsertionIndex(), rootClientId, selectBlockOnInsert);
if (onSelectOrClose) {
onSelectOrClose();
}
if (!selectBlockOnInsert) {
var message = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block that has been added
Object(external_wp_i18n_["__"])('%s block added'), allowedBlockType.title);
Object(external_wp_a11y_["speak"])(message);
}
}
};
}), // The global inserter should always be visible, we are using ( ! isAppender && ! rootClientId && ! clientId ) as
// a way to detect the global Inserter.
Object(external_wp_compose_["ifCondition"])(function (_ref6) {
var hasItems = _ref6.hasItems,
isAppender = _ref6.isAppender,
rootClientId = _ref6.rootClientId,
clientId = _ref6.clientId;
return hasItems || !isAppender && !rootClientId && !clientId;
})])(inserter_Inserter));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-block-appender/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function default_block_appender_DefaultBlockAppender(_ref) {
var isLocked = _ref.isLocked,
isVisible = _ref.isVisible,
onAppend = _ref.onAppend,
showPrompt = _ref.showPrompt,
placeholder = _ref.placeholder,
rootClientId = _ref.rootClientId;
if (isLocked || !isVisible) {
return null;
}
var value = Object(external_wp_htmlEntities_["decodeEntities"])(placeholder) || Object(external_wp_i18n_["__"])('Start writing or type / to choose a block'); // The appender "button" is in-fact a text field so as to support
// transitions by WritingFlow occurring by arrow key press. WritingFlow
// only supports tab transitions into text fields and to the block focus
// boundary.
//
// See: https://github.com/WordPress/gutenberg/issues/4829#issuecomment-374213658
//
// If it were ever to be made to be a proper `button` element, it is
// important to note that `onFocus` alone would not be sufficient to
// capture click events, notably in Firefox.
//
// See: https://gist.github.com/cvrebert/68659d0333a578d75372
// The wp-block className is important for editor styles.
return Object(external_wp_element_["createElement"])("div", {
"data-root-client-id": rootClientId || '',
className: "wp-block block-editor-default-block-appender"
}, Object(external_wp_element_["createElement"])(lib_default.a, {
role: "button",
"aria-label": Object(external_wp_i18n_["__"])('Add block'),
className: "block-editor-default-block-appender__content",
readOnly: true,
onFocus: onAppend,
value: showPrompt ? value : ''
}), Object(external_wp_element_["createElement"])(inserter, {
rootClientId: rootClientId,
position: "bottom right",
isAppender: true,
__experimentalIsQuick: true
}));
}
/* harmony default export */ var default_block_appender = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])(function (select, ownProps) {
var _select = select('core/block-editor'),
getBlockCount = _select.getBlockCount,
getBlockName = _select.getBlockName,
isBlockValid = _select.isBlockValid,
getSettings = _select.getSettings,
getTemplateLock = _select.getTemplateLock;
var isEmpty = !getBlockCount(ownProps.rootClientId);
var isLastBlockDefault = getBlockName(ownProps.lastBlockClientId) === Object(external_wp_blocks_["getDefaultBlockName"])();
var isLastBlockValid = isBlockValid(ownProps.lastBlockClientId);
var _getSettings = getSettings(),
bodyPlaceholder = _getSettings.bodyPlaceholder;
return {
isVisible: isEmpty || !isLastBlockDefault || !isLastBlockValid,
showPrompt: isEmpty,
isLocked: !!getTemplateLock(ownProps.rootClientId),
placeholder: bodyPlaceholder
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, ownProps) {
var _dispatch = dispatch('core/block-editor'),
insertDefaultBlock = _dispatch.insertDefaultBlock,
startTyping = _dispatch.startTyping;
return {
onAppend: function onAppend() {
var rootClientId = ownProps.rootClientId;
insertDefaultBlock(undefined, rootClientId);
startTyping();
}
};
}))(default_block_appender_DefaultBlockAppender));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/button-block-appender/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function button_block_appender_ButtonBlockAppender(_ref, ref) {
var rootClientId = _ref.rootClientId,
className = _ref.className,
selectBlockOnInsert = _ref.__experimentalSelectBlockOnInsert,
onFocus = _ref.onFocus,
tabIndex = _ref.tabIndex;
return Object(external_wp_element_["createElement"])(inserter, {
position: "bottom center",
rootClientId: rootClientId,
__experimentalSelectBlockOnInsert: selectBlockOnInsert,
__experimentalIsQuick: true,
renderToggle: function renderToggle(_ref2) {
var onToggle = _ref2.onToggle,
disabled = _ref2.disabled,
isOpen = _ref2.isOpen,
blockTitle = _ref2.blockTitle,
hasSingleBlockType = _ref2.hasSingleBlockType;
var label;
if (hasSingleBlockType) {
label = Object(external_wp_i18n_["sprintf"])( // translators: %s: the name of the block when there is only one
Object(external_wp_i18n_["_x"])('Add %s', 'directly add the only allowed block'), blockTitle);
} else {
label = Object(external_wp_i18n_["_x"])('Add block', 'Generic label for block inserter button');
}
var isToggleButton = !hasSingleBlockType;
var inserterButton = Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
ref: ref,
onFocus: onFocus,
tabIndex: tabIndex,
className: classnames_default()(className, 'block-editor-button-block-appender'),
onClick: onToggle,
"aria-haspopup": isToggleButton ? 'true' : undefined,
"aria-expanded": isToggleButton ? isOpen : undefined,
disabled: disabled,
label: label
}, !hasSingleBlockType && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
as: "span"
}, label), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
icon: plus["a" /* default */]
}));
if (isToggleButton || hasSingleBlockType) {
inserterButton = Object(external_wp_element_["createElement"])(external_wp_components_["Tooltip"], {
text: label
}, inserterButton);
}
return inserterButton;
},
isAppender: true
});
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/button-block-appender/README.md
*/
/* harmony default export */ var button_block_appender = (Object(external_wp_element_["forwardRef"])(button_block_appender_ButtonBlockAppender));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list-appender/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
// A Context to store the map of the appender map.
var AppenderNodesContext = Object(external_wp_element_["createContext"])();
function stopPropagation(event) {
event.stopPropagation();
}
function BlockListAppender(_ref) {
var blockClientIds = _ref.blockClientIds,
rootClientId = _ref.rootClientId,
canInsertDefaultBlock = _ref.canInsertDefaultBlock,
isLocked = _ref.isLocked,
CustomAppender = _ref.renderAppender,
className = _ref.className,
selectedBlockClientId = _ref.selectedBlockClientId,
_ref$tagName = _ref.tagName,
TagName = _ref$tagName === void 0 ? 'div' : _ref$tagName;
if (isLocked || CustomAppender === false) {
return null;
}
var appender;
if (CustomAppender) {
// Prefer custom render prop if provided.
appender = Object(external_wp_element_["createElement"])(CustomAppender, null);
} else {
var isDocumentAppender = !rootClientId;
var isParentSelected = selectedBlockClientId === rootClientId;
var isAnotherDefaultAppenderAlreadyDisplayed = selectedBlockClientId && !blockClientIds.includes(selectedBlockClientId);
if (!isDocumentAppender && !isParentSelected && (!selectedBlockClientId || isAnotherDefaultAppenderAlreadyDisplayed)) {
return null;
}
if (canInsertDefaultBlock) {
// Render the default block appender when renderAppender has not been
// provided and the context supports use of the default appender.
appender = Object(external_wp_element_["createElement"])(default_block_appender, {
rootClientId: rootClientId,
lastBlockClientId: Object(external_lodash_["last"])(blockClientIds)
});
} else {
// Fallback in the case no renderAppender has been provided and the
// default block can't be inserted.
appender = Object(external_wp_element_["createElement"])(button_block_appender, {
rootClientId: rootClientId,
className: "block-list-appender__toggle"
});
}
}
return Object(external_wp_element_["createElement"])(TagName // A `tabIndex` is used on the wrapping `div` element in order to
// force a focus event to occur when an appender `button` element
// is clicked. In some browsers (Firefox, Safari), button clicks do
// not emit a focus event, which could cause this event to propagate
// unexpectedly. The `tabIndex` ensures that the interaction is
// captured as a focus, without also adding an extra tab stop.
//
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
, {
tabIndex: -1 // Prevent the block from being selected when the appender is
// clicked.
,
onFocus: stopPropagation,
className: classnames_default()('block-list-appender', 'wp-block', className)
}, appender);
}
/* harmony default export */ var block_list_appender = (Object(external_wp_data_["withSelect"])(function (select, _ref2) {
var rootClientId = _ref2.rootClientId;
var _select = select('core/block-editor'),
getBlockOrder = _select.getBlockOrder,
canInsertBlockType = _select.canInsertBlockType,
getTemplateLock = _select.getTemplateLock,
getSelectedBlockClientId = _select.getSelectedBlockClientId;
return {
isLocked: !!getTemplateLock(rootClientId),
blockClientIds: getBlockOrder(rootClientId),
canInsertDefaultBlock: canInsertBlockType(Object(external_wp_blocks_["getDefaultBlockName"])(), rootClientId),
selectedBlockClientId: getSelectedBlockClientId()
};
})(BlockListAppender));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-on-block-drop/index.js
/**
* WordPress dependencies
*/
/** @typedef {import('@wordpress/element').WPSyntheticEvent} WPSyntheticEvent */
/**
* Retrieve the data for a block drop event.
*
* @param {WPSyntheticEvent} event The drop event.
*
* @return {Object} An object with block drag and drop data.
*/
function parseDropEvent(event) {
var result = {
srcRootClientId: null,
srcClientIds: null,
srcIndex: null,
type: null,
blocks: null
};
if (!event.dataTransfer) {
return result;
}
try {
result = Object.assign(result, JSON.parse(event.dataTransfer.getData('text')));
} catch (err) {
return result;
}
return result;
}
/**
* A function that returns an event handler function for block drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
* @param {Function} getBlockIndex A function that gets the index of a block.
* @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.
* @param {Function} moveBlocksToPosition A function that moves blocks.
* @param {Function} insertBlocks A function that inserts blocks.
* @param {Function} clearSelectedBlock A function that clears block selection.
* @return {Function} The event handler for a block drop event.
*/
function onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock) {
return function (event) {
var _parseDropEvent = parseDropEvent(event),
sourceRootClientId = _parseDropEvent.srcRootClientId,
sourceClientIds = _parseDropEvent.srcClientIds,
dropType = _parseDropEvent.type,
blocks = _parseDropEvent.blocks; // If the user is inserting a block
if (dropType === 'inserter') {
clearSelectedBlock();
insertBlocks(blocks, targetBlockIndex, targetRootClientId, false);
} // If the user is moving a block
if (dropType === 'block') {
var sourceBlockIndex = getBlockIndex(sourceClientIds[0], sourceRootClientId); // If the user is dropping to the same position, return early.
if (sourceRootClientId === targetRootClientId && sourceBlockIndex === targetBlockIndex) {
return;
} // If the user is attempting to drop a block within its own
// nested blocks, return early as this would create infinite
// recursion.
if (sourceClientIds.includes(targetRootClientId) || getClientIdsOfDescendants(sourceClientIds).some(function (id) {
return id === targetRootClientId;
})) {
return;
}
var isAtSameLevel = sourceRootClientId === targetRootClientId;
var draggedBlockCount = sourceClientIds.length; // If the block is kept at the same level and moved downwards,
// subtract to take into account that the blocks being dragged
// were removed from the block list above the insertion point.
var insertIndex = isAtSameLevel && sourceBlockIndex < targetBlockIndex ? targetBlockIndex - draggedBlockCount : targetBlockIndex;
moveBlocksToPosition(sourceClientIds, sourceRootClientId, targetRootClientId, insertIndex);
}
};
}
/**
* A function that returns an event handler function for block-related file drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
* @param {boolean} hasUploadPermissions Whether the user has upload permissions.
* @param {Function} updateBlockAttributes A function that updates a block's attributes.
* @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.
* @param {Function} insertBlocks A function that inserts blocks.
*
* @return {Function} The event handler for a block-related file drop event.
*/
function onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks) {
return function (files) {
if (!hasUploadPermissions) {
return;
}
var transformation = Object(external_wp_blocks_["findTransform"])(Object(external_wp_blocks_["getBlockTransforms"])('from'), function (transform) {
return transform.type === 'files' && canInsertBlockType(transform.blockName, targetRootClientId) && transform.isMatch(files);
});
if (transformation) {
var blocks = transformation.transform(files, updateBlockAttributes);
insertBlocks(blocks, targetBlockIndex, targetRootClientId);
}
};
}
/**
* A function that returns an event handler function for block-related HTML drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
* @param {Function} insertBlocks A function that inserts blocks.
*
* @return {Function} The event handler for a block-related HTML drop event.
*/
function use_on_block_drop_onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks) {
return function (HTML) {
var blocks = Object(external_wp_blocks_["pasteHandler"])({
HTML: HTML,
mode: 'BLOCKS'
});
if (blocks.length) {
insertBlocks(blocks, targetBlockIndex, targetRootClientId);
}
};
}
/**
* A React hook for handling block drop events.
*
* @param {string} targetRootClientId The root client id where the block(s) will be inserted.
* @param {number} targetBlockIndex The index where the block(s) will be inserted.
*
* @return {Object} An object that contains the event handlers `onDrop`, `onFilesDrop` and `onHTMLDrop`.
*/
function useOnBlockDrop(targetRootClientId, targetBlockIndex) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
_canInsertBlockType = _select.canInsertBlockType,
_getBlockIndex = _select.getBlockIndex,
_getClientIdsOfDescendants = _select.getClientIdsOfDescendants,
getSettings = _select.getSettings;
return {
canInsertBlockType: _canInsertBlockType,
getBlockIndex: _getBlockIndex,
getClientIdsOfDescendants: _getClientIdsOfDescendants,
hasUploadPermissions: getSettings().mediaUpload
};
}, []),
canInsertBlockType = _useSelect.canInsertBlockType,
getBlockIndex = _useSelect.getBlockIndex,
getClientIdsOfDescendants = _useSelect.getClientIdsOfDescendants,
hasUploadPermissions = _useSelect.hasUploadPermissions;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
insertBlocks = _useDispatch.insertBlocks,
moveBlocksToPosition = _useDispatch.moveBlocksToPosition,
updateBlockAttributes = _useDispatch.updateBlockAttributes,
clearSelectedBlock = _useDispatch.clearSelectedBlock;
return {
onDrop: onBlockDrop(targetRootClientId, targetBlockIndex, getBlockIndex, getClientIdsOfDescendants, moveBlocksToPosition, insertBlocks, clearSelectedBlock),
onFilesDrop: onFilesDrop(targetRootClientId, targetBlockIndex, hasUploadPermissions, updateBlockAttributes, canInsertBlockType, insertBlocks),
onHTMLDrop: use_on_block_drop_onHTMLDrop(targetRootClientId, targetBlockIndex, insertBlocks)
};
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/math.js
/**
* A string representing the name of an edge.
*
* @typedef {'top'|'right'|'bottom'|'left'} WPEdgeName
*/
/**
* @typedef {Object} WPPoint
* @property {number} x The horizontal position.
* @property {number} y The vertical position.
*/
/**
* Given a point, a DOMRect and the name of an edge, returns the distance to
* that edge of the rect.
*
* This function works for edges that are horizontal or vertical (e.g. not
* rotated), the following terms are used so that the function works in both
* orientations:
*
* - Forward, meaning the axis running horizontally when an edge is vertical
* and vertically when an edge is horizontal.
* - Lateral, meaning the axis running vertically when an edge is vertical
* and horizontally when an edge is horizontal.
*
* @param {WPPoint} point The point to measure distance from.
* @param {DOMRect} rect A DOM Rect containing edge positions.
* @param {WPEdgeName} edge The edge to measure to.
*/
function getDistanceFromPointToEdge(point, rect, edge) {
var isHorizontal = edge === 'top' || edge === 'bottom';
var x = point.x,
y = point.y;
var pointLateralPosition = isHorizontal ? x : y;
var pointForwardPosition = isHorizontal ? y : x;
var edgeStart = isHorizontal ? rect.left : rect.top;
var edgeEnd = isHorizontal ? rect.right : rect.bottom;
var edgeForwardPosition = rect[edge]; // Measure the straight line distance to the edge of the rect, when the
// point is adjacent to the edge.
// Else, if the point is positioned diagonally to the edge of the rect,
// measure diagonally to the nearest corner that the edge meets.
var edgeLateralPosition;
if (pointLateralPosition >= edgeStart && pointLateralPosition <= edgeEnd) {
edgeLateralPosition = pointLateralPosition;
} else if (pointLateralPosition < edgeEnd) {
edgeLateralPosition = edgeStart;
} else {
edgeLateralPosition = edgeEnd;
}
return Math.sqrt(Math.pow(pointLateralPosition - edgeLateralPosition, 2) + Math.pow(pointForwardPosition - edgeForwardPosition, 2));
}
/**
* Given a point, a DOMRect and a list of allowed edges returns the name of and
* distance to the nearest edge.
*
* @param {WPPoint} point The point to measure distance from.
* @param {DOMRect} rect A DOM Rect containing edge positions.
* @param {WPEdgeName[]} allowedEdges A list of the edges included in the
* calculation. Defaults to all edges.
*
* @return {[number, string]} An array where the first value is the distance
* and a second is the edge name.
*/
function getDistanceToNearestEdge(point, rect) {
var allowedEdges = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : ['top', 'bottom', 'left', 'right'];
var candidateDistance;
var candidateEdge;
allowedEdges.forEach(function (edge) {
var distance = getDistanceFromPointToEdge(point, rect, edge);
if (candidateDistance === undefined || distance < candidateDistance) {
candidateDistance = distance;
candidateEdge = edge;
}
});
return [candidateDistance, candidateEdge];
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-block-drop-zone/index.js
function use_block_drop_zone_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function use_block_drop_zone_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_block_drop_zone_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_block_drop_zone_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
/**
* The orientation of a block list.
*
* @typedef {'horizontal'|'vertical'|undefined} WPBlockListOrientation
*/
/**
* Given a list of block DOM elements finds the index that a block should be dropped
* at.
*
* @param {Element[]} elements Array of DOM elements that represent each block in a block list.
* @param {WPPoint} position The position of the item being dragged.
* @param {WPBlockListOrientation} orientation The orientation of a block list.
*
* @return {number|undefined} The block index that's closest to the drag position.
*/
function getNearestBlockIndex(elements, position, orientation) {
var allowedEdges = orientation === 'horizontal' ? ['left', 'right'] : ['top', 'bottom'];
var candidateIndex;
var candidateDistance;
elements.forEach(function (element, index) {
// Ensure the element is a block. It should have the `wp-block` class.
if (!element.classList.contains('wp-block')) {
return;
}
var rect = element.getBoundingClientRect();
var _getDistanceToNearest = getDistanceToNearestEdge(position, rect, allowedEdges),
_getDistanceToNearest2 = Object(slicedToArray["a" /* default */])(_getDistanceToNearest, 2),
distance = _getDistanceToNearest2[0],
edge = _getDistanceToNearest2[1];
if (candidateDistance === undefined || distance < candidateDistance) {
// If the user is dropping to the trailing edge of the block
// add 1 to the index to represent dragging after.
var isTrailingEdge = edge === 'bottom' || edge === 'right';
var offset = isTrailingEdge ? 1 : 0; // If the target is the dragged block itself and another 1 to
// index as the dragged block is set to `display: none` and
// should be skipped in the calculation.
var isTargetDraggedBlock = isTrailingEdge && elements[index + 1] && elements[index + 1].classList.contains('is-dragging');
offset += isTargetDraggedBlock ? 1 : 0; // Update the currently known best candidate.
candidateDistance = distance;
candidateIndex = index + offset;
}
});
return candidateIndex;
}
/**
* @typedef {Object} WPBlockDropZoneConfig
* @property {Object} element A React ref object pointing to the block list's DOM element.
* @property {string} rootClientId The root client id for the block list.
*/
/**
* A React hook that can be used to make a block list handle drag and drop.
*
* @param {WPBlockDropZoneConfig} dropZoneConfig configuration data for the drop zone.
*
* @return {number|undefined} The block index that's closest to the drag position.
*/
function useBlockDropZone(_ref) {
var element = _ref.element,
_ref$rootClientId = _ref.rootClientId,
targetRootClientId = _ref$rootClientId === void 0 ? '' : _ref$rootClientId;
var _useState = Object(external_wp_element_["useState"])(null),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
targetBlockIndex = _useState2[0],
setTargetBlockIndex = _useState2[1];
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _getBlockListSettings;
var _select = select('core/block-editor'),
getBlockListSettings = _select.getBlockListSettings,
getTemplateLock = _select.getTemplateLock;
return {
isLockedAll: getTemplateLock(targetRootClientId) === 'all',
orientation: (_getBlockListSettings = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
};
}, [targetRootClientId]),
isLockedAll = _useSelect.isLockedAll,
orientation = _useSelect.orientation;
var dropEventHandlers = useOnBlockDrop(targetRootClientId, targetBlockIndex);
var _useDropZone = Object(external_wp_components_["__unstableUseDropZone"])(use_block_drop_zone_objectSpread({
element: element,
isDisabled: isLockedAll,
withPosition: true
}, dropEventHandlers)),
position = _useDropZone.position;
Object(external_wp_element_["useEffect"])(function () {
if (position) {
var blockElements = Array.from(element.current.children);
var targetIndex = getNearestBlockIndex(blockElements, position, orientation);
setTargetBlockIndex(targetIndex === undefined ? 0 : targetIndex);
}
}, [position]);
if (position) {
return targetBlockIndex;
}
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/insertion-point.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InsertionPointInserter(_ref) {
var clientId = _ref.clientId,
rootClientId = _ref.rootClientId,
setIsInserterForced = _ref.setIsInserterForced;
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-block-list__insertion-point-inserter')
}, Object(external_wp_element_["createElement"])(inserter, {
position: "bottom center",
clientId: clientId,
rootClientId: rootClientId,
__experimentalIsQuick: true,
onToggle: setIsInserterForced,
onSelectOrClose: function onSelectOrClose() {
return setIsInserterForced(false);
}
}));
}
function InsertionPointPopover(_ref2) {
var clientId = _ref2.clientId,
selectedRootClientId = _ref2.selectedRootClientId,
isInserterShown = _ref2.isInserterShown,
isInserterForced = _ref2.isInserterForced,
setIsInserterForced = _ref2.setIsInserterForced,
containerRef = _ref2.containerRef,
showInsertionPoint = _ref2.showInsertionPoint;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
selectBlock = _useDispatch.selectBlock;
var ref = Object(external_wp_element_["useRef"])();
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _getBlockListSettings2;
var _select = select('core/block-editor'),
getBlockOrder = _select.getBlockOrder,
getBlockRootClientId = _select.getBlockRootClientId,
getBlockListSettings = _select.getBlockListSettings,
getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds,
getSelectedBlockClientId = _select.getSelectedBlockClientId,
hasMultiSelection = _select.hasMultiSelection,
getSettings = _select.getSettings;
var ownerDocument = containerRef.current.ownerDocument;
var targetRootClientId = clientId ? getBlockRootClientId(clientId) : selectedRootClientId;
var blockOrder = getBlockOrder(targetRootClientId);
if (!blockOrder.length) {
return {};
}
var previous = clientId ? clientId : blockOrder[blockOrder.length - 1];
var isLast = previous === blockOrder[blockOrder.length - 1];
var next = isLast ? null : blockOrder[blockOrder.indexOf(previous) + 1];
var _getSettings = getSettings(),
hasReducedUI = _getSettings.hasReducedUI;
var multiSelectedBlockClientIds = getMultiSelectedBlockClientIds();
var selectedBlockClientId = getSelectedBlockClientId();
var blockOrientation = ((_getBlockListSettings2 = getBlockListSettings(targetRootClientId)) === null || _getBlockListSettings2 === void 0 ? void 0 : _getBlockListSettings2.orientation) || 'vertical';
return {
previousElement: getBlockDOMNode(previous, ownerDocument),
nextElement: getBlockDOMNode(next, ownerDocument),
nextClientId: next,
isHidden: hasReducedUI || (hasMultiSelection() ? next && multiSelectedBlockClientIds.includes(next) : next && blockOrientation === 'vertical' && next === selectedBlockClientId),
orientation: blockOrientation,
rootClientId: targetRootClientId
};
}, [clientId, selectedRootClientId]),
previousElement = _useSelect.previousElement,
nextElement = _useSelect.nextElement,
orientation = _useSelect.orientation,
isHidden = _useSelect.isHidden,
nextClientId = _useSelect.nextClientId,
rootClientId = _useSelect.rootClientId;
var style = Object(external_wp_element_["useMemo"])(function () {
if (!previousElement) {
return {};
}
var previousRect = previousElement.getBoundingClientRect();
var nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
if (orientation === 'vertical') {
return {
width: previousElement.offsetWidth,
height: nextRect ? nextRect.top - previousRect.bottom : 0
};
}
var width = 0;
if (nextElement) {
width = Object(external_wp_i18n_["isRTL"])() ? previousRect.left - nextRect.right : nextRect.left - previousRect.right;
}
return {
width: width,
height: previousElement.offsetHeight
};
}, [previousElement, nextElement]);
var getAnchorRect = Object(external_wp_element_["useCallback"])(function () {
var previousRect = previousElement.getBoundingClientRect();
var nextRect = nextElement ? nextElement.getBoundingClientRect() : null;
if (orientation === 'vertical') {
return {
top: previousRect.bottom,
left: previousRect.left,
right: previousRect.right,
bottom: nextRect ? nextRect.top : previousRect.bottom
};
}
if (Object(external_wp_i18n_["isRTL"])()) {
return {
top: previousRect.top,
left: nextRect ? nextRect.right : previousRect.left,
right: previousRect.left,
bottom: previousRect.bottom
};
}
return {
top: previousRect.top,
left: previousRect.right,
right: nextRect ? nextRect.left : previousRect.right,
bottom: previousRect.bottom
};
}, [previousElement, nextElement]);
if (!previousElement) {
return null;
}
var className = classnames_default()('block-editor-block-list__insertion-point', 'is-' + orientation);
function onClick(event) {
if (event.target === ref.current && nextClientId) {
selectBlock(nextClientId, -1);
}
}
function onFocus(event) {
// Only handle click on the wrapper specifically, and not an event
// bubbled from the inserter itself.
if (event.target !== ref.current) {
setIsInserterForced(true);
}
} // Only show the inserter when there's a `nextElement` (a block after the
// insertion point). At the end of the block list the trailing appender
// should serve the purpose of inserting blocks.
var showInsertionPointInserter = !isHidden && nextElement && (isInserterShown || isInserterForced); // Show the indicator if the insertion point inserter is visible, or if
// the `showInsertionPoint` state is `true`. The latter is generally true
// when hovering blocks for insertion in the block library.
var showInsertionPointIndicator = showInsertionPointInserter || !isHidden && showInsertionPoint;
/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
// While ideally it would be enough to capture the
// bubbling focus event from the Inserter, due to the
// characteristics of click focusing of `button`s in
// Firefox and Safari, it is not reliable.
//
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
noArrow: true,
animate: false,
getAnchorRect: getAnchorRect,
focusOnMount: false,
className: "block-editor-block-list__insertion-point-popover",
__unstableSlotName: "block-toolbar"
}, Object(external_wp_element_["createElement"])("div", {
ref: ref,
tabIndex: -1,
onClick: onClick,
onFocus: onFocus,
className: className,
style: style
}, showInsertionPointIndicator && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-list__insertion-point-indicator"
}), showInsertionPointInserter && Object(external_wp_element_["createElement"])(InsertionPointInserter, {
rootClientId: rootClientId,
clientId: nextClientId,
setIsInserterForced: setIsInserterForced
})));
/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */
}
function insertion_point_useInsertionPoint(ref) {
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isInserterShown = _useState2[0],
setIsInserterShown = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isInserterForced = _useState4[0],
_setIsInserterForced = _useState4[1];
var _useState5 = Object(external_wp_element_["useState"])(null),
_useState6 = Object(slicedToArray["a" /* default */])(_useState5, 2),
inserterClientId = _useState6[0],
setInserterClientId = _useState6[1];
var _useSelect2 = Object(external_wp_data_["useSelect"])(function (select) {
var _select2 = select('core/block-editor'),
_isMultiSelecting = _select2.isMultiSelecting,
isBlockInsertionPointVisible = _select2.isBlockInsertionPointVisible,
getBlockInsertionPoint = _select2.getBlockInsertionPoint,
getBlockOrder = _select2.getBlockOrder,
_getBlockListSettings = _select2.getBlockListSettings;
var insertionPoint = getBlockInsertionPoint();
var order = getBlockOrder(insertionPoint.rootClientId);
return {
getBlockListSettings: _getBlockListSettings,
isMultiSelecting: _isMultiSelecting(),
isInserterVisible: isBlockInsertionPointVisible(),
selectedClientId: order[insertionPoint.index - 1],
selectedRootClientId: insertionPoint.rootClientId
};
}, []),
isMultiSelecting = _useSelect2.isMultiSelecting,
isInserterVisible = _useSelect2.isInserterVisible,
selectedClientId = _useSelect2.selectedClientId,
selectedRootClientId = _useSelect2.selectedRootClientId,
getBlockListSettings = _useSelect2.getBlockListSettings;
var onMouseMove = Object(external_wp_element_["useCallback"])(function (event) {
var _getBlockListSettings3;
if (!event.target.classList.contains('block-editor-block-list__layout')) {
if (isInserterShown) {
setIsInserterShown(false);
}
return;
}
var rootClientId;
if (!event.target.classList.contains('is-root-container')) {
var blockElement = !!event.target.getAttribute('data-block') ? event.target : event.target.closest('[data-block]');
rootClientId = blockElement.getAttribute('data-block');
}
var orientation = ((_getBlockListSettings3 = getBlockListSettings(rootClientId)) === null || _getBlockListSettings3 === void 0 ? void 0 : _getBlockListSettings3.orientation) || 'vertical';
var rect = event.target.getBoundingClientRect();
var offsetTop = event.clientY - rect.top;
var offsetLeft = event.clientX - rect.left;
var children = Array.from(event.target.children);
var nextElement = children.find(function (blockEl) {
return orientation === 'vertical' && blockEl.offsetTop > offsetTop || orientation === 'horizontal' && blockEl.offsetLeft > offsetLeft;
});
var element = nextElement ? children[children.indexOf(nextElement) - 1] : children[children.length - 1];
if (!element) {
return;
} // The block may be in an alignment wrapper, so check the first direct
// child if the element has no ID.
if (!element.id) {
element = element.firstElementChild;
if (!element) {
return;
}
}
var clientId = element.id.slice('block-'.length);
if (!clientId) {
return;
}
var elementRect = element.getBoundingClientRect();
if (orientation === 'horizontal' && (event.clientY > elementRect.bottom || event.clientY < elementRect.top) || orientation === 'vertical' && (event.clientX > elementRect.right || event.clientX < elementRect.left)) {
if (isInserterShown) {
setIsInserterShown(false);
}
return;
}
setIsInserterShown(true);
setInserterClientId(clientId);
}, [isInserterShown, setIsInserterShown, setInserterClientId]);
var enableMouseMove = !isInserterForced && !isMultiSelecting;
Object(external_wp_element_["useEffect"])(function () {
if (!enableMouseMove) {
return;
}
ref.current.addEventListener('mousemove', onMouseMove);
return function () {
ref.current.removeEventListener('mousemove', onMouseMove);
};
}, [enableMouseMove, onMouseMove]);
var isVisible = isInserterShown || isInserterForced || isInserterVisible;
return !isMultiSelecting && isVisible && Object(external_wp_element_["createElement"])(InsertionPointPopover, {
clientId: isInserterVisible ? selectedClientId : inserterClientId,
selectedRootClientId: selectedRootClientId,
isInserterShown: isInserterShown,
isInserterForced: isInserterForced,
setIsInserterForced: function setIsInserterForced(value) {
_setIsInserterForced(value);
if (!value) {
setIsInserterShown(value);
}
},
containerRef: ref,
showInsertionPoint: isInserterVisible
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-selection-button.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Returns true if the user is using windows.
*
* @return {boolean} Whether the user is using Windows.
*/
function isWindows() {
return window.navigator.platform.indexOf('Win') > -1;
}
function block_selection_button_selector(select) {
var _select = select('core/block-editor'),
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getMultiSelectedBlocksEndClientId = _select.getMultiSelectedBlocksEndClientId,
getPreviousBlockClientId = _select.getPreviousBlockClientId,
getNextBlockClientId = _select.getNextBlockClientId,
hasBlockMovingClientId = _select.hasBlockMovingClientId,
getBlockIndex = _select.getBlockIndex,
getBlockRootClientId = _select.getBlockRootClientId,
getClientIdsOfDescendants = _select.getClientIdsOfDescendants,
canInsertBlockType = _select.canInsertBlockType,
getBlockName = _select.getBlockName;
var selectedBlockClientId = getSelectedBlockClientId();
var selectionEndClientId = getMultiSelectedBlocksEndClientId();
return {
selectedBlockClientId: selectedBlockClientId,
selectionBeforeEndClientId: getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId),
selectionAfterEndClientId: getNextBlockClientId(selectionEndClientId || selectedBlockClientId),
hasBlockMovingClientId: hasBlockMovingClientId,
getBlockIndex: getBlockIndex,
getBlockRootClientId: getBlockRootClientId,
getClientIdsOfDescendants: getClientIdsOfDescendants,
canInsertBlockType: canInsertBlockType,
getBlockName: getBlockName
};
}
/**
* Block selection button component, displaying the label of the block. If the block
* descends from a root block, a button is displayed enabling the user to select
* the root block.
*
* @param {string} props Component props.
* @param {string} props.clientId Client ID of block.
*
* @return {WPComponent} The component to be rendered.
*/
function BlockSelectionButton(_ref) {
var clientId = _ref.clientId,
rootClientId = _ref.rootClientId,
blockElement = _ref.blockElement;
var selected = Object(external_wp_data_["useSelect"])(function (select) {
var _getBlockListSettings;
var _select2 = select('core/block-editor'),
__unstableGetBlockWithoutInnerBlocks = _select2.__unstableGetBlockWithoutInnerBlocks,
getBlockIndex = _select2.getBlockIndex,
hasBlockMovingClientId = _select2.hasBlockMovingClientId,
getBlockListSettings = _select2.getBlockListSettings;
var index = getBlockIndex(clientId, rootClientId);
var _unstableGetBlockWit = __unstableGetBlockWithoutInnerBlocks(clientId),
name = _unstableGetBlockWit.name,
attributes = _unstableGetBlockWit.attributes;
var blockMovingMode = hasBlockMovingClientId();
return {
index: index,
name: name,
attributes: attributes,
blockMovingMode: blockMovingMode,
orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
};
}, [clientId, rootClientId]);
var index = selected.index,
name = selected.name,
attributes = selected.attributes,
blockMovingMode = selected.blockMovingMode,
orientation = selected.orientation;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
setNavigationMode = _useDispatch.setNavigationMode,
removeBlock = _useDispatch.removeBlock;
var ref = Object(external_wp_element_["useRef"])(); // Focus the breadcrumb in navigation mode.
Object(external_wp_element_["useEffect"])(function () {
ref.current.focus(); // NVDA on windows suffers from a bug where focus changes are not announced properly
// See WordPress/gutenberg#24121 and nvaccess/nvda#5825 for more details
// To solve it we announce the focus change manually.
if (isWindows()) {
Object(external_wp_a11y_["speak"])(label);
}
}, []);
var _useSelect = Object(external_wp_data_["useSelect"])(block_selection_button_selector, []),
selectedBlockClientId = _useSelect.selectedBlockClientId,
selectionBeforeEndClientId = _useSelect.selectionBeforeEndClientId,
selectionAfterEndClientId = _useSelect.selectionAfterEndClientId,
hasBlockMovingClientId = _useSelect.hasBlockMovingClientId,
getBlockIndex = _useSelect.getBlockIndex,
getBlockRootClientId = _useSelect.getBlockRootClientId,
getClientIdsOfDescendants = _useSelect.getClientIdsOfDescendants;
var _useDispatch2 = Object(external_wp_data_["useDispatch"])('core/block-editor'),
selectBlock = _useDispatch2.selectBlock,
clearSelectedBlock = _useDispatch2.clearSelectedBlock,
setBlockMovingClientId = _useDispatch2.setBlockMovingClientId,
moveBlockToPosition = _useDispatch2.moveBlockToPosition;
function onKeyDown(event) {
var keyCode = event.keyCode;
var isUp = keyCode === external_wp_keycodes_["UP"];
var isDown = keyCode === external_wp_keycodes_["DOWN"];
var isLeft = keyCode === external_wp_keycodes_["LEFT"];
var isRight = keyCode === external_wp_keycodes_["RIGHT"];
var isTab = keyCode === external_wp_keycodes_["TAB"];
var isEscape = keyCode === external_wp_keycodes_["ESCAPE"];
var isEnter = keyCode === external_wp_keycodes_["ENTER"];
var isSpace = keyCode === external_wp_keycodes_["SPACE"];
var isShift = event.shiftKey;
if (keyCode === external_wp_keycodes_["BACKSPACE"] || keyCode === external_wp_keycodes_["DELETE"]) {
removeBlock(clientId);
event.preventDefault();
return;
}
var navigateUp = isTab && isShift || isUp;
var navigateDown = isTab && !isShift || isDown; // Move out of current nesting level (no effect if at root level).
var navigateOut = isLeft; // Move into next nesting level (no effect if the current block has no innerBlocks).
var navigateIn = isRight;
var focusedBlockUid;
if (navigateUp) {
focusedBlockUid = selectionBeforeEndClientId;
} else if (navigateDown) {
focusedBlockUid = selectionAfterEndClientId;
} else if (navigateOut) {
var _getBlockRootClientId;
focusedBlockUid = (_getBlockRootClientId = getBlockRootClientId(selectedBlockClientId)) !== null && _getBlockRootClientId !== void 0 ? _getBlockRootClientId : selectedBlockClientId;
} else if (navigateIn) {
var _getClientIdsOfDescen;
focusedBlockUid = (_getClientIdsOfDescen = getClientIdsOfDescendants([selectedBlockClientId])[0]) !== null && _getClientIdsOfDescen !== void 0 ? _getClientIdsOfDescen : selectedBlockClientId;
}
var startingBlockClientId = hasBlockMovingClientId();
if (isEscape && startingBlockClientId) {
setBlockMovingClientId(null);
}
if ((isEnter || isSpace) && startingBlockClientId) {
var sourceRoot = getBlockRootClientId(startingBlockClientId);
var destRoot = getBlockRootClientId(selectedBlockClientId);
var sourceBlockIndex = getBlockIndex(startingBlockClientId, sourceRoot);
var destinationBlockIndex = getBlockIndex(selectedBlockClientId, destRoot);
if (sourceBlockIndex < destinationBlockIndex && sourceRoot === destRoot) {
destinationBlockIndex -= 1;
}
moveBlockToPosition(startingBlockClientId, sourceRoot, destRoot, destinationBlockIndex);
selectBlock(startingBlockClientId);
setBlockMovingClientId(null);
}
if (navigateDown || navigateUp || navigateOut || navigateIn) {
if (focusedBlockUid) {
event.preventDefault();
selectBlock(focusedBlockUid);
} else if (isTab && selectedBlockClientId) {
var nextTabbable;
if (navigateDown) {
nextTabbable = external_wp_dom_["focus"].tabbable.findNext(blockElement);
if (!nextTabbable) {
nextTabbable = blockElement.ownerDocument.defaultView.frameElement;
nextTabbable = external_wp_dom_["focus"].tabbable.findNext(nextTabbable);
}
} else {
nextTabbable = external_wp_dom_["focus"].tabbable.findPrevious(blockElement);
}
if (nextTabbable) {
event.preventDefault();
nextTabbable.focus();
clearSelectedBlock();
}
}
}
}
var blockType = Object(external_wp_blocks_["getBlockType"])(name);
var label = Object(external_wp_blocks_["__experimentalGetAccessibleBlockLabel"])(blockType, attributes, index + 1, orientation);
var classNames = classnames_default()('block-editor-block-list__block-selection-button', {
'is-block-moving-mode': !!blockMovingMode
});
return Object(external_wp_element_["createElement"])("div", {
className: classNames
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
ref: ref,
onClick: function onClick() {
return setNavigationMode(false);
},
onKeyDown: onKeyDown,
label: label
}, Object(external_wp_element_["createElement"])(BlockTitle, {
clientId: clientId
})));
}
/* harmony default export */ var block_selection_button = (BlockSelectionButton);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/navigable-toolbar/index.js
/**
* WordPress dependencies
*/
function hasOnlyToolbarItem(elements) {
var dataProp = 'toolbarItem';
return !elements.some(function (element) {
return !(dataProp in element.dataset);
});
}
function getAllToolbarItemsIn(container) {
return Array.from(container.querySelectorAll('[data-toolbar-item]'));
}
function hasFocusWithin(container) {
return container.contains(container.ownerDocument.activeElement);
}
function focusFirstTabbableIn(container) {
var _focus$tabbable$find = external_wp_dom_["focus"].tabbable.find(container),
_focus$tabbable$find2 = Object(slicedToArray["a" /* default */])(_focus$tabbable$find, 1),
firstTabbable = _focus$tabbable$find2[0];
if (firstTabbable) {
firstTabbable.focus();
}
}
function useIsAccessibleToolbar(ref) {
/*
* By default, we'll assume the starting accessible state of the Toolbar
* is true, as it seems to be the most common case.
*
* Transitioning from an (initial) false to true state causes the
* component to mount twice, which is causing undesired
* side-effects. These side-effects appear to only affect certain
* E2E tests.
*
* This was initial discovered in this pull-request:
* https://github.com/WordPress/gutenberg/pull/23425
*/
var initialAccessibleToolbarState = true; // By default, it's gonna render NavigableMenu. If all the tabbable elements
// inside the toolbar are ToolbarItem components (or derived components like
// ToolbarButton), then we can wrap them with the accessible Toolbar
// component.
var _useState = Object(external_wp_element_["useState"])(initialAccessibleToolbarState),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isAccessibleToolbar = _useState2[0],
setIsAccessibleToolbar = _useState2[1];
var determineIsAccessibleToolbar = Object(external_wp_element_["useCallback"])(function () {
var tabbables = external_wp_dom_["focus"].tabbable.find(ref.current);
var onlyToolbarItem = hasOnlyToolbarItem(tabbables);
if (!onlyToolbarItem) {
external_wp_deprecated_default()('Using custom components as toolbar controls', {
alternative: 'ToolbarItem or ToolbarButton components',
link: 'https://developer.wordpress.org/block-editor/components/toolbar-button/#inside-blockcontrols'
});
}
setIsAccessibleToolbar(onlyToolbarItem);
}, []);
Object(external_wp_element_["useLayoutEffect"])(function () {
// Toolbar buttons may be rendered asynchronously, so we use
// MutationObserver to check if the toolbar subtree has been modified
var observer = new window.MutationObserver(determineIsAccessibleToolbar);
observer.observe(ref.current, {
childList: true,
subtree: true
});
return function () {
return observer.disconnect();
};
}, [isAccessibleToolbar]);
return isAccessibleToolbar;
}
function useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, defaultIndex, onIndexChange) {
// Make sure we don't use modified versions of this prop
var _useState3 = Object(external_wp_element_["useState"])(focusOnMount),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 1),
initialFocusOnMount = _useState4[0];
var _useState5 = Object(external_wp_element_["useState"])(defaultIndex),
_useState6 = Object(slicedToArray["a" /* default */])(_useState5, 1),
initialIndex = _useState6[0];
var focusToolbar = Object(external_wp_element_["useCallback"])(function () {
focusFirstTabbableIn(ref.current);
}, []); // Focus on toolbar when pressing alt+F10 when the toolbar is visible
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/focus-toolbar', focusToolbar, {
bindGlobal: true,
eventName: 'keydown'
});
Object(external_wp_element_["useEffect"])(function () {
if (initialFocusOnMount) {
focusToolbar();
}
}, [isAccessibleToolbar, initialFocusOnMount, focusToolbar]);
Object(external_wp_element_["useEffect"])(function () {
// If initialIndex is passed, we focus on that toolbar item when the
// toolbar gets mounted and initial focus is not forced.
// We have to wait for the next browser paint because block controls aren't
// rendered right away when the toolbar gets mounted.
var raf = 0;
if (initialIndex && !initialFocusOnMount) {
raf = window.requestAnimationFrame(function () {
var items = getAllToolbarItemsIn(ref.current);
var index = initialIndex || 0;
if (items[index] && hasFocusWithin(ref.current)) {
items[index].focus();
}
});
}
return function () {
window.cancelAnimationFrame(raf);
if (!onIndexChange) return; // When the toolbar element is unmounted and onIndexChange is passed, we
// pass the focused toolbar item index so it can be hydrated later.
var items = getAllToolbarItemsIn(ref.current);
var index = items.findIndex(function (item) {
return item.tabIndex === 0;
});
onIndexChange(index);
};
}, [initialIndex, initialFocusOnMount]);
}
function NavigableToolbar(_ref) {
var children = _ref.children,
focusOnMount = _ref.focusOnMount,
initialIndex = _ref.__experimentalInitialIndex,
onIndexChange = _ref.__experimentalOnIndexChange,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["children", "focusOnMount", "__experimentalInitialIndex", "__experimentalOnIndexChange"]);
var ref = Object(external_wp_element_["useRef"])();
var isAccessibleToolbar = useIsAccessibleToolbar(ref);
useToolbarFocus(ref, focusOnMount, isAccessibleToolbar, initialIndex, onIndexChange);
if (isAccessibleToolbar) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Toolbar"], Object(esm_extends["a" /* default */])({
label: props['aria-label'],
ref: ref
}, props), children);
}
return Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], Object(esm_extends["a" /* default */])({
orientation: "horizontal",
role: "toolbar",
ref: ref
}, props), children);
}
/* harmony default export */ var navigable_toolbar = (NavigableToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/use-scroll-when-dragging.js
/**
* WordPress dependencies
*/
var SCROLL_INACTIVE_DISTANCE_PX = 50;
var SCROLL_INTERVAL_MS = 25;
var PIXELS_PER_SECOND_PER_PERCENTAGE = 1000;
var VELOCITY_MULTIPLIER = PIXELS_PER_SECOND_PER_PERCENTAGE * (SCROLL_INTERVAL_MS / 1000);
/**
* React hook that scrolls the scroll container when a block is being dragged.
*
* @return {Function[]} `startScrolling`, `scrollOnDragOver`, `stopScrolling`
* functions to be called in `onDragStart`, `onDragOver`
* and `onDragEnd` events respectively.
*/
function useScrollWhenDragging() {
var dragStartY = Object(external_wp_element_["useRef"])(null);
var velocityY = Object(external_wp_element_["useRef"])(null);
var scrollParentY = Object(external_wp_element_["useRef"])(null);
var scrollEditorInterval = Object(external_wp_element_["useRef"])(null); // Clear interval when unmounting.
Object(external_wp_element_["useEffect"])(function () {
return function () {
if (scrollEditorInterval.current) {
clearInterval(scrollEditorInterval.current);
scrollEditorInterval.current = null;
}
};
}, []);
var startScrolling = Object(external_wp_element_["useCallback"])(function (event) {
dragStartY.current = event.clientY; // Find nearest parent(s) to scroll.
scrollParentY.current = Object(external_wp_dom_["getScrollContainer"])(event.target);
scrollEditorInterval.current = setInterval(function () {
if (scrollParentY.current && velocityY.current) {
var newTop = scrollParentY.current.scrollTop + velocityY.current; // Setting `behavior: 'smooth'` as a scroll property seems to hurt performance.
// Better to use a small scroll interval.
scrollParentY.current.scroll({
top: newTop
});
}
}, SCROLL_INTERVAL_MS);
}, []);
var scrollOnDragOver = Object(external_wp_element_["useCallback"])(function (event) {
if (!scrollParentY.current) {
return;
}
var scrollParentHeight = scrollParentY.current.offsetHeight;
var offsetDragStartPosition = dragStartY.current - scrollParentY.current.offsetTop;
var offsetDragPosition = event.clientY - scrollParentY.current.offsetTop;
if (event.clientY > offsetDragStartPosition) {
// User is dragging downwards.
var moveableDistance = Math.max(scrollParentHeight - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
var dragDistance = Math.max(offsetDragPosition - offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
var distancePercentage = dragDistance / moveableDistance;
velocityY.current = VELOCITY_MULTIPLIER * distancePercentage;
} else if (event.clientY < offsetDragStartPosition) {
// User is dragging upwards.
var _moveableDistance = Math.max(offsetDragStartPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
var _dragDistance = Math.max(offsetDragStartPosition - offsetDragPosition - SCROLL_INACTIVE_DISTANCE_PX, 0);
var _distancePercentage = _dragDistance / _moveableDistance;
velocityY.current = -VELOCITY_MULTIPLIER * _distancePercentage;
} else {
velocityY.current = 0;
}
}, []);
var stopScrolling = function stopScrolling() {
dragStartY.current = null;
scrollParentY.current = null;
if (scrollEditorInterval.current) {
clearInterval(scrollEditorInterval.current);
scrollEditorInterval.current = null;
}
};
return [startScrolling, scrollOnDragOver, stopScrolling];
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-draggable/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_draggable_BlockDraggable = function BlockDraggable(_ref) {
var children = _ref.children,
clientIds = _ref.clientIds,
cloneClassname = _ref.cloneClassname,
_onDragStart = _ref.onDragStart,
_onDragEnd = _ref.onDragEnd,
elementId = _ref.elementId;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _getBlockType;
var _select = select('core/block-editor'),
getBlockRootClientId = _select.getBlockRootClientId,
getTemplateLock = _select.getTemplateLock,
getBlockName = _select.getBlockName;
var rootClientId = getBlockRootClientId(clientIds[0]);
var templateLock = rootClientId ? getTemplateLock(rootClientId) : null;
var blockName = getBlockName(clientIds[0]);
return {
srcRootClientId: rootClientId,
isDraggable: 'all' !== templateLock,
icon: (_getBlockType = Object(external_wp_blocks_["getBlockType"])(blockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon
};
}, [clientIds]),
srcRootClientId = _useSelect.srcRootClientId,
isDraggable = _useSelect.isDraggable,
icon = _useSelect.icon;
var isDragging = Object(external_wp_element_["useRef"])(false);
var _useScrollWhenDraggin = useScrollWhenDragging(),
_useScrollWhenDraggin2 = Object(slicedToArray["a" /* default */])(_useScrollWhenDraggin, 3),
startScrolling = _useScrollWhenDraggin2[0],
scrollOnDragOver = _useScrollWhenDraggin2[1],
stopScrolling = _useScrollWhenDraggin2[2];
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
startDraggingBlocks = _useDispatch.startDraggingBlocks,
stopDraggingBlocks = _useDispatch.stopDraggingBlocks; // Stop dragging blocks if the block draggable is unmounted
Object(external_wp_element_["useEffect"])(function () {
return function () {
if (isDragging.current) {
stopDraggingBlocks();
}
};
}, []);
if (!isDraggable) {
return children({
isDraggable: false
});
}
var transferData = {
type: 'block',
srcClientIds: clientIds,
srcRootClientId: srcRootClientId
};
return Object(external_wp_element_["createElement"])(external_wp_components_["Draggable"], {
cloneClassname: cloneClassname,
elementId: elementId,
transferData: transferData,
onDragStart: function onDragStart(event) {
startDraggingBlocks(clientIds);
isDragging.current = true;
startScrolling(event);
if (_onDragStart) {
_onDragStart();
}
},
onDragOver: scrollOnDragOver,
onDragEnd: function onDragEnd() {
stopDraggingBlocks();
isDragging.current = false;
stopScrolling();
if (_onDragEnd) {
_onDragEnd();
}
},
__experimentalDragComponent: Object(external_wp_element_["createElement"])(BlockDraggableChip, {
count: clientIds.length,
icon: icon
})
}, function (_ref2) {
var onDraggableStart = _ref2.onDraggableStart,
onDraggableEnd = _ref2.onDraggableEnd;
return children({
draggable: true,
onDragStart: onDraggableStart,
onDragEnd: onDraggableEnd
});
});
};
/* harmony default export */ var block_draggable = (block_draggable_BlockDraggable);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-mover/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockMover(_ref) {
var isFirst = _ref.isFirst,
isLast = _ref.isLast,
clientIds = _ref.clientIds,
isLocked = _ref.isLocked,
isHidden = _ref.isHidden,
rootClientId = _ref.rootClientId,
orientation = _ref.orientation,
hideDragHandle = _ref.hideDragHandle;
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isFocused = _useState2[0],
setIsFocused = _useState2[1];
var onFocus = function onFocus() {
return setIsFocused(true);
};
var onBlur = function onBlur() {
return setIsFocused(false);
};
if (isLocked || isFirst && isLast && !rootClientId) {
return null;
}
var dragHandleLabel = Object(external_wp_i18n_["__"])('Drag'); // We emulate a disabled state because forcefully applying the `disabled`
// attribute on the buttons while it has focus causes the screen to change
// to an unfocused state (body as active element) without firing blur on,
// the rendering parent, leaving it unable to react to focus out.
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-block-mover', {
'is-visible': isFocused || !isHidden,
'is-horizontal': orientation === 'horizontal'
})
}, !hideDragHandle && Object(external_wp_element_["createElement"])(block_draggable, {
clientIds: clientIds,
cloneClassname: "block-editor-block-mover__drag-clone"
}, function (draggableProps) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({
icon: drag_handle,
className: "block-editor-block-mover__drag-handle",
"aria-hidden": "true",
label: dragHandleLabel // Should not be able to tab to drag handle as this
// button can only be used with a pointer device.
,
tabIndex: "-1"
}, draggableProps));
}), Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
className: "block-editor-block-mover__move-button-container"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], {
onFocus: onFocus,
onBlur: onBlur
}, function (itemProps) {
return Object(external_wp_element_["createElement"])(BlockMoverUpButton, Object(esm_extends["a" /* default */])({
clientIds: clientIds
}, itemProps));
}), Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], {
onFocus: onFocus,
onBlur: onBlur
}, function (itemProps) {
return Object(external_wp_element_["createElement"])(BlockMoverDownButton, Object(esm_extends["a" /* default */])({
clientIds: clientIds
}, itemProps));
})));
}
/* harmony default export */ var block_mover = (Object(external_wp_data_["withSelect"])(function (select, _ref2) {
var _getBlockListSettings;
var clientIds = _ref2.clientIds;
var _select = select('core/block-editor'),
getBlock = _select.getBlock,
getBlockIndex = _select.getBlockIndex,
getBlockListSettings = _select.getBlockListSettings,
getTemplateLock = _select.getTemplateLock,
getBlockOrder = _select.getBlockOrder,
getBlockRootClientId = _select.getBlockRootClientId;
var normalizedClientIds = Object(external_lodash_["castArray"])(clientIds);
var firstClientId = Object(external_lodash_["first"])(normalizedClientIds);
var block = getBlock(firstClientId);
var rootClientId = getBlockRootClientId(Object(external_lodash_["first"])(normalizedClientIds));
var firstIndex = getBlockIndex(firstClientId, rootClientId);
var lastIndex = getBlockIndex(Object(external_lodash_["last"])(normalizedClientIds), rootClientId);
var blockOrder = getBlockOrder(rootClientId);
var isFirst = firstIndex === 0;
var isLast = lastIndex === blockOrder.length - 1;
return {
blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
isLocked: getTemplateLock(rootClientId) === 'all',
rootClientId: rootClientId,
firstIndex: firstIndex,
isFirst: isFirst,
isLast: isLast,
orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation
};
})(BlockMover));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-parent-selector/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Block parent selector component, displaying the hierarchy of the
* current block selection as a single icon to "go up" a level.
*
* @return {WPComponent} Parent block selector.
*/
function BlockParentSelector() {
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
selectBlock = _useDispatch.selectBlock;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
getBlockParents = _select.getBlockParents,
getSelectedBlockClientId = _select.getSelectedBlockClientId;
var _select2 = select(external_wp_blocks_["store"]),
hasBlockSupport = _select2.hasBlockSupport;
var selectedBlockClientId = getSelectedBlockClientId();
var parents = getBlockParents(selectedBlockClientId);
var _firstParentClientId = parents[parents.length - 1];
var parentBlockName = getBlockName(_firstParentClientId);
var _parentBlockType = Object(external_wp_blocks_["getBlockType"])(parentBlockName);
return {
parentBlockType: _parentBlockType,
firstParentClientId: _firstParentClientId,
shouldHide: !hasBlockSupport(_parentBlockType, '__experimentalParentSelector', true)
};
}, []),
parentBlockType = _useSelect.parentBlockType,
firstParentClientId = _useSelect.firstParentClientId,
shouldHide = _useSelect.shouldHide;
if (shouldHide) {
return null;
}
if (firstParentClientId !== undefined) {
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-parent-selector",
key: firstParentClientId
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
className: "block-editor-block-parent-selector__button",
onClick: function onClick() {
return selectBlock(firstParentClientId);
},
label: Object(external_wp_i18n_["sprintf"])(
/* translators: %s: Name of the block's parent. */
Object(external_wp_i18n_["__"])('Select parent (%s)'), parentBlockType.title),
showTooltip: true,
icon: Object(external_wp_element_["createElement"])(BlockIcon, {
icon: parentBlockType.icon
})
}));
}
return null;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/stack.js
/**
* WordPress dependencies
*/
var stack_stack = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M20.2 8v11c0 .7-.6 1.2-1.2 1.2H6v1.5h13c1.5 0 2.7-1.2 2.7-2.8V8zM18 16.4V4.6c0-.9-.7-1.6-1.6-1.6H4.6C3.7 3 3 3.7 3 4.6v11.8c0 .9.7 1.6 1.6 1.6h11.8c.9 0 1.6-.7 1.6-1.6zm-13.5 0V4.6c0-.1.1-.1.1-.1h11.8c.1 0 .1.1.1.1v11.8c0 .1-.1.1-.1.1H4.6l-.1-.1z"
}));
/* harmony default export */ var library_stack = (stack_stack);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/preview-block-popover.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function PreviewBlockPopover(_ref) {
var blocks = _ref.blocks;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-switcher__popover__preview__parent"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-switcher__popover__preview__container"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
className: "block-editor-block-switcher__preview__popover",
position: "bottom right",
focusOnMount: false
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-switcher__preview"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-switcher__preview-title"
}, Object(external_wp_i18n_["__"])('Preview')), Object(external_wp_element_["createElement"])(block_preview, {
viewportWidth: 500,
blocks: blocks
})))));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-transformations-menu.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_transformations_menu_BlockTransformationsMenu = function BlockTransformationsMenu(_ref) {
var className = _ref.className,
possibleBlockTransformations = _ref.possibleBlockTransformations,
onSelect = _ref.onSelect,
blocks = _ref.blocks;
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
hoveredTransformItemName = _useState2[0],
setHoveredTransformItemName = _useState2[1];
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
label: Object(external_wp_i18n_["__"])('Transform to'),
className: className
}, hoveredTransformItemName && Object(external_wp_element_["createElement"])(PreviewBlockPopover, {
blocks: Object(external_wp_blocks_["switchToBlockType"])(blocks, hoveredTransformItemName)
}), possibleBlockTransformations.map(function (item) {
var name = item.name,
icon = item.icon,
title = item.title,
isDisabled = item.isDisabled;
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
key: name,
className: Object(external_wp_blocks_["getBlockMenuDefaultClassName"])(name),
onClick: function onClick(event) {
event.preventDefault();
onSelect(name);
},
disabled: isDisabled,
onMouseLeave: function onMouseLeave() {
return setHoveredTransformItemName(null);
},
onMouseEnter: function onMouseEnter() {
return setHoveredTransformItemName(name);
}
}, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: icon,
showColors: true
}), title);
}));
};
/* harmony default export */ var block_transformations_menu = (block_transformations_menu_BlockTransformationsMenu);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/utils.js
function utils_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = utils_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function utils_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return utils_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return utils_arrayLikeToArray(o, minLen); }
function utils_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Returns the active style from the given className.
*
* @param {Array} styles Block style variations.
* @param {string} className Class name
*
* @return {Object?} The active style.
*/
function getActiveStyle(styles, className) {
var _iterator = utils_createForOfIteratorHelper(new external_wp_tokenList_default.a(className).values()),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var style = _step.value;
if (style.indexOf('is-style-') === -1) {
continue;
}
var potentialStyleName = style.substring(9);
var activeStyle = Object(external_lodash_["find"])(styles, {
name: potentialStyleName
});
if (activeStyle) {
return activeStyle;
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
return Object(external_lodash_["find"])(styles, 'isDefault');
}
/**
* Replaces the active style in the block's className.
*
* @param {string} className Class name.
* @param {Object?} activeStyle The replaced style.
* @param {Object} newStyle The replacing style.
*
* @return {string} The updated className.
*/
function replaceActiveStyle(className, activeStyle, newStyle) {
var list = new external_wp_tokenList_default.a(className);
if (activeStyle) {
list.remove('is-style-' + activeStyle.name);
}
list.add('is-style-' + newStyle.name);
return list.value;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-styles/index.js
function block_styles_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_styles_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_styles_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_styles_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_styles_useGenericPreviewBlock = function useGenericPreviewBlock(block, type) {
return Object(external_wp_element_["useMemo"])(function () {
return type.example ? Object(external_wp_blocks_["getBlockFromExample"])(block.name, {
attributes: type.example.attributes,
innerBlocks: type.example.innerBlocks
}) : Object(external_wp_blocks_["cloneBlock"])(block);
}, [type.example ? block.name : block, type]);
};
function BlockStyles(_ref) {
var clientId = _ref.clientId,
_ref$onSwitch = _ref.onSwitch,
onSwitch = _ref$onSwitch === void 0 ? external_lodash_["noop"] : _ref$onSwitch,
_ref$onHoverClassName = _ref.onHoverClassName,
onHoverClassName = _ref$onHoverClassName === void 0 ? external_lodash_["noop"] : _ref$onHoverClassName,
itemRole = _ref.itemRole;
var selector = function selector(select) {
var _select = select('core/block-editor'),
getBlock = _select.getBlock;
var _select2 = select(external_wp_blocks_["store"]),
getBlockStyles = _select2.getBlockStyles;
var block = getBlock(clientId);
var blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
return {
block: block,
type: blockType,
styles: getBlockStyles(block.name),
className: block.attributes.className || ''
};
};
var _useSelect = Object(external_wp_data_["useSelect"])(selector, [clientId]),
styles = _useSelect.styles,
block = _useSelect.block,
type = _useSelect.type,
className = _useSelect.className;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlockAttributes = _useDispatch.updateBlockAttributes;
var genericPreviewBlock = block_styles_useGenericPreviewBlock(block, type);
if (!styles || styles.length === 0) {
return null;
}
var renderedStyles = Object(external_lodash_["find"])(styles, 'isDefault') ? styles : [{
name: 'default',
label: Object(external_wp_i18n_["_x"])('Default', 'block style'),
isDefault: true
}].concat(Object(toConsumableArray["a" /* default */])(styles));
var activeStyle = getActiveStyle(renderedStyles, className);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-styles"
}, renderedStyles.map(function (style) {
var styleClassName = replaceActiveStyle(className, activeStyle, style);
return Object(external_wp_element_["createElement"])(BlockStyleItem, {
genericPreviewBlock: genericPreviewBlock,
className: className,
isActive: activeStyle === style,
key: style.name,
onSelect: function onSelect() {
updateBlockAttributes(clientId, {
className: styleClassName
});
onHoverClassName(null);
onSwitch();
},
onBlur: function onBlur() {
return onHoverClassName(null);
},
onHover: function onHover() {
return onHoverClassName(styleClassName);
},
style: style,
styleClassName: styleClassName,
itemRole: itemRole
});
}));
}
function BlockStyleItem(_ref2) {
var genericPreviewBlock = _ref2.genericPreviewBlock,
style = _ref2.style,
isActive = _ref2.isActive,
onBlur = _ref2.onBlur,
onHover = _ref2.onHover,
onSelect = _ref2.onSelect,
styleClassName = _ref2.styleClassName,
itemRole = _ref2.itemRole;
var previewBlocks = Object(external_wp_element_["useMemo"])(function () {
return block_styles_objectSpread(block_styles_objectSpread({}, genericPreviewBlock), {}, {
attributes: block_styles_objectSpread(block_styles_objectSpread({}, genericPreviewBlock.attributes), {}, {
className: styleClassName
})
});
}, [genericPreviewBlock, styleClassName]);
return Object(external_wp_element_["createElement"])("div", {
key: style.name,
className: classnames_default()('block-editor-block-styles__item', {
'is-active': isActive
}),
onClick: function onClick() {
return onSelect();
},
onKeyDown: function onKeyDown(event) {
if (external_wp_keycodes_["ENTER"] === event.keyCode || external_wp_keycodes_["SPACE"] === event.keyCode) {
event.preventDefault();
onSelect();
}
},
onMouseEnter: onHover,
onMouseLeave: onBlur,
role: itemRole || 'button',
tabIndex: "0",
"aria-label": style.label || style.name
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-styles__item-preview"
}, Object(external_wp_element_["createElement"])(block_preview, {
viewportWidth: 500,
blocks: previewBlocks
})), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-styles__item-label"
}, style.label || style.name));
}
/* harmony default export */ var block_styles = (BlockStyles);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/block-styles-menu.js
function block_styles_menu_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_styles_menu_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_styles_menu_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_styles_menu_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockStylesMenu(_ref) {
var _ref$hoveredBlock = _ref.hoveredBlock,
name = _ref$hoveredBlock.name,
clientId = _ref$hoveredBlock.clientId,
onSwitch = _ref.onSwitch;
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
hoveredClassName = _useState2[0],
setHoveredClassName = _useState2[1];
var blockType = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/blocks').getBlockType(name);
}, [name]);
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], {
label: Object(external_wp_i18n_["__"])('Styles'),
className: "block-editor-block-switcher__styles__menugroup"
}, hoveredClassName && Object(external_wp_element_["createElement"])(PreviewBlockPopover, {
blocks: blockType.example ? Object(external_wp_blocks_["getBlockFromExample"])(blockType.name, {
attributes: block_styles_menu_objectSpread(block_styles_menu_objectSpread({}, blockType.example.attributes), {}, {
className: hoveredClassName
}),
innerBlocks: blockType.example.innerBlocks
}) : Object(external_wp_blocks_["cloneBlock"])(blockType, {
className: hoveredClassName
})
}), Object(external_wp_element_["createElement"])(block_styles, {
clientId: clientId,
onSwitch: onSwitch,
onHoverClassName: setHoveredClassName,
itemRole: "menuitem"
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-switcher/index.js
function block_switcher_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_switcher_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_switcher_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_switcher_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_switcher_BlockSwitcherDropdownMenu = function BlockSwitcherDropdownMenu(_ref) {
var clientIds = _ref.clientIds,
blocks = _ref.blocks;
var _useDispatch = Object(external_wp_data_["useDispatch"])(store),
replaceBlocks = _useDispatch.replaceBlocks;
var blockInformation = useBlockDisplayInformation(blocks[0].clientId);
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select(store),
getBlockRootClientId = _select.getBlockRootClientId,
getBlockTransformItems = _select.getBlockTransformItems,
__experimentalGetReusableBlockTitle = _select.__experimentalGetReusableBlockTitle;
var _select2 = select(external_wp_blocks_["store"]),
getBlockStyles = _select2.getBlockStyles,
getBlockType = _select2.getBlockType;
var rootClientId = getBlockRootClientId(Object(external_lodash_["castArray"])(clientIds)[0]);
var _blocks = Object(slicedToArray["a" /* default */])(blocks, 1),
firstBlockName = _blocks[0].name;
var _isSingleBlockSelected = blocks.length === 1;
var styles = _isSingleBlockSelected && getBlockStyles(firstBlockName);
var _icon;
var reusableBlockTitle;
if (_isSingleBlockSelected) {
_icon = blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon; // Take into account active block variations.
reusableBlockTitle = Object(external_wp_blocks_["isReusableBlock"])(blocks[0]) && __experimentalGetReusableBlockTitle(blocks[0].attributes.ref);
} else {
var _getBlockType;
var isSelectionOfSameType = Object(external_lodash_["uniq"])(blocks.map(function (_ref2) {
var name = _ref2.name;
return name;
})).length === 1; // When selection consists of blocks of multiple types, display an
// appropriate icon to communicate the non-uniformity.
_icon = isSelectionOfSameType ? (_getBlockType = getBlockType(firstBlockName)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.icon : library_stack;
}
return {
possibleBlockTransformations: getBlockTransformItems(blocks, rootClientId),
hasBlockStyles: !!(styles !== null && styles !== void 0 && styles.length),
icon: _icon,
blockTitle: reusableBlockTitle || getBlockType(firstBlockName).title
};
}, [clientIds, blocks, blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon]),
possibleBlockTransformations = _useSelect.possibleBlockTransformations,
hasBlockStyles = _useSelect.hasBlockStyles,
icon = _useSelect.icon,
blockTitle = _useSelect.blockTitle;
var isReusable = blocks.length === 1 && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]);
var onTransform = function onTransform(name) {
return replaceBlocks(clientIds, Object(external_wp_blocks_["switchToBlockType"])(blocks, name));
};
var hasPossibleBlockTransformations = !!possibleBlockTransformations.length;
if (!hasBlockStyles && !hasPossibleBlockTransformations) {
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
disabled: true,
className: "block-editor-block-switcher__no-switcher-icon",
title: blockTitle,
icon: Object(external_wp_element_["createElement"])(BlockIcon, {
icon: icon,
showColors: true
})
}));
}
var blockSwitcherLabel = blockTitle;
var blockSwitcherDescription = 1 === blocks.length ? Object(external_wp_i18n_["__"])('Change block type or style') : Object(external_wp_i18n_["sprintf"])(
/* translators: %s: number of blocks. */
Object(external_wp_i18n_["_n"])('Change type of %d block', 'Change type of %d blocks', blocks.length), blocks.length);
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, function (toggleProps) {
return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
className: "block-editor-block-switcher",
label: blockSwitcherLabel,
popoverProps: {
position: 'bottom right',
isAlternate: true,
className: 'block-editor-block-switcher__popover'
},
icon: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: icon,
className: "block-editor-block-switcher__toggle",
showColors: true
}), isReusable && Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-switcher__toggle-text"
}, Object(external_lodash_["truncate"])(blockTitle, {
length: 35
}))),
toggleProps: block_switcher_objectSpread({
describedBy: blockSwitcherDescription
}, toggleProps),
menuProps: {
orientation: 'both'
}
}, function (_ref3) {
var onClose = _ref3.onClose;
return (hasBlockStyles || hasPossibleBlockTransformations) && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-switcher__container"
}, hasPossibleBlockTransformations && Object(external_wp_element_["createElement"])(block_transformations_menu, {
className: "block-editor-block-switcher__transforms__menugroup",
possibleBlockTransformations: possibleBlockTransformations,
blocks: blocks,
onSelect: function onSelect(name) {
onTransform(name);
onClose();
}
}), hasBlockStyles && Object(external_wp_element_["createElement"])(BlockStylesMenu, {
hoveredBlock: blocks[0],
onSwitch: onClose
}));
});
}));
};
var block_switcher_BlockSwitcher = function BlockSwitcher(_ref4) {
var clientIds = _ref4.clientIds;
var blocks = Object(external_wp_data_["useSelect"])(function (select) {
return select(store).getBlocksByClientId(clientIds);
}, [clientIds]);
if (!blocks.length || blocks.some(function (block) {
return !block;
})) {
return null;
}
return Object(external_wp_element_["createElement"])(block_switcher_BlockSwitcherDropdownMenu, {
clientIds: clientIds,
blocks: blocks
});
};
/* harmony default export */ var block_switcher = (block_switcher_BlockSwitcher);
// EXTERNAL MODULE: external ["wp","blob"]
var external_wp_blob_ = __webpack_require__(43);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/get-paste-event-data.js
/**
* WordPress dependencies
*/
function getPasteEventData(_ref) {
var clipboardData = _ref.clipboardData;
var plainText = '';
var html = ''; // IE11 only supports `Text` as an argument for `getData` and will
// otherwise throw an invalid argument error, so we try the standard
// arguments first, then fallback to `Text` if they fail.
try {
plainText = clipboardData.getData('text/plain');
html = clipboardData.getData('text/html');
} catch (error1) {
try {
html = clipboardData.getData('Text');
} catch (error2) {
// Some browsers like UC Browser paste plain text by default and
// don't support clipboardData at all, so allow default
// behaviour.
return;
}
}
var files = Object(external_wp_dom_["getFilesFromDataTransfer"])(clipboardData).filter(function (_ref2) {
var type = _ref2.type;
return /^image\/(?:jpe?g|png|gif)$/.test(type);
}); // Only process files if no HTML is present.
// A pasted file may have the URL as plain text.
if (files.length && !html) {
html = files.map(function (file) {
return "");
}).join('');
plainText = '';
}
return {
html: html,
plainText: plainText
};
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function useNotifyCopy() {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor');
}, []),
getBlockName = _useSelect.getBlockName;
var _useSelect2 = Object(external_wp_data_["useSelect"])(function (select) {
return select(external_wp_blocks_["store"]);
}, []),
getBlockType = _useSelect2.getBlockType;
var _useDispatch = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]),
createSuccessNotice = _useDispatch.createSuccessNotice;
return Object(external_wp_element_["useCallback"])(function (eventType, selectedBlockClientIds) {
var notice = '';
if (selectedBlockClientIds.length === 1) {
var clientId = selectedBlockClientIds[0];
var _getBlockType = getBlockType(getBlockName(clientId)),
title = _getBlockType.title;
notice = eventType === 'copy' ? Object(external_wp_i18n_["sprintf"])( // Translators: Name of the block being copied, e.g. "Paragraph".
Object(external_wp_i18n_["__"])('Copied "%s" to clipboard.'), title) : Object(external_wp_i18n_["sprintf"])( // Translators: Name of the block being cut, e.g. "Paragraph".
Object(external_wp_i18n_["__"])('Moved "%s" to clipboard.'), title);
} else {
notice = eventType === 'copy' ? Object(external_wp_i18n_["sprintf"])( // Translators: %d: Number of blocks being copied.
Object(external_wp_i18n_["_n"])('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : Object(external_wp_i18n_["sprintf"])( // Translators: %d: Number of blocks being cut.
Object(external_wp_i18n_["_n"])('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
}
createSuccessNotice(notice, {
type: 'snackbar'
});
}, []);
}
function useClipboardHandler(ref) {
var _useSelect3 = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor');
}, []),
getBlocksByClientId = _useSelect3.getBlocksByClientId,
getSelectedBlockClientIds = _useSelect3.getSelectedBlockClientIds,
hasMultiSelection = _useSelect3.hasMultiSelection,
getSettings = _useSelect3.getSettings;
var _useDispatch2 = Object(external_wp_data_["useDispatch"])('core/block-editor'),
flashBlock = _useDispatch2.flashBlock,
removeBlocks = _useDispatch2.removeBlocks,
replaceBlocks = _useDispatch2.replaceBlocks;
var notifyCopy = useNotifyCopy();
Object(external_wp_element_["useEffect"])(function () {
function handler(event) {
var selectedBlockClientIds = getSelectedBlockClientIds();
if (selectedBlockClientIds.length === 0) {
return;
} // Always handle multiple selected blocks.
if (!hasMultiSelection()) {
var target = event.target;
var ownerDocument = target.ownerDocument; // If copying, only consider actual text selection as selection.
// Otherwise, any focus on an input field is considered.
var hasSelection = event.type === 'copy' || event.type === 'cut' ? Object(external_wp_dom_["documentHasUncollapsedSelection"])(ownerDocument) : Object(external_wp_dom_["documentHasSelection"])(ownerDocument); // Let native copy behaviour take over in input fields.
if (hasSelection) {
return;
}
}
if (!ref.current.contains(event.target)) {
return;
}
event.preventDefault();
if (event.type === 'copy' || event.type === 'cut') {
if (selectedBlockClientIds.length === 1) {
flashBlock(selectedBlockClientIds[0]);
}
notifyCopy(event.type, selectedBlockClientIds);
var blocks = getBlocksByClientId(selectedBlockClientIds);
var serialized = Object(external_wp_blocks_["serialize"])(blocks);
event.clipboardData.setData('text/plain', serialized);
event.clipboardData.setData('text/html', serialized);
}
if (event.type === 'cut') {
removeBlocks(selectedBlockClientIds);
} else if (event.type === 'paste') {
var _getSettings = getSettings(),
canUserUseUnfilteredHTML = _getSettings.__experimentalCanUserUseUnfilteredHTML;
var _getPasteEventData = getPasteEventData(event),
plainText = _getPasteEventData.plainText,
html = _getPasteEventData.html;
var _blocks = Object(external_wp_blocks_["pasteHandler"])({
HTML: html,
plainText: plainText,
mode: 'BLOCKS',
canUserUseUnfilteredHTML: canUserUseUnfilteredHTML
});
replaceBlocks(selectedBlockClientIds, _blocks, _blocks.length - 1, -1);
}
}
ref.current.addEventListener('copy', handler);
ref.current.addEventListener('cut', handler);
ref.current.addEventListener('paste', handler);
return function () {
ref.current.removeEventListener('copy', handler);
ref.current.removeEventListener('cut', handler);
ref.current.removeEventListener('paste', handler);
};
}, []);
}
function CopyHandler(_ref) {
var children = _ref.children;
var ref = Object(external_wp_element_["useRef"])();
useClipboardHandler(ref);
return Object(external_wp_element_["createElement"])("div", {
ref: ref
}, children);
}
/* harmony default export */ var copy_handler = (CopyHandler);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-actions/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockActions(_ref) {
var clientIds = _ref.clientIds,
children = _ref.children,
updateSelection = _ref.__experimentalUpdateSelection;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor');
}, []),
canInsertBlockType = _useSelect.canInsertBlockType,
getBlockRootClientId = _useSelect.getBlockRootClientId,
getBlocksByClientId = _useSelect.getBlocksByClientId,
getTemplateLock = _useSelect.getTemplateLock;
var _useSelect2 = Object(external_wp_data_["useSelect"])(function (select) {
return select(external_wp_blocks_["store"]);
}, []),
getDefaultBlockName = _useSelect2.getDefaultBlockName,
getGroupingBlockName = _useSelect2.getGroupingBlockName;
var blocks = getBlocksByClientId(clientIds);
var rootClientId = getBlockRootClientId(clientIds[0]);
var canDuplicate = Object(external_lodash_["every"])(blocks, function (block) {
return !!block && Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'multiple', true) && canInsertBlockType(block.name, rootClientId);
});
var canInsertDefaultBlock = canInsertBlockType(getDefaultBlockName(), rootClientId);
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
removeBlocks = _useDispatch.removeBlocks,
replaceBlocks = _useDispatch.replaceBlocks,
duplicateBlocks = _useDispatch.duplicateBlocks,
insertAfterBlock = _useDispatch.insertAfterBlock,
insertBeforeBlock = _useDispatch.insertBeforeBlock,
flashBlock = _useDispatch.flashBlock,
setBlockMovingClientId = _useDispatch.setBlockMovingClientId,
setNavigationMode = _useDispatch.setNavigationMode,
selectBlock = _useDispatch.selectBlock;
var notifyCopy = useNotifyCopy();
return children({
canDuplicate: canDuplicate,
canInsertDefaultBlock: canInsertDefaultBlock,
isLocked: !!getTemplateLock(rootClientId),
rootClientId: rootClientId,
blocks: blocks,
onDuplicate: function onDuplicate() {
return duplicateBlocks(clientIds, updateSelection);
},
onRemove: function onRemove() {
return removeBlocks(clientIds, updateSelection);
},
onInsertBefore: function onInsertBefore() {
insertBeforeBlock(Object(external_lodash_["first"])(Object(external_lodash_["castArray"])(clientIds)));
},
onInsertAfter: function onInsertAfter() {
insertAfterBlock(Object(external_lodash_["last"])(Object(external_lodash_["castArray"])(clientIds)));
},
onMoveTo: function onMoveTo() {
setNavigationMode(true);
selectBlock(clientIds[0]);
setBlockMovingClientId(clientIds[0]);
},
onGroup: function onGroup() {
if (!blocks.length) {
return;
}
var groupingBlockName = getGroupingBlockName(); // Activate the `transform` on `core/group` which does the conversion
var newBlocks = Object(external_wp_blocks_["switchToBlockType"])(blocks, groupingBlockName);
if (!newBlocks) {
return;
}
replaceBlocks(clientIds, newBlocks);
},
onUngroup: function onUngroup() {
if (!blocks.length) {
return;
}
var innerBlocks = blocks[0].innerBlocks;
if (!innerBlocks.length) {
return;
}
replaceBlocks(clientIds, innerBlocks);
},
onCopy: function onCopy() {
var selectedBlockClientIds = blocks.map(function (_ref2) {
var clientId = _ref2.clientId;
return clientId;
});
if (blocks.length === 1) {
flashBlock(selectedBlockClientIds[0]);
}
notifyCopy('copy', selectedBlockClientIds);
}
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-mode-toggle.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function BlockModeToggle(_ref) {
var blockType = _ref.blockType,
mode = _ref.mode,
onToggleMode = _ref.onToggleMode,
_ref$small = _ref.small,
small = _ref$small === void 0 ? false : _ref$small,
_ref$isCodeEditingEna = _ref.isCodeEditingEnabled,
isCodeEditingEnabled = _ref$isCodeEditingEna === void 0 ? true : _ref$isCodeEditingEna;
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'html', true) || !isCodeEditingEnabled) {
return null;
}
var label = mode === 'visual' ? Object(external_wp_i18n_["__"])('Edit as HTML') : Object(external_wp_i18n_["__"])('Edit visually');
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: onToggleMode
}, !small && label);
}
/* harmony default export */ var block_mode_toggle = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withSelect"])(function (select, _ref2) {
var clientId = _ref2.clientId;
var _select = select('core/block-editor'),
getBlock = _select.getBlock,
getBlockMode = _select.getBlockMode,
getSettings = _select.getSettings;
var block = getBlock(clientId);
var isCodeEditingEnabled = getSettings().codeEditingEnabled;
return {
mode: getBlockMode(clientId),
blockType: block ? Object(external_wp_blocks_["getBlockType"])(block.name) : null,
isCodeEditingEnabled: isCodeEditingEnabled
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, _ref3) {
var _ref3$onToggle = _ref3.onToggle,
onToggle = _ref3$onToggle === void 0 ? external_lodash_["noop"] : _ref3$onToggle,
clientId = _ref3.clientId;
return {
onToggleMode: function onToggleMode() {
dispatch('core/block-editor').toggleBlockMode(clientId);
onToggle();
}
};
})])(BlockModeToggle));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-convert-button.js
/**
* WordPress dependencies
*/
function BlockConvertButton(_ref) {
var shouldRender = _ref.shouldRender,
onClick = _ref.onClick,
small = _ref.small;
if (!shouldRender) {
return null;
}
var label = Object(external_wp_i18n_["__"])('Convert to Blocks');
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: onClick
}, !small && label);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-html-convert-button.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/* harmony default export */ var block_html_convert_button = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])(function (select, _ref) {
var clientId = _ref.clientId;
var block = select('core/block-editor').getBlock(clientId);
return {
block: block,
shouldRender: block && block.name === 'core/html'
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, _ref2) {
var block = _ref2.block;
return {
onClick: function onClick() {
return dispatch('core/block-editor').replaceBlocks(block.clientId, Object(external_wp_blocks_["rawHandler"])({
HTML: Object(external_wp_blocks_["getBlockContent"])(block)
}));
}
};
}))(BlockConvertButton));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-menu-first-item.js
/**
* WordPress dependencies
*/
var block_settings_menu_first_item_createSlotFill = Object(external_wp_components_["createSlotFill"])('__experimentalBlockSettingsMenuFirstItem'),
__experimentalBlockSettingsMenuFirstItem = block_settings_menu_first_item_createSlotFill.Fill,
block_settings_menu_first_item_Slot = block_settings_menu_first_item_createSlotFill.Slot;
__experimentalBlockSettingsMenuFirstItem.Slot = block_settings_menu_first_item_Slot;
/* harmony default export */ var block_settings_menu_first_item = (__experimentalBlockSettingsMenuFirstItem);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/use-convert-to-group-button-props.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Contains the properties `ConvertToGroupButton` component needs.
*
* @typedef {Object} ConvertToGroupButtonProps
* @property {string[]} clientIds An array of the selected client ids.
* @property {boolean} isGroupable Indicates if the selected blocks can be grouped.
* @property {boolean} isUngroupable Indicates if the selected blocks can be ungrouped.
* @property {WPBlock[]} blocksSelection An array of the selected blocks.
* @property {string} groupingBlockName The name of block used for handling grouping interactions.
*/
/**
* Returns the properties `ConvertToGroupButton` component needs to work properly.
* It is used in `BlockSettingsMenuControls` to know if `ConvertToGroupButton`
* should be rendered, to avoid ending up with an empty MenuGroup.
*
* @return {ConvertToGroupButtonProps} Returns the properties needed by `ConvertToGroupButton`.
*/
function useConvertToGroupButtonProps() {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _blocksSelection$;
var _select = select(store),
getBlockRootClientId = _select.getBlockRootClientId,
getBlocksByClientId = _select.getBlocksByClientId,
canInsertBlockType = _select.canInsertBlockType,
getSelectedBlockClientIds = _select.getSelectedBlockClientIds;
var _select2 = select(external_wp_blocks_["store"]),
getGroupingBlockName = _select2.getGroupingBlockName;
var _clientIds = getSelectedBlockClientIds();
var _groupingBlockName = getGroupingBlockName();
var rootClientId = !!(_clientIds !== null && _clientIds !== void 0 && _clientIds.length) ? getBlockRootClientId(_clientIds[0]) : undefined;
var groupingBlockAvailable = canInsertBlockType(_groupingBlockName, rootClientId);
var _blocksSelection = getBlocksByClientId(_clientIds);
var isSingleGroupingBlock = _blocksSelection.length === 1 && ((_blocksSelection$ = _blocksSelection[0]) === null || _blocksSelection$ === void 0 ? void 0 : _blocksSelection$.name) === _groupingBlockName; // Do we have
// 1. Grouping block available to be inserted?
// 2. One or more blocks selected
// (we allow single Blocks to become groups unless
// they are a soltiary group block themselves)
var _isGroupable = groupingBlockAvailable && _blocksSelection.length && !isSingleGroupingBlock; // Do we have a single Group Block selected and does that group have inner blocks?
var _isUngroupable = isSingleGroupingBlock && !!_blocksSelection[0].innerBlocks.length;
return {
clientIds: _clientIds,
isGroupable: _isGroupable,
isUngroupable: _isUngroupable,
blocksSelection: _blocksSelection,
groupingBlockName: _groupingBlockName
};
}, []),
clientIds = _useSelect.clientIds,
isGroupable = _useSelect.isGroupable,
isUngroupable = _useSelect.isUngroupable,
blocksSelection = _useSelect.blocksSelection,
groupingBlockName = _useSelect.groupingBlockName;
return {
clientIds: clientIds,
isGroupable: isGroupable,
isUngroupable: isUngroupable,
blocksSelection: blocksSelection,
groupingBlockName: groupingBlockName
};
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/convert-to-group-buttons/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function ConvertToGroupButton(_ref) {
var clientIds = _ref.clientIds,
isGroupable = _ref.isGroupable,
isUngroupable = _ref.isUngroupable,
blocksSelection = _ref.blocksSelection,
groupingBlockName = _ref.groupingBlockName,
_ref$onClose = _ref.onClose,
onClose = _ref$onClose === void 0 ? function () {} : _ref$onClose;
var _useDispatch = Object(external_wp_data_["useDispatch"])(store),
replaceBlocks = _useDispatch.replaceBlocks;
var onConvertToGroup = function onConvertToGroup() {
// Activate the `transform` on the Grouping Block which does the conversion
var newBlocks = Object(external_wp_blocks_["switchToBlockType"])(blocksSelection, groupingBlockName);
if (newBlocks) {
replaceBlocks(clientIds, newBlocks);
}
};
var onConvertFromGroup = function onConvertFromGroup() {
var innerBlocks = blocksSelection[0].innerBlocks;
if (!innerBlocks.length) {
return;
}
replaceBlocks(clientIds, innerBlocks);
};
if (!isGroupable && !isUngroupable) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, isGroupable && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: function onClick() {
onConvertToGroup();
onClose();
}
}, Object(external_wp_i18n_["_x"])('Group', 'verb')), isUngroupable && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: function onClick() {
onConvertFromGroup();
onClose();
}
}, Object(external_wp_i18n_["_x"])('Ungroup', 'Ungrouping blocks from within a Group block back into individual blocks within the Editor ')));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu-controls/index.js
function block_settings_menu_controls_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_settings_menu_controls_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_settings_menu_controls_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_settings_menu_controls_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_settings_menu_controls_createSlotFill = Object(external_wp_components_["createSlotFill"])('BlockSettingsMenuControls'),
BlockSettingsMenuControls = block_settings_menu_controls_createSlotFill.Fill,
block_settings_menu_controls_Slot = block_settings_menu_controls_createSlotFill.Slot;
var block_settings_menu_controls_BlockSettingsMenuControlsSlot = function BlockSettingsMenuControlsSlot(_ref) {
var fillProps = _ref.fillProps,
_ref$clientIds = _ref.clientIds,
clientIds = _ref$clientIds === void 0 ? null : _ref$clientIds;
var selectedBlocks = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select(store),
getBlocksByClientId = _select.getBlocksByClientId,
getSelectedBlockClientIds = _select.getSelectedBlockClientIds;
var ids = clientIds !== null ? clientIds : getSelectedBlockClientIds();
return Object(external_lodash_["map"])(Object(external_lodash_["compact"])(getBlocksByClientId(ids)), function (block) {
return block.name;
});
}, [clientIds]); // Check if current selection of blocks is Groupable or Ungroupable
// and pass this props down to ConvertToGroupButton.
var convertToGroupButtonProps = useConvertToGroupButtonProps();
var isGroupable = convertToGroupButtonProps.isGroupable,
isUngroupable = convertToGroupButtonProps.isUngroupable;
var showConvertToGroupButton = isGroupable || isUngroupable;
return Object(external_wp_element_["createElement"])(block_settings_menu_controls_Slot, {
fillProps: block_settings_menu_controls_objectSpread(block_settings_menu_controls_objectSpread({}, fillProps), {}, {
selectedBlocks: selectedBlocks
})
}, function (fills) {
if ((fills === null || fills === void 0 ? void 0 : fills.length) > 0 || showConvertToGroupButton) {
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, fills, Object(external_wp_element_["createElement"])(ConvertToGroupButton, Object(esm_extends["a" /* default */])({}, convertToGroupButtonProps, {
onClose: fillProps === null || fillProps === void 0 ? void 0 : fillProps.onClose
})));
}
});
};
BlockSettingsMenuControls.Slot = block_settings_menu_controls_BlockSettingsMenuControlsSlot;
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-settings-menu-controls/README.md
*/
/* harmony default export */ var block_settings_menu_controls = (BlockSettingsMenuControls);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/block-settings-dropdown.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_settings_dropdown_POPOVER_PROPS = {
className: 'block-editor-block-settings-menu__popover',
position: 'bottom right',
isAlternate: true
};
function BlockSettingsDropdown(_ref) {
var clientIds = _ref.clientIds,
__experimentalSelectBlock = _ref.__experimentalSelectBlock,
children = _ref.children,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["clientIds", "__experimentalSelectBlock", "children"]);
var blockClientIds = Object(external_lodash_["castArray"])(clientIds);
var count = blockClientIds.length;
var firstBlockClientId = blockClientIds[0];
var shortcuts = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select(external_wp_keyboardShortcuts_["store"]),
getShortcutRepresentation = _select.getShortcutRepresentation;
return {
duplicate: getShortcutRepresentation('core/block-editor/duplicate'),
remove: getShortcutRepresentation('core/block-editor/remove'),
insertAfter: getShortcutRepresentation('core/block-editor/insert-after'),
insertBefore: getShortcutRepresentation('core/block-editor/insert-before')
};
}, []);
var updateSelection = Object(external_wp_element_["useCallback"])(__experimentalSelectBlock ? /*#__PURE__*/function () {
var _ref2 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(clientIdsPromise) {
var ids;
return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return clientIdsPromise;
case 2:
ids = _context.sent;
if (ids && ids[0]) {
__experimentalSelectBlock(ids[0]);
}
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function (_x) {
return _ref2.apply(this, arguments);
};
}() : external_lodash_["noop"], [__experimentalSelectBlock]);
var removeBlockLabel = count === 1 ? Object(external_wp_i18n_["__"])('Remove block') : Object(external_wp_i18n_["__"])('Remove blocks');
return Object(external_wp_element_["createElement"])(BlockActions, {
clientIds: clientIds,
__experimentalUpdateSelection: !__experimentalSelectBlock
}, function (_ref3) {
var canDuplicate = _ref3.canDuplicate,
canInsertDefaultBlock = _ref3.canInsertDefaultBlock,
isLocked = _ref3.isLocked,
onDuplicate = _ref3.onDuplicate,
onInsertAfter = _ref3.onInsertAfter,
onInsertBefore = _ref3.onInsertBefore,
onRemove = _ref3.onRemove,
onCopy = _ref3.onCopy,
onMoveTo = _ref3.onMoveTo,
blocks = _ref3.blocks;
return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], Object(esm_extends["a" /* default */])({
icon: more_vertical["a" /* default */],
label: Object(external_wp_i18n_["__"])('Options'),
className: "block-editor-block-settings-menu",
popoverProps: block_settings_dropdown_POPOVER_PROPS,
noIcons: true
}, props), function (_ref4) {
var onClose = _ref4.onClose;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(block_settings_menu_first_item.Slot, {
fillProps: {
onClose: onClose
}
}), count === 1 && Object(external_wp_element_["createElement"])(block_html_convert_button, {
clientId: firstBlockClientId
}), Object(external_wp_element_["createElement"])(external_wp_components_["ClipboardButton"], {
text: function text() {
return Object(external_wp_blocks_["serialize"])(blocks);
},
role: "menuitem",
className: "components-menu-item__button",
onCopy: onCopy
}, Object(external_wp_i18n_["__"])('Copy')), canDuplicate && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: Object(external_lodash_["flow"])(onClose, onDuplicate, updateSelection),
shortcut: shortcuts.duplicate
}, Object(external_wp_i18n_["__"])('Duplicate')), canInsertDefaultBlock && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: Object(external_lodash_["flow"])(onClose, onInsertBefore),
shortcut: shortcuts.insertBefore
}, Object(external_wp_i18n_["__"])('Insert before')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: Object(external_lodash_["flow"])(onClose, onInsertAfter),
shortcut: shortcuts.insertAfter
}, Object(external_wp_i18n_["__"])('Insert after'))), !isLocked && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: Object(external_lodash_["flow"])(onClose, onMoveTo)
}, Object(external_wp_i18n_["__"])('Move to')), count === 1 && Object(external_wp_element_["createElement"])(block_mode_toggle, {
clientId: firstBlockClientId,
onToggle: onClose
})), Object(external_wp_element_["createElement"])(block_settings_menu_controls.Slot, {
fillProps: {
onClose: onClose
},
clientIds: clientIds
}), typeof children === 'function' ? children({
onClose: onClose
}) : external_wp_element_["Children"].map(function (child) {
return Object(external_wp_element_["cloneElement"])(child, {
onClose: onClose
});
}), Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, !isLocked && Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: Object(external_lodash_["flow"])(onClose, onRemove, updateSelection),
shortcut: shortcuts.remove
}, removeBlockLabel)));
});
});
}
/* harmony default export */ var block_settings_dropdown = (BlockSettingsDropdown);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-settings-menu/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockSettingsMenu(_ref) {
var clientIds = _ref.clientIds,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["clientIds"]);
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, function (toggleProps) {
return Object(external_wp_element_["createElement"])(block_settings_dropdown, Object(esm_extends["a" /* default */])({
clientIds: clientIds,
toggleProps: toggleProps
}, props));
}));
}
/* harmony default export */ var block_settings_menu = (BlockSettingsMenu);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/utils.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var utils_window = window,
utils_clearTimeout = utils_window.clearTimeout,
utils_setTimeout = utils_window.setTimeout;
var DEBOUNCE_TIMEOUT = 200;
/**
* Hook that creates a showMover state, as well as debounced show/hide callbacks.
*
* @param {Object} props Component props.
* @param {Object} props.ref Element reference.
* @param {boolean} props.isFocused Whether the component has current focus.
* @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
* @param {Function} [props.onChange=noop] Callback function.
*/
function useDebouncedShowMovers(_ref) {
var ref = _ref.ref,
isFocused = _ref.isFocused,
_ref$debounceTimeout = _ref.debounceTimeout,
debounceTimeout = _ref$debounceTimeout === void 0 ? DEBOUNCE_TIMEOUT : _ref$debounceTimeout,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange;
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
showMovers = _useState2[0],
setShowMovers = _useState2[1];
var timeoutRef = Object(external_wp_element_["useRef"])();
var handleOnChange = function handleOnChange(nextIsFocused) {
if (ref !== null && ref !== void 0 && ref.current) {
setShowMovers(nextIsFocused);
}
onChange(nextIsFocused);
};
var getIsHovered = function getIsHovered() {
return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.matches(':hover');
};
var shouldHideMovers = function shouldHideMovers() {
var isHovered = getIsHovered();
return !isFocused && !isHovered;
};
var clearTimeoutRef = function clearTimeoutRef() {
var timeout = timeoutRef.current;
if (timeout && utils_clearTimeout) {
utils_clearTimeout(timeout);
}
};
var debouncedShowMovers = function debouncedShowMovers(event) {
if (event) {
event.stopPropagation();
}
clearTimeoutRef();
if (!showMovers) {
handleOnChange(true);
}
};
var debouncedHideMovers = function debouncedHideMovers(event) {
if (event) {
event.stopPropagation();
}
clearTimeoutRef();
timeoutRef.current = utils_setTimeout(function () {
if (shouldHideMovers()) {
handleOnChange(false);
}
}, debounceTimeout);
};
Object(external_wp_element_["useEffect"])(function () {
return function () {
return clearTimeoutRef();
};
}, []);
return {
showMovers: showMovers,
debouncedShowMovers: debouncedShowMovers,
debouncedHideMovers: debouncedHideMovers
};
}
/**
* Hook that provides a showMovers state and gesture events for DOM elements
* that interact with the showMovers state.
*
* @param {Object} props Component props.
* @param {Object} props.ref Element reference.
* @param {number} [props.debounceTimeout=250] Debounce timeout in milliseconds.
* @param {Function} [props.onChange=noop] Callback function.
*/
function useShowMoversGestures(_ref2) {
var ref = _ref2.ref,
_ref2$debounceTimeout = _ref2.debounceTimeout,
debounceTimeout = _ref2$debounceTimeout === void 0 ? DEBOUNCE_TIMEOUT : _ref2$debounceTimeout,
_ref2$onChange = _ref2.onChange,
onChange = _ref2$onChange === void 0 ? external_lodash_["noop"] : _ref2$onChange;
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isFocused = _useState4[0],
setIsFocused = _useState4[1];
var _useDebouncedShowMove = useDebouncedShowMovers({
ref: ref,
debounceTimeout: debounceTimeout,
isFocused: isFocused,
onChange: onChange
}),
showMovers = _useDebouncedShowMove.showMovers,
debouncedShowMovers = _useDebouncedShowMove.debouncedShowMovers,
debouncedHideMovers = _useDebouncedShowMove.debouncedHideMovers;
var registerRef = Object(external_wp_element_["useRef"])(false);
var isFocusedWithin = function isFocusedWithin() {
return (ref === null || ref === void 0 ? void 0 : ref.current) && ref.current.contains(ref.current.ownerDocument.activeElement);
};
Object(external_wp_element_["useEffect"])(function () {
var node = ref.current;
var handleOnFocus = function handleOnFocus() {
if (isFocusedWithin()) {
setIsFocused(true);
debouncedShowMovers();
}
};
var handleOnBlur = function handleOnBlur() {
if (!isFocusedWithin()) {
setIsFocused(false);
debouncedHideMovers();
}
};
/**
* Events are added via DOM events (vs. React synthetic events),
* as the child React components swallow mouse events.
*/
if (node && !registerRef.current) {
node.addEventListener('focus', handleOnFocus, true);
node.addEventListener('blur', handleOnBlur, true);
registerRef.current = true;
}
return function () {
if (node) {
node.removeEventListener('focus', handleOnFocus);
node.removeEventListener('blur', handleOnBlur);
}
};
}, [ref, registerRef, setIsFocused, debouncedShowMovers, debouncedHideMovers]);
return {
showMovers: showMovers,
gestures: {
onMouseMove: debouncedShowMovers,
onMouseLeave: debouncedHideMovers
}
};
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-toolbar/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockToolbar(_ref) {
var hideDragHandle = _ref.hideDragHandle;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
getBlockMode = _select.getBlockMode,
getSelectedBlockClientIds = _select.getSelectedBlockClientIds,
isBlockValid = _select.isBlockValid,
getBlockRootClientId = _select.getBlockRootClientId,
getSettings = _select.getSettings;
var selectedBlockClientIds = getSelectedBlockClientIds();
var selectedBlockClientId = selectedBlockClientIds[0];
var blockRootClientId = getBlockRootClientId(selectedBlockClientId);
var settings = getSettings();
return {
blockClientIds: selectedBlockClientIds,
blockClientId: selectedBlockClientId,
blockType: selectedBlockClientId && Object(external_wp_blocks_["getBlockType"])(getBlockName(selectedBlockClientId)),
hasFixedToolbar: settings.hasFixedToolbar,
hasReducedUI: settings.hasReducedUI,
rootClientId: blockRootClientId,
isValid: selectedBlockClientIds.every(function (id) {
return isBlockValid(id);
}),
isVisual: selectedBlockClientIds.every(function (id) {
return getBlockMode(id) === 'visual';
})
};
}, []),
blockClientIds = _useSelect.blockClientIds,
blockClientId = _useSelect.blockClientId,
blockType = _useSelect.blockType,
hasFixedToolbar = _useSelect.hasFixedToolbar,
hasReducedUI = _useSelect.hasReducedUI,
isValid = _useSelect.isValid,
isVisual = _useSelect.isVisual;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
toggleBlockHighlight = _useDispatch.toggleBlockHighlight;
var nodeRef = Object(external_wp_element_["useRef"])();
var _useShowMoversGesture = useShowMoversGestures({
ref: nodeRef,
onChange: function onChange(isFocused) {
if (isFocused && hasReducedUI) {
return;
}
toggleBlockHighlight(blockClientId, isFocused);
}
}),
showMovers = _useShowMoversGesture.showMovers,
showMoversGestures = _useShowMoversGesture.gestures;
var displayHeaderToolbar = Object(external_wp_compose_["useViewportMatch"])('medium', '<') || hasFixedToolbar;
if (blockType) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, '__experimentalToolbar', true)) {
return null;
}
}
var shouldShowMovers = displayHeaderToolbar || showMovers;
if (blockClientIds.length === 0) {
return null;
}
var shouldShowVisualToolbar = isValid && isVisual;
var isMultiToolbar = blockClientIds.length > 1;
var classes = classnames_default()('block-editor-block-toolbar', shouldShowMovers && 'is-showing-movers');
return Object(external_wp_element_["createElement"])("div", {
className: classes
}, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
ref: nodeRef
}, showMoversGestures), !isMultiToolbar && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-toolbar__block-parent-selector-wrapper"
}, Object(external_wp_element_["createElement"])(BlockParentSelector, {
clientIds: blockClientIds
})), (shouldShowVisualToolbar || isMultiToolbar) && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
className: "block-editor-block-toolbar__block-controls"
}, Object(external_wp_element_["createElement"])(block_switcher, {
clientIds: blockClientIds
}), Object(external_wp_element_["createElement"])(block_mover, {
clientIds: blockClientIds,
hideDragHandle: hideDragHandle || hasReducedUI
}))), shouldShowVisualToolbar && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(block_controls.Slot, {
bubblesVirtually: true,
className: "block-editor-block-toolbar__slot"
}), Object(external_wp_element_["createElement"])(block_format_controls.Slot, {
bubblesVirtually: true,
className: "block-editor-block-toolbar__slot"
})), Object(external_wp_element_["createElement"])(block_settings_menu, {
clientIds: blockClientIds
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-contextual-toolbar.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockContextualToolbar(_ref) {
var focusOnMount = _ref.focusOnMount,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["focusOnMount"]);
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
getSelectedBlockClientIds = _select.getSelectedBlockClientIds;
var _select2 = select(external_wp_blocks_["store"]),
getBlockType = _select2.getBlockType;
var selectedBlockClientIds = getSelectedBlockClientIds();
var selectedBlockClientId = selectedBlockClientIds[0];
return {
blockType: selectedBlockClientId && getBlockType(getBlockName(selectedBlockClientId))
};
}, []),
blockType = _useSelect.blockType;
if (blockType) {
if (!Object(external_wp_blocks_["hasBlockSupport"])(blockType, '__experimentalToolbar', true)) {
return null;
}
}
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-contextual-toolbar-wrapper"
}, Object(external_wp_element_["createElement"])(navigable_toolbar, Object(esm_extends["a" /* default */])({
focusOnMount: focusOnMount,
className: "block-editor-block-contextual-toolbar"
/* translators: accessibility text for the block toolbar */
,
"aria-label": Object(external_wp_i18n_["__"])('Block tools')
}, props), Object(external_wp_element_["createElement"])(BlockToolbar, null)));
}
/* harmony default export */ var block_contextual_toolbar = (BlockContextualToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-popover.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function block_popover_selector(select) {
var _select = select('core/block-editor'),
isNavigationMode = _select.isNavigationMode,
isMultiSelecting = _select.isMultiSelecting,
hasMultiSelection = _select.hasMultiSelection,
isTyping = _select.isTyping,
isCaretWithinFormattedText = _select.isCaretWithinFormattedText,
getSettings = _select.getSettings,
getLastMultiSelectedBlockClientId = _select.getLastMultiSelectedBlockClientId;
return {
isNavigationMode: isNavigationMode(),
isMultiSelecting: isMultiSelecting(),
isTyping: isTyping(),
isCaretWithinFormattedText: isCaretWithinFormattedText(),
hasMultiSelection: hasMultiSelection(),
hasFixedToolbar: getSettings().hasFixedToolbar,
lastClientId: getLastMultiSelectedBlockClientId()
};
}
function BlockPopover(_ref) {
var clientId = _ref.clientId,
rootClientId = _ref.rootClientId,
isValid = _ref.isValid,
isEmptyDefaultBlock = _ref.isEmptyDefaultBlock,
capturingClientId = _ref.capturingClientId;
var _useSelect = Object(external_wp_data_["useSelect"])(block_popover_selector, []),
isNavigationMode = _useSelect.isNavigationMode,
isMultiSelecting = _useSelect.isMultiSelecting,
isTyping = _useSelect.isTyping,
isCaretWithinFormattedText = _useSelect.isCaretWithinFormattedText,
hasMultiSelection = _useSelect.hasMultiSelection,
hasFixedToolbar = _useSelect.hasFixedToolbar,
lastClientId = _useSelect.lastClientId;
var isLargeViewport = Object(external_wp_compose_["useViewportMatch"])('medium');
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isToolbarForced = _useState2[0],
setIsToolbarForced = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isInserterShown = _useState4[0],
setIsInserterShown = _useState4[1];
var blockNodes = Object(external_wp_element_["useContext"])(BlockNodes);
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
stopTyping = _useDispatch.stopTyping; // Controls when the side inserter on empty lines should
// be shown, including writing and selection modes.
var showEmptyBlockSideInserter = !isTyping && !isNavigationMode && isEmptyDefaultBlock && isValid;
var shouldShowBreadcrumb = isNavigationMode;
var shouldShowContextualToolbar = !isNavigationMode && !hasFixedToolbar && isLargeViewport && !showEmptyBlockSideInserter && !isMultiSelecting && (!isTyping || isCaretWithinFormattedText);
var canFocusHiddenToolbar = !isNavigationMode && !shouldShowContextualToolbar && !hasFixedToolbar && !isEmptyDefaultBlock;
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/focus-toolbar', Object(external_wp_element_["useCallback"])(function () {
setIsToolbarForced(true);
stopTyping(true);
}, []), {
bindGlobal: true,
eventName: 'keydown',
isDisabled: !canFocusHiddenToolbar
});
Object(external_wp_element_["useEffect"])(function () {
if (!shouldShowContextualToolbar) {
setIsToolbarForced(false);
}
}, [shouldShowContextualToolbar]); // Stores the active toolbar item index so the block toolbar can return focus
// to it when re-mounting.
var initialToolbarItemIndexRef = Object(external_wp_element_["useRef"])();
Object(external_wp_element_["useEffect"])(function () {
// Resets the index whenever the active block changes so this is not
// persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169
initialToolbarItemIndexRef.current = undefined;
}, [clientId]);
if (!shouldShowBreadcrumb && !shouldShowContextualToolbar && !isToolbarForced && !showEmptyBlockSideInserter) {
return null;
}
var node = blockNodes[clientId];
if (!node) {
return null;
}
var _node = node,
ownerDocument = _node.ownerDocument;
if (capturingClientId) {
node = getBlockDOMNode(capturingClientId, ownerDocument);
}
var anchorRef = node;
if (hasMultiSelection) {
var bottomNode = blockNodes[lastClientId]; // Wait to render the popover until the bottom reference is available
// as well.
if (!bottomNode) {
return null;
}
anchorRef = {
top: node,
bottom: bottomNode
};
}
function onFocus() {
setIsInserterShown(true);
}
function onBlur() {
setIsInserterShown(false);
} // Position above the anchor, pop out towards the right, and position in the
// left corner. For the side inserter, pop out towards the left, and
// position in the right corner.
// To do: refactor `Popover` to make this prop clearer.
var popoverPosition = showEmptyBlockSideInserter ? 'top left right' : 'top right left';
var stickyBoundaryElement = showEmptyBlockSideInserter ? undefined : // The sticky boundary element should be the boundary at which the
// the block toolbar becomes sticky when the block scolls out of view.
// In case of an iframe, this should be the iframe boundary, otherwise
// the scroll container.
ownerDocument.defaultView.frameElement || Object(external_wp_dom_["getScrollContainer"])(node) || ownerDocument.body;
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
noArrow: true,
animate: false,
position: popoverPosition,
focusOnMount: false,
anchorRef: anchorRef,
className: "block-editor-block-list__block-popover",
__unstableStickyBoundaryElement: stickyBoundaryElement,
__unstableSlotName: "block-toolbar",
__unstableBoundaryParent: true // Observe movement for block animations (especially horizontal).
,
__unstableObserveElement: node,
shouldAnchorIncludePadding: true
}, (shouldShowContextualToolbar || isToolbarForced) && Object(external_wp_element_["createElement"])("div", {
onFocus: onFocus,
onBlur: onBlur // While ideally it would be enough to capture the
// bubbling focus event from the Inserter, due to the
// characteristics of click focusing of `button`s in
// Firefox and Safari, it is not reliable.
//
// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus
,
tabIndex: -1,
className: classnames_default()('block-editor-block-list__block-popover-inserter', {
'is-visible': isInserterShown
})
}, Object(external_wp_element_["createElement"])(inserter, {
clientId: clientId,
rootClientId: rootClientId,
__experimentalIsQuick: true
})), (shouldShowContextualToolbar || isToolbarForced) && Object(external_wp_element_["createElement"])(block_contextual_toolbar // If the toolbar is being shown because of being forced
// it should focus the toolbar right after the mount.
, {
focusOnMount: isToolbarForced,
__experimentalInitialIndex: initialToolbarItemIndexRef.current,
__experimentalOnIndexChange: function __experimentalOnIndexChange(index) {
initialToolbarItemIndexRef.current = index;
}
}), shouldShowBreadcrumb && Object(external_wp_element_["createElement"])(block_selection_button, {
clientId: clientId,
rootClientId: rootClientId,
blockElement: node
}), showEmptyBlockSideInserter && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-list__empty-block-inserter"
}, Object(external_wp_element_["createElement"])(inserter, {
position: "bottom right",
rootClientId: rootClientId,
clientId: clientId,
__experimentalIsQuick: true
})));
}
function wrapperSelector(select) {
var _select2 = select('core/block-editor'),
getSelectedBlockClientId = _select2.getSelectedBlockClientId,
getFirstMultiSelectedBlockClientId = _select2.getFirstMultiSelectedBlockClientId,
getBlockRootClientId = _select2.getBlockRootClientId,
__unstableGetBlockWithoutInnerBlocks = _select2.__unstableGetBlockWithoutInnerBlocks,
getBlockParents = _select2.getBlockParents,
__experimentalGetBlockListSettingsForBlocks = _select2.__experimentalGetBlockListSettingsForBlocks;
var clientId = getSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();
if (!clientId) {
return;
}
var _ref2 = __unstableGetBlockWithoutInnerBlocks(clientId) || {},
name = _ref2.name,
_ref2$attributes = _ref2.attributes,
attributes = _ref2$attributes === void 0 ? {} : _ref2$attributes,
isValid = _ref2.isValid;
var blockParentsClientIds = getBlockParents(clientId); // Get Block List Settings for all ancestors of the current Block clientId
var ancestorBlockListSettings = __experimentalGetBlockListSettingsForBlocks(blockParentsClientIds); // Find the index of the first Block with the `captureDescendantsToolbars` prop defined
// This will be the top most ancestor because getBlockParents() returns tree from top -> bottom
var topmostAncestorWithCaptureDescendantsToolbarsIndex = Object(external_lodash_["findIndex"])(ancestorBlockListSettings, ['__experimentalCaptureToolbars', true]);
var capturingClientId;
if (topmostAncestorWithCaptureDescendantsToolbarsIndex !== -1) {
capturingClientId = blockParentsClientIds[topmostAncestorWithCaptureDescendantsToolbarsIndex];
}
return {
clientId: clientId,
rootClientId: getBlockRootClientId(clientId),
name: name,
isValid: isValid,
isEmptyDefaultBlock: name && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])({
name: name,
attributes: attributes
}),
capturingClientId: capturingClientId
};
}
function WrappedBlockPopover() {
var selected = Object(external_wp_data_["useSelect"])(wrapperSelector, []);
if (!selected) {
return null;
}
var clientId = selected.clientId,
rootClientId = selected.rootClientId,
name = selected.name,
isValid = selected.isValid,
isEmptyDefaultBlock = selected.isEmptyDefaultBlock,
capturingClientId = selected.capturingClientId;
if (!name) {
return null;
}
return Object(external_wp_element_["createElement"])(BlockPopover, {
clientId: clientId,
rootClientId: rootClientId,
isValid: isValid,
isEmptyDefaultBlock: isEmptyDefaultBlock,
capturingClientId: capturingClientId
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* If the block count exceeds the threshold, we disable the reordering animation
* to avoid laginess.
*/
var BLOCK_ANIMATION_THRESHOLD = 200;
var BlockNodes = Object(external_wp_element_["createContext"])();
var SetBlockNodes = Object(external_wp_element_["createContext"])();
function BlockList(_ref) {
var className = _ref.className;
var ref = Object(external_wp_element_["useRef"])();
var _useState = Object(external_wp_element_["useState"])({}),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
blockNodes = _useState2[0],
setBlockNodes = _useState2[1];
var insertionPoint = insertion_point_useInsertionPoint(ref);
return Object(external_wp_element_["createElement"])(BlockNodes.Provider, {
value: blockNodes
}, insertionPoint, Object(external_wp_element_["createElement"])(WrappedBlockPopover, null), Object(external_wp_element_["createElement"])("div", {
ref: ref,
className: classnames_default()('block-editor-block-list__layout is-root-container', className)
}, Object(external_wp_element_["createElement"])(SetBlockNodes.Provider, {
value: setBlockNodes
}, Object(external_wp_element_["createElement"])(BlockListItems, {
wrapperRef: ref
}))));
}
function Items(_ref2) {
var placeholder = _ref2.placeholder,
rootClientId = _ref2.rootClientId,
renderAppender = _ref2.renderAppender,
__experimentalAppenderTagName = _ref2.__experimentalAppenderTagName,
wrapperRef = _ref2.wrapperRef;
function selector(select) {
var _getBlockListSettings;
var _select = select('core/block-editor'),
getBlockOrder = _select.getBlockOrder,
getBlockListSettings = _select.getBlockListSettings,
getSettings = _select.getSettings,
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds,
hasMultiSelection = _select.hasMultiSelection,
getGlobalBlockCount = _select.getGlobalBlockCount,
isTyping = _select.isTyping,
__experimentalGetActiveBlockIdByBlockNames = _select.__experimentalGetActiveBlockIdByBlockNames; // Determine if there is an active entity area to spotlight.
var activeEntityBlockId = __experimentalGetActiveBlockIdByBlockNames(getSettings().__experimentalSpotlightEntityBlocks);
return {
blockClientIds: getBlockOrder(rootClientId),
selectedBlockClientId: getSelectedBlockClientId(),
multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
orientation: (_getBlockListSettings = getBlockListSettings(rootClientId)) === null || _getBlockListSettings === void 0 ? void 0 : _getBlockListSettings.orientation,
hasMultiSelection: hasMultiSelection(),
enableAnimation: !isTyping() && getGlobalBlockCount() <= BLOCK_ANIMATION_THRESHOLD,
activeEntityBlockId: activeEntityBlockId
};
}
var _useSelect = Object(external_wp_data_["useSelect"])(selector, [rootClientId]),
blockClientIds = _useSelect.blockClientIds,
selectedBlockClientId = _useSelect.selectedBlockClientId,
multiSelectedBlockClientIds = _useSelect.multiSelectedBlockClientIds,
orientation = _useSelect.orientation,
hasMultiSelection = _useSelect.hasMultiSelection,
enableAnimation = _useSelect.enableAnimation,
activeEntityBlockId = _useSelect.activeEntityBlockId;
var dropTargetIndex = useBlockDropZone({
element: wrapperRef,
rootClientId: rootClientId
});
var isAppenderDropTarget = dropTargetIndex === blockClientIds.length;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, blockClientIds.map(function (clientId, index) {
var isBlockInSelection = hasMultiSelection ? multiSelectedBlockClientIds.includes(clientId) : selectedBlockClientId === clientId;
var isDropTarget = dropTargetIndex === index;
return Object(external_wp_element_["createElement"])(external_wp_data_["AsyncModeProvider"], {
key: clientId,
value: !isBlockInSelection
}, Object(external_wp_element_["createElement"])(block_list_block, {
rootClientId: rootClientId,
clientId: clientId // This prop is explicitely computed and passed down
// to avoid being impacted by the async mode
// otherwise there might be a small delay to trigger the animation.
,
index: index,
enableAnimation: enableAnimation,
className: classnames_default()({
'is-drop-target': isDropTarget,
'is-dropping-horizontally': isDropTarget && orientation === 'horizontal',
'has-active-entity': activeEntityBlockId
}),
activeEntityBlockId: activeEntityBlockId
}));
}), blockClientIds.length < 1 && placeholder, Object(external_wp_element_["createElement"])(block_list_appender, {
tagName: __experimentalAppenderTagName,
rootClientId: rootClientId,
renderAppender: renderAppender,
className: classnames_default()({
'is-drop-target': isAppenderDropTarget,
'is-dropping-horizontally': isAppenderDropTarget && orientation === 'horizontal'
})
}));
}
function BlockListItems(props) {
// This component needs to always be synchronous as it's the one changing
// the async mode depending on the block selection.
return Object(external_wp_element_["createElement"])(external_wp_data_["AsyncModeProvider"], {
value: false
}, Object(external_wp_element_["createElement"])(Items, props));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-focus-first-element.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/**
* Returns the initial position if the block needs to be focussed, `undefined`
* otherwise. The initial position is either 0 (start) or -1 (end).
*
* @param {string} clientId Block client ID.
*
* @return {number} The initial position, either 0 (start) or -1 (end).
*/
function useInitialPosition(clientId) {
return Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlocksInitialCaretPosition = _select.getSelectedBlocksInitialCaretPosition,
isMultiSelecting = _select.isMultiSelecting,
isNavigationMode = _select.isNavigationMode,
isBlockSelected = _select.isBlockSelected;
if (!isBlockSelected(clientId)) {
return;
}
if (isMultiSelecting() || isNavigationMode()) {
return;
} // If there's no initial position, return 0 to focus the start.
return getSelectedBlocksInitialCaretPosition() || 0;
}, [clientId]);
}
/**
* Transitions focus to the block or inner tabbable when the block becomes
* selected.
*
* @param {RefObject} ref React ref with the block element.
* @param {string} clientId Block client ID.
*/
function useFocusFirstElement(ref, clientId) {
var initialPosition = useInitialPosition(clientId);
Object(external_wp_element_["useEffect"])(function () {
if (initialPosition === undefined) {
return;
}
var ownerDocument = ref.current.ownerDocument; // Focus is captured by the wrapper node, so while focus transition
// should only consider tabbables within editable display, since it
// may be the wrapper itself or a side control which triggered the
// focus event, don't unnecessary transition to an inner tabbable.
if (ownerDocument.activeElement && isInsideRootBlock(ref.current, ownerDocument.activeElement)) {
return;
} // Find all tabbables within node.
var textInputs = external_wp_dom_["focus"].tabbable.find(ref.current).filter(function (node) {
return Object(external_wp_dom_["isTextField"])(node) && // Exclude inner blocks and block appenders
isInsideRootBlock(ref.current, node) && !node.closest('.block-list-appender');
}); // If reversed (e.g. merge via backspace), use the last in the set of
// tabbables.
var isReverse = -1 === initialPosition;
var target = (isReverse ? external_lodash_["last"] : external_lodash_["first"])(textInputs) || ref.current;
Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(target, isReverse);
}, [initialPosition]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-is-hovered.js
/**
* WordPress dependencies
*/
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/**
* Returns true when the block is hovered and in navigation or outline mode, false if not.
*
* @param {RefObject} ref React ref with the block element.
*
* @return {boolean} Hovered state.
*/
function useIsHovered(ref) {
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isHovered = _useState2[0],
setHovered = _useState2[1];
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
selectIsNavigationMode = _select.isNavigationMode,
getSettings = _select.getSettings;
return {
isNavigationMode: selectIsNavigationMode(),
isOutlineMode: getSettings().outlineMode
};
}, []),
isNavigationMode = _useSelect.isNavigationMode,
isOutlineMode = _useSelect.isOutlineMode;
Object(external_wp_element_["useEffect"])(function () {
function addListener(eventType, value) {
function listener(event) {
if (event.defaultPrevented) {
return;
}
event.preventDefault();
setHovered(value);
}
ref.current.addEventListener(eventType, listener);
return function () {
ref.current.removeEventListener(eventType, listener);
};
}
if (isHovered) {
return addListener('mouseout', false);
}
if (isOutlineMode || isNavigationMode) {
return addListener('mouseover', true);
}
}, [isNavigationMode, isOutlineMode, isHovered, setHovered]);
return isHovered;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-block-moving-mode-class-names.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Returns the class names used for block moving mode.
*
* @param {string} clientId The block client ID to insert above.
*
* @return {string} The class names.
*/
function useBlockMovingModeClassNames(clientId) {
return Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
hasBlockMovingClientId = _select.hasBlockMovingClientId,
canInsertBlockType = _select.canInsertBlockType,
getBlockName = _select.getBlockName,
getBlockRootClientId = _select.getBlockRootClientId,
isBlockSelected = _select.isBlockSelected; // The classes are only relevant for the selected block. Avoid
// re-rendering all blocks!
if (!isBlockSelected(clientId)) {
return;
}
var movingClientId = hasBlockMovingClientId();
if (!movingClientId) {
return;
}
return classnames_default()('is-block-moving-mode', {
'can-insert-moving-block': canInsertBlockType(getBlockName(movingClientId), getBlockRootClientId(clientId))
});
}, [clientId]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/focus-capture.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Renders focus capturing areas to redirect focus to the selected block if not
* in Navigation mode.
*
* @param {string} selectedClientId Client ID of the selected block.
* @param {boolean} isReverse Set to true if the component is rendered
* after the block list, false if rendered
* before.
* @param {Object} containerRef Reference containing the element reference
* of the block list container.
* @param {boolean} noCapture Reference containing the flag for enabling
* or disabling capturing.
*
* @return {WPElement} The focus capture element.
*/
var FocusCapture = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var selectedClientId = _ref.selectedClientId,
isReverse = _ref.isReverse,
containerRef = _ref.containerRef,
noCapture = _ref.noCapture,
hasMultiSelection = _ref.hasMultiSelection,
multiSelectionContainer = _ref.multiSelectionContainer;
var isNavigationMode = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').isNavigationMode();
});
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
setNavigationMode = _useDispatch.setNavigationMode;
function onFocus() {
// Do not capture incoming focus if set by us in WritingFlow.
if (noCapture.current) {
noCapture.current = null;
return;
} // When focus coming in from out of the block list, and no block is
// selected, enable Navigation mode and select the first or last block
// depending on the direction.
if (!selectedClientId) {
if (hasMultiSelection) {
multiSelectionContainer.current.focus();
return;
}
setNavigationMode(true);
var tabbables = external_wp_dom_["focus"].tabbable.find(containerRef.current);
if (tabbables.length) {
if (isReverse) {
Object(external_lodash_["last"])(tabbables).focus();
} else {
Object(external_lodash_["first"])(tabbables).focus();
}
}
return;
} // If there is a selected block, move focus to the first or last
// tabbable element depending on the direction.
var wrapper = getBlockDOMNode(selectedClientId, ref.current.ownerDocument);
if (isReverse) {
var _tabbables = external_wp_dom_["focus"].tabbable.find(wrapper);
var lastTabbable = Object(external_lodash_["last"])(_tabbables) || wrapper;
lastTabbable.focus();
} else {
wrapper.focus();
}
}
return Object(external_wp_element_["createElement"])("div", {
ref: ref // Don't allow tabbing to this element in Navigation mode.
,
tabIndex: !isNavigationMode ? '0' : undefined,
onFocus: onFocus // Needs to be positioned within the viewport, so focus to this
// element does not scroll the page.
,
style: {
position: 'fixed'
}
});
});
/* harmony default export */ var focus_capture = (FocusCapture);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-multi-selection.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Returns for the deepest node at the start or end of a container node. Ignores
* any text nodes that only contain HTML formatting whitespace.
*
* @param {Element} node Container to search.
* @param {string} type 'start' or 'end'.
*/
function getDeepestNode(node, type) {
var child = type === 'start' ? 'firstChild' : 'lastChild';
var sibling = type === 'start' ? 'nextSibling' : 'previousSibling';
while (node[child]) {
node = node[child];
while (node.nodeType === node.TEXT_NODE && /^[ \t\n]*$/.test(node.data) && node[sibling]) {
node = node[sibling];
}
}
return node;
}
function use_multi_selection_selector(select) {
var _select = select('core/block-editor'),
isSelectionEnabled = _select.isSelectionEnabled,
isMultiSelecting = _select.isMultiSelecting,
getMultiSelectedBlockClientIds = _select.getMultiSelectedBlockClientIds,
hasMultiSelection = _select.hasMultiSelection,
getBlockParents = _select.getBlockParents,
getSelectedBlockClientId = _select.getSelectedBlockClientId;
return {
isSelectionEnabled: isSelectionEnabled(),
isMultiSelecting: isMultiSelecting(),
multiSelectedBlockClientIds: getMultiSelectedBlockClientIds(),
hasMultiSelection: hasMultiSelection(),
getBlockParents: getBlockParents,
selectedBlockClientId: getSelectedBlockClientId()
};
}
function toggleRichText(container, toggle) {
Array.from(container.querySelectorAll('.rich-text')).forEach(function (node) {
if (toggle) {
node.setAttribute('contenteditable', true);
} else {
node.removeAttribute('contenteditable');
}
});
}
function useMultiSelection(ref) {
var _useSelect = Object(external_wp_data_["useSelect"])(use_multi_selection_selector, []),
isSelectionEnabled = _useSelect.isSelectionEnabled,
isMultiSelecting = _useSelect.isMultiSelecting,
multiSelectedBlockClientIds = _useSelect.multiSelectedBlockClientIds,
hasMultiSelection = _useSelect.hasMultiSelection,
getBlockParents = _useSelect.getBlockParents,
selectedBlockClientId = _useSelect.selectedBlockClientId;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
startMultiSelect = _useDispatch.startMultiSelect,
stopMultiSelect = _useDispatch.stopMultiSelect,
multiSelect = _useDispatch.multiSelect,
selectBlock = _useDispatch.selectBlock;
var rafId = Object(external_wp_element_["useRef"])();
var startClientId = Object(external_wp_element_["useRef"])();
var anchorElement = Object(external_wp_element_["useRef"])();
/**
* When the component updates, and there is multi selection, we need to
* select the entire block contents.
*/
Object(external_wp_element_["useEffect"])(function () {
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
if (!hasMultiSelection || isMultiSelecting) {
if (!selectedBlockClientId || isMultiSelecting) {
return;
}
var _selection = defaultView.getSelection();
if (_selection.rangeCount && !_selection.isCollapsed) {
var blockNode = getBlockDOMNode(selectedBlockClientId, ownerDocument);
var _selection$getRangeAt = _selection.getRangeAt(0),
startContainer = _selection$getRangeAt.startContainer,
endContainer = _selection$getRangeAt.endContainer;
if (!!blockNode && (!blockNode.contains(startContainer) || !blockNode.contains(endContainer))) {
_selection.removeAllRanges();
}
}
return;
}
var length = multiSelectedBlockClientIds.length;
if (length < 2) {
return;
} // These must be in the right DOM order.
var start = multiSelectedBlockClientIds[0];
var end = multiSelectedBlockClientIds[length - 1];
var startNode = getBlockDOMNode(start, ownerDocument);
var endNode = getBlockDOMNode(end, ownerDocument);
var selection = defaultView.getSelection();
var range = ownerDocument.createRange(); // The most stable way to select the whole block contents is to start
// and end at the deepest points.
startNode = getDeepestNode(startNode, 'start');
endNode = getDeepestNode(endNode, 'end');
range.setStartBefore(startNode);
range.setEndAfter(endNode);
selection.removeAllRanges();
selection.addRange(range);
}, [hasMultiSelection, isMultiSelecting, multiSelectedBlockClientIds, selectBlock, selectedBlockClientId]);
var onSelectionChange = Object(external_wp_element_["useCallback"])(function (_ref) {
var isSelectionEnd = _ref.isSelectionEnd;
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
var selection = defaultView.getSelection(); // If no selection is found, end multi selection and enable all rich
// text areas.
if (!selection.rangeCount || selection.isCollapsed) {
toggleRichText(ref.current, true);
return;
}
var clientId = getBlockClientId(selection.focusNode);
var isSingularSelection = startClientId.current === clientId;
if (isSingularSelection) {
selectBlock(clientId); // If the selection is complete (on mouse up), and no multiple
// blocks have been selected, set focus back to the anchor element
// if the anchor element contains the selection. Additionally, rich
// text elements that were previously disabled can now be enabled
// again.
if (isSelectionEnd) {
toggleRichText(ref.current, true);
if (selection.rangeCount) {
var _selection$getRangeAt2 = selection.getRangeAt(0),
commonAncestorContainer = _selection$getRangeAt2.commonAncestorContainer;
if (anchorElement.current.contains(commonAncestorContainer)) {
anchorElement.current.focus();
}
}
}
} else {
var startPath = [].concat(Object(toConsumableArray["a" /* default */])(getBlockParents(startClientId.current)), [startClientId.current]);
var endPath = [].concat(Object(toConsumableArray["a" /* default */])(getBlockParents(clientId)), [clientId]);
var depth = Math.min(startPath.length, endPath.length) - 1;
multiSelect(startPath[depth], endPath[depth]);
}
}, [selectBlock, getBlockParents, multiSelect]);
/**
* Handles a mouseup event to end the current mouse multi-selection.
*/
var onSelectionEnd = Object(external_wp_element_["useCallback"])(function () {
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
ownerDocument.removeEventListener('selectionchange', onSelectionChange); // Equivalent to attaching the listener once.
defaultView.removeEventListener('mouseup', onSelectionEnd); // The browser selection won't have updated yet at this point, so wait
// until the next animation frame to get the browser selection.
rafId.current = defaultView.requestAnimationFrame(function () {
onSelectionChange({
isSelectionEnd: true
});
stopMultiSelect();
});
}, [onSelectionChange, stopMultiSelect]); // Only clean up when unmounting, these are added and cleaned up elsewhere.
Object(external_wp_element_["useEffect"])(function () {
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
return function () {
ownerDocument.removeEventListener('selectionchange', onSelectionChange);
defaultView.removeEventListener('mouseup', onSelectionEnd);
defaultView.cancelAnimationFrame(rafId.current);
};
}, [onSelectionChange, onSelectionEnd]);
/**
* Binds event handlers to the document for tracking a pending multi-select
* in response to a mousedown event occurring in a rendered block.
*/
return Object(external_wp_element_["useCallback"])(function (clientId) {
if (!isSelectionEnabled) {
return;
}
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
startClientId.current = clientId;
anchorElement.current = ownerDocument.activeElement;
startMultiSelect(); // `onSelectionStart` is called after `mousedown` and `mouseleave`
// (from a block). The selection ends when `mouseup` happens anywhere
// in the window.
ownerDocument.addEventListener('selectionchange', onSelectionChange);
defaultView.addEventListener('mouseup', onSelectionEnd); // Removing the contenteditable attributes within the block editor is
// essential for selection to work across editable areas. The edible
// hosts are removed, allowing selection to be extended outside the
// DOM element. `startMultiSelect` sets a flag in the store so the rich
// text components are updated, but the rerender may happen very slowly,
// especially in Safari for the blocks that are asynchonously rendered.
// To ensure the browser instantly removes the selection boundaries, we
// remove the contenteditable attributes manually.
toggleRichText(ref.current, false);
}, [isSelectionEnabled, startMultiSelect, onSelectionEnd]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var SelectionStart = Object(external_wp_element_["createContext"])();
function writing_flow_getComputedStyle(node) {
return node.ownerDocument.defaultView.getComputedStyle(node);
}
/**
* Returns true if the element should consider edge navigation upon a keyboard
* event of the given directional key code, or false otherwise.
*
* @param {Element} element HTML element to test.
* @param {number} keyCode KeyboardEvent keyCode to test.
* @param {boolean} hasModifier Whether a modifier is pressed.
*
* @return {boolean} Whether element should consider edge navigation.
*/
function isNavigationCandidate(element, keyCode, hasModifier) {
var isVertical = keyCode === external_wp_keycodes_["UP"] || keyCode === external_wp_keycodes_["DOWN"]; // Currently, all elements support unmodified vertical navigation.
if (isVertical && !hasModifier) {
return true;
} // Native inputs should not navigate horizontally.
var tagName = element.tagName;
return tagName !== 'INPUT' && tagName !== 'TEXTAREA';
}
/**
* Returns the optimal tab target from the given focused element in the
* desired direction. A preference is made toward text fields, falling back
* to the block focus stop if no other candidates exist for the block.
*
* @param {Element} target Currently focused text field.
* @param {boolean} isReverse True if considering as the first field.
* @param {Element} containerElement Element containing all blocks.
* @param {boolean} onlyVertical Whether to only consider tabbable elements
* that are visually above or under the
* target.
*
* @return {?Element} Optimal tab target, if one exists.
*/
function getClosestTabbable(target, isReverse, containerElement, onlyVertical) {
// Since the current focus target is not guaranteed to be a text field,
// find all focusables. Tabbability is considered later.
var focusableNodes = external_wp_dom_["focus"].focusable.find(containerElement);
if (isReverse) {
focusableNodes = Object(external_lodash_["reverse"])(focusableNodes);
} // Consider as candidates those focusables after the current target.
// It's assumed this can only be reached if the target is focusable
// (on its keydown event), so no need to verify it exists in the set.
focusableNodes = focusableNodes.slice(focusableNodes.indexOf(target) + 1);
var targetRect;
if (onlyVertical) {
targetRect = target.getBoundingClientRect();
}
function isTabCandidate(node, i, array) {
// Not a candidate if the node is not tabbable.
if (!external_wp_dom_["focus"].tabbable.isTabbableIndex(node)) {
return false;
}
if (onlyVertical) {
var nodeRect = node.getBoundingClientRect();
if (nodeRect.left >= targetRect.right || nodeRect.right <= targetRect.left) {
return false;
}
} // Prefer text fields...
if (Object(external_wp_dom_["isTextField"])(node)) {
return true;
} // ...but settle for block focus stop.
if (!isBlockFocusStop(node)) {
return false;
} // If element contains inner blocks, stop immediately at its focus
// wrapper.
if (hasInnerBlocksContext(node)) {
return true;
} // If navigating out of a block (in reverse), don't consider its
// block focus stop.
if (node.contains(target)) {
return false;
} // In case of block focus stop, check to see if there's a better
// text field candidate within.
for (var offset = 1, nextNode; nextNode = array[i + offset]; offset++) {
// Abort if no longer testing descendents of focus stop.
if (!node.contains(nextNode)) {
break;
} // Apply same tests by recursion. This is important to consider
// nestable blocks where we don't want to settle for the inner
// block focus stop.
if (isTabCandidate(nextNode, i + offset, array)) {
return false;
}
}
return true;
}
return Object(external_lodash_["find"])(focusableNodes, isTabCandidate);
}
function writing_flow_selector(select) {
var _select = select('core/block-editor'),
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getMultiSelectedBlocksStartClientId = _select.getMultiSelectedBlocksStartClientId,
getMultiSelectedBlocksEndClientId = _select.getMultiSelectedBlocksEndClientId,
getPreviousBlockClientId = _select.getPreviousBlockClientId,
getNextBlockClientId = _select.getNextBlockClientId,
getFirstMultiSelectedBlockClientId = _select.getFirstMultiSelectedBlockClientId,
getLastMultiSelectedBlockClientId = _select.getLastMultiSelectedBlockClientId,
hasMultiSelection = _select.hasMultiSelection,
getBlockOrder = _select.getBlockOrder,
isNavigationMode = _select.isNavigationMode,
isSelectionEnabled = _select.isSelectionEnabled,
getBlockSelectionStart = _select.getBlockSelectionStart,
isMultiSelecting = _select.isMultiSelecting,
getSettings = _select.getSettings;
var selectedBlockClientId = getSelectedBlockClientId();
var selectionStartClientId = getMultiSelectedBlocksStartClientId();
var selectionEndClientId = getMultiSelectedBlocksEndClientId();
var blocks = getBlockOrder();
return {
selectedBlockClientId: selectedBlockClientId,
selectionStartClientId: selectionStartClientId,
selectionBeforeEndClientId: getPreviousBlockClientId(selectionEndClientId || selectedBlockClientId),
selectionAfterEndClientId: getNextBlockClientId(selectionEndClientId || selectedBlockClientId),
selectedFirstClientId: getFirstMultiSelectedBlockClientId(),
selectedLastClientId: getLastMultiSelectedBlockClientId(),
hasMultiSelection: hasMultiSelection(),
firstBlock: Object(external_lodash_["first"])(blocks),
lastBlock: Object(external_lodash_["last"])(blocks),
isNavigationMode: isNavigationMode(),
isSelectionEnabled: isSelectionEnabled(),
blockSelectionStart: getBlockSelectionStart(),
isMultiSelecting: isMultiSelecting(),
keepCaretInsideBlock: getSettings().keepCaretInsideBlock
};
}
/**
* Handles selection and navigation across blocks. This component should be
* wrapped around BlockList.
*
* @param {Object} props Component properties.
* @param {WPElement} props.children Children to be rendered.
*/
function WritingFlow(_ref) {
var children = _ref.children;
var container = Object(external_wp_element_["useRef"])();
var focusCaptureBeforeRef = Object(external_wp_element_["useRef"])();
var focusCaptureAfterRef = Object(external_wp_element_["useRef"])();
var multiSelectionContainer = Object(external_wp_element_["useRef"])();
var entirelySelected = Object(external_wp_element_["useRef"])(); // Reference that holds the a flag for enabling or disabling
// capturing on the focus capture elements.
var noCapture = Object(external_wp_element_["useRef"])(); // Here a DOMRect is stored while moving the caret vertically so vertical
// position of the start position can be restored. This is to recreate
// browser behaviour across blocks.
var verticalRect = Object(external_wp_element_["useRef"])();
var onSelectionStart = useMultiSelection(container);
var _useSelect = Object(external_wp_data_["useSelect"])(writing_flow_selector, []),
selectedBlockClientId = _useSelect.selectedBlockClientId,
selectionStartClientId = _useSelect.selectionStartClientId,
selectionBeforeEndClientId = _useSelect.selectionBeforeEndClientId,
selectionAfterEndClientId = _useSelect.selectionAfterEndClientId,
selectedFirstClientId = _useSelect.selectedFirstClientId,
selectedLastClientId = _useSelect.selectedLastClientId,
hasMultiSelection = _useSelect.hasMultiSelection,
firstBlock = _useSelect.firstBlock,
lastBlock = _useSelect.lastBlock,
isNavigationMode = _useSelect.isNavigationMode,
isSelectionEnabled = _useSelect.isSelectionEnabled,
blockSelectionStart = _useSelect.blockSelectionStart,
isMultiSelecting = _useSelect.isMultiSelecting,
keepCaretInsideBlock = _useSelect.keepCaretInsideBlock;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
multiSelect = _useDispatch.multiSelect,
selectBlock = _useDispatch.selectBlock,
setNavigationMode = _useDispatch.setNavigationMode;
function onMouseDown(event) {
verticalRect.current = null;
var ownerDocument = event.target.ownerDocument; // Clicking inside a selected block should exit navigation mode and block moving mode.
if (isNavigationMode && selectedBlockClientId && isInsideRootBlock(getBlockDOMNode(selectedBlockClientId, ownerDocument), event.target)) {
setNavigationMode(false);
} // Multi-select blocks when Shift+clicking.
if (isSelectionEnabled && // The main button.
// https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
event.button === 0) {
var clientId = getBlockClientId(event.target);
if (clientId) {
if (event.shiftKey) {
if (blockSelectionStart !== clientId) {
multiSelect(blockSelectionStart, clientId);
event.preventDefault();
} // Allow user to escape out of a multi-selection to a singular
// selection of a block via click. This is handled here since
// focus handling excludes blocks when there is multiselection,
// as focus can be incurred by starting a multiselection (focus
// moved to first block's multi-controls).
} else if (hasMultiSelection) {
selectBlock(clientId);
}
}
}
}
function expandSelection(isReverse) {
var nextSelectionEndClientId = isReverse ? selectionBeforeEndClientId : selectionAfterEndClientId;
if (nextSelectionEndClientId) {
multiSelect(selectionStartClientId || selectedBlockClientId, nextSelectionEndClientId);
}
}
function moveSelection(isReverse) {
var focusedBlockClientId = isReverse ? selectedFirstClientId : selectedLastClientId;
if (focusedBlockClientId) {
selectBlock(focusedBlockClientId);
}
}
/**
* Returns true if the given target field is the last in its block which
* can be considered for tab transition. For example, in a block with two
* text fields, this would return true when reversing from the first of the
* two fields, but false when reversing from the second.
*
* @param {Element} target Currently focused text field.
* @param {boolean} isReverse True if considering as the first field.
*
* @return {boolean} Whether field is at edge for tab transition.
*/
function isTabbableEdge(target, isReverse) {
var closestTabbable = getClosestTabbable(target, isReverse, container.current);
return !closestTabbable || !isInSameBlock(target, closestTabbable);
}
function onKeyDown(event) {
var keyCode = event.keyCode,
target = event.target; // Handle only if the event occurred within the same DOM hierarchy as
// the rendered container. This is used to distinguish between events
// which bubble through React's virtual event system from those which
// strictly occur in the DOM created by the component.
//
// The implication here is: If it's not desirable for a bubbled event to
// be considered by WritingFlow, it can be avoided by rendering to a
// distinct place in the DOM (e.g. using Slot/Fill).
if (!container.current.contains(target)) {
return;
}
var isUp = keyCode === external_wp_keycodes_["UP"];
var isDown = keyCode === external_wp_keycodes_["DOWN"];
var isLeft = keyCode === external_wp_keycodes_["LEFT"];
var isRight = keyCode === external_wp_keycodes_["RIGHT"];
var isTab = keyCode === external_wp_keycodes_["TAB"];
var isEscape = keyCode === external_wp_keycodes_["ESCAPE"];
var isReverse = isUp || isLeft;
var isHorizontal = isLeft || isRight;
var isVertical = isUp || isDown;
var isNav = isHorizontal || isVertical;
var isShift = event.shiftKey;
var hasModifier = isShift || event.ctrlKey || event.altKey || event.metaKey;
var isNavEdge = isVertical ? external_wp_dom_["isVerticalEdge"] : external_wp_dom_["isHorizontalEdge"];
var ownerDocument = container.current.ownerDocument;
var defaultView = ownerDocument.defaultView; // In Edit mode, Tab should focus the first tabbable element after the
// content, which is normally the sidebar (with block controls) and
// Shift+Tab should focus the first tabbable element before the content,
// which is normally the block toolbar.
// Arrow keys can be used, and Tab and arrow keys can be used in
// Navigation mode (press Esc), to navigate through blocks.
if (selectedBlockClientId) {
if (isTab) {
var wrapper = getBlockDOMNode(selectedBlockClientId, ownerDocument);
if (isShift) {
if (target === wrapper) {
// Disable focus capturing on the focus capture element, so
// it doesn't refocus this block and so it allows default
// behaviour (moving focus to the next tabbable element).
noCapture.current = true;
focusCaptureBeforeRef.current.focus();
return;
}
} else {
var tabbables = external_wp_dom_["focus"].tabbable.find(wrapper);
var lastTabbable = Object(external_lodash_["last"])(tabbables) || wrapper;
if (target === lastTabbable) {
// See comment above.
noCapture.current = true;
focusCaptureAfterRef.current.focus();
return;
}
}
} else if (isEscape) {
setNavigationMode(true);
}
} // When presing any key other than up or down, the initial vertical
// position must ALWAYS be reset. The vertical position is saved so it
// can be restored as well as possible on sebsequent vertical arrow key
// presses. It may not always be possible to restore the exact same
// position (such as at an empty line), so it wouldn't be good to
// compute the position right before any vertical arrow key press.
if (!isVertical) {
verticalRect.current = null;
} else if (!verticalRect.current) {
verticalRect.current = Object(external_wp_dom_["computeCaretRect"])(defaultView);
} // This logic inside this condition needs to be checked before
// the check for event.nativeEvent.defaultPrevented.
// The logic handles meta+a keypress and this event is default prevented
// by RichText.
if (!isNav) {
// Set immediately before the meta+a combination can be pressed.
if (external_wp_keycodes_["isKeyboardEvent"].primary(event)) {
entirelySelected.current = Object(external_wp_dom_["isEntirelySelected"])(target);
}
if (external_wp_keycodes_["isKeyboardEvent"].primary(event, 'a')) {
// When the target is contentEditable, selection will already
// have been set by the browser earlier in this call stack. We
// need check the previous result, otherwise all blocks will be
// selected right away.
if (target.isContentEditable ? entirelySelected.current : Object(external_wp_dom_["isEntirelySelected"])(target)) {
multiSelect(firstBlock, lastBlock);
event.preventDefault();
} // After pressing primary + A we can assume isEntirelySelected is true.
// Calling right away isEntirelySelected after primary + A may still return false on some browsers.
entirelySelected.current = true;
}
return;
} // Abort if navigation has already been handled (e.g. RichText inline
// boundaries).
if (event.nativeEvent.defaultPrevented) {
return;
} // Abort if our current target is not a candidate for navigation (e.g.
// preserve native input behaviors).
if (!isNavigationCandidate(target, keyCode, hasModifier)) {
return;
} // In the case of RTL scripts, right means previous and left means next,
// which is the exact reverse of LTR.
var _getComputedStyle = writing_flow_getComputedStyle(target),
direction = _getComputedStyle.direction;
var isReverseDir = direction === 'rtl' ? !isReverse : isReverse;
if (isShift) {
if ( // Ensure that there is a target block.
(isReverse && selectionBeforeEndClientId || !isReverse && selectionAfterEndClientId) && isTabbableEdge(target, isReverse) && isNavEdge(target, isReverse)) {
// Shift key is down, and there is multi selection or we're at
// the end of the current block.
expandSelection(isReverse);
event.preventDefault();
}
} else if (isVertical && Object(external_wp_dom_["isVerticalEdge"])(target, isReverse) && !keepCaretInsideBlock) {
var closestTabbable = getClosestTabbable(target, isReverse, container.current, true);
if (closestTabbable) {
Object(external_wp_dom_["placeCaretAtVerticalEdge"])(closestTabbable, isReverse, verticalRect.current);
event.preventDefault();
}
} else if (isHorizontal && defaultView.getSelection().isCollapsed && Object(external_wp_dom_["isHorizontalEdge"])(target, isReverseDir) && !keepCaretInsideBlock) {
var _closestTabbable = getClosestTabbable(target, isReverseDir, container.current);
Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(_closestTabbable, isReverseDir);
event.preventDefault();
}
}
function onMultiSelectKeyDown(event) {
var keyCode = event.keyCode,
shiftKey = event.shiftKey;
var isUp = keyCode === external_wp_keycodes_["UP"];
var isDown = keyCode === external_wp_keycodes_["DOWN"];
var isLeft = keyCode === external_wp_keycodes_["LEFT"];
var isRight = keyCode === external_wp_keycodes_["RIGHT"];
var isReverse = isUp || isLeft;
var isHorizontal = isLeft || isRight;
var isVertical = isUp || isDown;
var isNav = isHorizontal || isVertical;
if (keyCode === external_wp_keycodes_["TAB"]) {
// Disable focus capturing on the focus capture element, so it
// doesn't refocus this element and so it allows default behaviour
// (moving focus to the next tabbable element).
noCapture.current = true;
if (shiftKey) {
focusCaptureBeforeRef.current.focus();
} else {
focusCaptureAfterRef.current.focus();
}
} else if (isNav) {
var action = shiftKey ? expandSelection : moveSelection;
action(isReverse);
event.preventDefault();
}
}
Object(external_wp_element_["useEffect"])(function () {
if (hasMultiSelection && !isMultiSelecting) {
multiSelectionContainer.current.focus();
}
}, [hasMultiSelection, isMultiSelecting]);
var className = classnames_default()('block-editor-writing-flow', {
'is-navigate-mode': isNavigationMode
}); // Disable reason: Wrapper itself is non-interactive, but must capture
// bubbling events from children to determine focus transition intents.
/* eslint-disable jsx-a11y/no-static-element-interactions */
return Object(external_wp_element_["createElement"])(SelectionStart.Provider, {
value: onSelectionStart
}, Object(external_wp_element_["createElement"])(focus_capture, {
ref: focusCaptureBeforeRef,
selectedClientId: selectedBlockClientId,
containerRef: container,
noCapture: noCapture,
hasMultiSelection: hasMultiSelection,
multiSelectionContainer: multiSelectionContainer
}), Object(external_wp_element_["createElement"])("div", {
ref: multiSelectionContainer,
tabIndex: hasMultiSelection ? '0' : undefined,
"aria-label": hasMultiSelection ? Object(external_wp_i18n_["__"])('Multiple selected blocks') : undefined // Needs to be positioned within the viewport, so focus to this
// element does not scroll the page.
,
style: {
position: 'fixed'
},
onKeyDown: onMultiSelectKeyDown
}), Object(external_wp_element_["createElement"])("div", {
ref: container,
className: className,
onKeyDown: onKeyDown,
onMouseDown: onMouseDown
}, children), Object(external_wp_element_["createElement"])(focus_capture, {
ref: focusCaptureAfterRef,
selectedClientId: selectedBlockClientId,
containerRef: container,
noCapture: noCapture,
hasMultiSelection: hasMultiSelection,
multiSelectionContainer: multiSelectionContainer,
isReverse: true
}));
/* eslint-enable jsx-a11y/no-static-element-interactions */
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/use-event-handlers.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/**
* Adds block behaviour:
* - Selects the block if it receives focus.
* - Removes the block on BACKSPACE.
* - Inserts a default block on ENTER.
* - Initiates selection start for multi-selection.
* - Disables dragging of block contents.
*
* @param {RefObject} ref React ref with the block element.
* @param {string} clientId Block client ID.
*/
function useEventHandlers(ref, clientId) {
var onSelectionStart = Object(external_wp_element_["useContext"])(SelectionStart);
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
isBlockSelected = _select.isBlockSelected,
getBlockRootClientId = _select.getBlockRootClientId,
getBlockIndex = _select.getBlockIndex;
return {
isSelected: isBlockSelected(clientId),
rootClientId: getBlockRootClientId(clientId),
index: getBlockIndex(clientId)
};
}, [clientId]),
isSelected = _useSelect.isSelected,
rootClientId = _useSelect.rootClientId,
index = _useSelect.index;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
insertDefaultBlock = _useDispatch.insertDefaultBlock,
removeBlock = _useDispatch.removeBlock,
selectBlock = _useDispatch.selectBlock;
Object(external_wp_element_["useEffect"])(function () {
if (!isSelected) {
/**
* Marks the block as selected when focused and not already
* selected. This specifically handles the case where block does not
* set focus on its own (via `setFocus`), typically if there is no
* focusable input in the block.
*
* @param {FocusEvent} event Focus event.
*/
function onFocus(event) {
// If an inner block is focussed, that block is resposible for
// setting the selected block.
if (!isInsideRootBlock(ref.current, event.target)) {
return;
}
selectBlock(clientId);
}
ref.current.addEventListener('focusin', onFocus);
return function () {
ref.current.removeEventListener('focusin', onFocus);
};
}
/**
* Interprets keydown event intent to remove or insert after block if
* key event occurs on wrapper node. This can occur when the block has
* no text fields of its own, particularly after initial insertion, to
* allow for easy deletion and continuous writing flow to add additional
* content.
*
* @param {KeyboardEvent} event Keydown event.
*/
function onKeyDown(event) {
var keyCode = event.keyCode,
target = event.target;
if (keyCode !== external_wp_keycodes_["ENTER"] && keyCode !== external_wp_keycodes_["BACKSPACE"] && keyCode !== external_wp_keycodes_["DELETE"]) {
return;
}
if (target !== ref.current || Object(external_wp_dom_["isTextField"])(target)) {
return;
}
event.preventDefault();
if (keyCode === external_wp_keycodes_["ENTER"]) {
insertDefaultBlock({}, rootClientId, index + 1);
} else {
removeBlock(clientId);
}
}
function onMouseLeave(_ref) {
var buttons = _ref.buttons;
// The primary button must be pressed to initiate selection.
// See https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
if (buttons === 1) {
onSelectionStart(clientId);
}
}
/**
* Prevents default dragging behavior within a block. To do: we must
* handle this in the future and clean up the drag target.
*
* @param {DragEvent} event Drag event.
*/
function onDragStart(event) {
event.preventDefault();
}
ref.current.addEventListener('keydown', onKeyDown);
ref.current.addEventListener('mouseleave', onMouseLeave);
ref.current.addEventListener('dragstart', onDragStart);
return function () {
ref.current.removeEventListener('mouseleave', onMouseLeave);
ref.current.removeEventListener('keydown', onKeyDown);
ref.current.removeEventListener('dragstart', onDragStart);
};
}, [isSelected, rootClientId, index, onSelectionStart, insertDefaultBlock, removeBlock, selectBlock]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/use-block-props/index.js
function use_block_props_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function use_block_props_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_block_props_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_block_props_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* This hook is used to lightly mark an element as a block element. The element
* should be the outermost element of a block. Call this hook and pass the
* returned props to the element to mark as a block. If you define a ref for the
* element, it is important to pass the ref to this hook, which the hook in turn
* will pass to the component through the props it returns. Optionally, you can
* also pass any other props through this hook, and they will be merged and
* returned.
*
* @param {Object} props Optional. Props to pass to the element. Must contain
* the ref if one is defined.
* @param {Object} options Options for internal use only.
* @param {boolean} options.__unstableIsHtml
*
* @return {Object} Props to pass to the element to mark as a block.
*/
function useBlockProps() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
__unstableIsHtml = _ref.__unstableIsHtml;
var fallbackRef = Object(external_wp_element_["useRef"])();
var ref = props.ref || fallbackRef;
var setBlockNodes = Object(external_wp_element_["useContext"])(SetBlockNodes);
var _useContext = Object(external_wp_element_["useContext"])(BlockListBlockContext),
clientId = _useContext.clientId,
isSelected = _useContext.isSelected,
isFirstMultiSelected = _useContext.isFirstMultiSelected,
isLastMultiSelected = _useContext.isLastMultiSelected,
isPartOfMultiSelection = _useContext.isPartOfMultiSelection,
enableAnimation = _useContext.enableAnimation,
index = _useContext.index,
className = _useContext.className,
name = _useContext.name,
mode = _useContext.mode,
blockTitle = _useContext.blockTitle,
_useContext$wrapperPr = _useContext.wrapperProps,
wrapperProps = _useContext$wrapperPr === void 0 ? {} : _useContext$wrapperPr; // Provide the selected node, or the first and last nodes of a multi-
// selection, so it can be used to position the contextual block toolbar.
// We only provide what is necessary, and remove the nodes again when they
// are no longer selected.
Object(external_wp_element_["useEffect"])(function () {
if (isSelected || isFirstMultiSelected || isLastMultiSelected) {
var node = ref.current;
setBlockNodes(function (nodes) {
return use_block_props_objectSpread(use_block_props_objectSpread({}, nodes), {}, Object(defineProperty["a" /* default */])({}, clientId, node));
});
return function () {
setBlockNodes(function (nodes) {
return Object(external_lodash_["omit"])(nodes, clientId);
});
};
}
}, [isSelected, isFirstMultiSelected, isLastMultiSelected]); // Set new block node if it changes.
// This effect should happen on every render, so no dependencies should be
// added.
Object(external_wp_element_["useEffect"])(function () {
var node = ref.current;
setBlockNodes(function (nodes) {
if (!nodes[clientId] || nodes[clientId] === node) {
return nodes;
}
return use_block_props_objectSpread(use_block_props_objectSpread({}, nodes), {}, Object(defineProperty["a" /* default */])({}, clientId, node));
});
}); // translators: %s: Type of block (i.e. Text, Image etc)
var blockLabel = Object(external_wp_i18n_["sprintf"])(Object(external_wp_i18n_["__"])('Block: %s'), blockTitle);
useFocusFirstElement(ref, clientId);
useEventHandlers(ref, clientId); // Block Reordering animation
use_moving_animation(ref, isSelected || isPartOfMultiSelection, isSelected || isFirstMultiSelected, enableAnimation, index);
var isHovered = useIsHovered(ref);
var blockMovingModeClassNames = useBlockMovingModeClassNames(clientId);
var htmlSuffix = mode === 'html' && !__unstableIsHtml ? '-visual' : '';
return use_block_props_objectSpread(use_block_props_objectSpread(use_block_props_objectSpread({}, wrapperProps), props), {}, {
ref: ref,
id: "block-".concat(clientId).concat(htmlSuffix),
tabIndex: 0,
role: 'group',
'aria-label': blockLabel,
'data-block': clientId,
'data-type': name,
'data-title': blockTitle,
className: classnames_default()(className, props.className, wrapperProps.className, blockMovingModeClassNames, {
'is-hovered': isHovered
}),
style: use_block_props_objectSpread(use_block_props_objectSpread({}, wrapperProps.style), props.style)
});
}
/**
* Call within a save function to get the props for the block wrapper.
*
* @param {Object} props Optional. Props to pass to the element.
*/
useBlockProps.save = external_wp_blocks_["__unstableGetBlockProps"];
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block.js
function block_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var BlockListBlockContext = Object(external_wp_element_["createContext"])();
/**
* Merges wrapper props with special handling for classNames and styles.
*
* @param {Object} propsA
* @param {Object} propsB
*
* @return {Object} Merged props.
*/
function mergeWrapperProps(propsA, propsB) {
var newProps = block_objectSpread(block_objectSpread({}, propsA), propsB);
if (propsA && propsB && propsA.className && propsB.className) {
newProps.className = classnames_default()(propsA.className, propsB.className);
}
if (propsA && propsB && propsA.style && propsB.style) {
newProps.style = block_objectSpread(block_objectSpread({}, propsA.style), propsB.style);
}
return newProps;
}
function Block(_ref) {
var children = _ref.children,
isHtml = _ref.isHtml,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["children", "isHtml"]);
return Object(external_wp_element_["createElement"])("div", useBlockProps(props, {
__unstableIsHtml: isHtml
}), children);
}
function block_BlockListBlock(_ref2) {
var mode = _ref2.mode,
isLocked = _ref2.isLocked,
clientId = _ref2.clientId,
isSelected = _ref2.isSelected,
isMultiSelected = _ref2.isMultiSelected,
isPartOfMultiSelection = _ref2.isPartOfMultiSelection,
isFirstMultiSelected = _ref2.isFirstMultiSelected,
isLastMultiSelected = _ref2.isLastMultiSelected,
isTypingWithinBlock = _ref2.isTypingWithinBlock,
isAncestorOfSelectedBlock = _ref2.isAncestorOfSelectedBlock,
isSelectionEnabled = _ref2.isSelectionEnabled,
className = _ref2.className,
name = _ref2.name,
isValid = _ref2.isValid,
attributes = _ref2.attributes,
wrapperProps = _ref2.wrapperProps,
setAttributes = _ref2.setAttributes,
onReplace = _ref2.onReplace,
onInsertBlocksAfter = _ref2.onInsertBlocksAfter,
onMerge = _ref2.onMerge,
toggleSelection = _ref2.toggleSelection,
index = _ref2.index,
enableAnimation = _ref2.enableAnimation,
activeEntityBlockId = _ref2.activeEntityBlockId;
var isLargeViewport = Object(external_wp_compose_["useViewportMatch"])('medium'); // In addition to withSelect, we should favor using useSelect in this
// component going forward to avoid leaking new props to the public API
// (editor.BlockListBlock filter)
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
isBlockBeingDragged = _select.isBlockBeingDragged,
isBlockHighlighted = _select.isBlockHighlighted,
getSettings = _select.getSettings;
return {
isDragging: isBlockBeingDragged(clientId),
isHighlighted: isBlockHighlighted(clientId),
isFocusMode: getSettings().focusMode,
isOutlineMode: getSettings().outlineMode
};
}, [clientId]),
isDragging = _useSelect.isDragging,
isHighlighted = _useSelect.isHighlighted,
isFocusMode = _useSelect.isFocusMode,
isOutlineMode = _useSelect.isOutlineMode;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
removeBlock = _useDispatch.removeBlock;
var onRemove = Object(external_wp_element_["useCallback"])(function () {
return removeBlock(clientId);
}, [clientId]); // Handling the error state
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
hasError = _useState2[0],
setErrorState = _useState2[1];
var onBlockError = function onBlockError() {
return setErrorState(true);
};
var blockType = Object(external_wp_blocks_["getBlockType"])(name);
var lightBlockWrapper = blockType.apiVersion > 1 || Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'lightBlockWrapper', false);
var isUnregisteredBlock = name === Object(external_wp_blocks_["getUnregisteredTypeHandlerName"])(); // Determine whether the block has props to apply to the wrapper.
if (blockType.getEditWrapperProps) {
wrapperProps = mergeWrapperProps(wrapperProps, blockType.getEditWrapperProps(attributes));
}
var generatedClassName = lightBlockWrapper && Object(external_wp_blocks_["hasBlockSupport"])(blockType, 'className', true) ? Object(external_wp_blocks_["getBlockDefaultClassName"])(name) : null;
var customClassName = lightBlockWrapper ? attributes.className : null;
var isAligned = wrapperProps && !!wrapperProps['data-align']; // The wp-block className is important for editor styles.
// Generate the wrapper class names handling the different states of the
// block.
var wrapperClassName = classnames_default()(generatedClassName, customClassName, 'block-editor-block-list__block', {
'wp-block': !isAligned,
'has-warning': !isValid || !!hasError || isUnregisteredBlock,
'is-selected': isSelected && !isDragging,
'is-highlighted': isHighlighted,
'is-multi-selected': isMultiSelected,
'is-reusable': Object(external_wp_blocks_["isReusableBlock"])(blockType),
'is-dragging': isDragging,
'is-typing': isTypingWithinBlock,
'is-focused': isFocusMode && isLargeViewport && (isSelected || isAncestorOfSelectedBlock),
'is-focus-mode': isFocusMode && isLargeViewport,
'is-outline-mode': isOutlineMode,
'has-child-selected': isAncestorOfSelectedBlock && !isDragging,
'is-active-entity': activeEntityBlockId === clientId
}, className); // We wrap the BlockEdit component in a div that hides it when editing in
// HTML mode. This allows us to render all of the ancillary pieces
// (InspectorControls, etc.) which are inside `BlockEdit` but not
// `BlockHTML`, even in HTML mode.
var blockEdit = Object(external_wp_element_["createElement"])(block_edit_BlockEdit, {
name: name,
isSelected: isSelected,
attributes: attributes,
setAttributes: setAttributes,
insertBlocksAfter: isLocked ? undefined : onInsertBlocksAfter,
onReplace: isLocked ? undefined : onReplace,
onRemove: isLocked ? undefined : onRemove,
mergeBlocks: isLocked ? undefined : onMerge,
clientId: clientId,
isSelectionEnabled: isSelectionEnabled,
toggleSelection: toggleSelection
}); // For aligned blocks, provide a wrapper element so the block can be
// positioned relative to the block column.
if (isAligned) {
var alignmentWrapperProps = {
'data-align': wrapperProps['data-align']
};
blockEdit = Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
className: "wp-block"
}, alignmentWrapperProps), blockEdit);
}
var value = {
clientId: clientId,
isSelected: isSelected,
isFirstMultiSelected: isFirstMultiSelected,
isLastMultiSelected: isLastMultiSelected,
isPartOfMultiSelection: isPartOfMultiSelection,
enableAnimation: enableAnimation,
index: index,
className: wrapperClassName,
isLocked: isLocked,
name: name,
mode: mode,
blockTitle: blockType.title,
wrapperProps: Object(external_lodash_["omit"])(wrapperProps, ['data-align'])
};
var memoizedValue = Object(external_wp_element_["useMemo"])(function () {
return value;
}, Object.values(value));
var block;
if (!isValid) {
block = Object(external_wp_element_["createElement"])(Block, null, Object(external_wp_element_["createElement"])(block_invalid_warning, {
clientId: clientId
}), Object(external_wp_element_["createElement"])("div", null, Object(external_wp_blocks_["getSaveElement"])(blockType, attributes)));
} else if (mode === 'html') {
// Render blockEdit so the inspector controls don't disappear.
// See #8969.
block = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
style: {
display: 'none'
}
}, blockEdit), Object(external_wp_element_["createElement"])(Block, {
isHtml: true
}, Object(external_wp_element_["createElement"])(block_html, {
clientId: clientId
})));
} else if (lightBlockWrapper) {
block = blockEdit;
} else {
block = Object(external_wp_element_["createElement"])(Block, wrapperProps, blockEdit);
}
return Object(external_wp_element_["createElement"])(BlockListBlockContext.Provider, {
value: memoizedValue
}, Object(external_wp_element_["createElement"])(block_crash_boundary, {
onError: onBlockError
}, block), !!hasError && Object(external_wp_element_["createElement"])(Block, null, Object(external_wp_element_["createElement"])(block_crash_warning, null)));
}
var applyWithSelect = Object(external_wp_data_["withSelect"])(function (select, _ref3) {
var clientId = _ref3.clientId,
rootClientId = _ref3.rootClientId;
var _select2 = select('core/block-editor'),
isBlockSelected = _select2.isBlockSelected,
isAncestorMultiSelected = _select2.isAncestorMultiSelected,
isBlockMultiSelected = _select2.isBlockMultiSelected,
isFirstMultiSelectedBlock = _select2.isFirstMultiSelectedBlock,
getLastMultiSelectedBlockClientId = _select2.getLastMultiSelectedBlockClientId,
isTyping = _select2.isTyping,
getBlockMode = _select2.getBlockMode,
isSelectionEnabled = _select2.isSelectionEnabled,
hasSelectedInnerBlock = _select2.hasSelectedInnerBlock,
getTemplateLock = _select2.getTemplateLock,
__unstableGetBlockWithoutInnerBlocks = _select2.__unstableGetBlockWithoutInnerBlocks,
getMultiSelectedBlockClientIds = _select2.getMultiSelectedBlockClientIds;
var block = __unstableGetBlockWithoutInnerBlocks(clientId);
var isSelected = isBlockSelected(clientId);
var templateLock = getTemplateLock(rootClientId);
var checkDeep = true; // "ancestor" is the more appropriate label due to "deep" check
var isAncestorOfSelectedBlock = hasSelectedInnerBlock(clientId, checkDeep); // The fallback to `{}` is a temporary fix.
// This function should never be called when a block is not present in
// the state. It happens now because the order in withSelect rendering
// is not correct.
var _ref4 = block || {},
name = _ref4.name,
attributes = _ref4.attributes,
isValid = _ref4.isValid;
var isFirstMultiSelected = isFirstMultiSelectedBlock(clientId); // Do not add new properties here, use `useSelect` instead to avoid
// leaking new props to the public API (editor.BlockListBlock filter).
return {
isMultiSelected: isBlockMultiSelected(clientId),
isPartOfMultiSelection: isBlockMultiSelected(clientId) || isAncestorMultiSelected(clientId),
isFirstMultiSelected: isFirstMultiSelected,
isLastMultiSelected: getLastMultiSelectedBlockClientId() === clientId,
multiSelectedClientIds: isFirstMultiSelected ? getMultiSelectedBlockClientIds() : undefined,
// We only care about this prop when the block is selected
// Thus to avoid unnecessary rerenders we avoid updating the prop if
// the block is not selected.
isTypingWithinBlock: (isSelected || isAncestorOfSelectedBlock) && isTyping(),
mode: getBlockMode(clientId),
isSelectionEnabled: isSelectionEnabled(),
isLocked: !!templateLock,
// Users of the editor.BlockListBlock filter used to be able to
// access the block prop.
// Ideally these blocks would rely on the clientId prop only.
// This is kept for backward compatibility reasons.
block: block,
name: name,
attributes: attributes,
isValid: isValid,
isSelected: isSelected,
isAncestorOfSelectedBlock: isAncestorOfSelectedBlock
};
});
var applyWithDispatch = Object(external_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref5) {
var select = _ref5.select;
var _dispatch = dispatch('core/block-editor'),
updateBlockAttributes = _dispatch.updateBlockAttributes,
insertBlocks = _dispatch.insertBlocks,
mergeBlocks = _dispatch.mergeBlocks,
replaceBlocks = _dispatch.replaceBlocks,
_toggleSelection = _dispatch.toggleSelection,
__unstableMarkLastChangeAsPersistent = _dispatch.__unstableMarkLastChangeAsPersistent; // Do not add new properties here, use `useDispatch` instead to avoid
// leaking new props to the public API (editor.BlockListBlock filter).
return {
setAttributes: function setAttributes(newAttributes) {
var clientId = ownProps.clientId,
isFirstMultiSelected = ownProps.isFirstMultiSelected,
multiSelectedClientIds = ownProps.multiSelectedClientIds;
var clientIds = isFirstMultiSelected ? multiSelectedClientIds : [clientId];
updateBlockAttributes(clientIds, newAttributes);
},
onInsertBlocks: function onInsertBlocks(blocks, index) {
var rootClientId = ownProps.rootClientId;
insertBlocks(blocks, index, rootClientId);
},
onInsertBlocksAfter: function onInsertBlocksAfter(blocks) {
var clientId = ownProps.clientId,
rootClientId = ownProps.rootClientId;
var _select3 = select('core/block-editor'),
getBlockIndex = _select3.getBlockIndex;
var index = getBlockIndex(clientId, rootClientId);
insertBlocks(blocks, index + 1, rootClientId);
},
onMerge: function onMerge(forward) {
var clientId = ownProps.clientId;
var _select4 = select('core/block-editor'),
getPreviousBlockClientId = _select4.getPreviousBlockClientId,
getNextBlockClientId = _select4.getNextBlockClientId;
if (forward) {
var nextBlockClientId = getNextBlockClientId(clientId);
if (nextBlockClientId) {
mergeBlocks(clientId, nextBlockClientId);
}
} else {
var previousBlockClientId = getPreviousBlockClientId(clientId);
if (previousBlockClientId) {
mergeBlocks(previousBlockClientId, clientId);
}
}
},
onReplace: function onReplace(blocks, indexToSelect, initialPosition) {
if (blocks.length && !Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(blocks[blocks.length - 1])) {
__unstableMarkLastChangeAsPersistent();
}
replaceBlocks([ownProps.clientId], blocks, indexToSelect, initialPosition);
},
toggleSelection: function toggleSelection(selectionEnabled) {
_toggleSelection(selectionEnabled);
}
};
});
/* harmony default export */ var block_list_block = (Object(external_wp_compose_["compose"])(external_wp_compose_["pure"], applyWithSelect, applyWithDispatch, // block is sometimes not mounted at the right time, causing it be undefined
// see issue for more info
// https://github.com/WordPress/gutenberg/issues/17013
Object(external_wp_compose_["ifCondition"])(function (_ref6) {
var block = _ref6.block;
return !!block;
}), Object(external_wp_components_["withFilters"])('editor.BlockListBlock'))(block_BlockListBlock));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/indentation.js
/**
* External dependencies
*/
var lineClassName = 'block-editor-block-navigator-indentation';
function Indentation(_ref) {
var level = _ref.level;
return Object(external_lodash_["times"])(level - 1, function (index) {
// The first 'level' that has an indentation is level 2.
// Add 2 to the zero-based index below to reflect that.
var currentLevel = index + 2;
var hasItem = currentLevel === level;
return Object(external_wp_element_["createElement"])("div", {
key: index,
"aria-hidden": "true",
className: classnames_default()(lineClassName, {
'has-item': hasItem
})
});
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/utils.js
/**
* WordPress dependencies
*/
var utils_getBlockPositionDescription = function getBlockPositionDescription(position, siblingCount, level) {
return Object(external_wp_i18n_["sprintf"])(
/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */
Object(external_wp_i18n_["__"])('Block %1$d of %2$d, Level %3$d'), position, siblingCount, level);
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-select-button.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigationBlockSelectButton(_ref, ref) {
var className = _ref.className,
clientId = _ref.block.clientId,
isSelected = _ref.isSelected,
onClick = _ref.onClick,
position = _ref.position,
siblingBlockCount = _ref.siblingBlockCount,
level = _ref.level,
tabIndex = _ref.tabIndex,
onFocus = _ref.onFocus,
onDragStart = _ref.onDragStart,
onDragEnd = _ref.onDragEnd,
draggable = _ref.draggable;
var blockInformation = useBlockDisplayInformation(clientId);
var instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationBlockSelectButton);
var descriptionId = "block-navigation-block-select-button__".concat(instanceId);
var blockPositionDescription = utils_getBlockPositionDescription(position, siblingBlockCount, level);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: classnames_default()('block-editor-block-navigation-block-select-button', className),
onClick: onClick,
"aria-describedby": descriptionId,
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus,
onDragStart: onDragStart,
onDragEnd: onDragEnd,
draggable: draggable
}, Object(external_wp_element_["createElement"])(Indentation, {
level: level
}), Object(external_wp_element_["createElement"])(BlockIcon, {
icon: blockInformation === null || blockInformation === void 0 ? void 0 : blockInformation.icon,
showColors: true
}), Object(external_wp_element_["createElement"])(BlockTitle, {
clientId: clientId
}), isSelected && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('(selected block)'))), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation-block-select-button__description",
id: descriptionId
}, blockPositionDescription));
}
/* harmony default export */ var block_select_button = (Object(external_wp_element_["forwardRef"])(BlockNavigationBlockSelectButton));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-slot.js
function block_slot_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_slot_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_slot_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_slot_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var getSlotName = function getSlotName(clientId) {
return "BlockNavigationBlock-".concat(clientId);
};
function BlockNavigationBlockSlot(props, ref) {
var instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationBlockSlot);
var clientId = props.block.clientId;
return Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
name: getSlotName(clientId)
}, function (fills) {
if (!fills.length) {
return Object(external_wp_element_["createElement"])(block_select_button, Object(esm_extends["a" /* default */])({
ref: ref
}, props));
}
var className = props.className,
block = props.block,
isSelected = props.isSelected,
position = props.position,
siblingBlockCount = props.siblingBlockCount,
level = props.level,
tabIndex = props.tabIndex,
onFocus = props.onFocus;
var name = block.name;
var blockType = Object(external_wp_blocks_["getBlockType"])(name);
var descriptionId = "block-navigation-block-slot__".concat(instanceId);
var blockPositionDescription = utils_getBlockPositionDescription(position, siblingBlockCount, level);
var forwardedFillProps = {
// Ensure that the component in the slot can receive
// keyboard navigation.
tabIndex: tabIndex,
onFocus: onFocus,
ref: ref,
// Give the element rendered in the slot a description
// that describes its position.
'aria-describedby': descriptionId
};
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-block-navigation-block-slot', className)
}, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: blockType.icon,
showColors: true
}), external_wp_element_["Children"].map(fills, function (fill) {
return Object(external_wp_element_["cloneElement"])(fill, block_slot_objectSpread(block_slot_objectSpread({}, fill.props), forwardedFillProps));
}), isSelected && Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], null, Object(external_wp_i18n_["__"])('(selected block)')), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation-block-slot__description",
id: descriptionId
}, blockPositionDescription)));
});
}
/* harmony default export */ var block_slot = (Object(external_wp_element_["forwardRef"])(BlockNavigationBlockSlot));
var block_slot_BlockNavigationBlockFill = function BlockNavigationBlockFill(props) {
var _useContext = Object(external_wp_element_["useContext"])(BlockListBlockContext),
clientId = _useContext.clientId;
return Object(external_wp_element_["createElement"])(external_wp_components_["Fill"], Object(esm_extends["a" /* default */])({}, props, {
name: getSlotName(clientId)
}));
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block-contents.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var BlockNavigationBlockContents = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var onClick = _ref.onClick,
block = _ref.block,
isSelected = _ref.isSelected,
position = _ref.position,
siblingBlockCount = _ref.siblingBlockCount,
level = _ref.level,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["onClick", "block", "isSelected", "position", "siblingBlockCount", "level"]);
var _useBlockNavigationCo = context_useBlockNavigationContext(),
__experimentalFeatures = _useBlockNavigationCo.__experimentalFeatures,
_useBlockNavigationCo2 = _useBlockNavigationCo.blockDropTarget,
blockDropTarget = _useBlockNavigationCo2 === void 0 ? {} : _useBlockNavigationCo2;
var clientId = block.clientId;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockRootClientId = _select.getBlockRootClientId,
hasBlockMovingClientId = _select.hasBlockMovingClientId,
getSelectedBlockClientId = _select.getSelectedBlockClientId;
return {
rootClientId: getBlockRootClientId(clientId) || '',
blockMovingClientId: hasBlockMovingClientId(),
selectedBlockInBlockEditor: getSelectedBlockClientId()
};
}, [clientId]),
rootClientId = _useSelect.rootClientId,
blockMovingClientId = _useSelect.blockMovingClientId,
selectedBlockInBlockEditor = _useSelect.selectedBlockInBlockEditor;
var isBlockMoveTarget = blockMovingClientId && selectedBlockInBlockEditor === clientId;
var dropTargetRootClientId = blockDropTarget.rootClientId,
dropTargetClientId = blockDropTarget.clientId,
dropPosition = blockDropTarget.dropPosition;
var isDroppingBefore = dropTargetRootClientId === rootClientId && dropTargetClientId === clientId && dropPosition === 'top';
var isDroppingAfter = dropTargetRootClientId === rootClientId && dropTargetClientId === clientId && dropPosition === 'bottom';
var isDroppingToInnerBlocks = dropTargetRootClientId === clientId && dropPosition === 'inside';
var className = classnames_default()('block-editor-block-navigation-block-contents', {
'is-dropping-before': isDroppingBefore || isBlockMoveTarget,
'is-dropping-after': isDroppingAfter,
'is-dropping-to-inner-blocks': isDroppingToInnerBlocks
});
return Object(external_wp_element_["createElement"])(block_draggable, {
clientIds: [block.clientId],
elementId: "block-navigation-block-".concat(block.clientId)
}, function (_ref2) {
var draggable = _ref2.draggable,
onDragStart = _ref2.onDragStart,
onDragEnd = _ref2.onDragEnd;
return __experimentalFeatures ? Object(external_wp_element_["createElement"])(block_slot, Object(esm_extends["a" /* default */])({
ref: ref,
className: className,
block: block,
onClick: onClick,
isSelected: isSelected,
position: position,
siblingBlockCount: siblingBlockCount,
level: level,
draggable: draggable && __experimentalFeatures,
onDragStart: onDragStart,
onDragEnd: onDragEnd
}, props)) : Object(external_wp_element_["createElement"])(block_select_button, Object(esm_extends["a" /* default */])({
ref: ref,
className: className,
block: block,
onClick: onClick,
isSelected: isSelected,
position: position,
siblingBlockCount: siblingBlockCount,
level: level,
draggable: draggable && __experimentalFeatures,
onDragStart: onDragStart,
onDragEnd: onDragEnd
}, props));
});
});
/* harmony default export */ var block_contents = (BlockNavigationBlockContents);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/block.js
function block_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = block_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function block_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return block_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return block_arrayLikeToArray(o, minLen); }
function block_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigationBlock(_ref) {
var block = _ref.block,
isSelected = _ref.isSelected,
_onClick = _ref.onClick,
position = _ref.position,
level = _ref.level,
rowCount = _ref.rowCount,
siblingBlockCount = _ref.siblingBlockCount,
showBlockMovers = _ref.showBlockMovers,
path = _ref.path;
var cellRef = Object(external_wp_element_["useRef"])(null);
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isHovered = _useState2[0],
setIsHovered = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isFocused = _useState4[0],
setIsFocused = _useState4[1];
var clientId = block.clientId;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
isBlockBeingDragged = _select.isBlockBeingDragged,
isAncestorBeingDragged = _select.isAncestorBeingDragged,
getBlockParents = _select.getBlockParents;
return {
isDragging: isBlockBeingDragged(clientId) || isAncestorBeingDragged(clientId),
blockParents: getBlockParents(clientId)
};
}, [clientId]),
isDragging = _useSelect.isDragging,
blockParents = _useSelect.blockParents;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
selectEditorBlock = _useDispatch.selectBlock;
var hasSiblings = siblingBlockCount > 0;
var hasRenderedMovers = showBlockMovers && hasSiblings;
var hasVisibleMovers = isHovered || isFocused;
var moverCellClassName = classnames_default()('block-editor-block-navigation-block__mover-cell', {
'is-visible': hasVisibleMovers
});
var _useBlockNavigationCo = context_useBlockNavigationContext(),
withExperimentalFeatures = _useBlockNavigationCo.__experimentalFeatures;
var blockNavigationBlockSettingsClassName = classnames_default()('block-editor-block-navigation-block__menu-cell', {
'is-visible': hasVisibleMovers
});
Object(external_wp_element_["useEffect"])(function () {
if (withExperimentalFeatures && isSelected) {
cellRef.current.focus();
}
}, [withExperimentalFeatures, isSelected]);
return Object(external_wp_element_["createElement"])(BlockNavigationLeaf, {
className: classnames_default()({
'is-selected': isSelected,
'is-dragging': isDragging
}),
onMouseEnter: function onMouseEnter() {
return setIsHovered(true);
},
onMouseLeave: function onMouseLeave() {
return setIsHovered(false);
},
onFocus: function onFocus() {
return setIsFocused(true);
},
onBlur: function onBlur() {
return setIsFocused(false);
},
level: level,
position: position,
rowCount: rowCount,
path: path,
id: "block-navigation-block-".concat(clientId),
"data-block": clientId
}, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
className: "block-editor-block-navigation-block__contents-cell",
colSpan: hasRenderedMovers ? undefined : 2,
ref: cellRef
}, function (_ref2) {
var ref = _ref2.ref,
tabIndex = _ref2.tabIndex,
onFocus = _ref2.onFocus;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation-block__contents-container"
}, Object(external_wp_element_["createElement"])(block_contents, {
block: block,
onClick: function onClick() {
return _onClick(block.clientId);
},
isSelected: isSelected,
position: position,
siblingBlockCount: siblingBlockCount,
level: level,
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus
}));
}), hasRenderedMovers && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
className: moverCellClassName,
withoutGridItem: true
}, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridItem"], null, function (_ref3) {
var ref = _ref3.ref,
tabIndex = _ref3.tabIndex,
onFocus = _ref3.onFocus;
return Object(external_wp_element_["createElement"])(BlockMoverUpButton, {
orientation: "vertical",
clientIds: [clientId],
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus
});
}), Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridItem"], null, function (_ref4) {
var ref = _ref4.ref,
tabIndex = _ref4.tabIndex,
onFocus = _ref4.onFocus;
return Object(external_wp_element_["createElement"])(BlockMoverDownButton, {
orientation: "vertical",
clientIds: [clientId],
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus
});
}))), withExperimentalFeatures && Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
className: blockNavigationBlockSettingsClassName
}, function (_ref5) {
var ref = _ref5.ref,
tabIndex = _ref5.tabIndex,
onFocus = _ref5.onFocus;
return Object(external_wp_element_["createElement"])(block_settings_dropdown, {
clientIds: [clientId],
icon: more_vertical["a" /* default */],
toggleProps: {
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus
},
disableOpenOnArrowDown: true,
__experimentalSelectBlock: _onClick
}, function (_ref6) {
var onClose = _ref6.onClose;
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
onClick: /*#__PURE__*/Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee() {
var _iterator, _step, parent;
return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (!blockParents.length) {
_context.next = 20;
break;
}
// If the block to select is inside a dropdown, we need to open the dropdown.
// Otherwise focus won't transfer to the block.
_iterator = block_createForOfIteratorHelper(blockParents);
_context.prev = 2;
_iterator.s();
case 4:
if ((_step = _iterator.n()).done) {
_context.next = 10;
break;
}
parent = _step.value;
_context.next = 8;
return selectEditorBlock(parent);
case 8:
_context.next = 4;
break;
case 10:
_context.next = 15;
break;
case 12:
_context.prev = 12;
_context.t0 = _context["catch"](2);
_iterator.e(_context.t0);
case 15:
_context.prev = 15;
_iterator.f();
return _context.finish(15);
case 18:
_context.next = 22;
break;
case 20:
_context.next = 22;
return selectEditorBlock(null);
case 22:
_context.next = 24;
return selectEditorBlock(clientId);
case 24:
onClose();
case 25:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 12, 15, 18]]);
}))
}, Object(external_wp_i18n_["__"])('Go to block')));
});
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/appender.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigationAppender(_ref) {
var parentBlockClientId = _ref.parentBlockClientId,
position = _ref.position,
level = _ref.level,
rowCount = _ref.rowCount,
path = _ref.path;
var isDragging = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
isBlockBeingDragged = _select.isBlockBeingDragged,
isAncestorBeingDragged = _select.isAncestorBeingDragged;
return isBlockBeingDragged(parentBlockClientId) || isAncestorBeingDragged(parentBlockClientId);
}, [parentBlockClientId]);
var instanceId = Object(external_wp_compose_["useInstanceId"])(BlockNavigationAppender);
var descriptionId = "block-navigation-appender-row__description_".concat(instanceId);
var appenderPositionDescription = Object(external_wp_i18n_["sprintf"])(
/* translators: 1: The numerical position of the block that will be inserted. 2: The level of nesting for the block that will be inserted. */
Object(external_wp_i18n_["__"])('Add block at position %1$d, Level %2$d'), position, level);
return Object(external_wp_element_["createElement"])(BlockNavigationLeaf, {
className: classnames_default()({
'is-dragging': isDragging
}),
level: level,
position: position,
rowCount: rowCount,
path: path
}, Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGridCell"], {
className: "block-editor-block-navigation-appender__cell",
colSpan: "3"
}, function (_ref2) {
var ref = _ref2.ref,
tabIndex = _ref2.tabIndex,
onFocus = _ref2.onFocus;
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation-appender__container"
}, Object(external_wp_element_["createElement"])(Indentation, {
level: level
}), Object(external_wp_element_["createElement"])(inserter, {
rootClientId: parentBlockClientId,
__experimentalIsQuick: true,
__experimentalSelectBlockOnInsert: false,
"aria-describedby": descriptionId,
toggleProps: {
ref: ref,
tabIndex: tabIndex,
onFocus: onFocus
}
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation-appender__description",
id: descriptionId
}, appenderPositionDescription));
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/branch.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigationBranch(props) {
var blocks = props.blocks,
selectBlock = props.selectBlock,
selectedBlockClientId = props.selectedBlockClientId,
showAppender = props.showAppender,
showBlockMovers = props.showBlockMovers,
showNestedBlocks = props.showNestedBlocks,
parentBlockClientId = props.parentBlockClientId,
_props$level = props.level,
level = _props$level === void 0 ? 1 : _props$level,
_props$terminatedLeve = props.terminatedLevels,
terminatedLevels = _props$terminatedLeve === void 0 ? [] : _props$terminatedLeve,
_props$path = props.path,
path = _props$path === void 0 ? [] : _props$path;
var isTreeRoot = !parentBlockClientId;
var filteredBlocks = Object(external_lodash_["compact"])(blocks);
var itemHasAppender = function itemHasAppender(parentClientId) {
return showAppender && !isTreeRoot && selectedBlockClientId === parentClientId;
};
var hasAppender = itemHasAppender(parentBlockClientId); // Add +1 to the rowCount to take the block appender into account.
var blockCount = filteredBlocks.length;
var rowCount = hasAppender ? blockCount + 1 : blockCount;
var appenderPosition = rowCount;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_lodash_["map"])(filteredBlocks, function (block, index) {
var clientId = block.clientId,
innerBlocks = block.innerBlocks;
var position = index + 1;
var isLastRowAtLevel = rowCount === position;
var updatedTerminatedLevels = isLastRowAtLevel ? [].concat(Object(toConsumableArray["a" /* default */])(terminatedLevels), [level]) : terminatedLevels;
var updatedPath = [].concat(Object(toConsumableArray["a" /* default */])(path), [position]);
var hasNestedBlocks = showNestedBlocks && !!innerBlocks && !!innerBlocks.length;
var hasNestedAppender = itemHasAppender(clientId);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], {
key: clientId
}, Object(external_wp_element_["createElement"])(BlockNavigationBlock, {
block: block,
onClick: selectBlock,
isSelected: selectedBlockClientId === clientId,
level: level,
position: position,
rowCount: rowCount,
siblingBlockCount: blockCount,
showBlockMovers: showBlockMovers,
terminatedLevels: terminatedLevels,
path: updatedPath
}), (hasNestedBlocks || hasNestedAppender) && Object(external_wp_element_["createElement"])(BlockNavigationBranch, {
blocks: innerBlocks,
selectedBlockClientId: selectedBlockClientId,
selectBlock: selectBlock,
showAppender: showAppender,
showBlockMovers: showBlockMovers,
showNestedBlocks: showNestedBlocks,
parentBlockClientId: clientId,
level: level + 1,
terminatedLevels: updatedTerminatedLevels,
path: updatedPath
}));
}), hasAppender && Object(external_wp_element_["createElement"])(BlockNavigationAppender, {
parentBlockClientId: parentBlockClientId,
position: rowCount,
rowCount: appenderPosition,
level: level,
terminatedLevels: terminatedLevels,
path: [].concat(Object(toConsumableArray["a" /* default */])(path), [appenderPosition])
}));
}
BlockNavigationBranch.defaultProps = {
selectBlock: function selectBlock() {}
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/use-block-navigation-drop-zone.js
function use_block_navigation_drop_zone_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function use_block_navigation_drop_zone_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_block_navigation_drop_zone_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_block_navigation_drop_zone_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function use_block_navigation_drop_zone_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = use_block_navigation_drop_zone_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function use_block_navigation_drop_zone_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return use_block_navigation_drop_zone_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return use_block_navigation_drop_zone_arrayLikeToArray(o, minLen); }
function use_block_navigation_drop_zone_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/** @typedef {import('../../utils/math').WPPoint} WPPoint */
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/**
* The type of a drag event.
*
* @typedef {'default'|'file'|'html'} WPDragEventType
*/
/**
* An array representing data for blocks in the DOM used by drag and drop.
*
* @typedef {Object} WPBlockNavigationDropZoneBlocks
* @property {string} clientId The client id for the block.
* @property {string} rootClientId The root client id for the block.
* @property {number} blockIndex The block's index.
* @property {Element} element The DOM element representing the block.
* @property {number} innerBlockCount The number of inner blocks the block has.
* @property {boolean} isDraggedBlock Whether the block is currently being dragged.
* @property {boolean} canInsertDraggedBlocksAsSibling Whether the dragged block can be a sibling of this block.
* @property {boolean} canInsertDraggedBlocksAsChild Whether the dragged block can be a child of this block.
*/
/**
* An object containing details of a drop target.
*
* @typedef {Object} WPBlockNavigationDropZoneTarget
* @property {string} blockIndex The insertion index.
* @property {string} rootClientId The root client id for the block.
* @property {string|undefined} clientId The client id for the block.
* @property {'top'|'bottom'|'inside'} dropPosition The position relative to the block that the user is dropping to.
* 'inside' refers to nesting as an inner block.
*/
/**
* A react hook that returns data about blocks used for computing where a user
* can drop to when dragging and dropping blocks.
*
* @param {Object} ref A React ref of a containing element for block navigation.
* @param {WPPoint} position The current drag position.
* @param {WPDragEventType} dragEventType The drag event type.
*
* @return {RefObject} A React ref containing the blocks data.
*/
function useDropTargetBlocksData(ref, position, dragEventType) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var selectors = select('core/block-editor');
return {
canInsertBlocks: selectors.canInsertBlocks,
getBlockRootClientId: selectors.getBlockRootClientId,
getBlockIndex: selectors.getBlockIndex,
getBlockCount: selectors.getBlockCount,
getDraggedBlockClientIds: selectors.getDraggedBlockClientIds
};
}, []),
getBlockRootClientId = _useSelect.getBlockRootClientId,
getBlockIndex = _useSelect.getBlockIndex,
getBlockCount = _useSelect.getBlockCount,
getDraggedBlockClientIds = _useSelect.getDraggedBlockClientIds,
canInsertBlocks = _useSelect.canInsertBlocks;
var blocksData = Object(external_wp_element_["useRef"])(); // Compute data about blocks only when the user
// starts dragging, as determined by `hasPosition`.
var hasPosition = !!position;
Object(external_wp_element_["useEffect"])(function () {
if (!ref.current || !hasPosition) {
return;
}
var isBlockDrag = dragEventType === 'default';
var draggedBlockClientIds = isBlockDrag ? getDraggedBlockClientIds() : undefined;
var blockElements = Array.from(ref.current.querySelectorAll('[data-block]'));
blocksData.current = blockElements.map(function (blockElement) {
var clientId = blockElement.dataset.block;
var rootClientId = getBlockRootClientId(clientId);
return {
clientId: clientId,
rootClientId: rootClientId,
blockIndex: getBlockIndex(clientId, rootClientId),
element: blockElement,
isDraggedBlock: isBlockDrag ? draggedBlockClientIds.includes(clientId) : false,
innerBlockCount: getBlockCount(clientId),
canInsertDraggedBlocksAsSibling: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, rootClientId) : true,
canInsertDraggedBlocksAsChild: isBlockDrag ? canInsertBlocks(draggedBlockClientIds, clientId) : true
};
});
}, [// `ref` shouldn't actually change during a drag operation, but
// is specified for completeness as it's used within the hook.
ref, hasPosition, dragEventType, canInsertBlocks, getBlockCount, getBlockIndex, getBlockRootClientId, getDraggedBlockClientIds]);
return blocksData;
}
/**
* Is the point contained by the rectangle.
*
* @param {WPPoint} point The point.
* @param {DOMRect} rect The rectangle.
*
* @return {boolean} True if the point is contained by the rectangle, false otherwise.
*/
function isPointContainedByRect(point, rect) {
return rect.left <= point.x && rect.right >= point.x && rect.top <= point.y && rect.bottom >= point.y;
}
/**
* Determines whether the user positioning the dragged block to nest as an
* inner block.
*
* Presently this is determined by whether the cursor is on the right hand side
* of the block.
*
* @param {WPPoint} point The point representing the cursor position when dragging.
* @param {DOMRect} rect The rectangle.
*/
function isNestingGesture(point, rect) {
var blockCenterX = rect.left + rect.width / 2;
return point.x > blockCenterX;
} // Block navigation is always a vertical list, so only allow dropping
// to the above or below a block.
var ALLOWED_DROP_EDGES = ['top', 'bottom'];
/**
* Given blocks data and the cursor position, compute the drop target.
*
* @param {WPBlockNavigationDropZoneBlocks} blocksData Data about the blocks in block navigation.
* @param {WPPoint} position The point representing the cursor position when dragging.
*
* @return {WPBlockNavigationDropZoneTarget} An object containing data about the drop target.
*/
function getBlockNavigationDropTarget(blocksData, position) {
var candidateEdge;
var candidateBlockData;
var candidateDistance;
var candidateRect;
var _iterator = use_block_navigation_drop_zone_createForOfIteratorHelper(blocksData),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var blockData = _step.value;
if (blockData.isDraggedBlock) {
continue;
}
var rect = blockData.element.getBoundingClientRect();
var _getDistanceToNearest = getDistanceToNearestEdge(position, rect, ALLOWED_DROP_EDGES),
_getDistanceToNearest2 = Object(slicedToArray["a" /* default */])(_getDistanceToNearest, 2),
distance = _getDistanceToNearest2[0],
edge = _getDistanceToNearest2[1];
var isCursorWithinBlock = isPointContainedByRect(position, rect);
if (candidateDistance === undefined || distance < candidateDistance || isCursorWithinBlock) {
candidateDistance = distance;
var index = blocksData.indexOf(blockData);
var previousBlockData = blocksData[index - 1]; // If dragging near the top of a block and the preceding block
// is at the same level, use the preceding block as the candidate
// instead, as later it makes determining a nesting drop easier.
if (edge === 'top' && previousBlockData && previousBlockData.rootClientId === blockData.rootClientId && !previousBlockData.isDraggedBlock) {
candidateBlockData = previousBlockData;
candidateEdge = 'bottom';
candidateRect = previousBlockData.element.getBoundingClientRect();
} else {
candidateBlockData = blockData;
candidateEdge = edge;
candidateRect = rect;
} // If the mouse position is within the block, break early
// as the user would intend to drop either before or after
// this block.
//
// This solves an issue where some rows in the block navigation
// tree overlap slightly due to sub-pixel rendering.
if (isCursorWithinBlock) {
break;
}
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
if (!candidateBlockData) {
return;
}
var isDraggingBelow = candidateEdge === 'bottom'; // If the user is dragging towards the bottom of the block check whether
// they might be trying to nest the block as a child.
// If the block already has inner blocks, this should always be treated
// as nesting since the next block in the tree will be the first child.
if (isDraggingBelow && candidateBlockData.canInsertDraggedBlocksAsChild && (candidateBlockData.innerBlockCount > 0 || isNestingGesture(position, candidateRect))) {
return {
rootClientId: candidateBlockData.clientId,
blockIndex: 0,
dropPosition: 'inside'
};
} // If dropping as a sibling, but block cannot be inserted in
// this context, return early.
if (!candidateBlockData.canInsertDraggedBlocksAsSibling) {
return;
}
var offset = isDraggingBelow ? 1 : 0;
return {
rootClientId: candidateBlockData.rootClientId,
clientId: candidateBlockData.clientId,
blockIndex: candidateBlockData.blockIndex + offset,
dropPosition: candidateEdge
};
}
/**
* A react hook for implementing a drop zone in block navigation.
*
* @param {Object} ref A React ref of a containing element for block navigation.
*
* @return {WPBlockNavigationDropZoneTarget} The drop target.
*/
function useBlockNavigationDropZone(ref) {
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
_useState2$ = _useState2[0],
target = _useState2$ === void 0 ? {} : _useState2$,
setTarget = _useState2[1];
var targetRootClientId = target.rootClientId,
targetBlockIndex = target.blockIndex;
var dropEventHandlers = useOnBlockDrop(targetRootClientId, targetBlockIndex);
var _useDropZone = Object(external_wp_components_["__unstableUseDropZone"])(use_block_navigation_drop_zone_objectSpread({
element: ref,
withPosition: true
}, dropEventHandlers)),
position = _useDropZone.position,
dragEventType = _useDropZone.type;
var blocksData = useDropTargetBlocksData(ref, position, dragEventType); // Calculate the drop target based on the drag position.
Object(external_wp_element_["useEffect"])(function () {
if (position) {
var newTarget = getBlockNavigationDropTarget(blocksData.current, position);
if (newTarget) {
setTarget(newTarget);
}
}
}, [blocksData, position]);
if (position) {
return target;
}
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/tree.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Wrap `BlockNavigationRows` with `TreeGrid`. BlockNavigationRows is a
* recursive component (it renders itself), so this ensures TreeGrid is only
* present at the very top of the navigation grid.
*
* @param {Object} props Components props.
* @param {Object} props.__experimentalFeatures Object used in context provider.
*/
function BlockNavigationTree(_ref) {
var __experimentalFeatures = _ref.__experimentalFeatures,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["__experimentalFeatures"]);
var treeGridRef = Object(external_wp_element_["useRef"])();
var blockDropTarget = useBlockNavigationDropZone(treeGridRef);
if (!__experimentalFeatures) {
blockDropTarget = undefined;
}
var contextValue = Object(external_wp_element_["useMemo"])(function () {
return {
__experimentalFeatures: __experimentalFeatures,
blockDropTarget: blockDropTarget
};
}, [__experimentalFeatures, blockDropTarget]);
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalTreeGrid"], {
className: "block-editor-block-navigation-tree",
"aria-label": Object(external_wp_i18n_["__"])('Block navigation structure'),
ref: treeGridRef
}, Object(external_wp_element_["createElement"])(BlockNavigationContext.Provider, {
value: contextValue
}, Object(external_wp_element_["createElement"])(BlockNavigationBranch, props)));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigation(_ref) {
var rootBlock = _ref.rootBlock,
rootBlocks = _ref.rootBlocks,
selectedBlockClientId = _ref.selectedBlockClientId,
selectBlock = _ref.selectBlock,
__experimentalFeatures = _ref.__experimentalFeatures;
if (!rootBlocks || rootBlocks.length === 0) {
return null;
}
var hasHierarchy = rootBlock && (rootBlock.clientId !== selectedBlockClientId || rootBlock.innerBlocks && rootBlock.innerBlocks.length !== 0);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-navigation__container"
}, Object(external_wp_element_["createElement"])("p", {
className: "block-editor-block-navigation__label"
}, Object(external_wp_i18n_["__"])('List view')), Object(external_wp_element_["createElement"])(BlockNavigationTree, {
blocks: hasHierarchy ? [rootBlock] : rootBlocks,
selectedBlockClientId: selectedBlockClientId,
selectBlock: selectBlock,
__experimentalFeatures: __experimentalFeatures,
showNestedBlocks: true
}));
}
/* harmony default export */ var block_navigation = (Object(external_wp_compose_["compose"])(Object(external_wp_data_["withSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getBlockHierarchyRootClientId = _select.getBlockHierarchyRootClientId,
__unstableGetBlockWithBlockTree = _select.__unstableGetBlockWithBlockTree,
__unstableGetBlockTree = _select.__unstableGetBlockTree;
var selectedBlockClientId = getSelectedBlockClientId();
return {
rootBlocks: __unstableGetBlockTree(),
rootBlock: selectedBlockClientId ? __unstableGetBlockWithBlockTree(getBlockHierarchyRootClientId(selectedBlockClientId)) : null,
selectedBlockClientId: selectedBlockClientId
};
}), Object(external_wp_data_["withDispatch"])(function (dispatch, _ref2) {
var _ref2$onSelect = _ref2.onSelect,
onSelect = _ref2$onSelect === void 0 ? external_lodash_["noop"] : _ref2$onSelect;
return {
selectBlock: function selectBlock(clientId) {
dispatch('core/block-editor').selectBlock(clientId);
onSelect(clientId);
}
};
}))(BlockNavigation));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/dropdown.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var MenuIcon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24",
width: "24",
height: "24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M13.8 5.2H3v1.5h10.8V5.2zm-3.6 12v1.5H21v-1.5H10.2zm7.2-6H6.6v1.5h10.8v-1.5z"
}));
function BlockNavigationDropdownToggle(_ref) {
var isEnabled = _ref.isEnabled,
onToggle = _ref.onToggle,
isOpen = _ref.isOpen,
innerRef = _ref.innerRef,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isEnabled", "onToggle", "isOpen", "innerRef"]);
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/edit-post/toggle-block-navigation', Object(external_wp_element_["useCallback"])(onToggle, [onToggle]), {
bindGlobal: true,
isDisabled: !isEnabled
});
var shortcut = Object(external_wp_data_["useSelect"])(function (select) {
return select(external_wp_keyboardShortcuts_["store"]).getShortcutRepresentation('core/edit-post/toggle-block-navigation');
}, []);
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, props, {
ref: innerRef,
icon: MenuIcon,
"aria-expanded": isOpen,
"aria-haspopup": "true",
onClick: isEnabled ? onToggle : undefined
/* translators: button label text should, if possible, be under 16 characters. */
,
label: Object(external_wp_i18n_["__"])('Outline'),
className: "block-editor-block-navigation",
shortcut: shortcut,
"aria-disabled": !isEnabled
}));
}
function BlockNavigationDropdown(_ref2, ref) {
var isDisabled = _ref2.isDisabled,
__experimentalFeatures = _ref2.__experimentalFeatures,
props = Object(objectWithoutProperties["a" /* default */])(_ref2, ["isDisabled", "__experimentalFeatures"]);
var hasBlocks = Object(external_wp_data_["useSelect"])(function (select) {
return !!select('core/block-editor').getBlockCount();
}, []);
var isEnabled = hasBlocks && !isDisabled;
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
contentClassName: "block-editor-block-navigation__popover",
position: "bottom right",
renderToggle: function renderToggle(_ref3) {
var isOpen = _ref3.isOpen,
onToggle = _ref3.onToggle;
return Object(external_wp_element_["createElement"])(BlockNavigationDropdownToggle, Object(esm_extends["a" /* default */])({}, props, {
innerRef: ref,
isOpen: isOpen,
onToggle: onToggle,
isEnabled: isEnabled
}));
},
renderContent: function renderContent(_ref4) {
var onClose = _ref4.onClose;
return Object(external_wp_element_["createElement"])(block_navigation, {
onSelect: onClose,
__experimentalFeatures: __experimentalFeatures
});
}
});
}
/* harmony default export */ var dropdown = (Object(external_wp_element_["forwardRef"])(BlockNavigationDropdown));
// EXTERNAL MODULE: external ["wp","shortcode"]
var external_wp_shortcode_ = __webpack_require__(127);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/remove-browser-shortcuts.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Set of keyboard shortcuts handled internally by RichText.
*
* @type {Array}
*/
var HANDLED_SHORTCUTS = [external_wp_keycodes_["rawShortcut"].primary('z'), external_wp_keycodes_["rawShortcut"].primaryShift('z'), external_wp_keycodes_["rawShortcut"].primary('y')];
/**
* An instance of a KeyboardShortcuts element pre-bound for the handled
* shortcuts. Since shortcuts never change, the element can be considered
* static, and can be skipped in reconciliation.
*
* @type {WPElement}
*/
var SHORTCUTS_ELEMENT = Object(external_wp_element_["createElement"])(external_wp_components_["KeyboardShortcuts"], {
bindGlobal: true,
shortcuts: Object(external_lodash_["fromPairs"])(HANDLED_SHORTCUTS.map(function (shortcut) {
return [shortcut, function (event) {
return event.preventDefault();
}];
}))
});
/**
* Component which registered keyboard event handlers to prevent default
* behaviors for key combinations otherwise handled internally by RichText.
*
* @return {WPComponent} The component to be rendered.
*/
var RemoveBrowserShortcuts = function RemoveBrowserShortcuts() {
return SHORTCUTS_ELEMENT;
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/file-paste-handler.js
/**
* WordPress dependencies
*/
function filePasteHandler(files) {
return files.filter(function (_ref) {
var type = _ref.type;
return /^image\/(?:jpe?g|png|gif)$/.test(type);
}).map(function (file) {
return "");
}).join('');
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var format_toolbar_POPOVER_PROPS = {
position: 'bottom right',
isAlternate: true
};
var format_toolbar_FormatToolbar = function FormatToolbar() {
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-format-toolbar"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], null, ['bold', 'italic', 'link', 'text-color'].map(function (format) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
name: "RichText.ToolbarControls.".concat(format),
key: format
});
}), Object(external_wp_element_["createElement"])(external_wp_components_["Slot"], {
name: "RichText.ToolbarControls"
}, function (fills) {
return fills.length !== 0 && Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarItem"], null, function (toggleProps) {
return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
icon: chevron_down["a" /* default */]
/* translators: button label text should, if possible, be under 16 characters. */
,
label: Object(external_wp_i18n_["__"])('More'),
toggleProps: toggleProps,
controls: Object(external_lodash_["orderBy"])(fills.map(function (_ref) {
var _ref2 = Object(slicedToArray["a" /* default */])(_ref, 1),
props = _ref2[0].props;
return props;
}), 'title'),
popoverProps: format_toolbar_POPOVER_PROPS
});
});
})));
};
/* harmony default export */ var format_toolbar = (format_toolbar_FormatToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/format-toolbar-container.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var format_toolbar_container_FormatToolbarContainer = function FormatToolbarContainer(_ref) {
var inline = _ref.inline,
anchorRef = _ref.anchorRef;
if (inline) {
// Render in popover
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
noArrow: true,
position: "top center",
focusOnMount: false,
anchorRef: anchorRef,
className: "block-editor-rich-text__inline-format-toolbar",
__unstableSlotName: "block-toolbar"
}, Object(external_wp_element_["createElement"])(format_toolbar, null));
} // Render regular toolbar
return Object(external_wp_element_["createElement"])(block_format_controls, null, Object(external_wp_element_["createElement"])(format_toolbar, null));
};
/* harmony default export */ var format_toolbar_container = (format_toolbar_container_FormatToolbarContainer);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/index.js
function rich_text_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function rich_text_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { rich_text_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { rich_text_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var wrapperClasses = 'block-editor-rich-text';
var rich_text_classes = 'block-editor-rich-text__editable';
/**
* Get the multiline tag based on the multiline prop.
*
* @param {?(string|boolean)} multiline The multiline prop.
*
* @return {?string} The multiline tag.
*/
function getMultilineTag(multiline) {
if (multiline !== true && multiline !== 'p' && multiline !== 'li') {
return;
}
return multiline === true ? 'p' : multiline;
}
function getAllowedFormats(_ref) {
var allowedFormats = _ref.allowedFormats,
formattingControls = _ref.formattingControls,
disableFormats = _ref.disableFormats;
if (disableFormats) {
return getAllowedFormats.EMPTY_ARRAY;
}
if (!allowedFormats && !formattingControls) {
return;
}
if (allowedFormats) {
return allowedFormats;
}
external_wp_deprecated_default()('wp.blockEditor.RichText formattingControls prop', {
alternative: 'allowedFormats'
});
return formattingControls.map(function (name) {
return "core/".concat(name);
});
}
getAllowedFormats.EMPTY_ARRAY = [];
var rich_text_isShortcode = function isShortcode(text) {
return Object(external_wp_shortcode_["regexp"])('.*').test(text);
};
function RichTextWrapper(_ref2, forwardedRef) {
var children = _ref2.children,
tagName = _ref2.tagName,
originalValue = _ref2.value,
originalOnChange = _ref2.onChange,
originalIsSelected = _ref2.isSelected,
multiline = _ref2.multiline,
inlineToolbar = _ref2.inlineToolbar,
wrapperClassName = _ref2.wrapperClassName,
autocompleters = _ref2.autocompleters,
onReplace = _ref2.onReplace,
placeholder = _ref2.placeholder,
keepPlaceholderOnFocus = _ref2.keepPlaceholderOnFocus,
allowedFormats = _ref2.allowedFormats,
formattingControls = _ref2.formattingControls,
withoutInteractiveFormatting = _ref2.withoutInteractiveFormatting,
onRemove = _ref2.onRemove,
onMerge = _ref2.onMerge,
onSplit = _ref2.onSplit,
onSplitAtEnd = _ref2.__unstableOnSplitAtEnd,
onSplitMiddle = _ref2.__unstableOnSplitMiddle,
identifier = _ref2.identifier,
preserveWhiteSpace = _ref2.preserveWhiteSpace,
pastePlainText = _ref2.__unstablePastePlainText,
__unstableEmbedURLOnPaste = _ref2.__unstableEmbedURLOnPaste,
disableFormats = _ref2.__unstableDisableFormats,
disableLineBreaks = _ref2.disableLineBreaks,
unstableOnFocus = _ref2.unstableOnFocus,
__unstableAllowPrefixTransformations = _ref2.__unstableAllowPrefixTransformations,
__unstableMultilineRootTag = _ref2.__unstableMultilineRootTag,
__unstableMobileNoFocusOnMount = _ref2.__unstableMobileNoFocusOnMount,
deleteEnter = _ref2.deleteEnter,
placeholderTextColor = _ref2.placeholderTextColor,
textAlign = _ref2.textAlign,
selectionColor = _ref2.selectionColor,
tagsToEliminate = _ref2.tagsToEliminate,
rootTagsToEliminate = _ref2.rootTagsToEliminate,
disableEditingMenu = _ref2.disableEditingMenu,
fontSize = _ref2.fontSize,
fontFamily = _ref2.fontFamily,
fontWeight = _ref2.fontWeight,
fontStyle = _ref2.fontStyle,
minWidth = _ref2.minWidth,
maxWidth = _ref2.maxWidth,
onBlur = _ref2.onBlur,
setRef = _ref2.setRef,
props = Object(objectWithoutProperties["a" /* default */])(_ref2, ["children", "tagName", "value", "onChange", "isSelected", "multiline", "inlineToolbar", "wrapperClassName", "autocompleters", "onReplace", "placeholder", "keepPlaceholderOnFocus", "allowedFormats", "formattingControls", "withoutInteractiveFormatting", "onRemove", "onMerge", "onSplit", "__unstableOnSplitAtEnd", "__unstableOnSplitMiddle", "identifier", "preserveWhiteSpace", "__unstablePastePlainText", "__unstableEmbedURLOnPaste", "__unstableDisableFormats", "disableLineBreaks", "unstableOnFocus", "__unstableAllowPrefixTransformations", "__unstableMultilineRootTag", "__unstableMobileNoFocusOnMount", "deleteEnter", "placeholderTextColor", "textAlign", "selectionColor", "tagsToEliminate", "rootTagsToEliminate", "disableEditingMenu", "fontSize", "fontFamily", "fontWeight", "fontStyle", "minWidth", "maxWidth", "onBlur", "setRef"]);
var instanceId = Object(external_wp_compose_["useInstanceId"])(RichTextWrapper);
identifier = identifier || instanceId;
var fallbackRef = Object(external_wp_element_["useRef"])();
var ref = forwardedRef || fallbackRef;
var _useBlockEditContext = useBlockEditContext(),
clientId = _useBlockEditContext.clientId,
onCaretVerticalPositionChange = _useBlockEditContext.onCaretVerticalPositionChange,
blockIsSelected = _useBlockEditContext.isSelected;
var selector = function selector(select) {
var _select = select('core/block-editor'),
isCaretWithinFormattedText = _select.isCaretWithinFormattedText,
getSelectionStart = _select.getSelectionStart,
getSelectionEnd = _select.getSelectionEnd,
getSettings = _select.getSettings,
didAutomaticChange = _select.didAutomaticChange,
__unstableGetBlockWithoutInnerBlocks = _select.__unstableGetBlockWithoutInnerBlocks,
isMultiSelecting = _select.isMultiSelecting,
hasMultiSelection = _select.hasMultiSelection;
var selectionStart = getSelectionStart();
var selectionEnd = getSelectionEnd();
var _getSettings = getSettings(),
undo = _getSettings.__experimentalUndo;
var isSelected;
if (originalIsSelected === undefined) {
isSelected = selectionStart.clientId === clientId && selectionStart.attributeKey === identifier;
} else if (originalIsSelected) {
isSelected = selectionStart.clientId === clientId;
}
var extraProps = {};
if (external_wp_element_["Platform"].OS === 'native') {
// If the block of this RichText is unmodified then it's a candidate for replacing when adding a new block.
// In order to fix https://github.com/wordpress-mobile/gutenberg-mobile/issues/1126, let's blur on unmount in that case.
// This apparently assumes functionality the BlockHlder actually
var block = clientId && __unstableGetBlockWithoutInnerBlocks(clientId);
var _shouldBlurOnUnmount = block && isSelected && Object(external_wp_blocks_["isUnmodifiedDefaultBlock"])(block);
extraProps = {
shouldBlurOnUnmount: _shouldBlurOnUnmount
};
}
return rich_text_objectSpread({
isCaretWithinFormattedText: isCaretWithinFormattedText(),
selectionStart: isSelected ? selectionStart.offset : undefined,
selectionEnd: isSelected ? selectionEnd.offset : undefined,
isSelected: isSelected,
didAutomaticChange: didAutomaticChange(),
disabled: isMultiSelecting() || hasMultiSelection(),
undo: undo
}, extraProps);
}; // This selector must run on every render so the right selection state is
// retreived from the store on merge.
// To do: fix this somehow.
var _useSelect = Object(external_wp_data_["useSelect"])(selector),
isCaretWithinFormattedText = _useSelect.isCaretWithinFormattedText,
selectionStart = _useSelect.selectionStart,
selectionEnd = _useSelect.selectionEnd,
isSelected = _useSelect.isSelected,
didAutomaticChange = _useSelect.didAutomaticChange,
disabled = _useSelect.disabled,
undo = _useSelect.undo,
shouldBlurOnUnmount = _useSelect.shouldBlurOnUnmount;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
__unstableMarkLastChangeAsPersistent = _useDispatch.__unstableMarkLastChangeAsPersistent,
enterFormattedText = _useDispatch.enterFormattedText,
exitFormattedText = _useDispatch.exitFormattedText,
selectionChange = _useDispatch.selectionChange,
__unstableMarkAutomaticChange = _useDispatch.__unstableMarkAutomaticChange;
var multilineTag = getMultilineTag(multiline);
var adjustedAllowedFormats = getAllowedFormats({
allowedFormats: allowedFormats,
formattingControls: formattingControls,
disableFormats: disableFormats
});
var hasFormats = !adjustedAllowedFormats || adjustedAllowedFormats.length > 0;
var adjustedValue = originalValue;
var adjustedOnChange = originalOnChange; // Handle deprecated format.
if (Array.isArray(originalValue)) {
adjustedValue = external_wp_blocks_["children"].toHTML(originalValue);
adjustedOnChange = function adjustedOnChange(newValue) {
return originalOnChange(external_wp_blocks_["children"].fromDOM(Object(external_wp_richText_["__unstableCreateElement"])(document, newValue).childNodes));
};
}
var onSelectionChange = Object(external_wp_element_["useCallback"])(function (start, end) {
selectionChange(clientId, identifier, start, end);
}, [clientId, identifier]);
var onDelete = Object(external_wp_element_["useCallback"])(function (_ref3) {
var value = _ref3.value,
isReverse = _ref3.isReverse;
if (onMerge) {
onMerge(!isReverse);
} // Only handle remove on Backspace. This serves dual-purpose of being
// an intentional user interaction distinguishing between Backspace and
// Delete to remove the empty field, but also to avoid merge & remove
// causing destruction of two fields (merge, then removed merged).
if (onRemove && Object(external_wp_richText_["isEmpty"])(value) && isReverse) {
onRemove(!isReverse);
}
}, [onMerge, onRemove]);
/**
* Signals to the RichText owner that the block can be replaced with two
* blocks as a result of splitting the block by pressing enter, or with
* blocks as a result of splitting the block by pasting block content in the
* instance.
*
* @param {Object} record The rich text value to split.
* @param {Array} pastedBlocks The pasted blocks to insert, if any.
*/
var splitValue = Object(external_wp_element_["useCallback"])(function (record) {
var pastedBlocks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
if (!onReplace || !onSplit) {
return;
}
var blocks = [];
var _split = Object(external_wp_richText_["split"])(record),
_split2 = Object(slicedToArray["a" /* default */])(_split, 2),
before = _split2[0],
after = _split2[1];
var hasPastedBlocks = pastedBlocks.length > 0;
var lastPastedBlockIndex = -1; // Create a block with the content before the caret if there's no pasted
// blocks, or if there are pasted blocks and the value is not empty.
// We do not want a leading empty block on paste, but we do if split
// with e.g. the enter key.
if (!hasPastedBlocks || !Object(external_wp_richText_["isEmpty"])(before)) {
blocks.push(onSplit(Object(external_wp_richText_["toHTMLString"])({
value: before,
multilineTag: multilineTag
})));
lastPastedBlockIndex += 1;
}
if (hasPastedBlocks) {
blocks.push.apply(blocks, Object(toConsumableArray["a" /* default */])(pastedBlocks));
lastPastedBlockIndex += pastedBlocks.length;
} else if (onSplitMiddle) {
blocks.push(onSplitMiddle());
} // If there's pasted blocks, append a block with non empty content
/// after the caret. Otherwise, do append an empty block if there
// is no `onSplitMiddle` prop, but if there is and the content is
// empty, the middle block is enough to set focus in.
if (hasPastedBlocks ? !Object(external_wp_richText_["isEmpty"])(after) : !onSplitMiddle || !Object(external_wp_richText_["isEmpty"])(after)) {
blocks.push(onSplit(Object(external_wp_richText_["toHTMLString"])({
value: after,
multilineTag: multilineTag
})));
} // If there are pasted blocks, set the selection to the last one.
// Otherwise, set the selection to the second block.
var indexToSelect = hasPastedBlocks ? lastPastedBlockIndex : 1; // If there are pasted blocks, move the caret to the end of the selected block
// Otherwise, retain the default value.
var initialPosition = hasPastedBlocks ? -1 : null;
onReplace(blocks, indexToSelect, initialPosition);
}, [onReplace, onSplit, multilineTag, onSplitMiddle]);
var onEnter = Object(external_wp_element_["useCallback"])(function (_ref4) {
var value = _ref4.value,
onChange = _ref4.onChange,
shiftKey = _ref4.shiftKey;
var canSplit = onReplace && onSplit;
if (onReplace) {
var transforms = Object(external_wp_blocks_["getBlockTransforms"])('from').filter(function (_ref5) {
var type = _ref5.type;
return type === 'enter';
});
var transformation = Object(external_wp_blocks_["findTransform"])(transforms, function (item) {
return item.regExp.test(value.text);
});
if (transformation) {
onReplace([transformation.transform({
content: value.text
})]);
__unstableMarkAutomaticChange();
}
}
if (multiline) {
if (shiftKey) {
if (!disableLineBreaks) {
onChange(Object(external_wp_richText_["insert"])(value, '\n'));
}
} else if (canSplit && Object(external_wp_richText_["__unstableIsEmptyLine"])(value)) {
splitValue(value);
} else {
onChange(Object(external_wp_richText_["__unstableInsertLineSeparator"])(value));
}
} else {
var text = value.text,
start = value.start,
end = value.end;
var canSplitAtEnd = onSplitAtEnd && start === end && end === text.length;
if (shiftKey || !canSplit && !canSplitAtEnd) {
if (!disableLineBreaks) {
onChange(Object(external_wp_richText_["insert"])(value, '\n'));
}
} else if (!canSplit && canSplitAtEnd) {
onSplitAtEnd();
} else if (canSplit) {
splitValue(value);
}
}
}, [onReplace, onSplit, __unstableMarkAutomaticChange, multiline, splitValue, onSplitAtEnd]);
var onPaste = Object(external_wp_element_["useCallback"])(function (_ref6) {
var value = _ref6.value,
onChange = _ref6.onChange,
html = _ref6.html,
plainText = _ref6.plainText,
files = _ref6.files,
activeFormats = _ref6.activeFormats;
if (pastePlainText) {
onChange(Object(external_wp_richText_["insert"])(value, Object(external_wp_richText_["create"])({
text: plainText
})));
return;
} // Only process file if no HTML is present.
// Note: a pasted file may have the URL as plain text.
if (files && files.length && !html) {
var _content = Object(external_wp_blocks_["pasteHandler"])({
HTML: filePasteHandler(files),
mode: 'BLOCKS',
tagName: tagName,
preserveWhiteSpace: preserveWhiteSpace
}); // Allows us to ask for this information when we get a report.
// eslint-disable-next-line no-console
window.console.log('Received items:\n\n', files);
if (onReplace && Object(external_wp_richText_["isEmpty"])(value)) {
onReplace(_content);
} else {
splitValue(value, _content);
}
return;
}
var mode = onReplace && onSplit ? 'AUTO' : 'INLINE'; // Force the blocks mode when the user is pasting
// on a new line & the content resembles a shortcode.
// Otherwise it's going to be detected as inline
// and the shortcode won't be replaced.
if (mode === 'AUTO' && Object(external_wp_richText_["isEmpty"])(value) && rich_text_isShortcode(plainText)) {
mode = 'BLOCKS';
}
if (__unstableEmbedURLOnPaste && Object(external_wp_richText_["isEmpty"])(value) && Object(external_wp_url_["isURL"])(plainText.trim())) {
mode = 'BLOCKS';
}
var content = Object(external_wp_blocks_["pasteHandler"])({
HTML: html,
plainText: plainText,
mode: mode,
tagName: tagName,
preserveWhiteSpace: preserveWhiteSpace
});
if (typeof content === 'string') {
var valueToInsert = Object(external_wp_richText_["create"])({
html: content
}); // If there are active formats, merge them with the pasted formats.
if (activeFormats.length) {
var index = valueToInsert.formats.length;
while (index--) {
valueToInsert.formats[index] = [].concat(Object(toConsumableArray["a" /* default */])(activeFormats), Object(toConsumableArray["a" /* default */])(valueToInsert.formats[index] || []));
}
} // If the content should be multiline, we should process text
// separated by a line break as separate lines.
if (multiline) {
valueToInsert = Object(external_wp_richText_["replace"])(valueToInsert, /\n+/g, external_wp_richText_["__UNSTABLE_LINE_SEPARATOR"]);
}
onChange(Object(external_wp_richText_["insert"])(value, valueToInsert));
} else if (content.length > 0) {
if (onReplace && Object(external_wp_richText_["isEmpty"])(value)) {
onReplace(content, content.length - 1, -1);
} else {
splitValue(value, content);
}
}
}, [tagName, onReplace, onSplit, splitValue, __unstableEmbedURLOnPaste, multiline, preserveWhiteSpace, pastePlainText]);
var inputRule = Object(external_wp_element_["useCallback"])(function (value, valueToFormat) {
if (!onReplace) {
return;
}
var start = value.start,
text = value.text;
var characterBefore = text.slice(start - 1, start); // The character right before the caret must be a plain space.
if (characterBefore !== ' ') {
return;
}
var trimmedTextBefore = text.slice(0, start).trim();
var prefixTransforms = Object(external_wp_blocks_["getBlockTransforms"])('from').filter(function (_ref7) {
var type = _ref7.type;
return type === 'prefix';
});
var transformation = Object(external_wp_blocks_["findTransform"])(prefixTransforms, function (_ref8) {
var prefix = _ref8.prefix;
return trimmedTextBefore === prefix;
});
if (!transformation) {
return;
}
var content = valueToFormat(Object(external_wp_richText_["slice"])(value, start, text.length));
var block = transformation.transform(content);
onReplace([block]);
__unstableMarkAutomaticChange();
}, [onReplace, __unstableMarkAutomaticChange]);
var content = Object(external_wp_element_["createElement"])(external_wp_richText_["__experimentalRichText"], {
clientId: clientId,
identifier: identifier,
ref: ref,
value: adjustedValue,
onChange: adjustedOnChange,
selectionStart: selectionStart,
selectionEnd: selectionEnd,
onSelectionChange: onSelectionChange,
tagName: tagName,
placeholder: placeholder,
allowedFormats: adjustedAllowedFormats,
withoutInteractiveFormatting: withoutInteractiveFormatting,
onEnter: onEnter,
onDelete: onDelete,
onPaste: onPaste,
__unstableIsSelected: isSelected,
__unstableInputRule: inputRule,
__unstableMultilineTag: multilineTag,
__unstableIsCaretWithinFormattedText: isCaretWithinFormattedText,
__unstableOnEnterFormattedText: enterFormattedText,
__unstableOnExitFormattedText: exitFormattedText,
__unstableOnCreateUndoLevel: __unstableMarkLastChangeAsPersistent,
__unstableMarkAutomaticChange: __unstableMarkAutomaticChange,
__unstableDidAutomaticChange: didAutomaticChange,
__unstableUndo: undo,
__unstableDisableFormats: disableFormats,
preserveWhiteSpace: preserveWhiteSpace,
disabled: disabled,
unstableOnFocus: unstableOnFocus,
__unstableAllowPrefixTransformations: __unstableAllowPrefixTransformations,
__unstableMultilineRootTag: __unstableMultilineRootTag // Native props.
,
onCaretVerticalPositionChange: onCaretVerticalPositionChange,
blockIsSelected: originalIsSelected !== undefined ? originalIsSelected : blockIsSelected,
shouldBlurOnUnmount: shouldBlurOnUnmount,
__unstableMobileNoFocusOnMount: __unstableMobileNoFocusOnMount,
deleteEnter: deleteEnter,
placeholderTextColor: placeholderTextColor,
textAlign: textAlign,
selectionColor: selectionColor,
tagsToEliminate: tagsToEliminate,
rootTagsToEliminate: rootTagsToEliminate,
disableEditingMenu: disableEditingMenu,
fontSize: fontSize,
fontFamily: fontFamily,
fontWeight: fontWeight,
fontStyle: fontStyle,
minWidth: minWidth,
maxWidth: maxWidth,
onBlur: onBlur,
setRef: setRef // Props to be set on the editable container are destructured on the
// element itself for web (see below), but passed through rich text
// for native.
,
id: props.id,
style: props.style
}, function (_ref9) {
var nestedIsSelected = _ref9.isSelected,
value = _ref9.value,
onChange = _ref9.onChange,
onFocus = _ref9.onFocus,
editableProps = _ref9.editableProps,
TagName = _ref9.editableTagName;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, children && children({
value: value,
onChange: onChange,
onFocus: onFocus
}), nestedIsSelected && hasFormats && Object(external_wp_element_["createElement"])(format_toolbar_container, {
inline: inlineToolbar,
anchorRef: ref.current
}), nestedIsSelected && Object(external_wp_element_["createElement"])(RemoveBrowserShortcuts, null), Object(external_wp_element_["createElement"])(autocomplete, {
onReplace: onReplace,
completers: autocompleters,
record: value,
onChange: onChange,
isSelected: nestedIsSelected,
contentRef: ref
}, function (_ref10) {
var listBoxId = _ref10.listBoxId,
activeId = _ref10.activeId,
_onKeyDown = _ref10.onKeyDown;
return Object(external_wp_element_["createElement"])(TagName, Object(esm_extends["a" /* default */])({}, editableProps, props, {
style: props.style ? rich_text_objectSpread(rich_text_objectSpread({}, props.style), editableProps.style) : editableProps.style,
className: classnames_default()(rich_text_classes, props.className, editableProps.className, {
'keep-placeholder-on-focus': keepPlaceholderOnFocus
}),
"aria-autocomplete": listBoxId ? 'list' : undefined,
"aria-owns": listBoxId,
"aria-activedescendant": activeId,
onKeyDown: function onKeyDown(event) {
_onKeyDown(event);
editableProps.onKeyDown(event);
}
}));
}));
});
if (!wrapperClassName) {
return content;
}
external_wp_deprecated_default()('wp.blockEditor.RichText wrapperClassName prop', {
alternative: 'className prop or create your own wrapper div'
});
return Object(external_wp_element_["createElement"])("div", {
className: classnames_default()(wrapperClasses, wrapperClassName)
}, content);
}
var ForwardedRichTextContainer = Object(external_wp_element_["forwardRef"])(RichTextWrapper);
ForwardedRichTextContainer.Content = function (_ref11) {
var value = _ref11.value,
Tag = _ref11.tagName,
multiline = _ref11.multiline,
props = Object(objectWithoutProperties["a" /* default */])(_ref11, ["value", "tagName", "multiline"]);
// Handle deprecated `children` and `node` sources.
if (Array.isArray(value)) {
value = external_wp_blocks_["children"].toHTML(value);
}
var MultilineTag = getMultilineTag(multiline);
if (!value && MultilineTag) {
value = "<".concat(MultilineTag, ">").concat(MultilineTag, ">");
}
var content = Object(external_wp_element_["createElement"])(external_wp_element_["RawHTML"], null, value);
if (Tag) {
return Object(external_wp_element_["createElement"])(Tag, Object(external_lodash_["omit"])(props, ['format']), content);
}
return content;
};
ForwardedRichTextContainer.isEmpty = function (value) {
return !value || value.length === 0;
};
ForwardedRichTextContainer.Content.defaultProps = {
format: 'string',
value: ''
};
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md
*/
/* harmony default export */ var rich_text = (ForwardedRichTextContainer);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-navigation/editor.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function BlockNavigationEditor(_ref) {
var value = _ref.value,
onChange = _ref.onChange;
return Object(external_wp_element_["createElement"])(block_slot_BlockNavigationBlockFill, null, Object(external_wp_element_["createElement"])(rich_text, {
value: value,
onChange: onChange,
placeholder: Object(external_wp_i18n_["__"])('Navigation item'),
keepPlaceholderOnFocus: true,
withoutInteractiveFormatting: true,
allowedFormats: ['core/bold', 'core/italic', 'core/image', 'core/strikethrough']
}));
}
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/layout.js
var library_layout = __webpack_require__(307);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-picker/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function BlockVariationPicker(_ref) {
var _ref$icon = _ref.icon,
icon = _ref$icon === void 0 ? library_layout["a" /* default */] : _ref$icon,
_ref$label = _ref.label,
label = _ref$label === void 0 ? Object(external_wp_i18n_["__"])('Choose variation') : _ref$label,
_ref$instructions = _ref.instructions,
instructions = _ref$instructions === void 0 ? Object(external_wp_i18n_["__"])('Select a variation to start with.') : _ref$instructions,
variations = _ref.variations,
onSelect = _ref.onSelect,
allowSkip = _ref.allowSkip;
var classes = classnames_default()('block-editor-block-variation-picker', {
'has-many-variations': variations.length > 4
});
return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
icon: icon,
label: label,
instructions: instructions,
className: classes
}, Object(external_wp_element_["createElement"])("ul", {
className: "block-editor-block-variation-picker__variations",
role: "list",
"aria-label": Object(external_wp_i18n_["__"])('Block variations')
}, variations.map(function (variation) {
return Object(external_wp_element_["createElement"])("li", {
key: variation.name
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSecondary: true,
icon: variation.icon,
iconSize: 48,
onClick: function onClick() {
return onSelect(variation);
},
className: "block-editor-block-variation-picker__variation",
label: variation.description || variation.title
}), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-variation-picker__variation-label",
role: "presentation"
}, variation.title));
})), allowSkip && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-variation-picker__skip"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isLink: true,
onClick: function onClick() {
return onSelect();
}
}, Object(external_wp_i18n_["__"])('Skip'))));
}
/* harmony default export */ var block_variation_picker = (BlockVariationPicker);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/block-variation-transforms.js
/**
* External dependencies
*/
/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */
/**
* Matches the provided block variations with a block's attributes. If no match
* or more than one matches are found it returns `undefined`. If a single match is
* found it returns it.
*
* This is a simple implementation for now as it takes into account only the attributes
* of a block variation and not `InnerBlocks`.
*
* @param {Object} blockAttributes - The block attributes to try to find a match.
* @param {WPBlockVariation[]} variations - A list of block variations to test for a match.
* @return {?WPBlockVariation} - If a match is found returns it. If not or more than one matches are found returns `undefined`.
*/
var block_variation_transforms_experimentalGetMatchingVariation = function __experimentalGetMatchingVariation(blockAttributes, variations) {
if (!variations || !blockAttributes) return;
var matches = variations.filter(function (_ref) {
var attributes = _ref.attributes;
if (!attributes || !Object.keys(attributes).length) return false;
return Object(external_lodash_["isMatch"])(blockAttributes, attributes);
});
if (matches.length !== 1) return;
return matches[0];
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-variation-transforms/index.js
function block_variation_transforms_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_variation_transforms_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_variation_transforms_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_variation_transforms_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function __experimentalBlockVariationTransforms(_ref) {
var blockClientId = _ref.blockClientId;
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
selectedValue = _useState2[0],
setSelectedValue = _useState2[1];
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlockAttributes = _useDispatch.updateBlockAttributes;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select(external_wp_blocks_["store"]),
getBlockVariations = _select.getBlockVariations;
var _select2 = select('core/block-editor'),
getBlockName = _select2.getBlockName,
getBlockAttributes = _select2.getBlockAttributes;
var blockName = blockClientId && getBlockName(blockClientId);
return {
variations: blockName && getBlockVariations(blockName, 'transform'),
blockAttributes: getBlockAttributes(blockClientId)
};
}, [blockClientId]),
variations = _useSelect.variations,
blockAttributes = _useSelect.blockAttributes;
Object(external_wp_element_["useEffect"])(function () {
var _getMatchingVariation;
setSelectedValue((_getMatchingVariation = block_variation_transforms_experimentalGetMatchingVariation(blockAttributes, variations)) === null || _getMatchingVariation === void 0 ? void 0 : _getMatchingVariation.name);
}, [blockAttributes, variations]);
if (!(variations !== null && variations !== void 0 && variations.length)) return null;
var selectOptions = variations.map(function (_ref2) {
var name = _ref2.name,
title = _ref2.title,
description = _ref2.description;
return {
value: name,
label: title,
info: description
};
});
var onSelectVariation = function onSelectVariation(variationName) {
updateBlockAttributes(blockClientId, block_variation_transforms_objectSpread({}, variations.find(function (_ref3) {
var name = _ref3.name;
return name === variationName;
}).attributes));
};
var baseClass = 'block-editor-block-variation-transforms';
return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
className: baseClass,
label: Object(external_wp_i18n_["__"])('Transform to variation'),
text: Object(external_wp_i18n_["__"])('Transform to variation'),
popoverProps: {
position: 'bottom center',
className: "".concat(baseClass, "__popover")
},
icon: chevron_down["a" /* default */],
toggleProps: {
iconPosition: 'right'
}
}, function () {
return Object(external_wp_element_["createElement"])("div", {
className: "".concat(baseClass, "__container")
}, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItemsChoice"], {
choices: selectOptions,
value: selectedValue,
onSelect: onSelectVariation
})));
});
}
/* harmony default export */ var block_variation_transforms = (__experimentalBlockVariationTransforms);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-toolbar/icons.js
/**
* WordPress dependencies
*/
var alignBottom = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M15 4H9v11h6V4zM4 18.5V20h16v-1.5H4z"
}));
var alignCenter = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M20 11h-5V4H9v7H4v1.5h5V20h6v-7.5h5z"
}));
var alignTop = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M9 20h6V9H9v11zM4 4v1.5h16V4H4z"
}));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-vertical-alignment-toolbar/index.js
function block_vertical_alignment_toolbar_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_vertical_alignment_toolbar_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_vertical_alignment_toolbar_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_vertical_alignment_toolbar_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_vertical_alignment_toolbar_BLOCK_ALIGNMENTS_CONTROLS = {
top: {
icon: alignTop,
title: Object(external_wp_i18n_["_x"])('Align top', 'Block vertical alignment setting')
},
center: {
icon: alignCenter,
title: Object(external_wp_i18n_["_x"])('Align middle', 'Block vertical alignment setting')
},
bottom: {
icon: alignBottom,
title: Object(external_wp_i18n_["_x"])('Align bottom', 'Block vertical alignment setting')
}
};
var block_vertical_alignment_toolbar_DEFAULT_CONTROLS = ['top', 'center', 'bottom'];
var block_vertical_alignment_toolbar_DEFAULT_CONTROL = 'top';
var block_vertical_alignment_toolbar_POPOVER_PROPS = {
isAlternate: true
};
function BlockVerticalAlignmentToolbar(_ref) {
var value = _ref.value,
onChange = _ref.onChange,
_ref$controls = _ref.controls,
controls = _ref$controls === void 0 ? block_vertical_alignment_toolbar_DEFAULT_CONTROLS : _ref$controls,
_ref$isCollapsed = _ref.isCollapsed,
isCollapsed = _ref$isCollapsed === void 0 ? true : _ref$isCollapsed;
function applyOrUnset(align) {
return function () {
return onChange(value === align ? undefined : align);
};
}
var activeAlignment = block_vertical_alignment_toolbar_BLOCK_ALIGNMENTS_CONTROLS[value];
var defaultAlignmentControl = block_vertical_alignment_toolbar_BLOCK_ALIGNMENTS_CONTROLS[block_vertical_alignment_toolbar_DEFAULT_CONTROL];
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
popoverProps: block_vertical_alignment_toolbar_POPOVER_PROPS,
isCollapsed: isCollapsed,
icon: activeAlignment ? activeAlignment.icon : defaultAlignmentControl.icon,
label: Object(external_wp_i18n_["_x"])('Change vertical alignment', 'Block vertical alignment setting label'),
controls: controls.map(function (control) {
return block_vertical_alignment_toolbar_objectSpread(block_vertical_alignment_toolbar_objectSpread({}, block_vertical_alignment_toolbar_BLOCK_ALIGNMENTS_CONTROLS[control]), {}, {
isActive: value === control,
role: isCollapsed ? 'menuitemradio' : undefined,
onClick: applyOrUnset(control)
});
})
});
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-vertical-alignment-toolbar/README.md
*/
/* harmony default export */ var block_vertical_alignment_toolbar = (BlockVerticalAlignmentToolbar);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/with-color-context.js
function with_color_context_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function with_color_context_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { with_color_context_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { with_color_context_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/* harmony default export */ var with_color_context = (Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return function (props) {
var colorsFeature = useEditorFeature('color.palette');
var disableCustomColorsFeature = !useEditorFeature('color.custom');
var colors = props.colors === undefined ? colorsFeature : props.colors;
var disableCustomColors = props.disableCustomColors === undefined ? disableCustomColorsFeature : props.disableCustomColors;
var hasColorsToChoose = !Object(external_lodash_["isEmpty"])(colors) || !disableCustomColors;
return Object(external_wp_element_["createElement"])(WrappedComponent, with_color_context_objectSpread(with_color_context_objectSpread({}, props), {}, {
colors: colors,
disableCustomColors: disableCustomColors,
hasColorsToChoose: hasColorsToChoose
}));
};
}, 'withColorContext'));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/* harmony default export */ var color_palette = (with_color_context(external_wp_components_["ColorPalette"]));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/color-palette/control.js
/**
* Internal dependencies
*/
function ColorPaletteControl(_ref) {
var onChange = _ref.onChange,
value = _ref.value,
otherProps = Object(objectWithoutProperties["a" /* default */])(_ref, ["onChange", "value"]);
return Object(external_wp_element_["createElement"])(control, Object(esm_extends["a" /* default */])({}, otherProps, {
onColorChange: onChange,
colorValue: value,
gradients: [],
disableCustomGradients: true
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var gradient_picker_EMPTY_ARRAY = [];
function GradientPickerWithGradients(props) {
var gradients = useEditorFeature('color.gradients') || gradient_picker_EMPTY_ARRAY;
var disableCustomGradients = !useEditorFeature('color.customGradient');
return Object(external_wp_element_["createElement"])(external_wp_components_["__experimentalGradientPicker"], Object(esm_extends["a" /* default */])({
gradients: props.gradients !== undefined ? props.gradient : gradients,
disableCustomGradients: props.disableCustomGradients !== undefined ? props.disableCustomGradients : disableCustomGradients
}, props));
}
/* harmony default export */ var gradient_picker = (function (props) {
var ComponentToUse = props.gradients !== undefined && props.disableCustomGradients !== undefined ? external_wp_components_["__experimentalGradientPicker"] : GradientPickerWithGradients;
return Object(external_wp_element_["createElement"])(ComponentToUse, props);
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/control.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function GradientPickerControl(_ref) {
var className = _ref.className,
value = _ref.value,
onChange = _ref.onChange,
_ref$label = _ref.label,
label = _ref$label === void 0 ? Object(external_wp_i18n_["__"])('Gradient Presets') : _ref$label,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["className", "value", "onChange", "label"]);
var gradients = useEditorFeature('color.gradients');
var disableCustomGradients = !useEditorFeature('color.customGradient');
if (Object(external_lodash_["isEmpty"])(gradients) && disableCustomGradients) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], {
className: classnames_default()('block-editor-gradient-picker-control', className)
}, Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"].VisualLabel, null, label), Object(external_wp_element_["createElement"])(gradient_picker, Object(esm_extends["a" /* default */])({
value: value,
onChange: onChange,
className: "block-editor-gradient-picker-control__gradient-picker-presets",
gradients: gradients,
disableCustomGradients: disableCustomGradients
}, props)));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/gradient-picker/panel.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function GradientPanel(props) {
var gradients = useEditorFeature('color.gradients');
if (Object(external_lodash_["isEmpty"])(gradients)) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Gradient')
}, Object(external_wp_element_["createElement"])(GradientPickerControl, props));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/image-size-control/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var IMAGE_SIZE_PRESETS = [25, 50, 75, 100];
function ImageSizeControl(_ref) {
var _ref2, _ref3;
var imageWidth = _ref.imageWidth,
imageHeight = _ref.imageHeight,
_ref$imageSizeOptions = _ref.imageSizeOptions,
imageSizeOptions = _ref$imageSizeOptions === void 0 ? [] : _ref$imageSizeOptions,
_ref$isResizable = _ref.isResizable,
isResizable = _ref$isResizable === void 0 ? true : _ref$isResizable,
slug = _ref.slug,
width = _ref.width,
height = _ref.height,
_onChange = _ref.onChange,
_ref$onChangeImage = _ref.onChangeImage,
onChangeImage = _ref$onChangeImage === void 0 ? external_lodash_["noop"] : _ref$onChangeImage;
function updateDimensions(nextWidth, nextHeight) {
return function () {
_onChange({
width: nextWidth,
height: nextHeight
});
};
}
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, !Object(external_lodash_["isEmpty"])(imageSizeOptions) && Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
label: Object(external_wp_i18n_["__"])('Image size'),
value: slug,
options: imageSizeOptions,
onChange: onChangeImage
}), isResizable && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-image-size-control"
}, Object(external_wp_element_["createElement"])("p", {
className: "block-editor-image-size-control__row"
}, Object(external_wp_i18n_["__"])('Image dimensions')), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-image-size-control__row"
}, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
type: "number",
className: "block-editor-image-size-control__width",
label: Object(external_wp_i18n_["__"])('Width'),
value: (_ref2 = width !== null && width !== void 0 ? width : imageWidth) !== null && _ref2 !== void 0 ? _ref2 : '',
min: 1,
onChange: function onChange(value) {
return _onChange({
width: parseInt(value, 10)
});
}
}), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
type: "number",
className: "block-editor-image-size-control__height",
label: Object(external_wp_i18n_["__"])('Height'),
value: (_ref3 = height !== null && height !== void 0 ? height : imageHeight) !== null && _ref3 !== void 0 ? _ref3 : '',
min: 1,
onChange: function onChange(value) {
return _onChange({
height: parseInt(value, 10)
});
}
})), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-image-size-control__row"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ButtonGroup"], {
"aria-label": Object(external_wp_i18n_["__"])('Image size presets')
}, IMAGE_SIZE_PRESETS.map(function (scale) {
var scaledWidth = Math.round(imageWidth * (scale / 100));
var scaledHeight = Math.round(imageHeight * (scale / 100));
var isCurrent = width === scaledWidth && height === scaledHeight;
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
key: scale,
isSmall: true,
isPrimary: isCurrent,
isPressed: isCurrent,
onClick: updateDimensions(scaledWidth, scaledHeight)
}, scale, "%");
})), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSmall: true,
onClick: updateDimensions()
}, Object(external_wp_i18n_["__"])('Reset')))));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/with-client-id.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var withClientId = Object(external_wp_compose_["createHigherOrderComponent"])(function (WrappedComponent) {
return function (props) {
var _useBlockEditContext = useBlockEditContext(),
clientId = _useBlockEditContext.clientId;
return Object(external_wp_element_["createElement"])(WrappedComponent, Object(esm_extends["a" /* default */])({}, props, {
clientId: clientId
}));
};
}, 'withClientId');
/* harmony default export */ var with_client_id = (withClientId);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/button-block-appender.js
/**
* Internal dependencies
*/
var inner_blocks_button_block_appender_ButtonBlockAppender = function ButtonBlockAppender(_ref) {
var clientId = _ref.clientId,
showSeparator = _ref.showSeparator,
isFloating = _ref.isFloating,
onAddBlock = _ref.onAddBlock;
return Object(external_wp_element_["createElement"])(button_block_appender, {
rootClientId: clientId,
showSeparator: showSeparator,
isFloating: isFloating,
onAddBlock: onAddBlock
});
};
/* harmony default export */ var inner_blocks_button_block_appender = (with_client_id(inner_blocks_button_block_appender_ButtonBlockAppender));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/default-block-appender.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var inner_blocks_default_block_appender_DefaultBlockAppender = function DefaultBlockAppender(_ref) {
var clientId = _ref.clientId,
lastBlockClientId = _ref.lastBlockClientId;
return Object(external_wp_element_["createElement"])(default_block_appender, {
rootClientId: clientId,
lastBlockClientId: lastBlockClientId
});
};
/* harmony default export */ var inner_blocks_default_block_appender = (Object(external_wp_compose_["compose"])([with_client_id, Object(external_wp_data_["withSelect"])(function (select, _ref2) {
var clientId = _ref2.clientId;
var _select = select('core/block-editor'),
getBlockOrder = _select.getBlockOrder;
var blockClientIds = getBlockOrder(clientId);
return {
lastBlockClientId: Object(external_lodash_["last"])(blockClientIds)
};
})])(inner_blocks_default_block_appender_DefaultBlockAppender));
// EXTERNAL MODULE: external ["wp","isShallowEqual"]
var external_wp_isShallowEqual_ = __webpack_require__(63);
var external_wp_isShallowEqual_default = /*#__PURE__*/__webpack_require__.n(external_wp_isShallowEqual_);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-nested-settings-update.js
/**
* WordPress dependencies
*/
/**
* This hook is a side effect which updates the block-editor store when changes
* happen to inner block settings. The given props are transformed into a
* settings object, and if that is different from the current settings object in
* the block-editor store, then the store is updated with the new settings which
* came from props.
*
* @param {string} clientId The client ID of the block to update.
* @param {string[]} allowedBlocks An array of block names which are permitted
* in inner blocks.
* @param {string} [templateLock] The template lock specified for the inner
* blocks component. (e.g. "all")
* @param {boolean} captureToolbars Whether or children toolbars should be shown
* in the inner blocks component rather than on
* the child block.
* @param {string} orientation The direction in which the block
* should face.
*/
function useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation) {
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
updateBlockListSettings = _useDispatch.updateBlockListSettings;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var rootClientId = select('core/block-editor').getBlockRootClientId(clientId);
return {
blockListSettings: select('core/block-editor').getBlockListSettings(clientId),
parentLock: select('core/block-editor').getTemplateLock(rootClientId)
};
}, [clientId]),
blockListSettings = _useSelect.blockListSettings,
parentLock = _useSelect.parentLock;
Object(external_wp_element_["useLayoutEffect"])(function () {
var newSettings = {
allowedBlocks: allowedBlocks,
templateLock: templateLock === undefined ? parentLock : templateLock
}; // These values are not defined for RN, so only include them if they
// are defined.
if (captureToolbars !== undefined) {
newSettings.__experimentalCaptureToolbars = captureToolbars;
}
if (orientation !== undefined) {
newSettings.orientation = orientation;
}
if (!external_wp_isShallowEqual_default()(blockListSettings, newSettings)) {
updateBlockListSettings(clientId, newSettings);
}
}, [clientId, blockListSettings, allowedBlocks, templateLock, parentLock, captureToolbars, orientation, updateBlockListSettings]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/use-inner-block-template-sync.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* This hook makes sure that a block's inner blocks stay in sync with the given
* block "template". The template is a block hierarchy to which inner blocks must
* conform. If the blocks get "out of sync" with the template and the template
* is meant to be locked (e.g. templateLock = "all"), then we replace the inner
* blocks with the correct value after synchronizing it with the template.
*
* @param {string} clientId The block client ID.
* @param {Object} template The template to match.
* @param {string} templateLock The template lock state for the inner blocks. For
* example, if the template lock is set to "all",
* then the inner blocks will stay in sync with the
* template. If not defined or set to false, then
* the inner blocks will not be synchronized with
* the given template.
* @param {boolean} templateInsertUpdatesSelection Whether or not to update the
* block-editor selection state when inner blocks
* are replaced after template synchronization.
*/
function useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection) {
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
replaceInnerBlocks = _useDispatch.replaceInnerBlocks;
var innerBlocks = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').getBlocks(clientId);
}, [clientId]); // Maintain a reference to the previous value so we can do a deep equality check.
var existingTemplate = Object(external_wp_element_["useRef"])(null);
Object(external_wp_element_["useLayoutEffect"])(function () {
// Only synchronize innerBlocks with template if innerBlocks are empty or
// a locking all exists directly on the block.
if (innerBlocks.length === 0 || templateLock === 'all') {
var hasTemplateChanged = !Object(external_lodash_["isEqual"])(template, existingTemplate.current);
if (hasTemplateChanged) {
existingTemplate.current = template;
var nextBlocks = Object(external_wp_blocks_["synchronizeBlocksWithTemplate"])(innerBlocks, template);
if (!Object(external_lodash_["isEqual"])(nextBlocks, innerBlocks)) {
replaceInnerBlocks(clientId, nextBlocks, innerBlocks.length === 0 && templateInsertUpdatesSelection && nextBlocks.length !== 0);
}
}
}
}, [innerBlocks, template, templateLock, clientId]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/get-block-context.js
/**
* External dependencies
*/
/**
* Block context cache, implemented as a WeakMap mapping block types to a
* WeakMap mapping attributes object to context value.
*
* @type {WeakMap>}
*/
var BLOCK_CONTEXT_CACHE = new WeakMap();
/**
* Returns a cached context object value for a given set of attributes for the
* block type.
*
* @param {Record} attributes Block attributes object.
* @param {WPBlockType} blockType Block type settings.
*
* @return {Record} Context value.
*/
function getBlockContext(attributes, blockType) {
if (!BLOCK_CONTEXT_CACHE.has(blockType)) {
BLOCK_CONTEXT_CACHE.set(blockType, new WeakMap());
}
var blockTypeCache = BLOCK_CONTEXT_CACHE.get(blockType);
if (!blockTypeCache.has(attributes)) {
var context = Object(external_lodash_["mapValues"])(blockType.providesContext, function (attributeName) {
return attributes[attributeName];
});
blockTypeCache.set(attributes, context);
}
return blockTypeCache.get(attributes);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inner-blocks/index.js
function inner_blocks_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function inner_blocks_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { inner_blocks_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { inner_blocks_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Internal dependencies
*/
/**
* InnerBlocks is a component which allows a single block to have multiple blocks
* as children. The UncontrolledInnerBlocks component is used whenever the inner
* blocks are not controlled by another entity. In other words, it is normally
* used for inner blocks in the post editor
*
* @param {Object} props The component props.
*/
function UncontrolledInnerBlocks(props) {
var clientId = props.clientId,
allowedBlocks = props.allowedBlocks,
template = props.template,
templateLock = props.templateLock,
wrapperRef = props.wrapperRef,
templateInsertUpdatesSelection = props.templateInsertUpdatesSelection,
captureToolbars = props.__experimentalCaptureToolbars,
__experimentalAppenderTagName = props.__experimentalAppenderTagName,
renderAppender = props.renderAppender,
orientation = props.orientation,
placeholder = props.placeholder,
_props$__experimental = props.__experimentalLayout,
layout = _props$__experimental === void 0 ? defaultLayout : _props$__experimental;
useNestedSettingsUpdate(clientId, allowedBlocks, templateLock, captureToolbars, orientation);
useInnerBlockTemplateSync(clientId, template, templateLock, templateInsertUpdatesSelection);
var context = Object(external_wp_data_["useSelect"])(function (select) {
var block = select('core/block-editor').getBlock(clientId);
var blockType = Object(external_wp_blocks_["getBlockType"])(block.name);
if (!blockType || !blockType.providesContext) {
return;
}
return getBlockContext(block.attributes, blockType);
}, [clientId]); // This component needs to always be synchronous as it's the one changing
// the async mode depending on the block selection.
return Object(external_wp_element_["createElement"])(LayoutProvider, {
value: layout
}, Object(external_wp_element_["createElement"])(BlockContextProvider, {
value: context
}, Object(external_wp_element_["createElement"])(BlockListItems, {
rootClientId: clientId,
renderAppender: renderAppender,
__experimentalAppenderTagName: __experimentalAppenderTagName,
wrapperRef: wrapperRef,
placeholder: placeholder
})));
}
/**
* The controlled inner blocks component wraps the uncontrolled inner blocks
* component with the blockSync hook. This keeps the innerBlocks of the block in
* the block-editor store in sync with the blocks of the controlling entity. An
* example of an inner block controller is a template part block, which provides
* its own blocks from the template part entity data source.
*
* @param {Object} props The component props.
*/
function ControlledInnerBlocks(props) {
useBlockSync(props);
return Object(external_wp_element_["createElement"])(UncontrolledInnerBlocks, props);
}
var ForwardedInnerBlocks = Object(external_wp_element_["forwardRef"])(function (props, ref) {
var innerBlocksProps = useInnerBlocksProps({
ref: ref
}, props);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-inner-blocks"
}, Object(external_wp_element_["createElement"])("div", innerBlocksProps));
});
/**
* This hook is used to lightly mark an element as an inner blocks wrapper
* element. Call this hook and pass the returned props to the element to mark as
* an inner blocks wrapper, automatically rendering inner blocks as children. If
* you define a ref for the element, it is important to pass the ref to this
* hook, which the hook in turn will pass to the component through the props it
* returns. Optionally, you can also pass any other props through this hook, and
* they will be merged and returned.
*
* @param {Object} props Optional. Props to pass to the element. Must contain
* the ref if one is defined.
* @param {Object} options Optional. Inner blocks options.
*
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
*/
function useInnerBlocksProps() {
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var fallbackRef = Object(external_wp_element_["useRef"])();
var _useBlockEditContext = useBlockEditContext(),
clientId = _useBlockEditContext.clientId;
var isSmallScreen = Object(external_wp_compose_["useViewportMatch"])('medium', '<');
var hasOverlay = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockName = _select.getBlockName,
isBlockSelected = _select.isBlockSelected,
hasSelectedInnerBlock = _select.hasSelectedInnerBlock,
isNavigationMode = _select.isNavigationMode;
var enableClickThrough = isNavigationMode() || isSmallScreen;
return getBlockName(clientId) !== 'core/template' && !isBlockSelected(clientId) && !hasSelectedInnerBlock(clientId, true) && enableClickThrough;
}, [clientId, isSmallScreen]);
var ref = props.ref || fallbackRef;
var InnerBlocks = options.value && options.onChange ? ControlledInnerBlocks : UncontrolledInnerBlocks;
return inner_blocks_objectSpread(inner_blocks_objectSpread({}, props), {}, {
ref: ref,
className: classnames_default()(props.className, 'block-editor-block-list__layout', {
'has-overlay': hasOverlay
}),
children: Object(external_wp_element_["createElement"])(InnerBlocks, Object(esm_extends["a" /* default */])({}, options, {
clientId: clientId,
wrapperRef: ref
}))
});
} // Expose default appender placeholders as components.
ForwardedInnerBlocks.DefaultBlockAppender = inner_blocks_default_block_appender;
ForwardedInnerBlocks.ButtonBlockAppender = inner_blocks_button_block_appender;
ForwardedInnerBlocks.Content = Object(external_wp_blocks_["withBlockContentContext"])(function (_ref) {
var BlockContent = _ref.BlockContent;
return Object(external_wp_element_["createElement"])(BlockContent, null);
});
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/inner-blocks/README.md
*/
/* harmony default export */ var inner_blocks = (ForwardedInnerBlocks);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/keyboard-return.js
var keyboard_return = __webpack_require__(218);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/settings-drawer.js
function settings_drawer_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function settings_drawer_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { settings_drawer_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { settings_drawer_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var defaultSettings = [{
id: 'opensInNewTab',
title: Object(external_wp_i18n_["__"])('Open in new tab')
}];
var settings_drawer_LinkControlSettingsDrawer = function LinkControlSettingsDrawer(_ref) {
var value = _ref.value,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange,
_ref$settings = _ref.settings,
settings = _ref$settings === void 0 ? defaultSettings : _ref$settings;
if (!settings || !settings.length) {
return null;
}
var handleSettingChange = function handleSettingChange(setting) {
return function (newValue) {
onChange(settings_drawer_objectSpread(settings_drawer_objectSpread({}, value), {}, Object(defineProperty["a" /* default */])({}, setting.id, newValue)));
};
};
var theSettings = settings.map(function (setting) {
return Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
className: "block-editor-link-control__setting",
key: setting.id,
label: setting.title,
onChange: handleSettingChange(setting),
checked: value ? !!value[setting.id] : false
});
});
return Object(external_wp_element_["createElement"])("fieldset", {
className: "block-editor-link-control__settings"
}, Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
as: "legend"
}, Object(external_wp_i18n_["__"])('Currently selected link settings')), theSettings);
};
/* harmony default export */ var settings_drawer = (settings_drawer_LinkControlSettingsDrawer);
// EXTERNAL MODULE: ./node_modules/dom-scroll-into-view/lib/index.js
var dom_scroll_into_view_lib = __webpack_require__(123);
var dom_scroll_into_view_lib_default = /*#__PURE__*/__webpack_require__.n(dom_scroll_into_view_lib);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/index.js
function url_input_createSuper(Derived) { var hasNativeReflectConstruct = url_input_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function url_input_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var url_input_URLInput = /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(URLInput, _Component);
var _super = url_input_createSuper(URLInput);
function URLInput(props) {
var _this;
Object(classCallCheck["a" /* default */])(this, URLInput);
_this = _super.call(this, props);
_this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.onFocus = _this.onFocus.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.selectLink = _this.selectLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.handleOnClick = _this.handleOnClick.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.bindSuggestionNode = _this.bindSuggestionNode.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.autocompleteRef = props.autocompleteRef || Object(external_wp_element_["createRef"])();
_this.inputRef = Object(external_wp_element_["createRef"])();
_this.updateSuggestions = Object(external_lodash_["debounce"])(_this.updateSuggestions.bind(Object(assertThisInitialized["a" /* default */])(_this)), 200);
_this.suggestionNodes = [];
_this.isUpdatingSuggestions = false;
_this.state = {
suggestions: [],
showSuggestions: false,
selectedSuggestion: null,
suggestionsListboxId: '',
suggestionOptionIdPrefix: ''
};
return _this;
}
Object(createClass["a" /* default */])(URLInput, [{
key: "componentDidUpdate",
value: function componentDidUpdate(prevProps) {
var _this2 = this;
var _this$state = this.state,
showSuggestions = _this$state.showSuggestions,
selectedSuggestion = _this$state.selectedSuggestion;
var value = this.props.value; // only have to worry about scrolling selected suggestion into view
// when already expanded
if (showSuggestions && selectedSuggestion !== null && this.suggestionNodes[selectedSuggestion] && !this.scrollingIntoView) {
this.scrollingIntoView = true;
dom_scroll_into_view_lib_default()(this.suggestionNodes[selectedSuggestion], this.autocompleteRef.current, {
onlyScrollIfNeeded: true
});
this.props.setTimeout(function () {
_this2.scrollingIntoView = false;
}, 100);
} // Only attempt an update on suggestions if the input value has actually changed.
if (prevProps.value !== value && this.shouldShowInitialSuggestions()) {
this.updateSuggestions();
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
if (this.shouldShowInitialSuggestions()) {
this.updateSuggestions();
}
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
delete this.suggestionsRequest;
}
}, {
key: "bindSuggestionNode",
value: function bindSuggestionNode(index) {
var _this3 = this;
return function (ref) {
_this3.suggestionNodes[index] = ref;
};
}
}, {
key: "shouldShowInitialSuggestions",
value: function shouldShowInitialSuggestions() {
var suggestions = this.state.suggestions;
var _this$props = this.props,
_this$props$__experim = _this$props.__experimentalShowInitialSuggestions,
__experimentalShowInitialSuggestions = _this$props$__experim === void 0 ? false : _this$props$__experim,
value = _this$props.value;
return !this.isUpdatingSuggestions && __experimentalShowInitialSuggestions && !(value && value.length) && !(suggestions && suggestions.length);
}
}, {
key: "updateSuggestions",
value: function updateSuggestions() {
var _this4 = this;
var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
var _this$props2 = this.props,
fetchLinkSuggestions = _this$props2.__experimentalFetchLinkSuggestions,
handleURLSuggestions = _this$props2.__experimentalHandleURLSuggestions;
if (!fetchLinkSuggestions) {
return;
}
var isInitialSuggestions = !(value && value.length); // Allow a suggestions request if:
// - there are at least 2 characters in the search input (except manual searches where
// search input length is not required to trigger a fetch)
// - this is a direct entry (eg: a URL)
if (!isInitialSuggestions && (value.length < 2 || !handleURLSuggestions && Object(external_wp_url_["isURL"])(value))) {
this.setState({
showSuggestions: false,
selectedSuggestion: null,
loading: false
});
return;
}
this.isUpdatingSuggestions = true;
this.setState({
selectedSuggestion: null,
loading: true
});
var request = fetchLinkSuggestions(value, {
isInitialSuggestions: isInitialSuggestions
});
request.then(function (suggestions) {
// A fetch Promise doesn't have an abort option. It's mimicked by
// comparing the request reference in on the instance, which is
// reset or deleted on subsequent requests or unmounting.
if (_this4.suggestionsRequest !== request) {
return;
}
_this4.setState({
suggestions: suggestions,
loading: false,
showSuggestions: !!suggestions.length
});
if (!!suggestions.length) {
_this4.props.debouncedSpeak(Object(external_wp_i18n_["sprintf"])(
/* translators: %s: number of results. */
Object(external_wp_i18n_["_n"])('%d result found, use up and down arrow keys to navigate.', '%d results found, use up and down arrow keys to navigate.', suggestions.length), suggestions.length), 'assertive');
} else {
_this4.props.debouncedSpeak(Object(external_wp_i18n_["__"])('No results.'), 'assertive');
}
_this4.isUpdatingSuggestions = false;
}).catch(function () {
if (_this4.suggestionsRequest === request) {
_this4.setState({
loading: false
});
_this4.isUpdatingSuggestions = false;
}
}); // Note that this assignment is handled *before* the async search request
// as a Promise always resolves on the next tick of the event loop.
this.suggestionsRequest = request;
}
}, {
key: "onChange",
value: function onChange(event) {
var inputValue = event.target.value;
this.props.onChange(inputValue);
if (!this.props.disableSuggestions) {
this.updateSuggestions(inputValue.trim());
}
}
}, {
key: "onFocus",
value: function onFocus() {
var suggestions = this.state.suggestions;
var _this$props3 = this.props,
disableSuggestions = _this$props3.disableSuggestions,
value = _this$props3.value; // When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value
// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)
if (value && !disableSuggestions && !this.isUpdatingSuggestions && !(suggestions && suggestions.length)) {
// Ensure the suggestions are updated with the current input value
this.updateSuggestions(value.trim());
}
}
}, {
key: "onKeyDown",
value: function onKeyDown(event) {
var _this$state2 = this.state,
showSuggestions = _this$state2.showSuggestions,
selectedSuggestion = _this$state2.selectedSuggestion,
suggestions = _this$state2.suggestions,
loading = _this$state2.loading; // If the suggestions are not shown or loading, we shouldn't handle the arrow keys
// We shouldn't preventDefault to allow block arrow keys navigation
if (!showSuggestions || !suggestions.length || loading) {
// In the Windows version of Firefox the up and down arrows don't move the caret
// within an input field like they do for Mac Firefox/Chrome/Safari. This causes
// a form of focus trapping that is disruptive to the user experience. This disruption
// only happens if the caret is not in the first or last position in the text input.
// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747
switch (event.keyCode) {
// When UP is pressed, if the caret is at the start of the text, move it to the 0
// position.
case external_wp_keycodes_["UP"]:
{
if (0 !== event.target.selectionStart) {
event.stopPropagation();
event.preventDefault(); // Set the input caret to position 0
event.target.setSelectionRange(0, 0);
}
break;
}
// When DOWN is pressed, if the caret is not at the end of the text, move it to the
// last position.
case external_wp_keycodes_["DOWN"]:
{
if (this.props.value.length !== event.target.selectionStart) {
event.stopPropagation();
event.preventDefault(); // Set the input caret to the last position
event.target.setSelectionRange(this.props.value.length, this.props.value.length);
}
break;
}
}
return;
}
var suggestion = this.state.suggestions[this.state.selectedSuggestion];
switch (event.keyCode) {
case external_wp_keycodes_["UP"]:
{
event.stopPropagation();
event.preventDefault();
var previousIndex = !selectedSuggestion ? suggestions.length - 1 : selectedSuggestion - 1;
this.setState({
selectedSuggestion: previousIndex
});
break;
}
case external_wp_keycodes_["DOWN"]:
{
event.stopPropagation();
event.preventDefault();
var nextIndex = selectedSuggestion === null || selectedSuggestion === suggestions.length - 1 ? 0 : selectedSuggestion + 1;
this.setState({
selectedSuggestion: nextIndex
});
break;
}
case external_wp_keycodes_["TAB"]:
{
if (this.state.selectedSuggestion !== null) {
this.selectLink(suggestion); // Announce a link has been selected when tabbing away from the input field.
this.props.speak(Object(external_wp_i18n_["__"])('Link selected.'));
}
break;
}
case external_wp_keycodes_["ENTER"]:
{
if (this.state.selectedSuggestion !== null) {
event.stopPropagation();
this.selectLink(suggestion);
}
break;
}
}
}
}, {
key: "selectLink",
value: function selectLink(suggestion) {
this.props.onChange(suggestion.url, suggestion);
this.setState({
selectedSuggestion: null,
showSuggestions: false
});
}
}, {
key: "handleOnClick",
value: function handleOnClick(suggestion) {
this.selectLink(suggestion); // Move focus to the input field when a link suggestion is clicked.
this.inputRef.current.focus();
}
}, {
key: "render",
value: function render() {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, this.renderControl(), this.renderSuggestions());
}
}, {
key: "renderControl",
value: function renderControl() {
var _this$props4 = this.props,
label = _this$props4.label,
className = _this$props4.className,
isFullWidth = _this$props4.isFullWidth,
instanceId = _this$props4.instanceId,
_this$props4$placehol = _this$props4.placeholder,
placeholder = _this$props4$placehol === void 0 ? Object(external_wp_i18n_["__"])('Paste URL or type to search') : _this$props4$placehol,
renderControl = _this$props4.__experimentalRenderControl,
_this$props4$value = _this$props4.value,
value = _this$props4$value === void 0 ? '' : _this$props4$value;
var _this$state3 = this.state,
loading = _this$state3.loading,
showSuggestions = _this$state3.showSuggestions,
selectedSuggestion = _this$state3.selectedSuggestion,
suggestionsListboxId = _this$state3.suggestionsListboxId,
suggestionOptionIdPrefix = _this$state3.suggestionOptionIdPrefix;
var controlProps = {
id: "url-input-control-".concat(instanceId),
label: label,
className: classnames_default()('block-editor-url-input', className, {
'is-full-width': isFullWidth
})
};
var inputProps = {
value: value,
required: true,
className: 'block-editor-url-input__input',
type: 'text',
onChange: this.onChange,
onFocus: this.onFocus,
placeholder: placeholder,
onKeyDown: this.onKeyDown,
role: 'combobox',
'aria-label': Object(external_wp_i18n_["__"])('URL'),
'aria-expanded': showSuggestions,
'aria-autocomplete': 'list',
'aria-owns': suggestionsListboxId,
'aria-activedescendant': selectedSuggestion !== null ? "".concat(suggestionOptionIdPrefix, "-").concat(selectedSuggestion) : undefined,
ref: this.inputRef
};
if (renderControl) {
return renderControl(controlProps, inputProps, loading);
}
return Object(external_wp_element_["createElement"])(external_wp_components_["BaseControl"], controlProps, Object(external_wp_element_["createElement"])("input", inputProps), loading && Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null));
}
}, {
key: "renderSuggestions",
value: function renderSuggestions() {
var _this5 = this;
var _this$props5 = this.props,
className = _this$props5.className,
renderSuggestions = _this$props5.__experimentalRenderSuggestions,
_this$props5$value = _this$props5.value,
value = _this$props5$value === void 0 ? '' : _this$props5$value,
_this$props5$__experi = _this$props5.__experimentalShowInitialSuggestions,
__experimentalShowInitialSuggestions = _this$props5$__experi === void 0 ? false : _this$props5$__experi;
var _this$state4 = this.state,
showSuggestions = _this$state4.showSuggestions,
suggestions = _this$state4.suggestions,
selectedSuggestion = _this$state4.selectedSuggestion,
suggestionsListboxId = _this$state4.suggestionsListboxId,
suggestionOptionIdPrefix = _this$state4.suggestionOptionIdPrefix,
loading = _this$state4.loading;
var suggestionsListProps = {
id: suggestionsListboxId,
ref: this.autocompleteRef,
role: 'listbox'
};
var buildSuggestionItemProps = function buildSuggestionItemProps(suggestion, index) {
return {
role: 'option',
tabIndex: '-1',
id: "".concat(suggestionOptionIdPrefix, "-").concat(index),
ref: _this5.bindSuggestionNode(index),
'aria-selected': index === selectedSuggestion
};
};
if (Object(external_lodash_["isFunction"])(renderSuggestions) && showSuggestions && !!suggestions.length) {
return renderSuggestions({
suggestions: suggestions,
selectedSuggestion: selectedSuggestion,
suggestionsListProps: suggestionsListProps,
buildSuggestionItemProps: buildSuggestionItemProps,
isLoading: loading,
handleSuggestionClick: this.handleOnClick,
isInitialSuggestions: __experimentalShowInitialSuggestions && !(value && value.length)
});
}
if (!Object(external_lodash_["isFunction"])(renderSuggestions) && showSuggestions && !!suggestions.length) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], {
position: "bottom",
noArrow: true,
focusOnMount: false
}, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({}, suggestionsListProps, {
className: classnames_default()('block-editor-url-input__suggestions', "".concat(className, "__suggestions"))
}), suggestions.map(function (suggestion, index) {
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, buildSuggestionItemProps(suggestion, index), {
key: suggestion.id,
className: classnames_default()('block-editor-url-input__suggestion', {
'is-selected': index === selectedSuggestion
}),
onClick: function onClick() {
return _this5.handleOnClick(suggestion);
}
}), suggestion.title);
})));
}
return null;
}
}], [{
key: "getDerivedStateFromProps",
value: function getDerivedStateFromProps(_ref, _ref2) {
var value = _ref.value,
instanceId = _ref.instanceId,
disableSuggestions = _ref.disableSuggestions,
_ref$__experimentalSh = _ref.__experimentalShowInitialSuggestions,
__experimentalShowInitialSuggestions = _ref$__experimentalSh === void 0 ? false : _ref$__experimentalSh;
var showSuggestions = _ref2.showSuggestions;
var shouldShowSuggestions = showSuggestions;
var hasValue = value && value.length;
if (!__experimentalShowInitialSuggestions && !hasValue) {
shouldShowSuggestions = false;
}
if (disableSuggestions === true) {
shouldShowSuggestions = false;
}
return {
showSuggestions: shouldShowSuggestions,
suggestionsListboxId: "block-editor-url-input-suggestions-".concat(instanceId),
suggestionOptionIdPrefix: "block-editor-url-input-suggestion-".concat(instanceId)
};
}
}]);
return URLInput;
}(external_wp_element_["Component"]);
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
*/
/* harmony default export */ var url_input = (Object(external_wp_compose_["compose"])(external_wp_compose_["withSafeTimeout"], external_wp_components_["withSpokenMessages"], external_wp_compose_["withInstanceId"], Object(external_wp_data_["withSelect"])(function (select, props) {
// If a link suggestions handler is already provided then
// bail
if (Object(external_lodash_["isFunction"])(props.__experimentalFetchLinkSuggestions)) {
return;
}
var _select = select('core/block-editor'),
getSettings = _select.getSettings;
return {
__experimentalFetchLinkSuggestions: getSettings().__experimentalFetchLinkSuggestions
};
}))(url_input_URLInput));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-create-button.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var search_create_button_LinkControlSearchCreate = function LinkControlSearchCreate(_ref) {
var searchTerm = _ref.searchTerm,
onClick = _ref.onClick,
itemProps = _ref.itemProps,
isSelected = _ref.isSelected,
buttonText = _ref.buttonText;
if (!searchTerm) {
return null;
}
var text;
if (buttonText) {
text = Object(external_lodash_["isFunction"])(buttonText) ? buttonText(searchTerm) : buttonText;
} else {
text = Object(external_wp_element_["createInterpolateElement"])(Object(external_wp_i18n_["sprintf"])(
/* translators: %s: search term. */
Object(external_wp_i18n_["__"])('Create: %s'), searchTerm), {
mark: Object(external_wp_element_["createElement"])("mark", null)
});
}
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, itemProps, {
className: classnames_default()('block-editor-link-control__search-create block-editor-link-control__search-item', {
'is-selected': isSelected
}),
onClick: onClick
}), Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
className: "block-editor-link-control__search-item-icon",
icon: plus["a" /* default */]
}), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-header"
}, Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-title"
}, text)));
};
/* harmony default export */ var search_create_button = (search_create_button_LinkControlSearchCreate);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/globe.js
/**
* WordPress dependencies
*/
var globe = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "-2 -2 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M9 0C4.03 0 0 4.03 0 9s4.03 9 9 9 9-4.03 9-9-4.03-9-9-9zM1.11 9.68h2.51c.04.91.167 1.814.38 2.7H1.84c-.403-.85-.65-1.764-.73-2.7zm8.57-5.4V1.19c.964.366 1.756 1.08 2.22 2 .205.347.386.708.54 1.08l-2.76.01zm3.22 1.35c.232.883.37 1.788.41 2.7H9.68v-2.7h3.22zM8.32 1.19v3.09H5.56c.154-.372.335-.733.54-1.08.462-.924 1.255-1.64 2.22-2.01zm0 4.44v2.7H4.7c.04-.912.178-1.817.41-2.7h3.21zm-4.7 2.69H1.11c.08-.936.327-1.85.73-2.7H4c-.213.886-.34 1.79-.38 2.7zM4.7 9.68h3.62v2.7H5.11c-.232-.883-.37-1.788-.41-2.7zm3.63 4v3.09c-.964-.366-1.756-1.08-2.22-2-.205-.347-.386-.708-.54-1.08l2.76-.01zm1.35 3.09v-3.04h2.76c-.154.372-.335.733-.54 1.08-.464.92-1.256 1.634-2.22 2v-.04zm0-4.44v-2.7h3.62c-.04.912-.178 1.817-.41 2.7H9.68zm4.71-2.7h2.51c-.08.936-.327 1.85-.73 2.7H14c.21-.87.337-1.757.38-2.65l.01-.05zm0-1.35c-.046-.894-.176-1.78-.39-2.65h2.16c.403.85.65 1.764.73 2.7l-2.5-.05zm1-4H13.6c-.324-.91-.793-1.76-1.39-2.52 1.244.56 2.325 1.426 3.14 2.52h.04zm-9.6-2.52c-.597.76-1.066 1.61-1.39 2.52H2.65c.815-1.094 1.896-1.96 3.14-2.52zm-3.15 12H4.4c.324.91.793 1.76 1.39 2.52-1.248-.567-2.33-1.445-3.14-2.55l-.01.03zm9.56 2.52c.597-.76 1.066-1.61 1.39-2.52h1.76c-.82 1.08-1.9 1.933-3.14 2.48l-.01.04z"
}));
/* harmony default export */ var library_globe = (globe);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-item.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var search_item_LinkControlSearchItem = function LinkControlSearchItem(_ref) {
var itemProps = _ref.itemProps,
suggestion = _ref.suggestion,
_ref$isSelected = _ref.isSelected,
isSelected = _ref$isSelected === void 0 ? false : _ref$isSelected,
onClick = _ref.onClick,
_ref$isURL = _ref.isURL,
isURL = _ref$isURL === void 0 ? false : _ref$isURL,
_ref$searchTerm = _ref.searchTerm,
searchTerm = _ref$searchTerm === void 0 ? '' : _ref$searchTerm,
_ref$shouldShowType = _ref.shouldShowType,
shouldShowType = _ref$shouldShowType === void 0 ? false : _ref$shouldShowType;
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, itemProps, {
onClick: onClick,
className: classnames_default()('block-editor-link-control__search-item', {
'is-selected': isSelected,
'is-url': isURL,
'is-entity': !isURL
})
}), isURL && Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
className: "block-editor-link-control__search-item-icon",
icon: library_globe
}), Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-header"
}, Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-title"
}, Object(external_wp_element_["createElement"])(external_wp_components_["TextHighlight"], {
text: suggestion.title,
highlight: searchTerm
})), Object(external_wp_element_["createElement"])("span", {
"aria-hidden": !isURL,
className: "block-editor-link-control__search-item-info"
}, !isURL && (Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(suggestion.url)) || ''), isURL && Object(external_wp_i18n_["__"])('Press ENTER to add this link'))), shouldShowType && suggestion.type && Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-type"
}, suggestion.type === 'post_tag' ? 'tag' : suggestion.type));
};
/* harmony default export */ var search_item = (search_item_LinkControlSearchItem);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/constants.js
// Used as a unique identifier for the "Create" option within search results.
// Used to help distinguish the "Create" suggestion within the search results in
// order to handle it as a unique case.
var CREATE_TYPE = '__CREATE__';
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-results.js
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
/**
* Internal dependencies
*/
function LinkControlSearchResults(_ref) {
var instanceId = _ref.instanceId,
withCreateSuggestion = _ref.withCreateSuggestion,
currentInputValue = _ref.currentInputValue,
handleSuggestionClick = _ref.handleSuggestionClick,
suggestionsListProps = _ref.suggestionsListProps,
buildSuggestionItemProps = _ref.buildSuggestionItemProps,
suggestions = _ref.suggestions,
selectedSuggestion = _ref.selectedSuggestion,
isLoading = _ref.isLoading,
isInitialSuggestions = _ref.isInitialSuggestions,
createSuggestionButtonText = _ref.createSuggestionButtonText,
suggestionsQuery = _ref.suggestionsQuery;
var resultsListClasses = classnames_default()('block-editor-link-control__search-results', {
'is-loading': isLoading
});
var directLinkEntryTypes = ['url', 'mailto', 'tel', 'internal'];
var isSingleDirectEntryResult = suggestions.length === 1 && directLinkEntryTypes.includes(suggestions[0].type.toLowerCase());
var shouldShowCreateSuggestion = withCreateSuggestion && !isSingleDirectEntryResult && !isInitialSuggestions; // If the query has a specified type, then we can skip showing them in the result. See #24839.
var shouldShowSuggestionsTypes = !(suggestionsQuery !== null && suggestionsQuery !== void 0 && suggestionsQuery.type); // According to guidelines aria-label should be added if the label
// itself is not visible.
// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role
var searchResultsLabelId = "block-editor-link-control-search-results-label-".concat(instanceId);
var labelText = isInitialSuggestions ? Object(external_wp_i18n_["__"])('Recently updated') : Object(external_wp_i18n_["sprintf"])(
/* translators: %s: search term. */
Object(external_wp_i18n_["__"])('Search results for "%s"'), currentInputValue); // VisuallyHidden rightly doesn't accept custom classNames
// so we conditionally render it as a wrapper to visually hide the label
// when that is required.
var searchResultsLabel = Object(external_wp_element_["createElement"])(isInitialSuggestions ? external_wp_element_["Fragment"] : external_wp_components_["VisuallyHidden"], {}, // empty props
Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-results-label",
id: searchResultsLabelId
}, labelText));
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-link-control__search-results-wrapper"
}, searchResultsLabel, Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({}, suggestionsListProps, {
className: resultsListClasses,
"aria-labelledby": searchResultsLabelId
}), suggestions.map(function (suggestion, index) {
if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
return Object(external_wp_element_["createElement"])(search_create_button, {
searchTerm: currentInputValue,
buttonText: createSuggestionButtonText,
onClick: function onClick() {
return handleSuggestionClick(suggestion);
} // Intentionally only using `type` here as
// the constant is enough to uniquely
// identify the single "CREATE" suggestion.
,
key: suggestion.type,
itemProps: buildSuggestionItemProps(suggestion, index),
isSelected: index === selectedSuggestion
});
} // If we're not handling "Create" suggestions above then
// we don't want them in the main results so exit early
if (CREATE_TYPE === suggestion.type) {
return null;
}
return Object(external_wp_element_["createElement"])(search_item, {
key: "".concat(suggestion.id, "-").concat(suggestion.type),
itemProps: buildSuggestionItemProps(suggestion, index),
suggestion: suggestion,
index: index,
onClick: function onClick() {
handleSuggestionClick(suggestion);
},
isSelected: index === selectedSuggestion,
isURL: directLinkEntryTypes.includes(suggestion.type.toLowerCase()),
searchTerm: currentInputValue,
shouldShowType: shouldShowSuggestionsTypes
});
})));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/is-url-like.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Determines whether a given value could be a URL. Note this does not
* guarantee the value is a URL only that it looks like it might be one. For
* example, just because a string has `www.` in it doesn't make it a URL,
* but it does make it highly likely that it will be so in the context of
* creating a link it makes sense to treat it like one.
*
* @param {string} val the candidate for being URL-like (or not).
* @return {boolean} whether or not the value is potentially a URL.
*/
function isURLLike(val) {
var isInternal = Object(external_lodash_["startsWith"])(val, '#');
return Object(external_wp_url_["isURL"])(val) || val && val.includes('www.') || isInternal;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-search-handler.js
function use_search_handler_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function use_search_handler_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { use_search_handler_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { use_search_handler_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* External dependencies
*/
/**
* Internal dependencies
*/
var handleNoop = function handleNoop() {
return Promise.resolve([]);
};
var use_search_handler_handleDirectEntry = function handleDirectEntry(val) {
var type = 'URL';
var protocol = Object(external_wp_url_["getProtocol"])(val) || '';
if (protocol.includes('mailto')) {
type = 'mailto';
}
if (protocol.includes('tel')) {
type = 'tel';
}
if (Object(external_lodash_["startsWith"])(val, '#')) {
type = 'internal';
}
return Promise.resolve([{
id: val,
title: val,
url: type === 'URL' ? Object(external_wp_url_["prependHTTP"])(val) : val,
type: type
}]);
};
var handleEntitySearch = /*#__PURE__*/function () {
var _ref = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(val, suggestionsQuery, fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion) {
var isInitialSuggestions, results, couldBeURL;
return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
isInitialSuggestions = suggestionsQuery.isInitialSuggestions;
_context.next = 3;
return Promise.all([fetchSearchSuggestions(val, suggestionsQuery), directEntryHandler(val)]);
case 3:
results = _context.sent;
couldBeURL = !val.includes(' '); // If it's potentially a URL search then concat on a URL search suggestion
// just for good measure. That way once the actual results run out we always
// have a URL option to fallback on.
if (couldBeURL && withURLSuggestion && !isInitialSuggestions) {
results = results[0].concat(results[1]);
} else {
results = results[0];
} // If displaying initial suggestions just return plain results.
if (!isInitialSuggestions) {
_context.next = 8;
break;
}
return _context.abrupt("return", results);
case 8:
return _context.abrupt("return", isURLLike(val) || !withCreateSuggestion ? results : results.concat({
// the `id` prop is intentionally ommitted here because it
// is never exposed as part of the component's public API.
// see: https://github.com/WordPress/gutenberg/pull/19775#discussion_r378931316.
title: val,
// must match the existing ``s text value
url: val,
// must match the existing ``s text value
type: CREATE_TYPE
}));
case 9:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function handleEntitySearch(_x, _x2, _x3, _x4, _x5, _x6) {
return _ref.apply(this, arguments);
};
}();
function useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion) {
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSettings = _select.getSettings;
return {
fetchSearchSuggestions: getSettings().__experimentalFetchLinkSuggestions
};
}, []),
fetchSearchSuggestions = _useSelect.fetchSearchSuggestions;
var directEntryHandler = allowDirectEntry ? use_search_handler_handleDirectEntry : handleNoop;
return Object(external_wp_element_["useCallback"])(function (val, _ref2) {
var isInitialSuggestions = _ref2.isInitialSuggestions;
return isURLLike(val) ? directEntryHandler(val, {
isInitialSuggestions: isInitialSuggestions
}) : handleEntitySearch(val, use_search_handler_objectSpread(use_search_handler_objectSpread({}, suggestionsQuery), {}, {
isInitialSuggestions: isInitialSuggestions
}), fetchSearchSuggestions, directEntryHandler, withCreateSuggestion, withURLSuggestion);
}, [directEntryHandler, fetchSearchSuggestions, withCreateSuggestion]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/search-input.js
function search_input_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function search_input_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { search_input_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { search_input_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var noopSearchHandler = Promise.resolve([]);
var LinkControlSearchInput = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var value = _ref.value,
children = _ref.children,
_ref$currentLink = _ref.currentLink,
currentLink = _ref$currentLink === void 0 ? {} : _ref$currentLink,
_ref$className = _ref.className,
className = _ref$className === void 0 ? null : _ref$className,
_ref$placeholder = _ref.placeholder,
placeholder = _ref$placeholder === void 0 ? null : _ref$placeholder,
_ref$withCreateSugges = _ref.withCreateSuggestion,
withCreateSuggestion = _ref$withCreateSugges === void 0 ? false : _ref$withCreateSugges,
_ref$onCreateSuggesti = _ref.onCreateSuggestion,
onCreateSuggestion = _ref$onCreateSuggesti === void 0 ? external_lodash_["noop"] : _ref$onCreateSuggesti,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange,
_ref$onSelect = _ref.onSelect,
onSelect = _ref$onSelect === void 0 ? external_lodash_["noop"] : _ref$onSelect,
_ref$showSuggestions = _ref.showSuggestions,
showSuggestions = _ref$showSuggestions === void 0 ? true : _ref$showSuggestions,
_ref$renderSuggestion = _ref.renderSuggestions,
renderSuggestions = _ref$renderSuggestion === void 0 ? function (props) {
return Object(external_wp_element_["createElement"])(LinkControlSearchResults, props);
} : _ref$renderSuggestion,
_ref$fetchSuggestions = _ref.fetchSuggestions,
fetchSuggestions = _ref$fetchSuggestions === void 0 ? null : _ref$fetchSuggestions,
_ref$allowDirectEntry = _ref.allowDirectEntry,
allowDirectEntry = _ref$allowDirectEntry === void 0 ? true : _ref$allowDirectEntry,
_ref$showInitialSugge = _ref.showInitialSuggestions,
showInitialSuggestions = _ref$showInitialSugge === void 0 ? false : _ref$showInitialSugge,
_ref$suggestionsQuery = _ref.suggestionsQuery,
suggestionsQuery = _ref$suggestionsQuery === void 0 ? {} : _ref$suggestionsQuery,
_ref$withURLSuggestio = _ref.withURLSuggestion,
withURLSuggestion = _ref$withURLSuggestio === void 0 ? true : _ref$withURLSuggestio,
createSuggestionButtonText = _ref.createSuggestionButtonText;
var genericSearchHandler = useSearchHandler(suggestionsQuery, allowDirectEntry, withCreateSuggestion, withURLSuggestion);
var searchHandler = showSuggestions ? fetchSuggestions || genericSearchHandler : noopSearchHandler;
var instanceId = Object(external_wp_compose_["useInstanceId"])(LinkControlSearchInput);
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
focusedSuggestion = _useState2[0],
setFocusedSuggestion = _useState2[1];
/**
* Handles the user moving between different suggestions. Does not handle
* choosing an individual item.
*
* @param {string} selection the url of the selected suggestion.
* @param {Object} suggestion the suggestion object.
*/
var onInputChange = function onInputChange(selection, suggestion) {
onChange(selection);
setFocusedSuggestion(suggestion);
};
var onFormSubmit = function onFormSubmit(event) {
event.preventDefault();
onSuggestionSelected(focusedSuggestion || {
url: value
});
};
var handleRenderSuggestions = function handleRenderSuggestions(props) {
return renderSuggestions(search_input_objectSpread(search_input_objectSpread({}, props), {}, {
instanceId: instanceId,
withCreateSuggestion: withCreateSuggestion,
currentInputValue: value,
createSuggestionButtonText: createSuggestionButtonText,
suggestionsQuery: suggestionsQuery,
handleSuggestionClick: function handleSuggestionClick(suggestion) {
if (props.handleSuggestionClick) {
props.handleSuggestionClick(suggestion);
}
onSuggestionSelected(suggestion);
}
}));
};
var onSuggestionSelected = /*#__PURE__*/function () {
var _ref2 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(selectedSuggestion) {
var suggestion, _suggestion;
return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
suggestion = selectedSuggestion;
if (!(CREATE_TYPE === selectedSuggestion.type)) {
_context.next = 12;
break;
}
_context.prev = 2;
_context.next = 5;
return onCreateSuggestion(selectedSuggestion.title);
case 5:
suggestion = _context.sent;
if ((_suggestion = suggestion) !== null && _suggestion !== void 0 && _suggestion.url) {
onSelect(suggestion);
}
_context.next = 11;
break;
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](2);
case 11:
return _context.abrupt("return");
case 12:
if (allowDirectEntry || suggestion && Object.keys(suggestion).length >= 1) {
onSelect( // Some direct entries don't have types or IDs, and we still need to clear the previous ones.
search_input_objectSpread(search_input_objectSpread({}, Object(external_lodash_["omit"])(currentLink, 'id', 'url')), suggestion), suggestion);
}
case 13:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 9]]);
}));
return function onSuggestionSelected(_x) {
return _ref2.apply(this, arguments);
};
}();
return Object(external_wp_element_["createElement"])("form", {
onSubmit: onFormSubmit
}, Object(external_wp_element_["createElement"])(url_input, {
className: className,
value: value,
onChange: onInputChange,
placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : Object(external_wp_i18n_["__"])('Search or type url'),
__experimentalRenderSuggestions: showSuggestions ? handleRenderSuggestions : null,
__experimentalFetchLinkSuggestions: searchHandler,
__experimentalHandleURLSuggestions: true,
__experimentalShowInitialSuggestions: showInitialSuggestions,
ref: ref
}), children);
});
/* harmony default export */ var search_input = (LinkControlSearchInput);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/viewer-slot.js
/**
* WordPress dependencies
*/
var viewer_slot_createSlotFill = Object(external_wp_components_["createSlotFill"])('BlockEditorLinkControlViewer'),
ViewerSlot = viewer_slot_createSlotFill.Slot,
ViewerFill = viewer_slot_createSlotFill.Fill;
/* harmony default export */ var viewer_slot = (ViewerSlot);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/link-preview.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LinkPreview(_ref) {
var value = _ref.value,
onEditClick = _ref.onEditClick;
var displayURL = value && Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(value.url), 16) || '';
return Object(external_wp_element_["createElement"])("div", {
"aria-label": Object(external_wp_i18n_["__"])('Currently selected'),
"aria-selected": "true",
className: classnames_default()('block-editor-link-control__search-item', {
'is-current': true
})
}, Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-header"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
className: "block-editor-link-control__search-item-title",
href: value.url
}, value && value.title || displayURL), value && value.title && Object(external_wp_element_["createElement"])("span", {
className: "block-editor-link-control__search-item-info"
}, displayURL)), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSecondary: true,
onClick: function onClick() {
return onEditClick();
},
className: "block-editor-link-control__search-item-action"
}, Object(external_wp_i18n_["__"])('Edit')), Object(external_wp_element_["createElement"])(ViewerSlot, {
fillProps: value
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/use-create-page.js
/**
* WordPress dependencies
*/
function useCreatePage(handleCreatePage) {
var cancelableCreateSuggestion = Object(external_wp_element_["useRef"])();
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isCreatingPage = _useState2[0],
setIsCreatingPage = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(null),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
errorMessage = _useState4[0],
setErrorMessage = _useState4[1];
var createPage = /*#__PURE__*/function () {
var _ref = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(suggestionTitle) {
return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
setIsCreatingPage(true);
setErrorMessage(null);
_context.prev = 2;
// Make cancellable in order that we can avoid setting State
// if the component unmounts during the call to `createSuggestion`
cancelableCreateSuggestion.current = makeCancelable( // Using Promise.resolve to allow createSuggestion to return a
// non-Promise based value.
Promise.resolve(handleCreatePage(suggestionTitle)));
_context.next = 6;
return cancelableCreateSuggestion.current.promise;
case 6:
return _context.abrupt("return", _context.sent);
case 9:
_context.prev = 9;
_context.t0 = _context["catch"](2);
if (!(_context.t0 && _context.t0.isCanceled)) {
_context.next = 13;
break;
}
return _context.abrupt("return");
case 13:
setErrorMessage(_context.t0.message || Object(external_wp_i18n_["__"])('An unknown error occurred during creation. Please try again.'));
throw _context.t0;
case 15:
_context.prev = 15;
setIsCreatingPage(false);
return _context.finish(15);
case 18:
case "end":
return _context.stop();
}
}
}, _callee, null, [[2, 9, 15, 18]]);
}));
return function createPage(_x) {
return _ref.apply(this, arguments);
};
}();
/**
* Handles cancelling any pending Promises that have been made cancelable.
*/
Object(external_wp_element_["useEffect"])(function () {
return function () {
// componentDidUnmount
if (cancelableCreateSuggestion.current) {
cancelableCreateSuggestion.current.cancel();
}
};
}, []);
return {
createPage: createPage,
isCreatingPage: isCreatingPage,
errorMessage: errorMessage
};
}
/**
* Creates a wrapper around a promise which allows it to be programmatically
* cancelled.
* See: https://reactjs.org/blog/2015/12/16/ismounted-antipattern.html
*
* @param {Promise} promise the Promise to make cancelable
*/
var makeCancelable = function makeCancelable(promise) {
var hasCanceled_ = false;
var wrappedPromise = new Promise(function (resolve, reject) {
promise.then(function (val) {
return hasCanceled_ ? reject({
isCanceled: true
}) : resolve(val);
}, function (error) {
return hasCanceled_ ? reject({
isCanceled: true
}) : reject(error);
});
});
return {
promise: wrappedPromise,
cancel: function cancel() {
hasCanceled_ = true;
}
};
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/link-control/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Default properties associated with a link control value.
*
* @typedef WPLinkControlDefaultValue
*
* @property {string} url Link URL.
* @property {string=} title Link title.
* @property {boolean=} opensInNewTab Whether link should open in a new browser
* tab. This value is only assigned if not
* providing a custom `settings` prop.
*/
/* eslint-disable jsdoc/valid-types */
/**
* Custom settings values associated with a link.
*
* @typedef {{[setting:string]:any}} WPLinkControlSettingsValue
*/
/* eslint-enable */
/**
* Custom settings values associated with a link.
*
* @typedef WPLinkControlSetting
*
* @property {string} id Identifier to use as property for setting value.
* @property {string} title Human-readable label to show in user interface.
*/
/**
* Properties associated with a link control value, composed as a union of the
* default properties and any custom settings values.
*
* @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue
*/
/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */
/**
* Properties associated with a search suggestion used within the LinkControl.
*
* @typedef WPLinkControlSuggestion
*
* @property {string} id Identifier to use to uniquely identify the suggestion.
* @property {string} type Identifies the type of the suggestion (eg: `post`,
* `page`, `url`...etc)
* @property {string} title Human-readable label to show in user interface.
* @property {string} url A URL for the suggestion.
*/
/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */
/**
* @typedef WPLinkControlProps
*
* @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to
* render a `ToggleControl` for that setting.
* @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the
* internal editing state of the component to respective
* show or not show the URL input field.
* @property {WPLinkControlValue=} value Current link value.
* @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if
* the user selects a new link or updates settings.
* @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.
* @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.
* @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.
* @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
* @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
* @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
*/
/**
* Renders a link control. A link control is a controlled input which maintains
* a value associated with a link (HTML anchor element) and relevant settings
* for how that link is expected to behave.
*
* @param {WPLinkControlProps} props Component props.
*/
function LinkControl(_ref) {
var searchInputPlaceholder = _ref.searchInputPlaceholder,
value = _ref.value,
settings = _ref.settings,
_ref$onChange = _ref.onChange,
onChange = _ref$onChange === void 0 ? external_lodash_["noop"] : _ref$onChange,
_ref$noDirectEntry = _ref.noDirectEntry,
noDirectEntry = _ref$noDirectEntry === void 0 ? false : _ref$noDirectEntry,
_ref$showSuggestions = _ref.showSuggestions,
showSuggestions = _ref$showSuggestions === void 0 ? true : _ref$showSuggestions,
showInitialSuggestions = _ref.showInitialSuggestions,
forceIsEditingLink = _ref.forceIsEditingLink,
createSuggestion = _ref.createSuggestion,
withCreateSuggestion = _ref.withCreateSuggestion,
_ref$inputValue = _ref.inputValue,
propInputValue = _ref$inputValue === void 0 ? '' : _ref$inputValue,
_ref$suggestionsQuery = _ref.suggestionsQuery,
suggestionsQuery = _ref$suggestionsQuery === void 0 ? {} : _ref$suggestionsQuery,
_ref$noURLSuggestion = _ref.noURLSuggestion,
noURLSuggestion = _ref$noURLSuggestion === void 0 ? false : _ref$noURLSuggestion,
createSuggestionButtonText = _ref.createSuggestionButtonText;
if (withCreateSuggestion === undefined && createSuggestion) {
withCreateSuggestion = true;
}
var isMounting = Object(external_wp_element_["useRef"])(true);
var wrapperNode = Object(external_wp_element_["useRef"])();
var _useState = Object(external_wp_element_["useState"])(value && value.url || ''),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
internalInputValue = _useState2[0],
setInternalInputValue = _useState2[1];
var currentInputValue = propInputValue || internalInputValue;
var _useState3 = Object(external_wp_element_["useState"])(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isEditingLink = _useState4[0],
setIsEditingLink = _useState4[1];
var isEndingEditWithFocus = Object(external_wp_element_["useRef"])(false);
Object(external_wp_element_["useEffect"])(function () {
if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) {
setIsEditingLink(forceIsEditingLink);
}
}, [forceIsEditingLink]);
Object(external_wp_element_["useEffect"])(function () {
if (isMounting.current) {
isMounting.current = false;
return;
} // When `isEditingLink` changes, a focus loss could occur
// since the link input may be removed from the DOM. To avoid this,
// reinstate focus to a suitable target if focus has in-fact been lost.
// Note that the check is necessary because while typically unsetting
// edit mode would render the read-only mode's link element, it isn't
// guaranteed. The link input may continue to be shown if the next value
// is still unassigned after calling `onChange`.
var hadFocusLoss = !wrapperNode.current.contains(wrapperNode.current.ownerDocument.activeElement);
if (hadFocusLoss) {
// Prefer to focus a natural focusable descendent of the wrapper,
// but settle for the wrapper if there are no other options.
var nextFocusTarget = external_wp_dom_["focus"].focusable.find(wrapperNode.current)[0] || wrapperNode.current;
nextFocusTarget.focus();
}
isEndingEditWithFocus.current = false;
}, [isEditingLink]);
/**
* Cancels editing state and marks that focus may need to be restored after
* the next render, if focus was within the wrapper when editing finished.
*/
function stopEditing() {
var _wrapperNode$current;
isEndingEditWithFocus.current = !!((_wrapperNode$current = wrapperNode.current) !== null && _wrapperNode$current !== void 0 && _wrapperNode$current.contains(wrapperNode.current.ownerDocument.activeElement));
setIsEditingLink(false);
}
var _useCreatePage = useCreatePage(createSuggestion),
createPage = _useCreatePage.createPage,
isCreatingPage = _useCreatePage.isCreatingPage,
errorMessage = _useCreatePage.errorMessage;
var handleSelectSuggestion = function handleSelectSuggestion(updatedValue) {
onChange(updatedValue);
stopEditing();
};
return Object(external_wp_element_["createElement"])("div", {
tabIndex: -1,
ref: wrapperNode,
className: "block-editor-link-control"
}, isCreatingPage && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-link-control__loading"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Spinner"], null), " ", Object(external_wp_i18n_["__"])('Creating'), "\u2026"), (isEditingLink || !value) && !isCreatingPage && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-link-control__search-input-wrapper"
}, Object(external_wp_element_["createElement"])(search_input, {
currentLink: value,
className: "block-editor-link-control__search-input",
placeholder: searchInputPlaceholder,
value: currentInputValue,
withCreateSuggestion: withCreateSuggestion,
onCreateSuggestion: createPage,
onChange: setInternalInputValue,
onSelect: handleSelectSuggestion,
showInitialSuggestions: showInitialSuggestions,
allowDirectEntry: !noDirectEntry,
showSuggestions: showSuggestions,
suggestionsQuery: suggestionsQuery,
withURLSuggestion: !noURLSuggestion,
createSuggestionButtonText: createSuggestionButtonText
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-link-control__search-actions"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
type: "submit",
label: Object(external_wp_i18n_["__"])('Submit'),
icon: keyboard_return["a" /* default */],
className: "block-editor-link-control__search-submit"
})))), errorMessage && Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
className: "block-editor-link-control__search-error",
status: "error",
isDismissible: false
}, errorMessage)), value && !isEditingLink && !isCreatingPage && Object(external_wp_element_["createElement"])(LinkPreview, {
value: value,
onEditClick: function onEditClick() {
return setIsEditingLink(true);
}
}), Object(external_wp_element_["createElement"])(settings_drawer, {
value: value,
settings: settings,
onChange: onChange
}));
}
LinkControl.ViewerFill = ViewerFill;
/* harmony default export */ var link_control = (LinkControl);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/media.js
var library_media = __webpack_require__(308);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/upload.js
var upload = __webpack_require__(219);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/index.js
/**
* WordPress dependencies
*/
/**
* This is a placeholder for the media upload component necessary to make it possible to provide
* an integration with the core blocks that handle media files. By default it renders nothing but
* it provides a way to have it overridden with the `editor.MediaUpload` filter.
*
* @return {WPComponent} The component to be rendered.
*/
var MediaUpload = function MediaUpload() {
return null;
};
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
*/
/* harmony default export */ var media_upload = (Object(external_wp_components_["withFilters"])('editor.MediaUpload')(MediaUpload));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-upload/check.js
/**
* WordPress dependencies
*/
function MediaUploadCheck(_ref) {
var _ref$fallback = _ref.fallback,
fallback = _ref$fallback === void 0 ? null : _ref$fallback,
children = _ref.children;
var hasUploadPermissions = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSettings = _select.getSettings;
return !!getSettings().mediaUpload;
}, []);
return hasUploadPermissions ? children : fallback;
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-upload/README.md
*/
/* harmony default export */ var check = (MediaUploadCheck);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var media_replace_flow_MediaReplaceFlow = function MediaReplaceFlow(_ref) {
var mediaURL = _ref.mediaURL,
mediaId = _ref.mediaId,
allowedTypes = _ref.allowedTypes,
accept = _ref.accept,
onSelect = _ref.onSelect,
onSelectURL = _ref.onSelectURL,
_ref$onFilesUpload = _ref.onFilesUpload,
onFilesUpload = _ref$onFilesUpload === void 0 ? external_lodash_["noop"] : _ref$onFilesUpload,
_ref$name = _ref.name,
name = _ref$name === void 0 ? Object(external_wp_i18n_["__"])('Replace') : _ref$name,
createNotice = _ref.createNotice,
removeNotice = _ref.removeNotice;
var _useState = Object(external_wp_element_["useState"])(mediaURL),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
mediaURLValue = _useState2[0],
setMediaURLValue = _useState2[1];
var mediaUpload = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').getSettings().mediaUpload;
}, []);
var editMediaButtonRef = Object(external_wp_element_["createRef"])();
var errorNoticeID = Object(external_lodash_["uniqueId"])('block-editor/media-replace-flow/error-notice/');
var onError = function onError(message) {
var errorElement = document.createElement('div');
errorElement.innerHTML = Object(external_wp_element_["renderToString"])(message); // The default error contains some HTML that,
// for example, makes the filename bold.
// The notice, by default, accepts strings only and so
// we need to remove the html from the error.
var renderMsg = errorElement.textContent || errorElement.innerText || ''; // We need to set a timeout for showing the notice
// so that VoiceOver and possibly other screen readers
// can announce the error afer the toolbar button
// regains focus once the upload dialog closes.
// Otherwise VO simply skips over the notice and announces
// the focused element and the open menu.
setTimeout(function () {
createNotice('error', renderMsg, {
speak: true,
id: errorNoticeID,
isDismissible: true
});
}, 1000);
};
var selectMedia = function selectMedia(media) {
onSelect(media);
setMediaURLValue(media.url);
Object(external_wp_a11y_["speak"])(Object(external_wp_i18n_["__"])('The media file has been replaced'));
removeNotice(errorNoticeID);
};
var selectURL = function selectURL(newURL) {
onSelectURL(newURL);
};
var uploadFiles = function uploadFiles(event) {
var files = event.target.files;
onFilesUpload(files);
var setMedia = function setMedia(_ref2) {
var _ref3 = Object(slicedToArray["a" /* default */])(_ref2, 1),
media = _ref3[0];
selectMedia(media);
};
mediaUpload({
allowedTypes: allowedTypes,
filesList: files,
onFileChange: setMedia,
onError: onError
});
};
var openOnArrowDown = function openOnArrowDown(event) {
if (event.keyCode === external_wp_keycodes_["DOWN"]) {
event.preventDefault();
event.stopPropagation();
event.target.click();
}
};
var POPOVER_PROPS = {
isAlternate: true
};
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
popoverProps: POPOVER_PROPS,
contentClassName: "block-editor-media-replace-flow__options",
renderToggle: function renderToggle(_ref4) {
var isOpen = _ref4.isOpen,
onToggle = _ref4.onToggle;
return Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarGroup"], {
className: "media-replace-flow"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
ref: editMediaButtonRef,
"aria-expanded": isOpen,
"aria-haspopup": "true",
onClick: onToggle,
onKeyDown: openOnArrowDown
}, name));
},
renderContent: function renderContent(_ref5) {
var onClose = _ref5.onClose;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], {
className: "block-editor-media-replace-flow__media-upload-menu"
}, Object(external_wp_element_["createElement"])(media_upload, {
value: mediaId,
onSelect: function onSelect(media) {
return selectMedia(media);
},
allowedTypes: allowedTypes,
render: function render(_ref6) {
var open = _ref6.open;
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
icon: library_media["a" /* default */],
onClick: open
}, Object(external_wp_i18n_["__"])('Open Media Library'));
}
}), Object(external_wp_element_["createElement"])(check, null, Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
onChange: function onChange(event) {
uploadFiles(event, onClose);
},
accept: accept,
render: function render(_ref7) {
var openFileDialog = _ref7.openFileDialog;
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
icon: upload["a" /* default */],
onClick: function onClick() {
openFileDialog();
}
}, Object(external_wp_i18n_["__"])('Upload'));
}
}))), onSelectURL && // eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
Object(external_wp_element_["createElement"])("form", {
className: "block-editor-media-flow__url-input",
onKeyDown: function onKeyDown(event) {
if (![external_wp_keycodes_["TAB"], external_wp_keycodes_["ESCAPE"]].includes(event.keyCode)) {
event.stopPropagation();
}
},
onKeyPress: function onKeyPress(event) {
if (![external_wp_keycodes_["TAB"], external_wp_keycodes_["ESCAPE"]].includes(event.keyCode)) {
event.stopPropagation();
}
}
}, Object(external_wp_element_["createElement"])("span", {
className: "block-editor-media-replace-flow__image-url-label"
}, Object(external_wp_i18n_["__"])('Current media URL:')), Object(external_wp_element_["createElement"])(link_control, {
value: {
url: mediaURLValue
},
settings: [],
showSuggestions: false,
onChange: function onChange(_ref8) {
var url = _ref8.url;
setMediaURLValue(url);
selectURL(url);
editMediaButtonRef.current.focus();
}
})));
}
});
};
/* harmony default export */ var media_replace_flow = (Object(external_wp_compose_["compose"])([Object(external_wp_data_["withDispatch"])(function (dispatch) {
var _dispatch = dispatch(external_wp_notices_["store"]),
createNotice = _dispatch.createNotice,
removeNotice = _dispatch.removeNotice;
return {
createNotice: createNotice,
removeNotice: removeNotice
};
}), Object(external_wp_components_["withFilters"])('editor.MediaReplaceFlow')])(media_replace_flow_MediaReplaceFlow));
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/edit.js + 1 modules
var library_edit = __webpack_require__(270);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer-url.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function LinkViewerURL(_ref) {
var url = _ref.url,
urlLabel = _ref.urlLabel,
className = _ref.className;
var linkClassName = classnames_default()(className, 'block-editor-url-popover__link-viewer-url');
if (!url) {
return Object(external_wp_element_["createElement"])("span", {
className: linkClassName
});
}
return Object(external_wp_element_["createElement"])(external_wp_components_["ExternalLink"], {
className: linkClassName,
href: url
}, urlLabel || Object(external_wp_url_["filterURLForDisplay"])(Object(external_wp_url_["safeDecodeURI"])(url)));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-viewer.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LinkViewer(_ref) {
var className = _ref.className,
linkClassName = _ref.linkClassName,
onEditLinkClick = _ref.onEditLinkClick,
url = _ref.url,
urlLabel = _ref.urlLabel,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["className", "linkClassName", "onEditLinkClick", "url", "urlLabel"]);
return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
className: classnames_default()('block-editor-url-popover__link-viewer', className)
}, props), Object(external_wp_element_["createElement"])(LinkViewerURL, {
url: url,
urlLabel: urlLabel,
className: linkClassName
}), onEditLinkClick && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: library_edit["a" /* default */],
label: Object(external_wp_i18n_["__"])('Edit'),
onClick: onEditLinkClick
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/link-editor.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function LinkEditor(_ref) {
var autocompleteRef = _ref.autocompleteRef,
className = _ref.className,
onChangeInputValue = _ref.onChangeInputValue,
value = _ref.value,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["autocompleteRef", "className", "onChangeInputValue", "value"]);
return Object(external_wp_element_["createElement"])("form", Object(esm_extends["a" /* default */])({
className: classnames_default()('block-editor-url-popover__link-editor', className)
}, props), Object(external_wp_element_["createElement"])(url_input, {
value: value,
onChange: onChangeInputValue,
autocompleteRef: autocompleteRef
}), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: keyboard_return["a" /* default */],
label: Object(external_wp_i18n_["__"])('Apply'),
type: "submit"
}));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function URLPopover(_ref) {
var additionalControls = _ref.additionalControls,
children = _ref.children,
renderSettings = _ref.renderSettings,
_ref$position = _ref.position,
position = _ref$position === void 0 ? 'bottom center' : _ref$position,
_ref$focusOnMount = _ref.focusOnMount,
focusOnMount = _ref$focusOnMount === void 0 ? 'firstElement' : _ref$focusOnMount,
popoverProps = Object(objectWithoutProperties["a" /* default */])(_ref, ["additionalControls", "children", "renderSettings", "position", "focusOnMount"]);
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isSettingsExpanded = _useState2[0],
setIsSettingsExpanded = _useState2[1];
var showSettings = !!renderSettings && isSettingsExpanded;
var toggleSettingsVisibility = function toggleSettingsVisibility() {
setIsSettingsExpanded(!isSettingsExpanded);
};
return Object(external_wp_element_["createElement"])(external_wp_components_["Popover"], Object(esm_extends["a" /* default */])({
className: "block-editor-url-popover",
focusOnMount: focusOnMount,
position: position
}, popoverProps), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-popover__input-container"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-popover__row"
}, children, !!renderSettings && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-url-popover__settings-toggle",
icon: chevron_down["a" /* default */],
label: Object(external_wp_i18n_["__"])('Link settings'),
onClick: toggleSettingsVisibility,
"aria-expanded": isSettingsExpanded
})), showSettings && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-popover__row block-editor-url-popover__settings"
}, renderSettings())), additionalControls && !showSettings && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-popover__additional-controls"
}, additionalControls));
}
URLPopover.LinkEditor = LinkEditor;
URLPopover.LinkViewer = LinkViewer;
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-popover/README.md
*/
/* harmony default export */ var url_popover = (URLPopover);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-placeholder/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var media_placeholder_InsertFromURLPopover = function InsertFromURLPopover(_ref) {
var src = _ref.src,
onChange = _ref.onChange,
onSubmit = _ref.onSubmit,
onClose = _ref.onClose;
return Object(external_wp_element_["createElement"])(url_popover, {
onClose: onClose
}, Object(external_wp_element_["createElement"])("form", {
className: "block-editor-media-placeholder__url-input-form",
onSubmit: onSubmit
}, Object(external_wp_element_["createElement"])("input", {
className: "block-editor-media-placeholder__url-input-field",
type: "url",
"aria-label": Object(external_wp_i18n_["__"])('URL'),
placeholder: Object(external_wp_i18n_["__"])('Paste or type URL'),
onChange: onChange,
value: src
}), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-media-placeholder__url-input-submit-button",
icon: keyboard_return["a" /* default */],
label: Object(external_wp_i18n_["__"])('Apply'),
type: "submit"
})));
};
function MediaPlaceholder(_ref2) {
var _ref2$value = _ref2.value,
value = _ref2$value === void 0 ? {} : _ref2$value,
allowedTypes = _ref2.allowedTypes,
className = _ref2.className,
icon = _ref2.icon,
_ref2$labels = _ref2.labels,
labels = _ref2$labels === void 0 ? {} : _ref2$labels,
mediaPreview = _ref2.mediaPreview,
notices = _ref2.notices,
isAppender = _ref2.isAppender,
accept = _ref2.accept,
addToGallery = _ref2.addToGallery,
_ref2$multiple = _ref2.multiple,
multiple = _ref2$multiple === void 0 ? false : _ref2$multiple,
dropZoneUIOnly = _ref2.dropZoneUIOnly,
disableDropZone = _ref2.disableDropZone,
disableMediaButtons = _ref2.disableMediaButtons,
onError = _ref2.onError,
onSelect = _ref2.onSelect,
onCancel = _ref2.onCancel,
onSelectURL = _ref2.onSelectURL,
onDoubleClick = _ref2.onDoubleClick,
_ref2$onFilesPreUploa = _ref2.onFilesPreUpload,
onFilesPreUpload = _ref2$onFilesPreUploa === void 0 ? external_lodash_["noop"] : _ref2$onFilesPreUploa,
_ref2$onHTMLDrop = _ref2.onHTMLDrop,
onHTMLDrop = _ref2$onHTMLDrop === void 0 ? external_lodash_["noop"] : _ref2$onHTMLDrop,
children = _ref2.children;
var mediaUpload = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSettings = _select.getSettings;
return getSettings().mediaUpload;
}, []);
var _useState = Object(external_wp_element_["useState"])(''),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
src = _useState2[0],
setSrc = _useState2[1];
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isURLInputVisible = _useState4[0],
setIsURLInputVisible = _useState4[1];
Object(external_wp_element_["useEffect"])(function () {
var _value$src;
setSrc((_value$src = value === null || value === void 0 ? void 0 : value.src) !== null && _value$src !== void 0 ? _value$src : '');
}, [value === null || value === void 0 ? void 0 : value.src]);
var onlyAllowsImages = function onlyAllowsImages() {
if (!allowedTypes || allowedTypes.length === 0) {
return false;
}
return allowedTypes.every(function (allowedType) {
return allowedType === 'image' || allowedType.startsWith('image/');
});
};
var onChangeSrc = function onChangeSrc(event) {
setSrc(event.target.value);
};
var openURLInput = function openURLInput() {
setIsURLInputVisible(true);
};
var closeURLInput = function closeURLInput() {
setIsURLInputVisible(false);
};
var onSubmitSrc = function onSubmitSrc(event) {
event.preventDefault();
if (src && onSelectURL) {
onSelectURL(src);
closeURLInput();
}
};
var onFilesUpload = function onFilesUpload(files) {
onFilesPreUpload(files);
var setMedia;
if (multiple) {
if (addToGallery) {
// Since the setMedia function runs multiple times per upload group
// and is passed newMedia containing every item in its group each time, we must
// filter out whatever this upload group had previously returned to the
// gallery before adding and returning the image array with replacement newMedia
// values.
// Define an array to store urls from newMedia between subsequent function calls.
var lastMediaPassed = [];
setMedia = function setMedia(newMedia) {
// Remove any images this upload group is responsible for (lastMediaPassed).
// Their replacements are contained in newMedia.
var filteredMedia = (value !== null && value !== void 0 ? value : []).filter(function (item) {
// If Item has id, only remove it if lastMediaPassed has an item with that id.
if (item.id) {
return !lastMediaPassed.some( // Be sure to convert to number for comparison.
function (_ref3) {
var id = _ref3.id;
return Number(id) === Number(item.id);
});
} // Compare transient images via .includes since gallery may append extra info onto the url.
return !lastMediaPassed.some(function (_ref4) {
var urlSlug = _ref4.urlSlug;
return item.url.includes(urlSlug);
});
}); // Return the filtered media array along with newMedia.
onSelect(filteredMedia.concat(newMedia)); // Reset lastMediaPassed and set it with ids and urls from newMedia.
lastMediaPassed = newMedia.map(function (media) {
// Add everything up to '.fileType' to compare via .includes.
var cutOffIndex = media.url.lastIndexOf('.');
var urlSlug = media.url.slice(0, cutOffIndex);
return {
id: media.id,
urlSlug: urlSlug
};
});
};
} else {
setMedia = onSelect;
}
} else {
setMedia = function setMedia(_ref5) {
var _ref6 = Object(slicedToArray["a" /* default */])(_ref5, 1),
media = _ref6[0];
return onSelect(media);
};
}
mediaUpload({
allowedTypes: allowedTypes,
filesList: files,
onFileChange: setMedia,
onError: onError
});
};
var onUpload = function onUpload(event) {
onFilesUpload(event.target.files);
};
var renderPlaceholder = function renderPlaceholder(content, onClick) {
var instructions = labels.instructions,
title = labels.title;
if (!mediaUpload && !onSelectURL) {
instructions = Object(external_wp_i18n_["__"])('To edit this block, you need permission to upload media.');
}
if (instructions === undefined || title === undefined) {
var typesAllowed = allowedTypes !== null && allowedTypes !== void 0 ? allowedTypes : [];
var _typesAllowed = Object(slicedToArray["a" /* default */])(typesAllowed, 1),
firstAllowedType = _typesAllowed[0];
var isOneType = 1 === typesAllowed.length;
var isAudio = isOneType && 'audio' === firstAllowedType;
var isImage = isOneType && 'image' === firstAllowedType;
var isVideo = isOneType && 'video' === firstAllowedType;
if (instructions === undefined && mediaUpload) {
instructions = Object(external_wp_i18n_["__"])('Upload a media file or pick one from your media library.');
if (isAudio) {
instructions = Object(external_wp_i18n_["__"])('Upload an audio file, pick one from your media library, or add one with a URL.');
} else if (isImage) {
instructions = Object(external_wp_i18n_["__"])('Upload an image file, pick one from your media library, or add one with a URL.');
} else if (isVideo) {
instructions = Object(external_wp_i18n_["__"])('Upload a video file, pick one from your media library, or add one with a URL.');
}
}
if (title === undefined) {
title = Object(external_wp_i18n_["__"])('Media');
if (isAudio) {
title = Object(external_wp_i18n_["__"])('Audio');
} else if (isImage) {
title = Object(external_wp_i18n_["__"])('Image');
} else if (isVideo) {
title = Object(external_wp_i18n_["__"])('Video');
}
}
}
var placeholderClassName = classnames_default()('block-editor-media-placeholder', className, {
'is-appender': isAppender
});
return Object(external_wp_element_["createElement"])(external_wp_components_["Placeholder"], {
icon: icon,
label: title,
instructions: instructions,
className: placeholderClassName,
notices: notices,
onClick: onClick,
onDoubleClick: onDoubleClick,
preview: mediaPreview
}, content, children);
};
var renderDropZone = function renderDropZone() {
if (disableDropZone) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_components_["DropZone"], {
onFilesDrop: onFilesUpload,
onHTMLDrop: onHTMLDrop
});
};
var renderCancelLink = function renderCancelLink() {
return onCancel && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-media-placeholder__cancel-button",
title: Object(external_wp_i18n_["__"])('Cancel'),
isLink: true,
onClick: onCancel
}, Object(external_wp_i18n_["__"])('Cancel'));
};
var renderUrlSelectionUI = function renderUrlSelectionUI() {
return onSelectURL && Object(external_wp_element_["createElement"])("div", {
className: "block-editor-media-placeholder__url-input-container"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-media-placeholder__button",
onClick: openURLInput,
isPressed: isURLInputVisible,
isTertiary: true
}, Object(external_wp_i18n_["__"])('Insert from URL')), isURLInputVisible && Object(external_wp_element_["createElement"])(media_placeholder_InsertFromURLPopover, {
src: src,
onChange: onChangeSrc,
onSubmit: onSubmitSrc,
onClose: closeURLInput
}));
};
var renderMediaUploadChecked = function renderMediaUploadChecked() {
var mediaLibraryButton = Object(external_wp_element_["createElement"])(media_upload, {
addToGallery: addToGallery,
gallery: multiple && onlyAllowsImages(),
multiple: multiple,
onSelect: onSelect,
allowedTypes: allowedTypes,
value: Array.isArray(value) ? value.map(function (_ref7) {
var id = _ref7.id;
return id;
}) : value.id,
render: function render(_ref8) {
var open = _ref8.open;
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isTertiary: true,
onClick: function onClick(event) {
event.stopPropagation();
open();
}
}, Object(external_wp_i18n_["__"])('Media Library'));
}
});
if (mediaUpload && isAppender) {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, renderDropZone(), Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
onChange: onUpload,
accept: accept,
multiple: multiple,
render: function render(_ref9) {
var openFileDialog = _ref9.openFileDialog;
var content = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isPrimary: true,
className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button')
}, Object(external_wp_i18n_["__"])('Upload')), mediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
return renderPlaceholder(content, openFileDialog);
}
}));
}
if (mediaUpload) {
var content = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, renderDropZone(), Object(external_wp_element_["createElement"])(external_wp_components_["FormFileUpload"], {
isPrimary: true,
className: classnames_default()('block-editor-media-placeholder__button', 'block-editor-media-placeholder__upload-button'),
onChange: onUpload,
accept: accept,
multiple: multiple
}, Object(external_wp_i18n_["__"])('Upload')), mediaLibraryButton, renderUrlSelectionUI(), renderCancelLink());
return renderPlaceholder(content);
}
return renderPlaceholder(mediaLibraryButton);
};
if (dropZoneUIOnly || disableMediaButtons) {
if (dropZoneUIOnly) {
external_wp_deprecated_default()('wp.blockEditor.MediaPlaceholder dropZoneUIOnly prop', {
alternative: 'disableMediaButtons'
});
}
return Object(external_wp_element_["createElement"])(check, null, renderDropZone());
}
return Object(external_wp_element_["createElement"])(check, {
fallback: renderPlaceholder(renderUrlSelectionUI())
}, renderMediaUploadChecked());
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/media-placeholder/README.md
*/
/* harmony default export */ var media_placeholder = (Object(external_wp_components_["withFilters"])('editor.MediaPlaceholder')(MediaPlaceholder));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editable-text/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var EditableText = Object(external_wp_element_["forwardRef"])(function (props, ref) {
return Object(external_wp_element_["createElement"])(rich_text, Object(esm_extends["a" /* default */])({
ref: ref
}, props, {
__unstableDisableFormats: true,
preserveWhiteSpace: true
}));
});
EditableText.Content = function (_ref) {
var _ref$value = _ref.value,
value = _ref$value === void 0 ? '' : _ref$value,
_ref$tagName = _ref.tagName,
Tag = _ref$tagName === void 0 ? 'div' : _ref$tagName,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["value", "tagName"]);
return Object(external_wp_element_["createElement"])(Tag, props, value);
};
/**
* Renders an editable text input in which text formatting is not allowed.
*/
/* harmony default export */ var editable_text = (EditableText);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/plain-text/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/plain-text/README.md
*/
var PlainText = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var __experimentalVersion = _ref.__experimentalVersion,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["__experimentalVersion"]);
if (__experimentalVersion === 2) {
return Object(external_wp_element_["createElement"])(editable_text, Object(esm_extends["a" /* default */])({
ref: ref
}, props));
}
var className = props.className,
_onChange = props.onChange,
remainingProps = Object(objectWithoutProperties["a" /* default */])(props, ["className", "onChange"]);
return Object(external_wp_element_["createElement"])(lib_default.a, Object(esm_extends["a" /* default */])({
ref: ref,
className: classnames_default()('block-editor-plain-text', className),
onChange: function onChange(event) {
return _onChange(event.target.value);
}
}, remainingProps));
});
/* harmony default export */ var plain_text = (PlainText);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/label.js
/**
* WordPress dependencies
*/
function ResponsiveBlockControlLabel(_ref) {
var property = _ref.property,
viewport = _ref.viewport,
desc = _ref.desc;
var instanceId = Object(external_wp_compose_["useInstanceId"])(ResponsiveBlockControlLabel);
var accessibleLabel = desc || Object(external_wp_i18n_["sprintf"])(
/* translators: 1: property name. 2: viewport name. */
Object(external_wp_i18n_["_x"])('Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.'), property, viewport.label);
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])("span", {
"aria-describedby": "rbc-desc-".concat(instanceId)
}, viewport.label), Object(external_wp_element_["createElement"])(external_wp_components_["VisuallyHidden"], {
as: "span",
id: "rbc-desc-".concat(instanceId)
}, accessibleLabel));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/responsive-block-control/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function ResponsiveBlockControl(props) {
var title = props.title,
property = props.property,
toggleLabel = props.toggleLabel,
onIsResponsiveChange = props.onIsResponsiveChange,
renderDefaultControl = props.renderDefaultControl,
renderResponsiveControls = props.renderResponsiveControls,
_props$isResponsive = props.isResponsive,
isResponsive = _props$isResponsive === void 0 ? false : _props$isResponsive,
_props$defaultLabel = props.defaultLabel,
defaultLabel = _props$defaultLabel === void 0 ? {
id: 'all',
/* translators: 'Label. Used to signify a layout property (eg: margin, padding) will apply uniformly to all screensizes.' */
label: Object(external_wp_i18n_["__"])('All')
} : _props$defaultLabel,
_props$viewports = props.viewports,
viewports = _props$viewports === void 0 ? [{
id: 'small',
label: Object(external_wp_i18n_["__"])('Small screens')
}, {
id: 'medium',
label: Object(external_wp_i18n_["__"])('Medium screens')
}, {
id: 'large',
label: Object(external_wp_i18n_["__"])('Large screens')
}] : _props$viewports;
if (!title || !property || !renderDefaultControl) {
return null;
}
var toggleControlLabel = toggleLabel || Object(external_wp_i18n_["sprintf"])(
/* translators: 'Toggle control label. Should the property be the same across all screen sizes or unique per screen size.'. %s property value for the control (eg: margin, padding...etc) */
Object(external_wp_i18n_["__"])('Use the same %s on all screensizes.'), property);
/* translators: 'Help text for the responsive mode toggle control.' */
var toggleHelpText = Object(external_wp_i18n_["__"])('Toggle between using the same value for all screen sizes or using a unique value per screen size.');
var defaultControl = renderDefaultControl(Object(external_wp_element_["createElement"])(ResponsiveBlockControlLabel, {
property: property,
viewport: defaultLabel
}), defaultLabel);
var defaultResponsiveControls = function defaultResponsiveControls() {
return viewports.map(function (viewport) {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], {
key: viewport.id
}, renderDefaultControl(Object(external_wp_element_["createElement"])(ResponsiveBlockControlLabel, {
property: property,
viewport: viewport
}), viewport));
});
};
return Object(external_wp_element_["createElement"])("fieldset", {
className: "block-editor-responsive-block-control"
}, Object(external_wp_element_["createElement"])("legend", {
className: "block-editor-responsive-block-control__title"
}, title), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-responsive-block-control__inner"
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
className: "block-editor-responsive-block-control__toggle",
label: toggleControlLabel,
checked: !isResponsive,
onChange: onIsResponsiveChange,
help: toggleHelpText
}), Object(external_wp_element_["createElement"])("div", {
className: classnames_default()('block-editor-responsive-block-control__group', {
'is-responsive': isResponsive
})
}, !isResponsive && defaultControl, isResponsive && (renderResponsiveControls ? renderResponsiveControls(viewports) : defaultResponsiveControls()))));
}
/* harmony default export */ var responsive_block_control = (ResponsiveBlockControl);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/shortcut.js
/**
* WordPress dependencies
*/
function RichTextShortcut(_ref) {
var character = _ref.character,
type = _ref.type,
onUse = _ref.onUse;
var callback = function callback() {
onUse();
return false;
};
Object(external_wp_compose_["useKeyboardShortcut"])(external_wp_keycodes_["rawShortcut"][type](character), callback, {
bindGlobal: true
});
return null;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/toolbar-button.js
/**
* WordPress dependencies
*/
function RichTextToolbarButton(_ref) {
var name = _ref.name,
shortcutType = _ref.shortcutType,
shortcutCharacter = _ref.shortcutCharacter,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["name", "shortcutType", "shortcutCharacter"]);
var shortcut;
var fillName = 'RichText.ToolbarControls';
if (name) {
fillName += ".".concat(name);
}
if (shortcutType && shortcutCharacter) {
shortcut = external_wp_keycodes_["displayShortcut"][shortcutType](shortcutCharacter);
}
return Object(external_wp_element_["createElement"])(external_wp_components_["Fill"], {
name: fillName
}, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], Object(esm_extends["a" /* default */])({}, props, {
shortcut: shortcut
})));
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/rich-text/input-event.js
function input_event_createSuper(Derived) { var hasNativeReflectConstruct = input_event_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function input_event_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* WordPress dependencies
*/
var input_event_unstableRichTextInputEvent = /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(__unstableRichTextInputEvent, _Component);
var _super = input_event_createSuper(__unstableRichTextInputEvent);
function __unstableRichTextInputEvent() {
var _this;
Object(classCallCheck["a" /* default */])(this, __unstableRichTextInputEvent);
_this = _super.apply(this, arguments);
_this.onInput = _this.onInput.bind(Object(assertThisInitialized["a" /* default */])(_this));
return _this;
}
Object(createClass["a" /* default */])(__unstableRichTextInputEvent, [{
key: "onInput",
value: function onInput(event) {
if (event.inputType === this.props.inputType) {
this.props.onInput();
}
}
}, {
key: "componentDidMount",
value: function componentDidMount() {
document.addEventListener('input', this.onInput, true);
}
}, {
key: "componentWillUnmount",
value: function componentWillUnmount() {
document.removeEventListener('input', this.onInput, true);
}
}, {
key: "render",
value: function render() {
return null;
}
}]);
return __unstableRichTextInputEvent;
}(external_wp_element_["Component"]);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/tool-selector/index.js
/**
* WordPress dependencies
*/
var selectIcon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
width: "24",
height: "24",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M9.4 20.5L5.2 3.8l14.6 9-2 .3c-.2 0-.4.1-.7.1-.9.2-1.6.3-2.2.5-.8.3-1.4.5-1.8.8-.4.3-.8.8-1.3 1.5-.4.5-.8 1.2-1.2 2l-.3.6-.9 1.9zM7.6 7.1l2.4 9.3c.2-.4.5-.8.7-1.1.6-.8 1.1-1.4 1.6-1.8.5-.4 1.3-.8 2.2-1.1l1.2-.3-8.1-5z"
}));
function ToolSelector(props, ref) {
var isNavigationTool = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').isNavigationMode();
}, []);
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
setNavigationMode = _useDispatch.setNavigationMode;
var onSwitchMode = function onSwitchMode(mode) {
setNavigationMode(mode === 'edit' ? false : true);
};
return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
renderToggle: function renderToggle(_ref) {
var isOpen = _ref.isOpen,
onToggle = _ref.onToggle;
return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], Object(esm_extends["a" /* default */])({}, props, {
ref: ref,
icon: isNavigationTool ? selectIcon : library_edit["a" /* default */],
"aria-expanded": isOpen,
"aria-haspopup": "true",
onClick: onToggle
/* translators: button label text should, if possible, be under 16 characters. */
,
label: Object(external_wp_i18n_["__"])('Modes')
}));
},
position: "bottom right",
renderContent: function renderContent() {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], {
role: "menu",
"aria-label": Object(external_wp_i18n_["__"])('Modes')
}, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItemsChoice"], {
value: isNavigationTool ? 'select' : 'edit',
onSelect: onSwitchMode,
choices: [{
value: 'edit',
label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(build_module_icon["a" /* default */], {
icon: library_edit["a" /* default */]
}), Object(external_wp_i18n_["__"])('Edit'))
}, {
value: 'select',
label: Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, selectIcon, Object(external_wp_i18n_["__"])('Select'))
}]
})), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-tool-selector__help"
}, Object(external_wp_i18n_["__"])('Tools offer different interactions for block selection & editing. To select, press Escape, to go back to editing, press Enter.')));
}
});
}
/* harmony default export */ var tool_selector = (Object(external_wp_element_["forwardRef"])(ToolSelector));
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/link.js
var library_link = __webpack_require__(195);
// CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/arrow-left.js
/**
* WordPress dependencies
*/
var arrowLeft = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
xmlns: "http://www.w3.org/2000/svg",
viewBox: "0 0 24 24"
}, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
d: "M9.737 18.011L3.98 12.255l5.734-6.28 1.107 1.012-4.103 4.494h13.3v1.5H6.828l3.97 3.97-1.06 1.06z"
}));
/* harmony default export */ var arrow_left = (arrowLeft);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-input/button.js
function button_createSuper(Derived) { var hasNativeReflectConstruct = button_isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
function button_isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var button_URLInputButton = /*#__PURE__*/function (_Component) {
Object(inherits["a" /* default */])(URLInputButton, _Component);
var _super = button_createSuper(URLInputButton);
function URLInputButton() {
var _this;
Object(classCallCheck["a" /* default */])(this, URLInputButton);
_this = _super.apply(this, arguments);
_this.toggle = _this.toggle.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.submitLink = _this.submitLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
_this.state = {
expanded: false
};
return _this;
}
Object(createClass["a" /* default */])(URLInputButton, [{
key: "toggle",
value: function toggle() {
this.setState({
expanded: !this.state.expanded
});
}
}, {
key: "submitLink",
value: function submitLink(event) {
event.preventDefault();
this.toggle();
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
url = _this$props.url,
onChange = _this$props.onChange;
var expanded = this.state.expanded;
var buttonLabel = url ? Object(external_wp_i18n_["__"])('Edit link') : Object(external_wp_i18n_["__"])('Insert link');
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-input__button"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: library_link["a" /* default */],
label: buttonLabel,
onClick: this.toggle,
className: "components-toolbar__control",
isPressed: !!url
}), expanded && Object(external_wp_element_["createElement"])("form", {
className: "block-editor-url-input__button-modal",
onSubmit: this.submitLink
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-url-input__button-modal-line"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
className: "block-editor-url-input__back",
icon: arrow_left,
label: Object(external_wp_i18n_["__"])('Close'),
onClick: this.toggle
}), Object(external_wp_element_["createElement"])(url_input, {
value: url || '',
onChange: onChange
}), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: keyboard_return["a" /* default */],
label: Object(external_wp_i18n_["__"])('Submit'),
type: "submit"
}))));
}
}]);
return URLInputButton;
}(external_wp_element_["Component"]);
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md
*/
/* harmony default export */ var url_input_button = (button_URLInputButton);
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/close.js
var library_close = __webpack_require__(160);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/url-popover/image-url-input-ui.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var LINK_DESTINATION_NONE = 'none';
var LINK_DESTINATION_CUSTOM = 'custom';
var LINK_DESTINATION_MEDIA = 'media';
var LINK_DESTINATION_ATTACHMENT = 'attachment';
var NEW_TAB_REL = ['noreferrer', 'noopener'];
var image_url_input_ui_icon = Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M0,0h24v24H0V0z",
fill: "none"
}), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "m19 5v14h-14v-14h14m0-2h-14c-1.1 0-2 0.9-2 2v14c0 1.1 0.9 2 2 2h14c1.1 0 2-0.9 2-2v-14c0-1.1-0.9-2-2-2z"
}), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "m14.14 11.86l-3 3.87-2.14-2.59-3 3.86h12l-3.86-5.14z"
}));
var image_url_input_ui_ImageURLInputUI = function ImageURLInputUI(_ref) {
var linkDestination = _ref.linkDestination,
onChangeUrl = _ref.onChangeUrl,
url = _ref.url,
_ref$mediaType = _ref.mediaType,
mediaType = _ref$mediaType === void 0 ? 'image' : _ref$mediaType,
mediaUrl = _ref.mediaUrl,
mediaLink = _ref.mediaLink,
linkTarget = _ref.linkTarget,
linkClass = _ref.linkClass,
rel = _ref.rel;
var _useState = Object(external_wp_element_["useState"])(false),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
isOpen = _useState2[0],
setIsOpen = _useState2[1];
var openLinkUI = Object(external_wp_element_["useCallback"])(function () {
setIsOpen(true);
});
var _useState3 = Object(external_wp_element_["useState"])(false),
_useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
isEditingLink = _useState4[0],
setIsEditingLink = _useState4[1];
var _useState5 = Object(external_wp_element_["useState"])(null),
_useState6 = Object(slicedToArray["a" /* default */])(_useState5, 2),
urlInput = _useState6[0],
setUrlInput = _useState6[1];
var autocompleteRef = Object(external_wp_element_["useRef"])(null);
var startEditLink = Object(external_wp_element_["useCallback"])(function () {
if (linkDestination === LINK_DESTINATION_MEDIA || linkDestination === LINK_DESTINATION_ATTACHMENT) {
setUrlInput('');
}
setIsEditingLink(true);
});
var stopEditLink = Object(external_wp_element_["useCallback"])(function () {
setIsEditingLink(false);
});
var closeLinkUI = Object(external_wp_element_["useCallback"])(function () {
setUrlInput(null);
stopEditLink();
setIsOpen(false);
});
var removeNewTabRel = function removeNewTabRel(currentRel) {
var newRel = currentRel;
if (currentRel !== undefined && !Object(external_lodash_["isEmpty"])(newRel)) {
if (!Object(external_lodash_["isEmpty"])(newRel)) {
Object(external_lodash_["each"])(NEW_TAB_REL, function (relVal) {
var regExp = new RegExp('\\b' + relVal + '\\b', 'gi');
newRel = newRel.replace(regExp, '');
}); // Only trim if NEW_TAB_REL values was replaced.
if (newRel !== currentRel) {
newRel = newRel.trim();
}
if (Object(external_lodash_["isEmpty"])(newRel)) {
newRel = undefined;
}
}
}
return newRel;
};
var getUpdatedLinkTargetSettings = function getUpdatedLinkTargetSettings(value) {
var newLinkTarget = value ? '_blank' : undefined;
var updatedRel;
if (!newLinkTarget && !rel) {
updatedRel = undefined;
} else {
updatedRel = removeNewTabRel(rel);
}
return {
linkTarget: newLinkTarget,
rel: updatedRel
};
};
var onFocusOutside = Object(external_wp_element_["useCallback"])(function () {
return function (event) {
// The autocomplete suggestions list renders in a separate popover (in a portal),
// so onFocusOutside fails to detect that a click on a suggestion occurred in the
// LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and
// return to avoid the popover being closed.
var autocompleteElement = autocompleteRef.current;
if (autocompleteElement && autocompleteElement.contains(event.target)) {
return;
}
setIsOpen(false);
setUrlInput(null);
stopEditLink();
};
});
var onSubmitLinkChange = Object(external_wp_element_["useCallback"])(function () {
return function (event) {
if (urlInput) {
var _getLinkDestinations$;
// It is possible the entered URL actually matches a named link destination.
// This check will ensure our link destination is correct.
var selectedDestination = ((_getLinkDestinations$ = getLinkDestinations().find(function (destination) {
return destination.url === urlInput;
})) === null || _getLinkDestinations$ === void 0 ? void 0 : _getLinkDestinations$.linkDestination) || LINK_DESTINATION_CUSTOM;
onChangeUrl({
href: urlInput,
linkDestination: selectedDestination
});
}
stopEditLink();
setUrlInput(null);
event.preventDefault();
};
});
var onLinkRemove = Object(external_wp_element_["useCallback"])(function () {
onChangeUrl({
linkDestination: LINK_DESTINATION_NONE,
href: ''
});
});
var getLinkDestinations = function getLinkDestinations() {
var linkDestinations = [{
linkDestination: LINK_DESTINATION_MEDIA,
title: Object(external_wp_i18n_["__"])('Media File'),
url: mediaType === 'image' ? mediaUrl : undefined,
icon: image_url_input_ui_icon
}];
if (mediaType === 'image' && mediaLink) {
linkDestinations.push({
linkDestination: LINK_DESTINATION_ATTACHMENT,
title: Object(external_wp_i18n_["__"])('Attachment Page'),
url: mediaType === 'image' ? mediaLink : undefined,
icon: Object(external_wp_element_["createElement"])(external_wp_components_["SVG"], {
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg"
}, Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M0 0h24v24H0V0z",
fill: "none"
}), Object(external_wp_element_["createElement"])(external_wp_components_["Path"], {
d: "M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zM6 20V4h7v5h5v11H6z"
}))
});
}
return linkDestinations;
};
var onSetHref = function onSetHref(value) {
var linkDestinations = getLinkDestinations();
var linkDestinationInput;
if (!value) {
linkDestinationInput = LINK_DESTINATION_NONE;
} else {
linkDestinationInput = (Object(external_lodash_["find"])(linkDestinations, function (destination) {
return destination.url === value;
}) || {
linkDestination: LINK_DESTINATION_CUSTOM
}).linkDestination;
}
onChangeUrl({
linkDestination: linkDestinationInput,
href: value
});
};
var onSetNewTab = function onSetNewTab(value) {
var updatedLinkTarget = getUpdatedLinkTargetSettings(value);
onChangeUrl(updatedLinkTarget);
};
var onSetLinkRel = function onSetLinkRel(value) {
onChangeUrl({
rel: value
});
};
var onSetLinkClass = function onSetLinkClass(value) {
onChangeUrl({
linkClass: value
});
};
var advancedOptions = Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToggleControl"], {
label: Object(external_wp_i18n_["__"])('Open in new tab'),
onChange: onSetNewTab,
checked: linkTarget === '_blank'
}), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
label: Object(external_wp_i18n_["__"])('Link Rel'),
value: removeNewTabRel(rel) || '',
onChange: onSetLinkRel
}), Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
label: Object(external_wp_i18n_["__"])('Link CSS Class'),
value: linkClass || '',
onChange: onSetLinkClass
}));
var linkEditorValue = urlInput !== null ? urlInput : url;
var urlLabel = (Object(external_lodash_["find"])(getLinkDestinations(), ['linkDestination', linkDestination]) || {}).title;
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["ToolbarButton"], {
icon: library_link["a" /* default */],
className: "components-toolbar__control",
label: url ? Object(external_wp_i18n_["__"])('Edit link') : Object(external_wp_i18n_["__"])('Insert link'),
"aria-expanded": isOpen,
onClick: openLinkUI
}), isOpen && Object(external_wp_element_["createElement"])(url_popover, {
onFocusOutside: onFocusOutside(),
onClose: closeLinkUI,
renderSettings: function renderSettings() {
return advancedOptions;
},
additionalControls: !linkEditorValue && Object(external_wp_element_["createElement"])(external_wp_components_["NavigableMenu"], null, Object(external_lodash_["map"])(getLinkDestinations(), function (link) {
return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
key: link.linkDestination,
icon: link.icon,
onClick: function onClick() {
setUrlInput(null);
onSetHref(link.url);
stopEditLink();
}
}, link.title);
}))
}, (!url || isEditingLink) && Object(external_wp_element_["createElement"])(url_popover.LinkEditor, {
className: "block-editor-format-toolbar__link-container-content",
value: linkEditorValue,
onChangeInputValue: setUrlInput,
onSubmit: onSubmitLinkChange(),
autocompleteRef: autocompleteRef
}), url && !isEditingLink && Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(url_popover.LinkViewer, {
className: "block-editor-format-toolbar__link-container-content",
url: url,
onEditLinkClick: startEditLink,
urlLabel: urlLabel
}), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
icon: library_close["a" /* default */],
label: Object(external_wp_i18n_["__"])('Remove link'),
onClick: onLinkRemove
}))));
};
// EXTERNAL MODULE: ./node_modules/@wordpress/icons/build-module/library/check.js
var library_check = __webpack_require__(161);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preview-options/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function PreviewOptions(_ref) {
var children = _ref.children,
className = _ref.className,
_ref$isEnabled = _ref.isEnabled,
isEnabled = _ref$isEnabled === void 0 ? true : _ref$isEnabled,
deviceType = _ref.deviceType,
setDeviceType = _ref.setDeviceType;
var isMobile = Object(external_wp_compose_["useViewportMatch"])('small', '<');
if (isMobile) return null;
var popoverProps = {
className: classnames_default()(className, 'block-editor-post-preview__dropdown-content'),
position: 'bottom left'
};
var toggleProps = {
isTertiary: true,
className: 'block-editor-post-preview__button-toggle',
disabled: !isEnabled,
/* translators: button label text should, if possible, be under 16 characters. */
children: Object(external_wp_i18n_["__"])('Preview')
};
return Object(external_wp_element_["createElement"])(external_wp_components_["DropdownMenu"], {
className: "block-editor-post-preview__dropdown",
popoverProps: popoverProps,
toggleProps: toggleProps,
icon: null
}, function () {
return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuGroup"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
className: "block-editor-post-preview__button-resize",
onClick: function onClick() {
return setDeviceType('Desktop');
},
icon: deviceType === 'Desktop' && library_check["a" /* default */]
}, Object(external_wp_i18n_["__"])('Desktop')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
className: "block-editor-post-preview__button-resize",
onClick: function onClick() {
return setDeviceType('Tablet');
},
icon: deviceType === 'Tablet' && library_check["a" /* default */]
}, Object(external_wp_i18n_["__"])('Tablet')), Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
className: "block-editor-post-preview__button-resize",
onClick: function onClick() {
return setDeviceType('Mobile');
},
icon: deviceType === 'Mobile' && library_check["a" /* default */]
}, Object(external_wp_i18n_["__"])('Mobile'))), children);
});
}
// EXTERNAL MODULE: ./node_modules/css-mediaquery/index.js
var css_mediaquery = __webpack_require__(274);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-simulated-media-query/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var ENABLED_MEDIA_QUERY = '(min-width:0px)';
var DISABLED_MEDIA_QUERY = '(min-width:999999px)';
var VALID_MEDIA_QUERY_REGEX = /\((min|max)-width:[^\(]*?\)/g;
function getStyleSheetsThatMatchHostname() {
var _window$document$styl, _window, _window$document;
if (typeof window === 'undefined') {
return [];
}
return Object(external_lodash_["filter"])((_window$document$styl = (_window = window) === null || _window === void 0 ? void 0 : (_window$document = _window.document) === null || _window$document === void 0 ? void 0 : _window$document.styleSheets) !== null && _window$document$styl !== void 0 ? _window$document$styl : [], function (styleSheet) {
if (!styleSheet.href) {
return false;
}
return Object(external_wp_url_["getProtocol"])(styleSheet.href) === window.location.protocol && Object(external_wp_url_["getAuthority"])(styleSheet.href) === window.location.host;
});
}
function isReplaceableMediaRule(rule) {
if (!rule.media) {
return false;
} // Need to use "media.mediaText" instead of "conditionText" for IE support.
return !!rule.media.mediaText.match(VALID_MEDIA_QUERY_REGEX);
}
function replaceRule(styleSheet, newRuleText, index) {
styleSheet.deleteRule(index);
styleSheet.insertRule(newRuleText, index);
}
function replaceMediaQueryWithWidthEvaluation(ruleText, widthValue) {
return ruleText.replace(VALID_MEDIA_QUERY_REGEX, function (matchedSubstring) {
if (Object(css_mediaquery["match"])(matchedSubstring, {
type: 'screen',
width: widthValue
})) {
return ENABLED_MEDIA_QUERY;
}
return DISABLED_MEDIA_QUERY;
});
}
/**
* Function that manipulates media queries from stylesheets to simulate a given
* viewport width.
*
* @param {string} marker CSS selector string defining start and end of
* manipulable styles.
* @param {number?} width Viewport width to simulate. If provided null, the
* stylesheets will not be modified.
*/
function useSimulatedMediaQuery(marker, width) {
Object(external_wp_element_["useEffect"])(function () {
if (!width) {
return;
}
var styleSheets = getStyleSheetsThatMatchHostname();
var originalStyles = [];
styleSheets.forEach(function (styleSheet, styleSheetIndex) {
var relevantSection = false;
for (var ruleIndex = 0; ruleIndex < styleSheet.cssRules.length; ++ruleIndex) {
var rule = styleSheet.cssRules[ruleIndex];
if (rule.type !== window.CSSRule.STYLE_RULE && rule.type !== window.CSSRule.MEDIA_RULE) {
continue;
}
if (!relevantSection && !!rule.cssText.match(new RegExp("#start-".concat(marker)))) {
relevantSection = true;
}
if (relevantSection && !!rule.cssText.match(new RegExp("#end-".concat(marker)))) {
relevantSection = false;
}
if (!relevantSection || !isReplaceableMediaRule(rule)) {
continue;
}
var ruleText = rule.cssText;
if (!originalStyles[styleSheetIndex]) {
originalStyles[styleSheetIndex] = [];
}
originalStyles[styleSheetIndex][ruleIndex] = ruleText;
replaceRule(styleSheet, replaceMediaQueryWithWidthEvaluation(ruleText, width), ruleIndex);
}
});
return function () {
originalStyles.forEach(function (rulesCollection, styleSheetIndex) {
if (!rulesCollection) {
return;
}
for (var ruleIndex = 0; ruleIndex < rulesCollection.length; ++ruleIndex) {
var originalRuleText = rulesCollection[ruleIndex];
if (originalRuleText) {
replaceRule(styleSheets[styleSheetIndex], originalRuleText, ruleIndex);
}
}
});
};
}, [width]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-resize-canvas/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Function to resize the editor window.
*
* @param {string} deviceType Used for determining the size of the container (e.g. Desktop, Tablet, Mobile)
* @param {boolean} __unstableDisableSimulation Whether to disable media query simulation.
*
* @return {Object} Inline styles to be added to resizable container.
*/
function useResizeCanvas(deviceType, __unstableDisableSimulation) {
var _useState = Object(external_wp_element_["useState"])(window.innerWidth),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
actualWidth = _useState2[0],
updateActualWidth = _useState2[1];
Object(external_wp_element_["useEffect"])(function () {
if (deviceType === 'Desktop') {
return;
}
var resizeListener = function resizeListener() {
return updateActualWidth(window.innerWidth);
};
window.addEventListener('resize', resizeListener);
return function () {
window.removeEventListener('resize', resizeListener);
};
}, [deviceType]);
var getCanvasWidth = function getCanvasWidth(device) {
var deviceWidth;
switch (device) {
case 'Tablet':
deviceWidth = 780;
break;
case 'Mobile':
deviceWidth = 360;
break;
default:
return null;
}
return deviceWidth < actualWidth ? deviceWidth : actualWidth;
};
var marginValue = function marginValue() {
return window.innerHeight < 800 ? 36 : 72;
};
var contentInlineStyles = function contentInlineStyles(device) {
var height = device === 'Mobile' ? '768px' : '1024px';
switch (device) {
case 'Tablet':
case 'Mobile':
return {
width: getCanvasWidth(device),
margin: marginValue() + 'px auto',
flexGrow: 0,
height: height,
minHeight: height,
maxHeight: height,
overflowY: 'auto'
};
default:
return null;
}
};
var width = __unstableDisableSimulation ? null : getCanvasWidth(deviceType);
useSimulatedMediaQuery('resizable-editor-section', width);
return contentInlineStyles(deviceType);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/skip-to-selected-block/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var skip_to_selected_block_SkipToSelectedBlock = function SkipToSelectedBlock(_ref) {
var selectedBlockClientId = _ref.selectedBlockClientId;
var onClick = function onClick() {
var selectedBlockElement = getBlockDOMNode(selectedBlockClientId, document);
selectedBlockElement.focus();
};
return selectedBlockClientId && Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
isSecondary: true,
className: "block-editor-skip-to-selected-block",
onClick: onClick
}, Object(external_wp_i18n_["__"])('Skip to the selected block'));
};
/* harmony default export */ var skip_to_selected_block = (Object(external_wp_data_["withSelect"])(function (select) {
return {
selectedBlockClientId: select('core/block-editor').getBlockSelectionStart()
};
})(skip_to_selected_block_SkipToSelectedBlock));
// EXTERNAL MODULE: external ["wp","wordcount"]
var external_wp_wordcount_ = __webpack_require__(124);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-selection-inspector/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function MultiSelectionInspector(_ref) {
var blocks = _ref.blocks;
var words = Object(external_wp_wordcount_["count"])(Object(external_wp_blocks_["serialize"])(blocks), 'words');
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-multi-selection-inspector__card"
}, Object(external_wp_element_["createElement"])(BlockIcon, {
icon: library_stack,
showColors: true
}), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-multi-selection-inspector__card-content"
}, Object(external_wp_element_["createElement"])("div", {
className: "block-editor-multi-selection-inspector__card-title"
}, Object(external_wp_i18n_["sprintf"])(
/* translators: %d: number of blocks */
Object(external_wp_i18n_["_n"])('%d block', '%d blocks', blocks.length), blocks.length)), Object(external_wp_element_["createElement"])("div", {
className: "block-editor-multi-selection-inspector__card-description"
}, Object(external_wp_i18n_["sprintf"])(
/* translators: %d: number of words */
Object(external_wp_i18n_["_n"])('%d word', '%d words', words), words))));
}
/* harmony default export */ var multi_selection_inspector = (Object(external_wp_data_["withSelect"])(function (select) {
var _select = select('core/block-editor'),
getMultiSelectedBlocks = _select.getMultiSelectedBlocks;
return {
blocks: getMultiSelectedBlocks()
};
})(MultiSelectionInspector));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/default-style-picker/index.js
/**
* WordPress dependencies
*/
function DefaultStylePicker(_ref) {
var blockName = _ref.blockName;
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _preferredStyleVariat, _preferredStyleVariat2;
var settings = select('core/block-editor').getSettings();
var preferredStyleVariations = settings.__experimentalPreferredStyleVariations;
return {
preferredStyle: preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : (_preferredStyleVariat = preferredStyleVariations.value) === null || _preferredStyleVariat === void 0 ? void 0 : _preferredStyleVariat[blockName],
onUpdatePreferredStyleVariations: (_preferredStyleVariat2 = preferredStyleVariations === null || preferredStyleVariations === void 0 ? void 0 : preferredStyleVariations.onChange) !== null && _preferredStyleVariat2 !== void 0 ? _preferredStyleVariat2 : null,
styles: select(external_wp_blocks_["store"]).getBlockStyles(blockName)
};
}, [blockName]),
preferredStyle = _useSelect.preferredStyle,
onUpdatePreferredStyleVariations = _useSelect.onUpdatePreferredStyleVariations,
styles = _useSelect.styles;
var selectOptions = Object(external_wp_element_["useMemo"])(function () {
return [{
label: Object(external_wp_i18n_["__"])('Not set'),
value: ''
}].concat(Object(toConsumableArray["a" /* default */])(styles.map(function (_ref2) {
var label = _ref2.label,
name = _ref2.name;
return {
label: label,
value: name
};
})));
}, [styles]);
var selectOnChange = Object(external_wp_element_["useCallback"])(function (blockStyle) {
onUpdatePreferredStyleVariations(blockName, blockStyle);
}, [blockName, onUpdatePreferredStyleVariations]);
return onUpdatePreferredStyleVariations && Object(external_wp_element_["createElement"])(external_wp_components_["SelectControl"], {
options: selectOptions,
value: preferredStyle || '',
label: Object(external_wp_i18n_["__"])('Default Style'),
onChange: selectOnChange
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-inspector/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var block_inspector_BlockInspector = function BlockInspector(_ref) {
var blockType = _ref.blockType,
count = _ref.count,
hasBlockStyles = _ref.hasBlockStyles,
selectedBlockClientId = _ref.selectedBlockClientId,
selectedBlockName = _ref.selectedBlockName,
_ref$showNoBlockSelec = _ref.showNoBlockSelectedMessage,
showNoBlockSelectedMessage = _ref$showNoBlockSelec === void 0 ? true : _ref$showNoBlockSelec,
_ref$bubblesVirtually = _ref.bubblesVirtually,
bubblesVirtually = _ref$bubblesVirtually === void 0 ? true : _ref$bubblesVirtually;
if (count > 1) {
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-inspector"
}, Object(external_wp_element_["createElement"])(multi_selection_inspector, null), Object(external_wp_element_["createElement"])(inspector_controls.Slot, {
bubblesVirtually: bubblesVirtually
}));
}
var isSelectedBlockUnregistered = selectedBlockName === Object(external_wp_blocks_["getUnregisteredTypeHandlerName"])();
/*
* If the selected block is of an unregistered type, avoid showing it as an actual selection
* because we want the user to focus on the unregistered block warning, not block settings.
*/
if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) {
if (showNoBlockSelectedMessage) {
return Object(external_wp_element_["createElement"])("span", {
className: "block-editor-block-inspector__no-blocks"
}, Object(external_wp_i18n_["__"])('No block selected.'));
}
return null;
}
return Object(external_wp_element_["createElement"])(block_inspector_BlockInspectorSingleBlock, {
clientId: selectedBlockClientId,
blockName: blockType.name,
hasBlockStyles: hasBlockStyles,
bubblesVirtually: bubblesVirtually
});
};
var block_inspector_BlockInspectorSingleBlock = function BlockInspectorSingleBlock(_ref2) {
var clientId = _ref2.clientId,
blockName = _ref2.blockName,
hasBlockStyles = _ref2.hasBlockStyles,
bubblesVirtually = _ref2.bubblesVirtually;
var blockInformation = useBlockDisplayInformation(clientId);
return Object(external_wp_element_["createElement"])("div", {
className: "block-editor-block-inspector"
}, Object(external_wp_element_["createElement"])(block_card, blockInformation), Object(external_wp_element_["createElement"])(block_variation_transforms, {
blockClientId: clientId
}), hasBlockStyles && Object(external_wp_element_["createElement"])("div", null, Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
title: Object(external_wp_i18n_["__"])('Styles')
}, Object(external_wp_element_["createElement"])(block_styles, {
clientId: clientId
}), Object(external_wp_blocks_["hasBlockSupport"])(blockName, 'defaultStylePicker', true) && Object(external_wp_element_["createElement"])(DefaultStylePicker, {
blockName: blockName
}))), Object(external_wp_element_["createElement"])(inspector_controls.Slot, {
bubblesVirtually: bubblesVirtually
}), Object(external_wp_element_["createElement"])("div", null, Object(external_wp_element_["createElement"])(block_inspector_AdvancedControls, {
slotName: inspector_advanced_controls.slotName,
bubblesVirtually: bubblesVirtually
})), Object(external_wp_element_["createElement"])(skip_to_selected_block, {
key: "back"
}));
};
var block_inspector_AdvancedControls = function AdvancedControls(_ref3) {
var slotName = _ref3.slotName,
bubblesVirtually = _ref3.bubblesVirtually;
var slot = Object(external_wp_components_["__experimentalUseSlot"])(slotName);
var hasFills = Boolean(slot.fills && slot.fills.length);
if (!hasFills) {
return null;
}
return Object(external_wp_element_["createElement"])(external_wp_components_["PanelBody"], {
className: "block-editor-block-inspector__advanced",
title: Object(external_wp_i18n_["__"])('Advanced'),
initialOpen: false
}, Object(external_wp_element_["createElement"])(inspector_advanced_controls.Slot, {
bubblesVirtually: bubblesVirtually
}));
};
/* harmony default export */ var block_inspector = (Object(external_wp_data_["withSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlockClientId = _select.getSelectedBlockClientId,
getSelectedBlockCount = _select.getSelectedBlockCount,
getBlockName = _select.getBlockName;
var _select2 = select(external_wp_blocks_["store"]),
getBlockStyles = _select2.getBlockStyles;
var selectedBlockClientId = getSelectedBlockClientId();
var selectedBlockName = selectedBlockClientId && getBlockName(selectedBlockClientId);
var blockType = selectedBlockClientId && Object(external_wp_blocks_["getBlockType"])(selectedBlockName);
var blockStyles = selectedBlockClientId && getBlockStyles(selectedBlockName);
return {
count: getSelectedBlockCount(),
hasBlockStyles: blockStyles && blockStyles.length > 0,
selectedBlockName: selectedBlockName,
selectedBlockClientId: selectedBlockClientId,
blockType: blockType
};
})(block_inspector_BlockInspector));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-wrapper-elements.js
/**
* HTML elements that can be used as a block wrapper.
*/
var ELEMENTS = ['p', 'div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'ol', 'ul', 'li', 'figure', 'nav', 'pre', 'header', 'section', 'aside', 'footer', 'main'];
/* harmony default export */ var block_wrapper_elements = (ELEMENTS);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-list/block-wrapper.js
function block_wrapper_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function block_wrapper_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { block_wrapper_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { block_wrapper_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
var BlockComponent = Object(external_wp_element_["forwardRef"])(function (_ref, ref) {
var children = _ref.children,
_ref$tagName = _ref.tagName,
TagName = _ref$tagName === void 0 ? 'div' : _ref$tagName,
props = Object(objectWithoutProperties["a" /* default */])(_ref, ["children", "tagName"]);
external_wp_deprecated_default()('wp.blockEditor.__experimentalBlock', {
alternative: 'wp.blockEditor.useBlockProps'
});
var blockProps = useBlockProps(block_wrapper_objectSpread(block_wrapper_objectSpread({}, props), {}, {
ref: ref
}));
return Object(external_wp_element_["createElement"])(TagName, blockProps, children);
});
var ExtendedBlockComponent = block_wrapper_elements.reduce(function (acc, element) {
acc[element] = Object(external_wp_element_["forwardRef"])(function (props, ref) {
return Object(external_wp_element_["createElement"])(BlockComponent, Object(esm_extends["a" /* default */])({}, props, {
ref: ref,
tagName: element
}));
});
return acc;
}, BlockComponent);
var block_wrapper_Block = ExtendedBlockComponent;
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/block-selection-clearer/index.js
/**
* WordPress dependencies
*/
function useBlockSelectionClearer(ref) {
var hasSelection = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
hasSelectedBlock = _select.hasSelectedBlock,
hasMultiSelection = _select.hasMultiSelection;
return hasSelectedBlock() || hasMultiSelection();
});
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
clearSelectedBlock = _useDispatch.clearSelectedBlock;
Object(external_wp_element_["useEffect"])(function () {
if (!hasSelection) {
return;
}
function onMouseDown(event) {
// Only handle clicks on the canvas, not the content.
if (event.target.closest('.wp-block')) {
return;
}
clearSelectedBlock();
}
ref.current.addEventListener('mousedown', onMouseDown);
return function () {
ref.current.removeEventListener('mousedown', onMouseDown);
};
}, [hasSelection, clearSelectedBlock]);
}
function BlockSelectionClearer(props) {
var ref = Object(external_wp_element_["useRef"])();
useBlockSelectionClearer(ref);
return Object(external_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({
ref: ref
}, props));
}
// EXTERNAL MODULE: ./node_modules/traverse/index.js
var traverse = __webpack_require__(275);
var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/parse.js
/* eslint-disable @wordpress/no-unused-vars-before-return */
// Adapted from https://github.com/reworkcss/css
// because we needed to remove source map support.
// http://www.w3.org/TR/CSS21/grammar.htm
// https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027
var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;
/* harmony default export */ var parse = (function (css, options) {
options = options || {};
/**
* Positional.
*/
var lineno = 1;
var column = 1;
/**
* Update lineno and column based on `str`.
*/
function updatePosition(str) {
var lines = str.match(/\n/g);
if (lines) {
lineno += lines.length;
}
var i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise
column = ~i ? str.length - i : column + str.length;
}
/**
* Mark position and patch `node.position`.
*/
function position() {
var start = {
line: lineno,
column: column
};
return function (node) {
node.position = new Position(start);
whitespace();
return node;
};
}
/**
* Store position information for a node
*/
function Position(start) {
this.start = start;
this.end = {
line: lineno,
column: column
};
this.source = options.source;
}
/**
* Non-enumerable source string
*/
Position.prototype.content = css;
/**
* Error `msg`.
*/
var errorsList = [];
function error(msg) {
var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg);
err.reason = msg;
err.filename = options.source;
err.line = lineno;
err.column = column;
err.source = css;
if (options.silent) {
errorsList.push(err);
} else {
throw err;
}
}
/**
* Parse stylesheet.
*/
function stylesheet() {
var rulesList = rules();
return {
type: 'stylesheet',
stylesheet: {
source: options.source,
rules: rulesList,
parsingErrors: errorsList
}
};
}
/**
* Opening brace.
*/
function open() {
return match(/^{\s*/);
}
/**
* Closing brace.
*/
function close() {
return match(/^}/);
}
/**
* Parse ruleset.
*/
function rules() {
var node;
var accumulator = [];
whitespace();
comments(accumulator);
while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) {
if (node !== false) {
accumulator.push(node);
comments(accumulator);
}
}
return accumulator;
}
/**
* Match `re` and return captures.
*/
function match(re) {
var m = re.exec(css);
if (!m) {
return;
}
var str = m[0];
updatePosition(str);
css = css.slice(str.length);
return m;
}
/**
* Parse whitespace.
*/
function whitespace() {
match(/^\s*/);
}
/**
* Parse comments;
*/
function comments(accumulator) {
var c;
accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign
while (c = comment()) {
if (c !== false) {
accumulator.push(c);
}
}
return accumulator;
}
/**
* Parse comment.
*/
function comment() {
var pos = position();
if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) {
return;
}
var i = 2;
while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) {
++i;
}
i += 2;
if ('' === css.charAt(i - 1)) {
return error('End of comment missing');
}
var str = css.slice(2, i - 2);
column += 2;
updatePosition(str);
css = css.slice(i);
column += 2;
return pos({
type: 'comment',
comment: str
});
}
/**
* Parse selector.
*/
function selector() {
var m = match(/^([^{]+)/);
if (!m) {
return;
} // FIXME: Remove all comments from selectors http://ostermiller.org/findcomment.html
return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) {
return matched.replace(/,/g, "\u200C");
}).split(/\s*(?![^(]*\)),\s*/).map(function (s) {
return s.replace(/\u200C/g, ',');
});
}
/**
* Parse declaration.
*/
function declaration() {
var pos = position(); // prop
var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);
if (!prop) {
return;
}
prop = trim(prop[0]); // :
if (!match(/^:\s*/)) {
return error("property missing ':'");
} // val
var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/);
var ret = pos({
type: 'declaration',
property: prop.replace(commentre, ''),
value: val ? trim(val[0]).replace(commentre, '') : ''
}); // ;
match(/^[;\s]*/);
return ret;
}
/**
* Parse declarations.
*/
function declarations() {
var decls = [];
if (!open()) {
return error("missing '{'");
}
comments(decls); // declarations
var decl; // eslint-disable-next-line no-cond-assign
while (decl = declaration()) {
if (decl !== false) {
decls.push(decl);
comments(decls);
}
}
if (!close()) {
return error("missing '}'");
}
return decls;
}
/**
* Parse keyframe.
*/
function keyframe() {
var m;
var vals = [];
var pos = position(); // eslint-disable-next-line no-cond-assign
while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) {
vals.push(m[1]);
match(/^,\s*/);
}
if (!vals.length) {
return;
}
return pos({
type: 'keyframe',
values: vals,
declarations: declarations()
});
}
/**
* Parse keyframes.
*/
function atkeyframes() {
var pos = position();
var m = match(/^@([-\w]+)?keyframes\s*/);
if (!m) {
return;
}
var vendor = m[1]; // identifier
m = match(/^([-\w]+)\s*/);
if (!m) {
return error('@keyframes missing name');
}
var name = m[1];
if (!open()) {
return error("@keyframes missing '{'");
}
var frame;
var frames = comments(); // eslint-disable-next-line no-cond-assign
while (frame = keyframe()) {
frames.push(frame);
frames = frames.concat(comments());
}
if (!close()) {
return error("@keyframes missing '}'");
}
return pos({
type: 'keyframes',
name: name,
vendor: vendor,
keyframes: frames
});
}
/**
* Parse supports.
*/
function atsupports() {
var pos = position();
var m = match(/^@supports *([^{]+)/);
if (!m) {
return;
}
var supports = trim(m[1]);
if (!open()) {
return error("@supports missing '{'");
}
var style = comments().concat(rules());
if (!close()) {
return error("@supports missing '}'");
}
return pos({
type: 'supports',
supports: supports,
rules: style
});
}
/**
* Parse host.
*/
function athost() {
var pos = position();
var m = match(/^@host\s*/);
if (!m) {
return;
}
if (!open()) {
return error("@host missing '{'");
}
var style = comments().concat(rules());
if (!close()) {
return error("@host missing '}'");
}
return pos({
type: 'host',
rules: style
});
}
/**
* Parse media.
*/
function atmedia() {
var pos = position();
var m = match(/^@media *([^{]+)/);
if (!m) {
return;
}
var media = trim(m[1]);
if (!open()) {
return error("@media missing '{'");
}
var style = comments().concat(rules());
if (!close()) {
return error("@media missing '}'");
}
return pos({
type: 'media',
media: media,
rules: style
});
}
/**
* Parse custom-media.
*/
function atcustommedia() {
var pos = position();
var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);
if (!m) {
return;
}
return pos({
type: 'custom-media',
name: trim(m[1]),
media: trim(m[2])
});
}
/**
* Parse paged media.
*/
function atpage() {
var pos = position();
var m = match(/^@page */);
if (!m) {
return;
}
var sel = selector() || [];
if (!open()) {
return error("@page missing '{'");
}
var decls = comments(); // declarations
var decl; // eslint-disable-next-line no-cond-assign
while (decl = declaration()) {
decls.push(decl);
decls = decls.concat(comments());
}
if (!close()) {
return error("@page missing '}'");
}
return pos({
type: 'page',
selectors: sel,
declarations: decls
});
}
/**
* Parse document.
*/
function atdocument() {
var pos = position();
var m = match(/^@([-\w]+)?document *([^{]+)/);
if (!m) {
return;
}
var vendor = trim(m[1]);
var doc = trim(m[2]);
if (!open()) {
return error("@document missing '{'");
}
var style = comments().concat(rules());
if (!close()) {
return error("@document missing '}'");
}
return pos({
type: 'document',
document: doc,
vendor: vendor,
rules: style
});
}
/**
* Parse font-face.
*/
function atfontface() {
var pos = position();
var m = match(/^@font-face\s*/);
if (!m) {
return;
}
if (!open()) {
return error("@font-face missing '{'");
}
var decls = comments(); // declarations
var decl; // eslint-disable-next-line no-cond-assign
while (decl = declaration()) {
decls.push(decl);
decls = decls.concat(comments());
}
if (!close()) {
return error("@font-face missing '}'");
}
return pos({
type: 'font-face',
declarations: decls
});
}
/**
* Parse import
*/
var atimport = _compileAtrule('import');
/**
* Parse charset
*/
var atcharset = _compileAtrule('charset');
/**
* Parse namespace
*/
var atnamespace = _compileAtrule('namespace');
/**
* Parse non-block at-rules
*/
function _compileAtrule(name) {
var re = new RegExp('^@' + name + '\\s*([^;]+);');
return function () {
var pos = position();
var m = match(re);
if (!m) {
return;
}
var ret = {
type: name
};
ret[name] = m[1].trim();
return pos(ret);
};
}
/**
* Parse at rule.
*/
function atrule() {
if (css[0] !== '@') {
return;
}
return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface();
}
/**
* Parse rule.
*/
function rule() {
var pos = position();
var sel = selector();
if (!sel) {
return error('selector missing');
}
comments();
return pos({
type: 'rule',
selectors: sel,
declarations: declarations()
});
}
return addParent(stylesheet());
});
/**
* Trim `str`.
*/
function trim(str) {
return str ? str.replace(/^\s+|\s+$/g, '') : '';
}
/**
* Adds non-enumerable parent node reference to each node.
*/
function addParent(obj, parent) {
var isNode = obj && typeof obj.type === 'string';
var childParent = isNode ? obj : parent;
for (var k in obj) {
var value = obj[k];
if (Array.isArray(value)) {
value.forEach(function (v) {
addParent(v, childParent);
});
} else if (value && Object(esm_typeof["a" /* default */])(value) === 'object') {
addParent(value, childParent);
}
}
if (isNode) {
Object.defineProperty(obj, 'parent', {
configurable: true,
writable: true,
enumerable: false,
value: parent || null
});
}
return obj;
}
/* eslint-enable @wordpress/no-unused-vars-before-return */
// EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js
var inherits_browser = __webpack_require__(175);
var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compiler.js
// Adapted from https://github.com/reworkcss/css
// because we needed to remove source map support.
/**
* Expose `Compiler`.
*/
/* harmony default export */ var stringify_compiler = (Compiler);
/**
* Initialize a compiler.
*/
function Compiler(opts) {
this.options = opts || {};
}
/**
* Emit `str`
*/
Compiler.prototype.emit = function (str) {
return str;
};
/**
* Visit `node`.
*/
Compiler.prototype.visit = function (node) {
return this[node.type](node);
};
/**
* Map visit over array of `nodes`, optionally using a `delim`
*/
Compiler.prototype.mapVisit = function (nodes, delim) {
var buf = '';
delim = delim || '';
for (var i = 0, length = nodes.length; i < length; i++) {
buf += this.visit(nodes[i]);
if (delim && i < length - 1) {
buf += this.emit(delim);
}
}
return buf;
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/compress.js
// Adapted from https://github.com/reworkcss/css
// because we needed to remove source map support.
/**
* External dependencies
*/
/**
* Internal dependencies
*/
/**
* Expose compiler.
*/
/* harmony default export */ var compress = (compress_Compiler);
/**
* Initialize a new `Compiler`.
*/
function compress_Compiler(options) {
stringify_compiler.call(this, options);
}
/**
* Inherit from `Base.prototype`.
*/
inherits_browser_default()(compress_Compiler, stringify_compiler);
/**
* Compile `node`.
*/
compress_Compiler.prototype.compile = function (node) {
return node.stylesheet.rules.map(this.visit, this).join('');
};
/**
* Visit comment node.
*/
compress_Compiler.prototype.comment = function (node) {
return this.emit('', node.position);
};
/**
* Visit import node.
*/
compress_Compiler.prototype.import = function (node) {
return this.emit('@import ' + node.import + ';', node.position);
};
/**
* Visit media node.
*/
compress_Compiler.prototype.media = function (node) {
return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
};
/**
* Visit document node.
*/
compress_Compiler.prototype.document = function (node) {
var doc = '@' + (node.vendor || '') + 'document ' + node.document;
return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
};
/**
* Visit charset node.
*/
compress_Compiler.prototype.charset = function (node) {
return this.emit('@charset ' + node.charset + ';', node.position);
};
/**
* Visit namespace node.
*/
compress_Compiler.prototype.namespace = function (node) {
return this.emit('@namespace ' + node.namespace + ';', node.position);
};
/**
* Visit supports node.
*/
compress_Compiler.prototype.supports = function (node) {
return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
};
/**
* Visit keyframes node.
*/
compress_Compiler.prototype.keyframes = function (node) {
return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}');
};
/**
* Visit keyframe node.
*/
compress_Compiler.prototype.keyframe = function (node) {
var decls = node.declarations;
return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
};
/**
* Visit page node.
*/
compress_Compiler.prototype.page = function (node) {
var sel = node.selectors.length ? node.selectors.join(', ') : '';
return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
};
/**
* Visit font-face node.
*/
compress_Compiler.prototype['font-face'] = function (node) {
return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}');
};
/**
* Visit host node.
*/
compress_Compiler.prototype.host = function (node) {
return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}');
};
/**
* Visit custom-media node.
*/
compress_Compiler.prototype['custom-media'] = function (node) {
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
};
/**
* Visit rule node.
*/
compress_Compiler.prototype.rule = function (node) {
var decls = node.declarations;
if (!decls.length) {
return '';
}
return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}');
};
/**
* Visit declaration node.
*/
compress_Compiler.prototype.declaration = function (node) {
return this.emit(node.property + ':' + node.value, node.position) + this.emit(';');
};
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/identity.js
/* eslint-disable @wordpress/no-unused-vars-before-return */
// Adapted from https://github.com/reworkcss/css
// because we needed to remove source map support.
/**
* External dependencies
*/
/**
* Internal dependencies
*/
/**
* Expose compiler.
*/
/* harmony default export */ var identity = (identity_Compiler);
/**
* Initialize a new `Compiler`.
*/
function identity_Compiler(options) {
options = options || {};
stringify_compiler.call(this, options);
this.indentation = options.indent;
}
/**
* Inherit from `Base.prototype`.
*/
inherits_browser_default()(identity_Compiler, stringify_compiler);
/**
* Compile `node`.
*/
identity_Compiler.prototype.compile = function (node) {
return this.stylesheet(node);
};
/**
* Visit stylesheet node.
*/
identity_Compiler.prototype.stylesheet = function (node) {
return this.mapVisit(node.stylesheet.rules, '\n\n');
};
/**
* Visit comment node.
*/
identity_Compiler.prototype.comment = function (node) {
return this.emit(this.indent() + '/*' + node.comment + '*/', node.position);
};
/**
* Visit import node.
*/
identity_Compiler.prototype.import = function (node) {
return this.emit('@import ' + node.import + ';', node.position);
};
/**
* Visit media node.
*/
identity_Compiler.prototype.media = function (node) {
return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
};
/**
* Visit document node.
*/
identity_Compiler.prototype.document = function (node) {
var doc = '@' + (node.vendor || '') + 'document ' + node.document;
return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
};
/**
* Visit charset node.
*/
identity_Compiler.prototype.charset = function (node) {
return this.emit('@charset ' + node.charset + ';', node.position);
};
/**
* Visit namespace node.
*/
identity_Compiler.prototype.namespace = function (node) {
return this.emit('@namespace ' + node.namespace + ';', node.position);
};
/**
* Visit supports node.
*/
identity_Compiler.prototype.supports = function (node) {
return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
};
/**
* Visit keyframes node.
*/
identity_Compiler.prototype.keyframes = function (node) {
return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}');
};
/**
* Visit keyframe node.
*/
identity_Compiler.prototype.keyframe = function (node) {
var decls = node.declarations;
return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n');
};
/**
* Visit page node.
*/
identity_Compiler.prototype.page = function (node) {
var sel = node.selectors.length ? node.selectors.join(', ') + ' ' : '';
return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
};
/**
* Visit font-face node.
*/
identity_Compiler.prototype['font-face'] = function (node) {
return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}');
};
/**
* Visit host node.
*/
identity_Compiler.prototype.host = function (node) {
return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}');
};
/**
* Visit custom-media node.
*/
identity_Compiler.prototype['custom-media'] = function (node) {
return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position);
};
/**
* Visit rule node.
*/
identity_Compiler.prototype.rule = function (node) {
var indent = this.indent();
var decls = node.declarations;
if (!decls.length) {
return '';
}
return this.emit(node.selectors.map(function (s) {
return indent + s;
}).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}');
};
/**
* Visit declaration node.
*/
identity_Compiler.prototype.declaration = function (node) {
return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';');
};
/**
* Increase, decrease or return current indentation.
*/
identity_Compiler.prototype.indent = function (level) {
this.level = this.level || 1;
if (null !== level) {
this.level += level;
return '';
}
return Array(this.level).join(this.indentation || ' ');
};
/* eslint-enable @wordpress/no-unused-vars-before-return */
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/ast/stringify/index.js
// Adapted from https://github.com/reworkcss/css
// because we needed to remove source map support.
/**
* Internal dependencies
*/
/**
* Stringfy the given AST `node`.
*
* Options:
*
* - `compress` space-optimized output
* - `sourcemap` return an object with `.code` and `.map`
*
* @param {Object} node
* @param {Object} [options]
* @return {string}
*/
/* harmony default export */ var stringify = (function (node, options) {
options = options || {};
var compiler = options.compress ? new compress(options) : new identity(options);
var code = compiler.compile(node);
return code;
});
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/traverse.js
/**
* External dependencies
*/
/**
* Internal dependencies
*/
function traverseCSS(css, callback) {
try {
var parsed = parse(css);
var updated = traverse_default.a.map(parsed, function (node) {
if (!node) {
return node;
}
var updatedNode = callback(node);
return this.update(updatedNode);
});
return stringify(updated);
} catch (err) {
// eslint-disable-next-line no-console
console.warn('Error while traversing the CSS: ' + err);
return null;
}
}
/* harmony default export */ var transform_styles_traverse = (traverseCSS);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/url-rewrite.js
function url_rewrite_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function url_rewrite_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { url_rewrite_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { url_rewrite_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* Return `true` if the given path is http/https.
*
* @param {string} filePath path
*
* @return {boolean} is remote path.
*/
function isRemotePath(filePath) {
return /^(?:https?:)?\/\//.test(filePath);
}
/**
* Return `true` if the given filePath is an absolute url.
*
* @param {string} filePath path
*
* @return {boolean} is absolute path.
*/
function isAbsolutePath(filePath) {
return /^\/(?!\/)/.test(filePath);
}
/**
* Whether or not the url should be inluded.
*
* @param {Object} meta url meta info
*
* @return {boolean} is valid.
*/
function isValidURL(meta) {
// ignore hashes or data uris
if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) {
return false;
}
if (isAbsolutePath(meta.value)) {
return false;
} // do not handle the http/https urls if `includeRemote` is false
if (isRemotePath(meta.value)) {
return false;
}
return true;
}
/**
* Get the absolute path of the url, relative to the basePath
*
* @param {string} str the url
* @param {string} baseURL base URL
*
* @return {string} the full path to the file
*/
function getResourcePath(str, baseURL) {
return new URL(str, baseURL).toString();
}
/**
* Process the single `url()` pattern
*
* @param {string} baseURL the base URL for relative URLs
* @return {Promise} the Promise
*/
function processURL(baseURL) {
return function (meta) {
return url_rewrite_objectSpread(url_rewrite_objectSpread({}, meta), {}, {
newUrl: 'url(' + meta.before + meta.quote + getResourcePath(meta.value, baseURL) + meta.quote + meta.after + ')'
});
};
}
/**
* Get all `url()`s, and return the meta info
*
* @param {string} value decl.value
*
* @return {Array} the urls
*/
function getURLs(value) {
var reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g;
var match;
var URLs = [];
while ((match = reg.exec(value)) !== null) {
var meta = {
source: match[0],
before: match[1],
quote: match[2],
value: match[3],
after: match[4]
};
if (isValidURL(meta)) {
URLs.push(meta);
}
}
return URLs;
}
/**
* Replace the raw value's `url()` segment to the new value
*
* @param {string} raw the raw value
* @param {Array} URLs the URLs to replace
*
* @return {string} the new value
*/
function replaceURLs(raw, URLs) {
URLs.forEach(function (item) {
raw = raw.replace(item.source, item.newUrl);
});
return raw;
}
var rewrite = function rewrite(rootURL) {
return function (node) {
if (node.type === 'declaration') {
var updatedURLs = getURLs(node.value).map(processURL(rootURL));
return url_rewrite_objectSpread(url_rewrite_objectSpread({}, node), {}, {
value: replaceURLs(node.value, updatedURLs)
});
}
return node;
};
};
/* harmony default export */ var url_rewrite = (rewrite);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/transforms/wrap.js
function wrap_ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function wrap_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { wrap_ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { wrap_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
/**
* @constant string IS_ROOT_TAG Regex to check if the selector is a root tag selector.
*/
var IS_ROOT_TAG = /^(body|html|:root).*$/;
var wrap = function wrap(namespace) {
var ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
return function (node) {
var updateSelector = function updateSelector(selector) {
if (ignore.includes(selector.trim())) {
return selector;
} // Anything other than a root tag is always prefixed.
{
if (!selector.match(IS_ROOT_TAG)) {
return namespace + ' ' + selector;
}
} // HTML and Body elements cannot be contained within our container so lets extract their styles.
return selector.replace(/^(body|html|:root)/, namespace);
};
if (node.type === 'rule') {
return wrap_objectSpread(wrap_objectSpread({}, node), {}, {
selectors: node.selectors.map(updateSelector)
});
}
return node;
};
};
/* harmony default export */ var transforms_wrap = (wrap);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/transform-styles/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* Applies a series of CSS rule transforms to wrap selectors inside a given class and/or rewrite URLs depending on the parameters passed.
*
* @param {Array} styles CSS rules.
* @param {string} wrapperClassName Wrapper Class Name.
* @return {Array} converted rules.
*/
var transform_styles_transformStyles = function transformStyles(styles) {
var wrapperClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
return Object(external_lodash_["map"])(styles, function (_ref) {
var css = _ref.css,
baseURL = _ref.baseURL,
_ref$__experimentalNo = _ref.__experimentalNoWrapper,
__experimentalNoWrapper = _ref$__experimentalNo === void 0 ? false : _ref$__experimentalNo;
var transforms = [];
if (wrapperClassName && !__experimentalNoWrapper) {
transforms.push(transforms_wrap(wrapperClassName));
}
if (baseURL) {
transforms.push(url_rewrite(baseURL));
}
if (transforms.length) {
return transform_styles_traverse(css, Object(external_wp_compose_["compose"])(transforms));
}
return css;
});
};
/* harmony default export */ var transform_styles = (transform_styles_transformStyles);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/editor-styles/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function syncDarkThemeBodyClassname(node) {
var backgroundColor = window.getComputedStyle(node, null).getPropertyValue('background-color');
var ownerDocument = node.ownerDocument;
var body = ownerDocument.getElementsByTagName('body')[0];
if (tinycolor_default()(backgroundColor).getLuminance() > 0.5) {
body.classList.remove('is-dark-theme');
} else {
body.classList.add('is-dark-theme');
}
}
function useEditorStyles(styles) {
var nodes = Object(external_wp_element_["useRef"])([]);
return Object(external_wp_element_["useCallback"])(function (node) {
if (!node) {
nodes.current.forEach(function (styleElement) {
return styleElement.ownerDocument.body.removeChild(styleElement);
});
return;
}
var updatedStyles = transform_styles(styles, '.editor-styles-wrapper');
var ownerDocument = node.ownerDocument;
nodes.current = Object(external_lodash_["map"])(Object(external_lodash_["compact"])(updatedStyles), function (updatedCSS) {
var styleElement = ownerDocument.createElement('style');
styleElement.innerHTML = updatedCSS;
ownerDocument.body.appendChild(styleElement);
return styleElement;
});
syncDarkThemeBodyClassname(node);
}, [styles]);
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function InserterLibrary(_ref) {
var rootClientId = _ref.rootClientId,
clientId = _ref.clientId,
isAppender = _ref.isAppender,
showInserterHelpPanel = _ref.showInserterHelpPanel,
_ref$showMostUsedBloc = _ref.showMostUsedBlocks,
showMostUsedBlocks = _ref$showMostUsedBloc === void 0 ? false : _ref$showMostUsedBloc,
__experimentalSelectBlockOnInsert = _ref.__experimentalSelectBlockOnInsert,
__experimentalInsertionIndex = _ref.__experimentalInsertionIndex,
_ref$onSelect = _ref.onSelect,
onSelect = _ref$onSelect === void 0 ? external_lodash_["noop"] : _ref$onSelect;
var destinationRootClientId = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockRootClientId = _select.getBlockRootClientId;
return rootClientId || getBlockRootClientId(clientId) || undefined;
}, [clientId, rootClientId]);
return Object(external_wp_element_["createElement"])(menu, {
onSelect: onSelect,
rootClientId: destinationRootClientId,
clientId: clientId,
isAppender: isAppender,
showInserterHelpPanel: showInserterHelpPanel,
showMostUsedBlocks: showMostUsedBlocks,
__experimentalSelectBlockOnInsert: __experimentalSelectBlockOnInsert,
__experimentalInsertionIndex: __experimentalInsertionIndex
});
}
/* harmony default export */ var library = (InserterLibrary);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/keyboard-shortcuts/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
function KeyboardShortcuts() {
// Shortcuts Logic
var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getSelectedBlockClientIds = _select.getSelectedBlockClientIds,
getBlockOrder = _select.getBlockOrder,
getBlockRootClientId = _select.getBlockRootClientId;
var selectedClientIds = getSelectedBlockClientIds();
var _selectedClientIds = Object(slicedToArray["a" /* default */])(selectedClientIds, 1),
firstClientId = _selectedClientIds[0];
return {
clientIds: selectedClientIds,
rootBlocksClientIds: getBlockOrder(),
rootClientId: getBlockRootClientId(firstClientId)
};
}, []),
clientIds = _useSelect.clientIds,
rootBlocksClientIds = _useSelect.rootBlocksClientIds,
rootClientId = _useSelect.rootClientId;
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
duplicateBlocks = _useDispatch.duplicateBlocks,
removeBlocks = _useDispatch.removeBlocks,
insertAfterBlock = _useDispatch.insertAfterBlock,
insertBeforeBlock = _useDispatch.insertBeforeBlock,
multiSelect = _useDispatch.multiSelect,
clearSelectedBlock = _useDispatch.clearSelectedBlock,
moveBlocksUp = _useDispatch.moveBlocksUp,
moveBlocksDown = _useDispatch.moveBlocksDown; // Moves selected block/blocks up
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/move-up', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
moveBlocksUp(clientIds, rootClientId);
}, [clientIds, moveBlocksUp]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
}); // Moves selected block/blocks up
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/move-down', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
moveBlocksDown(clientIds, rootClientId);
}, [clientIds, moveBlocksDown]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
}); // Prevents bookmark all Tabs shortcut in Chrome when devtools are closed.
// Prevents reposition Chrome devtools pane shortcut when devtools are open.
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/duplicate', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
duplicateBlocks(clientIds);
}, [clientIds, duplicateBlocks]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
}); // Does not clash with any known browser/native shortcuts, but preventDefault
// is used to prevent any obscure unknown shortcuts from triggering.
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/remove', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
removeBlocks(clientIds);
}, [clientIds, removeBlocks]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
}); // Does not clash with any known browser/native shortcuts, but preventDefault
// is used to prevent any obscure unknown shortcuts from triggering.
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/insert-after', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
insertAfterBlock(Object(external_lodash_["last"])(clientIds));
}, [clientIds, insertAfterBlock]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
}); // Prevent 'view recently closed tabs' in Opera using preventDefault.
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/insert-before', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
insertBeforeBlock(Object(external_lodash_["first"])(clientIds));
}, [clientIds, insertBeforeBlock]), {
bindGlobal: true,
isDisabled: clientIds.length === 0
});
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/delete-multi-selection', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
removeBlocks(clientIds);
}, [clientIds, removeBlocks]), {
isDisabled: clientIds.length < 2
});
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/select-all', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
multiSelect(Object(external_lodash_["first"])(rootBlocksClientIds), Object(external_lodash_["last"])(rootBlocksClientIds));
}, [rootBlocksClientIds, multiSelect]));
Object(external_wp_keyboardShortcuts_["useShortcut"])('core/block-editor/unselect', Object(external_wp_element_["useCallback"])(function (event) {
event.preventDefault();
clearSelectedBlock();
event.target.ownerDocument.defaultView.getSelection().removeAllRanges();
}, [clientIds, clearSelectedBlock]), {
isDisabled: clientIds.length < 2
});
return null;
}
function KeyboardShortcutsRegister() {
// Registering the shortcuts
var _useDispatch2 = Object(external_wp_data_["useDispatch"])(external_wp_keyboardShortcuts_["store"]),
registerShortcut = _useDispatch2.registerShortcut;
Object(external_wp_element_["useEffect"])(function () {
registerShortcut({
name: 'core/block-editor/duplicate',
category: 'block',
description: Object(external_wp_i18n_["__"])('Duplicate the selected block(s).'),
keyCombination: {
modifier: 'primaryShift',
character: 'd'
}
});
registerShortcut({
name: 'core/block-editor/remove',
category: 'block',
description: Object(external_wp_i18n_["__"])('Remove the selected block(s).'),
keyCombination: {
modifier: 'access',
character: 'z'
}
});
registerShortcut({
name: 'core/block-editor/insert-before',
category: 'block',
description: Object(external_wp_i18n_["__"])('Insert a new block before the selected block(s).'),
keyCombination: {
modifier: 'primaryAlt',
character: 't'
}
});
registerShortcut({
name: 'core/block-editor/insert-after',
category: 'block',
description: Object(external_wp_i18n_["__"])('Insert a new block after the selected block(s).'),
keyCombination: {
modifier: 'primaryAlt',
character: 'y'
}
});
registerShortcut({
name: 'core/block-editor/delete-multi-selection',
category: 'block',
description: Object(external_wp_i18n_["__"])('Remove multiple selected blocks.'),
keyCombination: {
character: 'del'
},
aliases: [{
character: 'backspace'
}]
});
registerShortcut({
name: 'core/block-editor/select-all',
category: 'selection',
description: Object(external_wp_i18n_["__"])('Select all text when typing. Press again to select all blocks.'),
keyCombination: {
modifier: 'primary',
character: 'a'
}
});
registerShortcut({
name: 'core/block-editor/unselect',
category: 'selection',
description: Object(external_wp_i18n_["__"])('Clear selection.'),
keyCombination: {
character: 'escape'
}
});
registerShortcut({
name: 'core/block-editor/focus-toolbar',
category: 'global',
description: Object(external_wp_i18n_["__"])('Navigate to the nearest toolbar.'),
keyCombination: {
modifier: 'alt',
character: 'F10'
}
});
registerShortcut({
name: 'core/block-editor/move-up',
category: 'block',
description: Object(external_wp_i18n_["__"])('Move the selected block(s) up.'),
keyCombination: {
modifier: 'secondary',
character: 't'
}
});
registerShortcut({
name: 'core/block-editor/move-down',
category: 'block',
description: Object(external_wp_i18n_["__"])('Move the selected block(s) down.'),
keyCombination: {
modifier: 'secondary',
character: 'y'
}
});
}, [registerShortcut]);
return null;
}
KeyboardShortcuts.Register = KeyboardShortcutsRegister;
/* harmony default export */ var keyboard_shortcuts = (KeyboardShortcuts);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/multi-select-scroll-into-view/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
function useScrollMultiSelectionIntoView(ref) {
var selectionEnd = Object(external_wp_data_["useSelect"])(function (select) {
var _select = select('core/block-editor'),
getBlockSelectionEnd = _select.getBlockSelectionEnd,
hasMultiSelection = _select.hasMultiSelection,
isMultiSelecting = _select.isMultiSelecting;
var blockSelectionEnd = getBlockSelectionEnd();
if (!blockSelectionEnd || isMultiSelecting() || !hasMultiSelection()) {
return;
}
return blockSelectionEnd;
}, []);
Object(external_wp_element_["useEffect"])(function () {
if (!selectionEnd) {
return;
}
var ownerDocument = ref.current.ownerDocument;
var extentNode = getBlockDOMNode(selectionEnd, ownerDocument);
if (!extentNode) {
return;
}
var scrollContainer = Object(external_wp_dom_["getScrollContainer"])(extentNode); // If there's no scroll container, it follows that there's no scrollbar
// and thus there's no need to try to scroll into view.
if (!scrollContainer) {
return;
}
dom_scroll_into_view_lib_default()(extentNode, scrollContainer, {
onlyScrollIfNeeded: true
});
}, [selectionEnd]);
}
/**
* Scrolls the multi block selection end into view if not in view already. This
* is important to do after selection by keyboard.
*/
function MultiSelectScrollIntoView() {
var ref = Object(external_wp_element_["useRef"])();
useScrollMultiSelectionIntoView(ref);
return Object(external_wp_element_["createElement"])("div", {
ref: ref
});
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/observe-typing/index.js
/**
* WordPress dependencies
*/
/** @typedef {import('@wordpress/element').RefObject} RefObject */
/**
* Set of key codes upon which typing is to be initiated on a keydown event.
*
* @type {Set}
*/
var KEY_DOWN_ELIGIBLE_KEY_CODES = new Set([external_wp_keycodes_["UP"], external_wp_keycodes_["RIGHT"], external_wp_keycodes_["DOWN"], external_wp_keycodes_["LEFT"], external_wp_keycodes_["ENTER"], external_wp_keycodes_["BACKSPACE"]]);
/**
* Returns true if a given keydown event can be inferred as intent to start
* typing, or false otherwise. A keydown is considered eligible if it is a
* text navigation without shift active.
*
* @param {KeyboardEvent} event Keydown event to test.
*
* @return {boolean} Whether event is eligible to start typing.
*/
function isKeyDownEligibleForStartTyping(event) {
var keyCode = event.keyCode,
shiftKey = event.shiftKey;
return !shiftKey && KEY_DOWN_ELIGIBLE_KEY_CODES.has(keyCode);
}
/**
* Removes the `isTyping` flag when the mouse moves in the document of the given
* element.
*
* @param {RefObject} ref React ref containing an element.
*/
function useMouseMoveTypingReset(ref) {
var isTyping = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').isTyping();
});
var _useDispatch = Object(external_wp_data_["useDispatch"])('core/block-editor'),
stopTyping = _useDispatch.stopTyping;
Object(external_wp_element_["useEffect"])(function () {
if (!isTyping) {
return;
}
var element = ref.current;
var ownerDocument = element.ownerDocument;
var lastClientX;
var lastClientY;
/**
* On mouse move, unset typing flag if user has moved cursor.
*
* @param {MouseEvent} event Mousemove event.
*/
function stopTypingOnMouseMove(event) {
var clientX = event.clientX,
clientY = event.clientY; // We need to check that the mouse really moved because Safari
// triggers mousemove events when shift or ctrl are pressed.
if (lastClientX && lastClientY && (lastClientX !== clientX || lastClientY !== clientY)) {
stopTyping();
}
lastClientX = clientX;
lastClientY = clientY;
}
ownerDocument.addEventListener('mousemove', stopTypingOnMouseMove);
return function () {
ownerDocument.removeEventListener('mousemove', stopTypingOnMouseMove);
};
}, [isTyping, stopTyping]);
}
/**
* Sets and removes the `isTyping` flag based on user actions:
*
* - Sets the flag if the user types within the given element.
* - Removes the flag when the user selects some text, focusses a non-text
* field, presses ESC or TAB, or moves the mouse in the document.
*
* @param {RefObject} ref React ref containing an element.
*/
function useTypingObserver(ref) {
var isTyping = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').isTyping();
});
var _useDispatch2 = Object(external_wp_data_["useDispatch"])('core/block-editor'),
startTyping = _useDispatch2.startTyping,
stopTyping = _useDispatch2.stopTyping;
useMouseMoveTypingReset(ref);
Object(external_wp_element_["useEffect"])(function () {
var element = ref.current;
var ownerDocument = element.ownerDocument;
var defaultView = ownerDocument.defaultView; // Listeners to stop typing should only be added when typing.
// Listeners to start typing should only be added when not typing.
if (isTyping) {
var timerId;
/**
* Stops typing when focus transitions to a non-text field element.
*
* @param {FocusEvent} event Focus event.
*/
function stopTypingOnNonTextField(event) {
var target = event.target; // Since focus to a non-text field via arrow key will trigger
// before the keydown event, wait until after current stack
// before evaluating whether typing is to be stopped. Otherwise,
// typing will re-start.
timerId = defaultView.setTimeout(function () {
if (!Object(external_wp_dom_["isTextField"])(target)) {
stopTyping();
}
});
}
/**
* Unsets typing flag if user presses Escape while typing flag is
* active.
*
* @param {KeyboardEvent} event Keypress or keydown event to
* interpret.
*/
function stopTypingOnEscapeKey(event) {
var keyCode = event.keyCode;
if (keyCode === external_wp_keycodes_["ESCAPE"] || keyCode === external_wp_keycodes_["TAB"]) {
stopTyping();
}
}
/**
* On selection change, unset typing flag if user has made an
* uncollapsed (shift) selection.
*/
function stopTypingOnSelectionUncollapse() {
var selection = defaultView.getSelection();
var isCollapsed = selection.rangeCount > 0 && selection.getRangeAt(0).collapsed;
if (!isCollapsed) {
stopTyping();
}
}
element.addEventListener('focus', stopTypingOnNonTextField);
element.addEventListener('keydown', stopTypingOnEscapeKey);
ownerDocument.addEventListener('selectionchange', stopTypingOnSelectionUncollapse);
return function () {
defaultView.clearTimeout(timerId);
element.removeEventListener('focus', stopTypingOnNonTextField);
element.removeEventListener('keydown', stopTypingOnEscapeKey);
ownerDocument.removeEventListener('selectionchange', stopTypingOnSelectionUncollapse);
};
}
/**
* Handles a keypress or keydown event to infer intention to start
* typing.
*
* @param {KeyboardEvent} event Keypress or keydown event to interpret.
*/
function startTypingInTextField(event) {
var type = event.type,
target = event.target; // Abort early if already typing, or key press is incurred outside a
// text field (e.g. arrow-ing through toolbar buttons).
// Ignore typing if outside the current DOM container
if (!Object(external_wp_dom_["isTextField"])(target) || !element.contains(target)) {
return;
} // Special-case keydown because certain keys do not emit a keypress
// event. Conversely avoid keydown as the canonical event since
// there are many keydown which are explicitly not targeted for
// typing.
if (type === 'keydown' && !isKeyDownEligibleForStartTyping(event)) {
return;
}
startTyping();
}
element.addEventListener('keypress', startTypingInTextField);
element.addEventListener('keydown', startTypingInTextField);
return function () {
element.removeEventListener('keypress', startTypingInTextField);
element.removeEventListener('keydown', startTypingInTextField);
};
}, [isTyping, startTyping, stopTyping]);
}
function ObserveTyping(_ref) {
var children = _ref.children;
var ref = Object(external_wp_element_["useRef"])();
useTypingObserver(ref);
return Object(external_wp_element_["createElement"])("div", {
ref: ref
}, children);
}
/**
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/observe-typing/README.md
*/
/* harmony default export */ var observe_typing = (ObserveTyping);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/preserve-scroll-in-reorder/index.js
/**
* WordPress dependencies
*/
function PreserveScrollInReorder() {
external_wp_deprecated_default()('PreserveScrollInReorder component', {
hint: 'This behavior is now built-in the block list'
});
return null;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js
/**
* WordPress dependencies
*/
var isIE = window.navigator.userAgent.indexOf('Trident') !== -1;
var arrowKeyCodes = new Set([external_wp_keycodes_["UP"], external_wp_keycodes_["DOWN"], external_wp_keycodes_["LEFT"], external_wp_keycodes_["RIGHT"]]);
var initialTriggerPercentage = 0.75;
function useTypewriter(ref) {
var hasSelectedBlock = Object(external_wp_data_["useSelect"])(function (select) {
return select('core/block-editor').hasSelectedBlock();
});
Object(external_wp_element_["useEffect"])(function () {
if (!hasSelectedBlock) {
return;
}
var ownerDocument = ref.current.ownerDocument;
var defaultView = ownerDocument.defaultView;
var scrollResizeRafId;
var onKeyDownRafId;
var caretRect;
function onScrollResize() {
if (scrollResizeRafId) {
return;
}
scrollResizeRafId = defaultView.requestAnimationFrame(function () {
computeCaretRectangle();
scrollResizeRafId = null;
});
}
function onKeyDown(event) {
// Ensure the any remaining request is cancelled.
if (onKeyDownRafId) {
defaultView.cancelAnimationFrame(onKeyDownRafId);
} // Use an animation frame for a smooth result.
onKeyDownRafId = defaultView.requestAnimationFrame(function () {
maintainCaretPosition(event);
onKeyDownRafId = null;
});
}
/**
* Maintains the scroll position after a selection change caused by a
* keyboard event.
*
* @param {KeyboardEvent} event Keyboard event.
*/
function maintainCaretPosition(_ref) {
var keyCode = _ref.keyCode;
if (!isSelectionEligibleForScroll()) {
return;
}
var currentCaretRect = Object(external_wp_dom_["computeCaretRect"])(defaultView);
if (!currentCaretRect) {
return;
} // If for some reason there is no position set to be scrolled to, let
// this be the position to be scrolled to in the future.
if (!caretRect) {
caretRect = currentCaretRect;
return;
} // Even though enabling the typewriter effect for arrow keys results in
// a pleasant experience, it may not be the case for everyone, so, for
// now, let's disable it.
if (arrowKeyCodes.has(keyCode)) {
// Reset the caret position to maintain.
caretRect = currentCaretRect;
return;
}
var diff = currentCaretRect.top - caretRect.top;
if (diff === 0) {
return;
}
var scrollContainer = Object(external_wp_dom_["getScrollContainer"])(ref.current); // The page must be scrollable.
if (!scrollContainer) {
return;
}
var windowScroll = scrollContainer === ownerDocument.body;
var scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
var scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
var relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY); // If the scroll position is at the start, the active editable element
// is the last one, and the caret is positioned within the initial
// trigger percentage of the page, do not scroll the page.
// The typewriter effect should not kick in until an empty page has been
// filled with the initial trigger percentage or the user scrolls
// intentionally down.
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
// Reset the caret position to maintain.
caretRect = currentCaretRect;
return;
}
var scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight; // Abort if the target scroll position would scroll the caret out of
// view.
if ( // The caret is under the lower fold.
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight || // The caret is above the upper fold.
caretRect.top < scrollContainerY) {
// Reset the caret position to maintain.
caretRect = currentCaretRect;
return;
}
if (windowScroll) {
defaultView.scrollBy(0, diff);
} else {
scrollContainer.scrollTop += diff;
}
}
/**
* Adds a `selectionchange` listener to reset the scroll position to be
* maintained.
*/
function addSelectionChangeListener() {
ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange);
}
/**
* Resets the scroll position to be maintained during a `selectionchange`
* event. Also removes the listener, so it acts as a one-time listener.
*/
function computeCaretRectOnSelectionChange() {
ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
computeCaretRectangle();
}
/**
* Resets the scroll position to be maintained.
*/
function computeCaretRectangle() {
if (isSelectionEligibleForScroll()) {
caretRect = Object(external_wp_dom_["computeCaretRect"])(defaultView);
}
}
/**
* Checks if the current situation is elegible for scroll:
* - There should be one and only one block selected.
* - The component must contain the selection.
* - The active element must be contenteditable.
*/
function isSelectionEligibleForScroll() {
return ref.current.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable;
}
function isLastEditableNode() {
var editableNodes = ref.current.querySelectorAll('[contenteditable="true"]');
var lastEditableNode = editableNodes[editableNodes.length - 1];
return lastEditableNode === ownerDocument.activeElement;
} // When the user scrolls or resizes, the scroll position should be
// reset.
defaultView.addEventListener('scroll', onScrollResize, true);
defaultView.addEventListener('resize', onScrollResize, true);
ref.current.addEventListener('keydown', onKeyDown);
ref.current.addEventListener('keyup', maintainCaretPosition);
ref.current.addEventListener('mousedown', addSelectionChangeListener);
ref.current.addEventListener('touchstart', addSelectionChangeListener);
return function () {
defaultView.removeEventListener('scroll', onScrollResize, true);
defaultView.removeEventListener('resize', onScrollResize, true);
ref.current.removeEventListener('keydown', onKeyDown);
ref.current.removeEventListener('keyup', maintainCaretPosition);
ref.current.removeEventListener('mousedown', addSelectionChangeListener);
ref.current.removeEventListener('touchstart', addSelectionChangeListener);
ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
defaultView.cancelAnimationFrame(scrollResizeRafId);
defaultView.cancelAnimationFrame(onKeyDownRafId);
};
}, [hasSelectedBlock]);
}
function Typewriter(_ref2) {
var children = _ref2.children;
var ref = Object(external_wp_element_["useRef"])();
useTypewriter(ref);
return Object(external_wp_element_["createElement"])("div", {
ref: ref,
className: "block-editor__typewriter"
}, children);
}
/**
* The exported component. The implementation of Typewriter faced technical
* challenges in Internet Explorer, and is simply skipped, rendering the given
* props children instead.
*
* @type {WPComponent}
*/
var TypewriterOrIEBypass = isIE ? function (props) {
return props.children;
} : Typewriter;
/**
* Ensures that the text selection keeps the same vertical distance from the
* viewport during keyboard events within this component. The vertical distance
* can vary. It is the last clicked or scrolled to position.
*/
/* harmony default export */ var typewriter = (TypewriterOrIEBypass);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-canvas-click-redirect/index.js
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
/**
* Given an element, returns true if the element is a tabbable text field, or
* false otherwise.
*
* @param {Element} element Element to test.
*
* @return {boolean} Whether element is a tabbable text field.
*/
var isTabbableTextField = Object(external_lodash_["overEvery"])([external_wp_dom_["isTextField"], external_wp_dom_["focus"].tabbable.isTabbableIndex]);
function useCanvasClickRedirect(ref) {
Object(external_wp_element_["useEffect"])(function () {
function onMouseDown(event) {
// Only handle clicks on the canvas, not the content.
if (event.target !== ref.current) {
return;
}
var focusableNodes = external_wp_dom_["focus"].focusable.find(ref.current);
var target = Object(external_lodash_["findLast"])(focusableNodes, isTabbableTextField);
if (!target) {
return;
}
Object(external_wp_dom_["placeCaretAtHorizontalEdge"])(target, true);
event.preventDefault();
}
ref.current.addEventListener('mousedown', onMouseDown);
return function () {
ref.current.addEventListener('mousedown', onMouseDown);
};
}, []);
}
// EXTERNAL MODULE: ./node_modules/react-merge-refs/dist/react-merge-refs.esm.js
var react_merge_refs_esm = __webpack_require__(72);
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/iframe/index.js
function iframe_createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = iframe_unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
function iframe_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return iframe_arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return iframe_arrayLikeToArray(o, minLen); }
function iframe_arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
/**
* External dependencies
*/
/**
* WordPress dependencies
*/
var BODY_CLASS_NAME = 'editor-styles-wrapper';
var BLOCK_PREFIX = 'wp-block';
/**
* Clones stylesheets targetting the editor canvas to the given document. A
* stylesheet is considered targetting the editor a canvas if it contains the
* `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.
*
* Ideally, this hook should be removed in the future and styles should be added
* explicitly as editor styles.
*
* @param {Document} doc The document to append cloned stylesheets to.
*/
function styleSheetsCompat(doc) {
// Search the document for stylesheets targetting the editor canvas.
Array.from(document.styleSheets).forEach(function (styleSheet) {
try {
// May fail for external styles.
// eslint-disable-next-line no-unused-expressions
styleSheet.cssRules;
} catch (e) {
return;
}
var ownerNode = styleSheet.ownerNode,
cssRules = styleSheet.cssRules;
if (!cssRules) {
return;
}
var isMatch = Array.from(cssRules).find(function (_ref) {
var selectorText = _ref.selectorText;
return selectorText && (selectorText.includes(".".concat(BODY_CLASS_NAME)) || selectorText.includes(".".concat(BLOCK_PREFIX)));
});
if (isMatch && !doc.getElementById(ownerNode.id)) {
doc.head.appendChild(ownerNode.cloneNode(true));
}
});
}
/**
* Bubbles some event types (keydown, keypress, and dragover) to parent document
* document to ensure that the keyboard shortcuts and drag and drop work.
*
* Ideally, we should remove event bubbling in the future. Keyboard shortcuts
* should be context dependent, e.g. actions on blocks like Cmd+A should not
* work globally outside the block editor.
*
* @param {Document} doc Document to attach listeners to.
*/
function bubbleEvents(doc) {
var defaultView = doc.defaultView;
var frameElement = defaultView.frameElement;
function bubbleEvent(event) {
var prototype = Object.getPrototypeOf(event);
var constructorName = prototype.constructor.name;
var Constructor = window[constructorName];
var init = {};
for (var key in event) {
init[key] = event[key];
}
if (event instanceof defaultView.MouseEvent) {
var rect = frameElement.getBoundingClientRect();
init.clientX += rect.left;
init.clientY += rect.top;
}
var newEvent = new Constructor(event.type, init);
var cancelled = !frameElement.dispatchEvent(newEvent);
if (cancelled) {
event.preventDefault();
}
}
var eventTypes = ['keydown', 'keypress', 'dragover'];
for (var _i = 0, _eventTypes = eventTypes; _i < _eventTypes.length; _i++) {
var name = _eventTypes[_i];
doc.addEventListener(name, bubbleEvent);
}
}
/**
* Sets the document direction.
*
* Sets the `editor-styles-wrapper` class name on the body.
*
* Copies the `admin-color-*` class name to the body so that the admin color
* scheme applies to components in the iframe.
*
* @param {Document} doc Document to add class name to.
*/
function setBodyClassName(doc) {
doc.dir = document.dir;
doc.body.className = BODY_CLASS_NAME;
var _iterator = iframe_createForOfIteratorHelper(document.body.classList),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var name = _step.value;
if (name.startsWith('admin-color-')) {
doc.body.classList.add(name);
}
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
/**
* Sets the document head and default styles.
*
* @param {Document} doc Document to set the head for.
* @param {string} head HTML to set as the head.
*/
function setHead(doc, head) {
doc.head.innerHTML = // Body margin must be overridable by themes.
'' + head;
}
function Iframe(_ref2, ref) {
var contentRef = _ref2.contentRef,
children = _ref2.children,
head = _ref2.head,
props = Object(objectWithoutProperties["a" /* default */])(_ref2, ["contentRef", "children", "head"]);
var _useState = Object(external_wp_element_["useState"])(),
_useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
iframeDocument = _useState2[0],
setIframeDocument = _useState2[1];
var setRef = Object(external_wp_element_["useCallback"])(function (node) {
if (!node) {
return;
}
function setDocumentIfReady() {
var contentDocument = node.contentDocument;
var readyState = contentDocument.readyState;
if (readyState !== 'interactive' && readyState !== 'complete') {
return false;
}
contentRef.current = contentDocument.body;
setIframeDocument(contentDocument);
setHead(contentDocument, head);
setBodyClassName(contentDocument);
styleSheetsCompat(contentDocument);
bubbleEvents(contentDocument);
setBodyClassName(contentDocument);
return true;
}
if (setDocumentIfReady()) {
return;
} // Document is not immediately loaded in Firefox.
node.addEventListener('load', function () {
setDocumentIfReady();
});
}, []);
return Object(external_wp_element_["createElement"])("iframe", Object(esm_extends["a" /* default */])({}, props, {
ref: Object(external_wp_element_["useCallback"])(Object(react_merge_refs_esm["a" /* default */])([ref, setRef]), []),
tabIndex: "0",
title: Object(external_wp_i18n_["__"])('Editor canvas'),
name: "editor-canvas"
}), iframeDocument && Object(external_wp_element_["createPortal"])(children, iframeDocument.body));
}
/* harmony default export */ var iframe = (Object(external_wp_element_["forwardRef"])(Iframe));
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-no-recursive-renders/index.js
/**
* WordPress dependencies
*/
var RenderedRefsContext = Object(external_wp_element_["createContext"])(new Set()); // Immutably add to a Set
function add(set, element) {
var result = new Set(set);
result.add(element);
return result;
}
/**
* A React hook for keeping track of blocks previously rendered up in the block
* tree. Blocks susceptible to recursiion can use this hook in their `Edit`
* function to prevent said recursion.
*
* @param {*} uniqueId Any value that acts as a unique identifier for a block instance.
*
* @return {[boolean, Function]} A tuple of:
* - a boolean describing whether the provided id
* has already been rendered;
* - a React context provider to be used to wrap
* other elements.
*/
function useNoRecursiveRenders(uniqueId) {
var previouslyRenderedBlocks = Object(external_wp_element_["useContext"])(RenderedRefsContext);
var hasAlreadyRendered = previouslyRenderedBlocks.has(uniqueId);
var newRenderedBlocks = Object(external_wp_element_["useMemo"])(function () {
return add(previouslyRenderedBlocks, uniqueId);
}, [uniqueId, previouslyRenderedBlocks]);
var Provider = Object(external_wp_element_["useCallback"])(function (_ref) {
var children = _ref.children;
return Object(external_wp_element_["createElement"])(RenderedRefsContext.Provider, {
value: newRenderedBlocks
}, children);
}, [newRenderedBlocks]);
return [hasAlreadyRendered, Provider];
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/index.js
/*
* Block Creation Components
*/
/*
* Content Related Components
*/
/*
* State Related Components
*/
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/theme.js
/**
* Internal dependencies
*/
/**
* Given an array of theme colors checks colors for validity
*
* @param {Array} colors The array of theme colors
*
* @return {Array} The array of valid theme colors or the default colors
*/
function validateThemeColors(colors) {
if (colors === undefined) {
colors = SETTINGS_DEFAULTS.colors;
} else {
var validColors = colors.filter(function (c) {
return c.color;
});
if (validColors.length === 0) {
colors = SETTINGS_DEFAULTS.colors;
} else if (validColors.length < colors.length) {
// Filter out invalid colors
colors = validColors;
}
}
return colors;
}
/**
* Given an array of theme gradients checks gradients for validity
*
* @param {Array} gradients The array of theme gradients
*
* @return {Array} The array of valid theme gradients or the default gradients
*/
function validateThemeGradients(gradients) {
if (gradients === undefined) {
gradients = SETTINGS_DEFAULTS.gradients;
} else {
var validGradients = gradients.filter(function (c) {
return c.gradient;
});
if (validGradients.length === 0) {
gradients = SETTINGS_DEFAULTS.gradients;
} else if (validGradients.length < gradients.length) {
// Filter out invalid gradients
gradients = validGradients;
}
}
return gradients;
}
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/index.js
// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/index.js
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/***/ }),
/***/ 46:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["keyboardShortcuts"]; }());
/***/ }),
/***/ 47:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/***/ }),
/***/ 48:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["a11y"]; }());
/***/ }),
/***/ 5:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/***/ }),
/***/ 51:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["notices"]; }());
/***/ }),
/***/ 52:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _setPrototypeOf; });
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
/***/ }),
/***/ 60:
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__;// TinyColor v1.4.2
// https://github.com/bgrins/TinyColor
// Brian Grinstead, MIT License
(function(Math) {
var trimLeft = /^\s+/,
trimRight = /\s+$/,
tinyCounter = 0,
mathRound = Math.round,
mathMin = Math.min,
mathMax = Math.max,
mathRandom = Math.random;
function tinycolor (color, opts) {
color = (color) ? color : '';
opts = opts || { };
// If input is already a tinycolor, return itself
if (color instanceof tinycolor) {
return color;
}
// If we are called as a function, call using new instead
if (!(this instanceof tinycolor)) {
return new tinycolor(color, opts);
}
var rgb = inputToRGB(color);
this._originalInput = color,
this._r = rgb.r,
this._g = rgb.g,
this._b = rgb.b,
this._a = rgb.a,
this._roundA = mathRound(100*this._a) / 100,
this._format = opts.format || rgb.format;
this._gradientType = opts.gradientType;
// Don't let the range of [0,255] come back in [0,1].
// Potentially lose a little bit of precision here, but will fix issues where
// .5 gets interpreted as half of the total, instead of half of 1
// If it was supposed to be 128, this was already taken care of by `inputToRgb`
if (this._r < 1) { this._r = mathRound(this._r); }
if (this._g < 1) { this._g = mathRound(this._g); }
if (this._b < 1) { this._b = mathRound(this._b); }
this._ok = rgb.ok;
this._tc_id = tinyCounter++;
}
tinycolor.prototype = {
isDark: function() {
return this.getBrightness() < 128;
},
isLight: function() {
return !this.isDark();
},
isValid: function() {
return this._ok;
},
getOriginalInput: function() {
return this._originalInput;
},
getFormat: function() {
return this._format;
},
getAlpha: function() {
return this._a;
},
getBrightness: function() {
//http://www.w3.org/TR/AERT#color-contrast
var rgb = this.toRgb();
return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
},
getLuminance: function() {
//http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
var rgb = this.toRgb();
var RsRGB, GsRGB, BsRGB, R, G, B;
RsRGB = rgb.r/255;
GsRGB = rgb.g/255;
BsRGB = rgb.b/255;
if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}
if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}
if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}
return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);
},
setAlpha: function(value) {
this._a = boundAlpha(value);
this._roundA = mathRound(100*this._a) / 100;
return this;
},
toHsv: function() {
var hsv = rgbToHsv(this._r, this._g, this._b);
return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
},
toHsvString: function() {
var hsv = rgbToHsv(this._r, this._g, this._b);
var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
return (this._a == 1) ?
"hsv(" + h + ", " + s + "%, " + v + "%)" :
"hsva(" + h + ", " + s + "%, " + v + "%, "+ this._roundA + ")";
},
toHsl: function() {
var hsl = rgbToHsl(this._r, this._g, this._b);
return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
},
toHslString: function() {
var hsl = rgbToHsl(this._r, this._g, this._b);
var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
return (this._a == 1) ?
"hsl(" + h + ", " + s + "%, " + l + "%)" :
"hsla(" + h + ", " + s + "%, " + l + "%, "+ this._roundA + ")";
},
toHex: function(allow3Char) {
return rgbToHex(this._r, this._g, this._b, allow3Char);
},
toHexString: function(allow3Char) {
return '#' + this.toHex(allow3Char);
},
toHex8: function(allow4Char) {
return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
},
toHex8String: function(allow4Char) {
return '#' + this.toHex8(allow4Char);
},
toRgb: function() {
return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };
},
toRgbString: function() {
return (this._a == 1) ?
"rgb(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ")" :
"rgba(" + mathRound(this._r) + ", " + mathRound(this._g) + ", " + mathRound(this._b) + ", " + this._roundA + ")";
},
toPercentageRgb: function() {
return { r: mathRound(bound01(this._r, 255) * 100) + "%", g: mathRound(bound01(this._g, 255) * 100) + "%", b: mathRound(bound01(this._b, 255) * 100) + "%", a: this._a };
},
toPercentageRgbString: function() {
return (this._a == 1) ?
"rgb(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%)" :
"rgba(" + mathRound(bound01(this._r, 255) * 100) + "%, " + mathRound(bound01(this._g, 255) * 100) + "%, " + mathRound(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
},
toName: function() {
if (this._a === 0) {
return "transparent";
}
if (this._a < 1) {
return false;
}
return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
},
toFilter: function(secondColor) {
var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);
var secondHex8String = hex8String;
var gradientType = this._gradientType ? "GradientType = 1, " : "";
if (secondColor) {
var s = tinycolor(secondColor);
secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);
}
return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
},
toString: function(format) {
var formatSet = !!format;
format = format || this._format;
var formattedString = false;
var hasAlpha = this._a < 1 && this._a >= 0;
var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
if (needsAlphaFormat) {
// Special case for "transparent", all other non-alpha formats
// will return rgba when there is transparency.
if (format === "name" && this._a === 0) {
return this.toName();
}
return this.toRgbString();
}
if (format === "rgb") {
formattedString = this.toRgbString();
}
if (format === "prgb") {
formattedString = this.toPercentageRgbString();
}
if (format === "hex" || format === "hex6") {
formattedString = this.toHexString();
}
if (format === "hex3") {
formattedString = this.toHexString(true);
}
if (format === "hex4") {
formattedString = this.toHex8String(true);
}
if (format === "hex8") {
formattedString = this.toHex8String();
}
if (format === "name") {
formattedString = this.toName();
}
if (format === "hsl") {
formattedString = this.toHslString();
}
if (format === "hsv") {
formattedString = this.toHsvString();
}
return formattedString || this.toHexString();
},
clone: function() {
return tinycolor(this.toString());
},
_applyModification: function(fn, args) {
var color = fn.apply(null, [this].concat([].slice.call(args)));
this._r = color._r;
this._g = color._g;
this._b = color._b;
this.setAlpha(color._a);
return this;
},
lighten: function() {
return this._applyModification(lighten, arguments);
},
brighten: function() {
return this._applyModification(brighten, arguments);
},
darken: function() {
return this._applyModification(darken, arguments);
},
desaturate: function() {
return this._applyModification(desaturate, arguments);
},
saturate: function() {
return this._applyModification(saturate, arguments);
},
greyscale: function() {
return this._applyModification(greyscale, arguments);
},
spin: function() {
return this._applyModification(spin, arguments);
},
_applyCombination: function(fn, args) {
return fn.apply(null, [this].concat([].slice.call(args)));
},
analogous: function() {
return this._applyCombination(analogous, arguments);
},
complement: function() {
return this._applyCombination(complement, arguments);
},
monochromatic: function() {
return this._applyCombination(monochromatic, arguments);
},
splitcomplement: function() {
return this._applyCombination(splitcomplement, arguments);
},
triad: function() {
return this._applyCombination(triad, arguments);
},
tetrad: function() {
return this._applyCombination(tetrad, arguments);
}
};
// If input is an object, force 1 into "1.0" to handle ratios properly
// String input requires "1.0" as input, so 1 will be treated as 1
tinycolor.fromRatio = function(color, opts) {
if (typeof color == "object") {
var newColor = {};
for (var i in color) {
if (color.hasOwnProperty(i)) {
if (i === "a") {
newColor[i] = color[i];
}
else {
newColor[i] = convertToPercentage(color[i]);
}
}
}
color = newColor;
}
return tinycolor(color, opts);
};
// Given a string or object, convert that input to RGB
// Possible string inputs:
//
// "red"
// "#f00" or "f00"
// "#ff0000" or "ff0000"
// "#ff000000" or "ff000000"
// "rgb 255 0 0" or "rgb (255, 0, 0)"
// "rgb 1.0 0 0" or "rgb (1, 0, 0)"
// "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
// "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
// "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
// "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
// "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
//
function inputToRGB(color) {
var rgb = { r: 0, g: 0, b: 0 };
var a = 1;
var s = null;
var v = null;
var l = null;
var ok = false;
var format = false;
if (typeof color == "string") {
color = stringInputToObject(color);
}
if (typeof color == "object") {
if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
rgb = rgbToRgb(color.r, color.g, color.b);
ok = true;
format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
s = convertToPercentage(color.s);
v = convertToPercentage(color.v);
rgb = hsvToRgb(color.h, s, v);
ok = true;
format = "hsv";
}
else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
s = convertToPercentage(color.s);
l = convertToPercentage(color.l);
rgb = hslToRgb(color.h, s, l);
ok = true;
format = "hsl";
}
if (color.hasOwnProperty("a")) {
a = color.a;
}
}
a = boundAlpha(a);
return {
ok: ok,
format: color.format || format,
r: mathMin(255, mathMax(rgb.r, 0)),
g: mathMin(255, mathMax(rgb.g, 0)),
b: mathMin(255, mathMax(rgb.b, 0)),
a: a
};
}
// Conversion Functions
// --------------------
// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
//
// `rgbToRgb`
// Handle bounds / percentage checking to conform to CSS color spec
//
// *Assumes:* r, g, b in [0, 255] or [0, 1]
// *Returns:* { r, g, b } in [0, 255]
function rgbToRgb(r, g, b){
return {
r: bound01(r, 255) * 255,
g: bound01(g, 255) * 255,
b: bound01(b, 255) * 255
};
}
// `rgbToHsl`
// Converts an RGB color value to HSL.
// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
// *Returns:* { h, s, l } in [0,1]
function rgbToHsl(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = mathMax(r, g, b), min = mathMin(r, g, b);
var h, s, l = (max + min) / 2;
if(max == min) {
h = s = 0; // achromatic
}
else {
var d = max - min;
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
switch(max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return { h: h, s: s, l: l };
}
// `hslToRgb`
// Converts an HSL color value to RGB.
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
// *Returns:* { r, g, b } in the set [0, 255]
function hslToRgb(h, s, l) {
var r, g, b;
h = bound01(h, 360);
s = bound01(s, 100);
l = bound01(l, 100);
function hue2rgb(p, q, t) {
if(t < 0) t += 1;
if(t > 1) t -= 1;
if(t < 1/6) return p + (q - p) * 6 * t;
if(t < 1/2) return q;
if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
return p;
}
if(s === 0) {
r = g = b = l; // achromatic
}
else {
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
var p = 2 * l - q;
r = hue2rgb(p, q, h + 1/3);
g = hue2rgb(p, q, h);
b = hue2rgb(p, q, h - 1/3);
}
return { r: r * 255, g: g * 255, b: b * 255 };
}
// `rgbToHsv`
// Converts an RGB color value to HSV
// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
// *Returns:* { h, s, v } in [0,1]
function rgbToHsv(r, g, b) {
r = bound01(r, 255);
g = bound01(g, 255);
b = bound01(b, 255);
var max = mathMax(r, g, b), min = mathMin(r, g, b);
var h, s, v = max;
var d = max - min;
s = max === 0 ? 0 : d / max;
if(max == min) {
h = 0; // achromatic
}
else {
switch(max) {
case r: h = (g - b) / d + (g < b ? 6 : 0); break;
case g: h = (b - r) / d + 2; break;
case b: h = (r - g) / d + 4; break;
}
h /= 6;
}
return { h: h, s: s, v: v };
}
// `hsvToRgb`
// Converts an HSV color value to RGB.
// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
// *Returns:* { r, g, b } in the set [0, 255]
function hsvToRgb(h, s, v) {
h = bound01(h, 360) * 6;
s = bound01(s, 100);
v = bound01(v, 100);
var i = Math.floor(h),
f = h - i,
p = v * (1 - s),
q = v * (1 - f * s),
t = v * (1 - (1 - f) * s),
mod = i % 6,
r = [v, q, p, p, t, v][mod],
g = [t, v, v, q, p, p][mod],
b = [p, p, t, v, v, q][mod];
return { r: r * 255, g: g * 255, b: b * 255 };
}
// `rgbToHex`
// Converts an RGB color to hex
// Assumes r, g, and b are contained in the set [0, 255]
// Returns a 3 or 6 character hex
function rgbToHex(r, g, b, allow3Char) {
var hex = [
pad2(mathRound(r).toString(16)),
pad2(mathRound(g).toString(16)),
pad2(mathRound(b).toString(16))
];
// Return a 3 character hex if possible
if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
}
return hex.join("");
}
// `rgbaToHex`
// Converts an RGBA color plus alpha transparency to hex
// Assumes r, g, b are contained in the set [0, 255] and
// a in [0, 1]. Returns a 4 or 8 character rgba hex
function rgbaToHex(r, g, b, a, allow4Char) {
var hex = [
pad2(mathRound(r).toString(16)),
pad2(mathRound(g).toString(16)),
pad2(mathRound(b).toString(16)),
pad2(convertDecimalToHex(a))
];
// Return a 4 character hex if possible
if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
}
return hex.join("");
}
// `rgbaToArgbHex`
// Converts an RGBA color to an ARGB Hex8 string
// Rarely used, but required for "toFilter()"
function rgbaToArgbHex(r, g, b, a) {
var hex = [
pad2(convertDecimalToHex(a)),
pad2(mathRound(r).toString(16)),
pad2(mathRound(g).toString(16)),
pad2(mathRound(b).toString(16))
];
return hex.join("");
}
// `equals`
// Can be called with any tinycolor input
tinycolor.equals = function (color1, color2) {
if (!color1 || !color2) { return false; }
return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
};
tinycolor.random = function() {
return tinycolor.fromRatio({
r: mathRandom(),
g: mathRandom(),
b: mathRandom()
});
};
// Modification Functions
// ----------------------
// Thanks to less.js for some of the basics here
//
function desaturate(color, amount) {
amount = (amount === 0) ? 0 : (amount || 10);
var hsl = tinycolor(color).toHsl();
hsl.s -= amount / 100;
hsl.s = clamp01(hsl.s);
return tinycolor(hsl);
}
function saturate(color, amount) {
amount = (amount === 0) ? 0 : (amount || 10);
var hsl = tinycolor(color).toHsl();
hsl.s += amount / 100;
hsl.s = clamp01(hsl.s);
return tinycolor(hsl);
}
function greyscale(color) {
return tinycolor(color).desaturate(100);
}
function lighten (color, amount) {
amount = (amount === 0) ? 0 : (amount || 10);
var hsl = tinycolor(color).toHsl();
hsl.l += amount / 100;
hsl.l = clamp01(hsl.l);
return tinycolor(hsl);
}
function brighten(color, amount) {
amount = (amount === 0) ? 0 : (amount || 10);
var rgb = tinycolor(color).toRgb();
rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));
rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));
rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));
return tinycolor(rgb);
}
function darken (color, amount) {
amount = (amount === 0) ? 0 : (amount || 10);
var hsl = tinycolor(color).toHsl();
hsl.l -= amount / 100;
hsl.l = clamp01(hsl.l);
return tinycolor(hsl);
}
// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
// Values outside of this range will be wrapped into this range.
function spin(color, amount) {
var hsl = tinycolor(color).toHsl();
var hue = (hsl.h + amount) % 360;
hsl.h = hue < 0 ? 360 + hue : hue;
return tinycolor(hsl);
}
// Combination Functions
// ---------------------
// Thanks to jQuery xColor for some of the ideas behind these
//
function complement(color) {
var hsl = tinycolor(color).toHsl();
hsl.h = (hsl.h + 180) % 360;
return tinycolor(hsl);
}
function triad(color) {
var hsl = tinycolor(color).toHsl();
var h = hsl.h;
return [
tinycolor(color),
tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
];
}
function tetrad(color) {
var hsl = tinycolor(color).toHsl();
var h = hsl.h;
return [
tinycolor(color),
tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
];
}
function splitcomplement(color) {
var hsl = tinycolor(color).toHsl();
var h = hsl.h;
return [
tinycolor(color),
tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
];
}
function analogous(color, results, slices) {
results = results || 6;
slices = slices || 30;
var hsl = tinycolor(color).toHsl();
var part = 360 / slices;
var ret = [tinycolor(color)];
for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
hsl.h = (hsl.h + part) % 360;
ret.push(tinycolor(hsl));
}
return ret;
}
function monochromatic(color, results) {
results = results || 6;
var hsv = tinycolor(color).toHsv();
var h = hsv.h, s = hsv.s, v = hsv.v;
var ret = [];
var modification = 1 / results;
while (results--) {
ret.push(tinycolor({ h: h, s: s, v: v}));
v = (v + modification) % 1;
}
return ret;
}
// Utility Functions
// ---------------------
tinycolor.mix = function(color1, color2, amount) {
amount = (amount === 0) ? 0 : (amount || 50);
var rgb1 = tinycolor(color1).toRgb();
var rgb2 = tinycolor(color2).toRgb();
var p = amount / 100;
var rgba = {
r: ((rgb2.r - rgb1.r) * p) + rgb1.r,
g: ((rgb2.g - rgb1.g) * p) + rgb1.g,
b: ((rgb2.b - rgb1.b) * p) + rgb1.b,
a: ((rgb2.a - rgb1.a) * p) + rgb1.a
};
return tinycolor(rgba);
};
// Readability Functions
// ---------------------
// false
// tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
tinycolor.isReadable = function(color1, color2, wcag2) {
var readability = tinycolor.readability(color1, color2);
var wcag2Parms, out;
out = false;
wcag2Parms = validateWCAG2Parms(wcag2);
switch (wcag2Parms.level + wcag2Parms.size) {
case "AAsmall":
case "AAAlarge":
out = readability >= 4.5;
break;
case "AAlarge":
out = readability >= 3;
break;
case "AAAsmall":
out = readability >= 7;
break;
}
return out;
};
// `mostReadable`
// Given a base color and a list of possible foreground or background
// colors for that base, returns the most readable color.
// Optionally returns Black or White if the most readable color is unreadable.
// *Example*
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
// tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
// tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
tinycolor.mostReadable = function(baseColor, colorList, args) {
var bestColor = null;
var bestScore = 0;
var readability;
var includeFallbackColors, level, size ;
args = args || {};
includeFallbackColors = args.includeFallbackColors ;
level = args.level;
size = args.size;
for (var i= 0; i < colorList.length ; i++) {
readability = tinycolor.readability(baseColor, colorList[i]);
if (readability > bestScore) {
bestScore = readability;
bestColor = tinycolor(colorList[i]);
}
}
if (tinycolor.isReadable(baseColor, bestColor, {"level":level,"size":size}) || !includeFallbackColors) {
return bestColor;
}
else {
args.includeFallbackColors=false;
return tinycolor.mostReadable(baseColor,["#fff", "#000"],args);
}
};
// Big List of Colors
// ------------------
//
var names = tinycolor.names = {
aliceblue: "f0f8ff",
antiquewhite: "faebd7",
aqua: "0ff",
aquamarine: "7fffd4",
azure: "f0ffff",
beige: "f5f5dc",
bisque: "ffe4c4",
black: "000",
blanchedalmond: "ffebcd",
blue: "00f",
blueviolet: "8a2be2",
brown: "a52a2a",
burlywood: "deb887",
burntsienna: "ea7e5d",
cadetblue: "5f9ea0",
chartreuse: "7fff00",
chocolate: "d2691e",
coral: "ff7f50",
cornflowerblue: "6495ed",
cornsilk: "fff8dc",
crimson: "dc143c",
cyan: "0ff",
darkblue: "00008b",
darkcyan: "008b8b",
darkgoldenrod: "b8860b",
darkgray: "a9a9a9",
darkgreen: "006400",
darkgrey: "a9a9a9",
darkkhaki: "bdb76b",
darkmagenta: "8b008b",
darkolivegreen: "556b2f",
darkorange: "ff8c00",
darkorchid: "9932cc",
darkred: "8b0000",
darksalmon: "e9967a",
darkseagreen: "8fbc8f",
darkslateblue: "483d8b",
darkslategray: "2f4f4f",
darkslategrey: "2f4f4f",
darkturquoise: "00ced1",
darkviolet: "9400d3",
deeppink: "ff1493",
deepskyblue: "00bfff",
dimgray: "696969",
dimgrey: "696969",
dodgerblue: "1e90ff",
firebrick: "b22222",
floralwhite: "fffaf0",
forestgreen: "228b22",
fuchsia: "f0f",
gainsboro: "dcdcdc",
ghostwhite: "f8f8ff",
gold: "ffd700",
goldenrod: "daa520",
gray: "808080",
green: "008000",
greenyellow: "adff2f",
grey: "808080",
honeydew: "f0fff0",
hotpink: "ff69b4",
indianred: "cd5c5c",
indigo: "4b0082",
ivory: "fffff0",
khaki: "f0e68c",
lavender: "e6e6fa",
lavenderblush: "fff0f5",
lawngreen: "7cfc00",
lemonchiffon: "fffacd",
lightblue: "add8e6",
lightcoral: "f08080",
lightcyan: "e0ffff",
lightgoldenrodyellow: "fafad2",
lightgray: "d3d3d3",
lightgreen: "90ee90",
lightgrey: "d3d3d3",
lightpink: "ffb6c1",
lightsalmon: "ffa07a",
lightseagreen: "20b2aa",
lightskyblue: "87cefa",
lightslategray: "789",
lightslategrey: "789",
lightsteelblue: "b0c4de",
lightyellow: "ffffe0",
lime: "0f0",
limegreen: "32cd32",
linen: "faf0e6",
magenta: "f0f",
maroon: "800000",
mediumaquamarine: "66cdaa",
mediumblue: "0000cd",
mediumorchid: "ba55d3",
mediumpurple: "9370db",
mediumseagreen: "3cb371",
mediumslateblue: "7b68ee",
mediumspringgreen: "00fa9a",
mediumturquoise: "48d1cc",
mediumvioletred: "c71585",
midnightblue: "191970",
mintcream: "f5fffa",
mistyrose: "ffe4e1",
moccasin: "ffe4b5",
navajowhite: "ffdead",
navy: "000080",
oldlace: "fdf5e6",
olive: "808000",
olivedrab: "6b8e23",
orange: "ffa500",
orangered: "ff4500",
orchid: "da70d6",
palegoldenrod: "eee8aa",
palegreen: "98fb98",
paleturquoise: "afeeee",
palevioletred: "db7093",
papayawhip: "ffefd5",
peachpuff: "ffdab9",
peru: "cd853f",
pink: "ffc0cb",
plum: "dda0dd",
powderblue: "b0e0e6",
purple: "800080",
rebeccapurple: "663399",
red: "f00",
rosybrown: "bc8f8f",
royalblue: "4169e1",
saddlebrown: "8b4513",
salmon: "fa8072",
sandybrown: "f4a460",
seagreen: "2e8b57",
seashell: "fff5ee",
sienna: "a0522d",
silver: "c0c0c0",
skyblue: "87ceeb",
slateblue: "6a5acd",
slategray: "708090",
slategrey: "708090",
snow: "fffafa",
springgreen: "00ff7f",
steelblue: "4682b4",
tan: "d2b48c",
teal: "008080",
thistle: "d8bfd8",
tomato: "ff6347",
turquoise: "40e0d0",
violet: "ee82ee",
wheat: "f5deb3",
white: "fff",
whitesmoke: "f5f5f5",
yellow: "ff0",
yellowgreen: "9acd32"
};
// Make it easy to access colors via `hexNames[hex]`
var hexNames = tinycolor.hexNames = flip(names);
// Utilities
// ---------
// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
function flip(o) {
var flipped = { };
for (var i in o) {
if (o.hasOwnProperty(i)) {
flipped[o[i]] = i;
}
}
return flipped;
}
// Return a valid alpha value [0,1] with all invalid values being set to 1
function boundAlpha(a) {
a = parseFloat(a);
if (isNaN(a) || a < 0 || a > 1) {
a = 1;
}
return a;
}
// Take input from [0, n] and return it as [0, 1]
function bound01(n, max) {
if (isOnePointZero(n)) { n = "100%"; }
var processPercent = isPercentage(n);
n = mathMin(max, mathMax(0, parseFloat(n)));
// Automatically convert percentage into number
if (processPercent) {
n = parseInt(n * max, 10) / 100;
}
// Handle floating point rounding errors
if ((Math.abs(n - max) < 0.000001)) {
return 1;
}
// Convert into [0, 1] range if it isn't already
return (n % max) / parseFloat(max);
}
// Force a number between 0 and 1
function clamp01(val) {
return mathMin(1, mathMax(0, val));
}
// Parse a base-16 hex value into a base-10 integer
function parseIntFromHex(val) {
return parseInt(val, 16);
}
// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
//
function isOnePointZero(n) {
return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
}
// Check to see if string passed in is a percentage
function isPercentage(n) {
return typeof n === "string" && n.indexOf('%') != -1;
}
// Force a hex value to have 2 characters
function pad2(c) {
return c.length == 1 ? '0' + c : '' + c;
}
// Replace a decimal with it's percentage value
function convertToPercentage(n) {
if (n <= 1) {
n = (n * 100) + "%";
}
return n;
}
// Converts a decimal to a hex value
function convertDecimalToHex(d) {
return Math.round(parseFloat(d) * 255).toString(16);
}
// Converts a hex value to a decimal
function convertHexToDecimal(h) {
return (parseIntFromHex(h) / 255);
}
var matchers = (function() {
//
var CSS_INTEGER = "[-\\+]?\\d+%?";
//
var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
// Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
// Actual matching.
// Parentheses and commas are optional, but not required.
// Whitespace can take the place of commas or opening paren
var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
return {
CSS_UNIT: new RegExp(CSS_UNIT),
rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
};
})();
// `isValidCSSUnit`
// Take in a single string / number and check to see if it looks like a CSS unit
// (see `matchers` above for definition).
function isValidCSSUnit(color) {
return !!matchers.CSS_UNIT.exec(color);
}
// `stringInputToObject`
// Permissive string parsing. Take in a number of formats, and output an object
// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
function stringInputToObject(color) {
color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
var named = false;
if (names[color]) {
color = names[color];
named = true;
}
else if (color == 'transparent') {
return { r: 0, g: 0, b: 0, a: 0, format: "name" };
}
// Try to match string input using regular expressions.
// Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
// Just return an object and let the conversion functions handle that.
// This way the result will be the same whether the tinycolor is initialized with string or object.
var match;
if ((match = matchers.rgb.exec(color))) {
return { r: match[1], g: match[2], b: match[3] };
}
if ((match = matchers.rgba.exec(color))) {
return { r: match[1], g: match[2], b: match[3], a: match[4] };
}
if ((match = matchers.hsl.exec(color))) {
return { h: match[1], s: match[2], l: match[3] };
}
if ((match = matchers.hsla.exec(color))) {
return { h: match[1], s: match[2], l: match[3], a: match[4] };
}
if ((match = matchers.hsv.exec(color))) {
return { h: match[1], s: match[2], v: match[3] };
}
if ((match = matchers.hsva.exec(color))) {
return { h: match[1], s: match[2], v: match[3], a: match[4] };
}
if ((match = matchers.hex8.exec(color))) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
a: convertHexToDecimal(match[4]),
format: named ? "name" : "hex8"
};
}
if ((match = matchers.hex6.exec(color))) {
return {
r: parseIntFromHex(match[1]),
g: parseIntFromHex(match[2]),
b: parseIntFromHex(match[3]),
format: named ? "name" : "hex"
};
}
if ((match = matchers.hex4.exec(color))) {
return {
r: parseIntFromHex(match[1] + '' + match[1]),
g: parseIntFromHex(match[2] + '' + match[2]),
b: parseIntFromHex(match[3] + '' + match[3]),
a: convertHexToDecimal(match[4] + '' + match[4]),
format: named ? "name" : "hex8"
};
}
if ((match = matchers.hex3.exec(color))) {
return {
r: parseIntFromHex(match[1] + '' + match[1]),
g: parseIntFromHex(match[2] + '' + match[2]),
b: parseIntFromHex(match[3] + '' + match[3]),
format: named ? "name" : "hex"
};
}
return false;
}
function validateWCAG2Parms(parms) {
// return valid WCAG2 parms for isReadable.
// If input parms are invalid, return {"level":"AA", "size":"small"}
var level, size;
parms = parms || {"level":"AA", "size":"small"};
level = (parms.level || "AA").toUpperCase();
size = (parms.size || "small").toLowerCase();
if (level !== "AA" && level !== "AAA") {
level = "AA";
}
if (size !== "small" && size !== "large") {
size = "small";
}
return {"level":level, "size":size};
}
// Node: Export function
if ( true && module.exports) {
module.exports = tinycolor;
}
// AMD/requirejs: Define the module
else if (true) {
!(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {return tinycolor;}).call(exports, __webpack_require__, exports, module),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
}
// Browser: Expose to window
else {}
})(Math);
/***/ }),
/***/ 63:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["isShallowEqual"]; }());
/***/ }),
/***/ 64:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["htmlEntities"]; }());
/***/ }),
/***/ 7:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["primitives"]; }());
/***/ }),
/***/ 71:
/***/ (function(module, exports, __webpack_require__) {
/**
* Memize options object.
*
* @typedef MemizeOptions
*
* @property {number} [maxSize] Maximum size of the cache.
*/
/**
* Internal cache entry.
*
* @typedef MemizeCacheNode
*
* @property {?MemizeCacheNode|undefined} [prev] Previous node.
* @property {?MemizeCacheNode|undefined} [next] Next node.
* @property {Array<*>} args Function arguments for cache
* entry.
* @property {*} val Function result.
*/
/**
* Properties of the enhanced function for controlling cache.
*
* @typedef MemizeMemoizedFunction
*
* @property {()=>void} clear Clear the cache.
*/
/**
* Accepts a function to be memoized, and returns a new memoized function, with
* optional options.
*
* @template {Function} F
*
* @param {F} fn Function to memoize.
* @param {MemizeOptions} [options] Options object.
*
* @return {F & MemizeMemoizedFunction} Memoized function.
*/
function memize( fn, options ) {
var size = 0;
/** @type {?MemizeCacheNode|undefined} */
var head;
/** @type {?MemizeCacheNode|undefined} */
var tail;
options = options || {};
function memoized( /* ...args */ ) {
var node = head,
len = arguments.length,
args, i;
searchCache: while ( node ) {
// Perform a shallow equality test to confirm that whether the node
// under test is a candidate for the arguments passed. Two arrays
// are shallowly equal if their length matches and each entry is
// strictly equal between the two sets. Avoid abstracting to a
// function which could incur an arguments leaking deoptimization.
// Check whether node arguments match arguments length
if ( node.args.length !== arguments.length ) {
node = node.next;
continue;
}
// Check whether node arguments match arguments values
for ( i = 0; i < len; i++ ) {
if ( node.args[ i ] !== arguments[ i ] ) {
node = node.next;
continue searchCache;
}
}
// At this point we can assume we've found a match
// Surface matched node to head if not already
if ( node !== head ) {
// As tail, shift to previous. Must only shift if not also
// head, since if both head and tail, there is no previous.
if ( node === tail ) {
tail = node.prev;
}
// Adjust siblings to point to each other. If node was tail,
// this also handles new tail's empty `next` assignment.
/** @type {MemizeCacheNode} */ ( node.prev ).next = node.next;
if ( node.next ) {
node.next.prev = node.prev;
}
node.next = head;
node.prev = null;
/** @type {MemizeCacheNode} */ ( head ).prev = node;
head = node;
}
// Return immediately
return node.val;
}
// No cached value found. Continue to insertion phase:
// Create a copy of arguments (avoid leaking deoptimization)
args = new Array( len );
for ( i = 0; i < len; i++ ) {
args[ i ] = arguments[ i ];
}
node = {
args: args,
// Generate the result from original function
val: fn.apply( null, args ),
};
// Don't need to check whether node is already head, since it would
// have been returned above already if it was
// Shift existing head down list
if ( head ) {
head.prev = node;
node.next = head;
} else {
// If no head, follows that there's no tail (at initial or reset)
tail = node;
}
// Trim tail if we're reached max size and are pending cache insertion
if ( size === /** @type {MemizeOptions} */ ( options ).maxSize ) {
tail = /** @type {MemizeCacheNode} */ ( tail ).prev;
/** @type {MemizeCacheNode} */ ( tail ).next = null;
} else {
size++;
}
head = node;
return node.val;
}
memoized.clear = function() {
head = null;
tail = null;
size = 0;
};
if ( false ) {}
// Ignore reason: There's not a clear solution to create an intersection of
// the function with additional properties, where the goal is to retain the
// function signature of the incoming argument and add control properties
// on the return value.
// @ts-ignore
return memoized;
}
module.exports = memize;
/***/ }),
/***/ 72:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
function mergeRefs(refs) {
return function (value) {
refs.forEach(function (ref) {
if (typeof ref === "function") {
ref(value);
} else if (ref != null) {
ref.current = value;
}
});
};
}
/* harmony default export */ __webpack_exports__["a"] = (mergeRefs);
/***/ }),
/***/ 8:
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/***/ }),
/***/ 9:
/***/ (function(module, exports) {
(function() { module.exports = window["wp"]["blocks"]; }());
/***/ }),
/***/ 90:
/***/ (function(module, exports, __webpack_require__) {
"use strict";
exports.__esModule = true;
var TextareaAutosize_1 = __webpack_require__(189);
exports["default"] = TextareaAutosize_1.TextareaAutosize;
/***/ })
/******/ });