@wordpress/format-library 4.11.0 → 4.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +6 -8
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +6 -8
  5. package/build/code/index.js.map +1 -1
  6. package/build/image/index.js +24 -28
  7. package/build/image/index.js.map +1 -1
  8. package/build/index.js +4 -7
  9. package/build/index.js.map +1 -1
  10. package/build/italic/index.js +6 -8
  11. package/build/italic/index.js.map +1 -1
  12. package/build/keyboard/index.js +6 -8
  13. package/build/keyboard/index.js.map +1 -1
  14. package/build/link/index.js +12 -15
  15. package/build/link/index.js.map +1 -1
  16. package/build/link/index.native.js +2 -6
  17. package/build/link/index.native.js.map +1 -1
  18. package/build/link/inline.js +10 -11
  19. package/build/link/inline.js.map +1 -1
  20. package/build/link/modal-screens/link-picker-screen.native.js +4 -6
  21. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  22. package/build/link/modal-screens/link-settings-screen.native.js +25 -33
  23. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  24. package/build/link/modal.native.js +4 -5
  25. package/build/link/modal.native.js.map +1 -1
  26. package/build/link/utils.js +18 -44
  27. package/build/link/utils.js.map +1 -1
  28. package/build/strikethrough/index.js +6 -8
  29. package/build/strikethrough/index.js.map +1 -1
  30. package/build/subscript/index.js +6 -8
  31. package/build/subscript/index.js.map +1 -1
  32. package/build/superscript/index.js +6 -8
  33. package/build/superscript/index.js.map +1 -1
  34. package/build/text-color/index.js +11 -14
  35. package/build/text-color/index.js.map +1 -1
  36. package/build/text-color/index.native.js +16 -23
  37. package/build/text-color/index.native.js.map +1 -1
  38. package/build/text-color/inline.js +15 -21
  39. package/build/text-color/inline.js.map +1 -1
  40. package/build/text-color/inline.native.js +16 -24
  41. package/build/text-color/inline.native.js.map +1 -1
  42. package/build/underline/index.js +4 -6
  43. package/build/underline/index.js.map +1 -1
  44. package/build/unknown/index.js +6 -8
  45. package/build/unknown/index.js.map +1 -1
  46. package/build-module/bold/index.js +6 -8
  47. package/build-module/bold/index.js.map +1 -1
  48. package/build-module/code/index.js +6 -8
  49. package/build-module/code/index.js.map +1 -1
  50. package/build-module/image/index.js +24 -28
  51. package/build-module/image/index.js.map +1 -1
  52. package/build-module/index.js +4 -7
  53. package/build-module/index.js.map +1 -1
  54. package/build-module/italic/index.js +6 -8
  55. package/build-module/italic/index.js.map +1 -1
  56. package/build-module/keyboard/index.js +6 -8
  57. package/build-module/keyboard/index.js.map +1 -1
  58. package/build-module/link/index.js +12 -15
  59. package/build-module/link/index.js.map +1 -1
  60. package/build-module/link/index.native.js +2 -6
  61. package/build-module/link/index.native.js.map +1 -1
  62. package/build-module/link/inline.js +10 -11
  63. package/build-module/link/inline.js.map +1 -1
  64. package/build-module/link/modal-screens/link-picker-screen.native.js +4 -5
  65. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  66. package/build-module/link/modal-screens/link-settings-screen.native.js +25 -33
  67. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  68. package/build-module/link/modal.native.js +4 -5
  69. package/build-module/link/modal.native.js.map +1 -1
  70. package/build-module/link/utils.js +18 -44
  71. package/build-module/link/utils.js.map +1 -1
  72. package/build-module/strikethrough/index.js +6 -8
  73. package/build-module/strikethrough/index.js.map +1 -1
  74. package/build-module/subscript/index.js +6 -8
  75. package/build-module/subscript/index.js.map +1 -1
  76. package/build-module/superscript/index.js +6 -8
  77. package/build-module/superscript/index.js.map +1 -1
  78. package/build-module/text-color/index.js +11 -14
  79. package/build-module/text-color/index.js.map +1 -1
  80. package/build-module/text-color/index.native.js +16 -23
  81. package/build-module/text-color/index.native.js.map +1 -1
  82. package/build-module/text-color/inline.js +15 -21
  83. package/build-module/text-color/inline.js.map +1 -1
  84. package/build-module/text-color/inline.native.js +16 -24
  85. package/build-module/text-color/inline.native.js.map +1 -1
  86. package/build-module/underline/index.js +4 -6
  87. package/build-module/underline/index.js.map +1 -1
  88. package/build-module/unknown/index.js +6 -8
  89. package/build-module/unknown/index.js.map +1 -1
  90. package/package.json +13 -13
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-picker-screen.native.js"],"names":["LinkPickerScreen","navigation","route","navigateToLinkTimeoutRef","navigateBackTimeoutRef","onLinkPicked","url","title","Keyboard","dismiss","current","setTimeout","navigate","linkSettingsScreens","settings","inputValue","text","onCancel","goBack","clearTimeout","params"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAOA;;AAKA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAG,MAAM;AAC9B,QAAMC,UAAU,GAAG,4BAAnB;AACA,QAAMC,KAAK,GAAG,uBAAd;AACA,QAAMC,wBAAwB,GAAG,qBAAQ,IAAR,CAAjC;AACA,QAAMC,sBAAsB,GAAG,qBAAQ,IAAR,CAA/B;;AAEA,QAAMC,YAAY,GAAG,QAAsB;AAAA,QAApB;AAAEC,MAAAA,GAAF;AAAOC,MAAAA;AAAP,KAAoB;;AAC1CC,0BAASC,OAAT;;AACAN,IAAAA,wBAAwB,CAACO,OAAzB,GAAmCC,UAAU,CAAE,MAAM;AACpDV,MAAAA,UAAU,CAACW,QAAX,CAAqBC,iBAAoBC,QAAzC,EAAmD;AAClDC,QAAAA,UAAU,EAAET,GADsC;AAElDU,QAAAA,IAAI,EAAET;AAF4C,OAAnD;AAIA,KAL4C,EAK1C,GAL0C,CAA7C;AAMA,GARD;;AAUA,QAAMU,QAAQ,GAAG,MAAM;AACtBT,0BAASC,OAAT;;AACAL,IAAAA,sBAAsB,CAACM,OAAvB,GAAiCC,UAAU,CAAE,MAAM;AAClDV,MAAAA,UAAU,CAACiB,MAAX;AACA,KAF0C,EAExC,GAFwC,CAA3C;AAGA,GALD;;AAOA,0BAAW,MAAM;AAChB,WAAO,MAAM;AACZC,MAAAA,YAAY,CAAEhB,wBAAwB,CAACO,OAA3B,CAAZ;AACAS,MAAAA,YAAY,CAAEf,sBAAsB,CAACM,OAAzB,CAAZ;AACA,KAHD;AAIA,GALD,EAKG,EALH;AAOA,QAAM;AAAEK,IAAAA;AAAF,MAAiBb,KAAK,CAACkB,MAA7B;AACA,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,sBAAD;AACC,MAAA,KAAK,EAAGL,UADT;AAEC,MAAA,YAAY,EAAGV,YAFhB;AAGC,MAAA,QAAQ,EAAGY;AAHZ,MADD;AAOA,GARM,EAQJ,CAAEF,UAAF,CARI,CAAP;AASA,CAxCD;;eA0Cef,gB","sourcesContent":["/**\n * External dependencies\n */\nimport { Keyboard } from 'react-native';\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\n\nimport { LinkPicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport linkSettingsScreens from './screens';\n\nconst LinkPickerScreen = () => {\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst navigateToLinkTimeoutRef = useRef( null );\n\tconst navigateBackTimeoutRef = useRef( null );\n\n\tconst onLinkPicked = ( { url, title } ) => {\n\t\tKeyboard.dismiss();\n\t\tnavigateToLinkTimeoutRef.current = setTimeout( () => {\n\t\t\tnavigation.navigate( linkSettingsScreens.settings, {\n\t\t\t\tinputValue: url,\n\t\t\t\ttext: title,\n\t\t\t} );\n\t\t}, 100 );\n\t};\n\n\tconst onCancel = () => {\n\t\tKeyboard.dismiss();\n\t\tnavigateBackTimeoutRef.current = setTimeout( () => {\n\t\t\tnavigation.goBack();\n\t\t}, 100 );\n\t};\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( navigateToLinkTimeoutRef.current );\n\t\t\tclearTimeout( navigateBackTimeoutRef.current );\n\t\t};\n\t}, [] );\n\n\tconst { inputValue } = route.params;\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<LinkPicker\n\t\t\t\tvalue={ inputValue }\n\t\t\t\tonLinkPicked={ onLinkPicked }\n\t\t\t\tonCancel={ onCancel }\n\t\t\t/>\n\t\t);\n\t}, [ inputValue ] );\n};\n\nexport default LinkPickerScreen;\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-picker-screen.native.js"],"names":["LinkPickerScreen","navigation","route","navigateToLinkTimeoutRef","navigateBackTimeoutRef","onLinkPicked","url","title","Keyboard","dismiss","current","setTimeout","navigate","linkSettingsScreens","settings","inputValue","text","onCancel","goBack","clearTimeout","params"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAOA;;AAKA;;AAhBA;AACA;AACA;;AAIA;AACA;AACA;;AAKA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAG,MAAM;AAC9B,QAAMC,UAAU,GAAG,4BAAnB;AACA,QAAMC,KAAK,GAAG,uBAAd;AACA,QAAMC,wBAAwB,GAAG,qBAAQ,IAAR,CAAjC;AACA,QAAMC,sBAAsB,GAAG,qBAAQ,IAAR,CAA/B;;AAEA,QAAMC,YAAY,GAAG,CAAE;AAAEC,IAAAA,GAAF;AAAOC,IAAAA;AAAP,GAAF,KAAsB;AAC1CC,0BAASC,OAAT;;AACAN,IAAAA,wBAAwB,CAACO,OAAzB,GAAmCC,UAAU,CAAE,MAAM;AACpDV,MAAAA,UAAU,CAACW,QAAX,CAAqBC,iBAAoBC,QAAzC,EAAmD;AAClDC,QAAAA,UAAU,EAAET,GADsC;AAElDU,QAAAA,IAAI,EAAET;AAF4C,OAAnD;AAIA,KAL4C,EAK1C,GAL0C,CAA7C;AAMA,GARD;;AAUA,QAAMU,QAAQ,GAAG,MAAM;AACtBT,0BAASC,OAAT;;AACAL,IAAAA,sBAAsB,CAACM,OAAvB,GAAiCC,UAAU,CAAE,MAAM;AAClDV,MAAAA,UAAU,CAACiB,MAAX;AACA,KAF0C,EAExC,GAFwC,CAA3C;AAGA,GALD;;AAOA,0BAAW,MAAM;AAChB,WAAO,MAAM;AACZC,MAAAA,YAAY,CAAEhB,wBAAwB,CAACO,OAA3B,CAAZ;AACAS,MAAAA,YAAY,CAAEf,sBAAsB,CAACM,OAAzB,CAAZ;AACA,KAHD;AAIA,GALD,EAKG,EALH;AAOA,QAAM;AAAEK,IAAAA;AAAF,MAAiBb,KAAK,CAACkB,MAA7B;AACA,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,sBAAD;AACC,MAAA,KAAK,EAAGL,UADT;AAEC,MAAA,YAAY,EAAGV,YAFhB;AAGC,MAAA,QAAQ,EAAGY;AAHZ,MADD;AAOA,GARM,EAQJ,CAAEF,UAAF,CARI,CAAP;AASA,CAxCD;;eA0Cef,gB","sourcesContent":["/**\n * External dependencies\n */\nimport { Keyboard } from 'react-native';\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { useEffect, useMemo, useRef } from '@wordpress/element';\n\nimport { LinkPicker } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport linkSettingsScreens from './screens';\n\nconst LinkPickerScreen = () => {\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst navigateToLinkTimeoutRef = useRef( null );\n\tconst navigateBackTimeoutRef = useRef( null );\n\n\tconst onLinkPicked = ( { url, title } ) => {\n\t\tKeyboard.dismiss();\n\t\tnavigateToLinkTimeoutRef.current = setTimeout( () => {\n\t\t\tnavigation.navigate( linkSettingsScreens.settings, {\n\t\t\t\tinputValue: url,\n\t\t\t\ttext: title,\n\t\t\t} );\n\t\t}, 100 );\n\t};\n\n\tconst onCancel = () => {\n\t\tKeyboard.dismiss();\n\t\tnavigateBackTimeoutRef.current = setTimeout( () => {\n\t\t\tnavigation.goBack();\n\t\t}, 100 );\n\t};\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( navigateToLinkTimeoutRef.current );\n\t\t\tclearTimeout( navigateBackTimeoutRef.current );\n\t\t};\n\t}, [] );\n\n\tconst { inputValue } = route.params;\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<LinkPicker\n\t\t\t\tvalue={ inputValue }\n\t\t\t\tonLinkPicked={ onLinkPicked }\n\t\t\t\tonCancel={ onCancel }\n\t\t\t/>\n\t\t);\n\t}, [ inputValue ] );\n};\n\nexport default LinkPickerScreen;\n"]}
@@ -38,19 +38,16 @@ var _modal = _interopRequireDefault(require("../modal.scss"));
38
38
  /**
39
39
  * Internal dependencies
40
40
  */
41
- const LinkSettingsScreen = _ref => {
42
- var _route$params;
43
-
44
- let {
45
- onRemove,
46
- onClose,
47
- onChange,
48
- speak,
49
- value,
50
- isActive,
51
- activeAttributes,
52
- isVisible
53
- } = _ref;
41
+ const LinkSettingsScreen = ({
42
+ onRemove,
43
+ onClose,
44
+ onChange,
45
+ speak,
46
+ value,
47
+ isActive,
48
+ activeAttributes,
49
+ isVisible
50
+ }) => {
54
51
  const [text, setText] = (0, _element.useState)((0, _richText.getTextContent)((0, _richText.slice)(value)));
55
52
  const [opensInNewWindow, setOpensInNewWindows] = (0, _element.useState)(activeAttributes.target === '_blank');
56
53
  const [linkValues, setLinkValues] = (0, _element.useState)({
@@ -99,10 +96,9 @@ const LinkSettingsScreen = _ref => {
99
96
  }
100
97
  }, [inputValue, isVisible, linkValues.isActiveLink, linkValues.isRemovingLink]);
101
98
 
102
- const clearFormat = function () {
103
- let {
104
- skipStateUpdates = false
105
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
99
+ const clearFormat = ({
100
+ skipStateUpdates = false
101
+ } = {}) => {
106
102
  onChange({ ...value,
107
103
  activeFormats: []
108
104
  });
@@ -115,11 +111,10 @@ const LinkSettingsScreen = _ref => {
115
111
  }
116
112
  };
117
113
 
118
- const submitLink = function () {
119
- let {
120
- shouldCloseBottomSheet = true,
121
- skipStateUpdates = false
122
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
114
+ const submitLink = ({
115
+ shouldCloseBottomSheet = true,
116
+ skipStateUpdates = false
117
+ } = {}) => {
123
118
  const url = (0, _url.prependHTTP)(inputValue);
124
119
  const linkText = text || inputValue;
125
120
  const format = (0, _utils.createLinkFormat)({
@@ -181,11 +176,10 @@ const LinkSettingsScreen = _ref => {
181
176
  }
182
177
  };
183
178
 
184
- const removeLink = function () {
185
- let {
186
- shouldCloseBottomSheet = true,
187
- skipStateUpdates = false
188
- } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
179
+ const removeLink = ({
180
+ shouldCloseBottomSheet = true,
181
+ skipStateUpdates = false
182
+ } = {}) => {
189
183
  clearFormat({
190
184
  skipStateUpdates
191
185
  });
@@ -196,11 +190,9 @@ const LinkSettingsScreen = _ref => {
196
190
  }
197
191
  };
198
192
 
199
- const submit = function (submitValue) {
200
- let {
201
- skipStateUpdates = false
202
- } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
203
-
193
+ const submit = (submitValue, {
194
+ skipStateUpdates = false
195
+ } = {}) => {
204
196
  if (submitValue === '') {
205
197
  removeLink({
206
198
  skipStateUpdates
@@ -223,7 +215,7 @@ const LinkSettingsScreen = _ref => {
223
215
  }
224
216
  });
225
217
  return unsubscribe;
226
- }, [navigation, (_route$params = route.params) === null || _route$params === void 0 ? void 0 : _route$params.text, text]);
218
+ }, [navigation, route.params?.text, text]);
227
219
  return (0, _element.useMemo)(() => {
228
220
  const shouldShowLinkOptions = !!inputValue;
229
221
  return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.BottomSheet.LinkCell, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"names":["LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","BottomSheetContext","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","linkSettingsScreens","picker","submit","skipStateUpdates","submitLink","shouldCloseBottomSheet","removeLink","clearFormat","activeFormats","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","textColor","undefined","external","styles","clearLinkButton","safeAreaBottomInset"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAQA;;AAKA;;AACA;;AAEA;;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAG,QASpB;AAAA;;AAAA,MATsB;AAC5BC,IAAAA,QAD4B;AAE5BC,IAAAA,OAF4B;AAG5BC,IAAAA,QAH4B;AAI5BC,IAAAA,KAJ4B;AAK5BC,IAAAA,KAL4B;AAM5BC,IAAAA,QAN4B;AAO5BC,IAAAA,gBAP4B;AAQ5BC,IAAAA;AAR4B,GAStB;AACN,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,8BAAgB,qBAAOL,KAAP,CAAhB,CAAV,CAA1B;AACA,QAAM,CAAEM,gBAAF,EAAoBC,oBAApB,IAA6C,uBAClDL,gBAAgB,CAACM,MAAjB,KAA4B,QADsB,CAAnD;AAGA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU;AAC/CC,IAAAA,YAAY,EAAEV,QADiC;AAE/CW,IAAAA,cAAc,EAAE;AAF+B,GAAV,CAAtC;AAKA,QAAM;AACLC,IAAAA,gCADK;AAELC,IAAAA,0BAFK;AAGLC,IAAAA;AAHK,MAIF,yBAAYC,8BAAZ,CAJJ;AAMA,QAAMC,UAAU,GAAG,4BAAnB;AACA,QAAMC,KAAK,GAAG,uBAAd;AACA,QAAM;AAAEC,IAAAA,UAAU,GAAGjB,gBAAgB,CAACkB,GAAjB,IAAwB;AAAvC,MAA8CF,KAAK,CAACG,MAAN,IAAgB,EAApE;;AACA,QAAMC,iBAAiB,GAAG,MAAM;AAC/B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AK,EAAG,cAAI,iBAAJ,CAFT;AAGC,MAAA,KAAK,EAAG1C,gBAHT;AAIC,MAAA,aAAa,EAAGC,oBAJjB;AAKC,MAAA,aAAa,EAAG;AALjB,MADD,EAQC,4BAAC,uBAAD,CAAa,IAAb;AACC,MAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,MAAA,UAAU,EAAG0C,eAAOC,eAFrB;AAGC,MAAA,aAAa,EAAG,MAHjB;AAIC,MAAA,OAAO,EAAGpB;AAJX,MARD,CAfF,CADD;AAkCA,GArCM,EAqCJ,CAAEX,UAAF,EAAcf,IAAd,EAAoBE,gBAApB,EAAsCS,SAAS,CAACoC,mBAAhD,CArCI,CAAP;AAsCA,CApMD;;eAsMexD,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue, { skipStateUpdates: true } );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( { shouldCloseBottomSheet: false } );\n\t\t} else if (\n\t\t\t( ( inputValue === '' && isActiveLink ) || isRemovingLink ) &&\n\t\t\tisVisible\n\t\t) {\n\t\t\tremoveLink( { shouldCloseBottomSheet: false } );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = ( { skipStateUpdates = false } = {} ) => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t\t}\n\t};\n\n\tconst submitLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Insert link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// Edit text in selected link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// Transform selected text into link.\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// Move selection to end of link.\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\t\t}\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tclearFormat( { skipStateUpdates } );\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue, { skipStateUpdates = false } = {} ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink( { skipStateUpdates } );\n\t\t} else {\n\t\t\tsubmitLink( { skipStateUpdates } );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType={ 'fullWidth' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType={ 'none' }\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/modal-screens/link-settings-screen.native.js"],"names":["LinkSettingsScreen","onRemove","onClose","onChange","speak","value","isActive","activeAttributes","isVisible","text","setText","opensInNewWindow","setOpensInNewWindows","target","linkValues","setLinkValues","isActiveLink","isRemovingLink","shouldEnableBottomSheetMaxHeight","onHandleClosingBottomSheet","listProps","BottomSheetContext","navigation","route","inputValue","url","params","onLinkCellPressed","navigate","linkSettingsScreens","picker","submit","skipStateUpdates","submitLink","shouldCloseBottomSheet","removeLink","clearFormat","activeFormats","linkText","format","newAttributes","toInsert","length","start","end","textLength","needsSelectionUpdate","submitValue","unsubscribe","addListener","shouldShowLinkOptions","textColor","undefined","external","styles","clearLinkButton","safeAreaBottomInset"],"mappings":";;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AACA;;AACA;;AAQA;;AAKA;;AACA;;AAEA;;AA5BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAMA,MAAMA,kBAAkB,GAAG,CAAE;AAC5BC,EAAAA,QAD4B;AAE5BC,EAAAA,OAF4B;AAG5BC,EAAAA,QAH4B;AAI5BC,EAAAA,KAJ4B;AAK5BC,EAAAA,KAL4B;AAM5BC,EAAAA,QAN4B;AAO5BC,EAAAA,gBAP4B;AAQ5BC,EAAAA;AAR4B,CAAF,KASpB;AACN,QAAM,CAAEC,IAAF,EAAQC,OAAR,IAAoB,uBAAU,8BAAgB,qBAAOL,KAAP,CAAhB,CAAV,CAA1B;AACA,QAAM,CAAEM,gBAAF,EAAoBC,oBAApB,IAA6C,uBAClDL,gBAAgB,CAACM,MAAjB,KAA4B,QADsB,CAAnD;AAGA,QAAM,CAAEC,UAAF,EAAcC,aAAd,IAAgC,uBAAU;AAC/CC,IAAAA,YAAY,EAAEV,QADiC;AAE/CW,IAAAA,cAAc,EAAE;A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IAHT;AAIC,MAAA,WAAW,EAAG,cAAI,eAAJ,CAJf;AAKC,MAAA,aAAa,EAAGC,OALjB;AAMC,MAAA,QAAQ,EAAGqB,MANZ;AAOC,MAAA,aAAa,EAAGmB,qBAAqB,GAAGE,SAAH,GAAe;AAPrD,MALD,EAcGF,qBAAqB,IACtB,qDACC,4BAAC,uBAAD,CAAa,UAAb;AACC,MAAA,IAAI,EAAGG,eADR;AAEC,MAAA,KAAK,EAAG,cAAI,iBAAJ,CAFT;AAGC,MAAA,KAAK,EAAG1C,gBAHT;AAIC,MAAA,aAAa,EAAGC,oBAJjB;AAKC,MAAA,aAAa,EAAG;AALjB,MADD,EAQC,4BAAC,uBAAD,CAAa,IAAb;AACC,MAAA,KAAK,EAAG,cAAI,aAAJ,CADT;AAEC,MAAA,UAAU,EAAG0C,eAAOC,eAFrB;AAGC,MAAA,aAAa,EAAG,MAHjB;AAIC,MAAA,OAAO,EAAGpB;AAJX,MARD,CAfF,CADD;AAkCA,GArCM,EAqCJ,CAAEX,UAAF,EAAcf,IAAd,EAAoBE,gBAApB,EAAsCS,SAAS,CAACoC,mBAAhD,CArCI,CAAP;AAsCA,CApMD;;eAsMexD,kB","sourcesContent":["/**\n * External dependencies\n */\nimport { useNavigation, useRoute } from '@react-navigation/native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useState, useContext, useEffect, useMemo } from '@wordpress/element';\nimport { prependHTTP } from '@wordpress/url';\nimport { BottomSheet, BottomSheetContext } from '@wordpress/components';\nimport {\n\tcreate,\n\tinsert,\n\tisCollapsed,\n\tapplyFormat,\n\tgetTextContent,\n\tslice,\n} from '@wordpress/rich-text';\nimport { external, textColor } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { createLinkFormat, isValidHref } from '../utils';\nimport linkSettingsScreens from './screens';\n\nimport styles from '../modal.scss';\n\nconst LinkSettingsScreen = ( {\n\tonRemove,\n\tonClose,\n\tonChange,\n\tspeak,\n\tvalue,\n\tisActive,\n\tactiveAttributes,\n\tisVisible,\n} ) => {\n\tconst [ text, setText ] = useState( getTextContent( slice( value ) ) );\n\tconst [ opensInNewWindow, setOpensInNewWindows ] = useState(\n\t\tactiveAttributes.target === '_blank'\n\t);\n\tconst [ linkValues, setLinkValues ] = useState( {\n\t\tisActiveLink: isActive,\n\t\tisRemovingLink: false,\n\t} );\n\n\tconst {\n\t\tshouldEnableBottomSheetMaxHeight,\n\t\tonHandleClosingBottomSheet,\n\t\tlistProps,\n\t} = useContext( BottomSheetContext );\n\n\tconst navigation = useNavigation();\n\tconst route = useRoute();\n\tconst { inputValue = activeAttributes.url || '' } = route.params || {};\n\tconst onLinkCellPressed = () => {\n\t\tshouldEnableBottomSheetMaxHeight( false );\n\t\tnavigation.navigate( linkSettingsScreens.picker, { inputValue } );\n\t};\n\tuseEffect( () => {\n\t\tonHandleClosingBottomSheet( () => {\n\t\t\tsubmit( inputValue, { skipStateUpdates: true } );\n\t\t} );\n\t}, [ inputValue, opensInNewWindow, text ] );\n\n\tuseEffect( () => {\n\t\tconst { isActiveLink, isRemovingLink } = linkValues;\n\t\tif ( !! inputValue && ! isActiveLink && isVisible ) {\n\t\t\tsubmitLink( { shouldCloseBottomSheet: false } );\n\t\t} else if (\n\t\t\t( ( inputValue === '' && isActiveLink ) || isRemovingLink ) &&\n\t\t\tisVisible\n\t\t) {\n\t\t\tremoveLink( { shouldCloseBottomSheet: false } );\n\t\t}\n\t}, [\n\t\tinputValue,\n\t\tisVisible,\n\t\tlinkValues.isActiveLink,\n\t\tlinkValues.isRemovingLink,\n\t] );\n\n\tconst clearFormat = ( { skipStateUpdates = false } = {} ) => {\n\t\tonChange( { ...value, activeFormats: [] } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: false, isRemovingLink: true } );\n\t\t}\n\t};\n\n\tconst submitLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tconst url = prependHTTP( inputValue );\n\t\tconst linkText = text || inputValue;\n\t\tconst format = createLinkFormat( {\n\t\t\turl,\n\t\t\topensInNewWindow,\n\t\t\ttext: linkText,\n\t\t} );\n\t\tlet newAttributes;\n\t\tif ( isCollapsed( value ) && ! isActive ) {\n\t\t\t// Insert link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text: linkText } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\tlinkText.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert );\n\t\t} else if ( text !== getTextContent( slice( value ) ) ) {\n\t\t\t// Edit text in selected link.\n\t\t\tconst toInsert = applyFormat(\n\t\t\t\tcreate( { text } ),\n\t\t\t\tformat,\n\t\t\t\t0,\n\t\t\t\ttext.length\n\t\t\t);\n\t\t\tnewAttributes = insert( value, toInsert, value.start, value.end );\n\t\t} else {\n\t\t\t// Transform selected text into link.\n\t\t\tnewAttributes = applyFormat( value, format );\n\t\t}\n\t\t// Move selection to end of link.\n\t\tconst textLength = newAttributes.text.length;\n\t\t// check for zero width spaces\n\t\tif ( newAttributes.end > textLength ) {\n\t\t\tnewAttributes.start = textLength;\n\t\t\tnewAttributes.end = textLength;\n\t\t} else {\n\t\t\tnewAttributes.start = newAttributes.end;\n\t\t}\n\t\tnewAttributes.activeFormats = [];\n\t\tonChange( { ...newAttributes, needsSelectionUpdate: true } );\n\t\tif ( ! skipStateUpdates ) {\n\t\t\tsetLinkValues( { isActiveLink: true, isRemovingLink: false } );\n\t\t}\n\n\t\tif ( ! isValidHref( url ) ) {\n\t\t\tspeak(\n\t\t\t\t__(\n\t\t\t\t\t'Warning: the link has been inserted but may have errors. Please test it.'\n\t\t\t\t),\n\t\t\t\t'assertive'\n\t\t\t);\n\t\t} else if ( isActive ) {\n\t\t\tspeak( __( 'Link edited.' ), 'assertive' );\n\t\t} else {\n\t\t\tspeak( __( 'Link inserted' ), 'assertive' );\n\t\t}\n\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst removeLink = ( {\n\t\tshouldCloseBottomSheet = true,\n\t\tskipStateUpdates = false,\n\t} = {} ) => {\n\t\tclearFormat( { skipStateUpdates } );\n\t\tonRemove();\n\t\tif ( shouldCloseBottomSheet ) {\n\t\t\tonClose();\n\t\t}\n\t};\n\n\tconst submit = ( submitValue, { skipStateUpdates = false } = {} ) => {\n\t\tif ( submitValue === '' ) {\n\t\t\tremoveLink( { skipStateUpdates } );\n\t\t} else {\n\t\t\tsubmitLink( { skipStateUpdates } );\n\t\t}\n\t};\n\n\tuseEffect( () => {\n\t\tconst unsubscribe = navigation.addListener( 'focus', () => {\n\t\t\tconst { params = {} } = route;\n\t\t\tif ( ! text && params.text ) {\n\t\t\t\tsetText( params.text );\n\t\t\t}\n\t\t} );\n\t\treturn unsubscribe;\n\t}, [ navigation, route.params?.text, text ] );\n\n\treturn useMemo( () => {\n\t\tconst shouldShowLinkOptions = !! inputValue;\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BottomSheet.LinkCell\n\t\t\t\t\tvalue={ inputValue }\n\t\t\t\t\tonPress={ onLinkCellPressed }\n\t\t\t\t/>\n\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\ticon={ textColor }\n\t\t\t\t\tlabel={ __( 'Link text' ) }\n\t\t\t\t\tvalue={ text }\n\t\t\t\t\tplaceholder={ __( 'Add link text' ) }\n\t\t\t\t\tonChangeValue={ setText }\n\t\t\t\t\tonSubmit={ submit }\n\t\t\t\t\tseparatorType={ shouldShowLinkOptions ? undefined : 'none' }\n\t\t\t\t/>\n\t\t\t\t{ shouldShowLinkOptions && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<BottomSheet.SwitchCell\n\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\tvalue={ opensInNewWindow }\n\t\t\t\t\t\t\tonValueChange={ setOpensInNewWindows }\n\t\t\t\t\t\t\tseparatorType={ 'fullWidth' }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<BottomSheet.Cell\n\t\t\t\t\t\t\tlabel={ __( 'Remove link' ) }\n\t\t\t\t\t\t\tlabelStyle={ styles.clearLinkButton }\n\t\t\t\t\t\t\tseparatorType={ 'none' }\n\t\t\t\t\t\t\tonPress={ removeLink }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}, [ inputValue, text, opensInNewWindow, listProps.safeAreaBottomInset ] );\n};\n\nexport default LinkSettingsScreen;\n"]}
@@ -26,11 +26,10 @@ var _linkPickerScreen = _interopRequireDefault(require("./modal-screens/link-pic
26
26
  /**
27
27
  * Internal dependencies
28
28
  */
29
- const ModalLinkUI = _ref => {
30
- let {
31
- isVisible,
32
- ...restProps
33
- } = _ref;
29
+ const ModalLinkUI = ({
30
+ isVisible,
31
+ ...restProps
32
+ }) => {
34
33
  return (0, _element.useMemo)(() => {
35
34
  return (0, _element.createElement)(_components.BottomSheet, {
36
35
  isVisible: isVisible,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["ModalLinkUI","isVisible","restProps","onClose","screens","settings","picker"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,WAAW,GAAG,QAAmC;AAAA,MAAjC;AAAEC,IAAAA,SAAF;AAAa,OAAGC;AAAhB,GAAiC;AACtD,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,uBAAD;AACC,MAAA,SAAS,EAAGD,SADb;AAEC,MAAA,UAAU,MAFX;AAGC,MAAA,OAAO,EAAGC,SAAS,CAACC,OAHrB;AAIC,MAAA,aAAa,MAJd;AAKC,MAAA,MAAM,EAAC;AALR,OAOC,4BAAC,uBAAD,CAAa,mBAAb;AAAiC,MAAA,OAAO,MAAxC;AAAyC,MAAA,IAAI;AAA7C,OACC,4BAAC,uBAAD,CAAa,gBAAb;AAA8B,MAAA,IAAI,EAAGC,iBAAQC;AAA7C,OACC,4BAAC,2BAAD;AACC,MAAA,SAAS,EAAGJ;AADb,OAEMC,SAFN,EADD,CADD,EAOC,4BAAC,uBAAD,CAAa,gBAAb;AACC,MAAA,IAAI,EAAGE,iBAAQE,MADhB;AAEC,MAAA,YAAY,MAFb;AAGC,MAAA,UAAU;AAHX,OAKC,4BAAC,yBAAD,OALD,CAPD,CAPD,CADD;AAyBA,GA1BM,EA0BJ,CAAEL,SAAF,CA1BI,CAAP;AA2BA,CA5BD;;eA8Be,oCAAoBD,WAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/modal.native.js"],"names":["ModalLinkUI","isVisible","restProps","onClose","screens","settings","picker"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AAKA;;AACA;;AACA;;AAXA;AACA;AACA;;AAIA;AACA;AACA;AAKA,MAAMA,WAAW,GAAG,CAAE;AAAEC,EAAAA,SAAF;AAAa,KAAGC;AAAhB,CAAF,KAAmC;AACtD,SAAO,sBAAS,MAAM;AACrB,WACC,4BAAC,uBAAD;AACC,MAAA,SAAS,EAAGD,SADb;AAEC,MAAA,UAAU,MAFX;AAGC,MAAA,OAAO,EAAGC,SAAS,CAACC,OAHrB;AAIC,MAAA,aAAa,MAJd;AAKC,MAAA,MAAM,EAAC;AALR,OAOC,4BAAC,uBAAD,CAAa,mBAAb;AAAiC,MAAA,OAAO,MAAxC;AAAyC,MAAA,IAAI;AAA7C,OACC,4BAAC,uBAAD,CAAa,gBAAb;AAA8B,MAAA,IAAI,EAAGC,iBAAQC;AAA7C,OACC,4BAAC,2BAAD;AACC,MAAA,SAAS,EAAGJ;AADb,OAEMC,SAFN,EADD,CADD,EAOC,4BAAC,uBAAD,CAAa,gBAAb;AACC,MAAA,IAAI,EAAGE,iBAAQE,MADhB;AAEC,MAAA,YAAY,MAFb;AAGC,MAAA,UAAU;AAHX,OAKC,4BAAC,yBAAD,OALD,CAPD,CAPD,CADD;AAyBA,GA1BM,EA0BJ,CAAEL,SAAF,CA1BI,CAAP;AA2BA,CA5BD;;eA8Be,oCAAoBD,WAApB,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { BottomSheet, withSpokenMessages } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport screens from './modal-screens/screens';\nimport LinkSettingsScreen from './modal-screens/link-settings-screen';\nimport LinkPickerScreen from './modal-screens/link-picker-screen';\n\nconst ModalLinkUI = ( { isVisible, ...restProps } ) => {\n\treturn useMemo( () => {\n\t\treturn (\n\t\t\t<BottomSheet\n\t\t\t\tisVisible={ isVisible }\n\t\t\t\thideHeader\n\t\t\t\tonClose={ restProps.onClose }\n\t\t\t\thasNavigation\n\t\t\t\ttestID=\"link-settings-modal\"\n\t\t\t>\n\t\t\t\t<BottomSheet.NavigationContainer animate main>\n\t\t\t\t\t<BottomSheet.NavigationScreen name={ screens.settings }>\n\t\t\t\t\t\t<LinkSettingsScreen\n\t\t\t\t\t\t\tisVisible={ isVisible }\n\t\t\t\t\t\t\t{ ...restProps }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t\t<BottomSheet.NavigationScreen\n\t\t\t\t\t\tname={ screens.picker }\n\t\t\t\t\t\tisScrollable\n\t\t\t\t\t\tfullScreen\n\t\t\t\t\t>\n\t\t\t\t\t\t<LinkPickerScreen />\n\t\t\t\t\t</BottomSheet.NavigationScreen>\n\t\t\t\t</BottomSheet.NavigationContainer>\n\t\t\t</BottomSheet>\n\t\t);\n\t}, [ isVisible ] );\n};\n\nexport default withSpokenMessages( ModalLinkUI );\n"]}
@@ -90,13 +90,12 @@ function isValidHref(href) {
90
90
  */
91
91
 
92
92
 
93
- function createLinkFormat(_ref) {
94
- let {
95
- url,
96
- type,
97
- id,
98
- opensInNewWindow
99
- } = _ref;
93
+ function createLinkFormat({
94
+ url,
95
+ type,
96
+ id,
97
+ opensInNewWindow
98
+ }) {
100
99
  const format = {
101
100
  type: 'core/link',
102
101
  attributes: {
@@ -129,11 +128,7 @@ function createLinkFormat(_ref) {
129
128
  /* eslint-enable jsdoc/no-undefined-types */
130
129
 
131
130
 
132
- function getFormatBoundary(value, format) {
133
- var _newFormats$startInde, _newFormats$endIndex, _newFormats;
134
-
135
- let startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : value.start;
136
- let endIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : value.end;
131
+ function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
137
132
  const EMPTY_BOUNDARIES = {
138
133
  start: null,
139
134
  end: null
@@ -144,30 +139,21 @@ function getFormatBoundary(value, format) {
144
139
  let targetFormat;
145
140
  let initialIndex;
146
141
 
147
- if (!(formats !== null && formats !== void 0 && formats.length)) {
142
+ if (!formats?.length) {
148
143
  return EMPTY_BOUNDARIES;
149
144
  } // Clone formats to avoid modifying source formats.
150
145
 
151
146
 
152
147
  const newFormats = formats.slice();
153
- const formatAtStart = (_newFormats$startInde = newFormats[startIndex]) === null || _newFormats$startInde === void 0 ? void 0 : _newFormats$startInde.find(_ref2 => {
154
- let {
155
- type
156
- } = _ref2;
157
- return type === format.type;
158
- });
159
- const formatAtEnd = (_newFormats$endIndex = newFormats[endIndex]) === null || _newFormats$endIndex === void 0 ? void 0 : _newFormats$endIndex.find(_ref3 => {
160
- let {
161
- type
162
- } = _ref3;
163
- return type === format.type;
164
- });
165
- const formatAtEndMinusOne = (_newFormats = newFormats[endIndex - 1]) === null || _newFormats === void 0 ? void 0 : _newFormats.find(_ref4 => {
166
- let {
167
- type
168
- } = _ref4;
169
- return type === format.type;
170
- });
148
+ const formatAtStart = newFormats[startIndex]?.find(({
149
+ type
150
+ }) => type === format.type);
151
+ const formatAtEnd = newFormats[endIndex]?.find(({
152
+ type
153
+ }) => type === format.type);
154
+ const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({
155
+ type
156
+ }) => type === format.type);
171
157
 
172
158
  if (!!formatAtStart) {
173
159
  // Set values to conform to "start"
@@ -235,19 +221,7 @@ function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, dir
235
221
  return index;
236
222
  }
237
223
 
238
- const partialRight = function (fn) {
239
- for (var _len = arguments.length, partialArgs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
240
- partialArgs[_key - 1] = arguments[_key];
241
- }
242
-
243
- return function () {
244
- for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
245
- args[_key2] = arguments[_key2];
246
- }
247
-
248
- return fn(...args, ...partialArgs);
249
- };
250
- };
224
+ const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs);
251
225
 
252
226
  const walkToStart = partialRight(walkToBoundary, 'backwards');
253
227
  const walkToEnd = partialRight(walkToBoundary, 'forwards');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","startsWith","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","find","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionIncrement","inverseDirectionIncrement","partialRight","fn","partialArgs","args"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AAED,QAAMC,WAAW,GAAGD,IAAI,CAACE,IAAL,EAApB;;AAEA,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,KAAP;AACA,GATkC,CAWnC;;;AACA,MAAK,QAAQE,IAAR,CAAcF,WAAd,CAAL,EAAmC;AAClC,UAAMG,QAAQ,GAAG,sBAAaH,WAAb,CAAjB;;AACA,QAAK,CAAE,0BAAiBG,QAAjB,CAAP,EAAqC;AACpC,aAAO,KAAP;AACA,KAJiC,CAMlC;AACA;;;AACA,QACCA,QAAQ,CAACC,UAAT,CAAqB,MAArB,KACA,CAAE,uBAAuBF,IAAvB,CAA6BF,WAA7B,CAFH,EA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,QAAMC,kBAAkB,GAAGH,UAAU,CAAED,SAAF,CAAV,IAA2B,CAAtD,CARC,CAQwD;;AACzD,QAAMK,yBAAyB,GAAGD,kBAAkB,GAAG,CAAC,CAAxD;;AAEA,SACCtB,OAAO,CAAEU,KAAF,CAAP,IACAV,OAAO,CAAEU,KAAF,CAAP,CAAkBO,WAAlB,MAAoCD,eAFrC,EAGE;AACD;AACAN,IAAAA,KAAK,GAAGA,KAAK,GAAGY,kBAAhB;AACA,GAjBA,CAmBD;AACA;;;AACAZ,EAAAA,KAAK,GAAGA,KAAK,GAAGa,yBAAhB;AAEA,SAAOb,KAAP;AACA;;AAED,MAAMc,YAAY,GACjB,UAAEC,EAAF;AAAA,oCAASC,WAAT;AAASA,IAAAA,WAAT;AAAA;;AAAA,SACA;AAAA,uCAAKC,IAAL;AAAKA,MAAAA,IAAL;AAAA;;AAAA,WACCF,EAAE,CAAE,GAAGE,IAAL,EAAW,GAAGD,WAAd,CADH;AAAA,GADA;AAAA,CADD;;AAKA,MAAMb,WAAW,GAAGW,YAAY,CAAET,cAAF,EAAkB,WAAlB,CAAhC;AAEA,MAAMD,SAAS,GAAGU,YAAY,CAAET,cAAF,EAAkB,UAAlB,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = newFormats[ startIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEnd = newFormats[ endIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEndMinusOne = newFormats[ endIndex - 1 ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0.\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// // Return the indicies of the \"edges\" as the boundaries.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["isValidHref","href","trimmedHref","trim","test","protocol","startsWith","authority","path","queryString","fragment","createLinkFormat","url","type","id","opensInNewWindow","format","attributes","target","rel","getFormatBoundary","value","startIndex","start","endIndex","end","EMPTY_BOUNDARIES","formats","targetFormat","initialIndex","length","newFormats","slice","formatAtStart","find","formatAtEnd","formatAtEndMinusOne","index","indexOf","walkingArgs","walkToStart","walkToEnd","walkToBoundary","targetFormatRef","formatIndex","direction","directions","forwards","backwards","directionIncrement","inverseDirectionIncrement","partialRight","fn","partialArgs","args"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;;AAcA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,WAAT,CAAsBC,IAAtB,EAA6B;AACnC,MAAK,CAAEA,IAAP,EAAc;AACb,WAAO,KAAP;AACA;;AAED,QAAMC,WAAW,GAAGD,IAAI,CAACE,IAAL,EAApB;;AAEA,MAAK,CAAED,WAAP,EAAqB;AACpB,WAAO,KAAP;AACA,GATkC,CAWnC;;;AACA,MAAK,QAAQE,IAAR,CAAcF,WAAd,CAAL,EAAmC;AAClC,UAAMG,QAAQ,GAAG,sBAAaH,WAAb,CAAjB;;AACA,QAAK,CAAE,0BAAiBG,QAAjB,CAAP,EAAqC;AACpC,aAAO,KAAP;AACA,KAJiC,CAMlC;AACA;;;AACA,QACCA,QAAQ,CAACC,UAAT,CAAqB,MAArB,KACA,CAAE,uBAAuBF,IAAvB,CAA6BF,WAA7B,CAFH,EAGE;AACD,aAAO,KAAP;AACA;;AAED,UAAMK,SAAS,GAAG,uBAAcL,WAAd,CAAlB;;AACA,QAAK,CAAE,2BAAkBK,SAAlB,CAAP,EAAuC;AACtC,aAAO,KAAP;AACA;;AAED,UAAMC,IAAI,GAAG,kBAASN,WAAT,CAAb;;AACA,QAAKM,IAAI,IAAI,CAAE,sBAAaA,IAAb,CAAf,EAAqC;AACpC,aAAO,KAAP;AACA;;AAED,UAAMC,WAAW,GAAG,yBAAgBP,WAAhB,CAApB;;AACA,QAAKO,WAAW,IAAI,CAAE,6BAAoBA,WAApB,CAAtB,EAA0D;AACzD,aAAO,KAAP;AACA;;AAED,UAAMC,QAAQ,GAAG,sBAA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hC;AAEA,MAAMD,SAAS,GAAGU,YAAY,CAAET,cAAF,EAAkB,UAAlB,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tgetProtocol,\n\tisValidProtocol,\n\tgetAuthority,\n\tisValidAuthority,\n\tgetPath,\n\tisValidPath,\n\tgetQueryString,\n\tisValidQueryString,\n\tgetFragment,\n\tisValidFragment,\n} from '@wordpress/url';\n\n/**\n * Check for issues with the provided href.\n *\n * @param {string} href The href.\n *\n * @return {boolean} Is the href invalid?\n */\nexport function isValidHref( href ) {\n\tif ( ! href ) {\n\t\treturn false;\n\t}\n\n\tconst trimmedHref = href.trim();\n\n\tif ( ! trimmedHref ) {\n\t\treturn false;\n\t}\n\n\t// Does the href start with something that looks like a URL protocol?\n\tif ( /^\\S+:/.test( trimmedHref ) ) {\n\t\tconst protocol = getProtocol( trimmedHref );\n\t\tif ( ! isValidProtocol( protocol ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Add some extra checks for http(s) URIs, since these are the most common use-case.\n\t\t// This ensures URIs with an http protocol have exactly two forward slashes following the protocol.\n\t\tif (\n\t\t\tprotocol.startsWith( 'http' ) &&\n\t\t\t! /^https?:\\/\\/[^\\/\\s]/i.test( trimmedHref )\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst authority = getAuthority( trimmedHref );\n\t\tif ( ! isValidAuthority( authority ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst path = getPath( trimmedHref );\n\t\tif ( path && ! isValidPath( path ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst queryString = getQueryString( trimmedHref );\n\t\tif ( queryString && ! isValidQueryString( queryString ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fragment = getFragment( trimmedHref );\n\t\tif ( fragment && ! isValidFragment( fragment ) ) {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t// Validate anchor links.\n\tif ( trimmedHref.startsWith( '#' ) && ! isValidFragment( trimmedHref ) ) {\n\t\treturn false;\n\t}\n\n\treturn true;\n}\n\n/**\n * Generates the format object that will be applied to the link text.\n *\n * @param {Object} options\n * @param {string} options.url The href of the link.\n * @param {string} options.type The type of the link.\n * @param {string} options.id The ID of the link.\n * @param {boolean} options.opensInNewWindow Whether this link will open in a new window.\n *\n * @return {Object} The final format object.\n */\nexport function createLinkFormat( { url, type, id, opensInNewWindow } ) {\n\tconst format = {\n\t\ttype: 'core/link',\n\t\tattributes: {\n\t\t\turl,\n\t\t},\n\t};\n\n\tif ( type ) format.attributes.type = type;\n\tif ( id ) format.attributes.id = id;\n\n\tif ( opensInNewWindow ) {\n\t\tformat.attributes.target = '_blank';\n\t\tformat.attributes.rel = 'noreferrer noopener';\n\t}\n\n\treturn format;\n}\n\n/* eslint-disable jsdoc/no-undefined-types */\n/**\n * Get the start and end boundaries of a given format from a rich text value.\n *\n *\n * @param {RichTextValue} value the rich text value to interrogate.\n * @param {string} format the identifier for the target format (e.g. `core/link`, `core/bold`).\n * @param {number?} startIndex optional startIndex to seek from.\n * @param {number?} endIndex optional endIndex to seek from.\n * @return {Object}\tobject containing start and end values for the given format.\n */\n/* eslint-enable jsdoc/no-undefined-types */\nexport function getFormatBoundary(\n\tvalue,\n\tformat,\n\tstartIndex = value.start,\n\tendIndex = value.end\n) {\n\tconst EMPTY_BOUNDARIES = {\n\t\tstart: null,\n\t\tend: null,\n\t};\n\n\tconst { formats } = value;\n\tlet targetFormat;\n\tlet initialIndex;\n\n\tif ( ! formats?.length ) {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\t// Clone formats to avoid modifying source formats.\n\tconst newFormats = formats.slice();\n\n\tconst formatAtStart = newFormats[ startIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEnd = newFormats[ endIndex ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tconst formatAtEndMinusOne = newFormats[ endIndex - 1 ]?.find(\n\t\t( { type } ) => type === format.type\n\t);\n\n\tif ( !! formatAtStart ) {\n\t\t// Set values to conform to \"start\"\n\t\ttargetFormat = formatAtStart;\n\t\tinitialIndex = startIndex;\n\t} else if ( !! formatAtEnd ) {\n\t\t// Set values to conform to \"end\"\n\t\ttargetFormat = formatAtEnd;\n\t\tinitialIndex = endIndex;\n\t} else if ( !! formatAtEndMinusOne ) {\n\t\t// This is an edge case which will occur if you create a format, then place\n\t\t// the caret just before the format and hit the back ARROW key. The resulting\n\t\t// value object will have start and end +1 beyond the edge of the format boundary.\n\t\ttargetFormat = formatAtEndMinusOne;\n\t\tinitialIndex = endIndex - 1;\n\t} else {\n\t\treturn EMPTY_BOUNDARIES;\n\t}\n\n\tconst index = newFormats[ initialIndex ].indexOf( targetFormat );\n\n\tconst walkingArgs = [ newFormats, initialIndex, targetFormat, index ];\n\n\t// Walk the startIndex \"backwards\" to the leading \"edge\" of the matching format.\n\tstartIndex = walkToStart( ...walkingArgs );\n\n\t// Walk the endIndex \"forwards\" until the trailing \"edge\" of the matching format.\n\tendIndex = walkToEnd( ...walkingArgs );\n\n\t// Safe guard: start index cannot be less than 0.\n\tstartIndex = startIndex < 0 ? 0 : startIndex;\n\n\t// // Return the indicies of the \"edges\" as the boundaries.\n\treturn {\n\t\tstart: startIndex,\n\t\tend: endIndex,\n\t};\n}\n\n/**\n * Walks forwards/backwards towards the boundary of a given format within an\n * array of format objects. Returns the index of the boundary.\n *\n * @param {Array} formats the formats to search for the given format type.\n * @param {number} initialIndex the starting index from which to walk.\n * @param {Object} targetFormatRef a reference to the format type object being sought.\n * @param {number} formatIndex the index at which we expect the target format object to be.\n * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.\n * @return {number} the index of the boundary of the given format.\n */\nfunction walkToBoundary(\n\tformats,\n\tinitialIndex,\n\ttargetFormatRef,\n\tformatIndex,\n\tdirection\n) {\n\tlet index = initialIndex;\n\n\tconst directions = {\n\t\tforwards: 1,\n\t\tbackwards: -1,\n\t};\n\n\tconst directionIncrement = directions[ direction ] || 1; // invalid direction arg default to forwards\n\tconst inverseDirectionIncrement = directionIncrement * -1;\n\n\twhile (\n\t\tformats[ index ] &&\n\t\tformats[ index ][ formatIndex ] === targetFormatRef\n\t) {\n\t\t// Increment/decrement in the direction of operation.\n\t\tindex = index + directionIncrement;\n\t}\n\n\t// Restore by one in inverse direction of operation\n\t// to avoid out of bounds.\n\tindex = index + inverseDirectionIncrement;\n\n\treturn index;\n}\n\nconst partialRight =\n\t( fn, ...partialArgs ) =>\n\t( ...args ) =>\n\t\tfn( ...args, ...partialArgs );\n\nconst walkToStart = partialRight( walkToBoundary, 'backwards' );\n\nconst walkToEnd = partialRight( walkToBoundary, 'forwards' );\n"]}
@@ -26,14 +26,12 @@ const strikethrough = {
26
26
  tagName: 's',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onClick() {
38
36
  onChange((0, _richText.toggleFormat)(value, {
39
37
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AATA;AACA;AACA;AASA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,QADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGE,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MAND,CADD;AAgBA;;AA3B2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n} from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"access\"\n\t\t\t\t\tcharacter=\"d\"\n\t\t\t\t\tonUse={ onClick }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","formatStrikethrough"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAIA;;AATA;AACA;AACA;AASA,MAAMA,IAAI,GAAG,oBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,eAAJ,CAAd;AAEO,MAAMC,aAAa,GAAG;AAC5BF,EAAAA,IAD4B;AAE5BC,EAAAA,KAF4B;AAG5BE,EAAAA,OAAO,EAAE,GAHmB;AAI5BC,EAAAA,SAAS,EAAE,IAJiB;;AAK5BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,OAAT,GAAmB;AAClBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,qDACC,4BAAC,6BAAD;AACC,MAAA,IAAI,EAAC,QADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGE,0BADR;AAEC,MAAA,KAAK,EAAGX,KAFT;AAGC,MAAA,OAAO,EAAGS,OAHX;AAIC,MAAA,QAAQ,EAAGJ,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MAND,CADD;AAgBA;;AA3B2B,CAAtB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport {\n\tRichTextToolbarButton,\n\tRichTextShortcut,\n} from '@wordpress/block-editor';\nimport { formatStrikethrough } from '@wordpress/icons';\n\nconst name = 'core/strikethrough';\nconst title = __( 'Strikethrough' );\n\nexport const strikethrough = {\n\tname,\n\ttitle,\n\ttagName: 's',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onClick() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<RichTextShortcut\n\t\t\t\t\ttype=\"access\"\n\t\t\t\t\tcharacter=\"d\"\n\t\t\t\t\tonUse={ onClick }\n\t\t\t\t/>\n\t\t\t\t<RichTextToolbarButton\n\t\t\t\t\ticon={ formatStrikethrough }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonClick={ onClick }\n\t\t\t\t\tisActive={ isActive }\n\t\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t},\n};\n"]}
@@ -26,14 +26,12 @@ const subscript = {
26
26
  tagName: 'sub',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onToggle() {
38
36
  onChange((0, _richText.toggleFormat)(value, {
39
37
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["name","title","subscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","subscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,gBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEO,MAAMC,SAAS,GAAG;AACxBF,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBE,EAAAA,OAAO,EAAE,KAHe;AAIxBC,EAAAA,SAAS,EAAE,IAJa;;AAKxBC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,gBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxBuB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { subscript as subscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/subscript';\nconst title = __( 'Subscript' );\n\nexport const subscript = {\n\tname,\n\ttitle,\n\ttagName: 'sub',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ subscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -26,14 +26,12 @@ const superscript = {
26
26
  tagName: 'sup',
27
27
  className: null,
28
28
 
29
- edit(_ref) {
30
- let {
31
- isActive,
32
- value,
33
- onChange,
34
- onFocus
35
- } = _ref;
36
-
29
+ edit({
30
+ isActive,
31
+ value,
32
+ onChange,
33
+ onFocus
34
+ }) {
37
35
  function onToggle() {
38
36
  onChange((0, _richText.toggleFormat)(value, {
39
37
  type: name,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,OAA2C;AAAA,QAAzC;AAAEC,MAAAA,QAAF;AAAYC,MAAAA,KAAZ;AAAmBC,MAAAA,QAAnB;AAA6BC,MAAAA;AAA7B,KAAyC;;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["name","title","superscript","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","superscriptIcon"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AANA;AACA;AACA;AAMA,MAAMA,IAAI,GAAG,kBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,aAAJ,CAAd;AAEO,MAAMC,WAAW,GAAG;AAC1BF,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BE,EAAAA,OAAO,EAAE,KAHiB;AAI1BC,EAAAA,SAAS,EAAE,IAJe;;AAK1BC,EAAAA,IAAI,CAAE;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,KAAZ;AAAmBC,IAAAA,QAAnB;AAA6BC,IAAAA;AAA7B,GAAF,EAA2C;AAC9C,aAASC,QAAT,GAAoB;AACnBF,MAAAA,QAAQ,CAAE,4BAAcD,KAAd,EAAqB;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAArB,CAAF,CAAR;AACA;;AAED,aAASW,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,4BAAC,kCAAD;AACC,MAAA,IAAI,EAAGI,kBADR;AAEC,MAAA,KAAK,EAAGZ,KAFT;AAGC,MAAA,OAAO,EAAGW,OAHX;AAIC,MAAA,QAAQ,EAAGN,QAJZ;AAKC,MAAA,IAAI,EAAC;AALN,MADD;AASA;;AAxByB,CAApB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { toggleFormat } from '@wordpress/rich-text';\nimport { RichTextToolbarButton } from '@wordpress/block-editor';\nimport { superscript as superscriptIcon } from '@wordpress/icons';\n\nconst name = 'core/superscript';\nconst title = __( 'Superscript' );\n\nexport const superscript = {\n\tname,\n\ttitle,\n\ttagName: 'sup',\n\tclassName: null,\n\tedit( { isActive, value, onChange, onFocus } ) {\n\t\tfunction onToggle() {\n\t\t\tonChange( toggleFormat( value, { type: name, title } ) );\n\t\t}\n\n\t\tfunction onClick() {\n\t\t\tonToggle();\n\t\t\tonFocus();\n\t\t}\n\n\t\treturn (\n\t\t\t<RichTextToolbarButton\n\t\t\t\ticon={ superscriptIcon }\n\t\t\t\ttitle={ title }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tisActive={ isActive }\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t);\n\t},\n};\n"]}
@@ -51,12 +51,10 @@ function getComputedStyleProperty(element, property) {
51
51
  return value;
52
52
  }
53
53
 
54
- function fillComputedColors(element, _ref) {
55
- let {
56
- color,
57
- backgroundColor
58
- } = _ref;
59
-
54
+ function fillComputedColors(element, {
55
+ color,
56
+ backgroundColor
57
+ }) {
60
58
  if (!color && !backgroundColor) {
61
59
  return;
62
60
  }
@@ -67,14 +65,13 @@ function fillComputedColors(element, _ref) {
67
65
  };
68
66
  }
69
67
 
70
- function TextColorEdit(_ref2) {
71
- let {
72
- value,
73
- onChange,
74
- isActive,
75
- activeAttributes,
76
- contentRef
77
- } = _ref2;
68
+ function TextColorEdit({
69
+ value,
70
+ onChange,
71
+ isActive,
72
+ activeAttributes,
73
+ contentRef
74
+ }) {
78
75
  const allowCustomControl = (0, _blockEditor.useSetting)('color.custom');
79
76
  const colors = (0, _blockEditor.useSetting)('color.palette') || EMPTY_ARRAY;
80
77
  const [isAddingColor, setIsAddingColor] = (0, _element.useState)(false);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","Object","keys","textColorIcon","colorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AAKA;;;;;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAG,kBAAzB;;AAEP,MAAMC,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAoBF,OAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAkBD,aAAxB;AACA,QAAME,KAAK,GAAGD,WA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AAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO/B,KAAP,EAAe;AAC5C,QAAK+B,GAAG,KAAK,OAAb,EAAuB,OAAO/B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAACgC,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAOhC,KAAP;AACrD,UAAMiC,QAAQ,GAAG,CAAE,kBAAF,EAAsB5C,gBAAtB,EAAyC6C,IAAzC,CAA+C,GAA/C,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAOlC,KAAK,GAAG,CAAEiC,QAAF,EAAYjC,KAAZ,EAAoBkC,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAE7B;AA3BkB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set.\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","color","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","Object","keys","textColorIcon","colorIcon","textColor","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AAKA;;AAKA;;;;;;AAhBA;AACA;AACA;;AAWA;AACA;AACA;AAGO,MAAMA,gBAAgB,GAAG,kBAAzB;;AAEP,MAAMC,IAAI,GAAG,iBAAb;AACA,MAAMC,KAAK,GAAG,cAAI,WAAJ,CAAd;AAEA,MAAMC,WAAW,GAAG,EAApB;;AAEA,SAASC,wBAAT,CAAmCC,OAAnC,EAA4CC,QAA5C,EAAuD;AACtD,QAAM;AAAEC,IAAAA;AAAF,MAAoBF,OAA1B;AACA,QAAM;AAAEG,IAAAA;AAAF,MAAkBD,aAAxB;AACA,QAAME,KAAK,GAAGD,WAAW,CAACE,gBAAZ,CAA8BL,OAA9B,CAAd;AACA,QAAMM,KAAK,GAAGF,KAAK,CAACG,gBAAN,CAAwBN,QAAxB,CAAd;;AAEA,MACCA,QAAQ,KAAK,kBAAb,IACAK,KAAK,KAAKX,gBADV,IAEAK,OAAO,CAACQ,aAHT,EAIE;AACD,WAAOT,wBAAwB,CAAEC,OAAO,CAACQ,aAAV,EAAyBP,QAAzB,CAA/B;AACA;;AAED,SAAOK,KAAP;AACA;;AAED,SAASG,kBAAT,CAA6BT,OAA7B,EAAsC;AAAEU,EAAAA,KAAF;AAASC,EAAAA;AAAT,CAAtC,EAAmE;AAClE,MAAK,CAAED,KAAF,IAAW,CAAEC,eAAlB,EAAoC;AACnC;AACA;;AAED,SAAO;AACND,IAAAA,KAAK,EAAEA,KAAK,IAAIX,wBAAwB,CAAEC,OAAF,EAAW,OAAX,CADlC;AAENW,IAAAA,eAAe,EACdA,eAAe,KAAKhB,gBAApB,GACGI,wBAAwB,CAAEC,OAAF,EAAW,kBAAX,CAD3B,GAEGW;AALE,GAAP;AAOA;;AAED,SAASC,aAAT,CAAwB;AACvBN,EAAAA,KADuB;AAEvBO,EAA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AlBnB;AAoBC,IAAA,IAAI,EAAC;AApBN,IADD,EAuBGuB,aAAa,IACd,4BAAC,eAAD;AACC,IAAA,IAAI,EAAGvB,IADR;AAEC,IAAA,OAAO,EAAG0B,oBAFX;AAGC,IAAA,gBAAgB,EAAGP,gBAHpB;AAIC,IAAA,KAAK,EAAGT,KAJT;AAKC,IAAA,QAAQ,EAAGO,QALZ;AAMC,IAAA,UAAU,EAAGG;AANd,IAxBF,CADD;AAoCA;;AAEM,MAAMe,SAAS,GAAG;AACxBnC,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBmC,EAAAA,OAAO,EAAE,MAHe;AAIxBC,EAAAA,SAAS,EAAE,kBAJa;AAKxBC,EAAAA,UAAU,EAAE;AACX9B,IAAAA,KAAK,EAAE,OADI;AAEX+B,IAAAA,KAAK,EAAE;AAFI,GALY;;AASxB;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACCC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO/B,KAAP,EAAe;AAC5C,QAAK+B,GAAG,KAAK,OAAb,EAAuB,OAAO/B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAACgC,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAOhC,KAAP;AACrD,UAAMiC,QAAQ,GAAG,CAAE,kBAAF,EAAsB5C,gBAAtB,EAAyC6C,IAAzC,CAA+C,GAA/C,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAOlC,KAAK,GAAG,CAAEiC,QAAF,EAAYjC,KAAZ,EAAoBkC,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAE7B;AA3BkB,CAAlB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useCallback, useMemo, useState } from '@wordpress/element';\nimport { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';\nimport {\n\tIcon,\n\tcolor as colorIcon,\n\ttextColor as textColorIcon,\n} from '@wordpress/icons';\nimport { removeFormat } from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { default as InlineColorUI, getActiveColors } from './inline';\n\nexport const transparentValue = 'rgba(0, 0, 0, 0)';\n\nconst name = 'core/text-color';\nconst title = __( 'Highlight' );\n\nconst EMPTY_ARRAY = [];\n\nfunction getComputedStyleProperty( element, property ) {\n\tconst { ownerDocument } = element;\n\tconst { defaultView } = ownerDocument;\n\tconst style = defaultView.getComputedStyle( element );\n\tconst value = style.getPropertyValue( property );\n\n\tif (\n\t\tproperty === 'background-color' &&\n\t\tvalue === transparentValue &&\n\t\telement.parentElement\n\t) {\n\t\treturn getComputedStyleProperty( element.parentElement, property );\n\t}\n\n\treturn value;\n}\n\nfunction fillComputedColors( element, { color, backgroundColor } ) {\n\tif ( ! color && ! backgroundColor ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tcolor: color || getComputedStyleProperty( element, 'color' ),\n\t\tbackgroundColor:\n\t\t\tbackgroundColor === transparentValue\n\t\t\t\t? getComputedStyleProperty( element, 'background-color' )\n\t\t\t\t: backgroundColor,\n\t};\n}\n\nfunction TextColorEdit( {\n\tvalue,\n\tonChange,\n\tisActive,\n\tactiveAttributes,\n\tcontentRef,\n} ) {\n\tconst allowCustomControl = useSetting( 'color.custom' );\n\tconst colors = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst [ isAddingColor, setIsAddingColor ] = useState( false );\n\tconst enableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( true ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst disableIsAddingColor = useCallback(\n\t\t() => setIsAddingColor( false ),\n\t\t[ setIsAddingColor ]\n\t);\n\tconst colorIndicatorStyle = useMemo(\n\t\t() =>\n\t\t\tfillComputedColors(\n\t\t\t\tcontentRef.current,\n\t\t\t\tgetActiveColors( value, name, colors )\n\t\t\t),\n\t\t[ value, colors ]\n\t);\n\n\tconst hasColorsToChoose = colors.length || ! allowCustomControl;\n\tif ( ! hasColorsToChoose && ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<RichTextToolbarButton\n\t\t\t\tclassName=\"format-library-text-color-button\"\n\t\t\t\tisActive={ isActive }\n\t\t\t\ticon={\n\t\t\t\t\t<Icon\n\t\t\t\t\t\ticon={\n\t\t\t\t\t\t\tObject.keys( activeAttributes ).length\n\t\t\t\t\t\t\t\t? textColorIcon\n\t\t\t\t\t\t\t\t: colorIcon\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstyle={ colorIndicatorStyle }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\ttitle={ title }\n\t\t\t\t// If has no colors to choose but a color is active remove the color onClick.\n\t\t\t\tonClick={\n\t\t\t\t\thasColorsToChoose\n\t\t\t\t\t\t? enableIsAddingColor\n\t\t\t\t\t\t: () => onChange( removeFormat( value, name ) )\n\t\t\t\t}\n\t\t\t\trole=\"menuitemcheckbox\"\n\t\t\t/>\n\t\t\t{ isAddingColor && (\n\t\t\t\t<InlineColorUI\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonClose={ disableIsAddingColor }\n\t\t\t\t\tactiveAttributes={ activeAttributes }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport const textColor = {\n\tname,\n\ttitle,\n\ttagName: 'mark',\n\tclassName: 'has-inline-color',\n\tattributes: {\n\t\tstyle: 'style',\n\t\tclass: 'class',\n\t},\n\t/*\n\t * Since this format relies on the <mark> tag, it's important to\n\t * prevent the default yellow background color applied by most\n\t * browsers. The solution is to detect when this format is used with a\n\t * text color but no background color, and in such cases to override\n\t * the default styling with a transparent background.\n\t *\n\t * @see https://github.com/WordPress/gutenberg/pull/35516\n\t */\n\t__unstableFilterAttributeValue( key, value ) {\n\t\tif ( key !== 'style' ) return value;\n\t\t// We should not add a background-color if it's already set.\n\t\tif ( value && value.includes( 'background-color' ) ) return value;\n\t\tconst addedCSS = [ 'background-color', transparentValue ].join( ':' );\n\t\t// Prepend `addedCSS` to avoid a double `;;` as any the existing CSS\n\t\t// rules will already include a `;`.\n\t\treturn value ? [ addedCSS, value ].join( ';' ) : addedCSS;\n\t},\n\tedit: TextColorEdit,\n};\n"]}