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
@@ -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
@@ -30966,7 +30993,7 @@ const fullsizeStack = new Set();
30966
30993
  editor.registerButton({
30967
30994
  name: 'fullsize'
30968
30995
  });
30969
- let isEnabled = false, oldHeight = 0, oldWidth = 0, wasToggled = false;
30996
+ let isEnabled = false, oldHeight = 0, oldWidth = 0, savedScrollLeft = 0, savedScrollTop = 0, wasToggled = false;
30970
30997
  const resize = ()=>{
30971
30998
  const { container, events } = editor;
30972
30999
  if (!events) {
@@ -31014,12 +31041,22 @@ const fullsizeStack = new Set();
31014
31041
  enable ? fullsizeStack.add(container) : fullsizeStack.delete(container);
31015
31042
  const shouldToggleGlobalFullsize = editor.o.globalFullSize && (fullsizeStack.size === 1 && enable || fullsizeStack.size === 0 && !enable);
31016
31043
  if (shouldToggleGlobalFullsize) {
31044
+ // Entering fullsize sets `position: fixed` on <html>, which
31045
+ // makes the browser reset the page scroll to the top. Remember
31046
+ // the scroll position so it can be restored on exit (#1255).
31047
+ if (enable) {
31048
+ savedScrollLeft = editor.ow.scrollX;
31049
+ savedScrollTop = editor.ow.scrollY;
31050
+ }
31017
31051
  let node = container.parentNode;
31018
31052
  while(node && node.nodeType !== Node.DOCUMENT_NODE && node.nodeType !== Node.DOCUMENT_FRAGMENT_NODE){
31019
31053
  node.classList.toggle('jodit_fullsize-box_true', enable);
31020
31054
  node = node.parentNode;
31021
31055
  }
31022
31056
  resize();
31057
+ if (!enable) {
31058
+ editor.ow.scrollTo(savedScrollLeft, savedScrollTop);
31059
+ }
31023
31060
  }
31024
31061
  events.fire('afterResize');
31025
31062
  };
@@ -34841,6 +34878,7 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.link = {
34841
34878
  followOnDblClick: false,
34842
34879
  processVideoLink: true,
34843
34880
  processPastedLink: true,
34881
+ deriveUrlFromText: false,
34844
34882
  noFollowCheckbox: true,
34845
34883
  openInNewTabCheckbox: true,
34846
34884
  openInNewTabCheckboxDefaultChecked: false,
@@ -35040,6 +35078,9 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35040
35078
  insert.textContent = i18n('Update');
35041
35079
  } else {
35042
35080
  jodit_core_dom__WEBPACK_IMPORTED_MODULE_3__.Dom.hide(unlink);
35081
+ if (jodit.o.link.deriveUrlFromText && url_input && !isImageContent && !url_input.value.trim()) {
35082
+ url_input.value = guessUrlFromText(content_input.value);
35083
+ }
35043
35084
  if (openInNewTabCheckbox && target_checkbox) {
35044
35085
  target_checkbox.checked = openInNewTabCheckboxDefaultChecked;
35045
35086
  }
@@ -35166,6 +35207,29 @@ jodit_config__WEBPACK_IMPORTED_MODULE_2__.Config.prototype.controls.link = {
35166
35207
  jodit_core_decorators__WEBPACK_IMPORTED_MODULE_2__.autobind
35167
35208
  ], link.prototype, "__onClickReadOnlyLink", null);
35168
35209
  jodit_core_global__WEBPACK_IMPORTED_MODULE_4__.pluginSystem.add('link', link);
35210
+ /**
35211
+ * Guess a usable `href` from the selected text for the link dialog.
35212
+ * Returns an empty string when the text is not a plausible URL/email,
35213
+ * so plain text (e.g. "click here") is left untouched.
35214
+ */ function guessUrlFromText(text) {
35215
+ const value = text.trim();
35216
+ if (!value || /\s/.test(value)) {
35217
+ return '';
35218
+ }
35219
+ // already an explicit scheme, an anchor or a relative path
35220
+ if (/^(https?:|mailto:|tel:|ftp:|#|\/|\.{1,2}\/)/i.test(value)) {
35221
+ return value;
35222
+ }
35223
+ // email address -> mailto:
35224
+ if (/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
35225
+ return `mailto:${value}`;
35226
+ }
35227
+ // bare domain like example.com or www.example.com/path -> https://
35228
+ if (/^[a-z0-9-]+(\.[a-z0-9-]+)+(\/\S*)?$/i.test(value)) {
35229
+ return `https://${value}`;
35230
+ }
35231
+ return '';
35232
+ }
35169
35233
  function writeClasses(modeClassName, className_input, className_select, a) {
35170
35234
  if (modeClassName && (className_input ?? className_select)) {
35171
35235
  if (modeClassName === 'input') {