kindy-editor 1.0.1 → 2.0.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/CAPABILITIES.md +39 -0
- package/CHANGELOG.md +56 -0
- package/GUIDE.md +190 -0
- package/MIGRATION.md +46 -0
- package/README.md +198 -253
- package/README.zh-CN.md +41 -192
- package/dist/assets/docx.worker-9ZRUe-2j.js +243 -0
- package/dist/kindy-core.cjs +786 -0
- package/dist/kindy-core.js +738 -0
- package/dist/kindy-editor.cjs +421 -76
- package/dist/kindy-editor.css +1 -1
- package/dist/kindy-editor.d.ts +165 -169
- package/dist/kindy-editor.js +55210 -30323
- package/dist/types/core/adapters/legacy.d.ts +9 -0
- package/dist/types/core/adapters/memory.d.ts +87 -0
- package/dist/types/core/adapters/rest.d.ts +27 -0
- package/dist/types/core/client.d.ts +47 -0
- package/dist/types/core/collaboration.d.ts +30 -0
- package/dist/types/core/editor-state.d.ts +47 -0
- package/dist/types/core/emitter.d.ts +19 -0
- package/dist/types/core/errors.d.ts +13 -0
- package/dist/types/core/index.d.ts +10 -0
- package/dist/types/core/state.d.ts +9 -0
- package/dist/types/core/types.d.ts +235 -0
- package/docs/README.md +15 -0
- package/docs/api-reference.md +510 -0
- package/docs/completion-roadmap.md +62 -0
- package/docs/getting-started.md +180 -0
- package/docs/performance.md +149 -0
- package/docs/plugin-development.md +100 -0
- package/docs/ui-engine.md +242 -0
- package/openapi/document-api.yaml +267 -0
- package/package.json +59 -9
- package/dist/kindy-editor.iife.js +0 -148
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DocumentApiAdapter, KindyDocumentState } from '../types';
|
|
2
|
+
export interface LegacyCallbackOptions {
|
|
3
|
+
onSave?: (payload: {
|
|
4
|
+
json: KindyDocumentState['content'];
|
|
5
|
+
state: KindyDocumentState;
|
|
6
|
+
}, page: KindyDocumentState['page']) => Promise<unknown>;
|
|
7
|
+
onFileUpload?: (file: File | Blob) => Promise<unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare function createLegacyCallbackAdapter(options?: LegacyCallbackOptions): DocumentApiAdapter;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { CreateDocumentInput, DocumentApiAdapter, DocumentQuery, DocumentRecord, DocumentSnapshot, DocumentVersion, Folder, ImportDocumentInput, Page, SaveResult, SaveStateInput, StoreArtifactInput } from '../types';
|
|
2
|
+
export declare class MemoryDocumentAdapter implements DocumentApiAdapter {
|
|
3
|
+
private documents;
|
|
4
|
+
private states;
|
|
5
|
+
private versions;
|
|
6
|
+
private versionStates;
|
|
7
|
+
private artifacts;
|
|
8
|
+
private folders;
|
|
9
|
+
constructor(seed?: {
|
|
10
|
+
documents?: DocumentSnapshot[];
|
|
11
|
+
folders?: Folder[];
|
|
12
|
+
});
|
|
13
|
+
private seed;
|
|
14
|
+
private requireDocument;
|
|
15
|
+
listDocuments(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentRecord>>;
|
|
16
|
+
getDocument(documentId: string, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
17
|
+
createDocument(input: CreateDocumentInput, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
18
|
+
importDocument(input: ImportDocumentInput, signal?: AbortSignal): Promise<{
|
|
19
|
+
id: string;
|
|
20
|
+
updatedAt: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
metadata?: Record<string, unknown>;
|
|
23
|
+
originalSource?: import("..").OriginalDocxSource;
|
|
24
|
+
title: string;
|
|
25
|
+
fileName: string;
|
|
26
|
+
folderId?: string | null;
|
|
27
|
+
tags?: string[];
|
|
28
|
+
currentVersionId?: string;
|
|
29
|
+
currentRevisionId?: string;
|
|
30
|
+
isTemplate?: boolean;
|
|
31
|
+
createdAt?: string;
|
|
32
|
+
capabilities?: import("..").DocumentCapabilities;
|
|
33
|
+
}>;
|
|
34
|
+
updateDocument(documentId: string, patch: Partial<DocumentRecord>, signal?: AbortSignal): Promise<{
|
|
35
|
+
id: string;
|
|
36
|
+
updatedAt: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
metadata?: Record<string, unknown>;
|
|
39
|
+
originalSource?: import("..").OriginalDocxSource;
|
|
40
|
+
title: string;
|
|
41
|
+
fileName: string;
|
|
42
|
+
folderId?: string | null;
|
|
43
|
+
tags?: string[];
|
|
44
|
+
currentVersionId?: string;
|
|
45
|
+
currentRevisionId?: string;
|
|
46
|
+
isTemplate?: boolean;
|
|
47
|
+
createdAt?: string;
|
|
48
|
+
capabilities?: import("..").DocumentCapabilities;
|
|
49
|
+
}>;
|
|
50
|
+
loadState(documentId: string, versionId?: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
51
|
+
saveState(documentId: string, input: SaveStateInput, signal?: AbortSignal): Promise<SaveResult>;
|
|
52
|
+
listVersions(documentId: string, query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentVersion>>;
|
|
53
|
+
restoreVersion(documentId: string, versionId: string, signal?: AbortSignal): Promise<{
|
|
54
|
+
document: DocumentRecord;
|
|
55
|
+
state: import("..").KindyDocumentState;
|
|
56
|
+
revisionId: string;
|
|
57
|
+
version: DocumentVersion;
|
|
58
|
+
}>;
|
|
59
|
+
listFolders(_query?: DocumentQuery, signal?: AbortSignal): Promise<Folder[]>;
|
|
60
|
+
listTemplates(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentRecord>>;
|
|
61
|
+
storeArtifact(documentId: string, input: StoreArtifactInput, signal?: AbortSignal): Promise<{
|
|
62
|
+
blob: Blob | undefined;
|
|
63
|
+
id: string;
|
|
64
|
+
documentId: string;
|
|
65
|
+
versionId?: string;
|
|
66
|
+
format: import("..").ArtifactFormat;
|
|
67
|
+
fileName: string;
|
|
68
|
+
mimeType: string;
|
|
69
|
+
size?: number;
|
|
70
|
+
url?: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
}>;
|
|
73
|
+
getArtifact(documentId: string, artifactId: string, signal?: AbortSignal): Promise<{
|
|
74
|
+
blob: Blob | undefined;
|
|
75
|
+
id: string;
|
|
76
|
+
documentId: string;
|
|
77
|
+
versionId?: string;
|
|
78
|
+
format: import("..").ArtifactFormat;
|
|
79
|
+
fileName: string;
|
|
80
|
+
mimeType: string;
|
|
81
|
+
size?: number;
|
|
82
|
+
url?: string;
|
|
83
|
+
createdAt: string;
|
|
84
|
+
}>;
|
|
85
|
+
private makeVersion;
|
|
86
|
+
}
|
|
87
|
+
export declare const createMemoryDocumentAdapter: (seed?: ConstructorParameters<typeof MemoryDocumentAdapter>[0]) => MemoryDocumentAdapter;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CreateDocumentInput, DocumentApiAdapter, DocumentArtifact, DocumentQuery, DocumentRecord, DocumentSnapshot, DocumentSummary, DocumentVersion, Folder, ImportDocumentInput, Page, SaveResult, SaveStateInput, StoreArtifactInput } from '../types';
|
|
2
|
+
export type DocumentTransport = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export interface RestDocumentAdapterOptions {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
transport?: DocumentTransport;
|
|
6
|
+
}
|
|
7
|
+
export declare class RestDocumentAdapter implements DocumentApiAdapter {
|
|
8
|
+
private readonly baseUrl;
|
|
9
|
+
private readonly transport;
|
|
10
|
+
constructor(options: RestDocumentAdapterOptions);
|
|
11
|
+
private request;
|
|
12
|
+
private json;
|
|
13
|
+
listDocuments(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentSummary>>;
|
|
14
|
+
getDocument(documentId: string, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
15
|
+
createDocument(input: CreateDocumentInput, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
16
|
+
importDocument(input: ImportDocumentInput, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
17
|
+
updateDocument(documentId: string, patch: Partial<DocumentRecord>, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
18
|
+
loadState(documentId: string, versionId?: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
19
|
+
saveState(documentId: string, input: SaveStateInput, signal?: AbortSignal): Promise<SaveResult>;
|
|
20
|
+
listVersions(documentId: string, query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentVersion>>;
|
|
21
|
+
restoreVersion(documentId: string, versionId: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
22
|
+
listFolders(query?: DocumentQuery, signal?: AbortSignal): Promise<Folder[]>;
|
|
23
|
+
listTemplates(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentSummary>>;
|
|
24
|
+
storeArtifact(documentId: string, input: StoreArtifactInput, signal?: AbortSignal): Promise<DocumentArtifact>;
|
|
25
|
+
getArtifact(documentId: string, artifactId: string, signal?: AbortSignal): Promise<DocumentArtifact>;
|
|
26
|
+
}
|
|
27
|
+
export declare const createRestDocumentAdapter: (options: RestDocumentAdapterOptions) => RestDocumentAdapter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { TypedEventEmitter } from './emitter';
|
|
2
|
+
import type { CreateDocumentInput, DocumentApiAdapter, DocumentQuery, DocumentSnapshot, ImportDocumentInput, KindyDocumentState, SaveReason, StoreArtifactInput, EditorEngineAdapter } from './types';
|
|
3
|
+
export interface DocumentLibraryClientOptions {
|
|
4
|
+
adapter: DocumentApiAdapter;
|
|
5
|
+
autosave?: {
|
|
6
|
+
enabled?: boolean;
|
|
7
|
+
delay?: number;
|
|
8
|
+
};
|
|
9
|
+
codecs?: Record<string, unknown>;
|
|
10
|
+
engine?: EditorEngineAdapter;
|
|
11
|
+
locale?: string;
|
|
12
|
+
theme?: Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare class DocumentLibraryClient extends TypedEventEmitter {
|
|
15
|
+
readonly adapter: DocumentApiAdapter;
|
|
16
|
+
readonly codecs?: Record<string, unknown>;
|
|
17
|
+
readonly engine?: EditorEngineAdapter;
|
|
18
|
+
readonly locale: string;
|
|
19
|
+
readonly theme: Record<string, string>;
|
|
20
|
+
private autosaveEnabled;
|
|
21
|
+
private autosaveDelay;
|
|
22
|
+
private autosaveTimer;
|
|
23
|
+
private saveController;
|
|
24
|
+
private savePromise;
|
|
25
|
+
private snapshot;
|
|
26
|
+
private dirty;
|
|
27
|
+
private conflicted;
|
|
28
|
+
private mutation;
|
|
29
|
+
constructor(options: DocumentLibraryClientOptions);
|
|
30
|
+
get current(): DocumentSnapshot | null;
|
|
31
|
+
get hasUnsavedChanges(): boolean;
|
|
32
|
+
get hasConflict(): boolean;
|
|
33
|
+
listDocuments(query?: DocumentQuery, signal?: AbortSignal): Promise<import("./types").Page<import("./types").DocumentSummary>>;
|
|
34
|
+
open(documentId: string, versionId?: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
35
|
+
create(input: CreateDocumentInput, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
36
|
+
import(input: ImportDocumentInput, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
37
|
+
updateState(state: KindyDocumentState): DocumentSnapshot;
|
|
38
|
+
save(reason?: SaveReason): Promise<import("./types").SaveResult>;
|
|
39
|
+
private performSave;
|
|
40
|
+
restore(versionId: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
41
|
+
storeArtifact(input: StoreArtifactInput, signal?: AbortSignal): Promise<import("./types").DocumentArtifact>;
|
|
42
|
+
resolveConflict(snapshot: DocumentSnapshot): void;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
private scheduleAutosave;
|
|
45
|
+
private cancelPendingSave;
|
|
46
|
+
}
|
|
47
|
+
export declare const createDocumentLibrary: (options: DocumentLibraryClientOptions) => DocumentLibraryClient;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CollaborationAdapter, CollaborationSession } from './types';
|
|
2
|
+
export interface YjsProviderLike {
|
|
3
|
+
connect?(): void;
|
|
4
|
+
disconnect?(): void;
|
|
5
|
+
destroy?(): void;
|
|
6
|
+
awareness?: {
|
|
7
|
+
getStates?(): Map<unknown, unknown>;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface YjsCollaborationAdapterOptions {
|
|
11
|
+
providerFactory(context: {
|
|
12
|
+
documentId: string;
|
|
13
|
+
user?: {
|
|
14
|
+
id?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
color?: string;
|
|
17
|
+
};
|
|
18
|
+
editor: unknown;
|
|
19
|
+
}): YjsProviderLike | Promise<YjsProviderLike>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Host-provided Yjs provider boundary. The SDK deliberately does not create a
|
|
23
|
+
* WebSocket connection or ship a collaboration server.
|
|
24
|
+
*/
|
|
25
|
+
export declare class YjsCollaborationAdapter implements CollaborationAdapter {
|
|
26
|
+
private readonly options;
|
|
27
|
+
constructor(options: YjsCollaborationAdapterOptions);
|
|
28
|
+
connect(context: Parameters<CollaborationAdapter['connect']>[0]): Promise<CollaborationSession>;
|
|
29
|
+
}
|
|
30
|
+
export declare const createYjsCollaborationAdapter: (options: YjsCollaborationAdapterOptions) => YjsCollaborationAdapter;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import type { AssetReference, KindyDocumentState, KindyHeaderFooterState, KindyPageMargin, KindySectionState } from './types';
|
|
3
|
+
type LegacyHeaderFooter = {
|
|
4
|
+
enable?: boolean;
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
text?: string;
|
|
7
|
+
leftText?: string;
|
|
8
|
+
content?: JSONContent;
|
|
9
|
+
variants?: {
|
|
10
|
+
first?: {
|
|
11
|
+
text?: string;
|
|
12
|
+
content?: JSONContent;
|
|
13
|
+
};
|
|
14
|
+
even?: {
|
|
15
|
+
text?: string;
|
|
16
|
+
content?: JSONContent;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
differentFirstPage?: boolean;
|
|
20
|
+
differentOddEven?: boolean;
|
|
21
|
+
};
|
|
22
|
+
type LegacyPage = {
|
|
23
|
+
size?: {
|
|
24
|
+
width?: number;
|
|
25
|
+
height?: number;
|
|
26
|
+
};
|
|
27
|
+
orientation?: 'portrait' | 'landscape';
|
|
28
|
+
margin?: Partial<KindyPageMargin>;
|
|
29
|
+
background?: string;
|
|
30
|
+
watermark?: Record<string, unknown>;
|
|
31
|
+
header?: LegacyHeaderFooter;
|
|
32
|
+
footer?: LegacyHeaderFooter;
|
|
33
|
+
sections?: Array<LegacySection>;
|
|
34
|
+
};
|
|
35
|
+
type LegacySection = LegacyPage & {
|
|
36
|
+
id?: string;
|
|
37
|
+
fromBlockId?: string;
|
|
38
|
+
pageNumberStart?: number;
|
|
39
|
+
};
|
|
40
|
+
export declare function toCanonicalHeaderFooter(value?: LegacyHeaderFooter): KindyHeaderFooterState | undefined;
|
|
41
|
+
export declare function toCanonicalSection(section: LegacySection, page: LegacyPage): KindySectionState;
|
|
42
|
+
export declare function createEditorDocumentState(input: {
|
|
43
|
+
content: JSONContent;
|
|
44
|
+
page?: LegacyPage;
|
|
45
|
+
assets?: AssetReference[];
|
|
46
|
+
}): KindyDocumentState;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type DocumentLibraryEventMap = {
|
|
2
|
+
ready: unknown;
|
|
3
|
+
opened: unknown;
|
|
4
|
+
changed: unknown;
|
|
5
|
+
'save-started': unknown;
|
|
6
|
+
saved: unknown;
|
|
7
|
+
'save-failed': unknown;
|
|
8
|
+
imported: unknown;
|
|
9
|
+
'compatibility-warning': unknown;
|
|
10
|
+
'version-restored': unknown;
|
|
11
|
+
printed: unknown;
|
|
12
|
+
error: unknown;
|
|
13
|
+
};
|
|
14
|
+
export declare class TypedEventEmitter<Events extends Record<string, unknown> = DocumentLibraryEventMap> {
|
|
15
|
+
private listeners;
|
|
16
|
+
on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): () => boolean;
|
|
17
|
+
emit<K extends keyof Events>(event: K, payload: Events[K]): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const DOCUMENT_ERROR_CODES: readonly ["DOCX_INVALID", "DOCX_UNSUPPORTED", "IMPORT_FAILED", "EXPORT_FAILED", "ADAPTER_ERROR", "NETWORK_ERROR", "VERSION_CONFLICT", "DOCUMENT_NOT_FOUND", "OPERATION_CANCELLED"];
|
|
2
|
+
export type DocumentErrorCode = (typeof DOCUMENT_ERROR_CODES)[number];
|
|
3
|
+
export declare class DocumentLibraryError extends Error {
|
|
4
|
+
readonly code: DocumentErrorCode;
|
|
5
|
+
readonly status?: number;
|
|
6
|
+
readonly details?: unknown;
|
|
7
|
+
constructor(code: DocumentErrorCode, message: string, options?: {
|
|
8
|
+
status?: number;
|
|
9
|
+
details?: unknown;
|
|
10
|
+
cause?: unknown;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export declare function toDocumentLibraryError(error: unknown, fallback?: DocumentErrorCode): DocumentLibraryError;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './types';
|
|
2
|
+
export * from './errors';
|
|
3
|
+
export * from './state';
|
|
4
|
+
export * from './editor-state';
|
|
5
|
+
export * from './emitter';
|
|
6
|
+
export * from './client';
|
|
7
|
+
export * from './collaboration';
|
|
8
|
+
export * from './adapters/rest';
|
|
9
|
+
export * from './adapters/memory';
|
|
10
|
+
export * from './adapters/legacy';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
import { type KindyDocumentState, type KindyPageState } from './types';
|
|
3
|
+
export declare const DEFAULT_PAGE_STATE: KindyPageState;
|
|
4
|
+
export declare function cloneDocumentState<T>(value: T): T;
|
|
5
|
+
export declare function createEmptyDocumentState(overrides?: Partial<KindyDocumentState>): KindyDocumentState;
|
|
6
|
+
export declare function migrateDocumentState(input: unknown): KindyDocumentState;
|
|
7
|
+
export declare function stateFromEditor(editor: {
|
|
8
|
+
getJSON(): JSONContent;
|
|
9
|
+
}, page?: Partial<KindyPageState>): KindyDocumentState;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import type { JSONContent } from '@tiptap/core';
|
|
2
|
+
export declare const KINDY_DOCUMENT_SCHEMA_VERSION: "2.0";
|
|
3
|
+
export type KindyDocumentSchemaVersion = typeof KINDY_DOCUMENT_SCHEMA_VERSION;
|
|
4
|
+
export type SaveReason = 'autosave' | 'manual';
|
|
5
|
+
export type ArtifactFormat = 'docx' | 'pdf' | 'original-docx';
|
|
6
|
+
export interface KindyPageMargin {
|
|
7
|
+
top: number;
|
|
8
|
+
right: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
left: number;
|
|
11
|
+
}
|
|
12
|
+
export interface KindyHeaderFooterState {
|
|
13
|
+
enabled: boolean;
|
|
14
|
+
content?: JSONContent;
|
|
15
|
+
text?: string;
|
|
16
|
+
firstContent?: JSONContent;
|
|
17
|
+
firstText?: string;
|
|
18
|
+
evenContent?: JSONContent;
|
|
19
|
+
evenText?: string;
|
|
20
|
+
differentFirstPage?: boolean;
|
|
21
|
+
differentOddEven?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface KindySectionState {
|
|
24
|
+
id: string;
|
|
25
|
+
fromBlockId?: string;
|
|
26
|
+
pageNumberStart?: number;
|
|
27
|
+
size: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
orientation: 'portrait' | 'landscape';
|
|
32
|
+
margin: KindyPageMargin;
|
|
33
|
+
header?: KindyHeaderFooterState;
|
|
34
|
+
footer?: KindyHeaderFooterState;
|
|
35
|
+
}
|
|
36
|
+
export interface KindyPageState {
|
|
37
|
+
size: {
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
};
|
|
41
|
+
orientation: 'portrait' | 'landscape';
|
|
42
|
+
margin: KindyPageMargin;
|
|
43
|
+
background?: string;
|
|
44
|
+
watermark?: Record<string, unknown>;
|
|
45
|
+
header?: KindyHeaderFooterState;
|
|
46
|
+
footer?: KindyHeaderFooterState;
|
|
47
|
+
sections?: KindySectionState[];
|
|
48
|
+
}
|
|
49
|
+
export interface AssetReference {
|
|
50
|
+
id: string;
|
|
51
|
+
kind: 'image' | 'video' | 'audio' | 'file' | 'other';
|
|
52
|
+
url?: string;
|
|
53
|
+
mimeType?: string;
|
|
54
|
+
fileName?: string;
|
|
55
|
+
size?: number;
|
|
56
|
+
metadata?: Record<string, unknown>;
|
|
57
|
+
}
|
|
58
|
+
export interface KindyDocumentState {
|
|
59
|
+
schemaVersion: KindyDocumentSchemaVersion;
|
|
60
|
+
content: JSONContent;
|
|
61
|
+
page: KindyPageState;
|
|
62
|
+
assets: AssetReference[];
|
|
63
|
+
}
|
|
64
|
+
export interface DocumentCapabilities {
|
|
65
|
+
view?: boolean;
|
|
66
|
+
edit?: boolean;
|
|
67
|
+
comment?: boolean;
|
|
68
|
+
review?: boolean;
|
|
69
|
+
download?: boolean;
|
|
70
|
+
restore?: boolean;
|
|
71
|
+
manage?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface DocumentSummary {
|
|
74
|
+
id: string;
|
|
75
|
+
title: string;
|
|
76
|
+
fileName: string;
|
|
77
|
+
folderId?: string | null;
|
|
78
|
+
tags?: string[];
|
|
79
|
+
currentVersionId?: string;
|
|
80
|
+
currentRevisionId?: string;
|
|
81
|
+
isTemplate?: boolean;
|
|
82
|
+
updatedAt: string;
|
|
83
|
+
createdAt?: string;
|
|
84
|
+
capabilities?: DocumentCapabilities;
|
|
85
|
+
}
|
|
86
|
+
export interface OriginalDocxSource {
|
|
87
|
+
artifactId: string;
|
|
88
|
+
revisionId: string;
|
|
89
|
+
format: 'original-docx';
|
|
90
|
+
fileName: string;
|
|
91
|
+
compatibilityReport?: CompatibilityReport;
|
|
92
|
+
}
|
|
93
|
+
export interface DocumentRecord extends DocumentSummary {
|
|
94
|
+
description?: string;
|
|
95
|
+
metadata?: Record<string, unknown>;
|
|
96
|
+
originalSource?: OriginalDocxSource;
|
|
97
|
+
}
|
|
98
|
+
export interface DocumentVersion {
|
|
99
|
+
id: string;
|
|
100
|
+
documentId: string;
|
|
101
|
+
number: number;
|
|
102
|
+
revisionId: string;
|
|
103
|
+
reason: SaveReason | 'create' | 'import' | 'restore' | 'template';
|
|
104
|
+
createdAt: string;
|
|
105
|
+
createdBy?: {
|
|
106
|
+
id?: string;
|
|
107
|
+
name?: string;
|
|
108
|
+
};
|
|
109
|
+
label?: string;
|
|
110
|
+
}
|
|
111
|
+
export interface DocumentSnapshot {
|
|
112
|
+
document: DocumentRecord;
|
|
113
|
+
state: KindyDocumentState;
|
|
114
|
+
revisionId: string;
|
|
115
|
+
version?: DocumentVersion;
|
|
116
|
+
}
|
|
117
|
+
export interface DocumentArtifact {
|
|
118
|
+
id: string;
|
|
119
|
+
documentId: string;
|
|
120
|
+
versionId?: string;
|
|
121
|
+
format: ArtifactFormat;
|
|
122
|
+
fileName: string;
|
|
123
|
+
mimeType: string;
|
|
124
|
+
size?: number;
|
|
125
|
+
url?: string;
|
|
126
|
+
blob?: Blob;
|
|
127
|
+
createdAt: string;
|
|
128
|
+
}
|
|
129
|
+
export interface Folder {
|
|
130
|
+
id: string;
|
|
131
|
+
name: string;
|
|
132
|
+
parentId?: string | null;
|
|
133
|
+
}
|
|
134
|
+
export interface Page<T> {
|
|
135
|
+
items: T[];
|
|
136
|
+
total: number;
|
|
137
|
+
page: number;
|
|
138
|
+
pageSize: number;
|
|
139
|
+
}
|
|
140
|
+
export interface DocumentQuery {
|
|
141
|
+
search?: string;
|
|
142
|
+
folderId?: string | null;
|
|
143
|
+
tags?: string[];
|
|
144
|
+
page?: number;
|
|
145
|
+
pageSize?: number;
|
|
146
|
+
templatesOnly?: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface CreateDocumentInput {
|
|
149
|
+
title: string;
|
|
150
|
+
fileName?: string;
|
|
151
|
+
folderId?: string | null;
|
|
152
|
+
tags?: string[];
|
|
153
|
+
templateId?: string;
|
|
154
|
+
state?: KindyDocumentState;
|
|
155
|
+
metadata?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export interface ImportDocumentInput extends CreateDocumentInput {
|
|
158
|
+
file: File | Blob;
|
|
159
|
+
state: KindyDocumentState;
|
|
160
|
+
compatibilityReport?: CompatibilityReport;
|
|
161
|
+
}
|
|
162
|
+
export interface SaveStateInput {
|
|
163
|
+
state: KindyDocumentState;
|
|
164
|
+
baseRevisionId: string;
|
|
165
|
+
reason: SaveReason;
|
|
166
|
+
clientMutationId: string;
|
|
167
|
+
}
|
|
168
|
+
export interface SaveResult {
|
|
169
|
+
revisionId: string;
|
|
170
|
+
savedAt: string;
|
|
171
|
+
version?: DocumentVersion;
|
|
172
|
+
}
|
|
173
|
+
export interface StoreArtifactInput {
|
|
174
|
+
format: ArtifactFormat;
|
|
175
|
+
blob: Blob;
|
|
176
|
+
fileName: string;
|
|
177
|
+
versionId?: string;
|
|
178
|
+
compatibilityReport?: CompatibilityReport;
|
|
179
|
+
}
|
|
180
|
+
export type CompatibilitySeverity = 'info' | 'warning' | 'error';
|
|
181
|
+
export interface CompatibilityIssue {
|
|
182
|
+
code: string;
|
|
183
|
+
feature: string;
|
|
184
|
+
message: string;
|
|
185
|
+
severity: CompatibilitySeverity;
|
|
186
|
+
location?: string;
|
|
187
|
+
}
|
|
188
|
+
export interface CompatibilityReport {
|
|
189
|
+
profile: 'kindy-docx-v2.0' | 'kindy-docx-v2.1' | 'kindy-docx-v2.2';
|
|
190
|
+
supported: boolean;
|
|
191
|
+
issues: CompatibilityIssue[];
|
|
192
|
+
}
|
|
193
|
+
export interface DocumentApiAdapter {
|
|
194
|
+
listDocuments(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentSummary>>;
|
|
195
|
+
getDocument(documentId: string, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
196
|
+
createDocument(input: CreateDocumentInput, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
197
|
+
importDocument(input: ImportDocumentInput, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
198
|
+
updateDocument(documentId: string, patch: Partial<DocumentRecord>, signal?: AbortSignal): Promise<DocumentRecord>;
|
|
199
|
+
loadState(documentId: string, versionId?: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
200
|
+
saveState(documentId: string, input: SaveStateInput, signal?: AbortSignal): Promise<SaveResult>;
|
|
201
|
+
listVersions(documentId: string, query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentVersion>>;
|
|
202
|
+
restoreVersion(documentId: string, versionId: string, signal?: AbortSignal): Promise<DocumentSnapshot>;
|
|
203
|
+
listFolders(query?: DocumentQuery, signal?: AbortSignal): Promise<Folder[]>;
|
|
204
|
+
listTemplates(query?: DocumentQuery, signal?: AbortSignal): Promise<Page<DocumentSummary>>;
|
|
205
|
+
storeArtifact(documentId: string, input: StoreArtifactInput, signal?: AbortSignal): Promise<DocumentArtifact>;
|
|
206
|
+
getArtifact(documentId: string, artifactId: string, signal?: AbortSignal): Promise<DocumentArtifact>;
|
|
207
|
+
}
|
|
208
|
+
export interface EditorEngineHandle {
|
|
209
|
+
load(state: KindyDocumentState): Promise<void> | void;
|
|
210
|
+
getState(): KindyDocumentState;
|
|
211
|
+
setReadOnly(readOnly: boolean): void;
|
|
212
|
+
focus(): void;
|
|
213
|
+
destroy(): void;
|
|
214
|
+
onChange(listener: (state: KindyDocumentState) => void): () => void;
|
|
215
|
+
}
|
|
216
|
+
export interface EditorEngineAdapter {
|
|
217
|
+
readonly id: string;
|
|
218
|
+
mount(container: HTMLElement, options?: Record<string, unknown>): Promise<EditorEngineHandle> | EditorEngineHandle;
|
|
219
|
+
}
|
|
220
|
+
export interface CollaborationSession {
|
|
221
|
+
disconnect(): void;
|
|
222
|
+
getUsers?(): unknown[];
|
|
223
|
+
}
|
|
224
|
+
export interface CollaborationAdapter {
|
|
225
|
+
connect(context: {
|
|
226
|
+
documentId: string;
|
|
227
|
+
revisionId: string;
|
|
228
|
+
user?: {
|
|
229
|
+
id?: string;
|
|
230
|
+
name?: string;
|
|
231
|
+
color?: string;
|
|
232
|
+
};
|
|
233
|
+
editor: unknown;
|
|
234
|
+
}): Promise<CollaborationSession> | CollaborationSession;
|
|
235
|
+
}
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Kindy Editor v2 documentation
|
|
2
|
+
|
|
3
|
+
Tài liệu chính của SDK:
|
|
4
|
+
|
|
5
|
+
1. [Getting started](./getting-started.md)
|
|
6
|
+
2. [UI engine](./ui-engine.md)
|
|
7
|
+
3. [API reference](./api-reference.md)
|
|
8
|
+
4. [Backend integration, security và adapter](../GUIDE.md)
|
|
9
|
+
5. [DOCX compatibility matrix](../CAPABILITIES.md)
|
|
10
|
+
6. [Performance và tài liệu dài](./performance.md)
|
|
11
|
+
7. [Migration v1 → v2](../MIGRATION.md)
|
|
12
|
+
8. [REST OpenAPI](../openapi/document-api.yaml)
|
|
13
|
+
9. [Completion roadmap và release gates](./completion-roadmap.md)
|
|
14
|
+
|
|
15
|
+
Các thư mục `architecture/`, `adr/`, `packages/`, `research/` và `epic-story-task/` ghi lại nghiên cứu/prototype cũ của codebase. Chúng không phải public contract của `kindy-editor@2`; khi có khác biệt, tài liệu trong danh sách trên và TypeScript declarations là nguồn chính xác.
|