diff --git a/eslint.config.mjs b/eslint.config.mjs index 5d5b7cdd..3a95d59d 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -176,6 +176,40 @@ const pluginReviewRules = { }; }, }, + "no-codemirror-theme-styles": { + meta: { + type: "problem", + docs: { + description: + "Disallow static CodeMirror theme styles in TypeScript; use stylesheet selectors instead.", + }, + messages: { + noCodeMirrorThemeStyles: + "Move CodeMirror styling out of TypeScript and into the plugin stylesheet.", + }, + schema: [], + }, + create(context) { + return { + CallExpression(node) { + const { callee } = node; + if ( + callee.type === "MemberExpression" && + !callee.computed && + callee.object.type === "Identifier" && + callee.object.name === "EditorView" && + callee.property.type === "Identifier" && + callee.property.name === "theme" + ) { + context.report({ + node: callee, + messageId: "noCodeMirrorThemeStyles", + }); + } + }, + }; + }, + }, }, }; @@ -277,6 +311,7 @@ export default [ "@microsoft/sdl/no-inner-html": "warn", "plugin-review/require-eslint-directive-description": "warn", "plugin-review/no-network-interval": "warn", + "plugin-review/no-codemirror-theme-styles": "warn", "obsidianmd/no-static-styles-assignment": "warn", "obsidianmd/rule-custom-message": "warn", "obsidianmd/ui/sentence-case": "warn", diff --git a/src/editor/EmbeddableMarkdownEditor.ts b/src/editor/EmbeddableMarkdownEditor.ts index 2a0185a4..fc4d9acf 100644 --- a/src/editor/EmbeddableMarkdownEditor.ts +++ b/src/editor/EmbeddableMarkdownEditor.ts @@ -340,14 +340,6 @@ export class EmbeddableMarkdownEditor extends getEditorBase() { buildLocalExtensions(): Extension[] { const extensions = super.buildLocalExtensions(); - // Explicitly hide line numbers with CSS - extensions.push( - EditorView.theme({ - ".cm-lineNumbers": { display: "none !important" }, - ".cm-gutters": { display: "none !important" }, - }) - ); - extensions.push( tooltips({ parent: activeDocument.body, diff --git a/styles/task-modal.css b/styles/task-modal.css index 35780626..0762c411 100644 --- a/styles/task-modal.css +++ b/styles/task-modal.css @@ -61,6 +61,11 @@ border-left-color: var(--text-normal); } +.details-markdown-editor .cm-lineNumbers, +.details-markdown-editor .cm-gutters { + display: none; +} + /* Placeholder styling */ .details-markdown-editor .cm-placeholder { color: var(--text-faint); @@ -130,6 +135,11 @@ border-left-color: var(--text-normal); } +.nl-markdown-editor .cm-lineNumbers, +.nl-markdown-editor .cm-gutters { + display: none; +} + .nl-markdown-editor .cm-placeholder { color: var(--text-muted);