oasis-editor 0.0.137 → 0.0.139
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/{OasisEditorApp-32ewgFUr.js → OasisEditorApp-B1x9P0Ua.js} +610 -122
- package/dist/adapters/mountController.d.ts +11 -0
- package/dist/adapters/react.d.ts +8 -0
- package/dist/adapters/ui.d.ts +1 -1
- package/dist/adapters/vue.d.ts +10 -0
- package/dist/app/bootstrap/createOasisEditorApp.d.ts +9 -0
- package/dist/app/bootstrap/createOasisEditorContainer.d.ts +9 -0
- package/dist/app/client/OasisEditorClient.d.ts +254 -1
- package/dist/app/client/publicDocumentApi.d.ts +223 -0
- package/dist/app/controllers/animationFrame.d.ts +2 -0
- package/dist/app/controllers/documentIO/DocumentExporter.d.ts +10 -2
- package/dist/app/controllers/documentIO/DocumentImporter.d.ts +6 -0
- package/dist/app/controllers/tableResize/tableResizeDom.d.ts +3 -3
- package/dist/app/controllers/tableResize/tableResizeHitTest.d.ts +1 -1
- package/dist/app/controllers/tableResize/tableResizeTypes.d.ts +1 -0
- package/dist/app/controllers/useEditorDocumentIO.d.ts +4 -2
- package/dist/app/controllers/useEditorFindReplace.d.ts +7 -0
- package/dist/app/controllers/useEditorPersistence.d.ts +10 -0
- package/dist/app/controllers/useEditorTableCornerResize.d.ts +1 -0
- package/dist/app/controllers/useEditorTableDrag.d.ts +2 -0
- package/dist/app/services/FindReplaceService.d.ts +9 -0
- package/dist/app/services/indexedDbPersistence.d.ts +10 -1
- package/dist/app/services/tablePropertiesService.d.ts +12 -3
- package/dist/app/services/userPreferences.d.ts +4 -0
- package/dist/assets/{importDocxWorker-B0cSSI12.js → importDocxWorker-B1vHeo5L.js} +1 -1
- package/dist/core/Editor.d.ts +33 -1
- package/dist/core/commands/CommandBus.d.ts +26 -0
- package/dist/core/commands/publicCommandTypes.d.ts +53 -0
- package/dist/core/commands/table/tableCellStyleCommands.d.ts +3 -0
- package/dist/core/commands/table/tableRowCommands.d.ts +1 -0
- package/dist/core/editorState/defaultStyles.d.ts +1 -0
- package/dist/core/model/index.d.ts +1 -1
- package/dist/core/model/types/document.d.ts +2 -0
- package/dist/core/model/types/nodes.d.ts +123 -5
- package/dist/core/plugin.d.ts +60 -0
- package/dist/export/docx/text/sdtXml.d.ts +10 -0
- package/dist/i18n/locales/en.d.ts +4 -0
- package/dist/i18n/locales/pt-BR.d.ts +4 -0
- package/dist/import/DocumentFormatImporter.d.ts +20 -4
- package/dist/import/documentImporterRegistry.d.ts +6 -2
- package/dist/import/docx/contentControls.d.ts +9 -0
- package/dist/import/docx/tableProperties.d.ts +1 -14
- package/dist/{index-Djyuogou.js → index-BVWzLonI.js} +2005 -1367
- package/dist/index.d.ts +3 -1
- package/dist/mountController.d.ts +11 -0
- package/dist/oasis-editor.css +1 -1
- package/dist/oasis-editor.js +57 -49
- package/dist/oasis-editor.umd.cjs +4 -4
- package/dist/react.d.ts +8 -0
- package/dist/ui/OasisEditorAppProps.d.ts +8 -4
- package/dist/ui/OasisEditorEditorProps.d.ts +0 -1
- package/dist/ui/app/EditorWorkspace.d.ts +0 -1
- package/dist/ui/app/connectEditorClientHost.d.ts +12 -2
- package/dist/ui/app/createEditorCommandRuntime.d.ts +8 -1
- package/dist/ui/app/createEditorDocumentRuntime.d.ts +4 -2
- package/dist/ui/app/createEditorInteractionRuntime.d.ts +1 -0
- package/dist/ui/canvas/CanvasDebug.d.ts +15 -1
- package/dist/ui/components/Menubar/menuRegistry.d.ts +11 -0
- package/dist/ui/components/Toolbar/presets/defaultToolbar/buttonSpecs.d.ts +1 -0
- package/dist/ui/components/Toolbar/primitives/useSurfaceRect.d.ts +2 -2
- package/dist/ui/components/Toolbar/registry/ToolbarRegistry.d.ts +43 -7
- package/dist/ui/components/Toolbar/schema/items.d.ts +39 -7
- package/dist/ui/components/Toolbar/state/createToolbarApi.d.ts +8 -4
- package/dist/ui/editorHistory.d.ts +2 -0
- package/dist/ui/shells/DocumentShell.d.ts +1 -2
- package/dist/ui.d.ts +1 -1
- package/dist/ui.js +29 -30
- package/dist/vue.d.ts +10 -0
- package/package.json +1 -1
- package/dist/ui/components/FloatingToolbar/FloatingTableToolbar.d.ts +0 -11
|
@@ -6,7 +6,18 @@ import { OasisEditorAppProps, OasisEditorClient } from '../index.ts';
|
|
|
6
6
|
* around their own reactivity hooks.
|
|
7
7
|
*/
|
|
8
8
|
export interface OasisMountController {
|
|
9
|
+
/**
|
|
10
|
+
* Mounts the editor into the given container.
|
|
11
|
+
* @param container - The DOM element to mount into.
|
|
12
|
+
* @param props - Editor configuration props.
|
|
13
|
+
* @param onClient - Optional callback receiving the mounted client.
|
|
14
|
+
*/
|
|
9
15
|
mount(container: HTMLElement, props: OasisEditorAppProps, onClient?: (client: OasisEditorClient) => void): void;
|
|
16
|
+
/** Unmounts the editor and releases resources. */
|
|
10
17
|
unmount(): void;
|
|
11
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a framework-agnostic mount controller.
|
|
21
|
+
* @returns A new OasisMountController.
|
|
22
|
+
*/
|
|
12
23
|
export declare function createOasisMountController(): OasisMountController;
|
package/dist/adapters/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { OasisEditorAppProps, OasisEditorClient } from '../index.ts';
|
|
3
3
|
|
|
4
|
+
/** Props for the React adapter component, extending the standard editor app props. */
|
|
4
5
|
export type ReactOasisEditorProps = OasisEditorAppProps & {
|
|
5
6
|
/**
|
|
6
7
|
* Receives the mounted Oasis client. Props are mount-only for this adapter;
|
|
@@ -8,4 +9,11 @@ export type ReactOasisEditorProps = OasisEditorAppProps & {
|
|
|
8
9
|
*/
|
|
9
10
|
onClient?: (client: OasisEditorClient) => void;
|
|
10
11
|
};
|
|
12
|
+
/**
|
|
13
|
+
* React component that mounts the Oasis editor. Mount-only — remount to
|
|
14
|
+
* apply a new configuration.
|
|
15
|
+
*
|
|
16
|
+
* @param props - The editor configuration props.
|
|
17
|
+
* @returns A React element wrapping the editor.
|
|
18
|
+
*/
|
|
11
19
|
export declare const OasisEditor: React.FC<ReactOasisEditorProps>;
|
package/dist/adapters/ui.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { Button, Checkbox, ColorField, ColorPicker, ColorPicker as ToolbarColorPicker, Dialog, DialogFooter, FieldGroup, FieldRow, FloatingActionButton, FormField, Grid, GridPicker, Heading, IconButton, Menu, NumberField, Popover, Radio, RadioGroup, Select, SelectField, Separator, SidePanel, SidePanelBody, SidePanelFooter, SidePanelHeader, SplitButton, Stack, StatusText, SurfaceButton, Tabs, Text, TextAreaField, TextField, ToolbarButton, ToggleChip, } from '../index.ts';
|
|
2
2
|
export type { ActionRowProps, ButtonProps, CheckboxProps, ColorFieldProps, ColorPickerKind, ColorPickerProps, DialogFooterProps, DialogProps, FieldGroupProps, FieldRowProps, FloatingActionButtonProps, FormFieldProps, GridOffset, GridPickerProps, GridProps, GridSize, HeadingProps, IconButtonProps, MenuProps, NumberFieldProps, PopoverProps, PopoverTriggerApi, RadioGroupOption, RadioGroupProps, RadioProps, ResponsiveValue, SelectFieldOption, SelectFieldProps, SeparatorProps, SidePanelProps, SidePanelSectionProps, SplitButtonProps, StackProps, StatusTextProps, SurfaceButtonProps, TabsItem, TabsProps, TextAreaFieldProps, TextProps, TextFieldProps, ToolbarButtonProps, ToolbarSelectProps, ToggleChipProps, } from '../index.ts';
|
package/dist/adapters/vue.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { VNode, RendererNode, RendererElement, PropType } from 'vue';
|
|
2
2
|
import { OasisEditorAppProps, OasisEditorClient } from '../index.ts';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Vue 3 component that mounts the Oasis editor. Mount-only — remount to
|
|
6
|
+
* apply a new configuration.
|
|
7
|
+
*
|
|
8
|
+
* @component
|
|
9
|
+
* @param props.config - Editor configuration props.
|
|
10
|
+
* @param props.class - CSS class for the container.
|
|
11
|
+
* @param props.style - CSS style for the container.
|
|
12
|
+
* @param props.onClient - Callback receiving the mounted client.
|
|
13
|
+
*/
|
|
4
14
|
export declare const OasisEditor: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
5
15
|
config: {
|
|
6
16
|
type: () => OasisEditorAppProps;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { OasisEditorAppProps } from '../../ui/OasisEditorApp.js';
|
|
2
2
|
import { OasisEditorClient } from '../client/OasisEditorClient.js';
|
|
3
3
|
|
|
4
|
+
/** An Oasis editor instance created via {@link createOasisEditor}. */
|
|
4
5
|
export type OasisEditorInstance = OasisEditorClient;
|
|
6
|
+
/**
|
|
7
|
+
* Mounts the full Oasis editor application (document shell) into a container
|
|
8
|
+
* element and returns the public editor client API.
|
|
9
|
+
*
|
|
10
|
+
* @param container - The DOM element to mount the editor into.
|
|
11
|
+
* @param props - Optional editor configuration props.
|
|
12
|
+
* @returns The editor client API.
|
|
13
|
+
*/
|
|
5
14
|
export declare function createOasisEditor(container: HTMLElement, props?: OasisEditorAppProps): OasisEditorInstance;
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { OasisEditorContainerProps } from '../../ui/OasisEditorContainer.js';
|
|
2
2
|
import { OasisEditorClient } from '../client/OasisEditorClient.js';
|
|
3
3
|
|
|
4
|
+
/** An Oasis editor container instance created via {@link createOasisEditorContainer}. */
|
|
4
5
|
export type OasisEditorContainerInstance = OasisEditorClient;
|
|
6
|
+
/**
|
|
7
|
+
* Mounts the Oasis editor container component into a container element and
|
|
8
|
+
* returns the public editor client API.
|
|
9
|
+
*
|
|
10
|
+
* @param container - The DOM element to mount into.
|
|
11
|
+
* @param props - Optional container props.
|
|
12
|
+
* @returns The editor client API.
|
|
13
|
+
*/
|
|
5
14
|
export declare function createOasisEditorContainer(container: HTMLElement, props?: OasisEditorContainerProps): OasisEditorContainerInstance;
|
|
@@ -2,80 +2,305 @@ import { EditorDocument, EditorSelection, EditorState } from '../../core/model.j
|
|
|
2
2
|
import { Editor } from '../../core/Editor.js';
|
|
3
3
|
import { ToolbarCommandState } from '../../ui/components/Toolbar/schema/items.js';
|
|
4
4
|
import { TypedCommandBus } from '../../core/commands/publicCommandTypes.js';
|
|
5
|
+
import { queryDocument, ApplyEditRequest, ApplyEditValue, DocumentRange, DocumentSelector, OasisResult, SemanticDocumentSnapshot } from './publicDocumentApi.js';
|
|
6
|
+
import { ToolbarRegistry } from '../../ui/components/Toolbar/registry/ToolbarRegistry.js';
|
|
7
|
+
import { MenuRegistry } from '../../ui/components/Menubar/menuRegistry.js';
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
/** UI-related editor state that can be toggled or configured at runtime. */
|
|
10
|
+
export interface OasisEditorUiState {
|
|
11
|
+
showChrome?: boolean;
|
|
12
|
+
showTitleBar?: boolean;
|
|
13
|
+
showMenubar?: boolean;
|
|
14
|
+
showToolbar?: boolean;
|
|
15
|
+
showOutline?: boolean;
|
|
16
|
+
shell?: "document" | "inline" | "balloon";
|
|
17
|
+
locale?: "pt-BR" | "en";
|
|
18
|
+
toolbar?: {
|
|
19
|
+
view?: "ribbon" | "compact";
|
|
20
|
+
layout?: "overflow" | "wrap";
|
|
21
|
+
};
|
|
22
|
+
viewportHeight?: number | string;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/** Events emitted by the editor client lifecycle. */
|
|
26
|
+
export type OasisEditorClientEvent = "ready" | "change" | "documentChange" | "selectionChange" | "uiChange" | "error";
|
|
27
|
+
/** Payload types associated with each client event. */
|
|
7
28
|
export interface OasisEditorClientEvents {
|
|
8
29
|
ready: Editor;
|
|
9
30
|
change: EditorState;
|
|
10
31
|
documentChange: EditorDocument;
|
|
11
32
|
selectionChange: EditorSelection;
|
|
33
|
+
uiChange: OasisEditorUiState;
|
|
12
34
|
error: unknown;
|
|
13
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Handler signature for subscribing to client events.
|
|
38
|
+
* @typeParam TEvent - The specific event type being handled.
|
|
39
|
+
*/
|
|
14
40
|
export type OasisEditorClientEventHandler<TEvent extends OasisEditorClientEvent = OasisEditorClientEvent> = (payload: OasisEditorClientEvents[TEvent]) => void;
|
|
41
|
+
/** Low-level document CRUD API exposed through the editor client. */
|
|
15
42
|
export interface OasisEditorDocumentApi {
|
|
43
|
+
/** Returns the current document. */
|
|
16
44
|
get(): EditorDocument;
|
|
45
|
+
/** @param document - The new document to set. Marks the editor dirty. */
|
|
17
46
|
set(document: EditorDocument): void;
|
|
47
|
+
/** @param document - The document to load. Does NOT mark the editor dirty. */
|
|
18
48
|
load(document: EditorDocument): void;
|
|
49
|
+
/** @param updater - Function that receives the current document and returns the new one. */
|
|
19
50
|
update(updater: (document: EditorDocument) => EditorDocument): void;
|
|
51
|
+
/** Resets the document to its initial empty state. */
|
|
20
52
|
reset(): void;
|
|
53
|
+
/** @returns A promise that resolves once the document is persisted. */
|
|
21
54
|
save(): Promise<void>;
|
|
55
|
+
/** @returns `true` if the document has unsaved changes. */
|
|
22
56
|
isDirty(): boolean;
|
|
57
|
+
/** Marks the document as clean (no unsaved changes). */
|
|
23
58
|
markClean(): void;
|
|
59
|
+
/** @returns A monotonically increasing version counter, incremented on every mutation. */
|
|
60
|
+
version(): number;
|
|
61
|
+
}
|
|
62
|
+
/** Query API for reading the document without mutation. */
|
|
63
|
+
export interface OasisEditorQueryApi {
|
|
64
|
+
/** @returns A snapshot of the entire document (text, outline, nodes). */
|
|
65
|
+
snapshot(): SemanticDocumentSnapshot;
|
|
66
|
+
/**
|
|
67
|
+
* @param target - Optional selector or range to scope the text to.
|
|
68
|
+
* @returns Plain text for the whole document or a specific target/range.
|
|
69
|
+
*/
|
|
70
|
+
getText(target?: DocumentSelector | DocumentRange): string;
|
|
71
|
+
/**
|
|
72
|
+
* @param selector - The selector identifying the node.
|
|
73
|
+
* @returns A semantic node descriptor, or `null` if not found.
|
|
74
|
+
*/
|
|
75
|
+
getNode(selector: DocumentSelector): ReturnType<ReturnType<typeof queryDocument>["getNode"]>;
|
|
76
|
+
/**
|
|
77
|
+
* @param text - The text to search for.
|
|
78
|
+
* @returns An array of match descriptors.
|
|
79
|
+
*/
|
|
80
|
+
find(text: string): ReturnType<ReturnType<typeof queryDocument>["find"]>;
|
|
81
|
+
/** @returns The document outline (heading-based hierarchy). */
|
|
82
|
+
outline(): ReturnType<ReturnType<typeof queryDocument>["outline"]>;
|
|
83
|
+
}
|
|
84
|
+
/** Edit API for applying structured operations to the document. */
|
|
85
|
+
export interface OasisEditorEditApi {
|
|
86
|
+
/**
|
|
87
|
+
* Applies one or more edit operations.
|
|
88
|
+
* @param request - The edit request containing operations and optional version checks.
|
|
89
|
+
* @returns A result indicating success or failure with error details.
|
|
90
|
+
*/
|
|
91
|
+
apply(request: ApplyEditRequest): Promise<OasisResult<ApplyEditValue>>;
|
|
24
92
|
}
|
|
93
|
+
/** Selection read/write API. */
|
|
25
94
|
export interface OasisEditorSelectionApi {
|
|
95
|
+
/** @returns The current selection. */
|
|
26
96
|
get(): EditorSelection;
|
|
97
|
+
/** @param selection - The new selection to set. */
|
|
27
98
|
set(selection: EditorSelection): void;
|
|
28
99
|
}
|
|
100
|
+
/** Focus management API. */
|
|
29
101
|
export interface OasisEditorFocusApi {
|
|
102
|
+
/** Focuses the editor input area. */
|
|
30
103
|
focus(): void;
|
|
104
|
+
/** Blurs the editor input area. */
|
|
31
105
|
blur(): void;
|
|
32
106
|
}
|
|
107
|
+
/** History (undo/redo) API. */
|
|
33
108
|
export interface OasisEditorHistoryApi {
|
|
109
|
+
/** @returns The result of undoing the last operation. */
|
|
34
110
|
undo(): unknown;
|
|
111
|
+
/** @returns The result of reapplying the last undone operation. */
|
|
35
112
|
redo(): unknown;
|
|
113
|
+
/** @returns `true` if undo is available. */
|
|
36
114
|
canUndo(): boolean;
|
|
115
|
+
/** @returns `true` if redo is available. */
|
|
37
116
|
canRedo(): boolean;
|
|
117
|
+
/** Clears the entire undo/redo history. */
|
|
38
118
|
clear(): void;
|
|
39
119
|
}
|
|
120
|
+
/** File import API. */
|
|
40
121
|
export interface OasisEditorImportApi {
|
|
122
|
+
/**
|
|
123
|
+
* Imports a .docx file from a browser File object.
|
|
124
|
+
* @param file - The .docx file to import.
|
|
125
|
+
*/
|
|
41
126
|
docx(file: File): Promise<void>;
|
|
42
127
|
}
|
|
128
|
+
/** File export API. */
|
|
43
129
|
export interface OasisEditorExportApi {
|
|
130
|
+
/** @returns A promise resolving to the exported .docx data. */
|
|
44
131
|
docx(): Promise<unknown>;
|
|
132
|
+
/** @returns A promise resolving to the exported .pdf data. */
|
|
45
133
|
pdf(): Promise<unknown>;
|
|
46
134
|
}
|
|
135
|
+
/** Data input/output API with progress reporting and result wrapping. */
|
|
136
|
+
export interface OasisEditorDataIoApi {
|
|
137
|
+
/**
|
|
138
|
+
* Imports a document from raw data.
|
|
139
|
+
* @param request - Import configuration including format, data, and optional progress callback.
|
|
140
|
+
* @returns A wrapped result indicating success or failure.
|
|
141
|
+
*/
|
|
142
|
+
import(request: {
|
|
143
|
+
format: "docx";
|
|
144
|
+
data: Blob | ArrayBuffer | Uint8Array;
|
|
145
|
+
filename?: string;
|
|
146
|
+
signal?: AbortSignal;
|
|
147
|
+
onProgress?: (progress: unknown) => void;
|
|
148
|
+
}): Promise<OasisResult<{
|
|
149
|
+
format: "docx";
|
|
150
|
+
}>>;
|
|
151
|
+
/**
|
|
152
|
+
* Exports the document as a Blob in the requested format.
|
|
153
|
+
* @param request - Export configuration including format and optional filename.
|
|
154
|
+
* @returns A wrapped result containing the blob.
|
|
155
|
+
*/
|
|
156
|
+
export(request: {
|
|
157
|
+
format: "docx" | "pdf";
|
|
158
|
+
filename?: string;
|
|
159
|
+
}): Promise<OasisResult<{
|
|
160
|
+
format: "docx" | "pdf";
|
|
161
|
+
blob: Blob;
|
|
162
|
+
arrayBuffer: () => Promise<ArrayBuffer>;
|
|
163
|
+
}>>;
|
|
164
|
+
}
|
|
165
|
+
/** UI configuration and chrome API. */
|
|
166
|
+
export interface OasisEditorUiApi {
|
|
167
|
+
/** @returns The current UI state. */
|
|
168
|
+
state(): OasisEditorUiState;
|
|
169
|
+
/**
|
|
170
|
+
* Applies a partial UI state patch.
|
|
171
|
+
* @param patch - The partial state to apply.
|
|
172
|
+
* @returns The new UI state after applying the patch.
|
|
173
|
+
*/
|
|
174
|
+
update(patch: OasisEditorUiState): OasisEditorUiState;
|
|
175
|
+
/** @param value - Whether the editor should be read-only. */
|
|
176
|
+
setReadOnly(value: boolean): void;
|
|
177
|
+
/** Zoom controls. */
|
|
178
|
+
zoom: {
|
|
179
|
+
get(): number;
|
|
180
|
+
set(value: number): void;
|
|
181
|
+
adjust(delta: number): void;
|
|
182
|
+
};
|
|
183
|
+
/** Chrome visibility controls. */
|
|
184
|
+
chrome: {
|
|
185
|
+
setVisible(value: boolean): void;
|
|
186
|
+
};
|
|
187
|
+
/** Title bar visibility control. */
|
|
188
|
+
titleBar: {
|
|
189
|
+
setVisible(value: boolean): void;
|
|
190
|
+
};
|
|
191
|
+
/** Menubar visibility and item registry. */
|
|
192
|
+
menubar: {
|
|
193
|
+
setVisible(value: boolean): void;
|
|
194
|
+
items: MenuRegistry;
|
|
195
|
+
};
|
|
196
|
+
/** Toolbar visibility and item registry. */
|
|
197
|
+
toolbar: {
|
|
198
|
+
setVisible(value: boolean): void;
|
|
199
|
+
items: ToolbarRegistry;
|
|
200
|
+
};
|
|
201
|
+
/** Outline panel visibility control. */
|
|
202
|
+
outline: {
|
|
203
|
+
setVisible(value: boolean): void;
|
|
204
|
+
};
|
|
205
|
+
/** @param value - The shell mode to set. */
|
|
206
|
+
shell: {
|
|
207
|
+
set(value: "document" | "inline" | "balloon"): void;
|
|
208
|
+
};
|
|
209
|
+
/** @param value - The locale to set. */
|
|
210
|
+
locale: {
|
|
211
|
+
set(value: "pt-BR" | "en"): void;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* The main public API surface of an Oasis Editor instance. Returned by
|
|
216
|
+
* {@link createOasisEditor} and {@link createOasisEditorContainer}.
|
|
217
|
+
*/
|
|
47
218
|
export interface OasisEditorClient {
|
|
219
|
+
/** Resolves once the editor runtime is fully initialized. */
|
|
48
220
|
readonly ready: Promise<Editor>;
|
|
221
|
+
/** Typed command bus for dispatching editor commands. */
|
|
49
222
|
readonly commands: TypedCommandBus<ToolbarCommandState>;
|
|
223
|
+
/** Document CRUD API. */
|
|
50
224
|
readonly document: OasisEditorDocumentApi;
|
|
225
|
+
/** Selection API. */
|
|
51
226
|
readonly selection: OasisEditorSelectionApi;
|
|
227
|
+
/** Focus API. */
|
|
52
228
|
readonly focus: OasisEditorFocusApi;
|
|
229
|
+
/** History (undo/redo) API. */
|
|
53
230
|
readonly history: OasisEditorHistoryApi;
|
|
231
|
+
/** File import API. */
|
|
54
232
|
readonly import: OasisEditorImportApi;
|
|
233
|
+
/** File export API. */
|
|
55
234
|
readonly export: OasisEditorExportApi;
|
|
235
|
+
/** Document query API. */
|
|
236
|
+
readonly query: OasisEditorQueryApi;
|
|
237
|
+
/** Document edit API. */
|
|
238
|
+
readonly edit: OasisEditorEditApi;
|
|
239
|
+
/** Data import/export API with result wrapping. */
|
|
240
|
+
readonly io: OasisEditorDataIoApi;
|
|
241
|
+
/** UI configuration API. */
|
|
242
|
+
readonly ui: OasisEditorUiApi;
|
|
243
|
+
/** Disposes the editor, releasing resources. */
|
|
56
244
|
dispose(): void | Promise<void>;
|
|
245
|
+
/** @returns The current editor state. */
|
|
57
246
|
getState(): EditorState;
|
|
247
|
+
/** @returns The current document. */
|
|
58
248
|
getDocument(): EditorDocument;
|
|
249
|
+
/** @param document - The new document to set. Marks the editor dirty. */
|
|
59
250
|
setDocument(document: EditorDocument): void;
|
|
251
|
+
/** @param document - The document to load. Does NOT mark the editor dirty. */
|
|
60
252
|
loadDocument(document: EditorDocument): void;
|
|
253
|
+
/**
|
|
254
|
+
* @param updater - Function that receives the current document and returns the new one.
|
|
255
|
+
*/
|
|
61
256
|
updateDocument(updater: (document: EditorDocument) => EditorDocument): void;
|
|
257
|
+
/** Resets the document to its initial state. */
|
|
62
258
|
resetDocument(): void;
|
|
259
|
+
/** @returns A promise that resolves once the document is persisted. */
|
|
63
260
|
save(): Promise<void>;
|
|
261
|
+
/** @returns `true` if the document has unsaved changes. */
|
|
64
262
|
isDirty(): boolean;
|
|
263
|
+
/** Marks the document as clean. */
|
|
65
264
|
markClean(): void;
|
|
265
|
+
/** @returns The current selection. */
|
|
66
266
|
getSelection(): EditorSelection;
|
|
267
|
+
/** @param selection - The new selection to set. */
|
|
67
268
|
setSelection(selection: EditorSelection): void;
|
|
269
|
+
/** Focuses the editor. */
|
|
68
270
|
focusEditor(): void;
|
|
271
|
+
/** Blurs the editor. */
|
|
69
272
|
blurEditor(): void;
|
|
273
|
+
/**
|
|
274
|
+
* Subscribes to a client event.
|
|
275
|
+
* @param event - The event name.
|
|
276
|
+
* @param callback - The handler to invoke when the event fires.
|
|
277
|
+
* @returns An unsubscribe function.
|
|
278
|
+
*/
|
|
70
279
|
on<TEvent extends OasisEditorClientEvent>(event: TEvent, callback: OasisEditorClientEventHandler<TEvent>): () => void;
|
|
280
|
+
/**
|
|
281
|
+
* Subscribes to a single emission of a client event.
|
|
282
|
+
* @param event - The event name.
|
|
283
|
+
* @param callback - The handler to invoke once.
|
|
284
|
+
* @returns An unsubscribe function.
|
|
285
|
+
*/
|
|
71
286
|
once<TEvent extends OasisEditorClientEvent>(event: TEvent, callback: OasisEditorClientEventHandler<TEvent>): () => void;
|
|
287
|
+
/**
|
|
288
|
+
* Removes a previously subscribed event handler.
|
|
289
|
+
* @param event - The event name.
|
|
290
|
+
* @param callback - The handler to remove.
|
|
291
|
+
*/
|
|
72
292
|
off<TEvent extends OasisEditorClientEvent>(event: TEvent, callback: OasisEditorClientEventHandler<TEvent>): void;
|
|
73
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Internal contract used by the host (editor UI shell) to drive the client.
|
|
296
|
+
* Extends the public {@link OasisEditorClient} with connection lifecycle methods.
|
|
297
|
+
*/
|
|
74
298
|
export interface OasisEditorClientHost {
|
|
75
299
|
getRuntimeEditor(): Editor | null;
|
|
76
300
|
getState(): EditorState;
|
|
77
301
|
getDocument(): EditorDocument;
|
|
78
302
|
setDocument(document: EditorDocument): void;
|
|
303
|
+
applyTransactionalState?(producer: (state: EditorState) => EditorState): void;
|
|
79
304
|
resetDocument(): void;
|
|
80
305
|
saveDocument(): Promise<void>;
|
|
81
306
|
getSelection(): EditorSelection;
|
|
@@ -86,12 +311,40 @@ export interface OasisEditorClientHost {
|
|
|
86
311
|
importDocx(file: File): Promise<void>;
|
|
87
312
|
exportDocx(): Promise<unknown>;
|
|
88
313
|
exportPdf(): Promise<unknown>;
|
|
314
|
+
exportDocxBlob(): Promise<Blob>;
|
|
315
|
+
exportPdfBlob(): Promise<Blob>;
|
|
316
|
+
getUiState?(): OasisEditorUiState;
|
|
317
|
+
updateUiState?(patch: OasisEditorUiState): OasisEditorUiState;
|
|
318
|
+
getZoom?(): number;
|
|
319
|
+
setZoom?(value: number): void;
|
|
320
|
+
adjustZoom?(delta: number): void;
|
|
321
|
+
toolbarRegistry?: ToolbarRegistry;
|
|
322
|
+
menuRegistry?: MenuRegistry;
|
|
89
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Combined interface for the internal client-controller, extending the public
|
|
326
|
+
* API with host connection, disposal, ready resolution, and event emission.
|
|
327
|
+
*/
|
|
90
328
|
export interface OasisEditorClientController extends OasisEditorClient {
|
|
329
|
+
/** @param host - The host to connect. */
|
|
91
330
|
connectHost(host: OasisEditorClientHost): void;
|
|
331
|
+
/** @param dispose - The dispose function to call on cleanup. */
|
|
92
332
|
setDispose(dispose: () => void | Promise<void>): void;
|
|
333
|
+
/** @param editor - The editor instance that is now ready. */
|
|
93
334
|
resolveReady(editor: Editor): void;
|
|
335
|
+
/** @param error - The error that prevented initialization. */
|
|
94
336
|
rejectReady(error: unknown): void;
|
|
337
|
+
/**
|
|
338
|
+
* Emits a client event.
|
|
339
|
+
* @param event - The event name.
|
|
340
|
+
* @param payload - The event payload.
|
|
341
|
+
*/
|
|
95
342
|
emit<TEvent extends OasisEditorClientEvent>(event: TEvent, payload: OasisEditorClientEvents[TEvent]): void;
|
|
96
343
|
}
|
|
344
|
+
/**
|
|
345
|
+
* Creates a new editor client controller. The client is a lightweight broker
|
|
346
|
+
* that connects the public API surface to the host runtime once mounted.
|
|
347
|
+
*
|
|
348
|
+
* @returns A new {@link OasisEditorClientController} instance.
|
|
349
|
+
*/
|
|
97
350
|
export declare function createOasisEditorClient(): OasisEditorClientController;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { EditorBlockNode, EditorDocument, EditorParagraphNode, EditorPosition, EditorTextStyle } from '../../core/model.js';
|
|
2
|
+
import { createEditorParagraph, createEditorTable } from '../../core/editorState.js';
|
|
3
|
+
|
|
4
|
+
/** Current version of the editor document schema. */
|
|
5
|
+
export declare const EDITOR_SCHEMA_VERSION = 1;
|
|
6
|
+
/**
|
|
7
|
+
* Selects a specific node in the document tree. Used as a targeting mechanism
|
|
8
|
+
* for edit operations and queries.
|
|
9
|
+
*/
|
|
10
|
+
export type DocumentSelector = {
|
|
11
|
+
nodeId: string;
|
|
12
|
+
} | {
|
|
13
|
+
text: string;
|
|
14
|
+
occurrence?: number;
|
|
15
|
+
} | {
|
|
16
|
+
headingPath: string[];
|
|
17
|
+
} | {
|
|
18
|
+
tableId: string;
|
|
19
|
+
row: number;
|
|
20
|
+
column: number;
|
|
21
|
+
} | {
|
|
22
|
+
bookmark: string;
|
|
23
|
+
} | {
|
|
24
|
+
contentControlTag: string;
|
|
25
|
+
};
|
|
26
|
+
/** A range between two positions in the document. */
|
|
27
|
+
export interface DocumentRange {
|
|
28
|
+
start: EditorPosition;
|
|
29
|
+
end: EditorPosition;
|
|
30
|
+
}
|
|
31
|
+
/** Descriptor for a node in a semantic document snapshot. */
|
|
32
|
+
export interface SemanticNode {
|
|
33
|
+
id: string;
|
|
34
|
+
type: string;
|
|
35
|
+
text?: string;
|
|
36
|
+
node: unknown;
|
|
37
|
+
}
|
|
38
|
+
/** Descriptor for a text match found by the find API. */
|
|
39
|
+
export interface DocumentMatch {
|
|
40
|
+
selector: {
|
|
41
|
+
nodeId: string;
|
|
42
|
+
};
|
|
43
|
+
paragraphId: string;
|
|
44
|
+
text: string;
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
}
|
|
48
|
+
/** An item in the document outline (heading hierarchy). */
|
|
49
|
+
export interface DocumentOutlineItem {
|
|
50
|
+
id: string;
|
|
51
|
+
level: number;
|
|
52
|
+
text: string;
|
|
53
|
+
path: string[];
|
|
54
|
+
}
|
|
55
|
+
/** Immutable snapshot of the document's semantic structure. */
|
|
56
|
+
export interface SemanticDocumentSnapshot {
|
|
57
|
+
schemaVersion: number;
|
|
58
|
+
documentId: string;
|
|
59
|
+
text: string;
|
|
60
|
+
outline: DocumentOutlineItem[];
|
|
61
|
+
nodes: SemanticNode[];
|
|
62
|
+
}
|
|
63
|
+
/** Non-fatal warning produced during an operation. */
|
|
64
|
+
export type OasisWarning = {
|
|
65
|
+
code: string;
|
|
66
|
+
message: string;
|
|
67
|
+
nodeId?: string;
|
|
68
|
+
};
|
|
69
|
+
/** Error codes for operation failures. */
|
|
70
|
+
export type OasisErrorCode = "NODE_NOT_FOUND" | "AMBIGUOUS_SELECTOR" | "INVALID_RANGE" | "VALIDATION_FAILED" | "READ_ONLY" | "UNSUPPORTED_OPERATION" | "DOCUMENT_VERSION_CONFLICT" | "IMPORT_FAILED" | "EXPORT_FAILED" | "ABORTED";
|
|
71
|
+
/** Structured error information returned on operation failure. */
|
|
72
|
+
export interface OasisError {
|
|
73
|
+
code: OasisErrorCode;
|
|
74
|
+
message: string;
|
|
75
|
+
expectedVersion?: number;
|
|
76
|
+
actualVersion?: number;
|
|
77
|
+
details?: unknown;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Wraps a successful value or an error with its metadata.
|
|
81
|
+
* @typeParam T - The type of the success value.
|
|
82
|
+
*/
|
|
83
|
+
export type OasisResult<T> = {
|
|
84
|
+
ok: true;
|
|
85
|
+
value: T;
|
|
86
|
+
version: number;
|
|
87
|
+
warnings: OasisWarning[];
|
|
88
|
+
} | {
|
|
89
|
+
ok: false;
|
|
90
|
+
error: OasisError;
|
|
91
|
+
};
|
|
92
|
+
/** A single edit operation to be applied to the document. */
|
|
93
|
+
export type EditOperation = {
|
|
94
|
+
op: "insertText";
|
|
95
|
+
target: DocumentSelector;
|
|
96
|
+
text: string;
|
|
97
|
+
offset?: number;
|
|
98
|
+
} | {
|
|
99
|
+
op: "replaceText";
|
|
100
|
+
target: DocumentSelector;
|
|
101
|
+
text: string;
|
|
102
|
+
} | {
|
|
103
|
+
op: "deleteRange";
|
|
104
|
+
range: DocumentRange;
|
|
105
|
+
} | {
|
|
106
|
+
op: "insertParagraph";
|
|
107
|
+
text?: string;
|
|
108
|
+
after?: DocumentSelector;
|
|
109
|
+
} | {
|
|
110
|
+
op: "insertBlocks";
|
|
111
|
+
blocks: EditorBlockNode[];
|
|
112
|
+
after?: DocumentSelector;
|
|
113
|
+
} | {
|
|
114
|
+
op: "deleteNode";
|
|
115
|
+
target: DocumentSelector;
|
|
116
|
+
} | {
|
|
117
|
+
op: "setTextStyle";
|
|
118
|
+
target: DocumentSelector;
|
|
119
|
+
style: EditorTextStyle;
|
|
120
|
+
} | {
|
|
121
|
+
op: "setParagraphStyle";
|
|
122
|
+
target: DocumentSelector;
|
|
123
|
+
style: {
|
|
124
|
+
styleId: string;
|
|
125
|
+
};
|
|
126
|
+
} | {
|
|
127
|
+
op: "insertTable";
|
|
128
|
+
rows: string[][];
|
|
129
|
+
after?: DocumentSelector;
|
|
130
|
+
} | {
|
|
131
|
+
op: "updateTableCell";
|
|
132
|
+
target: {
|
|
133
|
+
tableId: string;
|
|
134
|
+
row: number;
|
|
135
|
+
column: number;
|
|
136
|
+
};
|
|
137
|
+
text: string;
|
|
138
|
+
};
|
|
139
|
+
/** Describes the origin/actor of an edit request. */
|
|
140
|
+
export interface EditActor {
|
|
141
|
+
type: string;
|
|
142
|
+
actorId?: string;
|
|
143
|
+
label?: string;
|
|
144
|
+
}
|
|
145
|
+
/** Request to apply one or more edit operations to the document. */
|
|
146
|
+
export interface ApplyEditRequest {
|
|
147
|
+
operations: EditOperation[];
|
|
148
|
+
expectedVersion?: number;
|
|
149
|
+
transactionId?: string;
|
|
150
|
+
idempotencyKey?: string;
|
|
151
|
+
origin?: EditActor;
|
|
152
|
+
}
|
|
153
|
+
/** Result value returned after applying edit operations. */
|
|
154
|
+
export interface ApplyEditValue {
|
|
155
|
+
changedNodeIds: string[];
|
|
156
|
+
createdNodeIds: string[];
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Deep-clones a document.
|
|
160
|
+
* @param document - The document to clone.
|
|
161
|
+
* @returns A deep copy of the document.
|
|
162
|
+
*/
|
|
163
|
+
export declare function cloneDocument<T extends EditorDocument>(document: T): T;
|
|
164
|
+
/**
|
|
165
|
+
* Ensures the document has a schemaVersion property set.
|
|
166
|
+
* @param document - The document to normalize.
|
|
167
|
+
* @returns The normalized document.
|
|
168
|
+
*/
|
|
169
|
+
export declare function normalizeDocument(document: EditorDocument): EditorDocument;
|
|
170
|
+
/**
|
|
171
|
+
* Validates document structure, returning errors if any.
|
|
172
|
+
* @param document - The document to validate.
|
|
173
|
+
* @returns An OasisResult indicating success or listing validation errors.
|
|
174
|
+
*/
|
|
175
|
+
export declare function validateDocument(document: EditorDocument): OasisResult<true>;
|
|
176
|
+
/**
|
|
177
|
+
* Creates a new empty editor document.
|
|
178
|
+
* @param options - Optional initial blocks and title.
|
|
179
|
+
* @returns A new EditorDocument.
|
|
180
|
+
*/
|
|
181
|
+
export declare function createDocument(options?: {
|
|
182
|
+
blocks?: EditorBlockNode[];
|
|
183
|
+
title?: string;
|
|
184
|
+
}): EditorDocument;
|
|
185
|
+
/** Creates an empty paragraph node. Alias for {@link createEditorParagraph}. */
|
|
186
|
+
export declare const createParagraph: typeof createEditorParagraph;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a heading paragraph.
|
|
189
|
+
* @param text - The heading text.
|
|
190
|
+
* @param options - Options including the heading level.
|
|
191
|
+
* @returns A new heading paragraph node.
|
|
192
|
+
*/
|
|
193
|
+
export declare function createHeading(text: string, options?: {
|
|
194
|
+
level?: number;
|
|
195
|
+
}): EditorParagraphNode;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a table node from a 2D array of string cell values.
|
|
198
|
+
* @param rows - A 2D array where each inner array represents a row of cell values.
|
|
199
|
+
* @returns A new table node.
|
|
200
|
+
*/
|
|
201
|
+
export declare function createTable(rows: string[][]): ReturnType<typeof createEditorTable>;
|
|
202
|
+
/**
|
|
203
|
+
* Creates a query object for read-only document inspection.
|
|
204
|
+
* @param document - The document to query against.
|
|
205
|
+
* @returns An object with snapshot, getText, getNode, find, and outline methods.
|
|
206
|
+
*/
|
|
207
|
+
export declare function queryDocument(document: EditorDocument): {
|
|
208
|
+
snapshot: () => SemanticDocumentSnapshot;
|
|
209
|
+
getText: (target?: DocumentSelector | DocumentRange) => string;
|
|
210
|
+
getNode: (selector: DocumentSelector) => SemanticNode | null;
|
|
211
|
+
find: (text: string) => DocumentMatch[];
|
|
212
|
+
outline: () => DocumentOutlineItem[];
|
|
213
|
+
};
|
|
214
|
+
/**
|
|
215
|
+
* Applies an array of edit operations to a document.
|
|
216
|
+
* @param document - The document to mutate.
|
|
217
|
+
* @param operations - The operations to apply.
|
|
218
|
+
* @returns The mutated document along with metadata about changed and created nodes.
|
|
219
|
+
*/
|
|
220
|
+
export declare function applyDocumentOperations(document: EditorDocument, operations: EditOperation[]): {
|
|
221
|
+
document: EditorDocument;
|
|
222
|
+
value: ApplyEditValue;
|
|
223
|
+
};
|