@wordpress/format-library 4.16.0 → 4.17.1

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 (107) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bold/index.js +1 -10
  3. package/build/bold/index.js.map +1 -1
  4. package/build/code/index.js +3 -17
  5. package/build/code/index.js.map +1 -1
  6. package/build/default-formats.js +0 -14
  7. package/build/default-formats.js.map +1 -1
  8. package/build/default-formats.native.js +0 -6
  9. package/build/default-formats.native.js.map +1 -1
  10. package/build/image/index.js +5 -14
  11. package/build/image/index.js.map +1 -1
  12. package/build/index.js +1 -3
  13. package/build/index.js.map +1 -1
  14. package/build/italic/index.js +1 -10
  15. package/build/italic/index.js.map +1 -1
  16. package/build/keyboard/index.js +1 -10
  17. package/build/keyboard/index.js.map +1 -1
  18. package/build/language/index.js +1 -11
  19. package/build/language/index.js.map +1 -1
  20. package/build/link/index.js +5 -26
  21. package/build/link/index.js.map +1 -1
  22. package/build/link/index.native.js +14 -39
  23. package/build/link/index.native.js.map +1 -1
  24. package/build/link/inline.js +41 -78
  25. package/build/link/inline.js.map +1 -1
  26. package/build/link/modal-screens/link-picker-screen.native.js +1 -13
  27. package/build/link/modal-screens/link-picker-screen.native.js.map +1 -1
  28. package/build/link/modal-screens/link-settings-screen.native.js +9 -36
  29. package/build/link/modal-screens/link-settings-screen.native.js.map +1 -1
  30. package/build/link/modal-screens/screens.native.js.map +1 -1
  31. package/build/link/modal.native.js +1 -9
  32. package/build/link/modal.native.js.map +1 -1
  33. package/build/link/use-link-instance-key.js +3 -7
  34. package/build/link/use-link-instance-key.js.map +1 -1
  35. package/build/link/utils.js +23 -47
  36. package/build/link/utils.js.map +1 -1
  37. package/build/strikethrough/index.js +1 -9
  38. package/build/strikethrough/index.js.map +1 -1
  39. package/build/subscript/index.js +1 -10
  40. package/build/subscript/index.js.map +1 -1
  41. package/build/superscript/index.js +1 -10
  42. package/build/superscript/index.js.map +1 -1
  43. package/build/text-color/index.js +7 -25
  44. package/build/text-color/index.js.map +1 -1
  45. package/build/text-color/index.native.js +11 -34
  46. package/build/text-color/index.native.js.map +1 -1
  47. package/build/text-color/inline.js +5 -26
  48. package/build/text-color/inline.js.map +1 -1
  49. package/build/text-color/inline.native.js +9 -25
  50. package/build/text-color/inline.native.js.map +1 -1
  51. package/build/underline/index.js +1 -8
  52. package/build/underline/index.js.map +1 -1
  53. package/build/unknown/index.js +1 -11
  54. package/build/unknown/index.js.map +1 -1
  55. package/build-module/bold/index.js +0 -7
  56. package/build-module/bold/index.js.map +1 -1
  57. package/build-module/code/index.js +2 -14
  58. package/build-module/code/index.js.map +1 -1
  59. package/build-module/default-formats.js.map +1 -1
  60. package/build-module/default-formats.native.js.map +1 -1
  61. package/build-module/image/index.js +4 -10
  62. package/build-module/image/index.js.map +1 -1
  63. package/build-module/index.js +1 -1
  64. package/build-module/index.js.map +1 -1
  65. package/build-module/italic/index.js +0 -7
  66. package/build-module/italic/index.js.map +1 -1
  67. package/build-module/keyboard/index.js +0 -7
  68. package/build-module/keyboard/index.js.map +1 -1
  69. package/build-module/language/index.js +1 -8
  70. package/build-module/language/index.js.map +1 -1
  71. package/build-module/link/index.js +5 -17
  72. package/build-module/link/index.js.map +1 -1
  73. package/build-module/link/index.native.js +15 -30
  74. package/build-module/link/index.native.js.map +1 -1
  75. package/build-module/link/inline.js +42 -69
  76. package/build-module/link/inline.js.map +1 -1
  77. package/build-module/link/modal-screens/link-picker-screen.native.js +2 -8
  78. package/build-module/link/modal-screens/link-picker-screen.native.js.map +1 -1
  79. package/build-module/link/modal-screens/link-settings-screen.native.js +10 -28
  80. package/build-module/link/modal-screens/link-settings-screen.native.js.map +1 -1
  81. package/build-module/link/modal-screens/screens.native.js.map +1 -1
  82. package/build-module/link/modal.native.js +1 -4
  83. package/build-module/link/modal.native.js.map +1 -1
  84. package/build-module/link/use-link-instance-key.js +3 -7
  85. package/build-module/link/use-link-instance-key.js.map +1 -1
  86. package/build-module/link/utils.js +24 -43
  87. package/build-module/link/utils.js.map +1 -1
  88. package/build-module/strikethrough/index.js +0 -6
  89. package/build-module/strikethrough/index.js.map +1 -1
  90. package/build-module/subscript/index.js +0 -7
  91. package/build-module/subscript/index.js.map +1 -1
  92. package/build-module/superscript/index.js +0 -7
  93. package/build-module/superscript/index.js.map +1 -1
  94. package/build-module/text-color/index.js +7 -20
  95. package/build-module/text-color/index.js.map +1 -1
  96. package/build-module/text-color/index.native.js +12 -24
  97. package/build-module/text-color/index.native.js.map +1 -1
  98. package/build-module/text-color/inline.js +5 -20
  99. package/build-module/text-color/inline.js.map +1 -1
  100. package/build-module/text-color/inline.native.js +9 -21
  101. package/build-module/text-color/inline.native.js.map +1 -1
  102. package/build-module/underline/index.js +0 -6
  103. package/build-module/underline/index.js.map +1 -1
  104. package/build-module/unknown/index.js +0 -8
  105. package/build-module/unknown/index.js.map +1 -1
  106. package/package.json +13 -13
  107. package/src/link/inline.js +11 -34
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { getProtocol, isValidProtocol, getAuthority, isValidAuthority, getPath, isValidPath, getQueryString, isValidQueryString, getFragment, isValidFragment } from '@wordpress/url';
5
+
5
6
  /**
6
7
  * Check for issues with the provided href.
7
8
  *
@@ -9,64 +10,52 @@ import { getProtocol, isValidProtocol, getAuthority, isValidAuthority, getPath,
9
10
  *
10
11
  * @return {boolean} Is the href invalid?
11
12
  */
12
-
13
13
  export function isValidHref(href) {
14
14
  if (!href) {
15
15
  return false;
16
16
  }
17
-
18
17
  const trimmedHref = href.trim();
19
-
20
18
  if (!trimmedHref) {
21
19
  return false;
22
- } // Does the href start with something that looks like a URL protocol?
23
-
20
+ }
24
21
 
22
+ // Does the href start with something that looks like a URL protocol?
25
23
  if (/^\S+:/.test(trimmedHref)) {
26
24
  const protocol = getProtocol(trimmedHref);
27
-
28
25
  if (!isValidProtocol(protocol)) {
29
26
  return false;
30
- } // Add some extra checks for http(s) URIs, since these are the most common use-case.
31
- // This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
32
-
27
+ }
33
28
 
29
+ // Add some extra checks for http(s) URIs, since these are the most common use-case.
30
+ // This ensures URIs with an http protocol have exactly two forward slashes following the protocol.
34
31
  if (protocol.startsWith('http') && !/^https?:\/\/[^\/\s]/i.test(trimmedHref)) {
35
32
  return false;
36
33
  }
37
-
38
34
  const authority = getAuthority(trimmedHref);
39
-
40
35
  if (!isValidAuthority(authority)) {
41
36
  return false;
42
37
  }
43
-
44
38
  const path = getPath(trimmedHref);
45
-
46
39
  if (path && !isValidPath(path)) {
47
40
  return false;
48
41
  }
49
-
50
42
  const queryString = getQueryString(trimmedHref);
51
-
52
43
  if (queryString && !isValidQueryString(queryString)) {
53
44
  return false;
54
45
  }
55
-
56
46
  const fragment = getFragment(trimmedHref);
57
-
58
47
  if (fragment && !isValidFragment(fragment)) {
59
48
  return false;
60
49
  }
61
- } // Validate anchor links.
62
-
50
+ }
63
51
 
52
+ // Validate anchor links.
64
53
  if (trimmedHref.startsWith('#') && !isValidFragment(trimmedHref)) {
65
54
  return false;
66
55
  }
67
-
68
56
  return true;
69
57
  }
58
+
70
59
  /**
71
60
  * Generates the format object that will be applied to the link text.
72
61
  *
@@ -78,7 +67,6 @@ export function isValidHref(href) {
78
67
  *
79
68
  * @return {Object} The final format object.
80
69
  */
81
-
82
70
  export function createLinkFormat({
83
71
  url,
84
72
  type,
@@ -93,16 +81,14 @@ export function createLinkFormat({
93
81
  };
94
82
  if (type) format.attributes.type = type;
95
83
  if (id) format.attributes.id = id;
96
-
97
84
  if (opensInNewWindow) {
98
85
  format.attributes.target = '_blank';
99
86
  format.attributes.rel = 'noreferrer noopener';
100
87
  }
101
-
102
88
  return format;
103
89
  }
104
- /* eslint-disable jsdoc/no-undefined-types */
105
90
 
91
+ /* eslint-disable jsdoc/no-undefined-types */
106
92
  /**
107
93
  * Get the start and end boundaries of a given format from a rich text value.
108
94
  *
@@ -113,9 +99,7 @@ export function createLinkFormat({
113
99
  * @param {number?} endIndex optional endIndex to seek from.
114
100
  * @return {Object} object containing start and end values for the given format.
115
101
  */
116
-
117
102
  /* eslint-enable jsdoc/no-undefined-types */
118
-
119
103
  export function getFormatBoundary(value, format, startIndex = value.start, endIndex = value.end) {
120
104
  const EMPTY_BOUNDARIES = {
121
105
  start: null,
@@ -126,12 +110,11 @@ export function getFormatBoundary(value, format, startIndex = value.start, endIn
126
110
  } = value;
127
111
  let targetFormat;
128
112
  let initialIndex;
129
-
130
113
  if (!formats?.length) {
131
114
  return EMPTY_BOUNDARIES;
132
- } // Clone formats to avoid modifying source formats.
133
-
115
+ }
134
116
 
117
+ // Clone formats to avoid modifying source formats.
135
118
  const newFormats = formats.slice();
136
119
  const formatAtStart = newFormats[startIndex]?.find(({
137
120
  type
@@ -142,7 +125,6 @@ export function getFormatBoundary(value, format, startIndex = value.start, endIn
142
125
  const formatAtEndMinusOne = newFormats[endIndex - 1]?.find(({
143
126
  type
144
127
  }) => type === format.type);
145
-
146
128
  if (!!formatAtStart) {
147
129
  // Set values to conform to "start"
148
130
  targetFormat = formatAtStart;
@@ -160,21 +142,25 @@ export function getFormatBoundary(value, format, startIndex = value.start, endIn
160
142
  } else {
161
143
  return EMPTY_BOUNDARIES;
162
144
  }
163
-
164
145
  const index = newFormats[initialIndex].indexOf(targetFormat);
165
- const walkingArgs = [newFormats, initialIndex, targetFormat, index]; // Walk the startIndex "backwards" to the leading "edge" of the matching format.
146
+ const walkingArgs = [newFormats, initialIndex, targetFormat, index];
166
147
 
167
- startIndex = walkToStart(...walkingArgs); // Walk the endIndex "forwards" until the trailing "edge" of the matching format.
148
+ // Walk the startIndex "backwards" to the leading "edge" of the matching format.
149
+ startIndex = walkToStart(...walkingArgs);
168
150
 
169
- endIndex = walkToEnd(...walkingArgs); // Safe guard: start index cannot be less than 0.
151
+ // Walk the endIndex "forwards" until the trailing "edge" of the matching format.
152
+ endIndex = walkToEnd(...walkingArgs);
170
153
 
171
- startIndex = startIndex < 0 ? 0 : startIndex; // // Return the indicies of the "edges" as the boundaries.
154
+ // Safe guard: start index cannot be less than 0.
155
+ startIndex = startIndex < 0 ? 0 : startIndex;
172
156
 
157
+ // // Return the indicies of the "edges" as the boundaries.
173
158
  return {
174
159
  start: startIndex,
175
160
  end: endIndex
176
161
  };
177
162
  }
163
+
178
164
  /**
179
165
  * Walks forwards/backwards towards the boundary of a given format within an
180
166
  * array of format objects. Returns the index of the boundary.
@@ -186,7 +172,6 @@ export function getFormatBoundary(value, format, startIndex = value.start, endIn
186
172
  * @param {string} direction either 'forwards' or 'backwards' to indicate the direction.
187
173
  * @return {number} the index of the boundary of the given format.
188
174
  */
189
-
190
175
  function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, direction) {
191
176
  let index = initialIndex;
192
177
  const directions = {
@@ -194,22 +179,18 @@ function walkToBoundary(formats, initialIndex, targetFormatRef, formatIndex, dir
194
179
  backwards: -1
195
180
  };
196
181
  const directionIncrement = directions[direction] || 1; // invalid direction arg default to forwards
197
-
198
182
  const inverseDirectionIncrement = directionIncrement * -1;
199
-
200
183
  while (formats[index] && formats[index][formatIndex] === targetFormatRef) {
201
184
  // Increment/decrement in the direction of operation.
202
185
  index = index + directionIncrement;
203
- } // Restore by one in inverse direction of operation
204
- // to avoid out of bounds.
205
-
186
+ }
206
187
 
188
+ // Restore by one in inverse direction of operation
189
+ // to avoid out of bounds.
207
190
  index = index + inverseDirectionIncrement;
208
191
  return index;
209
192
  }
210
-
211
193
  const partialRight = (fn, ...partialArgs) => (...args) => fn(...args, ...partialArgs);
212
-
213
194
  const walkToStart = partialRight(walkToBoundary, 'backwards');
214
195
  const walkToEnd = partialRight(walkToBoundary, 'forwards');
215
196
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/link/utils.js"],"names":["getProtocol","isValidProtocol","getAuthority","isValidAuthority","getPath","isValidPath","getQueryString","isValidQueryString","getFragment","isValidFragment","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":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,eAFD,EAGCC,YAHD,EAICC,gBAJD,EAKCC,OALD,EAMCC,WAND,EAOCC,cAPD,EAQCC,kBARD,EASCC,WATD,EAUCC,eAVD,QAWO,gBAXP;AAaA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,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,GAAGf,WAAW,CAAEY,WAAF,CAA5B;;AACA,QAAK,CAAEX,eAAe,CAAEc,QAAF,CAAtB,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,GAAGf,YAAY,CAAEU,WAAF,CAA9B;;AACA,QAAK,CAAET,gBAAgB,CAAEc,SAAF,CAAvB,EAAuC;AACtC,aAAO,KAAP;AACA;;AAED,UAAMC,IAAI,GAAGd,OAAO,CAAEQ,WAAF,CAApB;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BD;AACA;;;AACAZ,EAAAA,KAAK,GAAGA,KAAK,GAAGa,yBAAhB;AAEA,SAAOb,KAAP;AACA;;AAED,MAAMc,YAAY,GACjB,CAAEC,EAAF,EAAM,GAAGC,WAAT,KACA,CAAE,GAAGC,IAAL,KACCF,EAAE,CAAE,GAAGE,IAAL,EAAW,GAAGD,WAAd,CAHJ;;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,"names":["getProtocol","isValidProtocol","getAuthority","isValidAuthority","getPath","isValidPath","getQueryString","isValidQueryString","getFragment","isValidFragment","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"],"sources":["@wordpress/format-library/src/link/utils.js"],"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"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WAAW,EACXC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,OAAO,EACPC,WAAW,EACXC,cAAc,EACdC,kBAAkB,EAClBC,WAAW,EACXC,eAAe,QACT,gBAAgB;;AAEvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAEC,IAAI,EAAG;EACnC,IAAK,CAAEA,IAAI,EAAG;IACb,OAAO,KAAK;EACb;EAEA,MAAMC,WAAW,GAAGD,IAAI,CAACE,IAAI,CAAC,CAAC;EAE/B,IAAK,CAAED,WAAW,EAAG;IACpB,OAAO,KAAK;EACb;;EAEA;EACA,IAAK,OAAO,CAACE,IAAI,CAAEF,WAAY,CAAC,EAAG;IAClC,MAAMG,QAAQ,GAAGf,WAAW,CAAEY,WAAY,CAAC;IAC3C,IAAK,CAAEX,eAAe,CAAEc,QAAS,CAAC,EAAG;MACpC,OAAO,KAAK;IACb;;IAEA;IACA;IACA,IACCA,QAAQ,CAACC,UAAU,CAAE,MAAO,CAAC,IAC7B,CAAE,sBAAsB,CAACF,IAAI,CAAEF,WAAY,CAAC,EAC3C;MACD,OAAO,KAAK;IACb;IAEA,MAAMK,SAAS,GAAGf,YAAY,CAAEU,WAAY,CAAC;IAC7C,IAAK,CAAET,gBAAgB,CAAEc,SAAU,CAAC,EAAG;MACtC,OAAO,KAAK;IACb;IAEA,MAAMC,IAAI,GAAGd,OAAO,CAAEQ,WAAY,CAAC;IACnC,IAAKM,IAAI,IAAI,CAAEb,WAAW,CAAEa,IAAK,CAAC,EAAG;MACpC,OAAO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, Fragment } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -8,15 +7,12 @@ import { toggleFormat } from '@wordpress/rich-text';
8
7
  import { RichTextToolbarButton, RichTextShortcut } from '@wordpress/block-editor';
9
8
  import { formatStrikethrough } from '@wordpress/icons';
10
9
  const name = 'core/strikethrough';
11
-
12
10
  const title = __('Strikethrough');
13
-
14
11
  export const strikethrough = {
15
12
  name,
16
13
  title,
17
14
  tagName: 's',
18
15
  className: null,
19
-
20
16
  edit({
21
17
  isActive,
22
18
  value,
@@ -30,7 +26,6 @@ export const strikethrough = {
30
26
  }));
31
27
  onFocus();
32
28
  }
33
-
34
29
  return createElement(Fragment, null, createElement(RichTextShortcut, {
35
30
  type: "access",
36
31
  character: "d",
@@ -43,6 +38,5 @@ export const strikethrough = {
43
38
  role: "menuitemcheckbox"
44
39
  }));
45
40
  }
46
-
47
41
  };
48
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/strikethrough/index.js"],"names":["__","toggleFormat","RichTextToolbarButton","RichTextShortcut","formatStrikethrough","name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SACCC,qBADD,EAECC,gBAFD,QAGO,yBAHP;AAIA,SAASC,mBAAT,QAAoC,kBAApC;AAEA,MAAMC,IAAI,GAAG,oBAAb;;AACA,MAAMC,KAAK,GAAGN,EAAE,CAAE,eAAF,CAAhB;;AAEA,OAAO,MAAMO,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,CAAEZ,YAAY,CAAEW,KAAF,EAAS;AAAEI,QAAAA,IAAI,EAAEX,IAAR;AAAcC,QAAAA;AAAd,OAAT,CAAd,CAAR;AACAQ,MAAAA,OAAO;AACP;;AAED,WACC,8BACC,cAAC,gBAAD;AACC,MAAA,IAAI,EAAC,QADN;AAEC,MAAA,SAAS,EAAC,GAFX;AAGC,MAAA,KAAK,EAAGC;AAHT,MADD,EAMC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAGX,mBADR;AAEC,MAAA,KAAK,EAAGE,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,"names":["__","toggleFormat","RichTextToolbarButton","RichTextShortcut","formatStrikethrough","name","title","strikethrough","tagName","className","edit","isActive","value","onChange","onFocus","onClick","type","createElement","Fragment","character","onUse","icon","role"],"sources":["@wordpress/format-library/src/strikethrough/index.js"],"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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SACCC,qBAAqB,EACrBC,gBAAgB,QACV,yBAAyB;AAChC,SAASC,mBAAmB,QAAQ,kBAAkB;AAEtD,MAAMC,IAAI,GAAG,oBAAoB;AACjC,MAAMC,KAAK,GAAGN,EAAE,CAAE,eAAgB,CAAC;AAEnC,OAAO,MAAMO,aAAa,GAAG;EAC5BF,IAAI;EACJC,KAAK;EACLE,OAAO,EAAE,GAAG;EACZC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAEZ,YAAY,CAAEW,KAAK,EAAE;QAAEI,IAAI,EAAEX,IAAI;QAAEC;MAAM,CAAE,CAAE,CAAC;MACxDQ,OAAO,CAAC,CAAC;IACV;IAEA,OACCG,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACd,gBAAgB;MAChBa,IAAI,EAAC,QAAQ;MACbG,SAAS,EAAC,GAAG;MACbC,KAAK,EAAGL;IAAS,CACjB,CAAC,EACFE,aAAA,CAACf,qBAAqB;MACrBmB,IAAI,EAAGjB,mBAAqB;MAC5BE,KAAK,EAAGA,KAAO;MACfS,OAAO,EAAGA,OAAS;MACnBJ,QAAQ,EAAGA,QAAU;MACrBW,IAAI,EAAC;IAAkB,CACvB,CACA,CAAC;EAEL;AACD,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -8,15 +7,12 @@ import { toggleFormat } from '@wordpress/rich-text';
8
7
  import { RichTextToolbarButton } from '@wordpress/block-editor';
9
8
  import { subscript as subscriptIcon } from '@wordpress/icons';
10
9
  const name = 'core/subscript';
11
-
12
10
  const title = __('Subscript');
13
-
14
11
  export const subscript = {
15
12
  name,
16
13
  title,
17
14
  tagName: 'sub',
18
15
  className: null,
19
-
20
16
  edit({
21
17
  isActive,
22
18
  value,
@@ -29,12 +25,10 @@ export const subscript = {
29
25
  title
30
26
  }));
31
27
  }
32
-
33
28
  function onClick() {
34
29
  onToggle();
35
30
  onFocus();
36
31
  }
37
-
38
32
  return createElement(RichTextToolbarButton, {
39
33
  icon: subscriptIcon,
40
34
  title: title,
@@ -43,6 +37,5 @@ export const subscript = {
43
37
  role: "menuitemcheckbox"
44
38
  });
45
39
  }
46
-
47
40
  };
48
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/subscript/index.js"],"names":["__","toggleFormat","RichTextToolbarButton","subscript","subscriptIcon","name","title","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SAASC,qBAAT,QAAsC,yBAAtC;AACA,SAASC,SAAS,IAAIC,aAAtB,QAA2C,kBAA3C;AAEA,MAAMC,IAAI,GAAG,gBAAb;;AACA,MAAMC,KAAK,GAAGN,EAAE,CAAE,WAAF,CAAhB;;AAEA,OAAO,MAAMG,SAAS,GAAG;AACxBE,EAAAA,IADwB;AAExBC,EAAAA,KAFwB;AAGxBC,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,CAAEX,YAAY,CAAEU,KAAF,EAAS;AAAEI,QAAAA,IAAI,EAAEV,IAAR;AAAcC,QAAAA;AAAd,OAAT,CAAd,CAAR;AACA;;AAED,aAASU,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAGT,aADR;AAEC,MAAA,KAAK,EAAGE,KAFT;AAGC,MAAA,OAAO,EAAGU,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,"names":["__","toggleFormat","RichTextToolbarButton","subscript","subscriptIcon","name","title","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","createElement","icon","role"],"sources":["@wordpress/format-library/src/subscript/index.js"],"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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,SAAS,IAAIC,aAAa,QAAQ,kBAAkB;AAE7D,MAAMC,IAAI,GAAG,gBAAgB;AAC7B,MAAMC,KAAK,GAAGN,EAAE,CAAE,WAAY,CAAC;AAE/B,OAAO,MAAMG,SAAS,GAAG;EACxBE,IAAI;EACJC,KAAK;EACLC,OAAO,EAAE,KAAK;EACdC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,QAAQA,CAAA,EAAG;MACnBF,QAAQ,CAAEX,YAAY,CAAEU,KAAK,EAAE;QAAEI,IAAI,EAAEV,IAAI;QAAEC;MAAM,CAAE,CAAE,CAAC;IACzD;IAEA,SAASU,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAC,CAAC;MACVD,OAAO,CAAC,CAAC;IACV;IAEA,OACCI,aAAA,CAACf,qBAAqB;MACrBgB,IAAI,EAAGd,aAAe;MACtBE,KAAK,EAAGA,KAAO;MACfU,OAAO,EAAGA,OAAS;MACnBN,QAAQ,EAAGA,QAAU;MACrBS,IAAI,EAAC;IAAkB,CACvB,CAAC;EAEJ;AACD,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -8,15 +7,12 @@ import { toggleFormat } from '@wordpress/rich-text';
8
7
  import { RichTextToolbarButton } from '@wordpress/block-editor';
9
8
  import { superscript as superscriptIcon } from '@wordpress/icons';
10
9
  const name = 'core/superscript';
11
-
12
10
  const title = __('Superscript');
13
-
14
11
  export const superscript = {
15
12
  name,
16
13
  title,
17
14
  tagName: 'sup',
18
15
  className: null,
19
-
20
16
  edit({
21
17
  isActive,
22
18
  value,
@@ -29,12 +25,10 @@ export const superscript = {
29
25
  title
30
26
  }));
31
27
  }
32
-
33
28
  function onClick() {
34
29
  onToggle();
35
30
  onFocus();
36
31
  }
37
-
38
32
  return createElement(RichTextToolbarButton, {
39
33
  icon: superscriptIcon,
40
34
  title: title,
@@ -43,6 +37,5 @@ export const superscript = {
43
37
  role: "menuitemcheckbox"
44
38
  });
45
39
  }
46
-
47
40
  };
48
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/superscript/index.js"],"names":["__","toggleFormat","RichTextToolbarButton","superscript","superscriptIcon","name","title","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,sBAA7B;AACA,SAASC,qBAAT,QAAsC,yBAAtC;AACA,SAASC,WAAW,IAAIC,eAAxB,QAA+C,kBAA/C;AAEA,MAAMC,IAAI,GAAG,kBAAb;;AACA,MAAMC,KAAK,GAAGN,EAAE,CAAE,aAAF,CAAhB;;AAEA,OAAO,MAAMG,WAAW,GAAG;AAC1BE,EAAAA,IAD0B;AAE1BC,EAAAA,KAF0B;AAG1BC,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,CAAEX,YAAY,CAAEU,KAAF,EAAS;AAAEI,QAAAA,IAAI,EAAEV,IAAR;AAAcC,QAAAA;AAAd,OAAT,CAAd,CAAR;AACA;;AAED,aAASU,OAAT,GAAmB;AAClBF,MAAAA,QAAQ;AACRD,MAAAA,OAAO;AACP;;AAED,WACC,cAAC,qBAAD;AACC,MAAA,IAAI,EAAGT,eADR;AAEC,MAAA,KAAK,EAAGE,KAFT;AAGC,MAAA,OAAO,EAAGU,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,"names":["__","toggleFormat","RichTextToolbarButton","superscript","superscriptIcon","name","title","tagName","className","edit","isActive","value","onChange","onFocus","onToggle","type","onClick","createElement","icon","role"],"sources":["@wordpress/format-library/src/superscript/index.js"],"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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,QAAQ,sBAAsB;AACnD,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,WAAW,IAAIC,eAAe,QAAQ,kBAAkB;AAEjE,MAAMC,IAAI,GAAG,kBAAkB;AAC/B,MAAMC,KAAK,GAAGN,EAAE,CAAE,aAAc,CAAC;AAEjC,OAAO,MAAMG,WAAW,GAAG;EAC1BE,IAAI;EACJC,KAAK;EACLC,OAAO,EAAE,KAAK;EACdC,SAAS,EAAE,IAAI;EACfC,IAAIA,CAAE;IAAEC,QAAQ;IAAEC,KAAK;IAAEC,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IAC9C,SAASC,QAAQA,CAAA,EAAG;MACnBF,QAAQ,CAAEX,YAAY,CAAEU,KAAK,EAAE;QAAEI,IAAI,EAAEV,IAAI;QAAEC;MAAM,CAAE,CAAE,CAAC;IACzD;IAEA,SAASU,OAAOA,CAAA,EAAG;MAClBF,QAAQ,CAAC,CAAC;MACVD,OAAO,CAAC,CAAC;IACV;IAEA,OACCI,aAAA,CAACf,qBAAqB;MACrBgB,IAAI,EAAGd,eAAiB;MACxBE,KAAK,EAAGA,KAAO;MACfU,OAAO,EAAGA,OAAS;MACnBN,QAAQ,EAAGA,QAAU;MACrBS,IAAI,EAAC;IAAkB,CACvB,CAAC;EAEJ;AACD,CAAC"}
@@ -1,5 +1,4 @@
1
1
  import { createElement, Fragment } from "@wordpress/element";
2
-
3
2
  /**
4
3
  * WordPress dependencies
5
4
  */
@@ -8,18 +7,15 @@ import { useCallback, useMemo, useState } from '@wordpress/element';
8
7
  import { RichTextToolbarButton, useSetting } from '@wordpress/block-editor';
9
8
  import { Icon, color as colorIcon, textColor as textColorIcon } from '@wordpress/icons';
10
9
  import { removeFormat } from '@wordpress/rich-text';
10
+
11
11
  /**
12
12
  * Internal dependencies
13
13
  */
14
-
15
14
  import { default as InlineColorUI, getActiveColors } from './inline';
16
15
  export const transparentValue = 'rgba(0, 0, 0, 0)';
17
16
  const name = 'core/text-color';
18
-
19
17
  const title = __('Highlight');
20
-
21
18
  const EMPTY_ARRAY = [];
22
-
23
19
  function getComputedStyleProperty(element, property) {
24
20
  const {
25
21
  ownerDocument
@@ -29,14 +25,11 @@ function getComputedStyleProperty(element, property) {
29
25
  } = ownerDocument;
30
26
  const style = defaultView.getComputedStyle(element);
31
27
  const value = style.getPropertyValue(property);
32
-
33
28
  if (property === 'background-color' && value === transparentValue && element.parentElement) {
34
29
  return getComputedStyleProperty(element.parentElement, property);
35
30
  }
36
-
37
31
  return value;
38
32
  }
39
-
40
33
  function fillComputedColors(element, {
41
34
  color,
42
35
  backgroundColor
@@ -44,13 +37,11 @@ function fillComputedColors(element, {
44
37
  if (!color && !backgroundColor) {
45
38
  return;
46
39
  }
47
-
48
40
  return {
49
41
  color: color || getComputedStyleProperty(element, 'color'),
50
42
  backgroundColor: backgroundColor === transparentValue ? getComputedStyleProperty(element, 'background-color') : backgroundColor
51
43
  };
52
44
  }
53
-
54
45
  function TextColorEdit({
55
46
  value,
56
47
  onChange,
@@ -65,11 +56,9 @@ function TextColorEdit({
65
56
  const disableIsAddingColor = useCallback(() => setIsAddingColor(false), [setIsAddingColor]);
66
57
  const colorIndicatorStyle = useMemo(() => fillComputedColors(contentRef.current, getActiveColors(value, name, colors)), [value, colors]);
67
58
  const hasColorsToChoose = colors.length || !allowCustomControl;
68
-
69
59
  if (!hasColorsToChoose && !isActive) {
70
60
  return null;
71
61
  }
72
-
73
62
  return createElement(Fragment, null, createElement(RichTextToolbarButton, {
74
63
  className: "format-library-text-color-button",
75
64
  isActive: isActive,
@@ -77,7 +66,8 @@ function TextColorEdit({
77
66
  icon: Object.keys(activeAttributes).length ? textColorIcon : colorIcon,
78
67
  style: colorIndicatorStyle
79
68
  }),
80
- title: title // If has no colors to choose but a color is active remove the color onClick.
69
+ title: title
70
+ // If has no colors to choose but a color is active remove the color onClick.
81
71
  ,
82
72
  onClick: hasColorsToChoose ? enableIsAddingColor : () => onChange(removeFormat(value, name)),
83
73
  role: "menuitemcheckbox"
@@ -90,7 +80,6 @@ function TextColorEdit({
90
80
  contentRef: contentRef
91
81
  }));
92
82
  }
93
-
94
83
  export const textColor = {
95
84
  name,
96
85
  title,
@@ -100,7 +89,6 @@ export const textColor = {
100
89
  style: 'style',
101
90
  class: 'class'
102
91
  },
103
-
104
92
  /*
105
93
  * Since this format relies on the <mark> tag, it's important to
106
94
  * prevent the default yellow background color applied by most
@@ -111,15 +99,14 @@ export const textColor = {
111
99
  * @see https://github.com/WordPress/gutenberg/pull/35516
112
100
  */
113
101
  __unstableFilterAttributeValue(key, value) {
114
- if (key !== 'style') return value; // We should not add a background-color if it's already set.
115
-
102
+ if (key !== 'style') return value;
103
+ // We should not add a background-color if it's already set.
116
104
  if (value && value.includes('background-color')) return value;
117
- const addedCSS = ['background-color', transparentValue].join(':'); // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
105
+ const addedCSS = ['background-color', transparentValue].join(':');
106
+ // Prepend `addedCSS` to avoid a double `;;` as any the existing CSS
118
107
  // rules will already include a `;`.
119
-
120
108
  return value ? [addedCSS, value].join(';') : addedCSS;
121
109
  },
122
-
123
110
  edit: TextColorEdit
124
111
  };
125
112
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/format-library/src/text-color/index.js"],"names":["__","useCallback","useMemo","useState","RichTextToolbarButton","useSetting","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","Object","keys","tagName","className","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,EAAsBC,OAAtB,EAA+BC,QAA/B,QAA+C,oBAA/C;AACA,SAASC,qBAAT,EAAgCC,UAAhC,QAAkD,yBAAlD;AACA,SACCC,IADD,EAECC,KAAK,IAAIC,SAFV,EAGCC,SAAS,IAAIC,aAHd,QAIO,kBAJP;AAKA,SAASC,YAAT,QAA6B,sBAA7B;AAEA;AACA;AACA;;AACA,SAASC,OAAO,IAAIC,aAApB,EAAmCC,eAAnC,QAA0D,UAA1D;AAEA,OAAO,MAAMC,gBAAgB,GAAG,kBAAzB;AAEP,MAAMC,IAAI,GAAG,iBAAb;;AACA,MAAMC,KAAK,GAAGjB,EAAE,CAAE,WAAF,CAAhB;;AAEA,MAAMkB,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,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CC,EAAAA,8BAA8B,CAAEC,GAAF,EAAO3B,KAAP,EAAe;AAC5C,QAAK2B,GAAG,KAAK,OAAb,EAAuB,OAAO3B,KAAP,CADqB,CAE5C;;AACA,QAAKA,KAAK,IAAIA,KAAK,CAAC4B,QAAN,CAAgB,kBAAhB,CAAd,EAAqD,OAAO5B,KAAP;AACrD,UAAM6B,QAAQ,GAAG,CAAE,kBAAF,EAAsBxC,gBAAtB,EAAyCyC,IAAzC,CAA+C,GAA/C,CAAjB,CAJ4C,CAK5C;AACA;;AACA,WAAO9B,KAAK,GAAG,CAAE6B,QAAF,EAAY7B,KAAZ,EAAoB8B,IAApB,CAA0B,GAA1B,CAAH,GAAqCD,QAAjD;AACA,GA1BuB;;AA2BxBE,EAAAA,IAAI,EAAE1B;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,"names":["__","useCallback","useMemo","useState","RichTextToolbarButton","useSetting","Icon","color","colorIcon","textColor","textColorIcon","removeFormat","default","InlineColorUI","getActiveColors","transparentValue","name","title","EMPTY_ARRAY","getComputedStyleProperty","element","property","ownerDocument","defaultView","style","getComputedStyle","value","getPropertyValue","parentElement","fillComputedColors","backgroundColor","TextColorEdit","onChange","isActive","activeAttributes","contentRef","allowCustomControl","colors","isAddingColor","setIsAddingColor","enableIsAddingColor","disableIsAddingColor","colorIndicatorStyle","current","hasColorsToChoose","length","createElement","Fragment","className","icon","Object","keys","onClick","role","onClose","tagName","attributes","class","__unstableFilterAttributeValue","key","includes","addedCSS","join","edit"],"sources":["@wordpress/format-library/src/text-color/index.js"],"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"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,oBAAoB;AACnE,SAASC,qBAAqB,EAAEC,UAAU,QAAQ,yBAAyB;AAC3E,SACCC,IAAI,EACJC,KAAK,IAAIC,SAAS,EAClBC,SAAS,IAAIC,aAAa,QACpB,kBAAkB;AACzB,SAASC,YAAY,QAAQ,sBAAsB;;AAEnD;AACA;AACA;AACA,SAASC,OAAO,IAAIC,aAAa,EAAEC,eAAe,QAAQ,UAAU;AAEpE,OAAO,MAAMC,gBAAgB,GAAG,kBAAkB;AAElD,MAAMC,IAAI,GAAG,iBAAiB;AAC9B,MAAMC,KAAK,GAAGjB,EAAE,CAAE,WAAY,CAAC;AAE/B,MAAMkB,WAAW,GAAG,EAAE;AAEtB,SAASC,wBAAwBA,CAAEC,OAAO,EAAEC,QAAQ,EAAG;EACtD,MAAM;IAAEC;EAAc,CAAC,GAAGF,OAAO;EACjC,MAAM;IAAEG;EAAY,CAAC,GAAGD,aAAa;EACrC,MAAME,KAAK,GAAGD,WAAW,CAACE,gBAAgB,CAAEL,OAAQ,C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