jodit 4.12.37 → 4.12.39

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 (65) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +4 -4
  3. package/es2015/jodit.css +1 -1
  4. package/es2015/jodit.fat.min.js +4 -4
  5. package/es2015/jodit.js +69 -5
  6. package/es2015/jodit.min.js +5 -5
  7. package/es2015/plugins/debug/debug.css +1 -1
  8. package/es2015/plugins/debug/debug.js +1 -1
  9. package/es2015/plugins/debug/debug.min.js +1 -1
  10. package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
  11. package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
  12. package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
  13. package/es2018/jodit.fat.min.js +4 -4
  14. package/es2018/jodit.min.js +5 -5
  15. package/es2018/plugins/debug/debug.min.js +1 -1
  16. package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
  17. package/es2021/jodit.css +1 -1
  18. package/es2021/jodit.fat.min.js +6 -6
  19. package/es2021/jodit.js +69 -5
  20. package/es2021/jodit.min.js +7 -7
  21. package/es2021/plugins/debug/debug.css +1 -1
  22. package/es2021/plugins/debug/debug.js +1 -1
  23. package/es2021/plugins/debug/debug.min.js +1 -1
  24. package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
  25. package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
  26. package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
  27. package/es2021.en/jodit.css +1 -1
  28. package/es2021.en/jodit.fat.min.js +6 -6
  29. package/es2021.en/jodit.js +69 -5
  30. package/es2021.en/jodit.min.js +6 -6
  31. package/es2021.en/plugins/debug/debug.css +1 -1
  32. package/es2021.en/plugins/debug/debug.js +1 -1
  33. package/es2021.en/plugins/debug/debug.min.js +1 -1
  34. package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
  35. package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
  36. package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
  37. package/es5/jodit.css +2 -2
  38. package/es5/jodit.fat.min.js +2 -2
  39. package/es5/jodit.js +69 -5
  40. package/es5/jodit.min.css +2 -2
  41. package/es5/jodit.min.js +2 -2
  42. package/es5/plugins/debug/debug.css +1 -1
  43. package/es5/plugins/debug/debug.js +1 -1
  44. package/es5/plugins/debug/debug.min.js +1 -1
  45. package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
  46. package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
  47. package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
  48. package/es5/polyfills.fat.min.js +1 -1
  49. package/es5/polyfills.js +1 -1
  50. package/es5/polyfills.min.js +1 -1
  51. package/esm/config.d.ts +22 -0
  52. package/esm/config.js +14 -0
  53. package/esm/core/constants.js +1 -1
  54. package/esm/core/global.js +4 -0
  55. package/esm/core/helpers/utils/append-script.js +6 -0
  56. package/esm/core/helpers/utils/scroll-into-view.js +6 -2
  57. package/esm/plugins/fullsize/fullsize.js +11 -1
  58. package/esm/plugins/link/config.d.ts +8 -0
  59. package/esm/plugins/link/config.js +1 -0
  60. package/esm/plugins/link/link.js +30 -0
  61. package/esm/types/view.d.ts +6 -0
  62. package/package.json +1 -1
  63. package/types/config.d.ts +22 -0
  64. package/types/plugins/link/config.d.ts +8 -0
  65. package/types/types/view.d.ts +6 -0
package/es5/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.39
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
@@ -300,6 +300,19 @@ var ConfigPrototype = {};
300
300
  * editor.value = '<p>start</p>';
301
301
  * ```
302
302
  */ (0,_swc_helpers_define_property__WEBPACK_IMPORTED_MODULE_2__._)(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_2__._)(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.
@@ -2074,7 +2087,7 @@ __webpack_require__.r(__webpack_exports__);
2074
2087
  * @packageDocumentation
2075
2088
  * @module constants
2076
2089
  */
2077
- var APP_VERSION = "4.12.37";
2090
+ var APP_VERSION = "4.12.39";
2078
2091
  // prettier-ignore
2079
2092
  var ES = "es5";
2080
2093
  var IS_ES_MODERN = false;
@@ -5674,6 +5687,10 @@ var boxes = new WeakMap();
5674
5687
  var box = c.element(tag, {
5675
5688
  className: "jodit jodit-".concat((0,jodit_core_helpers_string_kebab_case__WEBPACK_IMPORTED_MODULE_3__.kebabCase)(name), "-container jodit-box")
5676
5689
  });
5690
+ // Let a strict CSP accept the injected <style>/<script> box
5691
+ if (view.o.nonce && (tag === 'style' || tag === 'script')) {
5692
+ box.setAttribute('nonce', view.o.nonce);
5693
+ }
5677
5694
  box.classList.add("jodit_theme_".concat(view.o.theme || 'default'));
5678
5695
  body.appendChild(box);
5679
5696
  data[key] = box;
@@ -8599,6 +8616,9 @@ var cacheLoaders = function cacheLoaders(loader) {
8599
8616
  async: true,
8600
8617
  src: (0,_complete_url__WEBPACK_IMPORTED_MODULE_1__.completeUrl)(url)
8601
8618
  });
8619
+ if (jodit.o.nonce) {
8620
+ script.setAttribute('nonce', jodit.o.nonce);
8621
+ }
8602
8622
  jodit.e.one(script, 'error', reject).one(script, 'load', resolve);
8603
8623
  jodit.od.body.appendChild(script);
8604
8624
  });
@@ -8614,6 +8634,9 @@ var cacheLoaders = function cacheLoaders(loader) {
8614
8634
  link.rel = 'stylesheet';
8615
8635
  link.media = 'all';
8616
8636
  link.crossOrigin = 'anonymous';
8637
+ if (jodit.o.nonce) {
8638
+ link.setAttribute('nonce', jodit.o.nonce);
8639
+ }
8617
8640
  var callback = function callback() {
8618
8641
  return resolve(link);
8619
8642
  };
@@ -10137,8 +10160,12 @@ var map = {};
10137
10160
  return false;
10138
10161
  }
10139
10162
  }
10140
- // Check it's within the document viewport
10141
- return top <= (doc.documentElement && doc.documentElement.clientHeight || 0);
10163
+ // Check it's within the document viewport: the element must not be below
10164
+ // the viewport bottom, and (its bottom) must not be above the viewport top —
10165
+ // the latter guard was missing, so an element scrolled above the top was
10166
+ // wrongly reported as visible and never scrolled to. See #1279
10167
+ var clientHeight = doc.documentElement && doc.documentElement.clientHeight || 0;
10168
+ return top <= clientHeight && top + height >= 0;
10142
10169
  }
10143
10170
  /**
10144
10171
  * Scroll element into view if it is not in view
@@ -37330,7 +37357,7 @@ var fullsizeStack = new Set();
37330
37357
  editor.registerButton({
37331
37358
  name: 'fullsize'
37332
37359
  });
37333
- var isEnabled = false, oldHeight = 0, oldWidth = 0, wasToggled = false;
37360
+ var isEnabled = false, oldHeight = 0, oldWidth = 0, savedScrollLeft = 0, savedScrollTop = 0, wasToggled = false;
37334
37361
  var resize = function resize() {
37335
37362
  var container = editor.container, events = editor.events;
37336
37363
  if (!events) {
@@ -37379,12 +37406,22 @@ var fullsizeStack = new Set();
37379
37406
  enable ? fullsizeStack.add(container) : fullsizeStack.delete(container);
37380
37407
  var shouldToggleGlobalFullsize = editor.o.globalFullSize && (fullsizeStack.size === 1 && enable || fullsizeStack.size === 0 && !enable);
37381
37408
  if (shouldToggleGlobalFullsize) {
37409
+ // Entering fullsize sets `position: fixed` on <html>, which
37410
+ // makes the browser reset the page scroll to the top. Remember
37411
+ // the scroll position so it can be restored on exit (#1255).
37412
+ if (enable) {
37413
+ savedScrollLeft = editor.ow.scrollX;
37414
+ savedScrollTop = editor.ow.scrollY;
37415
+ }
37382
37416
  var node = container.parentNode;
37383
37417
  while(node && node.nodeType !== Node.DOCUMENT_NODE && node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE){
37384
37418
  node.classList.toggle('jodit_fullsize-box_true', enable);
37385
37419
  node = node.parentNode;
37386
37420
  }
37387
37421
  resize();
37422
+ if (!enable) {
37423
+ editor.ow.scrollTo(savedScrollLeft, savedScrollTop);
37424
+ }
37388
37425
  }
37389
37426
  events.fire('afterResize');
37390
37427
  };
@@ -42266,6 +42303,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.link = {
42266
42303
  followOnDblClick: false,
42267
42304
  processVideoLink: true,
42268
42305
  processPastedLink: true,
42306
+ deriveUrlFromText: false,
42269
42307
  noFollowCheckbox: true,
42270
42308
  openInNewTabCheckbox: true,
42271
42309
  openInNewTabCheckboxDefaultChecked: false,
@@ -42505,6 +42543,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
42505
42543
  insert.textContent = i18n('Update');
42506
42544
  } else {
42507
42545
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_8__.Dom.hide(unlink);
42546
+ if (jodit.o.link.deriveUrlFromText && url_input && !isImageContent && !url_input.value.trim()) {
42547
+ url_input.value = guessUrlFromText(content_input.value);
42548
+ }
42508
42549
  if (openInNewTabCheckbox && target_checkbox) {
42509
42550
  target_checkbox.checked = openInNewTabCheckboxDefaultChecked;
42510
42551
  }
@@ -42634,6 +42675,29 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
42634
42675
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_7__.autobind
42635
42676
  ], link.prototype, "__onClickReadOnlyLink", null);
42636
42677
  jodit_core_global__WEBPACK_IMPORTED_MODULE_9__.pluginSystem.add('link', link);
42678
+ /**
42679
+ * Guess a usable `href` from the selected text for the link dialog.
42680
+ * Returns an empty string when the text is not a plausible URL/email,
42681
+ * so plain text (e.g. "click here") is left untouched.
42682
+ */ function guessUrlFromText(text) {
42683
+ var value = text.trim();
42684
+ if (!value || /\s/.test(value)) {
42685
+ return '';
42686
+ }
42687
+ // already an explicit scheme, an anchor or a relative path
42688
+ if (/^(https?:|mailto:|tel:|ftp:|#|\/|\.{1,2}\/)/i.test(value)) {
42689
+ return value;
42690
+ }
42691
+ // email address -> mailto:
42692
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
42693
+ return "mailto:".concat(value);
42694
+ }
42695
+ // bare domain like example.com or www.example.com/path -> https://
42696
+ if (/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(value)) {
42697
+ return "https://".concat(value);
42698
+ }
42699
+ return '';
42700
+ }
42637
42701
  function writeClasses(modeClassName, className_input, className_select, a) {
42638
42702
  if (modeClassName && (className_input !== null && className_input !== void 0 ? className_input : className_select)) {
42639
42703
  if (modeClassName === 'input') {
package/es5/jodit.min.css CHANGED
@@ -1,14 +1,14 @@
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.39
5
5
  * Url: https://xdsoft.net/jodit/
6
6
  * License(s): MIT
7
7
  */
8
8
  /*!
9
9
  * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
10
10
  * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
11
- * Version: v4.12.37
11
+ * Version: v4.12.39
12
12
  * Url: https://xdsoft.net/jodit/
13
13
  * License(s): MIT
14
14
  */