mirror of
https://github.com/mayurankv/Obsidian-Code-Styler.git
synced 2026-07-22 08:10:29 +00:00
update
This commit is contained in:
parent
d88824d255
commit
5f227b6ff6
3 changed files with 23 additions and 5 deletions
|
|
@ -75,14 +75,14 @@ export function renderedFencedCodeUndecorating(): void {
|
|||
|
||||
export function renderedViewFold(
|
||||
contentEl: HTMLElement,
|
||||
fold?: boolean,
|
||||
fold: boolean | null,
|
||||
): void {
|
||||
const codeblockPreElements = contentEl.querySelectorAll(`pre.${PREFIX}pre`);
|
||||
codeblockPreElements.forEach(
|
||||
(codeblockPreElement: HTMLElement) => {
|
||||
foldFencePreElement(
|
||||
codeblockPreElement,
|
||||
(typeof fold === "undefined") ? (codeblockPreElement.getAttribute(DEFAULT_FOLD_ATTRIBUTE) ?? "false") === "true" : fold,
|
||||
fold ?? (codeblockPreElement.getAttribute(DEFAULT_FOLD_ATTRIBUTE) ?? "false") === "true",
|
||||
);
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -267,16 +267,17 @@ function setTitleAndReference(
|
|||
): Partial<FenceCodeParameters> {
|
||||
if (parameterValue !== null) {
|
||||
const linkInfo = parseLink(parameterValue)
|
||||
if (linkInfo === null)
|
||||
if (linkInfo === null) {
|
||||
if (parameterKey === "title")
|
||||
return { ...result, title: parameterValue }
|
||||
else
|
||||
return result
|
||||
else
|
||||
} else {
|
||||
if ((parameterKey === "title") || !("title" in result))
|
||||
return {...result, ...linkInfo}
|
||||
return { ...result, ...linkInfo }
|
||||
else
|
||||
return { ...result, reference: linkInfo.reference }
|
||||
}
|
||||
|
||||
} else {
|
||||
if (parameterKey !== "title" || !("title" in result))
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
import { MarkdownView } from "obsidian";
|
||||
import CodeStylerPlugin from "src/main";
|
||||
import { renderedViewFold } from "../Decorating/Rendered/Fenced";
|
||||
|
||||
export function viewFold(
|
||||
fold: boolean | null,
|
||||
plugin: CodeStylerPlugin,
|
||||
) {
|
||||
const activeView = plugin.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (activeView) {
|
||||
if (activeView.getMode() === "preview")
|
||||
renderedViewFold(activeView.contentEl, fold);
|
||||
else if (activeView.getMode() === "source")
|
||||
//@ts-expect-error Undocumented Obsidian API
|
||||
editingDocumentFold(activeView.editor.cm.docView.view, fold);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue