Skip to content

Commit

Permalink
rename command id, beautify settings input width
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Mar 18, 2024
1 parent 80d48b3 commit 8f22949
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
## 🏗️ developed
> to be updated in the next version
## 3.0.0-b5
## 3.0.0-b7
- [feature] support multi-cursor for commands ([#48](https://github.com/Benature/obsidian-text-format/issues/48))
- [feature] heading upper/lower for multi-lines ([#83](https://github.com/Benature/obsidian-text-format/issues/83))
- [fix] remove all `(?<=)` for compatible issue ([#82](https://github.com/Benature/obsidian-text-format/issues/82))
- [renamed] rename ~~`toggle case`~~ to `cycle case` (id ~~`togglecase`~~ to `cycle-case`), rename ~~`titlecase`~~ to `title-case`. (Hotkeys on these commands need to be re-configured)

## 2.7.1
- [fix] `customReplace()`: error when search contains like `\.\!\?`
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| **Capitalize** all **words** ⚙️ | Capitalize all words in selection or the whole title (when cursor focus inline tile) |
| **Capitalize** only first word of **sentence** ⚙️ | Capitalize only first word of sentence(s) in selection or the whole title (when cursor focus inline tile) |
| **Title case** ⚙️ | Capitalize words but leave certain words in lower case in selection or the whole title (when cursor focus inline tile) [#1](https://github.com/Benature/obsidian-text-format/issues/1) |
| **Toggle case** ⚙️ | A custom loop to format the selection or the whole title (when cursor focus inline tile) |
| **Cycle case** ⚙️ | A custom loop to format the selection or the whole title (when cursor focus inline tile) |
| **Slugify** selected text | convert any input text into a URL-friendly slug |
| **Snakify** selected text | Lowercase all letters in selection *and* replace spaces with underscores |

### Markdown Grammar

| Command | Description |
| ------------- | -------------------------------------------------------------------- |
| Heading Upper | e.g.: `# Heading` -> `## Heading` (default shortcut: `Ctrl+Shift+]`) |
| Heading Lower | e.g.: `## Heading` -> `# Heading` (default shortcut: `Ctrl+Shift+[`) |
| Command | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
| Heading upper | e.g.: `# Heading` -> `## Heading` (default shortcut: `Ctrl+Shift+]`) |
| Heading lower | e.g.: `## Heading` -> `# Heading` (default shortcut: `Ctrl+Shift+[`) [[discussions](https://github.com/Benature/obsidian-text-format/issues/83)] |
| Callout format | [#80](https://github.com/Benature/obsidian-text-format/issues/80) |

*discussions in [#83](https://github.com/Benature/obsidian-text-format/issues/83)*

#### List
| Command | Description |
Expand Down
8 changes: 4 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,10 +391,10 @@ export default class TextFormat extends Plugin {
case "capitalize-sentence":
replacedText = capitalizeSentence(this.settings.LowercaseFirst ? selectedText.toLowerCase() : selectedText);
break;
case "titlecase":
case "title-case":
replacedText = toTitleCase(selectedText, this.settings);
break;
case "togglecase":
case "cycle-case":
let lowerString = selectedText.toLowerCase();
const settings = this.settings;
function getNewString(caseCommand: string): string {
Expand All @@ -421,12 +421,12 @@ export default class TextFormat extends Plugin {
break;
}
}
if (!duplicated) { //: if the converted text is the same as before toggle case, ignore it
if (!duplicated) { //: if the converted text is the same as before cycle case, ignore it
if (selectedText == resText) { break; }
}
textHistory.push(resText);
}
//: find the toggle case that is different from the original text
//: find the cycle case that is different from the original text
for (i++; i < i + L; i++) {
let resText = getNewString(toggleSeq[i % L]);
if (selectedText != resText) {
Expand Down
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-text-format",
"name": "Text Format",
"version": "3.0.0-b6",
"version": "3.0.0-b7",
"minAppVersion": "0.9.7",
"description": "Format text such as lowercase/uppercase/capitalize/titlecase, converting order/bullet list, removing redundant spaces/newline characters.",
"author": "Benature",
Expand Down
4 changes: 2 additions & 2 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export const LetterCaseCommands = [
}, {
id: "capitalize-sentence",
}, {
id: "titlecase",
id: "title-case",
}, {
id: "togglecase",
id: "cycle-case",
},
]

Expand Down
8 changes: 4 additions & 4 deletions src/langs/langs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const EN = {
"lowercase": "Lowercase",
"capitalize-word": "Capitalize all words",
"capitalize-sentence": "Capitalize only first word of sentence",
"titlecase": "Titlecase",
"togglecase": "Togglecase",
"title-case": "Titlecase",
"cycle-case": "Cycle case",
"slugify": "Slugify",
"snakify": "Snakify",
"remove-trailing-spaces": "Remove trailing spaces",
Expand All @@ -24,8 +24,8 @@ const ZH = {
"lowercase": "全部小写",
"capitalize-word": "首字母大写(所有单词)",
"capitalize-sentence": "首字母大写(句首单词)",
"titlecase": "标题格式大小写",
"togglecase": "切换大小写格式",
"title-case": "标题格式大小写",
"cycle-case": "循环切换大小写格式",
"slugify": "使用 Slugify 格式化(`-`连字符)",
"snakify": "使用 Snakify 格式化(`_`连字符)",
"remove-trailing-spaces": "移除所有行末空格",
Expand Down
16 changes: 12 additions & 4 deletions src/settings/settingTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class TextFormatSettingTab extends PluginSettingTab {
addSettingsAboutWordCase(containerEl: HTMLElement) {
let headerDiv = containerEl.createDiv({ cls: "header-div" });
let headerEl = headerDiv.createEl("h3", { text: "Word cases" })
headerDiv.createEl("div", { text: "lowercase / uppercase / title case / toggle case / capitalize case", cls: "setting-item-description heading-description" });
headerDiv.createEl("div", { text: "lowercase / uppercase / title case / capitalize case / cycle case", cls: "setting-item-description heading-description" });
this.contentEl = containerEl.createDiv();
this.makeCollapsible(headerEl, this.contentEl);
new Setting(this.contentEl)
Expand All @@ -151,7 +151,7 @@ export class TextFormatSettingTab extends PluginSettingTab {
});
});
new Setting(this.contentEl)
.setName("Toggle case sequence (one case in a line)")
.setName("Cycle case sequence (one case in a line)")
.setDesc("Support cases: `lowerCase`, `upperCase`, `capitalizeWord`, `capitalizeSentence`, `titleCase`. \n" +
"Note that the result of `capitalizeWord` and `titleCase` could be the same in some cases, " +
"the two cases are not recommended to be used in the same time.")
Expand Down Expand Up @@ -394,12 +394,14 @@ export class TextFormatSettingTab extends PluginSettingTab {
this.display();
});
});
s.infoEl.remove();
s.settingEl.addClass("wrapper");
});
}
addSettingsAboutApiRequest(containerEl: HTMLElement) {
let headerDiv = containerEl.createDiv({ cls: "header-div" });
let headerEl = headerDiv.createEl("h3", { text: "API Request" });
headerDiv.createEl("div", { text: "Send a request to an API and replace the selection with the return.", cls: "setting-item-description heading-description" });
headerDiv.createEl("div", { text: "Send a request to an API and replace the selection with the return", cls: "setting-item-description heading-description" });

this.contentEl = containerEl.createDiv();
this.makeCollapsible(headerEl, this.contentEl);
Expand Down Expand Up @@ -452,11 +454,15 @@ export class TextFormatSettingTab extends PluginSettingTab {
this.display();
});
});
s.infoEl.remove();
s.settingEl.addClass("api-request");
});
}
addSettingsAboutReplacement(containerEl: HTMLElement) {
let headerDiv = containerEl.createDiv({ cls: "header-div" });
let headerEl = headerDiv.createEl("h3", { text: "Custom replacement" });
headerDiv.createEl("div", { text: "Replace specific pattern with custom string", cls: "setting-item-description heading-description" });


this.contentEl = containerEl.createDiv();
this.makeCollapsible(headerEl, this.contentEl);
Expand Down Expand Up @@ -516,6 +522,8 @@ export class TextFormatSettingTab extends PluginSettingTab {
this.display();
});
});
s.settingEl.addClass("custom-replace");
s.infoEl.remove();
});
}
addSettingsAboutZotero(containerEl: HTMLElement) {
Expand Down Expand Up @@ -565,7 +573,7 @@ export class TextFormatSettingTab extends PluginSettingTab {
addSettingsAboutMarkdownQuicker(containerEl: HTMLElement) {
let headerDiv = containerEl.createDiv({ cls: "header-div" });
let headerEl = headerDiv.createEl("h3", { text: "Markdown quicker" });
headerDiv.createEl("div", { text: "Quickly format the selection with common markdown syntax.", cls: "setting-item-description heading-description" });
headerDiv.createEl("div", { text: "Quickly format the selection with common markdown syntax", cls: "setting-item-description heading-description" });
this.contentEl = containerEl.createDiv();
this.makeCollapsible(headerEl, this.contentEl);

Expand Down
17 changes: 16 additions & 1 deletion styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@
margin-top: 5px;
}

.plugin-text-format .setting-item > .setting-item-control > input {
min-width: 145px;
}

.plugin-text-format .setting-item.custom-replace input,
.plugin-text-format .setting-item.wrapper input {
width: 33%;
}
.plugin-text-format .setting-item.api-request input:first-child {
width: 30%;
}
.plugin-text-format .setting-item.api-request input {
width: 70%;
}

.tf-collapsible-content.is-active {
display: block;
}
Expand All @@ -23,7 +38,7 @@
display: none;
}

.tf-collapsible-header:hover {
.plugin-text-format .header-div:hover {
background-color: var(--interactive-hover, #363636);
border-radius: var(--button-radius, 5px);
}
Expand Down

0 comments on commit 8f22949

Please sign in to comment.