jedison 1.20.0 → 1.20.1

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.
@@ -2228,6 +2228,8 @@ class Editor {
2228
2228
  this.theme = this.instance.jedison.theme;
2229
2229
  this.markdownEnabled = getSchemaXOption(this.instance.schema, "parseMarkdown") ?? this.instance.jedison.getOption("parseMarkdown");
2230
2230
  this.purifyEnabled = getSchemaXOption(this.instance.schema, "purifyHtml") ?? this.instance.jedison.getOption("purifyHtml");
2231
+ this.markdownCache = /* @__PURE__ */ new Map();
2232
+ this.purifyCache = /* @__PURE__ */ new Map();
2231
2233
  }
2232
2234
  /**
2233
2235
  * Gets the JSON Pointer level by counting how many "/" it has
@@ -2462,7 +2464,13 @@ class Editor {
2462
2464
  */
2463
2465
  purifyContent(content, domPurifyOptions) {
2464
2466
  if (this.instance.jedison.getOption("purifyHtml") && typeof window !== "undefined" && window.DOMPurify) {
2465
- return window.DOMPurify.sanitize(content, domPurifyOptions);
2467
+ const cacheKey = JSON.stringify([content, domPurifyOptions]);
2468
+ if (this.purifyCache.has(cacheKey)) {
2469
+ return this.purifyCache.get(cacheKey);
2470
+ }
2471
+ const clean = window.DOMPurify.sanitize(content, domPurifyOptions);
2472
+ this.purifyCache.set(cacheKey, clean);
2473
+ return clean;
2466
2474
  } else {
2467
2475
  const tmp = document.createElement("div");
2468
2476
  tmp.innerHTML = content;
@@ -2470,7 +2478,12 @@ class Editor {
2470
2478
  }
2471
2479
  }
2472
2480
  getHtmlFromMarkdown(content) {
2473
- return window.marked.parse(content);
2481
+ if (this.markdownCache.has(content)) {
2482
+ return this.markdownCache.get(content);
2483
+ }
2484
+ const html = window.marked.parse(content);
2485
+ this.markdownCache.set(content, html);
2486
+ return html;
2474
2487
  }
2475
2488
  getTitle() {
2476
2489
  let titleFromSchema = false;