-
Notifications
You must be signed in to change notification settings - Fork 443
Expand file tree
/
Copy pathtypes.ts
More file actions
188 lines (162 loc) · 3.97 KB
/
Copy pathtypes.ts
File metadata and controls
188 lines (162 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import { TFile } from 'obsidian';
import { KanbanSettings } from 'src/Settings';
import { Nestable } from 'src/dnd/types';
import { InlineField } from 'src/parsers/helpers/inlineMetadata';
import { FileAccessor } from 'src/parsers/helpers/parser';
export enum LaneSort {
TitleAsc,
TitleDsc,
DateAsc,
DateDsc,
TagsAsc,
TagsDsc,
}
export interface LaneData {
shouldMarkItemsComplete?: boolean;
title: string;
maxItems?: number;
query?: string;
dom?: HTMLDivElement;
forceEditMode?: boolean;
sorted?: LaneSort | string;
}
export interface DataKey {
metadataKey: string;
label: string;
shouldHideLabel: boolean;
containsMarkdown: boolean;
}
export interface TagColor {
tagKey: string;
color: string;
backgroundColor: string;
}
export interface TagSort {
tag: string;
}
export interface DateColor {
isToday?: boolean;
isBefore?: boolean;
isAfter?: boolean;
distance?: number;
unit?: 'hours' | 'days' | 'weeks' | 'months';
direction?: 'before' | 'after';
color?: string;
backgroundColor?: string;
}
export type PageDataValue =
| string
| number
| Array<string | number>
| { [k: string]: PageDataValue };
export interface PageData extends DataKey {
value: PageDataValue;
}
export interface FileMetadata {
[k: string]: PageData;
}
export interface ItemMetadata {
dateStr?: string;
date?: moment.Moment;
timeStr?: string;
time?: moment.Moment;
tags?: string[];
fileAccessor?: FileAccessor;
file?: TFile | null;
fileMetadata?: FileMetadata;
fileMetadataOrder?: string[];
inlineMetadata?: InlineField[];
}
export interface ItemData {
blockId?: string;
checked: boolean;
checkChar: string;
title: string;
titleRaw: string;
titleSearch: string;
titleSearchRaw: string;
metadata: ItemMetadata;
forceEditMode?: boolean;
fromQuery?: boolean;
querySource?: {
path: string;
line: number;
blockId?: string;
};
}
export interface ErrorReport {
description: string;
stack: string;
}
export interface BoardData {
isSearching: boolean;
settings: KanbanSettings;
frontmatter: Record<string, number | string | Array<number | string>>;
archive: Item[];
errors: ErrorReport[];
}
export type Item = Nestable<ItemData>;
export type Lane = Nestable<LaneData, Item>;
export type Board = Nestable<BoardData, Lane>;
export type MetadataSetting = Nestable<DataKey>;
export type TagColorSetting = Nestable<TagColor>;
export type TagSortSetting = Nestable<TagSort>;
export type DateColorSetting = Nestable<DateColor>;
export const DataTypes = {
Item: 'item',
Lane: 'lane',
Board: 'board',
MetadataSetting: 'metadata-setting',
TagColorSetting: 'tag-color',
TagSortSetting: 'tag-sort',
DateColorSetting: 'date-color',
};
export const ItemTemplate = {
accepts: [DataTypes.Item],
type: DataTypes.Item,
children: [] as any[],
};
export const LaneTemplate = {
accepts: [DataTypes.Lane],
type: DataTypes.Lane,
};
export const BoardTemplate = {
accepts: [] as string[],
type: DataTypes.Board,
};
export const MetadataSettingTemplate = {
accepts: [DataTypes.MetadataSetting],
type: DataTypes.MetadataSetting,
children: [] as any[],
};
export const TagSortSettingTemplate = {
accepts: [DataTypes.TagSortSetting],
type: DataTypes.TagSortSetting,
children: [] as any[],
};
// TODO: all this is unecessary because these aren't sortable
export const TagColorSettingTemplate = {
accepts: [] as string[],
type: DataTypes.TagColorSetting,
children: [] as any[],
};
// TODO: all this is unecessary because these aren't sortable
export const DateColorSettingTemplate = {
accepts: [] as string[],
type: DataTypes.DateColorSetting,
children: [] as any[],
};
export interface EditCoordinates {
x: number;
y: number;
}
export enum EditingState {
cancel,
complete,
}
export type EditState = EditCoordinates | EditingState;
export function isEditing(state: EditState): state is EditCoordinates {
if (state === null) return false;
if (typeof state === 'number') return false;
return true;
}