format-library.js 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550
  1. this["wp"] = this["wp"] || {}; this["wp"]["formatLibrary"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = 350);
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ 0:
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = this["wp"]["element"]; }());
  92. /***/ }),
  93. /***/ 1:
  94. /***/ (function(module, exports) {
  95. (function() { module.exports = this["wp"]["i18n"]; }());
  96. /***/ }),
  97. /***/ 10:
  98. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  99. "use strict";
  100. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
  101. function _defineProperty(obj, key, value) {
  102. if (key in obj) {
  103. Object.defineProperty(obj, key, {
  104. value: value,
  105. enumerable: true,
  106. configurable: true,
  107. writable: true
  108. });
  109. } else {
  110. obj[key] = value;
  111. }
  112. return obj;
  113. }
  114. /***/ }),
  115. /***/ 11:
  116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117. "use strict";
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
  119. function _defineProperties(target, props) {
  120. for (var i = 0; i < props.length; i++) {
  121. var descriptor = props[i];
  122. descriptor.enumerable = descriptor.enumerable || false;
  123. descriptor.configurable = true;
  124. if ("value" in descriptor) descriptor.writable = true;
  125. Object.defineProperty(target, descriptor.key, descriptor);
  126. }
  127. }
  128. function _createClass(Constructor, protoProps, staticProps) {
  129. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  130. if (staticProps) _defineProperties(Constructor, staticProps);
  131. return Constructor;
  132. }
  133. /***/ }),
  134. /***/ 12:
  135. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  136. "use strict";
  137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
  138. function _classCallCheck(instance, Constructor) {
  139. if (!(instance instanceof Constructor)) {
  140. throw new TypeError("Cannot call a class as a function");
  141. }
  142. }
  143. /***/ }),
  144. /***/ 13:
  145. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  146. "use strict";
  147. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
  148. /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(31);
  149. /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
  150. function _possibleConstructorReturn(self, call) {
  151. if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
  152. return call;
  153. }
  154. return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
  155. }
  156. /***/ }),
  157. /***/ 14:
  158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  159. "use strict";
  160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
  161. function _getPrototypeOf(o) {
  162. _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  163. return o.__proto__ || Object.getPrototypeOf(o);
  164. };
  165. return _getPrototypeOf(o);
  166. }
  167. /***/ }),
  168. /***/ 15:
  169. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  170. "use strict";
  171. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
  172. function _setPrototypeOf(o, p) {
  173. _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  174. o.__proto__ = p;
  175. return o;
  176. };
  177. return _setPrototypeOf(o, p);
  178. }
  179. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
  180. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
  181. function _inherits(subClass, superClass) {
  182. if (typeof superClass !== "function" && superClass !== null) {
  183. throw new TypeError("Super expression must either be null or a function");
  184. }
  185. subClass.prototype = Object.create(superClass && superClass.prototype, {
  186. constructor: {
  187. value: subClass,
  188. writable: true,
  189. configurable: true
  190. }
  191. });
  192. if (superClass) _setPrototypeOf(subClass, superClass);
  193. }
  194. /***/ }),
  195. /***/ 18:
  196. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  197. "use strict";
  198. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; });
  199. function _extends() {
  200. _extends = Object.assign || function (target) {
  201. for (var i = 1; i < arguments.length; i++) {
  202. var source = arguments[i];
  203. for (var key in source) {
  204. if (Object.prototype.hasOwnProperty.call(source, key)) {
  205. target[key] = source[key];
  206. }
  207. }
  208. }
  209. return target;
  210. };
  211. return _extends.apply(this, arguments);
  212. }
  213. /***/ }),
  214. /***/ 19:
  215. /***/ (function(module, exports) {
  216. (function() { module.exports = this["wp"]["keycodes"]; }());
  217. /***/ }),
  218. /***/ 2:
  219. /***/ (function(module, exports) {
  220. (function() { module.exports = this["lodash"]; }());
  221. /***/ }),
  222. /***/ 21:
  223. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  224. "use strict";
  225. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js
  226. function _objectWithoutPropertiesLoose(source, excluded) {
  227. if (source == null) return {};
  228. var target = {};
  229. var sourceKeys = Object.keys(source);
  230. var key, i;
  231. for (i = 0; i < sourceKeys.length; i++) {
  232. key = sourceKeys[i];
  233. if (excluded.indexOf(key) >= 0) continue;
  234. target[key] = source[key];
  235. }
  236. return target;
  237. }
  238. // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js
  239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; });
  240. function _objectWithoutProperties(source, excluded) {
  241. if (source == null) return {};
  242. var target = _objectWithoutPropertiesLoose(source, excluded);
  243. var key, i;
  244. if (Object.getOwnPropertySymbols) {
  245. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  246. for (i = 0; i < sourceSymbolKeys.length; i++) {
  247. key = sourceSymbolKeys[i];
  248. if (excluded.indexOf(key) >= 0) continue;
  249. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  250. target[key] = source[key];
  251. }
  252. }
  253. return target;
  254. }
  255. /***/ }),
  256. /***/ 22:
  257. /***/ (function(module, exports) {
  258. (function() { module.exports = this["wp"]["richText"]; }());
  259. /***/ }),
  260. /***/ 25:
  261. /***/ (function(module, exports) {
  262. (function() { module.exports = this["wp"]["dom"]; }());
  263. /***/ }),
  264. /***/ 26:
  265. /***/ (function(module, exports) {
  266. (function() { module.exports = this["wp"]["url"]; }());
  267. /***/ }),
  268. /***/ 3:
  269. /***/ (function(module, exports) {
  270. (function() { module.exports = this["wp"]["components"]; }());
  271. /***/ }),
  272. /***/ 31:
  273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  274. "use strict";
  275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
  276. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  277. function _typeof(obj) {
  278. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  279. _typeof = function _typeof(obj) {
  280. return _typeof2(obj);
  281. };
  282. } else {
  283. _typeof = function _typeof(obj) {
  284. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  285. };
  286. }
  287. return _typeof(obj);
  288. }
  289. /***/ }),
  290. /***/ 350:
  291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  292. "use strict";
  293. __webpack_require__.r(__webpack_exports__);
  294. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules
  295. var objectWithoutProperties = __webpack_require__(21);
  296. // EXTERNAL MODULE: external {"this":["wp","richText"]}
  297. var external_this_wp_richText_ = __webpack_require__(22);
  298. // EXTERNAL MODULE: external {"this":["wp","element"]}
  299. var external_this_wp_element_ = __webpack_require__(0);
  300. // EXTERNAL MODULE: external {"this":["wp","i18n"]}
  301. var external_this_wp_i18n_ = __webpack_require__(1);
  302. // EXTERNAL MODULE: external {"this":["wp","blockEditor"]}
  303. var external_this_wp_blockEditor_ = __webpack_require__(6);
  304. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/bold/index.js
  305. /**
  306. * WordPress dependencies
  307. */
  308. var bold_name = 'core/bold';
  309. var title = Object(external_this_wp_i18n_["__"])('Bold');
  310. var bold = {
  311. name: bold_name,
  312. title: title,
  313. tagName: 'strong',
  314. className: null,
  315. edit: function edit(_ref) {
  316. var isActive = _ref.isActive,
  317. value = _ref.value,
  318. onChange = _ref.onChange;
  319. var onToggle = function onToggle() {
  320. return onChange(Object(external_this_wp_richText_["toggleFormat"])(value, {
  321. type: bold_name
  322. }));
  323. };
  324. return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextShortcut"], {
  325. type: "primary",
  326. character: "b",
  327. onUse: onToggle
  328. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  329. name: "bold",
  330. icon: "editor-bold",
  331. title: title,
  332. onClick: onToggle,
  333. isActive: isActive,
  334. shortcutType: "primary",
  335. shortcutCharacter: "b"
  336. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["__unstableRichTextInputEvent"], {
  337. inputType: "formatBold",
  338. onInput: onToggle
  339. }));
  340. }
  341. };
  342. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/code/index.js
  343. /**
  344. * WordPress dependencies
  345. */
  346. var code_name = 'core/code';
  347. var code_title = Object(external_this_wp_i18n_["__"])('Inline Code');
  348. var code = {
  349. name: code_name,
  350. title: code_title,
  351. tagName: 'code',
  352. className: null,
  353. __unstableInputRule: function __unstableInputRule(value) {
  354. var BACKTICK = '`';
  355. var _value = value,
  356. start = _value.start,
  357. text = _value.text;
  358. var characterBefore = text.slice(start - 1, start); // Quick check the text for the necessary character.
  359. if (characterBefore !== BACKTICK) {
  360. return value;
  361. }
  362. var textBefore = text.slice(0, start - 1);
  363. var indexBefore = textBefore.lastIndexOf(BACKTICK);
  364. if (indexBefore === -1) {
  365. return value;
  366. }
  367. var startIndex = indexBefore;
  368. var endIndex = start - 2;
  369. if (startIndex === endIndex) {
  370. return value;
  371. }
  372. value = Object(external_this_wp_richText_["remove"])(value, startIndex, startIndex + 1);
  373. value = Object(external_this_wp_richText_["remove"])(value, endIndex, endIndex + 1);
  374. value = Object(external_this_wp_richText_["applyFormat"])(value, {
  375. type: code_name
  376. }, startIndex, endIndex);
  377. return value;
  378. },
  379. edit: function edit(_ref) {
  380. var value = _ref.value,
  381. onChange = _ref.onChange,
  382. isActive = _ref.isActive;
  383. var onToggle = function onToggle() {
  384. return onChange(Object(external_this_wp_richText_["toggleFormat"])(value, {
  385. type: code_name
  386. }));
  387. };
  388. return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  389. icon: "editor-code",
  390. title: code_title,
  391. onClick: onToggle,
  392. isActive: isActive
  393. });
  394. }
  395. };
  396. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js
  397. var objectSpread = __webpack_require__(7);
  398. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
  399. var classCallCheck = __webpack_require__(12);
  400. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
  401. var createClass = __webpack_require__(11);
  402. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
  403. var possibleConstructorReturn = __webpack_require__(13);
  404. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
  405. var getPrototypeOf = __webpack_require__(14);
  406. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
  407. var assertThisInitialized = __webpack_require__(5);
  408. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
  409. var inherits = __webpack_require__(15);
  410. // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
  411. var esm_extends = __webpack_require__(18);
  412. // EXTERNAL MODULE: external {"this":["wp","components"]}
  413. var external_this_wp_components_ = __webpack_require__(3);
  414. // EXTERNAL MODULE: external {"this":["wp","keycodes"]}
  415. var external_this_wp_keycodes_ = __webpack_require__(19);
  416. // EXTERNAL MODULE: external {"this":["wp","dom"]}
  417. var external_this_wp_dom_ = __webpack_require__(25);
  418. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/image/index.js
  419. /**
  420. * WordPress dependencies
  421. */
  422. var ALLOWED_MEDIA_TYPES = ['image'];
  423. var image_name = 'core/image';
  424. var image_title = Object(external_this_wp_i18n_["__"])('Inline image');
  425. var stopKeyPropagation = function stopKeyPropagation(event) {
  426. return event.stopPropagation();
  427. };
  428. var image_PopoverAtImage = function PopoverAtImage(_ref) {
  429. var dependencies = _ref.dependencies,
  430. props = Object(objectWithoutProperties["a" /* default */])(_ref, ["dependencies"]);
  431. return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Popover"], Object(esm_extends["a" /* default */])({
  432. position: "bottom center",
  433. focusOnMount: false,
  434. anchorRect: Object(external_this_wp_element_["useMemo"])(function () {
  435. return Object(external_this_wp_dom_["computeCaretRect"])();
  436. }, dependencies)
  437. }, props));
  438. };
  439. var image_image = {
  440. name: image_name,
  441. title: image_title,
  442. keywords: [Object(external_this_wp_i18n_["__"])('photo'), Object(external_this_wp_i18n_["__"])('media')],
  443. object: true,
  444. tagName: 'img',
  445. className: null,
  446. attributes: {
  447. className: 'class',
  448. style: 'style',
  449. url: 'src',
  450. alt: 'alt'
  451. },
  452. edit:
  453. /*#__PURE__*/
  454. function (_Component) {
  455. Object(inherits["a" /* default */])(ImageEdit, _Component);
  456. function ImageEdit() {
  457. var _this;
  458. Object(classCallCheck["a" /* default */])(this, ImageEdit);
  459. _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(ImageEdit).apply(this, arguments));
  460. _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(_this));
  461. _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(_this));
  462. _this.openModal = _this.openModal.bind(Object(assertThisInitialized["a" /* default */])(_this));
  463. _this.closeModal = _this.closeModal.bind(Object(assertThisInitialized["a" /* default */])(_this));
  464. _this.state = {
  465. modal: false
  466. };
  467. return _this;
  468. }
  469. Object(createClass["a" /* default */])(ImageEdit, [{
  470. key: "onChange",
  471. value: function onChange(width) {
  472. this.setState({
  473. width: width
  474. });
  475. }
  476. }, {
  477. key: "onKeyDown",
  478. value: function onKeyDown(event) {
  479. if ([external_this_wp_keycodes_["LEFT"], external_this_wp_keycodes_["DOWN"], external_this_wp_keycodes_["RIGHT"], external_this_wp_keycodes_["UP"], external_this_wp_keycodes_["BACKSPACE"], external_this_wp_keycodes_["ENTER"]].indexOf(event.keyCode) > -1) {
  480. // Stop the key event from propagating up to ObserveTyping.startTypingInTextField.
  481. event.stopPropagation();
  482. }
  483. }
  484. }, {
  485. key: "openModal",
  486. value: function openModal() {
  487. this.setState({
  488. modal: true
  489. });
  490. }
  491. }, {
  492. key: "closeModal",
  493. value: function closeModal() {
  494. this.setState({
  495. modal: false
  496. });
  497. }
  498. }, {
  499. key: "render",
  500. value: function render() {
  501. var _this2 = this;
  502. var _this$props = this.props,
  503. value = _this$props.value,
  504. onChange = _this$props.onChange,
  505. isObjectActive = _this$props.isObjectActive,
  506. activeObjectAttributes = _this$props.activeObjectAttributes;
  507. var style = activeObjectAttributes.style;
  508. return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUploadCheck"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  509. icon: Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], {
  510. xmlns: "http://www.w3.org/2000/svg",
  511. viewBox: "0 0 24 24"
  512. }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], {
  513. d: "M4 16h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v9c0 1.1.9 2 2 2zM4 5h10v9H4V5zm14 9v2h4v-2h-4zM2 20h20v-2H2v2zm6.4-8.8L7 9.4 5 12h8l-2.6-3.4-2 2.6z"
  514. })),
  515. title: image_title,
  516. onClick: this.openModal,
  517. isActive: isObjectActive
  518. }), this.state.modal && Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUpload"], {
  519. allowedTypes: ALLOWED_MEDIA_TYPES,
  520. onSelect: function onSelect(_ref2) {
  521. var id = _ref2.id,
  522. url = _ref2.url,
  523. alt = _ref2.alt,
  524. width = _ref2.width;
  525. _this2.closeModal();
  526. onChange(Object(external_this_wp_richText_["insertObject"])(value, {
  527. type: image_name,
  528. attributes: {
  529. className: "wp-image-".concat(id),
  530. style: "width: ".concat(Math.min(width, 150), "px;"),
  531. url: url,
  532. alt: alt
  533. }
  534. }));
  535. },
  536. onClose: this.closeModal,
  537. render: function render(_ref3) {
  538. var open = _ref3.open;
  539. open();
  540. return null;
  541. }
  542. }), isObjectActive && Object(external_this_wp_element_["createElement"])(image_PopoverAtImage // Reposition Popover when the selection changes or
  543. // when the width changes.
  544. , {
  545. dependencies: [style, value.start]
  546. }, Object(external_this_wp_element_["createElement"])("form", {
  547. className: "editor-format-toolbar__image-container-content block-editor-format-toolbar__image-container-content",
  548. onKeyPress: stopKeyPropagation,
  549. onKeyDown: this.onKeyDown,
  550. onSubmit: function onSubmit(event) {
  551. var newReplacements = value.replacements.slice();
  552. newReplacements[value.start] = {
  553. type: image_name,
  554. attributes: Object(objectSpread["a" /* default */])({}, activeObjectAttributes, {
  555. style: "width: ".concat(_this2.state.width, "px;")
  556. })
  557. };
  558. onChange(Object(objectSpread["a" /* default */])({}, value, {
  559. replacements: newReplacements
  560. }));
  561. event.preventDefault();
  562. }
  563. }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], {
  564. className: "editor-format-toolbar__image-container-value block-editor-format-toolbar__image-container-value",
  565. type: "number",
  566. label: Object(external_this_wp_i18n_["__"])('Width'),
  567. value: this.state.width,
  568. min: 1,
  569. onChange: this.onChange
  570. }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], {
  571. icon: "editor-break",
  572. label: Object(external_this_wp_i18n_["__"])('Apply'),
  573. type: "submit"
  574. }))));
  575. }
  576. }], [{
  577. key: "getDerivedStateFromProps",
  578. value: function getDerivedStateFromProps(props, state) {
  579. var style = props.activeObjectAttributes.style;
  580. if (style === state.previousStyle) {
  581. return null;
  582. }
  583. if (!style) {
  584. return {
  585. width: undefined,
  586. previousStyle: style
  587. };
  588. }
  589. return {
  590. width: style.replace(/\D/g, ''),
  591. previousStyle: style
  592. };
  593. }
  594. }]);
  595. return ImageEdit;
  596. }(external_this_wp_element_["Component"])
  597. };
  598. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/italic/index.js
  599. /**
  600. * WordPress dependencies
  601. */
  602. var italic_name = 'core/italic';
  603. var italic_title = Object(external_this_wp_i18n_["__"])('Italic');
  604. var italic = {
  605. name: italic_name,
  606. title: italic_title,
  607. tagName: 'em',
  608. className: null,
  609. edit: function edit(_ref) {
  610. var isActive = _ref.isActive,
  611. value = _ref.value,
  612. onChange = _ref.onChange;
  613. var onToggle = function onToggle() {
  614. return onChange(Object(external_this_wp_richText_["toggleFormat"])(value, {
  615. type: italic_name
  616. }));
  617. };
  618. return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextShortcut"], {
  619. type: "primary",
  620. character: "i",
  621. onUse: onToggle
  622. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  623. name: "italic",
  624. icon: "editor-italic",
  625. title: italic_title,
  626. onClick: onToggle,
  627. isActive: isActive,
  628. shortcutType: "primary",
  629. shortcutCharacter: "i"
  630. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["__unstableRichTextInputEvent"], {
  631. inputType: "formatItalic",
  632. onInput: onToggle
  633. }));
  634. }
  635. };
  636. // EXTERNAL MODULE: external {"this":["wp","url"]}
  637. var external_this_wp_url_ = __webpack_require__(26);
  638. // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]}
  639. var external_this_wp_htmlEntities_ = __webpack_require__(52);
  640. // EXTERNAL MODULE: external "lodash"
  641. var external_lodash_ = __webpack_require__(2);
  642. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/utils.js
  643. /**
  644. * External dependencies
  645. */
  646. /**
  647. * WordPress dependencies
  648. */
  649. /**
  650. * Check for issues with the provided href.
  651. *
  652. * @param {string} href The href.
  653. *
  654. * @return {boolean} Is the href invalid?
  655. */
  656. function isValidHref(href) {
  657. if (!href) {
  658. return false;
  659. }
  660. var trimmedHref = href.trim();
  661. if (!trimmedHref) {
  662. return false;
  663. } // Does the href start with something that looks like a URL protocol?
  664. if (/^\S+:/.test(trimmedHref)) {
  665. var protocol = Object(external_this_wp_url_["getProtocol"])(trimmedHref);
  666. if (!Object(external_this_wp_url_["isValidProtocol"])(protocol)) {
  667. return false;
  668. } // Add some extra checks for http(s) URIs, since these are the most common use-case.
  669. // This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
  670. if (Object(external_lodash_["startsWith"])(protocol, 'http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
  671. return false;
  672. }
  673. var authority = Object(external_this_wp_url_["getAuthority"])(trimmedHref);
  674. if (!Object(external_this_wp_url_["isValidAuthority"])(authority)) {
  675. return false;
  676. }
  677. var path = Object(external_this_wp_url_["getPath"])(trimmedHref);
  678. if (path && !Object(external_this_wp_url_["isValidPath"])(path)) {
  679. return false;
  680. }
  681. var queryString = Object(external_this_wp_url_["getQueryString"])(trimmedHref);
  682. if (queryString && !Object(external_this_wp_url_["isValidQueryString"])(queryString)) {
  683. return false;
  684. }
  685. var fragment = Object(external_this_wp_url_["getFragment"])(trimmedHref);
  686. if (fragment && !Object(external_this_wp_url_["isValidFragment"])(fragment)) {
  687. return false;
  688. }
  689. } // Validate anchor links.
  690. if (Object(external_lodash_["startsWith"])(trimmedHref, '#') && !Object(external_this_wp_url_["isValidFragment"])(trimmedHref)) {
  691. return false;
  692. }
  693. return true;
  694. }
  695. /**
  696. * Generates the format object that will be applied to the link text.
  697. *
  698. * @param {Object} options
  699. * @param {string} options.url The href of the link.
  700. * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.
  701. * @param {Object} options.text The text that is being hyperlinked.
  702. *
  703. * @return {Object} The final format object.
  704. */
  705. function createLinkFormat(_ref) {
  706. var url = _ref.url,
  707. opensInNewWindow = _ref.opensInNewWindow,
  708. text = _ref.text;
  709. var format = {
  710. type: 'core/link',
  711. attributes: {
  712. url: url
  713. }
  714. };
  715. if (opensInNewWindow) {
  716. // translators: accessibility label for external links, where the argument is the link text
  717. var label = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('%s (opens in a new tab)'), text);
  718. format.attributes.target = '_blank';
  719. format.attributes.rel = 'noreferrer noopener';
  720. format.attributes['aria-label'] = label;
  721. }
  722. return format;
  723. }
  724. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/inline.js
  725. /**
  726. * WordPress dependencies
  727. */
  728. /**
  729. * Internal dependencies
  730. */
  731. var inline_stopKeyPropagation = function stopKeyPropagation(event) {
  732. return event.stopPropagation();
  733. };
  734. function isShowingInput(props, state) {
  735. return props.addingLink || state.editLink;
  736. }
  737. var inline_URLPopoverAtLink = function URLPopoverAtLink(_ref) {
  738. var isActive = _ref.isActive,
  739. addingLink = _ref.addingLink,
  740. value = _ref.value,
  741. props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isActive", "addingLink", "value"]);
  742. var anchorRect = Object(external_this_wp_element_["useMemo"])(function () {
  743. var selection = window.getSelection();
  744. var range = selection.rangeCount > 0 ? selection.getRangeAt(0) : null;
  745. if (!range) {
  746. return;
  747. }
  748. if (addingLink) {
  749. return Object(external_this_wp_dom_["getRectangleFromRange"])(range);
  750. }
  751. var element = range.startContainer; // If the caret is right before the element, select the next element.
  752. element = element.nextElementSibling || element;
  753. while (element.nodeType !== window.Node.ELEMENT_NODE) {
  754. element = element.parentNode;
  755. }
  756. var closest = element.closest('a');
  757. if (closest) {
  758. return closest.getBoundingClientRect();
  759. }
  760. }, [isActive, addingLink, value.start, value.end]);
  761. if (!anchorRect) {
  762. return null;
  763. }
  764. return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["URLPopover"], Object(esm_extends["a" /* default */])({
  765. anchorRect: anchorRect
  766. }, props));
  767. };
  768. var inline_InlineLinkUI =
  769. /*#__PURE__*/
  770. function (_Component) {
  771. Object(inherits["a" /* default */])(InlineLinkUI, _Component);
  772. function InlineLinkUI() {
  773. var _this;
  774. Object(classCallCheck["a" /* default */])(this, InlineLinkUI);
  775. _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(InlineLinkUI).apply(this, arguments));
  776. _this.editLink = _this.editLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
  777. _this.submitLink = _this.submitLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
  778. _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(_this));
  779. _this.onChangeInputValue = _this.onChangeInputValue.bind(Object(assertThisInitialized["a" /* default */])(_this));
  780. _this.setLinkTarget = _this.setLinkTarget.bind(Object(assertThisInitialized["a" /* default */])(_this));
  781. _this.onFocusOutside = _this.onFocusOutside.bind(Object(assertThisInitialized["a" /* default */])(_this));
  782. _this.resetState = _this.resetState.bind(Object(assertThisInitialized["a" /* default */])(_this));
  783. _this.autocompleteRef = Object(external_this_wp_element_["createRef"])();
  784. _this.state = {
  785. opensInNewWindow: false,
  786. inputValue: ''
  787. };
  788. return _this;
  789. }
  790. Object(createClass["a" /* default */])(InlineLinkUI, [{
  791. key: "onKeyDown",
  792. value: function onKeyDown(event) {
  793. if ([external_this_wp_keycodes_["LEFT"], external_this_wp_keycodes_["DOWN"], external_this_wp_keycodes_["RIGHT"], external_this_wp_keycodes_["UP"], external_this_wp_keycodes_["BACKSPACE"], external_this_wp_keycodes_["ENTER"]].indexOf(event.keyCode) > -1) {
  794. // Stop the key event from propagating up to ObserveTyping.startTypingInTextField.
  795. event.stopPropagation();
  796. }
  797. }
  798. }, {
  799. key: "onChangeInputValue",
  800. value: function onChangeInputValue(inputValue) {
  801. this.setState({
  802. inputValue: inputValue
  803. });
  804. }
  805. }, {
  806. key: "setLinkTarget",
  807. value: function setLinkTarget(opensInNewWindow) {
  808. var _this$props = this.props,
  809. _this$props$activeAtt = _this$props.activeAttributes.url,
  810. url = _this$props$activeAtt === void 0 ? '' : _this$props$activeAtt,
  811. value = _this$props.value,
  812. onChange = _this$props.onChange;
  813. this.setState({
  814. opensInNewWindow: opensInNewWindow
  815. }); // Apply now if URL is not being edited.
  816. if (!isShowingInput(this.props, this.state)) {
  817. var selectedText = Object(external_this_wp_richText_["getTextContent"])(Object(external_this_wp_richText_["slice"])(value));
  818. onChange(Object(external_this_wp_richText_["applyFormat"])(value, createLinkFormat({
  819. url: url,
  820. opensInNewWindow: opensInNewWindow,
  821. text: selectedText
  822. })));
  823. }
  824. }
  825. }, {
  826. key: "editLink",
  827. value: function editLink(event) {
  828. this.setState({
  829. editLink: true
  830. });
  831. event.preventDefault();
  832. }
  833. }, {
  834. key: "submitLink",
  835. value: function submitLink(event) {
  836. var _this$props2 = this.props,
  837. isActive = _this$props2.isActive,
  838. value = _this$props2.value,
  839. onChange = _this$props2.onChange,
  840. speak = _this$props2.speak;
  841. var _this$state = this.state,
  842. inputValue = _this$state.inputValue,
  843. opensInNewWindow = _this$state.opensInNewWindow;
  844. var url = Object(external_this_wp_url_["prependHTTP"])(inputValue);
  845. var selectedText = Object(external_this_wp_richText_["getTextContent"])(Object(external_this_wp_richText_["slice"])(value));
  846. var format = createLinkFormat({
  847. url: url,
  848. opensInNewWindow: opensInNewWindow,
  849. text: selectedText
  850. });
  851. event.preventDefault();
  852. if (Object(external_this_wp_richText_["isCollapsed"])(value) && !isActive) {
  853. var toInsert = Object(external_this_wp_richText_["applyFormat"])(Object(external_this_wp_richText_["create"])({
  854. text: url
  855. }), format, 0, url.length);
  856. onChange(Object(external_this_wp_richText_["insert"])(value, toInsert));
  857. } else {
  858. onChange(Object(external_this_wp_richText_["applyFormat"])(value, format));
  859. }
  860. this.resetState();
  861. if (!isValidHref(url)) {
  862. speak(Object(external_this_wp_i18n_["__"])('Warning: the link has been inserted but may have errors. Please test it.'), 'assertive');
  863. } else if (isActive) {
  864. speak(Object(external_this_wp_i18n_["__"])('Link edited.'), 'assertive');
  865. } else {
  866. speak(Object(external_this_wp_i18n_["__"])('Link inserted.'), 'assertive');
  867. }
  868. }
  869. }, {
  870. key: "onFocusOutside",
  871. value: function onFocusOutside() {
  872. // The autocomplete suggestions list renders in a separate popover (in a portal),
  873. // so onFocusOutside fails to detect that a click on a suggestion occurred in the
  874. // LinkContainer. Detect clicks on autocomplete suggestions using a ref here, and
  875. // return to avoid the popover being closed.
  876. var autocompleteElement = this.autocompleteRef.current;
  877. if (autocompleteElement && autocompleteElement.contains(document.activeElement)) {
  878. return;
  879. }
  880. this.resetState();
  881. }
  882. }, {
  883. key: "resetState",
  884. value: function resetState() {
  885. this.props.stopAddingLink();
  886. this.setState({
  887. editLink: false
  888. });
  889. }
  890. }, {
  891. key: "render",
  892. value: function render() {
  893. var _this2 = this;
  894. var _this$props3 = this.props,
  895. isActive = _this$props3.isActive,
  896. url = _this$props3.activeAttributes.url,
  897. addingLink = _this$props3.addingLink,
  898. value = _this$props3.value;
  899. if (!isActive && !addingLink) {
  900. return null;
  901. }
  902. var _this$state2 = this.state,
  903. inputValue = _this$state2.inputValue,
  904. opensInNewWindow = _this$state2.opensInNewWindow;
  905. var showInput = isShowingInput(this.props, this.state);
  906. return Object(external_this_wp_element_["createElement"])(inline_URLPopoverAtLink, {
  907. value: value,
  908. isActive: isActive,
  909. addingLink: addingLink,
  910. onFocusOutside: this.onFocusOutside,
  911. onClose: this.resetState,
  912. focusOnMount: showInput ? 'firstElement' : false,
  913. renderSettings: function renderSettings() {
  914. return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ToggleControl"], {
  915. label: Object(external_this_wp_i18n_["__"])('Open in New Tab'),
  916. checked: opensInNewWindow,
  917. onChange: _this2.setLinkTarget
  918. });
  919. }
  920. }, showInput ? Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["URLPopover"].LinkEditor, {
  921. className: "editor-format-toolbar__link-container-content block-editor-format-toolbar__link-container-content",
  922. value: inputValue,
  923. onChangeInputValue: this.onChangeInputValue,
  924. onKeyDown: this.onKeyDown,
  925. onKeyPress: inline_stopKeyPropagation,
  926. onSubmit: this.submitLink,
  927. autocompleteRef: this.autocompleteRef
  928. }) : Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["URLPopover"].LinkViewer, {
  929. className: "editor-format-toolbar__link-container-content block-editor-format-toolbar__link-container-content",
  930. onKeyPress: inline_stopKeyPropagation,
  931. url: url,
  932. onEditLinkClick: this.editLink,
  933. linkClassName: isValidHref(Object(external_this_wp_url_["prependHTTP"])(url)) ? undefined : 'has-invalid-link'
  934. }));
  935. }
  936. }], [{
  937. key: "getDerivedStateFromProps",
  938. value: function getDerivedStateFromProps(props, state) {
  939. var _props$activeAttribut = props.activeAttributes,
  940. url = _props$activeAttribut.url,
  941. target = _props$activeAttribut.target;
  942. var opensInNewWindow = target === '_blank';
  943. if (!isShowingInput(props, state)) {
  944. var update = {};
  945. if (url !== state.inputValue) {
  946. update.inputValue = url;
  947. }
  948. if (opensInNewWindow !== state.opensInNewWindow) {
  949. update.opensInNewWindow = opensInNewWindow;
  950. }
  951. return Object.keys(update).length ? update : null;
  952. }
  953. return null;
  954. }
  955. }]);
  956. return InlineLinkUI;
  957. }(external_this_wp_element_["Component"]);
  958. /* harmony default export */ var inline = (Object(external_this_wp_components_["withSpokenMessages"])(inline_InlineLinkUI));
  959. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/link/index.js
  960. /**
  961. * WordPress dependencies
  962. */
  963. /**
  964. * Internal dependencies
  965. */
  966. var link_name = 'core/link';
  967. var link_title = Object(external_this_wp_i18n_["__"])('Link');
  968. var link_link = {
  969. name: link_name,
  970. title: link_title,
  971. tagName: 'a',
  972. className: null,
  973. attributes: {
  974. url: 'href',
  975. target: 'target'
  976. },
  977. __unstablePasteRule: function __unstablePasteRule(value, _ref) {
  978. var html = _ref.html,
  979. plainText = _ref.plainText;
  980. if (Object(external_this_wp_richText_["isCollapsed"])(value)) {
  981. return value;
  982. }
  983. var pastedText = (html || plainText).replace(/<[^>]+>/g, '').trim(); // A URL was pasted, turn the selection into a link
  984. if (!Object(external_this_wp_url_["isURL"])(pastedText)) {
  985. return value;
  986. } // Allows us to ask for this information when we get a report.
  987. window.console.log('Created link:\n\n', pastedText);
  988. return Object(external_this_wp_richText_["applyFormat"])(value, {
  989. type: link_name,
  990. attributes: {
  991. url: Object(external_this_wp_htmlEntities_["decodeEntities"])(pastedText)
  992. }
  993. });
  994. },
  995. edit: Object(external_this_wp_components_["withSpokenMessages"])(
  996. /*#__PURE__*/
  997. function (_Component) {
  998. Object(inherits["a" /* default */])(LinkEdit, _Component);
  999. function LinkEdit() {
  1000. var _this;
  1001. Object(classCallCheck["a" /* default */])(this, LinkEdit);
  1002. _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(LinkEdit).apply(this, arguments));
  1003. _this.addLink = _this.addLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
  1004. _this.stopAddingLink = _this.stopAddingLink.bind(Object(assertThisInitialized["a" /* default */])(_this));
  1005. _this.onRemoveFormat = _this.onRemoveFormat.bind(Object(assertThisInitialized["a" /* default */])(_this));
  1006. _this.state = {
  1007. addingLink: false
  1008. };
  1009. return _this;
  1010. }
  1011. Object(createClass["a" /* default */])(LinkEdit, [{
  1012. key: "addLink",
  1013. value: function addLink() {
  1014. var _this$props = this.props,
  1015. value = _this$props.value,
  1016. onChange = _this$props.onChange;
  1017. var text = Object(external_this_wp_richText_["getTextContent"])(Object(external_this_wp_richText_["slice"])(value));
  1018. if (text && Object(external_this_wp_url_["isURL"])(text)) {
  1019. onChange(Object(external_this_wp_richText_["applyFormat"])(value, {
  1020. type: link_name,
  1021. attributes: {
  1022. url: text
  1023. }
  1024. }));
  1025. } else if (text && Object(external_this_wp_url_["isEmail"])(text)) {
  1026. onChange(Object(external_this_wp_richText_["applyFormat"])(value, {
  1027. type: link_name,
  1028. attributes: {
  1029. url: "mailto:".concat(text)
  1030. }
  1031. }));
  1032. } else {
  1033. this.setState({
  1034. addingLink: true
  1035. });
  1036. }
  1037. }
  1038. }, {
  1039. key: "stopAddingLink",
  1040. value: function stopAddingLink() {
  1041. this.setState({
  1042. addingLink: false
  1043. });
  1044. }
  1045. }, {
  1046. key: "onRemoveFormat",
  1047. value: function onRemoveFormat() {
  1048. var _this$props2 = this.props,
  1049. value = _this$props2.value,
  1050. onChange = _this$props2.onChange,
  1051. speak = _this$props2.speak;
  1052. onChange(Object(external_this_wp_richText_["removeFormat"])(value, link_name));
  1053. speak(Object(external_this_wp_i18n_["__"])('Link removed.'), 'assertive');
  1054. }
  1055. }, {
  1056. key: "render",
  1057. value: function render() {
  1058. var _this$props3 = this.props,
  1059. isActive = _this$props3.isActive,
  1060. activeAttributes = _this$props3.activeAttributes,
  1061. value = _this$props3.value,
  1062. onChange = _this$props3.onChange;
  1063. return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextShortcut"], {
  1064. type: "primary",
  1065. character: "k",
  1066. onUse: this.addLink
  1067. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextShortcut"], {
  1068. type: "primaryShift",
  1069. character: "k",
  1070. onUse: this.onRemoveFormat
  1071. }), isActive && Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  1072. name: "link",
  1073. icon: "editor-unlink",
  1074. title: Object(external_this_wp_i18n_["__"])('Unlink'),
  1075. onClick: this.onRemoveFormat,
  1076. isActive: isActive,
  1077. shortcutType: "primaryShift",
  1078. shortcutCharacter: "k"
  1079. }), !isActive && Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  1080. name: "link",
  1081. icon: "admin-links",
  1082. title: link_title,
  1083. onClick: this.addLink,
  1084. isActive: isActive,
  1085. shortcutType: "primary",
  1086. shortcutCharacter: "k"
  1087. }), Object(external_this_wp_element_["createElement"])(inline, {
  1088. addingLink: this.state.addingLink,
  1089. stopAddingLink: this.stopAddingLink,
  1090. isActive: isActive,
  1091. activeAttributes: activeAttributes,
  1092. value: value,
  1093. onChange: onChange
  1094. }));
  1095. }
  1096. }]);
  1097. return LinkEdit;
  1098. }(external_this_wp_element_["Component"]))
  1099. };
  1100. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/strikethrough/index.js
  1101. /**
  1102. * WordPress dependencies
  1103. */
  1104. var strikethrough_name = 'core/strikethrough';
  1105. var strikethrough_title = Object(external_this_wp_i18n_["__"])('Strikethrough');
  1106. var strikethrough = {
  1107. name: strikethrough_name,
  1108. title: strikethrough_title,
  1109. tagName: 's',
  1110. className: null,
  1111. edit: function edit(_ref) {
  1112. var isActive = _ref.isActive,
  1113. value = _ref.value,
  1114. onChange = _ref.onChange;
  1115. var onToggle = function onToggle() {
  1116. return onChange(Object(external_this_wp_richText_["toggleFormat"])(value, {
  1117. type: strikethrough_name
  1118. }));
  1119. };
  1120. return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextToolbarButton"], {
  1121. icon: "editor-strikethrough",
  1122. title: strikethrough_title,
  1123. onClick: onToggle,
  1124. isActive: isActive
  1125. });
  1126. }
  1127. };
  1128. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/underline/index.js
  1129. /**
  1130. * WordPress dependencies
  1131. */
  1132. var underline_name = 'core/underline';
  1133. var underline = {
  1134. name: underline_name,
  1135. title: Object(external_this_wp_i18n_["__"])('Underline'),
  1136. tagName: 'span',
  1137. className: null,
  1138. attributes: {
  1139. style: 'style'
  1140. },
  1141. edit: function edit(_ref) {
  1142. var value = _ref.value,
  1143. onChange = _ref.onChange;
  1144. var onToggle = function onToggle() {
  1145. onChange(Object(external_this_wp_richText_["toggleFormat"])(value, {
  1146. type: underline_name,
  1147. attributes: {
  1148. style: 'text-decoration: underline;'
  1149. }
  1150. }));
  1151. };
  1152. return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["RichTextShortcut"], {
  1153. type: "primary",
  1154. character: "u",
  1155. onUse: onToggle
  1156. }), Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["__unstableRichTextInputEvent"], {
  1157. inputType: "formatUnderline",
  1158. onInput: onToggle
  1159. }));
  1160. }
  1161. };
  1162. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/default-formats.js
  1163. /**
  1164. * Internal dependencies
  1165. */
  1166. /* harmony default export */ var default_formats = ([bold, code, image_image, italic, link_link, strikethrough, underline]);
  1167. // CONCATENATED MODULE: ./node_modules/@wordpress/format-library/build-module/index.js
  1168. /**
  1169. * WordPress dependencies
  1170. */
  1171. /**
  1172. * Internal dependencies
  1173. */
  1174. default_formats.forEach(function (_ref) {
  1175. var name = _ref.name,
  1176. settings = Object(objectWithoutProperties["a" /* default */])(_ref, ["name"]);
  1177. return Object(external_this_wp_richText_["registerFormatType"])(name, settings);
  1178. });
  1179. /***/ }),
  1180. /***/ 5:
  1181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1182. "use strict";
  1183. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
  1184. function _assertThisInitialized(self) {
  1185. if (self === void 0) {
  1186. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  1187. }
  1188. return self;
  1189. }
  1190. /***/ }),
  1191. /***/ 52:
  1192. /***/ (function(module, exports) {
  1193. (function() { module.exports = this["wp"]["htmlEntities"]; }());
  1194. /***/ }),
  1195. /***/ 6:
  1196. /***/ (function(module, exports) {
  1197. (function() { module.exports = this["wp"]["blockEditor"]; }());
  1198. /***/ }),
  1199. /***/ 7:
  1200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1201. "use strict";
  1202. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; });
  1203. /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(10);
  1204. function _objectSpread(target) {
  1205. for (var i = 1; i < arguments.length; i++) {
  1206. var source = arguments[i] != null ? arguments[i] : {};
  1207. var ownKeys = Object.keys(source);
  1208. if (typeof Object.getOwnPropertySymbols === 'function') {
  1209. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  1210. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  1211. }));
  1212. }
  1213. ownKeys.forEach(function (key) {
  1214. Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]);
  1215. });
  1216. }
  1217. return target;
  1218. }
  1219. /***/ })
  1220. /******/ });