generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring in mProjectsCode major refactor
- Loading branch information
Showing
52 changed files
with
3,716 additions
and
2,736 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
jest: true, | ||
}, | ||
extends: [ | ||
'eslint:recommended', | ||
'plugin:@typescript-eslint/recommended', | ||
], | ||
globals: { | ||
Atomics: 'readonly', | ||
SharedArrayBuffer: 'readonly', | ||
}, | ||
parser: '@typescript-eslint/parser', | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 2018, | ||
sourceType: 'module', | ||
}, | ||
plugins: ['@typescript-eslint'], | ||
rules: { | ||
'@typescript-eslint/explicit-function-return-type': 'off', | ||
'@typescript-eslint/member-delimiter-style': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-empty-function': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
'@typescript-eslint/no-use-before-define': 'off', | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-this-alias': 'off', | ||
'@typescript-eslint/no-inferrable-types': 'off', | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'react/no-unescaped-entities': 'off', | ||
'react/prop-types': 'off', | ||
'react/react-in-jsx-scope': 'off', | ||
'linebreak-style': ['error', 'unix'], | ||
indent: 'off', | ||
quotes: 'off', | ||
}, | ||
}; |
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
arrowParens: 'always', | ||
bracketSpacing: true, | ||
endOfLine: 'lf', | ||
htmlWhitespaceSensitivity: 'css', | ||
jsxBracketSameLine: false, | ||
jsxSingleQuote: false, | ||
printWidth: 80, | ||
proseWrap: 'preserve', | ||
quoteProps: 'as-needed', | ||
semi: true, | ||
singleQuote: true, | ||
trailingComma: 'es5', | ||
useTabs: true, | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -1,72 +1,83 @@ | ||
import {App, Modal, Setting, TextAreaComponent} from "obsidian"; | ||
import CSSSettingsPlugin from "./main"; | ||
import {SettingValue} from "./SettingsManager"; | ||
|
||
export class ExportModal extends Modal { | ||
plugin: CSSSettingsPlugin; | ||
section: string; | ||
config: Record<string, SettingValue>; | ||
|
||
constructor(app: App, plugin: CSSSettingsPlugin, section: string, config: Record<string, SettingValue>) { | ||
super(app); | ||
this.plugin = plugin; | ||
this.config = config; | ||
this.section = section; | ||
} | ||
|
||
onOpen() { | ||
let {contentEl, modalEl} = this; | ||
|
||
modalEl.addClass("modal-style-settings"); | ||
|
||
new Setting(contentEl).setName(`Export settings for: ${this.section}`).then((setting) => { | ||
const output = JSON.stringify(this.config, null, 2); | ||
|
||
// Build a copy to clipboard link | ||
setting.controlEl.createEl( | ||
"a", | ||
{ | ||
cls: "style-settings-copy", | ||
text: "Copy to clipboard", | ||
href: "#", | ||
}, | ||
(copyButton) => { | ||
new TextAreaComponent(contentEl).setValue(output).then((textarea) => { | ||
copyButton.addEventListener("click", (e) => { | ||
e.preventDefault(); | ||
|
||
// Select the textarea contents and copy them to the clipboard | ||
textarea.inputEl.select(); | ||
textarea.inputEl.setSelectionRange(0, 99999); | ||
document.execCommand("copy"); | ||
|
||
copyButton.addClass("success"); | ||
|
||
setTimeout(() => { | ||
// If the button is still in the dom, remove the success class | ||
if (copyButton.parentNode) { | ||
copyButton.removeClass("success"); | ||
} | ||
}, 2000); | ||
}); | ||
}); | ||
}, | ||
); | ||
|
||
// Build a download link | ||
setting.controlEl.createEl("a", { | ||
cls: "style-settings-download", | ||
text: "Download", | ||
attr: { | ||
download: "style-settings.json", | ||
href: `data:application/json;charset=utf-8,${encodeURIComponent(output)}`, | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
onClose() { | ||
let {contentEl} = this; | ||
contentEl.empty(); | ||
} | ||
} | ||
import { App, Modal, Setting, TextAreaComponent } from 'obsidian'; | ||
import CSSSettingsPlugin from './main'; | ||
import { SettingValue } from './SettingsManager'; | ||
|
||
export class ExportModal extends Modal { | ||
plugin: CSSSettingsPlugin; | ||
section: string; | ||
config: Record<string, SettingValue>; | ||
|
||
constructor( | ||
app: App, | ||
plugin: CSSSettingsPlugin, | ||
section: string, | ||
config: Record<string, SettingValue> | ||
) { | ||
super(app); | ||
this.plugin = plugin; | ||
this.config = config; | ||
this.section = section; | ||
} | ||
|
||
onOpen() { | ||
const { contentEl, modalEl } = this; | ||
|
||
modalEl.addClass('modal-style-settings'); | ||
|
||
new Setting(contentEl) | ||
.setName(`Export settings for: ${this.section}`) | ||
.then((setting) => { | ||
const output = JSON.stringify(this.config, null, 2); | ||
|
||
// Build a copy to clipboard link | ||
setting.controlEl.createEl( | ||
'a', | ||
{ | ||
cls: 'style-settings-copy', | ||
text: 'Copy to clipboard', | ||
href: '#', | ||
}, | ||
(copyButton) => { | ||
new TextAreaComponent(contentEl) | ||
.setValue(output) | ||
.then((textarea) => { | ||
copyButton.addEventListener('click', (e) => { | ||
e.preventDefault(); | ||
|
||
// Select the textarea contents and copy them to the clipboard | ||
textarea.inputEl.select(); | ||
textarea.inputEl.setSelectionRange(0, 99999); | ||
document.execCommand('copy'); | ||
|
||
copyButton.addClass('success'); | ||
|
||
setTimeout(() => { | ||
// If the button is still in the dom, remove the success class | ||
if (copyButton.parentNode) { | ||
copyButton.removeClass('success'); | ||
} | ||
}, 2000); | ||
}); | ||
}); | ||
} | ||
); | ||
|
||
// Build a download link | ||
setting.controlEl.createEl('a', { | ||
cls: 'style-settings-download', | ||
text: 'Download', | ||
attr: { | ||
download: 'style-settings.json', | ||
href: `data:application/json;charset=utf-8,${encodeURIComponent( | ||
output | ||
)}`, | ||
}, | ||
}); | ||
}); | ||
} | ||
|
||
onClose() { | ||
const { contentEl } = this; | ||
contentEl.empty(); | ||
} | ||
} |
Oops, something went wrong.