changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
18:be944660c56a | 19:3d72ae0968f4 |
---|---|
1 this["wp"] = this["wp"] || {}; this["wp"]["wordcount"] = |
1 /******/ (function() { // webpackBootstrap |
2 /******/ (function(modules) { // webpackBootstrap |
2 /******/ "use strict"; |
3 /******/ // The module cache |
3 /******/ // The require scope |
4 /******/ var installedModules = {}; |
4 /******/ var __webpack_require__ = {}; |
5 /******/ |
5 /******/ |
6 /******/ // The require function |
6 /************************************************************************/ |
7 /******/ function __webpack_require__(moduleId) { |
7 /******/ /* webpack/runtime/define property getters */ |
8 /******/ |
8 /******/ !function() { |
9 /******/ // Check if module is in cache |
9 /******/ // define getter functions for harmony exports |
10 /******/ if(installedModules[moduleId]) { |
10 /******/ __webpack_require__.d = function(exports, definition) { |
11 /******/ return installedModules[moduleId].exports; |
11 /******/ for(var key in definition) { |
12 /******/ } |
12 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { |
13 /******/ // Create a new module (and put it into the cache) |
13 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); |
14 /******/ var module = installedModules[moduleId] = { |
14 /******/ } |
15 /******/ i: moduleId, |
15 /******/ } |
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
16 /******/ }; |
19 /******/ |
17 /******/ }(); |
20 /******/ // Execute the module function |
18 /******/ |
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
19 /******/ /* webpack/runtime/hasOwnProperty shorthand */ |
22 /******/ |
20 /******/ !function() { |
23 /******/ // Flag the module as loaded |
21 /******/ __webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); } |
24 /******/ module.l = true; |
22 /******/ }(); |
25 /******/ |
23 /******/ |
26 /******/ // Return the exports of the module |
24 /******/ /* webpack/runtime/make namespace object */ |
27 /******/ return module.exports; |
25 /******/ !function() { |
28 /******/ } |
26 /******/ // define __esModule on exports |
29 /******/ |
27 /******/ __webpack_require__.r = function(exports) { |
30 /******/ |
28 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
31 /******/ // expose the modules object (__webpack_modules__) |
29 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
32 /******/ __webpack_require__.m = modules; |
30 /******/ } |
33 /******/ |
31 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
34 /******/ // expose the module cache |
32 /******/ }; |
35 /******/ __webpack_require__.c = installedModules; |
33 /******/ }(); |
36 /******/ |
34 /******/ |
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = "pC98"); |
|
86 /******/ }) |
|
87 /************************************************************************/ |
35 /************************************************************************/ |
88 /******/ ({ |
36 var __webpack_exports__ = {}; |
89 |
|
90 /***/ "YLtl": |
|
91 /***/ (function(module, exports) { |
|
92 |
|
93 (function() { module.exports = window["lodash"]; }()); |
|
94 |
|
95 /***/ }), |
|
96 |
|
97 /***/ "pC98": |
|
98 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
99 |
|
100 "use strict"; |
|
101 // ESM COMPAT FLAG |
37 // ESM COMPAT FLAG |
102 __webpack_require__.r(__webpack_exports__); |
38 __webpack_require__.r(__webpack_exports__); |
103 |
39 |
104 // EXPORTS |
40 // EXPORTS |
105 __webpack_require__.d(__webpack_exports__, "count", function() { return /* binding */ count; }); |
41 __webpack_require__.d(__webpack_exports__, { |
106 |
42 "count": function() { return /* binding */ count; } |
107 // EXTERNAL MODULE: external "lodash" |
43 }); |
108 var external_lodash_ = __webpack_require__("YLtl"); |
44 |
109 |
45 ;// CONCATENATED MODULE: external "lodash" |
110 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/defaultSettings.js |
46 var external_lodash_namespaceObject = window["lodash"]; |
47 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/defaultSettings.js |
|
111 /** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */ |
48 /** @typedef {import('./index').WPWordCountStrategy} WPWordCountStrategy */ |
112 |
49 |
113 /** @typedef {Partial<{type: WPWordCountStrategy, shortcodes: string[]}>} WPWordCountL10n */ |
50 /** @typedef {Partial<{type: WPWordCountStrategy, shortcodes: string[]}>} WPWordCountL10n */ |
114 |
51 |
115 /** |
52 /** |
149 const defaultSettings = { |
86 const defaultSettings = { |
150 HTMLRegExp: /<\/?[a-z][^>]*?>/gi, |
87 HTMLRegExp: /<\/?[a-z][^>]*?>/gi, |
151 HTMLcommentRegExp: /<!--[\s\S]*?-->/g, |
88 HTMLcommentRegExp: /<!--[\s\S]*?-->/g, |
152 spaceRegExp: / | /gi, |
89 spaceRegExp: / | /gi, |
153 HTMLEntityRegExp: /&\S+?;/g, |
90 HTMLEntityRegExp: /&\S+?;/g, |
154 // \u2014 = em-dash |
91 // \u2014 = em-dash. |
155 connectorRegExp: /--|\u2014/g, |
92 connectorRegExp: /--|\u2014/g, |
156 // Characters to be removed from input text. |
93 // Characters to be removed from input text. |
157 removeRegExp: new RegExp(['[', // Basic Latin (extract) |
94 removeRegExp: new RegExp(['[', // Basic Latin (extract) |
158 '\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E', // Latin-1 Supplement (extract) |
95 '\u0021-\u002F\u003A-\u0040\u005B-\u0060\u007B-\u007E', // Latin-1 Supplement (extract) |
159 '\u0080-\u00BF\u00D7\u00F7', |
96 '\u0080-\u00BF\u00D7\u00F7', |
182 * Supplemental Arrows-B |
119 * Supplemental Arrows-B |
183 * Miscellaneous Mathematical Symbols-B |
120 * Miscellaneous Mathematical Symbols-B |
184 * Supplemental Mathematical Operators |
121 * Supplemental Mathematical Operators |
185 * Miscellaneous Symbols and Arrows |
122 * Miscellaneous Symbols and Arrows |
186 */ |
123 */ |
187 '\u2000-\u2BFF', // Supplemental Punctuation |
124 '\u2000-\u2BFF', // Supplemental Punctuation. |
188 '\u2E00-\u2E7F', ']'].join(''), 'g'), |
125 '\u2E00-\u2E7F', ']'].join(''), 'g'), |
189 // Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF |
126 // Remove UTF-16 surrogate points, see https://en.wikipedia.org/wiki/UTF-16#U.2BD800_to_U.2BDFFF |
190 astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, |
127 astralRegExp: /[\uD800-\uDBFF][\uDC00-\uDFFF]/g, |
191 wordsRegExp: /\S\s+/g, |
128 wordsRegExp: /\S\s+/g, |
192 characters_excluding_spacesRegExp: /\S/g, |
129 characters_excluding_spacesRegExp: /\S/g, |
206 l10n: { |
143 l10n: { |
207 type: 'words' |
144 type: 'words' |
208 } |
145 } |
209 }; |
146 }; |
210 |
147 |
211 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripTags.js |
148 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripTags.js |
212 /** |
149 /** |
213 * Replaces items matched in the regex with new line |
150 * Replaces items matched in the regex with new line |
214 * |
151 * |
215 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
152 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
216 * @param {string} text The string being counted. |
153 * @param {string} text The string being counted. |
219 */ |
156 */ |
220 function stripTags(settings, text) { |
157 function stripTags(settings, text) { |
221 return text.replace(settings.HTMLRegExp, '\n'); |
158 return text.replace(settings.HTMLRegExp, '\n'); |
222 } |
159 } |
223 |
160 |
224 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeAstralsToCountableChar.js |
161 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeAstralsToCountableChar.js |
225 /** |
162 /** |
226 * Replaces items matched in the regex with character. |
163 * Replaces items matched in the regex with character. |
227 * |
164 * |
228 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
165 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
229 * @param {string} text The string being counted. |
166 * @param {string} text The string being counted. |
232 */ |
169 */ |
233 function transposeAstralsToCountableChar(settings, text) { |
170 function transposeAstralsToCountableChar(settings, text) { |
234 return text.replace(settings.astralRegExp, 'a'); |
171 return text.replace(settings.astralRegExp, 'a'); |
235 } |
172 } |
236 |
173 |
237 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLEntities.js |
174 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLEntities.js |
238 /** |
175 /** |
239 * Removes items matched in the regex. |
176 * Removes items matched in the regex. |
240 * |
177 * |
241 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
178 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
242 * @param {string} text The string being counted. |
179 * @param {string} text The string being counted. |
245 */ |
182 */ |
246 function stripHTMLEntities(settings, text) { |
183 function stripHTMLEntities(settings, text) { |
247 return text.replace(settings.HTMLEntityRegExp, ''); |
184 return text.replace(settings.HTMLEntityRegExp, ''); |
248 } |
185 } |
249 |
186 |
250 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripConnectors.js |
187 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripConnectors.js |
251 /** |
188 /** |
252 * Replaces items matched in the regex with spaces. |
189 * Replaces items matched in the regex with spaces. |
253 * |
190 * |
254 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
191 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
255 * @param {string} text The string being counted. |
192 * @param {string} text The string being counted. |
258 */ |
195 */ |
259 function stripConnectors(settings, text) { |
196 function stripConnectors(settings, text) { |
260 return text.replace(settings.connectorRegExp, ' '); |
197 return text.replace(settings.connectorRegExp, ' '); |
261 } |
198 } |
262 |
199 |
263 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripRemovables.js |
200 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripRemovables.js |
264 /** |
201 /** |
265 * Removes items matched in the regex. |
202 * Removes items matched in the regex. |
266 * |
203 * |
267 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
204 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
268 * @param {string} text The string being counted. |
205 * @param {string} text The string being counted. |
271 */ |
208 */ |
272 function stripRemovables(settings, text) { |
209 function stripRemovables(settings, text) { |
273 return text.replace(settings.removeRegExp, ''); |
210 return text.replace(settings.removeRegExp, ''); |
274 } |
211 } |
275 |
212 |
276 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLComments.js |
213 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripHTMLComments.js |
277 /** |
214 /** |
278 * Removes items matched in the regex. |
215 * Removes items matched in the regex. |
279 * |
216 * |
280 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
217 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
281 * @param {string} text The string being counted. |
218 * @param {string} text The string being counted. |
284 */ |
221 */ |
285 function stripHTMLComments(settings, text) { |
222 function stripHTMLComments(settings, text) { |
286 return text.replace(settings.HTMLcommentRegExp, ''); |
223 return text.replace(settings.HTMLcommentRegExp, ''); |
287 } |
224 } |
288 |
225 |
289 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripShortcodes.js |
226 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripShortcodes.js |
290 /** |
227 /** |
291 * Replaces items matched in the regex with a new line. |
228 * Replaces items matched in the regex with a new line. |
292 * |
229 * |
293 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
230 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
294 * @param {string} text The string being counted. |
231 * @param {string} text The string being counted. |
301 } |
238 } |
302 |
239 |
303 return text; |
240 return text; |
304 } |
241 } |
305 |
242 |
306 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripSpaces.js |
243 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/stripSpaces.js |
307 /** |
244 /** |
308 * Replaces items matched in the regex with spaces. |
245 * Replaces items matched in the regex with spaces. |
309 * |
246 * |
310 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
247 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
311 * @param {string} text The string being counted. |
248 * @param {string} text The string being counted. |
314 */ |
251 */ |
315 function stripSpaces(settings, text) { |
252 function stripSpaces(settings, text) { |
316 return text.replace(settings.spaceRegExp, ' '); |
253 return text.replace(settings.spaceRegExp, ' '); |
317 } |
254 } |
318 |
255 |
319 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeHTMLEntitiesToCountableChars.js |
256 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/transposeHTMLEntitiesToCountableChars.js |
320 /** |
257 /** |
321 * Replaces items matched in the regex with a single character. |
258 * Replaces items matched in the regex with a single character. |
322 * |
259 * |
323 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
260 * @param {import('./index').WPWordCountSettings} settings The main settings object containing regular expressions |
324 * @param {string} text The string being counted. |
261 * @param {string} text The string being counted. |
327 */ |
264 */ |
328 function transposeHTMLEntitiesToCountableChars(settings, text) { |
265 function transposeHTMLEntitiesToCountableChars(settings, text) { |
329 return text.replace(settings.HTMLEntityRegExp, 'a'); |
266 return text.replace(settings.HTMLEntityRegExp, 'a'); |
330 } |
267 } |
331 |
268 |
332 // CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/index.js |
269 ;// CONCATENATED MODULE: ./node_modules/@wordpress/wordcount/build-module/index.js |
333 /** |
270 /** |
334 * External dependencies |
271 * External dependencies |
335 */ |
272 */ |
336 |
273 |
337 /** |
274 /** |
369 */ |
306 */ |
370 |
307 |
371 function loadSettings(type, userSettings) { |
308 function loadSettings(type, userSettings) { |
372 var _settings$l10n$shortc, _settings$l10n; |
309 var _settings$l10n$shortc, _settings$l10n; |
373 |
310 |
374 const settings = Object(external_lodash_["extend"])({}, defaultSettings, userSettings); |
311 const settings = (0,external_lodash_namespaceObject.extend)({}, defaultSettings, userSettings); |
375 settings.shortcodes = (_settings$l10n$shortc = (_settings$l10n = settings.l10n) === null || _settings$l10n === void 0 ? void 0 : _settings$l10n.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : []; |
312 settings.shortcodes = (_settings$l10n$shortc = (_settings$l10n = settings.l10n) === null || _settings$l10n === void 0 ? void 0 : _settings$l10n.shortcodes) !== null && _settings$l10n$shortc !== void 0 ? _settings$l10n$shortc : []; |
376 |
313 |
377 if (settings.shortcodes && settings.shortcodes.length) { |
314 if (settings.shortcodes && settings.shortcodes.length) { |
378 settings.shortcodesRegExp = new RegExp('\\[\\/?(?:' + settings.shortcodes.join('|') + ')[^\\]]*?\\]', 'g'); |
315 settings.shortcodesRegExp = new RegExp('\\[\\/?(?:' + settings.shortcodes.join('|') + ')[^\\]]*?\\]', 'g'); |
379 } |
316 } |
398 |
335 |
399 |
336 |
400 function countWords(text, regex, settings) { |
337 function countWords(text, regex, settings) { |
401 var _text$match$length, _text$match; |
338 var _text$match$length, _text$match; |
402 |
339 |
403 text = Object(external_lodash_["flow"])(stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), stripSpaces.bind(null, settings), stripHTMLEntities.bind(null, settings), stripConnectors.bind(null, settings), stripRemovables.bind(null, settings))(text); |
340 text = (0,external_lodash_namespaceObject.flow)(stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), stripSpaces.bind(null, settings), stripHTMLEntities.bind(null, settings), stripConnectors.bind(null, settings), stripRemovables.bind(null, settings))(text); |
404 text = text + '\n'; |
341 text = text + '\n'; |
405 return (_text$match$length = (_text$match = text.match(regex)) === null || _text$match === void 0 ? void 0 : _text$match.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0; |
342 return (_text$match$length = (_text$match = text.match(regex)) === null || _text$match === void 0 ? void 0 : _text$match.length) !== null && _text$match$length !== void 0 ? _text$match$length : 0; |
406 } |
343 } |
407 /** |
344 /** |
408 * Count the characters in text |
345 * Count the characters in text |
416 |
353 |
417 |
354 |
418 function countCharacters(text, regex, settings) { |
355 function countCharacters(text, regex, settings) { |
419 var _text$match$length2, _text$match2; |
356 var _text$match$length2, _text$match2; |
420 |
357 |
421 text = Object(external_lodash_["flow"])(stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), transposeAstralsToCountableChar.bind(null, settings), stripSpaces.bind(null, settings), transposeHTMLEntitiesToCountableChars.bind(null, settings))(text); |
358 text = (0,external_lodash_namespaceObject.flow)(stripTags.bind(null, settings), stripHTMLComments.bind(null, settings), stripShortcodes.bind(null, settings), transposeAstralsToCountableChar.bind(null, settings), stripSpaces.bind(null, settings), transposeHTMLEntitiesToCountableChars.bind(null, settings))(text); |
422 text = text + '\n'; |
359 text = text + '\n'; |
423 return (_text$match$length2 = (_text$match2 = text.match(regex)) === null || _text$match2 === void 0 ? void 0 : _text$match2.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0; |
360 return (_text$match$length2 = (_text$match2 = text.match(regex)) === null || _text$match2 === void 0 ? void 0 : _text$match2.length) !== null && _text$match$length2 !== void 0 ? _text$match$length2 : 0; |
424 } |
361 } |
425 /** |
362 /** |
426 * Count some words. |
363 * Count some words. |
459 default: |
396 default: |
460 return 0; |
397 return 0; |
461 } |
398 } |
462 } |
399 } |
463 |
400 |
464 |
401 (window.wp = window.wp || {}).wordcount = __webpack_exports__; |
465 /***/ }) |
402 /******/ })() |
466 |
403 ; |
467 /******/ }); |