Skip to content

Commit ba2d77d

Browse files
committed
Fix some things according to the style guide
1 parent e077139 commit ba2d77d

9 files changed

+40
-58
lines changed

.eslintignore

-3
This file was deleted.

.eslintrc

-23
This file was deleted.

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Obsidian Paste-As-Embed
22

3-
When pasting text into a note, check the text against regexp patterns. When it matches, create a new note containing the text, and embed that note into the current note.
3+
When pasting text into a note, check the text against regexp patterns. When it matches, create a new note containing the text, and embed that note into the active note.
44

55
## How to use
66

@@ -16,9 +16,9 @@ When text is pasted from the clipboard, it is checked against a list of user-def
1616
When a rule is engaged:
1717

1818
- the pasted text is inserted into a template, if one is supplied for the rule;
19-
- a new note is created, with its name and directory determined according to the settings defined for the rule;
19+
- a new note is created, with its name and folder determined according to the settings defined for the rule;
2020
- the contents of the new note are the (potentially templated) pasted text;
21-
- the new note is embedded at the current position in the currently open note.
21+
- the new note is embedded at the current position in the active note.
2222

2323
If no rule is engaged, pasting proceeds as it normally would.
2424

@@ -48,11 +48,15 @@ Parts of this plugin are directly derived (see source comments) from parts of th
4848
- [obsidian-admonition](https://github.com/javalent/admonitions)
4949
- [advanced-paste](https://github.com/kxxt/obsidian-advanced-paste)
5050

51-
Additionally, I took inspiration from [obsidian-custom-attachment-location](https://github.com/RainCat1998/obsidian-custom-attachment-location) concerning the customization of note and directory naming.
51+
Additionally, I took inspiration from [obsidian-custom-attachment-location](https://github.com/RainCat1998/obsidian-custom-attachment-location) concerning the customization of note and folder naming.
5252

5353
## TODO
5454

5555
- [ ] Allow individual rules to be toggled on and off
5656
- [ ] Control precedence/order of rules
5757
- [ ] Allow rules to be either 1) regexp-based, or 2) associated with hotkeys
58-
- [ ] Toggle CSS styling (e.g. clean-embeds)
58+
- [ ] Toggle CSS styling (e.g. clean-embeds)
59+
60+
### Mobile support
61+
62+
- [ ] Replace Node.js `path`

eslint.config.mjs

+3
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ export default tseslint.config(
88
...tseslint.configs.recommended,
99
...tseslint.configs.strict,
1010
...tseslint.configs.stylistic,
11+
{
12+
ignores: ["node_modules/", "main.js"]
13+
}
1114
);

main.ts

+21-21
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,11 @@ export default class PasteAsEmbed extends Plugin {
7575
}
7676

7777
const embedNoteName = this.getEmbedNoteName(matchingRule, view.file);
78-
const embedDirectory = this.getEmbedDirectory(matchingRule, view.file)
79-
const embedFilePath = path.join(embedDirectory, embedNoteName + ".md");
78+
const embedFolder = this.getEmbedFolder(matchingRule, view.file)
79+
const embedFilePath = path.join(embedFolder, embedNoteName + ".md");
8080

81-
if (!await this.adapter.exists(embedDirectory))
82-
await this.adapter.mkdir(embedDirectory);
81+
if (!await this.adapter.exists(embedFolder))
82+
await this.adapter.mkdir(embedFolder);
8383

8484
this.app.vault.create(embedFilePath, txt)
8585

@@ -110,19 +110,19 @@ export default class PasteAsEmbed extends Plugin {
110110
return name;
111111
}
112112

113-
getEmbedDirectory(rule: PasteRule, file: TFile) {
114-
const directory = path.dirname(file.path);
113+
getEmbedFolder(rule: PasteRule, file: TFile) {
114+
const folder = path.dirname(file.path);
115115

116-
const ruleDirectory = rule.directory.replace('${notename}', file.basename);
116+
const ruleFolder = rule.folder.replace('${notename}', file.basename);
117117

118-
let embedDirectory;
119-
if (rule.directory.startsWith('./')) {
120-
embedDirectory = path.join(directory, ruleDirectory);
118+
let embedFolder;
119+
if (rule.folder.startsWith('./')) {
120+
embedFolder = path.join(folder, ruleFolder);
121121
} else {
122-
embedDirectory = ruleDirectory;
122+
embedFolder = ruleFolder;
123123
}
124124

125-
return embedDirectory;
125+
return embedFolder;
126126
}
127127

128128
async onload() { // Configure resources needed by the plugin.
@@ -169,7 +169,7 @@ export default class PasteAsEmbed extends Plugin {
169169
export interface PasteRule {
170170
name: string; // Identifies the rule
171171
desc?: string; // Describes the rule
172-
directory: string; // Where to create the new file
172+
folder: string; // Where to create the new file
173173
filenameFmt: string; // How to name the embedded notes.
174174
pattern: string; // Clipboard text pattern that triggers the rule
175175
template?: string; // Insert the pasted text into this template, when writing to new file (e.g. code fence)
@@ -220,7 +220,7 @@ class PasteAsEmbedSettingTab extends PluginSettingTab {
220220
if (modal.saved) {
221221
const rule = {
222222
name: modal.name,
223-
directory: modal.directory,
223+
folder: modal.folder,
224224
pattern: modal.pattern,
225225
template: modal.template,
226226
desc: modal.desc,
@@ -261,7 +261,7 @@ class PasteAsEmbedSettingTab extends PluginSettingTab {
261261
if (modal.saved) {
262262
const modalRule = {
263263
name: modal.name,
264-
directory: modal.directory,
264+
folder: modal.folder,
265265
pattern: modal.pattern,
266266
template: modal.template,
267267
desc: modal.desc,
@@ -350,7 +350,7 @@ class ConfirmDeleteModal extends Modal {
350350

351351
class SettingsModal extends Modal {
352352
name: string; // Identifies the rule
353-
directory: string; // Where to create the new file
353+
folder: string; // Where to create the new file
354354
pattern: string; // Clipboard text pattern that triggers the rule
355355
template?: string; // Insert the pasted text into this template, when writing to new file (e.g. code fence)
356356
desc?: string;
@@ -363,7 +363,7 @@ class SettingsModal extends Modal {
363363

364364
if (rule) {
365365
this.name = rule.name;
366-
this.directory = rule.directory;
366+
this.folder = rule.folder;
367367
this.pattern = rule.pattern;
368368
this.template = rule.template;
369369
this.desc = rule.desc;
@@ -415,13 +415,13 @@ class SettingsModal extends Modal {
415415
);
416416

417417
new Setting(settingDiv)
418-
.setName('Embedded note directory')
419-
.setDesc('Where to save the embedded notes. Start with "./" for path relative to the directory of the current note. Use ${notename} for the name of the current note.')
418+
.setName('Embedded note folder')
419+
.setDesc('Where to save the embedded notes. Start with "./" for path relative to the folder of the current note. Use ${notename} for the name of the current note.')
420420
.addText(text => text
421421
.setPlaceholder('')
422-
.setValue(this.directory ?? "")
422+
.setValue(this.folder ?? "")
423423
.onChange(async (value) => {
424-
this.directory = value;
424+
this.folder = value;
425425
})
426426
);
427427

manifest.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"id": "obsidian-paste-as-embed",
33
"name": "Paste as Embed",
4-
"version": "0.1.0",
4+
"version": "0.1.1",
55
"minAppVersion": "0.15.0",
66
"description": "Paste text into a separate note, and embed the note.",
77
"author": "Matt Laporte",
88
"authorUrl": "https://lprt.ca",
9-
"isDesktopOnly": false
9+
"isDesktopOnly": true
1010
}

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-paste-as-embed",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "Paste text into a separate note, and embed the note.",
55
"main": "main.js",
66
"scripts": {

versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"0.0.1": "0.15.0",
3-
"0.1.0": "0.15.0"
3+
"0.1.0": "0.15.0",
4+
"0.1.1": "0.15.0"
45
}

0 commit comments

Comments
 (0)