xiaodao-spreader 0.1.37 → 0.1.38
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/README.ZH.md +56 -1
- package/README.md +54 -1
- package/dist/style.css +1 -1
- package/dist/types/components/spreader/components/note-overlay.vue.d.ts +47 -0
- package/dist/types/components/spreader/components/spreader.vue.d.ts +2 -0
- package/dist/types/components/spreader/composables/core-state.d.ts +19 -1
- package/dist/types/components/spreader/composables/interactions.d.ts +21 -0
- package/dist/types/components/spreader/core/constants.d.ts +2 -0
- package/dist/types/components/spreader/core/notes.d.ts +47 -0
- package/dist/types/components/spreader/core/types.d.ts +24 -0
- package/dist/xiaodao-spreader.es.js +7469 -7104
- package/dist/xiaodao-spreader.umd.js +9 -9
- package/package.json +1 -1
|
@@ -6,6 +6,7 @@ type __VLS_Props = {
|
|
|
6
6
|
height?: number | string;
|
|
7
7
|
theme?: 'light' | 'dark';
|
|
8
8
|
locale?: string;
|
|
9
|
+
noteAuthor?: string;
|
|
9
10
|
};
|
|
10
11
|
type __VLS_PublicProps = {
|
|
11
12
|
'data'?: SheetModelData[];
|
|
@@ -15,6 +16,7 @@ declare const _default: import("vue").DefineComponent<__VLS_PublicProps, {}, {},
|
|
|
15
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
16
17
|
"onUpdate:data"?: ((value: SheetModelData[]) => any) | undefined;
|
|
17
18
|
}>, {
|
|
19
|
+
noteAuthor: string;
|
|
18
20
|
locale: string;
|
|
19
21
|
rowCount: number;
|
|
20
22
|
colCount: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ComputedRef, type Ref } from 'vue';
|
|
2
2
|
import { FormulaDeps } from '../core/formula';
|
|
3
|
-
import type { CellCoord, CellData, CellStyle, SelectionRange, BorderStyle, BorderSide, FreezePane, ViewportRegion, SheetFilter, FilterColumn, ConditionalFormattingRule, ConditionalFormattingFormat, DataValidationRule, DataValidationResult, DataValidationSeverity, DimensionOutline } from '../core/types';
|
|
3
|
+
import type { CellCoord, CellData, CellStyle, CellNote, SelectionRange, BorderStyle, BorderSide, FreezePane, ViewportRegion, SheetFilter, FilterColumn, ConditionalFormattingRule, ConditionalFormattingFormat, DataValidationRule, DataValidationResult, DataValidationSeverity, DimensionOutline } from '../core/types';
|
|
4
4
|
import { type FilterCandidates } from '../core/filter-core';
|
|
5
5
|
import { type OutlineValidationResult } from '../core/outline-core';
|
|
6
6
|
/** 选区触发方式,影响「合并单元格是否扩大选区」。
|
|
@@ -259,6 +259,24 @@ export interface CoreState {
|
|
|
259
259
|
clampScroll?: (sx: number | null, sy: number | null) => void;
|
|
260
260
|
/** 查找高亮钩子:返回某单元格当前的高亮类型(由 find-replace 模块注入) */
|
|
261
261
|
findHighlight?: (col: number, row: number) => 'active' | 'match' | null;
|
|
262
|
+
/** 当前工作表批注池:按 noteId 存放,cell.noteId 引用之;与 value/style 完全独立 */
|
|
263
|
+
notes: Record<string, CellNote>;
|
|
264
|
+
/** 单元格是否有批注 */
|
|
265
|
+
hasNote: (row: number, col: number) => boolean;
|
|
266
|
+
/** 读取单元格批注(返回池中对象引用) */
|
|
267
|
+
getNote: (row: number, col: number) => CellNote | undefined;
|
|
268
|
+
/** 为单元格创建/覆盖批注(一次独立 Undo),返回新批注 */
|
|
269
|
+
setCellNote: (row: number, col: number, text: string, author?: string, opts?: {
|
|
270
|
+
silent?: boolean;
|
|
271
|
+
}) => CellNote;
|
|
272
|
+
/** 更新现存批注文本(按 id,一次独立 Undo) */
|
|
273
|
+
updateCellNote: (id: string, text: string) => void;
|
|
274
|
+
/** 删除单元格批注(一次独立 Undo) */
|
|
275
|
+
deleteCellNote: (row: number, col: number) => void;
|
|
276
|
+
/** 清理 notes 池中未被任何 cell 引用的孤儿批注(删除/覆盖单元格后调用) */
|
|
277
|
+
gcNotes: () => void;
|
|
278
|
+
/** 批量读取选区内所有批注(key -> note) */
|
|
279
|
+
getNotesInRange: (range: SelectionRange) => Map<string, CellNote>;
|
|
262
280
|
/** 当前工作表的全部数据验证规则(规则属于 Sheet,不属于 Cell) */
|
|
263
281
|
dataValidations: DataValidationRule[];
|
|
264
282
|
/** 命中该单元格的全部规则(经空间索引,不遍历整表) */
|
|
@@ -69,6 +69,27 @@ export interface InteractionsState {
|
|
|
69
69
|
openValidationDropdown: (col: number, row: number) => boolean;
|
|
70
70
|
closeValidationDropdown: () => void;
|
|
71
71
|
onValidationDropdownSelect: (value: string) => void;
|
|
72
|
+
/** 当前显示的批注浮层:mode=view 查看 / edit 编辑;null=关闭 */
|
|
73
|
+
noteUi: Ref<{
|
|
74
|
+
mode: 'view' | 'edit';
|
|
75
|
+
row: number;
|
|
76
|
+
col: number;
|
|
77
|
+
} | null>;
|
|
78
|
+
/** 按逻辑坐标打开批注浮层(view / edit);编辑态需由宿主组件聚焦输入框 */
|
|
79
|
+
openNote: (row: number, col: number, mode: 'view' | 'edit') => void;
|
|
80
|
+
/** 关闭批注浮层 */
|
|
81
|
+
closeNote: () => void;
|
|
82
|
+
/** 右键 / Shift+F2 入口:新建或编辑批注(有则预填、无则新建) */
|
|
83
|
+
editNoteAt: (row: number, col: number) => void;
|
|
84
|
+
/** 编辑态保存:空文本删除现存批注;非空按新建/更新走 setCellNote/updateCellNote */
|
|
85
|
+
saveNoteAt: (row: number, col: number, text: string, author?: string) => void;
|
|
86
|
+
/** 右键:删除批注 */
|
|
87
|
+
removeNoteAt: (row: number, col: number) => void;
|
|
88
|
+
/** 命中测试:点是否落在单元格右上角的批注指示器上 */
|
|
89
|
+
isNoteIndicatorHit: (x: number, y: number) => {
|
|
90
|
+
row: number;
|
|
91
|
+
col: number;
|
|
92
|
+
} | null;
|
|
72
93
|
dimInputRef: Ref<HTMLInputElement | null>;
|
|
73
94
|
dimPanel: Ref<{
|
|
74
95
|
type: 'row' | 'col';
|
|
@@ -15,6 +15,8 @@ export declare const FILL_HANDLE_HIT_PADDING = 4;
|
|
|
15
15
|
export declare const UNDO_MAX = 50;
|
|
16
16
|
export declare const OUTLINE_PANEL = 16;
|
|
17
17
|
export declare const OUTLINE_GUTTER = 15;
|
|
18
|
+
/** 新建批注时的默认作者(空串=不记录作者名,显示时用 i18n noteUnnamed 占位) */
|
|
19
|
+
export declare const DEFAULT_NOTE_AUTHOR = "";
|
|
18
20
|
export declare const i18n: Record<string, Record<string, string>>;
|
|
19
21
|
export declare function t(locale: string, key: string): string;
|
|
20
22
|
export declare const DEFAULT_FONT_FAMILY = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Microsoft YaHei\", sans-serif";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { CellNote, CellData, SelectionRange } from './types';
|
|
2
|
+
/** 生成唯一 Note ID */
|
|
3
|
+
export declare function genNoteId(): string;
|
|
4
|
+
export declare function createEmptyNotes(): Record<string, CellNote>;
|
|
5
|
+
/** 从序列化数据加载批注池(兼容旧数据无 notes 的情况;返回浅拷贝避免共享引用) */
|
|
6
|
+
export declare function loadNotes(serialized?: Record<string, CellNote>): Record<string, CellNote>;
|
|
7
|
+
/** 单元格是否有批注 */
|
|
8
|
+
export declare function hasNote(row: number, col: number, cells: Record<string, CellData>): boolean;
|
|
9
|
+
/** 读取单元格批注(返回池中对象引用) */
|
|
10
|
+
export declare function getNote(row: number, col: number, cells: Record<string, CellData>, notes: Record<string, CellNote>): CellNote | undefined;
|
|
11
|
+
/** 按 ID 读取批注 */
|
|
12
|
+
export declare function getNoteById(id: string, notes: Record<string, CellNote>): CellNote | undefined;
|
|
13
|
+
/** 创建纯批注对象(不落池) */
|
|
14
|
+
export declare function createNote(text: string, author?: string): CellNote;
|
|
15
|
+
/**
|
|
16
|
+
* 为单元格创建/覆盖批注:新建 note 写入池并绑定 cell.noteId。
|
|
17
|
+
* 若 cell 原先已有批注会先清理旧池对象(避免孤儿)。
|
|
18
|
+
* 返回新批注对象。
|
|
19
|
+
*/
|
|
20
|
+
export declare function setNote(row: number, col: number, text: string, author: string | undefined, cells: Record<string, CellData>, notes: Record<string, CellNote>): CellNote;
|
|
21
|
+
/** 更新现存批注文本(仅改 text 与 updatedAt) */
|
|
22
|
+
export declare function updateNote(id: string, text: string, notes: Record<string, CellNote>): CellNote;
|
|
23
|
+
/** 删除单元格批注(清理池对象 + cell.noteId),返回被删的 note 或 undefined */
|
|
24
|
+
export declare function removeNote(row: number, col: number, cells: Record<string, CellData>, notes: Record<string, CellNote>): CellNote | undefined;
|
|
25
|
+
/** 批量读取选区内所有批注(key -> note) */
|
|
26
|
+
export declare function getNotesInRange(range: SelectionRange, cells: Record<string, CellData>, notes: Record<string, CellNote>): Map<string, CellNote>;
|
|
27
|
+
/**
|
|
28
|
+
* 复制批注引用:源 cell 有 note 时,目标 cell 复用同一 noteId(共享 note 对象)。
|
|
29
|
+
* 目标原有批注会被覆盖(其池对象交由上层统一 GC)。
|
|
30
|
+
*/
|
|
31
|
+
export declare function copyNoteToCell(srcRow: number, srcCol: number, dstRow: number, dstCol: number, cells: Record<string, CellData>): void;
|
|
32
|
+
/** 清理池中没有被任何 cell 引用的孤儿 note */
|
|
33
|
+
export declare function gcOrphanNotes(cells: Record<string, CellData>, notes: Record<string, CellNote>): void;
|
|
34
|
+
/**
|
|
35
|
+
* 插入行后平移全部 cell 引用(row >= insertAt 的行整体下移 count)。
|
|
36
|
+
* 项目本体在 sheets-ops 的 insertRows 中已有整块单元格搬移逻辑,
|
|
37
|
+
* 此处声明为独立函数便于与 notes 联动测试;实际调用时由上层在搬移后同步执行。
|
|
38
|
+
*/
|
|
39
|
+
export declare function adjustForInsertRows(insertAt: number, count: number, cells: Record<string, CellData>): void;
|
|
40
|
+
/** 插入列后平移全部 cell 引用 */
|
|
41
|
+
export declare function adjustForInsertCols(insertAt: number, count: number, cells: Record<string, CellData>): void;
|
|
42
|
+
/** 删除行:命中区间的 cell 及其 note 一并删除,后续行整体上移 */
|
|
43
|
+
export declare function adjustForDeleteRows(deleteStart: number, deleteEnd: number, cells: Record<string, CellData>, notes: Record<string, CellNote>): void;
|
|
44
|
+
/** 删除列:命中区间的 cell 及其 note 一并删除,后续列整体左移 */
|
|
45
|
+
export declare function adjustForDeleteCols(deleteStart: number, deleteEnd: number, cells: Record<string, CellData>, notes: Record<string, CellNote>): void;
|
|
46
|
+
/** 交换两个单元格的 noteId 引用(排序时随数据一起移动) */
|
|
47
|
+
export declare function swapNotes(row1: number, col1: number, row2: number, col2: number, cells: Record<string, CellData>): void;
|
|
@@ -59,6 +59,26 @@ export interface CellStyle {
|
|
|
59
59
|
export interface CellData {
|
|
60
60
|
value: string;
|
|
61
61
|
styleId?: number;
|
|
62
|
+
/** 批注引用:指向 Sheet 级 notes 池中的一个 CellNote;与 value/style 完全独立 */
|
|
63
|
+
noteId?: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 批注是绑定到 Cell 的独立附加元数据,不属于 cell.value / formula / style。
|
|
67
|
+
* 采用「Note Pool」存储:Sheet 级 notes 池按 id 存放,cell 只保存 noteId 引用,
|
|
68
|
+
* 便于扩展 Threaded Comment,且多个操作(排序/插入删除)移动 cell 时 noteId 随数据移动。
|
|
69
|
+
* 第一阶段实现与多人协作 Threaded Comment 无关。
|
|
70
|
+
*/
|
|
71
|
+
export interface CellNote {
|
|
72
|
+
/** 稳定唯一 ID(不可用数组 index) */
|
|
73
|
+
id: string;
|
|
74
|
+
/** 批注正文(多行文本,含换行) */
|
|
75
|
+
text: string;
|
|
76
|
+
/** 作者信息(可选) */
|
|
77
|
+
author?: string;
|
|
78
|
+
/** 创建时间(epoch ms) */
|
|
79
|
+
createdAt: number;
|
|
80
|
+
/** 最近修改时间(epoch ms) */
|
|
81
|
+
updatedAt: number;
|
|
62
82
|
}
|
|
63
83
|
/** 搜索范围:当前工作表 / 整个工作簿 / 当前选区 */
|
|
64
84
|
export type FindScope = 'sheet' | 'workbook' | 'selection';
|
|
@@ -296,6 +316,8 @@ export interface SheetModelData {
|
|
|
296
316
|
rowOutlines?: DimensionOutline[];
|
|
297
317
|
/** 列分组集合;旧数据缺省视为无分组 */
|
|
298
318
|
columnOutlines?: DimensionOutline[];
|
|
319
|
+
/** 单元格批注池:按 noteId 存放,cell.noteId 引用之;与 cell value/style 完全独立 */
|
|
320
|
+
notes?: Record<string, CellNote>;
|
|
299
321
|
}
|
|
300
322
|
export interface SheetState {
|
|
301
323
|
id: string;
|
|
@@ -328,6 +350,8 @@ export interface SheetState {
|
|
|
328
350
|
rowOutlines: DimensionOutline[];
|
|
329
351
|
/** 列分组集合;缺省为空数组 */
|
|
330
352
|
columnOutlines: DimensionOutline[];
|
|
353
|
+
/** 单元格批注池:按 noteId 存放,cell.noteId 引用之 */
|
|
354
|
+
notes: Record<string, CellNote>;
|
|
331
355
|
}
|
|
332
356
|
/** 视口区域:冻结窗格将画布划分为四个独立滚动区域 */
|
|
333
357
|
export interface ViewportRegion {
|