Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Benature committed Mar 19, 2024
1 parent e91a0c3 commit e82ca3a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 19 deletions.
38 changes: 22 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ This plugin is created to format selected text lowercase/uppercase/capitalize/ti

## Features

Experimental features:
- Format on paste: see [#86](https://github.com/Benature/obsidian-text-format/issues/86)

### Commands

Press <kbd>cmd/ctrl+P</kbd> to enter the command. 👇

Or you can consider to bind custom hotkeys to those commands according to [#29](https://github.com/Benature/obsidian-text-format/issues/29#issuecomment-1279246640).
Expand All @@ -29,14 +34,15 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](

- [Text Format](#text-format)
- [Features](#features)
- [Basic](#basic)
- [Markdown Grammar](#markdown-grammar)
- [List](#list)
- [Links](#links)
- [Copy / OCR issues](#copy--ocr-issues)
- [Academic / Study](#academic--study)
- [Advanced custom](#advanced-custom)
- [Others](#others)
- [Commands](#commands)
- [Basic](#basic)
- [Markdown Grammar](#markdown-grammar)
- [List](#list)
- [Links](#links)
- [Copy / OCR issues](#copy--ocr-issues)
- [Academic / Study](#academic--study)
- [Advanced custom](#advanced-custom)
- [Others](#others)
- [Support](#support)
- [Some Examples](#some-examples)
- [Zotero format](#zotero-format)
Expand All @@ -48,7 +54,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](

⚙️: There is setting of this command.

### Basic
#### Basic

| Command | Description |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -61,7 +67,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| **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
#### Markdown Grammar

| Command | Description |
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -70,7 +76,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| Callout format | [#80](https://github.com/Benature/obsidian-text-format/issues/80) |


#### List
##### List
| Command | Description |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Detect and format **bullet** list ⚙️ | Change `` into bullet list, i.e. `- `; split every bullet point into single line; and remove blank lines. ([test cases](https://github.com/Benature/obsidian-text-format/issues/66)) |
Expand All @@ -79,7 +85,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| Convert table to bullet list with header | Sub-list begins with `${header}: ` |
| **Sort to-do** list | [#37](https://github.com/Benature/obsidian-text-format/issues/37), [#46](https://github.com/Benature/obsidian-text-format/issues/46) |

#### Links
##### Links

| Command | Description |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -88,7 +94,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| Convert URL links to WikiLinks in selection | e.g. Convert `[Google](www.google.com)` to `[[Google]]` |
| Convert WikiLinks to plain markdown links in selection ⚙️ | e.g. Convert `[[Google]]` to `[Google](Google.md)` ([#40](https://github.com/Benature/obsidian-text-format/issues/40)) |

### Copy / OCR issues
#### Copy / OCR issues

| Command | Description |
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand All @@ -104,7 +110,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](
| Replace **ligature** | Replace [ligature](https://en.wikipedia.org/wiki/Ligature_(writing)) to Non-ligature [#24](https://github.com/Benature/obsidian-text-format/issues/24) |


### Academic / Study
#### Academic / Study

| Command | Description |
| ------------------------------------------------------ | ---------------------------------------------------------------------------- |
Expand All @@ -116,7 +122,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](



### Advanced custom
#### Advanced custom

| Command | Description |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand All @@ -126,7 +132,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29](



### Others
#### Others
| Command | Description |
| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| Decode **URL** | Decode URL for better reading and shorter url. |
Expand Down
6 changes: 4 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ export default class TextFormat extends Plugin {
let clipboard = evt.clipboardData.getData('text/html') || evt.clipboardData.getData('text/plain');
if (!clipboard) { return; }

evt.preventDefault()
evt?.preventDefault();
// evt?.stopPropagation();

for (let cmd of formatOnPasteCmdList) {
const formatText = (await this.formatSelection(clipboard, cmd)).editorChange.text;
Expand Down Expand Up @@ -101,6 +102,7 @@ export default class TextFormat extends Plugin {
const cursorTo = editor.getCursor("to");
editor.setSelection(editor.offsetToPos(editor.posToOffset(cursorTo) - clipboard.length), cursorTo);
pluginEasyTyping.formatSelectionOrCurLine(editor, info);
editor.setCursor(editor.getCursor("to"));
} catch (e) { console.error(e) }
}
}
Expand Down Expand Up @@ -521,7 +523,7 @@ export default class TextFormat extends Plugin {
// replacedText = selectedText.replace(/\n/g, "\n\n");
// break;
case "space-word-symbol":
replacedText = selectedText.replace(/(\w+)\(/g, "$1 (");
replacedText = selectedText.replace(/(\w+)([\(\[]])/g, "$1 $2").replace(/([\)\]])(\w+)/g, "$1 $2");
break;
case "remove-citation":
replacedText = selectedText.replace(/\[\d+\]|【\d+】/g, "").replace(/ +/g, " ");
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-text-format",
"name": "Text Format",
"version": "2.7.1",
"version": "3.0.0",
"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

0 comments on commit e82ca3a

Please sign in to comment.