wendang 0.0.1 → 0.1.1
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/LICENSE +44 -0
- package/NOTICE.md +7 -0
- package/README.md +169 -2
- package/dist/cjs/document.js +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/mindmap.js +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/schema.js +1 -0
- package/dist/cjs/shared/anchor.js +1 -0
- package/dist/cjs/shared/callout.js +1 -0
- package/dist/cjs/shared/code-block.js +1 -0
- package/dist/cjs/shared/code-languages.js +1 -0
- package/dist/cjs/shared/doc-compatibility.js +1 -0
- package/dist/cjs/shared/doc-text.js +1 -0
- package/dist/cjs/shared/document-colors.js +1 -0
- package/dist/cjs/shared/inline-comments.js +1 -0
- package/dist/cjs/shared/mind-map-folding.js +1 -0
- package/dist/cjs/shared/mind-map-phase2.js +1 -0
- package/dist/cjs/shared/mind-map.js +1 -0
- package/dist/cjs/shared/mind-topic-text.js +1 -0
- package/dist/cjs/shared/node-catalog.js +1 -0
- package/dist/cjs/shared/presence.js +1 -0
- package/dist/cjs/shared/safe-href.js +1 -0
- package/dist/cjs/shared/table-cell-format.js +1 -0
- package/dist/cjs/shared/table-layout.js +1 -0
- package/dist/cjs/shared/types.js +1 -0
- package/dist/cjs/shared/video-embed.js +1 -0
- package/dist/cjs/shared/workbook.js +1 -0
- package/dist/cjs/spreadsheet.js +1 -0
- package/dist/cjs/types.js +1 -0
- package/dist/cjs/validation/callout.js +1 -0
- package/dist/cjs/validation/doc-node-whitelist.js +1 -0
- package/dist/cjs/validation/error.js +1 -0
- package/dist/cjs/validation/mind-map.js +1 -0
- package/dist/cjs/validation/schema-version.js +1 -0
- package/dist/cjs/validation/schema.js +1 -0
- package/dist/cjs/validation/video-embed.js +1 -0
- package/dist/cjs/validation/workbook.js +1 -0
- package/dist/esm/document.js +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/mindmap.js +1 -0
- package/dist/esm/schema.js +1 -0
- package/dist/esm/shared/anchor.js +1 -0
- package/dist/esm/shared/callout.js +1 -0
- package/dist/esm/shared/code-block.js +1 -0
- package/dist/esm/shared/code-languages.js +1 -0
- package/dist/esm/shared/doc-compatibility.js +1 -0
- package/dist/esm/shared/doc-text.js +1 -0
- package/dist/esm/shared/document-colors.js +1 -0
- package/dist/esm/shared/inline-comments.js +1 -0
- package/dist/esm/shared/mind-map-folding.js +1 -0
- package/dist/esm/shared/mind-map-phase2.js +1 -0
- package/dist/esm/shared/mind-map.js +1 -0
- package/dist/esm/shared/mind-topic-text.js +1 -0
- package/dist/esm/shared/node-catalog.js +1 -0
- package/dist/esm/shared/presence.js +1 -0
- package/dist/esm/shared/safe-href.js +1 -0
- package/dist/esm/shared/table-cell-format.js +1 -0
- package/dist/esm/shared/table-layout.js +1 -0
- package/dist/esm/shared/types.js +1 -0
- package/dist/esm/shared/video-embed.js +1 -0
- package/dist/esm/shared/workbook.js +1 -0
- package/dist/esm/spreadsheet.js +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/validation/callout.js +1 -0
- package/dist/esm/validation/doc-node-whitelist.js +1 -0
- package/dist/esm/validation/error.js +1 -0
- package/dist/esm/validation/mind-map.js +1 -0
- package/dist/esm/validation/schema-version.js +1 -0
- package/dist/esm/validation/schema.js +1 -0
- package/dist/esm/validation/video-embed.js +1 -0
- package/dist/esm/validation/workbook.js +1 -0
- package/dist/types/document.d.ts +4 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/mindmap.d.ts +4 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/shared/anchor.d.ts +32 -0
- package/dist/types/shared/callout.d.ts +25 -0
- package/dist/types/shared/code-block.d.ts +25 -0
- package/dist/types/shared/code-languages.d.ts +7 -0
- package/dist/types/shared/doc-compatibility.d.ts +1 -0
- package/dist/types/shared/doc-text.d.ts +7 -0
- package/dist/types/shared/document-colors.d.ts +102 -0
- package/dist/types/shared/inline-comments.d.ts +29 -0
- package/dist/types/shared/mind-map-folding.d.ts +3 -0
- package/dist/types/shared/mind-map-phase2.d.ts +19 -0
- package/dist/types/shared/mind-map.d.ts +130 -0
- package/dist/types/shared/mind-topic-text.d.ts +16 -0
- package/dist/types/shared/node-catalog.d.ts +13 -0
- package/dist/types/shared/presence.d.ts +18 -0
- package/dist/types/shared/safe-href.d.ts +2 -0
- package/dist/types/shared/table-cell-format.d.ts +23 -0
- package/dist/types/shared/table-layout.d.ts +4 -0
- package/dist/types/shared/types.d.ts +40 -0
- package/dist/types/shared/video-embed.d.ts +10 -0
- package/dist/types/shared/workbook.d.ts +54 -0
- package/dist/types/spreadsheet.d.ts +1 -0
- package/dist/types/types.d.ts +3 -0
- package/dist/types/validation/callout.d.ts +1 -0
- package/dist/types/validation/doc-node-whitelist.d.ts +2 -0
- package/dist/types/validation/error.d.ts +7 -0
- package/dist/types/validation/mind-map.d.ts +20 -0
- package/dist/types/validation/schema-version.d.ts +1 -0
- package/dist/types/validation/schema.d.ts +15 -0
- package/dist/types/validation/video-embed.d.ts +1 -0
- package/dist/types/validation/workbook.d.ts +1 -0
- package/package.json +88 -6
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type NodeKind = 'block' | 'inline' | 'text' | 'atom';
|
|
2
|
+
export interface NodeSpecMeta {
|
|
3
|
+
type: string;
|
|
4
|
+
kind: NodeKind;
|
|
5
|
+
topLevel?: boolean;
|
|
6
|
+
atom?: boolean;
|
|
7
|
+
label: string;
|
|
8
|
+
editorOnly?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const NODE_CATALOG: NodeSpecMeta[];
|
|
11
|
+
export declare function nodeMeta(type: string | undefined): NodeSpecMeta | undefined;
|
|
12
|
+
export declare const UNKNOWN_NODE_LABEL = "\u6B64\u5185\u5BB9\u7531\u66F4\u9AD8\u7248\u672C\u7684\u7F16\u8F91\u5668\u521B\u5EFA\uFF0C\u5F53\u524D\u7248\u672C\u65E0\u6CD5\u663E\u793A";
|
|
13
|
+
export declare function headingTag(level: unknown): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PresenceUser {
|
|
2
|
+
userId: string;
|
|
3
|
+
displayName: string;
|
|
4
|
+
color: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const PRESENCE_PALETTE: readonly ["#2f6feb", "#127a45", "#b45309", "#c026d3", "#dc2626", "#0e7490", "#7c3aed", "#9a4a08"];
|
|
7
|
+
export declare function colorForUser(userId: string): string;
|
|
8
|
+
export declare function hashIndex(input: string, buckets: number): number;
|
|
9
|
+
export declare function initialOf(displayName: string): string;
|
|
10
|
+
export declare function collectPresence(states: Array<{
|
|
11
|
+
userId: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
}>, selfUserId: string | null): PresenceUser[];
|
|
14
|
+
export declare function relativeLuminance(hex: string): number;
|
|
15
|
+
export declare const DARK_TEXT = "#1f2937";
|
|
16
|
+
export declare function contrastRatio(a: string, b: string): number;
|
|
17
|
+
export declare function readableTextColor(hex: string): '#ffffff' | typeof DARK_TEXT;
|
|
18
|
+
export declare function parseHex(hex: string): [number, number, number] | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const CELL_BACKGROUNDS: readonly [{
|
|
2
|
+
readonly name: "默认";
|
|
3
|
+
readonly value: null;
|
|
4
|
+
}, {
|
|
5
|
+
readonly name: "灰";
|
|
6
|
+
readonly value: "#f1f3f5";
|
|
7
|
+
}, {
|
|
8
|
+
readonly name: "黄";
|
|
9
|
+
readonly value: "#fff3bf";
|
|
10
|
+
}, {
|
|
11
|
+
readonly name: "绿";
|
|
12
|
+
readonly value: "#d3f9d8";
|
|
13
|
+
}, {
|
|
14
|
+
readonly name: "蓝";
|
|
15
|
+
readonly value: "#d0ebff";
|
|
16
|
+
}, {
|
|
17
|
+
readonly name: "紫";
|
|
18
|
+
readonly value: "#e5dbff";
|
|
19
|
+
}, {
|
|
20
|
+
readonly name: "红";
|
|
21
|
+
readonly value: "#ffe3e3";
|
|
22
|
+
}];
|
|
23
|
+
export declare function cellBackground(value: unknown): string | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export interface ProseMirrorNode {
|
|
2
|
+
type?: string;
|
|
3
|
+
attrs?: Record<string, unknown>;
|
|
4
|
+
content?: ProseMirrorNode[];
|
|
5
|
+
marks?: Array<{
|
|
6
|
+
type: string;
|
|
7
|
+
attrs?: Record<string, unknown>;
|
|
8
|
+
}>;
|
|
9
|
+
text?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ProseMirrorDoc {
|
|
12
|
+
type: 'doc';
|
|
13
|
+
content?: ProseMirrorNode[];
|
|
14
|
+
}
|
|
15
|
+
export interface CommentAnchor {
|
|
16
|
+
quote: string;
|
|
17
|
+
prefix: string | null;
|
|
18
|
+
suffix: string | null;
|
|
19
|
+
start: number | null;
|
|
20
|
+
seq: number | null;
|
|
21
|
+
}
|
|
22
|
+
export interface CommentItem {
|
|
23
|
+
id: string;
|
|
24
|
+
pageId: string;
|
|
25
|
+
parentId: string | null;
|
|
26
|
+
body: string;
|
|
27
|
+
anchor?: CommentAnchor | null;
|
|
28
|
+
authorId: string | null;
|
|
29
|
+
authorName: string;
|
|
30
|
+
deleted: boolean;
|
|
31
|
+
canDelete: boolean;
|
|
32
|
+
canEdit?: boolean;
|
|
33
|
+
resolved: boolean;
|
|
34
|
+
resolvedByName: string | null;
|
|
35
|
+
resolvedAt: string | null;
|
|
36
|
+
canResolve: boolean;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
updatedAt: string;
|
|
39
|
+
replies: CommentItem[];
|
|
40
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface VideoEmbedData {
|
|
2
|
+
provider: 'youtube' | 'bilibili';
|
|
3
|
+
videoId: string;
|
|
4
|
+
page: number;
|
|
5
|
+
startSeconds: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function normalizeVideoEmbed(raw: unknown): VideoEmbedData | null;
|
|
8
|
+
export declare function parseVideoUrl(value: string): VideoEmbedData | null;
|
|
9
|
+
export declare function videoSourceUrl(data: VideoEmbedData): string;
|
|
10
|
+
export declare function videoPlayerUrl(data: VideoEmbedData): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface WorkbookCell {
|
|
2
|
+
v?: string | number | boolean | null;
|
|
3
|
+
f?: string;
|
|
4
|
+
t?: number;
|
|
5
|
+
s?: string | Record<string, unknown> | null;
|
|
6
|
+
p?: {
|
|
7
|
+
body?: {
|
|
8
|
+
dataStream?: string;
|
|
9
|
+
};
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
};
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export interface WorkbookSheet {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
rowCount: number;
|
|
18
|
+
columnCount: number;
|
|
19
|
+
cellData?: Record<string, Record<string, WorkbookCell | null>>;
|
|
20
|
+
mergeData?: Array<{
|
|
21
|
+
startRow: number;
|
|
22
|
+
endRow: number;
|
|
23
|
+
startColumn: number;
|
|
24
|
+
endColumn: number;
|
|
25
|
+
}>;
|
|
26
|
+
rowData?: Record<string, Record<string, unknown>>;
|
|
27
|
+
columnData?: Record<string, Record<string, unknown>>;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface WorkbookSnapshot {
|
|
31
|
+
id: string;
|
|
32
|
+
name: string;
|
|
33
|
+
sheetOrder: string[];
|
|
34
|
+
sheets: Record<string, WorkbookSheet>;
|
|
35
|
+
styles?: Record<string, Record<string, unknown>>;
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
}
|
|
38
|
+
export interface WorkbookDocument {
|
|
39
|
+
type: 'workbook';
|
|
40
|
+
formatVersion: 1;
|
|
41
|
+
workbook: WorkbookSnapshot;
|
|
42
|
+
}
|
|
43
|
+
export declare const WORKBOOK_LIMITS: {
|
|
44
|
+
readonly sheets: 20;
|
|
45
|
+
readonly rows: 10000;
|
|
46
|
+
readonly columns: 200;
|
|
47
|
+
readonly cells: 50000;
|
|
48
|
+
readonly bytes: number;
|
|
49
|
+
};
|
|
50
|
+
export declare function isWorkbookDocument(value: unknown): value is WorkbookDocument;
|
|
51
|
+
export declare function emptyWorkbook(id: string): WorkbookDocument;
|
|
52
|
+
export declare function validateWorkbook(raw: unknown): WorkbookDocument;
|
|
53
|
+
export declare function workbookCellText(cell: WorkbookCell | null | undefined): string;
|
|
54
|
+
export declare function workbookText(doc: WorkbookDocument): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './shared/workbook.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../shared/callout.js';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class ContentValidationError extends Error {
|
|
2
|
+
code: string;
|
|
3
|
+
status: number;
|
|
4
|
+
details?: Record<string, unknown> | undefined;
|
|
5
|
+
constructor(code: string, message: string, status?: number, details?: Record<string, unknown> | undefined);
|
|
6
|
+
static validation(message: string): ContentValidationError;
|
|
7
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
interface JsonNode {
|
|
2
|
+
type?: string;
|
|
3
|
+
attrs?: Record<string, unknown>;
|
|
4
|
+
text?: string;
|
|
5
|
+
content?: JsonNode[];
|
|
6
|
+
}
|
|
7
|
+
interface Topic {
|
|
8
|
+
id: string;
|
|
9
|
+
parentId: string;
|
|
10
|
+
order: number;
|
|
11
|
+
text: string;
|
|
12
|
+
description?: string;
|
|
13
|
+
note?: string;
|
|
14
|
+
attachmentId?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare function validateMindMap(node: JsonNode): void;
|
|
17
|
+
export declare function mindMapOutline(node: JsonNode): Array<Topic & {
|
|
18
|
+
depth: number;
|
|
19
|
+
}>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const CONTENT_SCHEMA_VERSION = 10;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ALLOWED_NODES } from './doc-node-whitelist.js';
|
|
2
|
+
export { ALLOWED_NODES };
|
|
3
|
+
export declare const SCHEMA_VERSION = 10;
|
|
4
|
+
export interface ValidatedDoc {
|
|
5
|
+
doc: Record<string, unknown>;
|
|
6
|
+
schemaVersion: number;
|
|
7
|
+
linkTargetIds: string[];
|
|
8
|
+
attachmentIds: string[];
|
|
9
|
+
mentionUserIds: string[];
|
|
10
|
+
}
|
|
11
|
+
export declare class ContentSchemaService {
|
|
12
|
+
validate(raw: unknown, schemaVersion: number): ValidatedDoc;
|
|
13
|
+
private isSafeHref;
|
|
14
|
+
extractPlainText(doc: unknown): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../shared/video-embed.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../shared/workbook.js';
|
package/package.json
CHANGED
|
@@ -1,14 +1,96 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wendang",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"license": "
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "文档、工作表和思维导图的内容协议与校验核心。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
7
|
+
"main": "./dist/cjs/index.js",
|
|
8
|
+
"module": "./dist/esm/index.js",
|
|
9
|
+
"types": "./dist/types/index.d.ts",
|
|
10
|
+
"typesVersions": {
|
|
11
|
+
"*": {
|
|
12
|
+
"internal/*": [
|
|
13
|
+
"dist/types/shared/*"
|
|
14
|
+
],
|
|
15
|
+
"validation/*": [
|
|
16
|
+
"dist/types/validation/*"
|
|
17
|
+
],
|
|
18
|
+
"*": [
|
|
19
|
+
"dist/types/*"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/types/index.d.ts",
|
|
26
|
+
"import": "./dist/esm/index.js",
|
|
27
|
+
"require": "./dist/cjs/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./document": {
|
|
30
|
+
"types": "./dist/types/document.d.ts",
|
|
31
|
+
"import": "./dist/esm/document.js",
|
|
32
|
+
"require": "./dist/cjs/document.js"
|
|
33
|
+
},
|
|
34
|
+
"./spreadsheet": {
|
|
35
|
+
"types": "./dist/types/spreadsheet.d.ts",
|
|
36
|
+
"import": "./dist/esm/spreadsheet.js",
|
|
37
|
+
"require": "./dist/cjs/spreadsheet.js"
|
|
38
|
+
},
|
|
39
|
+
"./mindmap": {
|
|
40
|
+
"types": "./dist/types/mindmap.d.ts",
|
|
41
|
+
"import": "./dist/esm/mindmap.js",
|
|
42
|
+
"require": "./dist/cjs/mindmap.js"
|
|
43
|
+
},
|
|
44
|
+
"./schema": {
|
|
45
|
+
"types": "./dist/types/schema.d.ts",
|
|
46
|
+
"import": "./dist/esm/schema.js",
|
|
47
|
+
"require": "./dist/cjs/schema.js"
|
|
48
|
+
},
|
|
49
|
+
"./types": {
|
|
50
|
+
"types": "./dist/types/types.d.ts",
|
|
51
|
+
"import": "./dist/esm/types.js",
|
|
52
|
+
"require": "./dist/cjs/types.js"
|
|
53
|
+
},
|
|
54
|
+
"./internal/*": {
|
|
55
|
+
"types": "./dist/types/shared/*.d.ts",
|
|
56
|
+
"import": "./dist/esm/shared/*.js",
|
|
57
|
+
"require": "./dist/cjs/shared/*.js"
|
|
58
|
+
},
|
|
59
|
+
"./validation/*": {
|
|
60
|
+
"types": "./dist/types/validation/*.d.ts",
|
|
61
|
+
"import": "./dist/esm/validation/*.js",
|
|
62
|
+
"require": "./dist/cjs/validation/*.js"
|
|
63
|
+
},
|
|
64
|
+
"./package.json": "./package.json"
|
|
65
|
+
},
|
|
66
|
+
"sideEffects": false,
|
|
7
67
|
"files": [
|
|
8
|
-
"
|
|
68
|
+
"dist",
|
|
69
|
+
"README.md",
|
|
70
|
+
"LICENSE",
|
|
71
|
+
"NOTICE.md",
|
|
72
|
+
"third-party-notices"
|
|
9
73
|
],
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=20.19"
|
|
76
|
+
},
|
|
10
77
|
"publishConfig": {
|
|
11
78
|
"access": "public",
|
|
12
79
|
"registry": "https://registry.npmjs.org/"
|
|
80
|
+
},
|
|
81
|
+
"author": "ztes",
|
|
82
|
+
"repository": {
|
|
83
|
+
"type": "git",
|
|
84
|
+
"url": "git+https://gitee.com/ztes/wendang.git",
|
|
85
|
+
"directory": "packages/core"
|
|
86
|
+
},
|
|
87
|
+
"homepage": "https://doc.yjmf.com",
|
|
88
|
+
"bugs": {
|
|
89
|
+
"url": "https://gitee.com/ztes/wendang/issues"
|
|
90
|
+
},
|
|
91
|
+
"scripts": {
|
|
92
|
+
"build": "node ../../scripts/build-core.mjs",
|
|
93
|
+
"dev": "node ../../scripts/build-core.mjs --watch",
|
|
94
|
+
"typecheck": "tsc --noEmit"
|
|
13
95
|
}
|
|
14
|
-
}
|
|
96
|
+
}
|