@coorax/core 0.0.0-canary.0 → 0.0.0-canary.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/dist/base/classes/component.class.d.ts +23 -0
- package/dist/base/classes/container.class.d.ts +17 -0
- package/dist/base/classes/field.class.d.ts +15 -0
- package/dist/base/classes/tnode.class.d.ts +14 -0
- package/{src/base/index.ts → dist/base/index.d.ts} +0 -4
- package/dist/base/types/components/components.d.ts +13 -0
- package/dist/base/types/container/container.d.ts +27 -0
- package/dist/base/types/container/division.types.d.ts +3 -0
- package/{src/base/types/container/section.types.ts → dist/base/types/container/section.types.d.ts} +2 -2
- package/{src/base/types/container/ul-list.types.ts → dist/base/types/container/ul-list.types.d.ts} +2 -2
- package/dist/base/types/css.types.d.ts +23 -0
- package/dist/base/types/field/divider.types.d.ts +3 -0
- package/{src/base/types/field/field.ts → dist/base/types/field/field.d.ts} +19 -26
- package/{src/base/types/field/field.media.types.ts → dist/base/types/field/field.media.types.d.ts} +2 -3
- package/{src/base/types/field/field.text.types.ts → dist/base/types/field/field.text.types.d.ts} +4 -5
- package/{src/base/types/field/heading.types.ts → dist/base/types/field/heading.types.d.ts} +2 -2
- package/{src/base/types/field/paragraph.types.ts → dist/base/types/field/paragraph.types.d.ts} +2 -2
- package/dist/base/types/global.types.d.ts +24 -0
- package/{src/base/types/node/span.types.ts → dist/base/types/node/link.types.d.ts} +2 -2
- package/{src/base/types/node/node.ts → dist/base/types/node/node.d.ts} +13 -17
- package/{src/base/types/node/link.types.ts → dist/base/types/node/span.types.d.ts} +2 -2
- package/dist/base/types/tree/tree.d.ts +23 -0
- package/{src/engine/engine.ts → dist/engine/engine.d.ts} +20 -24
- package/dist/engine/engine.test.d.ts +1 -0
- package/{src/index.ts → dist/index.d.ts} +0 -1
- package/dist/index.js +2466 -0
- package/dist/modules/editor/editor.module.d.ts +44 -0
- package/dist/modules/focus/focus.module.d.ts +54 -0
- package/dist/modules/history/history.module.d.ts +27 -0
- package/dist/modules/hover/hover.module.d.ts +53 -0
- package/dist/modules/insertion/insertion.module.d.ts +54 -0
- package/dist/modules/modules-manager.d.ts +41 -0
- package/{src/modules/modules.types.ts → dist/modules/modules.types.d.ts} +25 -30
- package/dist/modules/selection/selection.module.d.ts +60 -0
- package/dist/modules/selection/selection.test.d.ts +1 -0
- package/dist/modules/text-editing/text-editing.constants.d.ts +2 -0
- package/dist/modules/text-editing/text-editing.module.d.ts +83 -0
- package/dist/modules/text-editing/text-editing.utils.d.ts +6 -0
- package/dist/services/commandsbus/commandsbus.d.ts +53 -0
- package/dist/services/commandsbus/commandsbus.test.d.ts +17 -0
- package/dist/services/document/document.d.ts +45 -0
- package/dist/services/eventbus/eventbus.d.ts +86 -0
- package/dist/services/eventbus/eventbus.test.d.ts +8 -0
- package/dist/services/eventbus/subscriber.d.ts +18 -0
- package/dist/services/mutations/mutations.d.ts +38 -0
- package/dist/services/mutations/mutations.errors.d.ts +6 -0
- package/dist/services/mutations/mutations.test.d.ts +1 -0
- package/dist/services/shortcuts/shortcuts.d.ts +4 -0
- package/dist/services/state/state.d.ts +20 -0
- package/dist/services/state/state.errors.d.ts +6 -0
- package/dist/services/tasks/tasks.service.d.ts +106 -0
- package/dist/services/tasks/tasks.service.test.d.ts +7 -0
- package/{src/services/text-marks/marks.types.ts → dist/services/text-marks/marks.types.d.ts} +20 -23
- package/dist/services/text-marks/text-marks.d.ts +45 -0
- package/dist/services/ui/default-styles.d.ts +3 -0
- package/dist/services/ui/ui.d.ts +22 -0
- package/dist/services/ui/ui.errors.d.ts +3 -0
- package/dist/services/ui/ui.types.d.ts +113 -0
- package/dist/styles.css +537 -0
- package/dist/utils/components.utils.d.ts +10 -0
- package/dist/utils/container.utils.d.ts +13 -0
- package/dist/utils/fields.utils.d.ts +19 -0
- package/dist/utils/global.utils.d.ts +47 -0
- package/dist/utils/modules.utils.d.ts +11 -0
- package/dist/utils/tnode.utils.d.ts +9 -0
- package/dist/utils/tree.utils.d.ts +11 -0
- package/package.json +19 -6
- package/styles.css +1 -3
- package/src/base/classes/component.class.ts +0 -68
- package/src/base/classes/container.class.ts +0 -57
- package/src/base/classes/field.class.ts +0 -42
- package/src/base/classes/tnode.class.ts +0 -38
- package/src/base/types/components/components.ts +0 -21
- package/src/base/types/container/container.ts +0 -37
- package/src/base/types/container/division.types.ts +0 -3
- package/src/base/types/css.types.ts +0 -33
- package/src/base/types/field/divider.types.ts +0 -3
- package/src/base/types/global.types.ts +0 -45
- package/src/base/types/tree/tree.ts +0 -33
- package/src/engine/engine.test.ts +0 -27
- package/src/modules/editor/editor.module.ts +0 -119
- package/src/modules/focus/focus.module.ts +0 -185
- package/src/modules/history/history.module.ts +0 -60
- package/src/modules/hover/hover.module.ts +0 -121
- package/src/modules/insertion/insertion.module.ts +0 -140
- package/src/modules/modules-manager.ts +0 -132
- package/src/modules/selection/selection.module.ts +0 -174
- package/src/modules/selection/selection.test.ts +0 -1
- package/src/modules/text-editing/text-editing.constants.ts +0 -6
- package/src/modules/text-editing/text-editing.module.ts +0 -377
- package/src/modules/text-editing/text-editing.utils.ts +0 -27
- package/src/services/commandsbus/commandsbus.test.ts +0 -312
- package/src/services/commandsbus/commandsbus.ts +0 -360
- package/src/services/document/document.ts +0 -139
- package/src/services/eventbus/eventbus.test.ts +0 -144
- package/src/services/eventbus/eventbus.ts +0 -162
- package/src/services/eventbus/subscriber.ts +0 -46
- package/src/services/mutations/mutations.errors.ts +0 -12
- package/src/services/mutations/mutations.test.ts +0 -177
- package/src/services/mutations/mutations.ts +0 -457
- package/src/services/shortcuts/shortcuts.ts +0 -3
- package/src/services/state/state.errors.ts +0 -12
- package/src/services/state/state.ts +0 -64
- package/src/services/tasks/tasks.service.test.ts +0 -193
- package/src/services/tasks/tasks.service.ts +0 -288
- package/src/services/text-marks/text-marks.ts +0 -244
- package/src/services/ui/default-styles.ts +0 -93
- package/src/services/ui/ui.errors.ts +0 -6
- package/src/services/ui/ui.ts +0 -148
- package/src/services/ui/ui.types.ts +0 -197
- package/src/utils/components.utils.ts +0 -26
- package/src/utils/container.utils.ts +0 -59
- package/src/utils/fields.utils.ts +0 -118
- package/src/utils/global.utils.ts +0 -128
- package/src/utils/modules.utils.ts +0 -110
- package/src/utils/tnode.utils.ts +0 -48
- package/src/utils/tree.utils.ts +0 -120
- package/tsconfig.json +0 -9
- /package/{src/engine/index.ts → dist/engine/index.d.ts} +0 -0
- /package/{src/modules/index.ts → dist/modules/index.d.ts} +0 -0
- /package/{src/services/commandsbus/index.ts → dist/services/commandsbus/index.d.ts} +0 -0
- /package/{src/services/document/index.ts → dist/services/document/index.d.ts} +0 -0
- /package/{src/services/eventbus/index.ts → dist/services/eventbus/index.d.ts} +0 -0
- /package/{src/services/mutations/index.ts → dist/services/mutations/index.d.ts} +0 -0
- /package/{src/services/state/index.ts → dist/services/state/index.d.ts} +0 -0
- /package/{src/services/tasks/index.ts → dist/services/tasks/index.d.ts} +0 -0
- /package/{src/services/text-marks/index.ts → dist/services/text-marks/index.d.ts} +0 -0
- /package/{src/services/ui/index.ts → dist/services/ui/index.d.ts} +0 -0
- /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BlockRect, TModule } from "..";
|
|
2
|
+
import type { CommandMap } from "../../services/commandsbus/commandsbus";
|
|
3
|
+
export type EditorRect = Omit<BlockRect, "parentScrollTop" | "parentScrollLeft"> & {
|
|
4
|
+
clientTop: number;
|
|
5
|
+
clientLeft: number;
|
|
6
|
+
scrollTop: number;
|
|
7
|
+
scrollLeft: number;
|
|
8
|
+
};
|
|
9
|
+
export type OverlayPosition = {
|
|
10
|
+
top: number;
|
|
11
|
+
left: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/** Viewport block rects → `position: absolute` inside the scroll container. */
|
|
16
|
+
export declare function overlayPositionFromBlockRects(rects: readonly BlockRect[], editorRect: EditorRect | null): OverlayPosition | null;
|
|
17
|
+
declare module "../modules-manager" {
|
|
18
|
+
interface ModuleMap {
|
|
19
|
+
editor: {};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare module "../../services/state/state" {
|
|
23
|
+
interface StateMap {
|
|
24
|
+
editor: {
|
|
25
|
+
editorRect: EditorRect | null;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
30
|
+
interface CommandMap {
|
|
31
|
+
"editor.rect": {
|
|
32
|
+
payload: {
|
|
33
|
+
editorRect: EditorRect;
|
|
34
|
+
};
|
|
35
|
+
result: void;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
declare module "../../services/eventbus/eventbus" {
|
|
40
|
+
interface TEventMap {
|
|
41
|
+
"editor:rect": CommandMap["editor.rect"]["payload"];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export declare const EditorModule: TModule;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { BlockId } from "../../base";
|
|
2
|
+
import type { CommandMap } from "../../services/commandsbus";
|
|
3
|
+
import type { StateMap } from "../../services/state";
|
|
4
|
+
import type { BlockRect, TModule } from "../modules.types";
|
|
5
|
+
declare module "../modules-manager" {
|
|
6
|
+
interface ModuleMap {
|
|
7
|
+
focus: {};
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare module "../../services/state/state" {
|
|
11
|
+
interface StateMap {
|
|
12
|
+
focus: {
|
|
13
|
+
id: BlockId;
|
|
14
|
+
rect: BlockRect;
|
|
15
|
+
} | null;
|
|
16
|
+
focus_memory: {
|
|
17
|
+
blocks: {
|
|
18
|
+
id: BlockId;
|
|
19
|
+
rect: BlockRect;
|
|
20
|
+
}[];
|
|
21
|
+
count: number;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
26
|
+
interface CommandMap {
|
|
27
|
+
"blocks.focus": {
|
|
28
|
+
payload: StateMap["focus"];
|
|
29
|
+
result: void;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
declare module "../../services/eventbus/eventbus" {
|
|
34
|
+
interface TEventMap {
|
|
35
|
+
"blocks:focus": CommandMap["blocks.focus"]["payload"];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
declare module "../../services/ui/ui" {
|
|
39
|
+
interface SlotComponentMap {
|
|
40
|
+
FocusOverlay: {
|
|
41
|
+
position: {
|
|
42
|
+
top: number;
|
|
43
|
+
left: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
} | null;
|
|
47
|
+
hidden: boolean;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
interface ComponentContributionIdentityMap {
|
|
51
|
+
"focus-overlay": {};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export declare const FocusModule: TModule;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TModule } from "../modules.types";
|
|
2
|
+
declare module "../modules-manager" {
|
|
3
|
+
interface ModuleMap {
|
|
4
|
+
history: {};
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
declare module "../../services/state/state" {
|
|
8
|
+
interface StateMap {
|
|
9
|
+
history: {
|
|
10
|
+
canUndo: boolean;
|
|
11
|
+
canRedo: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
16
|
+
interface CommandMap {
|
|
17
|
+
"history.undo": {
|
|
18
|
+
payload: {};
|
|
19
|
+
result: void;
|
|
20
|
+
};
|
|
21
|
+
"history.redo": {
|
|
22
|
+
payload: {};
|
|
23
|
+
result: void;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare const HistoryModule: TModule;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BlockId } from "../../base";
|
|
2
|
+
import type { StateMap } from "../../services/state";
|
|
3
|
+
import type { BlockRect, TModule } from "../modules.types";
|
|
4
|
+
declare module "../modules-manager" {
|
|
5
|
+
interface ModuleMap {
|
|
6
|
+
hover: {};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
declare module "../../services/state/state" {
|
|
10
|
+
interface StateMap {
|
|
11
|
+
hover: {
|
|
12
|
+
id: BlockId;
|
|
13
|
+
rect: BlockRect;
|
|
14
|
+
} | null;
|
|
15
|
+
hover_memory: {
|
|
16
|
+
blocks: {
|
|
17
|
+
id: BlockId;
|
|
18
|
+
rect: BlockRect;
|
|
19
|
+
}[];
|
|
20
|
+
count: number;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
25
|
+
interface CommandMap {
|
|
26
|
+
"blocks.hover": {
|
|
27
|
+
payload: StateMap["hover"];
|
|
28
|
+
result: void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare module "../../services/eventbus/eventbus" {
|
|
33
|
+
interface TEventMap {
|
|
34
|
+
"blocks:hover": StateMap["hover"];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
declare module "../../services/ui/ui" {
|
|
38
|
+
interface SlotComponentMap {
|
|
39
|
+
HoverOverlay: {
|
|
40
|
+
position: {
|
|
41
|
+
top: number;
|
|
42
|
+
left: number;
|
|
43
|
+
width: number;
|
|
44
|
+
height: number;
|
|
45
|
+
} | null;
|
|
46
|
+
hidden: boolean;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
interface ComponentContributionIdentityMap {
|
|
50
|
+
"hover-overlay": {};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export declare const HoverModule: TModule;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Block, BlockId } from "../../base/types/tree/tree";
|
|
2
|
+
import type { CommandMap } from "../../services/commandsbus/commandsbus";
|
|
3
|
+
import type { TModule } from "../modules.types";
|
|
4
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
5
|
+
interface CommandMap {
|
|
6
|
+
"blocks.insert": {
|
|
7
|
+
payload: {
|
|
8
|
+
block: Block;
|
|
9
|
+
pos?: number;
|
|
10
|
+
};
|
|
11
|
+
result: void;
|
|
12
|
+
};
|
|
13
|
+
"blocks.delete": {
|
|
14
|
+
payload: {
|
|
15
|
+
blockId: BlockId;
|
|
16
|
+
};
|
|
17
|
+
result: void;
|
|
18
|
+
};
|
|
19
|
+
"actions.toggle": {
|
|
20
|
+
payload: boolean;
|
|
21
|
+
result: void;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
declare module "../../services/eventbus/eventbus" {
|
|
26
|
+
interface TEventMap {
|
|
27
|
+
"blocks:insert": CommandMap["blocks.insert"]["payload"];
|
|
28
|
+
"blocks:delete": CommandMap["blocks.delete"]["payload"];
|
|
29
|
+
"actions:toggle": CommandMap["actions.toggle"]["payload"];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
declare module "../../services/state/state" {
|
|
33
|
+
interface StateMap {
|
|
34
|
+
insertion: boolean;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
declare module "../modules-manager" {
|
|
38
|
+
interface ModuleMap {
|
|
39
|
+
insertion: {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
declare module "../../services/ui/ui" {
|
|
43
|
+
interface ButtonContributionIdentityMap {
|
|
44
|
+
"insert-field": {};
|
|
45
|
+
"insert-heading": {};
|
|
46
|
+
"insert-text": {};
|
|
47
|
+
"insert-image": {};
|
|
48
|
+
"insert-divider": {};
|
|
49
|
+
}
|
|
50
|
+
interface IconMap {
|
|
51
|
+
DividerIcon: {};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export declare const InsertionModule: TModule;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Engine } from "../engine/engine";
|
|
2
|
+
import type { TModule } from "./modules.types";
|
|
3
|
+
export interface ModuleMap {
|
|
4
|
+
}
|
|
5
|
+
export type ModuleName = keyof ModuleMap;
|
|
6
|
+
export interface ModuleManagerInterface {
|
|
7
|
+
register(modules: TModule[]): void;
|
|
8
|
+
isEnabled(name: ModuleName): boolean;
|
|
9
|
+
enable(name: ModuleName): void;
|
|
10
|
+
enableAll(): void;
|
|
11
|
+
disable(name: ModuleName, opts?: {
|
|
12
|
+
cascade?: boolean;
|
|
13
|
+
}): void;
|
|
14
|
+
disabledAll(): void;
|
|
15
|
+
unregister(name: ModuleName): void;
|
|
16
|
+
}
|
|
17
|
+
export declare class ModuleManager implements ModuleManagerInterface {
|
|
18
|
+
private registry;
|
|
19
|
+
private active;
|
|
20
|
+
private engine;
|
|
21
|
+
constructor(engine: Engine);
|
|
22
|
+
register(modules: TModule[]): void;
|
|
23
|
+
isEnabled(name: ModuleName): boolean;
|
|
24
|
+
enable(name: ModuleName): void;
|
|
25
|
+
enableAll(): void;
|
|
26
|
+
disabledAll(): void;
|
|
27
|
+
disable(name: ModuleName, opts?: {
|
|
28
|
+
cascade?: boolean;
|
|
29
|
+
}): void;
|
|
30
|
+
unregister(name: ModuleName): void;
|
|
31
|
+
/**
|
|
32
|
+
* Enable module recursively
|
|
33
|
+
*
|
|
34
|
+
* @param name string
|
|
35
|
+
* @param stack string[]
|
|
36
|
+
* @returns void
|
|
37
|
+
*/
|
|
38
|
+
private enableRec;
|
|
39
|
+
private activate;
|
|
40
|
+
private activeDependentsOf;
|
|
41
|
+
}
|
|
@@ -8,40 +8,35 @@ import type { TextMarksInterface } from "../services/text-marks/text-marks";
|
|
|
8
8
|
import type { UiInterface } from "../services/ui/ui";
|
|
9
9
|
import type { TasksInterface } from "../services/tasks/tasks.service";
|
|
10
10
|
import type { ModuleName } from "./modules-manager";
|
|
11
|
-
|
|
12
11
|
export type TModuleCtx = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
readonly events: EventBusInterface;
|
|
13
|
+
readonly commands: CommandsInterface;
|
|
14
|
+
readonly mutations: MutationsInterface;
|
|
15
|
+
readonly shortcuts: ShortcutsInterface;
|
|
16
|
+
readonly state: StateInterface;
|
|
17
|
+
readonly document: DocumentInterface;
|
|
18
|
+
readonly ui: UiInterface;
|
|
19
|
+
readonly text: TextMarksInterface;
|
|
20
|
+
readonly tasks: TasksInterface;
|
|
22
21
|
};
|
|
23
|
-
|
|
24
22
|
export type ModuleDisposer = () => void;
|
|
25
|
-
|
|
26
23
|
export interface TModule {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
install(ctx: TModuleCtx): void | ModuleDisposer;
|
|
24
|
+
readonly name: ModuleName;
|
|
25
|
+
readonly version: string;
|
|
26
|
+
readonly requires: ReadonlyArray<ModuleName>;
|
|
27
|
+
install(ctx: TModuleCtx): void | ModuleDisposer;
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
export type BlockRect = {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
top: number;
|
|
31
|
+
left: number;
|
|
32
|
+
right: number;
|
|
33
|
+
width: number;
|
|
34
|
+
height: number;
|
|
35
|
+
bottom: number;
|
|
36
|
+
offsetTop: number;
|
|
37
|
+
offsetLeft: number;
|
|
38
|
+
offsetWidth: number;
|
|
39
|
+
offsetHeight: number;
|
|
40
|
+
parentScrollTop: number;
|
|
41
|
+
parentScrollLeft: number;
|
|
47
42
|
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { BlockId } from "../../base/types/tree/tree";
|
|
2
|
+
import type { CommandMap } from "../../services/commandsbus/commandsbus";
|
|
3
|
+
import type { StateMap } from "../../services/state";
|
|
4
|
+
import type { BlockRect, TModule } from "../modules.types";
|
|
5
|
+
export type SelectedBlocks = Map<BlockId, BlockRect>;
|
|
6
|
+
type SelectMode = "replace" | "add" | "toggle" | "remove";
|
|
7
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
8
|
+
interface CommandMap {
|
|
9
|
+
"blocks.select": {
|
|
10
|
+
payload: {
|
|
11
|
+
blocks: StateMap["selection"]["blocks"];
|
|
12
|
+
mode?: SelectMode;
|
|
13
|
+
};
|
|
14
|
+
result: void;
|
|
15
|
+
};
|
|
16
|
+
"blocks.clearSelection": {
|
|
17
|
+
payload: void;
|
|
18
|
+
result: void;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
declare module "../../services/eventbus/eventbus" {
|
|
23
|
+
interface TEventMap {
|
|
24
|
+
"blocks:select": CommandMap["blocks.select"]["payload"];
|
|
25
|
+
"selection:changed": {
|
|
26
|
+
blocks: StateMap["selection"]["blocks"];
|
|
27
|
+
previous: StateMap["selection"]["blocks"];
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
declare module "../../services/state/state" {
|
|
32
|
+
interface StateMap {
|
|
33
|
+
selection: {
|
|
34
|
+
blocks: SelectedBlocks;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
declare module "../modules-manager" {
|
|
39
|
+
interface ModuleMap {
|
|
40
|
+
selection: {};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
declare module "../../services/ui/ui" {
|
|
44
|
+
interface SlotComponentMap {
|
|
45
|
+
SelectionOverlay: {
|
|
46
|
+
position: {
|
|
47
|
+
top: number;
|
|
48
|
+
left: number;
|
|
49
|
+
width: number;
|
|
50
|
+
height: number;
|
|
51
|
+
} | null;
|
|
52
|
+
hidden: boolean;
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
interface ComponentContributionIdentityMap {
|
|
56
|
+
"selection-overlay": {};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
export declare const SelectionModule: TModule;
|
|
60
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { FieldId } from "../../base";
|
|
2
|
+
import type { CommandMap } from "../../services/commandsbus";
|
|
3
|
+
import type { FieldTextContentPath, Mark, MarkAttrs, MarkSpec, MarkType } from "../../services/text-marks/marks.types";
|
|
4
|
+
import type { TModule } from "../modules.types";
|
|
5
|
+
export type TextSelection = {
|
|
6
|
+
blockId: FieldId;
|
|
7
|
+
path: FieldTextContentPath;
|
|
8
|
+
start: number;
|
|
9
|
+
end: number;
|
|
10
|
+
/** Marks du prochain caractère tapé (curseur sans sélection). null = comportement automatique. */
|
|
11
|
+
pendingMarks: readonly MarkSpec[] | null;
|
|
12
|
+
};
|
|
13
|
+
declare module "../modules-manager" {
|
|
14
|
+
interface ModuleMap {
|
|
15
|
+
"text-editing": {};
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
declare module "../../services/ui/ui" {
|
|
19
|
+
interface ButtonContributionIdentityMap {
|
|
20
|
+
"format-bold": {};
|
|
21
|
+
"format-italic": {};
|
|
22
|
+
"format-underline": {};
|
|
23
|
+
"format-link": {};
|
|
24
|
+
"format-code": {};
|
|
25
|
+
"format-initial": {};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
declare module "../../services/state/state" {
|
|
29
|
+
interface StateMap {
|
|
30
|
+
textSelection: TextSelection | null;
|
|
31
|
+
currentMarks: Mark[];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
declare module "../../services/ui/ui" {
|
|
35
|
+
interface IconMap {
|
|
36
|
+
UnderlineIcon: {};
|
|
37
|
+
ItalicIcon: {};
|
|
38
|
+
LinkIcon: {};
|
|
39
|
+
TextInitial: {};
|
|
40
|
+
}
|
|
41
|
+
interface SlotButtonPropsMap {
|
|
42
|
+
ToolBarButton: {
|
|
43
|
+
isActive: boolean;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
declare module "../../services/commandsbus/commandsbus" {
|
|
48
|
+
interface CommandMap {
|
|
49
|
+
"text.setSelection": {
|
|
50
|
+
payload: Omit<TextSelection, "pendingMarks"> | null;
|
|
51
|
+
result: void;
|
|
52
|
+
};
|
|
53
|
+
"text.format": {
|
|
54
|
+
payload: {
|
|
55
|
+
format: MarkType;
|
|
56
|
+
attrs?: MarkAttrs;
|
|
57
|
+
};
|
|
58
|
+
result: void;
|
|
59
|
+
};
|
|
60
|
+
"text.insert": {
|
|
61
|
+
payload: {
|
|
62
|
+
text: string;
|
|
63
|
+
};
|
|
64
|
+
result: void;
|
|
65
|
+
};
|
|
66
|
+
"text.delete": {
|
|
67
|
+
payload: {
|
|
68
|
+
direction?: "backward" | "forward";
|
|
69
|
+
type?: "word" | "character";
|
|
70
|
+
};
|
|
71
|
+
result: void;
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
declare module "../../services/eventbus/eventbus" {
|
|
76
|
+
interface TEventMap {
|
|
77
|
+
"text:setSelection": CommandMap["text.setSelection"]["payload"];
|
|
78
|
+
"text:format": CommandMap["text.format"]["payload"];
|
|
79
|
+
"text:insert": CommandMap["text.insert"]["payload"];
|
|
80
|
+
"text:delete": CommandMap["text.delete"]["payload"];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export declare const TextEditingModule: TModule;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface CommandMap {
|
|
2
|
+
}
|
|
3
|
+
export type CommandType = keyof CommandMap;
|
|
4
|
+
export type CommandPayload<T extends CommandType> = CommandMap[T]["payload"];
|
|
5
|
+
export type CommandResult<T extends CommandType> = CommandMap[T]["result"];
|
|
6
|
+
export type CommandHandler<T extends CommandType> = (payload: CommandPayload<T>) => CommandResult<T>;
|
|
7
|
+
export type CommandDisposer = () => void;
|
|
8
|
+
export type HookNextFunction<T extends CommandType = CommandType, P extends CommandPayload<T> = CommandPayload<T>> = (payload: P) => P | null;
|
|
9
|
+
export type AsyncHookNextFunction<T extends CommandType = CommandType, P extends CommandPayload<T> = CommandPayload<T>> = (payload: P) => Promise<P | null> | P | null;
|
|
10
|
+
export type AfterHook<T extends CommandType = CommandType> = (payload: CommandPayload<T>, result: CommandResult<T>) => void;
|
|
11
|
+
export type AsyncCommandHandler<T extends CommandType = CommandType> = (payload: CommandPayload<T>) => Promise<CommandResult<T>> | CommandResult<T>;
|
|
12
|
+
export type AsyncAfterHook<T extends CommandType = CommandType> = (payload: CommandPayload<T>, result: CommandResult<T>) => Promise<void> | void;
|
|
13
|
+
export interface CommandsInterface {
|
|
14
|
+
/**
|
|
15
|
+
* Return null if a **CmdNotFoundError** error is catched
|
|
16
|
+
* else throw the error
|
|
17
|
+
* @param cmd CommandType
|
|
18
|
+
* @param payload CommandPayload<T>
|
|
19
|
+
*/
|
|
20
|
+
tryExecute<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): CommandResult<T> | null;
|
|
21
|
+
tryExecuteAsync<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): Promise<CommandResult<T> | null>;
|
|
22
|
+
execute<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): CommandResult<T> | null;
|
|
23
|
+
executeAsync<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): Promise<CommandResult<T> | null>;
|
|
24
|
+
register<T extends CommandType = CommandType>(cmd: T, callback: CommandHandler<T>): CommandDisposer;
|
|
25
|
+
registerAsync<T extends CommandType = CommandType>(cmd: T, callback: AsyncCommandHandler<T>): CommandDisposer;
|
|
26
|
+
before<T extends CommandType = CommandType>(cmd: T, next: HookNextFunction<T, CommandPayload<T>>): CommandDisposer;
|
|
27
|
+
beforeAsync<T extends CommandType = CommandType>(cmd: T, next: AsyncHookNextFunction<T, CommandPayload<T>>): CommandDisposer;
|
|
28
|
+
after<T extends CommandType = CommandType>(cmd: T, callback: AfterHook<T>): CommandDisposer;
|
|
29
|
+
afterAsync<T extends CommandType = CommandType>(cmd: T, callback: AsyncAfterHook<T>): CommandDisposer;
|
|
30
|
+
has<T extends CommandType = CommandType>(cmd: T): boolean;
|
|
31
|
+
}
|
|
32
|
+
export declare class CmdNotFoundError extends Error {
|
|
33
|
+
constructor(cmd: CommandType);
|
|
34
|
+
}
|
|
35
|
+
export declare class CommandsBusService implements CommandsInterface {
|
|
36
|
+
private handlers;
|
|
37
|
+
private asyncHandlers;
|
|
38
|
+
private afterHooks;
|
|
39
|
+
private asyncAfterHooks;
|
|
40
|
+
private nextFunctions;
|
|
41
|
+
private asyncNextFunctions;
|
|
42
|
+
tryExecute<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): CommandResult<T> | null;
|
|
43
|
+
tryExecuteAsync<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): Promise<CommandResult<T> | null>;
|
|
44
|
+
execute<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): CommandResult<T> | null;
|
|
45
|
+
executeAsync<T extends CommandType = CommandType>(cmd: T, payload: CommandPayload<T>): Promise<CommandResult<T> | null>;
|
|
46
|
+
register<T extends CommandType = CommandType>(cmd: T, handler: CommandHandler<T>): CommandDisposer;
|
|
47
|
+
registerAsync<T extends CommandType = CommandType>(cmd: T, handler: AsyncCommandHandler<T>): CommandDisposer;
|
|
48
|
+
before<T extends CommandType = CommandType>(cmd: T, next: HookNextFunction<T, CommandPayload<T>>): CommandDisposer;
|
|
49
|
+
beforeAsync<T extends CommandType = CommandType>(cmd: T, next: AsyncHookNextFunction<T, CommandPayload<T>>): CommandDisposer;
|
|
50
|
+
after<T extends CommandType = CommandType>(cmd: T, callback: AfterHook<T>): CommandDisposer;
|
|
51
|
+
afterAsync<T extends CommandType = CommandType>(cmd: T, callback: AsyncAfterHook<T>): CommandDisposer;
|
|
52
|
+
has<T extends CommandType = CommandType>(cmd: T): boolean;
|
|
53
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Block, BlockId, CoraxTree } from "../../base/types/tree/tree";
|
|
2
|
+
import { type TreeDiff } from "../../utils/tree.utils";
|
|
3
|
+
import type { EventBusInterface } from "../eventbus/eventbus";
|
|
4
|
+
import type { StateInterface } from "../state/state";
|
|
5
|
+
declare module "../state/state" {
|
|
6
|
+
interface StateMap {
|
|
7
|
+
document: CoraxTree;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
declare module "../eventbus/eventbus" {
|
|
11
|
+
interface TEventMap {
|
|
12
|
+
"document:changed": {
|
|
13
|
+
prev: CoraxTree;
|
|
14
|
+
next: CoraxTree;
|
|
15
|
+
diff: TreeDiff;
|
|
16
|
+
origin: "user" | "history";
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export type DocumentDisposer = () => void;
|
|
21
|
+
export interface DocumentInterface {
|
|
22
|
+
get(): CoraxTree;
|
|
23
|
+
subscribeBlock(id: BlockId, fn: () => void): DocumentDisposer;
|
|
24
|
+
apply(fn: (tree: CoraxTree) => CoraxTree, options?: {
|
|
25
|
+
shouldEmitEvent?: boolean;
|
|
26
|
+
origin?: "user" | "history";
|
|
27
|
+
}): void;
|
|
28
|
+
getBlock(id: BlockId): Block | undefined;
|
|
29
|
+
has(id: BlockId): boolean;
|
|
30
|
+
}
|
|
31
|
+
export declare class DocumentService implements DocumentInterface {
|
|
32
|
+
private state;
|
|
33
|
+
private events;
|
|
34
|
+
private blockListeners;
|
|
35
|
+
constructor(state: StateInterface, events: EventBusInterface);
|
|
36
|
+
subscribeBlock(id: BlockId, fn: () => void): DocumentDisposer;
|
|
37
|
+
private bumpDocumentVersion;
|
|
38
|
+
get(): CoraxTree;
|
|
39
|
+
apply(predicate: (tree: CoraxTree) => CoraxTree, { shouldEmitEvent, origin }?: {
|
|
40
|
+
shouldEmitEvent?: boolean;
|
|
41
|
+
origin?: "user" | "history";
|
|
42
|
+
}): void;
|
|
43
|
+
getBlock(id: BlockId): Block | undefined;
|
|
44
|
+
has(id: BlockId): boolean;
|
|
45
|
+
}
|