Skip to content

Commit

Permalink
add commands
Browse files Browse the repository at this point in the history
  • Loading branch information
masaki39 committed Aug 8, 2024
1 parent 06e1b64 commit 54ed0e5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,15 @@ ContinuousText-->|replacement×1-5|ReplacedText
ReplacedText-->|+insertion|Export
```

Some
`{{i:id}}` is replaced with content between `{{s:id}}` and `{{e:id}}`.

### Select export method

Choose from the following options for exporting your text: Copy to clipboard. Append to the cursor's current position. Append to the bottom of the active note. Replace a section; if none exists, create it at the bottom of the note.

### Other commands

Fold all of indentation levels 1-3.
Fold all of indentation levels 1-5.

#### Swap lines commands

Expand Down
50 changes: 50 additions & 0 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,56 @@ export default class OutlineConverter extends Plugin {
}
});

// fold indentation level 4 command
this.addCommand({
id: 'fold-level4',
name: 'Fold all of indentation level 4',
editorCallback: async (editor: Editor) => {

// unfold all
editor.exec(`unfoldAll`);

// get lines
const lines = await this.splitContent(editor);

// get indent levels list
let indentLevels = this.calculateIndentLevels(lines);

// fold the indentlevel
for (let i = 0; i < indentLevels.length; i++) {
if (indentLevels[i] === 4) {
editor.setCursor(i);
editor.exec(`toggleFold`);
}
}
}
});

// fold indentation level 5 command
this.addCommand({
id: 'fold-level5',
name: 'Fold all of indentation level 5',
editorCallback: async (editor: Editor) => {

// unfold all
editor.exec(`unfoldAll`);

// get lines
const lines = await this.splitContent(editor);

// get indent levels list
let indentLevels = this.calculateIndentLevels(lines);

// fold the indentlevel
for (let i = 0; i < indentLevels.length; i++) {
if (indentLevels[i] === 5) {
editor.setCursor(i);
editor.exec(`toggleFold`);
}
}
}
});

this.addCommand({
id: 'line-up',
name: 'Swap line up',
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": "outline-converter",
"name": "Outline Converter",
"version": "1.3.0",
"version": "1.3.1",
"minAppVersion": "1.5.12",
"description": "Convert outline to continuous text.",
"author": "masaki39",
Expand Down

0 comments on commit 54ed0e5

Please sign in to comment.