From e82ca3a073d5925fb2821b1136a46e4d99e30307 Mon Sep 17 00:00:00 2001 From: Benature Date: Tue, 19 Mar 2024 21:41:27 +0800 Subject: [PATCH] 3.0.0 --- README.md | 38 ++++++++++++++++++++++---------------- main.ts | 6 ++++-- manifest.json | 2 +- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index e542f11..dd81f10 100644 --- a/README.md +++ b/README.md @@ -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 cmd/ctrl+P 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). @@ -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) @@ -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 | | ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -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 | | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | @@ -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)) | @@ -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 | | -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | @@ -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 | | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | @@ -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 | | ------------------------------------------------------ | ---------------------------------------------------------------------------- | @@ -116,7 +122,7 @@ Or you can consider to bind custom hotkeys to those commands according to [#29]( -### Advanced custom +#### Advanced custom | Command | Description | | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | @@ -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. | diff --git a/main.ts b/main.ts index 95119d6..093151e 100644 --- a/main.ts +++ b/main.ts @@ -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; @@ -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) } } } @@ -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, " "); diff --git a/manifest.json b/manifest.json index b61921f..e914e8f 100644 --- a/manifest.json +++ b/manifest.json @@ -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",