Move embedded editor styling to CSS

This commit is contained in:
callumalpass 2026-05-14 22:30:26 +10:00
parent 0c29943f37
commit 7da3572bac
3 changed files with 45 additions and 8 deletions

View file

@ -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",

View file

@ -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,

View file

@ -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);