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/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.39
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.39";
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);
@@ -9031,8 +9054,12 @@ const map = {};
9031
9054
  return false;
9032
9055
  }
9033
9056
  }
9034
- // Check it's within the document viewport
9035
- return top <= (doc.documentElement && doc.documentElement.clientHeight || 0);
9057
+ // Check it's within the document viewport: the element must not be below
9058
+ // the viewport bottom, and (its bottom) must not be above the viewport top —
9059
+ // the latter guard was missing, so an element scrolled above the top was
9060
+ // wrongly reported as visible and never scrolled to. See #1279
9061
+ const clientHeight = doc.documentElement && doc.documentElement.clientHeight || 0;
9062
+ return top <= clientHeight && top + height >= 0;
9036
9063
  }
9037
9064
  /**
9038
9065
  * Scroll element into view if it is not in view
@@ -31370,7 +31397,7 @@ const fullsizeStack = new Set();
31370
31397
  editor.registerButton({
31371
31398
  name: 'fullsize'
31372
31399
  });
31373
- let isEnabled = false, oldHeight = 0, oldWidth = 0, wasToggled = false;
31400
+ let isEnabled = false, oldHeight = 0, oldWidth = 0, savedScrollLeft = 0, savedScrollTop = 0, wasToggled = false;
31374
31401
  const resize = ()=>{
31375
31402
  const { container, events } = editor;
31376
31403
  if (!events) {
@@ -31418,12 +31445,22 @@ const fullsizeStack = new Set();
31418
31445
  enable ? fullsizeStack.add(container) : fullsizeStack.delete(container);
31419
31446
  const shouldToggleGlobalFullsize = editor.o.globalFullSize && (fullsizeStack.size === 1 && enable || fullsizeStack.size === 0 && !enable);
31420
31447
  if (shouldToggleGlobalFullsize) {
31448
+ // Entering fullsize sets `position: fixed` on <html>, which
31449
+ // makes the browser reset the page scroll to the top. Remember
31450
+ // the scroll position so it can be restored on exit (#1255).
31451
+ if (enable) {
31452
+ savedScrollLeft = editor.ow.scrollX;
31453
+ savedScrollTop = editor.ow.scrollY;
31454
+ }
31421
31455
  let node = container.parentNode;
31422
31456
  while(node && node.nodeType !== Node.DOCUMENT_NODE && node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE){
31423
31457
  node.classList.toggle('jodit_fullsize-box_true', enable);
31424
31458
  node = node.parentNode;
31425
31459
  }
31426
31460
  resize();
31461
+ if (!enable) {
31462
+ editor.ow.scrollTo(savedScrollLeft, savedScrollTop);
31463
+ }
31427
31464
  }
31428
31465
  events.fire('afterResize');
31429
31466
  };
@@ -35595,6 +35632,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.link = {
35595
35632
  followOnDblClick: false,
35596
35633
  processVideoLink: true,
35597
35634
  processPastedLink: true,
35635
+ deriveUrlFromText: false,
35598
35636
  noFollowCheckbox: true,
35599
35637
  openInNewTabCheckbox: true,
35600
35638
  openInNewTabCheckboxDefaultChecked: false,
@@ -35794,6 +35832,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35794
35832
  insert.textContent = i18n('Update');
35795
35833
  } else {
35796
35834
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.hide(unlink);
35835
+ if (jodit.o.link.deriveUrlFromText && url_input && !isImageContent && !url_input.value.trim()) {
35836
+ url_input.value = guessUrlFromText(content_input.value);
35837
+ }
35797
35838
  if (openInNewTabCheckbox && target_checkbox) {
35798
35839
  target_checkbox.checked = openInNewTabCheckboxDefaultChecked;
35799
35840
  }
@@ -35920,6 +35961,29 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35920
35961
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
35921
35962
  ], link.prototype, "__onClickReadOnlyLink", null);
35922
35963
  jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('link', link);
35964
+ /**
35965
+ * Guess a usable `href` from the selected text for the link dialog.
35966
+ * Returns an empty string when the text is not a plausible URL/email,
35967
+ * so plain text (e.g. "click here") is left untouched.
35968
+ */ function guessUrlFromText(text) {
35969
+ const value = text.trim();
35970
+ if (!value || /\s/.test(value)) {
35971
+ return '';
35972
+ }
35973
+ // already an explicit scheme, an anchor or a relative path
35974
+ if (/^(https?:|mailto:|tel:|ftp:|#|\/|\.{1,2}\/)/i.test(value)) {
35975
+ return value;
35976
+ }
35977
+ // email address -> mailto:
35978
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
35979
+ return `mailto:${value}`;
35980
+ }
35981
+ // bare domain like example.com or www.example.com/path -> https://
35982
+ if (/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(value)) {
35983
+ return `https://${value}`;
35984
+ }
35985
+ return '';
35986
+ }
35923
35987
  function writeClasses(modeClassName, className_input, className_select, a) {
35924
35988
  if (modeClassName && (className_input ?? className_select)) {
35925
35989
  if (modeClassName === 'input') {