> [!warning]
> 途中まで実装したけど消えてしまった。。。。
## 残件
- [ ] Wordを追加するときにPositionを追加してAddする
## 現状のモデル
```ts
export interface DefaultWord {
value: string;
description?: string;
aliases?: string[];
type: WordType;
createdPath: string;
// Add after judge
offset?: number;
hit?: string;
}
export interface CustomDictionaryWord extends DefaultWord {
type: "customDictionary";
caretSymbol?: string;
/** Use for inserting instead of value **/
insertedText?: string;
/** If true, ignore `Insert space after completion` option **/
ignoreSpaceAfterCompletion?: boolean;
}
```
## 新しく必要な情報
### 一意性を持つ何か
- 一旦はplaintext限定で考える
- 候補
- **行番号**
- テキストの編集が楽 (指定された行番号の置換でok)
- テキストを直接編集されたときリロードしないと間違った場所に書き込まれる
- そこを制限事項にすればあとは色々楽
- ==beforeの値をとっておいて、書き込み前に確認すればいけそう==
- index (配列のindex)
- メモリ内の編集は多分できる
- が、ファイルの書き込み時に書き込み場所が分からない
- valueの値
- valueは重複を許容しないが、エラーは出さない
- 結局検索が必要になるので、行番号の方が多分楽
- ==普通はvalueそのものを変更するので、beforeの値保持と判定がいる==
**とりあえず行番号が良さそう。**
#### [[JSON]]にも機能追加できるか?
- [[JSON]]だと配列のindexになりそう (行番号は1行にならないので)
- それらを ==同一の抽象化した概念== で扱えばいけそう
==`position`とかにするか..==
というわけで
```ts
export interface CustomDictionaryWord extends DefaultWord {
type: "customDictionary";
position: number;
caretSymbol?: string;
/** Use for inserting instead of value **/
insertedText?: string;
/** If true, ignore `Insert space after completion` option **/
ignoreSpaceAfterCompletion?: boolean;
}
```
## 編集用のUI作成
- タイトルのところをリストにして切り替えられるようにしてみる
- UIを別だしするかは要検討
そもそも `position`がなくてエラーになっていたので定義修正。optionalに。
```ts
export interface CustomDictionaryWord extends DefaultWord {
type: "customDictionary";
/** array index if json / line no if text **/
position?: number;
```