From f5660076281db9845207849969977516956700e1 Mon Sep 17 00:00:00 2001 From: AKinnander44 <149686770+AntonKinnander@users.noreply.github.com> Date: Mon, 23 Mar 2026 16:00:59 +0100 Subject: [PATCH 1/2] Update big window + markdown Also sorry i hardcoded the background color because i was lazy but feel free to use any ot this in the main project --- dist/EnhanceCodeBlocks.plugin.js | 2504 +++++++++++++++++++++++------- 1 file changed, 1905 insertions(+), 599 deletions(-) diff --git a/dist/EnhanceCodeBlocks.plugin.js b/dist/EnhanceCodeBlocks.plugin.js index 5198e68..ee741dc 100644 --- a/dist/EnhanceCodeBlocks.plugin.js +++ b/dist/EnhanceCodeBlocks.plugin.js @@ -9,35 +9,57 @@ var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; -var __esm = (fn, res) => function() { - return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; -}; -var __commonJS = (cb, mod) => function() { - return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; -}; +var __getProtoOf = Object.getPrototypeOf, + __hasOwnProp = Object.prototype.hasOwnProperty; +var __esm = (fn, res) => + function () { + return (fn && (res = (0, fn[__getOwnPropNames(fn)[0]])((fn = 0))), res); + }; +var __commonJS = (cb, mod) => + function () { + return ( + mod || + (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), + mod.exports + ); + }; var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: !0 }); -}, __copyProps = (to, from, except, desc) => { - if (from && typeof from == "object" || typeof from == "function") - for (let key of __getOwnPropNames(from)) - !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, - mod -)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: !0 }); + }, + __copyProps = (to, from, except, desc) => { + if ((from && typeof from == "object") || typeof from == "function") + for (let key of __getOwnPropNames(from)) + !__hasOwnProp.call(to, key) && + key !== except && + __defProp(to, key, { + get: () => from[key], + enumerable: + !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, + }); + return to; + }; +var __toESM = (mod, isNodeMode, target) => ( + (target = mod != null ? __create(__getProtoOf(mod)) : {}), + __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule + ? __defProp(target, "default", { value: mod, enumerable: !0 }) + : target, + mod, + ) + ), + __toCommonJS = (mod) => + __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); // shim-@plugin/css:@plugin/css -var css_default, init_css = __esm({ - "shim-@plugin/css:@plugin/css"() { - css_default = `[class^="obscuredTextContent_"]:has(.ECBlock) {\r +var css_default, + init_css = __esm({ + "shim-@plugin/css:@plugin/css"() { + css_default = `[class^="obscuredTextContent_"]:has(.ECBlock) {\r pointer-events: all !important;\r }\r [class*="hidden_"] .ECBlock::after {\r @@ -56,7 +78,7 @@ var css_default, init_css = __esm({ display: flex;\r }\r .ECBlock {\r - background: var(--background-secondary-alt);\r + background: #131416;\r border: 1px solid var(--background-tertiary);\r border-radius: var(--radius-xs);\r overflow: hidden;\r @@ -90,9 +112,18 @@ var css_default, init_css = __esm({ .ECBlock-numberSetting [class*="value-"] {\r width: 120px;\r }\r +.ECBlock-markdownSetting select {\r + background: var(--background-primary);\r + color: var(--text-normal);\r + border: 1px solid var(--background-tertiary);\r + border-radius: 4px;\r + padding: 8px 12px;\r + cursor: pointer;\r +}\r .ECBlock-file .ECBlock {\r /* so they wont be small */\r width: 100vw;\r + max-width: 66rem\r }\r .ECBlock.ECBlock-loading .ECBlock-wrapper {\r display: flex;\r @@ -170,8 +201,12 @@ var css_default, init_css = __esm({ .ECBlock .ECBlock-actions > div.ECBlock-copied {\r color: var(--status-positive);\r }\r +.ECBlock-actions > div.ECBlock-markdownButton.ECBlock-active {\r + color: var(--status-positive);\r +}\r .ECBlock .ECBlock-wrapper {\r overflow: auto scroll;\r + user-select: text;\r }\r .ECBlock .ECBlock-table {\r font-size: 0.9em;\r @@ -184,7 +219,7 @@ var css_default, init_css = __esm({ text-align: center;\r position: sticky;\r left: 0;\r - background: var(--background-secondary-alt);\r + background: #131416;\r }\r .ECBlock .ECBlock-table tr > :last-child {\r padding: 0 8px;\r @@ -197,6 +232,122 @@ var css_default, init_css = __esm({ align-items: center;\r justify-content: center;\r }\r +.ECBlock-modal {\r + /* No max-height constraint - let it grow with dynamic size */\r + max-width: 66rem;\r +}\r +.ECBlock-modal .ECBlock-wrapper {\r + /* Allow wrapper to grow with content */\r + max-height: none;\r +}\r +/* Make Discord's dynamic modal wider for our content (height handled via ref) */\r +[class*="layer-"] > [class*="content-"]:has(.ECBlock-modal) {\r + width: 100vw !important;\r + max-width: 66rem !important;\r +}\r +.ECBlock-markdown {\r + padding: 16px;\r + color: #dcddde;\r + font-family: var(--font-primary);\r + line-height: 1.6;\r + background: #131416;\r + overflow-wrap: break-word;\r +}\r +.ECBlock-markdown h1, .ECBlock-markdown h2, .ECBlock-markdown h3,\r +.ECBlock-markdown h4, .ECBlock-markdown h5, .ECBlock-markdown h6 {\r + color: #ffffff;\r + margin-top: 1.2em;\r + margin-bottom: 0.6em;\r + font-weight: 600;\r +}\r +.ECBlock-markdown h1 {\r + font-size: 1.5em;\r + border-bottom: 1px solid #42454a;\r + padding-bottom: 0.3em;\r +}\r +.ECBlock-markdown h2 {\r + font-size: 1.3em;\r + border-bottom: 1px solid #42454a;\r + padding-bottom: 0.3em;\r +}\r +.ECBlock-markdown h3 {\r + font-size: 1.1em;\r +}\r +.ECBlock-markdown code {\r + background: #2b2d31;\r + padding: 2px 6px;\r + border-radius: 4px;\r + font-family: var(--font-code);\r + font-size: 0.9em;\r + color: #e0e0e0;\r +}\r +.ECBlock-markdown pre {\r + background: #2b2d31;\r + padding: 12px;\r + border-radius: 8px;\r + overflow-x: auto;\r + margin: 12px 0;\r +}\r +.ECBlock-markdown pre code {\r + background: transparent;\r + padding: 0;\r +}\r +.ECBlock-markdown blockquote {\r + border-left: 4px solid #4f545c;\r + padding-left: 16px;\r + margin: 12px 0;\r + color: #b9bbbe;\r +}\r +.ECBlock-markdown a {\r + color: #00aff4;\r + text-decoration: none;\r +}\r +.ECBlock-markdown a:hover {\r + text-decoration: underline;\r +}\r +.ECBlock-markdown ul, .ECBlock-markdown ol {\r + padding-left: 24px;\r + margin: 8px 0;\r +}\r +.ECBlock-markdown li {\r + margin: 4px 0;\r +}\r +.ECBlock-markdown table {\r + border-collapse: collapse;\r + width: 100%;\r + margin: 12px 0;\r +}\r +.ECBlock-markdown table th {\r + background: #2b2d31;\r + border: 1px solid #42454a;\r + padding: 8px 12px;\r + text-align: left;\r + color: #ffffff;\r +}\r +.ECBlock-markdown table td {\r + border: 1px solid #42454a;\r + padding: 8px 12px;\r +}\r +.ECBlock-markdown img {\r + max-width: 100%;\r + border-radius: 8px;\r +}\r +.ECBlock-markdown hr {\r + border: none;\r + border-top: 1px solid #42454a;\r + margin: 16px 0;\r +}\r +.ECBlock-markdown input[type="checkbox"] {\r + margin-right: 8px;\r + cursor: default;\r +}\r +.ECBlock-markdown li.task-list-item {\r + list-style-type: none;\r +}\r +.ECBlock-markdown del {\r + text-decoration: line-through;\r + color: var(--text-muted);\r +}\r .ECBlock-overflow {\r position: fixed;\r right: 12px;\r @@ -222,8 +373,8 @@ var css_default, init_css = __esm({ .ECBlock-zIndex-hook {\r z-index: 1;\r }`; - } -}); + }, + }); // shim-react:react var require_react = __commonJS({ @@ -231,7 +382,7 @@ var require_react = __commonJS({ var module2 = BdApi.React; Object.assign(exports2, module2); "default" in module2 || Object.assign(exports2, { default: module2 }); - } + }, }); // shim-react-spring:react-spring @@ -240,81 +391,232 @@ var require_react_spring = __commonJS({ var module2 = BdApi.Webpack.getModule((m) => m.useSpring && m.animated); Object.assign(exports2, module2); "default" in module2 || Object.assign(exports2, { default: module2 }); - } + }, }); // src/hooks/common.ts function useStateDeps(initialState, deps) { let [state, setState] = (0, import_react.useState)(initialState); - return (0, import_react.useLayoutEffect)(() => setState(initialState), deps), [state, setState]; + return ( + (0, import_react.useLayoutEffect)(() => setState(initialState), deps), + [state, setState] + ); } -var import_react, init_common = __esm({ - "src/hooks/common.ts"() { - "use strict"; - import_react = __toESM(require_react()); - } -}); +var import_react, + init_common = __esm({ + "src/hooks/common.ts"() { + "use strict"; + import_react = __toESM(require_react()); + }, + }); // shim-highlight.js:highlight.js var require_highlight = __commonJS({ "shim-highlight.js:highlight.js"(exports2) { - var module2 = BdApi.Webpack.getModule((m) => m.highlight && m.listLanguages); + var module2 = BdApi.Webpack.getModule( + (m) => m.highlight && m.listLanguages, + ); Object.assign(exports2, module2); "default" in module2 || Object.assign(exports2, { default: module2 }); - } + }, +}); + +// shim-marked:marked +var require_marked = __commonJS({ + "shim-marked:marked"(exports2) { + // Try to get from global window object (if loaded by CDN) + if (window.marked) { + Object.assign(exports2, window.marked); + "default" in window.marked || + Object.assign(exports2, { default: window.marked }); + return; + } + // If not available, create a minimal marked parser + // This is a fallback that provides basic markdown functionality + var marked = { + parse: function (text, options) { + options = options || {}; + var html = text; + // Escape HTML + html = html + .replace(/&/g, "&") + .replace(//g, ">"); + // Code blocks (must be first to avoid processing content inside) + html = html.replace( + /```(\w*)\n([\s\S]*?)```/g, + function (match, lang, code) { + return ( + '
' +
+              code +
+              "
" + ); + }, + ); + // Headers + html = html.replace(/^###### (.*$)/gim, "
$1
"); + html = html.replace(/^##### (.*$)/gim, "
$1
"); + html = html.replace(/^#### (.*$)/gim, "

$1

"); + html = html.replace(/^### (.*$)/gim, "

$1

"); + html = html.replace(/^## (.*$)/gim, "

$1

"); + html = html.replace(/^# (.*$)/gim, "

$1

"); + // Tables + html = html.replace(/((?:\|[^\n]+\|\n?)+)/g, function (match) { + var rows = match.trim().split("\n"); + if (rows.length < 2) return match; + var isTable = rows.every(function (row) { + return row.indexOf("|") === 0; + }); + if (!isTable) return match; + var result = ""; + for (var i = 0; i < rows.length; i++) { + var isHeader = + i === 0 || (i === 1 && rows[i].indexOf("|---") !== -1); + if (i === 1 && rows[i].indexOf("|---") !== -1) continue; + var cells = rows[i].split("|").filter(function (c) { + return c.trim(); + }); + var tag = isHeader ? "th" : "td"; + result += + "" + + cells + .map(function (c) { + return "<" + tag + ">" + c.trim() + ""; + }) + .join("") + + ""; + } + return result + "
"; + }); + // Horizontal rules + html = html.replace(/^(-{3,}|_{3,}|\*{3,})$/gim, "
"); + // Strikethrough + html = html.replace(/~~(.+?)~~/g, "$1"); + // Task lists + html = html.replace( + /^\- \[x\] (.*$)/gim, + '
  • $1
  • ', + ); + html = html.replace( + /^\- \[ \] (.*$)/gim, + '
  • $1
  • ', + ); + // Bold and italic + html = html.replace( + /\*\*\*(.+?)\*\*\*/g, + "$1", + ); + html = html.replace(/\*\*(.+?)\*\*/g, "$1"); + html = html.replace(/\*(.+?)\*/g, "$1"); + // Inline code + html = html.replace(/`([^`]+)`/g, "$1"); + // Links + html = html.replace( + /\[([^\]]+)\]\(([^)]+)\)/g, + '$1', + ); + // Images + html = html.replace( + /!\[([^\]]*)\]\(([^)]+)\)/g, + '$1', + ); + // Blockquotes + html = html.replace(/^\> (.*$)/gim, "
    $1
    "); + // Unordered lists + html = html.replace(/^\- (.*$)/gim, "
  • $1
  • "); + html = html.replace(/(
  • .*<\/li>)/s, ""); + html = html.replace(/<\/ul>\s*