Skip to content

Commit

Permalink
Merge pull request #70 from RyotaUshio/cleanup-before-release-0.2.0
Browse files Browse the repository at this point in the history
cleanup, dependency resolution
  • Loading branch information
RyotaUshio authored Aug 4, 2023
2 parents 2020636 + e42b7dd commit a752592
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 35 deletions.
48 changes: 35 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@lezer/common": "^1.0.3",
"@codemirror/language": "^6.0.0",
"yaml": "^2.3.1"
}
}
17 changes: 5 additions & 12 deletions src/callout_view.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { Extension } from '@codemirror/state';
import { Transaction } from '@codemirror/state';
import { StateField } from '@codemirror/state';
import { syntaxTree } from '@codemirror/language';
import { RangeSetBuilder } from '@codemirror/state';
import { EditorState } from '@codemirror/state';
import { Decoration, DecorationSet, EditorView, WidgetType } from "@codemirror/view";
import { SyntaxNodeRef } from '@lezer/common';
import { finishRenderMath, renderMath } from "obsidian";
import { Extension, Transaction, StateField, RangeSetBuilder, EditorState } from '@codemirror/state';
import { Decoration, DecorationSet, EditorView, WidgetType } from "@codemirror/view";
import { syntaxTree } from '@codemirror/language';

import { nodeText } from 'utils';


const DISPLAY_MATH_BEGIN = "formatting_formatting-math_formatting-math-begin_keyword_math_math-block";
Expand Down Expand Up @@ -139,10 +136,6 @@ function getMathInfos(state: EditorState): MathInfo[] {
return mathInfos;
}

function nodeText(node: SyntaxNodeRef, state: EditorState): string {
return state.sliceDoc(node.from, node.to);
}

function isInBlockquoteOrCallout(state: EditorState): boolean {
let cursor = state.selection.ranges[0].head;
let tree = syntaxTree(state);
Expand Down
6 changes: 1 addition & 5 deletions src/math_callout_title_hider.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { mathCalloutTitlePlulgin } from 'math_callouts_view';
import { RangeSetBuilder } from '@codemirror/state';
import { syntaxTree } from "@codemirror/language";
import { Decoration, DecorationSet, EditorView, MatchDecorator, PluginValue, ViewPlugin, ViewUpdate, WidgetType } from "@codemirror/view"
import { MATH_CALLOUT_PATTERN, formatTitleWithoutSubtitle, matchMathCallout, readMathCalloutMetadata, readMathCalloutSettingsAndTitle } from "autoIndex"
import MathPlugin from "main";
import { SmartCalloutModal } from "modals";
import { App, Editor, MarkdownView, TFile } from "obsidian";
import { MathSettings } from "settings";
import { formatTitle, overwriteMathCalloutMetadata, resolveSettings } from "smart_callouts";
import { nodeText, renderTextWithMath } from "utils";
import { nodeText } from 'utils';


export const MATH_CALLOUT_PATTERN_GLOBAL = new RegExp(MATH_CALLOUT_PATTERN.source, "g");
Expand Down
6 changes: 2 additions & 4 deletions src/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,16 @@ abstract class MathSettingModal<SettingsType> extends Modal {


export class MathCalloutModal extends MathSettingModal<MathSettings> {

constructor(
app: App,
plugin: MathPlugin,
public view: MarkdownView,
callback: (settings: MathSettings) => void,
public buttonText?: string,
public headerText?: string,
public buttonText: string,
public headerText: string,
currentCalloutSettings?: CalloutSettings,
) {
super(app, plugin, callback, currentCalloutSettings);
this.buttonText = buttonText ?? "Insert";
}


Expand Down
8 changes: 7 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EditorState } from '@codemirror/state';
import { SyntaxNodeRef } from '@lezer/common';

// Generic utility functions handing files.

Expand Down Expand Up @@ -203,6 +205,10 @@ export function insertAfter(referenceNode: HTMLElement, newNode: HTMLElement) {
referenceNode.parentNode?.insertBefore(newNode, referenceNode.nextSibling);
}

export function nodeText(node: SyntaxNodeRef, state: EditorState): string {
return state.sliceDoc(node.from, node.to);
}

const ROMAN = ["", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM",
"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", "XC",
"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"];
Expand Down Expand Up @@ -239,4 +245,4 @@ export const CONVERTER = {
"Alph": toAlphUpper,
"roman": toRomanLower,
"Roman": toRomanUpper,
}
}

0 comments on commit a752592

Please sign in to comment.