Skip to content

Commit 93deba4

Browse files
Enhance Editor File API Docs with pinned state features (#65)
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
1 parent f8a9101 commit 93deba4

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/editor-components/editor-file.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
The Editor File API provides functionality to create, manage, interact with files/tabs in the Acode editor. It handles file operations, state management, editor session control, custom editor tab, etc.
44

55
::: tip
6-
This API is defined in the [Acode source code (src/lib/editorFile.js)](https://github.com/Acode-Foundation/Acode/blob/52bf3a59c4aebe422d8cfdecf5c85191ed6f6004/src/lib/editorFile.js).
6+
This API is defined in the [Acode source code (src/lib/editorFile.js)](https://github.com/Acode-Foundation/Acode/blob/228a339296a3869fff7ff84e0898378a438931b8/src/lib/editorFile.js).
77
:::
88

99
## Import
@@ -68,6 +68,7 @@ Both methods are equivalent and accept & return the same parameters.
6868
| uri | `string` | File location on the device |
6969
| eol | `'windows' \| 'unix'` | End of line character |
7070
| editable | `boolean` | Whether file can be edited |
71+
| pinned | `boolean` | Whether the file is pinned |
7172
| isUnsaved | `boolean` | Whether file has unsaved changes |
7273
| name | `string` | File name (for plugin compatibility) |
7374
| cacheFile | `string` | Cache file URL |
@@ -90,6 +91,7 @@ Both methods are equivalent and accept & return the same parameters.
9091
| uri | `string` | Set file location |
9192
| eol | `'windows' \| 'unix'` | Set end of line character |
9293
| editable | `boolean` | Set file editability |
94+
| pinned | `boolean` | Set file pinned state |
9395
| readOnly | `boolean` | Set file readonly state |
9496

9597
## Methods
@@ -110,11 +112,18 @@ Saves the file to a new location.
110112
await file.saveAs();
111113
```
112114

113-
#### [remove(force = false)](#removeforce--false)
115+
#### [remove(force = false, options = { ignorePinned = false, silentPinned = false })](#removeforce--false)
114116
Removes and closes the file.
115117

116118
```js
117119
await file.remove(true); // Force close without save prompt
120+
121+
// Attempt to close a pinned tab, bypassing the pinned check
122+
// Attempt to close a pinned tab, bypassing the pinned check
123+
await file.remove(false, { ignorePinned: true });
124+
125+
// Attempt to close a pinned tab silently (toast suppressed)
126+
await file.remove(false, { silentPinned: true });
118127
```
119128

120129
#### [makeActive()](#makeactive)
@@ -131,6 +140,23 @@ Removes active state from the file.
131140
file.removeActive();
132141
```
133142

143+
#### [setPinnedState(value: boolean, options = { reorder = false, emit = true })](#setpinnedstate)
144+
Updates Pinned State for the file, triggers reorder (if true), emits Events (editorManager `update` event with `pin-tab` as the first argument and affected File - second argument )
145+
146+
```js
147+
file.setPinnedState(false, {})
148+
149+
editorManager.on("update", (action, file) => {
150+
if(action === "pin-tab") doSomething();
151+
});
152+
```
153+
154+
#### [togglePinned()](#togglepinned)
155+
Toggles the pinned State of the file
156+
157+
```js
158+
file.togglePinned();
159+
134160
### Editor Operations
135161

136162
#### [setMode(mode)](#setmodemode)

0 commit comments

Comments
 (0)