Skip to content

Commit

Permalink
2.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Apr 26, 2024
1 parent 64186b6 commit 8136a48
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.1.2

- New: Added an option to toggle SNW off and on in Source Mode. By default, it is toggled off, since source mode is intended to view the raw markdown. This can be changed in the settings. [#137](https://github.com/TfTHacker/obsidian42-strange-new-worlds/issues/137)

# 2.1.1

- Fix to sidepane not opening after being closed [#136](https://github.com/TfTHacker/obsidian42-strange-new-worlds/issues/136)
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian42-strange-new-worlds",
"name": "Strange New Worlds",
"version": "2.1.1",
"version": "2.1.2",
"minAppVersion": "1.5.11",
"description": "Help see how your vault is interconnected with visual indicators.",
"author": "TfTHacker",
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian42-strange-new-worlds",
"version": "2.1.1",
"version": "2.1.2",
"description": "Revealing networked thought and the strange new worlds created by your vault",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand All @@ -27,9 +27,9 @@
"@html-eslint/eslint-plugin": "^0.24.1",
"@html-eslint/parser": "^0.24.1",
"@types/obsidian-typings": "github:Fevol/obsidian-typings",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"@typescript-eslint/utils": "^7.7.0",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"@typescript-eslint/utils": "^7.7.1",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-css": "^0.9.2",
Expand Down
2 changes: 2 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface Settings {
displayIncomingFilesheader: boolean;
displayInlineReferencesLivePreview: boolean;
displayInlineReferencesMarkdown: boolean;
displayInlineReferencesInSourceMode: boolean;
displayEmbedReferencesInGutter: boolean;
displayEmbedReferencesInGutterMobile: boolean;
displayPropertyReferences: boolean;
Expand All @@ -34,6 +35,7 @@ export const DEFAULT_SETTINGS: Settings = {
displayIncomingFilesheader: true,
displayInlineReferencesLivePreview: true,
displayInlineReferencesMarkdown: true,
displayInlineReferencesInSourceMode: false,
displayEmbedReferencesInGutter: false,
displayEmbedReferencesInGutterMobile: false,
displayPropertyReferences: true,
Expand Down
15 changes: 15 additions & 0 deletions src/ui/SettingsTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,21 @@ export class SettingsTab extends PluginSettingTab {
});
});

new Setting(containerEl)
.setName('Show SNW indicators in Source Mode ')
.setDesc(
'While in Source Mode of a document, display inline of the text of documents all reference counts for links, blocks and embeds.' +
'By default, this is turned off since the goal of Source Mode is to see the raw markdown.' +
'Note: files may need to be closed and reopened for this setting to take effect.'
)
.addToggle((cb: ToggleComponent) => {
cb.setValue(this.plugin.settings.displayInlineReferencesInSourceMode);
cb.onChange(async (value: boolean) => {
this.plugin.settings.displayInlineReferencesInSourceMode = value;
await this.plugin.saveSettings();
});
});

new Setting(containerEl)
.setName('Embed references in Gutter in Live Preview Mode (Desktop)')
.setDesc(
Expand Down
3 changes: 3 additions & 0 deletions src/view-extensions/gutters-cm6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ const ReferenceGutterExtension = gutter({
lineMarker(editorView: EditorView, line: BlockInfo) {
const mdView = editorView.state.field(editorInfoField);

// Check if should show in source mode
if (mdView.currentMode?.sourceMode === true && plugin.settings.displayInlineReferencesInSourceMode === false) return null;

if (!mdView.file) return null;
const transformedCache = getSNWCacheByFile(mdView.file);

Expand Down
4 changes: 4 additions & 0 deletions src/view-extensions/references-cm6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export const InlineReferenceExtension = ViewPlugin.fromClass(
const mdView = view.state.field(editorInfoField);
// there is no file, likely a canvas file, so stop processing
if (!mdView.file) return;

// Check if should show in source mode
if (mdView.currentMode?.sourceMode === true && plugin.settings.displayInlineReferencesInSourceMode === false) return null;

const mdViewFile = mdView.file!;
const transformedCache = getSNWCacheByFile(mdViewFile);

Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"2.0.2": "1.5.11",
"2.0.3": "1.5.11",
"2.1.0": "1.5.11",
"2.1.1": "1.5.11"
"2.1.1": "1.5.11",
"2.1.2": "1.5.11"
}

0 comments on commit 8136a48

Please sign in to comment.