mirror of
https://github.com/mayurankv/Obsidian-Code-Styler.git
synced 2026-07-22 08:10:29 +00:00
Changing structure
This commit is contained in:
parent
e110858ed3
commit
2c9cd83fe3
86 changed files with 1620 additions and 1650 deletions
18
.todo
18
.todo
|
|
@ -2,9 +2,15 @@ style live preview
|
|||
fold by clicking and commands
|
||||
|
||||
Refactor:
|
||||
☐ Add highlights in css
|
||||
☐ make external reference titles link but remain styled
|
||||
☐ SettingsTabs
|
||||
☐ Features:
|
||||
☐ Make identification of codeblocks split into partial and full so that
|
||||
☐ Make general styling apply to partially detected codeblocks via mix of viewplugins and statefields and make full identification features available via statefield (see https://github.com/mayurankv/Obsidian-Code-Styler/issues/312)
|
||||
☐ Add highlights in css
|
||||
☐ Fold by clicking in live preview and commands for reading and live preview
|
||||
☐ SettingsTabs
|
||||
☐ On command, use a value to determine whether the blocks are folderd, unfolded or null and set new blocks by that
|
||||
☐ Should be on a page by page basis
|
||||
☐ Colourised Bracket matching and line under to match vs code setup
|
||||
☐ Checks:
|
||||
☐ Check wrapped and active unwrap looks and works ok in live preview
|
||||
☐ Fixes:
|
||||
|
|
@ -14,7 +20,7 @@ Refactor:
|
|||
☐ Cursor disppears before live preview filler elements
|
||||
☐ scroll into view long lines when cursor moves
|
||||
☐ Mouse leaves for hover when focus goes
|
||||
☐ issue with startup reference
|
||||
☐ Issue with startup reference
|
||||
☐ Live Preview selection of lines: right edges of filler elements are selected, shouldn't be though
|
||||
|
||||
Hard fixes:
|
||||
|
|
@ -37,6 +43,8 @@ Refactor:
|
|||
☐ Update actions to use https://docs.obsidian.md/Reference/TypeScript+API/Workspace/activeEditor
|
||||
|
||||
Next Refactor:
|
||||
☐ Split CSS into fence and inline folders with names that relate directly to what the css does i.e. layout, highlighting, border, spacing, heaer, footer etc.
|
||||
☐ Make external reference titles link but remain styled
|
||||
☐ Add styles not exposed to style settings or settings for padding and margin settings
|
||||
☐ add default code icon svg based on < > icon and reference code icon svg
|
||||
☐ add mermaid icon
|
||||
|
|
@ -58,6 +66,8 @@ Next Refactor:
|
|||
☐ Proper diff notation
|
||||
☐ Set highlight lines using base highlight techniques (overriden by actual highlights)
|
||||
☐ Check reference with no internet
|
||||
☐ Bracket matching like vscode
|
||||
☐ Feature with new codeblock from clipboard which determines the language
|
||||
|
||||
Later Refactors:
|
||||
☐ Look into tokenising with textmate tokeniser
|
||||
|
|
|
|||
276
css/styles.css
Normal file
276
css/styles.css
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -18,7 +18,7 @@ const context = await esbuild.context({
|
|||
},
|
||||
entryPoints: [
|
||||
"src/main.ts",
|
||||
"src/styles.scss",
|
||||
"src/css/styles.scss",
|
||||
],
|
||||
bundle: true,
|
||||
// minify: true,
|
||||
|
|
|
|||
970
main.js
970
main.js
File diff suppressed because one or more lines are too long
1090
package-lock.json
generated
1090
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -3,11 +3,11 @@ import { EditorView } from "@codemirror/view";
|
|||
import { MarkdownView } from "obsidian";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { fenceScroll } from "./stateEffects";
|
||||
import { HOVER_TIMEOUT, SCROLL_TIMEOUT } from "src/Internal/constants/interface";
|
||||
import { HOVER_TIMEOUT, SCROLL_TIMEOUT } from "src/internal/constants/interface";
|
||||
import { areRangesInteracting, isRangeInteracting, lineDOMatPos } from "./utils";
|
||||
import { SKIP_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { getCodeblockLines } from "src/Internal/utils/elements";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { SKIP_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import { getCodeblockLines } from "src/internal/utils/elements";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
|
||||
let scrollTimeout: NodeJS.Timeout = setTimeout(() => { });
|
||||
let reset: boolean = true
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { isUrl } from "src/Internal/utils/parsing";
|
||||
import { isUrl } from "src/internal/utils/parsing";
|
||||
|
||||
const MODES = [
|
||||
"reference",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
import { Range, StateEffect, StateEffectType } from "@codemirror/state";
|
||||
import { Decoration } from "@codemirror/view";
|
||||
import { AnyRange } from "src/Internal/types/decoration";
|
||||
import { AnyRange } from "src/internal/types/decoration";
|
||||
|
||||
export const visualStateUpdate: StateEffectType<boolean> = StateEffect.define();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ import { EditorState, Range, RangeSet, RangeValue, SelectionRange, StateField, T
|
|||
import { Decoration, DecorationSet, EditorView, ViewUpdate } from "@codemirror/view";
|
||||
import { SyntaxNodeRef } from "@lezer/common";
|
||||
import { editorInfoField, editorLivePreviewField, livePreviewState } from "obsidian";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { LinkInfo } from "src/Internal/types/parsing";
|
||||
import { parseLinks } from "src/Internal/utils/parsing";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { LinkInfo } from "src/internal/types/parsing";
|
||||
import { parseLinks } from "src/internal/utils/parsing";
|
||||
import { CommentLinkWidget } from "./widgets";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { fenceScroll, visualStateUpdate } from "./stateEffects";
|
||||
import { AnyRange, BaseRange, FenceInfo } from "src/Internal/types/decoration";
|
||||
import { AnyRange, BaseRange, FenceInfo } from "src/internal/types/decoration";
|
||||
import { RangeNumber } from "./ranges";
|
||||
|
||||
export function createViewUpdater() {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { EditorView, WidgetType } from "@codemirror/view";
|
||||
import { MarkdownRenderer } from "obsidian";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { CodeParameters, FenceCodeParameters, InlineCodeParameters, LineParameters } from "src/Internal/types/parsing";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { CodeParameters, FenceCodeParameters, InlineCodeParameters, LineParameters } from "src/internal/types/parsing";
|
||||
import { isDeepStrictEqual } from "util";
|
||||
import { createFooterElement, createHeaderElement, ignoreActionEvents } from "../../elements";
|
||||
import { foldOnClick } from "./actions";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { getLanguageIcon } from "src/Internal/utils/decorating";
|
||||
import { getTheme } from "src/Internal/utils/themes";
|
||||
import { getLanguageIcon } from "src/internal/utils/decorating";
|
||||
import { getTheme } from "src/internal/utils/themes";
|
||||
|
||||
export class HeaderWidget extends WidgetType {
|
||||
codeParameters: CodeParameters;
|
||||
|
|
|
|||
|
|
@ -3,18 +3,19 @@ import { EditorState, Extension, Range, RangeSet, StateEffect, StateField, Trans
|
|||
import { Decoration, DecorationSet, EditorView, PluginValue, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||
import { SyntaxNodeRef } from "@lezer/common";
|
||||
import { editorInfoField } from "obsidian";
|
||||
import { isFenceComment, isFenceEnd, isFenceLine, isFenceStart, updateFenceInfo } from "src/Internal/Detecting/LivePreview/fenced";
|
||||
import { FenceInfo } from "src/Internal/types/decoration";
|
||||
import { getLineClasses } from "src/Internal/utils/decorating";
|
||||
import { isFenceComment, isFenceEnd, isFenceLine, isFenceStart, updateFenceInfo } from "src/internal/detecting/LivePreview/fenced";
|
||||
import { FenceInfo } from "src/internal/types/decoration";
|
||||
import { getLineClasses } from "src/internal/utils/decorating";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { hoverListener, scrollListener, setScroll } from "./codemirror/eventListeners";
|
||||
import { getCommentDecorations, getFenceLimits, getFoldStatuses, getScrollStatus, getStateFieldDecorations, getStateFieldScrollStates, getStateFieldsViewDecorations, isFileIgnored, lineDOMatPos, updateBaseStateField, updateInteractions, updateStateField, updateViewPlugin, valueInRange } from "./codemirror/utils";
|
||||
import { FillerWidget, FooterWidget, HeaderWidget, LineNumberWidget } from "./codemirror/widgets";
|
||||
import { RangeNumber } from "./codemirror/ranges";
|
||||
import { fenceScroll } from "./codemirror/stateEffects";
|
||||
import { SCROLL_TIMEOUT } from "src/Internal/constants/interface";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { DATA_PREFIX, SKIP_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { SCROLL_TIMEOUT } from "src/internal/constants/interface";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { DATA_PREFIX, SKIP_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import { toParseFenceCode } from "src/internal/parsing/fenced";
|
||||
|
||||
export function getFenceCodemirrorExtensions(
|
||||
plugin: CodeStylerPlugin,
|
||||
|
|
@ -253,7 +254,7 @@ function buildFenceCodeDecorations(
|
|||
value: RangeSet<any>,
|
||||
plugin: CodeStylerPlugin,
|
||||
): RangeSet<any> {
|
||||
if (isFileIgnored(state))
|
||||
if (isFileIgnored(state) || !toParseFenceCode(plugin))
|
||||
return Decoration.none;
|
||||
|
||||
let fenceInfo = new FenceInfo({sourcePath: state.field(editorInfoField)?.file?.path ?? ""})
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
import { EditorState, Extension, Range, RangeSetBuilder, StateField, Transaction } from "@codemirror/state";
|
||||
import { Decoration, DecorationSet, EditorView, PluginValue, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||
import { editorInfoField } from "obsidian";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { toDecorateInlineCode, toHighlightInlineCode } from "src/Internal/Parsing/inline";
|
||||
import { InlineCodeInfo } from "src/Internal/types/detecting";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { toDecorateInlineCode, toHighlightInlineCode, toParseInlineCode } from "src/internal/parsing/inline";
|
||||
import { InlineCodeInfo } from "src/internal/types/detecting";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { areRangesInteracting, getCommentDecorations, getStateFieldDecorations, getStateFieldsViewDecorations, isFileIgnored, updateStateField, updateViewPlugin } from "./codemirror/utils";
|
||||
import { FooterWidget, HeaderWidget } from "./codemirror/widgets";
|
||||
import { syntaxTree } from "@codemirror/language";
|
||||
import { getInlineCodeInfo } from "src/Internal/Detecting/LivePreview/inline";
|
||||
import { getInlineCodeInfo } from "src/internal/detecting/LivePreview/inline";
|
||||
|
||||
export function getInlineCodeMirrorExtensions(
|
||||
plugin: CodeStylerPlugin,
|
||||
|
|
@ -132,7 +132,7 @@ function buildInlineCodeDecorations(
|
|||
value: DecorationSet,
|
||||
plugin: CodeStylerPlugin,
|
||||
): DecorationSet {
|
||||
if (isFileIgnored(state))
|
||||
if (isFileIgnored(state) || !toParseInlineCode(plugin))
|
||||
return Decoration.none;
|
||||
|
||||
let allDecorations: Array<Range<Decoration>> = [];
|
||||
|
|
@ -159,7 +159,7 @@ function buildInlineDecoration(
|
|||
if (!inlineCodeInfo || !toDecorateInlineCode(inlineCodeInfo.parameters.value, inlineCodeInfo.content.value))
|
||||
return []
|
||||
|
||||
let decorations: Array<Range<Decoration>> = []
|
||||
const decorations: Array<Range<Decoration>> = []
|
||||
|
||||
if (inlineCodeInfo.parameters.from < inlineCodeInfo.parameters.to)
|
||||
decorations.push({
|
||||
|
|
@ -171,8 +171,7 @@ function buildInlineDecoration(
|
|||
});
|
||||
|
||||
if (toHighlightInlineCode(inlineCodeInfo.parameters.value, plugin))
|
||||
decorations = [
|
||||
...decorations,
|
||||
decorations.push(
|
||||
...inlineSyntaxHighlight(
|
||||
state,
|
||||
inlineCodeInfo.parameters.value.language,
|
||||
|
|
@ -180,7 +179,7 @@ function buildInlineDecoration(
|
|||
inlineCodeInfo.parameters.to,
|
||||
plugin,
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
decorations.push({
|
||||
from: inlineCodeInfo.parameters.from,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { EditorView, PluginValue, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||
import { editorInfoField } from "obsidian";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { addReferenceSyntaxHighlight } from "src/Internal/Decorating/LivePreview/codemirror/modes";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { addReferenceSyntaxHighlight } from "src/internal/Decorating/LivePreview/codemirror/modes";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
class ReferenceModeViewPlugin implements PluginValue {
|
||||
|
|
|
|||
|
|
@ -2,19 +2,19 @@ import { ElementContent } from "hast";
|
|||
import { fromHtml } from "hast-util-from-html";
|
||||
import { toHtml } from "hast-util-to-html";
|
||||
import { MarkdownPostProcessorContext, sanitizeHTMLToDom } from "obsidian";
|
||||
import { DECORATED_ATTRIBUTE, DEFAULT_FOLD_ATTRIBUTE, FOLD_ATTRIBUTE, WRAP_ATTRIBUTE } from "src/Internal/constants/decoration";
|
||||
import { DETECTING_CONTEXT, PARAMETERS_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { CodeDetectingContext } from "src/Internal/types/detecting";
|
||||
import { FenceCodeParameters } from "src/Internal/types/parsing";
|
||||
import { DECORATED_ATTRIBUTE, DEFAULT_FOLD_ATTRIBUTE, FOLD_ATTRIBUTE, WRAP_ATTRIBUTE } from "src/internal/constants/decoration";
|
||||
import { DETECTING_CONTEXT, PARAMETERS_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { CodeDetectingContext } from "src/internal/types/detecting";
|
||||
import { FenceCodeParameters } from "src/internal/types/parsing";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { visitParents } from "unist-util-visit-parents";
|
||||
import { parseFenceCodeParameters, referenceAdjustParameters, toDecorateFenceCode } from "../../Parsing/fenced";
|
||||
import { parseFenceCodeParameters, referenceAdjustParameters, toDecorateFenceCode } from "../../parsing/fenced";
|
||||
import { convertCommentLinks, getIndentation, getLineClasses } from "../../utils/decorating";
|
||||
import { createFooterElement, createHeaderElement } from "../elements";
|
||||
import { BUTTON_TIMEOUT, BUTTON_TRANSITION, FOLD_TRANSITION } from "src/Internal/constants/interface";
|
||||
import { convertBoolean } from "src/Internal/utils/string";
|
||||
import { animateIconChange, copyButton, toggleFoldIcon } from "src/Internal/utils/elements";
|
||||
import { BUTTON_TIMEOUT, BUTTON_TRANSITION, FOLD_TRANSITION } from "src/internal/constants/interface";
|
||||
import { convertBoolean } from "src/internal/utils/string";
|
||||
import { animateIconChange, copyButton, toggleFoldIcon } from "src/internal/utils/elements";
|
||||
|
||||
export async function renderedFencedCodeDecorating(
|
||||
element: HTMLElement,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import { MarkdownPostProcessorContext, MarkdownRenderer } from "obsidian";
|
||||
import { DECORATED_ATTRIBUTE, TEMPORARY_SOURCEPATH } from "src/Internal/constants/decoration";
|
||||
import { CONTENT_ATTRIBUTE, PARAMETERS_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { InlineCodeParameters } from "src/Internal/types/parsing";
|
||||
import { DECORATED_ATTRIBUTE, TEMPORARY_SOURCEPATH } from "src/internal/constants/decoration";
|
||||
import { CONTENT_ATTRIBUTE, PARAMETERS_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { InlineCodeParameters } from "src/internal/types/parsing";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { parseInlineCodeParameters, toDecorateInlineCode, toHighlightInlineCode } from "../../Parsing/inline";
|
||||
import { parseInlineCodeParameters, toDecorateInlineCode, toHighlightInlineCode } from "../../parsing/inline";
|
||||
import { createFooterElement, createHeaderElement } from "../elements";
|
||||
import { codeToHast, codeToHtml, codeToTokens } from 'shiki'
|
||||
import { USE_SHIKI } from "src/Internal/constants/settings";
|
||||
import { USE_SHIKI } from "src/internal/constants/settings";
|
||||
|
||||
export async function renderedInlineCodeDecorating(
|
||||
element: HTMLElement,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { MarkdownPostProcessorContext, MarkdownRenderer, MarkdownSectionInformation } from "obsidian";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { applyStandaloneFencedDetecting } from "../../Detecting/Rendered/fenced";
|
||||
import { applyStandaloneFencedDetecting } from "../../detecting/Rendered/fenced";
|
||||
import { PREFIX } from "../../constants/general";
|
||||
import { REFERENCE_ATTRIBUTE } from "../../constants/reference";
|
||||
import { Reference } from "../../types/reference";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { getLanguageIcon, getLanguageName } from "../utils/decorating";
|
|||
import { FOLD_ATTRIBUTE, FOLD_PLACEHOLDER, GIT_ICONS, SITE_ICONS, STAMP_ICON, UPDATE_ICON } from "../constants/decoration";
|
||||
import { editorLivePreviewField, MarkdownPostProcessorContext, MarkdownRenderer, MarkdownView, Notice, setIcon } from "obsidian";
|
||||
import { isUrl } from "../utils/parsing";
|
||||
import { rerenderCodeElement } from "src/Internal/Interface/Actions/clicks";
|
||||
import { rerenderCodeElement } from "src/internal/Interface/actions/clicks";
|
||||
import { updateExternalReference } from "../utils/reference";
|
||||
import { Reference } from "../types/reference";
|
||||
import { getTheme } from "../utils/themes";
|
||||
|
|
@ -512,7 +512,7 @@ async function foldFence(
|
|||
): Promise<void> {
|
||||
await viewDependentCallback(
|
||||
plugin,
|
||||
(view: MarkdownView, plugin: CodeStylerPlugin) => {
|
||||
(view: MarkdownView, plugin: CodeStylerPlugin) => new Promise( _ => {
|
||||
const fencePreElement = triggerElement.closest("pre.cs-pre") as HTMLElement | null
|
||||
if (!fencePreElement || !(fencePreElement.tagName.toLowerCase() === "pre"))
|
||||
return false
|
||||
|
|
@ -520,8 +520,8 @@ async function foldFence(
|
|||
renderedFoldFence(fencePreElement)
|
||||
|
||||
return true
|
||||
},
|
||||
(view: EditorView, plugin: CodeStylerPlugin) => {
|
||||
}),
|
||||
(view: EditorView, plugin: CodeStylerPlugin) => new Promise( _ => {
|
||||
const parentElement = (triggerElement.closest(`.${PREFIX}header`) ?? triggerElement.closest(`.${PREFIX}footer`))
|
||||
if (!parentElement)
|
||||
return
|
||||
|
|
@ -534,7 +534,7 @@ async function foldFence(
|
|||
});
|
||||
console.log("Fold live preview should work but need to do recieving of effects")
|
||||
// view.requestMeasure(); //TODO: needed?
|
||||
},
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { CodeStylerSettings } from "../types/settings";
|
|||
import { BODY_CLASS, STYLE_ELEMENT_ID } from "../constants/decoration";
|
||||
import { PREFIX } from "../constants/general";
|
||||
import { getTheme } from "../utils/themes";
|
||||
import { addExtraVars, addLanguageColourVars, convertStylesToVars } from "../utils/settings";
|
||||
import { addExtraVars, addHighlightStyles, addLanguageColourVars, convertStylesToVars } from "../utils/settings";
|
||||
import { BASE_THEME_MODE_STYLES } from "../constants/settings";
|
||||
|
||||
const BODY_CLASSES = [
|
||||
|
|
@ -45,6 +45,8 @@ function getStyleText(
|
|||
|
||||
styleString += convertStylesToVars(plugin, "light")
|
||||
styleString += convertStylesToVars(plugin, "dark")
|
||||
styleString += addHighlightStyles(plugin, "light")
|
||||
styleString += addHighlightStyles(plugin, "dark")
|
||||
styleString += addExtraVars()
|
||||
styleString += addLanguageColourVars(plugin)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { EditorState } from "@codemirror/state";
|
||||
import { SyntaxNodeRef } from "@lezer/common";
|
||||
import { parseFenceCodeParameters, toDecorateFenceCode } from "src/Internal/Parsing/fenced";
|
||||
import { FenceInfo } from "src/Internal/types/decoration";
|
||||
import { cleanFenceCodeParametersLine } from "src/Internal/utils/detecting";
|
||||
import { parseFenceCodeParameters, toDecorateFenceCode } from "src/internal/parsing/fenced";
|
||||
import { FenceInfo } from "src/internal/types/decoration";
|
||||
import { cleanFenceCodeParametersLine } from "src/internal/utils/detecting";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
export function updateFenceInfo(
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import { syntaxTree } from "@codemirror/language";
|
|||
import { EditorState, Range, RangeSetBuilder } from "@codemirror/state";
|
||||
import { Decoration, DecorationSet, EditorView } from "@codemirror/view";
|
||||
import { SyntaxNodeRef } from "@lezer/common";
|
||||
import { getInlineDelimiterSize, isFileIgnored } from "src/Internal/Decorating/LivePreview/codemirror/utils";
|
||||
import { parseInlineCodeParameters, splitInlineCodeRaw } from "src/Internal/Parsing/inline";
|
||||
import { InlineCodeInfo } from "src/Internal/types/detecting";
|
||||
import { getInlineDelimiterSize, isFileIgnored } from "src/internal/Decorating/LivePreview/codemirror/utils";
|
||||
import { parseInlineCodeParameters, splitInlineCodeRaw } from "src/internal/parsing/inline";
|
||||
import { InlineCodeInfo } from "src/internal/types/detecting";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
export function getInlineCodeInfo(
|
||||
|
|
|
|||
|
|
@ -1,20 +1,24 @@
|
|||
import { CachedMetadata, DataAdapter, MarkdownPostProcessorContext, MarkdownSectionInformation, parseLinktext, resolveSubpath, SectionCache, View } from "obsidian";
|
||||
import { DETECTING_CONTEXT, PARAMETERS_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { DETECTING_CONTEXT, PARAMETERS_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { unified } from "unified";
|
||||
import markdown from 'remark-parse';
|
||||
import { visit } from 'unist-util-visit';
|
||||
import { cleanFenceCodeParametersLine, isUndetectedCodeElement } from "../../utils/detecting";
|
||||
import { SETTINGS_TAB_SOURCEPATH_PREFIX } from "src/Internal/constants/interface";
|
||||
import { CodeDetectingContext } from "src/Internal/types/detecting";
|
||||
import { getFileContentLines } from "src/Internal/utils/rendered";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { SETTINGS_TAB_SOURCEPATH_PREFIX } from "src/internal/constants/interface";
|
||||
import { CodeDetectingContext } from "src/internal/types/detecting";
|
||||
import { getFileContentLines } from "src/internal/utils/rendered";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { toParseFenceCode } from "src/internal/parsing/fenced";
|
||||
|
||||
export async function renderedFencedCodeDetecting(
|
||||
element: HTMLElement,
|
||||
context: MarkdownPostProcessorContext,
|
||||
plugin: CodeStylerPlugin,
|
||||
): Promise<void> {
|
||||
if (!toParseFenceCode(plugin))
|
||||
return;
|
||||
|
||||
const view = plugin.app.workspace.getActiveViewOfType(View);
|
||||
const cache = plugin.app.metadataCache.getCache(context.sourcePath)
|
||||
if (!view || !cache)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { MarkdownPostProcessorContext } from "obsidian";
|
||||
import { CONTENT_ATTRIBUTE, EMPTY_PARAMETERS_ATTRIBUTE, PARAMETERS_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { CONTENT_ATTRIBUTE, EMPTY_PARAMETERS_ATTRIBUTE, PARAMETERS_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { splitInlineCodeRaw } from "../../Parsing/inline";
|
||||
import { splitInlineCodeRaw, toParseInlineCode } from "../../parsing/inline";
|
||||
import { isUndetectedCodeElement } from "../../utils/detecting";
|
||||
|
||||
export async function renderedInlineCodeDetecting(
|
||||
|
|
@ -9,6 +9,9 @@ export async function renderedInlineCodeDetecting(
|
|||
context: MarkdownPostProcessorContext,
|
||||
plugin: CodeStylerPlugin,
|
||||
): Promise<void> {
|
||||
if (!toParseInlineCode(plugin))
|
||||
return;
|
||||
|
||||
for (const inlineCodeElement of Array.from(element.querySelectorAll(":not(pre) > code")) as Array<HTMLElement>) {
|
||||
const inlineCodeRaw = inlineCodeElement.innerText;
|
||||
const {inlineCodeParametersLine, inlineCodeContent} = splitInlineCodeRaw(inlineCodeRaw);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { MarkdownView } from "obsidian";
|
||||
import { PREFIX } from "src/Internal/constants/general";
|
||||
import { rerender } from "src/Internal/Decorating/LivePreview/codemirror/stateEffects";
|
||||
import { PREFIX } from "src/internal/constants/general";
|
||||
import { rerender } from "src/internal/Decorating/LivePreview/codemirror/stateEffects";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
export function rerenderCodeElement(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { EditorView } from "@codemirror/view";
|
||||
import { MarkdownView, WorkspaceLeaf } from "obsidian";
|
||||
import { renderedViewFold } from "src/Internal/Decorating/Rendered/fenced";
|
||||
import { viewDependentCallback } from "src/Internal/utils/interface";
|
||||
import { manageExternalReferencedFiles } from "src/Internal/utils/reference";
|
||||
import { renderedViewFold } from "src/internal/Decorating/Rendered/fenced";
|
||||
import { viewDependentCallback } from "src/internal/utils/interface";
|
||||
import { manageExternalReferencedFiles } from "src/internal/utils/reference";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
async function viewFold(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { MarkdownView, WorkspaceLeaf } from "obsidian";
|
||||
import { WORKSPACE_CHANGE_TIMEOUT } from "src/Internal/constants/interface";
|
||||
import { WORKSPACE_CHANGE_TIMEOUT } from "src/internal/constants/interface";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
let rerenderTimeout: NodeJS.Timeout = setTimeout(() => { });
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { MarkdownPreviewRenderer, Plugin } from "obsidian";
|
||||
import { basename } from "path";
|
||||
import { getArgs } from "src/External/ExecuteCode/CodeBlockArgs";
|
||||
import { getArgs } from "src/external/execute-code/CodeBlockArgs";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { EXECUTE_CODE_SUPPORTED_LANGUAGES } from "../constants/external";
|
||||
import { PLUGIN_CODEBLOCK_WHITELIST as BASE_PLUGIN_CODEBLOCK_WHITELIST, FENCE_PARAMETERS_KEY_VALUE, FENCE_PARAMETERS_SHORTHAND } from "../constants/parsing";
|
||||
|
|
@ -10,6 +10,7 @@ import { FenceCodeParameters, Highlights } from "../types/parsing";
|
|||
import { Reference } from "../types/reference";
|
||||
import { isLanguageMatched, separateParameters, setTitleAndReference } from "../utils/parsing";
|
||||
import { convertBoolean, removeBoundaryQuotes, removeCurlyBraces } from "../utils/string";
|
||||
import { getTheme } from "../utils/themes";
|
||||
|
||||
export function parseFenceCodeParameters(
|
||||
fenceCodeParametersLine: string,
|
||||
|
|
@ -364,3 +365,9 @@ export function toDecorateFenceCode(
|
|||
|
||||
return true
|
||||
}
|
||||
|
||||
export function toParseFenceCode(
|
||||
plugin: CodeStylerPlugin,
|
||||
): boolean {
|
||||
return getTheme(plugin).settings.fence.parse
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,6 +92,12 @@ export function toHighlightInlineCode(
|
|||
return getTheme(plugin).settings.inline.syntaxHighlight && (inlineCodeParameters.language !== null)
|
||||
}
|
||||
|
||||
export function toParseInlineCode(
|
||||
plugin: CodeStylerPlugin,
|
||||
): boolean {
|
||||
return getTheme(plugin).settings.inline.parse
|
||||
}
|
||||
|
||||
export function splitInlineCodeRaw(
|
||||
inlineCodeRaw: string,
|
||||
): { inlineCodeParametersLine: string | null, inlineCodeContent: string } {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { EditorState, Extension, Line, Range, RangeSetBuilder, SelectionRange, StateEffect, StateField, Transaction } from "@codemirror/state";
|
||||
import { Decoration, DecorationSet, EditorView, ViewUpdate } from "@codemirror/view";
|
||||
import { editorEditorField } from "obsidian";
|
||||
import { hideFold, unhideFold } from "src/Internal/Decorating/LivePreview/codemirror/stateEffects";
|
||||
import { areRangesInteracting, isFileIgnored, isRangeInteracting, isSourceMode } from "src/Internal/Decorating/LivePreview/codemirror/utils";
|
||||
import { CodeStylerSettings } from "src/Internal/types/settings";
|
||||
import { hideFold, unhideFold } from "src/internal/Decorating/LivePreview/codemirror/stateEffects";
|
||||
import { areRangesInteracting, isFileIgnored, isRangeInteracting, isSourceMode } from "src/internal/Decorating/LivePreview/codemirror/utils";
|
||||
import { CodeStylerSettings } from "src/internal/types/settings";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
interface SettingsState {
|
||||
|
|
@ -120,6 +120,7 @@ const HEADER_DISPLAY_SETTINGS = {
|
|||
|
||||
export const THEME_DEFAULT_SETTINGS: CodeStylerThemeSettings = {
|
||||
fence: {
|
||||
parse: true,
|
||||
syntaxHighlight: true,
|
||||
header: {
|
||||
display: HEADER_DISPLAY_SETTINGS,
|
||||
|
|
@ -136,6 +137,7 @@ export const THEME_DEFAULT_SETTINGS: CodeStylerThemeSettings = {
|
|||
},
|
||||
},
|
||||
inline: {
|
||||
parse: true,
|
||||
syntaxHighlight: true,
|
||||
header: {
|
||||
display: HEADER_DISPLAY_SETTINGS,
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ interface HeaderSettings {
|
|||
}
|
||||
|
||||
interface CodeSettings {
|
||||
parse: boolean;
|
||||
syntaxHighlight: boolean;
|
||||
header: HeaderSettings;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { MarkdownRenderer } from "obsidian";
|
|||
import { ElementContent, Element } from "hast";
|
||||
import { fromHtml } from "hast-util-from-html";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { FenceCodeParameters, Highlights, InlineCodeParameters, LinkInfo } from "src/Internal/types/parsing";
|
||||
import { FenceCodeParameters, Highlights, InlineCodeParameters, LinkInfo } from "src/internal/types/parsing";
|
||||
import { PREFIX } from "../constants/general";
|
||||
import { toKebabCase } from "./string";
|
||||
import { LANGUAGE_NAMES } from "../constants/parsing";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { PARAMETERS_ATTRIBUTE } from "src/Internal/constants/detecting";
|
||||
import { PARAMETERS_ATTRIBUTE } from "src/internal/constants/detecting";
|
||||
export function cleanFenceCodeParametersLine(
|
||||
fenceCodeParametersLine: string,
|
||||
): string {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ import { LOCAL_PREFIX } from "../constants/interface";
|
|||
import CodeStylerPlugin from "src/main";
|
||||
import { EXTERNAL_REFERENCE_CACHE, EXTERNAL_REFERENCE_INFO_SUFFIX, EXTERNAL_REFERENCE_PATH, REFERENCE_CODEBLOCK } from "../constants/reference";
|
||||
import { Cache, IdCache, Reference, ReferenceByFile } from "../types/reference";
|
||||
import { getLineLimits, parseExternalReference, parseReferenceParameters } from "../Parsing/reference";
|
||||
import { getLineLimits, parseExternalReference, parseReferenceParameters } from "../parsing/reference";
|
||||
import { getFileContentLines } from "./rendered";
|
||||
import { rerenderRenderedView } from "src/Internal/Interface/View/rendered";
|
||||
import { rerenderRenderedView } from "src/internal/Interface/View/rendered";
|
||||
import { isUrl } from "./parsing";
|
||||
import { cleanFenceCodeParametersLine } from "./detecting";
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,28 @@ export function convertStylesToVars(
|
|||
return styleString
|
||||
}
|
||||
|
||||
export function addHighlightStyles(
|
||||
plugin: CodeStylerPlugin,
|
||||
mode: "light" | "dark",
|
||||
): string {
|
||||
const styles = getThemeStyles(plugin, mode)
|
||||
|
||||
let styleString = ""
|
||||
|
||||
styleString += `body.cs-plugin.theme-${mode}{\n`;
|
||||
|
||||
styleString += `div.cm-line:not(.cm-embed-block):not(.HyperMD-codeblock-begin).cs-line.cs-highlighted-default::after {
|
||||
content: "";
|
||||
// --cs-fence-gutter-background-colour: var(--cs-fence-highlights-default-highlight-colour);
|
||||
// --cs-fence-gutter-border-colour: var(--cs-fence-highlights-default-highlight-colour);
|
||||
// --cs-fence-background-colour: var(--cs-fence-highlights-default-highlight-colour);
|
||||
};`
|
||||
|
||||
styleString += "}";
|
||||
|
||||
return styleString
|
||||
}
|
||||
|
||||
export function addLanguageColourVars(
|
||||
plugin: CodeStylerPlugin,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { LANGUAGES } from "src/Internal/constants/decoration";
|
||||
import { LANGUAGES } from "src/internal/constants/decoration";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
|
||||
export function loadLanguageIcons(): Record<string, string> {
|
||||
|
|
|
|||
|
|
@ -39,8 +39,6 @@ body.cs-plugin {
|
|||
.markdown-source-view {
|
||||
:not(pre.code-styler-pre) > .code-styler-header-container + [class*="code-styler-line"].HyperMD-codeblock-begin {
|
||||
border-top: none !important;
|
||||
border-top-left-radius: 0px !important;
|
||||
border-top-right-radius: 0px !important;
|
||||
}
|
||||
.HyperMD-codeblock[class*='code-styler-line'] {
|
||||
overflow: hidden;
|
||||
|
|
@ -70,8 +68,6 @@ body.cs-plugin {
|
|||
border-right: var(--code-styler-header-border);
|
||||
border-left: var(--code-styler-header-border);
|
||||
background: linear-gradient(var(--code-styler-header-background-colour) 0%,var(--code-styler-header-background-colour) calc(100% - var(--header-separator-width)), var(--code-styler-header-separator-colour) calc(100% - var(--header-separator-width)), var(--code-styler-header-separator-colour) 100%) var(--language-border-width) bottom/100% border-box no-repeat,var(--language-border-colour) !important;
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
}
|
||||
pre.code-styler-pre .code-styler-header-container {
|
||||
border-bottom: var(--header-separator-width) solid var(--code-styler-header-separator-colour);
|
||||
|
|
@ -82,8 +78,6 @@ body.cs-plugin {
|
|||
border-bottom: var(--code-styler-header-border);
|
||||
border-bottom: var(--folded-bottom-border);
|
||||
background: linear-gradient(var(--code-styler-header-background-colour) 0%,var(--code-styler-header-background-colour) 100%) var(--language-border-width) bottom/100% border-box no-repeat,var(--language-border-colour) !important;
|
||||
border-bottom-left-radius: var(--border-radius);
|
||||
border-bottom-right-radius: var(--border-radius);
|
||||
}
|
||||
pre.code-styler-pre.code-styler-folded .code-styler-header-container {
|
||||
border-bottom: var(--folded-bottom-border);
|
||||
|
|
@ -96,16 +90,11 @@ body.cs-plugin {
|
|||
padding-right: var(--header-spacing);
|
||||
padding-bottom: calc(1em * var(--header-inner-vertical-padding));
|
||||
padding-left: var(--header-spacing);
|
||||
border-radius: var(--border-radius) var(--border-radius) 0px 0px;
|
||||
margin-right: var(--header-spacing);
|
||||
background-color: var(--code-styler-header-language-tag-background-colour);
|
||||
text-align: center;
|
||||
transition: border-radius, padding ease-in-out var(--duration-button);
|
||||
}
|
||||
.markdown-source-view :not(pre.code-styler-pre) > .code-styler-header-container.code-styler-header-folded .code-styler-header-language-tag,
|
||||
pre.code-styler-pre.code-styler-folded .code-styler-header-container .code-styler-header-language-tag {
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
.code-styler-header-text,
|
||||
.code-styler-header-external-reference > div,
|
||||
pre.code-styler-pre .code-styler-header-external-reference > button {
|
||||
|
|
@ -133,10 +122,6 @@ body.cs-plugin {
|
|||
pre.code-styler-pre .code-styler-header-external-reference > button:hover {
|
||||
scale: 1.4;
|
||||
}
|
||||
body .code-styler-header-container:not(:has( div > img.code-styler-icon)) .code-styler-header-language-tag {
|
||||
border-bottom-left-radius: 0 !important;
|
||||
border-top-left-radius: 0 !important;
|
||||
}
|
||||
body .code-styler-header-container:not(:has( .code-styler-header-language-tag)) .code-styler-header-text {
|
||||
padding-left: var(--header-spacing);
|
||||
}
|
||||
14
src/css/_update/pdfExport.scss
Normal file
14
src/css/_update/pdfExport.scss
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
div.print {
|
||||
--line-wrapping: pre-wrap !important;
|
||||
}
|
||||
|
||||
body.cs-plugin div.print {
|
||||
pre.code-styler-pre {
|
||||
code {
|
||||
max-height: unset !important;
|
||||
}
|
||||
&.code-styler-folded code {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
1
src/css/export/init.scss
Normal file
1
src/css/export/init.scss
Normal file
|
|
@ -0,0 +1 @@
|
|||
@import url("obsidian/init.scss");
|
||||
1
src/css/export/obsidian/init.scss
Normal file
1
src/css/export/obsidian/init.scss
Normal file
|
|
@ -0,0 +1 @@
|
|||
@import url("pdf.scss");
|
||||
|
|
@ -427,6 +427,18 @@ body.cs-plugin {
|
|||
opacity: 1 !important;
|
||||
};
|
||||
|
||||
div.cm-line:not(.cm-embed-block):not(.HyperMD-codeblock-begin).cs-line.cs-highlighted-default::after {
|
||||
display: inline-block;
|
||||
position: sticky;
|
||||
width: 100%;
|
||||
// width: var(--size-4-3);
|
||||
// left: 100%;
|
||||
background: linear-gradient(to right, yellow, var(--cs-fence-highlights-gradient-highlights-colour-stop), yellow);
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
height: calc(1em * var(--line-height-normal));
|
||||
margin-bottom: calc(-1 * (var(--line-height-normal) - 1) * 1em);
|
||||
}
|
||||
|
||||
.cs-pre-parent {
|
||||
> pre.cs-pre {
|
||||
|
|
@ -561,6 +573,10 @@ body.cs-plugin {
|
|||
color: rgba(0,0,0,0) !important;
|
||||
--cs-fence-gutter-background-colour: var(--cs-fence-background-colour);
|
||||
--cs-fence-gutter-border-colour: var(--cs-fence-background-colour);
|
||||
|
||||
a.external-link {
|
||||
background: none !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
src/css/fence/init.scss
Normal file
0
src/css/fence/init.scss
Normal file
|
|
@ -1,47 +0,0 @@
|
|||
.cm-hmd-frontmatter.cm-inline-code,
|
||||
.cm-hmd-frontmatter.cm-math {
|
||||
color: var(--code-normal);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-hmd-frontmatter.cm-def.cm-def,
|
||||
.cm-hmd-frontmatter.cm-comment,
|
||||
.cm-hmd-frontmatter.cm-meta {
|
||||
color: var(--code-comment);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-tag {
|
||||
color: var(--code-tag);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-punctuation,
|
||||
.cm-hmd-frontmatter.cm-bracket,
|
||||
.cm-hmd-frontmatter.cm-hr {
|
||||
color: var(--code-punctuation);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-number {
|
||||
color: var(--code-value);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-qualifier,
|
||||
.cm-hmd-frontmatter.cm-string,
|
||||
.cm-hmd-frontmatter.cm-string-2 {
|
||||
color: var(--code-string);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-operator {
|
||||
color: var(--code-operator);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-link,
|
||||
.cm-hmd-frontmatter.cm-variable,
|
||||
.cm-hmd-frontmatter.cm-variable-2,
|
||||
.cm-hmd-frontmatter.cm-variable-3 {
|
||||
color: var(--code-property);
|
||||
}
|
||||
.cm-hmd-frontmatter,
|
||||
.cm-hmd-frontmatter.cm-builtin,
|
||||
.cm-hmd-frontmatter.cm-property,
|
||||
.cm-hmd-frontmatter.cm-attribute,
|
||||
.cm-hmd-frontmatter.cm-type {
|
||||
color: var(--code-function);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-keyword {
|
||||
color: var(--code-keyword);
|
||||
}
|
||||
.cm-hmd-frontmatter.cm-atom {
|
||||
color: var(--code-important)
|
||||
}
|
||||
17
src/css/inline/decorations.scss
Normal file
17
src/css/inline/decorations.scss
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
body.cs-plugin {
|
||||
span.cm-comment {
|
||||
span.cs-comment {
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
padding: 0px !important;
|
||||
}
|
||||
}
|
||||
|
||||
span.cs-comment {
|
||||
box-sizing:initial;
|
||||
|
||||
p {
|
||||
display: inline !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
src/css/inline/footer.scss
Normal file
45
src/css/inline/footer.scss
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
body.cs-plugin {
|
||||
span.cs-footer {
|
||||
padding-left: 0.4em !important;
|
||||
|
||||
&.cm-inline-code {
|
||||
padding-left: 0px !important;
|
||||
padding-right: 0.25em; // Obsidian default value
|
||||
border-radius: 0px var(--cs-inline-curvature) var(--cs-inline-curvature) 0px !important;
|
||||
}
|
||||
|
||||
button.cs-copy-code-button {
|
||||
--icon-size: var(--icon-xs);
|
||||
padding: 0.15em;
|
||||
margin-left: var(--size-4-1);
|
||||
background-color: var(--cs-inline-button-inactive-background-colour);
|
||||
box-shadow: none;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
color: var(--cs-inline-button-inactive-colour);
|
||||
|
||||
transition: opacity, background-color, color;
|
||||
transition-duration: var(--cs-transition-length-button);
|
||||
|
||||
> svg {
|
||||
display: inline;
|
||||
height: 100%;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--cs-inline-button-hover-background-colour);
|
||||
color: var(--cs-inline-button-hover-colour);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: var(--cs-inline-button-active-background-colour);
|
||||
color: var(--cs-inline-button-active-colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// code:not(:hover) span.cs-footer button.cs-copy-code-button {
|
||||
// visibility: hidden;
|
||||
// }
|
||||
}
|
||||
|
|
@ -1,17 +1,4 @@
|
|||
body.cs-plugin {
|
||||
|
||||
.markdown-rendered :not(pre) > code:not([class*="blur"]) {
|
||||
display: inline;
|
||||
border-radius: var(--cs-inline-curvature);
|
||||
color: var(--cs-inline-text-colour);
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
|
||||
span.cm-inline-code {
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
span.cm-formatting.cm-inline-code ~ span.cs-header {
|
||||
border-radius: 0px !important;
|
||||
}
|
||||
|
|
@ -103,114 +90,4 @@ body.cs-plugin {
|
|||
color: var(--cs-inline-header-separator-background-colour);
|
||||
}
|
||||
}
|
||||
|
||||
span.cs-parameters {
|
||||
color: var(--cs-inline-parameters-text-colour);
|
||||
font-weight: var(--cs-inline-parameters-font-weight);
|
||||
font-style: var(--cs-inline-parameters-font-style);
|
||||
font-family: var(--cs-inline-parameters-font-family);
|
||||
}
|
||||
|
||||
span.cs-footer {
|
||||
padding-left: 0.4em !important;
|
||||
|
||||
&.cm-inline-code {
|
||||
padding-left: 0px !important;
|
||||
padding-right: 0.25em; // Obsidian default value
|
||||
border-radius: 0px var(--cs-inline-curvature) var(--cs-inline-curvature) 0px !important;
|
||||
}
|
||||
|
||||
button.cs-copy-code-button {
|
||||
--icon-size: var(--icon-xs);
|
||||
padding: 0.15em;
|
||||
margin-left: var(--size-4-1);
|
||||
background-color: var(--cs-inline-button-inactive-background-colour);
|
||||
box-shadow: none;
|
||||
height: 100%;
|
||||
display: inline-block;
|
||||
color: var(--cs-inline-button-inactive-colour);
|
||||
|
||||
transition: opacity, background-color, color;
|
||||
transition-duration: var(--cs-transition-length-button);
|
||||
|
||||
> svg {
|
||||
display: inline;
|
||||
height: 100%;
|
||||
vertical-align: text-top;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: var(--cs-inline-button-hover-background-colour);
|
||||
color: var(--cs-inline-button-hover-colour);
|
||||
}
|
||||
|
||||
&:active {
|
||||
background-color: var(--cs-inline-button-active-background-colour);
|
||||
color: var(--cs-inline-button-active-colour);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
code:not(:hover) span.cs-footer button.cs-copy-code-button {
|
||||
// visibility: hidden;
|
||||
}
|
||||
|
||||
span.cs-inline-parameters {
|
||||
color: var( --code-styler-inline-colour-parameters);
|
||||
}
|
||||
|
||||
span.cm-comment {
|
||||
span.cs-comment {
|
||||
font-size: inherit;
|
||||
line-height: inherit;
|
||||
padding: 0px !important;
|
||||
}
|
||||
}
|
||||
|
||||
span.cs-comment {
|
||||
box-sizing:initial;
|
||||
|
||||
p {
|
||||
display: inline !important;
|
||||
}
|
||||
}
|
||||
|
||||
// Overwrite Obsidian Defaults
|
||||
.cm-s-obsidian span.cm-inline-code {
|
||||
color: var(--cs-inline-text-colour);
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
|
||||
span.cm-inline-code {
|
||||
&.cm-hmd-indented-code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
&:not(.cm-formatting):not(.cm-hmd-indented-code):not(.obsidian-search-match-highlight) {
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.cm-formatting) {
|
||||
border-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
|
||||
&.cm-formatting {
|
||||
border-start-start-radius: var(--cs-inline-curvature);
|
||||
border-end-start-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
|
||||
&:not(.cm-formatting) + .cm-formatting.cm-inline-code {
|
||||
border-start-end-radius: var(--cs-inline-curvature);
|
||||
border-end-end-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
}
|
||||
|
||||
// Specific Corrections
|
||||
tr code.cs-code-inline {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.reveal img.cs-icon {
|
||||
margin: inherit;
|
||||
}
|
||||
}
|
||||
6
src/css/inline/init.scss
Normal file
6
src/css/inline/init.scss
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
@import url("decorations.scss");
|
||||
@import url("header.scss");
|
||||
@import url("footer.scss");
|
||||
@import url("spacing.scss");
|
||||
@import url("styling.scss");
|
||||
@import url("syntax_highlighting.scss");
|
||||
19
src/css/inline/spacing.scss
Normal file
19
src/css/inline/spacing.scss
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
body.cs-plugin {
|
||||
.markdown-rendered :not(pre) > code:not([class*="blur"]) {
|
||||
display: inline;
|
||||
|
||||
span.cm-inline-code {
|
||||
padding-left: 0 !important;
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
}
|
||||
|
||||
// Specific Corrections
|
||||
tr code.cs-code-inline {
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.reveal img.cs-icon {
|
||||
margin: inherit;
|
||||
}
|
||||
}
|
||||
37
src/css/inline/styling.scss
Normal file
37
src/css/inline/styling.scss
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
body.cs-plugin {
|
||||
.markdown-rendered :not(pre) > code:not([class*="blur"]) {
|
||||
border-radius: var(--cs-inline-curvature);
|
||||
color: var(--cs-inline-text-colour);
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
}
|
||||
|
||||
// Overwrite Obsidian Defaults
|
||||
.cm-s-obsidian span.cm-inline-code {
|
||||
color: var(--cs-inline-text-colour);
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
|
||||
span.cm-inline-code {
|
||||
&.cm-hmd-indented-code {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
&:not(.cm-formatting):not(.cm-hmd-indented-code):not(.obsidian-search-match-highlight) {
|
||||
background-color: var(--cs-inline-background-colour);
|
||||
}
|
||||
}
|
||||
|
||||
&:not(.cm-formatting) {
|
||||
border-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
|
||||
&.cm-formatting {
|
||||
border-start-start-radius: var(--cs-inline-curvature);
|
||||
border-end-start-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
|
||||
&:not(.cm-formatting) + .cm-formatting.cm-inline-code {
|
||||
border-start-end-radius: var(--cs-inline-curvature);
|
||||
border-end-end-radius: var(--cs-inline-curvature);
|
||||
}
|
||||
}
|
||||
}
|
||||
8
src/css/inline/syntax_highlighting.scss
Normal file
8
src/css/inline/syntax_highlighting.scss
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
body.cs-plugin {
|
||||
span.cs-parameters {
|
||||
color: var(--cs-inline-parameters-text-colour);
|
||||
font-weight: var(--cs-inline-parameters-font-weight);
|
||||
font-style: var(--cs-inline-parameters-font-style);
|
||||
font-family: var(--cs-inline-parameters-font-family);
|
||||
}
|
||||
}
|
||||
58
src/css/other/frontmatter.scss
Normal file
58
src/css/other/frontmatter.scss
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
.cm-hmd-frontmatter {
|
||||
&,
|
||||
.cm-builtin,
|
||||
.cm-property,
|
||||
.cm-attribute,
|
||||
.cm-type {
|
||||
color: var(--code-function);
|
||||
}
|
||||
|
||||
.cm-inline-code,
|
||||
.cm-math {
|
||||
color: var(--code-normal);
|
||||
}
|
||||
.cm-def,
|
||||
.cm-comment,
|
||||
.cm-meta {
|
||||
color: var(--code-comment);
|
||||
}
|
||||
|
||||
.cm-tag {
|
||||
color: var(--code-tag);
|
||||
}
|
||||
|
||||
.cm-punctuation,
|
||||
.cm-bracket,
|
||||
.cm-hr {
|
||||
color: var(--code-punctuation);
|
||||
}
|
||||
|
||||
.cm-number {
|
||||
color: var(--code-value);
|
||||
}
|
||||
|
||||
.cm-qualifier,
|
||||
.cm-string,
|
||||
.cm-string-2 {
|
||||
color: var(--code-string);
|
||||
}
|
||||
|
||||
.cm-operator {
|
||||
color: var(--code-operator);
|
||||
}
|
||||
|
||||
.cm-link,
|
||||
.cm-variable,
|
||||
.cm-variable-2,
|
||||
.cm-variable-3 {
|
||||
color: var(--code-property);
|
||||
}
|
||||
|
||||
.cm-keyword {
|
||||
color: var(--code-keyword);
|
||||
}
|
||||
|
||||
.cm-atom {
|
||||
color: var(--code-important)
|
||||
}
|
||||
}
|
||||
5
src/css/other/hidden.scss
Normal file
5
src/css/other/hidden.scss
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
body.cs-plugin {
|
||||
.cs-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
2
src/css/other/init.scss
Normal file
2
src/css/other/init.scss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@import url("frontmatter.scss");
|
||||
@import url("hidden.scss");
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
div.print {
|
||||
--line-wrapping: pre-wrap !important;
|
||||
}
|
||||
.code-styler div.print pre.code-styler-pre code {
|
||||
max-height: unset !important;
|
||||
}
|
||||
.code-styler div.print pre.code-styler-pre.code-styler-folded code {
|
||||
display: none !important;
|
||||
}
|
||||
0
src/css/plugins/advanced-slides/fence.scss
Normal file
0
src/css/plugins/advanced-slides/fence.scss
Normal file
0
src/css/plugins/advanced-slides/inline.scss
Normal file
0
src/css/plugins/advanced-slides/inline.scss
Normal file
0
src/css/plugins/code-emitter/fence.scss
Normal file
0
src/css/plugins/code-emitter/fence.scss
Normal file
0
src/css/plugins/code-emitter/inline.scss
Normal file
0
src/css/plugins/code-emitter/inline.scss
Normal file
0
src/css/plugins/embed-code/fence.scss
Normal file
0
src/css/plugins/embed-code/fence.scss
Normal file
0
src/css/plugins/embed-code/inline.scss
Normal file
0
src/css/plugins/embed-code/inline.scss
Normal file
0
src/css/plugins/execute-code/fence.scss
Normal file
0
src/css/plugins/execute-code/fence.scss
Normal file
0
src/css/plugins/execute-code/inline.scss
Normal file
0
src/css/plugins/execute-code/inline.scss
Normal file
0
src/css/plugins/file-include/fence.scss
Normal file
0
src/css/plugins/file-include/fence.scss
Normal file
0
src/css/plugins/file-include/inline.scss
Normal file
0
src/css/plugins/file-include/inline.scss
Normal file
12
src/css/plugins/init.scss
Normal file
12
src/css/plugins/init.scss
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
@import url("./advanced-slides/fence.scss");
|
||||
@import url("./advanced-slides/inline.scss");
|
||||
@import url("./code-emitter/fence.scss");
|
||||
@import url("./code-emitter/inline.scss");
|
||||
@import url("./embed-code/fence.scss");
|
||||
@import url("./embed-code/inline.scss");
|
||||
@import url("./execute-code/fence.scss");
|
||||
@import url("./execute-code/inline.scss");
|
||||
@import url("./file-include/fence.scss");
|
||||
@import url("./file-include/inline.scss");
|
||||
@import url("./slides/fence.scss");
|
||||
@import url("./slides/inline.scss");
|
||||
0
src/css/plugins/slides/fence.scss
Normal file
0
src/css/plugins/slides/fence.scss
Normal file
0
src/css/plugins/slides/inline.scss
Normal file
0
src/css/plugins/slides/inline.scss
Normal file
1
src/css/scss/init.scss
Normal file
1
src/css/scss/init.scss
Normal file
|
|
@ -0,0 +1 @@
|
|||
@import url("mixins.scss");
|
||||
|
|
@ -5,9 +5,3 @@ $prefix: "cs-";
|
|||
@content;
|
||||
}
|
||||
}
|
||||
|
||||
body.cs-plugin {
|
||||
.cs-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
2
src/css/settings/init.scss
Normal file
2
src/css/settings/init.scss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
@import url("settings.scss");
|
||||
@import url("style_settings.css");
|
||||
0
src/css/settings/settings.scss
Normal file
0
src/css/settings/settings.scss
Normal file
0
src/css/settings/style_settings.css
Normal file
0
src/css/settings/style_settings.css
Normal file
8
src/css/styles.scss
Normal file
8
src/css/styles.scss
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
@import url("scss/init.scss");
|
||||
|
||||
@import url("fence/init.scss");
|
||||
@import url("inline/init.scss");
|
||||
@import url("settings/init.scss");
|
||||
@import url("other/init.scss");
|
||||
|
||||
@import url("plugins/init.scss");
|
||||
42
src/main.ts
42
src/main.ts
|
|
@ -1,25 +1,25 @@
|
|||
import { Plugin} from "obsidian";
|
||||
import { CodeStylerSettings } from "./Internal/types/settings";
|
||||
import { SettingsTab } from "./Internal/Interface/Settings/settingsTab";
|
||||
import { renderedInlineCodeDetecting } from "./Internal/Detecting/Rendered/inline";
|
||||
import { renderedFencedCodeDetecting } from "./Internal/Detecting/Rendered/fenced";
|
||||
import { toPostProcess } from "./Internal/utils/rendered";
|
||||
import { mutationObservers, renderedFencedCodeDecorating, renderedFencedCodeUndecorating } from "./Internal/Decorating/Rendered/fenced";
|
||||
import { renderedInlineCodeDecorating, renderedInlineCodeUndecorating } from "./Internal/Decorating/Rendered/inline";
|
||||
import { DEFAULT_SETTINGS } from "./Internal/constants/settings";
|
||||
import { convertSettings } from "./Internal/utils/settings";
|
||||
import { EXTERNAL_REFERENCE_CACHE, EXTERNAL_REFERENCE_PATH, REFERENCE_CODEBLOCK } from "./Internal/constants/reference";
|
||||
import { registerCommands } from "./Internal/Interface/Actions/commands";
|
||||
import { loadLanguageIcons, unloadLanguageIcons } from "./Resources/icons";
|
||||
import { registerRerenderingOnWorkspaceChange, rerenderRenderedView } from "./Internal/Interface/View/rendered";
|
||||
import { addModes, parseObsidianMarkdown } from "./Internal/Decorating/LivePreview/codemirror/modes";
|
||||
import { applyStyling, removeStyling } from "./Internal/Decorating/styles";
|
||||
import { manageExternalReferencedFiles } from "./Internal/utils/reference";
|
||||
import { getReferenceCodeMirrorExtensions as getReferenceCodemirrorExtensions } from "./Internal/Decorating/LivePreview/reference";
|
||||
import { getFenceCodemirrorExtensions } from "./Internal/Decorating/LivePreview/fenced";
|
||||
import { getInlineCodeMirrorExtensions as getInlineCodemirrorExtensions } from "./Internal/Decorating/LivePreview/inline";
|
||||
import { referenceCodeblockProcessor } from "./Internal/Decorating/Rendered/reference";
|
||||
import { createViewUpdater } from "./Internal/Decorating/LivePreview/codemirror/utils";
|
||||
import { CodeStylerSettings } from "./internal/types/settings";
|
||||
import { SettingsTab } from "./internal/Interface/settings/settingsTab";
|
||||
import { renderedInlineCodeDetecting } from "./internal/detecting/Rendered/inline";
|
||||
import { renderedFencedCodeDetecting } from "./internal/detecting/Rendered/fenced";
|
||||
import { toPostProcess } from "./internal/utils/rendered";
|
||||
import { mutationObservers, renderedFencedCodeDecorating, renderedFencedCodeUndecorating } from "./internal/Decorating/Rendered/fenced";
|
||||
import { renderedInlineCodeDecorating, renderedInlineCodeUndecorating } from "./internal/Decorating/Rendered/inline";
|
||||
import { DEFAULT_SETTINGS } from "./internal/constants/settings";
|
||||
import { convertSettings } from "./internal/utils/settings";
|
||||
import { EXTERNAL_REFERENCE_CACHE, EXTERNAL_REFERENCE_PATH, REFERENCE_CODEBLOCK } from "./internal/constants/reference";
|
||||
import { registerCommands } from "./internal/Interface/actions/commands";
|
||||
import { loadLanguageIcons, unloadLanguageIcons } from "./resources/icons";
|
||||
import { registerRerenderingOnWorkspaceChange, rerenderRenderedView } from "./internal/Interface/View/rendered";
|
||||
import { addModes, parseObsidianMarkdown } from "./internal/Decorating/LivePreview/codemirror/modes";
|
||||
import { applyStyling, removeStyling } from "./internal/Decorating/styles";
|
||||
import { manageExternalReferencedFiles } from "./internal/utils/reference";
|
||||
import { getReferenceCodeMirrorExtensions as getReferenceCodemirrorExtensions } from "./internal/Decorating/LivePreview/reference";
|
||||
import { getFenceCodemirrorExtensions } from "./internal/Decorating/LivePreview/fenced";
|
||||
import { getInlineCodeMirrorExtensions as getInlineCodemirrorExtensions } from "./internal/Decorating/LivePreview/inline";
|
||||
import { referenceCodeblockProcessor } from "./internal/Decorating/Rendered/reference";
|
||||
import { createViewUpdater } from "./internal/decorating/LivePreview/codemirror/utils";
|
||||
|
||||
export default class CodeStylerPlugin extends Plugin {
|
||||
settings: CodeStylerSettings;
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
/** Import stylesheets */
|
||||
@import url("./css/_settings.scss");
|
||||
@import url("./css/_style_settings.css");
|
||||
|
||||
@import url("./css/fence.scss");
|
||||
@import url("./css/inline.scss");
|
||||
// @import url("./css/frontmatter.scss");
|
||||
// @import url("./css/pdfExport.scss");
|
||||
// @import url("./css/pickr.scss");
|
||||
// @import url("./css/settings.scss");
|
||||
// @import url("./css/pluginCompatibility.scss");
|
||||
|
||||
@import url("./css/shiki.scss");
|
||||
|
||||
//TODO: Remove
|
||||
@import url("./css/_old_variables.scss");
|
||||
190
styles.css
190
styles.css
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue