diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5eb1c..e178bba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 `\.\!\?` diff --git a/README.md b/README.md index dcbe58e..111fcea 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/main.ts b/main.ts index 7d4c9ac..b0fd09e 100644 --- a/main.ts +++ b/main.ts @@ -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 { @@ -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) { diff --git a/manifest-beta.json b/manifest-beta.json index 0192f8c..470cd7b 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -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", diff --git a/src/commands.ts b/src/commands.ts index 44a4148..ebb43d4 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -8,9 +8,9 @@ export const LetterCaseCommands = [ }, { id: "capitalize-sentence", }, { - id: "titlecase", + id: "title-case", }, { - id: "togglecase", + id: "cycle-case", }, ] diff --git a/src/langs/langs.ts b/src/langs/langs.ts index 14486d1..0660c2a 100644 --- a/src/langs/langs.ts +++ b/src/langs/langs.ts @@ -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", @@ -24,8 +24,8 @@ const ZH = { "lowercase": "全部小写", "capitalize-word": "首字母大写(所有单词)", "capitalize-sentence": "首字母大写(句首单词)", - "titlecase": "标题格式大小写", - "togglecase": "切换大小写格式", + "title-case": "标题格式大小写", + "cycle-case": "循环切换大小写格式", "slugify": "使用 Slugify 格式化(`-`连字符)", "snakify": "使用 Snakify 格式化(`_`连字符)", "remove-trailing-spaces": "移除所有行末空格", diff --git a/src/settings/settingTab.ts b/src/settings/settingTab.ts index 30c861f..0b96907 100644 --- a/src/settings/settingTab.ts +++ b/src/settings/settingTab.ts @@ -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) @@ -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.") @@ -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); @@ -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); @@ -516,6 +522,8 @@ export class TextFormatSettingTab extends PluginSettingTab { this.display(); }); }); + s.settingEl.addClass("custom-replace"); + s.infoEl.remove(); }); } addSettingsAboutZotero(containerEl: HTMLElement) { @@ -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); diff --git a/styles.css b/styles.css index 9bb3b70..fb2018a 100644 --- a/styles.css +++ b/styles.css @@ -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; } @@ -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); }