@coorax/core 0.0.0-canary.1 → 0.0.0-canary.3

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.
Files changed (46) hide show
  1. package/dist/base/types/field/field.blockquote.types.d.ts +4 -0
  2. package/dist/base/types/field/field.d.ts +14 -3
  3. package/dist/base/types/field/field.image.types.d.ts +3 -0
  4. package/dist/base/types/field/field.video.types.d.ts +8 -0
  5. package/dist/base/types/field/fields.iframe.types.d.ts +7 -0
  6. package/dist/base/types/global.types.d.ts +2 -0
  7. package/dist/base/types/tree/tree.d.ts +2 -1
  8. package/dist/constants/field.constants.d.ts +1 -0
  9. package/dist/constants/index.d.ts +1 -0
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.js +1511 -361
  12. package/dist/modules/caption/caption.module.d.ts +35 -0
  13. package/dist/modules/caption/caption.test.d.ts +1 -0
  14. package/dist/modules/code/code.module.d.ts +37 -0
  15. package/dist/modules/deletion/deletion.module.d.ts +26 -0
  16. package/dist/modules/divider/divider.module.d.ts +58 -0
  17. package/dist/modules/focus/focus.module.d.ts +1 -1
  18. package/dist/modules/history/history.module.d.ts +14 -0
  19. package/dist/modules/hover/hover.module.d.ts +1 -1
  20. package/dist/modules/index.d.ts +6 -1
  21. package/dist/modules/insertion/insertion.module.d.ts +20 -1
  22. package/dist/modules/media/media.module.d.ts +52 -0
  23. package/dist/modules/modules-manager.d.ts +2 -0
  24. package/dist/modules/paragraph-theme/paragraph-theme.module.d.ts +49 -0
  25. package/dist/modules/selection/selection.module.d.ts +1 -1
  26. package/dist/modules/text-editing/text-editing.constants.d.ts +1 -1
  27. package/dist/modules/text-editing/text-editing.module.d.ts +1 -2
  28. package/dist/modules/text-editing/text-editing.utils.d.ts +1 -1
  29. package/dist/services/document/document.d.ts +1 -2
  30. package/dist/services/eventbus/eventbus.d.ts +4 -4
  31. package/dist/services/eventbus/eventbus.test.d.ts +1 -1
  32. package/dist/services/eventbus/subscriber.d.ts +4 -4
  33. package/dist/services/mutations/mutations.d.ts +10 -5
  34. package/dist/services/tasks/tasks.service.d.ts +1 -1
  35. package/dist/services/text-marks/index.d.ts +0 -1
  36. package/dist/services/text-marks/text-marks.d.ts +1 -1
  37. package/dist/services/ui/contributions.types.d.ts +79 -0
  38. package/dist/services/ui/default-styles.d.ts +1 -1
  39. package/dist/services/ui/index.d.ts +0 -1
  40. package/dist/services/ui/ui.d.ts +7 -6
  41. package/dist/services/ui/ui.types.d.ts +7 -95
  42. package/dist/styles.css +1 -536
  43. package/dist/utils/fields.utils.d.ts +10 -2
  44. package/dist/utils/index.d.ts +0 -6
  45. package/package.json +12 -8
  46. package/styles.css +4 -2
@@ -0,0 +1,35 @@
1
+ import { type FieldId } from "@coorax/schema";
2
+ import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
+ import type { TModule } from "../modules.types";
4
+ declare module "../modules-manager" {
5
+ interface ModuleMap {
6
+ caption: {};
7
+ }
8
+ }
9
+ declare module "../../services/commandsbus/commandsbus" {
10
+ interface CommandMap {
11
+ "caption.add": {
12
+ payload: {
13
+ mediaId: FieldId;
14
+ };
15
+ result: void;
16
+ };
17
+ }
18
+ }
19
+ declare module "../../services/eventbus/eventbus" {
20
+ interface TEventMap {
21
+ "caption:add": CommandMap["caption.add"]["payload"];
22
+ }
23
+ }
24
+ declare module "../../services/ui/ui" {
25
+ interface ButtonContributionIdentityMap {
26
+ "insert-caption": {};
27
+ }
28
+ interface IconMap {
29
+ CaptionsIcon: {};
30
+ }
31
+ interface SlotButtonPropsMap {
32
+ CaptionButton: {};
33
+ }
34
+ }
35
+ export declare const CaptionModule: TModule;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { type FieldId } from "@coorax/schema";
2
+ import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
+ import type { TModule } from "../modules.types";
4
+ declare module "../modules-manager" {
5
+ interface ModuleMap {
6
+ code: {};
7
+ }
8
+ }
9
+ declare module "../../services/commandsbus/commandsbus" {
10
+ interface CommandMap {
11
+ "code.toggleTheme": {
12
+ payload: {
13
+ fieldId: FieldId;
14
+ };
15
+ result: void;
16
+ };
17
+ }
18
+ }
19
+ declare module "../../services/eventbus/eventbus" {
20
+ interface TEventMap {
21
+ "code:toggleTheme": CommandMap["code.toggleTheme"]["payload"];
22
+ }
23
+ }
24
+ declare module "../../services/ui/ui" {
25
+ interface ButtonContributionIdentityMap {
26
+ "format-code-theme": {};
27
+ }
28
+ interface IconMap {
29
+ PaletteIcon: {};
30
+ }
31
+ interface SlotButtonPropsMap {
32
+ CodeThemeButton: {
33
+ isActive: boolean;
34
+ };
35
+ }
36
+ }
37
+ export declare const CodeModule: TModule;
@@ -0,0 +1,26 @@
1
+ import type { TModule } from "../modules.types";
2
+ declare module "../modules-manager" {
3
+ interface ModuleMap {
4
+ deletion: {};
5
+ }
6
+ }
7
+ declare module "../../services/commandsbus/commandsbus" {
8
+ interface CommandMap {
9
+ "blocks.deleteSelection": {
10
+ payload: void;
11
+ result: void;
12
+ };
13
+ }
14
+ }
15
+ declare module "../../services/ui/ui" {
16
+ interface ButtonContributionIdentityMap {
17
+ "delete-blocks": {};
18
+ }
19
+ interface IconMap {
20
+ TrashIcon: {};
21
+ }
22
+ interface SlotButtonPropsMap {
23
+ DeleteButton: {};
24
+ }
25
+ }
26
+ export declare const DeletionModule: TModule;
@@ -0,0 +1,58 @@
1
+ import type { FieldId } from "@coorax/schema";
2
+ import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
+ import type { TModule } from "../modules.types";
4
+ /** Styles de trait proposés dans la toolbar pour le séparateur. */
5
+ declare const DIVIDER_STYLES: readonly ["solid", "dashed", "dotted"];
6
+ export type DividerStyle = (typeof DIVIDER_STYLES)[number];
7
+ declare module "../modules-manager" {
8
+ interface ModuleMap {
9
+ divider: {};
10
+ }
11
+ }
12
+ declare module "../../services/commandsbus/commandsbus" {
13
+ interface CommandMap {
14
+ "divider.setWidth": {
15
+ payload: {
16
+ fieldId: FieldId;
17
+ width: string;
18
+ };
19
+ result: void;
20
+ };
21
+ "divider.setStyle": {
22
+ payload: {
23
+ fieldId: FieldId;
24
+ style: DividerStyle;
25
+ };
26
+ result: void;
27
+ };
28
+ }
29
+ }
30
+ declare module "../../services/eventbus/eventbus" {
31
+ interface TEventMap {
32
+ "divider:setWidth": CommandMap["divider.setWidth"]["payload"];
33
+ "divider:setStyle": CommandMap["divider.setStyle"]["payload"];
34
+ }
35
+ }
36
+ declare module "../../services/ui/ui" {
37
+ interface ButtonContributionIdentityMap {
38
+ "divider-width-sm": {};
39
+ "divider-width-lg": {};
40
+ "divider-style-solid": {};
41
+ "divider-style-dashed": {};
42
+ "divider-style-dotted": {};
43
+ }
44
+ interface IconMap {
45
+ LineStyleIcon: {};
46
+ }
47
+ interface SlotButtonPropsMap {
48
+ DividerWidthButton: {
49
+ isActive: boolean;
50
+ };
51
+ DividerStyleButton: {
52
+ isActive: boolean;
53
+ borderStyle: DividerStyle;
54
+ };
55
+ }
56
+ }
57
+ export declare const DividerModule: TModule;
58
+ export {};
@@ -1,4 +1,4 @@
1
- import type { BlockId } from "../../base";
1
+ import { type BlockId } from "@coorax/schema";
2
2
  import type { CommandMap } from "../../services/commandsbus";
3
3
  import type { StateMap } from "../../services/state";
4
4
  import type { BlockRect, TModule } from "../modules.types";
@@ -10,6 +10,10 @@ declare module "../../services/state/state" {
10
10
  canUndo: boolean;
11
11
  canRedo: boolean;
12
12
  };
13
+ "history:stack": {
14
+ size: number;
15
+ cursor: number;
16
+ };
13
17
  }
14
18
  }
15
19
  declare module "../../services/commandsbus/commandsbus" {
@@ -22,6 +26,16 @@ declare module "../../services/commandsbus/commandsbus" {
22
26
  payload: {};
23
27
  result: void;
24
28
  };
29
+ "history.cleanup": {
30
+ payload: {};
31
+ result: void;
32
+ };
33
+ "history.move": {
34
+ payload: {
35
+ cursor: number;
36
+ };
37
+ result: void;
38
+ };
25
39
  }
26
40
  }
27
41
  export declare const HistoryModule: TModule;
@@ -1,4 +1,4 @@
1
- import type { BlockId } from "../../base";
1
+ import type { BlockId } from "@coorax/schema";
2
2
  import type { StateMap } from "../../services/state";
3
3
  import type { BlockRect, TModule } from "../modules.types";
4
4
  declare module "../modules-manager" {
@@ -6,5 +6,10 @@ export * from "./modules-manager";
6
6
  export * from "./hover/hover.module";
7
7
  export * from "./history/history.module";
8
8
  export * from "./text-editing/text-editing.module";
9
- export * from "./text-editing/text-editing.utils";
10
9
  export * from "./editor/editor.module";
10
+ export * from "./code/code.module";
11
+ export * from "./caption/caption.module";
12
+ export * from "./media/media.module";
13
+ export * from "./divider/divider.module";
14
+ export * from "./paragraph-theme/paragraph-theme.module";
15
+ export * from "./deletion/deletion.module";
@@ -1,4 +1,4 @@
1
- import type { Block, BlockId } from "../../base/types/tree/tree";
1
+ import { type Block, type BlockId, type FieldId, type FieldType } from "@coorax/schema";
2
2
  import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
3
  import type { TModule } from "../modules.types";
4
4
  declare module "../../services/commandsbus/commandsbus" {
@@ -10,6 +10,13 @@ declare module "../../services/commandsbus/commandsbus" {
10
10
  };
11
11
  result: void;
12
12
  };
13
+ "fields.change": {
14
+ payload: {
15
+ fieldId: FieldId;
16
+ type: FieldType;
17
+ };
18
+ result: void;
19
+ };
13
20
  "blocks.delete": {
14
21
  payload: {
15
22
  blockId: BlockId;
@@ -25,6 +32,7 @@ declare module "../../services/commandsbus/commandsbus" {
25
32
  declare module "../../services/eventbus/eventbus" {
26
33
  interface TEventMap {
27
34
  "blocks:insert": CommandMap["blocks.insert"]["payload"];
35
+ "fields:change": CommandMap["fields.change"]["payload"];
28
36
  "blocks:delete": CommandMap["blocks.delete"]["payload"];
29
37
  "actions:toggle": CommandMap["actions.toggle"]["payload"];
30
38
  }
@@ -43,12 +51,23 @@ declare module "../../services/ui/ui" {
43
51
  interface ButtonContributionIdentityMap {
44
52
  "insert-field": {};
45
53
  "insert-heading": {};
54
+ "insert-sub-heading": {};
46
55
  "insert-text": {};
47
56
  "insert-image": {};
57
+ "insert-video": {};
48
58
  "insert-divider": {};
59
+ "insert-iframe": {};
60
+ "insert-doc": {};
61
+ "insert-blockquote": {};
62
+ "insert-code": {};
49
63
  }
50
64
  interface IconMap {
51
65
  DividerIcon: {};
66
+ YoutubeIcon: {};
67
+ FileTextIcon: {};
68
+ QuoteIcon: {};
69
+ CodeIcon: {};
70
+ Heading2Icon: {};
52
71
  }
53
72
  }
54
73
  export declare const InsertionModule: TModule;
@@ -0,0 +1,52 @@
1
+ import { type FieldId } from "@coorax/schema";
2
+ import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
+ import type { TModule } from "../modules.types";
4
+ declare module "../modules-manager" {
5
+ interface ModuleMap {
6
+ media: {};
7
+ }
8
+ }
9
+ declare module "../../services/commandsbus/commandsbus" {
10
+ interface CommandMap {
11
+ "iframe.playback": {
12
+ payload: {
13
+ fieldId: FieldId;
14
+ action: "play" | "pause";
15
+ };
16
+ result: void;
17
+ };
18
+ "image.setWidth": {
19
+ payload: {
20
+ fieldId: FieldId;
21
+ width: string;
22
+ };
23
+ result: void;
24
+ };
25
+ }
26
+ }
27
+ declare module "../../services/eventbus/eventbus" {
28
+ interface TEventMap {
29
+ "iframe:playback": CommandMap["iframe.playback"]["payload"];
30
+ "image:setWidth": CommandMap["image.setWidth"]["payload"];
31
+ }
32
+ }
33
+ declare module "../../services/ui/ui" {
34
+ interface ButtonContributionIdentityMap {
35
+ "iframe-playback": {};
36
+ "image-width-sm": {};
37
+ "image-width-lg": {};
38
+ }
39
+ interface IconMap {
40
+ PlayIcon: {};
41
+ PauseIcon: {};
42
+ MoveHorizontalIcon: {};
43
+ ExpandIcon: {};
44
+ }
45
+ interface SlotButtonPropsMap {
46
+ IframePlaybackButton: {};
47
+ ImageWidthButton: {
48
+ isActive: boolean;
49
+ };
50
+ }
51
+ }
52
+ export declare const MediaModule: TModule;
@@ -6,6 +6,7 @@ export type ModuleName = keyof ModuleMap;
6
6
  export interface ModuleManagerInterface {
7
7
  register(modules: TModule[]): void;
8
8
  isEnabled(name: ModuleName): boolean;
9
+ isRegistered(name: ModuleName): boolean;
9
10
  enable(name: ModuleName): void;
10
11
  enableAll(): void;
11
12
  disable(name: ModuleName, opts?: {
@@ -21,6 +22,7 @@ export declare class ModuleManager implements ModuleManagerInterface {
21
22
  constructor(engine: Engine);
22
23
  register(modules: TModule[]): void;
23
24
  isEnabled(name: ModuleName): boolean;
25
+ isRegistered(name: ModuleName): boolean;
24
26
  enable(name: ModuleName): void;
25
27
  enableAll(): void;
26
28
  disabledAll(): void;
@@ -0,0 +1,49 @@
1
+ import type { FieldId, MarkTheme, NodeCommonProps, TextContent } from "@coorax/schema";
2
+ import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
+ import type { TModule } from "../modules.types";
4
+ /** Style du `<span>` couvrant tout le texte du paragraphe, par thème. */
5
+ export declare const PARAGRAPH_THEME_STYLES: Record<MarkTheme, NodeCommonProps["style"]>;
6
+ /** Thème appliqué sur tout le texte du paragraphe, ou null s'il n'y en a pas. */
7
+ export declare const getParagraphTheme: (content: TextContent) => MarkTheme | null;
8
+ declare module "../modules-manager" {
9
+ interface ModuleMap {
10
+ "paragraph-theme": {};
11
+ }
12
+ }
13
+ declare module "../../services/commandsbus/commandsbus" {
14
+ interface CommandMap {
15
+ "paragraph.setTheme": {
16
+ payload: {
17
+ fieldId: FieldId;
18
+ theme: MarkTheme;
19
+ };
20
+ result: void;
21
+ };
22
+ }
23
+ }
24
+ declare module "../../services/eventbus/eventbus" {
25
+ interface TEventMap {
26
+ "paragraph:setTheme": CommandMap["paragraph.setTheme"]["payload"];
27
+ }
28
+ }
29
+ declare module "../../services/ui/ui" {
30
+ interface ButtonContributionIdentityMap {
31
+ "paragraph-theme-neutral": {};
32
+ "paragraph-theme-warning": {};
33
+ "paragraph-theme-error": {};
34
+ "paragraph-theme-info": {};
35
+ }
36
+ interface IconMap {
37
+ ThemeNeutralIcon: {};
38
+ ThemeWarningIcon: {};
39
+ ThemeErrorIcon: {};
40
+ ThemeInfoIcon: {};
41
+ }
42
+ interface SlotButtonPropsMap {
43
+ ParagraphThemeButton: {
44
+ isActive: boolean;
45
+ theme: MarkTheme;
46
+ };
47
+ }
48
+ }
49
+ export declare const ParagraphThemeModule: TModule;
@@ -1,4 +1,4 @@
1
- import type { BlockId } from "../../base/types/tree/tree";
1
+ import type { BlockId } from "@coorax/schema";
2
2
  import type { CommandMap } from "../../services/commandsbus/commandsbus";
3
3
  import type { StateMap } from "../../services/state";
4
4
  import type { BlockRect, TModule } from "../modules.types";
@@ -1,2 +1,2 @@
1
- import type { MarkAttrs, MarkType } from "../../services/text-marks";
1
+ import type { MarkAttrs, MarkType } from "@coorax/schema";
2
2
  export declare const MARK_DEFAULT_ATTRS: Partial<Record<MarkType, MarkAttrs>>;
@@ -1,6 +1,5 @@
1
- import type { FieldId } from "../../base";
1
+ import { type FieldId, type FieldTextContentPath, type Mark, type MarkAttrs, type MarkSpec, type MarkType } from "@coorax/schema";
2
2
  import type { CommandMap } from "../../services/commandsbus";
3
- import type { FieldTextContentPath, Mark, MarkAttrs, MarkSpec, MarkType } from "../../services/text-marks/marks.types";
4
3
  import type { TModule } from "../modules.types";
5
4
  export type TextSelection = {
6
5
  blockId: FieldId;
@@ -1,4 +1,4 @@
1
- import type { Mark, TextContent } from "../../services/text-marks";
1
+ import type { Mark, TextContent } from "@coorax/schema";
2
2
  export interface Segment {
3
3
  text: string;
4
4
  marks: readonly Mark[];
@@ -1,5 +1,4 @@
1
- import type { Block, BlockId, CoraxTree } from "../../base/types/tree/tree";
2
- import { type TreeDiff } from "../../utils/tree.utils";
1
+ import { type Block, type BlockId, type CoraxTree, type TreeDiff } from "@coorax/schema";
3
2
  import type { EventBusInterface } from "../eventbus/eventbus";
4
3
  import type { StateInterface } from "../state/state";
5
4
  declare module "../state/state" {
@@ -1,4 +1,4 @@
1
- import type { FieldId } from "../../base";
1
+ import { type FieldId } from "@coorax/schema";
2
2
  import { type SubscriberProps } from "./subscriber";
3
3
  export type CustomProps<T extends any = any> = T extends object ? Omit<T, "event"> : T;
4
4
  export interface TEventMap {
@@ -14,10 +14,10 @@ export interface TEventMap {
14
14
  }
15
15
  export type TEvent = keyof TEventMap;
16
16
  export type EventPropsValue<E extends TEvent = TEvent> = TEventMap[E];
17
- type EventCallback<E extends TEvent = TEvent, T extends CustomProps = CustomProps> = (scb: SubscriberProps<E, T>) => void | Promise<void>;
17
+ type EventCallback<E extends TEvent = TEvent, T extends CustomProps = {}> = (scb: SubscriberProps<E, NoInfer<T>>) => void | Promise<void>;
18
18
  type EventDisposer = () => void;
19
19
  export interface EventBusInterface {
20
- on<E extends TEvent = TEvent, T extends CustomProps = CustomProps>(ev: E, handler: EventCallback<E, T>): EventDisposer;
20
+ on<E extends TEvent = TEvent, T extends CustomProps = {}>(ev: E, handler: EventCallback<E, T>): EventDisposer;
21
21
  emit<E extends TEvent = TEvent, T extends EventPropsValue<E> = EventPropsValue<E>>(ev: E, props: T, toAwaited?: boolean): Promise<void>;
22
22
  batch(evs: ReadonlyArray<readonly [TEvent, any]>): Promise<void>[];
23
23
  }
@@ -25,7 +25,7 @@ export declare class EventBusService implements EventBusInterface {
25
25
  private handlers;
26
26
  isRerenderEventActive: boolean;
27
27
  private cleanUpCallback;
28
- on<E extends TEvent = TEvent, T extends CustomProps = CustomProps>(ev: E, callback: EventCallback<E, T>): EventDisposer;
28
+ on<E extends TEvent = TEvent, T extends CustomProps = {}>(ev: E, callback: EventCallback<E, T>): EventDisposer;
29
29
  /**
30
30
  * If passed, props will overwrite all custom properties
31
31
  * on each event handler
@@ -1,4 +1,4 @@
1
- import type { Field } from "../../base/types/field/field";
1
+ import type { Field } from "@coorax/schema";
2
2
  declare module "./eventbus" {
3
3
  interface TEventMap {
4
4
  "field:test": {
@@ -1,14 +1,14 @@
1
1
  import type { TEvent, CustomProps, EventPropsValue } from "./eventbus";
2
2
  export interface SCB<E extends TEvent = TEvent> extends EventProps<E> {
3
3
  readonly target: string;
4
- readonly event: Omit<TEvent, "changes">;
4
+ readonly event: Omit<E, "changes">;
5
5
  }
6
6
  export type EventProps<E extends TEvent = TEvent> = {
7
7
  value: EventPropsValue<E>;
8
8
  };
9
- export type SubscriberProps<E extends TEvent = TEvent, T extends CustomProps = CustomProps> = SCB & {
10
- value: Partial<T>;
11
- } & EventProps<E>;
9
+ export type SubscriberProps<E extends TEvent = TEvent, T extends CustomProps = {}> = SCB<E> & {
10
+ value: EventPropsValue<E> & Partial<T>;
11
+ };
12
12
  export declare class Subscriber<E extends TEvent = TEvent> implements SCB<E> {
13
13
  readonly target: string;
14
14
  readonly event: E;
@@ -1,7 +1,4 @@
1
- import type { Container } from "../../base/types/container/container";
2
- import type { Field, FieldId } from "../../base/types/field/field";
3
- import type { OmitContainersMethods, OmitFieldsMethods } from "../../base/types/global.types";
4
- import type { CoraxTree } from "../../base/types/tree/tree";
1
+ import { type Container, type CoraxTree, type Field, type FieldId, type FieldType, type OmitContainersMethods, type OmitFieldsMethods } from "@coorax/schema";
5
2
  type MaxDepth = [1, 2, 3];
6
3
  type DataKeys<T> = {
7
4
  [K in keyof T]: T[K] extends (...args: any[]) => any ? never : K;
@@ -12,7 +9,7 @@ type DeepKey<T, Depth extends any[] = MaxDepth> = Depth["length"] extends 0 ? ne
12
9
  }[DataKeys<T>];
13
10
  type Tail<T extends any[]> = ((...args: T) => any) extends (_: any, ...tail: infer TT) => any ? TT : [];
14
11
  type DeepValue<T, K extends string> = K extends keyof T ? T[K] : K extends `${infer First}.${infer Rest}` ? First extends keyof T ? DeepValue<T[First], Rest> : any : any;
15
- type MutationOptions<T extends object, K extends DeepKey<T> = DeepKey<T>> = {
12
+ export type MutationOptions<T extends object, K extends DeepKey<T> = DeepKey<T>> = {
16
13
  id: "id" extends keyof T ? T["id"] : never;
17
14
  keyValuePairs: Omit<{
18
15
  [Key in K]?: DeepValue<T, Key>;
@@ -22,12 +19,20 @@ type MutationOptions<T extends object, K extends DeepKey<T> = DeepKey<T>> = {
22
19
  export interface MutationsInterface {
23
20
  insertField(tree: CoraxTree, field: Field, index?: number): CoraxTree;
24
21
  deleteField(tree: CoraxTree, fieldId: FieldId): CoraxTree;
22
+ changeField(tree: CoraxTree, options: {
23
+ fieldId: FieldId;
24
+ type: FieldType;
25
+ }): CoraxTree;
25
26
  mutateField<T extends Field = Field>(tree: CoraxTree, options: MutationOptions<OmitFieldsMethods<T>>): CoraxTree;
26
27
  mutateContainer(tree: CoraxTree, options: MutationOptions<OmitContainersMethods<Container>>): CoraxTree;
27
28
  }
28
29
  export declare class MutationsService implements MutationsInterface {
29
30
  insertField(tree: CoraxTree, _field: Field, index?: number): CoraxTree;
30
31
  deleteField(tree: CoraxTree, fieldId: FieldId): CoraxTree;
32
+ changeField(tree: CoraxTree, { fieldId, type }: {
33
+ fieldId: FieldId;
34
+ type: FieldType;
35
+ }): CoraxTree;
31
36
  mutateField<T extends Field = Field>(tree: CoraxTree, { id, keyValuePairs, autoMerge }: MutationOptions<OmitFieldsMethods<T>>): CoraxTree;
32
37
  private canMerge;
33
38
  private mergeValues;
@@ -1,4 +1,4 @@
1
- import { type CustomID } from "../../utils";
1
+ import { type CustomID } from "@coorax/schema";
2
2
  /**
3
3
  * Extensible interface mapping task names.
4
4
  * Modules or files can extend this interface via declaration merging:
@@ -1,2 +1 @@
1
- export * from "./marks.types";
2
1
  export * from "./text-marks";
@@ -1,4 +1,4 @@
1
- import type { MarkBehavior, MarkSpec, MarkType, TextContent } from "./marks.types";
1
+ import type { MarkBehavior, MarkSpec, MarkType, TextContent } from "@coorax/schema";
2
2
  export type TextMarksDisposer = () => void;
3
3
  export interface TextMarksInterface {
4
4
  replaceRange(content: TextContent, start: number, end: number, text: string, opts?: {
@@ -0,0 +1,79 @@
1
+ import type { BlockId } from "@coorax/schema";
2
+ import type { CommandPayload, CommandType } from "../commandsbus";
3
+ import type { UIContext } from "./ui.types";
4
+ export interface IconMap {
5
+ TextIcon: {};
6
+ CursorIcon: {};
7
+ HeadingIcon: {};
8
+ CameraIcon: {};
9
+ ImagePlus: {};
10
+ TvMinimalPlayIcon: {};
11
+ BracesIcon: {};
12
+ MinusIcon: {};
13
+ PlusIcon: {};
14
+ BoldIcon: {};
15
+ }
16
+ export type SlotIcon = keyof IconMap;
17
+ export interface SlotMap {
18
+ toolbar: {};
19
+ "block-actions": {};
20
+ sidebar: {};
21
+ inspector: {};
22
+ overlay: {};
23
+ }
24
+ export type SlotName = keyof SlotMap;
25
+ export interface SlotButtonPropsMap {
26
+ BlockActionButton: {
27
+ variant: "default" | "outline" | "secondary";
28
+ size: "icon" | "default" | "icon-lg" | "icon-sm";
29
+ isBaseButton?: boolean;
30
+ };
31
+ }
32
+ export type SlotButtonKey = keyof SlotButtonPropsMap;
33
+ export interface SlotComponentMap {
34
+ TextInspector: {
35
+ blockId: BlockId;
36
+ };
37
+ }
38
+ export type SlotComponentKey = keyof SlotComponentMap;
39
+ export type SlotKey = SlotButtonKey | SlotComponentKey;
40
+ export type SlotBaseProps<C extends Contribution = Contribution> = {
41
+ c: C;
42
+ ui: UIContext;
43
+ };
44
+ export interface ButtonIdMap {
45
+ }
46
+ export type ButtonId = keyof ButtonIdMap extends never ? string : keyof ButtonIdMap;
47
+ interface BaseContribution<S extends SlotName> {
48
+ id: string;
49
+ slot: S;
50
+ order?: number;
51
+ when?: (ui: UIContext) => boolean;
52
+ }
53
+ export type ButtonContribution<S extends SlotName = SlotName, C extends CommandType = CommandType, K extends SlotButtonKey = SlotButtonKey> = BaseContribution<S> & {
54
+ kind: "button";
55
+ name: K;
56
+ command: C;
57
+ icon: SlotIcon;
58
+ label?: string;
59
+ getPayload: (ui: UIContext) => CommandPayload<C>;
60
+ getProps: (ui: UIContext) => SlotButtonPropsMap[K] | null;
61
+ };
62
+ export type ComponentContribution<S extends SlotName = SlotName, K extends SlotComponentKey = SlotComponentKey> = BaseContribution<S> & {
63
+ kind: "component";
64
+ name: K;
65
+ getProps: (ui: UIContext) => SlotComponentMap[K] | null;
66
+ };
67
+ export interface ContributionKindMap {
68
+ button: {
69
+ [K in SlotButtonKey]: ButtonContribution<SlotName, any, K>;
70
+ }[SlotButtonKey];
71
+ component: {
72
+ [K in SlotComponentKey]: ComponentContribution<SlotName, K>;
73
+ }[SlotComponentKey];
74
+ }
75
+ export type ContributionKind = keyof ContributionKindMap;
76
+ export type Contribution<K extends ContributionKind = ContributionKind> = ContributionKindMap[K];
77
+ export declare const defineButton: <S extends SlotName, C extends CommandType, K extends SlotButtonKey>(c: ButtonContribution<S, C, K>) => ButtonContribution<S, C, K>;
78
+ export declare const defineComponent: <S extends SlotName, K extends SlotComponentKey>(c: ComponentContribution<S, K>) => ComponentContribution<S, K>;
79
+ export {};
@@ -1,3 +1,3 @@
1
1
  import type { NodeCommonProps } from "../../base/types/global.types";
2
2
  import type { StyleName } from "./ui.types";
3
- export declare const STYLES: Partial<Record<StyleName, NodeCommonProps>>;
3
+ export declare const DEFAULT_STYLES: Partial<Record<StyleName, NodeCommonProps>>;
@@ -1,3 +1,2 @@
1
- export * from "./default-styles";
2
1
  export * from "./ui.errors";
3
2
  export * from "./ui";