Skip to content

Commit 1cae2ff

Browse files
Enhance Editor File API with pinned state features
Added pinned state functionality and updated remove method options.
1 parent c0cd8ce commit 1cae2ff

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

docs/editor-components/editor-file.md

Lines changed: 24 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,17 @@ 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+
editorFile.remove(false, { ignorePinned: true });
123+
124+
// Attempt to close a pinned tab silently (toast suppressed)
125+
editorFile.remove(false, { silentPinned: true });
118126
```
119127

120128
#### [makeActive()](#makeactive)
@@ -131,6 +139,20 @@ Removes active state from the file.
131139
file.removeActive();
132140
```
133141

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

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

0 commit comments

Comments
 (0)