jodit-pro-react 5.5.37 → 5.5.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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  JoditEditor_default
3
- } from "./chunk-BUSY7HMW.mjs";
3
+ } from "./chunk-HUTDB76G.mjs";
4
4
  export {
5
5
  JoditEditor_default as default
6
6
  };
@@ -193,7 +193,7 @@ var APP_VERSION, ES, IS_ES_MODERN, IS_ES_NEXT, IS_PROD, IS_TEST, FAT_MODE, HOMEP
193
193
  var init_constants = __esm({
194
194
  "node_modules/jodit/esm/core/constants.js"() {
195
195
  "use strict";
196
- APP_VERSION = "4.12.18";
196
+ APP_VERSION = "4.12.21";
197
197
  ES = "es2020";
198
198
  IS_ES_MODERN = true;
199
199
  IS_ES_NEXT = true;
@@ -3326,6 +3326,11 @@ function applyStyles(html) {
3326
3326
  iframeDoc.open();
3327
3327
  iframeDoc.write(html);
3328
3328
  iframeDoc.close();
3329
+ Dom.each(iframeDoc.body, (node) => {
3330
+ if (Dom.isElement(node) && /mso-list:\s*ignore/i.test(node.getAttribute("style") || "")) {
3331
+ Dom.safeRemove(node);
3332
+ }
3333
+ });
3329
3334
  try {
3330
3335
  for (let i53 = 0; i53 < iframeDoc.styleSheets.length; i53 += 1) {
3331
3336
  const rules = iframeDoc.styleSheets[i53].cssRules;
@@ -3407,6 +3412,10 @@ function cleanFromWord(html) {
3407
3412
  Dom.unwrap(node);
3408
3413
  break;
3409
3414
  default:
3415
+ if (/mso-list:\s*ignore/i.test(node.getAttribute("style") || "")) {
3416
+ marks.push(node);
3417
+ break;
3418
+ }
3410
3419
  toArray(node.attributes).forEach((attr2) => {
3411
3420
  if ([
3412
3421
  "src",
@@ -3976,7 +3985,6 @@ var init_convert_media_url_to_video_embed = __esm({
3976
3985
  return url2;
3977
3986
  }
3978
3987
  const parser = globalDocument.createElement("a");
3979
- const pattern1 = /(?:http?s?:\/\/)?(?:www\.)?(?:vimeo\.com)\/?(.+)/g;
3980
3988
  parser.href = url2;
3981
3989
  if (!width) {
3982
3990
  width = 400;
@@ -3987,17 +3995,29 @@ var init_convert_media_url_to_video_embed = __esm({
3987
3995
  const protocol = parser.protocol || "";
3988
3996
  switch (parser.hostname) {
3989
3997
  case "www.vimeo.com":
3990
- case "vimeo.com":
3991
- return pattern1.test(url2) ? url2.replace(pattern1, '<iframe width="' + width + '" height="' + height + '" src="' + protocol + '//player.vimeo.com/video/$1" frameborder="0" allowfullscreen></iframe>') : url2;
3998
+ case "vimeo.com": {
3999
+ const segments = parser.pathname.split("/").filter(Boolean);
4000
+ const idIndex = segments.findIndex((s48) => /^\d+$/.test(s48));
4001
+ if (idIndex === -1) {
4002
+ return url2;
4003
+ }
4004
+ let path = segments[idIndex];
4005
+ const hash = segments[idIndex + 1];
4006
+ if (hash && idIndex === 0) {
4007
+ path += "/" + hash;
4008
+ }
4009
+ return '<iframe width="' + width + '" height="' + height + '" src="' + protocol + "//player.vimeo.com/video/" + path + '" frameborder="0" allowfullscreen></iframe>';
4010
+ }
3992
4011
  case "youtube.com":
3993
4012
  case "www.youtube.com":
4013
+ case "m.youtube.com":
4014
+ case "music.youtube.com":
3994
4015
  case "youtu.be":
3995
4016
  case "www.youtu.be": {
3996
- const query = parser.search ? parseQuery(parser.search) : { v: parser.pathname.substring(1) };
3997
- if (/^embed\/.*/.test(query.v)) {
3998
- query.v = query.v.substring(6);
3999
- }
4000
- return query.v ? '<iframe width="' + width + '" height="' + height + '" src="' + protocol + "//www.youtube.com/embed/" + query.v + '" frameborder="0" allowfullscreen></iframe>' : url2;
4017
+ const query = parser.search ? parseQuery(parser.search) : {};
4018
+ let v18 = query.v || parser.pathname.substring(1);
4019
+ v18 = v18.replace(/^(watch|embed|shorts|live|v)\//, "").replace(/\/$/, "");
4020
+ return v18 ? '<iframe width="' + width + '" height="' + height + '" src="' + protocol + "//www.youtube.com/embed/" + v18 + '" frameborder="0" allowfullscreen></iframe>' : url2;
4001
4021
  }
4002
4022
  }
4003
4023
  return url2;
@@ -4358,20 +4378,16 @@ function safeHTML(box, options2) {
4358
4378
  return;
4359
4379
  }
4360
4380
  const removeEvents = (_a2 = options2.removeEventAttributes) !== null && _a2 !== void 0 ? _a2 : options2.removeOnError;
4361
- if (removeEvents) {
4362
- removeAllEventAttributes(box);
4363
- $$("*", box).forEach((elm) => removeAllEventAttributes(elm));
4364
- } else if (options2.removeOnError) {
4365
- sanitizeHTMLElement(box, options2);
4366
- $$("[onerror]", box).forEach((elm) => sanitizeHTMLElement(elm, options2));
4367
- }
4368
- if (options2.safeJavaScriptLink) {
4369
- sanitizeHTMLElement(box, options2);
4370
- $$('a[href^="javascript"]', box).forEach((elm) => sanitizeHTMLElement(elm, options2));
4371
- }
4372
- if (options2.safeLinksTarget) {
4373
- $$('a[target="_blank"]', box).forEach((elm) => {
4374
- const rel = elm.getAttribute("rel") || "";
4381
+ const process2 = (node) => {
4382
+ if (!Dom.isElement(node)) {
4383
+ return;
4384
+ }
4385
+ if (removeEvents) {
4386
+ removeAllEventAttributes(node);
4387
+ }
4388
+ sanitizeHTMLElement(node, options2);
4389
+ if (options2.safeLinksTarget && node.nodeName === "A" && node.getAttribute("target") === "_blank") {
4390
+ const rel = node.getAttribute("rel") || "";
4375
4391
  const parts = rel.split(/\s+/).filter(Boolean);
4376
4392
  if (!parts.includes("noopener")) {
4377
4393
  parts.push("noopener");
@@ -4379,9 +4395,11 @@ function safeHTML(box, options2) {
4379
4395
  if (!parts.includes("noreferrer")) {
4380
4396
  parts.push("noreferrer");
4381
4397
  }
4382
- attr(elm, "rel", parts.join(" "));
4383
- });
4384
- }
4398
+ attr(node, "rel", parts.join(" "));
4399
+ }
4400
+ };
4401
+ process2(box);
4402
+ Dom.each(box, process2);
4385
4403
  }
4386
4404
  function removeAllEventAttributes(elm) {
4387
4405
  if (!Dom.isElement(elm)) {
@@ -4400,6 +4418,16 @@ function removeAllEventAttributes(elm) {
4400
4418
  }
4401
4419
  return effected;
4402
4420
  }
4421
+ function isDangerousUrl(value, tagName) {
4422
+ const normalized = value.replace(/[\u0000-\u0020]+/g, "").toLowerCase();
4423
+ if (/^(?:javascript|vbscript|livescript|mocha):/.test(normalized)) {
4424
+ return true;
4425
+ }
4426
+ if (/^data:(?:text\/html|application\/xhtml)/.test(normalized)) {
4427
+ return true;
4428
+ }
4429
+ return /^data:image\/svg/.test(normalized) && DOCUMENT_EMBED_TAGS.has(tagName);
4430
+ }
4403
4431
  function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError } = {
4404
4432
  safeJavaScriptLink: true,
4405
4433
  removeOnError: true
@@ -4417,18 +4445,43 @@ function sanitizeHTMLElement(elm, { safeJavaScriptLink, removeOnError } = {
4417
4445
  attr(elm, "href", location.protocol + "//" + href);
4418
4446
  effected = true;
4419
4447
  }
4448
+ if (safeJavaScriptLink) {
4449
+ if (elm.hasAttribute("srcdoc")) {
4450
+ attr(elm, "srcdoc", null);
4451
+ effected = true;
4452
+ }
4453
+ const tagName = elm.nodeName.toLowerCase();
4454
+ for (const name of URL_ATTRIBUTES) {
4455
+ const value = elm.getAttribute(name);
4456
+ if (value && isDangerousUrl(value, tagName)) {
4457
+ attr(elm, name, null);
4458
+ effected = true;
4459
+ }
4460
+ }
4461
+ }
4420
4462
  return effected;
4421
4463
  }
4464
+ var URL_ATTRIBUTES, DOCUMENT_EMBED_TAGS;
4422
4465
  var init_safe_html = __esm({
4423
4466
  "node_modules/jodit/esm/core/helpers/html/safe-html.js"() {
4424
4467
  "use strict";
4425
4468
  init_dom();
4426
4469
  init_utils3();
4470
+ URL_ATTRIBUTES = [
4471
+ "src",
4472
+ "data",
4473
+ "action",
4474
+ "formaction",
4475
+ "poster",
4476
+ "background",
4477
+ "xlink:href"
4478
+ ];
4479
+ DOCUMENT_EMBED_TAGS = /* @__PURE__ */ new Set(["iframe", "frame", "object", "embed"]);
4427
4480
  }
4428
4481
  });
4429
4482
 
4430
4483
  // node_modules/jodit/esm/core/helpers/html/strip-tags.js
4431
- function stripTags(html, doc = document, exclude = null) {
4484
+ function stripTags(html, doc = document, exclude = null, blockBr = false) {
4432
4485
  const tmp = doc.createElement("div");
4433
4486
  if (isString(html)) {
4434
4487
  tmp.innerHTML = html;
@@ -4442,7 +4495,7 @@ function stripTags(html, doc = document, exclude = null) {
4442
4495
  }
4443
4496
  if (exclude && Dom.isTag(p62, exclude)) {
4444
4497
  const tag = p62.nodeName.toLowerCase();
4445
- const text = !Dom.isTag(p62, ALONE_TAGS) ? `%%%jodit-${tag}%%%${stripTags(p62.innerHTML, doc, exclude)}%%%/jodit-${tag}%%%` : `%%%jodit-single-${tag}%%%`;
4498
+ const text = !Dom.isTag(p62, ALONE_TAGS) ? `%%%jodit-${tag}%%%${stripTags(p62.innerHTML, doc, exclude, blockBr)}%%%/jodit-${tag}%%%` : `%%%jodit-single-${tag}%%%`;
4446
4499
  Dom.before(p62, doc.createTextNode(text));
4447
4500
  Dom.safeRemove(p62);
4448
4501
  return;
@@ -4459,7 +4512,7 @@ function stripTags(html, doc = document, exclude = null) {
4459
4512
  return;
4460
4513
  }
4461
4514
  if (nx) {
4462
- pr.insertBefore(doc.createTextNode(" "), nx);
4515
+ pr.insertBefore(doc.createTextNode(blockBr ? "%%%jodit-single-br%%%" : " "), nx);
4463
4516
  }
4464
4517
  });
4465
4518
  return restoreTags(trim(tmp.innerText));
@@ -16633,7 +16686,17 @@ Config.prototype.enableDragAndDropFileToEditor = true;
16633
16686
  Config.prototype.uploader = {
16634
16687
  url: "",
16635
16688
  insertImageAsBase64URI: false,
16636
- imagesExtensions: ["jpg", "png", "jpeg", "gif"],
16689
+ imagesExtensions: [
16690
+ "jpg",
16691
+ "jpeg",
16692
+ "png",
16693
+ "gif",
16694
+ "webp",
16695
+ "bmp",
16696
+ "svg",
16697
+ "tiff",
16698
+ "avif"
16699
+ ],
16637
16700
  headers: null,
16638
16701
  data: null,
16639
16702
  filesVariableName(i53) {
@@ -20792,8 +20855,9 @@ Config.prototype.controls.brush = {
20792
20855
  const update = (key3, value) => {
20793
20856
  if (value && value !== css(editor.editor, key3).toString()) {
20794
20857
  button.state.icon.fill = value;
20795
- return;
20858
+ return true;
20796
20859
  }
20860
+ return false;
20797
20861
  };
20798
20862
  if (color2) {
20799
20863
  const mode = dataBind(button, "color");
@@ -20803,8 +20867,11 @@ Config.prototype.controls.brush = {
20803
20867
  const current = editor.s.current();
20804
20868
  if (current && !button.state.disabled) {
20805
20869
  const currentBpx = Dom.closest(current, Dom.isElement, editor.editor) || editor.editor;
20806
- update("color", css(currentBpx, "color").toString());
20807
- update("background-color", css(currentBpx, "background-color").toString());
20870
+ const hasColor = update("color", css(currentBpx, "color").toString());
20871
+ const hasBackground = update("background-color", css(currentBpx, "background-color").toString());
20872
+ if (hasColor || hasBackground) {
20873
+ return;
20874
+ }
20808
20875
  }
20809
20876
  button.state.icon.fill = "";
20810
20877
  button.state.activated = false;
@@ -22259,7 +22326,7 @@ init_config();
22259
22326
  Config.prototype.commandToHotkeys = {
22260
22327
  removeFormat: ["ctrl+shift+m", "cmd+shift+m"],
22261
22328
  insertOrderedList: ["ctrl+shift+7", "cmd+shift+7"],
22262
- insertUnorderedList: ["ctrl+shift+8, cmd+shift+8"],
22329
+ insertUnorderedList: ["ctrl+shift+8", "cmd+shift+8"],
22263
22330
  selectall: ["ctrl+a", "cmd+a"]
22264
22331
  };
22265
22332
 
@@ -23889,14 +23956,25 @@ Config.prototype.controls.indent = {
23889
23956
  };
23890
23957
  Config.prototype.controls.outdent = {
23891
23958
  isDisabled: (editor) => {
23959
+ var _a2;
23892
23960
  const current = editor.s.current();
23893
- if (current) {
23894
- const currentBox = Dom.closest(current, Dom.isBlock, editor.editor);
23895
- if (currentBox) {
23896
- const arrow = getKey(editor.o.direction, currentBox);
23897
- return !currentBox.style[arrow] || parseInt(currentBox.style[arrow], 10) <= 0;
23961
+ if (!current) {
23962
+ return true;
23963
+ }
23964
+ if ((_a2 = editor.o.tab) === null || _a2 === void 0 ? void 0 : _a2.tabInsideLiInsertNewList) {
23965
+ const li = Dom.closest(current, "li", editor.editor);
23966
+ if (li) {
23967
+ const list = Dom.closest(li, ["ul", "ol"], editor.editor);
23968
+ if (list && Dom.closest(list, "li", editor.editor)) {
23969
+ return false;
23970
+ }
23898
23971
  }
23899
23972
  }
23973
+ const currentBox = Dom.closest(current, Dom.isBlock, editor.editor);
23974
+ if (currentBox) {
23975
+ const arrow = getKey(editor.o.direction, currentBox);
23976
+ return !currentBox.style[arrow] || parseInt(currentBox.style[arrow], 10) <= 0;
23977
+ }
23900
23978
  return true;
23901
23979
  },
23902
23980
  tooltip: "Decrease Indent"
@@ -26147,10 +26225,13 @@ var paste = class extends Plugin {
26147
26225
  html = cleanFromWord(html);
26148
26226
  break;
26149
26227
  case INSERT_ONLY_TEXT:
26150
- html = stripTags(html, this.j.ed, new Set(this.j.o.pasteExcludeStripTags));
26228
+ html = stripTags(html, this.j.ed, new Set(this.j.o.pasteExcludeStripTags), this.j.o.nl2brInPlainText);
26151
26229
  break;
26152
26230
  case INSERT_AS_TEXT:
26153
26231
  html = htmlspecialchars(html);
26232
+ if (this.j.o.nl2brInPlainText) {
26233
+ html = nl2br(html);
26234
+ }
26154
26235
  break;
26155
26236
  default: {
26156
26237
  const newHTML = this.j.e.fire("onCustomPasteHTMLOption", action, html, e42);
@@ -26250,7 +26331,7 @@ var pasteFromWord = class extends Plugin {
26250
26331
  break;
26251
26332
  }
26252
26333
  case INSERT_ONLY_TEXT: {
26253
- html = stripTags(cleanFromWord(html));
26334
+ html = stripTags(cleanFromWord(html), this.j.ed, new Set(this.j.o.pasteExcludeStripTags), this.j.o.nl2brInPlainText);
26254
26335
  break;
26255
26336
  }
26256
26337
  }
@@ -33088,6 +33169,17 @@ var Jodit2 = Jodit_1 = class Jodit3 extends ViewWithToolbar {
33088
33169
  }
33089
33170
  this.synchronizeValues();
33090
33171
  }
33172
+ }).on(this.ow, "mouseup", (event) => {
33173
+ if (this.o.readonly || this.__isSilentChange) {
33174
+ return;
33175
+ }
33176
+ const target = event.target;
33177
+ const insideEditor = Boolean(target && isNumber(target.nodeType) && editor.contains(target));
33178
+ if (insideEditor || !this.s.isInsideArea) {
33179
+ return;
33180
+ }
33181
+ this.e.fire("changeSelection");
33182
+ this.synchronizeValues();
33091
33183
  });
33092
33184
  }
33093
33185
  fetch(url2, options2) {
@@ -2,7 +2,7 @@ import {
2
2
  Config,
3
3
  JoditEditor_default,
4
4
  n
5
- } from "./chunk-BUSY7HMW.mjs";
5
+ } from "./chunk-HUTDB76G.mjs";
6
6
 
7
7
  // src/index.ts
8
8
  var index_default = JoditEditor_default;