jodit 4.12.37 → 4.12.38

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 (62) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/es2015/jodit.css +1 -1
  3. package/es2015/jodit.fat.min.js +3 -3
  4. package/es2015/jodit.js +52 -2
  5. package/es2015/jodit.min.js +5 -5
  6. package/es2015/plugins/debug/debug.css +1 -1
  7. package/es2015/plugins/debug/debug.js +1 -1
  8. package/es2015/plugins/debug/debug.min.js +1 -1
  9. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  12. package/es2018/jodit.fat.min.js +3 -3
  13. package/es2018/jodit.min.js +5 -5
  14. package/es2018/plugins/debug/debug.min.js +1 -1
  15. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  16. package/es2021/jodit.css +1 -1
  17. package/es2021/jodit.fat.min.js +5 -5
  18. package/es2021/jodit.js +52 -2
  19. package/es2021/jodit.min.js +7 -7
  20. package/es2021/plugins/debug/debug.css +1 -1
  21. package/es2021/plugins/debug/debug.js +1 -1
  22. package/es2021/plugins/debug/debug.min.js +1 -1
  23. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  26. package/es2021.en/jodit.css +1 -1
  27. package/es2021.en/jodit.fat.min.js +5 -5
  28. package/es2021.en/jodit.js +52 -2
  29. package/es2021.en/jodit.min.js +5 -5
  30. package/es2021.en/plugins/debug/debug.css +1 -1
  31. package/es2021.en/plugins/debug/debug.js +1 -1
  32. package/es2021.en/plugins/debug/debug.min.js +1 -1
  33. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  36. package/es5/jodit.css +2 -2
  37. package/es5/jodit.fat.min.js +2 -2
  38. package/es5/jodit.js +52 -2
  39. package/es5/jodit.min.css +2 -2
  40. package/es5/jodit.min.js +2 -2
  41. package/es5/plugins/debug/debug.css +1 -1
  42. package/es5/plugins/debug/debug.js +1 -1
  43. package/es5/plugins/debug/debug.min.js +1 -1
  44. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  47. package/es5/polyfills.fat.min.js +1 -1
  48. package/es5/polyfills.js +1 -1
  49. package/es5/polyfills.min.js +1 -1
  50. package/esm/config.d.ts +22 -0
  51. package/esm/config.js +14 -0
  52. package/esm/core/constants.js +1 -1
  53. package/esm/core/global.js +4 -0
  54. package/esm/core/helpers/utils/append-script.js +6 -0
  55. package/esm/plugins/link/config.d.ts +8 -0
  56. package/esm/plugins/link/config.js +1 -0
  57. package/esm/plugins/link/link.js +30 -0
  58. package/esm/types/view.d.ts +6 -0
  59. package/package.json +1 -1
  60. package/types/config.d.ts +22 -0
  61. package/types/plugins/link/config.d.ts +8 -0
  62. package/types/types/view.d.ts +6 -0
package/es2021/jodit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
3
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
- * Version: v4.12.37
4
+ * Version: v4.12.38
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -300,6 +300,19 @@ let ConfigPrototype = {};
300
300
  * editor.value = '<p>start</p>';
301
301
  * ```
302
302
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "shadowRoot", null);
303
+ /**
304
+ * CSP nonce applied to every `<style>`, `<script>` and `<link>` element
305
+ * Jodit injects at runtime (plugin styles, CDN scripts for ACE/beautify,
306
+ * downloaded stylesheets). Set it to the same nonce your server puts in the
307
+ * `Content-Security-Policy` header so a strict `style-src`/`script-src`
308
+ * policy does not block the editor.
309
+ *
310
+ * ```js
311
+ * Jodit.make('#editor', {
312
+ * nonce: 'r4nd0m'
313
+ * });
314
+ * ```
315
+ */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_0__._)(this, "nonce", '');
303
316
  /**
304
317
  * Base CSS `z-index` for the editor UI (toolbar, popups, dialogs).
305
318
  * Set to a higher value when other page elements overlap the editor.
@@ -1810,7 +1823,7 @@ __webpack_require__.r(__webpack_exports__);
1810
1823
  * ```
1811
1824
  * @packageDocumentation
1812
1825
  * @module constants
1813
- */ const APP_VERSION = "4.12.37";
1826
+ */ const APP_VERSION = "4.12.38";
1814
1827
  // prettier-ignore
1815
1828
  const ES = "es2021";
1816
1829
  const IS_ES_MODERN = true;
@@ -4758,6 +4771,10 @@ const boxes = new WeakMap();
4758
4771
  const box = c.element(tag, {
4759
4772
  className: `jodit jodit-${(0,jodit_core_helpers_string_kebab_case__WEBPACK_IMPORTED_MODULE_3__.kebabCase)(name)}-container jodit-box`
4760
4773
  });
4774
+ // Let a strict CSP accept the injected <style>/<script> box
4775
+ if (view.o.nonce && (tag === 'style' || tag === 'script')) {
4776
+ box.setAttribute('nonce', view.o.nonce);
4777
+ }
4761
4778
  box.classList.add(`jodit_theme_${view.o.theme || 'default'}`);
4762
4779
  body.appendChild(box);
4763
4780
  data[key] = box;
@@ -7576,6 +7593,9 @@ const cacheLoaders = (loader)=>{
7576
7593
  async: true,
7577
7594
  src: (0,_complete_url__WEBPACK_IMPORTED_MODULE_1__.completeUrl)(url)
7578
7595
  });
7596
+ if (jodit.o.nonce) {
7597
+ script.setAttribute('nonce', jodit.o.nonce);
7598
+ }
7579
7599
  jodit.e.one(script, 'error', reject).one(script, 'load', resolve);
7580
7600
  jodit.od.body.appendChild(script);
7581
7601
  });
@@ -7591,6 +7611,9 @@ const cacheLoaders = (loader)=>{
7591
7611
  link.rel = 'stylesheet';
7592
7612
  link.media = 'all';
7593
7613
  link.crossOrigin = 'anonymous';
7614
+ if (jodit.o.nonce) {
7615
+ link.setAttribute('nonce', jodit.o.nonce);
7616
+ }
7594
7617
  const callback = ()=>resolve(link);
7595
7618
  !jodit.isInDestruct && jodit.e.on(link, 'load', callback).on(link, 'error', reject);
7596
7619
  link.href = (0,_complete_url__WEBPACK_IMPORTED_MODULE_1__.completeUrl)(url);
@@ -35595,6 +35618,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.link = {
35595
35618
  followOnDblClick: false,
35596
35619
  processVideoLink: true,
35597
35620
  processPastedLink: true,
35621
+ deriveUrlFromText: false,
35598
35622
  noFollowCheckbox: true,
35599
35623
  openInNewTabCheckbox: true,
35600
35624
  openInNewTabCheckboxDefaultChecked: false,
@@ -35794,6 +35818,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35794
35818
  insert.textContent = i18n('Update');
35795
35819
  } else {
35796
35820
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.hide(unlink);
35821
+ if (jodit.o.link.deriveUrlFromText && url_input && !isImageContent && !url_input.value.trim()) {
35822
+ url_input.value = guessUrlFromText(content_input.value);
35823
+ }
35797
35824
  if (openInNewTabCheckbox && target_checkbox) {
35798
35825
  target_checkbox.checked = openInNewTabCheckboxDefaultChecked;
35799
35826
  }
@@ -35920,6 +35947,29 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35920
35947
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
35921
35948
  ], link.prototype, "__onClickReadOnlyLink", null);
35922
35949
  jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('link', link);
35950
+ /**
35951
+ * Guess a usable `href` from the selected text for the link dialog.
35952
+ * Returns an empty string when the text is not a plausible URL/email,
35953
+ * so plain text (e.g. "click here") is left untouched.
35954
+ */ function guessUrlFromText(text) {
35955
+ const value = text.trim();
35956
+ if (!value || /\s/.test(value)) {
35957
+ return '';
35958
+ }
35959
+ // already an explicit scheme, an anchor or a relative path
35960
+ if (/^(https?:|mailto:|tel:|ftp:|#|\/|\.{1,2}\/)/i.test(value)) {
35961
+ return value;
35962
+ }
35963
+ // email address -> mailto:
35964
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
35965
+ return `mailto:${value}`;
35966
+ }
35967
+ // bare domain like example.com or www.example.com/path -> https://
35968
+ if (/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(value)) {
35969
+ return `https://${value}`;
35970
+ }
35971
+ return '';
35972
+ }
35923
35973
  function writeClasses(modeClassName, className_input, className_select, a) {
35924
35974
  if (modeClassName && (className_input ?? className_select)) {
35925
35975
  if (modeClassName === 'input') {