@bigbinary/neeto-editor 1.43.27 → 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.
@@ -15077,7 +15077,7 @@ var common = hljs;
15077
15077
  var HighlightJS = /*@__PURE__*/getDefaultExportFromCjs(common);
15078
15078
 
15079
15079
  /* eslint-disable @bigbinary/neeto/file-name-and-export-name-standards */
15080
- var highlightLinesScriptCDNPath = "//cdn.jsdelivr.net/gh/TRSasasusu/highlightjs-highlight-lines.js@1.2.0/highlightjs-highlight-lines.min.js";
15080
+ var highlightLinesScriptCDNPath = "https://cdn.jsdelivr.net/gh/TRSasasusu/highlightjs-highlight-lines.js@1.2.0/highlightjs-highlight-lines.min.js";
15081
15081
  var getHighlightedLines = function getHighlightedLines(preNode, codeNode) {
15082
15082
  var _preNode$getAttribute, _highlightedLines$spl, _highlightedLines$spl2;
15083
15083
  var highlightedLines = (_preNode$getAttribute = preNode === null || preNode === void 0 ? void 0 : preNode.getAttribute("data-highlighted-lines")) !== null && _preNode$getAttribute !== void 0 ? _preNode$getAttribute : codeNode === null || codeNode === void 0 ? void 0 : codeNode.getAttribute("data-highlighted-lines");
@@ -15118,29 +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
- document.addEventListener("DOMContentLoaded", function () {
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
- });
15145
- });
15146
+ return script.addEventListener("load", applyDecorations);
15147
+ };
15148
+ (function (_window$neetoEditor) {
15149
+ if (document.readyState === "loading") {
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;
15154
+ })();
15146
15155
  //# sourceMappingURL=codeBlockHighlight.js.map