joplin-plugin-codeblock-autocomplete 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 bwat47
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1
+ MIT License
2
+
3
+ Copyright (c) 2026 bwat47
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
package/README.md CHANGED
@@ -1,71 +1,79 @@
1
- > [!note]
2
- > This plugin was created entirely with AI tools
3
-
4
1
  # Codeblock Utils
5
2
 
6
- Codeblock Utils adds tools for working with fenced code blocks in Joplin:
3
+ Codeblock Utils adds tools for fenced code blocks in Joplin:
7
4
 
8
- - Language autocomplete when typing backticks or tildes in the Markdown editor
9
- - Copy button for fenced code blocks in the Markdown editor
10
- - Copy button for fenced code blocks in the Markdown viewer (and Rich Text editor)
11
- - Optional line numbers for fenced code blocks in the Markdown editor and viewer
12
- - Toolbar button, Edit menu command, and keyboard shortcut to insert, wrap, or unwrap code blocks in the Markdown editor
5
+ - Language autocomplete and a command to insert, wrap, or unwrap code blocks in the Markdown editor.
6
+ - A copy button and optional title in the Markdown editor, Markdown viewer, and Rich Text Editor.
7
+ - Optional line numbers and per-block line highlighting.
13
8
 
14
- ![ex](https://github.com/bwat47/joplin-codeblock-autocomplete/blob/main/images/example.gif)
9
+ ![Codeblock Utils example](https://github.com/bwat47/joplin-codeblock-autocomplete/blob/main/images/example.gif)
10
+
11
+ > [!note]
12
+ > This plugin was created entirely with AI tools.
15
13
 
16
14
  ## Usage
17
15
 
18
- ### Autocomplete
16
+ ### Create a code block
19
17
 
20
- Typing an opening fence (three+ backticks or three+ tildes) will trigger the auto-complete list by default. Selecting a language will complete the code block (adding the language and closing fence).
18
+ In the Markdown editor, type an opening fence of three or more backticks or tildes to open the language list. Selecting a language adds it and a matching closing fence. If the language has no matches, choose **Custom language** to use what you typed. For nested blocks, use more than three fence characters; the closing fence will have the same length. Changing the language of an existing code block only replaces the language; no extra closing fence is added. The list does not open on closing fences.
21
19
 
22
- - Specifying a lanauge that's not in the list (and has no matches) will show "Custom language" and will use the specified language as-is.
20
+ If you disable language autocomplete, typing exactly three backticks or tildes immediately inserts a closing fence. The cursor stays at the end of the opening fence so you can type a language or press Enter.
23
21
 
24
- - Supports nested code blocks (when the autocomplete languages dropdown is enabled): enter more than three fence characters will close the block with the same number of fence characters as the opening block.
22
+ You can also use the formatting toolbar button, Edit menu command, or keyboard shortcut (by default <kbd>CmdOrCtrl + Alt + `</kbd>). The command supports multiple cursors and selections. With no selection, it wraps the current line; inside an existing fenced block, it removes the surrounding fence lines.
25
23
 
26
- - If language auto-complete is disabled, typing exactly three backticks or tildes immediately inserts the closing fence and leaves the cursor at the end of the opening fence so you can type a language or press Enter.
24
+ ### Copy and title a block
27
25
 
28
- ### Insert code block command
26
+ Enable the code block header for the Markdown editor or Markdown viewer to show a button that copies the block's code to the clipboard. The viewer setting also applies to the Rich Text editors. A block can show a title in its header with the [`title` option](#per-block-options).
29
27
 
30
- An insert code block command is available via a formatting toolbar icon, Edit menu entry, and keyboard shortcut (by default CmdOrCtrl + Alt + `).
28
+ | Where | Header behavior |
29
+ | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
30
+ | Markdown editor | The language appears as a copy button at the top right, or **Copy** if no language is set. The title appears at the top left. The header replaces the opening fence while the cursor is elsewhere; click the title to reveal the fence for editing. |
31
+ | Markdown viewer | An icon-only copy button appears on hover, stays visible on touch devices, and is keyboard accessible. The title appears above the code. Copying shows a success toast. |
32
+ | Rich Text Editor | Uses the viewer setting. The mobile rich text editor hides the copy button because it has an **Edit** button in the same corner. |
31
33
 
32
- The command supports multiple cursors and selections, and is line-aware (e.g. cursor on line with no selection > invoke command > wraps entire line in code block). Invoking it with a cursor or selection inside an existing fenced code block removes the surrounding fence lines.
34
+ The viewer header applies to rendered fenced code. It does not change indented or inline code, raw HTML code blocks, or fences Joplin renders as diagrams or other content (Mermaid, ABC notation, Fountain).
33
35
 
34
- ### Markdown editor copy button
36
+ ### Number and highlight lines
35
37
 
36
- If the copy widget is enabled, you will see the code fence language rendered as a clickable copy button on the top-right of the code block (when the cursor isn't on the opening fence line).
38
+ The Markdown editor and Markdown viewer have independent line-number settings; the viewer setting also applies to the Rich Text editors. Numbering starts at 1 for each fenced block. Use [per-block options](#per-block-options) to turn numbering on or off, change the starting number, or highlight chosen lines for specific code blocks. Highlighting works even when numbers are hidden.
37
39
 
38
- Clicking the copy button will copy the code block contents to your clipboard. If the code fence doesn't have a language specified, it will display a generic "Copy" label instead of the language.
40
+ Viewer line numbers preserve highlighting, are excluded when copying code, and do not apply to diagram blocks.
39
41
 
40
- ### Markdown editor line numbers
42
+ ### Per-block options
41
43
 
42
- If line numbers are enabled, each line inside a fenced code block in the Markdown editor is numbered, starting from 1 on the line after the opening fence. The fence lines are shifted to stay aligned with the code but are not numbered.
44
+ Settings can be adjusted per code block by adding the following options after the language in the opening fence:
43
45
 
44
- ### Markdown viewer copy button
46
+ | Option | Effect |
47
+ | ----------------- | ---------------------------------------------------------------------------------------------------------------------------- |
48
+ | `ln` or `ln=true` | Show line numbers for this block. |
49
+ | `ln=false` | Hide line numbers for this block. |
50
+ | `start=N` | Start at the whole number `N` (0 or greater) and show line numbers, unless `ln=false` is set. |
51
+ | `title="text"` | Show a header title when the header is enabled. Quote titles containing spaces; use single quotes if the title contains `"`. |
52
+ | `hl=LINES` | Highlight displayed line numbers, such as `hl=2,5-7`. With `start=10`, `hl=10` highlights the first line. |
45
53
 
46
- The Markdown viewer has a separate copy-widget setting. When enabled, hovering over a rendered fenced code block shows an icon-only copy button in its top-right corner. The button remains visible on touch devices and can also be reached with the keyboard.
54
+ For example:
47
55
 
48
- Clicking the button copies the fenced code contents and displays a success toast. Indented code blocks, inline code, raw HTML code blocks, and fences that Joplin renders as something other than code (Mermaid, ABC notation, Fountain) are not changed.
56
+ ````markdown
57
+ ```python title="utils/greet.py" ln start=10 hl=11
58
+ def greet(name):
59
+ return f"Hello, {name}"
60
+ ```
61
+ ````
49
62
 
50
- > [!note]
51
- > This setting also enables a working copy button in the desktop rich text editor (TinyMCE).
52
- >
53
- > It technically works in the mobile (prosemirror) rich text editor as well, however, the prosemirror editor places its own "edit" button on the top right, so the two buttons overlap.
63
+ The language must come first because Joplin uses the first word for syntax highlighting. To number a block without a language, use a placeholder such as `txt ln`. Options can appear in any order; unknown or invalid options are ignored. The editor's copy button shows only the language.
54
64
 
55
- ### Markdown viewer line numbers
65
+ Other Markdown apps usually ignore the extra words and use the first one as the language. The Rich Text Editor preserves options when saving, copying, or editing a block; in the desktop editor's code block dialog, they appear in the Language field.
56
66
 
57
- Enable the viewer line-number setting to number each logical line of fenced code, starting from 1 for each block. Highlighting is preserved, and copying code excludes the numbers. This setting is independent of editor line numbers and viewer copy buttons. Diagram blocks are not numbered.
67
+ > [!warning]
68
+ > Adding options after `mermaid` or `abc` prevents those blocks from rendering as diagrams/abc notation in the Markdown viewer.
58
69
 
59
70
  ## Settings
60
71
 
61
- Enable language auto-complete - Toggle the language dropdown for code fences. When disabled, typing exactly three backticks or tildes inserts a closing fence immediately without opening the dropdown.
62
-
63
- Enable Markdown editor copy widget - Show a copy button on fenced code blocks in the Markdown editor and hide the opening-fence language text when the cursor is not on that line.
64
-
65
- Show line numbers in Markdown editor code blocks - Number the lines inside fenced code blocks in the Markdown editor.
66
-
67
- Enable Markdown viewer copy widget - Show a copy button when hovering over fenced code blocks in the Markdown viewer.
68
-
69
- Show line numbers in Markdown viewer code blocks - Number the lines inside fenced code blocks in the Markdown viewer.
70
-
71
- Autocomplete languages - Comma-separated list of language identifiers to show in the autocomplete menu.
72
+ | Setting | Controls |
73
+ | -------------------------------------------------------------- | ----------------------------------------------------------- |
74
+ | Enable language auto-complete | Language dropdown for code fences. |
75
+ | Show Markdown editor code block header (title and copy button) | Header in the Markdown editor. |
76
+ | Show line numbers in Markdown editor code blocks | Editor line numbers. |
77
+ | Show Markdown viewer code block header (title and copy button) | Header in the Markdown viewer and Rich Text editors. |
78
+ | Show line numbers in Markdown viewer code blocks | Line numbers in the Markdown viewer and Rich Text editors. |
79
+ | Autocomplete languages | Comma-separated language identifiers shown in the dropdown. |
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "joplin-plugin-codeblock-autocomplete",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "scripts": {
5
5
  "dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive",
6
6
  "prepare": "npm run dist",
7
7
  "updateVersion": "webpack --env joplin-plugin-config=updateVersion",
8
8
  "update": "npm install -g generator-joplin && yo joplin --node-package-manager npm --update --force",
9
- "lint": "eslint --ext .ts src/",
10
- "lint:fix": "eslint --ext .ts src/ --fix",
11
- "format": "prettier --write \"src/**/*.ts\"",
9
+ "lint": "eslint src/",
10
+ "lint:fix": "eslint src/ --fix",
11
+ "format": "prettier --write \"src/**/*.{ts,js,css}\"",
12
12
  "test": "vitest run --passWithNoTests",
13
13
  "test:watch": "vitest --passWithNoTests",
14
14
  "knip": "knip"
@@ -27,16 +27,18 @@
27
27
  "@codemirror/state": "^6.5.4",
28
28
  "@codemirror/view": "^6.35.0",
29
29
  "@eslint/js": "^10.0.1",
30
+ "@ianvs/prettier-plugin-sort-imports": "^4.7.1",
30
31
  "@lezer/common": "^1.5.2",
31
32
  "@types/node": "^24.13.2",
32
- "@typescript-eslint/eslint-plugin": "^8.66.0",
33
- "@typescript-eslint/parser": "^8.66.0",
33
+ "@vitest/eslint-plugin": "^1.6.27",
34
34
  "chalk": "^4.1.0",
35
35
  "copy-webpack-plugin": "^14.0.0",
36
36
  "eslint": "^10.8.1",
37
37
  "eslint-config-prettier": "^10.1.8",
38
+ "eslint-import-resolver-typescript": "^4.4.5",
38
39
  "eslint-plugin-import-x": "^4.16.2",
39
40
  "eslint-plugin-sonarjs": "^4.2.0",
41
+ "eslint-plugin-tsdoc": "^0.5.4",
40
42
  "fs-extra": "^10.1.0",
41
43
  "glob": "^8.0.3",
42
44
  "globals": "^17.7.0",
@@ -46,8 +48,14 @@
46
48
  "tar": "^7.5.12",
47
49
  "ts-loader": "^9.3.1",
48
50
  "typescript": "^6.0.3",
51
+ "typescript-eslint": "^8.72.1",
49
52
  "vitest": "^4.1.10",
50
53
  "webpack": "^5.105.4",
51
54
  "webpack-cli": "^6.0.1"
55
+ },
56
+ "overrides": {
57
+ "eslint-plugin-tsdoc": {
58
+ "@typescript-eslint/utils": "8.72.1"
59
+ }
52
60
  }
53
61
  }
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 1,
3
3
  "id": "com.bwat47.codeblock-autocomplete",
4
4
  "app_min_version": "3.3",
5
- "version": "1.6.0",
5
+ "version": "1.7.0",
6
6
  "platforms": [
7
7
  "desktop",
8
8
  "mobile"
@@ -40,6 +40,10 @@
40
40
  {
41
41
  "src": "images/screenshot3.png",
42
42
  "label": "Markdown viewer copy widget example"
43
+ },
44
+ {
45
+ "src": "images/line_numbers_both.png",
46
+ "label": "Split view line numbers example"
43
47
  }
44
48
  ],
45
49
  "icons": {
@@ -53,6 +57,6 @@
53
57
  "src": "images/promo.png",
54
58
  "label": "Codeblock Utils Promo Tile"
55
59
  },
56
- "_publish_hash": "sha256:7019157752bd88ba6fcf15acede1a970aa49108adf3582eed3e7c15d765d3c1b",
57
- "_publish_commit": "main:90e131c330c7349edaa72ae463da9c7e360840db"
60
+ "_publish_hash": "sha256:aefd5bc24f355055d1a47e0227848084e759dbc7a6ff24909e54a5505f7f35c5",
61
+ "_publish_commit": "main:294e06158da97c2713e7f5eea1b3777f143da00b"
58
62
  }