@4399ywkf/editor 0.14.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{DocView-VTKFMW46.js → DocView-7QBKHBU4.js} +4 -3
- package/dist/DocView-7QBKHBU4.js.map +1 -0
- package/dist/SheetView-WP4DKSDS.js +3 -0
- package/dist/{SheetView-6Z5EPBN4.js.map → SheetView-WP4DKSDS.js.map} +1 -1
- package/dist/base-model.d.ts +131 -0
- package/dist/base-model.js +3 -0
- package/dist/base-model.js.map +1 -0
- package/dist/base.d.ts +978 -0
- package/dist/base.js +14180 -0
- package/dist/base.js.map +1 -0
- package/dist/{chunk-FMTC3EDQ.js → chunk-4SIP4BYI.js} +3 -3
- package/dist/{chunk-FMTC3EDQ.js.map → chunk-4SIP4BYI.js.map} +1 -1
- package/dist/chunk-F4LWFKIA.js +2931 -0
- package/dist/chunk-F4LWFKIA.js.map +1 -0
- package/dist/chunk-S57WFYWY.js +2014 -0
- package/dist/chunk-S57WFYWY.js.map +1 -0
- package/dist/{chunk-ZLEGKX2U.js → chunk-X2JCKZP2.js} +9385 -9998
- package/dist/chunk-X2JCKZP2.js.map +1 -0
- package/dist/{chunk-OBKIMG6G.js → chunk-X4BUO2RH.js} +4 -4
- package/dist/{chunk-OBKIMG6G.js.map → chunk-X4BUO2RH.js.map} +1 -1
- package/dist/csv.js +1 -1
- package/dist/doc-standalone.js +11425 -9116
- package/dist/doc-standalone.js.map +1 -1
- package/dist/doc.d.ts +4 -379
- package/dist/doc.js +3 -2
- package/dist/doc.js.map +1 -1
- package/dist/editor-config-context-DvLRd7Gx.d.ts +382 -0
- package/dist/form-DqUOPVKI.d.ts +475 -0
- package/dist/{import-XL3AH3QH.js → import-TEZ37G5R.js} +5 -5
- package/dist/{import-XL3AH3QH.js.map → import-TEZ37G5R.js.map} +1 -1
- package/dist/index.js +2 -2
- package/dist/sheet.js +1 -1
- package/dist/style.css +2 -2
- package/dist/xlsx.js +4 -4
- package/package.json +10 -2
- package/dist/DocView-VTKFMW46.js.map +0 -1
- package/dist/SheetView-6Z5EPBN4.js +0 -3
- package/dist/chunk-ZLEGKX2U.js.map +0 -1
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import * as Y from 'yjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 字段类型注册表。类型 id、ui_type 与单元格值格式照搬飞书多维表格,以后接开放接口、CLI 不用转换:
|
|
5
|
+
* - 文本 1:文本片段数组 `[{ type: "text", text }]`
|
|
6
|
+
* - 数字 2:number。ui_type 还可以是进度 Progress(存小数,0.5 即 50%)、货币 Currency、评分 Rating
|
|
7
|
+
* - 单选 3:选项 id
|
|
8
|
+
* - 多选 4:选项 id 数组
|
|
9
|
+
* - 日期 5:毫秒时间戳
|
|
10
|
+
* - 复选框 7:true(未勾选不存值)
|
|
11
|
+
* - 人员 11:`[{ id, name, avatarUrl }]`
|
|
12
|
+
* - 电话号码 13:string
|
|
13
|
+
* - 超链接 15:`{ link, text }`
|
|
14
|
+
* - 附件 17:`[{ token, name, size, mimeType, url }]`
|
|
15
|
+
* - 创建时间 1001、最后更新时间 1002、创建人 1003、修改人 1004、自动编号 1005:系统字段,
|
|
16
|
+
* 值不存在单元格里,由记录元数据(RECORD_META)算出
|
|
17
|
+
*/
|
|
18
|
+
declare const FieldType: {
|
|
19
|
+
readonly Text: 1;
|
|
20
|
+
readonly Number: 2;
|
|
21
|
+
readonly SingleSelect: 3;
|
|
22
|
+
readonly MultiSelect: 4;
|
|
23
|
+
readonly DateTime: 5;
|
|
24
|
+
readonly Checkbox: 7;
|
|
25
|
+
readonly User: 11;
|
|
26
|
+
readonly Phone: 13;
|
|
27
|
+
readonly Url: 15;
|
|
28
|
+
readonly Attachment: 17;
|
|
29
|
+
readonly CreatedTime: 1001;
|
|
30
|
+
readonly ModifiedTime: 1002;
|
|
31
|
+
readonly CreatedUser: 1003;
|
|
32
|
+
readonly ModifiedUser: 1004;
|
|
33
|
+
readonly AutoNumber: 1005;
|
|
34
|
+
};
|
|
35
|
+
type FieldTypeId = (typeof FieldType)[keyof typeof FieldType];
|
|
36
|
+
declare const FIELD_UI_TYPE: Record<FieldTypeId, string>;
|
|
37
|
+
/** 数字字段的展示形态(飞书开放接口里是 ui_type,类型 id 都是 2) */
|
|
38
|
+
type NumberUiType = "Number" | "Progress" | "Currency" | "Rating";
|
|
39
|
+
declare const NUMBER_UI_TYPES: readonly NumberUiType[];
|
|
40
|
+
declare const isNumberUiType: (value: unknown) => value is NumberUiType;
|
|
41
|
+
declare const isFieldType: (type: unknown) => type is FieldTypeId;
|
|
42
|
+
/** 系统字段:值由记录元数据算出,不能编辑 */
|
|
43
|
+
declare const isComputedFieldType: (type: FieldTypeId) => boolean;
|
|
44
|
+
/** 看板能按哪些字段分组(同飞书:单选、人员) */
|
|
45
|
+
declare const isKanbanGroupFieldType: (type: FieldTypeId) => boolean;
|
|
46
|
+
/** 飞书开放接口的 ui_type:数字字段按展示形态细分 */
|
|
47
|
+
declare function fieldUiType(field: Pick<BaseField, "type" | "uiType">): string;
|
|
48
|
+
/** 日期按这个时区解析和显示(飞书多维表格默认跟随创建者,国内即东八区) */
|
|
49
|
+
declare const DEFAULT_TIME_ZONE = "Asia/Shanghai";
|
|
50
|
+
interface SelectOption {
|
|
51
|
+
id: string;
|
|
52
|
+
name: string;
|
|
53
|
+
/** 色板下标 */
|
|
54
|
+
color: number;
|
|
55
|
+
}
|
|
56
|
+
interface FieldProperty {
|
|
57
|
+
/** 单选、多选的选项,按显示顺序 */
|
|
58
|
+
options?: SelectOption[];
|
|
59
|
+
/**
|
|
60
|
+
* 数字:"0"、"0.0"、"0.00"、"1,000"、"1,000.00"、"0%"、"0.00%"(货币只看小数位,总带千分位);
|
|
61
|
+
* 日期:"yyyy/MM/dd"、"yyyy/MM/dd HH:mm"、"yyyy-MM-dd"、"MM-dd"、"MM/dd/yyyy"、"dd/MM/yyyy"
|
|
62
|
+
*/
|
|
63
|
+
formatter?: string;
|
|
64
|
+
/** 人员:允许添加多个成员(默认允许) */
|
|
65
|
+
multiple?: boolean;
|
|
66
|
+
/** 货币:CNY、USD、EUR、GBP、JPY、HKD */
|
|
67
|
+
currencyCode?: string;
|
|
68
|
+
/** 评分的最低、最高分;进度条的范围(存小数,默认 0–1) */
|
|
69
|
+
min?: number;
|
|
70
|
+
max?: number;
|
|
71
|
+
/** 评分图标:star、heart、thumbsup、fire、smile、lightning、flower、number */
|
|
72
|
+
ratingSymbol?: string;
|
|
73
|
+
}
|
|
74
|
+
interface BaseField {
|
|
75
|
+
id: string;
|
|
76
|
+
name: string;
|
|
77
|
+
type: FieldTypeId;
|
|
78
|
+
/** 只有数字字段有:进度 / 货币 / 评分;不填即普通数字 */
|
|
79
|
+
uiType?: NumberUiType;
|
|
80
|
+
property: FieldProperty;
|
|
81
|
+
description?: string;
|
|
82
|
+
}
|
|
83
|
+
interface TextSegment {
|
|
84
|
+
type: "text";
|
|
85
|
+
text: string;
|
|
86
|
+
}
|
|
87
|
+
interface UserValue {
|
|
88
|
+
id: string;
|
|
89
|
+
name?: string;
|
|
90
|
+
avatarUrl?: string;
|
|
91
|
+
}
|
|
92
|
+
interface UrlValue {
|
|
93
|
+
link: string;
|
|
94
|
+
text?: string;
|
|
95
|
+
}
|
|
96
|
+
interface AttachmentValue {
|
|
97
|
+
/** 宿主上传后给的文件标识 */
|
|
98
|
+
token: string;
|
|
99
|
+
name: string;
|
|
100
|
+
size?: number;
|
|
101
|
+
mimeType?: string;
|
|
102
|
+
/** 下载 / 预览地址(宿主给;没有时由宿主按 token 解析) */
|
|
103
|
+
url?: string;
|
|
104
|
+
}
|
|
105
|
+
type CellValue = TextSegment[] | number | string | string[] | true | UserValue[] | UrlValue | AttachmentValue[];
|
|
106
|
+
/**
|
|
107
|
+
* 记录元数据:和单元格存在同一个记录 Y.Map 里,键以下划线开头(字段 id 以 fld 开头,不会撞)。
|
|
108
|
+
* 每个键单独合并,两人同时改同一行也只是「最后更新」取后写入的那个。
|
|
109
|
+
*/
|
|
110
|
+
declare const RECORD_META: {
|
|
111
|
+
readonly createdTime: "_ct";
|
|
112
|
+
readonly createdUser: "_cb";
|
|
113
|
+
readonly modifiedTime: "_mt";
|
|
114
|
+
readonly modifiedUser: "_mb";
|
|
115
|
+
readonly autoNumber: "_no";
|
|
116
|
+
};
|
|
117
|
+
declare const isRecordMetaKey: (key: string) => boolean;
|
|
118
|
+
/** 字段的值存在记录的哪个键下:普通字段是字段 id,系统字段是元数据键 */
|
|
119
|
+
declare function fieldValueKey(field: Pick<BaseField, "id" | "type">): string;
|
|
120
|
+
/**
|
|
121
|
+
* 字段在一条记录上的值。get 读记录的一个键(Y.Map 的 get,或快照里的对象)。
|
|
122
|
+
* 没改过的记录,最后更新时间 / 修改人就是创建时间 / 创建人(同飞书)。
|
|
123
|
+
*/
|
|
124
|
+
declare function readFieldValue(field: Pick<BaseField, "id" | "type">, get: (key: string) => unknown): unknown;
|
|
125
|
+
declare function defaultFieldProperty(type: FieldTypeId, uiType?: NumberUiType): FieldProperty;
|
|
126
|
+
declare const isEmptyCellValue: (value: unknown) => boolean;
|
|
127
|
+
/**
|
|
128
|
+
* 把任意输入(编辑器的值、粘贴的文本、开放接口的值)规范成该字段的存储格式;空值返回 null(表示不存)。
|
|
129
|
+
* 单选、多选认选项 id,也认选项名(粘贴时用),不认识的丢掉。
|
|
130
|
+
*/
|
|
131
|
+
declare function normalizeCellValue(field: BaseField, input: unknown, timeZone?: string): CellValue | null;
|
|
132
|
+
type WallTime = [number, number, number, number, number, number];
|
|
133
|
+
/** 两个非空值的大小(排序、分组用)。单选、多选按选项顺序比,人员按第一个人的名字比。 */
|
|
134
|
+
declare function compareCellValues(field: BaseField, a: unknown, b: unknown): number;
|
|
135
|
+
/** 某时区里一天开始的时间戳(筛选「今天」「本周」这类条件用) */
|
|
136
|
+
declare function startOfDayIn(time: number, timeZone?: string): number;
|
|
137
|
+
/** 从某时区的某一天起往后数 days 天(按墙上日期数,跨夏令时也对) */
|
|
138
|
+
declare function addDaysIn(dayStart: number, days: number, timeZone?: string): number;
|
|
139
|
+
/** 某时区里一个月开始的时间戳;offset 是往后(正)或往前(负)的月数 */
|
|
140
|
+
declare function startOfMonthIn(time: number, offset?: number, timeZone?: string): number;
|
|
141
|
+
/** 某时区里的星期几:周一 0 … 周日 6(飞书的一周从周一开始) */
|
|
142
|
+
declare function weekdayIn(time: number, timeZone?: string): number;
|
|
143
|
+
/** 货币代码 → 符号 */
|
|
144
|
+
declare const CURRENCY_SYMBOLS: Record<string, string>;
|
|
145
|
+
/** 数字字段按展示形态格式化:货币带符号和千分位,进度按百分比格式 */
|
|
146
|
+
declare function formatNumberField(field: BaseField, value: number): string;
|
|
147
|
+
/** 单元格显示 / 纯文本(搜索、复制、快照的纯文本都用它) */
|
|
148
|
+
declare function cellValueToText(field: BaseField, value: unknown, timeZone?: string): string;
|
|
149
|
+
/** 时间戳 → 某时区的墙上时间 [年, 月, 日, 时, 分, 秒](月从 1 开始) */
|
|
150
|
+
declare function toWallTime(time: number, timeZone?: string): WallTime;
|
|
151
|
+
/** 某时区的墙上时间 → 时间戳(日、月可以越界,按日历顺延) */
|
|
152
|
+
declare function fromWallTime(wall: WallTime, timeZone?: string): number;
|
|
153
|
+
|
|
154
|
+
/** 统计栏的统计方式(同飞书 bitable.stat.*) */
|
|
155
|
+
type StatType = "none" | "countAll" | "empty" | "filled" | "unique" | "percentEmpty" | "percentFilled" | "percentUnique" | "sum" | "average" | "max" | "min" | "earliest" | "latest" | "dateRangeOfDays" | "dateRangeOfMonths" | "checked" | "unchecked" | "percentChecked" | "percentUnchecked";
|
|
156
|
+
declare const STAT_LABELS: Record<StatType, string>;
|
|
157
|
+
/** 一个字段能选哪些统计方式(菜单顺序同飞书) */
|
|
158
|
+
declare function statTypesFor(field: Pick<BaseField, "type">): StatType[];
|
|
159
|
+
/** 没设过统计方式时:主字段统计记录总数(表格左下角的「N 条记录」),其他字段不展示 */
|
|
160
|
+
declare function resolveStat(field: BaseField, primaryFieldId: string, stat: StatType | undefined): StatType;
|
|
161
|
+
/**
|
|
162
|
+
* 统计栏上显示的文字:记录总数是「N 条记录」,其他是「求和 1,234」这样的「方式 值」;不展示时为空串。
|
|
163
|
+
* values 是这一列在当前视图(筛选后)全部记录上的值。
|
|
164
|
+
*/
|
|
165
|
+
declare function statText(field: BaseField, values: unknown[], stat: StatType, timeZone?: string): string;
|
|
166
|
+
|
|
167
|
+
type FilterOperator = "is" | "isNot" | "contains" | "doesNotContain" | "isEmpty" | "isNotEmpty" | "isGreater" | "isGreaterEqual" | "isLess" | "isLessEqual";
|
|
168
|
+
/**
|
|
169
|
+
* 日期条件的值(同飞书筛选面板):具体日期,或相对今天的一段时间。
|
|
170
|
+
* 直接给时间戳等同于 `{ type: "exactDate", value }`。
|
|
171
|
+
*/
|
|
172
|
+
type DateFilterValue = {
|
|
173
|
+
type: "exactDate";
|
|
174
|
+
value: number;
|
|
175
|
+
} | {
|
|
176
|
+
type: "today" | "tomorrow" | "yesterday" | "currentWeek" | "lastWeek" | "currentMonth" | "lastMonth";
|
|
177
|
+
} | {
|
|
178
|
+
type: "pastDays" | "nextDays";
|
|
179
|
+
days: number;
|
|
180
|
+
};
|
|
181
|
+
interface FilterCondition {
|
|
182
|
+
fieldId: string;
|
|
183
|
+
operator: FilterOperator;
|
|
184
|
+
/**
|
|
185
|
+
* 文本 / 数字 / 日期(时间戳或 DateFilterValue)/ 选项 id(单选、多选可给数组,表示「任一」)/
|
|
186
|
+
* 人员 id 数组 / 布尔
|
|
187
|
+
*/
|
|
188
|
+
value?: unknown;
|
|
189
|
+
}
|
|
190
|
+
/** 字段类型 → 筛选时按哪类值比较 */
|
|
191
|
+
declare function filterKind(type: FieldTypeId): "text" | "number" | "date" | "select" | "multiSelect" | "user" | "checkbox" | "attachment";
|
|
192
|
+
/** 各类字段可选的筛选条件(顺序同飞书筛选面板) */
|
|
193
|
+
declare function filterOperatorsFor(type: FieldTypeId): FilterOperator[];
|
|
194
|
+
interface FilterConfig {
|
|
195
|
+
conjunction: "and" | "or";
|
|
196
|
+
conditions: FilterCondition[];
|
|
197
|
+
}
|
|
198
|
+
interface SortRule {
|
|
199
|
+
fieldId: string;
|
|
200
|
+
desc?: boolean;
|
|
201
|
+
}
|
|
202
|
+
type GroupRule = SortRule;
|
|
203
|
+
interface GroupHeader {
|
|
204
|
+
type: "group";
|
|
205
|
+
/** 由各级分组值拼成,同一分组在各端、各次计算里都一样(折叠状态按它记) */
|
|
206
|
+
id: string;
|
|
207
|
+
depth: number;
|
|
208
|
+
fieldId: string;
|
|
209
|
+
value: unknown;
|
|
210
|
+
/** 组内记录数(含折叠掉的) */
|
|
211
|
+
count: number;
|
|
212
|
+
collapsed: boolean;
|
|
213
|
+
}
|
|
214
|
+
interface GroupRows {
|
|
215
|
+
type: "rows";
|
|
216
|
+
count: number;
|
|
217
|
+
}
|
|
218
|
+
interface ComputedView {
|
|
219
|
+
/** 要显示的记录(折叠分组里的不算),按显示顺序 */
|
|
220
|
+
recordIds: string[];
|
|
221
|
+
/** 有分组时:分组头与记录段交替排列,记录段按顺序对应 recordIds;没有分组时为 null */
|
|
222
|
+
groups: Array<GroupHeader | GroupRows> | null;
|
|
223
|
+
/** 筛选后的记录数(含折叠掉的) */
|
|
224
|
+
total: number;
|
|
225
|
+
}
|
|
226
|
+
interface ComputeViewInput {
|
|
227
|
+
fields: BaseField[];
|
|
228
|
+
/** 按表内顺序(顺序键)排好的全部记录 */
|
|
229
|
+
recordIds: string[];
|
|
230
|
+
getValue: (recordId: string, fieldId: string) => unknown;
|
|
231
|
+
filter?: FilterConfig | null;
|
|
232
|
+
sort?: SortRule[];
|
|
233
|
+
group?: GroupRule[];
|
|
234
|
+
collapsedGroupIds?: ReadonlySet<string>;
|
|
235
|
+
timeZone?: string;
|
|
236
|
+
/** 「今天」「本周」这类日期条件以它为准,默认当前时间 */
|
|
237
|
+
now?: number;
|
|
238
|
+
}
|
|
239
|
+
/** 日期条件对应的时间段 [start, end) */
|
|
240
|
+
declare function dateFilterRange(expected: unknown, now: number, timeZone?: string): [number, number] | null;
|
|
241
|
+
/**
|
|
242
|
+
* 视图计算(纯函数,浏览器和 docs-collab 用同一份):筛选 → 排序(分组字段优先)→ 分组。
|
|
243
|
+
* 排序是稳定的,规则比不出先后时保持表内顺序。
|
|
244
|
+
*/
|
|
245
|
+
declare function computeView(input: ComputeViewInput): ComputedView;
|
|
246
|
+
|
|
247
|
+
interface BaseTableInfo {
|
|
248
|
+
id: string;
|
|
249
|
+
name: string;
|
|
250
|
+
primaryFieldId: string;
|
|
251
|
+
}
|
|
252
|
+
interface ColumnInfo {
|
|
253
|
+
width?: number;
|
|
254
|
+
/** 表格:隐藏列;看板:卡片上不显示;表单:不在表单里 */
|
|
255
|
+
hidden?: boolean;
|
|
256
|
+
/** 统计栏的统计方式;不填时主字段统计记录总数,其他字段不展示 */
|
|
257
|
+
stat?: StatType;
|
|
258
|
+
/** 表单:这一题必填 */
|
|
259
|
+
required?: boolean;
|
|
260
|
+
/** 表单:问题描述 */
|
|
261
|
+
description?: string;
|
|
262
|
+
}
|
|
263
|
+
/** 视图类型(同飞书:表格 grid、看板 kanban、表单 form;画册、甘特、日历以后加) */
|
|
264
|
+
type BaseViewType = "grid" | "kanban" | "form";
|
|
265
|
+
declare const BASE_VIEW_TYPES: readonly BaseViewType[];
|
|
266
|
+
declare const isBaseViewType: (value: unknown) => value is BaseViewType;
|
|
267
|
+
/** 行高四档,同飞书:1 低 32px、2 中 54px、3 高 88px、4 超高 124px */
|
|
268
|
+
type RowHeightLevel = 1 | 2 | 3 | 4;
|
|
269
|
+
interface BaseViewConfig {
|
|
270
|
+
id: string;
|
|
271
|
+
name: string;
|
|
272
|
+
type: BaseViewType;
|
|
273
|
+
/** 列顺序:去重、去掉已删字段,没排进来的字段(比如并发新建的)补在末尾 */
|
|
274
|
+
fieldIds: string[];
|
|
275
|
+
colInfos: Record<string, ColumnInfo>;
|
|
276
|
+
frozenColCount: number;
|
|
277
|
+
rowHeightLevel: RowHeightLevel;
|
|
278
|
+
filter: FilterConfig | null;
|
|
279
|
+
sort: SortRule[];
|
|
280
|
+
group: GroupRule[];
|
|
281
|
+
/** 看板:分组依据(单选或人员字段);没设、字段已删或类型不对时为 null */
|
|
282
|
+
groupFieldId: string | null;
|
|
283
|
+
/** 看板:卡片封面(附件字段);null 为无封面 */
|
|
284
|
+
coverFieldId: string | null;
|
|
285
|
+
/** 看板:卡片上显示字段名(飞书默认不显示) */
|
|
286
|
+
showFieldName: boolean;
|
|
287
|
+
/** 表单:标题、描述 */
|
|
288
|
+
formTitle: string;
|
|
289
|
+
formDescription: string;
|
|
290
|
+
}
|
|
291
|
+
declare function readTables(doc: Y.Doc): BaseTableInfo[];
|
|
292
|
+
declare function readTable(doc: Y.Doc, tableId: string): BaseTableInfo | null;
|
|
293
|
+
declare function readFieldMap(id: string, map: Y.Map<unknown>): BaseField | null;
|
|
294
|
+
/** 字段表:主字段在前,其余按第一个视图的列顺序,视图里没有的按 id 排在后面 */
|
|
295
|
+
declare function readFields(doc: Y.Doc, tableId: string): BaseField[];
|
|
296
|
+
declare function readViewMap(doc: Y.Doc, tableId: string, viewId: string, view: Y.Map<unknown>): BaseViewConfig;
|
|
297
|
+
declare function readViews(doc: Y.Doc, tableId: string): BaseViewConfig[];
|
|
298
|
+
declare function readView(doc: Y.Doc, tableId: string, viewId: string): BaseViewConfig | null;
|
|
299
|
+
/** 表里全部记录按顺序键排好(视图的筛选、排序、分组在 view.ts 的 computeView 里算) */
|
|
300
|
+
declare function orderedRecordIds(doc: Y.Doc, tableId: string): string[];
|
|
301
|
+
declare function readCellValue(doc: Y.Doc, tableId: string, recordId: string, fieldId: string): unknown;
|
|
302
|
+
|
|
303
|
+
/** 产品层上限:单表 1 万行(房间状态上限 12 MiB,见实现方案 §4) */
|
|
304
|
+
declare const MAX_RECORDS_PER_TABLE = 10000;
|
|
305
|
+
declare class BaseModelError extends Error {
|
|
306
|
+
}
|
|
307
|
+
/** 新建 / 修改字段时的属性:选项可以不带 id 和颜色,写入时自动补上 */
|
|
308
|
+
interface FieldPropertyInput extends Omit<FieldProperty, "options"> {
|
|
309
|
+
options?: Array<Partial<SelectOption> & {
|
|
310
|
+
name: string;
|
|
311
|
+
}>;
|
|
312
|
+
}
|
|
313
|
+
interface NewFieldInput {
|
|
314
|
+
name: string;
|
|
315
|
+
type: FieldTypeId;
|
|
316
|
+
/** 数字字段的展示形态:进度 / 货币 / 评分 */
|
|
317
|
+
uiType?: NumberUiType;
|
|
318
|
+
property?: FieldPropertyInput;
|
|
319
|
+
description?: string;
|
|
320
|
+
}
|
|
321
|
+
interface NewTableInput {
|
|
322
|
+
name: string;
|
|
323
|
+
/** 第一个是主字段;不给时用飞书新建数据表的默认字段(文本、单选、日期、附件) */
|
|
324
|
+
fields?: NewFieldInput[];
|
|
325
|
+
viewName?: string;
|
|
326
|
+
/** 建几条空记录;不给时:用默认字段的建 10 条(同飞书),自带字段的不建 */
|
|
327
|
+
recordCount?: number;
|
|
328
|
+
}
|
|
329
|
+
/** 飞书新建数据表的默认字段与空记录数(取自飞书网页版的建表代码) */
|
|
330
|
+
declare const DEFAULT_TABLE_FIELDS: readonly NewFieldInput[];
|
|
331
|
+
declare const DEFAULT_RECORD_COUNT = 10;
|
|
332
|
+
/** 第一个没被占用的名字:base、base 2、base 3…(新视图、新字段、新数据表的默认名) */
|
|
333
|
+
declare function uniqueName(names: Iterable<string>, base: string): string;
|
|
334
|
+
/** 副本的名字(同飞书「${1} 副本 ${2}」):xx 副本、xx 副本 2… */
|
|
335
|
+
declare function copyName(names: Iterable<string>, name: string): string;
|
|
336
|
+
/** 本端的操作者,写进新记录的创建人、改过的记录的修改人;宿主拿到当前用户后设一次 */
|
|
337
|
+
declare function setBaseActor(doc: Y.Doc, actor: UserValue | null): void;
|
|
338
|
+
interface CellChange {
|
|
339
|
+
recordId: string;
|
|
340
|
+
fieldId: string;
|
|
341
|
+
value: unknown;
|
|
342
|
+
}
|
|
343
|
+
interface ViewPatch {
|
|
344
|
+
name?: string;
|
|
345
|
+
frozenColCount?: number;
|
|
346
|
+
rowHeightLevel?: RowHeightLevel;
|
|
347
|
+
filter?: FilterConfig | null;
|
|
348
|
+
sort?: SortRule[];
|
|
349
|
+
group?: GroupRule[];
|
|
350
|
+
/** 看板:封面字段(附件),null 为无封面;换分组依据用 setKanbanGroupField */
|
|
351
|
+
coverFieldId?: string | null;
|
|
352
|
+
showFieldName?: boolean;
|
|
353
|
+
/** 表单 */
|
|
354
|
+
formTitle?: string;
|
|
355
|
+
formDescription?: string;
|
|
356
|
+
}
|
|
357
|
+
interface NewViewInput {
|
|
358
|
+
name?: string;
|
|
359
|
+
type?: BaseViewType;
|
|
360
|
+
}
|
|
361
|
+
/** 新视图的默认名(同飞书视图名:表格、看板、表单) */
|
|
362
|
+
declare const DEFAULT_VIEW_NAMES: Record<BaseViewType, string>;
|
|
363
|
+
/**
|
|
364
|
+
* 初始化空文档:写入 schemaVersion 并建第一张表。已初始化过的返回 null。
|
|
365
|
+
* 只该由一方执行(docs-collab 载入空房间时,或新建文档的那个客户端),否则两边会各建一张表。
|
|
366
|
+
*/
|
|
367
|
+
declare function initBase(doc: Y.Doc, input?: NewTableInput, origin?: unknown): {
|
|
368
|
+
tableId: string;
|
|
369
|
+
viewId: string;
|
|
370
|
+
} | null;
|
|
371
|
+
declare function addTable(doc: Y.Doc, input: NewTableInput, origin?: unknown): {
|
|
372
|
+
tableId: string;
|
|
373
|
+
viewId: string;
|
|
374
|
+
};
|
|
375
|
+
declare function renameTable(doc: Y.Doc, tableId: string, name: string, origin?: unknown): void;
|
|
376
|
+
/** 调整数据表顺序:把数据表移到第 index 位 */
|
|
377
|
+
declare function moveTable(doc: Y.Doc, tableId: string, index: number, origin?: unknown): void;
|
|
378
|
+
/**
|
|
379
|
+
* 复制数据表:字段、视图、记录(含元数据)都复制,id 全部重新生成,副本放在原表后面。
|
|
380
|
+
* 选项 id 只在字段内有效,原样保留。
|
|
381
|
+
*/
|
|
382
|
+
declare function duplicateTable(doc: Y.Doc, tableId: string, origin?: unknown): {
|
|
383
|
+
tableId: string;
|
|
384
|
+
viewId: string;
|
|
385
|
+
};
|
|
386
|
+
/** 删表:清空它的顶层类型(顶层类型本身删不掉),再从表清单里去掉 */
|
|
387
|
+
declare function deleteTable(doc: Y.Doc, tableId: string, origin?: unknown): void;
|
|
388
|
+
/** 字段在视图里的位置:在 viewId 这个视图里放到第 index 列(向左 / 向右插入字段时用) */
|
|
389
|
+
interface FieldPosition {
|
|
390
|
+
viewId: string;
|
|
391
|
+
index: number;
|
|
392
|
+
}
|
|
393
|
+
/** 新字段追加到每个视图的末尾;给了位置时,那个视图里放到指定列 */
|
|
394
|
+
declare function addField(doc: Y.Doc, tableId: string, input: NewFieldInput, origin?: unknown, position?: FieldPosition): string;
|
|
395
|
+
/** 复制字段:配置和各记录的值一起复制,副本放在原字段右边(给了视图时在那个视图里) */
|
|
396
|
+
declare function duplicateField(doc: Y.Doc, tableId: string, fieldId: string, options?: {
|
|
397
|
+
viewId?: string;
|
|
398
|
+
}, origin?: unknown): string;
|
|
399
|
+
interface FieldPatch {
|
|
400
|
+
name?: string;
|
|
401
|
+
description?: string;
|
|
402
|
+
property?: FieldPropertyInput;
|
|
403
|
+
/** 改类型:已有的值按新类型转换(同飞书:能转的转,转不了的清掉) */
|
|
404
|
+
type?: FieldTypeId;
|
|
405
|
+
uiType?: NumberUiType;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* 改字段名、描述、属性、类型。删掉的选项会从单元格里一并清掉;改类型时已有的值按新类型转换。
|
|
409
|
+
* 注意属性整体替换:两人同时改同一字段的选项,后写入的生效。
|
|
410
|
+
*/
|
|
411
|
+
declare function updateField(doc: Y.Doc, tableId: string, fieldId: string, patch: FieldPatch, origin?: unknown): void;
|
|
412
|
+
/** 删字段:主字段不能删;同时清掉各视图里的列、筛选排序分组条件和各记录里的值 */
|
|
413
|
+
declare function deleteField(doc: Y.Doc, tableId: string, fieldId: string, origin?: unknown): void;
|
|
414
|
+
/**
|
|
415
|
+
* 新增记录,第一条落在表内第 index 位(默认追加到末尾)。值按字段类型规范化,空值不存。
|
|
416
|
+
* 超过单表上限时抛错。
|
|
417
|
+
*/
|
|
418
|
+
declare function addRecords(doc: Y.Doc, tableId: string, rows: Array<Record<string, unknown>>, options?: {
|
|
419
|
+
index?: number;
|
|
420
|
+
}, origin?: unknown): string[];
|
|
421
|
+
/**
|
|
422
|
+
* 补自动编号:缺编号的、和别人撞号的(两端同时新增)改用新的号,最早建的那条保留原号。
|
|
423
|
+
* 只该由一方执行(docs-collab 存盘时),两端都修会再撞一次。返回改了几条。
|
|
424
|
+
*/
|
|
425
|
+
declare function repairAutoNumbers(doc: Y.Doc, tableId: string, origin?: unknown): number;
|
|
426
|
+
/** 改单元格:值按字段类型规范化,空值删除;和原值相同的不写(避免文档白白变大) */
|
|
427
|
+
declare function setCells(doc: Y.Doc, tableId: string, changes: CellChange[], origin?: unknown): void;
|
|
428
|
+
declare function deleteRecords(doc: Y.Doc, tableId: string, recordIds: string[], origin?: unknown): void;
|
|
429
|
+
/** 把一批记录(保持它们之间的相对顺序)移到表内第 index 位(index 按移走它们之前的顺序算) */
|
|
430
|
+
declare function moveRecords(doc: Y.Doc, tableId: string, recordIds: string[], index: number, origin?: unknown): void;
|
|
431
|
+
/** 看板、表单视图的专属配置(复制视图、载入快照时原样写回) */
|
|
432
|
+
declare function writeViewExtras(view: Y.Map<unknown>, source: BaseViewConfig): void;
|
|
433
|
+
/**
|
|
434
|
+
* 新建视图(第三个参数传字符串时是视图名,兼容旧调用)。
|
|
435
|
+
* 看板:分组依据取第一个单选字段,没有就取第一个人员字段,并在卡片上隐藏它(同飞书新建看板);都没有时留空,界面提示选择。
|
|
436
|
+
* 表单:系统字段(创建时间、编号等)不能填写,不进表单;标题默认用数据表名。
|
|
437
|
+
*/
|
|
438
|
+
declare function addView(doc: Y.Doc, tableId: string, input?: string | NewViewInput, origin?: unknown): string;
|
|
439
|
+
/** 看板换分组依据(单选或人员字段):新的分组字段在卡片上默认隐藏,列已经表达了它 */
|
|
440
|
+
declare function setKanbanGroupField(doc: Y.Doc, tableId: string, viewId: string, fieldId: string, origin?: unknown): void;
|
|
441
|
+
/** 删视图:至少保留一个 */
|
|
442
|
+
declare function deleteView(doc: Y.Doc, tableId: string, viewId: string, origin?: unknown): void;
|
|
443
|
+
/** 复制视图:列顺序、列宽、隐藏、冻结、行高、筛选、排序、分组都带上,副本紧跟在原视图后面 */
|
|
444
|
+
declare function duplicateView(doc: Y.Doc, tableId: string, viewId: string, origin?: unknown): string;
|
|
445
|
+
declare function updateView(doc: Y.Doc, tableId: string, viewId: string, patch: ViewPatch, origin?: unknown): void;
|
|
446
|
+
/** 改列宽 / 隐藏列(按字段分别存,两人改不同列互不影响) */
|
|
447
|
+
declare function setColumnInfo(doc: Y.Doc, tableId: string, viewId: string, fieldId: string, info: ColumnInfo, origin?: unknown): void;
|
|
448
|
+
/** 调整列顺序:把字段移到视图第 index 列(主字段固定在第一列) */
|
|
449
|
+
declare function moveViewField(doc: Y.Doc, tableId: string, viewId: string, fieldId: string, index: number, origin?: unknown): void;
|
|
450
|
+
/** 撤销 / 重做:只跟踪本端 origin 的改动,别人的改动不会被撤掉 */
|
|
451
|
+
declare function createBaseUndoManager(doc: Y.Doc, tableId: string, origin: unknown): Y.UndoManager;
|
|
452
|
+
|
|
453
|
+
/** 能放进表单的字段:系统字段(创建时间、编号…)由系统生成,不能填写 */
|
|
454
|
+
declare const isFormFieldType: (type: FieldTypeId) => boolean;
|
|
455
|
+
interface FormQuestion {
|
|
456
|
+
field: BaseField;
|
|
457
|
+
required: boolean;
|
|
458
|
+
description: string;
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* 表单里的题目:按视图的字段顺序,取没隐藏、能填写的字段。主字段(飞书叫索引列)不能移出表单,总在里面。
|
|
462
|
+
*/
|
|
463
|
+
declare function formQuestions(view: BaseViewConfig, fields: BaseField[], primaryFieldId: string): FormQuestion[];
|
|
464
|
+
/** 提交表单时必填题没填:missing 是没填的字段 id,界面据此逐题提示「该项为必填项」 */
|
|
465
|
+
declare class FormSubmitError extends BaseModelError {
|
|
466
|
+
readonly missing: string[];
|
|
467
|
+
constructor(missing: string[]);
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* 提交表单,新增一条记录(追加到表尾)并返回它的 id。只收表单里的题目,值按字段类型规范化;
|
|
471
|
+
* 必填题规范化后为空时抛 FormSubmitError,什么都不写。
|
|
472
|
+
*/
|
|
473
|
+
declare function submitForm(doc: Y.Doc, tableId: string, viewId: string, values: Record<string, unknown>, origin?: unknown): string;
|
|
474
|
+
|
|
475
|
+
export { addTable as $, type AttachmentValue as A, type BaseField as B, CURRENCY_SYMBOLS as C, DEFAULT_RECORD_COUNT as D, type GroupRows as E, type FilterConfig as F, type GroupHeader as G, type GroupRule as H, type NewFieldInput as I, type NewTableInput as J, type NewViewInput as K, type NumberUiType as L, MAX_RECORDS_PER_TABLE as M, NUMBER_UI_TYPES as N, type RowHeightLevel as O, STAT_LABELS as P, type StatType as Q, RECORD_META as R, type SortRule as S, type TextSegment as T, type UserValue as U, type UrlValue as V, type ViewPatch as W, type WallTime as X, addDaysIn as Y, addField as Z, addRecords as _, type SelectOption as a, addView as a0, cellValueToText as a1, compareCellValues as a2, computeView as a3, copyName as a4, createBaseUndoManager as a5, dateFilterRange as a6, defaultFieldProperty as a7, deleteField as a8, deleteRecords as a9, readCellValue as aA, readFieldMap as aB, readFieldValue as aC, readFields as aD, readTable as aE, readTables as aF, readView as aG, readViewMap as aH, readViews as aI, renameTable as aJ, repairAutoNumbers as aK, resolveStat as aL, setBaseActor as aM, setCells as aN, setColumnInfo as aO, setKanbanGroupField as aP, startOfDayIn as aQ, startOfMonthIn as aR, statText as aS, statTypesFor as aT, submitForm as aU, toWallTime as aV, uniqueName as aW, updateField as aX, updateView as aY, weekdayIn as aZ, writeViewExtras as a_, deleteTable as aa, deleteView as ab, duplicateField as ac, duplicateTable as ad, duplicateView as ae, fieldUiType as af, fieldValueKey as ag, filterKind as ah, filterOperatorsFor as ai, formQuestions as aj, formatNumberField as ak, fromWallTime as al, initBase as am, isBaseViewType as an, isComputedFieldType as ao, isEmptyCellValue as ap, isFieldType as aq, isFormFieldType as ar, isKanbanGroupFieldType as as, isNumberUiType as at, isRecordMetaKey as au, moveRecords as av, moveTable as aw, moveViewField as ax, normalizeCellValue as ay, orderedRecordIds as az, type BaseViewConfig as b, BASE_VIEW_TYPES as c, BaseModelError as d, type BaseTableInfo as e, type BaseViewType as f, type CellChange as g, type CellValue as h, type ColumnInfo as i, type ComputeViewInput as j, type ComputedView as k, DEFAULT_TABLE_FIELDS as l, DEFAULT_TIME_ZONE as m, DEFAULT_VIEW_NAMES as n, type DateFilterValue as o, FIELD_UI_TYPE as p, type FieldPatch as q, type FieldPosition as r, type FieldProperty as s, type FieldPropertyInput as t, FieldType as u, type FieldTypeId as v, type FilterCondition as w, type FilterOperator as x, type FormQuestion as y, FormSubmitError as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { importCsv, importSheetSource, importXlsx } from './chunk-
|
|
2
|
-
import './chunk-QU25OJJ6.js';
|
|
3
|
-
import './chunk-XDL4R54M.js';
|
|
1
|
+
export { importCsv, importSheetSource, importXlsx } from './chunk-X4BUO2RH.js';
|
|
4
2
|
import './chunk-OO2NIO3M.js';
|
|
3
|
+
import './chunk-QU25OJJ6.js';
|
|
5
4
|
import './chunk-W2ES4Q4B.js';
|
|
6
|
-
|
|
7
|
-
//# sourceMappingURL=import-
|
|
5
|
+
import './chunk-XDL4R54M.js';
|
|
6
|
+
//# sourceMappingURL=import-TEZ37G5R.js.map
|
|
7
|
+
//# sourceMappingURL=import-TEZ37G5R.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"import-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"import-TEZ37G5R.js"}
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,7 @@ registerFormat({
|
|
|
31
31
|
importExtensions: [".docx", ".md", ".html"],
|
|
32
32
|
exportFormats: ["docx", "html", "json", "markdown"]
|
|
33
33
|
},
|
|
34
|
-
load: () => import('./DocView-
|
|
34
|
+
load: () => import('./DocView-7QBKHBU4.js')
|
|
35
35
|
});
|
|
36
36
|
registerFormat({
|
|
37
37
|
format: "sheet",
|
|
@@ -51,7 +51,7 @@ registerFormat({
|
|
|
51
51
|
// 只导活动表、其余表在 warnings 里点名
|
|
52
52
|
exportFormats: ["xlsx", "csv"]
|
|
53
53
|
},
|
|
54
|
-
load: () => import('./SheetView-
|
|
54
|
+
load: () => import('./SheetView-WP4DKSDS.js')
|
|
55
55
|
});
|
|
56
56
|
registerFormat({
|
|
57
57
|
format: "pdf",
|
package/dist/sheet.js
CHANGED