@azlib/editor 0.2.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/LICENSE +201 -0
- package/README.md +28 -0
- package/dist/index.cjs +1310 -0
- package/dist/index.d.cts +128 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +128 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1278 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +62 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Schema } from "prosemirror-model";
|
|
2
|
+
|
|
3
|
+
//#region src/core/types.d.ts
|
|
4
|
+
type ContentFormat = "rich" | "markdown" | "html";
|
|
5
|
+
type DiagnosticSeverity = "info" | "warning" | "error";
|
|
6
|
+
interface RepresentationDiagnostic {
|
|
7
|
+
code: string;
|
|
8
|
+
severity: DiagnosticSeverity;
|
|
9
|
+
message: string;
|
|
10
|
+
location?: {
|
|
11
|
+
start?: number;
|
|
12
|
+
end?: number;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface EditorContent {
|
|
17
|
+
richText: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
}
|
|
20
|
+
interface EditorDocument {
|
|
21
|
+
id: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
content: EditorContent;
|
|
24
|
+
metadata: Record<string, unknown>;
|
|
25
|
+
revision: number;
|
|
26
|
+
}
|
|
27
|
+
interface EditorInput {
|
|
28
|
+
format: ContentFormat;
|
|
29
|
+
payload: string;
|
|
30
|
+
}
|
|
31
|
+
interface EditorExport {
|
|
32
|
+
format: ContentFormat;
|
|
33
|
+
payload: string;
|
|
34
|
+
diagnostics: RepresentationDiagnostic[];
|
|
35
|
+
}
|
|
36
|
+
interface EditorErrorEnvelope {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
severity: "warning" | "error";
|
|
40
|
+
recoverable: boolean;
|
|
41
|
+
details?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
interface CommandResult {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
document: EditorDocument;
|
|
46
|
+
diagnostics: RepresentationDiagnostic[];
|
|
47
|
+
}
|
|
48
|
+
interface EditorConfig {
|
|
49
|
+
initialContent?: EditorInput;
|
|
50
|
+
commandCapabilities?: string[];
|
|
51
|
+
onChange?: (document: EditorDocument) => void;
|
|
52
|
+
onError?: (error: EditorErrorEnvelope) => void;
|
|
53
|
+
}
|
|
54
|
+
interface EditorInstance {
|
|
55
|
+
getDocument: () => EditorDocument;
|
|
56
|
+
execute: (commandName: string, params?: Record<string, unknown>) => CommandResult;
|
|
57
|
+
export: (format: ContentFormat) => EditorExport;
|
|
58
|
+
import: (input: EditorInput) => CommandResult;
|
|
59
|
+
mount: (target: Element) => void;
|
|
60
|
+
unmount: () => void;
|
|
61
|
+
destroy: () => void;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/core/createEditor.d.ts
|
|
65
|
+
declare const createEditor: (config?: EditorConfig) => EditorInstance;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/core/schema.d.ts
|
|
68
|
+
declare const editorNodeNames: {
|
|
69
|
+
readonly doc: "doc";
|
|
70
|
+
readonly paragraph: "paragraph";
|
|
71
|
+
readonly heading: "heading";
|
|
72
|
+
readonly text: "text";
|
|
73
|
+
readonly bulletList: "bullet_list";
|
|
74
|
+
readonly orderedList: "ordered_list";
|
|
75
|
+
readonly listItem: "list_item";
|
|
76
|
+
readonly hardBreak: "hard_break";
|
|
77
|
+
};
|
|
78
|
+
declare const editorMarkNames: {
|
|
79
|
+
readonly strong: "strong";
|
|
80
|
+
readonly em: "em";
|
|
81
|
+
readonly underline: "underline";
|
|
82
|
+
readonly link: "link";
|
|
83
|
+
};
|
|
84
|
+
declare const createEditorSchema: () => Schema<"doc" | "paragraph" | "heading" | "text" | "bullet_list" | "ordered_list" | "list_item" | "hard_break", "strong" | "em" | "underline" | "link">;
|
|
85
|
+
declare const editorSchema: Schema<"doc" | "paragraph" | "heading" | "text" | "bullet_list" | "ordered_list" | "list_item" | "hard_break", "strong" | "em" | "underline" | "link">;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/core/toolbarModel.d.ts
|
|
88
|
+
interface ToolbarAction {
|
|
89
|
+
command: string;
|
|
90
|
+
label: string;
|
|
91
|
+
group: "inline" | "block" | "history";
|
|
92
|
+
}
|
|
93
|
+
declare const defaultToolbarActions: ToolbarAction[];
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/adapters/dom/createDomAdapter.d.ts
|
|
96
|
+
interface DomEditorAdapter {
|
|
97
|
+
mount: (target: Element) => void;
|
|
98
|
+
unmount: () => void;
|
|
99
|
+
destroy: () => void;
|
|
100
|
+
}
|
|
101
|
+
declare const createDomAdapter: (editor: EditorInstance) => DomEditorAdapter;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/adapters/react/useEditorAdapter.d.ts
|
|
104
|
+
declare const useEditorAdapter: (config: EditorConfig) => EditorInstance;
|
|
105
|
+
interface RichEditorAdapterProps extends EditorConfig {
|
|
106
|
+
className?: string;
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
onRequestEmbedValue?: (type: "link" | "image" | "video" | "formula") => Promise<string | null> | string | null;
|
|
109
|
+
}
|
|
110
|
+
declare function RichEditorAdapter({
|
|
111
|
+
className,
|
|
112
|
+
disabled,
|
|
113
|
+
initialContent,
|
|
114
|
+
onChange,
|
|
115
|
+
onError,
|
|
116
|
+
onRequestEmbedValue
|
|
117
|
+
}: RichEditorAdapterProps): import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/transforms/representationSwitch.d.ts
|
|
120
|
+
interface ImportResult {
|
|
121
|
+
document: EditorDocument;
|
|
122
|
+
diagnostics: RepresentationDiagnostic[];
|
|
123
|
+
}
|
|
124
|
+
declare const importRepresentation: (input: EditorInput, base: EditorDocument) => ImportResult;
|
|
125
|
+
declare const exportRepresentation: (document: EditorDocument, format: ContentFormat) => EditorExport;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { type CommandResult, type ContentFormat, type DiagnosticSeverity, type EditorConfig, type EditorDocument, type EditorErrorEnvelope, type EditorExport, type EditorInput, type EditorInstance, type RepresentationDiagnostic, RichEditorAdapter, type RichEditorAdapterProps, type ToolbarAction, createDomAdapter, createEditor, createEditorSchema, defaultToolbarActions, editorMarkNames, editorNodeNames, editorSchema, exportRepresentation, importRepresentation, useEditorAdapter };
|
|
128
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../src/core/types.ts","../src/core/createEditor.ts","../src/core/schema.ts","../src/core/toolbarModel.ts","../src/adapters/dom/createDomAdapter.ts","../src/adapters/react/useEditorAdapter.tsx","../src/transforms/representationSwitch.ts"],"mappings":";;;KAAY,aAAA;AAAA,KAEA,kBAAA;AAAA,UAEK,wBAAA;EACf,IAAA;EACA,QAAA,EAAU,kBAAkB;EAC5B,OAAA;EACA,QAAA;IACE,KAAA;IACA,GAAA;IACA,IAAA;EAAA;AAAA;AAAA,UAIa,aAAA;EACf,QAAA;EACA,IAAI;AAAA;AAAA,UAGW,cAAA;EACf,EAAA;EACA,KAAA;EACA,OAAA,EAAS,aAAA;EACT,QAAA,EAAU,MAAM;EAChB,QAAA;AAAA;AAAA,UAGe,WAAA;EACf,MAAA,EAAQ,aAAa;EACrB,OAAA;AAAA;AAAA,UAGe,YAAA;EACf,MAAA,EAAQ,aAAA;EACR,OAAA;EACA,WAAA,EAAa,wBAAwB;AAAA;AAAA,UAGtB,mBAAA;EACf,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,GAAU,MAAM;AAAA;AAAA,UAGD,aAAA;EACf,EAAA;EACA,QAAA,EAAU,cAAA;EACV,WAAA,EAAa,wBAAwB;AAAA;AAAA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EAAQ,cAAA,KAAiB,YAAA;AAAA,cA4DnE,oBAAA,GAAoB,QAAA,EAAc,cAAA,EAAc,MAAA,EAAU,aAAA,KAAgB,YAAA"}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Schema } from "prosemirror-model";
|
|
2
|
+
|
|
3
|
+
//#region src/core/types.d.ts
|
|
4
|
+
type ContentFormat = "rich" | "markdown" | "html";
|
|
5
|
+
type DiagnosticSeverity = "info" | "warning" | "error";
|
|
6
|
+
interface RepresentationDiagnostic {
|
|
7
|
+
code: string;
|
|
8
|
+
severity: DiagnosticSeverity;
|
|
9
|
+
message: string;
|
|
10
|
+
location?: {
|
|
11
|
+
start?: number;
|
|
12
|
+
end?: number;
|
|
13
|
+
path?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
interface EditorContent {
|
|
17
|
+
richText: string;
|
|
18
|
+
html?: string;
|
|
19
|
+
}
|
|
20
|
+
interface EditorDocument {
|
|
21
|
+
id: string;
|
|
22
|
+
title?: string;
|
|
23
|
+
content: EditorContent;
|
|
24
|
+
metadata: Record<string, unknown>;
|
|
25
|
+
revision: number;
|
|
26
|
+
}
|
|
27
|
+
interface EditorInput {
|
|
28
|
+
format: ContentFormat;
|
|
29
|
+
payload: string;
|
|
30
|
+
}
|
|
31
|
+
interface EditorExport {
|
|
32
|
+
format: ContentFormat;
|
|
33
|
+
payload: string;
|
|
34
|
+
diagnostics: RepresentationDiagnostic[];
|
|
35
|
+
}
|
|
36
|
+
interface EditorErrorEnvelope {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
severity: "warning" | "error";
|
|
40
|
+
recoverable: boolean;
|
|
41
|
+
details?: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
interface CommandResult {
|
|
44
|
+
ok: boolean;
|
|
45
|
+
document: EditorDocument;
|
|
46
|
+
diagnostics: RepresentationDiagnostic[];
|
|
47
|
+
}
|
|
48
|
+
interface EditorConfig {
|
|
49
|
+
initialContent?: EditorInput;
|
|
50
|
+
commandCapabilities?: string[];
|
|
51
|
+
onChange?: (document: EditorDocument) => void;
|
|
52
|
+
onError?: (error: EditorErrorEnvelope) => void;
|
|
53
|
+
}
|
|
54
|
+
interface EditorInstance {
|
|
55
|
+
getDocument: () => EditorDocument;
|
|
56
|
+
execute: (commandName: string, params?: Record<string, unknown>) => CommandResult;
|
|
57
|
+
export: (format: ContentFormat) => EditorExport;
|
|
58
|
+
import: (input: EditorInput) => CommandResult;
|
|
59
|
+
mount: (target: Element) => void;
|
|
60
|
+
unmount: () => void;
|
|
61
|
+
destroy: () => void;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
//#region src/core/createEditor.d.ts
|
|
65
|
+
declare const createEditor: (config?: EditorConfig) => EditorInstance;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/core/schema.d.ts
|
|
68
|
+
declare const editorNodeNames: {
|
|
69
|
+
readonly doc: "doc";
|
|
70
|
+
readonly paragraph: "paragraph";
|
|
71
|
+
readonly heading: "heading";
|
|
72
|
+
readonly text: "text";
|
|
73
|
+
readonly bulletList: "bullet_list";
|
|
74
|
+
readonly orderedList: "ordered_list";
|
|
75
|
+
readonly listItem: "list_item";
|
|
76
|
+
readonly hardBreak: "hard_break";
|
|
77
|
+
};
|
|
78
|
+
declare const editorMarkNames: {
|
|
79
|
+
readonly strong: "strong";
|
|
80
|
+
readonly em: "em";
|
|
81
|
+
readonly underline: "underline";
|
|
82
|
+
readonly link: "link";
|
|
83
|
+
};
|
|
84
|
+
declare const createEditorSchema: () => Schema<"doc" | "paragraph" | "heading" | "text" | "bullet_list" | "ordered_list" | "list_item" | "hard_break", "strong" | "em" | "underline" | "link">;
|
|
85
|
+
declare const editorSchema: Schema<"doc" | "paragraph" | "heading" | "text" | "bullet_list" | "ordered_list" | "list_item" | "hard_break", "strong" | "em" | "underline" | "link">;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/core/toolbarModel.d.ts
|
|
88
|
+
interface ToolbarAction {
|
|
89
|
+
command: string;
|
|
90
|
+
label: string;
|
|
91
|
+
group: "inline" | "block" | "history";
|
|
92
|
+
}
|
|
93
|
+
declare const defaultToolbarActions: ToolbarAction[];
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/adapters/dom/createDomAdapter.d.ts
|
|
96
|
+
interface DomEditorAdapter {
|
|
97
|
+
mount: (target: Element) => void;
|
|
98
|
+
unmount: () => void;
|
|
99
|
+
destroy: () => void;
|
|
100
|
+
}
|
|
101
|
+
declare const createDomAdapter: (editor: EditorInstance) => DomEditorAdapter;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/adapters/react/useEditorAdapter.d.ts
|
|
104
|
+
declare const useEditorAdapter: (config: EditorConfig) => EditorInstance;
|
|
105
|
+
interface RichEditorAdapterProps extends EditorConfig {
|
|
106
|
+
className?: string;
|
|
107
|
+
disabled?: boolean;
|
|
108
|
+
onRequestEmbedValue?: (type: "link" | "image" | "video" | "formula") => Promise<string | null> | string | null;
|
|
109
|
+
}
|
|
110
|
+
declare function RichEditorAdapter({
|
|
111
|
+
className,
|
|
112
|
+
disabled,
|
|
113
|
+
initialContent,
|
|
114
|
+
onChange,
|
|
115
|
+
onError,
|
|
116
|
+
onRequestEmbedValue
|
|
117
|
+
}: RichEditorAdapterProps): import("react/jsx-runtime").JSX.Element;
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/transforms/representationSwitch.d.ts
|
|
120
|
+
interface ImportResult {
|
|
121
|
+
document: EditorDocument;
|
|
122
|
+
diagnostics: RepresentationDiagnostic[];
|
|
123
|
+
}
|
|
124
|
+
declare const importRepresentation: (input: EditorInput, base: EditorDocument) => ImportResult;
|
|
125
|
+
declare const exportRepresentation: (document: EditorDocument, format: ContentFormat) => EditorExport;
|
|
126
|
+
//#endregion
|
|
127
|
+
export { type CommandResult, type ContentFormat, type DiagnosticSeverity, type EditorConfig, type EditorDocument, type EditorErrorEnvelope, type EditorExport, type EditorInput, type EditorInstance, type RepresentationDiagnostic, RichEditorAdapter, type RichEditorAdapterProps, type ToolbarAction, createDomAdapter, createEditor, createEditorSchema, defaultToolbarActions, editorMarkNames, editorNodeNames, editorSchema, exportRepresentation, importRepresentation, useEditorAdapter };
|
|
128
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/types.ts","../src/core/createEditor.ts","../src/core/schema.ts","../src/core/toolbarModel.ts","../src/adapters/dom/createDomAdapter.ts","../src/adapters/react/useEditorAdapter.tsx","../src/transforms/representationSwitch.ts"],"mappings":";;;KAAY,aAAA;AAAA,KAEA,kBAAA;AAAA,UAEK,wBAAA;EACf,IAAA;EACA,QAAA,EAAU,kBAAkB;EAC5B,OAAA;EACA,QAAA;IACE,KAAA;IACA,GAAA;IACA,IAAA;EAAA;AAAA;AAAA,UAIa,aAAA;EACf,QAAA;EACA,IAAI;AAAA;AAAA,UAGW,cAAA;EACf,EAAA;EACA,KAAA;EACA,OAAA,EAAS,aAAA;EACT,QAAA,EAAU,MAAM;EAChB,QAAA;AAAA;AAAA,UAGe,WAAA;EACf,MAAA,EAAQ,aAAa;EACrB,OAAA;AAAA;AAAA,UAGe,YAAA;EACf,MAAA,EAAQ,aAAA;EACR,OAAA;EACA,WAAA,EAAa,wBAAwB;AAAA;AAAA,UAGtB,mBAAA;EACf,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,GAAU,MAAM;AAAA;AAAA,UAGD,aAAA;EACf,EAAA;EACA,QAAA,EAAU,cAAA;EACV,WAAA,EAAa,wBAAwB;AAAA;AAAA,UAGtB,YAAA;EACf,cAAA,GAAiB,WAAA;EACjB,mBAAA;EACA,QAAA,IAAY,QAAA,EAAU,cAAA;EACtB,OAAA,IAAW,KAAA,EAAO,mBAAA;AAAA;AAAA,UAGH,cAAA;EACf,WAAA,QAAmB,cAAA;EACnB,OAAA,GAA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