generated from mProjectsCode/lemons-plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 11
Added Word Wrap as a global setting and some formatting to the Settings page #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Truncated
wants to merge
7
commits into
mProjectsCode:master
Choose a base branch
from
Truncated:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
29dfa66
Update README.md
Truncated 63bffb6
Update manifest-beta.json
Truncated 906827e
Update manifest.json
Truncated 42ba0d3
Update index.md
Truncated 7a0c61a
Update SettingsTab.ts
Truncated 14b20ce
Update Settings.ts
Truncated 4fa82aa
Update main.ts
Truncated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -138,6 +138,7 @@ export default class ShikiPlugin extends Plugin { | |
themeCssRoot: 'div.expressive-code', | ||
defaultProps: { | ||
showLineNumbers: false, | ||
wrap: this.settings.wrapGlobal, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, you should probably access |
||
}, | ||
}); | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ import type ShikiPlugin from 'src/main'; | |
import { StringSelectModal } from 'src/settings/StringSelectModal'; | ||
import { bundledThemesInfo } from 'shiki'; | ||
|
||
const needsARestart = '<strong style="color: var(--text-accent)">Requires restart of Obsidian to take effect.</strong>' | ||
export class ShikiSettingsTab extends PluginSettingTab { | ||
plugin: ShikiPlugin; | ||
|
||
|
@@ -15,12 +16,19 @@ export class ShikiSettingsTab extends PluginSettingTab { | |
display(): void { | ||
this.containerEl.empty(); | ||
|
||
// Theme | ||
const ThemeDesc = new DocumentFragment() | ||
ThemeDesc.createSpan({}, span => { | ||
span.innerHTML = `Select the theme for the code blocks.<br/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't use innerHTML, even if it is a "secure" string. |
||
⚠️ ${needsARestart} | ||
` | ||
}) | ||
const themes = Object.fromEntries(bundledThemesInfo.map(theme => [theme.id, `${theme.displayName} (${theme.type})`])); | ||
themes['obsidian-theme'] = 'Obsidian built-in (both)'; | ||
|
||
new Setting(this.containerEl) | ||
.setName('Theme') | ||
.setDesc('Select the theme for the code blocks. RESTART REQUIRED AFTER CHANGES.') | ||
.setDesc(ThemeDesc) | ||
.addDropdown(dropdown => { | ||
dropdown.addOptions(themes); | ||
dropdown.setValue(this.plugin.settings.theme).onChange(async value => { | ||
|
@@ -29,21 +37,51 @@ export class ShikiSettingsTab extends PluginSettingTab { | |
}); | ||
}); | ||
|
||
// Prefer theme colors | ||
const preferThemeColorsDesc = new DocumentFragment() | ||
preferThemeColorsDesc.createSpan({}, span => { | ||
span.innerHTML = `When enabled the plugin will prefer theme colors over CSS variables for things like the code block background.<br/> | ||
⚠️ ${needsARestart} | ||
` | ||
}) | ||
new Setting(this.containerEl) | ||
.setName('Prefer theme colors') | ||
.setDesc( | ||
'When enabled the plugin will prefer theme colors over CSS variables for things like the code block background. RESTART REQUIRED AFTER CHANGES.', | ||
) | ||
.setDesc(preferThemeColorsDesc) | ||
.addToggle(toggle => { | ||
toggle.setValue(this.plugin.settings.preferThemeColors).onChange(async value => { | ||
this.plugin.settings.preferThemeColors = value; | ||
await this.plugin.saveSettings(); | ||
}); | ||
}); | ||
|
||
// Wrap code in blocks | ||
const wrapCodeDesc = new DocumentFragment() | ||
wrapCodeDesc.createSpan({}, span => { | ||
span.innerHTML = `Set the default value for word wrap in all code blocks globally.<br/> | ||
<a href=https://expressive-code.com/key-features/word-wrap/>This can be manually overridden per block with these instructions</a>.<br/> | ||
⚠️ ${needsARestart} | ||
` | ||
}) | ||
new Setting(this.containerEl) | ||
.setName('Wrap code in blocks') | ||
.setDesc(wrapCodeDesc) | ||
.addToggle(toggle => { | ||
toggle.setValue(this.plugin.settings.wrapGlobal).onChange(async value => { | ||
this.plugin.settings.wrapGlobal = value; | ||
await this.plugin.saveSettings(); | ||
}); | ||
}); | ||
|
||
// Excluded Languages | ||
const excLangDesc = new DocumentFragment() | ||
excLangDesc.createSpan({}, span => { | ||
span.innerHTML = `Configure language to exclude.<br/> | ||
⚠️ ${needsARestart} | ||
` | ||
}) | ||
new Setting(this.containerEl) | ||
.setName('Excluded Languages') | ||
.setDesc('Configure language to exclude. RESTART REQUIRED AFTER CHANGES.') | ||
.setDesc(excLangDesc) | ||
.addButton(button => { | ||
button.setButtonText('Add Language Rule').onClick(() => { | ||
const modal = new StringSelectModal(this.plugin, Array.from(this.plugin.loadedLanguages.keys()), language => { | ||
|
@@ -54,7 +92,7 @@ export class ShikiSettingsTab extends PluginSettingTab { | |
modal.open(); | ||
}); | ||
}); | ||
|
||
for (const language of this.plugin.settings.disabledLanguages) { | ||
new Setting(this.containerEl).setName(language).addButton(button => { | ||
button | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.