@bigbinary/neeto-editor 1.43.28 → 1.43.29

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.
@@ -15118,34 +15118,38 @@ var addCopyToClipboardButton = function addCopyToClipboardButton(codeElement) {
15118
15118
  });
15119
15119
  codeElement.parentNode.appendChild(copyButton);
15120
15120
  };
15121
- function applyCodeblockDecorations(codeElement) {
15122
- var preElement = codeElement.closest("pre");
15123
- HighlightJS.highlightElement(codeElement);
15124
- addCopyToClipboardButton(codeElement);
15125
- var linesToHighlight = getHighlightedLines(preElement, codeElement);
15126
- var highlightLinesOptions = linesToHighlight.filter(function (line) {
15127
- return line > 0;
15128
- }).map(function (line) {
15129
- return {
15130
- start: line,
15131
- end: line,
15132
- color: "rgba(255, 255, 0, 0.2)"
15133
- };
15121
+ var applyDecorations = function applyDecorations() {
15122
+ document.querySelectorAll("pre code").forEach(function (codeElement) {
15123
+ var preElement = codeElement.closest("pre");
15124
+ HighlightJS.highlightElement(codeElement);
15125
+ addCopyToClipboardButton(codeElement);
15126
+ var linesToHighlight = getHighlightedLines(preElement, codeElement);
15127
+ var highlightLinesOptions = linesToHighlight.filter(function (line) {
15128
+ return line > 0;
15129
+ }).map(function (line) {
15130
+ return {
15131
+ start: line,
15132
+ end: line,
15133
+ color: "rgba(255, 255, 0, 0.2)"
15134
+ };
15135
+ });
15136
+ HighlightJS.highlightLinesElement(codeElement, highlightLinesOptions);
15134
15137
  });
15135
- HighlightJS.highlightLinesElement(codeElement, highlightLinesOptions);
15136
- }
15137
- var fetchHighlightLinesScript = function fetchHighlightLinesScript() {
15138
+ };
15139
+ var checkContextAndApplyDecorations = function checkContextAndApplyDecorations() {
15140
+ // Don't have to load the script if the `hljs.highlightLinesElement` is in the context.
15141
+ if (HighlightJS.highlightLinesElement) return applyDecorations();
15138
15142
  var script = document.createElement("script");
15139
15143
  script.src = highlightLinesScriptCDNPath;
15140
15144
  script.async = true;
15141
15145
  document.head.appendChild(script);
15142
- script.addEventListener("load", function () {
15143
- document.querySelectorAll("pre code").forEach(applyCodeblockDecorations);
15144
- });
15146
+ return script.addEventListener("load", applyDecorations);
15145
15147
  };
15146
- (function () {
15148
+ (function (_window$neetoEditor) {
15147
15149
  if (document.readyState === "loading") {
15148
- document.addEventListener("DOMContentLoaded", fetchHighlightLinesScript);
15149
- } else fetchHighlightLinesScript();
15150
+ document.addEventListener("DOMContentLoaded", checkContextAndApplyDecorations);
15151
+ } else checkContextAndApplyDecorations();
15152
+ window.neetoEditor = (_window$neetoEditor = window.neetoEditor) !== null && _window$neetoEditor !== void 0 ? _window$neetoEditor : {};
15153
+ window.neetoEditor.applyCodeblockDecorations = checkContextAndApplyDecorations;
15150
15154
  })();
15151
15155
  //# sourceMappingURL=codeBlockHighlight.js.map